@grackle-ai/web 0.89.0 → 0.89.1

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.
@@ -1,4 +1,4 @@
1
- const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/KnowledgePage-UHkf3T0n.js","assets/dagview-CzJGOIoX.js","assets/grpc-CRztlRZY.js","assets/markdown-DH3wQq0i.js","assets/KnowledgePage-DMqJ4jlP.css"])))=>i.map(i=>d[i]);
1
+ const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/KnowledgePage-CLcFJZi2.js","assets/dagview-CzJGOIoX.js","assets/grpc-CRztlRZY.js","assets/markdown-DH3wQq0i.js","assets/KnowledgePage-DMqJ4jlP.css"])))=>i.map(i=>d[i]);
2
2
  import{r as cT,a as uT,b as y,j as l,d as d0,H as f0,P as p0,i as dT,B as fT,c as pT,C as mT,M as hT}from"./dagview-CzJGOIoX.js";import{c as gT,a as vT,G as yT,f as bT,M as _T,A as _b,D as xb,W as xT,O as ST,b as TT,C as zc,d as kT,e as Sb,w as wT,t as NT,p as ac,g as jT,R as or,S as m0}from"./grpc-CRztlRZY.js";import{v as CT,r as ET,t as ic,i as AT,f as DT,M as Pc,a as Vc}from"./markdown-DH3wQq0i.js";(function(){const s=document.createElement("link").relList;if(s&&s.supports&&s.supports("modulepreload"))return;for(const c of document.querySelectorAll('link[rel="modulepreload"]'))o(c);new MutationObserver(c=>{for(const u of c)if(u.type==="childList")for(const d of u.addedNodes)d.tagName==="LINK"&&d.rel==="modulepreload"&&o(d)}).observe(document,{childList:!0,subtree:!0});function i(c){const u={};return c.integrity&&(u.integrity=c.integrity),c.referrerPolicy&&(u.referrerPolicy=c.referrerPolicy),c.crossOrigin==="use-credentials"?u.credentials="include":c.crossOrigin==="anonymous"?u.credentials="omit":u.credentials="same-origin",u}function o(c){if(c.ep)return;c.ep=!0;const u=i(c);fetch(c.href,u)}})();var uf={exports:{}},rr={},df={exports:{}},ff={};/**
3
3
  * @license React
4
4
  * scheduler.production.js
@@ -59,7 +59,7 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
59
59
  top: ${h}px !important;
60
60
  left: ${g}px !important;
61
61
  }
62
- `),()=>{document.head.removeChild(v)}},[s]),l.jsx(Kj,{isPresent:s,childRef:o,sizeRef:c,children:y.cloneElement(t,{ref:o})})}const Jj=({children:t,initial:s,isPresent:i,onExitComplete:o,custom:c,presenceAffectsLayout:u,mode:d})=>{const m=Ip(Wj),h=y.useId(),g=y.useCallback(_=>{m.set(_,!0);for(const b of m.values())if(!b)return;o&&o()},[m,o]),v=y.useMemo(()=>({id:h,initial:s,isPresent:i,custom:c,onExitComplete:g,register:_=>(m.set(_,!1),()=>m.delete(_))}),u?[Math.random(),g]:[i,g]);return y.useMemo(()=>{m.forEach((_,b)=>m.set(b,!1))},[i]),y.useEffect(()=>{!i&&!m.size&&o&&o()},[i]),d==="popLayout"&&(t=l.jsx(Yj,{isPresent:i,children:t})),l.jsx(Zc.Provider,{value:v,children:t})};function Wj(){return new Map}function Zb(t=!0){const s=y.useContext(Zc);if(s===null)return[!0,null];const{isPresent:i,onExitComplete:o,register:c}=s,u=y.useId();y.useEffect(()=>{t&&c(u)},[t]);const d=y.useCallback(()=>t&&o&&o(u),[u,o,t]);return!i&&o?[!1,d]:[!0]}const lc=t=>t.key||"";function I0(t){const s=[];return y.Children.forEach(t,i=>{y.isValidElement(i)&&s.push(i)}),s}const Bp=typeof window<"u",Kb=Bp?y.useLayoutEffect:y.useEffect,ds=({children:t,custom:s,initial:i=!0,onExitComplete:o,presenceAffectsLayout:c=!0,mode:u="sync",propagate:d=!1})=>{const[m,h]=Zb(d),g=y.useMemo(()=>I0(t),[t]),v=d&&!m?[]:g.map(lc),_=y.useRef(!0),b=y.useRef(g),S=Ip(()=>new Map),[T,N]=y.useState(g),[j,w]=y.useState(g);Kb(()=>{_.current=!1,b.current=g;for(let M=0;M<j.length;M++){const D=lc(j[M]);v.includes(D)?S.delete(D):S.get(D)!==!0&&S.set(D,!1)}},[j,v.length,v.join("-")]);const C=[];if(g!==T){let M=[...g];for(let D=0;D<j.length;D++){const E=j[D],$=lc(E);v.includes($)||(M.splice(D,0,E),C.push(E))}u==="wait"&&C.length&&(M=C),w(I0(M)),N(g);return}const{forceRender:A}=y.useContext(Mp);return l.jsx(l.Fragment,{children:j.map(M=>{const D=lc(M),E=d&&!m?!1:g===j||v.includes(D),$=()=>{if(S.has(D))S.set(D,!0);else return;let z=!0;S.forEach(K=>{K||(z=!1)}),z&&(A==null||A(),w(b.current),d&&(h==null||h()),o&&o())};return l.jsx(Jj,{isPresent:E,initial:!_.current||i?void 0:!1,custom:E?void 0:s,presenceAffectsLayout:c,mode:u,onExitComplete:E?void 0:$,children:M},D)})})},xn=t=>t;let Yb=xn;const Xj={useManualTiming:!1};function Qj(t){let s=new Set,i=new Set,o=!1,c=!1;const u=new WeakSet;let d={delta:0,timestamp:0,isProcessing:!1};function m(g){u.has(g)&&(h.schedule(g),t()),g(d)}const h={schedule:(g,v=!1,_=!1)=>{const S=_&&o?s:i;return v&&u.add(g),S.has(g)||S.add(g),g},cancel:g=>{i.delete(g),u.delete(g)},process:g=>{if(d=g,o){c=!0;return}o=!0,[s,i]=[i,s],s.forEach(m),s.clear(),o=!1,c&&(c=!1,h.process(g))}};return h}const cc=["read","resolveKeyframes","update","preRender","render","postRender"],eC=40;function Jb(t,s){let i=!1,o=!0;const c={delta:0,timestamp:0,isProcessing:!1},u=()=>i=!0,d=cc.reduce((w,C)=>(w[C]=Qj(u),w),{}),{read:m,resolveKeyframes:h,update:g,preRender:v,render:_,postRender:b}=d,S=()=>{const w=performance.now();i=!1,c.delta=o?1e3/60:Math.max(Math.min(w-c.timestamp,eC),1),c.timestamp=w,c.isProcessing=!0,m.process(c),h.process(c),g.process(c),v.process(c),_.process(c),b.process(c),c.isProcessing=!1,i&&s&&(o=!1,t(S))},T=()=>{i=!0,o=!0,c.isProcessing||t(S)};return{schedule:cc.reduce((w,C)=>{const A=d[C];return w[C]=(M,D=!1,E=!1)=>(i||T(),A.schedule(M,D,E)),w},{}),cancel:w=>{for(let C=0;C<cc.length;C++)d[cc[C]].cancel(w)},state:c,steps:d}}const{schedule:gt,cancel:Ta,state:Zt,steps:wf}=Jb(typeof requestAnimationFrame<"u"?requestAnimationFrame:xn,!0),Wb=y.createContext({strict:!1}),O0={animation:["animate","variants","whileHover","whileTap","exit","whileInView","whileFocus","whileDrag"],exit:["exit"],drag:["drag","dragControls"],focus:["whileFocus"],hover:["whileHover","onHoverStart","onHoverEnd"],tap:["whileTap","onTap","onTapStart","onTapCancel"],pan:["onPan","onPanStart","onPanSessionStart","onPanEnd"],inView:["whileInView","onViewportEnter","onViewportLeave"],layout:["layout","layoutId"]},oo={};for(const t in O0)oo[t]={isEnabled:s=>O0[t].some(i=>!!s[i])};function tC(t){for(const s in t)oo[s]={...oo[s],...t[s]}}const nC=new Set(["animate","exit","variants","initial","style","values","variants","transition","transformTemplate","custom","inherit","onBeforeLayoutMeasure","onAnimationStart","onAnimationComplete","onUpdate","onDragStart","onDrag","onDragEnd","onMeasureDragConstraints","onDirectionLock","onDragTransitionEnd","_dragX","_dragY","onHoverStart","onHoverEnd","onViewportEnter","onViewportLeave","globalTapTarget","ignoreStrict","viewport"]);function Cc(t){return t.startsWith("while")||t.startsWith("drag")&&t!=="draggable"||t.startsWith("layout")||t.startsWith("onTap")||t.startsWith("onPan")||t.startsWith("onLayout")||nC.has(t)}let Xb=t=>!Cc(t);function sC(t){t&&(Xb=s=>s.startsWith("on")?!Cc(s):t(s))}try{sC(require("@emotion/is-prop-valid").default)}catch{}function aC(t,s,i){const o={};for(const c in t)c==="values"&&typeof t.values=="object"||(Xb(c)||i===!0&&Cc(c)||!s&&!Cc(c)||t.draggable&&c.startsWith("onDrag"))&&(o[c]=t[c]);return o}function iC(t){if(typeof Proxy>"u")return t;const s=new Map,i=(...o)=>t(...o);return new Proxy(i,{get:(o,c)=>c==="create"?t:(s.has(c)||s.set(c,t(c)),s.get(c))})}const Kc=y.createContext({});function jr(t){return typeof t=="string"||Array.isArray(t)}function Yc(t){return t!==null&&typeof t=="object"&&typeof t.start=="function"}const Lp=["animate","whileInView","whileFocus","whileHover","whileTap","whileDrag","exit"],Up=["initial",...Lp];function Jc(t){return Yc(t.animate)||Up.some(s=>jr(t[s]))}function Qb(t){return!!(Jc(t)||t.variants)}function oC(t,s){if(Jc(t)){const{initial:i,animate:o}=t;return{initial:i===!1||jr(i)?i:void 0,animate:jr(o)?o:void 0}}return t.inherit!==!1?s:{}}function rC(t){const{initial:s,animate:i}=oC(t,y.useContext(Kc));return y.useMemo(()=>({initial:s,animate:i}),[B0(s),B0(i)])}function B0(t){return Array.isArray(t)?t.join(" "):t}const lC=Symbol.for("motionComponentSymbol");function Wi(t){return t&&typeof t=="object"&&Object.prototype.hasOwnProperty.call(t,"current")}function cC(t,s,i){return y.useCallback(o=>{o&&t.onMount&&t.onMount(o),s&&(o?s.mount(o):s.unmount()),i&&(typeof i=="function"?i(o):Wi(i)&&(i.current=o))},[s])}const zp=t=>t.replace(/([a-z])([A-Z])/gu,"$1-$2").toLowerCase(),uC="framerAppearId",e_="data-"+zp(uC),{schedule:Pp}=Jb(queueMicrotask,!1),t_=y.createContext({});function dC(t,s,i,o,c){var u,d;const{visualElement:m}=y.useContext(Kc),h=y.useContext(Wb),g=y.useContext(Zc),v=y.useContext(Op).reducedMotion,_=y.useRef(null);o=o||h.renderer,!_.current&&o&&(_.current=o(t,{visualState:s,parent:m,props:i,presenceContext:g,blockInitialAnimation:g?g.initial===!1:!1,reducedMotionConfig:v}));const b=_.current,S=y.useContext(t_);b&&!b.projection&&c&&(b.type==="html"||b.type==="svg")&&fC(_.current,i,c,S);const T=y.useRef(!1);y.useInsertionEffect(()=>{b&&T.current&&b.update(i,g)});const N=i[e_],j=y.useRef(!!N&&!(!((u=window.MotionHandoffIsComplete)===null||u===void 0)&&u.call(window,N))&&((d=window.MotionHasOptimisedAnimation)===null||d===void 0?void 0:d.call(window,N)));return Kb(()=>{b&&(T.current=!0,window.MotionIsMounted=!0,b.updateFeatures(),Pp.render(b.render),j.current&&b.animationState&&b.animationState.animateChanges())}),y.useEffect(()=>{b&&(!j.current&&b.animationState&&b.animationState.animateChanges(),j.current&&(queueMicrotask(()=>{var w;(w=window.MotionHandoffMarkAsComplete)===null||w===void 0||w.call(window,N)}),j.current=!1))}),b}function fC(t,s,i,o){const{layoutId:c,layout:u,drag:d,dragConstraints:m,layoutScroll:h,layoutRoot:g}=s;t.projection=new i(t.latestValues,s["data-framer-portal-id"]?void 0:n_(t.parent)),t.projection.setOptions({layoutId:c,layout:u,alwaysMeasureLayout:!!d||m&&Wi(m),visualElement:t,animationType:typeof u=="string"?u:"both",initialPromotionConfig:o,layoutScroll:h,layoutRoot:g})}function n_(t){if(t)return t.options.allowProjection!==!1?t.projection:n_(t.parent)}function pC({preloadedFeatures:t,createVisualElement:s,useRender:i,useVisualState:o,Component:c}){var u,d;t&&tC(t);function m(g,v){let _;const b={...y.useContext(Op),...g,layoutId:mC(g)},{isStatic:S}=b,T=rC(g),N=o(g,S);if(!S&&Bp){hC();const j=gC(b);_=j.MeasureLayout,T.visualElement=dC(c,N,b,s,j.ProjectionNode)}return l.jsxs(Kc.Provider,{value:T,children:[_&&T.visualElement?l.jsx(_,{visualElement:T.visualElement,...b}):null,i(c,g,cC(N,T.visualElement,v),N,S,T.visualElement)]})}m.displayName=`motion.${typeof c=="string"?c:`create(${(d=(u=c.displayName)!==null&&u!==void 0?u:c.name)!==null&&d!==void 0?d:""})`}`;const h=y.forwardRef(m);return h[lC]=c,h}function mC({layoutId:t}){const s=y.useContext(Mp).id;return s&&t!==void 0?s+"-"+t:t}function hC(t,s){y.useContext(Wb).strict}function gC(t){const{drag:s,layout:i}=oo;if(!s&&!i)return{};const o={...s,...i};return{MeasureLayout:s!=null&&s.isEnabled(t)||i!=null&&i.isEnabled(t)?o.MeasureLayout:void 0,ProjectionNode:o.ProjectionNode}}const vC=["animate","circle","defs","desc","ellipse","g","image","line","filter","marker","mask","metadata","path","pattern","polygon","polyline","rect","stop","switch","symbol","svg","text","tspan","use","view"];function Vp(t){return typeof t!="string"||t.includes("-")?!1:!!(vC.indexOf(t)>-1||/[A-Z]/u.test(t))}function L0(t){const s=[{},{}];return t==null||t.values.forEach((i,o)=>{s[0][o]=i.get(),s[1][o]=i.getVelocity()}),s}function Hp(t,s,i,o){if(typeof s=="function"){const[c,u]=L0(o);s=s(i!==void 0?i:t.custom,c,u)}if(typeof s=="string"&&(s=t.variants&&t.variants[s]),typeof s=="function"){const[c,u]=L0(o);s=s(i!==void 0?i:t.custom,c,u)}return s}const np=t=>Array.isArray(t),yC=t=>!!(t&&typeof t=="object"&&t.mix&&t.toValue),bC=t=>np(t)?t[t.length-1]||0:t,Xt=t=>!!(t&&t.getVelocity);function xc(t){const s=Xt(t)?t.get():t;return yC(s)?s.toValue():s}function _C({scrapeMotionValuesFromProps:t,createRenderState:s,onUpdate:i},o,c,u){const d={latestValues:xC(o,c,u,t),renderState:s()};return i&&(d.onMount=m=>i({props:o,current:m,...d}),d.onUpdate=m=>i(m)),d}const s_=t=>(s,i)=>{const o=y.useContext(Kc),c=y.useContext(Zc),u=()=>_C(t,s,o,c);return i?u():Ip(u)};function xC(t,s,i,o){const c={},u=o(t,{});for(const b in u)c[b]=xc(u[b]);let{initial:d,animate:m}=t;const h=Jc(t),g=Qb(t);s&&g&&!h&&t.inherit!==!1&&(d===void 0&&(d=s.initial),m===void 0&&(m=s.animate));let v=i?i.initial===!1:!1;v=v||d===!1;const _=v?m:d;if(_&&typeof _!="boolean"&&!Yc(_)){const b=Array.isArray(_)?_:[_];for(let S=0;S<b.length;S++){const T=Hp(t,b[S]);if(T){const{transitionEnd:N,transition:j,...w}=T;for(const C in w){let A=w[C];if(Array.isArray(A)){const M=v?A.length-1:0;A=A[M]}A!==null&&(c[C]=A)}for(const C in N)c[C]=N[C]}}}return c}const fo=["transformPerspective","x","y","z","translateX","translateY","translateZ","scale","scaleX","scaleY","rotate","rotateX","rotateY","rotateZ","skew","skewX","skewY"],ci=new Set(fo),a_=t=>s=>typeof s=="string"&&s.startsWith(t),i_=a_("--"),SC=a_("var(--"),$p=t=>SC(t)?TC.test(t.split("/*")[0].trim()):!1,TC=/var\(--(?:[\w-]+\s*|[\w-]+\s*,(?:\s*[^)(\s]|\s*\((?:[^)(]|\([^)(]*\))*\))+\s*)\)$/iu,o_=(t,s)=>s&&typeof t=="number"?s.transform(t):t,Ps=(t,s,i)=>i>s?s:i<t?t:i,po={test:t=>typeof t=="number",parse:parseFloat,transform:t=>t},Cr={...po,transform:t=>Ps(0,1,t)},uc={...po,default:1},Ir=t=>({test:s=>typeof s=="string"&&s.endsWith(t)&&s.split(" ").length===1,parse:parseFloat,transform:s=>`${s}${t}`}),_a=Ir("deg"),cs=Ir("%"),we=Ir("px"),kC=Ir("vh"),wC=Ir("vw"),U0={...cs,parse:t=>cs.parse(t)/100,transform:t=>cs.transform(t*100)},NC={borderWidth:we,borderTopWidth:we,borderRightWidth:we,borderBottomWidth:we,borderLeftWidth:we,borderRadius:we,radius:we,borderTopLeftRadius:we,borderTopRightRadius:we,borderBottomRightRadius:we,borderBottomLeftRadius:we,width:we,maxWidth:we,height:we,maxHeight:we,top:we,right:we,bottom:we,left:we,padding:we,paddingTop:we,paddingRight:we,paddingBottom:we,paddingLeft:we,margin:we,marginTop:we,marginRight:we,marginBottom:we,marginLeft:we,backgroundPositionX:we,backgroundPositionY:we},jC={rotate:_a,rotateX:_a,rotateY:_a,rotateZ:_a,scale:uc,scaleX:uc,scaleY:uc,scaleZ:uc,skew:_a,skewX:_a,skewY:_a,distance:we,translateX:we,translateY:we,translateZ:we,x:we,y:we,z:we,perspective:we,transformPerspective:we,opacity:Cr,originX:U0,originY:U0,originZ:we},z0={...po,transform:Math.round},Gp={...NC,...jC,zIndex:z0,size:we,fillOpacity:Cr,strokeOpacity:Cr,numOctaves:z0},CC={x:"translateX",y:"translateY",z:"translateZ",transformPerspective:"perspective"},EC=fo.length;function AC(t,s,i){let o="",c=!0;for(let u=0;u<EC;u++){const d=fo[u],m=t[d];if(m===void 0)continue;let h=!0;if(typeof m=="number"?h=m===(d.startsWith("scale")?1:0):h=parseFloat(m)===0,!h||i){const g=o_(m,Gp[d]);if(!h){c=!1;const v=CC[d]||d;o+=`${v}(${g}) `}i&&(s[d]=g)}}return o=o.trim(),i?o=i(s,c?"":o):c&&(o="none"),o}function qp(t,s,i){const{style:o,vars:c,transformOrigin:u}=t;let d=!1,m=!1;for(const h in s){const g=s[h];if(ci.has(h)){d=!0;continue}else if(i_(h)){c[h]=g;continue}else{const v=o_(g,Gp[h]);h.startsWith("origin")?(m=!0,u[h]=v):o[h]=v}}if(s.transform||(d||i?o.transform=AC(s,t.transform,i):o.transform&&(o.transform="none")),m){const{originX:h="50%",originY:g="50%",originZ:v=0}=u;o.transformOrigin=`${h} ${g} ${v}`}}const DC={offset:"stroke-dashoffset",array:"stroke-dasharray"},RC={offset:"strokeDashoffset",array:"strokeDasharray"};function MC(t,s,i=1,o=0,c=!0){t.pathLength=1;const u=c?DC:RC;t[u.offset]=we.transform(-o);const d=we.transform(s),m=we.transform(i);t[u.array]=`${d} ${m}`}function P0(t,s,i){return typeof t=="string"?t:we.transform(s+i*t)}function IC(t,s,i){const o=P0(s,t.x,t.width),c=P0(i,t.y,t.height);return`${o} ${c}`}function Fp(t,{attrX:s,attrY:i,attrScale:o,originX:c,originY:u,pathLength:d,pathSpacing:m=1,pathOffset:h=0,...g},v,_){if(qp(t,g,_),v){t.style.viewBox&&(t.attrs.viewBox=t.style.viewBox);return}t.attrs=t.style,t.style={};const{attrs:b,style:S,dimensions:T}=t;b.transform&&(T&&(S.transform=b.transform),delete b.transform),T&&(c!==void 0||u!==void 0||S.transform)&&(S.transformOrigin=IC(T,c!==void 0?c:.5,u!==void 0?u:.5)),s!==void 0&&(b.x=s),i!==void 0&&(b.y=i),o!==void 0&&(b.scale=o),d!==void 0&&MC(b,d,m,h,!1)}const Zp=()=>({style:{},transform:{},transformOrigin:{},vars:{}}),r_=()=>({...Zp(),attrs:{}}),Kp=t=>typeof t=="string"&&t.toLowerCase()==="svg";function l_(t,{style:s,vars:i},o,c){Object.assign(t.style,s,c&&c.getProjectionStyles(o));for(const u in i)t.style.setProperty(u,i[u])}const c_=new Set(["baseFrequency","diffuseConstant","kernelMatrix","kernelUnitLength","keySplines","keyTimes","limitingConeAngle","markerHeight","markerWidth","numOctaves","targetX","targetY","surfaceScale","specularConstant","specularExponent","stdDeviation","tableValues","viewBox","gradientTransform","pathLength","startOffset","textLength","lengthAdjust"]);function u_(t,s,i,o){l_(t,s,void 0,o);for(const c in s.attrs)t.setAttribute(c_.has(c)?c:zp(c),s.attrs[c])}const Ec={};function OC(t){Object.assign(Ec,t)}function d_(t,{layout:s,layoutId:i}){return ci.has(t)||t.startsWith("origin")||(s||i!==void 0)&&(!!Ec[t]||t==="opacity")}function Yp(t,s,i){var o;const{style:c}=t,u={};for(const d in c)(Xt(c[d])||s.style&&Xt(s.style[d])||d_(d,t)||((o=i==null?void 0:i.getValue(d))===null||o===void 0?void 0:o.liveStyle)!==void 0)&&(u[d]=c[d]);return u}function f_(t,s,i){const o=Yp(t,s,i);for(const c in t)if(Xt(t[c])||Xt(s[c])){const u=fo.indexOf(c)!==-1?"attr"+c.charAt(0).toUpperCase()+c.substring(1):c;o[u]=t[c]}return o}function BC(t,s){try{s.dimensions=typeof t.getBBox=="function"?t.getBBox():t.getBoundingClientRect()}catch{s.dimensions={x:0,y:0,width:0,height:0}}}const V0=["x","y","width","height","cx","cy","r"],LC={useVisualState:s_({scrapeMotionValuesFromProps:f_,createRenderState:r_,onUpdate:({props:t,prevProps:s,current:i,renderState:o,latestValues:c})=>{if(!i)return;let u=!!t.drag;if(!u){for(const m in c)if(ci.has(m)){u=!0;break}}if(!u)return;let d=!s;if(s)for(let m=0;m<V0.length;m++){const h=V0[m];t[h]!==s[h]&&(d=!0)}d&&gt.read(()=>{BC(i,o),gt.render(()=>{Fp(o,c,Kp(i.tagName),t.transformTemplate),u_(i,o)})})}})},UC={useVisualState:s_({scrapeMotionValuesFromProps:Yp,createRenderState:Zp})};function p_(t,s,i){for(const o in s)!Xt(s[o])&&!d_(o,i)&&(t[o]=s[o])}function zC({transformTemplate:t},s){return y.useMemo(()=>{const i=Zp();return qp(i,s,t),Object.assign({},i.vars,i.style)},[s])}function PC(t,s){const i=t.style||{},o={};return p_(o,i,t),Object.assign(o,zC(t,s)),o}function VC(t,s){const i={},o=PC(t,s);return t.drag&&t.dragListener!==!1&&(i.draggable=!1,o.userSelect=o.WebkitUserSelect=o.WebkitTouchCallout="none",o.touchAction=t.drag===!0?"none":`pan-${t.drag==="x"?"y":"x"}`),t.tabIndex===void 0&&(t.onTap||t.onTapStart||t.whileTap)&&(i.tabIndex=0),i.style=o,i}function HC(t,s,i,o){const c=y.useMemo(()=>{const u=r_();return Fp(u,s,Kp(o),t.transformTemplate),{...u.attrs,style:{...u.style}}},[s]);if(t.style){const u={};p_(u,t.style,t),c.style={...u,...c.style}}return c}function $C(t=!1){return(i,o,c,{latestValues:u},d)=>{const h=(Vp(i)?HC:VC)(o,u,d,i),g=aC(o,typeof i=="string",t),v=i!==y.Fragment?{...g,...h,ref:c}:{},{children:_}=o,b=y.useMemo(()=>Xt(_)?_.get():_,[_]);return y.createElement(i,{...v,children:b})}}function GC(t,s){return function(o,{forwardMotionProps:c}={forwardMotionProps:!1}){const d={...Vp(o)?LC:UC,preloadedFeatures:t,useRender:$C(c),createVisualElement:s,Component:o};return pC(d)}}function m_(t,s){if(!Array.isArray(s))return!1;const i=s.length;if(i!==t.length)return!1;for(let o=0;o<i;o++)if(s[o]!==t[o])return!1;return!0}function Wc(t,s,i){const o=t.getProps();return Hp(o,s,i!==void 0?i:o.custom,t)}function Jp(t,s){return t?t[s]||t.default||t:void 0}const h_=new Set(["width","height","top","left","right","bottom",...fo]);let Sc;function qC(){Sc=void 0}const us={now:()=>(Sc===void 0&&us.set(Zt.isProcessing||Xj.useManualTiming?Zt.timestamp:performance.now()),Sc),set:t=>{Sc=t,queueMicrotask(qC)}};function Wp(t,s){t.indexOf(s)===-1&&t.push(s)}function Xp(t,s){const i=t.indexOf(s);i>-1&&t.splice(i,1)}class Qp{constructor(){this.subscriptions=[]}add(s){return Wp(this.subscriptions,s),()=>Xp(this.subscriptions,s)}notify(s,i,o){const c=this.subscriptions.length;if(c)if(c===1)this.subscriptions[0](s,i,o);else for(let u=0;u<c;u++){const d=this.subscriptions[u];d&&d(s,i,o)}}getSize(){return this.subscriptions.length}clear(){this.subscriptions.length=0}}function g_(t,s){return s?t*(1e3/s):0}const H0=30,FC=t=>!isNaN(parseFloat(t));class ZC{constructor(s,i={}){this.version="11.18.2",this.canTrackVelocity=null,this.events={},this.updateAndNotify=(o,c=!0)=>{const u=us.now();this.updatedAt!==u&&this.setPrevFrameValue(),this.prev=this.current,this.setCurrent(o),this.current!==this.prev&&this.events.change&&this.events.change.notify(this.current),c&&this.events.renderRequest&&this.events.renderRequest.notify(this.current)},this.hasAnimated=!1,this.setCurrent(s),this.owner=i.owner}setCurrent(s){this.current=s,this.updatedAt=us.now(),this.canTrackVelocity===null&&s!==void 0&&(this.canTrackVelocity=FC(this.current))}setPrevFrameValue(s=this.current){this.prevFrameValue=s,this.prevUpdatedAt=this.updatedAt}onChange(s){return this.on("change",s)}on(s,i){this.events[s]||(this.events[s]=new Qp);const o=this.events[s].add(i);return s==="change"?()=>{o(),gt.read(()=>{this.events.change.getSize()||this.stop()})}:o}clearListeners(){for(const s in this.events)this.events[s].clear()}attach(s,i){this.passiveEffect=s,this.stopPassiveEffect=i}set(s,i=!0){!i||!this.passiveEffect?this.updateAndNotify(s,i):this.passiveEffect(s,this.updateAndNotify)}setWithVelocity(s,i,o){this.set(i),this.prev=void 0,this.prevFrameValue=s,this.prevUpdatedAt=this.updatedAt-o}jump(s,i=!0){this.updateAndNotify(s),this.prev=s,this.prevUpdatedAt=this.prevFrameValue=void 0,i&&this.stop(),this.stopPassiveEffect&&this.stopPassiveEffect()}get(){return this.current}getPrevious(){return this.prev}getVelocity(){const s=us.now();if(!this.canTrackVelocity||this.prevFrameValue===void 0||s-this.updatedAt>H0)return 0;const i=Math.min(this.updatedAt-this.prevUpdatedAt,H0);return g_(parseFloat(this.current)-parseFloat(this.prevFrameValue),i)}start(s){return this.stop(),new Promise(i=>{this.hasAnimated=!0,this.animation=s(i),this.events.animationStart&&this.events.animationStart.notify()}).then(()=>{this.events.animationComplete&&this.events.animationComplete.notify(),this.clearAnimation()})}stop(){this.animation&&(this.animation.stop(),this.events.animationCancel&&this.events.animationCancel.notify()),this.clearAnimation()}isAnimating(){return!!this.animation}clearAnimation(){delete this.animation}destroy(){this.clearListeners(),this.stop(),this.stopPassiveEffect&&this.stopPassiveEffect()}}function Er(t,s){return new ZC(t,s)}function KC(t,s,i){t.hasValue(s)?t.getValue(s).set(i):t.addValue(s,Er(i))}function YC(t,s){const i=Wc(t,s);let{transitionEnd:o={},transition:c={},...u}=i||{};u={...u,...o};for(const d in u){const m=bC(u[d]);KC(t,d,m)}}function JC(t){return!!(Xt(t)&&t.add)}function sp(t,s){const i=t.getValue("willChange");if(JC(i))return i.add(s)}function v_(t){return t.props[e_]}function em(t){let s;return()=>(s===void 0&&(s=t()),s)}const WC=em(()=>window.ScrollTimeline!==void 0);class XC{constructor(s){this.stop=()=>this.runAll("stop"),this.animations=s.filter(Boolean)}get finished(){return Promise.all(this.animations.map(s=>"finished"in s?s.finished:s))}getAll(s){return this.animations[0][s]}setAll(s,i){for(let o=0;o<this.animations.length;o++)this.animations[o][s]=i}attachTimeline(s,i){const o=this.animations.map(c=>{if(WC()&&c.attachTimeline)return c.attachTimeline(s);if(typeof i=="function")return i(c)});return()=>{o.forEach((c,u)=>{c&&c(),this.animations[u].stop()})}}get time(){return this.getAll("time")}set time(s){this.setAll("time",s)}get speed(){return this.getAll("speed")}set speed(s){this.setAll("speed",s)}get startTime(){return this.getAll("startTime")}get duration(){let s=0;for(let i=0;i<this.animations.length;i++)s=Math.max(s,this.animations[i].duration);return s}runAll(s){this.animations.forEach(i=>i[s]())}flatten(){this.runAll("flatten")}play(){this.runAll("play")}pause(){this.runAll("pause")}cancel(){this.runAll("cancel")}complete(){this.runAll("complete")}}class QC extends XC{then(s,i){return Promise.all(this.animations).then(s).catch(i)}}const Bs=t=>t*1e3,Ls=t=>t/1e3;function tm(t){return typeof t=="function"}function $0(t,s){t.timeline=s,t.onfinish=null}const nm=t=>Array.isArray(t)&&typeof t[0]=="number",eE={linearEasing:void 0};function tE(t,s){const i=em(t);return()=>{var o;return(o=eE[s])!==null&&o!==void 0?o:i()}}const Ac=tE(()=>{try{document.createElement("div").animate({opacity:0},{easing:"linear(0, 1)"})}catch{return!1}return!0},"linearEasing"),ro=(t,s,i)=>{const o=s-t;return o===0?1:(i-t)/o},y_=(t,s,i=10)=>{let o="";const c=Math.max(Math.round(s/i),2);for(let u=0;u<c;u++)o+=t(ro(0,c-1,u))+", ";return`linear(${o.substring(0,o.length-2)})`};function b_(t){return!!(typeof t=="function"&&Ac()||!t||typeof t=="string"&&(t in ap||Ac())||nm(t)||Array.isArray(t)&&t.every(b_))}const pr=([t,s,i,o])=>`cubic-bezier(${t}, ${s}, ${i}, ${o})`,ap={linear:"linear",ease:"ease",easeIn:"ease-in",easeOut:"ease-out",easeInOut:"ease-in-out",circIn:pr([0,.65,.55,1]),circOut:pr([.55,0,1,.45]),backIn:pr([.31,.01,.66,-.59]),backOut:pr([.33,1.53,.69,.99])};function __(t,s){if(t)return typeof t=="function"&&Ac()?y_(t,s):nm(t)?pr(t):Array.isArray(t)?t.map(i=>__(i,s)||ap.easeOut):ap[t]}const x_=(t,s,i)=>(((1-3*i+3*s)*t+(3*i-6*s))*t+3*s)*t,nE=1e-7,sE=12;function aE(t,s,i,o,c){let u,d,m=0;do d=s+(i-s)/2,u=x_(d,o,c)-t,u>0?i=d:s=d;while(Math.abs(u)>nE&&++m<sE);return d}function Or(t,s,i,o){if(t===s&&i===o)return xn;const c=u=>aE(u,0,1,t,i);return u=>u===0||u===1?u:x_(c(u),s,o)}const S_=t=>s=>s<=.5?t(2*s)/2:(2-t(2*(1-s)))/2,T_=t=>s=>1-t(1-s),k_=Or(.33,1.53,.69,.99),sm=T_(k_),w_=S_(sm),N_=t=>(t*=2)<1?.5*sm(t):.5*(2-Math.pow(2,-10*(t-1))),am=t=>1-Math.sin(Math.acos(t)),j_=T_(am),C_=S_(am),E_=t=>/^0[^.\s]+$/u.test(t);function iE(t){return typeof t=="number"?t===0:t!==null?t==="none"||t==="0"||E_(t):!0}const yr=t=>Math.round(t*1e5)/1e5,im=/-?(?:\d+(?:\.\d+)?|\.\d+)/gu;function oE(t){return t==null}const rE=/^(?:#[\da-f]{3,8}|(?:rgb|hsl)a?\((?:-?[\d.]+%?[,\s]+){2}-?[\d.]+%?\s*(?:[,/]\s*)?(?:\b\d+(?:\.\d+)?|\.\d+)?%?\))$/iu,om=(t,s)=>i=>!!(typeof i=="string"&&rE.test(i)&&i.startsWith(t)||s&&!oE(i)&&Object.prototype.hasOwnProperty.call(i,s)),A_=(t,s,i)=>o=>{if(typeof o!="string")return o;const[c,u,d,m]=o.match(im);return{[t]:parseFloat(c),[s]:parseFloat(u),[i]:parseFloat(d),alpha:m!==void 0?parseFloat(m):1}},lE=t=>Ps(0,255,t),Nf={...po,transform:t=>Math.round(lE(t))},Qa={test:om("rgb","red"),parse:A_("red","green","blue"),transform:({red:t,green:s,blue:i,alpha:o=1})=>"rgba("+Nf.transform(t)+", "+Nf.transform(s)+", "+Nf.transform(i)+", "+yr(Cr.transform(o))+")"};function cE(t){let s="",i="",o="",c="";return t.length>5?(s=t.substring(1,3),i=t.substring(3,5),o=t.substring(5,7),c=t.substring(7,9)):(s=t.substring(1,2),i=t.substring(2,3),o=t.substring(3,4),c=t.substring(4,5),s+=s,i+=i,o+=o,c+=c),{red:parseInt(s,16),green:parseInt(i,16),blue:parseInt(o,16),alpha:c?parseInt(c,16)/255:1}}const ip={test:om("#"),parse:cE,transform:Qa.transform},Xi={test:om("hsl","hue"),parse:A_("hue","saturation","lightness"),transform:({hue:t,saturation:s,lightness:i,alpha:o=1})=>"hsla("+Math.round(t)+", "+cs.transform(yr(s))+", "+cs.transform(yr(i))+", "+yr(Cr.transform(o))+")"},Wt={test:t=>Qa.test(t)||ip.test(t)||Xi.test(t),parse:t=>Qa.test(t)?Qa.parse(t):Xi.test(t)?Xi.parse(t):ip.parse(t),transform:t=>typeof t=="string"?t:t.hasOwnProperty("red")?Qa.transform(t):Xi.transform(t)},uE=/(?:#[\da-f]{3,8}|(?:rgb|hsl)a?\((?:-?[\d.]+%?[,\s]+){2}-?[\d.]+%?\s*(?:[,/]\s*)?(?:\b\d+(?:\.\d+)?|\.\d+)?%?\))/giu;function dE(t){var s,i;return isNaN(t)&&typeof t=="string"&&(((s=t.match(im))===null||s===void 0?void 0:s.length)||0)+(((i=t.match(uE))===null||i===void 0?void 0:i.length)||0)>0}const D_="number",R_="color",fE="var",pE="var(",G0="${}",mE=/var\s*\(\s*--(?:[\w-]+\s*|[\w-]+\s*,(?:\s*[^)(\s]|\s*\((?:[^)(]|\([^)(]*\))*\))+\s*)\)|#[\da-f]{3,8}|(?:rgb|hsl)a?\((?:-?[\d.]+%?[,\s]+){2}-?[\d.]+%?\s*(?:[,/]\s*)?(?:\b\d+(?:\.\d+)?|\.\d+)?%?\)|-?(?:\d+(?:\.\d+)?|\.\d+)/giu;function Ar(t){const s=t.toString(),i=[],o={color:[],number:[],var:[]},c=[];let u=0;const m=s.replace(mE,h=>(Wt.test(h)?(o.color.push(u),c.push(R_),i.push(Wt.parse(h))):h.startsWith(pE)?(o.var.push(u),c.push(fE),i.push(h)):(o.number.push(u),c.push(D_),i.push(parseFloat(h))),++u,G0)).split(G0);return{values:i,split:m,indexes:o,types:c}}function M_(t){return Ar(t).values}function I_(t){const{split:s,types:i}=Ar(t),o=s.length;return c=>{let u="";for(let d=0;d<o;d++)if(u+=s[d],c[d]!==void 0){const m=i[d];m===D_?u+=yr(c[d]):m===R_?u+=Wt.transform(c[d]):u+=c[d]}return u}}const hE=t=>typeof t=="number"?0:t;function gE(t){const s=M_(t);return I_(t)(s.map(hE))}const ka={test:dE,parse:M_,createTransformer:I_,getAnimatableNone:gE},vE=new Set(["brightness","contrast","saturate","opacity"]);function yE(t){const[s,i]=t.slice(0,-1).split("(");if(s==="drop-shadow")return t;const[o]=i.match(im)||[];if(!o)return t;const c=i.replace(o,"");let u=vE.has(s)?1:0;return o!==i&&(u*=100),s+"("+u+c+")"}const bE=/\b([a-z-]*)\(.*?\)/gu,op={...ka,getAnimatableNone:t=>{const s=t.match(bE);return s?s.map(yE).join(" "):t}},_E={...Gp,color:Wt,backgroundColor:Wt,outlineColor:Wt,fill:Wt,stroke:Wt,borderColor:Wt,borderTopColor:Wt,borderRightColor:Wt,borderBottomColor:Wt,borderLeftColor:Wt,filter:op,WebkitFilter:op},rm=t=>_E[t];function O_(t,s){let i=rm(t);return i!==op&&(i=ka),i.getAnimatableNone?i.getAnimatableNone(s):void 0}const xE=new Set(["auto","none","0"]);function SE(t,s,i){let o=0,c;for(;o<t.length&&!c;){const u=t[o];typeof u=="string"&&!xE.has(u)&&Ar(u).values.length&&(c=t[o]),o++}if(c&&i)for(const u of s)t[u]=O_(i,c)}const q0=t=>t===po||t===we,F0=(t,s)=>parseFloat(t.split(", ")[s]),Z0=(t,s)=>(i,{transform:o})=>{if(o==="none"||!o)return 0;const c=o.match(/^matrix3d\((.+)\)$/u);if(c)return F0(c[1],s);{const u=o.match(/^matrix\((.+)\)$/u);return u?F0(u[1],t):0}},TE=new Set(["x","y","z"]),kE=fo.filter(t=>!TE.has(t));function wE(t){const s=[];return kE.forEach(i=>{const o=t.getValue(i);o!==void 0&&(s.push([i,o.get()]),o.set(i.startsWith("scale")?1:0))}),s}const lo={width:({x:t},{paddingLeft:s="0",paddingRight:i="0"})=>t.max-t.min-parseFloat(s)-parseFloat(i),height:({y:t},{paddingTop:s="0",paddingBottom:i="0"})=>t.max-t.min-parseFloat(s)-parseFloat(i),top:(t,{top:s})=>parseFloat(s),left:(t,{left:s})=>parseFloat(s),bottom:({y:t},{top:s})=>parseFloat(s)+(t.max-t.min),right:({x:t},{left:s})=>parseFloat(s)+(t.max-t.min),x:Z0(4,13),y:Z0(5,14)};lo.translateX=lo.x;lo.translateY=lo.y;const ti=new Set;let rp=!1,lp=!1;function B_(){if(lp){const t=Array.from(ti).filter(o=>o.needsMeasurement),s=new Set(t.map(o=>o.element)),i=new Map;s.forEach(o=>{const c=wE(o);c.length&&(i.set(o,c),o.render())}),t.forEach(o=>o.measureInitialState()),s.forEach(o=>{o.render();const c=i.get(o);c&&c.forEach(([u,d])=>{var m;(m=o.getValue(u))===null||m===void 0||m.set(d)})}),t.forEach(o=>o.measureEndState()),t.forEach(o=>{o.suspendedScrollY!==void 0&&window.scrollTo(0,o.suspendedScrollY)})}lp=!1,rp=!1,ti.forEach(t=>t.complete()),ti.clear()}function L_(){ti.forEach(t=>{t.readKeyframes(),t.needsMeasurement&&(lp=!0)})}function NE(){L_(),B_()}class lm{constructor(s,i,o,c,u,d=!1){this.isComplete=!1,this.isAsync=!1,this.needsMeasurement=!1,this.isScheduled=!1,this.unresolvedKeyframes=[...s],this.onComplete=i,this.name=o,this.motionValue=c,this.element=u,this.isAsync=d}scheduleResolve(){this.isScheduled=!0,this.isAsync?(ti.add(this),rp||(rp=!0,gt.read(L_),gt.resolveKeyframes(B_))):(this.readKeyframes(),this.complete())}readKeyframes(){const{unresolvedKeyframes:s,name:i,element:o,motionValue:c}=this;for(let u=0;u<s.length;u++)if(s[u]===null)if(u===0){const d=c==null?void 0:c.get(),m=s[s.length-1];if(d!==void 0)s[0]=d;else if(o&&i){const h=o.readValue(i,m);h!=null&&(s[0]=h)}s[0]===void 0&&(s[0]=m),c&&d===void 0&&c.set(s[0])}else s[u]=s[u-1]}setFinalKeyframe(){}measureInitialState(){}renderEndStyles(){}measureEndState(){}complete(){this.isComplete=!0,this.onComplete(this.unresolvedKeyframes,this.finalKeyframe),ti.delete(this)}cancel(){this.isComplete||(this.isScheduled=!1,ti.delete(this))}resume(){this.isComplete||this.scheduleResolve()}}const U_=t=>/^-?(?:\d+(?:\.\d+)?|\.\d+)$/u.test(t),jE=/^var\(--(?:([\w-]+)|([\w-]+), ?([a-zA-Z\d ()%#.,-]+))\)/u;function CE(t){const s=jE.exec(t);if(!s)return[,];const[,i,o,c]=s;return[`--${i??o}`,c]}function z_(t,s,i=1){const[o,c]=CE(t);if(!o)return;const u=window.getComputedStyle(s).getPropertyValue(o);if(u){const d=u.trim();return U_(d)?parseFloat(d):d}return $p(c)?z_(c,s,i+1):c}const P_=t=>s=>s.test(t),EE={test:t=>t==="auto",parse:t=>t},V_=[po,we,cs,_a,wC,kC,EE],K0=t=>V_.find(P_(t));class H_ extends lm{constructor(s,i,o,c,u){super(s,i,o,c,u,!0)}readKeyframes(){const{unresolvedKeyframes:s,element:i,name:o}=this;if(!i||!i.current)return;super.readKeyframes();for(let h=0;h<s.length;h++){let g=s[h];if(typeof g=="string"&&(g=g.trim(),$p(g))){const v=z_(g,i.current);v!==void 0&&(s[h]=v),h===s.length-1&&(this.finalKeyframe=g)}}if(this.resolveNoneKeyframes(),!h_.has(o)||s.length!==2)return;const[c,u]=s,d=K0(c),m=K0(u);if(d!==m)if(q0(d)&&q0(m))for(let h=0;h<s.length;h++){const g=s[h];typeof g=="string"&&(s[h]=parseFloat(g))}else this.needsMeasurement=!0}resolveNoneKeyframes(){const{unresolvedKeyframes:s,name:i}=this,o=[];for(let c=0;c<s.length;c++)iE(s[c])&&o.push(c);o.length&&SE(s,o,i)}measureInitialState(){const{element:s,unresolvedKeyframes:i,name:o}=this;if(!s||!s.current)return;o==="height"&&(this.suspendedScrollY=window.pageYOffset),this.measuredOrigin=lo[o](s.measureViewportBox(),window.getComputedStyle(s.current)),i[0]=this.measuredOrigin;const c=i[i.length-1];c!==void 0&&s.getValue(o,c).jump(c,!1)}measureEndState(){var s;const{element:i,name:o,unresolvedKeyframes:c}=this;if(!i||!i.current)return;const u=i.getValue(o);u&&u.jump(this.measuredOrigin,!1);const d=c.length-1,m=c[d];c[d]=lo[o](i.measureViewportBox(),window.getComputedStyle(i.current)),m!==null&&this.finalKeyframe===void 0&&(this.finalKeyframe=m),!((s=this.removedTransforms)===null||s===void 0)&&s.length&&this.removedTransforms.forEach(([h,g])=>{i.getValue(h).set(g)}),this.resolveNoneKeyframes()}}const Y0=(t,s)=>s==="zIndex"?!1:!!(typeof t=="number"||Array.isArray(t)||typeof t=="string"&&(ka.test(t)||t==="0")&&!t.startsWith("url("));function AE(t){const s=t[0];if(t.length===1)return!0;for(let i=0;i<t.length;i++)if(t[i]!==s)return!0}function DE(t,s,i,o){const c=t[0];if(c===null)return!1;if(s==="display"||s==="visibility")return!0;const u=t[t.length-1],d=Y0(c,s),m=Y0(u,s);return!d||!m?!1:AE(t)||(i==="spring"||tm(i))&&o}const RE=t=>t!==null;function Xc(t,{repeat:s,repeatType:i="loop"},o){const c=t.filter(RE),u=s&&i!=="loop"&&s%2===1?0:c.length-1;return!u||o===void 0?c[u]:o}const ME=40;class $_{constructor({autoplay:s=!0,delay:i=0,type:o="keyframes",repeat:c=0,repeatDelay:u=0,repeatType:d="loop",...m}){this.isStopped=!1,this.hasAttemptedResolve=!1,this.createdAt=us.now(),this.options={autoplay:s,delay:i,type:o,repeat:c,repeatDelay:u,repeatType:d,...m},this.updateFinishedPromise()}calcStartTime(){return this.resolvedAt?this.resolvedAt-this.createdAt>ME?this.resolvedAt:this.createdAt:this.createdAt}get resolved(){return!this._resolved&&!this.hasAttemptedResolve&&NE(),this._resolved}onKeyframesResolved(s,i){this.resolvedAt=us.now(),this.hasAttemptedResolve=!0;const{name:o,type:c,velocity:u,delay:d,onComplete:m,onUpdate:h,isGenerator:g}=this.options;if(!g&&!DE(s,o,c,u))if(d)this.options.duration=0;else{h&&h(Xc(s,this.options,i)),m&&m(),this.resolveFinishedPromise();return}const v=this.initPlayback(s,i);v!==!1&&(this._resolved={keyframes:s,finalKeyframe:i,...v},this.onPostResolved())}onPostResolved(){}then(s,i){return this.currentFinishedPromise.then(s,i)}flatten(){this.options.type="keyframes",this.options.ease="linear"}updateFinishedPromise(){this.currentFinishedPromise=new Promise(s=>{this.resolveFinishedPromise=s})}}const cp=2e4;function G_(t){let s=0;const i=50;let o=t.next(s);for(;!o.done&&s<cp;)s+=i,o=t.next(s);return s>=cp?1/0:s}const xt=(t,s,i)=>t+(s-t)*i;function jf(t,s,i){return i<0&&(i+=1),i>1&&(i-=1),i<1/6?t+(s-t)*6*i:i<1/2?s:i<2/3?t+(s-t)*(2/3-i)*6:t}function IE({hue:t,saturation:s,lightness:i,alpha:o}){t/=360,s/=100,i/=100;let c=0,u=0,d=0;if(!s)c=u=d=i;else{const m=i<.5?i*(1+s):i+s-i*s,h=2*i-m;c=jf(h,m,t+1/3),u=jf(h,m,t),d=jf(h,m,t-1/3)}return{red:Math.round(c*255),green:Math.round(u*255),blue:Math.round(d*255),alpha:o}}function Dc(t,s){return i=>i>0?s:t}const Cf=(t,s,i)=>{const o=t*t,c=i*(s*s-o)+o;return c<0?0:Math.sqrt(c)},OE=[ip,Qa,Xi],BE=t=>OE.find(s=>s.test(t));function J0(t){const s=BE(t);if(!s)return!1;let i=s.parse(t);return s===Xi&&(i=IE(i)),i}const W0=(t,s)=>{const i=J0(t),o=J0(s);if(!i||!o)return Dc(t,s);const c={...i};return u=>(c.red=Cf(i.red,o.red,u),c.green=Cf(i.green,o.green,u),c.blue=Cf(i.blue,o.blue,u),c.alpha=xt(i.alpha,o.alpha,u),Qa.transform(c))},LE=(t,s)=>i=>s(t(i)),Br=(...t)=>t.reduce(LE),up=new Set(["none","hidden"]);function UE(t,s){return up.has(t)?i=>i<=0?t:s:i=>i>=1?s:t}function zE(t,s){return i=>xt(t,s,i)}function cm(t){return typeof t=="number"?zE:typeof t=="string"?$p(t)?Dc:Wt.test(t)?W0:HE:Array.isArray(t)?q_:typeof t=="object"?Wt.test(t)?W0:PE:Dc}function q_(t,s){const i=[...t],o=i.length,c=t.map((u,d)=>cm(u)(u,s[d]));return u=>{for(let d=0;d<o;d++)i[d]=c[d](u);return i}}function PE(t,s){const i={...t,...s},o={};for(const c in i)t[c]!==void 0&&s[c]!==void 0&&(o[c]=cm(t[c])(t[c],s[c]));return c=>{for(const u in o)i[u]=o[u](c);return i}}function VE(t,s){var i;const o=[],c={color:0,var:0,number:0};for(let u=0;u<s.values.length;u++){const d=s.types[u],m=t.indexes[d][c[d]],h=(i=t.values[m])!==null&&i!==void 0?i:0;o[u]=h,c[d]++}return o}const HE=(t,s)=>{const i=ka.createTransformer(s),o=Ar(t),c=Ar(s);return o.indexes.var.length===c.indexes.var.length&&o.indexes.color.length===c.indexes.color.length&&o.indexes.number.length>=c.indexes.number.length?up.has(t)&&!c.values.length||up.has(s)&&!o.values.length?UE(t,s):Br(q_(VE(o,c),c.values),i):Dc(t,s)};function F_(t,s,i){return typeof t=="number"&&typeof s=="number"&&typeof i=="number"?xt(t,s,i):cm(t)(t,s)}const $E=5;function Z_(t,s,i){const o=Math.max(s-$E,0);return g_(i-t(o),s-o)}const wt={stiffness:100,damping:10,mass:1,velocity:0,duration:800,bounce:.3,visualDuration:.3,restSpeed:{granular:.01,default:2},restDelta:{granular:.005,default:.5},minDuration:.01,maxDuration:10,minDamping:.05,maxDamping:1},Ef=.001;function GE({duration:t=wt.duration,bounce:s=wt.bounce,velocity:i=wt.velocity,mass:o=wt.mass}){let c,u,d=1-s;d=Ps(wt.minDamping,wt.maxDamping,d),t=Ps(wt.minDuration,wt.maxDuration,Ls(t)),d<1?(c=g=>{const v=g*d,_=v*t,b=v-i,S=dp(g,d),T=Math.exp(-_);return Ef-b/S*T},u=g=>{const _=g*d*t,b=_*i+i,S=Math.pow(d,2)*Math.pow(g,2)*t,T=Math.exp(-_),N=dp(Math.pow(g,2),d);return(-c(g)+Ef>0?-1:1)*((b-S)*T)/N}):(c=g=>{const v=Math.exp(-g*t),_=(g-i)*t+1;return-Ef+v*_},u=g=>{const v=Math.exp(-g*t),_=(i-g)*(t*t);return v*_});const m=5/t,h=FE(c,u,m);if(t=Bs(t),isNaN(h))return{stiffness:wt.stiffness,damping:wt.damping,duration:t};{const g=Math.pow(h,2)*o;return{stiffness:g,damping:d*2*Math.sqrt(o*g),duration:t}}}const qE=12;function FE(t,s,i){let o=i;for(let c=1;c<qE;c++)o=o-t(o)/s(o);return o}function dp(t,s){return t*Math.sqrt(1-s*s)}const ZE=["duration","bounce"],KE=["stiffness","damping","mass"];function X0(t,s){return s.some(i=>t[i]!==void 0)}function YE(t){let s={velocity:wt.velocity,stiffness:wt.stiffness,damping:wt.damping,mass:wt.mass,isResolvedFromDuration:!1,...t};if(!X0(t,KE)&&X0(t,ZE))if(t.visualDuration){const i=t.visualDuration,o=2*Math.PI/(i*1.2),c=o*o,u=2*Ps(.05,1,1-(t.bounce||0))*Math.sqrt(c);s={...s,mass:wt.mass,stiffness:c,damping:u}}else{const i=GE(t);s={...s,...i,mass:wt.mass},s.isResolvedFromDuration=!0}return s}function K_(t=wt.visualDuration,s=wt.bounce){const i=typeof t!="object"?{visualDuration:t,keyframes:[0,1],bounce:s}:t;let{restSpeed:o,restDelta:c}=i;const u=i.keyframes[0],d=i.keyframes[i.keyframes.length-1],m={done:!1,value:u},{stiffness:h,damping:g,mass:v,duration:_,velocity:b,isResolvedFromDuration:S}=YE({...i,velocity:-Ls(i.velocity||0)}),T=b||0,N=g/(2*Math.sqrt(h*v)),j=d-u,w=Ls(Math.sqrt(h/v)),C=Math.abs(j)<5;o||(o=C?wt.restSpeed.granular:wt.restSpeed.default),c||(c=C?wt.restDelta.granular:wt.restDelta.default);let A;if(N<1){const D=dp(w,N);A=E=>{const $=Math.exp(-N*w*E);return d-$*((T+N*w*j)/D*Math.sin(D*E)+j*Math.cos(D*E))}}else if(N===1)A=D=>d-Math.exp(-w*D)*(j+(T+w*j)*D);else{const D=w*Math.sqrt(N*N-1);A=E=>{const $=Math.exp(-N*w*E),z=Math.min(D*E,300);return d-$*((T+N*w*j)*Math.sinh(z)+D*j*Math.cosh(z))/D}}const M={calculatedDuration:S&&_||null,next:D=>{const E=A(D);if(S)m.done=D>=_;else{let $=0;N<1&&($=D===0?Bs(T):Z_(A,D,E));const z=Math.abs($)<=o,K=Math.abs(d-E)<=c;m.done=z&&K}return m.value=m.done?d:E,m},toString:()=>{const D=Math.min(G_(M),cp),E=y_($=>M.next(D*$).value,D,30);return D+"ms "+E}};return M}function Q0({keyframes:t,velocity:s=0,power:i=.8,timeConstant:o=325,bounceDamping:c=10,bounceStiffness:u=500,modifyTarget:d,min:m,max:h,restDelta:g=.5,restSpeed:v}){const _=t[0],b={done:!1,value:_},S=z=>m!==void 0&&z<m||h!==void 0&&z>h,T=z=>m===void 0?h:h===void 0||Math.abs(m-z)<Math.abs(h-z)?m:h;let N=i*s;const j=_+N,w=d===void 0?j:d(j);w!==j&&(N=w-_);const C=z=>-N*Math.exp(-z/o),A=z=>w+C(z),M=z=>{const K=C(z),F=A(z);b.done=Math.abs(K)<=g,b.value=b.done?w:F};let D,E;const $=z=>{S(b.value)&&(D=z,E=K_({keyframes:[b.value,T(b.value)],velocity:Z_(A,z,b.value),damping:c,stiffness:u,restDelta:g,restSpeed:v}))};return $(0),{calculatedDuration:null,next:z=>{let K=!1;return!E&&D===void 0&&(K=!0,M(z),$(z)),D!==void 0&&z>=D?E.next(z-D):(!K&&M(z),b)}}}const JE=Or(.42,0,1,1),WE=Or(0,0,.58,1),Y_=Or(.42,0,.58,1),XE=t=>Array.isArray(t)&&typeof t[0]!="number",QE={linear:xn,easeIn:JE,easeInOut:Y_,easeOut:WE,circIn:am,circInOut:C_,circOut:j_,backIn:sm,backInOut:w_,backOut:k_,anticipate:N_},ey=t=>{if(nm(t)){Yb(t.length===4);const[s,i,o,c]=t;return Or(s,i,o,c)}else if(typeof t=="string")return QE[t];return t};function eA(t,s,i){const o=[],c=i||F_,u=t.length-1;for(let d=0;d<u;d++){let m=c(t[d],t[d+1]);if(s){const h=Array.isArray(s)?s[d]||xn:s;m=Br(h,m)}o.push(m)}return o}function tA(t,s,{clamp:i=!0,ease:o,mixer:c}={}){const u=t.length;if(Yb(u===s.length),u===1)return()=>s[0];if(u===2&&s[0]===s[1])return()=>s[1];const d=t[0]===t[1];t[0]>t[u-1]&&(t=[...t].reverse(),s=[...s].reverse());const m=eA(s,o,c),h=m.length,g=v=>{if(d&&v<t[0])return s[0];let _=0;if(h>1)for(;_<t.length-2&&!(v<t[_+1]);_++);const b=ro(t[_],t[_+1],v);return m[_](b)};return i?v=>g(Ps(t[0],t[u-1],v)):g}function nA(t,s){const i=t[t.length-1];for(let o=1;o<=s;o++){const c=ro(0,s,o);t.push(xt(i,1,c))}}function sA(t){const s=[0];return nA(s,t.length-1),s}function aA(t,s){return t.map(i=>i*s)}function iA(t,s){return t.map(()=>s||Y_).splice(0,t.length-1)}function Rc({duration:t=300,keyframes:s,times:i,ease:o="easeInOut"}){const c=XE(o)?o.map(ey):ey(o),u={done:!1,value:s[0]},d=aA(i&&i.length===s.length?i:sA(s),t),m=tA(d,s,{ease:Array.isArray(c)?c:iA(s,c)});return{calculatedDuration:t,next:h=>(u.value=m(h),u.done=h>=t,u)}}const oA=t=>{const s=({timestamp:i})=>t(i);return{start:()=>gt.update(s,!0),stop:()=>Ta(s),now:()=>Zt.isProcessing?Zt.timestamp:us.now()}},rA={decay:Q0,inertia:Q0,tween:Rc,keyframes:Rc,spring:K_},lA=t=>t/100;class um extends $_{constructor(s){super(s),this.holdTime=null,this.cancelTime=null,this.currentTime=0,this.playbackSpeed=1,this.pendingPlayState="running",this.startTime=null,this.state="idle",this.stop=()=>{if(this.resolver.cancel(),this.isStopped=!0,this.state==="idle")return;this.teardown();const{onStop:h}=this.options;h&&h()};const{name:i,motionValue:o,element:c,keyframes:u}=this.options,d=(c==null?void 0:c.KeyframeResolver)||lm,m=(h,g)=>this.onKeyframesResolved(h,g);this.resolver=new d(u,m,i,o,c),this.resolver.scheduleResolve()}flatten(){super.flatten(),this._resolved&&Object.assign(this._resolved,this.initPlayback(this._resolved.keyframes))}initPlayback(s){const{type:i="keyframes",repeat:o=0,repeatDelay:c=0,repeatType:u,velocity:d=0}=this.options,m=tm(i)?i:rA[i]||Rc;let h,g;m!==Rc&&typeof s[0]!="number"&&(h=Br(lA,F_(s[0],s[1])),s=[0,100]);const v=m({...this.options,keyframes:s});u==="mirror"&&(g=m({...this.options,keyframes:[...s].reverse(),velocity:-d})),v.calculatedDuration===null&&(v.calculatedDuration=G_(v));const{calculatedDuration:_}=v,b=_+c,S=b*(o+1)-c;return{generator:v,mirroredGenerator:g,mapPercentToKeyframes:h,calculatedDuration:_,resolvedDuration:b,totalDuration:S}}onPostResolved(){const{autoplay:s=!0}=this.options;this.play(),this.pendingPlayState==="paused"||!s?this.pause():this.state=this.pendingPlayState}tick(s,i=!1){const{resolved:o}=this;if(!o){const{keyframes:z}=this.options;return{done:!0,value:z[z.length-1]}}const{finalKeyframe:c,generator:u,mirroredGenerator:d,mapPercentToKeyframes:m,keyframes:h,calculatedDuration:g,totalDuration:v,resolvedDuration:_}=o;if(this.startTime===null)return u.next(0);const{delay:b,repeat:S,repeatType:T,repeatDelay:N,onUpdate:j}=this.options;this.speed>0?this.startTime=Math.min(this.startTime,s):this.speed<0&&(this.startTime=Math.min(s-v/this.speed,this.startTime)),i?this.currentTime=s:this.holdTime!==null?this.currentTime=this.holdTime:this.currentTime=Math.round(s-this.startTime)*this.speed;const w=this.currentTime-b*(this.speed>=0?1:-1),C=this.speed>=0?w<0:w>v;this.currentTime=Math.max(w,0),this.state==="finished"&&this.holdTime===null&&(this.currentTime=v);let A=this.currentTime,M=u;if(S){const z=Math.min(this.currentTime,v)/_;let K=Math.floor(z),F=z%1;!F&&z>=1&&(F=1),F===1&&K--,K=Math.min(K,S+1),!!(K%2)&&(T==="reverse"?(F=1-F,N&&(F-=N/_)):T==="mirror"&&(M=d)),A=Ps(0,1,F)*_}const D=C?{done:!1,value:h[0]}:M.next(A);m&&(D.value=m(D.value));let{done:E}=D;!C&&g!==null&&(E=this.speed>=0?this.currentTime>=v:this.currentTime<=0);const $=this.holdTime===null&&(this.state==="finished"||this.state==="running"&&E);return $&&c!==void 0&&(D.value=Xc(h,this.options,c)),j&&j(D.value),$&&this.finish(),D}get duration(){const{resolved:s}=this;return s?Ls(s.calculatedDuration):0}get time(){return Ls(this.currentTime)}set time(s){s=Bs(s),this.currentTime=s,this.holdTime!==null||this.speed===0?this.holdTime=s:this.driver&&(this.startTime=this.driver.now()-s/this.speed)}get speed(){return this.playbackSpeed}set speed(s){const i=this.playbackSpeed!==s;this.playbackSpeed=s,i&&(this.time=Ls(this.currentTime))}play(){if(this.resolver.isScheduled||this.resolver.resume(),!this._resolved){this.pendingPlayState="running";return}if(this.isStopped)return;const{driver:s=oA,onPlay:i,startTime:o}=this.options;this.driver||(this.driver=s(u=>this.tick(u))),i&&i();const c=this.driver.now();this.holdTime!==null?this.startTime=c-this.holdTime:this.startTime?this.state==="finished"&&(this.startTime=c):this.startTime=o??this.calcStartTime(),this.state==="finished"&&this.updateFinishedPromise(),this.cancelTime=this.startTime,this.holdTime=null,this.state="running",this.driver.start()}pause(){var s;if(!this._resolved){this.pendingPlayState="paused";return}this.state="paused",this.holdTime=(s=this.currentTime)!==null&&s!==void 0?s:0}complete(){this.state!=="running"&&this.play(),this.pendingPlayState=this.state="finished",this.holdTime=null}finish(){this.teardown(),this.state="finished";const{onComplete:s}=this.options;s&&s()}cancel(){this.cancelTime!==null&&this.tick(this.cancelTime),this.teardown(),this.updateFinishedPromise()}teardown(){this.state="idle",this.stopDriver(),this.resolveFinishedPromise(),this.updateFinishedPromise(),this.startTime=this.cancelTime=null,this.resolver.cancel()}stopDriver(){this.driver&&(this.driver.stop(),this.driver=void 0)}sample(s){return this.startTime=0,this.tick(s,!0)}}const cA=new Set(["opacity","clipPath","filter","transform"]);function uA(t,s,i,{delay:o=0,duration:c=300,repeat:u=0,repeatType:d="loop",ease:m="easeInOut",times:h}={}){const g={[s]:i};h&&(g.offset=h);const v=__(m,c);return Array.isArray(v)&&(g.easing=v),t.animate(g,{delay:o,duration:c,easing:Array.isArray(v)?"linear":v,fill:"both",iterations:u+1,direction:d==="reverse"?"alternate":"normal"})}const dA=em(()=>Object.hasOwnProperty.call(Element.prototype,"animate")),Mc=10,fA=2e4;function pA(t){return tm(t.type)||t.type==="spring"||!b_(t.ease)}function mA(t,s){const i=new um({...s,keyframes:t,repeat:0,delay:0,isGenerator:!0});let o={done:!1,value:t[0]};const c=[];let u=0;for(;!o.done&&u<fA;)o=i.sample(u),c.push(o.value),u+=Mc;return{times:void 0,keyframes:c,duration:u-Mc,ease:"linear"}}const J_={anticipate:N_,backInOut:w_,circInOut:C_};function hA(t){return t in J_}class ty extends $_{constructor(s){super(s);const{name:i,motionValue:o,element:c,keyframes:u}=this.options;this.resolver=new H_(u,(d,m)=>this.onKeyframesResolved(d,m),i,o,c),this.resolver.scheduleResolve()}initPlayback(s,i){let{duration:o=300,times:c,ease:u,type:d,motionValue:m,name:h,startTime:g}=this.options;if(!m.owner||!m.owner.current)return!1;if(typeof u=="string"&&Ac()&&hA(u)&&(u=J_[u]),pA(this.options)){const{onComplete:_,onUpdate:b,motionValue:S,element:T,...N}=this.options,j=mA(s,N);s=j.keyframes,s.length===1&&(s[1]=s[0]),o=j.duration,c=j.times,u=j.ease,d="keyframes"}const v=uA(m.owner.current,h,s,{...this.options,duration:o,times:c,ease:u});return v.startTime=g??this.calcStartTime(),this.pendingTimeline?($0(v,this.pendingTimeline),this.pendingTimeline=void 0):v.onfinish=()=>{const{onComplete:_}=this.options;m.set(Xc(s,this.options,i)),_&&_(),this.cancel(),this.resolveFinishedPromise()},{animation:v,duration:o,times:c,type:d,ease:u,keyframes:s}}get duration(){const{resolved:s}=this;if(!s)return 0;const{duration:i}=s;return Ls(i)}get time(){const{resolved:s}=this;if(!s)return 0;const{animation:i}=s;return Ls(i.currentTime||0)}set time(s){const{resolved:i}=this;if(!i)return;const{animation:o}=i;o.currentTime=Bs(s)}get speed(){const{resolved:s}=this;if(!s)return 1;const{animation:i}=s;return i.playbackRate}set speed(s){const{resolved:i}=this;if(!i)return;const{animation:o}=i;o.playbackRate=s}get state(){const{resolved:s}=this;if(!s)return"idle";const{animation:i}=s;return i.playState}get startTime(){const{resolved:s}=this;if(!s)return null;const{animation:i}=s;return i.startTime}attachTimeline(s){if(!this._resolved)this.pendingTimeline=s;else{const{resolved:i}=this;if(!i)return xn;const{animation:o}=i;$0(o,s)}return xn}play(){if(this.isStopped)return;const{resolved:s}=this;if(!s)return;const{animation:i}=s;i.playState==="finished"&&this.updateFinishedPromise(),i.play()}pause(){const{resolved:s}=this;if(!s)return;const{animation:i}=s;i.pause()}stop(){if(this.resolver.cancel(),this.isStopped=!0,this.state==="idle")return;this.resolveFinishedPromise(),this.updateFinishedPromise();const{resolved:s}=this;if(!s)return;const{animation:i,keyframes:o,duration:c,type:u,ease:d,times:m}=s;if(i.playState==="idle"||i.playState==="finished")return;if(this.time){const{motionValue:g,onUpdate:v,onComplete:_,element:b,...S}=this.options,T=new um({...S,keyframes:o,duration:c,type:u,ease:d,times:m,isGenerator:!0}),N=Bs(this.time);g.setWithVelocity(T.sample(N-Mc).value,T.sample(N).value,Mc)}const{onStop:h}=this.options;h&&h(),this.cancel()}complete(){const{resolved:s}=this;s&&s.animation.finish()}cancel(){const{resolved:s}=this;s&&s.animation.cancel()}static supports(s){const{motionValue:i,name:o,repeatDelay:c,repeatType:u,damping:d,type:m}=s;if(!i||!i.owner||!(i.owner.current instanceof HTMLElement))return!1;const{onUpdate:h,transformTemplate:g}=i.owner.getProps();return dA()&&o&&cA.has(o)&&!h&&!g&&!c&&u!=="mirror"&&d!==0&&m!=="inertia"}}const gA={type:"spring",stiffness:500,damping:25,restSpeed:10},vA=t=>({type:"spring",stiffness:550,damping:t===0?2*Math.sqrt(550):30,restSpeed:10}),yA={type:"keyframes",duration:.8},bA={type:"keyframes",ease:[.25,.1,.35,1],duration:.3},_A=(t,{keyframes:s})=>s.length>2?yA:ci.has(t)?t.startsWith("scale")?vA(s[1]):gA:bA;function xA({when:t,delay:s,delayChildren:i,staggerChildren:o,staggerDirection:c,repeat:u,repeatType:d,repeatDelay:m,from:h,elapsed:g,...v}){return!!Object.keys(v).length}const dm=(t,s,i,o={},c,u)=>d=>{const m=Jp(o,t)||{},h=m.delay||o.delay||0;let{elapsed:g=0}=o;g=g-Bs(h);let v={keyframes:Array.isArray(i)?i:[null,i],ease:"easeOut",velocity:s.getVelocity(),...m,delay:-g,onUpdate:b=>{s.set(b),m.onUpdate&&m.onUpdate(b)},onComplete:()=>{d(),m.onComplete&&m.onComplete()},name:t,motionValue:s,element:u?void 0:c};xA(m)||(v={...v,..._A(t,v)}),v.duration&&(v.duration=Bs(v.duration)),v.repeatDelay&&(v.repeatDelay=Bs(v.repeatDelay)),v.from!==void 0&&(v.keyframes[0]=v.from);let _=!1;if((v.type===!1||v.duration===0&&!v.repeatDelay)&&(v.duration=0,v.delay===0&&(_=!0)),_&&!u&&s.get()!==void 0){const b=Xc(v.keyframes,m);if(b!==void 0)return gt.update(()=>{v.onUpdate(b),v.onComplete()}),new QC([])}return!u&&ty.supports(v)?new ty(v):new um(v)};function SA({protectedKeys:t,needsAnimating:s},i){const o=t.hasOwnProperty(i)&&s[i]!==!0;return s[i]=!1,o}function W_(t,s,{delay:i=0,transitionOverride:o,type:c}={}){var u;let{transition:d=t.getDefaultTransition(),transitionEnd:m,...h}=s;o&&(d=o);const g=[],v=c&&t.animationState&&t.animationState.getState()[c];for(const _ in h){const b=t.getValue(_,(u=t.latestValues[_])!==null&&u!==void 0?u:null),S=h[_];if(S===void 0||v&&SA(v,_))continue;const T={delay:i,...Jp(d||{},_)};let N=!1;if(window.MotionHandoffAnimation){const w=v_(t);if(w){const C=window.MotionHandoffAnimation(w,_,gt);C!==null&&(T.startTime=C,N=!0)}}sp(t,_),b.start(dm(_,b,S,t.shouldReduceMotion&&h_.has(_)?{type:!1}:T,t,N));const j=b.animation;j&&g.push(j)}return m&&Promise.all(g).then(()=>{gt.update(()=>{m&&YC(t,m)})}),g}function fp(t,s,i={}){var o;const c=Wc(t,s,i.type==="exit"?(o=t.presenceContext)===null||o===void 0?void 0:o.custom:void 0);let{transition:u=t.getDefaultTransition()||{}}=c||{};i.transitionOverride&&(u=i.transitionOverride);const d=c?()=>Promise.all(W_(t,c,i)):()=>Promise.resolve(),m=t.variantChildren&&t.variantChildren.size?(g=0)=>{const{delayChildren:v=0,staggerChildren:_,staggerDirection:b}=u;return TA(t,s,v+g,_,b,i)}:()=>Promise.resolve(),{when:h}=u;if(h){const[g,v]=h==="beforeChildren"?[d,m]:[m,d];return g().then(()=>v())}else return Promise.all([d(),m(i.delay)])}function TA(t,s,i=0,o=0,c=1,u){const d=[],m=(t.variantChildren.size-1)*o,h=c===1?(g=0)=>g*o:(g=0)=>m-g*o;return Array.from(t.variantChildren).sort(kA).forEach((g,v)=>{g.notify("AnimationStart",s),d.push(fp(g,s,{...u,delay:i+h(v)}).then(()=>g.notify("AnimationComplete",s)))}),Promise.all(d)}function kA(t,s){return t.sortNodePosition(s)}function wA(t,s,i={}){t.notify("AnimationStart",s);let o;if(Array.isArray(s)){const c=s.map(u=>fp(t,u,i));o=Promise.all(c)}else if(typeof s=="string")o=fp(t,s,i);else{const c=typeof s=="function"?Wc(t,s,i.custom):s;o=Promise.all(W_(t,c,i))}return o.then(()=>{t.notify("AnimationComplete",s)})}const NA=Up.length;function X_(t){if(!t)return;if(!t.isControllingVariants){const i=t.parent?X_(t.parent)||{}:{};return t.props.initial!==void 0&&(i.initial=t.props.initial),i}const s={};for(let i=0;i<NA;i++){const o=Up[i],c=t.props[o];(jr(c)||c===!1)&&(s[o]=c)}return s}const jA=[...Lp].reverse(),CA=Lp.length;function EA(t){return s=>Promise.all(s.map(({animation:i,options:o})=>wA(t,i,o)))}function AA(t){let s=EA(t),i=ny(),o=!0;const c=h=>(g,v)=>{var _;const b=Wc(t,v,h==="exit"?(_=t.presenceContext)===null||_===void 0?void 0:_.custom:void 0);if(b){const{transition:S,transitionEnd:T,...N}=b;g={...g,...N,...T}}return g};function u(h){s=h(t)}function d(h){const{props:g}=t,v=X_(t.parent)||{},_=[],b=new Set;let S={},T=1/0;for(let j=0;j<CA;j++){const w=jA[j],C=i[w],A=g[w]!==void 0?g[w]:v[w],M=jr(A),D=w===h?C.isActive:null;D===!1&&(T=j);let E=A===v[w]&&A!==g[w]&&M;if(E&&o&&t.manuallyAnimateOnMount&&(E=!1),C.protectedKeys={...S},!C.isActive&&D===null||!A&&!C.prevProp||Yc(A)||typeof A=="boolean")continue;const $=DA(C.prevProp,A);let z=$||w===h&&C.isActive&&!E&&M||j>T&&M,K=!1;const F=Array.isArray(A)?A:[A];let ee=F.reduce(c(w),{});D===!1&&(ee={});const{prevResolvedValues:ae={}}=C,me={...ae,...ee},ie=q=>{z=!0,b.has(q)&&(K=!0,b.delete(q)),C.needsAnimating[q]=!0;const te=t.getValue(q);te&&(te.liveStyle=!1)};for(const q in me){const te=ee[q],re=ae[q];if(S.hasOwnProperty(q))continue;let ue=!1;np(te)&&np(re)?ue=!m_(te,re):ue=te!==re,ue?te!=null?ie(q):b.add(q):te!==void 0&&b.has(q)?ie(q):C.protectedKeys[q]=!0}C.prevProp=A,C.prevResolvedValues=ee,C.isActive&&(S={...S,...ee}),o&&t.blockInitialAnimation&&(z=!1),z&&(!(E&&$)||K)&&_.push(...F.map(q=>({animation:q,options:{type:w}})))}if(b.size){const j={};b.forEach(w=>{const C=t.getBaseTarget(w),A=t.getValue(w);A&&(A.liveStyle=!0),j[w]=C??null}),_.push({animation:j})}let N=!!_.length;return o&&(g.initial===!1||g.initial===g.animate)&&!t.manuallyAnimateOnMount&&(N=!1),o=!1,N?s(_):Promise.resolve()}function m(h,g){var v;if(i[h].isActive===g)return Promise.resolve();(v=t.variantChildren)===null||v===void 0||v.forEach(b=>{var S;return(S=b.animationState)===null||S===void 0?void 0:S.setActive(h,g)}),i[h].isActive=g;const _=d(h);for(const b in i)i[b].protectedKeys={};return _}return{animateChanges:d,setActive:m,setAnimateFunction:u,getState:()=>i,reset:()=>{i=ny(),o=!0}}}function DA(t,s){return typeof s=="string"?s!==t:Array.isArray(s)?!m_(s,t):!1}function Za(t=!1){return{isActive:t,protectedKeys:{},needsAnimating:{},prevResolvedValues:{}}}function ny(){return{animate:Za(!0),whileInView:Za(),whileHover:Za(),whileTap:Za(),whileDrag:Za(),whileFocus:Za(),exit:Za()}}class Na{constructor(s){this.isMounted=!1,this.node=s}update(){}}class RA extends Na{constructor(s){super(s),s.animationState||(s.animationState=AA(s))}updateAnimationControlsSubscription(){const{animate:s}=this.node.getProps();Yc(s)&&(this.unmountControls=s.subscribe(this.node))}mount(){this.updateAnimationControlsSubscription()}update(){const{animate:s}=this.node.getProps(),{animate:i}=this.node.prevProps||{};s!==i&&this.updateAnimationControlsSubscription()}unmount(){var s;this.node.animationState.reset(),(s=this.unmountControls)===null||s===void 0||s.call(this)}}let MA=0;class IA extends Na{constructor(){super(...arguments),this.id=MA++}update(){if(!this.node.presenceContext)return;const{isPresent:s,onExitComplete:i}=this.node.presenceContext,{isPresent:o}=this.node.prevPresenceContext||{};if(!this.node.animationState||s===o)return;const c=this.node.animationState.setActive("exit",!s);i&&!s&&c.then(()=>i(this.id))}mount(){const{register:s}=this.node.presenceContext||{};s&&(this.unmount=s(this.id))}unmount(){}}const OA={animation:{Feature:RA},exit:{Feature:IA}},Jn={x:!1,y:!1};function Q_(){return Jn.x||Jn.y}function BA(t){return t==="x"||t==="y"?Jn[t]?null:(Jn[t]=!0,()=>{Jn[t]=!1}):Jn.x||Jn.y?null:(Jn.x=Jn.y=!0,()=>{Jn.x=Jn.y=!1})}const fm=t=>t.pointerType==="mouse"?typeof t.button!="number"||t.button<=0:t.isPrimary!==!1;function Dr(t,s,i,o={passive:!0}){return t.addEventListener(s,i,o),()=>t.removeEventListener(s,i)}function Lr(t){return{point:{x:t.pageX,y:t.pageY}}}const LA=t=>s=>fm(s)&&t(s,Lr(s));function br(t,s,i,o){return Dr(t,s,LA(i),o)}const sy=(t,s)=>Math.abs(t-s);function UA(t,s){const i=sy(t.x,s.x),o=sy(t.y,s.y);return Math.sqrt(i**2+o**2)}class ex{constructor(s,i,{transformPagePoint:o,contextWindow:c,dragSnapToOrigin:u=!1}={}){if(this.startEvent=null,this.lastMoveEvent=null,this.lastMoveEventInfo=null,this.handlers={},this.contextWindow=window,this.updatePoint=()=>{if(!(this.lastMoveEvent&&this.lastMoveEventInfo))return;const _=Df(this.lastMoveEventInfo,this.history),b=this.startEvent!==null,S=UA(_.offset,{x:0,y:0})>=3;if(!b&&!S)return;const{point:T}=_,{timestamp:N}=Zt;this.history.push({...T,timestamp:N});const{onStart:j,onMove:w}=this.handlers;b||(j&&j(this.lastMoveEvent,_),this.startEvent=this.lastMoveEvent),w&&w(this.lastMoveEvent,_)},this.handlePointerMove=(_,b)=>{this.lastMoveEvent=_,this.lastMoveEventInfo=Af(b,this.transformPagePoint),gt.update(this.updatePoint,!0)},this.handlePointerUp=(_,b)=>{this.end();const{onEnd:S,onSessionEnd:T,resumeAnimation:N}=this.handlers;if(this.dragSnapToOrigin&&N&&N(),!(this.lastMoveEvent&&this.lastMoveEventInfo))return;const j=Df(_.type==="pointercancel"?this.lastMoveEventInfo:Af(b,this.transformPagePoint),this.history);this.startEvent&&S&&S(_,j),T&&T(_,j)},!fm(s))return;this.dragSnapToOrigin=u,this.handlers=i,this.transformPagePoint=o,this.contextWindow=c||window;const d=Lr(s),m=Af(d,this.transformPagePoint),{point:h}=m,{timestamp:g}=Zt;this.history=[{...h,timestamp:g}];const{onSessionStart:v}=i;v&&v(s,Df(m,this.history)),this.removeListeners=Br(br(this.contextWindow,"pointermove",this.handlePointerMove),br(this.contextWindow,"pointerup",this.handlePointerUp),br(this.contextWindow,"pointercancel",this.handlePointerUp))}updateHandlers(s){this.handlers=s}end(){this.removeListeners&&this.removeListeners(),Ta(this.updatePoint)}}function Af(t,s){return s?{point:s(t.point)}:t}function ay(t,s){return{x:t.x-s.x,y:t.y-s.y}}function Df({point:t},s){return{point:t,delta:ay(t,tx(s)),offset:ay(t,zA(s)),velocity:PA(s,.1)}}function zA(t){return t[0]}function tx(t){return t[t.length-1]}function PA(t,s){if(t.length<2)return{x:0,y:0};let i=t.length-1,o=null;const c=tx(t);for(;i>=0&&(o=t[i],!(c.timestamp-o.timestamp>Bs(s)));)i--;if(!o)return{x:0,y:0};const u=Ls(c.timestamp-o.timestamp);if(u===0)return{x:0,y:0};const d={x:(c.x-o.x)/u,y:(c.y-o.y)/u};return d.x===1/0&&(d.x=0),d.y===1/0&&(d.y=0),d}const nx=1e-4,VA=1-nx,HA=1+nx,sx=.01,$A=0-sx,GA=0+sx;function Sn(t){return t.max-t.min}function qA(t,s,i){return Math.abs(t-s)<=i}function iy(t,s,i,o=.5){t.origin=o,t.originPoint=xt(s.min,s.max,t.origin),t.scale=Sn(i)/Sn(s),t.translate=xt(i.min,i.max,t.origin)-t.originPoint,(t.scale>=VA&&t.scale<=HA||isNaN(t.scale))&&(t.scale=1),(t.translate>=$A&&t.translate<=GA||isNaN(t.translate))&&(t.translate=0)}function _r(t,s,i,o){iy(t.x,s.x,i.x,o?o.originX:void 0),iy(t.y,s.y,i.y,o?o.originY:void 0)}function oy(t,s,i){t.min=i.min+s.min,t.max=t.min+Sn(s)}function FA(t,s,i){oy(t.x,s.x,i.x),oy(t.y,s.y,i.y)}function ry(t,s,i){t.min=s.min-i.min,t.max=t.min+Sn(s)}function xr(t,s,i){ry(t.x,s.x,i.x),ry(t.y,s.y,i.y)}function ZA(t,{min:s,max:i},o){return s!==void 0&&t<s?t=o?xt(s,t,o.min):Math.max(t,s):i!==void 0&&t>i&&(t=o?xt(i,t,o.max):Math.min(t,i)),t}function ly(t,s,i){return{min:s!==void 0?t.min+s:void 0,max:i!==void 0?t.max+i-(t.max-t.min):void 0}}function KA(t,{top:s,left:i,bottom:o,right:c}){return{x:ly(t.x,i,c),y:ly(t.y,s,o)}}function cy(t,s){let i=s.min-t.min,o=s.max-t.max;return s.max-s.min<t.max-t.min&&([i,o]=[o,i]),{min:i,max:o}}function YA(t,s){return{x:cy(t.x,s.x),y:cy(t.y,s.y)}}function JA(t,s){let i=.5;const o=Sn(t),c=Sn(s);return c>o?i=ro(s.min,s.max-o,t.min):o>c&&(i=ro(t.min,t.max-c,s.min)),Ps(0,1,i)}function WA(t,s){const i={};return s.min!==void 0&&(i.min=s.min-t.min),s.max!==void 0&&(i.max=s.max-t.min),i}const pp=.35;function XA(t=pp){return t===!1?t=0:t===!0&&(t=pp),{x:uy(t,"left","right"),y:uy(t,"top","bottom")}}function uy(t,s,i){return{min:dy(t,s),max:dy(t,i)}}function dy(t,s){return typeof t=="number"?t:t[s]||0}const fy=()=>({translate:0,scale:1,origin:0,originPoint:0}),Qi=()=>({x:fy(),y:fy()}),py=()=>({min:0,max:0}),At=()=>({x:py(),y:py()});function Un(t){return[t("x"),t("y")]}function ax({top:t,left:s,right:i,bottom:o}){return{x:{min:s,max:i},y:{min:t,max:o}}}function QA({x:t,y:s}){return{top:s.min,right:t.max,bottom:s.max,left:t.min}}function eD(t,s){if(!s)return t;const i=s({x:t.left,y:t.top}),o=s({x:t.right,y:t.bottom});return{top:i.y,left:i.x,bottom:o.y,right:o.x}}function Rf(t){return t===void 0||t===1}function mp({scale:t,scaleX:s,scaleY:i}){return!Rf(t)||!Rf(s)||!Rf(i)}function Wa(t){return mp(t)||ix(t)||t.z||t.rotate||t.rotateX||t.rotateY||t.skewX||t.skewY}function ix(t){return my(t.x)||my(t.y)}function my(t){return t&&t!=="0%"}function Ic(t,s,i){const o=t-i,c=s*o;return i+c}function hy(t,s,i,o,c){return c!==void 0&&(t=Ic(t,c,o)),Ic(t,i,o)+s}function hp(t,s=0,i=1,o,c){t.min=hy(t.min,s,i,o,c),t.max=hy(t.max,s,i,o,c)}function ox(t,{x:s,y:i}){hp(t.x,s.translate,s.scale,s.originPoint),hp(t.y,i.translate,i.scale,i.originPoint)}const gy=.999999999999,vy=1.0000000000001;function tD(t,s,i,o=!1){const c=i.length;if(!c)return;s.x=s.y=1;let u,d;for(let m=0;m<c;m++){u=i[m],d=u.projectionDelta;const{visualElement:h}=u.options;h&&h.props.style&&h.props.style.display==="contents"||(o&&u.options.layoutScroll&&u.scroll&&u!==u.root&&to(t,{x:-u.scroll.offset.x,y:-u.scroll.offset.y}),d&&(s.x*=d.x.scale,s.y*=d.y.scale,ox(t,d)),o&&Wa(u.latestValues)&&to(t,u.latestValues))}s.x<vy&&s.x>gy&&(s.x=1),s.y<vy&&s.y>gy&&(s.y=1)}function eo(t,s){t.min=t.min+s,t.max=t.max+s}function yy(t,s,i,o,c=.5){const u=xt(t.min,t.max,c);hp(t,s,i,u,o)}function to(t,s){yy(t.x,s.x,s.scaleX,s.scale,s.originX),yy(t.y,s.y,s.scaleY,s.scale,s.originY)}function rx(t,s){return ax(eD(t.getBoundingClientRect(),s))}function nD(t,s,i){const o=rx(t,i),{scroll:c}=s;return c&&(eo(o.x,c.offset.x),eo(o.y,c.offset.y)),o}const lx=({current:t})=>t?t.ownerDocument.defaultView:null,sD=new WeakMap;class aD{constructor(s){this.openDragLock=null,this.isDragging=!1,this.currentDirection=null,this.originPoint={x:0,y:0},this.constraints=!1,this.hasMutatedConstraints=!1,this.elastic=At(),this.visualElement=s}start(s,{snapToCursor:i=!1}={}){const{presenceContext:o}=this.visualElement;if(o&&o.isPresent===!1)return;const c=v=>{const{dragSnapToOrigin:_}=this.getProps();_?this.pauseAnimation():this.stopAnimation(),i&&this.snapToCursor(Lr(v).point)},u=(v,_)=>{const{drag:b,dragPropagation:S,onDragStart:T}=this.getProps();if(b&&!S&&(this.openDragLock&&this.openDragLock(),this.openDragLock=BA(b),!this.openDragLock))return;this.isDragging=!0,this.currentDirection=null,this.resolveConstraints(),this.visualElement.projection&&(this.visualElement.projection.isAnimationBlocked=!0,this.visualElement.projection.target=void 0),Un(j=>{let w=this.getAxisMotionValue(j).get()||0;if(cs.test(w)){const{projection:C}=this.visualElement;if(C&&C.layout){const A=C.layout.layoutBox[j];A&&(w=Sn(A)*(parseFloat(w)/100))}}this.originPoint[j]=w}),T&&gt.postRender(()=>T(v,_)),sp(this.visualElement,"transform");const{animationState:N}=this.visualElement;N&&N.setActive("whileDrag",!0)},d=(v,_)=>{const{dragPropagation:b,dragDirectionLock:S,onDirectionLock:T,onDrag:N}=this.getProps();if(!b&&!this.openDragLock)return;const{offset:j}=_;if(S&&this.currentDirection===null){this.currentDirection=iD(j),this.currentDirection!==null&&T&&T(this.currentDirection);return}this.updateAxis("x",_.point,j),this.updateAxis("y",_.point,j),this.visualElement.render(),N&&N(v,_)},m=(v,_)=>this.stop(v,_),h=()=>Un(v=>{var _;return this.getAnimationState(v)==="paused"&&((_=this.getAxisMotionValue(v).animation)===null||_===void 0?void 0:_.play())}),{dragSnapToOrigin:g}=this.getProps();this.panSession=new ex(s,{onSessionStart:c,onStart:u,onMove:d,onSessionEnd:m,resumeAnimation:h},{transformPagePoint:this.visualElement.getTransformPagePoint(),dragSnapToOrigin:g,contextWindow:lx(this.visualElement)})}stop(s,i){const o=this.isDragging;if(this.cancel(),!o)return;const{velocity:c}=i;this.startAnimation(c);const{onDragEnd:u}=this.getProps();u&&gt.postRender(()=>u(s,i))}cancel(){this.isDragging=!1;const{projection:s,animationState:i}=this.visualElement;s&&(s.isAnimationBlocked=!1),this.panSession&&this.panSession.end(),this.panSession=void 0;const{dragPropagation:o}=this.getProps();!o&&this.openDragLock&&(this.openDragLock(),this.openDragLock=null),i&&i.setActive("whileDrag",!1)}updateAxis(s,i,o){const{drag:c}=this.getProps();if(!o||!dc(s,c,this.currentDirection))return;const u=this.getAxisMotionValue(s);let d=this.originPoint[s]+o[s];this.constraints&&this.constraints[s]&&(d=ZA(d,this.constraints[s],this.elastic[s])),u.set(d)}resolveConstraints(){var s;const{dragConstraints:i,dragElastic:o}=this.getProps(),c=this.visualElement.projection&&!this.visualElement.projection.layout?this.visualElement.projection.measure(!1):(s=this.visualElement.projection)===null||s===void 0?void 0:s.layout,u=this.constraints;i&&Wi(i)?this.constraints||(this.constraints=this.resolveRefConstraints()):i&&c?this.constraints=KA(c.layoutBox,i):this.constraints=!1,this.elastic=XA(o),u!==this.constraints&&c&&this.constraints&&!this.hasMutatedConstraints&&Un(d=>{this.constraints!==!1&&this.getAxisMotionValue(d)&&(this.constraints[d]=WA(c.layoutBox[d],this.constraints[d]))})}resolveRefConstraints(){const{dragConstraints:s,onMeasureDragConstraints:i}=this.getProps();if(!s||!Wi(s))return!1;const o=s.current,{projection:c}=this.visualElement;if(!c||!c.layout)return!1;const u=nD(o,c.root,this.visualElement.getTransformPagePoint());let d=YA(c.layout.layoutBox,u);if(i){const m=i(QA(d));this.hasMutatedConstraints=!!m,m&&(d=ax(m))}return d}startAnimation(s){const{drag:i,dragMomentum:o,dragElastic:c,dragTransition:u,dragSnapToOrigin:d,onDragTransitionEnd:m}=this.getProps(),h=this.constraints||{},g=Un(v=>{if(!dc(v,i,this.currentDirection))return;let _=h&&h[v]||{};d&&(_={min:0,max:0});const b=c?200:1e6,S=c?40:1e7,T={type:"inertia",velocity:o?s[v]:0,bounceStiffness:b,bounceDamping:S,timeConstant:750,restDelta:1,restSpeed:10,...u,..._};return this.startAxisValueAnimation(v,T)});return Promise.all(g).then(m)}startAxisValueAnimation(s,i){const o=this.getAxisMotionValue(s);return sp(this.visualElement,s),o.start(dm(s,o,0,i,this.visualElement,!1))}stopAnimation(){Un(s=>this.getAxisMotionValue(s).stop())}pauseAnimation(){Un(s=>{var i;return(i=this.getAxisMotionValue(s).animation)===null||i===void 0?void 0:i.pause()})}getAnimationState(s){var i;return(i=this.getAxisMotionValue(s).animation)===null||i===void 0?void 0:i.state}getAxisMotionValue(s){const i=`_drag${s.toUpperCase()}`,o=this.visualElement.getProps(),c=o[i];return c||this.visualElement.getValue(s,(o.initial?o.initial[s]:void 0)||0)}snapToCursor(s){Un(i=>{const{drag:o}=this.getProps();if(!dc(i,o,this.currentDirection))return;const{projection:c}=this.visualElement,u=this.getAxisMotionValue(i);if(c&&c.layout){const{min:d,max:m}=c.layout.layoutBox[i];u.set(s[i]-xt(d,m,.5))}})}scalePositionWithinConstraints(){if(!this.visualElement.current)return;const{drag:s,dragConstraints:i}=this.getProps(),{projection:o}=this.visualElement;if(!Wi(i)||!o||!this.constraints)return;this.stopAnimation();const c={x:0,y:0};Un(d=>{const m=this.getAxisMotionValue(d);if(m&&this.constraints!==!1){const h=m.get();c[d]=JA({min:h,max:h},this.constraints[d])}});const{transformTemplate:u}=this.visualElement.getProps();this.visualElement.current.style.transform=u?u({},""):"none",o.root&&o.root.updateScroll(),o.updateLayout(),this.resolveConstraints(),Un(d=>{if(!dc(d,s,null))return;const m=this.getAxisMotionValue(d),{min:h,max:g}=this.constraints[d];m.set(xt(h,g,c[d]))})}addListeners(){if(!this.visualElement.current)return;sD.set(this.visualElement,this);const s=this.visualElement.current,i=br(s,"pointerdown",h=>{const{drag:g,dragListener:v=!0}=this.getProps();g&&v&&this.start(h)}),o=()=>{const{dragConstraints:h}=this.getProps();Wi(h)&&h.current&&(this.constraints=this.resolveRefConstraints())},{projection:c}=this.visualElement,u=c.addEventListener("measure",o);c&&!c.layout&&(c.root&&c.root.updateScroll(),c.updateLayout()),gt.read(o);const d=Dr(window,"resize",()=>this.scalePositionWithinConstraints()),m=c.addEventListener("didUpdate",(({delta:h,hasLayoutChanged:g})=>{this.isDragging&&g&&(Un(v=>{const _=this.getAxisMotionValue(v);_&&(this.originPoint[v]+=h[v].translate,_.set(_.get()+h[v].translate))}),this.visualElement.render())}));return()=>{d(),i(),u(),m&&m()}}getProps(){const s=this.visualElement.getProps(),{drag:i=!1,dragDirectionLock:o=!1,dragPropagation:c=!1,dragConstraints:u=!1,dragElastic:d=pp,dragMomentum:m=!0}=s;return{...s,drag:i,dragDirectionLock:o,dragPropagation:c,dragConstraints:u,dragElastic:d,dragMomentum:m}}}function dc(t,s,i){return(s===!0||s===t)&&(i===null||i===t)}function iD(t,s=10){let i=null;return Math.abs(t.y)>s?i="y":Math.abs(t.x)>s&&(i="x"),i}class oD extends Na{constructor(s){super(s),this.removeGroupControls=xn,this.removeListeners=xn,this.controls=new aD(s)}mount(){const{dragControls:s}=this.node.getProps();s&&(this.removeGroupControls=s.subscribe(this.controls)),this.removeListeners=this.controls.addListeners()||xn}unmount(){this.removeGroupControls(),this.removeListeners()}}const by=t=>(s,i)=>{t&&gt.postRender(()=>t(s,i))};class rD extends Na{constructor(){super(...arguments),this.removePointerDownListener=xn}onPointerDown(s){this.session=new ex(s,this.createPanHandlers(),{transformPagePoint:this.node.getTransformPagePoint(),contextWindow:lx(this.node)})}createPanHandlers(){const{onPanSessionStart:s,onPanStart:i,onPan:o,onPanEnd:c}=this.node.getProps();return{onSessionStart:by(s),onStart:by(i),onMove:o,onEnd:(u,d)=>{delete this.session,c&&gt.postRender(()=>c(u,d))}}}mount(){this.removePointerDownListener=br(this.node.current,"pointerdown",s=>this.onPointerDown(s))}update(){this.session&&this.session.updateHandlers(this.createPanHandlers())}unmount(){this.removePointerDownListener(),this.session&&this.session.end()}}const Tc={hasAnimatedSinceResize:!0,hasEverUpdated:!1};function _y(t,s){return s.max===s.min?0:t/(s.max-s.min)*100}const cr={correct:(t,s)=>{if(!s.target)return t;if(typeof t=="string")if(we.test(t))t=parseFloat(t);else return t;const i=_y(t,s.target.x),o=_y(t,s.target.y);return`${i}% ${o}%`}},lD={correct:(t,{treeScale:s,projectionDelta:i})=>{const o=t,c=ka.parse(t);if(c.length>5)return o;const u=ka.createTransformer(t),d=typeof c[0]!="number"?1:0,m=i.x.scale*s.x,h=i.y.scale*s.y;c[0+d]/=m,c[1+d]/=h;const g=xt(m,h,.5);return typeof c[2+d]=="number"&&(c[2+d]/=g),typeof c[3+d]=="number"&&(c[3+d]/=g),u(c)}};class cD extends y.Component{componentDidMount(){const{visualElement:s,layoutGroup:i,switchLayoutGroup:o,layoutId:c}=this.props,{projection:u}=s;OC(uD),u&&(i.group&&i.group.add(u),o&&o.register&&c&&o.register(u),u.root.didUpdate(),u.addEventListener("animationComplete",()=>{this.safeToRemove()}),u.setOptions({...u.options,onExitComplete:()=>this.safeToRemove()})),Tc.hasEverUpdated=!0}getSnapshotBeforeUpdate(s){const{layoutDependency:i,visualElement:o,drag:c,isPresent:u}=this.props,d=o.projection;return d&&(d.isPresent=u,c||s.layoutDependency!==i||i===void 0?d.willUpdate():this.safeToRemove(),s.isPresent!==u&&(u?d.promote():d.relegate()||gt.postRender(()=>{const m=d.getStack();(!m||!m.members.length)&&this.safeToRemove()}))),null}componentDidUpdate(){const{projection:s}=this.props.visualElement;s&&(s.root.didUpdate(),Pp.postRender(()=>{!s.currentAnimation&&s.isLead()&&this.safeToRemove()}))}componentWillUnmount(){const{visualElement:s,layoutGroup:i,switchLayoutGroup:o}=this.props,{projection:c}=s;c&&(c.scheduleCheckAfterUnmount(),i&&i.group&&i.group.remove(c),o&&o.deregister&&o.deregister(c))}safeToRemove(){const{safeToRemove:s}=this.props;s&&s()}render(){return null}}function cx(t){const[s,i]=Zb(),o=y.useContext(Mp);return l.jsx(cD,{...t,layoutGroup:o,switchLayoutGroup:y.useContext(t_),isPresent:s,safeToRemove:i})}const uD={borderRadius:{...cr,applyTo:["borderTopLeftRadius","borderTopRightRadius","borderBottomLeftRadius","borderBottomRightRadius"]},borderTopLeftRadius:cr,borderTopRightRadius:cr,borderBottomLeftRadius:cr,borderBottomRightRadius:cr,boxShadow:lD};function dD(t,s,i){const o=Xt(t)?t:Er(t);return o.start(dm("",o,s,i)),o.animation}function fD(t){return t instanceof SVGElement&&t.tagName!=="svg"}const pD=(t,s)=>t.depth-s.depth;class mD{constructor(){this.children=[],this.isDirty=!1}add(s){Wp(this.children,s),this.isDirty=!0}remove(s){Xp(this.children,s),this.isDirty=!0}forEach(s){this.isDirty&&this.children.sort(pD),this.isDirty=!1,this.children.forEach(s)}}function hD(t,s){const i=us.now(),o=({timestamp:c})=>{const u=c-i;u>=s&&(Ta(o),t(u-s))};return gt.read(o,!0),()=>Ta(o)}const ux=["TopLeft","TopRight","BottomLeft","BottomRight"],gD=ux.length,xy=t=>typeof t=="string"?parseFloat(t):t,Sy=t=>typeof t=="number"||we.test(t);function vD(t,s,i,o,c,u){c?(t.opacity=xt(0,i.opacity!==void 0?i.opacity:1,yD(o)),t.opacityExit=xt(s.opacity!==void 0?s.opacity:1,0,bD(o))):u&&(t.opacity=xt(s.opacity!==void 0?s.opacity:1,i.opacity!==void 0?i.opacity:1,o));for(let d=0;d<gD;d++){const m=`border${ux[d]}Radius`;let h=Ty(s,m),g=Ty(i,m);if(h===void 0&&g===void 0)continue;h||(h=0),g||(g=0),h===0||g===0||Sy(h)===Sy(g)?(t[m]=Math.max(xt(xy(h),xy(g),o),0),(cs.test(g)||cs.test(h))&&(t[m]+="%")):t[m]=g}(s.rotate||i.rotate)&&(t.rotate=xt(s.rotate||0,i.rotate||0,o))}function Ty(t,s){return t[s]!==void 0?t[s]:t.borderRadius}const yD=dx(0,.5,j_),bD=dx(.5,.95,xn);function dx(t,s,i){return o=>o<t?0:o>s?1:i(ro(t,s,o))}function ky(t,s){t.min=s.min,t.max=s.max}function On(t,s){ky(t.x,s.x),ky(t.y,s.y)}function wy(t,s){t.translate=s.translate,t.scale=s.scale,t.originPoint=s.originPoint,t.origin=s.origin}function Ny(t,s,i,o,c){return t-=s,t=Ic(t,1/i,o),c!==void 0&&(t=Ic(t,1/c,o)),t}function _D(t,s=0,i=1,o=.5,c,u=t,d=t){if(cs.test(s)&&(s=parseFloat(s),s=xt(d.min,d.max,s/100)-d.min),typeof s!="number")return;let m=xt(u.min,u.max,o);t===u&&(m-=s),t.min=Ny(t.min,s,i,m,c),t.max=Ny(t.max,s,i,m,c)}function jy(t,s,[i,o,c],u,d){_D(t,s[i],s[o],s[c],s.scale,u,d)}const xD=["x","scaleX","originX"],SD=["y","scaleY","originY"];function Cy(t,s,i,o){jy(t.x,s,xD,i?i.x:void 0,o?o.x:void 0),jy(t.y,s,SD,i?i.y:void 0,o?o.y:void 0)}function Ey(t){return t.translate===0&&t.scale===1}function fx(t){return Ey(t.x)&&Ey(t.y)}function Ay(t,s){return t.min===s.min&&t.max===s.max}function TD(t,s){return Ay(t.x,s.x)&&Ay(t.y,s.y)}function Dy(t,s){return Math.round(t.min)===Math.round(s.min)&&Math.round(t.max)===Math.round(s.max)}function px(t,s){return Dy(t.x,s.x)&&Dy(t.y,s.y)}function Ry(t){return Sn(t.x)/Sn(t.y)}function My(t,s){return t.translate===s.translate&&t.scale===s.scale&&t.originPoint===s.originPoint}class kD{constructor(){this.members=[]}add(s){Wp(this.members,s),s.scheduleRender()}remove(s){if(Xp(this.members,s),s===this.prevLead&&(this.prevLead=void 0),s===this.lead){const i=this.members[this.members.length-1];i&&this.promote(i)}}relegate(s){const i=this.members.findIndex(c=>s===c);if(i===0)return!1;let o;for(let c=i;c>=0;c--){const u=this.members[c];if(u.isPresent!==!1){o=u;break}}return o?(this.promote(o),!0):!1}promote(s,i){const o=this.lead;if(s!==o&&(this.prevLead=o,this.lead=s,s.show(),o)){o.instance&&o.scheduleRender(),s.scheduleRender(),s.resumeFrom=o,i&&(s.resumeFrom.preserveOpacity=!0),o.snapshot&&(s.snapshot=o.snapshot,s.snapshot.latestValues=o.animationValues||o.latestValues),s.root&&s.root.isUpdating&&(s.isLayoutDirty=!0);const{crossfade:c}=s.options;c===!1&&o.hide()}}exitAnimationComplete(){this.members.forEach(s=>{const{options:i,resumingFrom:o}=s;i.onExitComplete&&i.onExitComplete(),o&&o.options.onExitComplete&&o.options.onExitComplete()})}scheduleRender(){this.members.forEach(s=>{s.instance&&s.scheduleRender(!1)})}removeLeadSnapshot(){this.lead&&this.lead.snapshot&&(this.lead.snapshot=void 0)}}function wD(t,s,i){let o="";const c=t.x.translate/s.x,u=t.y.translate/s.y,d=(i==null?void 0:i.z)||0;if((c||u||d)&&(o=`translate3d(${c}px, ${u}px, ${d}px) `),(s.x!==1||s.y!==1)&&(o+=`scale(${1/s.x}, ${1/s.y}) `),i){const{transformPerspective:g,rotate:v,rotateX:_,rotateY:b,skewX:S,skewY:T}=i;g&&(o=`perspective(${g}px) ${o}`),v&&(o+=`rotate(${v}deg) `),_&&(o+=`rotateX(${_}deg) `),b&&(o+=`rotateY(${b}deg) `),S&&(o+=`skewX(${S}deg) `),T&&(o+=`skewY(${T}deg) `)}const m=t.x.scale*s.x,h=t.y.scale*s.y;return(m!==1||h!==1)&&(o+=`scale(${m}, ${h})`),o||"none"}const Xa={type:"projectionFrame",totalNodes:0,resolvedTargetDeltas:0,recalculatedProjection:0},mr=typeof window<"u"&&window.MotionDebug!==void 0,Mf=["","X","Y","Z"],ND={visibility:"hidden"},Iy=1e3;let jD=0;function If(t,s,i,o){const{latestValues:c}=s;c[t]&&(i[t]=c[t],s.setStaticValue(t,0),o&&(o[t]=0))}function mx(t){if(t.hasCheckedOptimisedAppear=!0,t.root===t)return;const{visualElement:s}=t.options;if(!s)return;const i=v_(s);if(window.MotionHasOptimisedAnimation(i,"transform")){const{layout:c,layoutId:u}=t.options;window.MotionCancelOptimisedAnimation(i,"transform",gt,!(c||u))}const{parent:o}=t;o&&!o.hasCheckedOptimisedAppear&&mx(o)}function hx({attachResizeListener:t,defaultParent:s,measureScroll:i,checkIsScrollRoot:o,resetTransform:c}){return class{constructor(d={},m=s==null?void 0:s()){this.id=jD++,this.animationId=0,this.children=new Set,this.options={},this.isTreeAnimating=!1,this.isAnimationBlocked=!1,this.isLayoutDirty=!1,this.isProjectionDirty=!1,this.isSharedProjectionDirty=!1,this.isTransformDirty=!1,this.updateManuallyBlocked=!1,this.updateBlockedByResize=!1,this.isUpdating=!1,this.isSVG=!1,this.needsReset=!1,this.shouldResetTransform=!1,this.hasCheckedOptimisedAppear=!1,this.treeScale={x:1,y:1},this.eventHandlers=new Map,this.hasTreeAnimated=!1,this.updateScheduled=!1,this.scheduleUpdate=()=>this.update(),this.projectionUpdateScheduled=!1,this.checkUpdateFailed=()=>{this.isUpdating&&(this.isUpdating=!1,this.clearAllSnapshots())},this.updateProjection=()=>{this.projectionUpdateScheduled=!1,mr&&(Xa.totalNodes=Xa.resolvedTargetDeltas=Xa.recalculatedProjection=0),this.nodes.forEach(AD),this.nodes.forEach(OD),this.nodes.forEach(BD),this.nodes.forEach(DD),mr&&window.MotionDebug.record(Xa)},this.resolvedRelativeTargetAt=0,this.hasProjected=!1,this.isVisible=!0,this.animationProgress=0,this.sharedNodes=new Map,this.latestValues=d,this.root=m?m.root||m:this,this.path=m?[...m.path,m]:[],this.parent=m,this.depth=m?m.depth+1:0;for(let h=0;h<this.path.length;h++)this.path[h].shouldResetTransform=!0;this.root===this&&(this.nodes=new mD)}addEventListener(d,m){return this.eventHandlers.has(d)||this.eventHandlers.set(d,new Qp),this.eventHandlers.get(d).add(m)}notifyListeners(d,...m){const h=this.eventHandlers.get(d);h&&h.notify(...m)}hasListeners(d){return this.eventHandlers.has(d)}mount(d,m=this.root.hasTreeAnimated){if(this.instance)return;this.isSVG=fD(d),this.instance=d;const{layoutId:h,layout:g,visualElement:v}=this.options;if(v&&!v.current&&v.mount(d),this.root.nodes.add(this),this.parent&&this.parent.children.add(this),m&&(g||h)&&(this.isLayoutDirty=!0),t){let _;const b=()=>this.root.updateBlockedByResize=!1;t(d,()=>{this.root.updateBlockedByResize=!0,_&&_(),_=hD(b,250),Tc.hasAnimatedSinceResize&&(Tc.hasAnimatedSinceResize=!1,this.nodes.forEach(By))})}h&&this.root.registerSharedNode(h,this),this.options.animate!==!1&&v&&(h||g)&&this.addEventListener("didUpdate",({delta:_,hasLayoutChanged:b,hasRelativeTargetChanged:S,layout:T})=>{if(this.isTreeAnimationBlocked()){this.target=void 0,this.relativeTarget=void 0;return}const N=this.options.transition||v.getDefaultTransition()||VD,{onLayoutAnimationStart:j,onLayoutAnimationComplete:w}=v.getProps(),C=!this.targetLayout||!px(this.targetLayout,T)||S,A=!b&&S;if(this.options.layoutRoot||this.resumeFrom&&this.resumeFrom.instance||A||b&&(C||!this.currentAnimation)){this.resumeFrom&&(this.resumingFrom=this.resumeFrom,this.resumingFrom.resumingFrom=void 0),this.setAnimationOrigin(_,A);const M={...Jp(N,"layout"),onPlay:j,onComplete:w};(v.shouldReduceMotion||this.options.layoutRoot)&&(M.delay=0,M.type=!1),this.startAnimation(M)}else b||By(this),this.isLead()&&this.options.onExitComplete&&this.options.onExitComplete();this.targetLayout=T})}unmount(){this.options.layoutId&&this.willUpdate(),this.root.nodes.remove(this);const d=this.getStack();d&&d.remove(this),this.parent&&this.parent.children.delete(this),this.instance=void 0,Ta(this.updateProjection)}blockUpdate(){this.updateManuallyBlocked=!0}unblockUpdate(){this.updateManuallyBlocked=!1}isUpdateBlocked(){return this.updateManuallyBlocked||this.updateBlockedByResize}isTreeAnimationBlocked(){return this.isAnimationBlocked||this.parent&&this.parent.isTreeAnimationBlocked()||!1}startUpdate(){this.isUpdateBlocked()||(this.isUpdating=!0,this.nodes&&this.nodes.forEach(LD),this.animationId++)}getTransformTemplate(){const{visualElement:d}=this.options;return d&&d.getProps().transformTemplate}willUpdate(d=!0){if(this.root.hasTreeAnimated=!0,this.root.isUpdateBlocked()){this.options.onExitComplete&&this.options.onExitComplete();return}if(window.MotionCancelOptimisedAnimation&&!this.hasCheckedOptimisedAppear&&mx(this),!this.root.isUpdating&&this.root.startUpdate(),this.isLayoutDirty)return;this.isLayoutDirty=!0;for(let v=0;v<this.path.length;v++){const _=this.path[v];_.shouldResetTransform=!0,_.updateScroll("snapshot"),_.options.layoutRoot&&_.willUpdate(!1)}const{layoutId:m,layout:h}=this.options;if(m===void 0&&!h)return;const g=this.getTransformTemplate();this.prevTransformTemplateValue=g?g(this.latestValues,""):void 0,this.updateSnapshot(),d&&this.notifyListeners("willUpdate")}update(){if(this.updateScheduled=!1,this.isUpdateBlocked()){this.unblockUpdate(),this.clearAllSnapshots(),this.nodes.forEach(Oy);return}this.isUpdating||this.nodes.forEach(MD),this.isUpdating=!1,this.nodes.forEach(ID),this.nodes.forEach(CD),this.nodes.forEach(ED),this.clearAllSnapshots();const m=us.now();Zt.delta=Ps(0,1e3/60,m-Zt.timestamp),Zt.timestamp=m,Zt.isProcessing=!0,wf.update.process(Zt),wf.preRender.process(Zt),wf.render.process(Zt),Zt.isProcessing=!1}didUpdate(){this.updateScheduled||(this.updateScheduled=!0,Pp.read(this.scheduleUpdate))}clearAllSnapshots(){this.nodes.forEach(RD),this.sharedNodes.forEach(UD)}scheduleUpdateProjection(){this.projectionUpdateScheduled||(this.projectionUpdateScheduled=!0,gt.preRender(this.updateProjection,!1,!0))}scheduleCheckAfterUnmount(){gt.postRender(()=>{this.isLayoutDirty?this.root.didUpdate():this.root.checkUpdateFailed()})}updateSnapshot(){this.snapshot||!this.instance||(this.snapshot=this.measure())}updateLayout(){if(!this.instance||(this.updateScroll(),!(this.options.alwaysMeasureLayout&&this.isLead())&&!this.isLayoutDirty))return;if(this.resumeFrom&&!this.resumeFrom.instance)for(let h=0;h<this.path.length;h++)this.path[h].updateScroll();const d=this.layout;this.layout=this.measure(!1),this.layoutCorrected=At(),this.isLayoutDirty=!1,this.projectionDelta=void 0,this.notifyListeners("measure",this.layout.layoutBox);const{visualElement:m}=this.options;m&&m.notify("LayoutMeasure",this.layout.layoutBox,d?d.layoutBox:void 0)}updateScroll(d="measure"){let m=!!(this.options.layoutScroll&&this.instance);if(this.scroll&&this.scroll.animationId===this.root.animationId&&this.scroll.phase===d&&(m=!1),m){const h=o(this.instance);this.scroll={animationId:this.root.animationId,phase:d,isRoot:h,offset:i(this.instance),wasRoot:this.scroll?this.scroll.isRoot:h}}}resetTransform(){if(!c)return;const d=this.isLayoutDirty||this.shouldResetTransform||this.options.alwaysMeasureLayout,m=this.projectionDelta&&!fx(this.projectionDelta),h=this.getTransformTemplate(),g=h?h(this.latestValues,""):void 0,v=g!==this.prevTransformTemplateValue;d&&(m||Wa(this.latestValues)||v)&&(c(this.instance,g),this.shouldResetTransform=!1,this.scheduleRender())}measure(d=!0){const m=this.measurePageBox();let h=this.removeElementScroll(m);return d&&(h=this.removeTransform(h)),HD(h),{animationId:this.root.animationId,measuredBox:m,layoutBox:h,latestValues:{},source:this.id}}measurePageBox(){var d;const{visualElement:m}=this.options;if(!m)return At();const h=m.measureViewportBox();if(!(((d=this.scroll)===null||d===void 0?void 0:d.wasRoot)||this.path.some($D))){const{scroll:v}=this.root;v&&(eo(h.x,v.offset.x),eo(h.y,v.offset.y))}return h}removeElementScroll(d){var m;const h=At();if(On(h,d),!((m=this.scroll)===null||m===void 0)&&m.wasRoot)return h;for(let g=0;g<this.path.length;g++){const v=this.path[g],{scroll:_,options:b}=v;v!==this.root&&_&&b.layoutScroll&&(_.wasRoot&&On(h,d),eo(h.x,_.offset.x),eo(h.y,_.offset.y))}return h}applyTransform(d,m=!1){const h=At();On(h,d);for(let g=0;g<this.path.length;g++){const v=this.path[g];!m&&v.options.layoutScroll&&v.scroll&&v!==v.root&&to(h,{x:-v.scroll.offset.x,y:-v.scroll.offset.y}),Wa(v.latestValues)&&to(h,v.latestValues)}return Wa(this.latestValues)&&to(h,this.latestValues),h}removeTransform(d){const m=At();On(m,d);for(let h=0;h<this.path.length;h++){const g=this.path[h];if(!g.instance||!Wa(g.latestValues))continue;mp(g.latestValues)&&g.updateSnapshot();const v=At(),_=g.measurePageBox();On(v,_),Cy(m,g.latestValues,g.snapshot?g.snapshot.layoutBox:void 0,v)}return Wa(this.latestValues)&&Cy(m,this.latestValues),m}setTargetDelta(d){this.targetDelta=d,this.root.scheduleUpdateProjection(),this.isProjectionDirty=!0}setOptions(d){this.options={...this.options,...d,crossfade:d.crossfade!==void 0?d.crossfade:!0}}clearMeasurements(){this.scroll=void 0,this.layout=void 0,this.snapshot=void 0,this.prevTransformTemplateValue=void 0,this.targetDelta=void 0,this.target=void 0,this.isLayoutDirty=!1}forceRelativeParentToResolveTarget(){this.relativeParent&&this.relativeParent.resolvedRelativeTargetAt!==Zt.timestamp&&this.relativeParent.resolveTargetDelta(!0)}resolveTargetDelta(d=!1){var m;const h=this.getLead();this.isProjectionDirty||(this.isProjectionDirty=h.isProjectionDirty),this.isTransformDirty||(this.isTransformDirty=h.isTransformDirty),this.isSharedProjectionDirty||(this.isSharedProjectionDirty=h.isSharedProjectionDirty);const g=!!this.resumingFrom||this!==h;if(!(d||g&&this.isSharedProjectionDirty||this.isProjectionDirty||!((m=this.parent)===null||m===void 0)&&m.isProjectionDirty||this.attemptToResolveRelativeTarget||this.root.updateBlockedByResize))return;const{layout:_,layoutId:b}=this.options;if(!(!this.layout||!(_||b))){if(this.resolvedRelativeTargetAt=Zt.timestamp,!this.targetDelta&&!this.relativeTarget){const S=this.getClosestProjectingParent();S&&S.layout&&this.animationProgress!==1?(this.relativeParent=S,this.forceRelativeParentToResolveTarget(),this.relativeTarget=At(),this.relativeTargetOrigin=At(),xr(this.relativeTargetOrigin,this.layout.layoutBox,S.layout.layoutBox),On(this.relativeTarget,this.relativeTargetOrigin)):this.relativeParent=this.relativeTarget=void 0}if(!(!this.relativeTarget&&!this.targetDelta)){if(this.target||(this.target=At(),this.targetWithTransforms=At()),this.relativeTarget&&this.relativeTargetOrigin&&this.relativeParent&&this.relativeParent.target?(this.forceRelativeParentToResolveTarget(),FA(this.target,this.relativeTarget,this.relativeParent.target)):this.targetDelta?(this.resumingFrom?this.target=this.applyTransform(this.layout.layoutBox):On(this.target,this.layout.layoutBox),ox(this.target,this.targetDelta)):On(this.target,this.layout.layoutBox),this.attemptToResolveRelativeTarget){this.attemptToResolveRelativeTarget=!1;const S=this.getClosestProjectingParent();S&&!!S.resumingFrom==!!this.resumingFrom&&!S.options.layoutScroll&&S.target&&this.animationProgress!==1?(this.relativeParent=S,this.forceRelativeParentToResolveTarget(),this.relativeTarget=At(),this.relativeTargetOrigin=At(),xr(this.relativeTargetOrigin,this.target,S.target),On(this.relativeTarget,this.relativeTargetOrigin)):this.relativeParent=this.relativeTarget=void 0}mr&&Xa.resolvedTargetDeltas++}}}getClosestProjectingParent(){if(!(!this.parent||mp(this.parent.latestValues)||ix(this.parent.latestValues)))return this.parent.isProjecting()?this.parent:this.parent.getClosestProjectingParent()}isProjecting(){return!!((this.relativeTarget||this.targetDelta||this.options.layoutRoot)&&this.layout)}calcProjection(){var d;const m=this.getLead(),h=!!this.resumingFrom||this!==m;let g=!0;if((this.isProjectionDirty||!((d=this.parent)===null||d===void 0)&&d.isProjectionDirty)&&(g=!1),h&&(this.isSharedProjectionDirty||this.isTransformDirty)&&(g=!1),this.resolvedRelativeTargetAt===Zt.timestamp&&(g=!1),g)return;const{layout:v,layoutId:_}=this.options;if(this.isTreeAnimating=!!(this.parent&&this.parent.isTreeAnimating||this.currentAnimation||this.pendingAnimation),this.isTreeAnimating||(this.targetDelta=this.relativeTarget=void 0),!this.layout||!(v||_))return;On(this.layoutCorrected,this.layout.layoutBox);const b=this.treeScale.x,S=this.treeScale.y;tD(this.layoutCorrected,this.treeScale,this.path,h),m.layout&&!m.target&&(this.treeScale.x!==1||this.treeScale.y!==1)&&(m.target=m.layout.layoutBox,m.targetWithTransforms=At());const{target:T}=m;if(!T){this.prevProjectionDelta&&(this.createProjectionDeltas(),this.scheduleRender());return}!this.projectionDelta||!this.prevProjectionDelta?this.createProjectionDeltas():(wy(this.prevProjectionDelta.x,this.projectionDelta.x),wy(this.prevProjectionDelta.y,this.projectionDelta.y)),_r(this.projectionDelta,this.layoutCorrected,T,this.latestValues),(this.treeScale.x!==b||this.treeScale.y!==S||!My(this.projectionDelta.x,this.prevProjectionDelta.x)||!My(this.projectionDelta.y,this.prevProjectionDelta.y))&&(this.hasProjected=!0,this.scheduleRender(),this.notifyListeners("projectionUpdate",T)),mr&&Xa.recalculatedProjection++}hide(){this.isVisible=!1}show(){this.isVisible=!0}scheduleRender(d=!0){var m;if((m=this.options.visualElement)===null||m===void 0||m.scheduleRender(),d){const h=this.getStack();h&&h.scheduleRender()}this.resumingFrom&&!this.resumingFrom.instance&&(this.resumingFrom=void 0)}createProjectionDeltas(){this.prevProjectionDelta=Qi(),this.projectionDelta=Qi(),this.projectionDeltaWithTransform=Qi()}setAnimationOrigin(d,m=!1){const h=this.snapshot,g=h?h.latestValues:{},v={...this.latestValues},_=Qi();(!this.relativeParent||!this.relativeParent.options.layoutRoot)&&(this.relativeTarget=this.relativeTargetOrigin=void 0),this.attemptToResolveRelativeTarget=!m;const b=At(),S=h?h.source:void 0,T=this.layout?this.layout.source:void 0,N=S!==T,j=this.getStack(),w=!j||j.members.length<=1,C=!!(N&&!w&&this.options.crossfade===!0&&!this.path.some(PD));this.animationProgress=0;let A;this.mixTargetDelta=M=>{const D=M/1e3;Ly(_.x,d.x,D),Ly(_.y,d.y,D),this.setTargetDelta(_),this.relativeTarget&&this.relativeTargetOrigin&&this.layout&&this.relativeParent&&this.relativeParent.layout&&(xr(b,this.layout.layoutBox,this.relativeParent.layout.layoutBox),zD(this.relativeTarget,this.relativeTargetOrigin,b,D),A&&TD(this.relativeTarget,A)&&(this.isProjectionDirty=!1),A||(A=At()),On(A,this.relativeTarget)),N&&(this.animationValues=v,vD(v,g,this.latestValues,D,C,w)),this.root.scheduleUpdateProjection(),this.scheduleRender(),this.animationProgress=D},this.mixTargetDelta(this.options.layoutRoot?1e3:0)}startAnimation(d){this.notifyListeners("animationStart"),this.currentAnimation&&this.currentAnimation.stop(),this.resumingFrom&&this.resumingFrom.currentAnimation&&this.resumingFrom.currentAnimation.stop(),this.pendingAnimation&&(Ta(this.pendingAnimation),this.pendingAnimation=void 0),this.pendingAnimation=gt.update(()=>{Tc.hasAnimatedSinceResize=!0,this.currentAnimation=dD(0,Iy,{...d,onUpdate:m=>{this.mixTargetDelta(m),d.onUpdate&&d.onUpdate(m)},onComplete:()=>{d.onComplete&&d.onComplete(),this.completeAnimation()}}),this.resumingFrom&&(this.resumingFrom.currentAnimation=this.currentAnimation),this.pendingAnimation=void 0})}completeAnimation(){this.resumingFrom&&(this.resumingFrom.currentAnimation=void 0,this.resumingFrom.preserveOpacity=void 0);const d=this.getStack();d&&d.exitAnimationComplete(),this.resumingFrom=this.currentAnimation=this.animationValues=void 0,this.notifyListeners("animationComplete")}finishAnimation(){this.currentAnimation&&(this.mixTargetDelta&&this.mixTargetDelta(Iy),this.currentAnimation.stop()),this.completeAnimation()}applyTransformsToTarget(){const d=this.getLead();let{targetWithTransforms:m,target:h,layout:g,latestValues:v}=d;if(!(!m||!h||!g)){if(this!==d&&this.layout&&g&&gx(this.options.animationType,this.layout.layoutBox,g.layoutBox)){h=this.target||At();const _=Sn(this.layout.layoutBox.x);h.x.min=d.target.x.min,h.x.max=h.x.min+_;const b=Sn(this.layout.layoutBox.y);h.y.min=d.target.y.min,h.y.max=h.y.min+b}On(m,h),to(m,v),_r(this.projectionDeltaWithTransform,this.layoutCorrected,m,v)}}registerSharedNode(d,m){this.sharedNodes.has(d)||this.sharedNodes.set(d,new kD),this.sharedNodes.get(d).add(m);const g=m.options.initialPromotionConfig;m.promote({transition:g?g.transition:void 0,preserveFollowOpacity:g&&g.shouldPreserveFollowOpacity?g.shouldPreserveFollowOpacity(m):void 0})}isLead(){const d=this.getStack();return d?d.lead===this:!0}getLead(){var d;const{layoutId:m}=this.options;return m?((d=this.getStack())===null||d===void 0?void 0:d.lead)||this:this}getPrevLead(){var d;const{layoutId:m}=this.options;return m?(d=this.getStack())===null||d===void 0?void 0:d.prevLead:void 0}getStack(){const{layoutId:d}=this.options;if(d)return this.root.sharedNodes.get(d)}promote({needsReset:d,transition:m,preserveFollowOpacity:h}={}){const g=this.getStack();g&&g.promote(this,h),d&&(this.projectionDelta=void 0,this.needsReset=!0),m&&this.setOptions({transition:m})}relegate(){const d=this.getStack();return d?d.relegate(this):!1}resetSkewAndRotation(){const{visualElement:d}=this.options;if(!d)return;let m=!1;const{latestValues:h}=d;if((h.z||h.rotate||h.rotateX||h.rotateY||h.rotateZ||h.skewX||h.skewY)&&(m=!0),!m)return;const g={};h.z&&If("z",d,g,this.animationValues);for(let v=0;v<Mf.length;v++)If(`rotate${Mf[v]}`,d,g,this.animationValues),If(`skew${Mf[v]}`,d,g,this.animationValues);d.render();for(const v in g)d.setStaticValue(v,g[v]),this.animationValues&&(this.animationValues[v]=g[v]);d.scheduleRender()}getProjectionStyles(d){var m,h;if(!this.instance||this.isSVG)return;if(!this.isVisible)return ND;const g={visibility:""},v=this.getTransformTemplate();if(this.needsReset)return this.needsReset=!1,g.opacity="",g.pointerEvents=xc(d==null?void 0:d.pointerEvents)||"",g.transform=v?v(this.latestValues,""):"none",g;const _=this.getLead();if(!this.projectionDelta||!this.layout||!_.target){const N={};return this.options.layoutId&&(N.opacity=this.latestValues.opacity!==void 0?this.latestValues.opacity:1,N.pointerEvents=xc(d==null?void 0:d.pointerEvents)||""),this.hasProjected&&!Wa(this.latestValues)&&(N.transform=v?v({},""):"none",this.hasProjected=!1),N}const b=_.animationValues||_.latestValues;this.applyTransformsToTarget(),g.transform=wD(this.projectionDeltaWithTransform,this.treeScale,b),v&&(g.transform=v(b,g.transform));const{x:S,y:T}=this.projectionDelta;g.transformOrigin=`${S.origin*100}% ${T.origin*100}% 0`,_.animationValues?g.opacity=_===this?(h=(m=b.opacity)!==null&&m!==void 0?m:this.latestValues.opacity)!==null&&h!==void 0?h:1:this.preserveOpacity?this.latestValues.opacity:b.opacityExit:g.opacity=_===this?b.opacity!==void 0?b.opacity:"":b.opacityExit!==void 0?b.opacityExit:0;for(const N in Ec){if(b[N]===void 0)continue;const{correct:j,applyTo:w}=Ec[N],C=g.transform==="none"?b[N]:j(b[N],_);if(w){const A=w.length;for(let M=0;M<A;M++)g[w[M]]=C}else g[N]=C}return this.options.layoutId&&(g.pointerEvents=_===this?xc(d==null?void 0:d.pointerEvents)||"":"none"),g}clearSnapshot(){this.resumeFrom=this.snapshot=void 0}resetTree(){this.root.nodes.forEach(d=>{var m;return(m=d.currentAnimation)===null||m===void 0?void 0:m.stop()}),this.root.nodes.forEach(Oy),this.root.sharedNodes.clear()}}}function CD(t){t.updateLayout()}function ED(t){var s;const i=((s=t.resumeFrom)===null||s===void 0?void 0:s.snapshot)||t.snapshot;if(t.isLead()&&t.layout&&i&&t.hasListeners("didUpdate")){const{layoutBox:o,measuredBox:c}=t.layout,{animationType:u}=t.options,d=i.source!==t.layout.source;u==="size"?Un(_=>{const b=d?i.measuredBox[_]:i.layoutBox[_],S=Sn(b);b.min=o[_].min,b.max=b.min+S}):gx(u,i.layoutBox,o)&&Un(_=>{const b=d?i.measuredBox[_]:i.layoutBox[_],S=Sn(o[_]);b.max=b.min+S,t.relativeTarget&&!t.currentAnimation&&(t.isProjectionDirty=!0,t.relativeTarget[_].max=t.relativeTarget[_].min+S)});const m=Qi();_r(m,o,i.layoutBox);const h=Qi();d?_r(h,t.applyTransform(c,!0),i.measuredBox):_r(h,o,i.layoutBox);const g=!fx(m);let v=!1;if(!t.resumeFrom){const _=t.getClosestProjectingParent();if(_&&!_.resumeFrom){const{snapshot:b,layout:S}=_;if(b&&S){const T=At();xr(T,i.layoutBox,b.layoutBox);const N=At();xr(N,o,S.layoutBox),px(T,N)||(v=!0),_.options.layoutRoot&&(t.relativeTarget=N,t.relativeTargetOrigin=T,t.relativeParent=_)}}}t.notifyListeners("didUpdate",{layout:o,snapshot:i,delta:h,layoutDelta:m,hasLayoutChanged:g,hasRelativeTargetChanged:v})}else if(t.isLead()){const{onExitComplete:o}=t.options;o&&o()}t.options.transition=void 0}function AD(t){mr&&Xa.totalNodes++,t.parent&&(t.isProjecting()||(t.isProjectionDirty=t.parent.isProjectionDirty),t.isSharedProjectionDirty||(t.isSharedProjectionDirty=!!(t.isProjectionDirty||t.parent.isProjectionDirty||t.parent.isSharedProjectionDirty)),t.isTransformDirty||(t.isTransformDirty=t.parent.isTransformDirty))}function DD(t){t.isProjectionDirty=t.isSharedProjectionDirty=t.isTransformDirty=!1}function RD(t){t.clearSnapshot()}function Oy(t){t.clearMeasurements()}function MD(t){t.isLayoutDirty=!1}function ID(t){const{visualElement:s}=t.options;s&&s.getProps().onBeforeLayoutMeasure&&s.notify("BeforeLayoutMeasure"),t.resetTransform()}function By(t){t.finishAnimation(),t.targetDelta=t.relativeTarget=t.target=void 0,t.isProjectionDirty=!0}function OD(t){t.resolveTargetDelta()}function BD(t){t.calcProjection()}function LD(t){t.resetSkewAndRotation()}function UD(t){t.removeLeadSnapshot()}function Ly(t,s,i){t.translate=xt(s.translate,0,i),t.scale=xt(s.scale,1,i),t.origin=s.origin,t.originPoint=s.originPoint}function Uy(t,s,i,o){t.min=xt(s.min,i.min,o),t.max=xt(s.max,i.max,o)}function zD(t,s,i,o){Uy(t.x,s.x,i.x,o),Uy(t.y,s.y,i.y,o)}function PD(t){return t.animationValues&&t.animationValues.opacityExit!==void 0}const VD={duration:.45,ease:[.4,0,.1,1]},zy=t=>typeof navigator<"u"&&navigator.userAgent&&navigator.userAgent.toLowerCase().includes(t),Py=zy("applewebkit/")&&!zy("chrome/")?Math.round:xn;function Vy(t){t.min=Py(t.min),t.max=Py(t.max)}function HD(t){Vy(t.x),Vy(t.y)}function gx(t,s,i){return t==="position"||t==="preserve-aspect"&&!qA(Ry(s),Ry(i),.2)}function $D(t){var s;return t!==t.root&&((s=t.scroll)===null||s===void 0?void 0:s.wasRoot)}const GD=hx({attachResizeListener:(t,s)=>Dr(t,"resize",s),measureScroll:()=>({x:document.documentElement.scrollLeft||document.body.scrollLeft,y:document.documentElement.scrollTop||document.body.scrollTop}),checkIsScrollRoot:()=>!0}),Of={current:void 0},vx=hx({measureScroll:t=>({x:t.scrollLeft,y:t.scrollTop}),defaultParent:()=>{if(!Of.current){const t=new GD({});t.mount(window),t.setOptions({layoutScroll:!0}),Of.current=t}return Of.current},resetTransform:(t,s)=>{t.style.transform=s!==void 0?s:"none"},checkIsScrollRoot:t=>window.getComputedStyle(t).position==="fixed"}),qD={pan:{Feature:rD},drag:{Feature:oD,ProjectionNode:vx,MeasureLayout:cx}};function FD(t,s,i){var o;if(t instanceof Element)return[t];if(typeof t=="string"){let c=document;const u=(o=void 0)!==null&&o!==void 0?o:c.querySelectorAll(t);return u?Array.from(u):[]}return Array.from(t)}function yx(t,s){const i=FD(t),o=new AbortController,c={passive:!0,...s,signal:o.signal};return[i,c,()=>o.abort()]}function Hy(t){return s=>{s.pointerType==="touch"||Q_()||t(s)}}function ZD(t,s,i={}){const[o,c,u]=yx(t,i),d=Hy(m=>{const{target:h}=m,g=s(m);if(typeof g!="function"||!h)return;const v=Hy(_=>{g(_),h.removeEventListener("pointerleave",v)});h.addEventListener("pointerleave",v,c)});return o.forEach(m=>{m.addEventListener("pointerenter",d,c)}),u}function $y(t,s,i){const{props:o}=t;t.animationState&&o.whileHover&&t.animationState.setActive("whileHover",i==="Start");const c="onHover"+i,u=o[c];u&&gt.postRender(()=>u(s,Lr(s)))}class KD extends Na{mount(){const{current:s}=this.node;s&&(this.unmount=ZD(s,i=>($y(this.node,i,"Start"),o=>$y(this.node,o,"End"))))}unmount(){}}class YD extends Na{constructor(){super(...arguments),this.isActive=!1}onFocus(){let s=!1;try{s=this.node.current.matches(":focus-visible")}catch{s=!0}!s||!this.node.animationState||(this.node.animationState.setActive("whileFocus",!0),this.isActive=!0)}onBlur(){!this.isActive||!this.node.animationState||(this.node.animationState.setActive("whileFocus",!1),this.isActive=!1)}mount(){this.unmount=Br(Dr(this.node.current,"focus",()=>this.onFocus()),Dr(this.node.current,"blur",()=>this.onBlur()))}unmount(){}}const bx=(t,s)=>s?t===s?!0:bx(t,s.parentElement):!1,JD=new Set(["BUTTON","INPUT","SELECT","TEXTAREA","A"]);function WD(t){return JD.has(t.tagName)||t.tabIndex!==-1}const hr=new WeakSet;function Gy(t){return s=>{s.key==="Enter"&&t(s)}}function Bf(t,s){t.dispatchEvent(new PointerEvent("pointer"+s,{isPrimary:!0,bubbles:!0}))}const XD=(t,s)=>{const i=t.currentTarget;if(!i)return;const o=Gy(()=>{if(hr.has(i))return;Bf(i,"down");const c=Gy(()=>{Bf(i,"up")}),u=()=>Bf(i,"cancel");i.addEventListener("keyup",c,s),i.addEventListener("blur",u,s)});i.addEventListener("keydown",o,s),i.addEventListener("blur",()=>i.removeEventListener("keydown",o),s)};function qy(t){return fm(t)&&!Q_()}function QD(t,s,i={}){const[o,c,u]=yx(t,i),d=m=>{const h=m.currentTarget;if(!qy(m)||hr.has(h))return;hr.add(h);const g=s(m),v=(S,T)=>{window.removeEventListener("pointerup",_),window.removeEventListener("pointercancel",b),!(!qy(S)||!hr.has(h))&&(hr.delete(h),typeof g=="function"&&g(S,{success:T}))},_=S=>{v(S,i.useGlobalTarget||bx(h,S.target))},b=S=>{v(S,!1)};window.addEventListener("pointerup",_,c),window.addEventListener("pointercancel",b,c)};return o.forEach(m=>{!WD(m)&&m.getAttribute("tabindex")===null&&(m.tabIndex=0),(i.useGlobalTarget?window:m).addEventListener("pointerdown",d,c),m.addEventListener("focus",g=>XD(g,c),c)}),u}function Fy(t,s,i){const{props:o}=t;t.animationState&&o.whileTap&&t.animationState.setActive("whileTap",i==="Start");const c="onTap"+(i==="End"?"":i),u=o[c];u&&gt.postRender(()=>u(s,Lr(s)))}class eR extends Na{mount(){const{current:s}=this.node;s&&(this.unmount=QD(s,i=>(Fy(this.node,i,"Start"),(o,{success:c})=>Fy(this.node,o,c?"End":"Cancel")),{useGlobalTarget:this.node.props.globalTapTarget}))}unmount(){}}const gp=new WeakMap,Lf=new WeakMap,tR=t=>{const s=gp.get(t.target);s&&s(t)},nR=t=>{t.forEach(tR)};function sR({root:t,...s}){const i=t||document;Lf.has(i)||Lf.set(i,{});const o=Lf.get(i),c=JSON.stringify(s);return o[c]||(o[c]=new IntersectionObserver(nR,{root:t,...s})),o[c]}function aR(t,s,i){const o=sR(s);return gp.set(t,i),o.observe(t),()=>{gp.delete(t),o.unobserve(t)}}const iR={some:0,all:1};class oR extends Na{constructor(){super(...arguments),this.hasEnteredView=!1,this.isInView=!1}startObserver(){this.unmount();const{viewport:s={}}=this.node.getProps(),{root:i,margin:o,amount:c="some",once:u}=s,d={root:i?i.current:void 0,rootMargin:o,threshold:typeof c=="number"?c:iR[c]},m=h=>{const{isIntersecting:g}=h;if(this.isInView===g||(this.isInView=g,u&&!g&&this.hasEnteredView))return;g&&(this.hasEnteredView=!0),this.node.animationState&&this.node.animationState.setActive("whileInView",g);const{onViewportEnter:v,onViewportLeave:_}=this.node.getProps(),b=g?v:_;b&&b(h)};return aR(this.node.current,d,m)}mount(){this.startObserver()}update(){if(typeof IntersectionObserver>"u")return;const{props:s,prevProps:i}=this.node;["amount","margin","root"].some(rR(s,i))&&this.startObserver()}unmount(){}}function rR({viewport:t={}},{viewport:s={}}={}){return i=>t[i]!==s[i]}const lR={inView:{Feature:oR},tap:{Feature:eR},focus:{Feature:YD},hover:{Feature:KD}},cR={layout:{ProjectionNode:vx,MeasureLayout:cx}},Oc={current:null},pm={current:!1};function _x(){if(pm.current=!0,!!Bp)if(window.matchMedia){const t=window.matchMedia("(prefers-reduced-motion)"),s=()=>Oc.current=t.matches;t.addListener(s),s()}else Oc.current=!1}const uR=[...V_,Wt,ka],dR=t=>uR.find(P_(t)),Zy=new WeakMap;function fR(t,s,i){for(const o in s){const c=s[o],u=i[o];if(Xt(c))t.addValue(o,c);else if(Xt(u))t.addValue(o,Er(c,{owner:t}));else if(u!==c)if(t.hasValue(o)){const d=t.getValue(o);d.liveStyle===!0?d.jump(c):d.hasAnimated||d.set(c)}else{const d=t.getStaticValue(o);t.addValue(o,Er(d!==void 0?d:c,{owner:t}))}}for(const o in i)s[o]===void 0&&t.removeValue(o);return s}const Ky=["AnimationStart","AnimationComplete","Update","BeforeLayoutMeasure","LayoutMeasure","LayoutAnimationStart","LayoutAnimationComplete"];class pR{scrapeMotionValuesFromProps(s,i,o){return{}}constructor({parent:s,props:i,presenceContext:o,reducedMotionConfig:c,blockInitialAnimation:u,visualState:d},m={}){this.current=null,this.children=new Set,this.isVariantNode=!1,this.isControllingVariants=!1,this.shouldReduceMotion=null,this.values=new Map,this.KeyframeResolver=lm,this.features={},this.valueSubscriptions=new Map,this.prevMotionValues={},this.events={},this.propEventSubscriptions={},this.notifyUpdate=()=>this.notify("Update",this.latestValues),this.render=()=>{this.current&&(this.triggerBuild(),this.renderInstance(this.current,this.renderState,this.props.style,this.projection))},this.renderScheduledAt=0,this.scheduleRender=()=>{const S=us.now();this.renderScheduledAt<S&&(this.renderScheduledAt=S,gt.render(this.render,!1,!0))};const{latestValues:h,renderState:g,onUpdate:v}=d;this.onUpdate=v,this.latestValues=h,this.baseTarget={...h},this.initialValues=i.initial?{...h}:{},this.renderState=g,this.parent=s,this.props=i,this.presenceContext=o,this.depth=s?s.depth+1:0,this.reducedMotionConfig=c,this.options=m,this.blockInitialAnimation=!!u,this.isControllingVariants=Jc(i),this.isVariantNode=Qb(i),this.isVariantNode&&(this.variantChildren=new Set),this.manuallyAnimateOnMount=!!(s&&s.current);const{willChange:_,...b}=this.scrapeMotionValuesFromProps(i,{},this);for(const S in b){const T=b[S];h[S]!==void 0&&Xt(T)&&T.set(h[S],!1)}}mount(s){this.current=s,Zy.set(s,this),this.projection&&!this.projection.instance&&this.projection.mount(s),this.parent&&this.isVariantNode&&!this.isControllingVariants&&(this.removeFromVariantTree=this.parent.addVariantChild(this)),this.values.forEach((i,o)=>this.bindToMotionValue(o,i)),pm.current||_x(),this.shouldReduceMotion=this.reducedMotionConfig==="never"?!1:this.reducedMotionConfig==="always"?!0:Oc.current,this.parent&&this.parent.children.add(this),this.update(this.props,this.presenceContext)}unmount(){Zy.delete(this.current),this.projection&&this.projection.unmount(),Ta(this.notifyUpdate),Ta(this.render),this.valueSubscriptions.forEach(s=>s()),this.valueSubscriptions.clear(),this.removeFromVariantTree&&this.removeFromVariantTree(),this.parent&&this.parent.children.delete(this);for(const s in this.events)this.events[s].clear();for(const s in this.features){const i=this.features[s];i&&(i.unmount(),i.isMounted=!1)}this.current=null}bindToMotionValue(s,i){this.valueSubscriptions.has(s)&&this.valueSubscriptions.get(s)();const o=ci.has(s),c=i.on("change",m=>{this.latestValues[s]=m,this.props.onUpdate&&gt.preRender(this.notifyUpdate),o&&this.projection&&(this.projection.isTransformDirty=!0)}),u=i.on("renderRequest",this.scheduleRender);let d;window.MotionCheckAppearSync&&(d=window.MotionCheckAppearSync(this,s,i)),this.valueSubscriptions.set(s,()=>{c(),u(),d&&d(),i.owner&&i.stop()})}sortNodePosition(s){return!this.current||!this.sortInstanceNodePosition||this.type!==s.type?0:this.sortInstanceNodePosition(this.current,s.current)}updateFeatures(){let s="animation";for(s in oo){const i=oo[s];if(!i)continue;const{isEnabled:o,Feature:c}=i;if(!this.features[s]&&c&&o(this.props)&&(this.features[s]=new c(this)),this.features[s]){const u=this.features[s];u.isMounted?u.update():(u.mount(),u.isMounted=!0)}}}triggerBuild(){this.build(this.renderState,this.latestValues,this.props)}measureViewportBox(){return this.current?this.measureInstanceViewportBox(this.current,this.props):At()}getStaticValue(s){return this.latestValues[s]}setStaticValue(s,i){this.latestValues[s]=i}update(s,i){(s.transformTemplate||this.props.transformTemplate)&&this.scheduleRender(),this.prevProps=this.props,this.props=s,this.prevPresenceContext=this.presenceContext,this.presenceContext=i;for(let o=0;o<Ky.length;o++){const c=Ky[o];this.propEventSubscriptions[c]&&(this.propEventSubscriptions[c](),delete this.propEventSubscriptions[c]);const u="on"+c,d=s[u];d&&(this.propEventSubscriptions[c]=this.on(c,d))}this.prevMotionValues=fR(this,this.scrapeMotionValuesFromProps(s,this.prevProps,this),this.prevMotionValues),this.handleChildMotionValue&&this.handleChildMotionValue(),this.onUpdate&&this.onUpdate(this)}getProps(){return this.props}getVariant(s){return this.props.variants?this.props.variants[s]:void 0}getDefaultTransition(){return this.props.transition}getTransformPagePoint(){return this.props.transformPagePoint}getClosestVariantNode(){return this.isVariantNode?this:this.parent?this.parent.getClosestVariantNode():void 0}addVariantChild(s){const i=this.getClosestVariantNode();if(i)return i.variantChildren&&i.variantChildren.add(s),()=>i.variantChildren.delete(s)}addValue(s,i){const o=this.values.get(s);i!==o&&(o&&this.removeValue(s),this.bindToMotionValue(s,i),this.values.set(s,i),this.latestValues[s]=i.get())}removeValue(s){this.values.delete(s);const i=this.valueSubscriptions.get(s);i&&(i(),this.valueSubscriptions.delete(s)),delete this.latestValues[s],this.removeValueFromRenderState(s,this.renderState)}hasValue(s){return this.values.has(s)}getValue(s,i){if(this.props.values&&this.props.values[s])return this.props.values[s];let o=this.values.get(s);return o===void 0&&i!==void 0&&(o=Er(i===null?void 0:i,{owner:this}),this.addValue(s,o)),o}readValue(s,i){var o;let c=this.latestValues[s]!==void 0||!this.current?this.latestValues[s]:(o=this.getBaseTargetFromProps(this.props,s))!==null&&o!==void 0?o:this.readValueFromInstance(this.current,s,this.options);return c!=null&&(typeof c=="string"&&(U_(c)||E_(c))?c=parseFloat(c):!dR(c)&&ka.test(i)&&(c=O_(s,i)),this.setBaseTarget(s,Xt(c)?c.get():c)),Xt(c)?c.get():c}setBaseTarget(s,i){this.baseTarget[s]=i}getBaseTarget(s){var i;const{initial:o}=this.props;let c;if(typeof o=="string"||typeof o=="object"){const d=Hp(this.props,o,(i=this.presenceContext)===null||i===void 0?void 0:i.custom);d&&(c=d[s])}if(o&&c!==void 0)return c;const u=this.getBaseTargetFromProps(this.props,s);return u!==void 0&&!Xt(u)?u:this.initialValues[s]!==void 0&&c===void 0?void 0:this.baseTarget[s]}on(s,i){return this.events[s]||(this.events[s]=new Qp),this.events[s].add(i)}notify(s,...i){this.events[s]&&this.events[s].notify(...i)}}class xx extends pR{constructor(){super(...arguments),this.KeyframeResolver=H_}sortInstanceNodePosition(s,i){return s.compareDocumentPosition(i)&2?1:-1}getBaseTargetFromProps(s,i){return s.style?s.style[i]:void 0}removeValueFromRenderState(s,{vars:i,style:o}){delete i[s],delete o[s]}handleChildMotionValue(){this.childSubscription&&(this.childSubscription(),delete this.childSubscription);const{children:s}=this.props;Xt(s)&&(this.childSubscription=s.on("change",i=>{this.current&&(this.current.textContent=`${i}`)}))}}function mR(t){return window.getComputedStyle(t)}class hR extends xx{constructor(){super(...arguments),this.type="html",this.renderInstance=l_}readValueFromInstance(s,i){if(ci.has(i)){const o=rm(i);return o&&o.default||0}else{const o=mR(s),c=(i_(i)?o.getPropertyValue(i):o[i])||0;return typeof c=="string"?c.trim():c}}measureInstanceViewportBox(s,{transformPagePoint:i}){return rx(s,i)}build(s,i,o){qp(s,i,o.transformTemplate)}scrapeMotionValuesFromProps(s,i,o){return Yp(s,i,o)}}class gR extends xx{constructor(){super(...arguments),this.type="svg",this.isSVGTag=!1,this.measureInstanceViewportBox=At}getBaseTargetFromProps(s,i){return s[i]}readValueFromInstance(s,i){if(ci.has(i)){const o=rm(i);return o&&o.default||0}return i=c_.has(i)?i:zp(i),s.getAttribute(i)}scrapeMotionValuesFromProps(s,i,o){return f_(s,i,o)}build(s,i,o){Fp(s,i,this.isSVGTag,o.transformTemplate)}renderInstance(s,i,o,c){u_(s,i,o,c)}mount(s){this.isSVGTag=Kp(s.tagName),super.mount(s)}}const vR=(t,s)=>Vp(t)?new gR(s):new hR(s,{allowProjection:t!==y.Fragment}),yR=GC({...OA,...lR,...qD,...cR},vR),Dt=iC(yR);function bR(){!pm.current&&_x();const[t]=y.useState(Oc.current);return t}const _R="_overlay_cmicx_1",xR="_dialog_cmicx_11",SR="_title_cmicx_30",TR="_description_cmicx_38",kR="_actions_cmicx_45",wR="_cancelButton_cmicx_52",NR="_confirmButton_cmicx_79",Ka={overlay:_R,dialog:xR,title:SR,description:TR,actions:kR,cancelButton:wR,confirmButton:NR};function ii({isOpen:t,title:s,description:i,confirmLabel:o="Delete",onConfirm:c,onCancel:u}){const d=y.useId(),m=y.useId();return l.jsx(ds,{children:t&&l.jsx(Dt.div,{className:Ka.overlay,initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},transition:{duration:.15},onClick:u,onKeyDown:h=>{h.key==="Escape"&&u()},role:"dialog","aria-modal":"true","aria-labelledby":d,"aria-describedby":i?m:void 0,children:l.jsxs(Dt.div,{className:Ka.dialog,initial:{opacity:0,scale:.93,y:-10},animate:{opacity:1,scale:1,y:0},exit:{opacity:0,scale:.93,y:-10},transition:{duration:.15,ease:[.16,1,.3,1]},onClick:h=>h.stopPropagation(),children:[l.jsx("h3",{id:d,className:Ka.title,children:s}),i&&l.jsx("p",{id:m,className:Ka.description,children:i}),l.jsxs("div",{className:Ka.actions,children:[l.jsx("button",{type:"button",className:Ka.cancelButton,onClick:u,autoFocus:!0,children:"Cancel"}),l.jsx("button",{type:"button",className:Ka.confirmButton,onClick:c,children:o})]})]})})})}const jR="_spinner_1uyt1_1",CR="_spin_1uyt1_1",ER="_sm_1uyt1_14",AR="_md_1uyt1_20",DR="_lg_1uyt1_26",RR="_xl_1uyt1_32",Yy={spinner:jR,spin:CR,sm:ER,md:AR,lg:DR,xl:RR};function Sx({size:t="md",className:s,label:i="Loading",liveRegion:o=!1}){return l.jsx("span",{className:`${Yy.spinner} ${Yy[t]} ${s??""}`,role:o?"status":void 0,"aria-label":i,"aria-hidden":o?void 0:!0})}const MR="_splash_1bn1g_1",IR="_logo_1bn1g_11",Jy={splash:MR,logo:IR};function Tx(){return l.jsxs("div",{className:Jy.splash,"data-testid":"splash-screen",children:[l.jsx("img",{src:"/grackle-logo.png",alt:"Grackle",className:Jy.logo}),l.jsx(Sx,{size:"xl",label:"Loading Grackle",liveRegion:!0})]})}const kx=50;function OR(t,s,i,o,c=kx){return o?t<c:s-t-i<c}function BR(t,s){const i=s-t;return i>0?i:0}function LR({scrollRef:t,contentLength:s,isReversed:i}){const[o,c]=y.useState(!0),u=y.useRef(0),d=y.useRef(!1),m=y.useRef(0);y.useEffect(()=>{const g=t.current;if(!g)return;let v=!0;const _=()=>{m.current||(m.current=requestAnimationFrame(()=>{m.current=0;const b=OR(g.scrollTop,g.scrollHeight,g.clientHeight,i,kx);b!==v&&(v=b,c(b))}))};return g.addEventListener("scroll",_,{passive:!0}),()=>{g.removeEventListener("scroll",_),m.current&&(cancelAnimationFrame(m.current),m.current=0)}},[t,i]),y.useLayoutEffect(()=>{const g=t.current;!g||d.current||(d.current=!0,i?g.scrollTop=0:g.scrollTop=g.scrollHeight,c(!0))},[t,i]),y.useLayoutEffect(()=>{const g=t.current;if(g){if(i&&!o){const v=BR(u.current,g.scrollHeight);v>0&&(g.scrollTop+=v)}o&&(i?g.scrollTo({top:0,behavior:"smooth"}):g.scrollTo({top:g.scrollHeight,behavior:"smooth"})),u.current=g.scrollHeight}},[s,o,i,t]);const h=y.useCallback(()=>{const g=t.current;if(!g)return;const v=i?0:g.scrollHeight;g.scrollTo({top:v,behavior:"smooth"}),c(!0)},[t,i]);return{isAtAnchor:o,scrollToAnchor:h}}const UR="_wrapper_1rtuy_1",zR="_scrollContainer_1rtuy_9",PR="_toolbar_1rtuy_15",VR="_directionToggle_1rtuy_22",HR="_scrollToAnchor_1rtuy_60",$R="_scrollToAnchorBottom_1rtuy_84",GR="_scrollToAnchorTop_1rtuy_88",qR="_eventOverflowWarning_1rtuy_92",xa={wrapper:UR,scrollContainer:zR,toolbar:PR,directionToggle:VR,scrollToAnchor:HR,scrollToAnchorBottom:$R,scrollToAnchorTop:GR,eventOverflowWarning:qR},wx="grackle-stream-direction";function FR(){try{return localStorage.getItem(wx)==="reversed"}catch{return!1}}function ZR({eventsDropped:t}){return t<=0?l.jsx(l.Fragment,{}):l.jsxs("div",{className:xa.eventOverflowWarning,role:"alert",children:["⚠"," ",t.toLocaleString()," older event",t===1?"":"s"," were dropped — only the most recent 5,000 are shown. Full history is available in the session log."]})}function mm({events:t,eventsDropped:s,emptyState:i}){const o=y.useRef(null),[c,u]=y.useState(FR),d=bR(),m=y.useMemo(()=>c?[...t].reverse():t,[t,c]),{isAtAnchor:h,scrollToAnchor:g}=LR({scrollRef:o,contentLength:t.length,isReversed:c}),v=()=>{const S=!c;u(S);try{localStorage.setItem(wx,S?"reversed":"default")}catch{}},_=d?0:.2,b=c?-8:8;return l.jsxs("div",{className:xa.wrapper,children:[l.jsx("div",{className:xa.toolbar,children:l.jsx("button",{className:xa.directionToggle,onClick:v,title:c?"Showing newest first":"Showing oldest first","aria-label":c?"Switch to newest at bottom":"Switch to newest at top","data-testid":"direction-toggle",children:c?"↓":"↑"})}),l.jsxs("div",{ref:o,className:xa.scrollContainer,"data-testid":"event-stream-scroll",children:[t.length===0&&i,l.jsx(ZR,{eventsDropped:s}),l.jsx(ds,{initial:!1,children:m.map((S,T)=>{const N=c?t.length-1-T:T;return l.jsx(Dt.div,{initial:{opacity:0,y:b},animate:{opacity:1,y:0},transition:{duration:_,ease:"easeOut"},children:l.jsx(Zj,{event:S,toolUseCtx:S.toolUseCtx})},`${S.sessionId}-${S.timestamp}-${N}`)})})]}),l.jsx(ds,{children:!h&&l.jsxs(Dt.button,{className:`${xa.scrollToAnchor} ${c?xa.scrollToAnchorTop:xa.scrollToAnchorBottom}`,onClick:g,initial:{opacity:0,scale:.9},animate:{opacity:1,scale:1},exit:{opacity:0,scale:.9},transition:{duration:.15},"aria-label":"Scroll to latest","data-testid":"scroll-to-anchor",children:[c?"↑":"↓"," New events"]})})]})}function hm(t){const{value:s,onSave:i,validate:o,fieldId:c,activeFieldId:u,onActivate:d,enterToSave:m=!0,trimOnSave:h=!0}=t,[g,v]=y.useState(""),[_,b]=y.useState(""),S=y.useRef(!1),T=u===c,N=y.useCallback($=>{v($),b("")},[]),j=y.useCallback(()=>{b("")},[]),w=y.useCallback(()=>{S.current=!1,d==null||d(null),v(""),b("")},[d]),C=y.useCallback(()=>{const $=h?g.trim():g;if(o){const K=o(g);if(K){b(K);return}}const z=h?s.trim():s;if($===z){w();return}i($),w()},[g,s,h,o,i,w]),A=y.useCallback(()=>{S.current=!0,d==null||d(c),v(s),b("")},[c,s,d]),M=y.useCallback($=>{if(S.current){S.current=!1;return}$.relatedTarget instanceof HTMLElement&&$.relatedTarget.dataset.editAction===c||C()},[c,C]),D=y.useCallback($=>{$.key==="Escape"?w():$.key==="Enter"&&m&&C()},[w,m,C]),E=(()=>{if(!T)return!1;const $=h?s.trim():s;return(h?g.trim():g)!==$})();return y.useEffect(()=>{!T&&(g!==""||_!=="")&&(v(""),b(""))},[T,g,_]),{isEditing:T,draft:g,error:_,isDirty:E,startEdit:A,cancelEdit:w,save:C,setDraft:N,clearError:j,handleBlur:M,handleKeyDown:D,ignoreInitialBlurRef:S}}const KR="_editFieldWrapper_yuzty_1",YR="_editInput_yuzty_10",JR="_editTextarea_yuzty_42",WR="_editSelect_yuzty_78",XR="_editError_yuzty_111",QR="_editInputInvalid_yuzty_118",eM="_editHint_yuzty_123",tM="_unsavedDot_yuzty_132",nM="_metaValueClickable_yuzty_140",sM="_editButton_yuzty_159",aM="_metaPlaceholder_yuzty_175",iM="_worktreeToggle_yuzty_180",Je={editFieldWrapper:KR,editInput:YR,editTextarea:JR,editSelect:WR,editError:XR,editInputInvalid:QR,editHint:eM,unsavedDot:tM,metaValueClickable:nM,editButton:sM,metaPlaceholder:aM,worktreeToggle:iM};function Kt(t){const{value:s,onSave:i,validate:o,mode:c="edit",fieldId:u="text",activeFieldId:d,onActivate:m,onChange:h,renderDisplay:g,placeholder:v,maxLength:_,ariaLabel:b,"data-testid":S}=t,T=y.useRef(null),N=hm({value:s,onSave:i,validate:o,fieldId:u,activeFieldId:d,onActivate:m,enterToSave:!0,trimOnSave:!0});if(y.useEffect(()=>{if(N.isEditing){const w=window.setTimeout(()=>{var C;(C=T.current)==null||C.focus()},0);return()=>window.clearTimeout(w)}},[N.isEditing]),c==="create"){const w=A=>{h==null||h(A.target.value)},C=o==null?void 0:o(s);return l.jsxs("div",{className:Je.editFieldWrapper,children:[l.jsx("input",{className:`${Je.editInput} ${C?Je.editInputInvalid:""}`,value:s,onChange:w,maxLength:_,placeholder:v,"aria-label":b,"data-testid":S?`${S}-input`:void 0}),C&&l.jsx("span",{className:Je.editError,"data-testid":"edit-error",children:C})]})}if(N.isEditing)return l.jsxs("div",{className:Je.editFieldWrapper,children:[l.jsx("input",{ref:T,className:`${Je.editInput} ${N.error?Je.editInputInvalid:""}`,value:N.draft,onChange:w=>N.setDraft(w.target.value),onBlur:N.handleBlur,onKeyDown:N.handleKeyDown,maxLength:_,placeholder:v,"aria-label":b,"data-testid":S?`${S}-input`:void 0}),N.isDirty&&l.jsx("span",{className:Je.unsavedDot,title:"Unsaved changes"}),N.error&&l.jsx("span",{className:Je.editError,"data-testid":"edit-error",children:N.error}),l.jsx("span",{className:Je.editHint,children:"Enter to save · Esc to cancel"})]});const j=g==null?void 0:g(s);return l.jsxs("span",{role:"button",tabIndex:0,className:Je.metaValueClickable,onClick:()=>N.startEdit(),onKeyDown:w=>{(w.key==="Enter"||w.key===" ")&&(w.preventDefault(),N.startEdit())},title:"Click to edit","aria-label":b,"data-testid":S?`${S}-button`:void 0,children:[j!==void 0?j:s?l.jsx("span",{children:s}):l.jsx("span",{className:Je.metaPlaceholder,children:v||"None"}),l.jsx("span",{className:Je.editButton,"aria-hidden":"true",children:"✏️"})]})}function vp(t){const{value:s,onSave:i,validate:o,mode:c="edit",fieldId:u="textarea",activeFieldId:d,onActivate:m,onChange:h,renderDisplay:g,placeholder:v,ariaLabel:_,"data-testid":b}=t,S=y.useRef(null),T=hm({value:s,onSave:i,validate:o,fieldId:u,activeFieldId:d,onActivate:m,enterToSave:!1,trimOnSave:!1});if(y.useEffect(()=>{if(T.isEditing){const j=window.setTimeout(()=>{var w;(w=S.current)==null||w.focus()},0);return()=>window.clearTimeout(j)}},[T.isEditing]),c==="create"){const j=C=>{h==null||h(C.target.value)},w=o==null?void 0:o(s);return l.jsxs("div",{className:Je.editFieldWrapper,children:[l.jsx("textarea",{className:`${Je.editTextarea} ${w?Je.editInputInvalid:""}`,value:s,onChange:j,placeholder:v,"aria-label":_,"data-testid":b?`${b}-input`:void 0}),w&&l.jsx("span",{className:Je.editError,"data-testid":"edit-error",children:w})]})}if(T.isEditing)return l.jsxs("div",{className:Je.editFieldWrapper,children:[l.jsx("textarea",{ref:S,className:`${Je.editTextarea} ${T.error?Je.editInputInvalid:""}`,value:T.draft,onChange:j=>T.setDraft(j.target.value),onBlur:T.handleBlur,onKeyDown:T.handleKeyDown,title:_,"aria-label":_,"data-testid":b?`${b}-input`:void 0}),T.isDirty&&l.jsx("span",{className:Je.unsavedDot,title:"Unsaved changes"}),T.error&&l.jsx("span",{className:Je.editError,"data-testid":"edit-error",children:T.error}),l.jsx("span",{className:Je.editHint,children:"Tab to save · Esc to cancel"})]});const N=g==null?void 0:g(s);return l.jsxs("span",{role:"button",tabIndex:0,className:Je.metaValueClickable,onClick:()=>T.startEdit(),onKeyDown:j=>{(j.key==="Enter"||j.key===" ")&&(j.preventDefault(),T.startEdit())},title:"Click to edit","aria-label":_,"data-testid":b?`${b}-button`:void 0,children:[N!==void 0?N:s?l.jsx("span",{children:s}):l.jsx("span",{className:Je.metaPlaceholder,children:v||"None"}),l.jsx("span",{className:Je.editButton,"aria-hidden":"true",children:"✏️"})]})}function Bc(t){var A;const{value:s,onSave:i,mode:o="edit",options:c,fieldId:u="select",activeFieldId:d,onActivate:m,onChange:h,renderDisplay:g,placeholder:v,ariaLabel:_,"data-testid":b}=t,S=y.useRef(null),T=hm({value:s,onSave:i,fieldId:u,activeFieldId:d,onActivate:m,enterToSave:!1,trimOnSave:!1});y.useEffect(()=>{if(T.isEditing){const M=window.setTimeout(()=>{var D;(D=S.current)==null||D.focus()},0);return()=>window.clearTimeout(M)}},[T.isEditing]);const N=y.useCallback(M=>{const D=M.target.value;T.ignoreInitialBlurRef.current=!1,D!==s&&i(D),T.cancelEdit()},[s,i,T]),j=y.useCallback(M=>{if(T.ignoreInitialBlurRef.current){T.ignoreInitialBlurRef.current=!1;return}M.relatedTarget instanceof HTMLElement&&M.relatedTarget.dataset.editAction===u||T.cancelEdit()},[u,T]);if(o==="create")return l.jsx("select",{className:Je.editSelect,value:s,onChange:M=>h==null?void 0:h(M.target.value),"aria-label":_,"data-testid":b?`${b}-select`:void 0,children:c.map(M=>l.jsx("option",{value:M.value,children:M.label},M.value))});if(T.isEditing)return l.jsx("select",{ref:S,className:Je.editSelect,value:T.draft,onChange:N,onBlur:j,title:_,"aria-label":_,"data-testid":b?`${b}-select`:void 0,children:c.map(M=>l.jsx("option",{value:M.value,children:M.label},M.value))});const w=g==null?void 0:g(s),C=(A=c.find(M=>M.value===s))==null?void 0:A.label;return l.jsxs("button",{type:"button",className:Je.metaValueClickable,onClick:()=>T.startEdit(),title:"Click to change","aria-label":_,"data-testid":b?`${b}-button`:void 0,children:[w!==void 0?w:C?l.jsx("span",{children:C}):l.jsx("span",{className:Je.metaPlaceholder,children:v||"None"}),l.jsx("span",{className:Je.editButton,"aria-hidden":"true",children:"✏️"})]})}function oM(t){const{checked:s,onChange:i,label:o,ariaLabel:c,"data-testid":u}=t;return l.jsxs("label",{className:Je.worktreeToggle,"data-testid":u,children:[l.jsx("input",{type:"checkbox",checked:s,onChange:d=>i(d.target.checked),"aria-label":c}),l.jsx("span",{children:o})]})}const rM="_envRow_1e1r5_1",lM="_envDot_1e1r5_7",cM="_envDotGreen_1e1r5_14",uM="_envDotYellow_1e1r5_18",dM="_envDotRed_1e1r5_22",fM="_envDotGray_1e1r5_26",no={envRow:rM,envDot:lM,envDotGreen:cM,envDotYellow:uM,envDotRed:dM,envDotGray:fM};function pM(t){const s=t.toLowerCase();return s==="ready"||s==="running"||s==="available"||s==="connected"?no.envDotGreen:s==="provisioning"||s==="starting"||s==="pending"||s==="connecting"?no.envDotYellow:s==="error"||s==="failed"||s==="disconnected"?no.envDotRed:no.envDotGray}function mM(t){const{value:s,onSave:i,environments:o,allowNone:c=!1,fieldId:u="environment",activeFieldId:d,onActivate:m,placeholder:h="No environment",ariaLabel:g="Environment","data-testid":v}=t,_=o.find(T=>T.id===s),b=[...c?[{value:"",label:"None"}]:[],...o.map(T=>({value:T.id,label:T.displayName}))],S=()=>{if(_)return l.jsxs("span",{className:no.envRow,children:[l.jsx("span",{className:`${no.envDot} ${pM(_.status)}`}),_.displayName]})};return l.jsx(Bc,{value:s,onSave:i,options:b,fieldId:u,activeFieldId:d,onActivate:m,renderDisplay:S,placeholder:h,ariaLabel:g,"data-testid":v})}const hM="_nav_1snmp_1",gM="_searchForm_1snmp_8",vM="_searchInput_1snmp_15",yM="_searchButton_1snmp_33",bM="_clearButton_1snmp_68",_M="_workspaceSelect_1snmp_85",xM="_listHeader_1snmp_99",SM="_nodeList_1snmp_108",TM="_nodeItem_1snmp_116",kM="_indicator_1snmp_129",wM="_label_1snmp_136",NM="_badge_1snmp_145",Bn={nav:hM,searchForm:gM,searchInput:vM,searchButton:yM,clearButton:bM,workspaceSelect:_M,listHeader:xM,nodeList:SM,nodeItem:TM,indicator:kM,label:wM,badge:NM};function jM({nodes:t,workspaces:s,loading:i,searchQuery:o,onSearch:c,onClearSearch:u,onSelectNode:d,onWorkspaceChange:m}){const[h,g]=y.useState(""),v=y.useCallback(T=>{T.preventDefault(),h.trim()&&c(h.trim())},[h,c]),_=y.useCallback(()=>{g(""),u()},[u]),b=y.useCallback(T=>{d(T)},[d]),S=y.useCallback(T=>{g(""),m(T)},[m]);return l.jsxs("div",{className:Bn.nav,"data-testid":"knowledge-nav",children:[l.jsxs("form",{className:Bn.searchForm,onSubmit:v,children:[l.jsx("input",{className:Bn.searchInput,type:"text",placeholder:"Search...",value:h,onChange:T=>{g(T.target.value)},"data-testid":"knowledge-search-input"}),l.jsx("button",{type:"submit",className:Bn.searchButton,disabled:i,children:"Go"})]}),o&&l.jsx("button",{type:"button",className:Bn.clearButton,onClick:_,children:"Clear search"}),l.jsxs("select",{className:Bn.workspaceSelect,onChange:T=>{S(T.target.value)},"data-testid":"knowledge-workspace-filter",children:[l.jsx("option",{value:"",children:"All workspaces"}),s.map(T=>l.jsx("option",{value:T.id,children:T.name},T.id))]}),l.jsxs("div",{className:Bn.listHeader,children:["Nodes (",t.length,")"]}),l.jsx("ul",{className:Bn.nodeList,children:t.map(T=>l.jsxs("li",{className:Bn.nodeItem,onClick:()=>{b(T.id)},onKeyDown:N=>{(N.key==="Enter"||N.key===" ")&&(N.preventDefault(),b(T.id))},role:"button",tabIndex:0,children:[l.jsx("span",{className:Bn.indicator,style:{backgroundColor:T.kind==="reference"?"#4A9EFF":T.category==="decision"?"#22C55E":T.category==="concept"?"#A855F7":T.category==="snippet"?"#6B7280":"#EAB308"}}),l.jsx("span",{className:Bn.label,children:T.label}),l.jsx("span",{className:Bn.badge,children:T.kind==="reference"?T.sourceType:T.category})]},T.id))})]})}const CM="_container_1mq5u_1",EM="_hamburger_1mq5u_33",AM="_brand_1mq5u_49",DM="_brandLogo_1mq5u_68",RM="_info_1mq5u_75",MM="_connectionLabel_1mq5u_90",IM="_connectionDot_1mq5u_103",OM="_connected_1mq5u_106",BM="_disconnected_1mq5u_110",Ms={container:CM,hamburger:EM,brand:AM,brandLogo:DM,info:RM,connectionLabel:MM,connectionDot:IM,connected:OM,disconnected:BM};function LM({connected:t,environments:s,sessions:i,onToggleSidebar:o,sidebarOpen:c}){const u=vt(),d=s.length,m=s.filter(g=>g.status==="connected").length,h=i.filter(g=>["running","idle"].includes(g.status)).length;return l.jsxs("div",{className:Ms.container,children:[o&&l.jsx("button",{type:"button",className:Ms.hamburger,onClick:o,"aria-label":"Toggle sidebar","aria-expanded":c,children:"☰"}),l.jsxs("button",{type:"button",className:Ms.brand,onClick:()=>u(ai),title:"Home",children:[l.jsx("img",{src:"/icon-192x192.png",alt:"",className:Ms.brandLogo,"aria-hidden":"true","data-testid":"statusbar-logo"}),"Grackle"]}),l.jsxs("div",{className:Ms.info,children:[l.jsxs("span",{"aria-label":t?"Connected":"Disconnected",children:[l.jsx("span",{className:`${Ms.connectionDot} ${t?Ms.connected:Ms.disconnected}`,"aria-hidden":"true",children:"●"})," ",l.jsx("span",{className:Ms.connectionLabel,"aria-hidden":"true",children:t?"Connected":"Disconnected"})]}),l.jsxs("span",{children:[m,"/",d," env",d!==1?"s":""]}),l.jsxs("span",{children:[h," active"]})]})]})}const UM="_nav_13gkc_1",zM="_tab_13gkc_35",PM="_tabIcon_13gkc_68",VM="_tabLabel_13gkc_79",HM="_tabActive_13gkc_84",ur={nav:UM,tab:zM,tabIcon:PM,tabLabel:VM,tabActive:HM},Ya=[{view:"dashboard",label:"Dashboard",icon:"🏠",route:ai,testId:"sidebar-tab-dashboard"},{view:"chat",label:"Chat",icon:"💬",route:o2,testId:"sidebar-tab-chat"},{view:"tasks",label:"Tasks",icon:"📋",route:r2,testId:"sidebar-tab-tasks"},{view:"environments",label:"Environments",icon:"🖥️",route:ao,testId:"sidebar-tab-environments"},{view:"knowledge",label:"Knowledge",icon:"🧠",route:Gb,testId:"sidebar-tab-knowledge"},{view:"findings",label:"Findings",icon:"🔍",route:Fc,testId:"sidebar-tab-findings"},{view:"settings",label:"Settings",icon:"⚙️",route:n2,testId:"sidebar-tab-settings"}];function $M(t){return t===ai||t==="/"?"dashboard":t.startsWith("/chat")||t.startsWith("/sessions")?"chat":t.startsWith("/workspaces")||t.startsWith("/environments")?"environments":t.startsWith(Gb)?"knowledge":t.startsWith(Fc)?"findings":t.startsWith(so)?"settings":"tasks"}function GM(){const t=Ut(),s=vt(),i=y.useRef(null),o=$M(t.pathname),c=y.useCallback(d=>{s(d.route)},[s]),u=y.useCallback(d=>{var _,b;const m=(_=i.current)==null?void 0:_.querySelectorAll('[role="tab"]');if(!m)return;const h=Array.from(m).findIndex(S=>S===document.activeElement),g=h>=0?h:Ya.findIndex(S=>S.view===o);let v=g;if(d.key==="ArrowRight"||d.key==="j"||d.key==="J")d.preventDefault(),v=(g+1)%Ya.length;else if(d.key==="ArrowLeft"||d.key==="k"||d.key==="K")d.preventDefault(),v=(g-1+Ya.length)%Ya.length;else if(d.key==="Home")d.preventDefault(),v=0;else if(d.key==="End")d.preventDefault(),v=Ya.length-1;else return;s(Ya[v].route),(b=m[v])==null||b.focus()},[o,s]);return l.jsx("nav",{className:ur.nav,ref:i,role:"tablist","aria-orientation":"horizontal","aria-label":"App navigation",onKeyDown:u,"data-testid":"sidebar-nav",children:Ya.map(d=>{const m=d.view===o;return l.jsxs("button",{role:"tab",type:"button","aria-selected":m,tabIndex:m?0:-1,className:`${ur.tab} ${m?ur.tabActive:""}`,onClick:()=>c(d),"data-testid":d.testId,title:d.label,"aria-label":d.label,children:[l.jsx("span",{className:ur.tabIcon,"aria-hidden":"true",children:d.icon}),l.jsx("span",{className:ur.tabLabel,children:d.label})]},d.view)})})}const qM="_container_pi6ii_1",FM="_content_pi6ii_66",Wy={container:qM,content:FM},ZM=320,Nx=220,jx=600,Cx="grackle-sidebar-width";function KM(){try{const t=localStorage.getItem(Cx);if(t!==null){const s=Number(t);if(Number.isFinite(s)&&s>=Nx&&s<=jx)return s}}catch{}return ZM}function YM(t){try{localStorage.setItem(Cx,String(t))}catch{}}function JM({content:t}){const[s]=y.useState(KM),i=y.useRef(null);if(y.useEffect(()=>{const o=i.current;if(!o)return;const c=new ResizeObserver(u=>{for(const d of u){const m=d.borderBoxSize[0];if(m){const h=Math.round(m.inlineSize);h>=Nx&&h<=jx&&YM(h)}}});return c.observe(o),()=>{c.disconnect()}},[]),t!==void 0)return l.jsx("div",{className:Wy.container,ref:i,"data-testid":"sidebar",style:{width:s},children:l.jsx("div",{className:Wy.content,children:t})})}const WM="_bar_tnfsh_1",XM="_btnPrimary_tnfsh_32",QM="_statusText_tnfsh_85",e3="_statusCompleted_tnfsh_90",t3="_statusFailed_tnfsh_94",n3="_statusBlocked_tnfsh_98",s3="_hintText_tnfsh_103",_t={bar:WM,btnPrimary:XM,statusText:QM,statusCompleted:e3,statusFailed:t3,statusBlocked:n3,hintText:s3};function a3({sessions:t,tasks:s,environments:i}){const o=vt(),c=Ut(),u=kt("/sessions/:sessionId"),d=kt("/tasks/:taskId"),m=kt("/tasks/:taskId/stream"),h=kt("/tasks/:taskId/findings"),g=kt("/tasks/:taskId/edit"),v=kt("/environments/:environmentId/workspaces/:workspaceId/tasks/:taskId"),_=kt("/environments/:environmentId/workspaces/:workspaceId/tasks/:taskId/stream"),b=kt("/environments/:environmentId/workspaces/:workspaceId/tasks/:taskId/findings"),S=kt("/environments/:environmentId/workspaces/:workspaceId/tasks/:taskId/edit"),T=kt("/sessions/new"),N=kt("/environments/:environmentId/workspaces/:workspaceId"),j=kt("/tasks/new"),w=kt("/chat"),C=kt("/"),A=kt("/settings/*"),M=u==null?void 0:u.params.sessionId,D=(d==null?void 0:d.params.taskId)??(m==null?void 0:m.params.taskId)??(h==null?void 0:h.params.taskId)??(v==null?void 0:v.params.taskId)??(_==null?void 0:_.params.taskId)??(b==null?void 0:b.params.taskId)??(S==null?void 0:S.params.taskId),E=v??_??b??S,$=(E==null?void 0:E.params.environmentId)??(N==null?void 0:N.params.environmentId),z=c.pathname.startsWith("/environments")&&!N&&!E,K=!!w,F=!!T,ee=!!N&&!v&&!_&&!b&&!S,ae=!!j;if(!!C&&!F&&!ee&&!ae||!!A||(!!g||!!S)||ae||z||F)return l.jsx(l.Fragment,{});if(K)return i.find(q=>q.adapterType==="local"&&q.status==="connected")?l.jsx(l.Fragment,{}):l.jsx("div",{className:_t.bar,children:l.jsx("span",{className:_t.hintText,children:"Add a local environment to start chatting"})});if(ee)return l.jsx("div",{className:_t.bar,children:l.jsx("span",{className:_t.hintText,children:"Select a task or click + to create one"})});if(D){const O=s.find(re=>re.id===D);if(!O)return l.jsx("div",{className:_t.bar,children:l.jsx("span",{className:_t.hintText,children:"Loading..."})});const q=new Map(s.map(re=>[re.id,re])),te=O.dependsOn.some(re=>{const ue=q.get(re);return ue!==void 0&&ue.status!=="complete"});if(O.status==="not_started"){const re=te?O.dependsOn.map(ue=>q.get(ue)).filter(ue=>ue&&ue.status!=="complete").map(ue=>ue.title):[];return l.jsx("div",{className:_t.bar,children:te?l.jsxs("span",{className:_t.statusBlocked,children:["Blocked by: ",re.join(", ")]}):l.jsx("span",{className:_t.hintText,children:"Use the buttons above to start or manage this task"})})}if(O.status==="working"||O.status==="paused"){const re=O.latestSessionId||void 0,ue=re?t.find(Ne=>Ne.id===re):void 0;return ue&&ue.status!=="stopped"?l.jsx(l.Fragment,{}):l.jsx("div",{className:_t.bar,children:l.jsx("span",{className:_t.hintText,children:"Waiting for agent..."})})}if(O.status==="complete")return l.jsxs("div",{className:_t.bar,children:[l.jsx("span",{className:`${_t.statusText} ${_t.statusCompleted}`,children:"Task completed"}),l.jsx("button",{onClick:()=>o(ri(O.workspaceId,void 0,$)),className:_t.btnPrimary,children:"+ New Task"})]});if(O.status==="failed")return l.jsx("div",{className:_t.bar,children:l.jsx("span",{className:`${_t.statusText} ${_t.statusFailed}`,children:"Task failed"})})}if(M){const O=t.find(re=>re.id===M),q=(O==null?void 0:O.status)==="stopped";if(O!==void 0&&!q)return l.jsx(l.Fragment,{});if(q)return l.jsxs("div",{className:_t.bar,children:[l.jsxs("span",{className:`${_t.statusText} ${_t.hintText}`,children:["Session ",O.endReason||O.status]}),l.jsx("button",{onClick:()=>o(Vb(O.environmentId)),className:_t.btnPrimary,children:"+ New Chat"})]})}return l.jsx("div",{className:_t.bar,children:l.jsx("span",{className:_t.hintText,children:"Loading..."})})}const i3="_nav_14i94_1",o3="_tab_14i94_24",r3="_tabActive_14i94_62",l3="_tabLabel_14i94_75",c3="_statusDot_14i94_81",u3="_pulse_14i94_87",d3="_addButton_14i94_99",f3="_empty_14i94_132",ha={nav:i3,tab:o3,tabActive:r3,tabLabel:l3,statusDot:c3,pulse:u3,addButton:d3,empty:f3},p3={connected:"var(--accent-green)",sleeping:"var(--accent-yellow)",error:"var(--accent-red)",disconnected:"var(--text-tertiary)",connecting:"var(--accent-blue)"};function m3({environments:t}){const s=vt(),i=y.useRef(null),o=kt("/environments/:environmentId"),c=kt("/environments/:environmentId/edit"),u=kt("/environments/:environmentId/workspaces/:workspaceId"),d=kt("/environments/:environmentId/workspaces/:workspaceId/*"),m=(o==null?void 0:o.params.environmentId)??(c==null?void 0:c.params.environmentId)??(u==null?void 0:u.params.environmentId)??(d==null?void 0:d.params.environmentId),h=m==="new"?void 0:m,g=y.useCallback(b=>{s(si(b))},[s]),v=y.useCallback(b=>{var w;const S=(w=i.current)==null?void 0:w.querySelectorAll('[role="tab"]');if(!S||S.length===0)return;const T=Array.from(S).findIndex(C=>C===document.activeElement),N=T>=0?T:t.findIndex(C=>C.id===h);let j=N;if(b.key==="ArrowDown"||b.key==="j"||b.key==="J")b.preventDefault(),j=(N+1)%S.length;else if(b.key==="ArrowUp"||b.key==="k"||b.key==="K")b.preventDefault(),j=(N-1+S.length)%S.length;else if(b.key==="Home")b.preventDefault(),j=0;else if(b.key==="End")b.preventDefault(),j=S.length-1;else return;j<t.length&&s(si(t[j].id)),S[j].focus()},[h,t,s]),_=h??(t.length>0?t[0].id:void 0);return l.jsxs("div",{className:ha.nav,"data-testid":"environment-nav",children:[l.jsx("nav",{ref:i,role:"tablist","aria-orientation":"vertical","aria-label":"Environments",onKeyDown:v,children:t.map(b=>{const S=b.id===h,T=b.id===_,N=p3[b.status]||"var(--text-tertiary)",j=b.status==="connected";return l.jsxs("button",{role:"tab",type:"button","aria-selected":S,tabIndex:T?0:-1,className:`${ha.tab} ${S?ha.tabActive:""}`,onClick:()=>g(b.id),"data-testid":"env-nav-item",children:[l.jsx("span",{className:`${ha.statusDot} ${j?ha.pulse:""}`,style:{color:N},children:"●"}),l.jsx("span",{className:ha.tabLabel,title:b.displayName||b.id,children:b.displayName||b.id})]},b.id)})}),l.jsx("button",{type:"button",className:ha.addButton,onClick:()=>s(e2),title:"Add environment","data-testid":"env-nav-add",children:"+ Add Environment"}),t.length===0&&l.jsx("div",{className:ha.empty,children:"No environments yet."})]})}function gm(t){const s=new Date(t),i=new Date,o=i.getTime()-s.getTime(),c=Math.floor(o/1e3),u=Math.floor(c/60),d=Math.floor(u/60),m=Math.floor(d/24);if(c<60)return"just now";if(u<60)return`${u}m ago`;if(d<24)return`${d}h ago`;if(m===1)return"yesterday";if(m<7)return`${m} days ago`;const h=s.getFullYear()===i.getFullYear(),g=s.toLocaleString("en-US",{month:"short"}),v=s.getDate();return h?`${g} ${v}`:`${g} ${v} ${s.getFullYear()}`}const Xy={architecture:{text:"var(--accent-blue)",bg:"var(--accent-blue-dim)"},api:{text:"var(--accent-green)",bg:"var(--accent-green-dim)"},bug:{text:"var(--accent-red)",bg:"var(--accent-red-dim)"},decision:{text:"var(--accent-yellow)",bg:"var(--accent-yellow-dim)"},dependency:{text:"var(--accent-purple)",bg:"var(--accent-purple-dim)"},pattern:{text:"var(--accent-cyan)",bg:"var(--accent-cyan-dim)"},general:{text:"var(--text-secondary)",bg:"var(--bg-elevated)"}};function Lc(t){return Xy[t]||Xy.general}const h3="_nav_dlm8m_1",g3="_categoryPills_dlm8m_24",v3="_categoryPill_dlm8m_24",y3="_tab_dlm8m_42",b3="_tabActive_dlm8m_80",_3="_tabContent_dlm8m_93",x3="_tabLabel_dlm8m_100",S3="_tabMeta_dlm8m_106",T3="_categoryDot_dlm8m_111",k3="_empty_dlm8m_118",os={nav:h3,categoryPills:g3,categoryPill:v3,tab:y3,tabActive:b3,tabContent:_3,tabLabel:x3,tabMeta:S3,categoryDot:T3,empty:k3};function w3({findings:t,workspaceId:s,environmentId:i}){const o=vt(),c=y.useRef(null),u=kt("/findings/:findingId"),d=kt("/environments/:environmentId/workspaces/:workspaceId/findings/:findingId"),m=(u==null?void 0:u.params.findingId)??(d==null?void 0:d.params.findingId),h=y.useMemo(()=>{const b=new Set(t.map(S=>S.category).filter(Boolean));return Array.from(b).sort()},[t]),g=y.useCallback(b=>{o(Qf(b,s,i))},[o,s,i]),v=y.useCallback(b=>{var w;const S=(w=c.current)==null?void 0:w.querySelectorAll('[role="tab"]');if(!S||S.length===0)return;const T=Array.from(S).findIndex(C=>C===document.activeElement),N=T>=0?T:t.findIndex(C=>C.id===m);let j=N;if(b.key==="ArrowDown"||b.key==="j"||b.key==="J")b.preventDefault(),j=(N+1)%S.length;else if(b.key==="ArrowUp"||b.key==="k"||b.key==="K")b.preventDefault(),j=(N-1+S.length)%S.length;else if(b.key==="Home")b.preventDefault(),j=0;else if(b.key==="End")b.preventDefault(),j=S.length-1;else return;j<t.length&&o(Qf(t[j].id,s,i)),S[j].focus()},[m,t,o,s,i]),_=m??(t.length>0?t[0].id:void 0);return l.jsxs("div",{className:os.nav,"data-testid":"findings-nav",children:[h.length>1&&l.jsx("div",{className:os.categoryPills,"data-testid":"findings-nav-categories",children:h.map(b=>l.jsx("span",{className:os.categoryPill,style:{color:Lc(b).text},children:b},b))}),l.jsx("nav",{ref:c,role:"tablist","aria-orientation":"vertical","aria-label":"Findings",onKeyDown:v,children:t.map(b=>{const S=b.id===m,T=b.id===_;return l.jsxs("button",{role:"tab",type:"button","aria-selected":S,tabIndex:T?0:-1,className:`${os.tab} ${S?os.tabActive:""}`,onClick:()=>g(b.id),"data-testid":"finding-nav-item",children:[l.jsx("span",{className:os.categoryDot,style:{color:Lc(b.category).text},children:"●"}),l.jsxs("span",{className:os.tabContent,children:[l.jsx("span",{className:os.tabLabel,title:b.title,children:b.title}),l.jsx("span",{className:os.tabMeta,title:b.createdAt,children:gm(b.createdAt)})]})]},b.id)})}),t.length===0&&l.jsx("div",{className:os.empty,children:"No findings yet. Agents will post discoveries here."})]})}function N3(t){if(t.length===0)return[];const s=[...t].sort((o,c)=>o[0]-c[0]),i=[[s[0][0],s[0][1]]];for(let o=1;o<s.length;o++){const c=i[i.length-1],[u,d]=s[o];u<=c[1]+1?c[1]=Math.max(c[1],d):i.push([u,d])}return i}function Ex({text:t,indices:s,highlightClass:i}){if(!s||s.length===0)return l.jsx(l.Fragment,{children:t});const o=N3(s),c=[];let u=0;for(const[d,m]of o)d>u&&c.push(l.jsx("span",{children:t.slice(u,d)},`p${u}`)),c.push(l.jsx("mark",{className:i,children:t.slice(d,m+1)},`m${d}`)),u=m+1;return u<t.length&&c.push(l.jsx("span",{children:t.slice(u)},`p${u}`)),l.jsx(l.Fragment,{children:c})}function j3(t){const s=new Map(t.map(o=>[o.id,{...o,children:[]}])),i=[];for(const o of s.values())o.parentTaskId&&s.has(o.parentTaskId)?s.get(o.parentTaskId).children.push(o):i.push(o);for(const o of s.values())o.children.sort((c,u)=>c.sortOrder-u.sortOrder);return i.sort((o,c)=>o.sortOrder-c.sortOrder)}function C3(t,s){const i=new Map;for(const u of t){const m=u.dependsOn.length>0&&u.dependsOn.some(g=>s.get(g)!=="complete")?"blocked":u.status,h=i.get(m);h?h.push(u):i.set(m,[u])}const o=[],c=new Set;for(const u of ak){c.add(u);const d=i.get(u);if(d&&d.length>0){d.sort((h,g)=>h.sortOrder-g.sortOrder);const m=Sa(u);o.push({status:u,label:m.label,style:m,tasks:d})}}for(const[u,d]of i)if(!c.has(u)&&d.length>0){d.sort((h,g)=>h.sortOrder-g.sortOrder);const m=Sa(u);o.push({status:u,label:m.label,style:m,tasks:d})}return o}const E3="_container_z4i38_1",A3="_header_z4i38_5",D3="_headerActions_z4i38_17",R3="_searchInput_z4i38_23",M3="_searchHighlight_z4i38_56",I3="_groupToggle_z4i38_62",O3="_groupToggleActive_z4i38_89",B3="_addButton_z4i38_93",L3="_taskRow_z4i38_120",U3="_selected_z4i38_140",z3="_expandArrow_z4i38_150",P3="_expanded_z4i38_157",V3="_leafSpacer_z4i38_161",H3="_taskStatusIcon_z4i38_166",$3="_taskTitle_z4i38_170",G3="_workspaceBadge_z4i38_177",q3="_childCountBadge_z4i38_195",F3="_dependencyBadge_z4i38_208",Z3="_blockedBadge_z4i38_220",K3="_addChildButton_z4i38_225",Y3="_emptyState_z4i38_268",J3="_statusGroupHeader_z4i38_275",W3="_statusGroupIcon_z4i38_294",X3="_statusGroupLabel_z4i38_298",Q3="_statusGroupCount_z4i38_303",He={container:E3,header:A3,headerActions:D3,searchInput:R3,searchHighlight:M3,groupToggle:I3,groupToggleActive:O3,addButton:B3,taskRow:L3,selected:U3,expandArrow:z3,expanded:P3,leafSpacer:V3,taskStatusIcon:H3,taskTitle:$3,workspaceBadge:G3,childCountBadge:q3,dependencyBadge:F3,blockedBadge:Z3,addChildButton:K3,emptyState:Y3,statusGroupHeader:J3,statusGroupIcon:W3,statusGroupLabel:X3,statusGroupCount:Q3},e6=[{name:"title",weight:2},{name:"description",weight:1}],Ax=16,t6=16,Dx="grackle-task-group-by-status";function Qy(){try{return localStorage.getItem(Dx)==="true"}catch{return!1}}function n6(t){try{localStorage.setItem(Dx,String(t))}catch{}}function s6({group:t,isExpanded:s,onToggle:i,selectedTaskId:o,navigate:c,titleHighlights:u,workspaceNames:d}){return l.jsxs("div",{"data-testid":`status-group-${t.status}`,children:[l.jsxs("div",{className:He.statusGroupHeader,role:"button",tabIndex:0,"aria-expanded":s,onClick:i,onKeyDown:m=>{(m.key==="Enter"||m.key===" ")&&(m.preventDefault(),i())},children:[l.jsx("span",{className:`${He.expandArrow} ${s?He.expanded:""}`,children:"▸"}),l.jsx("span",{className:He.statusGroupIcon,style:{color:t.style.color},children:t.style.icon}),l.jsx("span",{className:He.statusGroupLabel,children:t.label}),l.jsx("span",{className:He.statusGroupCount,children:t.tasks.length})]}),l.jsx(ds,{children:s&&l.jsx(Dt.div,{initial:{height:0,opacity:0},animate:{height:"auto",opacity:1},exit:{height:0,opacity:0},transition:{duration:.2},style:{overflow:"hidden"},children:t.tasks.map(m=>{const h=Sa(m.status),g=o===m.id,v=m.parentTaskId||!m.workspaceId?void 0:d.get(m.workspaceId);return l.jsxs("div",{onClick:()=>c(Xn(m.id)),className:`${He.taskRow} ${g?He.selected:""}`,style:{"--task-indent":`${Ax}px`},"data-task-id":m.id,children:[l.jsx("span",{className:He.leafSpacer}),l.jsx("span",{className:He.taskStatusIcon,style:{color:h.color},children:h.icon}),l.jsx("span",{className:He.taskTitle,title:m.title,children:l.jsx(Ex,{text:m.title,indices:u.get(m.id),highlightClass:He.searchHighlight})}),v&&l.jsx("span",{className:He.workspaceBadge,title:v,children:v})]},m.id)})})})]})}function Rx({node:t,depth:s,expandedTasks:i,toggleTask:o,selectedTaskId:c,navigate:u,taskStatusById:d,titleHighlights:m,workspaceNames:h}){const g=Sa(t.status),v=t.dependsOn.length>0&&t.dependsOn.some(w=>d.get(w)!=="complete"),_=i.has(t.id),b=t.children.length>0,S=c===t.id,T=Ax+s*t6,j=s===0&&!t.parentTaskId&&t.workspaceId?h.get(t.workspaceId):void 0;return l.jsxs(l.Fragment,{children:[l.jsxs("div",{onClick:()=>u(Xn(t.id)),className:`${He.taskRow} ${S?He.selected:""}`,style:{"--task-indent":`${T}px`},"data-task-id":t.id,children:[b&&l.jsx("span",{className:`${He.expandArrow} ${_?He.expanded:""}`,role:"button",tabIndex:0,"aria-label":_?"Collapse task":"Expand task",onClick:w=>{w.stopPropagation(),o(t.id)},onKeyDown:w=>{(w.key==="Enter"||w.key===" ")&&(w.preventDefault(),w.stopPropagation(),o(t.id))},children:"▸"}),!b&&l.jsx("span",{className:He.leafSpacer}),l.jsx("span",{className:He.taskStatusIcon,style:{color:g.color},children:g.icon}),l.jsx("span",{className:He.taskTitle,title:t.title,children:l.jsx(Ex,{text:t.title,indices:m.get(t.id),highlightClass:He.searchHighlight})}),j&&l.jsx("span",{className:He.workspaceBadge,title:j,children:j}),b&&l.jsxs("span",{className:He.childCountBadge,children:[t.children.filter(w=>w.status==="complete").length,"/",t.children.length]}),t.dependsOn.length>0&&l.jsx("span",{className:`${He.dependencyBadge} ${v?He.blockedBadge:""}`,title:`Depends on: ${t.dependsOn.join(", ")}`,children:v?"blocked":"dep"}),s<_T&&l.jsx("button",{onClick:w=>{w.stopPropagation(),u(ri(t.workspaceId,t.id))},title:"Add child task","aria-label":"Add child task",className:He.addChildButton,children:"+"})]}),l.jsx(ds,{children:b&&_&&l.jsx(Dt.div,{initial:{height:0,opacity:0},animate:{height:"auto",opacity:1},exit:{height:0,opacity:0},transition:{duration:.15},style:{overflow:"hidden"},children:t.children.map(w=>l.jsx(Rx,{node:w,depth:s+1,expandedTasks:i,toggleTask:o,selectedTaskId:c,navigate:u,taskStatusById:d,titleHighlights:m,workspaceNames:h},w.id))})})]})}function a6({workspaces:t,tasks:s}){const i=vt(),[o,c]=y.useState(new Set),[u,d]=y.useState(new Set),[m,h]=y.useState(Qy),[g,v]=y.useState(Qy),[_,b]=y.useState(new Map),S=kt("/tasks/:taskId/*"),T=(S==null?void 0:S.params.taskId)!=="new"?S==null?void 0:S.params.taskId:void 0,N=y.useMemo(()=>new Map(s.map(ie=>[ie.id,ie.status])),[s]),j=y.useMemo(()=>new Map(t.map(ie=>[ie.id,ie.name])),[t]),w=()=>{const ie=!m;n6(ie),h(ie),ie&&(v(!0),b(new Map))},C=ie=>{b(X=>{const O=new Map(X),q=O.has(ie)?O.get(ie):g;return O.set(ie,!q),O})},A=ie=>_.has(ie)?_.get(ie):g,M=ie=>{c(X=>{const O=new Set(X);return O.has(ie)?(O.delete(ie),d(q=>new Set(q).add(ie))):(O.add(ie),d(q=>{const te=new Set(q);return te.delete(ie),te})),O})};y.useEffect(()=>{const ie=new Set(s.filter(X=>X.parentTaskId).map(X=>X.parentTaskId));ie.size>0&&c(X=>{const O=new Set(X);for(const q of ie)u.has(q)||O.add(q);return O})},[s,u]);const[D,E]=y.useState(""),{directMatchTaskIds:$,treeMatchTaskIds:z,titleHighlights:K}=y.useMemo(()=>{if(!D.trim())return{directMatchTaskIds:null,treeMatchTaskIds:null,titleHighlights:new Map};const ie=bT(s,D,e6),X=new Set(ie.map(re=>re.item.id)),O=new Map;for(const re of ie){const ue=re.matches.find(Fe=>Fe.key==="title");ue&&O.set(re.item.id,ue.indices)}const q=new Set(X),te=new Map(s.map(re=>[re.id,re]));for(const re of[...X]){let ue=te.get(re);for(;ue!=null&&ue.parentTaskId;)q.add(ue.parentTaskId),ue=te.get(ue.parentTaskId)}return{directMatchTaskIds:X,treeMatchTaskIds:q,titleHighlights:O}},[D,s]),F=$!==null,ee=F?m?$:z:null,ae=ee?s.filter(ie=>ee.has(ie.id)):s,me=m?[]:j3(ae);return l.jsxs("div",{className:He.container,children:[l.jsxs("div",{className:He.header,children:[l.jsx("span",{children:"Tasks"}),l.jsxs("div",{className:He.headerActions,children:[l.jsx("button",{className:`${He.groupToggle} ${m?He.groupToggleActive:""}`,onClick:w,"aria-label":m?"Switch to tree view":"Group tasks by status","aria-pressed":m,title:m?"Switch to tree view":"Group tasks by status","data-testid":"task-group-by-status-toggle",children:"≡"}),l.jsx("button",{className:He.addButton,onClick:()=>i(ri()),"aria-label":"New task",title:"New task","data-testid":"new-task-button",children:"+"})]})]}),s.length>0&&l.jsx("input",{type:"text",value:D,onChange:ie=>E(ie.target.value),placeholder:"Filter...","aria-label":"Filter tasks",className:He.searchInput,"data-testid":"sidebar-search"}),m?C3(ae,N).map(ie=>l.jsx(s6,{group:ie,isExpanded:A(ie.status),onToggle:()=>C(ie.status),selectedTaskId:T,navigate:i,titleHighlights:K,workspaceNames:j},ie.status)):me.map(ie=>l.jsx(Rx,{node:ie,depth:0,expandedTasks:o,toggleTask:M,selectedTaskId:T,navigate:i,taskStatusById:N,titleHighlights:K,workspaceNames:j},ie.id)),ae.length===0&&!F&&l.jsx("div",{className:He.emptyState,children:"No tasks yet. Click + to create one."}),ae.length===0&&F&&l.jsx("div",{className:He.emptyState,children:"No matching tasks"})]})}const i6="_toast_da8ll_1",o6="_success_da8ll_18",r6="_icon_da8ll_22",l6="_error_da8ll_25",c6="_warning_da8ll_32",u6="_info_da8ll_38",d6="_message_da8ll_53",f6="_close_da8ll_60",dr={toast:i6,success:o6,icon:r6,error:l6,warning:c6,info:u6,message:d6,close:f6},p6={success:"✓",error:"✕",warning:"⚠",info:"ℹ"};function m6({toast:t,onDismiss:s}){return y.useEffect(()=>{const i=setTimeout(()=>s(t.id),t.duration);return()=>clearTimeout(i)},[t.id,t.duration,s]),l.jsxs(Dt.div,{className:`${dr.toast} ${dr[t.variant]}`,role:"status",initial:{opacity:0,y:-16,scale:.94},animate:{opacity:1,y:0,scale:1},exit:{opacity:0,y:-8,scale:.94},transition:{duration:.2,ease:"easeOut"},layout:!0,children:[l.jsx("span",{className:dr.icon,"aria-hidden":"true",children:p6[t.variant]}),l.jsx("span",{className:dr.message,children:t.message}),l.jsx("button",{type:"button",className:dr.close,onClick:()=>s(t.id),"aria-label":"Dismiss notification",children:"×"})]})}const h6="_container_qqse2_1",g6={container:h6};function v6({toasts:t,onDismiss:s}){return l.jsx("div",{className:g6.container,"data-testid":"toast-container",children:l.jsx(ds,{children:t.map(i=>l.jsx(m6,{toast:i,onDismiss:s},i.id))})})}const y6="_callout_1jaue_1",b6="_success_1jaue_11",_6="_icon_1jaue_15",x6="_error_1jaue_18",S6="_warning_1jaue_25",T6="_info_1jaue_32",k6="_content_1jaue_48",w6="_close_1jaue_53",fr={callout:y6,success:b6,icon:_6,error:x6,warning:S6,info:T6,content:k6,close:w6},N6={success:"✓",error:"✕",warning:"⚠",info:"ℹ"};function j6({variant:t="info",children:s,dismissible:i=!1,className:o}){const[c,u]=y.useState(!1);return l.jsx(l.Fragment,{children:!c&&l.jsxs("div",{className:[fr.callout,fr[t],o].filter(Boolean).join(" "),role:t==="error"||t==="warning"?"alert":"status",children:[l.jsx("span",{className:fr.icon,"aria-hidden":"true",children:N6[t]}),l.jsx("span",{className:fr.content,children:s}),i&&l.jsx("button",{type:"button",className:fr.close,onClick:()=>u(!0),"aria-label":"Dismiss",children:"×"})]})})}function C6({currentVersion:t,latestVersion:s,updateAvailable:i,isDocker:o}){if(!i)return l.jsx(l.Fragment,{});const c=o?"docker pull ghcr.io/nick-pape/grackle:latest && docker restart grackle":`npm install -g @grackle-ai/cli@${s}`;return l.jsx("div",{"data-testid":"update-banner",children:l.jsxs(j6,{variant:"info",dismissible:!0,children:[l.jsxs("strong",{children:["Grackle v",s]})," is available (you have v",t,")."," ","Run: ",l.jsx("code",{children:c})]})})}const E6="_container_de44x_1",A6="_emptyState_de44x_8",D6="_card_de44x_14",R6="_cardClickable_de44x_34",M6="_cardHeader_de44x_42",I6="_categoryBadge_de44x_54",O6="_findingTitle_de44x_62",B6="_findingDate_de44x_68",L6="_findingContent_de44x_80",U6="_tags_de44x_86",z6="_tag_de44x_86",Kn={container:E6,emptyState:A6,card:D6,cardClickable:R6,cardHeader:M6,categoryBadge:I6,findingTitle:O6,findingDate:B6,findingContent:L6,tags:U6,tag:z6};function Mx({findings:t,onFindingClick:s}){return t.length===0?l.jsx("div",{className:Kn.emptyState,children:"No findings yet. Agents will post discoveries here."}):l.jsx("div",{className:Kn.container,children:t.map((i,o)=>{const c=Lc(i.category),u=s?Dt.button:Dt.div;return l.jsxs(u,{type:s?"button":void 0,className:`${Kn.card} ${s?Kn.cardClickable:""}`,initial:{opacity:0,y:8},animate:{opacity:1,y:0},transition:{delay:o*.05,duration:.2},onClick:s?()=>{s(i.id)}:void 0,children:[l.jsxs("div",{className:Kn.cardHeader,children:[l.jsx("span",{className:Kn.categoryBadge,style:{background:c.bg,color:c.text},children:i.category}),l.jsx("span",{className:Kn.findingTitle,children:i.title}),l.jsx("span",{className:Kn.findingDate,title:i.createdAt,children:gm(i.createdAt)})]}),l.jsx("div",{className:Kn.findingContent,children:i.content.length>300?i.content.slice(0,300)+"...":i.content}),i.tags.length>0&&l.jsx("div",{className:Kn.tags,children:i.tags.map(d=>l.jsx("span",{className:Kn.tag,style:{color:c.text,textShadow:`0 0 8px ${c.text}`},children:d},d))})]},i.id)})})}const P6="_section_1ingb_14",V6="_sectionTitle_1ingb_26",H6="_sectionDescription_1ingb_35",$6="_tokenList_1ingb_48",G6="_tokenRow_1ingb_55",q6="_tokenBadge_1ingb_68",F6="_tokenName_1ingb_83",Z6="_tokenTarget_1ingb_90",K6="_deleteButton_1ingb_99",Y6="_addForm_1ingb_113",J6="_formRow_1ingb_119",W6="_input_1ingb_125",X6="_select_1ingb_155",Q6="_addButton_1ingb_187",eI="_emptyStateInfo_1ingb_221",tI="_themeOptions_1ingb_229",nI="_themeOption_1ingb_229",sI="_themeOptionSelected_1ingb_254",aI="_themeOptionHeader_1ingb_259",iI="_themeOptionLabel_1ingb_266",oI="_themeOptionDesc_1ingb_273",rI="_variantToggle_1ingb_279",lI="_variantButton_1ingb_286",cI="_variantActive_1ingb_305",uI="_themeSwatches_1ingb_311",dI="_themeSwatch_1ingb_311",fI="_systemToggle_1ingb_325",pI="_systemToggleHint_1ingb_341",mI="_themeActive_1ingb_348",hI="_aboutGrid_1ingb_354",gI="_aboutItem_1ingb_360",vI="_aboutLabel_1ingb_373",yI="_aboutValue_1ingb_379",bI="_aboutDot_1ingb_387",_I="_aboutDotConnected_1ingb_394",xI="_aboutDotDisconnected_1ingb_398",pe={section:P6,sectionTitle:V6,sectionDescription:H6,tokenList:$6,tokenRow:G6,tokenBadge:q6,tokenName:F6,tokenTarget:Z6,deleteButton:K6,addForm:Y6,formRow:J6,input:W6,select:X6,addButton:Q6,emptyStateInfo:eI,themeOptions:tI,themeOption:nI,themeOptionSelected:sI,themeOptionHeader:aI,themeOptionLabel:iI,themeOptionDesc:oI,variantToggle:rI,variantButton:lI,variantActive:cI,themeSwatches:uI,themeSwatch:dI,systemToggle:fI,systemToggleHint:pI,themeActive:mI,aboutGrid:hI,aboutItem:gI,aboutLabel:vI,aboutValue:yI,aboutDot:bI,aboutDotConnected:_I,aboutDotDisconnected:xI},SI=[{value:"env_var",label:"Environment Variable"},{value:"file",label:"File"}];function TI({tokens:t,onSetToken:s,onDeleteToken:i,onShowToast:o}){const[c,u]=y.useState(""),[d,m]=y.useState(""),[h,g]=y.useState("env_var"),[v,_]=y.useState(""),[b,S]=y.useState(null),T=w=>{if(w.preventDefault(),!c||!d)return;const C=h==="env_var"?v||c.toUpperCase()+"_TOKEN":"";s(c,d,h,C,h==="file"?v:""),o==null||o("Token saved successfully","success"),u(""),m(""),_("")},N=w=>{S(w)},j=()=>{b&&(i(b),o==null||o("Token deleted","info")),S(null)};return l.jsxs(l.Fragment,{children:[l.jsx(ii,{isOpen:b!==null,title:"Delete Token?",description:b?`"${b}" will be permanently removed.`:void 0,onConfirm:j,onCancel:()=>S(null)}),l.jsxs("section",{className:pe.section,children:[l.jsx("h3",{className:pe.sectionTitle,children:"Tokens"}),l.jsx("p",{className:pe.sectionDescription,children:"API tokens are auto-pushed to environments when set or updated. Values are write-only."}),t.length===0?l.jsx("div",{className:pe.emptyStateInfo,children:"Add your first API token to enable service integrations."}):l.jsx("div",{className:pe.tokenList,children:t.map(w=>l.jsxs("div",{className:pe.tokenRow,children:[l.jsx("span",{className:pe.tokenBadge,children:w.tokenType}),l.jsx("span",{className:pe.tokenName,children:w.name}),l.jsx("span",{className:pe.tokenTarget,children:w.tokenType==="env_var"?w.envVar:w.filePath}),l.jsx("button",{className:pe.deleteButton,onClick:()=>N(w.name),title:`Delete ${w.name}`,children:"×"})]},w.name))}),l.jsxs("form",{className:pe.addForm,onSubmit:T,children:[l.jsxs("div",{className:pe.formRow,children:[l.jsx("input",{className:pe.input,type:"text",placeholder:"Token name",value:c,onChange:w=>u(w.target.value)}),l.jsx("input",{className:pe.input,type:"password",placeholder:"Value",value:d,onChange:w=>m(w.target.value)})]}),l.jsxs("div",{className:pe.formRow,children:[l.jsx("select",{className:pe.select,value:h,onChange:w=>g(w.target.value),children:SI.map(w=>l.jsx("option",{value:w.value,children:w.label},w.value))}),l.jsx("input",{className:pe.input,type:"text",placeholder:h==="env_var"?"Env var name (e.g. API_TOKEN)":"File path (e.g. /home/user/.token)",value:v,onChange:w=>_(w.target.value)}),l.jsx("button",{className:pe.addButton,type:"submit",children:"Add Token"})]})]})]})]})}const Qc=[{id:"grackle",label:"Grackle",description:"The default Grackle theme — iridescent purple on clean dark.",swatches:["#0e1218","#8b5cf6","#60a5fa","#e5e7eb","#34d399"],variantLightId:"grackle-light",variantDarkId:"grackle-dark"},{id:"grackle-light",label:"Grackle Light",description:"Light Grackle variant.",hidden:!0},{id:"grackle-dark",label:"Grackle Dark",description:"Dark Grackle variant.",hidden:!0},{id:"glass",label:"Glassmorphism",description:"Dark frosted-glass aesthetic with backdrop blur effects.",swatches:["#0a0c14","#4ecca3","#70a1ff","#e2e8f0","#a855f7"]},{id:"matrix",label:"Matrix",description:"Phosphor-green CRT terminal with scanlines and glow.",swatches:["#050505","#00ff41","#00bfff","#33ff77","#ffb000"]},{id:"brutalist",label:"Neubrutalism",description:"Thick borders, raw colors, bold type — ugly on purpose.",swatches:["#f5f0e8","#ff5757","#5ce1e6","#1a1a1a","#ffde59"],variantLightId:"brutalist-light",variantDarkId:"brutalist-dark"},{id:"brutalist-light",label:"Neubrutalism Light",description:"Light neubrutalism variant.",hidden:!0},{id:"brutalist-dark",label:"Neubrutalism Dark",description:"Dark neubrutalism variant.",hidden:!0},{id:"monokai",label:"Monokai",description:"Classic warm editor palette — pink, green, and purple.",swatches:["#272822","#f92672","#a6e22e","#f8f8f2","#ae81ff"],variantLightId:"monokai-light",variantDarkId:"monokai-dark"},{id:"monokai-dark",label:"Monokai Dark",description:"Dark Monokai variant.",hidden:!0},{id:"monokai-light",label:"Monokai Light",description:"Light Monokai variant.",hidden:!0},{id:"ubuntu",label:"Ubuntu",description:"Aubergine terminal with the GNOME Tango palette.",swatches:["#300a24","#8ae234","#ef2929","#eeeeec","#fce94f"]},{id:"sandstone",label:"Sandstone",description:"Warm terracotta accent on dark brown, in the style of Claude Code.",swatches:["#1a1815","#C15F3C","#6b8afd","#e8e6e3","#a78bfa"]},{id:"verdigris",label:"Verdigris",description:"Teal accent on charcoal, in the style of ChatGPT.",swatches:["#141414","#00a67e","#3b82f6","#ececec","#ab68ff"]},{id:"primer",label:"Primer",description:"Blue accent on ink-dark grey, in the style of GitHub.",swatches:["#0d1117","#58a6ff","#3fb950","#c9d1d9","#bc8cff"]}],Ix=new Set(Qc.map(t=>t.id)),eb="grackle";function yp(t){return Qc.find(s=>s.id===t)}function kI({themeId:t,resolvedThemeId:s,onSetTheme:i,preferSystem:o,onSetPreferSystem:c}){return l.jsxs("section",{className:pe.section,children:[l.jsx("h3",{className:pe.sectionTitle,children:"Appearance"}),l.jsx("p",{className:pe.sectionDescription,children:"Choose how Grackle looks across the app."}),l.jsx("div",{className:pe.themeOptions,children:Qc.filter(u=>!u.hidden).map(u=>{const d=!!(u.variantLightId&&u.variantDarkId),m=d?t===u.id||t===u.variantLightId||t===u.variantDarkId:t===u.id,h=d&&s===u.variantLightId;return l.jsxs("button",{type:"button",className:`${pe.themeOption} ${m?pe.themeOptionSelected:""}`,"aria-pressed":m,onClick:()=>i(u.id),children:[l.jsxs("span",{className:pe.themeOptionHeader,children:[l.jsxs("span",{children:[l.jsx("span",{className:pe.themeOptionLabel,children:u.label}),l.jsx("span",{className:pe.themeOptionDesc,children:u.description})]}),d&&l.jsxs("span",{className:pe.variantToggle,children:[l.jsx("span",{role:"button",tabIndex:0,className:`${pe.variantButton} ${m&&h?pe.variantActive:""}`,onClick:g=>{g.stopPropagation(),c(!1),i(u.variantLightId)},onKeyDown:g=>{(g.key==="Enter"||g.key===" ")&&(g.preventDefault(),g.stopPropagation(),c(!1),i(u.variantLightId))},"aria-label":"Light variant","aria-pressed":m&&h,children:"☼"}),l.jsx("span",{role:"button",tabIndex:0,className:`${pe.variantButton} ${m&&!h?pe.variantActive:""}`,onClick:g=>{g.stopPropagation(),c(!1),i(u.variantDarkId)},onKeyDown:g=>{(g.key==="Enter"||g.key===" ")&&(g.preventDefault(),g.stopPropagation(),c(!1),i(u.variantDarkId))},"aria-label":"Dark variant","aria-pressed":m&&!h,children:"☾"})]})]}),u.swatches&&l.jsx("span",{className:pe.themeSwatches,children:u.swatches.map((g,v)=>l.jsx("span",{className:pe.themeSwatch,style:{background:g}},v))})]},u.id)})}),l.jsxs("label",{className:pe.systemToggle,children:[l.jsx("input",{type:"checkbox",checked:o,onChange:u=>c(u.target.checked)}),l.jsx("span",{children:"Match system light/dark preference"})]}),l.jsx("p",{className:pe.systemToggleHint,children:"Automatically switches between light and dark variants when available."}),l.jsxs("p",{className:pe.themeActive,children:["Active theme: ",l.jsx("strong",{children:s})]})]})}function wI({connected:t,environments:s,sessions:i}){const o=s.filter(d=>d.status==="connected").length,c=s.length,u=i.filter(d=>["running","idle"].includes(d.status)).length;return l.jsxs("section",{className:pe.section,"data-testid":"about-panel",children:[l.jsx("h3",{className:pe.sectionTitle,children:"About"}),l.jsx("p",{className:pe.sectionDescription,children:"Connection status and application information."}),l.jsxs("div",{className:pe.aboutGrid,children:[l.jsxs("div",{className:pe.aboutItem,children:[l.jsx("span",{className:pe.aboutLabel,children:"Connection"}),l.jsxs("span",{className:pe.aboutValue,children:[l.jsx("span",{className:`${pe.aboutDot} ${t?pe.aboutDotConnected:pe.aboutDotDisconnected}`}),t?"Connected":"Disconnected"]})]}),l.jsxs("div",{className:pe.aboutItem,children:[l.jsx("span",{className:pe.aboutLabel,children:"Environments"}),l.jsxs("span",{className:pe.aboutValue,children:[o,"/",c," connected"]})]}),l.jsxs("div",{className:pe.aboutItem,children:[l.jsx("span",{className:pe.aboutLabel,children:"Active Sessions"}),l.jsx("span",{className:pe.aboutValue,children:u})]}),l.jsxs("div",{className:pe.aboutItem,children:[l.jsx("span",{className:pe.aboutLabel,children:"Version"}),l.jsx("span",{className:pe.aboutValue,children:"0.88.0"})]})]})]})}const NI="_container_cddyd_1",jI="_header_cddyd_8",CI="_headerTitle_cddyd_35",EI="_badge_cddyd_44",AI="_headerActions_cddyd_54",DI="_body_cddyd_61",RI="_formContent_cddyd_73",MI="_section_cddyd_85",II="_label_cddyd_91",OI="_titleInput_cddyd_98",BI="_descriptionTextarea_cddyd_131",LI="_parentContext_cddyd_167",UI="_parentLabel_cddyd_175",zI="_parentName_cddyd_182",PI="_personaSelect_cddyd_186",VI="_depList_cddyd_220",HI="_depItem_cddyd_226",$I="_depItemSelected_cddyd_248",GI="_noDeps_cddyd_252",qI="_btnPrimary_cddyd_258",FI="_btnGhost_cddyd_289",Ye={container:NI,header:jI,headerTitle:CI,badge:EI,headerActions:AI,body:DI,formContent:RI,section:MI,label:II,titleInput:OI,descriptionTextarea:BI,parentContext:LI,parentLabel:UI,parentName:zI,personaSelect:PI,depList:VI,depItem:HI,depItemSelected:$I,noDeps:GI,btnPrimary:qI,btnGhost:FI};function Ox({mode:t,taskId:s,workspaceId:i,parentTaskId:o,environmentId:c,tasks:u,workspaces:d,personas:m,onCreateTask:h,onUpdateTask:g,onEditDone:v,onShowToast:_}){const b=vt(),S=t==="edit",T=S&&s?u.find(de=>de.id===s):void 0,N=S?(T==null?void 0:T.workspaceId)??"":i??"",[j,w]=y.useState(N),C=N||j,A=d.find(de=>de.id===C),M=c??(A==null?void 0:A.environmentId),D=!S&&!i,E=S?(T==null?void 0:T.parentTaskId)??"":o??"",$=E?u.find(de=>de.id===E):void 0,[z,K]=y.useState((T==null?void 0:T.title)??""),[F,ee]=y.useState((T==null?void 0:T.description)??""),[ae,me]=y.useState((T==null?void 0:T.dependsOn)??[]),[ie,X]=y.useState((T==null?void 0:T.defaultPersonaId)??""),[O,q]=y.useState((T==null?void 0:T.canDecompose)??!1),[te,re]=y.useState(!1),ue=y.useRef(!1);y.useEffect(()=>{S&&T&&!ue.current&&(ue.current=!0,K(T.title),ee(T.description),me(T.dependsOn),X(T.defaultPersonaId),q(T.canDecompose))},[S,T]);const Fe=u.filter(de=>de.workspaceId===C&&(!S||de.id!==s)&&de.id!==E),Ne=z.trim().length>0&&(!S||T!==void 0)&&C.length>0,ke=de=>{me(Ie=>Ie.includes(de)?Ie.filter(yt=>yt!==de):[...Ie,de])},Me=()=>{!Ne||te||S&&T===void 0||(S&&s?(g(s,z.trim(),F,ae,ie),_==null||_("Task updated","success"),v?v():b(Xn(s,void 0,C,M),{replace:!0})):(re(!0),h(C,z.trim(),F,ae.length>0?ae:void 0,E||void 0,ie,O,()=>{_==null||_("Task created","success"),b(i?ni(i,M):"/tasks",{replace:!0})},de=>{_==null||_(de,"error"),re(!1)})))},le=()=>{if(v){v();return}b(S&&s?Xn(s,void 0,C,M):i?ni(i,M):"/tasks")},ve=S?"edit task":E?"child task":"new task";return l.jsxs("div",{className:Ye.container,children:[l.jsxs("div",{className:Ye.header,children:[l.jsxs("div",{className:Ye.headerTitle,children:[l.jsx("span",{className:Ye.badge,children:ve}),$&&l.jsxs("span",{className:Ye.parentContext,children:[l.jsx("span",{className:Ye.parentLabel,children:"Child of"}),l.jsx("span",{className:Ye.parentName,children:$.title})]})]}),l.jsxs("div",{className:Ye.headerActions,children:[l.jsx("button",{onClick:Me,disabled:!Ne||te,className:Ye.btnPrimary,"data-testid":"task-edit-save",children:te?"Creating…":S?"Save Changes":"Create"}),l.jsx("button",{onClick:le,className:Ye.btnGhost,children:"Cancel"})]})]}),l.jsx("div",{className:Ye.body,children:l.jsxs("div",{className:Ye.formContent,children:[D&&l.jsxs("div",{className:Ye.section,children:[l.jsx("label",{className:Ye.label,htmlFor:"task-edit-workspace",children:"Workspace"}),l.jsxs("select",{id:"task-edit-workspace",value:j,onChange:de=>w(de.target.value),className:Ye.personaSelect,"data-testid":"task-edit-workspace",children:[l.jsx("option",{value:"",children:"Select a workspace..."}),d.map(de=>l.jsx("option",{value:de.id,children:de.name},de.id))]})]}),l.jsxs("div",{className:Ye.section,children:[l.jsx("label",{className:Ye.label,htmlFor:"task-edit-title",children:"Title"}),l.jsx("input",{id:"task-edit-title",type:"text",value:z,onChange:de=>K(de.target.value),placeholder:"Task title...",autoFocus:!0,className:Ye.titleInput,"data-testid":"task-edit-title",onKeyDown:de=>{de.key==="Enter"&&Ne&&Me()}})]}),l.jsxs("div",{className:Ye.section,children:[l.jsx("label",{className:Ye.label,htmlFor:"task-edit-description",children:"Description"}),l.jsx("textarea",{id:"task-edit-description",value:F,onChange:de=>ee(de.target.value),placeholder:"Describe the task... (markdown supported)",className:Ye.descriptionTextarea,"data-testid":"task-edit-description",rows:8})]}),l.jsxs("div",{className:Ye.section,children:[l.jsx("label",{className:Ye.label,htmlFor:"task-edit-persona",children:"Default Persona"}),l.jsxs("select",{id:"task-edit-persona",value:ie,onChange:de=>X(de.target.value),className:Ye.personaSelect,"data-testid":"task-edit-persona",children:[l.jsx("option",{value:"",children:"(Inherit)"}),m.map(de=>l.jsx("option",{value:de.id,children:de.name},de.id))]})]}),!S&&l.jsx("div",{className:Ye.section,children:l.jsxs("label",{className:Ye.depItem,"data-testid":"task-edit-can-decompose",children:[l.jsx("input",{type:"checkbox",checked:O,onChange:de=>q(de.target.checked)}),"Can spawn subtasks"]})}),l.jsxs("div",{className:Ye.section,children:[l.jsx("div",{className:Ye.label,children:"Dependencies"}),Fe.length===0?l.jsx("div",{className:Ye.noDeps,children:"No other tasks in this workspace"}):l.jsx("div",{className:Ye.depList,children:Fe.map(de=>{const Ie=ae.includes(de.id);return l.jsxs("label",{className:`${Ye.depItem} ${Ie?Ye.depItemSelected:""}`,"data-testid":`dep-option-${de.id}`,children:[l.jsx("input",{type:"checkbox",checked:Ie,onChange:()=>ke(de.id)}),de.title,l.jsxs("span",{style:{opacity:.5,fontSize:"11px",marginLeft:"4px"},children:["(",de.status,")"]})]},de.id)})})]})]})})]})}const ZI="_container_legrg_1",KI="_header_legrg_8",YI="_headerTitle_legrg_35",JI="_badge_legrg_44",WI="_headerActions_legrg_54",XI="_body_legrg_61",QI="_formContent_legrg_73",eO="_section_legrg_85",tO="_label_legrg_91",nO="_nameInput_legrg_98",sO="_fieldInput_legrg_131",aO="_adapterSelect_legrg_164",iO="_readOnlyValue_legrg_198",oO="_codespaceSection_legrg_204",rO="_codespaceActions_legrg_210",lO="_creatingHint_legrg_216",cO="_errorHint_legrg_222",uO="_btnPrimary_legrg_235",dO="_btnGhost_legrg_266",ne={container:ZI,header:KI,headerTitle:YI,badge:JI,headerActions:WI,body:XI,formContent:QI,section:eO,label:tO,nameInput:nO,fieldInput:sO,adapterSelect:aO,readOnlyValue:iO,codespaceSection:oO,codespaceActions:rO,creatingHint:lO,errorHint:cO,btnPrimary:uO,btnGhost:dO},kc=1,wc=65535;function Uf(t){if(!t.trim())return!0;const s=Number(t);return Number.isInteger(s)&&s>=kc&&s<=wc}function zf(t){try{const s=JSON.parse(t);if(typeof s=="object"&&s!==null&&!Array.isArray(s))return s}catch{}return{}}function fO({codespaceName:t,onCodespaceNameChange:s,envName:i,onEnvNameChange:o,codespaces:c,codespaceError:u,codespaceListError:d,codespaceCreating:m,onCreateCodespace:h}){const[g,v]=y.useState("pick"),[_,b]=y.useState(""),[S,T]=y.useState("");return g==="create"?l.jsxs("div",{className:ne.codespaceSection,children:[l.jsxs("div",{className:ne.section,children:[l.jsx("label",{className:ne.label,children:"Repository"}),l.jsx("input",{type:"text",value:_,onChange:N=>b(N.target.value),placeholder:"owner/repo",className:ne.fieldInput,"data-testid":"env-codespace-repo"})]}),l.jsxs("div",{className:ne.section,children:[l.jsx("label",{className:ne.label,children:"Machine Type"}),l.jsx("input",{type:"text",value:S,onChange:N=>T(N.target.value),placeholder:"Machine type (optional)...",className:ne.fieldInput,"data-testid":"env-codespace-machine"})]}),l.jsxs("div",{className:ne.codespaceActions,children:[l.jsx("button",{onClick:()=>{_.trim()&&(h(_.trim(),S.trim()||void 0),v("pick"),b(""),T(""))},disabled:!_.trim(),className:ne.btnPrimary,children:"Create"}),l.jsx("button",{onClick:()=>{v("pick"),b(""),T("")},className:ne.btnGhost,children:"Cancel"})]})]}):l.jsx("div",{className:ne.codespaceSection,children:l.jsxs("div",{className:ne.section,children:[l.jsx("label",{className:ne.label,children:"Codespace"}),!d&&l.jsxs("select",{value:t,onChange:N=>{N.target.value==="__create__"?(v("create"),s("")):(s(N.target.value),N.target.value&&!i.trim()&&o(N.target.value))},disabled:m,className:ne.adapterSelect,"data-testid":"env-codespace-select",children:[l.jsx("option",{value:"",children:"Select a codespace..."}),c.map(N=>l.jsxs("option",{value:N.name,children:[N.name," (",N.repository,") — ",N.state]},N.name)),l.jsx("option",{value:"__create__",children:"Create new from repo..."})]}),m&&l.jsx("span",{className:ne.creatingHint,children:"Creating codespace..."}),d&&l.jsxs(l.Fragment,{children:[l.jsx("span",{className:ne.errorHint,children:d}),l.jsx("input",{type:"text",value:t,onChange:N=>s(N.target.value),placeholder:"Or enter codespace name manually...",className:ne.fieldInput,"data-testid":"env-codespace-manual"})]}),u&&!d&&l.jsx("span",{className:ne.errorHint,children:u})]})})}function Bx({mode:t,environmentId:s,environments:i,onAddEnvironment:o,onUpdateEnvironment:c,onListCodespaces:u,codespaces:d,codespaceError:m,codespaceListError:h,codespaceCreating:g,onCreateCodespace:v,onShowToast:_}){const b=vt(),S=t==="edit",T=S&&s?i.find(le=>le.id===s):void 0,[N,j]=y.useState(""),[w,C]=y.useState("local"),[A,M]=y.useState(""),[D,E]=y.useState(""),[$,z]=y.useState(""),[K,F]=y.useState(""),[ee,ae]=y.useState(""),[me,ie]=y.useState(""),[X,O]=y.useState(""),[q,te]=y.useState(null),re=y.useCallback(()=>{const le={};if(w==="local"){if(A.trim()&&(le.host=A.trim()),D.trim()){const ve=Number(D);Number.isInteger(ve)&&(le.port=ve)}}else if(w==="ssh"){if(le.host=A.trim(),$.trim()&&(le.user=$.trim()),D.trim()){const ve=Number(D);Number.isInteger(ve)&&(le.sshPort=ve)}K.trim()&&(le.identityFile=K.trim())}else w==="docker"?(ee.trim()&&(le.image=ee.trim()),me.trim()&&(le.repo=me.trim())):w==="codespace"&&(le.codespaceName=X.trim());return le},[w,A,D,$,K,ee,me,X]),ue=()=>!(!N.trim()||w==="ssh"&&!A.trim()||w==="codespace"&&!X.trim()||(w==="local"||w==="ssh")&&!Uf(D)),Fe=()=>{ue()&&(o(N.trim(),w,re()),_==null||_("Environment added successfully","success"),b(ao,{replace:!0}))},Ne=()=>{b(s?si(s):ao)},ke=y.useCallback((le,ve)=>{if(!T||!s)return;const de=zf(T.adapterConfig),Ie=ve.trim();Ie?de[le]=Ie:delete de[le],c(s,{adapterConfig:de})},[T,s,c]),Me=y.useCallback((le,ve)=>{if(!T||!s)return;const de=zf(T.adapterConfig);if(ve.trim()){const Ie=Number(ve);Number.isInteger(Ie)&&Ie>=kc&&Ie<=wc&&(de[le]=Ie)}else delete de[le];c(s,{adapterConfig:de})},[T,s,c]);if(S){if(!T)return l.jsxs("div",{className:ne.container,children:[l.jsxs("div",{className:ne.header,children:[l.jsx("div",{className:ne.headerTitle,children:l.jsx("span",{className:ne.badge,children:"edit environment"})}),l.jsx("div",{className:ne.headerActions,children:l.jsx("button",{onClick:Ne,className:ne.btnGhost,children:"Back"})})]}),l.jsx("div",{className:ne.body,children:l.jsx("div",{className:ne.formContent,children:l.jsx("span",{className:ne.readOnlyValue,children:"Environment not found"})})})]});const le=zf(T.adapterConfig);return l.jsxs("div",{className:ne.container,"data-testid":"env-edit-panel",children:[l.jsxs("div",{className:ne.header,children:[l.jsx("div",{className:ne.headerTitle,children:l.jsx("span",{className:ne.badge,children:"edit environment"})}),l.jsx("div",{className:ne.headerActions,children:l.jsx("button",{onClick:Ne,className:ne.btnGhost,"data-testid":"env-edit-back",children:"Back"})})]}),l.jsx("div",{className:ne.body,children:l.jsxs("div",{className:ne.formContent,children:[l.jsxs("div",{className:ne.section,children:[l.jsx("label",{className:ne.label,children:"Name"}),l.jsx(Kt,{value:T.displayName,onSave:ve=>{s&&c(s,{displayName:ve})},validate:ve=>ve.trim()===""?"Name cannot be empty":void 0,mode:"edit",fieldId:"name",activeFieldId:q,onActivate:te,placeholder:"Environment name",ariaLabel:"Environment name","data-testid":"env-edit-name"})]}),l.jsxs("div",{className:ne.section,children:[l.jsx("label",{className:ne.label,children:"Adapter Type"}),l.jsx("span",{className:ne.readOnlyValue,"data-testid":"env-edit-adapter-type",children:T.adapterType})]}),T.adapterType==="local"&&l.jsxs(l.Fragment,{children:[l.jsxs("div",{className:ne.section,children:[l.jsx("label",{className:ne.label,children:"Host"}),l.jsx(Kt,{value:String(le.host??""),onSave:ve=>ke("host",ve),mode:"edit",fieldId:"host",activeFieldId:q,onActivate:te,placeholder:"(default)",ariaLabel:"Host","data-testid":"env-edit-host"})]}),l.jsxs("div",{className:ne.section,children:[l.jsx("label",{className:ne.label,children:"Port"}),l.jsx(Kt,{value:String(le.port??""),onSave:ve=>Me("port",ve),validate:ve=>Uf(ve)?void 0:"Port must be 1-65535",mode:"edit",fieldId:"port",activeFieldId:q,onActivate:te,placeholder:"(default)",ariaLabel:"Port","data-testid":"env-edit-port"})]})]}),T.adapterType==="ssh"&&l.jsxs(l.Fragment,{children:[l.jsxs("div",{className:ne.section,children:[l.jsx("label",{className:ne.label,children:"Host"}),l.jsx(Kt,{value:String(le.host??""),onSave:ve=>ke("host",ve),validate:ve=>ve.trim()===""?"Host is required":void 0,mode:"edit",fieldId:"host",activeFieldId:q,onActivate:te,placeholder:"hostname or IP",ariaLabel:"Host","data-testid":"env-edit-host"})]}),l.jsxs("div",{className:ne.section,children:[l.jsx("label",{className:ne.label,children:"User"}),l.jsx(Kt,{value:String(le.user??""),onSave:ve=>ke("user",ve),mode:"edit",fieldId:"user",activeFieldId:q,onActivate:te,placeholder:"(default)",ariaLabel:"User","data-testid":"env-edit-user"})]}),l.jsxs("div",{className:ne.section,children:[l.jsx("label",{className:ne.label,children:"SSH Port"}),l.jsx(Kt,{value:String(le.sshPort??""),onSave:ve=>Me("sshPort",ve),validate:ve=>Uf(ve)?void 0:"Port must be 1-65535",mode:"edit",fieldId:"sshPort",activeFieldId:q,onActivate:te,placeholder:"22",ariaLabel:"SSH Port","data-testid":"env-edit-ssh-port"})]}),l.jsxs("div",{className:ne.section,children:[l.jsx("label",{className:ne.label,children:"Identity File"}),l.jsx(Kt,{value:String(le.identityFile??""),onSave:ve=>ke("identityFile",ve),mode:"edit",fieldId:"identityFile",activeFieldId:q,onActivate:te,placeholder:"~/.ssh/id_rsa",ariaLabel:"Identity File","data-testid":"env-edit-identity-file"})]})]}),T.adapterType==="docker"&&l.jsxs(l.Fragment,{children:[l.jsxs("div",{className:ne.section,children:[l.jsx("label",{className:ne.label,children:"Image"}),l.jsx(Kt,{value:String(le.image??""),onSave:ve=>ke("image",ve),mode:"edit",fieldId:"image",activeFieldId:q,onActivate:te,placeholder:"(default)",ariaLabel:"Image","data-testid":"env-edit-image"})]}),l.jsxs("div",{className:ne.section,children:[l.jsx("label",{className:ne.label,children:"Repo"}),l.jsx(Kt,{value:String(le.repo??""),onSave:ve=>ke("repo",ve),mode:"edit",fieldId:"repo",activeFieldId:q,onActivate:te,placeholder:"(none)",ariaLabel:"Repo","data-testid":"env-edit-repo"})]})]}),T.adapterType==="codespace"&&l.jsxs("div",{className:ne.section,children:[l.jsx("label",{className:ne.label,children:"Codespace Name"}),l.jsx(Kt,{value:String(le.codespaceName??""),onSave:ve=>ke("codespaceName",ve),validate:ve=>ve.trim()===""?"Codespace name is required":void 0,mode:"edit",fieldId:"codespaceName",activeFieldId:q,onActivate:te,placeholder:"codespace-name",ariaLabel:"Codespace Name","data-testid":"env-edit-codespace-name"})]})]})})]})}return l.jsxs("div",{className:ne.container,"data-testid":"env-create-panel",children:[l.jsxs("div",{className:ne.header,children:[l.jsx("div",{className:ne.headerTitle,children:l.jsx("span",{className:ne.badge,children:"new environment"})}),l.jsxs("div",{className:ne.headerActions,children:[l.jsx("button",{onClick:Fe,disabled:!ue(),className:ne.btnPrimary,"data-testid":"env-create-submit",children:"Create"}),l.jsx("button",{onClick:Ne,className:ne.btnGhost,children:"Cancel"})]})]}),l.jsx("div",{className:ne.body,children:l.jsxs("div",{className:ne.formContent,children:[l.jsxs("div",{className:ne.section,children:[l.jsx("label",{className:ne.label,htmlFor:"env-create-name",children:"Name"}),l.jsx("input",{id:"env-create-name",type:"text",value:N,onChange:le=>j(le.target.value),placeholder:"Environment name...",autoFocus:!0,className:ne.nameInput,"data-testid":"env-create-name",onKeyDown:le=>{le.key==="Enter"&&ue()&&Fe()}})]}),l.jsxs("div",{className:ne.section,children:[l.jsx("label",{className:ne.label,htmlFor:"env-create-adapter",children:"Adapter Type"}),l.jsxs("select",{id:"env-create-adapter",value:w,onChange:le=>{C(le.target.value),le.target.value==="codespace"&&u()},className:ne.adapterSelect,"data-testid":"env-create-adapter",children:[l.jsx("option",{value:"local",children:"local"}),l.jsx("option",{value:"ssh",children:"ssh"}),l.jsx("option",{value:"docker",children:"docker"}),l.jsx("option",{value:"codespace",children:"codespace"})]})]}),w==="local"&&l.jsxs(l.Fragment,{children:[l.jsxs("div",{className:ne.section,children:[l.jsx("label",{className:ne.label,htmlFor:"env-create-host",children:"Host"}),l.jsx("input",{id:"env-create-host",type:"text",value:A,onChange:le=>M(le.target.value),placeholder:"Host (optional)...",className:ne.fieldInput,"data-testid":"env-create-host"})]}),l.jsxs("div",{className:ne.section,children:[l.jsx("label",{className:ne.label,htmlFor:"env-create-port",children:"Port"}),l.jsx("input",{id:"env-create-port",type:"number",min:kc,max:wc,value:D,onChange:le=>E(le.target.value),placeholder:"Port (optional)...",className:ne.fieldInput,"data-testid":"env-create-port"})]})]}),w==="ssh"&&l.jsxs(l.Fragment,{children:[l.jsxs("div",{className:ne.section,children:[l.jsx("label",{className:ne.label,htmlFor:"env-create-host",children:"Host"}),l.jsx("input",{id:"env-create-host",type:"text",value:A,onChange:le=>M(le.target.value),placeholder:"Host (required)...",className:ne.fieldInput,"data-testid":"env-create-host"})]}),l.jsxs("div",{className:ne.section,children:[l.jsx("label",{className:ne.label,htmlFor:"env-create-user",children:"User"}),l.jsx("input",{id:"env-create-user",type:"text",value:$,onChange:le=>z(le.target.value),placeholder:"User (optional)...",className:ne.fieldInput,"data-testid":"env-create-user"})]}),l.jsxs("div",{className:ne.section,children:[l.jsx("label",{className:ne.label,htmlFor:"env-create-port",children:"SSH Port"}),l.jsx("input",{id:"env-create-port",type:"number",min:kc,max:wc,value:D,onChange:le=>E(le.target.value),placeholder:"SSH port (optional)...",className:ne.fieldInput,"data-testid":"env-create-port"})]}),l.jsxs("div",{className:ne.section,children:[l.jsx("label",{className:ne.label,htmlFor:"env-create-identity",children:"Identity File"}),l.jsx("input",{id:"env-create-identity",type:"text",value:K,onChange:le=>F(le.target.value),placeholder:"Identity file (optional)...",className:ne.fieldInput,"data-testid":"env-create-identity"})]})]}),w==="docker"&&l.jsxs(l.Fragment,{children:[l.jsxs("div",{className:ne.section,children:[l.jsx("label",{className:ne.label,htmlFor:"env-create-image",children:"Image"}),l.jsx("input",{id:"env-create-image",type:"text",value:ee,onChange:le=>ae(le.target.value),placeholder:"Image (optional)...",className:ne.fieldInput,"data-testid":"env-create-image"})]}),l.jsxs("div",{className:ne.section,children:[l.jsx("label",{className:ne.label,htmlFor:"env-create-repo",children:"Repo"}),l.jsx("input",{id:"env-create-repo",type:"text",value:me,onChange:le=>ie(le.target.value),placeholder:"Repo (optional)...",className:ne.fieldInput,"data-testid":"env-create-repo"})]})]}),w==="codespace"&&l.jsx(fO,{codespaceName:X,onCodespaceNameChange:O,envName:N,onEnvNameChange:j,codespaces:d,codespaceError:m,codespaceListError:h,codespaceCreating:g,onCreateCodespace:v})]})})]})}const pO="_group_1iprv_1",mO="_groupTitle_1iprv_8",hO="_shortcutList_1iprv_17",gO="_shortcutRow_1iprv_23",vO="_keys_1iprv_36",yO="_kbd_1iprv_43",bO="_description_1iprv_60",Ja={group:pO,groupTitle:mO,shortcutList:hO,shortcutRow:gO,keys:vO,kbd:yO,description:bO},_O=[{title:"Global",shortcuts:[{keys:["?"],description:"Open keyboard shortcuts reference"},{keys:["N"],description:"Create a new task"},{keys:["Escape"],description:"Close dialog or cancel editing"}]},{title:"Task Page",shortcuts:[{keys:["1"],description:"Switch to Overview tab"},{keys:["2"],description:"Switch to Stream tab"},{keys:["3"],description:"Switch to Findings tab"}]},{title:"Workspace Page",shortcuts:[{keys:["1"],description:"Switch to Graph view"},{keys:["2"],description:"Switch to Board view"},{keys:["3"],description:"Switch to Tasks view"}]},{title:"Navigation Lists",shortcuts:[{keys:["←"],description:"Previous tab (horizontal nav)"},{keys:["→"],description:"Next tab (horizontal nav)"},{keys:["↑"],description:"Previous item (vertical nav)"},{keys:["↓"],description:"Next item (vertical nav)"},{keys:["J"],description:"Next item (alias for arrow down/right)"},{keys:["K"],description:"Previous item (alias for arrow up/left)"},{keys:["Home"],description:"Jump to first item"},{keys:["End"],description:"Jump to last item"}]},{title:"Editing",shortcuts:[{keys:["Enter"],description:"Activate / save inline edit"},{keys:["Space"],description:"Activate button or start editing"},{keys:["Escape"],description:"Cancel edit and discard changes"}]},{title:"Chat",shortcuts:[{keys:["Enter"],description:"Send message (when input is focused)"}]}];function xO(){return l.jsxs("section",{className:pe.section,"data-testid":"keyboard-shortcuts-panel",children:[l.jsx("h3",{className:pe.sectionTitle,children:"Keyboard Shortcuts"}),l.jsx("p",{className:pe.sectionDescription,children:"Keyboard shortcuts for navigating and interacting with Grackle. Global shortcuts are suppressed while typing in text fields."}),_O.map(t=>l.jsxs("div",{className:Ja.group,children:[l.jsx("h4",{className:Ja.groupTitle,children:t.title}),l.jsx("div",{className:Ja.shortcutList,children:t.shortcuts.map(s=>l.jsxs("div",{className:Ja.shortcutRow,children:[l.jsx("span",{className:Ja.keys,children:s.keys.map(i=>l.jsx("kbd",{className:Ja.kbd,children:i},i))}),l.jsx("span",{className:Ja.description,children:s.description})]},s.description))})]},t.title))]})}const SO="_workpadSection_y8nj9_1",TO="_workpadLabel_y8nj9_9",kO="_workpadStatus_y8nj9_17",wO="_workpadSummary_y8nj9_23",NO="_workpadExtra_y8nj9_29",ga={workpadSection:SO,workpadLabel:TO,workpadStatus:kO,workpadSummary:wO,workpadExtra:NO};function jO({workpad:t}){if(!t)return;let s;try{const i=JSON.parse(t);if(i==null||typeof i!="object"||Array.isArray(i))return;s=i}catch{return l.jsxs("div",{className:ga.workpadSection,"data-testid":"workpad-panel",children:[l.jsx("div",{className:ga.workpadLabel,children:"Workpad"}),l.jsx("div",{className:ga.workpadExtra,children:t})]})}if(!(!s.status&&!s.summary&&!s.extra))return l.jsxs("div",{className:ga.workpadSection,"data-testid":"workpad-panel",children:[l.jsx("div",{className:ga.workpadLabel,children:"Workpad"}),s.status&&l.jsx("div",{className:ga.workpadStatus,"data-testid":"workpad-status",children:s.status}),s.summary&&l.jsx("div",{className:ga.workpadSummary,"data-testid":"workpad-summary",children:s.summary}),s.extra&&Object.keys(s.extra).length>0&&l.jsx("div",{className:ga.workpadExtra,"data-testid":"workpad-extra",children:JSON.stringify(s.extra,null,2)})]})}const CO=[{key:"claude",label:"Claude",description:"Forward Claude credentials for AI agent access.",options:[{value:"off",label:"Off"},{value:"subscription",label:"Subscription"},{value:"api_key",label:"API Key"}]},{key:"github",label:"GitHub",description:"Forward GITHUB_TOKEN and GH_TOKEN for git operations.",options:[{value:"off",label:"Off"},{value:"on",label:"On"}]},{key:"copilot",label:"Copilot",description:"Forward Copilot tokens (COPILOT_GITHUB_TOKEN, CLI config).",options:[{value:"off",label:"Off"},{value:"on",label:"On"}]},{key:"codex",label:"Codex",description:"Forward OPENAI_API_KEY for Codex/OpenAI access.",options:[{value:"off",label:"Off"},{value:"on",label:"On"}]},{key:"goose",label:"Goose",description:"Forward Goose config and API keys for Goose agent access.",options:[{value:"off",label:"Off"},{value:"on",label:"On"}]}];function EO({credentialProviders:t,onUpdateCredentialProviders:s}){const i=(o,c)=>{const u={...t};o==="claude"?u.claude=c:u[o]=c,s(u)};return l.jsxs("section",{className:pe.section,children:[l.jsx("h3",{className:pe.sectionTitle,children:"Credential Providers"}),l.jsx("p",{className:pe.sectionDescription,children:"Enable providers to automatically forward credentials to environments at task start. Credentials are read fresh from the host each time."}),l.jsx("div",{className:pe.tokenList,children:CO.map(o=>l.jsxs("div",{className:pe.tokenRow,children:[l.jsx("span",{className:pe.tokenName,children:o.label}),l.jsx("span",{className:pe.tokenTarget,children:o.description}),l.jsx("select",{className:pe.select,value:t[o.key],onChange:c=>i(o.key,c.target.value),children:o.options.map(c=>l.jsx("option",{value:c.value,children:c.label},c.value))})]},o.key))})]})}const AO="_container_10efq_1",DO="_header_10efq_7",RO="_list_10efq_105",MO="_card_10efq_111",IO="_cardHeader_10efq_125",OO="_cardTitle_10efq_135",BO="_defaultBadge_10efq_141",LO="_cardActions_10efq_155",UO="_description_10efq_160",zO="_meta_10efq_166",PO="_empty_10efq_212",VO="_typeBadge_10efq_362",Ln={container:AO,header:DO,list:RO,card:MO,cardHeader:IO,cardTitle:OO,defaultBadge:BO,cardActions:LO,description:UO,meta:zO,empty:PO,typeBadge:VO};function HO({personas:t,appDefaultPersonaId:s,onDeletePersona:i,onSetAppDefaultPersonaId:o,onNavigateToNew:c,onNavigateToPersona:u}){const[d,m]=y.useState(null),h=d?t.find(v=>v.id===d):void 0,g=async v=>{await i(v),m(null)};return l.jsxs("div",{className:Ln.container,children:[l.jsxs("div",{className:Ln.header,children:[l.jsx("h2",{children:"Personas"}),l.jsx(Os,{variant:"primary",size:"md",onClick:c,"data-testid":"persona-new-button",children:"+ New Persona"})]}),t.length===0?l.jsx("p",{className:Ln.empty,children:"No personas yet. Create one to get started."}):l.jsx("div",{className:Ln.list,children:t.map(v=>{const _=s===v.id,b=v.type==="script";return l.jsxs("div",{className:Ln.card,"data-testid":`persona-card-${v.id}`,onClick:()=>u(v.id),role:"button",tabIndex:0,onKeyDown:S=>{S.currentTarget===S.target&&(S.key==="Enter"||S.key===" ")&&(S.preventDefault(),u(v.id))},children:[l.jsxs("div",{className:Ln.cardHeader,children:[l.jsxs("span",{className:Ln.cardTitle,children:[l.jsx("strong",{children:v.name}),l.jsx("span",{className:Ln.typeBadge,"data-testid":`persona-type-badge-${v.id}`,children:b?"Script":"Agent"}),_&&l.jsx("span",{className:Ln.defaultBadge,"data-testid":`persona-default-badge-${v.id}`,children:"App Default"})]}),l.jsxs("div",{className:Ln.cardActions,onClick:S=>S.stopPropagation(),children:[!_&&l.jsx(Os,{variant:"ghost",size:"sm",onClick:()=>{o(v.id).catch(()=>{})},"data-testid":`persona-set-default-${v.id}`,title:"Set as app default persona",children:"Set Default"}),l.jsx(Os,{variant:"ghost",size:"sm",onClick:()=>u(v.id),children:"Edit"}),l.jsx(Os,{variant:"ghost",size:"sm",onClick:()=>m(v.id),"data-testid":`persona-delete-${v.id}`,children:"Delete"})]})]}),v.description&&l.jsx("p",{className:Ln.description,children:v.description}),l.jsxs("div",{className:Ln.meta,children:[v.runtime&&l.jsxs("span",{children:["Runtime: ",v.runtime]}),v.model&&l.jsxs("span",{children:["Model: ",v.model]}),v.maxTurns>0&&l.jsxs("span",{children:["Max turns: ",v.maxTurns]})]})]},v.id)})}),l.jsx(ii,{isOpen:d!==null,title:"Delete Persona?",description:`"${(h==null?void 0:h.name)??""}" will be permanently removed.`,confirmLabel:"Delete",onConfirm:()=>{d&&g(d).catch(()=>{})},onCancel:()=>m(null)})]})}const $O="_container_uy08i_1",GO="_header_uy08i_7",qO="_count_uy08i_13",FO="_presets_uy08i_18",ZO="_presetButton_uy08i_24",KO="_filterInput_uy08i_41",YO="_groups_uy08i_53",JO="_group_uy08i_53",WO="_groupHeader_uy08i_68",XO="_groupName_uy08i_77",QO="_groupCount_uy08i_81",e4="_toolList_uy08i_87",t4="_toolItem_uy08i_95",n4="_toolName_uy08i_103",tn={container:$O,header:GO,count:qO,presets:FO,presetButton:ZO,filterInput:KO,groups:YO,group:JO,groupHeader:WO,groupName:XO,groupCount:QO,toolList:e4,toolItem:t4,toolName:n4},s4=(()=>{const t=new Map;for(const s of _b){const i=s==="get_version_status"?"version":s.split("_")[0];t.has(i)||t.set(i,[]),t.get(i).push(s)}return[...t.entries()].sort(([s],[i])=>s.localeCompare(i)).map(([s,i])=>({group:s,tools:i.sort()}))})(),a4=[{name:"default",label:"Default",tools:xb},{name:"worker",label:"Worker",tools:xT},{name:"orchestrator",label:"Orchestrator",tools:ST},{name:"admin",label:"Admin",tools:TT}];function tb({selectedTools:t,onChange:s,disabled:i}){const[o,c]=y.useState(""),u=y.useMemo(()=>new Set(t),[t]),d=y.useCallback(v=>{if(i)return;const _=new Set(u);_.has(v)?_.delete(v):_.add(v),s([..._].sort())},[u,s,i]),m=y.useCallback((v,_)=>{if(i)return;const b=new Set(u);for(const S of v)_?b.delete(S):b.add(S);s([...b].sort())},[u,s,i]),h=y.useCallback(v=>{i||s([...v].sort())},[s,i]),g=o.toLowerCase();return l.jsxs("div",{className:tn.container,"data-testid":"mcp-tool-selector",children:[l.jsx("div",{className:tn.header,children:l.jsx("span",{className:tn.count,children:t.length===0?`Using default (${xb.length} tools)`:`${t.length} of ${_b.size} tools selected`})}),l.jsxs("div",{className:tn.presets,"data-testid":"mcp-tool-presets",children:[a4.map(v=>l.jsx("button",{type:"button",className:tn.presetButton,disabled:i,onClick:()=>h(v.tools),"data-testid":`preset-${v.name}`,children:v.label},v.name)),l.jsx("button",{type:"button",className:tn.presetButton,disabled:i,onClick:()=>s([]),"data-testid":"preset-clear",children:"Clear"})]}),l.jsx("input",{type:"text",className:tn.filterInput,placeholder:"Filter tools...",value:o,onChange:v=>c(v.target.value),disabled:i,"data-testid":"mcp-tool-filter"}),l.jsx("div",{className:tn.groups,children:s4.map(({group:v,tools:_})=>{const b=g?_.filter(T=>T.toLowerCase().includes(g)):_;if(b.length===0)return null;const S=b.every(T=>u.has(T));return l.jsxs("div",{className:tn.group,"data-testid":`tool-group-${v}`,children:[l.jsxs("label",{className:tn.groupHeader,children:[l.jsx("input",{type:"checkbox",checked:S,onChange:()=>m(b,S),disabled:i,"data-testid":`group-toggle-${v}`}),l.jsx("span",{className:tn.groupName,children:v}),l.jsxs("span",{className:tn.groupCount,children:["(",b.filter(T=>u.has(T)).length,"/",b.length,")"]})]}),l.jsx("div",{className:tn.toolList,children:b.map(T=>l.jsxs("label",{className:tn.toolItem,children:[l.jsx("input",{type:"checkbox",checked:u.has(T),onChange:()=>d(T),disabled:i,"data-testid":`tool-${T}`}),l.jsx("span",{className:tn.toolName,children:T})]},T))})]},v)})})]})}const i4="_nav_1bhou_1",o4="_tab_1bhou_24",r4="_tabIcon_1bhou_62",l4="_tabActive_1bhou_68",fc={nav:i4,tab:o4,tabIcon:r4,tabActive:l4},Is=[{path:"credentials",label:"Credentials",icon:"🔑"},{path:"personas",label:"Personas",icon:"👤"},{path:"appearance",label:"Appearance",icon:"🎨"},{path:"shortcuts",label:"Shortcuts",icon:"⌨️"},{path:"about",label:"About",icon:"ℹ️"}];function c4(){var d;const t=Ut(),s=vt(),i=y.useRef(null),o=((d=Is.find(m=>{const h=`${so}/${m.path}`;return t.pathname===h||t.pathname.startsWith(`${h}/`)}))==null?void 0:d.path)??Is[0].path,c=y.useCallback(m=>{s(`${so}/${m}`)},[s]),u=y.useCallback(m=>{var S,T;const h=(S=i.current)==null?void 0:S.querySelectorAll('[role="tab"]');if(!h)return;const g=Array.from(h).findIndex(N=>N===document.activeElement),v=g>=0?g:Is.findIndex(N=>N.path===o);let _=v;if(m.key==="ArrowDown"||m.key==="j"||m.key==="J")m.preventDefault(),_=(v+1)%Is.length;else if(m.key==="ArrowUp"||m.key==="k"||m.key==="K")m.preventDefault(),_=(v-1+Is.length)%Is.length;else if(m.key==="Home")m.preventDefault(),_=0;else if(m.key==="End")m.preventDefault(),_=Is.length-1;else return;const b=Is[_].path;s(`${so}/${b}`),(T=h[_])==null||T.focus()},[o,s]);return l.jsx("nav",{className:fc.nav,ref:i,role:"tablist","aria-orientation":"vertical","aria-label":"Settings",onKeyDown:u,children:Is.map(m=>{const h=m.path===o;return l.jsxs("button",{role:"tab",type:"button","aria-selected":h,tabIndex:h?0:-1,className:`${fc.tab} ${h?fc.tabActive:""}`,onClick:()=>c(m.path),children:[l.jsx("span",{className:fc.tabIcon,"aria-hidden":"true",children:m.icon}),m.label]},m.path)})})}function u4({tasks:t,taskStatusById:s,sessionStatusByTaskId:i}){const o=new Map;for(const u of t)if(u.parentTaskId){const d=o.get(u.parentTaskId);d?d.push(u):o.set(u.parentTaskId,[u])}const c=new Map(S0.map(u=>[u,[]]));for(const u of t){const d=Tp(u.status),m=u.dependsOn.length>0&&u.dependsOn.some(T=>s.get(T)!=="complete"),h=o.get(u.id)??[],g=h.length,v=h.filter(T=>T.status==="complete").length;let _;if(d==="paused"&&i){const T=i.get(u.id);T==="idle"?_="Needs input":T==="completed"&&(_="Ready to complete")}const b={task:u,isBlocked:m,childCount:g,doneChildCount:v,pausedSubBadge:_},S=c.get(d);S?S.push(b):c.get("not_started").push(b)}for(const u of c.values())u.sort((d,m)=>d.task.sortOrder-m.task.sortOrder);return S0.map(u=>{const d=Sa(u);return{status:u,label:d.label,style:d,tasks:c.get(u)??[]}})}const d4="_boardContainer_1c4y1_1",f4="_column_1c4y1_17",p4="_columnHeader_1c4y1_34",m4="_columnIcon_1c4y1_47",h4="_columnLabel_1c4y1_52",g4="_columnCount_1c4y1_57",v4="_cardList_1c4y1_67",y4="_emptyPlaceholder_1c4y1_76",b4="_card_1c4y1_67",_4="_cardHeader_1c4y1_107",x4="_cardStatusIcon_1c4y1_113",S4="_cardTitle_1c4y1_119",T4="_cardBadges_1c4y1_127",k4="_badge_1c4y1_134",w4="_blockedBadge_1c4y1_146",N4="_childBadge_1c4y1_151",j4="_depBadge_1c4y1_155",C4="_parentBadge_1c4y1_159",E4="_pausedSubBadge_1c4y1_166",A4="_personaBadge_1c4y1_170",D4="_envBadge_1c4y1_174",R4="_emptyCta_1c4y1_178",M4="_ctaButton_1c4y1_188",I4="_ctaDescription_1c4y1_204",tt={boardContainer:d4,column:f4,columnHeader:p4,columnIcon:m4,columnLabel:h4,columnCount:g4,cardList:v4,emptyPlaceholder:y4,card:b4,cardHeader:_4,cardStatusIcon:x4,cardTitle:S4,cardBadges:T4,badge:k4,blockedBadge:w4,childBadge:N4,depBadge:j4,parentBadge:C4,pausedSubBadge:E4,personaBadge:A4,envBadge:D4,emptyCta:R4,ctaButton:M4,ctaDescription:I4};function O4({workspaceId:t,environmentId:s,tasks:i,sessions:o,personas:c,environments:u}){const d=vt(),m=y.useMemo(()=>i.filter(b=>b.workspaceId===t),[i,t]),h=y.useMemo(()=>new Map(i.map(b=>[b.id,b.status])),[i]),g=y.useMemo(()=>new Map(m.map(b=>[b.id,b])),[m]),v=y.useMemo(()=>{const b=new Map(o.map(C=>[C.id,C])),S=new Map(c.map(C=>[C.id,C])),T=new Map(u.map(C=>[C.id,C])),N=new Map,j=new Map,w=new Map;for(const C of m)if(C.latestSessionId){const A=b.get(C.latestSessionId);if(A){if(N.set(C.id,A.endReason||A.status),A.personaId){const M=S.get(A.personaId);M&&j.set(C.id,M.name)}if(A.environmentId){const M=T.get(A.environmentId);M&&w.set(C.id,M.displayName)}}}return{sessionStatusByTaskId:N,personaNameByTaskId:j,environmentNameByTaskId:w}},[m,o,c,u]),_=y.useMemo(()=>u4({tasks:m,taskStatusById:h,sessionStatusByTaskId:v.sessionStatusByTaskId}),[m,h,v]);return m.length===0?l.jsxs("div",{className:tt.emptyCta,"data-testid":"board-empty-cta",children:[l.jsx("button",{className:tt.ctaButton,onClick:()=>d(ri(t,void 0,s)),children:"Create Task"}),l.jsx("div",{className:tt.ctaDescription,children:"Break your work into tasks and let agents tackle them"})]}):l.jsx("div",{className:tt.boardContainer,"data-testid":"board-container",children:_.map(b=>l.jsxs("section",{className:tt.column,"data-testid":`board-column-${b.status}`,"aria-label":`${b.label}, ${b.tasks.length} ${b.tasks.length===1?"task":"tasks"}`,children:[l.jsxs("div",{className:tt.columnHeader,children:[l.jsx("span",{className:tt.columnIcon,style:{color:b.style.color},children:b.style.icon}),l.jsx("span",{className:tt.columnLabel,children:b.label}),l.jsx("span",{className:tt.columnCount,"data-testid":`board-count-${b.status}`,children:b.tasks.length})]}),l.jsx("div",{className:tt.cardList,children:b.tasks.length===0?l.jsx("div",{className:tt.emptyPlaceholder,children:"No tasks"}):l.jsx(ds,{mode:"popLayout",children:b.tasks.map(S=>l.jsx(Dt.div,{layout:!0,initial:{opacity:0,y:4},animate:{opacity:1,y:0},exit:{opacity:0,y:-4},transition:{duration:.15},children:l.jsx(B4,{boardTask:S,tasksById:g,personaName:v.personaNameByTaskId.get(S.task.id),envName:v.environmentNameByTaskId.get(S.task.id),onClick:()=>d(Xn(S.task.id,void 0,t,s))})},S.task.id))})})]},b.status))})}function B4({boardTask:t,tasksById:s,personaName:i,envName:o,onClick:c}){const{task:u,isBlocked:d,childCount:m,doneChildCount:h,pausedSubBadge:g}=t,v=Sa(u.status),_=u.parentTaskId?s.get(u.parentTaskId):void 0;return l.jsxs("div",{className:tt.card,tabIndex:0,role:"button","data-testid":`board-card-${u.id}`,onClick:c,onKeyDown:b=>{(b.key==="Enter"||b.key===" ")&&(b.preventDefault(),c())},children:[l.jsxs("div",{className:tt.cardHeader,children:[l.jsx("span",{className:tt.cardStatusIcon,style:{color:v.color},children:v.icon}),l.jsx("span",{className:tt.cardTitle,children:u.title})]}),l.jsxs("div",{className:tt.cardBadges,children:[_&&l.jsx("span",{className:`${tt.badge} ${tt.parentBadge}`,title:_.title,children:_.title}),m>0&&l.jsxs("span",{className:`${tt.badge} ${tt.childBadge}`,children:[h,"/",m]}),d&&l.jsx("span",{className:`${tt.badge} ${tt.blockedBadge}`,children:"blocked"}),u.dependsOn.length>0&&!d&&l.jsx("span",{className:`${tt.badge} ${tt.depBadge}`,children:"dep"}),g&&l.jsx("span",{className:`${tt.badge} ${tt.pausedSubBadge}`,children:g}),i&&l.jsx("span",{className:`${tt.badge} ${tt.personaBadge}`,children:i}),o&&l.jsx("span",{className:`${tt.badge} ${tt.envBadge}`,children:o})]})]})}const L4="_formContent_ymnez_1",U4="_section_ymnez_13",z4="_label_ymnez_19",P4="_titleInput_ymnez_26",V4="_descriptionTextarea_ymnez_58",H4="_selectField_ymnez_94",$4="_checkboxRow_ymnez_128",G4="_checkboxLabel_ymnez_141",q4="_fieldError_ymnez_146",mt={formContent:L4,section:U4,label:z4,titleInput:P4,descriptionTextarea:V4,selectField:H4,checkboxRow:$4,checkboxLabel:G4,fieldError:q4};function F4(t,s){return{name:(t==null?void 0:t.name)??"",description:(t==null?void 0:t.description)??"",repoUrl:(t==null?void 0:t.repoUrl)??"",environmentId:(t==null?void 0:t.environmentId)??s??"",defaultPersonaId:(t==null?void 0:t.defaultPersonaId)??"",useWorktrees:(t==null?void 0:t.useWorktrees)??!0,workingDirectory:(t==null?void 0:t.workingDirectory)??""}}const Z4=100;function K4({values:t,onChange:s,environments:i,personas:o,errors:c,disabled:u,autoFocusName:d}){const m=(h,g)=>{s({...t,[h]:g})};return l.jsxs("div",{className:mt.formContent,children:[l.jsxs("div",{className:mt.section,children:[l.jsx("label",{className:mt.label,htmlFor:"ws-name",children:"Name"}),l.jsx("input",{id:"ws-name",className:mt.titleInput,type:"text",value:t.name,onChange:h=>m("name",h.target.value),placeholder:"Workspace name",maxLength:Z4,autoFocus:d,disabled:u,"data-testid":"workspace-form-name"}),(c==null?void 0:c.name)&&l.jsx("span",{className:mt.fieldError,"data-testid":"workspace-form-error-name",children:c.name})]}),l.jsxs("div",{className:mt.section,children:[l.jsx("label",{className:mt.label,htmlFor:"ws-description",children:"Description"}),l.jsx("textarea",{id:"ws-description",className:mt.descriptionTextarea,value:t.description,onChange:h=>m("description",h.target.value),placeholder:"Optional description (Markdown supported)",disabled:u,"data-testid":"workspace-form-description"})]}),l.jsxs("div",{className:mt.section,children:[l.jsx("label",{className:mt.label,htmlFor:"ws-repo",children:"Repository URL"}),l.jsx("input",{id:"ws-repo",className:mt.titleInput,type:"text",value:t.repoUrl,onChange:h=>m("repoUrl",h.target.value),placeholder:"https://github.com/org/repo",disabled:u,"data-testid":"workspace-form-repo"}),(c==null?void 0:c.repoUrl)&&l.jsx("span",{className:mt.fieldError,"data-testid":"workspace-form-error-repoUrl",children:c.repoUrl})]}),l.jsxs("div",{className:mt.section,children:[l.jsx("label",{className:mt.label,htmlFor:"ws-environment",children:"Environment"}),l.jsxs("select",{id:"ws-environment",className:mt.selectField,value:t.environmentId,onChange:h=>m("environmentId",h.target.value),disabled:u,"data-testid":"workspace-form-environment",children:[l.jsx("option",{value:"",children:"Select environment…"}),i.map(h=>l.jsx("option",{value:h.id,children:h.displayName||h.id},h.id))]}),(c==null?void 0:c.environmentId)&&l.jsx("span",{className:mt.fieldError,"data-testid":"workspace-form-error-environmentId",children:c.environmentId})]}),l.jsxs("div",{className:mt.section,children:[l.jsx("label",{className:mt.label,htmlFor:"ws-persona",children:"Default Persona"}),l.jsxs("select",{id:"ws-persona",className:mt.selectField,value:t.defaultPersonaId,onChange:h=>m("defaultPersonaId",h.target.value),disabled:u,"data-testid":"workspace-form-persona",children:[l.jsx("option",{value:"",children:"(Inherit)"}),o.map(h=>l.jsx("option",{value:h.id,children:h.name},h.id))]})]}),l.jsx("div",{className:mt.section,children:l.jsxs("label",{className:mt.checkboxRow,children:[l.jsx("input",{type:"checkbox",checked:t.useWorktrees,onChange:h=>m("useWorktrees",h.target.checked),disabled:u,"data-testid":"workspace-form-worktrees"}),l.jsx("span",{className:mt.checkboxLabel,children:"Enable worktree isolation"})]})}),l.jsxs("div",{className:mt.section,children:[l.jsx("label",{className:mt.label,htmlFor:"ws-workdir",children:"Working Directory"}),l.jsx("input",{id:"ws-workdir",className:mt.titleInput,type:"text",value:t.workingDirectory,onChange:h=>m("workingDirectory",h.target.value),placeholder:"Default (server default)",disabled:u,"data-testid":"workspace-form-workdir"})]})]})}const Lx=y.createContext(void 0),Y4=4e3;function J4({children:t}){const[s,i]=y.useState([]),o=y.useRef(0),c=y.useCallback(d=>{i(m=>m.filter(h=>h.id!==d))},[]),u=y.useCallback((d,m="info",h=Y4)=>{const g=`toast-${++o.current}`;i(v=>[...v,{id:g,message:d,variant:m,duration:h}])},[]);return l.jsx(Lx.Provider,{value:{toasts:s,showToast:u,dismissToast:c},children:t})}function dn(){const t=y.useContext(Lx);if(!t)throw new Error("useToast must be used within ToastProvider");return t}const bp="grackle-theme",Ux="grackle-prefer-system",zx="(prefers-color-scheme: dark)";let gr=[],Nc;function Pf(){Nc=void 0;for(const t of gr)t()}function _p(){return typeof window>"u"?!1:window.matchMedia(zx).matches}function Sr(){if(typeof localStorage>"u")return eb;try{const t=localStorage.getItem(bp);if(t!==null&&Ix.has(t))return t}catch{}return eb}function Uc(){if(typeof localStorage>"u")return!1;try{return localStorage.getItem(Ux)==="true"}catch{return!1}}function xp(t){return Qc.find(s=>s.variantLightId===t||s.variantDarkId===t)}function Px(t,s){const i=yp(t);if(i!=null&&i.variantDarkId)return s&&i.variantLightId?_p()?i.variantDarkId:i.variantLightId:i.variantDarkId;if(i!=null&&i.hidden&&s){const o=xp(t);if(o!=null&&o.variantLightId&&o.variantDarkId)return _p()?o.variantDarkId:o.variantLightId}return t}function Ji(t,s,i=!1){i&&document.documentElement.classList.add("no-transitions"),document.documentElement.dataset.theme=Px(t,s),i&&(document.documentElement.offsetHeight,requestAnimationFrame(()=>{document.documentElement.classList.remove("no-transitions")}))}typeof document<"u"&&Ji(Sr(),Uc());function W4(){return Nc===void 0&&(Nc={themeId:Sr(),systemDark:_p(),preferSystem:Uc()}),Nc}function X4(t){return gr=[...gr,t],()=>{gr=gr.filter(s=>s!==t)}}function Q4(){const t=y.useSyncExternalStore(X4,W4),{themeId:s,preferSystem:i}=t,o=Px(s,i),c=y.useCallback(d=>{if(Ix.has(d)){try{localStorage.setItem(bp,d)}catch{}Ji(d,Uc(),!0),Pf()}},[]),u=y.useCallback(d=>{try{localStorage.setItem(Ux,d?"true":"false")}catch{}if(d){const m=Sr(),h=yp(m);if(h!=null&&h.hidden){const g=xp(m);if(g)try{localStorage.setItem(bp,g.id)}catch{}}}Ji(Sr(),d,!0),Pf()},[]);return y.useEffect(()=>{Ji(s,i)},[s,i]),y.useEffect(()=>{if(typeof window>"u")return;const d=window.matchMedia(zx),m=()=>{const h=Sr(),g=Uc();if(g){const v=yp(h);if(v!=null&&v.variantDarkId&&v.variantLightId&&Ji(h,g),v!=null&&v.hidden){const _=xp(h);_!=null&&_.variantDarkId&&_.variantLightId&&Ji(h,g)}}Pf()};return d.addEventListener("change",m),()=>{d.removeEventListener("change",m)}},[]),{themeId:s,setTheme:c,resolvedThemeId:o,preferSystem:i,setPreferSystem:u}}const Vx=y.createContext(void 0);function eB({children:t}){const s=Q4();return l.jsx(Vx.Provider,{value:s,children:t})}function Hx(){const t=y.useContext(Vx);if(!t)throw new Error("useThemeContext must be used within ThemeProvider");return t}const $x=y.createContext(void 0),Gx=y.createContext(void 0);function tB({children:t}){const[s,i]=y.useState(void 0),o=y.useCallback(c=>{i(c)},[]);return l.jsx(Gx.Provider,{value:o,children:l.jsx($x.Provider,{value:s,children:t})})}function nB(){return y.useContext($x)}function sB(){const t=y.useContext(Gx);if(t===void 0)throw new Error("useSidebarSetter must be used within a SidebarProvider");return t}const vm=y.createContext(void 0);function rt(){const t=y.useContext(vm);if(!t)throw new Error("useGrackle must be used within GrackleProvider");return t}function qx(t){return typeof t=="object"&&t!==null&&!Array.isArray(t)}function Fx(t,s){return console.warn(`[ws] Malformed "${t}" message: ${s}`),!1}function aB(t){return qx(t)&&typeof t.sessionId=="string"&&typeof t.eventType=="string"&&typeof t.timestamp=="string"&&typeof t.content=="string"&&(t.raw===void 0||typeof t.raw=="string")}const iB=new Set(["off","subscription","api_key"]),pc=new Set(["off","on"]);function oB(t){return qx(t)&&iB.has(t.claude)&&pc.has(t.github)&&pc.has(t.copilot)&&pc.has(t.codex)&&pc.has(t.goose)}function Zx(t){switch(t){case"waiting_input":return"idle";case"completed":return"stopped";case"killed":return"stopped";case"failed":return"stopped";case"interrupted":return"stopped";case"terminated":return"stopped";default:return t}}function Kx(t){switch(t){case"completed":return"completed";case"killed":return"killed";case"failed":return"interrupted";case"interrupted":return"interrupted";case"terminated":return"terminated";default:return}}const Yi=5e3;function rB(t,s){const i=[];let o=t;const c=new Set;for(;o&&s.has(o)&&!c.has(o);){c.add(o);const u=s.get(o);i.unshift(u),o=u.parentTaskId||void 0}return i}const Vs={label:"Home",url:ai};function lB(t){return t?[Vs,{label:"Settings",url:so},{label:t,url:void 0}]:[Vs,{label:"Settings",url:void 0}]}const ym={label:"Environments",url:ao};function cB(){return[Vs,{label:"Environments",url:void 0}]}function uB(){return[Vs,{label:"New Chat",url:void 0}]}function dB(t){return[Vs,{label:`Session ${t.slice(0,8)}`,url:void 0}]}function fB(t,s,i,o){const c=i.find(d=>d.id===t),u=o.find(d=>d.id===s);return[Vs,ym,{label:(u==null?void 0:u.displayName)??"Environment",url:si(s)},{label:(c==null?void 0:c.name)??"Workspace",url:void 0}]}function pB(t,s,i,o,c){const u=rB(t,c),d=c.get(t),m=d==null?void 0:d.workspaceId,h=m?i.find(S=>S.id===m):void 0,g=s??(h==null?void 0:h.environmentId),v=g?o.find(S=>S.id===g):void 0,_=[Vs];v&&g&&(_.push(ym),_.push({label:v.displayName,url:si(g)})),h&&g&&_.push({label:h.name,url:ni(h.id,g)});for(let S=0;S<u.length-1;S++)_.push({label:u[S].title,url:Xn(u[S].id,void 0,m,g)});const b=u[u.length-1];return _.push({label:(b==null?void 0:b.title)??t,url:void 0}),_}const mB={label:"Findings",url:Fc};function hB(){return[Vs,{label:"Findings",url:void 0}]}function Yx(t,s,i,o,c){const u=[Vs];if(s&&i){const d=o.find(h=>h.id===s),m=c.find(h=>h.id===i);u.push(ym),m&&u.push({label:m.displayName,url:si(i)}),d&&u.push({label:d.name,url:ni(s,i)}),u.push({label:"Findings",url:l2(s,i)})}else u.push(mB);return u.push({label:t,url:void 0}),u}function bm(t){const s=[];for(const i of t){const o=s[s.length-1];i.eventType==="text"&&(o==null?void 0:o.eventType)==="text"?s[s.length-1]={...o,content:o.content+i.content}:s.push(i)}return s}function _m(t){const s=new Map;for(const u of t)if(u.raw)try{s.set(u,JSON.parse(u.raw))}catch{}const i=new Map;for(const u of t){if(u.eventType!=="tool_use")continue;const d=s.get(u);if(!(!d||typeof d.id!="string"))try{const m=JSON.parse(u.content);i.set(d.id,{tool:m.tool,args:m.args})}catch{}}const o=new Set;return t.map(u=>{if(u.eventType!=="tool_result")return u;const d=s.get(u);if(!d||typeof d.tool_use_id!="string")return u;const m=i.get(d.tool_use_id);if(!m)return u;o.add(d.tool_use_id);let h;const g=u.content.trim();if(g.startsWith("{"))try{const v=JSON.parse(g);typeof v.detailedContent=="string"&&(h=v.detailedContent)}catch{}return{...u,toolUseCtx:{...m,detailedResult:h}}}).filter(u=>{if(u.eventType!=="tool_use")return!0;const d=s.get(u);return d&&typeof d.id=="string"?!o.has(d.id):!0})}function gB(t,s,i){const o=t.filter(h=>h.status==="running"||h.status==="idle"||h.status==="waiting").length,c=Jx(s),u=s.filter(h=>Sp(h,c)).length,d=s.filter(h=>h.status==="paused"||h.status==="failed"||Sp(h,c)).length,m=i.filter(h=>h.status==="disconnected"||h.status==="error").length;return{activeSessions:o,blockedTasks:u,attentionTasks:d,unhealthyEnvironments:m}}function Jx(t){const s=new Map;for(const i of t)s.set(i.id,i.status);return s}function Sp(t,s){return t.dependsOn.some(i=>s.get(i)!=="complete")}function vB(t,s){var d;const i=new Map;for(const m of s)i.set(m.id,m);const o=Jx(t),c=[];for(const m of t){const h=m.workspaceId?((d=i.get(m.workspaceId))==null?void 0:d.name)??"Unknown":"Unknown";m.status==="failed"?c.push({task:m,reason:"failed",workspaceName:h}):Sp(m,o)?c.push({task:m,reason:"blocked",workspaceName:h}):m.status==="paused"&&c.push({task:m,reason:"paused",workspaceName:h})}const u={failed:0,blocked:1,paused:2};return c.sort((m,h)=>(u[m.reason]??3)-(u[h.reason]??3)),c}function yB(t,s){const i=new Map;for(const o of s)i.set(o.id,o);return t.filter(o=>o.status==="running"||o.status==="idle"||o.status==="waiting").map(o=>{var c;return{session:o,environmentName:((c=i.get(o.environmentId))==null?void 0:c.displayName)??"Unknown"}})}function bB(t,s,i){const o=new Map;for(const c of s){if(!c.workspaceId)continue;let u=o.get(c.workspaceId);u||(u={totalTasks:0,completedTasks:0,workingTasks:0,failedTasks:0},o.set(c.workspaceId,u)),u.totalTasks+=1,c.status==="complete"?u.completedTasks+=1:c.status==="working"?u.workingTasks+=1:c.status==="failed"&&(u.failedTasks+=1)}return t.map(c=>{const u=o.get(c.id)??{totalTasks:0,completedTasks:0,workingTasks:0,failedTasks:0};return{workspace:c,totalTasks:u.totalTasks,completedTasks:u.completedTasks,workingTasks:u.workingTasks,failedTasks:u.failedTasks}})}const rs=[{id:"kn-auth-flow",label:"Authentication Flow",kind:"knowledge",category:"concept",content:"The application uses JWT Bearer tokens for stateless authentication. Access tokens expire after 24h. Refresh tokens are stored in the database and rotated on use. The auth middleware verifies tokens and attaches the decoded payload to req.user.",tags:["auth","jwt","security"],workspaceId:"proj-alpha",createdAt:"2026-02-25T10:30:00Z",updatedAt:"2026-02-27T08:15:00Z",val:5},{id:"kn-db-schema",label:"Database Schema",kind:"knowledge",category:"concept",content:"PostgreSQL database with tables: users, sessions, refresh_tokens, audit_log. Uses UUID primary keys, TIMESTAMPTZ for all timestamps, and JSONB for flexible metadata columns. Connection pooling via pg-pool with per-tenant isolation.",tags:["database","postgres","schema"],workspaceId:"proj-alpha",createdAt:"2026-02-23T11:00:00Z",updatedAt:"2026-02-26T22:45:00Z",val:4},{id:"kn-error-handling",label:"Error Response Pattern",kind:"knowledge",category:"concept",content:"All API errors follow the shape { error: string, code: string, details?: unknown }. HTTP status codes map to: 400 (validation), 401 (unauthenticated), 403 (forbidden), 404 (not found), 409 (conflict), 429 (rate limited), 500 (internal).",tags:["api","errors","patterns"],workspaceId:"proj-alpha",createdAt:"2026-02-27T08:17:00Z",updatedAt:"2026-02-27T08:17:00Z",val:3},{id:"kn-rate-limiting",label:"Rate Limiting Strategy",kind:"knowledge",category:"concept",content:"Token-bucket algorithm with in-memory state per client IP. Default rate: 100 requests/minute, burst: 20. Returns 429 with Retry-After header. Redis adapter available for multi-instance deployments.",tags:["api","rate-limiting","infrastructure"],workspaceId:"proj-alpha",createdAt:"2026-02-27T09:00:00Z",updatedAt:"2026-02-27T09:00:00Z",val:2},{id:"kn-etl-pipeline",label:"ETL Pipeline Architecture",kind:"knowledge",category:"concept",content:"Data pipelines follow an Extract-Transform-Load pattern with pluggable stages. Each stage reads from a source (Postgres, S3, API), transforms via configurable mappers, and loads into a target (Parquet, BigQuery, S3). Incremental loads use high-watermark tracking.",tags:["etl","pipeline","architecture"],workspaceId:"proj-beta",createdAt:"2026-02-26T08:00:00Z",updatedAt:"2026-02-27T09:05:00Z",val:4},{id:"kn-parquet-format",label:"Parquet Output Format",kind:"knowledge",category:"concept",content:"Parquet files are written with row-group buffering (configurable batch size, default 10000 rows). Supports Snappy, ZSTD, and GZIP compression. Schema is derived from the internal column type system using Arrow type mapping.",tags:["parquet","data-format","compression"],workspaceId:"proj-beta",createdAt:"2026-02-26T08:05:00Z",updatedAt:"2026-02-26T08:15:00Z",val:3},{id:"kn-jwt-over-session",label:"JWT over Session Auth",kind:"knowledge",category:"decision",content:"Chose JWT tokens over server-side sessions for stateless auth. Rationale: (1) no session store needed, (2) works across microservices without shared state, (3) supports mobile clients natively. Trade-off: tokens can't be revoked instantly (mitigated by short expiry + refresh rotation).",tags:["auth","decision","jwt"],workspaceId:"proj-alpha",createdAt:"2026-02-25T10:00:00Z",updatedAt:"2026-02-25T10:00:00Z",val:3},{id:"kn-pg-pool-decision",label:"pg-pool over Knex",kind:"knowledge",category:"decision",content:"Chose pg-pool over Knex for connection pooling. pg-pool gives direct control over idle timeout, max connections, and health check queries. Knex wraps pg-pool and adds query-building overhead we don't need since we write raw SQL with parameterized queries.",tags:["database","decision","postgres"],workspaceId:"proj-alpha",createdAt:"2026-02-23T11:30:00Z",updatedAt:"2026-02-23T11:30:00Z",val:2},{id:"kn-watermark-decision",label:"Local Watermark Storage",kind:"knowledge",category:"decision",content:"Currently using local SQLite for watermark storage. This works for single-worker pipelines but needs to move to a shared store (Redis or Postgres) for production multi-worker scenarios. Tracked as a follow-up task.",tags:["pipeline","decision","watermarks"],workspaceId:"proj-beta",createdAt:"2026-02-27T09:05:00Z",updatedAt:"2026-02-27T09:05:00Z",val:2},{id:"kn-jwt-middleware",label:"JWT Verify Middleware",kind:"knowledge",category:"snippet",content:`\`\`\`typescript
62
+ `),()=>{document.head.removeChild(v)}},[s]),l.jsx(Kj,{isPresent:s,childRef:o,sizeRef:c,children:y.cloneElement(t,{ref:o})})}const Jj=({children:t,initial:s,isPresent:i,onExitComplete:o,custom:c,presenceAffectsLayout:u,mode:d})=>{const m=Ip(Wj),h=y.useId(),g=y.useCallback(_=>{m.set(_,!0);for(const b of m.values())if(!b)return;o&&o()},[m,o]),v=y.useMemo(()=>({id:h,initial:s,isPresent:i,custom:c,onExitComplete:g,register:_=>(m.set(_,!1),()=>m.delete(_))}),u?[Math.random(),g]:[i,g]);return y.useMemo(()=>{m.forEach((_,b)=>m.set(b,!1))},[i]),y.useEffect(()=>{!i&&!m.size&&o&&o()},[i]),d==="popLayout"&&(t=l.jsx(Yj,{isPresent:i,children:t})),l.jsx(Zc.Provider,{value:v,children:t})};function Wj(){return new Map}function Zb(t=!0){const s=y.useContext(Zc);if(s===null)return[!0,null];const{isPresent:i,onExitComplete:o,register:c}=s,u=y.useId();y.useEffect(()=>{t&&c(u)},[t]);const d=y.useCallback(()=>t&&o&&o(u),[u,o,t]);return!i&&o?[!1,d]:[!0]}const lc=t=>t.key||"";function I0(t){const s=[];return y.Children.forEach(t,i=>{y.isValidElement(i)&&s.push(i)}),s}const Bp=typeof window<"u",Kb=Bp?y.useLayoutEffect:y.useEffect,ds=({children:t,custom:s,initial:i=!0,onExitComplete:o,presenceAffectsLayout:c=!0,mode:u="sync",propagate:d=!1})=>{const[m,h]=Zb(d),g=y.useMemo(()=>I0(t),[t]),v=d&&!m?[]:g.map(lc),_=y.useRef(!0),b=y.useRef(g),S=Ip(()=>new Map),[T,N]=y.useState(g),[j,w]=y.useState(g);Kb(()=>{_.current=!1,b.current=g;for(let M=0;M<j.length;M++){const D=lc(j[M]);v.includes(D)?S.delete(D):S.get(D)!==!0&&S.set(D,!1)}},[j,v.length,v.join("-")]);const C=[];if(g!==T){let M=[...g];for(let D=0;D<j.length;D++){const E=j[D],$=lc(E);v.includes($)||(M.splice(D,0,E),C.push(E))}u==="wait"&&C.length&&(M=C),w(I0(M)),N(g);return}const{forceRender:A}=y.useContext(Mp);return l.jsx(l.Fragment,{children:j.map(M=>{const D=lc(M),E=d&&!m?!1:g===j||v.includes(D),$=()=>{if(S.has(D))S.set(D,!0);else return;let z=!0;S.forEach(K=>{K||(z=!1)}),z&&(A==null||A(),w(b.current),d&&(h==null||h()),o&&o())};return l.jsx(Jj,{isPresent:E,initial:!_.current||i?void 0:!1,custom:E?void 0:s,presenceAffectsLayout:c,mode:u,onExitComplete:E?void 0:$,children:M},D)})})},xn=t=>t;let Yb=xn;const Xj={useManualTiming:!1};function Qj(t){let s=new Set,i=new Set,o=!1,c=!1;const u=new WeakSet;let d={delta:0,timestamp:0,isProcessing:!1};function m(g){u.has(g)&&(h.schedule(g),t()),g(d)}const h={schedule:(g,v=!1,_=!1)=>{const S=_&&o?s:i;return v&&u.add(g),S.has(g)||S.add(g),g},cancel:g=>{i.delete(g),u.delete(g)},process:g=>{if(d=g,o){c=!0;return}o=!0,[s,i]=[i,s],s.forEach(m),s.clear(),o=!1,c&&(c=!1,h.process(g))}};return h}const cc=["read","resolveKeyframes","update","preRender","render","postRender"],eC=40;function Jb(t,s){let i=!1,o=!0;const c={delta:0,timestamp:0,isProcessing:!1},u=()=>i=!0,d=cc.reduce((w,C)=>(w[C]=Qj(u),w),{}),{read:m,resolveKeyframes:h,update:g,preRender:v,render:_,postRender:b}=d,S=()=>{const w=performance.now();i=!1,c.delta=o?1e3/60:Math.max(Math.min(w-c.timestamp,eC),1),c.timestamp=w,c.isProcessing=!0,m.process(c),h.process(c),g.process(c),v.process(c),_.process(c),b.process(c),c.isProcessing=!1,i&&s&&(o=!1,t(S))},T=()=>{i=!0,o=!0,c.isProcessing||t(S)};return{schedule:cc.reduce((w,C)=>{const A=d[C];return w[C]=(M,D=!1,E=!1)=>(i||T(),A.schedule(M,D,E)),w},{}),cancel:w=>{for(let C=0;C<cc.length;C++)d[cc[C]].cancel(w)},state:c,steps:d}}const{schedule:gt,cancel:Ta,state:Zt,steps:wf}=Jb(typeof requestAnimationFrame<"u"?requestAnimationFrame:xn,!0),Wb=y.createContext({strict:!1}),O0={animation:["animate","variants","whileHover","whileTap","exit","whileInView","whileFocus","whileDrag"],exit:["exit"],drag:["drag","dragControls"],focus:["whileFocus"],hover:["whileHover","onHoverStart","onHoverEnd"],tap:["whileTap","onTap","onTapStart","onTapCancel"],pan:["onPan","onPanStart","onPanSessionStart","onPanEnd"],inView:["whileInView","onViewportEnter","onViewportLeave"],layout:["layout","layoutId"]},oo={};for(const t in O0)oo[t]={isEnabled:s=>O0[t].some(i=>!!s[i])};function tC(t){for(const s in t)oo[s]={...oo[s],...t[s]}}const nC=new Set(["animate","exit","variants","initial","style","values","variants","transition","transformTemplate","custom","inherit","onBeforeLayoutMeasure","onAnimationStart","onAnimationComplete","onUpdate","onDragStart","onDrag","onDragEnd","onMeasureDragConstraints","onDirectionLock","onDragTransitionEnd","_dragX","_dragY","onHoverStart","onHoverEnd","onViewportEnter","onViewportLeave","globalTapTarget","ignoreStrict","viewport"]);function Cc(t){return t.startsWith("while")||t.startsWith("drag")&&t!=="draggable"||t.startsWith("layout")||t.startsWith("onTap")||t.startsWith("onPan")||t.startsWith("onLayout")||nC.has(t)}let Xb=t=>!Cc(t);function sC(t){t&&(Xb=s=>s.startsWith("on")?!Cc(s):t(s))}try{sC(require("@emotion/is-prop-valid").default)}catch{}function aC(t,s,i){const o={};for(const c in t)c==="values"&&typeof t.values=="object"||(Xb(c)||i===!0&&Cc(c)||!s&&!Cc(c)||t.draggable&&c.startsWith("onDrag"))&&(o[c]=t[c]);return o}function iC(t){if(typeof Proxy>"u")return t;const s=new Map,i=(...o)=>t(...o);return new Proxy(i,{get:(o,c)=>c==="create"?t:(s.has(c)||s.set(c,t(c)),s.get(c))})}const Kc=y.createContext({});function jr(t){return typeof t=="string"||Array.isArray(t)}function Yc(t){return t!==null&&typeof t=="object"&&typeof t.start=="function"}const Lp=["animate","whileInView","whileFocus","whileHover","whileTap","whileDrag","exit"],Up=["initial",...Lp];function Jc(t){return Yc(t.animate)||Up.some(s=>jr(t[s]))}function Qb(t){return!!(Jc(t)||t.variants)}function oC(t,s){if(Jc(t)){const{initial:i,animate:o}=t;return{initial:i===!1||jr(i)?i:void 0,animate:jr(o)?o:void 0}}return t.inherit!==!1?s:{}}function rC(t){const{initial:s,animate:i}=oC(t,y.useContext(Kc));return y.useMemo(()=>({initial:s,animate:i}),[B0(s),B0(i)])}function B0(t){return Array.isArray(t)?t.join(" "):t}const lC=Symbol.for("motionComponentSymbol");function Wi(t){return t&&typeof t=="object"&&Object.prototype.hasOwnProperty.call(t,"current")}function cC(t,s,i){return y.useCallback(o=>{o&&t.onMount&&t.onMount(o),s&&(o?s.mount(o):s.unmount()),i&&(typeof i=="function"?i(o):Wi(i)&&(i.current=o))},[s])}const zp=t=>t.replace(/([a-z])([A-Z])/gu,"$1-$2").toLowerCase(),uC="framerAppearId",e_="data-"+zp(uC),{schedule:Pp}=Jb(queueMicrotask,!1),t_=y.createContext({});function dC(t,s,i,o,c){var u,d;const{visualElement:m}=y.useContext(Kc),h=y.useContext(Wb),g=y.useContext(Zc),v=y.useContext(Op).reducedMotion,_=y.useRef(null);o=o||h.renderer,!_.current&&o&&(_.current=o(t,{visualState:s,parent:m,props:i,presenceContext:g,blockInitialAnimation:g?g.initial===!1:!1,reducedMotionConfig:v}));const b=_.current,S=y.useContext(t_);b&&!b.projection&&c&&(b.type==="html"||b.type==="svg")&&fC(_.current,i,c,S);const T=y.useRef(!1);y.useInsertionEffect(()=>{b&&T.current&&b.update(i,g)});const N=i[e_],j=y.useRef(!!N&&!(!((u=window.MotionHandoffIsComplete)===null||u===void 0)&&u.call(window,N))&&((d=window.MotionHasOptimisedAnimation)===null||d===void 0?void 0:d.call(window,N)));return Kb(()=>{b&&(T.current=!0,window.MotionIsMounted=!0,b.updateFeatures(),Pp.render(b.render),j.current&&b.animationState&&b.animationState.animateChanges())}),y.useEffect(()=>{b&&(!j.current&&b.animationState&&b.animationState.animateChanges(),j.current&&(queueMicrotask(()=>{var w;(w=window.MotionHandoffMarkAsComplete)===null||w===void 0||w.call(window,N)}),j.current=!1))}),b}function fC(t,s,i,o){const{layoutId:c,layout:u,drag:d,dragConstraints:m,layoutScroll:h,layoutRoot:g}=s;t.projection=new i(t.latestValues,s["data-framer-portal-id"]?void 0:n_(t.parent)),t.projection.setOptions({layoutId:c,layout:u,alwaysMeasureLayout:!!d||m&&Wi(m),visualElement:t,animationType:typeof u=="string"?u:"both",initialPromotionConfig:o,layoutScroll:h,layoutRoot:g})}function n_(t){if(t)return t.options.allowProjection!==!1?t.projection:n_(t.parent)}function pC({preloadedFeatures:t,createVisualElement:s,useRender:i,useVisualState:o,Component:c}){var u,d;t&&tC(t);function m(g,v){let _;const b={...y.useContext(Op),...g,layoutId:mC(g)},{isStatic:S}=b,T=rC(g),N=o(g,S);if(!S&&Bp){hC();const j=gC(b);_=j.MeasureLayout,T.visualElement=dC(c,N,b,s,j.ProjectionNode)}return l.jsxs(Kc.Provider,{value:T,children:[_&&T.visualElement?l.jsx(_,{visualElement:T.visualElement,...b}):null,i(c,g,cC(N,T.visualElement,v),N,S,T.visualElement)]})}m.displayName=`motion.${typeof c=="string"?c:`create(${(d=(u=c.displayName)!==null&&u!==void 0?u:c.name)!==null&&d!==void 0?d:""})`}`;const h=y.forwardRef(m);return h[lC]=c,h}function mC({layoutId:t}){const s=y.useContext(Mp).id;return s&&t!==void 0?s+"-"+t:t}function hC(t,s){y.useContext(Wb).strict}function gC(t){const{drag:s,layout:i}=oo;if(!s&&!i)return{};const o={...s,...i};return{MeasureLayout:s!=null&&s.isEnabled(t)||i!=null&&i.isEnabled(t)?o.MeasureLayout:void 0,ProjectionNode:o.ProjectionNode}}const vC=["animate","circle","defs","desc","ellipse","g","image","line","filter","marker","mask","metadata","path","pattern","polygon","polyline","rect","stop","switch","symbol","svg","text","tspan","use","view"];function Vp(t){return typeof t!="string"||t.includes("-")?!1:!!(vC.indexOf(t)>-1||/[A-Z]/u.test(t))}function L0(t){const s=[{},{}];return t==null||t.values.forEach((i,o)=>{s[0][o]=i.get(),s[1][o]=i.getVelocity()}),s}function Hp(t,s,i,o){if(typeof s=="function"){const[c,u]=L0(o);s=s(i!==void 0?i:t.custom,c,u)}if(typeof s=="string"&&(s=t.variants&&t.variants[s]),typeof s=="function"){const[c,u]=L0(o);s=s(i!==void 0?i:t.custom,c,u)}return s}const np=t=>Array.isArray(t),yC=t=>!!(t&&typeof t=="object"&&t.mix&&t.toValue),bC=t=>np(t)?t[t.length-1]||0:t,Xt=t=>!!(t&&t.getVelocity);function xc(t){const s=Xt(t)?t.get():t;return yC(s)?s.toValue():s}function _C({scrapeMotionValuesFromProps:t,createRenderState:s,onUpdate:i},o,c,u){const d={latestValues:xC(o,c,u,t),renderState:s()};return i&&(d.onMount=m=>i({props:o,current:m,...d}),d.onUpdate=m=>i(m)),d}const s_=t=>(s,i)=>{const o=y.useContext(Kc),c=y.useContext(Zc),u=()=>_C(t,s,o,c);return i?u():Ip(u)};function xC(t,s,i,o){const c={},u=o(t,{});for(const b in u)c[b]=xc(u[b]);let{initial:d,animate:m}=t;const h=Jc(t),g=Qb(t);s&&g&&!h&&t.inherit!==!1&&(d===void 0&&(d=s.initial),m===void 0&&(m=s.animate));let v=i?i.initial===!1:!1;v=v||d===!1;const _=v?m:d;if(_&&typeof _!="boolean"&&!Yc(_)){const b=Array.isArray(_)?_:[_];for(let S=0;S<b.length;S++){const T=Hp(t,b[S]);if(T){const{transitionEnd:N,transition:j,...w}=T;for(const C in w){let A=w[C];if(Array.isArray(A)){const M=v?A.length-1:0;A=A[M]}A!==null&&(c[C]=A)}for(const C in N)c[C]=N[C]}}}return c}const fo=["transformPerspective","x","y","z","translateX","translateY","translateZ","scale","scaleX","scaleY","rotate","rotateX","rotateY","rotateZ","skew","skewX","skewY"],ci=new Set(fo),a_=t=>s=>typeof s=="string"&&s.startsWith(t),i_=a_("--"),SC=a_("var(--"),$p=t=>SC(t)?TC.test(t.split("/*")[0].trim()):!1,TC=/var\(--(?:[\w-]+\s*|[\w-]+\s*,(?:\s*[^)(\s]|\s*\((?:[^)(]|\([^)(]*\))*\))+\s*)\)$/iu,o_=(t,s)=>s&&typeof t=="number"?s.transform(t):t,Ps=(t,s,i)=>i>s?s:i<t?t:i,po={test:t=>typeof t=="number",parse:parseFloat,transform:t=>t},Cr={...po,transform:t=>Ps(0,1,t)},uc={...po,default:1},Ir=t=>({test:s=>typeof s=="string"&&s.endsWith(t)&&s.split(" ").length===1,parse:parseFloat,transform:s=>`${s}${t}`}),_a=Ir("deg"),cs=Ir("%"),we=Ir("px"),kC=Ir("vh"),wC=Ir("vw"),U0={...cs,parse:t=>cs.parse(t)/100,transform:t=>cs.transform(t*100)},NC={borderWidth:we,borderTopWidth:we,borderRightWidth:we,borderBottomWidth:we,borderLeftWidth:we,borderRadius:we,radius:we,borderTopLeftRadius:we,borderTopRightRadius:we,borderBottomRightRadius:we,borderBottomLeftRadius:we,width:we,maxWidth:we,height:we,maxHeight:we,top:we,right:we,bottom:we,left:we,padding:we,paddingTop:we,paddingRight:we,paddingBottom:we,paddingLeft:we,margin:we,marginTop:we,marginRight:we,marginBottom:we,marginLeft:we,backgroundPositionX:we,backgroundPositionY:we},jC={rotate:_a,rotateX:_a,rotateY:_a,rotateZ:_a,scale:uc,scaleX:uc,scaleY:uc,scaleZ:uc,skew:_a,skewX:_a,skewY:_a,distance:we,translateX:we,translateY:we,translateZ:we,x:we,y:we,z:we,perspective:we,transformPerspective:we,opacity:Cr,originX:U0,originY:U0,originZ:we},z0={...po,transform:Math.round},Gp={...NC,...jC,zIndex:z0,size:we,fillOpacity:Cr,strokeOpacity:Cr,numOctaves:z0},CC={x:"translateX",y:"translateY",z:"translateZ",transformPerspective:"perspective"},EC=fo.length;function AC(t,s,i){let o="",c=!0;for(let u=0;u<EC;u++){const d=fo[u],m=t[d];if(m===void 0)continue;let h=!0;if(typeof m=="number"?h=m===(d.startsWith("scale")?1:0):h=parseFloat(m)===0,!h||i){const g=o_(m,Gp[d]);if(!h){c=!1;const v=CC[d]||d;o+=`${v}(${g}) `}i&&(s[d]=g)}}return o=o.trim(),i?o=i(s,c?"":o):c&&(o="none"),o}function qp(t,s,i){const{style:o,vars:c,transformOrigin:u}=t;let d=!1,m=!1;for(const h in s){const g=s[h];if(ci.has(h)){d=!0;continue}else if(i_(h)){c[h]=g;continue}else{const v=o_(g,Gp[h]);h.startsWith("origin")?(m=!0,u[h]=v):o[h]=v}}if(s.transform||(d||i?o.transform=AC(s,t.transform,i):o.transform&&(o.transform="none")),m){const{originX:h="50%",originY:g="50%",originZ:v=0}=u;o.transformOrigin=`${h} ${g} ${v}`}}const DC={offset:"stroke-dashoffset",array:"stroke-dasharray"},RC={offset:"strokeDashoffset",array:"strokeDasharray"};function MC(t,s,i=1,o=0,c=!0){t.pathLength=1;const u=c?DC:RC;t[u.offset]=we.transform(-o);const d=we.transform(s),m=we.transform(i);t[u.array]=`${d} ${m}`}function P0(t,s,i){return typeof t=="string"?t:we.transform(s+i*t)}function IC(t,s,i){const o=P0(s,t.x,t.width),c=P0(i,t.y,t.height);return`${o} ${c}`}function Fp(t,{attrX:s,attrY:i,attrScale:o,originX:c,originY:u,pathLength:d,pathSpacing:m=1,pathOffset:h=0,...g},v,_){if(qp(t,g,_),v){t.style.viewBox&&(t.attrs.viewBox=t.style.viewBox);return}t.attrs=t.style,t.style={};const{attrs:b,style:S,dimensions:T}=t;b.transform&&(T&&(S.transform=b.transform),delete b.transform),T&&(c!==void 0||u!==void 0||S.transform)&&(S.transformOrigin=IC(T,c!==void 0?c:.5,u!==void 0?u:.5)),s!==void 0&&(b.x=s),i!==void 0&&(b.y=i),o!==void 0&&(b.scale=o),d!==void 0&&MC(b,d,m,h,!1)}const Zp=()=>({style:{},transform:{},transformOrigin:{},vars:{}}),r_=()=>({...Zp(),attrs:{}}),Kp=t=>typeof t=="string"&&t.toLowerCase()==="svg";function l_(t,{style:s,vars:i},o,c){Object.assign(t.style,s,c&&c.getProjectionStyles(o));for(const u in i)t.style.setProperty(u,i[u])}const c_=new Set(["baseFrequency","diffuseConstant","kernelMatrix","kernelUnitLength","keySplines","keyTimes","limitingConeAngle","markerHeight","markerWidth","numOctaves","targetX","targetY","surfaceScale","specularConstant","specularExponent","stdDeviation","tableValues","viewBox","gradientTransform","pathLength","startOffset","textLength","lengthAdjust"]);function u_(t,s,i,o){l_(t,s,void 0,o);for(const c in s.attrs)t.setAttribute(c_.has(c)?c:zp(c),s.attrs[c])}const Ec={};function OC(t){Object.assign(Ec,t)}function d_(t,{layout:s,layoutId:i}){return ci.has(t)||t.startsWith("origin")||(s||i!==void 0)&&(!!Ec[t]||t==="opacity")}function Yp(t,s,i){var o;const{style:c}=t,u={};for(const d in c)(Xt(c[d])||s.style&&Xt(s.style[d])||d_(d,t)||((o=i==null?void 0:i.getValue(d))===null||o===void 0?void 0:o.liveStyle)!==void 0)&&(u[d]=c[d]);return u}function f_(t,s,i){const o=Yp(t,s,i);for(const c in t)if(Xt(t[c])||Xt(s[c])){const u=fo.indexOf(c)!==-1?"attr"+c.charAt(0).toUpperCase()+c.substring(1):c;o[u]=t[c]}return o}function BC(t,s){try{s.dimensions=typeof t.getBBox=="function"?t.getBBox():t.getBoundingClientRect()}catch{s.dimensions={x:0,y:0,width:0,height:0}}}const V0=["x","y","width","height","cx","cy","r"],LC={useVisualState:s_({scrapeMotionValuesFromProps:f_,createRenderState:r_,onUpdate:({props:t,prevProps:s,current:i,renderState:o,latestValues:c})=>{if(!i)return;let u=!!t.drag;if(!u){for(const m in c)if(ci.has(m)){u=!0;break}}if(!u)return;let d=!s;if(s)for(let m=0;m<V0.length;m++){const h=V0[m];t[h]!==s[h]&&(d=!0)}d&&gt.read(()=>{BC(i,o),gt.render(()=>{Fp(o,c,Kp(i.tagName),t.transformTemplate),u_(i,o)})})}})},UC={useVisualState:s_({scrapeMotionValuesFromProps:Yp,createRenderState:Zp})};function p_(t,s,i){for(const o in s)!Xt(s[o])&&!d_(o,i)&&(t[o]=s[o])}function zC({transformTemplate:t},s){return y.useMemo(()=>{const i=Zp();return qp(i,s,t),Object.assign({},i.vars,i.style)},[s])}function PC(t,s){const i=t.style||{},o={};return p_(o,i,t),Object.assign(o,zC(t,s)),o}function VC(t,s){const i={},o=PC(t,s);return t.drag&&t.dragListener!==!1&&(i.draggable=!1,o.userSelect=o.WebkitUserSelect=o.WebkitTouchCallout="none",o.touchAction=t.drag===!0?"none":`pan-${t.drag==="x"?"y":"x"}`),t.tabIndex===void 0&&(t.onTap||t.onTapStart||t.whileTap)&&(i.tabIndex=0),i.style=o,i}function HC(t,s,i,o){const c=y.useMemo(()=>{const u=r_();return Fp(u,s,Kp(o),t.transformTemplate),{...u.attrs,style:{...u.style}}},[s]);if(t.style){const u={};p_(u,t.style,t),c.style={...u,...c.style}}return c}function $C(t=!1){return(i,o,c,{latestValues:u},d)=>{const h=(Vp(i)?HC:VC)(o,u,d,i),g=aC(o,typeof i=="string",t),v=i!==y.Fragment?{...g,...h,ref:c}:{},{children:_}=o,b=y.useMemo(()=>Xt(_)?_.get():_,[_]);return y.createElement(i,{...v,children:b})}}function GC(t,s){return function(o,{forwardMotionProps:c}={forwardMotionProps:!1}){const d={...Vp(o)?LC:UC,preloadedFeatures:t,useRender:$C(c),createVisualElement:s,Component:o};return pC(d)}}function m_(t,s){if(!Array.isArray(s))return!1;const i=s.length;if(i!==t.length)return!1;for(let o=0;o<i;o++)if(s[o]!==t[o])return!1;return!0}function Wc(t,s,i){const o=t.getProps();return Hp(o,s,i!==void 0?i:o.custom,t)}function Jp(t,s){return t?t[s]||t.default||t:void 0}const h_=new Set(["width","height","top","left","right","bottom",...fo]);let Sc;function qC(){Sc=void 0}const us={now:()=>(Sc===void 0&&us.set(Zt.isProcessing||Xj.useManualTiming?Zt.timestamp:performance.now()),Sc),set:t=>{Sc=t,queueMicrotask(qC)}};function Wp(t,s){t.indexOf(s)===-1&&t.push(s)}function Xp(t,s){const i=t.indexOf(s);i>-1&&t.splice(i,1)}class Qp{constructor(){this.subscriptions=[]}add(s){return Wp(this.subscriptions,s),()=>Xp(this.subscriptions,s)}notify(s,i,o){const c=this.subscriptions.length;if(c)if(c===1)this.subscriptions[0](s,i,o);else for(let u=0;u<c;u++){const d=this.subscriptions[u];d&&d(s,i,o)}}getSize(){return this.subscriptions.length}clear(){this.subscriptions.length=0}}function g_(t,s){return s?t*(1e3/s):0}const H0=30,FC=t=>!isNaN(parseFloat(t));class ZC{constructor(s,i={}){this.version="11.18.2",this.canTrackVelocity=null,this.events={},this.updateAndNotify=(o,c=!0)=>{const u=us.now();this.updatedAt!==u&&this.setPrevFrameValue(),this.prev=this.current,this.setCurrent(o),this.current!==this.prev&&this.events.change&&this.events.change.notify(this.current),c&&this.events.renderRequest&&this.events.renderRequest.notify(this.current)},this.hasAnimated=!1,this.setCurrent(s),this.owner=i.owner}setCurrent(s){this.current=s,this.updatedAt=us.now(),this.canTrackVelocity===null&&s!==void 0&&(this.canTrackVelocity=FC(this.current))}setPrevFrameValue(s=this.current){this.prevFrameValue=s,this.prevUpdatedAt=this.updatedAt}onChange(s){return this.on("change",s)}on(s,i){this.events[s]||(this.events[s]=new Qp);const o=this.events[s].add(i);return s==="change"?()=>{o(),gt.read(()=>{this.events.change.getSize()||this.stop()})}:o}clearListeners(){for(const s in this.events)this.events[s].clear()}attach(s,i){this.passiveEffect=s,this.stopPassiveEffect=i}set(s,i=!0){!i||!this.passiveEffect?this.updateAndNotify(s,i):this.passiveEffect(s,this.updateAndNotify)}setWithVelocity(s,i,o){this.set(i),this.prev=void 0,this.prevFrameValue=s,this.prevUpdatedAt=this.updatedAt-o}jump(s,i=!0){this.updateAndNotify(s),this.prev=s,this.prevUpdatedAt=this.prevFrameValue=void 0,i&&this.stop(),this.stopPassiveEffect&&this.stopPassiveEffect()}get(){return this.current}getPrevious(){return this.prev}getVelocity(){const s=us.now();if(!this.canTrackVelocity||this.prevFrameValue===void 0||s-this.updatedAt>H0)return 0;const i=Math.min(this.updatedAt-this.prevUpdatedAt,H0);return g_(parseFloat(this.current)-parseFloat(this.prevFrameValue),i)}start(s){return this.stop(),new Promise(i=>{this.hasAnimated=!0,this.animation=s(i),this.events.animationStart&&this.events.animationStart.notify()}).then(()=>{this.events.animationComplete&&this.events.animationComplete.notify(),this.clearAnimation()})}stop(){this.animation&&(this.animation.stop(),this.events.animationCancel&&this.events.animationCancel.notify()),this.clearAnimation()}isAnimating(){return!!this.animation}clearAnimation(){delete this.animation}destroy(){this.clearListeners(),this.stop(),this.stopPassiveEffect&&this.stopPassiveEffect()}}function Er(t,s){return new ZC(t,s)}function KC(t,s,i){t.hasValue(s)?t.getValue(s).set(i):t.addValue(s,Er(i))}function YC(t,s){const i=Wc(t,s);let{transitionEnd:o={},transition:c={},...u}=i||{};u={...u,...o};for(const d in u){const m=bC(u[d]);KC(t,d,m)}}function JC(t){return!!(Xt(t)&&t.add)}function sp(t,s){const i=t.getValue("willChange");if(JC(i))return i.add(s)}function v_(t){return t.props[e_]}function em(t){let s;return()=>(s===void 0&&(s=t()),s)}const WC=em(()=>window.ScrollTimeline!==void 0);class XC{constructor(s){this.stop=()=>this.runAll("stop"),this.animations=s.filter(Boolean)}get finished(){return Promise.all(this.animations.map(s=>"finished"in s?s.finished:s))}getAll(s){return this.animations[0][s]}setAll(s,i){for(let o=0;o<this.animations.length;o++)this.animations[o][s]=i}attachTimeline(s,i){const o=this.animations.map(c=>{if(WC()&&c.attachTimeline)return c.attachTimeline(s);if(typeof i=="function")return i(c)});return()=>{o.forEach((c,u)=>{c&&c(),this.animations[u].stop()})}}get time(){return this.getAll("time")}set time(s){this.setAll("time",s)}get speed(){return this.getAll("speed")}set speed(s){this.setAll("speed",s)}get startTime(){return this.getAll("startTime")}get duration(){let s=0;for(let i=0;i<this.animations.length;i++)s=Math.max(s,this.animations[i].duration);return s}runAll(s){this.animations.forEach(i=>i[s]())}flatten(){this.runAll("flatten")}play(){this.runAll("play")}pause(){this.runAll("pause")}cancel(){this.runAll("cancel")}complete(){this.runAll("complete")}}class QC extends XC{then(s,i){return Promise.all(this.animations).then(s).catch(i)}}const Bs=t=>t*1e3,Ls=t=>t/1e3;function tm(t){return typeof t=="function"}function $0(t,s){t.timeline=s,t.onfinish=null}const nm=t=>Array.isArray(t)&&typeof t[0]=="number",eE={linearEasing:void 0};function tE(t,s){const i=em(t);return()=>{var o;return(o=eE[s])!==null&&o!==void 0?o:i()}}const Ac=tE(()=>{try{document.createElement("div").animate({opacity:0},{easing:"linear(0, 1)"})}catch{return!1}return!0},"linearEasing"),ro=(t,s,i)=>{const o=s-t;return o===0?1:(i-t)/o},y_=(t,s,i=10)=>{let o="";const c=Math.max(Math.round(s/i),2);for(let u=0;u<c;u++)o+=t(ro(0,c-1,u))+", ";return`linear(${o.substring(0,o.length-2)})`};function b_(t){return!!(typeof t=="function"&&Ac()||!t||typeof t=="string"&&(t in ap||Ac())||nm(t)||Array.isArray(t)&&t.every(b_))}const pr=([t,s,i,o])=>`cubic-bezier(${t}, ${s}, ${i}, ${o})`,ap={linear:"linear",ease:"ease",easeIn:"ease-in",easeOut:"ease-out",easeInOut:"ease-in-out",circIn:pr([0,.65,.55,1]),circOut:pr([.55,0,1,.45]),backIn:pr([.31,.01,.66,-.59]),backOut:pr([.33,1.53,.69,.99])};function __(t,s){if(t)return typeof t=="function"&&Ac()?y_(t,s):nm(t)?pr(t):Array.isArray(t)?t.map(i=>__(i,s)||ap.easeOut):ap[t]}const x_=(t,s,i)=>(((1-3*i+3*s)*t+(3*i-6*s))*t+3*s)*t,nE=1e-7,sE=12;function aE(t,s,i,o,c){let u,d,m=0;do d=s+(i-s)/2,u=x_(d,o,c)-t,u>0?i=d:s=d;while(Math.abs(u)>nE&&++m<sE);return d}function Or(t,s,i,o){if(t===s&&i===o)return xn;const c=u=>aE(u,0,1,t,i);return u=>u===0||u===1?u:x_(c(u),s,o)}const S_=t=>s=>s<=.5?t(2*s)/2:(2-t(2*(1-s)))/2,T_=t=>s=>1-t(1-s),k_=Or(.33,1.53,.69,.99),sm=T_(k_),w_=S_(sm),N_=t=>(t*=2)<1?.5*sm(t):.5*(2-Math.pow(2,-10*(t-1))),am=t=>1-Math.sin(Math.acos(t)),j_=T_(am),C_=S_(am),E_=t=>/^0[^.\s]+$/u.test(t);function iE(t){return typeof t=="number"?t===0:t!==null?t==="none"||t==="0"||E_(t):!0}const yr=t=>Math.round(t*1e5)/1e5,im=/-?(?:\d+(?:\.\d+)?|\.\d+)/gu;function oE(t){return t==null}const rE=/^(?:#[\da-f]{3,8}|(?:rgb|hsl)a?\((?:-?[\d.]+%?[,\s]+){2}-?[\d.]+%?\s*(?:[,/]\s*)?(?:\b\d+(?:\.\d+)?|\.\d+)?%?\))$/iu,om=(t,s)=>i=>!!(typeof i=="string"&&rE.test(i)&&i.startsWith(t)||s&&!oE(i)&&Object.prototype.hasOwnProperty.call(i,s)),A_=(t,s,i)=>o=>{if(typeof o!="string")return o;const[c,u,d,m]=o.match(im);return{[t]:parseFloat(c),[s]:parseFloat(u),[i]:parseFloat(d),alpha:m!==void 0?parseFloat(m):1}},lE=t=>Ps(0,255,t),Nf={...po,transform:t=>Math.round(lE(t))},Qa={test:om("rgb","red"),parse:A_("red","green","blue"),transform:({red:t,green:s,blue:i,alpha:o=1})=>"rgba("+Nf.transform(t)+", "+Nf.transform(s)+", "+Nf.transform(i)+", "+yr(Cr.transform(o))+")"};function cE(t){let s="",i="",o="",c="";return t.length>5?(s=t.substring(1,3),i=t.substring(3,5),o=t.substring(5,7),c=t.substring(7,9)):(s=t.substring(1,2),i=t.substring(2,3),o=t.substring(3,4),c=t.substring(4,5),s+=s,i+=i,o+=o,c+=c),{red:parseInt(s,16),green:parseInt(i,16),blue:parseInt(o,16),alpha:c?parseInt(c,16)/255:1}}const ip={test:om("#"),parse:cE,transform:Qa.transform},Xi={test:om("hsl","hue"),parse:A_("hue","saturation","lightness"),transform:({hue:t,saturation:s,lightness:i,alpha:o=1})=>"hsla("+Math.round(t)+", "+cs.transform(yr(s))+", "+cs.transform(yr(i))+", "+yr(Cr.transform(o))+")"},Wt={test:t=>Qa.test(t)||ip.test(t)||Xi.test(t),parse:t=>Qa.test(t)?Qa.parse(t):Xi.test(t)?Xi.parse(t):ip.parse(t),transform:t=>typeof t=="string"?t:t.hasOwnProperty("red")?Qa.transform(t):Xi.transform(t)},uE=/(?:#[\da-f]{3,8}|(?:rgb|hsl)a?\((?:-?[\d.]+%?[,\s]+){2}-?[\d.]+%?\s*(?:[,/]\s*)?(?:\b\d+(?:\.\d+)?|\.\d+)?%?\))/giu;function dE(t){var s,i;return isNaN(t)&&typeof t=="string"&&(((s=t.match(im))===null||s===void 0?void 0:s.length)||0)+(((i=t.match(uE))===null||i===void 0?void 0:i.length)||0)>0}const D_="number",R_="color",fE="var",pE="var(",G0="${}",mE=/var\s*\(\s*--(?:[\w-]+\s*|[\w-]+\s*,(?:\s*[^)(\s]|\s*\((?:[^)(]|\([^)(]*\))*\))+\s*)\)|#[\da-f]{3,8}|(?:rgb|hsl)a?\((?:-?[\d.]+%?[,\s]+){2}-?[\d.]+%?\s*(?:[,/]\s*)?(?:\b\d+(?:\.\d+)?|\.\d+)?%?\)|-?(?:\d+(?:\.\d+)?|\.\d+)/giu;function Ar(t){const s=t.toString(),i=[],o={color:[],number:[],var:[]},c=[];let u=0;const m=s.replace(mE,h=>(Wt.test(h)?(o.color.push(u),c.push(R_),i.push(Wt.parse(h))):h.startsWith(pE)?(o.var.push(u),c.push(fE),i.push(h)):(o.number.push(u),c.push(D_),i.push(parseFloat(h))),++u,G0)).split(G0);return{values:i,split:m,indexes:o,types:c}}function M_(t){return Ar(t).values}function I_(t){const{split:s,types:i}=Ar(t),o=s.length;return c=>{let u="";for(let d=0;d<o;d++)if(u+=s[d],c[d]!==void 0){const m=i[d];m===D_?u+=yr(c[d]):m===R_?u+=Wt.transform(c[d]):u+=c[d]}return u}}const hE=t=>typeof t=="number"?0:t;function gE(t){const s=M_(t);return I_(t)(s.map(hE))}const ka={test:dE,parse:M_,createTransformer:I_,getAnimatableNone:gE},vE=new Set(["brightness","contrast","saturate","opacity"]);function yE(t){const[s,i]=t.slice(0,-1).split("(");if(s==="drop-shadow")return t;const[o]=i.match(im)||[];if(!o)return t;const c=i.replace(o,"");let u=vE.has(s)?1:0;return o!==i&&(u*=100),s+"("+u+c+")"}const bE=/\b([a-z-]*)\(.*?\)/gu,op={...ka,getAnimatableNone:t=>{const s=t.match(bE);return s?s.map(yE).join(" "):t}},_E={...Gp,color:Wt,backgroundColor:Wt,outlineColor:Wt,fill:Wt,stroke:Wt,borderColor:Wt,borderTopColor:Wt,borderRightColor:Wt,borderBottomColor:Wt,borderLeftColor:Wt,filter:op,WebkitFilter:op},rm=t=>_E[t];function O_(t,s){let i=rm(t);return i!==op&&(i=ka),i.getAnimatableNone?i.getAnimatableNone(s):void 0}const xE=new Set(["auto","none","0"]);function SE(t,s,i){let o=0,c;for(;o<t.length&&!c;){const u=t[o];typeof u=="string"&&!xE.has(u)&&Ar(u).values.length&&(c=t[o]),o++}if(c&&i)for(const u of s)t[u]=O_(i,c)}const q0=t=>t===po||t===we,F0=(t,s)=>parseFloat(t.split(", ")[s]),Z0=(t,s)=>(i,{transform:o})=>{if(o==="none"||!o)return 0;const c=o.match(/^matrix3d\((.+)\)$/u);if(c)return F0(c[1],s);{const u=o.match(/^matrix\((.+)\)$/u);return u?F0(u[1],t):0}},TE=new Set(["x","y","z"]),kE=fo.filter(t=>!TE.has(t));function wE(t){const s=[];return kE.forEach(i=>{const o=t.getValue(i);o!==void 0&&(s.push([i,o.get()]),o.set(i.startsWith("scale")?1:0))}),s}const lo={width:({x:t},{paddingLeft:s="0",paddingRight:i="0"})=>t.max-t.min-parseFloat(s)-parseFloat(i),height:({y:t},{paddingTop:s="0",paddingBottom:i="0"})=>t.max-t.min-parseFloat(s)-parseFloat(i),top:(t,{top:s})=>parseFloat(s),left:(t,{left:s})=>parseFloat(s),bottom:({y:t},{top:s})=>parseFloat(s)+(t.max-t.min),right:({x:t},{left:s})=>parseFloat(s)+(t.max-t.min),x:Z0(4,13),y:Z0(5,14)};lo.translateX=lo.x;lo.translateY=lo.y;const ti=new Set;let rp=!1,lp=!1;function B_(){if(lp){const t=Array.from(ti).filter(o=>o.needsMeasurement),s=new Set(t.map(o=>o.element)),i=new Map;s.forEach(o=>{const c=wE(o);c.length&&(i.set(o,c),o.render())}),t.forEach(o=>o.measureInitialState()),s.forEach(o=>{o.render();const c=i.get(o);c&&c.forEach(([u,d])=>{var m;(m=o.getValue(u))===null||m===void 0||m.set(d)})}),t.forEach(o=>o.measureEndState()),t.forEach(o=>{o.suspendedScrollY!==void 0&&window.scrollTo(0,o.suspendedScrollY)})}lp=!1,rp=!1,ti.forEach(t=>t.complete()),ti.clear()}function L_(){ti.forEach(t=>{t.readKeyframes(),t.needsMeasurement&&(lp=!0)})}function NE(){L_(),B_()}class lm{constructor(s,i,o,c,u,d=!1){this.isComplete=!1,this.isAsync=!1,this.needsMeasurement=!1,this.isScheduled=!1,this.unresolvedKeyframes=[...s],this.onComplete=i,this.name=o,this.motionValue=c,this.element=u,this.isAsync=d}scheduleResolve(){this.isScheduled=!0,this.isAsync?(ti.add(this),rp||(rp=!0,gt.read(L_),gt.resolveKeyframes(B_))):(this.readKeyframes(),this.complete())}readKeyframes(){const{unresolvedKeyframes:s,name:i,element:o,motionValue:c}=this;for(let u=0;u<s.length;u++)if(s[u]===null)if(u===0){const d=c==null?void 0:c.get(),m=s[s.length-1];if(d!==void 0)s[0]=d;else if(o&&i){const h=o.readValue(i,m);h!=null&&(s[0]=h)}s[0]===void 0&&(s[0]=m),c&&d===void 0&&c.set(s[0])}else s[u]=s[u-1]}setFinalKeyframe(){}measureInitialState(){}renderEndStyles(){}measureEndState(){}complete(){this.isComplete=!0,this.onComplete(this.unresolvedKeyframes,this.finalKeyframe),ti.delete(this)}cancel(){this.isComplete||(this.isScheduled=!1,ti.delete(this))}resume(){this.isComplete||this.scheduleResolve()}}const U_=t=>/^-?(?:\d+(?:\.\d+)?|\.\d+)$/u.test(t),jE=/^var\(--(?:([\w-]+)|([\w-]+), ?([a-zA-Z\d ()%#.,-]+))\)/u;function CE(t){const s=jE.exec(t);if(!s)return[,];const[,i,o,c]=s;return[`--${i??o}`,c]}function z_(t,s,i=1){const[o,c]=CE(t);if(!o)return;const u=window.getComputedStyle(s).getPropertyValue(o);if(u){const d=u.trim();return U_(d)?parseFloat(d):d}return $p(c)?z_(c,s,i+1):c}const P_=t=>s=>s.test(t),EE={test:t=>t==="auto",parse:t=>t},V_=[po,we,cs,_a,wC,kC,EE],K0=t=>V_.find(P_(t));class H_ extends lm{constructor(s,i,o,c,u){super(s,i,o,c,u,!0)}readKeyframes(){const{unresolvedKeyframes:s,element:i,name:o}=this;if(!i||!i.current)return;super.readKeyframes();for(let h=0;h<s.length;h++){let g=s[h];if(typeof g=="string"&&(g=g.trim(),$p(g))){const v=z_(g,i.current);v!==void 0&&(s[h]=v),h===s.length-1&&(this.finalKeyframe=g)}}if(this.resolveNoneKeyframes(),!h_.has(o)||s.length!==2)return;const[c,u]=s,d=K0(c),m=K0(u);if(d!==m)if(q0(d)&&q0(m))for(let h=0;h<s.length;h++){const g=s[h];typeof g=="string"&&(s[h]=parseFloat(g))}else this.needsMeasurement=!0}resolveNoneKeyframes(){const{unresolvedKeyframes:s,name:i}=this,o=[];for(let c=0;c<s.length;c++)iE(s[c])&&o.push(c);o.length&&SE(s,o,i)}measureInitialState(){const{element:s,unresolvedKeyframes:i,name:o}=this;if(!s||!s.current)return;o==="height"&&(this.suspendedScrollY=window.pageYOffset),this.measuredOrigin=lo[o](s.measureViewportBox(),window.getComputedStyle(s.current)),i[0]=this.measuredOrigin;const c=i[i.length-1];c!==void 0&&s.getValue(o,c).jump(c,!1)}measureEndState(){var s;const{element:i,name:o,unresolvedKeyframes:c}=this;if(!i||!i.current)return;const u=i.getValue(o);u&&u.jump(this.measuredOrigin,!1);const d=c.length-1,m=c[d];c[d]=lo[o](i.measureViewportBox(),window.getComputedStyle(i.current)),m!==null&&this.finalKeyframe===void 0&&(this.finalKeyframe=m),!((s=this.removedTransforms)===null||s===void 0)&&s.length&&this.removedTransforms.forEach(([h,g])=>{i.getValue(h).set(g)}),this.resolveNoneKeyframes()}}const Y0=(t,s)=>s==="zIndex"?!1:!!(typeof t=="number"||Array.isArray(t)||typeof t=="string"&&(ka.test(t)||t==="0")&&!t.startsWith("url("));function AE(t){const s=t[0];if(t.length===1)return!0;for(let i=0;i<t.length;i++)if(t[i]!==s)return!0}function DE(t,s,i,o){const c=t[0];if(c===null)return!1;if(s==="display"||s==="visibility")return!0;const u=t[t.length-1],d=Y0(c,s),m=Y0(u,s);return!d||!m?!1:AE(t)||(i==="spring"||tm(i))&&o}const RE=t=>t!==null;function Xc(t,{repeat:s,repeatType:i="loop"},o){const c=t.filter(RE),u=s&&i!=="loop"&&s%2===1?0:c.length-1;return!u||o===void 0?c[u]:o}const ME=40;class $_{constructor({autoplay:s=!0,delay:i=0,type:o="keyframes",repeat:c=0,repeatDelay:u=0,repeatType:d="loop",...m}){this.isStopped=!1,this.hasAttemptedResolve=!1,this.createdAt=us.now(),this.options={autoplay:s,delay:i,type:o,repeat:c,repeatDelay:u,repeatType:d,...m},this.updateFinishedPromise()}calcStartTime(){return this.resolvedAt?this.resolvedAt-this.createdAt>ME?this.resolvedAt:this.createdAt:this.createdAt}get resolved(){return!this._resolved&&!this.hasAttemptedResolve&&NE(),this._resolved}onKeyframesResolved(s,i){this.resolvedAt=us.now(),this.hasAttemptedResolve=!0;const{name:o,type:c,velocity:u,delay:d,onComplete:m,onUpdate:h,isGenerator:g}=this.options;if(!g&&!DE(s,o,c,u))if(d)this.options.duration=0;else{h&&h(Xc(s,this.options,i)),m&&m(),this.resolveFinishedPromise();return}const v=this.initPlayback(s,i);v!==!1&&(this._resolved={keyframes:s,finalKeyframe:i,...v},this.onPostResolved())}onPostResolved(){}then(s,i){return this.currentFinishedPromise.then(s,i)}flatten(){this.options.type="keyframes",this.options.ease="linear"}updateFinishedPromise(){this.currentFinishedPromise=new Promise(s=>{this.resolveFinishedPromise=s})}}const cp=2e4;function G_(t){let s=0;const i=50;let o=t.next(s);for(;!o.done&&s<cp;)s+=i,o=t.next(s);return s>=cp?1/0:s}const xt=(t,s,i)=>t+(s-t)*i;function jf(t,s,i){return i<0&&(i+=1),i>1&&(i-=1),i<1/6?t+(s-t)*6*i:i<1/2?s:i<2/3?t+(s-t)*(2/3-i)*6:t}function IE({hue:t,saturation:s,lightness:i,alpha:o}){t/=360,s/=100,i/=100;let c=0,u=0,d=0;if(!s)c=u=d=i;else{const m=i<.5?i*(1+s):i+s-i*s,h=2*i-m;c=jf(h,m,t+1/3),u=jf(h,m,t),d=jf(h,m,t-1/3)}return{red:Math.round(c*255),green:Math.round(u*255),blue:Math.round(d*255),alpha:o}}function Dc(t,s){return i=>i>0?s:t}const Cf=(t,s,i)=>{const o=t*t,c=i*(s*s-o)+o;return c<0?0:Math.sqrt(c)},OE=[ip,Qa,Xi],BE=t=>OE.find(s=>s.test(t));function J0(t){const s=BE(t);if(!s)return!1;let i=s.parse(t);return s===Xi&&(i=IE(i)),i}const W0=(t,s)=>{const i=J0(t),o=J0(s);if(!i||!o)return Dc(t,s);const c={...i};return u=>(c.red=Cf(i.red,o.red,u),c.green=Cf(i.green,o.green,u),c.blue=Cf(i.blue,o.blue,u),c.alpha=xt(i.alpha,o.alpha,u),Qa.transform(c))},LE=(t,s)=>i=>s(t(i)),Br=(...t)=>t.reduce(LE),up=new Set(["none","hidden"]);function UE(t,s){return up.has(t)?i=>i<=0?t:s:i=>i>=1?s:t}function zE(t,s){return i=>xt(t,s,i)}function cm(t){return typeof t=="number"?zE:typeof t=="string"?$p(t)?Dc:Wt.test(t)?W0:HE:Array.isArray(t)?q_:typeof t=="object"?Wt.test(t)?W0:PE:Dc}function q_(t,s){const i=[...t],o=i.length,c=t.map((u,d)=>cm(u)(u,s[d]));return u=>{for(let d=0;d<o;d++)i[d]=c[d](u);return i}}function PE(t,s){const i={...t,...s},o={};for(const c in i)t[c]!==void 0&&s[c]!==void 0&&(o[c]=cm(t[c])(t[c],s[c]));return c=>{for(const u in o)i[u]=o[u](c);return i}}function VE(t,s){var i;const o=[],c={color:0,var:0,number:0};for(let u=0;u<s.values.length;u++){const d=s.types[u],m=t.indexes[d][c[d]],h=(i=t.values[m])!==null&&i!==void 0?i:0;o[u]=h,c[d]++}return o}const HE=(t,s)=>{const i=ka.createTransformer(s),o=Ar(t),c=Ar(s);return o.indexes.var.length===c.indexes.var.length&&o.indexes.color.length===c.indexes.color.length&&o.indexes.number.length>=c.indexes.number.length?up.has(t)&&!c.values.length||up.has(s)&&!o.values.length?UE(t,s):Br(q_(VE(o,c),c.values),i):Dc(t,s)};function F_(t,s,i){return typeof t=="number"&&typeof s=="number"&&typeof i=="number"?xt(t,s,i):cm(t)(t,s)}const $E=5;function Z_(t,s,i){const o=Math.max(s-$E,0);return g_(i-t(o),s-o)}const wt={stiffness:100,damping:10,mass:1,velocity:0,duration:800,bounce:.3,visualDuration:.3,restSpeed:{granular:.01,default:2},restDelta:{granular:.005,default:.5},minDuration:.01,maxDuration:10,minDamping:.05,maxDamping:1},Ef=.001;function GE({duration:t=wt.duration,bounce:s=wt.bounce,velocity:i=wt.velocity,mass:o=wt.mass}){let c,u,d=1-s;d=Ps(wt.minDamping,wt.maxDamping,d),t=Ps(wt.minDuration,wt.maxDuration,Ls(t)),d<1?(c=g=>{const v=g*d,_=v*t,b=v-i,S=dp(g,d),T=Math.exp(-_);return Ef-b/S*T},u=g=>{const _=g*d*t,b=_*i+i,S=Math.pow(d,2)*Math.pow(g,2)*t,T=Math.exp(-_),N=dp(Math.pow(g,2),d);return(-c(g)+Ef>0?-1:1)*((b-S)*T)/N}):(c=g=>{const v=Math.exp(-g*t),_=(g-i)*t+1;return-Ef+v*_},u=g=>{const v=Math.exp(-g*t),_=(i-g)*(t*t);return v*_});const m=5/t,h=FE(c,u,m);if(t=Bs(t),isNaN(h))return{stiffness:wt.stiffness,damping:wt.damping,duration:t};{const g=Math.pow(h,2)*o;return{stiffness:g,damping:d*2*Math.sqrt(o*g),duration:t}}}const qE=12;function FE(t,s,i){let o=i;for(let c=1;c<qE;c++)o=o-t(o)/s(o);return o}function dp(t,s){return t*Math.sqrt(1-s*s)}const ZE=["duration","bounce"],KE=["stiffness","damping","mass"];function X0(t,s){return s.some(i=>t[i]!==void 0)}function YE(t){let s={velocity:wt.velocity,stiffness:wt.stiffness,damping:wt.damping,mass:wt.mass,isResolvedFromDuration:!1,...t};if(!X0(t,KE)&&X0(t,ZE))if(t.visualDuration){const i=t.visualDuration,o=2*Math.PI/(i*1.2),c=o*o,u=2*Ps(.05,1,1-(t.bounce||0))*Math.sqrt(c);s={...s,mass:wt.mass,stiffness:c,damping:u}}else{const i=GE(t);s={...s,...i,mass:wt.mass},s.isResolvedFromDuration=!0}return s}function K_(t=wt.visualDuration,s=wt.bounce){const i=typeof t!="object"?{visualDuration:t,keyframes:[0,1],bounce:s}:t;let{restSpeed:o,restDelta:c}=i;const u=i.keyframes[0],d=i.keyframes[i.keyframes.length-1],m={done:!1,value:u},{stiffness:h,damping:g,mass:v,duration:_,velocity:b,isResolvedFromDuration:S}=YE({...i,velocity:-Ls(i.velocity||0)}),T=b||0,N=g/(2*Math.sqrt(h*v)),j=d-u,w=Ls(Math.sqrt(h/v)),C=Math.abs(j)<5;o||(o=C?wt.restSpeed.granular:wt.restSpeed.default),c||(c=C?wt.restDelta.granular:wt.restDelta.default);let A;if(N<1){const D=dp(w,N);A=E=>{const $=Math.exp(-N*w*E);return d-$*((T+N*w*j)/D*Math.sin(D*E)+j*Math.cos(D*E))}}else if(N===1)A=D=>d-Math.exp(-w*D)*(j+(T+w*j)*D);else{const D=w*Math.sqrt(N*N-1);A=E=>{const $=Math.exp(-N*w*E),z=Math.min(D*E,300);return d-$*((T+N*w*j)*Math.sinh(z)+D*j*Math.cosh(z))/D}}const M={calculatedDuration:S&&_||null,next:D=>{const E=A(D);if(S)m.done=D>=_;else{let $=0;N<1&&($=D===0?Bs(T):Z_(A,D,E));const z=Math.abs($)<=o,K=Math.abs(d-E)<=c;m.done=z&&K}return m.value=m.done?d:E,m},toString:()=>{const D=Math.min(G_(M),cp),E=y_($=>M.next(D*$).value,D,30);return D+"ms "+E}};return M}function Q0({keyframes:t,velocity:s=0,power:i=.8,timeConstant:o=325,bounceDamping:c=10,bounceStiffness:u=500,modifyTarget:d,min:m,max:h,restDelta:g=.5,restSpeed:v}){const _=t[0],b={done:!1,value:_},S=z=>m!==void 0&&z<m||h!==void 0&&z>h,T=z=>m===void 0?h:h===void 0||Math.abs(m-z)<Math.abs(h-z)?m:h;let N=i*s;const j=_+N,w=d===void 0?j:d(j);w!==j&&(N=w-_);const C=z=>-N*Math.exp(-z/o),A=z=>w+C(z),M=z=>{const K=C(z),F=A(z);b.done=Math.abs(K)<=g,b.value=b.done?w:F};let D,E;const $=z=>{S(b.value)&&(D=z,E=K_({keyframes:[b.value,T(b.value)],velocity:Z_(A,z,b.value),damping:c,stiffness:u,restDelta:g,restSpeed:v}))};return $(0),{calculatedDuration:null,next:z=>{let K=!1;return!E&&D===void 0&&(K=!0,M(z),$(z)),D!==void 0&&z>=D?E.next(z-D):(!K&&M(z),b)}}}const JE=Or(.42,0,1,1),WE=Or(0,0,.58,1),Y_=Or(.42,0,.58,1),XE=t=>Array.isArray(t)&&typeof t[0]!="number",QE={linear:xn,easeIn:JE,easeInOut:Y_,easeOut:WE,circIn:am,circInOut:C_,circOut:j_,backIn:sm,backInOut:w_,backOut:k_,anticipate:N_},ey=t=>{if(nm(t)){Yb(t.length===4);const[s,i,o,c]=t;return Or(s,i,o,c)}else if(typeof t=="string")return QE[t];return t};function eA(t,s,i){const o=[],c=i||F_,u=t.length-1;for(let d=0;d<u;d++){let m=c(t[d],t[d+1]);if(s){const h=Array.isArray(s)?s[d]||xn:s;m=Br(h,m)}o.push(m)}return o}function tA(t,s,{clamp:i=!0,ease:o,mixer:c}={}){const u=t.length;if(Yb(u===s.length),u===1)return()=>s[0];if(u===2&&s[0]===s[1])return()=>s[1];const d=t[0]===t[1];t[0]>t[u-1]&&(t=[...t].reverse(),s=[...s].reverse());const m=eA(s,o,c),h=m.length,g=v=>{if(d&&v<t[0])return s[0];let _=0;if(h>1)for(;_<t.length-2&&!(v<t[_+1]);_++);const b=ro(t[_],t[_+1],v);return m[_](b)};return i?v=>g(Ps(t[0],t[u-1],v)):g}function nA(t,s){const i=t[t.length-1];for(let o=1;o<=s;o++){const c=ro(0,s,o);t.push(xt(i,1,c))}}function sA(t){const s=[0];return nA(s,t.length-1),s}function aA(t,s){return t.map(i=>i*s)}function iA(t,s){return t.map(()=>s||Y_).splice(0,t.length-1)}function Rc({duration:t=300,keyframes:s,times:i,ease:o="easeInOut"}){const c=XE(o)?o.map(ey):ey(o),u={done:!1,value:s[0]},d=aA(i&&i.length===s.length?i:sA(s),t),m=tA(d,s,{ease:Array.isArray(c)?c:iA(s,c)});return{calculatedDuration:t,next:h=>(u.value=m(h),u.done=h>=t,u)}}const oA=t=>{const s=({timestamp:i})=>t(i);return{start:()=>gt.update(s,!0),stop:()=>Ta(s),now:()=>Zt.isProcessing?Zt.timestamp:us.now()}},rA={decay:Q0,inertia:Q0,tween:Rc,keyframes:Rc,spring:K_},lA=t=>t/100;class um extends $_{constructor(s){super(s),this.holdTime=null,this.cancelTime=null,this.currentTime=0,this.playbackSpeed=1,this.pendingPlayState="running",this.startTime=null,this.state="idle",this.stop=()=>{if(this.resolver.cancel(),this.isStopped=!0,this.state==="idle")return;this.teardown();const{onStop:h}=this.options;h&&h()};const{name:i,motionValue:o,element:c,keyframes:u}=this.options,d=(c==null?void 0:c.KeyframeResolver)||lm,m=(h,g)=>this.onKeyframesResolved(h,g);this.resolver=new d(u,m,i,o,c),this.resolver.scheduleResolve()}flatten(){super.flatten(),this._resolved&&Object.assign(this._resolved,this.initPlayback(this._resolved.keyframes))}initPlayback(s){const{type:i="keyframes",repeat:o=0,repeatDelay:c=0,repeatType:u,velocity:d=0}=this.options,m=tm(i)?i:rA[i]||Rc;let h,g;m!==Rc&&typeof s[0]!="number"&&(h=Br(lA,F_(s[0],s[1])),s=[0,100]);const v=m({...this.options,keyframes:s});u==="mirror"&&(g=m({...this.options,keyframes:[...s].reverse(),velocity:-d})),v.calculatedDuration===null&&(v.calculatedDuration=G_(v));const{calculatedDuration:_}=v,b=_+c,S=b*(o+1)-c;return{generator:v,mirroredGenerator:g,mapPercentToKeyframes:h,calculatedDuration:_,resolvedDuration:b,totalDuration:S}}onPostResolved(){const{autoplay:s=!0}=this.options;this.play(),this.pendingPlayState==="paused"||!s?this.pause():this.state=this.pendingPlayState}tick(s,i=!1){const{resolved:o}=this;if(!o){const{keyframes:z}=this.options;return{done:!0,value:z[z.length-1]}}const{finalKeyframe:c,generator:u,mirroredGenerator:d,mapPercentToKeyframes:m,keyframes:h,calculatedDuration:g,totalDuration:v,resolvedDuration:_}=o;if(this.startTime===null)return u.next(0);const{delay:b,repeat:S,repeatType:T,repeatDelay:N,onUpdate:j}=this.options;this.speed>0?this.startTime=Math.min(this.startTime,s):this.speed<0&&(this.startTime=Math.min(s-v/this.speed,this.startTime)),i?this.currentTime=s:this.holdTime!==null?this.currentTime=this.holdTime:this.currentTime=Math.round(s-this.startTime)*this.speed;const w=this.currentTime-b*(this.speed>=0?1:-1),C=this.speed>=0?w<0:w>v;this.currentTime=Math.max(w,0),this.state==="finished"&&this.holdTime===null&&(this.currentTime=v);let A=this.currentTime,M=u;if(S){const z=Math.min(this.currentTime,v)/_;let K=Math.floor(z),F=z%1;!F&&z>=1&&(F=1),F===1&&K--,K=Math.min(K,S+1),!!(K%2)&&(T==="reverse"?(F=1-F,N&&(F-=N/_)):T==="mirror"&&(M=d)),A=Ps(0,1,F)*_}const D=C?{done:!1,value:h[0]}:M.next(A);m&&(D.value=m(D.value));let{done:E}=D;!C&&g!==null&&(E=this.speed>=0?this.currentTime>=v:this.currentTime<=0);const $=this.holdTime===null&&(this.state==="finished"||this.state==="running"&&E);return $&&c!==void 0&&(D.value=Xc(h,this.options,c)),j&&j(D.value),$&&this.finish(),D}get duration(){const{resolved:s}=this;return s?Ls(s.calculatedDuration):0}get time(){return Ls(this.currentTime)}set time(s){s=Bs(s),this.currentTime=s,this.holdTime!==null||this.speed===0?this.holdTime=s:this.driver&&(this.startTime=this.driver.now()-s/this.speed)}get speed(){return this.playbackSpeed}set speed(s){const i=this.playbackSpeed!==s;this.playbackSpeed=s,i&&(this.time=Ls(this.currentTime))}play(){if(this.resolver.isScheduled||this.resolver.resume(),!this._resolved){this.pendingPlayState="running";return}if(this.isStopped)return;const{driver:s=oA,onPlay:i,startTime:o}=this.options;this.driver||(this.driver=s(u=>this.tick(u))),i&&i();const c=this.driver.now();this.holdTime!==null?this.startTime=c-this.holdTime:this.startTime?this.state==="finished"&&(this.startTime=c):this.startTime=o??this.calcStartTime(),this.state==="finished"&&this.updateFinishedPromise(),this.cancelTime=this.startTime,this.holdTime=null,this.state="running",this.driver.start()}pause(){var s;if(!this._resolved){this.pendingPlayState="paused";return}this.state="paused",this.holdTime=(s=this.currentTime)!==null&&s!==void 0?s:0}complete(){this.state!=="running"&&this.play(),this.pendingPlayState=this.state="finished",this.holdTime=null}finish(){this.teardown(),this.state="finished";const{onComplete:s}=this.options;s&&s()}cancel(){this.cancelTime!==null&&this.tick(this.cancelTime),this.teardown(),this.updateFinishedPromise()}teardown(){this.state="idle",this.stopDriver(),this.resolveFinishedPromise(),this.updateFinishedPromise(),this.startTime=this.cancelTime=null,this.resolver.cancel()}stopDriver(){this.driver&&(this.driver.stop(),this.driver=void 0)}sample(s){return this.startTime=0,this.tick(s,!0)}}const cA=new Set(["opacity","clipPath","filter","transform"]);function uA(t,s,i,{delay:o=0,duration:c=300,repeat:u=0,repeatType:d="loop",ease:m="easeInOut",times:h}={}){const g={[s]:i};h&&(g.offset=h);const v=__(m,c);return Array.isArray(v)&&(g.easing=v),t.animate(g,{delay:o,duration:c,easing:Array.isArray(v)?"linear":v,fill:"both",iterations:u+1,direction:d==="reverse"?"alternate":"normal"})}const dA=em(()=>Object.hasOwnProperty.call(Element.prototype,"animate")),Mc=10,fA=2e4;function pA(t){return tm(t.type)||t.type==="spring"||!b_(t.ease)}function mA(t,s){const i=new um({...s,keyframes:t,repeat:0,delay:0,isGenerator:!0});let o={done:!1,value:t[0]};const c=[];let u=0;for(;!o.done&&u<fA;)o=i.sample(u),c.push(o.value),u+=Mc;return{times:void 0,keyframes:c,duration:u-Mc,ease:"linear"}}const J_={anticipate:N_,backInOut:w_,circInOut:C_};function hA(t){return t in J_}class ty extends $_{constructor(s){super(s);const{name:i,motionValue:o,element:c,keyframes:u}=this.options;this.resolver=new H_(u,(d,m)=>this.onKeyframesResolved(d,m),i,o,c),this.resolver.scheduleResolve()}initPlayback(s,i){let{duration:o=300,times:c,ease:u,type:d,motionValue:m,name:h,startTime:g}=this.options;if(!m.owner||!m.owner.current)return!1;if(typeof u=="string"&&Ac()&&hA(u)&&(u=J_[u]),pA(this.options)){const{onComplete:_,onUpdate:b,motionValue:S,element:T,...N}=this.options,j=mA(s,N);s=j.keyframes,s.length===1&&(s[1]=s[0]),o=j.duration,c=j.times,u=j.ease,d="keyframes"}const v=uA(m.owner.current,h,s,{...this.options,duration:o,times:c,ease:u});return v.startTime=g??this.calcStartTime(),this.pendingTimeline?($0(v,this.pendingTimeline),this.pendingTimeline=void 0):v.onfinish=()=>{const{onComplete:_}=this.options;m.set(Xc(s,this.options,i)),_&&_(),this.cancel(),this.resolveFinishedPromise()},{animation:v,duration:o,times:c,type:d,ease:u,keyframes:s}}get duration(){const{resolved:s}=this;if(!s)return 0;const{duration:i}=s;return Ls(i)}get time(){const{resolved:s}=this;if(!s)return 0;const{animation:i}=s;return Ls(i.currentTime||0)}set time(s){const{resolved:i}=this;if(!i)return;const{animation:o}=i;o.currentTime=Bs(s)}get speed(){const{resolved:s}=this;if(!s)return 1;const{animation:i}=s;return i.playbackRate}set speed(s){const{resolved:i}=this;if(!i)return;const{animation:o}=i;o.playbackRate=s}get state(){const{resolved:s}=this;if(!s)return"idle";const{animation:i}=s;return i.playState}get startTime(){const{resolved:s}=this;if(!s)return null;const{animation:i}=s;return i.startTime}attachTimeline(s){if(!this._resolved)this.pendingTimeline=s;else{const{resolved:i}=this;if(!i)return xn;const{animation:o}=i;$0(o,s)}return xn}play(){if(this.isStopped)return;const{resolved:s}=this;if(!s)return;const{animation:i}=s;i.playState==="finished"&&this.updateFinishedPromise(),i.play()}pause(){const{resolved:s}=this;if(!s)return;const{animation:i}=s;i.pause()}stop(){if(this.resolver.cancel(),this.isStopped=!0,this.state==="idle")return;this.resolveFinishedPromise(),this.updateFinishedPromise();const{resolved:s}=this;if(!s)return;const{animation:i,keyframes:o,duration:c,type:u,ease:d,times:m}=s;if(i.playState==="idle"||i.playState==="finished")return;if(this.time){const{motionValue:g,onUpdate:v,onComplete:_,element:b,...S}=this.options,T=new um({...S,keyframes:o,duration:c,type:u,ease:d,times:m,isGenerator:!0}),N=Bs(this.time);g.setWithVelocity(T.sample(N-Mc).value,T.sample(N).value,Mc)}const{onStop:h}=this.options;h&&h(),this.cancel()}complete(){const{resolved:s}=this;s&&s.animation.finish()}cancel(){const{resolved:s}=this;s&&s.animation.cancel()}static supports(s){const{motionValue:i,name:o,repeatDelay:c,repeatType:u,damping:d,type:m}=s;if(!i||!i.owner||!(i.owner.current instanceof HTMLElement))return!1;const{onUpdate:h,transformTemplate:g}=i.owner.getProps();return dA()&&o&&cA.has(o)&&!h&&!g&&!c&&u!=="mirror"&&d!==0&&m!=="inertia"}}const gA={type:"spring",stiffness:500,damping:25,restSpeed:10},vA=t=>({type:"spring",stiffness:550,damping:t===0?2*Math.sqrt(550):30,restSpeed:10}),yA={type:"keyframes",duration:.8},bA={type:"keyframes",ease:[.25,.1,.35,1],duration:.3},_A=(t,{keyframes:s})=>s.length>2?yA:ci.has(t)?t.startsWith("scale")?vA(s[1]):gA:bA;function xA({when:t,delay:s,delayChildren:i,staggerChildren:o,staggerDirection:c,repeat:u,repeatType:d,repeatDelay:m,from:h,elapsed:g,...v}){return!!Object.keys(v).length}const dm=(t,s,i,o={},c,u)=>d=>{const m=Jp(o,t)||{},h=m.delay||o.delay||0;let{elapsed:g=0}=o;g=g-Bs(h);let v={keyframes:Array.isArray(i)?i:[null,i],ease:"easeOut",velocity:s.getVelocity(),...m,delay:-g,onUpdate:b=>{s.set(b),m.onUpdate&&m.onUpdate(b)},onComplete:()=>{d(),m.onComplete&&m.onComplete()},name:t,motionValue:s,element:u?void 0:c};xA(m)||(v={...v,..._A(t,v)}),v.duration&&(v.duration=Bs(v.duration)),v.repeatDelay&&(v.repeatDelay=Bs(v.repeatDelay)),v.from!==void 0&&(v.keyframes[0]=v.from);let _=!1;if((v.type===!1||v.duration===0&&!v.repeatDelay)&&(v.duration=0,v.delay===0&&(_=!0)),_&&!u&&s.get()!==void 0){const b=Xc(v.keyframes,m);if(b!==void 0)return gt.update(()=>{v.onUpdate(b),v.onComplete()}),new QC([])}return!u&&ty.supports(v)?new ty(v):new um(v)};function SA({protectedKeys:t,needsAnimating:s},i){const o=t.hasOwnProperty(i)&&s[i]!==!0;return s[i]=!1,o}function W_(t,s,{delay:i=0,transitionOverride:o,type:c}={}){var u;let{transition:d=t.getDefaultTransition(),transitionEnd:m,...h}=s;o&&(d=o);const g=[],v=c&&t.animationState&&t.animationState.getState()[c];for(const _ in h){const b=t.getValue(_,(u=t.latestValues[_])!==null&&u!==void 0?u:null),S=h[_];if(S===void 0||v&&SA(v,_))continue;const T={delay:i,...Jp(d||{},_)};let N=!1;if(window.MotionHandoffAnimation){const w=v_(t);if(w){const C=window.MotionHandoffAnimation(w,_,gt);C!==null&&(T.startTime=C,N=!0)}}sp(t,_),b.start(dm(_,b,S,t.shouldReduceMotion&&h_.has(_)?{type:!1}:T,t,N));const j=b.animation;j&&g.push(j)}return m&&Promise.all(g).then(()=>{gt.update(()=>{m&&YC(t,m)})}),g}function fp(t,s,i={}){var o;const c=Wc(t,s,i.type==="exit"?(o=t.presenceContext)===null||o===void 0?void 0:o.custom:void 0);let{transition:u=t.getDefaultTransition()||{}}=c||{};i.transitionOverride&&(u=i.transitionOverride);const d=c?()=>Promise.all(W_(t,c,i)):()=>Promise.resolve(),m=t.variantChildren&&t.variantChildren.size?(g=0)=>{const{delayChildren:v=0,staggerChildren:_,staggerDirection:b}=u;return TA(t,s,v+g,_,b,i)}:()=>Promise.resolve(),{when:h}=u;if(h){const[g,v]=h==="beforeChildren"?[d,m]:[m,d];return g().then(()=>v())}else return Promise.all([d(),m(i.delay)])}function TA(t,s,i=0,o=0,c=1,u){const d=[],m=(t.variantChildren.size-1)*o,h=c===1?(g=0)=>g*o:(g=0)=>m-g*o;return Array.from(t.variantChildren).sort(kA).forEach((g,v)=>{g.notify("AnimationStart",s),d.push(fp(g,s,{...u,delay:i+h(v)}).then(()=>g.notify("AnimationComplete",s)))}),Promise.all(d)}function kA(t,s){return t.sortNodePosition(s)}function wA(t,s,i={}){t.notify("AnimationStart",s);let o;if(Array.isArray(s)){const c=s.map(u=>fp(t,u,i));o=Promise.all(c)}else if(typeof s=="string")o=fp(t,s,i);else{const c=typeof s=="function"?Wc(t,s,i.custom):s;o=Promise.all(W_(t,c,i))}return o.then(()=>{t.notify("AnimationComplete",s)})}const NA=Up.length;function X_(t){if(!t)return;if(!t.isControllingVariants){const i=t.parent?X_(t.parent)||{}:{};return t.props.initial!==void 0&&(i.initial=t.props.initial),i}const s={};for(let i=0;i<NA;i++){const o=Up[i],c=t.props[o];(jr(c)||c===!1)&&(s[o]=c)}return s}const jA=[...Lp].reverse(),CA=Lp.length;function EA(t){return s=>Promise.all(s.map(({animation:i,options:o})=>wA(t,i,o)))}function AA(t){let s=EA(t),i=ny(),o=!0;const c=h=>(g,v)=>{var _;const b=Wc(t,v,h==="exit"?(_=t.presenceContext)===null||_===void 0?void 0:_.custom:void 0);if(b){const{transition:S,transitionEnd:T,...N}=b;g={...g,...N,...T}}return g};function u(h){s=h(t)}function d(h){const{props:g}=t,v=X_(t.parent)||{},_=[],b=new Set;let S={},T=1/0;for(let j=0;j<CA;j++){const w=jA[j],C=i[w],A=g[w]!==void 0?g[w]:v[w],M=jr(A),D=w===h?C.isActive:null;D===!1&&(T=j);let E=A===v[w]&&A!==g[w]&&M;if(E&&o&&t.manuallyAnimateOnMount&&(E=!1),C.protectedKeys={...S},!C.isActive&&D===null||!A&&!C.prevProp||Yc(A)||typeof A=="boolean")continue;const $=DA(C.prevProp,A);let z=$||w===h&&C.isActive&&!E&&M||j>T&&M,K=!1;const F=Array.isArray(A)?A:[A];let ee=F.reduce(c(w),{});D===!1&&(ee={});const{prevResolvedValues:ae={}}=C,me={...ae,...ee},ie=q=>{z=!0,b.has(q)&&(K=!0,b.delete(q)),C.needsAnimating[q]=!0;const te=t.getValue(q);te&&(te.liveStyle=!1)};for(const q in me){const te=ee[q],re=ae[q];if(S.hasOwnProperty(q))continue;let ue=!1;np(te)&&np(re)?ue=!m_(te,re):ue=te!==re,ue?te!=null?ie(q):b.add(q):te!==void 0&&b.has(q)?ie(q):C.protectedKeys[q]=!0}C.prevProp=A,C.prevResolvedValues=ee,C.isActive&&(S={...S,...ee}),o&&t.blockInitialAnimation&&(z=!1),z&&(!(E&&$)||K)&&_.push(...F.map(q=>({animation:q,options:{type:w}})))}if(b.size){const j={};b.forEach(w=>{const C=t.getBaseTarget(w),A=t.getValue(w);A&&(A.liveStyle=!0),j[w]=C??null}),_.push({animation:j})}let N=!!_.length;return o&&(g.initial===!1||g.initial===g.animate)&&!t.manuallyAnimateOnMount&&(N=!1),o=!1,N?s(_):Promise.resolve()}function m(h,g){var v;if(i[h].isActive===g)return Promise.resolve();(v=t.variantChildren)===null||v===void 0||v.forEach(b=>{var S;return(S=b.animationState)===null||S===void 0?void 0:S.setActive(h,g)}),i[h].isActive=g;const _=d(h);for(const b in i)i[b].protectedKeys={};return _}return{animateChanges:d,setActive:m,setAnimateFunction:u,getState:()=>i,reset:()=>{i=ny(),o=!0}}}function DA(t,s){return typeof s=="string"?s!==t:Array.isArray(s)?!m_(s,t):!1}function Za(t=!1){return{isActive:t,protectedKeys:{},needsAnimating:{},prevResolvedValues:{}}}function ny(){return{animate:Za(!0),whileInView:Za(),whileHover:Za(),whileTap:Za(),whileDrag:Za(),whileFocus:Za(),exit:Za()}}class Na{constructor(s){this.isMounted=!1,this.node=s}update(){}}class RA extends Na{constructor(s){super(s),s.animationState||(s.animationState=AA(s))}updateAnimationControlsSubscription(){const{animate:s}=this.node.getProps();Yc(s)&&(this.unmountControls=s.subscribe(this.node))}mount(){this.updateAnimationControlsSubscription()}update(){const{animate:s}=this.node.getProps(),{animate:i}=this.node.prevProps||{};s!==i&&this.updateAnimationControlsSubscription()}unmount(){var s;this.node.animationState.reset(),(s=this.unmountControls)===null||s===void 0||s.call(this)}}let MA=0;class IA extends Na{constructor(){super(...arguments),this.id=MA++}update(){if(!this.node.presenceContext)return;const{isPresent:s,onExitComplete:i}=this.node.presenceContext,{isPresent:o}=this.node.prevPresenceContext||{};if(!this.node.animationState||s===o)return;const c=this.node.animationState.setActive("exit",!s);i&&!s&&c.then(()=>i(this.id))}mount(){const{register:s}=this.node.presenceContext||{};s&&(this.unmount=s(this.id))}unmount(){}}const OA={animation:{Feature:RA},exit:{Feature:IA}},Jn={x:!1,y:!1};function Q_(){return Jn.x||Jn.y}function BA(t){return t==="x"||t==="y"?Jn[t]?null:(Jn[t]=!0,()=>{Jn[t]=!1}):Jn.x||Jn.y?null:(Jn.x=Jn.y=!0,()=>{Jn.x=Jn.y=!1})}const fm=t=>t.pointerType==="mouse"?typeof t.button!="number"||t.button<=0:t.isPrimary!==!1;function Dr(t,s,i,o={passive:!0}){return t.addEventListener(s,i,o),()=>t.removeEventListener(s,i)}function Lr(t){return{point:{x:t.pageX,y:t.pageY}}}const LA=t=>s=>fm(s)&&t(s,Lr(s));function br(t,s,i,o){return Dr(t,s,LA(i),o)}const sy=(t,s)=>Math.abs(t-s);function UA(t,s){const i=sy(t.x,s.x),o=sy(t.y,s.y);return Math.sqrt(i**2+o**2)}class ex{constructor(s,i,{transformPagePoint:o,contextWindow:c,dragSnapToOrigin:u=!1}={}){if(this.startEvent=null,this.lastMoveEvent=null,this.lastMoveEventInfo=null,this.handlers={},this.contextWindow=window,this.updatePoint=()=>{if(!(this.lastMoveEvent&&this.lastMoveEventInfo))return;const _=Df(this.lastMoveEventInfo,this.history),b=this.startEvent!==null,S=UA(_.offset,{x:0,y:0})>=3;if(!b&&!S)return;const{point:T}=_,{timestamp:N}=Zt;this.history.push({...T,timestamp:N});const{onStart:j,onMove:w}=this.handlers;b||(j&&j(this.lastMoveEvent,_),this.startEvent=this.lastMoveEvent),w&&w(this.lastMoveEvent,_)},this.handlePointerMove=(_,b)=>{this.lastMoveEvent=_,this.lastMoveEventInfo=Af(b,this.transformPagePoint),gt.update(this.updatePoint,!0)},this.handlePointerUp=(_,b)=>{this.end();const{onEnd:S,onSessionEnd:T,resumeAnimation:N}=this.handlers;if(this.dragSnapToOrigin&&N&&N(),!(this.lastMoveEvent&&this.lastMoveEventInfo))return;const j=Df(_.type==="pointercancel"?this.lastMoveEventInfo:Af(b,this.transformPagePoint),this.history);this.startEvent&&S&&S(_,j),T&&T(_,j)},!fm(s))return;this.dragSnapToOrigin=u,this.handlers=i,this.transformPagePoint=o,this.contextWindow=c||window;const d=Lr(s),m=Af(d,this.transformPagePoint),{point:h}=m,{timestamp:g}=Zt;this.history=[{...h,timestamp:g}];const{onSessionStart:v}=i;v&&v(s,Df(m,this.history)),this.removeListeners=Br(br(this.contextWindow,"pointermove",this.handlePointerMove),br(this.contextWindow,"pointerup",this.handlePointerUp),br(this.contextWindow,"pointercancel",this.handlePointerUp))}updateHandlers(s){this.handlers=s}end(){this.removeListeners&&this.removeListeners(),Ta(this.updatePoint)}}function Af(t,s){return s?{point:s(t.point)}:t}function ay(t,s){return{x:t.x-s.x,y:t.y-s.y}}function Df({point:t},s){return{point:t,delta:ay(t,tx(s)),offset:ay(t,zA(s)),velocity:PA(s,.1)}}function zA(t){return t[0]}function tx(t){return t[t.length-1]}function PA(t,s){if(t.length<2)return{x:0,y:0};let i=t.length-1,o=null;const c=tx(t);for(;i>=0&&(o=t[i],!(c.timestamp-o.timestamp>Bs(s)));)i--;if(!o)return{x:0,y:0};const u=Ls(c.timestamp-o.timestamp);if(u===0)return{x:0,y:0};const d={x:(c.x-o.x)/u,y:(c.y-o.y)/u};return d.x===1/0&&(d.x=0),d.y===1/0&&(d.y=0),d}const nx=1e-4,VA=1-nx,HA=1+nx,sx=.01,$A=0-sx,GA=0+sx;function Sn(t){return t.max-t.min}function qA(t,s,i){return Math.abs(t-s)<=i}function iy(t,s,i,o=.5){t.origin=o,t.originPoint=xt(s.min,s.max,t.origin),t.scale=Sn(i)/Sn(s),t.translate=xt(i.min,i.max,t.origin)-t.originPoint,(t.scale>=VA&&t.scale<=HA||isNaN(t.scale))&&(t.scale=1),(t.translate>=$A&&t.translate<=GA||isNaN(t.translate))&&(t.translate=0)}function _r(t,s,i,o){iy(t.x,s.x,i.x,o?o.originX:void 0),iy(t.y,s.y,i.y,o?o.originY:void 0)}function oy(t,s,i){t.min=i.min+s.min,t.max=t.min+Sn(s)}function FA(t,s,i){oy(t.x,s.x,i.x),oy(t.y,s.y,i.y)}function ry(t,s,i){t.min=s.min-i.min,t.max=t.min+Sn(s)}function xr(t,s,i){ry(t.x,s.x,i.x),ry(t.y,s.y,i.y)}function ZA(t,{min:s,max:i},o){return s!==void 0&&t<s?t=o?xt(s,t,o.min):Math.max(t,s):i!==void 0&&t>i&&(t=o?xt(i,t,o.max):Math.min(t,i)),t}function ly(t,s,i){return{min:s!==void 0?t.min+s:void 0,max:i!==void 0?t.max+i-(t.max-t.min):void 0}}function KA(t,{top:s,left:i,bottom:o,right:c}){return{x:ly(t.x,i,c),y:ly(t.y,s,o)}}function cy(t,s){let i=s.min-t.min,o=s.max-t.max;return s.max-s.min<t.max-t.min&&([i,o]=[o,i]),{min:i,max:o}}function YA(t,s){return{x:cy(t.x,s.x),y:cy(t.y,s.y)}}function JA(t,s){let i=.5;const o=Sn(t),c=Sn(s);return c>o?i=ro(s.min,s.max-o,t.min):o>c&&(i=ro(t.min,t.max-c,s.min)),Ps(0,1,i)}function WA(t,s){const i={};return s.min!==void 0&&(i.min=s.min-t.min),s.max!==void 0&&(i.max=s.max-t.min),i}const pp=.35;function XA(t=pp){return t===!1?t=0:t===!0&&(t=pp),{x:uy(t,"left","right"),y:uy(t,"top","bottom")}}function uy(t,s,i){return{min:dy(t,s),max:dy(t,i)}}function dy(t,s){return typeof t=="number"?t:t[s]||0}const fy=()=>({translate:0,scale:1,origin:0,originPoint:0}),Qi=()=>({x:fy(),y:fy()}),py=()=>({min:0,max:0}),At=()=>({x:py(),y:py()});function Un(t){return[t("x"),t("y")]}function ax({top:t,left:s,right:i,bottom:o}){return{x:{min:s,max:i},y:{min:t,max:o}}}function QA({x:t,y:s}){return{top:s.min,right:t.max,bottom:s.max,left:t.min}}function eD(t,s){if(!s)return t;const i=s({x:t.left,y:t.top}),o=s({x:t.right,y:t.bottom});return{top:i.y,left:i.x,bottom:o.y,right:o.x}}function Rf(t){return t===void 0||t===1}function mp({scale:t,scaleX:s,scaleY:i}){return!Rf(t)||!Rf(s)||!Rf(i)}function Wa(t){return mp(t)||ix(t)||t.z||t.rotate||t.rotateX||t.rotateY||t.skewX||t.skewY}function ix(t){return my(t.x)||my(t.y)}function my(t){return t&&t!=="0%"}function Ic(t,s,i){const o=t-i,c=s*o;return i+c}function hy(t,s,i,o,c){return c!==void 0&&(t=Ic(t,c,o)),Ic(t,i,o)+s}function hp(t,s=0,i=1,o,c){t.min=hy(t.min,s,i,o,c),t.max=hy(t.max,s,i,o,c)}function ox(t,{x:s,y:i}){hp(t.x,s.translate,s.scale,s.originPoint),hp(t.y,i.translate,i.scale,i.originPoint)}const gy=.999999999999,vy=1.0000000000001;function tD(t,s,i,o=!1){const c=i.length;if(!c)return;s.x=s.y=1;let u,d;for(let m=0;m<c;m++){u=i[m],d=u.projectionDelta;const{visualElement:h}=u.options;h&&h.props.style&&h.props.style.display==="contents"||(o&&u.options.layoutScroll&&u.scroll&&u!==u.root&&to(t,{x:-u.scroll.offset.x,y:-u.scroll.offset.y}),d&&(s.x*=d.x.scale,s.y*=d.y.scale,ox(t,d)),o&&Wa(u.latestValues)&&to(t,u.latestValues))}s.x<vy&&s.x>gy&&(s.x=1),s.y<vy&&s.y>gy&&(s.y=1)}function eo(t,s){t.min=t.min+s,t.max=t.max+s}function yy(t,s,i,o,c=.5){const u=xt(t.min,t.max,c);hp(t,s,i,u,o)}function to(t,s){yy(t.x,s.x,s.scaleX,s.scale,s.originX),yy(t.y,s.y,s.scaleY,s.scale,s.originY)}function rx(t,s){return ax(eD(t.getBoundingClientRect(),s))}function nD(t,s,i){const o=rx(t,i),{scroll:c}=s;return c&&(eo(o.x,c.offset.x),eo(o.y,c.offset.y)),o}const lx=({current:t})=>t?t.ownerDocument.defaultView:null,sD=new WeakMap;class aD{constructor(s){this.openDragLock=null,this.isDragging=!1,this.currentDirection=null,this.originPoint={x:0,y:0},this.constraints=!1,this.hasMutatedConstraints=!1,this.elastic=At(),this.visualElement=s}start(s,{snapToCursor:i=!1}={}){const{presenceContext:o}=this.visualElement;if(o&&o.isPresent===!1)return;const c=v=>{const{dragSnapToOrigin:_}=this.getProps();_?this.pauseAnimation():this.stopAnimation(),i&&this.snapToCursor(Lr(v).point)},u=(v,_)=>{const{drag:b,dragPropagation:S,onDragStart:T}=this.getProps();if(b&&!S&&(this.openDragLock&&this.openDragLock(),this.openDragLock=BA(b),!this.openDragLock))return;this.isDragging=!0,this.currentDirection=null,this.resolveConstraints(),this.visualElement.projection&&(this.visualElement.projection.isAnimationBlocked=!0,this.visualElement.projection.target=void 0),Un(j=>{let w=this.getAxisMotionValue(j).get()||0;if(cs.test(w)){const{projection:C}=this.visualElement;if(C&&C.layout){const A=C.layout.layoutBox[j];A&&(w=Sn(A)*(parseFloat(w)/100))}}this.originPoint[j]=w}),T&&gt.postRender(()=>T(v,_)),sp(this.visualElement,"transform");const{animationState:N}=this.visualElement;N&&N.setActive("whileDrag",!0)},d=(v,_)=>{const{dragPropagation:b,dragDirectionLock:S,onDirectionLock:T,onDrag:N}=this.getProps();if(!b&&!this.openDragLock)return;const{offset:j}=_;if(S&&this.currentDirection===null){this.currentDirection=iD(j),this.currentDirection!==null&&T&&T(this.currentDirection);return}this.updateAxis("x",_.point,j),this.updateAxis("y",_.point,j),this.visualElement.render(),N&&N(v,_)},m=(v,_)=>this.stop(v,_),h=()=>Un(v=>{var _;return this.getAnimationState(v)==="paused"&&((_=this.getAxisMotionValue(v).animation)===null||_===void 0?void 0:_.play())}),{dragSnapToOrigin:g}=this.getProps();this.panSession=new ex(s,{onSessionStart:c,onStart:u,onMove:d,onSessionEnd:m,resumeAnimation:h},{transformPagePoint:this.visualElement.getTransformPagePoint(),dragSnapToOrigin:g,contextWindow:lx(this.visualElement)})}stop(s,i){const o=this.isDragging;if(this.cancel(),!o)return;const{velocity:c}=i;this.startAnimation(c);const{onDragEnd:u}=this.getProps();u&&gt.postRender(()=>u(s,i))}cancel(){this.isDragging=!1;const{projection:s,animationState:i}=this.visualElement;s&&(s.isAnimationBlocked=!1),this.panSession&&this.panSession.end(),this.panSession=void 0;const{dragPropagation:o}=this.getProps();!o&&this.openDragLock&&(this.openDragLock(),this.openDragLock=null),i&&i.setActive("whileDrag",!1)}updateAxis(s,i,o){const{drag:c}=this.getProps();if(!o||!dc(s,c,this.currentDirection))return;const u=this.getAxisMotionValue(s);let d=this.originPoint[s]+o[s];this.constraints&&this.constraints[s]&&(d=ZA(d,this.constraints[s],this.elastic[s])),u.set(d)}resolveConstraints(){var s;const{dragConstraints:i,dragElastic:o}=this.getProps(),c=this.visualElement.projection&&!this.visualElement.projection.layout?this.visualElement.projection.measure(!1):(s=this.visualElement.projection)===null||s===void 0?void 0:s.layout,u=this.constraints;i&&Wi(i)?this.constraints||(this.constraints=this.resolveRefConstraints()):i&&c?this.constraints=KA(c.layoutBox,i):this.constraints=!1,this.elastic=XA(o),u!==this.constraints&&c&&this.constraints&&!this.hasMutatedConstraints&&Un(d=>{this.constraints!==!1&&this.getAxisMotionValue(d)&&(this.constraints[d]=WA(c.layoutBox[d],this.constraints[d]))})}resolveRefConstraints(){const{dragConstraints:s,onMeasureDragConstraints:i}=this.getProps();if(!s||!Wi(s))return!1;const o=s.current,{projection:c}=this.visualElement;if(!c||!c.layout)return!1;const u=nD(o,c.root,this.visualElement.getTransformPagePoint());let d=YA(c.layout.layoutBox,u);if(i){const m=i(QA(d));this.hasMutatedConstraints=!!m,m&&(d=ax(m))}return d}startAnimation(s){const{drag:i,dragMomentum:o,dragElastic:c,dragTransition:u,dragSnapToOrigin:d,onDragTransitionEnd:m}=this.getProps(),h=this.constraints||{},g=Un(v=>{if(!dc(v,i,this.currentDirection))return;let _=h&&h[v]||{};d&&(_={min:0,max:0});const b=c?200:1e6,S=c?40:1e7,T={type:"inertia",velocity:o?s[v]:0,bounceStiffness:b,bounceDamping:S,timeConstant:750,restDelta:1,restSpeed:10,...u,..._};return this.startAxisValueAnimation(v,T)});return Promise.all(g).then(m)}startAxisValueAnimation(s,i){const o=this.getAxisMotionValue(s);return sp(this.visualElement,s),o.start(dm(s,o,0,i,this.visualElement,!1))}stopAnimation(){Un(s=>this.getAxisMotionValue(s).stop())}pauseAnimation(){Un(s=>{var i;return(i=this.getAxisMotionValue(s).animation)===null||i===void 0?void 0:i.pause()})}getAnimationState(s){var i;return(i=this.getAxisMotionValue(s).animation)===null||i===void 0?void 0:i.state}getAxisMotionValue(s){const i=`_drag${s.toUpperCase()}`,o=this.visualElement.getProps(),c=o[i];return c||this.visualElement.getValue(s,(o.initial?o.initial[s]:void 0)||0)}snapToCursor(s){Un(i=>{const{drag:o}=this.getProps();if(!dc(i,o,this.currentDirection))return;const{projection:c}=this.visualElement,u=this.getAxisMotionValue(i);if(c&&c.layout){const{min:d,max:m}=c.layout.layoutBox[i];u.set(s[i]-xt(d,m,.5))}})}scalePositionWithinConstraints(){if(!this.visualElement.current)return;const{drag:s,dragConstraints:i}=this.getProps(),{projection:o}=this.visualElement;if(!Wi(i)||!o||!this.constraints)return;this.stopAnimation();const c={x:0,y:0};Un(d=>{const m=this.getAxisMotionValue(d);if(m&&this.constraints!==!1){const h=m.get();c[d]=JA({min:h,max:h},this.constraints[d])}});const{transformTemplate:u}=this.visualElement.getProps();this.visualElement.current.style.transform=u?u({},""):"none",o.root&&o.root.updateScroll(),o.updateLayout(),this.resolveConstraints(),Un(d=>{if(!dc(d,s,null))return;const m=this.getAxisMotionValue(d),{min:h,max:g}=this.constraints[d];m.set(xt(h,g,c[d]))})}addListeners(){if(!this.visualElement.current)return;sD.set(this.visualElement,this);const s=this.visualElement.current,i=br(s,"pointerdown",h=>{const{drag:g,dragListener:v=!0}=this.getProps();g&&v&&this.start(h)}),o=()=>{const{dragConstraints:h}=this.getProps();Wi(h)&&h.current&&(this.constraints=this.resolveRefConstraints())},{projection:c}=this.visualElement,u=c.addEventListener("measure",o);c&&!c.layout&&(c.root&&c.root.updateScroll(),c.updateLayout()),gt.read(o);const d=Dr(window,"resize",()=>this.scalePositionWithinConstraints()),m=c.addEventListener("didUpdate",(({delta:h,hasLayoutChanged:g})=>{this.isDragging&&g&&(Un(v=>{const _=this.getAxisMotionValue(v);_&&(this.originPoint[v]+=h[v].translate,_.set(_.get()+h[v].translate))}),this.visualElement.render())}));return()=>{d(),i(),u(),m&&m()}}getProps(){const s=this.visualElement.getProps(),{drag:i=!1,dragDirectionLock:o=!1,dragPropagation:c=!1,dragConstraints:u=!1,dragElastic:d=pp,dragMomentum:m=!0}=s;return{...s,drag:i,dragDirectionLock:o,dragPropagation:c,dragConstraints:u,dragElastic:d,dragMomentum:m}}}function dc(t,s,i){return(s===!0||s===t)&&(i===null||i===t)}function iD(t,s=10){let i=null;return Math.abs(t.y)>s?i="y":Math.abs(t.x)>s&&(i="x"),i}class oD extends Na{constructor(s){super(s),this.removeGroupControls=xn,this.removeListeners=xn,this.controls=new aD(s)}mount(){const{dragControls:s}=this.node.getProps();s&&(this.removeGroupControls=s.subscribe(this.controls)),this.removeListeners=this.controls.addListeners()||xn}unmount(){this.removeGroupControls(),this.removeListeners()}}const by=t=>(s,i)=>{t&&gt.postRender(()=>t(s,i))};class rD extends Na{constructor(){super(...arguments),this.removePointerDownListener=xn}onPointerDown(s){this.session=new ex(s,this.createPanHandlers(),{transformPagePoint:this.node.getTransformPagePoint(),contextWindow:lx(this.node)})}createPanHandlers(){const{onPanSessionStart:s,onPanStart:i,onPan:o,onPanEnd:c}=this.node.getProps();return{onSessionStart:by(s),onStart:by(i),onMove:o,onEnd:(u,d)=>{delete this.session,c&&gt.postRender(()=>c(u,d))}}}mount(){this.removePointerDownListener=br(this.node.current,"pointerdown",s=>this.onPointerDown(s))}update(){this.session&&this.session.updateHandlers(this.createPanHandlers())}unmount(){this.removePointerDownListener(),this.session&&this.session.end()}}const Tc={hasAnimatedSinceResize:!0,hasEverUpdated:!1};function _y(t,s){return s.max===s.min?0:t/(s.max-s.min)*100}const cr={correct:(t,s)=>{if(!s.target)return t;if(typeof t=="string")if(we.test(t))t=parseFloat(t);else return t;const i=_y(t,s.target.x),o=_y(t,s.target.y);return`${i}% ${o}%`}},lD={correct:(t,{treeScale:s,projectionDelta:i})=>{const o=t,c=ka.parse(t);if(c.length>5)return o;const u=ka.createTransformer(t),d=typeof c[0]!="number"?1:0,m=i.x.scale*s.x,h=i.y.scale*s.y;c[0+d]/=m,c[1+d]/=h;const g=xt(m,h,.5);return typeof c[2+d]=="number"&&(c[2+d]/=g),typeof c[3+d]=="number"&&(c[3+d]/=g),u(c)}};class cD extends y.Component{componentDidMount(){const{visualElement:s,layoutGroup:i,switchLayoutGroup:o,layoutId:c}=this.props,{projection:u}=s;OC(uD),u&&(i.group&&i.group.add(u),o&&o.register&&c&&o.register(u),u.root.didUpdate(),u.addEventListener("animationComplete",()=>{this.safeToRemove()}),u.setOptions({...u.options,onExitComplete:()=>this.safeToRemove()})),Tc.hasEverUpdated=!0}getSnapshotBeforeUpdate(s){const{layoutDependency:i,visualElement:o,drag:c,isPresent:u}=this.props,d=o.projection;return d&&(d.isPresent=u,c||s.layoutDependency!==i||i===void 0?d.willUpdate():this.safeToRemove(),s.isPresent!==u&&(u?d.promote():d.relegate()||gt.postRender(()=>{const m=d.getStack();(!m||!m.members.length)&&this.safeToRemove()}))),null}componentDidUpdate(){const{projection:s}=this.props.visualElement;s&&(s.root.didUpdate(),Pp.postRender(()=>{!s.currentAnimation&&s.isLead()&&this.safeToRemove()}))}componentWillUnmount(){const{visualElement:s,layoutGroup:i,switchLayoutGroup:o}=this.props,{projection:c}=s;c&&(c.scheduleCheckAfterUnmount(),i&&i.group&&i.group.remove(c),o&&o.deregister&&o.deregister(c))}safeToRemove(){const{safeToRemove:s}=this.props;s&&s()}render(){return null}}function cx(t){const[s,i]=Zb(),o=y.useContext(Mp);return l.jsx(cD,{...t,layoutGroup:o,switchLayoutGroup:y.useContext(t_),isPresent:s,safeToRemove:i})}const uD={borderRadius:{...cr,applyTo:["borderTopLeftRadius","borderTopRightRadius","borderBottomLeftRadius","borderBottomRightRadius"]},borderTopLeftRadius:cr,borderTopRightRadius:cr,borderBottomLeftRadius:cr,borderBottomRightRadius:cr,boxShadow:lD};function dD(t,s,i){const o=Xt(t)?t:Er(t);return o.start(dm("",o,s,i)),o.animation}function fD(t){return t instanceof SVGElement&&t.tagName!=="svg"}const pD=(t,s)=>t.depth-s.depth;class mD{constructor(){this.children=[],this.isDirty=!1}add(s){Wp(this.children,s),this.isDirty=!0}remove(s){Xp(this.children,s),this.isDirty=!0}forEach(s){this.isDirty&&this.children.sort(pD),this.isDirty=!1,this.children.forEach(s)}}function hD(t,s){const i=us.now(),o=({timestamp:c})=>{const u=c-i;u>=s&&(Ta(o),t(u-s))};return gt.read(o,!0),()=>Ta(o)}const ux=["TopLeft","TopRight","BottomLeft","BottomRight"],gD=ux.length,xy=t=>typeof t=="string"?parseFloat(t):t,Sy=t=>typeof t=="number"||we.test(t);function vD(t,s,i,o,c,u){c?(t.opacity=xt(0,i.opacity!==void 0?i.opacity:1,yD(o)),t.opacityExit=xt(s.opacity!==void 0?s.opacity:1,0,bD(o))):u&&(t.opacity=xt(s.opacity!==void 0?s.opacity:1,i.opacity!==void 0?i.opacity:1,o));for(let d=0;d<gD;d++){const m=`border${ux[d]}Radius`;let h=Ty(s,m),g=Ty(i,m);if(h===void 0&&g===void 0)continue;h||(h=0),g||(g=0),h===0||g===0||Sy(h)===Sy(g)?(t[m]=Math.max(xt(xy(h),xy(g),o),0),(cs.test(g)||cs.test(h))&&(t[m]+="%")):t[m]=g}(s.rotate||i.rotate)&&(t.rotate=xt(s.rotate||0,i.rotate||0,o))}function Ty(t,s){return t[s]!==void 0?t[s]:t.borderRadius}const yD=dx(0,.5,j_),bD=dx(.5,.95,xn);function dx(t,s,i){return o=>o<t?0:o>s?1:i(ro(t,s,o))}function ky(t,s){t.min=s.min,t.max=s.max}function On(t,s){ky(t.x,s.x),ky(t.y,s.y)}function wy(t,s){t.translate=s.translate,t.scale=s.scale,t.originPoint=s.originPoint,t.origin=s.origin}function Ny(t,s,i,o,c){return t-=s,t=Ic(t,1/i,o),c!==void 0&&(t=Ic(t,1/c,o)),t}function _D(t,s=0,i=1,o=.5,c,u=t,d=t){if(cs.test(s)&&(s=parseFloat(s),s=xt(d.min,d.max,s/100)-d.min),typeof s!="number")return;let m=xt(u.min,u.max,o);t===u&&(m-=s),t.min=Ny(t.min,s,i,m,c),t.max=Ny(t.max,s,i,m,c)}function jy(t,s,[i,o,c],u,d){_D(t,s[i],s[o],s[c],s.scale,u,d)}const xD=["x","scaleX","originX"],SD=["y","scaleY","originY"];function Cy(t,s,i,o){jy(t.x,s,xD,i?i.x:void 0,o?o.x:void 0),jy(t.y,s,SD,i?i.y:void 0,o?o.y:void 0)}function Ey(t){return t.translate===0&&t.scale===1}function fx(t){return Ey(t.x)&&Ey(t.y)}function Ay(t,s){return t.min===s.min&&t.max===s.max}function TD(t,s){return Ay(t.x,s.x)&&Ay(t.y,s.y)}function Dy(t,s){return Math.round(t.min)===Math.round(s.min)&&Math.round(t.max)===Math.round(s.max)}function px(t,s){return Dy(t.x,s.x)&&Dy(t.y,s.y)}function Ry(t){return Sn(t.x)/Sn(t.y)}function My(t,s){return t.translate===s.translate&&t.scale===s.scale&&t.originPoint===s.originPoint}class kD{constructor(){this.members=[]}add(s){Wp(this.members,s),s.scheduleRender()}remove(s){if(Xp(this.members,s),s===this.prevLead&&(this.prevLead=void 0),s===this.lead){const i=this.members[this.members.length-1];i&&this.promote(i)}}relegate(s){const i=this.members.findIndex(c=>s===c);if(i===0)return!1;let o;for(let c=i;c>=0;c--){const u=this.members[c];if(u.isPresent!==!1){o=u;break}}return o?(this.promote(o),!0):!1}promote(s,i){const o=this.lead;if(s!==o&&(this.prevLead=o,this.lead=s,s.show(),o)){o.instance&&o.scheduleRender(),s.scheduleRender(),s.resumeFrom=o,i&&(s.resumeFrom.preserveOpacity=!0),o.snapshot&&(s.snapshot=o.snapshot,s.snapshot.latestValues=o.animationValues||o.latestValues),s.root&&s.root.isUpdating&&(s.isLayoutDirty=!0);const{crossfade:c}=s.options;c===!1&&o.hide()}}exitAnimationComplete(){this.members.forEach(s=>{const{options:i,resumingFrom:o}=s;i.onExitComplete&&i.onExitComplete(),o&&o.options.onExitComplete&&o.options.onExitComplete()})}scheduleRender(){this.members.forEach(s=>{s.instance&&s.scheduleRender(!1)})}removeLeadSnapshot(){this.lead&&this.lead.snapshot&&(this.lead.snapshot=void 0)}}function wD(t,s,i){let o="";const c=t.x.translate/s.x,u=t.y.translate/s.y,d=(i==null?void 0:i.z)||0;if((c||u||d)&&(o=`translate3d(${c}px, ${u}px, ${d}px) `),(s.x!==1||s.y!==1)&&(o+=`scale(${1/s.x}, ${1/s.y}) `),i){const{transformPerspective:g,rotate:v,rotateX:_,rotateY:b,skewX:S,skewY:T}=i;g&&(o=`perspective(${g}px) ${o}`),v&&(o+=`rotate(${v}deg) `),_&&(o+=`rotateX(${_}deg) `),b&&(o+=`rotateY(${b}deg) `),S&&(o+=`skewX(${S}deg) `),T&&(o+=`skewY(${T}deg) `)}const m=t.x.scale*s.x,h=t.y.scale*s.y;return(m!==1||h!==1)&&(o+=`scale(${m}, ${h})`),o||"none"}const Xa={type:"projectionFrame",totalNodes:0,resolvedTargetDeltas:0,recalculatedProjection:0},mr=typeof window<"u"&&window.MotionDebug!==void 0,Mf=["","X","Y","Z"],ND={visibility:"hidden"},Iy=1e3;let jD=0;function If(t,s,i,o){const{latestValues:c}=s;c[t]&&(i[t]=c[t],s.setStaticValue(t,0),o&&(o[t]=0))}function mx(t){if(t.hasCheckedOptimisedAppear=!0,t.root===t)return;const{visualElement:s}=t.options;if(!s)return;const i=v_(s);if(window.MotionHasOptimisedAnimation(i,"transform")){const{layout:c,layoutId:u}=t.options;window.MotionCancelOptimisedAnimation(i,"transform",gt,!(c||u))}const{parent:o}=t;o&&!o.hasCheckedOptimisedAppear&&mx(o)}function hx({attachResizeListener:t,defaultParent:s,measureScroll:i,checkIsScrollRoot:o,resetTransform:c}){return class{constructor(d={},m=s==null?void 0:s()){this.id=jD++,this.animationId=0,this.children=new Set,this.options={},this.isTreeAnimating=!1,this.isAnimationBlocked=!1,this.isLayoutDirty=!1,this.isProjectionDirty=!1,this.isSharedProjectionDirty=!1,this.isTransformDirty=!1,this.updateManuallyBlocked=!1,this.updateBlockedByResize=!1,this.isUpdating=!1,this.isSVG=!1,this.needsReset=!1,this.shouldResetTransform=!1,this.hasCheckedOptimisedAppear=!1,this.treeScale={x:1,y:1},this.eventHandlers=new Map,this.hasTreeAnimated=!1,this.updateScheduled=!1,this.scheduleUpdate=()=>this.update(),this.projectionUpdateScheduled=!1,this.checkUpdateFailed=()=>{this.isUpdating&&(this.isUpdating=!1,this.clearAllSnapshots())},this.updateProjection=()=>{this.projectionUpdateScheduled=!1,mr&&(Xa.totalNodes=Xa.resolvedTargetDeltas=Xa.recalculatedProjection=0),this.nodes.forEach(AD),this.nodes.forEach(OD),this.nodes.forEach(BD),this.nodes.forEach(DD),mr&&window.MotionDebug.record(Xa)},this.resolvedRelativeTargetAt=0,this.hasProjected=!1,this.isVisible=!0,this.animationProgress=0,this.sharedNodes=new Map,this.latestValues=d,this.root=m?m.root||m:this,this.path=m?[...m.path,m]:[],this.parent=m,this.depth=m?m.depth+1:0;for(let h=0;h<this.path.length;h++)this.path[h].shouldResetTransform=!0;this.root===this&&(this.nodes=new mD)}addEventListener(d,m){return this.eventHandlers.has(d)||this.eventHandlers.set(d,new Qp),this.eventHandlers.get(d).add(m)}notifyListeners(d,...m){const h=this.eventHandlers.get(d);h&&h.notify(...m)}hasListeners(d){return this.eventHandlers.has(d)}mount(d,m=this.root.hasTreeAnimated){if(this.instance)return;this.isSVG=fD(d),this.instance=d;const{layoutId:h,layout:g,visualElement:v}=this.options;if(v&&!v.current&&v.mount(d),this.root.nodes.add(this),this.parent&&this.parent.children.add(this),m&&(g||h)&&(this.isLayoutDirty=!0),t){let _;const b=()=>this.root.updateBlockedByResize=!1;t(d,()=>{this.root.updateBlockedByResize=!0,_&&_(),_=hD(b,250),Tc.hasAnimatedSinceResize&&(Tc.hasAnimatedSinceResize=!1,this.nodes.forEach(By))})}h&&this.root.registerSharedNode(h,this),this.options.animate!==!1&&v&&(h||g)&&this.addEventListener("didUpdate",({delta:_,hasLayoutChanged:b,hasRelativeTargetChanged:S,layout:T})=>{if(this.isTreeAnimationBlocked()){this.target=void 0,this.relativeTarget=void 0;return}const N=this.options.transition||v.getDefaultTransition()||VD,{onLayoutAnimationStart:j,onLayoutAnimationComplete:w}=v.getProps(),C=!this.targetLayout||!px(this.targetLayout,T)||S,A=!b&&S;if(this.options.layoutRoot||this.resumeFrom&&this.resumeFrom.instance||A||b&&(C||!this.currentAnimation)){this.resumeFrom&&(this.resumingFrom=this.resumeFrom,this.resumingFrom.resumingFrom=void 0),this.setAnimationOrigin(_,A);const M={...Jp(N,"layout"),onPlay:j,onComplete:w};(v.shouldReduceMotion||this.options.layoutRoot)&&(M.delay=0,M.type=!1),this.startAnimation(M)}else b||By(this),this.isLead()&&this.options.onExitComplete&&this.options.onExitComplete();this.targetLayout=T})}unmount(){this.options.layoutId&&this.willUpdate(),this.root.nodes.remove(this);const d=this.getStack();d&&d.remove(this),this.parent&&this.parent.children.delete(this),this.instance=void 0,Ta(this.updateProjection)}blockUpdate(){this.updateManuallyBlocked=!0}unblockUpdate(){this.updateManuallyBlocked=!1}isUpdateBlocked(){return this.updateManuallyBlocked||this.updateBlockedByResize}isTreeAnimationBlocked(){return this.isAnimationBlocked||this.parent&&this.parent.isTreeAnimationBlocked()||!1}startUpdate(){this.isUpdateBlocked()||(this.isUpdating=!0,this.nodes&&this.nodes.forEach(LD),this.animationId++)}getTransformTemplate(){const{visualElement:d}=this.options;return d&&d.getProps().transformTemplate}willUpdate(d=!0){if(this.root.hasTreeAnimated=!0,this.root.isUpdateBlocked()){this.options.onExitComplete&&this.options.onExitComplete();return}if(window.MotionCancelOptimisedAnimation&&!this.hasCheckedOptimisedAppear&&mx(this),!this.root.isUpdating&&this.root.startUpdate(),this.isLayoutDirty)return;this.isLayoutDirty=!0;for(let v=0;v<this.path.length;v++){const _=this.path[v];_.shouldResetTransform=!0,_.updateScroll("snapshot"),_.options.layoutRoot&&_.willUpdate(!1)}const{layoutId:m,layout:h}=this.options;if(m===void 0&&!h)return;const g=this.getTransformTemplate();this.prevTransformTemplateValue=g?g(this.latestValues,""):void 0,this.updateSnapshot(),d&&this.notifyListeners("willUpdate")}update(){if(this.updateScheduled=!1,this.isUpdateBlocked()){this.unblockUpdate(),this.clearAllSnapshots(),this.nodes.forEach(Oy);return}this.isUpdating||this.nodes.forEach(MD),this.isUpdating=!1,this.nodes.forEach(ID),this.nodes.forEach(CD),this.nodes.forEach(ED),this.clearAllSnapshots();const m=us.now();Zt.delta=Ps(0,1e3/60,m-Zt.timestamp),Zt.timestamp=m,Zt.isProcessing=!0,wf.update.process(Zt),wf.preRender.process(Zt),wf.render.process(Zt),Zt.isProcessing=!1}didUpdate(){this.updateScheduled||(this.updateScheduled=!0,Pp.read(this.scheduleUpdate))}clearAllSnapshots(){this.nodes.forEach(RD),this.sharedNodes.forEach(UD)}scheduleUpdateProjection(){this.projectionUpdateScheduled||(this.projectionUpdateScheduled=!0,gt.preRender(this.updateProjection,!1,!0))}scheduleCheckAfterUnmount(){gt.postRender(()=>{this.isLayoutDirty?this.root.didUpdate():this.root.checkUpdateFailed()})}updateSnapshot(){this.snapshot||!this.instance||(this.snapshot=this.measure())}updateLayout(){if(!this.instance||(this.updateScroll(),!(this.options.alwaysMeasureLayout&&this.isLead())&&!this.isLayoutDirty))return;if(this.resumeFrom&&!this.resumeFrom.instance)for(let h=0;h<this.path.length;h++)this.path[h].updateScroll();const d=this.layout;this.layout=this.measure(!1),this.layoutCorrected=At(),this.isLayoutDirty=!1,this.projectionDelta=void 0,this.notifyListeners("measure",this.layout.layoutBox);const{visualElement:m}=this.options;m&&m.notify("LayoutMeasure",this.layout.layoutBox,d?d.layoutBox:void 0)}updateScroll(d="measure"){let m=!!(this.options.layoutScroll&&this.instance);if(this.scroll&&this.scroll.animationId===this.root.animationId&&this.scroll.phase===d&&(m=!1),m){const h=o(this.instance);this.scroll={animationId:this.root.animationId,phase:d,isRoot:h,offset:i(this.instance),wasRoot:this.scroll?this.scroll.isRoot:h}}}resetTransform(){if(!c)return;const d=this.isLayoutDirty||this.shouldResetTransform||this.options.alwaysMeasureLayout,m=this.projectionDelta&&!fx(this.projectionDelta),h=this.getTransformTemplate(),g=h?h(this.latestValues,""):void 0,v=g!==this.prevTransformTemplateValue;d&&(m||Wa(this.latestValues)||v)&&(c(this.instance,g),this.shouldResetTransform=!1,this.scheduleRender())}measure(d=!0){const m=this.measurePageBox();let h=this.removeElementScroll(m);return d&&(h=this.removeTransform(h)),HD(h),{animationId:this.root.animationId,measuredBox:m,layoutBox:h,latestValues:{},source:this.id}}measurePageBox(){var d;const{visualElement:m}=this.options;if(!m)return At();const h=m.measureViewportBox();if(!(((d=this.scroll)===null||d===void 0?void 0:d.wasRoot)||this.path.some($D))){const{scroll:v}=this.root;v&&(eo(h.x,v.offset.x),eo(h.y,v.offset.y))}return h}removeElementScroll(d){var m;const h=At();if(On(h,d),!((m=this.scroll)===null||m===void 0)&&m.wasRoot)return h;for(let g=0;g<this.path.length;g++){const v=this.path[g],{scroll:_,options:b}=v;v!==this.root&&_&&b.layoutScroll&&(_.wasRoot&&On(h,d),eo(h.x,_.offset.x),eo(h.y,_.offset.y))}return h}applyTransform(d,m=!1){const h=At();On(h,d);for(let g=0;g<this.path.length;g++){const v=this.path[g];!m&&v.options.layoutScroll&&v.scroll&&v!==v.root&&to(h,{x:-v.scroll.offset.x,y:-v.scroll.offset.y}),Wa(v.latestValues)&&to(h,v.latestValues)}return Wa(this.latestValues)&&to(h,this.latestValues),h}removeTransform(d){const m=At();On(m,d);for(let h=0;h<this.path.length;h++){const g=this.path[h];if(!g.instance||!Wa(g.latestValues))continue;mp(g.latestValues)&&g.updateSnapshot();const v=At(),_=g.measurePageBox();On(v,_),Cy(m,g.latestValues,g.snapshot?g.snapshot.layoutBox:void 0,v)}return Wa(this.latestValues)&&Cy(m,this.latestValues),m}setTargetDelta(d){this.targetDelta=d,this.root.scheduleUpdateProjection(),this.isProjectionDirty=!0}setOptions(d){this.options={...this.options,...d,crossfade:d.crossfade!==void 0?d.crossfade:!0}}clearMeasurements(){this.scroll=void 0,this.layout=void 0,this.snapshot=void 0,this.prevTransformTemplateValue=void 0,this.targetDelta=void 0,this.target=void 0,this.isLayoutDirty=!1}forceRelativeParentToResolveTarget(){this.relativeParent&&this.relativeParent.resolvedRelativeTargetAt!==Zt.timestamp&&this.relativeParent.resolveTargetDelta(!0)}resolveTargetDelta(d=!1){var m;const h=this.getLead();this.isProjectionDirty||(this.isProjectionDirty=h.isProjectionDirty),this.isTransformDirty||(this.isTransformDirty=h.isTransformDirty),this.isSharedProjectionDirty||(this.isSharedProjectionDirty=h.isSharedProjectionDirty);const g=!!this.resumingFrom||this!==h;if(!(d||g&&this.isSharedProjectionDirty||this.isProjectionDirty||!((m=this.parent)===null||m===void 0)&&m.isProjectionDirty||this.attemptToResolveRelativeTarget||this.root.updateBlockedByResize))return;const{layout:_,layoutId:b}=this.options;if(!(!this.layout||!(_||b))){if(this.resolvedRelativeTargetAt=Zt.timestamp,!this.targetDelta&&!this.relativeTarget){const S=this.getClosestProjectingParent();S&&S.layout&&this.animationProgress!==1?(this.relativeParent=S,this.forceRelativeParentToResolveTarget(),this.relativeTarget=At(),this.relativeTargetOrigin=At(),xr(this.relativeTargetOrigin,this.layout.layoutBox,S.layout.layoutBox),On(this.relativeTarget,this.relativeTargetOrigin)):this.relativeParent=this.relativeTarget=void 0}if(!(!this.relativeTarget&&!this.targetDelta)){if(this.target||(this.target=At(),this.targetWithTransforms=At()),this.relativeTarget&&this.relativeTargetOrigin&&this.relativeParent&&this.relativeParent.target?(this.forceRelativeParentToResolveTarget(),FA(this.target,this.relativeTarget,this.relativeParent.target)):this.targetDelta?(this.resumingFrom?this.target=this.applyTransform(this.layout.layoutBox):On(this.target,this.layout.layoutBox),ox(this.target,this.targetDelta)):On(this.target,this.layout.layoutBox),this.attemptToResolveRelativeTarget){this.attemptToResolveRelativeTarget=!1;const S=this.getClosestProjectingParent();S&&!!S.resumingFrom==!!this.resumingFrom&&!S.options.layoutScroll&&S.target&&this.animationProgress!==1?(this.relativeParent=S,this.forceRelativeParentToResolveTarget(),this.relativeTarget=At(),this.relativeTargetOrigin=At(),xr(this.relativeTargetOrigin,this.target,S.target),On(this.relativeTarget,this.relativeTargetOrigin)):this.relativeParent=this.relativeTarget=void 0}mr&&Xa.resolvedTargetDeltas++}}}getClosestProjectingParent(){if(!(!this.parent||mp(this.parent.latestValues)||ix(this.parent.latestValues)))return this.parent.isProjecting()?this.parent:this.parent.getClosestProjectingParent()}isProjecting(){return!!((this.relativeTarget||this.targetDelta||this.options.layoutRoot)&&this.layout)}calcProjection(){var d;const m=this.getLead(),h=!!this.resumingFrom||this!==m;let g=!0;if((this.isProjectionDirty||!((d=this.parent)===null||d===void 0)&&d.isProjectionDirty)&&(g=!1),h&&(this.isSharedProjectionDirty||this.isTransformDirty)&&(g=!1),this.resolvedRelativeTargetAt===Zt.timestamp&&(g=!1),g)return;const{layout:v,layoutId:_}=this.options;if(this.isTreeAnimating=!!(this.parent&&this.parent.isTreeAnimating||this.currentAnimation||this.pendingAnimation),this.isTreeAnimating||(this.targetDelta=this.relativeTarget=void 0),!this.layout||!(v||_))return;On(this.layoutCorrected,this.layout.layoutBox);const b=this.treeScale.x,S=this.treeScale.y;tD(this.layoutCorrected,this.treeScale,this.path,h),m.layout&&!m.target&&(this.treeScale.x!==1||this.treeScale.y!==1)&&(m.target=m.layout.layoutBox,m.targetWithTransforms=At());const{target:T}=m;if(!T){this.prevProjectionDelta&&(this.createProjectionDeltas(),this.scheduleRender());return}!this.projectionDelta||!this.prevProjectionDelta?this.createProjectionDeltas():(wy(this.prevProjectionDelta.x,this.projectionDelta.x),wy(this.prevProjectionDelta.y,this.projectionDelta.y)),_r(this.projectionDelta,this.layoutCorrected,T,this.latestValues),(this.treeScale.x!==b||this.treeScale.y!==S||!My(this.projectionDelta.x,this.prevProjectionDelta.x)||!My(this.projectionDelta.y,this.prevProjectionDelta.y))&&(this.hasProjected=!0,this.scheduleRender(),this.notifyListeners("projectionUpdate",T)),mr&&Xa.recalculatedProjection++}hide(){this.isVisible=!1}show(){this.isVisible=!0}scheduleRender(d=!0){var m;if((m=this.options.visualElement)===null||m===void 0||m.scheduleRender(),d){const h=this.getStack();h&&h.scheduleRender()}this.resumingFrom&&!this.resumingFrom.instance&&(this.resumingFrom=void 0)}createProjectionDeltas(){this.prevProjectionDelta=Qi(),this.projectionDelta=Qi(),this.projectionDeltaWithTransform=Qi()}setAnimationOrigin(d,m=!1){const h=this.snapshot,g=h?h.latestValues:{},v={...this.latestValues},_=Qi();(!this.relativeParent||!this.relativeParent.options.layoutRoot)&&(this.relativeTarget=this.relativeTargetOrigin=void 0),this.attemptToResolveRelativeTarget=!m;const b=At(),S=h?h.source:void 0,T=this.layout?this.layout.source:void 0,N=S!==T,j=this.getStack(),w=!j||j.members.length<=1,C=!!(N&&!w&&this.options.crossfade===!0&&!this.path.some(PD));this.animationProgress=0;let A;this.mixTargetDelta=M=>{const D=M/1e3;Ly(_.x,d.x,D),Ly(_.y,d.y,D),this.setTargetDelta(_),this.relativeTarget&&this.relativeTargetOrigin&&this.layout&&this.relativeParent&&this.relativeParent.layout&&(xr(b,this.layout.layoutBox,this.relativeParent.layout.layoutBox),zD(this.relativeTarget,this.relativeTargetOrigin,b,D),A&&TD(this.relativeTarget,A)&&(this.isProjectionDirty=!1),A||(A=At()),On(A,this.relativeTarget)),N&&(this.animationValues=v,vD(v,g,this.latestValues,D,C,w)),this.root.scheduleUpdateProjection(),this.scheduleRender(),this.animationProgress=D},this.mixTargetDelta(this.options.layoutRoot?1e3:0)}startAnimation(d){this.notifyListeners("animationStart"),this.currentAnimation&&this.currentAnimation.stop(),this.resumingFrom&&this.resumingFrom.currentAnimation&&this.resumingFrom.currentAnimation.stop(),this.pendingAnimation&&(Ta(this.pendingAnimation),this.pendingAnimation=void 0),this.pendingAnimation=gt.update(()=>{Tc.hasAnimatedSinceResize=!0,this.currentAnimation=dD(0,Iy,{...d,onUpdate:m=>{this.mixTargetDelta(m),d.onUpdate&&d.onUpdate(m)},onComplete:()=>{d.onComplete&&d.onComplete(),this.completeAnimation()}}),this.resumingFrom&&(this.resumingFrom.currentAnimation=this.currentAnimation),this.pendingAnimation=void 0})}completeAnimation(){this.resumingFrom&&(this.resumingFrom.currentAnimation=void 0,this.resumingFrom.preserveOpacity=void 0);const d=this.getStack();d&&d.exitAnimationComplete(),this.resumingFrom=this.currentAnimation=this.animationValues=void 0,this.notifyListeners("animationComplete")}finishAnimation(){this.currentAnimation&&(this.mixTargetDelta&&this.mixTargetDelta(Iy),this.currentAnimation.stop()),this.completeAnimation()}applyTransformsToTarget(){const d=this.getLead();let{targetWithTransforms:m,target:h,layout:g,latestValues:v}=d;if(!(!m||!h||!g)){if(this!==d&&this.layout&&g&&gx(this.options.animationType,this.layout.layoutBox,g.layoutBox)){h=this.target||At();const _=Sn(this.layout.layoutBox.x);h.x.min=d.target.x.min,h.x.max=h.x.min+_;const b=Sn(this.layout.layoutBox.y);h.y.min=d.target.y.min,h.y.max=h.y.min+b}On(m,h),to(m,v),_r(this.projectionDeltaWithTransform,this.layoutCorrected,m,v)}}registerSharedNode(d,m){this.sharedNodes.has(d)||this.sharedNodes.set(d,new kD),this.sharedNodes.get(d).add(m);const g=m.options.initialPromotionConfig;m.promote({transition:g?g.transition:void 0,preserveFollowOpacity:g&&g.shouldPreserveFollowOpacity?g.shouldPreserveFollowOpacity(m):void 0})}isLead(){const d=this.getStack();return d?d.lead===this:!0}getLead(){var d;const{layoutId:m}=this.options;return m?((d=this.getStack())===null||d===void 0?void 0:d.lead)||this:this}getPrevLead(){var d;const{layoutId:m}=this.options;return m?(d=this.getStack())===null||d===void 0?void 0:d.prevLead:void 0}getStack(){const{layoutId:d}=this.options;if(d)return this.root.sharedNodes.get(d)}promote({needsReset:d,transition:m,preserveFollowOpacity:h}={}){const g=this.getStack();g&&g.promote(this,h),d&&(this.projectionDelta=void 0,this.needsReset=!0),m&&this.setOptions({transition:m})}relegate(){const d=this.getStack();return d?d.relegate(this):!1}resetSkewAndRotation(){const{visualElement:d}=this.options;if(!d)return;let m=!1;const{latestValues:h}=d;if((h.z||h.rotate||h.rotateX||h.rotateY||h.rotateZ||h.skewX||h.skewY)&&(m=!0),!m)return;const g={};h.z&&If("z",d,g,this.animationValues);for(let v=0;v<Mf.length;v++)If(`rotate${Mf[v]}`,d,g,this.animationValues),If(`skew${Mf[v]}`,d,g,this.animationValues);d.render();for(const v in g)d.setStaticValue(v,g[v]),this.animationValues&&(this.animationValues[v]=g[v]);d.scheduleRender()}getProjectionStyles(d){var m,h;if(!this.instance||this.isSVG)return;if(!this.isVisible)return ND;const g={visibility:""},v=this.getTransformTemplate();if(this.needsReset)return this.needsReset=!1,g.opacity="",g.pointerEvents=xc(d==null?void 0:d.pointerEvents)||"",g.transform=v?v(this.latestValues,""):"none",g;const _=this.getLead();if(!this.projectionDelta||!this.layout||!_.target){const N={};return this.options.layoutId&&(N.opacity=this.latestValues.opacity!==void 0?this.latestValues.opacity:1,N.pointerEvents=xc(d==null?void 0:d.pointerEvents)||""),this.hasProjected&&!Wa(this.latestValues)&&(N.transform=v?v({},""):"none",this.hasProjected=!1),N}const b=_.animationValues||_.latestValues;this.applyTransformsToTarget(),g.transform=wD(this.projectionDeltaWithTransform,this.treeScale,b),v&&(g.transform=v(b,g.transform));const{x:S,y:T}=this.projectionDelta;g.transformOrigin=`${S.origin*100}% ${T.origin*100}% 0`,_.animationValues?g.opacity=_===this?(h=(m=b.opacity)!==null&&m!==void 0?m:this.latestValues.opacity)!==null&&h!==void 0?h:1:this.preserveOpacity?this.latestValues.opacity:b.opacityExit:g.opacity=_===this?b.opacity!==void 0?b.opacity:"":b.opacityExit!==void 0?b.opacityExit:0;for(const N in Ec){if(b[N]===void 0)continue;const{correct:j,applyTo:w}=Ec[N],C=g.transform==="none"?b[N]:j(b[N],_);if(w){const A=w.length;for(let M=0;M<A;M++)g[w[M]]=C}else g[N]=C}return this.options.layoutId&&(g.pointerEvents=_===this?xc(d==null?void 0:d.pointerEvents)||"":"none"),g}clearSnapshot(){this.resumeFrom=this.snapshot=void 0}resetTree(){this.root.nodes.forEach(d=>{var m;return(m=d.currentAnimation)===null||m===void 0?void 0:m.stop()}),this.root.nodes.forEach(Oy),this.root.sharedNodes.clear()}}}function CD(t){t.updateLayout()}function ED(t){var s;const i=((s=t.resumeFrom)===null||s===void 0?void 0:s.snapshot)||t.snapshot;if(t.isLead()&&t.layout&&i&&t.hasListeners("didUpdate")){const{layoutBox:o,measuredBox:c}=t.layout,{animationType:u}=t.options,d=i.source!==t.layout.source;u==="size"?Un(_=>{const b=d?i.measuredBox[_]:i.layoutBox[_],S=Sn(b);b.min=o[_].min,b.max=b.min+S}):gx(u,i.layoutBox,o)&&Un(_=>{const b=d?i.measuredBox[_]:i.layoutBox[_],S=Sn(o[_]);b.max=b.min+S,t.relativeTarget&&!t.currentAnimation&&(t.isProjectionDirty=!0,t.relativeTarget[_].max=t.relativeTarget[_].min+S)});const m=Qi();_r(m,o,i.layoutBox);const h=Qi();d?_r(h,t.applyTransform(c,!0),i.measuredBox):_r(h,o,i.layoutBox);const g=!fx(m);let v=!1;if(!t.resumeFrom){const _=t.getClosestProjectingParent();if(_&&!_.resumeFrom){const{snapshot:b,layout:S}=_;if(b&&S){const T=At();xr(T,i.layoutBox,b.layoutBox);const N=At();xr(N,o,S.layoutBox),px(T,N)||(v=!0),_.options.layoutRoot&&(t.relativeTarget=N,t.relativeTargetOrigin=T,t.relativeParent=_)}}}t.notifyListeners("didUpdate",{layout:o,snapshot:i,delta:h,layoutDelta:m,hasLayoutChanged:g,hasRelativeTargetChanged:v})}else if(t.isLead()){const{onExitComplete:o}=t.options;o&&o()}t.options.transition=void 0}function AD(t){mr&&Xa.totalNodes++,t.parent&&(t.isProjecting()||(t.isProjectionDirty=t.parent.isProjectionDirty),t.isSharedProjectionDirty||(t.isSharedProjectionDirty=!!(t.isProjectionDirty||t.parent.isProjectionDirty||t.parent.isSharedProjectionDirty)),t.isTransformDirty||(t.isTransformDirty=t.parent.isTransformDirty))}function DD(t){t.isProjectionDirty=t.isSharedProjectionDirty=t.isTransformDirty=!1}function RD(t){t.clearSnapshot()}function Oy(t){t.clearMeasurements()}function MD(t){t.isLayoutDirty=!1}function ID(t){const{visualElement:s}=t.options;s&&s.getProps().onBeforeLayoutMeasure&&s.notify("BeforeLayoutMeasure"),t.resetTransform()}function By(t){t.finishAnimation(),t.targetDelta=t.relativeTarget=t.target=void 0,t.isProjectionDirty=!0}function OD(t){t.resolveTargetDelta()}function BD(t){t.calcProjection()}function LD(t){t.resetSkewAndRotation()}function UD(t){t.removeLeadSnapshot()}function Ly(t,s,i){t.translate=xt(s.translate,0,i),t.scale=xt(s.scale,1,i),t.origin=s.origin,t.originPoint=s.originPoint}function Uy(t,s,i,o){t.min=xt(s.min,i.min,o),t.max=xt(s.max,i.max,o)}function zD(t,s,i,o){Uy(t.x,s.x,i.x,o),Uy(t.y,s.y,i.y,o)}function PD(t){return t.animationValues&&t.animationValues.opacityExit!==void 0}const VD={duration:.45,ease:[.4,0,.1,1]},zy=t=>typeof navigator<"u"&&navigator.userAgent&&navigator.userAgent.toLowerCase().includes(t),Py=zy("applewebkit/")&&!zy("chrome/")?Math.round:xn;function Vy(t){t.min=Py(t.min),t.max=Py(t.max)}function HD(t){Vy(t.x),Vy(t.y)}function gx(t,s,i){return t==="position"||t==="preserve-aspect"&&!qA(Ry(s),Ry(i),.2)}function $D(t){var s;return t!==t.root&&((s=t.scroll)===null||s===void 0?void 0:s.wasRoot)}const GD=hx({attachResizeListener:(t,s)=>Dr(t,"resize",s),measureScroll:()=>({x:document.documentElement.scrollLeft||document.body.scrollLeft,y:document.documentElement.scrollTop||document.body.scrollTop}),checkIsScrollRoot:()=>!0}),Of={current:void 0},vx=hx({measureScroll:t=>({x:t.scrollLeft,y:t.scrollTop}),defaultParent:()=>{if(!Of.current){const t=new GD({});t.mount(window),t.setOptions({layoutScroll:!0}),Of.current=t}return Of.current},resetTransform:(t,s)=>{t.style.transform=s!==void 0?s:"none"},checkIsScrollRoot:t=>window.getComputedStyle(t).position==="fixed"}),qD={pan:{Feature:rD},drag:{Feature:oD,ProjectionNode:vx,MeasureLayout:cx}};function FD(t,s,i){var o;if(t instanceof Element)return[t];if(typeof t=="string"){let c=document;const u=(o=void 0)!==null&&o!==void 0?o:c.querySelectorAll(t);return u?Array.from(u):[]}return Array.from(t)}function yx(t,s){const i=FD(t),o=new AbortController,c={passive:!0,...s,signal:o.signal};return[i,c,()=>o.abort()]}function Hy(t){return s=>{s.pointerType==="touch"||Q_()||t(s)}}function ZD(t,s,i={}){const[o,c,u]=yx(t,i),d=Hy(m=>{const{target:h}=m,g=s(m);if(typeof g!="function"||!h)return;const v=Hy(_=>{g(_),h.removeEventListener("pointerleave",v)});h.addEventListener("pointerleave",v,c)});return o.forEach(m=>{m.addEventListener("pointerenter",d,c)}),u}function $y(t,s,i){const{props:o}=t;t.animationState&&o.whileHover&&t.animationState.setActive("whileHover",i==="Start");const c="onHover"+i,u=o[c];u&&gt.postRender(()=>u(s,Lr(s)))}class KD extends Na{mount(){const{current:s}=this.node;s&&(this.unmount=ZD(s,i=>($y(this.node,i,"Start"),o=>$y(this.node,o,"End"))))}unmount(){}}class YD extends Na{constructor(){super(...arguments),this.isActive=!1}onFocus(){let s=!1;try{s=this.node.current.matches(":focus-visible")}catch{s=!0}!s||!this.node.animationState||(this.node.animationState.setActive("whileFocus",!0),this.isActive=!0)}onBlur(){!this.isActive||!this.node.animationState||(this.node.animationState.setActive("whileFocus",!1),this.isActive=!1)}mount(){this.unmount=Br(Dr(this.node.current,"focus",()=>this.onFocus()),Dr(this.node.current,"blur",()=>this.onBlur()))}unmount(){}}const bx=(t,s)=>s?t===s?!0:bx(t,s.parentElement):!1,JD=new Set(["BUTTON","INPUT","SELECT","TEXTAREA","A"]);function WD(t){return JD.has(t.tagName)||t.tabIndex!==-1}const hr=new WeakSet;function Gy(t){return s=>{s.key==="Enter"&&t(s)}}function Bf(t,s){t.dispatchEvent(new PointerEvent("pointer"+s,{isPrimary:!0,bubbles:!0}))}const XD=(t,s)=>{const i=t.currentTarget;if(!i)return;const o=Gy(()=>{if(hr.has(i))return;Bf(i,"down");const c=Gy(()=>{Bf(i,"up")}),u=()=>Bf(i,"cancel");i.addEventListener("keyup",c,s),i.addEventListener("blur",u,s)});i.addEventListener("keydown",o,s),i.addEventListener("blur",()=>i.removeEventListener("keydown",o),s)};function qy(t){return fm(t)&&!Q_()}function QD(t,s,i={}){const[o,c,u]=yx(t,i),d=m=>{const h=m.currentTarget;if(!qy(m)||hr.has(h))return;hr.add(h);const g=s(m),v=(S,T)=>{window.removeEventListener("pointerup",_),window.removeEventListener("pointercancel",b),!(!qy(S)||!hr.has(h))&&(hr.delete(h),typeof g=="function"&&g(S,{success:T}))},_=S=>{v(S,i.useGlobalTarget||bx(h,S.target))},b=S=>{v(S,!1)};window.addEventListener("pointerup",_,c),window.addEventListener("pointercancel",b,c)};return o.forEach(m=>{!WD(m)&&m.getAttribute("tabindex")===null&&(m.tabIndex=0),(i.useGlobalTarget?window:m).addEventListener("pointerdown",d,c),m.addEventListener("focus",g=>XD(g,c),c)}),u}function Fy(t,s,i){const{props:o}=t;t.animationState&&o.whileTap&&t.animationState.setActive("whileTap",i==="Start");const c="onTap"+(i==="End"?"":i),u=o[c];u&&gt.postRender(()=>u(s,Lr(s)))}class eR extends Na{mount(){const{current:s}=this.node;s&&(this.unmount=QD(s,i=>(Fy(this.node,i,"Start"),(o,{success:c})=>Fy(this.node,o,c?"End":"Cancel")),{useGlobalTarget:this.node.props.globalTapTarget}))}unmount(){}}const gp=new WeakMap,Lf=new WeakMap,tR=t=>{const s=gp.get(t.target);s&&s(t)},nR=t=>{t.forEach(tR)};function sR({root:t,...s}){const i=t||document;Lf.has(i)||Lf.set(i,{});const o=Lf.get(i),c=JSON.stringify(s);return o[c]||(o[c]=new IntersectionObserver(nR,{root:t,...s})),o[c]}function aR(t,s,i){const o=sR(s);return gp.set(t,i),o.observe(t),()=>{gp.delete(t),o.unobserve(t)}}const iR={some:0,all:1};class oR extends Na{constructor(){super(...arguments),this.hasEnteredView=!1,this.isInView=!1}startObserver(){this.unmount();const{viewport:s={}}=this.node.getProps(),{root:i,margin:o,amount:c="some",once:u}=s,d={root:i?i.current:void 0,rootMargin:o,threshold:typeof c=="number"?c:iR[c]},m=h=>{const{isIntersecting:g}=h;if(this.isInView===g||(this.isInView=g,u&&!g&&this.hasEnteredView))return;g&&(this.hasEnteredView=!0),this.node.animationState&&this.node.animationState.setActive("whileInView",g);const{onViewportEnter:v,onViewportLeave:_}=this.node.getProps(),b=g?v:_;b&&b(h)};return aR(this.node.current,d,m)}mount(){this.startObserver()}update(){if(typeof IntersectionObserver>"u")return;const{props:s,prevProps:i}=this.node;["amount","margin","root"].some(rR(s,i))&&this.startObserver()}unmount(){}}function rR({viewport:t={}},{viewport:s={}}={}){return i=>t[i]!==s[i]}const lR={inView:{Feature:oR},tap:{Feature:eR},focus:{Feature:YD},hover:{Feature:KD}},cR={layout:{ProjectionNode:vx,MeasureLayout:cx}},Oc={current:null},pm={current:!1};function _x(){if(pm.current=!0,!!Bp)if(window.matchMedia){const t=window.matchMedia("(prefers-reduced-motion)"),s=()=>Oc.current=t.matches;t.addListener(s),s()}else Oc.current=!1}const uR=[...V_,Wt,ka],dR=t=>uR.find(P_(t)),Zy=new WeakMap;function fR(t,s,i){for(const o in s){const c=s[o],u=i[o];if(Xt(c))t.addValue(o,c);else if(Xt(u))t.addValue(o,Er(c,{owner:t}));else if(u!==c)if(t.hasValue(o)){const d=t.getValue(o);d.liveStyle===!0?d.jump(c):d.hasAnimated||d.set(c)}else{const d=t.getStaticValue(o);t.addValue(o,Er(d!==void 0?d:c,{owner:t}))}}for(const o in i)s[o]===void 0&&t.removeValue(o);return s}const Ky=["AnimationStart","AnimationComplete","Update","BeforeLayoutMeasure","LayoutMeasure","LayoutAnimationStart","LayoutAnimationComplete"];class pR{scrapeMotionValuesFromProps(s,i,o){return{}}constructor({parent:s,props:i,presenceContext:o,reducedMotionConfig:c,blockInitialAnimation:u,visualState:d},m={}){this.current=null,this.children=new Set,this.isVariantNode=!1,this.isControllingVariants=!1,this.shouldReduceMotion=null,this.values=new Map,this.KeyframeResolver=lm,this.features={},this.valueSubscriptions=new Map,this.prevMotionValues={},this.events={},this.propEventSubscriptions={},this.notifyUpdate=()=>this.notify("Update",this.latestValues),this.render=()=>{this.current&&(this.triggerBuild(),this.renderInstance(this.current,this.renderState,this.props.style,this.projection))},this.renderScheduledAt=0,this.scheduleRender=()=>{const S=us.now();this.renderScheduledAt<S&&(this.renderScheduledAt=S,gt.render(this.render,!1,!0))};const{latestValues:h,renderState:g,onUpdate:v}=d;this.onUpdate=v,this.latestValues=h,this.baseTarget={...h},this.initialValues=i.initial?{...h}:{},this.renderState=g,this.parent=s,this.props=i,this.presenceContext=o,this.depth=s?s.depth+1:0,this.reducedMotionConfig=c,this.options=m,this.blockInitialAnimation=!!u,this.isControllingVariants=Jc(i),this.isVariantNode=Qb(i),this.isVariantNode&&(this.variantChildren=new Set),this.manuallyAnimateOnMount=!!(s&&s.current);const{willChange:_,...b}=this.scrapeMotionValuesFromProps(i,{},this);for(const S in b){const T=b[S];h[S]!==void 0&&Xt(T)&&T.set(h[S],!1)}}mount(s){this.current=s,Zy.set(s,this),this.projection&&!this.projection.instance&&this.projection.mount(s),this.parent&&this.isVariantNode&&!this.isControllingVariants&&(this.removeFromVariantTree=this.parent.addVariantChild(this)),this.values.forEach((i,o)=>this.bindToMotionValue(o,i)),pm.current||_x(),this.shouldReduceMotion=this.reducedMotionConfig==="never"?!1:this.reducedMotionConfig==="always"?!0:Oc.current,this.parent&&this.parent.children.add(this),this.update(this.props,this.presenceContext)}unmount(){Zy.delete(this.current),this.projection&&this.projection.unmount(),Ta(this.notifyUpdate),Ta(this.render),this.valueSubscriptions.forEach(s=>s()),this.valueSubscriptions.clear(),this.removeFromVariantTree&&this.removeFromVariantTree(),this.parent&&this.parent.children.delete(this);for(const s in this.events)this.events[s].clear();for(const s in this.features){const i=this.features[s];i&&(i.unmount(),i.isMounted=!1)}this.current=null}bindToMotionValue(s,i){this.valueSubscriptions.has(s)&&this.valueSubscriptions.get(s)();const o=ci.has(s),c=i.on("change",m=>{this.latestValues[s]=m,this.props.onUpdate&&gt.preRender(this.notifyUpdate),o&&this.projection&&(this.projection.isTransformDirty=!0)}),u=i.on("renderRequest",this.scheduleRender);let d;window.MotionCheckAppearSync&&(d=window.MotionCheckAppearSync(this,s,i)),this.valueSubscriptions.set(s,()=>{c(),u(),d&&d(),i.owner&&i.stop()})}sortNodePosition(s){return!this.current||!this.sortInstanceNodePosition||this.type!==s.type?0:this.sortInstanceNodePosition(this.current,s.current)}updateFeatures(){let s="animation";for(s in oo){const i=oo[s];if(!i)continue;const{isEnabled:o,Feature:c}=i;if(!this.features[s]&&c&&o(this.props)&&(this.features[s]=new c(this)),this.features[s]){const u=this.features[s];u.isMounted?u.update():(u.mount(),u.isMounted=!0)}}}triggerBuild(){this.build(this.renderState,this.latestValues,this.props)}measureViewportBox(){return this.current?this.measureInstanceViewportBox(this.current,this.props):At()}getStaticValue(s){return this.latestValues[s]}setStaticValue(s,i){this.latestValues[s]=i}update(s,i){(s.transformTemplate||this.props.transformTemplate)&&this.scheduleRender(),this.prevProps=this.props,this.props=s,this.prevPresenceContext=this.presenceContext,this.presenceContext=i;for(let o=0;o<Ky.length;o++){const c=Ky[o];this.propEventSubscriptions[c]&&(this.propEventSubscriptions[c](),delete this.propEventSubscriptions[c]);const u="on"+c,d=s[u];d&&(this.propEventSubscriptions[c]=this.on(c,d))}this.prevMotionValues=fR(this,this.scrapeMotionValuesFromProps(s,this.prevProps,this),this.prevMotionValues),this.handleChildMotionValue&&this.handleChildMotionValue(),this.onUpdate&&this.onUpdate(this)}getProps(){return this.props}getVariant(s){return this.props.variants?this.props.variants[s]:void 0}getDefaultTransition(){return this.props.transition}getTransformPagePoint(){return this.props.transformPagePoint}getClosestVariantNode(){return this.isVariantNode?this:this.parent?this.parent.getClosestVariantNode():void 0}addVariantChild(s){const i=this.getClosestVariantNode();if(i)return i.variantChildren&&i.variantChildren.add(s),()=>i.variantChildren.delete(s)}addValue(s,i){const o=this.values.get(s);i!==o&&(o&&this.removeValue(s),this.bindToMotionValue(s,i),this.values.set(s,i),this.latestValues[s]=i.get())}removeValue(s){this.values.delete(s);const i=this.valueSubscriptions.get(s);i&&(i(),this.valueSubscriptions.delete(s)),delete this.latestValues[s],this.removeValueFromRenderState(s,this.renderState)}hasValue(s){return this.values.has(s)}getValue(s,i){if(this.props.values&&this.props.values[s])return this.props.values[s];let o=this.values.get(s);return o===void 0&&i!==void 0&&(o=Er(i===null?void 0:i,{owner:this}),this.addValue(s,o)),o}readValue(s,i){var o;let c=this.latestValues[s]!==void 0||!this.current?this.latestValues[s]:(o=this.getBaseTargetFromProps(this.props,s))!==null&&o!==void 0?o:this.readValueFromInstance(this.current,s,this.options);return c!=null&&(typeof c=="string"&&(U_(c)||E_(c))?c=parseFloat(c):!dR(c)&&ka.test(i)&&(c=O_(s,i)),this.setBaseTarget(s,Xt(c)?c.get():c)),Xt(c)?c.get():c}setBaseTarget(s,i){this.baseTarget[s]=i}getBaseTarget(s){var i;const{initial:o}=this.props;let c;if(typeof o=="string"||typeof o=="object"){const d=Hp(this.props,o,(i=this.presenceContext)===null||i===void 0?void 0:i.custom);d&&(c=d[s])}if(o&&c!==void 0)return c;const u=this.getBaseTargetFromProps(this.props,s);return u!==void 0&&!Xt(u)?u:this.initialValues[s]!==void 0&&c===void 0?void 0:this.baseTarget[s]}on(s,i){return this.events[s]||(this.events[s]=new Qp),this.events[s].add(i)}notify(s,...i){this.events[s]&&this.events[s].notify(...i)}}class xx extends pR{constructor(){super(...arguments),this.KeyframeResolver=H_}sortInstanceNodePosition(s,i){return s.compareDocumentPosition(i)&2?1:-1}getBaseTargetFromProps(s,i){return s.style?s.style[i]:void 0}removeValueFromRenderState(s,{vars:i,style:o}){delete i[s],delete o[s]}handleChildMotionValue(){this.childSubscription&&(this.childSubscription(),delete this.childSubscription);const{children:s}=this.props;Xt(s)&&(this.childSubscription=s.on("change",i=>{this.current&&(this.current.textContent=`${i}`)}))}}function mR(t){return window.getComputedStyle(t)}class hR extends xx{constructor(){super(...arguments),this.type="html",this.renderInstance=l_}readValueFromInstance(s,i){if(ci.has(i)){const o=rm(i);return o&&o.default||0}else{const o=mR(s),c=(i_(i)?o.getPropertyValue(i):o[i])||0;return typeof c=="string"?c.trim():c}}measureInstanceViewportBox(s,{transformPagePoint:i}){return rx(s,i)}build(s,i,o){qp(s,i,o.transformTemplate)}scrapeMotionValuesFromProps(s,i,o){return Yp(s,i,o)}}class gR extends xx{constructor(){super(...arguments),this.type="svg",this.isSVGTag=!1,this.measureInstanceViewportBox=At}getBaseTargetFromProps(s,i){return s[i]}readValueFromInstance(s,i){if(ci.has(i)){const o=rm(i);return o&&o.default||0}return i=c_.has(i)?i:zp(i),s.getAttribute(i)}scrapeMotionValuesFromProps(s,i,o){return f_(s,i,o)}build(s,i,o){Fp(s,i,this.isSVGTag,o.transformTemplate)}renderInstance(s,i,o,c){u_(s,i,o,c)}mount(s){this.isSVGTag=Kp(s.tagName),super.mount(s)}}const vR=(t,s)=>Vp(t)?new gR(s):new hR(s,{allowProjection:t!==y.Fragment}),yR=GC({...OA,...lR,...qD,...cR},vR),Dt=iC(yR);function bR(){!pm.current&&_x();const[t]=y.useState(Oc.current);return t}const _R="_overlay_cmicx_1",xR="_dialog_cmicx_11",SR="_title_cmicx_30",TR="_description_cmicx_38",kR="_actions_cmicx_45",wR="_cancelButton_cmicx_52",NR="_confirmButton_cmicx_79",Ka={overlay:_R,dialog:xR,title:SR,description:TR,actions:kR,cancelButton:wR,confirmButton:NR};function ii({isOpen:t,title:s,description:i,confirmLabel:o="Delete",onConfirm:c,onCancel:u}){const d=y.useId(),m=y.useId();return l.jsx(ds,{children:t&&l.jsx(Dt.div,{className:Ka.overlay,initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},transition:{duration:.15},onClick:u,onKeyDown:h=>{h.key==="Escape"&&u()},role:"dialog","aria-modal":"true","aria-labelledby":d,"aria-describedby":i?m:void 0,children:l.jsxs(Dt.div,{className:Ka.dialog,initial:{opacity:0,scale:.93,y:-10},animate:{opacity:1,scale:1,y:0},exit:{opacity:0,scale:.93,y:-10},transition:{duration:.15,ease:[.16,1,.3,1]},onClick:h=>h.stopPropagation(),children:[l.jsx("h3",{id:d,className:Ka.title,children:s}),i&&l.jsx("p",{id:m,className:Ka.description,children:i}),l.jsxs("div",{className:Ka.actions,children:[l.jsx("button",{type:"button",className:Ka.cancelButton,onClick:u,autoFocus:!0,children:"Cancel"}),l.jsx("button",{type:"button",className:Ka.confirmButton,onClick:c,children:o})]})]})})})}const jR="_spinner_1uyt1_1",CR="_spin_1uyt1_1",ER="_sm_1uyt1_14",AR="_md_1uyt1_20",DR="_lg_1uyt1_26",RR="_xl_1uyt1_32",Yy={spinner:jR,spin:CR,sm:ER,md:AR,lg:DR,xl:RR};function Sx({size:t="md",className:s,label:i="Loading",liveRegion:o=!1}){return l.jsx("span",{className:`${Yy.spinner} ${Yy[t]} ${s??""}`,role:o?"status":void 0,"aria-label":i,"aria-hidden":o?void 0:!0})}const MR="_splash_1bn1g_1",IR="_logo_1bn1g_11",Jy={splash:MR,logo:IR};function Tx(){return l.jsxs("div",{className:Jy.splash,"data-testid":"splash-screen",children:[l.jsx("img",{src:"/grackle-logo.png",alt:"Grackle",className:Jy.logo}),l.jsx(Sx,{size:"xl",label:"Loading Grackle",liveRegion:!0})]})}const kx=50;function OR(t,s,i,o,c=kx){return o?t<c:s-t-i<c}function BR(t,s){const i=s-t;return i>0?i:0}function LR({scrollRef:t,contentLength:s,isReversed:i}){const[o,c]=y.useState(!0),u=y.useRef(0),d=y.useRef(!1),m=y.useRef(0);y.useEffect(()=>{const g=t.current;if(!g)return;let v=!0;const _=()=>{m.current||(m.current=requestAnimationFrame(()=>{m.current=0;const b=OR(g.scrollTop,g.scrollHeight,g.clientHeight,i,kx);b!==v&&(v=b,c(b))}))};return g.addEventListener("scroll",_,{passive:!0}),()=>{g.removeEventListener("scroll",_),m.current&&(cancelAnimationFrame(m.current),m.current=0)}},[t,i]),y.useLayoutEffect(()=>{const g=t.current;!g||d.current||(d.current=!0,i?g.scrollTop=0:g.scrollTop=g.scrollHeight,c(!0))},[t,i]),y.useLayoutEffect(()=>{const g=t.current;if(g){if(i&&!o){const v=BR(u.current,g.scrollHeight);v>0&&(g.scrollTop+=v)}o&&(i?g.scrollTo({top:0,behavior:"smooth"}):g.scrollTo({top:g.scrollHeight,behavior:"smooth"})),u.current=g.scrollHeight}},[s,o,i,t]);const h=y.useCallback(()=>{const g=t.current;if(!g)return;const v=i?0:g.scrollHeight;g.scrollTo({top:v,behavior:"smooth"}),c(!0)},[t,i]);return{isAtAnchor:o,scrollToAnchor:h}}const UR="_wrapper_1rtuy_1",zR="_scrollContainer_1rtuy_9",PR="_toolbar_1rtuy_15",VR="_directionToggle_1rtuy_22",HR="_scrollToAnchor_1rtuy_60",$R="_scrollToAnchorBottom_1rtuy_84",GR="_scrollToAnchorTop_1rtuy_88",qR="_eventOverflowWarning_1rtuy_92",xa={wrapper:UR,scrollContainer:zR,toolbar:PR,directionToggle:VR,scrollToAnchor:HR,scrollToAnchorBottom:$R,scrollToAnchorTop:GR,eventOverflowWarning:qR},wx="grackle-stream-direction";function FR(){try{return localStorage.getItem(wx)==="reversed"}catch{return!1}}function ZR({eventsDropped:t}){return t<=0?l.jsx(l.Fragment,{}):l.jsxs("div",{className:xa.eventOverflowWarning,role:"alert",children:["⚠"," ",t.toLocaleString()," older event",t===1?"":"s"," were dropped — only the most recent 5,000 are shown. Full history is available in the session log."]})}function mm({events:t,eventsDropped:s,emptyState:i}){const o=y.useRef(null),[c,u]=y.useState(FR),d=bR(),m=y.useMemo(()=>c?[...t].reverse():t,[t,c]),{isAtAnchor:h,scrollToAnchor:g}=LR({scrollRef:o,contentLength:t.length,isReversed:c}),v=()=>{const S=!c;u(S);try{localStorage.setItem(wx,S?"reversed":"default")}catch{}},_=d?0:.2,b=c?-8:8;return l.jsxs("div",{className:xa.wrapper,children:[l.jsx("div",{className:xa.toolbar,children:l.jsx("button",{className:xa.directionToggle,onClick:v,title:c?"Showing newest first":"Showing oldest first","aria-label":c?"Switch to newest at bottom":"Switch to newest at top","data-testid":"direction-toggle",children:c?"↓":"↑"})}),l.jsxs("div",{ref:o,className:xa.scrollContainer,"data-testid":"event-stream-scroll",children:[t.length===0&&i,l.jsx(ZR,{eventsDropped:s}),l.jsx(ds,{initial:!1,children:m.map((S,T)=>{const N=c?t.length-1-T:T;return l.jsx(Dt.div,{initial:{opacity:0,y:b},animate:{opacity:1,y:0},transition:{duration:_,ease:"easeOut"},children:l.jsx(Zj,{event:S,toolUseCtx:S.toolUseCtx})},`${S.sessionId}-${S.timestamp}-${N}`)})})]}),l.jsx(ds,{children:!h&&l.jsxs(Dt.button,{className:`${xa.scrollToAnchor} ${c?xa.scrollToAnchorTop:xa.scrollToAnchorBottom}`,onClick:g,initial:{opacity:0,scale:.9},animate:{opacity:1,scale:1},exit:{opacity:0,scale:.9},transition:{duration:.15},"aria-label":"Scroll to latest","data-testid":"scroll-to-anchor",children:[c?"↑":"↓"," New events"]})})]})}function hm(t){const{value:s,onSave:i,validate:o,fieldId:c,activeFieldId:u,onActivate:d,enterToSave:m=!0,trimOnSave:h=!0}=t,[g,v]=y.useState(""),[_,b]=y.useState(""),S=y.useRef(!1),T=u===c,N=y.useCallback($=>{v($),b("")},[]),j=y.useCallback(()=>{b("")},[]),w=y.useCallback(()=>{S.current=!1,d==null||d(null),v(""),b("")},[d]),C=y.useCallback(()=>{const $=h?g.trim():g;if(o){const K=o(g);if(K){b(K);return}}const z=h?s.trim():s;if($===z){w();return}i($),w()},[g,s,h,o,i,w]),A=y.useCallback(()=>{S.current=!0,d==null||d(c),v(s),b("")},[c,s,d]),M=y.useCallback($=>{if(S.current){S.current=!1;return}$.relatedTarget instanceof HTMLElement&&$.relatedTarget.dataset.editAction===c||C()},[c,C]),D=y.useCallback($=>{$.key==="Escape"?w():$.key==="Enter"&&m&&C()},[w,m,C]),E=(()=>{if(!T)return!1;const $=h?s.trim():s;return(h?g.trim():g)!==$})();return y.useEffect(()=>{!T&&(g!==""||_!=="")&&(v(""),b(""))},[T,g,_]),{isEditing:T,draft:g,error:_,isDirty:E,startEdit:A,cancelEdit:w,save:C,setDraft:N,clearError:j,handleBlur:M,handleKeyDown:D,ignoreInitialBlurRef:S}}const KR="_editFieldWrapper_yuzty_1",YR="_editInput_yuzty_10",JR="_editTextarea_yuzty_42",WR="_editSelect_yuzty_78",XR="_editError_yuzty_111",QR="_editInputInvalid_yuzty_118",eM="_editHint_yuzty_123",tM="_unsavedDot_yuzty_132",nM="_metaValueClickable_yuzty_140",sM="_editButton_yuzty_159",aM="_metaPlaceholder_yuzty_175",iM="_worktreeToggle_yuzty_180",Je={editFieldWrapper:KR,editInput:YR,editTextarea:JR,editSelect:WR,editError:XR,editInputInvalid:QR,editHint:eM,unsavedDot:tM,metaValueClickable:nM,editButton:sM,metaPlaceholder:aM,worktreeToggle:iM};function Kt(t){const{value:s,onSave:i,validate:o,mode:c="edit",fieldId:u="text",activeFieldId:d,onActivate:m,onChange:h,renderDisplay:g,placeholder:v,maxLength:_,ariaLabel:b,"data-testid":S}=t,T=y.useRef(null),N=hm({value:s,onSave:i,validate:o,fieldId:u,activeFieldId:d,onActivate:m,enterToSave:!0,trimOnSave:!0});if(y.useEffect(()=>{if(N.isEditing){const w=window.setTimeout(()=>{var C;(C=T.current)==null||C.focus()},0);return()=>window.clearTimeout(w)}},[N.isEditing]),c==="create"){const w=A=>{h==null||h(A.target.value)},C=o==null?void 0:o(s);return l.jsxs("div",{className:Je.editFieldWrapper,children:[l.jsx("input",{className:`${Je.editInput} ${C?Je.editInputInvalid:""}`,value:s,onChange:w,maxLength:_,placeholder:v,"aria-label":b,"data-testid":S?`${S}-input`:void 0}),C&&l.jsx("span",{className:Je.editError,"data-testid":"edit-error",children:C})]})}if(N.isEditing)return l.jsxs("div",{className:Je.editFieldWrapper,children:[l.jsx("input",{ref:T,className:`${Je.editInput} ${N.error?Je.editInputInvalid:""}`,value:N.draft,onChange:w=>N.setDraft(w.target.value),onBlur:N.handleBlur,onKeyDown:N.handleKeyDown,maxLength:_,placeholder:v,"aria-label":b,"data-testid":S?`${S}-input`:void 0}),N.isDirty&&l.jsx("span",{className:Je.unsavedDot,title:"Unsaved changes"}),N.error&&l.jsx("span",{className:Je.editError,"data-testid":"edit-error",children:N.error}),l.jsx("span",{className:Je.editHint,children:"Enter to save · Esc to cancel"})]});const j=g==null?void 0:g(s);return l.jsxs("span",{role:"button",tabIndex:0,className:Je.metaValueClickable,onClick:()=>N.startEdit(),onKeyDown:w=>{(w.key==="Enter"||w.key===" ")&&(w.preventDefault(),N.startEdit())},title:"Click to edit","aria-label":b,"data-testid":S?`${S}-button`:void 0,children:[j!==void 0?j:s?l.jsx("span",{children:s}):l.jsx("span",{className:Je.metaPlaceholder,children:v||"None"}),l.jsx("span",{className:Je.editButton,"aria-hidden":"true",children:"✏️"})]})}function vp(t){const{value:s,onSave:i,validate:o,mode:c="edit",fieldId:u="textarea",activeFieldId:d,onActivate:m,onChange:h,renderDisplay:g,placeholder:v,ariaLabel:_,"data-testid":b}=t,S=y.useRef(null),T=hm({value:s,onSave:i,validate:o,fieldId:u,activeFieldId:d,onActivate:m,enterToSave:!1,trimOnSave:!1});if(y.useEffect(()=>{if(T.isEditing){const j=window.setTimeout(()=>{var w;(w=S.current)==null||w.focus()},0);return()=>window.clearTimeout(j)}},[T.isEditing]),c==="create"){const j=C=>{h==null||h(C.target.value)},w=o==null?void 0:o(s);return l.jsxs("div",{className:Je.editFieldWrapper,children:[l.jsx("textarea",{className:`${Je.editTextarea} ${w?Je.editInputInvalid:""}`,value:s,onChange:j,placeholder:v,"aria-label":_,"data-testid":b?`${b}-input`:void 0}),w&&l.jsx("span",{className:Je.editError,"data-testid":"edit-error",children:w})]})}if(T.isEditing)return l.jsxs("div",{className:Je.editFieldWrapper,children:[l.jsx("textarea",{ref:S,className:`${Je.editTextarea} ${T.error?Je.editInputInvalid:""}`,value:T.draft,onChange:j=>T.setDraft(j.target.value),onBlur:T.handleBlur,onKeyDown:T.handleKeyDown,title:_,"aria-label":_,"data-testid":b?`${b}-input`:void 0}),T.isDirty&&l.jsx("span",{className:Je.unsavedDot,title:"Unsaved changes"}),T.error&&l.jsx("span",{className:Je.editError,"data-testid":"edit-error",children:T.error}),l.jsx("span",{className:Je.editHint,children:"Tab to save · Esc to cancel"})]});const N=g==null?void 0:g(s);return l.jsxs("span",{role:"button",tabIndex:0,className:Je.metaValueClickable,onClick:()=>T.startEdit(),onKeyDown:j=>{(j.key==="Enter"||j.key===" ")&&(j.preventDefault(),T.startEdit())},title:"Click to edit","aria-label":_,"data-testid":b?`${b}-button`:void 0,children:[N!==void 0?N:s?l.jsx("span",{children:s}):l.jsx("span",{className:Je.metaPlaceholder,children:v||"None"}),l.jsx("span",{className:Je.editButton,"aria-hidden":"true",children:"✏️"})]})}function Bc(t){var A;const{value:s,onSave:i,mode:o="edit",options:c,fieldId:u="select",activeFieldId:d,onActivate:m,onChange:h,renderDisplay:g,placeholder:v,ariaLabel:_,"data-testid":b}=t,S=y.useRef(null),T=hm({value:s,onSave:i,fieldId:u,activeFieldId:d,onActivate:m,enterToSave:!1,trimOnSave:!1});y.useEffect(()=>{if(T.isEditing){const M=window.setTimeout(()=>{var D;(D=S.current)==null||D.focus()},0);return()=>window.clearTimeout(M)}},[T.isEditing]);const N=y.useCallback(M=>{const D=M.target.value;T.ignoreInitialBlurRef.current=!1,D!==s&&i(D),T.cancelEdit()},[s,i,T]),j=y.useCallback(M=>{if(T.ignoreInitialBlurRef.current){T.ignoreInitialBlurRef.current=!1;return}M.relatedTarget instanceof HTMLElement&&M.relatedTarget.dataset.editAction===u||T.cancelEdit()},[u,T]);if(o==="create")return l.jsx("select",{className:Je.editSelect,value:s,onChange:M=>h==null?void 0:h(M.target.value),"aria-label":_,"data-testid":b?`${b}-select`:void 0,children:c.map(M=>l.jsx("option",{value:M.value,children:M.label},M.value))});if(T.isEditing)return l.jsx("select",{ref:S,className:Je.editSelect,value:T.draft,onChange:N,onBlur:j,title:_,"aria-label":_,"data-testid":b?`${b}-select`:void 0,children:c.map(M=>l.jsx("option",{value:M.value,children:M.label},M.value))});const w=g==null?void 0:g(s),C=(A=c.find(M=>M.value===s))==null?void 0:A.label;return l.jsxs("button",{type:"button",className:Je.metaValueClickable,onClick:()=>T.startEdit(),title:"Click to change","aria-label":_,"data-testid":b?`${b}-button`:void 0,children:[w!==void 0?w:C?l.jsx("span",{children:C}):l.jsx("span",{className:Je.metaPlaceholder,children:v||"None"}),l.jsx("span",{className:Je.editButton,"aria-hidden":"true",children:"✏️"})]})}function oM(t){const{checked:s,onChange:i,label:o,ariaLabel:c,"data-testid":u}=t;return l.jsxs("label",{className:Je.worktreeToggle,"data-testid":u,children:[l.jsx("input",{type:"checkbox",checked:s,onChange:d=>i(d.target.checked),"aria-label":c}),l.jsx("span",{children:o})]})}const rM="_envRow_1e1r5_1",lM="_envDot_1e1r5_7",cM="_envDotGreen_1e1r5_14",uM="_envDotYellow_1e1r5_18",dM="_envDotRed_1e1r5_22",fM="_envDotGray_1e1r5_26",no={envRow:rM,envDot:lM,envDotGreen:cM,envDotYellow:uM,envDotRed:dM,envDotGray:fM};function pM(t){const s=t.toLowerCase();return s==="ready"||s==="running"||s==="available"||s==="connected"?no.envDotGreen:s==="provisioning"||s==="starting"||s==="pending"||s==="connecting"?no.envDotYellow:s==="error"||s==="failed"||s==="disconnected"?no.envDotRed:no.envDotGray}function mM(t){const{value:s,onSave:i,environments:o,allowNone:c=!1,fieldId:u="environment",activeFieldId:d,onActivate:m,placeholder:h="No environment",ariaLabel:g="Environment","data-testid":v}=t,_=o.find(T=>T.id===s),b=[...c?[{value:"",label:"None"}]:[],...o.map(T=>({value:T.id,label:T.displayName}))],S=()=>{if(_)return l.jsxs("span",{className:no.envRow,children:[l.jsx("span",{className:`${no.envDot} ${pM(_.status)}`}),_.displayName]})};return l.jsx(Bc,{value:s,onSave:i,options:b,fieldId:u,activeFieldId:d,onActivate:m,renderDisplay:S,placeholder:h,ariaLabel:g,"data-testid":v})}const hM="_nav_1snmp_1",gM="_searchForm_1snmp_8",vM="_searchInput_1snmp_15",yM="_searchButton_1snmp_33",bM="_clearButton_1snmp_68",_M="_workspaceSelect_1snmp_85",xM="_listHeader_1snmp_99",SM="_nodeList_1snmp_108",TM="_nodeItem_1snmp_116",kM="_indicator_1snmp_129",wM="_label_1snmp_136",NM="_badge_1snmp_145",Bn={nav:hM,searchForm:gM,searchInput:vM,searchButton:yM,clearButton:bM,workspaceSelect:_M,listHeader:xM,nodeList:SM,nodeItem:TM,indicator:kM,label:wM,badge:NM};function jM({nodes:t,workspaces:s,loading:i,searchQuery:o,onSearch:c,onClearSearch:u,onSelectNode:d,onWorkspaceChange:m}){const[h,g]=y.useState(""),v=y.useCallback(T=>{T.preventDefault(),h.trim()&&c(h.trim())},[h,c]),_=y.useCallback(()=>{g(""),u()},[u]),b=y.useCallback(T=>{d(T)},[d]),S=y.useCallback(T=>{g(""),m(T)},[m]);return l.jsxs("div",{className:Bn.nav,"data-testid":"knowledge-nav",children:[l.jsxs("form",{className:Bn.searchForm,onSubmit:v,children:[l.jsx("input",{className:Bn.searchInput,type:"text",placeholder:"Search...",value:h,onChange:T=>{g(T.target.value)},"data-testid":"knowledge-search-input"}),l.jsx("button",{type:"submit",className:Bn.searchButton,disabled:i,children:"Go"})]}),o&&l.jsx("button",{type:"button",className:Bn.clearButton,onClick:_,children:"Clear search"}),l.jsxs("select",{className:Bn.workspaceSelect,onChange:T=>{S(T.target.value)},"data-testid":"knowledge-workspace-filter",children:[l.jsx("option",{value:"",children:"All workspaces"}),s.map(T=>l.jsx("option",{value:T.id,children:T.name},T.id))]}),l.jsxs("div",{className:Bn.listHeader,children:["Nodes (",t.length,")"]}),l.jsx("ul",{className:Bn.nodeList,children:t.map(T=>l.jsxs("li",{className:Bn.nodeItem,onClick:()=>{b(T.id)},onKeyDown:N=>{(N.key==="Enter"||N.key===" ")&&(N.preventDefault(),b(T.id))},role:"button",tabIndex:0,children:[l.jsx("span",{className:Bn.indicator,style:{backgroundColor:T.kind==="reference"?"#4A9EFF":T.category==="decision"?"#22C55E":T.category==="concept"?"#A855F7":T.category==="snippet"?"#6B7280":"#EAB308"}}),l.jsx("span",{className:Bn.label,children:T.label}),l.jsx("span",{className:Bn.badge,children:T.kind==="reference"?T.sourceType:T.category})]},T.id))})]})}const CM="_container_1mq5u_1",EM="_hamburger_1mq5u_33",AM="_brand_1mq5u_49",DM="_brandLogo_1mq5u_68",RM="_info_1mq5u_75",MM="_connectionLabel_1mq5u_90",IM="_connectionDot_1mq5u_103",OM="_connected_1mq5u_106",BM="_disconnected_1mq5u_110",Ms={container:CM,hamburger:EM,brand:AM,brandLogo:DM,info:RM,connectionLabel:MM,connectionDot:IM,connected:OM,disconnected:BM};function LM({connected:t,environments:s,sessions:i,onToggleSidebar:o,sidebarOpen:c}){const u=vt(),d=s.length,m=s.filter(g=>g.status==="connected").length,h=i.filter(g=>["running","idle"].includes(g.status)).length;return l.jsxs("div",{className:Ms.container,children:[o&&l.jsx("button",{type:"button",className:Ms.hamburger,onClick:o,"aria-label":"Toggle sidebar","aria-expanded":c,children:"☰"}),l.jsxs("button",{type:"button",className:Ms.brand,onClick:()=>u(ai),title:"Home",children:[l.jsx("img",{src:"/icon-192x192.png",alt:"",className:Ms.brandLogo,"aria-hidden":"true","data-testid":"statusbar-logo"}),"Grackle"]}),l.jsxs("div",{className:Ms.info,children:[l.jsxs("span",{"aria-label":t?"Connected":"Disconnected",children:[l.jsx("span",{className:`${Ms.connectionDot} ${t?Ms.connected:Ms.disconnected}`,"aria-hidden":"true",children:"●"})," ",l.jsx("span",{className:Ms.connectionLabel,"aria-hidden":"true",children:t?"Connected":"Disconnected"})]}),l.jsxs("span",{children:[m,"/",d," env",d!==1?"s":""]}),l.jsxs("span",{children:[h," active"]})]})]})}const UM="_nav_13gkc_1",zM="_tab_13gkc_35",PM="_tabIcon_13gkc_68",VM="_tabLabel_13gkc_79",HM="_tabActive_13gkc_84",ur={nav:UM,tab:zM,tabIcon:PM,tabLabel:VM,tabActive:HM},Ya=[{view:"dashboard",label:"Dashboard",icon:"🏠",route:ai,testId:"sidebar-tab-dashboard"},{view:"chat",label:"Chat",icon:"💬",route:o2,testId:"sidebar-tab-chat"},{view:"tasks",label:"Tasks",icon:"📋",route:r2,testId:"sidebar-tab-tasks"},{view:"environments",label:"Environments",icon:"🖥️",route:ao,testId:"sidebar-tab-environments"},{view:"knowledge",label:"Knowledge",icon:"🧠",route:Gb,testId:"sidebar-tab-knowledge"},{view:"findings",label:"Findings",icon:"🔍",route:Fc,testId:"sidebar-tab-findings"},{view:"settings",label:"Settings",icon:"⚙️",route:n2,testId:"sidebar-tab-settings"}];function $M(t){return t===ai||t==="/"?"dashboard":t.startsWith("/chat")||t.startsWith("/sessions")?"chat":t.startsWith("/workspaces")||t.startsWith("/environments")?"environments":t.startsWith(Gb)?"knowledge":t.startsWith(Fc)?"findings":t.startsWith(so)?"settings":"tasks"}function GM(){const t=Ut(),s=vt(),i=y.useRef(null),o=$M(t.pathname),c=y.useCallback(d=>{s(d.route)},[s]),u=y.useCallback(d=>{var _,b;const m=(_=i.current)==null?void 0:_.querySelectorAll('[role="tab"]');if(!m)return;const h=Array.from(m).findIndex(S=>S===document.activeElement),g=h>=0?h:Ya.findIndex(S=>S.view===o);let v=g;if(d.key==="ArrowRight"||d.key==="j"||d.key==="J")d.preventDefault(),v=(g+1)%Ya.length;else if(d.key==="ArrowLeft"||d.key==="k"||d.key==="K")d.preventDefault(),v=(g-1+Ya.length)%Ya.length;else if(d.key==="Home")d.preventDefault(),v=0;else if(d.key==="End")d.preventDefault(),v=Ya.length-1;else return;s(Ya[v].route),(b=m[v])==null||b.focus()},[o,s]);return l.jsx("nav",{className:ur.nav,ref:i,role:"tablist","aria-orientation":"horizontal","aria-label":"App navigation",onKeyDown:u,"data-testid":"sidebar-nav",children:Ya.map(d=>{const m=d.view===o;return l.jsxs("button",{role:"tab",type:"button","aria-selected":m,tabIndex:m?0:-1,className:`${ur.tab} ${m?ur.tabActive:""}`,onClick:()=>c(d),"data-testid":d.testId,title:d.label,"aria-label":d.label,children:[l.jsx("span",{className:ur.tabIcon,"aria-hidden":"true",children:d.icon}),l.jsx("span",{className:ur.tabLabel,children:d.label})]},d.view)})})}const qM="_container_pi6ii_1",FM="_content_pi6ii_66",Wy={container:qM,content:FM},ZM=320,Nx=220,jx=600,Cx="grackle-sidebar-width";function KM(){try{const t=localStorage.getItem(Cx);if(t!==null){const s=Number(t);if(Number.isFinite(s)&&s>=Nx&&s<=jx)return s}}catch{}return ZM}function YM(t){try{localStorage.setItem(Cx,String(t))}catch{}}function JM({content:t}){const[s]=y.useState(KM),i=y.useRef(null);if(y.useEffect(()=>{const o=i.current;if(!o)return;const c=new ResizeObserver(u=>{for(const d of u){const m=d.borderBoxSize[0];if(m){const h=Math.round(m.inlineSize);h>=Nx&&h<=jx&&YM(h)}}});return c.observe(o),()=>{c.disconnect()}},[]),t!==void 0)return l.jsx("div",{className:Wy.container,ref:i,"data-testid":"sidebar",style:{width:s},children:l.jsx("div",{className:Wy.content,children:t})})}const WM="_bar_tnfsh_1",XM="_btnPrimary_tnfsh_32",QM="_statusText_tnfsh_85",e3="_statusCompleted_tnfsh_90",t3="_statusFailed_tnfsh_94",n3="_statusBlocked_tnfsh_98",s3="_hintText_tnfsh_103",_t={bar:WM,btnPrimary:XM,statusText:QM,statusCompleted:e3,statusFailed:t3,statusBlocked:n3,hintText:s3};function a3({sessions:t,tasks:s,environments:i}){const o=vt(),c=Ut(),u=kt("/sessions/:sessionId"),d=kt("/tasks/:taskId"),m=kt("/tasks/:taskId/stream"),h=kt("/tasks/:taskId/findings"),g=kt("/tasks/:taskId/edit"),v=kt("/environments/:environmentId/workspaces/:workspaceId/tasks/:taskId"),_=kt("/environments/:environmentId/workspaces/:workspaceId/tasks/:taskId/stream"),b=kt("/environments/:environmentId/workspaces/:workspaceId/tasks/:taskId/findings"),S=kt("/environments/:environmentId/workspaces/:workspaceId/tasks/:taskId/edit"),T=kt("/sessions/new"),N=kt("/environments/:environmentId/workspaces/:workspaceId"),j=kt("/tasks/new"),w=kt("/chat"),C=kt("/"),A=kt("/settings/*"),M=u==null?void 0:u.params.sessionId,D=(d==null?void 0:d.params.taskId)??(m==null?void 0:m.params.taskId)??(h==null?void 0:h.params.taskId)??(v==null?void 0:v.params.taskId)??(_==null?void 0:_.params.taskId)??(b==null?void 0:b.params.taskId)??(S==null?void 0:S.params.taskId),E=v??_??b??S,$=(E==null?void 0:E.params.environmentId)??(N==null?void 0:N.params.environmentId),z=c.pathname.startsWith("/environments")&&!N&&!E,K=!!w,F=!!T,ee=!!N&&!v&&!_&&!b&&!S,ae=!!j;if(!!C&&!F&&!ee&&!ae||!!A||(!!g||!!S)||ae||z||F)return l.jsx(l.Fragment,{});if(K)return i.find(q=>q.adapterType==="local"&&q.status==="connected")?l.jsx(l.Fragment,{}):l.jsx("div",{className:_t.bar,children:l.jsx("span",{className:_t.hintText,children:"Add a local environment to start chatting"})});if(ee)return l.jsx("div",{className:_t.bar,children:l.jsx("span",{className:_t.hintText,children:"Select a task or click + to create one"})});if(D){const O=s.find(re=>re.id===D);if(!O)return l.jsx("div",{className:_t.bar,children:l.jsx("span",{className:_t.hintText,children:"Loading..."})});const q=new Map(s.map(re=>[re.id,re])),te=O.dependsOn.some(re=>{const ue=q.get(re);return ue!==void 0&&ue.status!=="complete"});if(O.status==="not_started"){const re=te?O.dependsOn.map(ue=>q.get(ue)).filter(ue=>ue&&ue.status!=="complete").map(ue=>ue.title):[];return l.jsx("div",{className:_t.bar,children:te?l.jsxs("span",{className:_t.statusBlocked,children:["Blocked by: ",re.join(", ")]}):l.jsx("span",{className:_t.hintText,children:"Use the buttons above to start or manage this task"})})}if(O.status==="working"||O.status==="paused"){const re=O.latestSessionId||void 0,ue=re?t.find(Ne=>Ne.id===re):void 0;return ue&&ue.status!=="stopped"?l.jsx(l.Fragment,{}):l.jsx("div",{className:_t.bar,children:l.jsx("span",{className:_t.hintText,children:"Waiting for agent..."})})}if(O.status==="complete")return l.jsxs("div",{className:_t.bar,children:[l.jsx("span",{className:`${_t.statusText} ${_t.statusCompleted}`,children:"Task completed"}),l.jsx("button",{onClick:()=>o(ri(O.workspaceId,void 0,$)),className:_t.btnPrimary,children:"+ New Task"})]});if(O.status==="failed")return l.jsx("div",{className:_t.bar,children:l.jsx("span",{className:`${_t.statusText} ${_t.statusFailed}`,children:"Task failed"})})}if(M){const O=t.find(re=>re.id===M),q=(O==null?void 0:O.status)==="stopped";if(O!==void 0&&!q)return l.jsx(l.Fragment,{});if(q)return l.jsxs("div",{className:_t.bar,children:[l.jsxs("span",{className:`${_t.statusText} ${_t.hintText}`,children:["Session ",O.endReason||O.status]}),l.jsx("button",{onClick:()=>o(Vb(O.environmentId)),className:_t.btnPrimary,children:"+ New Chat"})]})}return l.jsx("div",{className:_t.bar,children:l.jsx("span",{className:_t.hintText,children:"Loading..."})})}const i3="_nav_14i94_1",o3="_tab_14i94_24",r3="_tabActive_14i94_62",l3="_tabLabel_14i94_75",c3="_statusDot_14i94_81",u3="_pulse_14i94_87",d3="_addButton_14i94_99",f3="_empty_14i94_132",ha={nav:i3,tab:o3,tabActive:r3,tabLabel:l3,statusDot:c3,pulse:u3,addButton:d3,empty:f3},p3={connected:"var(--accent-green)",sleeping:"var(--accent-yellow)",error:"var(--accent-red)",disconnected:"var(--text-tertiary)",connecting:"var(--accent-blue)"};function m3({environments:t}){const s=vt(),i=y.useRef(null),o=kt("/environments/:environmentId"),c=kt("/environments/:environmentId/edit"),u=kt("/environments/:environmentId/workspaces/:workspaceId"),d=kt("/environments/:environmentId/workspaces/:workspaceId/*"),m=(o==null?void 0:o.params.environmentId)??(c==null?void 0:c.params.environmentId)??(u==null?void 0:u.params.environmentId)??(d==null?void 0:d.params.environmentId),h=m==="new"?void 0:m,g=y.useCallback(b=>{s(si(b))},[s]),v=y.useCallback(b=>{var w;const S=(w=i.current)==null?void 0:w.querySelectorAll('[role="tab"]');if(!S||S.length===0)return;const T=Array.from(S).findIndex(C=>C===document.activeElement),N=T>=0?T:t.findIndex(C=>C.id===h);let j=N;if(b.key==="ArrowDown"||b.key==="j"||b.key==="J")b.preventDefault(),j=(N+1)%S.length;else if(b.key==="ArrowUp"||b.key==="k"||b.key==="K")b.preventDefault(),j=(N-1+S.length)%S.length;else if(b.key==="Home")b.preventDefault(),j=0;else if(b.key==="End")b.preventDefault(),j=S.length-1;else return;j<t.length&&s(si(t[j].id)),S[j].focus()},[h,t,s]),_=h??(t.length>0?t[0].id:void 0);return l.jsxs("div",{className:ha.nav,"data-testid":"environment-nav",children:[l.jsx("nav",{ref:i,role:"tablist","aria-orientation":"vertical","aria-label":"Environments",onKeyDown:v,children:t.map(b=>{const S=b.id===h,T=b.id===_,N=p3[b.status]||"var(--text-tertiary)",j=b.status==="connected";return l.jsxs("button",{role:"tab",type:"button","aria-selected":S,tabIndex:T?0:-1,className:`${ha.tab} ${S?ha.tabActive:""}`,onClick:()=>g(b.id),"data-testid":"env-nav-item",children:[l.jsx("span",{className:`${ha.statusDot} ${j?ha.pulse:""}`,style:{color:N},children:"●"}),l.jsx("span",{className:ha.tabLabel,title:b.displayName||b.id,children:b.displayName||b.id})]},b.id)})}),l.jsx("button",{type:"button",className:ha.addButton,onClick:()=>s(e2),title:"Add environment","data-testid":"env-nav-add",children:"+ Add Environment"}),t.length===0&&l.jsx("div",{className:ha.empty,children:"No environments yet."})]})}function gm(t){const s=new Date(t),i=new Date,o=i.getTime()-s.getTime(),c=Math.floor(o/1e3),u=Math.floor(c/60),d=Math.floor(u/60),m=Math.floor(d/24);if(c<60)return"just now";if(u<60)return`${u}m ago`;if(d<24)return`${d}h ago`;if(m===1)return"yesterday";if(m<7)return`${m} days ago`;const h=s.getFullYear()===i.getFullYear(),g=s.toLocaleString("en-US",{month:"short"}),v=s.getDate();return h?`${g} ${v}`:`${g} ${v} ${s.getFullYear()}`}const Xy={architecture:{text:"var(--accent-blue)",bg:"var(--accent-blue-dim)"},api:{text:"var(--accent-green)",bg:"var(--accent-green-dim)"},bug:{text:"var(--accent-red)",bg:"var(--accent-red-dim)"},decision:{text:"var(--accent-yellow)",bg:"var(--accent-yellow-dim)"},dependency:{text:"var(--accent-purple)",bg:"var(--accent-purple-dim)"},pattern:{text:"var(--accent-cyan)",bg:"var(--accent-cyan-dim)"},general:{text:"var(--text-secondary)",bg:"var(--bg-elevated)"}};function Lc(t){return Xy[t]||Xy.general}const h3="_nav_dlm8m_1",g3="_categoryPills_dlm8m_24",v3="_categoryPill_dlm8m_24",y3="_tab_dlm8m_42",b3="_tabActive_dlm8m_80",_3="_tabContent_dlm8m_93",x3="_tabLabel_dlm8m_100",S3="_tabMeta_dlm8m_106",T3="_categoryDot_dlm8m_111",k3="_empty_dlm8m_118",os={nav:h3,categoryPills:g3,categoryPill:v3,tab:y3,tabActive:b3,tabContent:_3,tabLabel:x3,tabMeta:S3,categoryDot:T3,empty:k3};function w3({findings:t,workspaceId:s,environmentId:i}){const o=vt(),c=y.useRef(null),u=kt("/findings/:findingId"),d=kt("/environments/:environmentId/workspaces/:workspaceId/findings/:findingId"),m=(u==null?void 0:u.params.findingId)??(d==null?void 0:d.params.findingId),h=y.useMemo(()=>{const b=new Set(t.map(S=>S.category).filter(Boolean));return Array.from(b).sort()},[t]),g=y.useCallback(b=>{o(Qf(b,s,i))},[o,s,i]),v=y.useCallback(b=>{var w;const S=(w=c.current)==null?void 0:w.querySelectorAll('[role="tab"]');if(!S||S.length===0)return;const T=Array.from(S).findIndex(C=>C===document.activeElement),N=T>=0?T:t.findIndex(C=>C.id===m);let j=N;if(b.key==="ArrowDown"||b.key==="j"||b.key==="J")b.preventDefault(),j=(N+1)%S.length;else if(b.key==="ArrowUp"||b.key==="k"||b.key==="K")b.preventDefault(),j=(N-1+S.length)%S.length;else if(b.key==="Home")b.preventDefault(),j=0;else if(b.key==="End")b.preventDefault(),j=S.length-1;else return;j<t.length&&o(Qf(t[j].id,s,i)),S[j].focus()},[m,t,o,s,i]),_=m??(t.length>0?t[0].id:void 0);return l.jsxs("div",{className:os.nav,"data-testid":"findings-nav",children:[h.length>1&&l.jsx("div",{className:os.categoryPills,"data-testid":"findings-nav-categories",children:h.map(b=>l.jsx("span",{className:os.categoryPill,style:{color:Lc(b).text},children:b},b))}),l.jsx("nav",{ref:c,role:"tablist","aria-orientation":"vertical","aria-label":"Findings",onKeyDown:v,children:t.map(b=>{const S=b.id===m,T=b.id===_;return l.jsxs("button",{role:"tab",type:"button","aria-selected":S,tabIndex:T?0:-1,className:`${os.tab} ${S?os.tabActive:""}`,onClick:()=>g(b.id),"data-testid":"finding-nav-item",children:[l.jsx("span",{className:os.categoryDot,style:{color:Lc(b.category).text},children:"●"}),l.jsxs("span",{className:os.tabContent,children:[l.jsx("span",{className:os.tabLabel,title:b.title,children:b.title}),l.jsx("span",{className:os.tabMeta,title:b.createdAt,children:gm(b.createdAt)})]})]},b.id)})}),t.length===0&&l.jsx("div",{className:os.empty,children:"No findings yet. Agents will post discoveries here."})]})}function N3(t){if(t.length===0)return[];const s=[...t].sort((o,c)=>o[0]-c[0]),i=[[s[0][0],s[0][1]]];for(let o=1;o<s.length;o++){const c=i[i.length-1],[u,d]=s[o];u<=c[1]+1?c[1]=Math.max(c[1],d):i.push([u,d])}return i}function Ex({text:t,indices:s,highlightClass:i}){if(!s||s.length===0)return l.jsx(l.Fragment,{children:t});const o=N3(s),c=[];let u=0;for(const[d,m]of o)d>u&&c.push(l.jsx("span",{children:t.slice(u,d)},`p${u}`)),c.push(l.jsx("mark",{className:i,children:t.slice(d,m+1)},`m${d}`)),u=m+1;return u<t.length&&c.push(l.jsx("span",{children:t.slice(u)},`p${u}`)),l.jsx(l.Fragment,{children:c})}function j3(t){const s=new Map(t.map(o=>[o.id,{...o,children:[]}])),i=[];for(const o of s.values())o.parentTaskId&&s.has(o.parentTaskId)?s.get(o.parentTaskId).children.push(o):i.push(o);for(const o of s.values())o.children.sort((c,u)=>c.sortOrder-u.sortOrder);return i.sort((o,c)=>o.sortOrder-c.sortOrder)}function C3(t,s){const i=new Map;for(const u of t){const m=u.dependsOn.length>0&&u.dependsOn.some(g=>s.get(g)!=="complete")?"blocked":u.status,h=i.get(m);h?h.push(u):i.set(m,[u])}const o=[],c=new Set;for(const u of ak){c.add(u);const d=i.get(u);if(d&&d.length>0){d.sort((h,g)=>h.sortOrder-g.sortOrder);const m=Sa(u);o.push({status:u,label:m.label,style:m,tasks:d})}}for(const[u,d]of i)if(!c.has(u)&&d.length>0){d.sort((h,g)=>h.sortOrder-g.sortOrder);const m=Sa(u);o.push({status:u,label:m.label,style:m,tasks:d})}return o}const E3="_container_z4i38_1",A3="_header_z4i38_5",D3="_headerActions_z4i38_17",R3="_searchInput_z4i38_23",M3="_searchHighlight_z4i38_56",I3="_groupToggle_z4i38_62",O3="_groupToggleActive_z4i38_89",B3="_addButton_z4i38_93",L3="_taskRow_z4i38_120",U3="_selected_z4i38_140",z3="_expandArrow_z4i38_150",P3="_expanded_z4i38_157",V3="_leafSpacer_z4i38_161",H3="_taskStatusIcon_z4i38_166",$3="_taskTitle_z4i38_170",G3="_workspaceBadge_z4i38_177",q3="_childCountBadge_z4i38_195",F3="_dependencyBadge_z4i38_208",Z3="_blockedBadge_z4i38_220",K3="_addChildButton_z4i38_225",Y3="_emptyState_z4i38_268",J3="_statusGroupHeader_z4i38_275",W3="_statusGroupIcon_z4i38_294",X3="_statusGroupLabel_z4i38_298",Q3="_statusGroupCount_z4i38_303",He={container:E3,header:A3,headerActions:D3,searchInput:R3,searchHighlight:M3,groupToggle:I3,groupToggleActive:O3,addButton:B3,taskRow:L3,selected:U3,expandArrow:z3,expanded:P3,leafSpacer:V3,taskStatusIcon:H3,taskTitle:$3,workspaceBadge:G3,childCountBadge:q3,dependencyBadge:F3,blockedBadge:Z3,addChildButton:K3,emptyState:Y3,statusGroupHeader:J3,statusGroupIcon:W3,statusGroupLabel:X3,statusGroupCount:Q3},e6=[{name:"title",weight:2},{name:"description",weight:1}],Ax=16,t6=16,Dx="grackle-task-group-by-status";function Qy(){try{return localStorage.getItem(Dx)==="true"}catch{return!1}}function n6(t){try{localStorage.setItem(Dx,String(t))}catch{}}function s6({group:t,isExpanded:s,onToggle:i,selectedTaskId:o,navigate:c,titleHighlights:u,workspaceNames:d}){return l.jsxs("div",{"data-testid":`status-group-${t.status}`,children:[l.jsxs("div",{className:He.statusGroupHeader,role:"button",tabIndex:0,"aria-expanded":s,onClick:i,onKeyDown:m=>{(m.key==="Enter"||m.key===" ")&&(m.preventDefault(),i())},children:[l.jsx("span",{className:`${He.expandArrow} ${s?He.expanded:""}`,children:"▸"}),l.jsx("span",{className:He.statusGroupIcon,style:{color:t.style.color},children:t.style.icon}),l.jsx("span",{className:He.statusGroupLabel,children:t.label}),l.jsx("span",{className:He.statusGroupCount,children:t.tasks.length})]}),l.jsx(ds,{children:s&&l.jsx(Dt.div,{initial:{height:0,opacity:0},animate:{height:"auto",opacity:1},exit:{height:0,opacity:0},transition:{duration:.2},style:{overflow:"hidden"},children:t.tasks.map(m=>{const h=Sa(m.status),g=o===m.id,v=m.parentTaskId||!m.workspaceId?void 0:d.get(m.workspaceId);return l.jsxs("div",{onClick:()=>c(Xn(m.id)),className:`${He.taskRow} ${g?He.selected:""}`,style:{"--task-indent":`${Ax}px`},"data-task-id":m.id,children:[l.jsx("span",{className:He.leafSpacer}),l.jsx("span",{className:He.taskStatusIcon,style:{color:h.color},children:h.icon}),l.jsx("span",{className:He.taskTitle,title:m.title,children:l.jsx(Ex,{text:m.title,indices:u.get(m.id),highlightClass:He.searchHighlight})}),v&&l.jsx("span",{className:He.workspaceBadge,title:v,children:v})]},m.id)})})})]})}function Rx({node:t,depth:s,expandedTasks:i,toggleTask:o,selectedTaskId:c,navigate:u,taskStatusById:d,titleHighlights:m,workspaceNames:h}){const g=Sa(t.status),v=t.dependsOn.length>0&&t.dependsOn.some(w=>d.get(w)!=="complete"),_=i.has(t.id),b=t.children.length>0,S=c===t.id,T=Ax+s*t6,j=s===0&&!t.parentTaskId&&t.workspaceId?h.get(t.workspaceId):void 0;return l.jsxs(l.Fragment,{children:[l.jsxs("div",{onClick:()=>u(Xn(t.id)),className:`${He.taskRow} ${S?He.selected:""}`,style:{"--task-indent":`${T}px`},"data-task-id":t.id,children:[b&&l.jsx("span",{className:`${He.expandArrow} ${_?He.expanded:""}`,role:"button",tabIndex:0,"aria-label":_?"Collapse task":"Expand task",onClick:w=>{w.stopPropagation(),o(t.id)},onKeyDown:w=>{(w.key==="Enter"||w.key===" ")&&(w.preventDefault(),w.stopPropagation(),o(t.id))},children:"▸"}),!b&&l.jsx("span",{className:He.leafSpacer}),l.jsx("span",{className:He.taskStatusIcon,style:{color:g.color},children:g.icon}),l.jsx("span",{className:He.taskTitle,title:t.title,children:l.jsx(Ex,{text:t.title,indices:m.get(t.id),highlightClass:He.searchHighlight})}),j&&l.jsx("span",{className:He.workspaceBadge,title:j,children:j}),b&&l.jsxs("span",{className:He.childCountBadge,children:[t.children.filter(w=>w.status==="complete").length,"/",t.children.length]}),t.dependsOn.length>0&&l.jsx("span",{className:`${He.dependencyBadge} ${v?He.blockedBadge:""}`,title:`Depends on: ${t.dependsOn.join(", ")}`,children:v?"blocked":"dep"}),s<_T&&l.jsx("button",{onClick:w=>{w.stopPropagation(),u(ri(t.workspaceId,t.id))},title:"Add child task","aria-label":"Add child task",className:He.addChildButton,children:"+"})]}),l.jsx(ds,{children:b&&_&&l.jsx(Dt.div,{initial:{height:0,opacity:0},animate:{height:"auto",opacity:1},exit:{height:0,opacity:0},transition:{duration:.15},style:{overflow:"hidden"},children:t.children.map(w=>l.jsx(Rx,{node:w,depth:s+1,expandedTasks:i,toggleTask:o,selectedTaskId:c,navigate:u,taskStatusById:d,titleHighlights:m,workspaceNames:h},w.id))})})]})}function a6({workspaces:t,tasks:s}){const i=vt(),[o,c]=y.useState(new Set),[u,d]=y.useState(new Set),[m,h]=y.useState(Qy),[g,v]=y.useState(Qy),[_,b]=y.useState(new Map),S=kt("/tasks/:taskId/*"),T=(S==null?void 0:S.params.taskId)!=="new"?S==null?void 0:S.params.taskId:void 0,N=y.useMemo(()=>new Map(s.map(ie=>[ie.id,ie.status])),[s]),j=y.useMemo(()=>new Map(t.map(ie=>[ie.id,ie.name])),[t]),w=()=>{const ie=!m;n6(ie),h(ie),ie&&(v(!0),b(new Map))},C=ie=>{b(X=>{const O=new Map(X),q=O.has(ie)?O.get(ie):g;return O.set(ie,!q),O})},A=ie=>_.has(ie)?_.get(ie):g,M=ie=>{c(X=>{const O=new Set(X);return O.has(ie)?(O.delete(ie),d(q=>new Set(q).add(ie))):(O.add(ie),d(q=>{const te=new Set(q);return te.delete(ie),te})),O})};y.useEffect(()=>{const ie=new Set(s.filter(X=>X.parentTaskId).map(X=>X.parentTaskId));ie.size>0&&c(X=>{const O=new Set(X);for(const q of ie)u.has(q)||O.add(q);return O})},[s,u]);const[D,E]=y.useState(""),{directMatchTaskIds:$,treeMatchTaskIds:z,titleHighlights:K}=y.useMemo(()=>{if(!D.trim())return{directMatchTaskIds:null,treeMatchTaskIds:null,titleHighlights:new Map};const ie=bT(s,D,e6),X=new Set(ie.map(re=>re.item.id)),O=new Map;for(const re of ie){const ue=re.matches.find(Fe=>Fe.key==="title");ue&&O.set(re.item.id,ue.indices)}const q=new Set(X),te=new Map(s.map(re=>[re.id,re]));for(const re of[...X]){let ue=te.get(re);for(;ue!=null&&ue.parentTaskId;)q.add(ue.parentTaskId),ue=te.get(ue.parentTaskId)}return{directMatchTaskIds:X,treeMatchTaskIds:q,titleHighlights:O}},[D,s]),F=$!==null,ee=F?m?$:z:null,ae=ee?s.filter(ie=>ee.has(ie.id)):s,me=m?[]:j3(ae);return l.jsxs("div",{className:He.container,children:[l.jsxs("div",{className:He.header,children:[l.jsx("span",{children:"Tasks"}),l.jsxs("div",{className:He.headerActions,children:[l.jsx("button",{className:`${He.groupToggle} ${m?He.groupToggleActive:""}`,onClick:w,"aria-label":m?"Switch to tree view":"Group tasks by status","aria-pressed":m,title:m?"Switch to tree view":"Group tasks by status","data-testid":"task-group-by-status-toggle",children:"≡"}),l.jsx("button",{className:He.addButton,onClick:()=>i(ri()),"aria-label":"New task",title:"New task","data-testid":"new-task-button",children:"+"})]})]}),s.length>0&&l.jsx("input",{type:"text",value:D,onChange:ie=>E(ie.target.value),placeholder:"Filter...","aria-label":"Filter tasks",className:He.searchInput,"data-testid":"sidebar-search"}),m?C3(ae,N).map(ie=>l.jsx(s6,{group:ie,isExpanded:A(ie.status),onToggle:()=>C(ie.status),selectedTaskId:T,navigate:i,titleHighlights:K,workspaceNames:j},ie.status)):me.map(ie=>l.jsx(Rx,{node:ie,depth:0,expandedTasks:o,toggleTask:M,selectedTaskId:T,navigate:i,taskStatusById:N,titleHighlights:K,workspaceNames:j},ie.id)),ae.length===0&&!F&&l.jsx("div",{className:He.emptyState,children:"No tasks yet. Click + to create one."}),ae.length===0&&F&&l.jsx("div",{className:He.emptyState,children:"No matching tasks"})]})}const i6="_toast_da8ll_1",o6="_success_da8ll_18",r6="_icon_da8ll_22",l6="_error_da8ll_25",c6="_warning_da8ll_32",u6="_info_da8ll_38",d6="_message_da8ll_53",f6="_close_da8ll_60",dr={toast:i6,success:o6,icon:r6,error:l6,warning:c6,info:u6,message:d6,close:f6},p6={success:"✓",error:"✕",warning:"⚠",info:"ℹ"};function m6({toast:t,onDismiss:s}){return y.useEffect(()=>{const i=setTimeout(()=>s(t.id),t.duration);return()=>clearTimeout(i)},[t.id,t.duration,s]),l.jsxs(Dt.div,{className:`${dr.toast} ${dr[t.variant]}`,role:"status",initial:{opacity:0,y:-16,scale:.94},animate:{opacity:1,y:0,scale:1},exit:{opacity:0,y:-8,scale:.94},transition:{duration:.2,ease:"easeOut"},layout:!0,children:[l.jsx("span",{className:dr.icon,"aria-hidden":"true",children:p6[t.variant]}),l.jsx("span",{className:dr.message,children:t.message}),l.jsx("button",{type:"button",className:dr.close,onClick:()=>s(t.id),"aria-label":"Dismiss notification",children:"×"})]})}const h6="_container_qqse2_1",g6={container:h6};function v6({toasts:t,onDismiss:s}){return l.jsx("div",{className:g6.container,"data-testid":"toast-container",children:l.jsx(ds,{children:t.map(i=>l.jsx(m6,{toast:i,onDismiss:s},i.id))})})}const y6="_callout_1jaue_1",b6="_success_1jaue_11",_6="_icon_1jaue_15",x6="_error_1jaue_18",S6="_warning_1jaue_25",T6="_info_1jaue_32",k6="_content_1jaue_48",w6="_close_1jaue_53",fr={callout:y6,success:b6,icon:_6,error:x6,warning:S6,info:T6,content:k6,close:w6},N6={success:"✓",error:"✕",warning:"⚠",info:"ℹ"};function j6({variant:t="info",children:s,dismissible:i=!1,className:o}){const[c,u]=y.useState(!1);return l.jsx(l.Fragment,{children:!c&&l.jsxs("div",{className:[fr.callout,fr[t],o].filter(Boolean).join(" "),role:t==="error"||t==="warning"?"alert":"status",children:[l.jsx("span",{className:fr.icon,"aria-hidden":"true",children:N6[t]}),l.jsx("span",{className:fr.content,children:s}),i&&l.jsx("button",{type:"button",className:fr.close,onClick:()=>u(!0),"aria-label":"Dismiss",children:"×"})]})})}function C6({currentVersion:t,latestVersion:s,updateAvailable:i,isDocker:o}){if(!i)return l.jsx(l.Fragment,{});const c=o?"docker pull ghcr.io/nick-pape/grackle:latest && docker restart grackle":`npm install -g @grackle-ai/cli@${s}`;return l.jsx("div",{"data-testid":"update-banner",children:l.jsxs(j6,{variant:"info",dismissible:!0,children:[l.jsxs("strong",{children:["Grackle v",s]})," is available (you have v",t,")."," ","Run: ",l.jsx("code",{children:c})]})})}const E6="_container_de44x_1",A6="_emptyState_de44x_8",D6="_card_de44x_14",R6="_cardClickable_de44x_34",M6="_cardHeader_de44x_42",I6="_categoryBadge_de44x_54",O6="_findingTitle_de44x_62",B6="_findingDate_de44x_68",L6="_findingContent_de44x_80",U6="_tags_de44x_86",z6="_tag_de44x_86",Kn={container:E6,emptyState:A6,card:D6,cardClickable:R6,cardHeader:M6,categoryBadge:I6,findingTitle:O6,findingDate:B6,findingContent:L6,tags:U6,tag:z6};function Mx({findings:t,onFindingClick:s}){return t.length===0?l.jsx("div",{className:Kn.emptyState,children:"No findings yet. Agents will post discoveries here."}):l.jsx("div",{className:Kn.container,children:t.map((i,o)=>{const c=Lc(i.category),u=s?Dt.button:Dt.div;return l.jsxs(u,{type:s?"button":void 0,className:`${Kn.card} ${s?Kn.cardClickable:""}`,initial:{opacity:0,y:8},animate:{opacity:1,y:0},transition:{delay:o*.05,duration:.2},onClick:s?()=>{s(i.id)}:void 0,children:[l.jsxs("div",{className:Kn.cardHeader,children:[l.jsx("span",{className:Kn.categoryBadge,style:{background:c.bg,color:c.text},children:i.category}),l.jsx("span",{className:Kn.findingTitle,children:i.title}),l.jsx("span",{className:Kn.findingDate,title:i.createdAt,children:gm(i.createdAt)})]}),l.jsx("div",{className:Kn.findingContent,children:i.content.length>300?i.content.slice(0,300)+"...":i.content}),i.tags.length>0&&l.jsx("div",{className:Kn.tags,children:i.tags.map(d=>l.jsx("span",{className:Kn.tag,style:{color:c.text,textShadow:`0 0 8px ${c.text}`},children:d},d))})]},i.id)})})}const P6="_section_1ingb_14",V6="_sectionTitle_1ingb_26",H6="_sectionDescription_1ingb_35",$6="_tokenList_1ingb_48",G6="_tokenRow_1ingb_55",q6="_tokenBadge_1ingb_68",F6="_tokenName_1ingb_83",Z6="_tokenTarget_1ingb_90",K6="_deleteButton_1ingb_99",Y6="_addForm_1ingb_113",J6="_formRow_1ingb_119",W6="_input_1ingb_125",X6="_select_1ingb_155",Q6="_addButton_1ingb_187",eI="_emptyStateInfo_1ingb_221",tI="_themeOptions_1ingb_229",nI="_themeOption_1ingb_229",sI="_themeOptionSelected_1ingb_254",aI="_themeOptionHeader_1ingb_259",iI="_themeOptionLabel_1ingb_266",oI="_themeOptionDesc_1ingb_273",rI="_variantToggle_1ingb_279",lI="_variantButton_1ingb_286",cI="_variantActive_1ingb_305",uI="_themeSwatches_1ingb_311",dI="_themeSwatch_1ingb_311",fI="_systemToggle_1ingb_325",pI="_systemToggleHint_1ingb_341",mI="_themeActive_1ingb_348",hI="_aboutGrid_1ingb_354",gI="_aboutItem_1ingb_360",vI="_aboutLabel_1ingb_373",yI="_aboutValue_1ingb_379",bI="_aboutDot_1ingb_387",_I="_aboutDotConnected_1ingb_394",xI="_aboutDotDisconnected_1ingb_398",pe={section:P6,sectionTitle:V6,sectionDescription:H6,tokenList:$6,tokenRow:G6,tokenBadge:q6,tokenName:F6,tokenTarget:Z6,deleteButton:K6,addForm:Y6,formRow:J6,input:W6,select:X6,addButton:Q6,emptyStateInfo:eI,themeOptions:tI,themeOption:nI,themeOptionSelected:sI,themeOptionHeader:aI,themeOptionLabel:iI,themeOptionDesc:oI,variantToggle:rI,variantButton:lI,variantActive:cI,themeSwatches:uI,themeSwatch:dI,systemToggle:fI,systemToggleHint:pI,themeActive:mI,aboutGrid:hI,aboutItem:gI,aboutLabel:vI,aboutValue:yI,aboutDot:bI,aboutDotConnected:_I,aboutDotDisconnected:xI},SI=[{value:"env_var",label:"Environment Variable"},{value:"file",label:"File"}];function TI({tokens:t,onSetToken:s,onDeleteToken:i,onShowToast:o}){const[c,u]=y.useState(""),[d,m]=y.useState(""),[h,g]=y.useState("env_var"),[v,_]=y.useState(""),[b,S]=y.useState(null),T=w=>{if(w.preventDefault(),!c||!d)return;const C=h==="env_var"?v||c.toUpperCase()+"_TOKEN":"";s(c,d,h,C,h==="file"?v:""),o==null||o("Token saved successfully","success"),u(""),m(""),_("")},N=w=>{S(w)},j=()=>{b&&(i(b),o==null||o("Token deleted","info")),S(null)};return l.jsxs(l.Fragment,{children:[l.jsx(ii,{isOpen:b!==null,title:"Delete Token?",description:b?`"${b}" will be permanently removed.`:void 0,onConfirm:j,onCancel:()=>S(null)}),l.jsxs("section",{className:pe.section,children:[l.jsx("h3",{className:pe.sectionTitle,children:"Tokens"}),l.jsx("p",{className:pe.sectionDescription,children:"API tokens are auto-pushed to environments when set or updated. Values are write-only."}),t.length===0?l.jsx("div",{className:pe.emptyStateInfo,children:"Add your first API token to enable service integrations."}):l.jsx("div",{className:pe.tokenList,children:t.map(w=>l.jsxs("div",{className:pe.tokenRow,children:[l.jsx("span",{className:pe.tokenBadge,children:w.tokenType}),l.jsx("span",{className:pe.tokenName,children:w.name}),l.jsx("span",{className:pe.tokenTarget,children:w.tokenType==="env_var"?w.envVar:w.filePath}),l.jsx("button",{className:pe.deleteButton,onClick:()=>N(w.name),title:`Delete ${w.name}`,children:"×"})]},w.name))}),l.jsxs("form",{className:pe.addForm,onSubmit:T,children:[l.jsxs("div",{className:pe.formRow,children:[l.jsx("input",{className:pe.input,type:"text",placeholder:"Token name",value:c,onChange:w=>u(w.target.value)}),l.jsx("input",{className:pe.input,type:"password",placeholder:"Value",value:d,onChange:w=>m(w.target.value)})]}),l.jsxs("div",{className:pe.formRow,children:[l.jsx("select",{className:pe.select,value:h,onChange:w=>g(w.target.value),children:SI.map(w=>l.jsx("option",{value:w.value,children:w.label},w.value))}),l.jsx("input",{className:pe.input,type:"text",placeholder:h==="env_var"?"Env var name (e.g. API_TOKEN)":"File path (e.g. /home/user/.token)",value:v,onChange:w=>_(w.target.value)}),l.jsx("button",{className:pe.addButton,type:"submit",children:"Add Token"})]})]})]})]})}const Qc=[{id:"grackle",label:"Grackle",description:"The default Grackle theme — iridescent purple on clean dark.",swatches:["#0e1218","#8b5cf6","#60a5fa","#e5e7eb","#34d399"],variantLightId:"grackle-light",variantDarkId:"grackle-dark"},{id:"grackle-light",label:"Grackle Light",description:"Light Grackle variant.",hidden:!0},{id:"grackle-dark",label:"Grackle Dark",description:"Dark Grackle variant.",hidden:!0},{id:"glass",label:"Glassmorphism",description:"Dark frosted-glass aesthetic with backdrop blur effects.",swatches:["#0a0c14","#4ecca3","#70a1ff","#e2e8f0","#a855f7"]},{id:"matrix",label:"Matrix",description:"Phosphor-green CRT terminal with scanlines and glow.",swatches:["#050505","#00ff41","#00bfff","#33ff77","#ffb000"]},{id:"brutalist",label:"Neubrutalism",description:"Thick borders, raw colors, bold type — ugly on purpose.",swatches:["#f5f0e8","#ff5757","#5ce1e6","#1a1a1a","#ffde59"],variantLightId:"brutalist-light",variantDarkId:"brutalist-dark"},{id:"brutalist-light",label:"Neubrutalism Light",description:"Light neubrutalism variant.",hidden:!0},{id:"brutalist-dark",label:"Neubrutalism Dark",description:"Dark neubrutalism variant.",hidden:!0},{id:"monokai",label:"Monokai",description:"Classic warm editor palette — pink, green, and purple.",swatches:["#272822","#f92672","#a6e22e","#f8f8f2","#ae81ff"],variantLightId:"monokai-light",variantDarkId:"monokai-dark"},{id:"monokai-dark",label:"Monokai Dark",description:"Dark Monokai variant.",hidden:!0},{id:"monokai-light",label:"Monokai Light",description:"Light Monokai variant.",hidden:!0},{id:"ubuntu",label:"Ubuntu",description:"Aubergine terminal with the GNOME Tango palette.",swatches:["#300a24","#8ae234","#ef2929","#eeeeec","#fce94f"]},{id:"sandstone",label:"Sandstone",description:"Warm terracotta accent on dark brown, in the style of Claude Code.",swatches:["#1a1815","#C15F3C","#6b8afd","#e8e6e3","#a78bfa"]},{id:"verdigris",label:"Verdigris",description:"Teal accent on charcoal, in the style of ChatGPT.",swatches:["#141414","#00a67e","#3b82f6","#ececec","#ab68ff"]},{id:"primer",label:"Primer",description:"Blue accent on ink-dark grey, in the style of GitHub.",swatches:["#0d1117","#58a6ff","#3fb950","#c9d1d9","#bc8cff"]}],Ix=new Set(Qc.map(t=>t.id)),eb="grackle";function yp(t){return Qc.find(s=>s.id===t)}function kI({themeId:t,resolvedThemeId:s,onSetTheme:i,preferSystem:o,onSetPreferSystem:c}){return l.jsxs("section",{className:pe.section,children:[l.jsx("h3",{className:pe.sectionTitle,children:"Appearance"}),l.jsx("p",{className:pe.sectionDescription,children:"Choose how Grackle looks across the app."}),l.jsx("div",{className:pe.themeOptions,children:Qc.filter(u=>!u.hidden).map(u=>{const d=!!(u.variantLightId&&u.variantDarkId),m=d?t===u.id||t===u.variantLightId||t===u.variantDarkId:t===u.id,h=d&&s===u.variantLightId;return l.jsxs("button",{type:"button",className:`${pe.themeOption} ${m?pe.themeOptionSelected:""}`,"aria-pressed":m,onClick:()=>i(u.id),children:[l.jsxs("span",{className:pe.themeOptionHeader,children:[l.jsxs("span",{children:[l.jsx("span",{className:pe.themeOptionLabel,children:u.label}),l.jsx("span",{className:pe.themeOptionDesc,children:u.description})]}),d&&l.jsxs("span",{className:pe.variantToggle,children:[l.jsx("span",{role:"button",tabIndex:0,className:`${pe.variantButton} ${m&&h?pe.variantActive:""}`,onClick:g=>{g.stopPropagation(),c(!1),i(u.variantLightId)},onKeyDown:g=>{(g.key==="Enter"||g.key===" ")&&(g.preventDefault(),g.stopPropagation(),c(!1),i(u.variantLightId))},"aria-label":"Light variant","aria-pressed":m&&h,children:"☼"}),l.jsx("span",{role:"button",tabIndex:0,className:`${pe.variantButton} ${m&&!h?pe.variantActive:""}`,onClick:g=>{g.stopPropagation(),c(!1),i(u.variantDarkId)},onKeyDown:g=>{(g.key==="Enter"||g.key===" ")&&(g.preventDefault(),g.stopPropagation(),c(!1),i(u.variantDarkId))},"aria-label":"Dark variant","aria-pressed":m&&!h,children:"☾"})]})]}),u.swatches&&l.jsx("span",{className:pe.themeSwatches,children:u.swatches.map((g,v)=>l.jsx("span",{className:pe.themeSwatch,style:{background:g}},v))})]},u.id)})}),l.jsxs("label",{className:pe.systemToggle,children:[l.jsx("input",{type:"checkbox",checked:o,onChange:u=>c(u.target.checked)}),l.jsx("span",{children:"Match system light/dark preference"})]}),l.jsx("p",{className:pe.systemToggleHint,children:"Automatically switches between light and dark variants when available."}),l.jsxs("p",{className:pe.themeActive,children:["Active theme: ",l.jsx("strong",{children:s})]})]})}function wI({connected:t,environments:s,sessions:i}){const o=s.filter(d=>d.status==="connected").length,c=s.length,u=i.filter(d=>["running","idle"].includes(d.status)).length;return l.jsxs("section",{className:pe.section,"data-testid":"about-panel",children:[l.jsx("h3",{className:pe.sectionTitle,children:"About"}),l.jsx("p",{className:pe.sectionDescription,children:"Connection status and application information."}),l.jsxs("div",{className:pe.aboutGrid,children:[l.jsxs("div",{className:pe.aboutItem,children:[l.jsx("span",{className:pe.aboutLabel,children:"Connection"}),l.jsxs("span",{className:pe.aboutValue,children:[l.jsx("span",{className:`${pe.aboutDot} ${t?pe.aboutDotConnected:pe.aboutDotDisconnected}`}),t?"Connected":"Disconnected"]})]}),l.jsxs("div",{className:pe.aboutItem,children:[l.jsx("span",{className:pe.aboutLabel,children:"Environments"}),l.jsxs("span",{className:pe.aboutValue,children:[o,"/",c," connected"]})]}),l.jsxs("div",{className:pe.aboutItem,children:[l.jsx("span",{className:pe.aboutLabel,children:"Active Sessions"}),l.jsx("span",{className:pe.aboutValue,children:u})]}),l.jsxs("div",{className:pe.aboutItem,children:[l.jsx("span",{className:pe.aboutLabel,children:"Version"}),l.jsx("span",{className:pe.aboutValue,children:"0.89.0"})]})]})]})}const NI="_container_cddyd_1",jI="_header_cddyd_8",CI="_headerTitle_cddyd_35",EI="_badge_cddyd_44",AI="_headerActions_cddyd_54",DI="_body_cddyd_61",RI="_formContent_cddyd_73",MI="_section_cddyd_85",II="_label_cddyd_91",OI="_titleInput_cddyd_98",BI="_descriptionTextarea_cddyd_131",LI="_parentContext_cddyd_167",UI="_parentLabel_cddyd_175",zI="_parentName_cddyd_182",PI="_personaSelect_cddyd_186",VI="_depList_cddyd_220",HI="_depItem_cddyd_226",$I="_depItemSelected_cddyd_248",GI="_noDeps_cddyd_252",qI="_btnPrimary_cddyd_258",FI="_btnGhost_cddyd_289",Ye={container:NI,header:jI,headerTitle:CI,badge:EI,headerActions:AI,body:DI,formContent:RI,section:MI,label:II,titleInput:OI,descriptionTextarea:BI,parentContext:LI,parentLabel:UI,parentName:zI,personaSelect:PI,depList:VI,depItem:HI,depItemSelected:$I,noDeps:GI,btnPrimary:qI,btnGhost:FI};function Ox({mode:t,taskId:s,workspaceId:i,parentTaskId:o,environmentId:c,tasks:u,workspaces:d,personas:m,onCreateTask:h,onUpdateTask:g,onEditDone:v,onShowToast:_}){const b=vt(),S=t==="edit",T=S&&s?u.find(de=>de.id===s):void 0,N=S?(T==null?void 0:T.workspaceId)??"":i??"",[j,w]=y.useState(N),C=N||j,A=d.find(de=>de.id===C),M=c??(A==null?void 0:A.environmentId),D=!S&&!i,E=S?(T==null?void 0:T.parentTaskId)??"":o??"",$=E?u.find(de=>de.id===E):void 0,[z,K]=y.useState((T==null?void 0:T.title)??""),[F,ee]=y.useState((T==null?void 0:T.description)??""),[ae,me]=y.useState((T==null?void 0:T.dependsOn)??[]),[ie,X]=y.useState((T==null?void 0:T.defaultPersonaId)??""),[O,q]=y.useState((T==null?void 0:T.canDecompose)??!1),[te,re]=y.useState(!1),ue=y.useRef(!1);y.useEffect(()=>{S&&T&&!ue.current&&(ue.current=!0,K(T.title),ee(T.description),me(T.dependsOn),X(T.defaultPersonaId),q(T.canDecompose))},[S,T]);const Fe=u.filter(de=>de.workspaceId===C&&(!S||de.id!==s)&&de.id!==E),Ne=z.trim().length>0&&(!S||T!==void 0)&&C.length>0,ke=de=>{me(Ie=>Ie.includes(de)?Ie.filter(yt=>yt!==de):[...Ie,de])},Me=()=>{!Ne||te||S&&T===void 0||(S&&s?(g(s,z.trim(),F,ae,ie),_==null||_("Task updated","success"),v?v():b(Xn(s,void 0,C,M),{replace:!0})):(re(!0),h(C,z.trim(),F,ae.length>0?ae:void 0,E||void 0,ie,O,()=>{_==null||_("Task created","success"),b(i?ni(i,M):"/tasks",{replace:!0})},de=>{_==null||_(de,"error"),re(!1)})))},le=()=>{if(v){v();return}b(S&&s?Xn(s,void 0,C,M):i?ni(i,M):"/tasks")},ve=S?"edit task":E?"child task":"new task";return l.jsxs("div",{className:Ye.container,children:[l.jsxs("div",{className:Ye.header,children:[l.jsxs("div",{className:Ye.headerTitle,children:[l.jsx("span",{className:Ye.badge,children:ve}),$&&l.jsxs("span",{className:Ye.parentContext,children:[l.jsx("span",{className:Ye.parentLabel,children:"Child of"}),l.jsx("span",{className:Ye.parentName,children:$.title})]})]}),l.jsxs("div",{className:Ye.headerActions,children:[l.jsx("button",{onClick:Me,disabled:!Ne||te,className:Ye.btnPrimary,"data-testid":"task-edit-save",children:te?"Creating…":S?"Save Changes":"Create"}),l.jsx("button",{onClick:le,className:Ye.btnGhost,children:"Cancel"})]})]}),l.jsx("div",{className:Ye.body,children:l.jsxs("div",{className:Ye.formContent,children:[D&&l.jsxs("div",{className:Ye.section,children:[l.jsx("label",{className:Ye.label,htmlFor:"task-edit-workspace",children:"Workspace"}),l.jsxs("select",{id:"task-edit-workspace",value:j,onChange:de=>w(de.target.value),className:Ye.personaSelect,"data-testid":"task-edit-workspace",children:[l.jsx("option",{value:"",children:"Select a workspace..."}),d.map(de=>l.jsx("option",{value:de.id,children:de.name},de.id))]})]}),l.jsxs("div",{className:Ye.section,children:[l.jsx("label",{className:Ye.label,htmlFor:"task-edit-title",children:"Title"}),l.jsx("input",{id:"task-edit-title",type:"text",value:z,onChange:de=>K(de.target.value),placeholder:"Task title...",autoFocus:!0,className:Ye.titleInput,"data-testid":"task-edit-title",onKeyDown:de=>{de.key==="Enter"&&Ne&&Me()}})]}),l.jsxs("div",{className:Ye.section,children:[l.jsx("label",{className:Ye.label,htmlFor:"task-edit-description",children:"Description"}),l.jsx("textarea",{id:"task-edit-description",value:F,onChange:de=>ee(de.target.value),placeholder:"Describe the task... (markdown supported)",className:Ye.descriptionTextarea,"data-testid":"task-edit-description",rows:8})]}),l.jsxs("div",{className:Ye.section,children:[l.jsx("label",{className:Ye.label,htmlFor:"task-edit-persona",children:"Default Persona"}),l.jsxs("select",{id:"task-edit-persona",value:ie,onChange:de=>X(de.target.value),className:Ye.personaSelect,"data-testid":"task-edit-persona",children:[l.jsx("option",{value:"",children:"(Inherit)"}),m.map(de=>l.jsx("option",{value:de.id,children:de.name},de.id))]})]}),!S&&l.jsx("div",{className:Ye.section,children:l.jsxs("label",{className:Ye.depItem,"data-testid":"task-edit-can-decompose",children:[l.jsx("input",{type:"checkbox",checked:O,onChange:de=>q(de.target.checked)}),"Can spawn subtasks"]})}),l.jsxs("div",{className:Ye.section,children:[l.jsx("div",{className:Ye.label,children:"Dependencies"}),Fe.length===0?l.jsx("div",{className:Ye.noDeps,children:"No other tasks in this workspace"}):l.jsx("div",{className:Ye.depList,children:Fe.map(de=>{const Ie=ae.includes(de.id);return l.jsxs("label",{className:`${Ye.depItem} ${Ie?Ye.depItemSelected:""}`,"data-testid":`dep-option-${de.id}`,children:[l.jsx("input",{type:"checkbox",checked:Ie,onChange:()=>ke(de.id)}),de.title,l.jsxs("span",{style:{opacity:.5,fontSize:"11px",marginLeft:"4px"},children:["(",de.status,")"]})]},de.id)})})]})]})})]})}const ZI="_container_legrg_1",KI="_header_legrg_8",YI="_headerTitle_legrg_35",JI="_badge_legrg_44",WI="_headerActions_legrg_54",XI="_body_legrg_61",QI="_formContent_legrg_73",eO="_section_legrg_85",tO="_label_legrg_91",nO="_nameInput_legrg_98",sO="_fieldInput_legrg_131",aO="_adapterSelect_legrg_164",iO="_readOnlyValue_legrg_198",oO="_codespaceSection_legrg_204",rO="_codespaceActions_legrg_210",lO="_creatingHint_legrg_216",cO="_errorHint_legrg_222",uO="_btnPrimary_legrg_235",dO="_btnGhost_legrg_266",ne={container:ZI,header:KI,headerTitle:YI,badge:JI,headerActions:WI,body:XI,formContent:QI,section:eO,label:tO,nameInput:nO,fieldInput:sO,adapterSelect:aO,readOnlyValue:iO,codespaceSection:oO,codespaceActions:rO,creatingHint:lO,errorHint:cO,btnPrimary:uO,btnGhost:dO},kc=1,wc=65535;function Uf(t){if(!t.trim())return!0;const s=Number(t);return Number.isInteger(s)&&s>=kc&&s<=wc}function zf(t){try{const s=JSON.parse(t);if(typeof s=="object"&&s!==null&&!Array.isArray(s))return s}catch{}return{}}function fO({codespaceName:t,onCodespaceNameChange:s,envName:i,onEnvNameChange:o,codespaces:c,codespaceError:u,codespaceListError:d,codespaceCreating:m,onCreateCodespace:h}){const[g,v]=y.useState("pick"),[_,b]=y.useState(""),[S,T]=y.useState("");return g==="create"?l.jsxs("div",{className:ne.codespaceSection,children:[l.jsxs("div",{className:ne.section,children:[l.jsx("label",{className:ne.label,children:"Repository"}),l.jsx("input",{type:"text",value:_,onChange:N=>b(N.target.value),placeholder:"owner/repo",className:ne.fieldInput,"data-testid":"env-codespace-repo"})]}),l.jsxs("div",{className:ne.section,children:[l.jsx("label",{className:ne.label,children:"Machine Type"}),l.jsx("input",{type:"text",value:S,onChange:N=>T(N.target.value),placeholder:"Machine type (optional)...",className:ne.fieldInput,"data-testid":"env-codespace-machine"})]}),l.jsxs("div",{className:ne.codespaceActions,children:[l.jsx("button",{onClick:()=>{_.trim()&&(h(_.trim(),S.trim()||void 0),v("pick"),b(""),T(""))},disabled:!_.trim(),className:ne.btnPrimary,children:"Create"}),l.jsx("button",{onClick:()=>{v("pick"),b(""),T("")},className:ne.btnGhost,children:"Cancel"})]})]}):l.jsx("div",{className:ne.codespaceSection,children:l.jsxs("div",{className:ne.section,children:[l.jsx("label",{className:ne.label,children:"Codespace"}),!d&&l.jsxs("select",{value:t,onChange:N=>{N.target.value==="__create__"?(v("create"),s("")):(s(N.target.value),N.target.value&&!i.trim()&&o(N.target.value))},disabled:m,className:ne.adapterSelect,"data-testid":"env-codespace-select",children:[l.jsx("option",{value:"",children:"Select a codespace..."}),c.map(N=>l.jsxs("option",{value:N.name,children:[N.name," (",N.repository,") — ",N.state]},N.name)),l.jsx("option",{value:"__create__",children:"Create new from repo..."})]}),m&&l.jsx("span",{className:ne.creatingHint,children:"Creating codespace..."}),d&&l.jsxs(l.Fragment,{children:[l.jsx("span",{className:ne.errorHint,children:d}),l.jsx("input",{type:"text",value:t,onChange:N=>s(N.target.value),placeholder:"Or enter codespace name manually...",className:ne.fieldInput,"data-testid":"env-codespace-manual"})]}),u&&!d&&l.jsx("span",{className:ne.errorHint,children:u})]})})}function Bx({mode:t,environmentId:s,environments:i,onAddEnvironment:o,onUpdateEnvironment:c,onListCodespaces:u,codespaces:d,codespaceError:m,codespaceListError:h,codespaceCreating:g,onCreateCodespace:v,onShowToast:_}){const b=vt(),S=t==="edit",T=S&&s?i.find(le=>le.id===s):void 0,[N,j]=y.useState(""),[w,C]=y.useState("local"),[A,M]=y.useState(""),[D,E]=y.useState(""),[$,z]=y.useState(""),[K,F]=y.useState(""),[ee,ae]=y.useState(""),[me,ie]=y.useState(""),[X,O]=y.useState(""),[q,te]=y.useState(null),re=y.useCallback(()=>{const le={};if(w==="local"){if(A.trim()&&(le.host=A.trim()),D.trim()){const ve=Number(D);Number.isInteger(ve)&&(le.port=ve)}}else if(w==="ssh"){if(le.host=A.trim(),$.trim()&&(le.user=$.trim()),D.trim()){const ve=Number(D);Number.isInteger(ve)&&(le.sshPort=ve)}K.trim()&&(le.identityFile=K.trim())}else w==="docker"?(ee.trim()&&(le.image=ee.trim()),me.trim()&&(le.repo=me.trim())):w==="codespace"&&(le.codespaceName=X.trim());return le},[w,A,D,$,K,ee,me,X]),ue=()=>!(!N.trim()||w==="ssh"&&!A.trim()||w==="codespace"&&!X.trim()||(w==="local"||w==="ssh")&&!Uf(D)),Fe=()=>{ue()&&(o(N.trim(),w,re()),_==null||_("Environment added successfully","success"),b(ao,{replace:!0}))},Ne=()=>{b(s?si(s):ao)},ke=y.useCallback((le,ve)=>{if(!T||!s)return;const de=zf(T.adapterConfig),Ie=ve.trim();Ie?de[le]=Ie:delete de[le],c(s,{adapterConfig:de})},[T,s,c]),Me=y.useCallback((le,ve)=>{if(!T||!s)return;const de=zf(T.adapterConfig);if(ve.trim()){const Ie=Number(ve);Number.isInteger(Ie)&&Ie>=kc&&Ie<=wc&&(de[le]=Ie)}else delete de[le];c(s,{adapterConfig:de})},[T,s,c]);if(S){if(!T)return l.jsxs("div",{className:ne.container,children:[l.jsxs("div",{className:ne.header,children:[l.jsx("div",{className:ne.headerTitle,children:l.jsx("span",{className:ne.badge,children:"edit environment"})}),l.jsx("div",{className:ne.headerActions,children:l.jsx("button",{onClick:Ne,className:ne.btnGhost,children:"Back"})})]}),l.jsx("div",{className:ne.body,children:l.jsx("div",{className:ne.formContent,children:l.jsx("span",{className:ne.readOnlyValue,children:"Environment not found"})})})]});const le=zf(T.adapterConfig);return l.jsxs("div",{className:ne.container,"data-testid":"env-edit-panel",children:[l.jsxs("div",{className:ne.header,children:[l.jsx("div",{className:ne.headerTitle,children:l.jsx("span",{className:ne.badge,children:"edit environment"})}),l.jsx("div",{className:ne.headerActions,children:l.jsx("button",{onClick:Ne,className:ne.btnGhost,"data-testid":"env-edit-back",children:"Back"})})]}),l.jsx("div",{className:ne.body,children:l.jsxs("div",{className:ne.formContent,children:[l.jsxs("div",{className:ne.section,children:[l.jsx("label",{className:ne.label,children:"Name"}),l.jsx(Kt,{value:T.displayName,onSave:ve=>{s&&c(s,{displayName:ve})},validate:ve=>ve.trim()===""?"Name cannot be empty":void 0,mode:"edit",fieldId:"name",activeFieldId:q,onActivate:te,placeholder:"Environment name",ariaLabel:"Environment name","data-testid":"env-edit-name"})]}),l.jsxs("div",{className:ne.section,children:[l.jsx("label",{className:ne.label,children:"Adapter Type"}),l.jsx("span",{className:ne.readOnlyValue,"data-testid":"env-edit-adapter-type",children:T.adapterType})]}),T.adapterType==="local"&&l.jsxs(l.Fragment,{children:[l.jsxs("div",{className:ne.section,children:[l.jsx("label",{className:ne.label,children:"Host"}),l.jsx(Kt,{value:String(le.host??""),onSave:ve=>ke("host",ve),mode:"edit",fieldId:"host",activeFieldId:q,onActivate:te,placeholder:"(default)",ariaLabel:"Host","data-testid":"env-edit-host"})]}),l.jsxs("div",{className:ne.section,children:[l.jsx("label",{className:ne.label,children:"Port"}),l.jsx(Kt,{value:String(le.port??""),onSave:ve=>Me("port",ve),validate:ve=>Uf(ve)?void 0:"Port must be 1-65535",mode:"edit",fieldId:"port",activeFieldId:q,onActivate:te,placeholder:"(default)",ariaLabel:"Port","data-testid":"env-edit-port"})]})]}),T.adapterType==="ssh"&&l.jsxs(l.Fragment,{children:[l.jsxs("div",{className:ne.section,children:[l.jsx("label",{className:ne.label,children:"Host"}),l.jsx(Kt,{value:String(le.host??""),onSave:ve=>ke("host",ve),validate:ve=>ve.trim()===""?"Host is required":void 0,mode:"edit",fieldId:"host",activeFieldId:q,onActivate:te,placeholder:"hostname or IP",ariaLabel:"Host","data-testid":"env-edit-host"})]}),l.jsxs("div",{className:ne.section,children:[l.jsx("label",{className:ne.label,children:"User"}),l.jsx(Kt,{value:String(le.user??""),onSave:ve=>ke("user",ve),mode:"edit",fieldId:"user",activeFieldId:q,onActivate:te,placeholder:"(default)",ariaLabel:"User","data-testid":"env-edit-user"})]}),l.jsxs("div",{className:ne.section,children:[l.jsx("label",{className:ne.label,children:"SSH Port"}),l.jsx(Kt,{value:String(le.sshPort??""),onSave:ve=>Me("sshPort",ve),validate:ve=>Uf(ve)?void 0:"Port must be 1-65535",mode:"edit",fieldId:"sshPort",activeFieldId:q,onActivate:te,placeholder:"22",ariaLabel:"SSH Port","data-testid":"env-edit-ssh-port"})]}),l.jsxs("div",{className:ne.section,children:[l.jsx("label",{className:ne.label,children:"Identity File"}),l.jsx(Kt,{value:String(le.identityFile??""),onSave:ve=>ke("identityFile",ve),mode:"edit",fieldId:"identityFile",activeFieldId:q,onActivate:te,placeholder:"~/.ssh/id_rsa",ariaLabel:"Identity File","data-testid":"env-edit-identity-file"})]})]}),T.adapterType==="docker"&&l.jsxs(l.Fragment,{children:[l.jsxs("div",{className:ne.section,children:[l.jsx("label",{className:ne.label,children:"Image"}),l.jsx(Kt,{value:String(le.image??""),onSave:ve=>ke("image",ve),mode:"edit",fieldId:"image",activeFieldId:q,onActivate:te,placeholder:"(default)",ariaLabel:"Image","data-testid":"env-edit-image"})]}),l.jsxs("div",{className:ne.section,children:[l.jsx("label",{className:ne.label,children:"Repo"}),l.jsx(Kt,{value:String(le.repo??""),onSave:ve=>ke("repo",ve),mode:"edit",fieldId:"repo",activeFieldId:q,onActivate:te,placeholder:"(none)",ariaLabel:"Repo","data-testid":"env-edit-repo"})]})]}),T.adapterType==="codespace"&&l.jsxs("div",{className:ne.section,children:[l.jsx("label",{className:ne.label,children:"Codespace Name"}),l.jsx(Kt,{value:String(le.codespaceName??""),onSave:ve=>ke("codespaceName",ve),validate:ve=>ve.trim()===""?"Codespace name is required":void 0,mode:"edit",fieldId:"codespaceName",activeFieldId:q,onActivate:te,placeholder:"codespace-name",ariaLabel:"Codespace Name","data-testid":"env-edit-codespace-name"})]})]})})]})}return l.jsxs("div",{className:ne.container,"data-testid":"env-create-panel",children:[l.jsxs("div",{className:ne.header,children:[l.jsx("div",{className:ne.headerTitle,children:l.jsx("span",{className:ne.badge,children:"new environment"})}),l.jsxs("div",{className:ne.headerActions,children:[l.jsx("button",{onClick:Fe,disabled:!ue(),className:ne.btnPrimary,"data-testid":"env-create-submit",children:"Create"}),l.jsx("button",{onClick:Ne,className:ne.btnGhost,children:"Cancel"})]})]}),l.jsx("div",{className:ne.body,children:l.jsxs("div",{className:ne.formContent,children:[l.jsxs("div",{className:ne.section,children:[l.jsx("label",{className:ne.label,htmlFor:"env-create-name",children:"Name"}),l.jsx("input",{id:"env-create-name",type:"text",value:N,onChange:le=>j(le.target.value),placeholder:"Environment name...",autoFocus:!0,className:ne.nameInput,"data-testid":"env-create-name",onKeyDown:le=>{le.key==="Enter"&&ue()&&Fe()}})]}),l.jsxs("div",{className:ne.section,children:[l.jsx("label",{className:ne.label,htmlFor:"env-create-adapter",children:"Adapter Type"}),l.jsxs("select",{id:"env-create-adapter",value:w,onChange:le=>{C(le.target.value),le.target.value==="codespace"&&u()},className:ne.adapterSelect,"data-testid":"env-create-adapter",children:[l.jsx("option",{value:"local",children:"local"}),l.jsx("option",{value:"ssh",children:"ssh"}),l.jsx("option",{value:"docker",children:"docker"}),l.jsx("option",{value:"codespace",children:"codespace"})]})]}),w==="local"&&l.jsxs(l.Fragment,{children:[l.jsxs("div",{className:ne.section,children:[l.jsx("label",{className:ne.label,htmlFor:"env-create-host",children:"Host"}),l.jsx("input",{id:"env-create-host",type:"text",value:A,onChange:le=>M(le.target.value),placeholder:"Host (optional)...",className:ne.fieldInput,"data-testid":"env-create-host"})]}),l.jsxs("div",{className:ne.section,children:[l.jsx("label",{className:ne.label,htmlFor:"env-create-port",children:"Port"}),l.jsx("input",{id:"env-create-port",type:"number",min:kc,max:wc,value:D,onChange:le=>E(le.target.value),placeholder:"Port (optional)...",className:ne.fieldInput,"data-testid":"env-create-port"})]})]}),w==="ssh"&&l.jsxs(l.Fragment,{children:[l.jsxs("div",{className:ne.section,children:[l.jsx("label",{className:ne.label,htmlFor:"env-create-host",children:"Host"}),l.jsx("input",{id:"env-create-host",type:"text",value:A,onChange:le=>M(le.target.value),placeholder:"Host (required)...",className:ne.fieldInput,"data-testid":"env-create-host"})]}),l.jsxs("div",{className:ne.section,children:[l.jsx("label",{className:ne.label,htmlFor:"env-create-user",children:"User"}),l.jsx("input",{id:"env-create-user",type:"text",value:$,onChange:le=>z(le.target.value),placeholder:"User (optional)...",className:ne.fieldInput,"data-testid":"env-create-user"})]}),l.jsxs("div",{className:ne.section,children:[l.jsx("label",{className:ne.label,htmlFor:"env-create-port",children:"SSH Port"}),l.jsx("input",{id:"env-create-port",type:"number",min:kc,max:wc,value:D,onChange:le=>E(le.target.value),placeholder:"SSH port (optional)...",className:ne.fieldInput,"data-testid":"env-create-port"})]}),l.jsxs("div",{className:ne.section,children:[l.jsx("label",{className:ne.label,htmlFor:"env-create-identity",children:"Identity File"}),l.jsx("input",{id:"env-create-identity",type:"text",value:K,onChange:le=>F(le.target.value),placeholder:"Identity file (optional)...",className:ne.fieldInput,"data-testid":"env-create-identity"})]})]}),w==="docker"&&l.jsxs(l.Fragment,{children:[l.jsxs("div",{className:ne.section,children:[l.jsx("label",{className:ne.label,htmlFor:"env-create-image",children:"Image"}),l.jsx("input",{id:"env-create-image",type:"text",value:ee,onChange:le=>ae(le.target.value),placeholder:"Image (optional)...",className:ne.fieldInput,"data-testid":"env-create-image"})]}),l.jsxs("div",{className:ne.section,children:[l.jsx("label",{className:ne.label,htmlFor:"env-create-repo",children:"Repo"}),l.jsx("input",{id:"env-create-repo",type:"text",value:me,onChange:le=>ie(le.target.value),placeholder:"Repo (optional)...",className:ne.fieldInput,"data-testid":"env-create-repo"})]})]}),w==="codespace"&&l.jsx(fO,{codespaceName:X,onCodespaceNameChange:O,envName:N,onEnvNameChange:j,codespaces:d,codespaceError:m,codespaceListError:h,codespaceCreating:g,onCreateCodespace:v})]})})]})}const pO="_group_1iprv_1",mO="_groupTitle_1iprv_8",hO="_shortcutList_1iprv_17",gO="_shortcutRow_1iprv_23",vO="_keys_1iprv_36",yO="_kbd_1iprv_43",bO="_description_1iprv_60",Ja={group:pO,groupTitle:mO,shortcutList:hO,shortcutRow:gO,keys:vO,kbd:yO,description:bO},_O=[{title:"Global",shortcuts:[{keys:["?"],description:"Open keyboard shortcuts reference"},{keys:["N"],description:"Create a new task"},{keys:["Escape"],description:"Close dialog or cancel editing"}]},{title:"Task Page",shortcuts:[{keys:["1"],description:"Switch to Overview tab"},{keys:["2"],description:"Switch to Stream tab"},{keys:["3"],description:"Switch to Findings tab"}]},{title:"Workspace Page",shortcuts:[{keys:["1"],description:"Switch to Graph view"},{keys:["2"],description:"Switch to Board view"},{keys:["3"],description:"Switch to Tasks view"}]},{title:"Navigation Lists",shortcuts:[{keys:["←"],description:"Previous tab (horizontal nav)"},{keys:["→"],description:"Next tab (horizontal nav)"},{keys:["↑"],description:"Previous item (vertical nav)"},{keys:["↓"],description:"Next item (vertical nav)"},{keys:["J"],description:"Next item (alias for arrow down/right)"},{keys:["K"],description:"Previous item (alias for arrow up/left)"},{keys:["Home"],description:"Jump to first item"},{keys:["End"],description:"Jump to last item"}]},{title:"Editing",shortcuts:[{keys:["Enter"],description:"Activate / save inline edit"},{keys:["Space"],description:"Activate button or start editing"},{keys:["Escape"],description:"Cancel edit and discard changes"}]},{title:"Chat",shortcuts:[{keys:["Enter"],description:"Send message (when input is focused)"}]}];function xO(){return l.jsxs("section",{className:pe.section,"data-testid":"keyboard-shortcuts-panel",children:[l.jsx("h3",{className:pe.sectionTitle,children:"Keyboard Shortcuts"}),l.jsx("p",{className:pe.sectionDescription,children:"Keyboard shortcuts for navigating and interacting with Grackle. Global shortcuts are suppressed while typing in text fields."}),_O.map(t=>l.jsxs("div",{className:Ja.group,children:[l.jsx("h4",{className:Ja.groupTitle,children:t.title}),l.jsx("div",{className:Ja.shortcutList,children:t.shortcuts.map(s=>l.jsxs("div",{className:Ja.shortcutRow,children:[l.jsx("span",{className:Ja.keys,children:s.keys.map(i=>l.jsx("kbd",{className:Ja.kbd,children:i},i))}),l.jsx("span",{className:Ja.description,children:s.description})]},s.description))})]},t.title))]})}const SO="_workpadSection_y8nj9_1",TO="_workpadLabel_y8nj9_9",kO="_workpadStatus_y8nj9_17",wO="_workpadSummary_y8nj9_23",NO="_workpadExtra_y8nj9_29",ga={workpadSection:SO,workpadLabel:TO,workpadStatus:kO,workpadSummary:wO,workpadExtra:NO};function jO({workpad:t}){if(!t)return;let s;try{const i=JSON.parse(t);if(i==null||typeof i!="object"||Array.isArray(i))return;s=i}catch{return l.jsxs("div",{className:ga.workpadSection,"data-testid":"workpad-panel",children:[l.jsx("div",{className:ga.workpadLabel,children:"Workpad"}),l.jsx("div",{className:ga.workpadExtra,children:t})]})}if(!(!s.status&&!s.summary&&!s.extra))return l.jsxs("div",{className:ga.workpadSection,"data-testid":"workpad-panel",children:[l.jsx("div",{className:ga.workpadLabel,children:"Workpad"}),s.status&&l.jsx("div",{className:ga.workpadStatus,"data-testid":"workpad-status",children:s.status}),s.summary&&l.jsx("div",{className:ga.workpadSummary,"data-testid":"workpad-summary",children:s.summary}),s.extra&&Object.keys(s.extra).length>0&&l.jsx("div",{className:ga.workpadExtra,"data-testid":"workpad-extra",children:JSON.stringify(s.extra,null,2)})]})}const CO=[{key:"claude",label:"Claude",description:"Forward Claude credentials for AI agent access.",options:[{value:"off",label:"Off"},{value:"subscription",label:"Subscription"},{value:"api_key",label:"API Key"}]},{key:"github",label:"GitHub",description:"Forward GITHUB_TOKEN and GH_TOKEN for git operations.",options:[{value:"off",label:"Off"},{value:"on",label:"On"}]},{key:"copilot",label:"Copilot",description:"Forward Copilot tokens (COPILOT_GITHUB_TOKEN, CLI config).",options:[{value:"off",label:"Off"},{value:"on",label:"On"}]},{key:"codex",label:"Codex",description:"Forward OPENAI_API_KEY for Codex/OpenAI access.",options:[{value:"off",label:"Off"},{value:"on",label:"On"}]},{key:"goose",label:"Goose",description:"Forward Goose config and API keys for Goose agent access.",options:[{value:"off",label:"Off"},{value:"on",label:"On"}]}];function EO({credentialProviders:t,onUpdateCredentialProviders:s}){const i=(o,c)=>{const u={...t};o==="claude"?u.claude=c:u[o]=c,s(u)};return l.jsxs("section",{className:pe.section,children:[l.jsx("h3",{className:pe.sectionTitle,children:"Credential Providers"}),l.jsx("p",{className:pe.sectionDescription,children:"Enable providers to automatically forward credentials to environments at task start. Credentials are read fresh from the host each time."}),l.jsx("div",{className:pe.tokenList,children:CO.map(o=>l.jsxs("div",{className:pe.tokenRow,children:[l.jsx("span",{className:pe.tokenName,children:o.label}),l.jsx("span",{className:pe.tokenTarget,children:o.description}),l.jsx("select",{className:pe.select,value:t[o.key],onChange:c=>i(o.key,c.target.value),children:o.options.map(c=>l.jsx("option",{value:c.value,children:c.label},c.value))})]},o.key))})]})}const AO="_container_10efq_1",DO="_header_10efq_7",RO="_list_10efq_105",MO="_card_10efq_111",IO="_cardHeader_10efq_125",OO="_cardTitle_10efq_135",BO="_defaultBadge_10efq_141",LO="_cardActions_10efq_155",UO="_description_10efq_160",zO="_meta_10efq_166",PO="_empty_10efq_212",VO="_typeBadge_10efq_362",Ln={container:AO,header:DO,list:RO,card:MO,cardHeader:IO,cardTitle:OO,defaultBadge:BO,cardActions:LO,description:UO,meta:zO,empty:PO,typeBadge:VO};function HO({personas:t,appDefaultPersonaId:s,onDeletePersona:i,onSetAppDefaultPersonaId:o,onNavigateToNew:c,onNavigateToPersona:u}){const[d,m]=y.useState(null),h=d?t.find(v=>v.id===d):void 0,g=async v=>{await i(v),m(null)};return l.jsxs("div",{className:Ln.container,children:[l.jsxs("div",{className:Ln.header,children:[l.jsx("h2",{children:"Personas"}),l.jsx(Os,{variant:"primary",size:"md",onClick:c,"data-testid":"persona-new-button",children:"+ New Persona"})]}),t.length===0?l.jsx("p",{className:Ln.empty,children:"No personas yet. Create one to get started."}):l.jsx("div",{className:Ln.list,children:t.map(v=>{const _=s===v.id,b=v.type==="script";return l.jsxs("div",{className:Ln.card,"data-testid":`persona-card-${v.id}`,onClick:()=>u(v.id),role:"button",tabIndex:0,onKeyDown:S=>{S.currentTarget===S.target&&(S.key==="Enter"||S.key===" ")&&(S.preventDefault(),u(v.id))},children:[l.jsxs("div",{className:Ln.cardHeader,children:[l.jsxs("span",{className:Ln.cardTitle,children:[l.jsx("strong",{children:v.name}),l.jsx("span",{className:Ln.typeBadge,"data-testid":`persona-type-badge-${v.id}`,children:b?"Script":"Agent"}),_&&l.jsx("span",{className:Ln.defaultBadge,"data-testid":`persona-default-badge-${v.id}`,children:"App Default"})]}),l.jsxs("div",{className:Ln.cardActions,onClick:S=>S.stopPropagation(),children:[!_&&l.jsx(Os,{variant:"ghost",size:"sm",onClick:()=>{o(v.id).catch(()=>{})},"data-testid":`persona-set-default-${v.id}`,title:"Set as app default persona",children:"Set Default"}),l.jsx(Os,{variant:"ghost",size:"sm",onClick:()=>u(v.id),children:"Edit"}),l.jsx(Os,{variant:"ghost",size:"sm",onClick:()=>m(v.id),"data-testid":`persona-delete-${v.id}`,children:"Delete"})]})]}),v.description&&l.jsx("p",{className:Ln.description,children:v.description}),l.jsxs("div",{className:Ln.meta,children:[v.runtime&&l.jsxs("span",{children:["Runtime: ",v.runtime]}),v.model&&l.jsxs("span",{children:["Model: ",v.model]}),v.maxTurns>0&&l.jsxs("span",{children:["Max turns: ",v.maxTurns]})]})]},v.id)})}),l.jsx(ii,{isOpen:d!==null,title:"Delete Persona?",description:`"${(h==null?void 0:h.name)??""}" will be permanently removed.`,confirmLabel:"Delete",onConfirm:()=>{d&&g(d).catch(()=>{})},onCancel:()=>m(null)})]})}const $O="_container_uy08i_1",GO="_header_uy08i_7",qO="_count_uy08i_13",FO="_presets_uy08i_18",ZO="_presetButton_uy08i_24",KO="_filterInput_uy08i_41",YO="_groups_uy08i_53",JO="_group_uy08i_53",WO="_groupHeader_uy08i_68",XO="_groupName_uy08i_77",QO="_groupCount_uy08i_81",e4="_toolList_uy08i_87",t4="_toolItem_uy08i_95",n4="_toolName_uy08i_103",tn={container:$O,header:GO,count:qO,presets:FO,presetButton:ZO,filterInput:KO,groups:YO,group:JO,groupHeader:WO,groupName:XO,groupCount:QO,toolList:e4,toolItem:t4,toolName:n4},s4=(()=>{const t=new Map;for(const s of _b){const i=s==="get_version_status"?"version":s.split("_")[0];t.has(i)||t.set(i,[]),t.get(i).push(s)}return[...t.entries()].sort(([s],[i])=>s.localeCompare(i)).map(([s,i])=>({group:s,tools:i.sort()}))})(),a4=[{name:"default",label:"Default",tools:xb},{name:"worker",label:"Worker",tools:xT},{name:"orchestrator",label:"Orchestrator",tools:ST},{name:"admin",label:"Admin",tools:TT}];function tb({selectedTools:t,onChange:s,disabled:i}){const[o,c]=y.useState(""),u=y.useMemo(()=>new Set(t),[t]),d=y.useCallback(v=>{if(i)return;const _=new Set(u);_.has(v)?_.delete(v):_.add(v),s([..._].sort())},[u,s,i]),m=y.useCallback((v,_)=>{if(i)return;const b=new Set(u);for(const S of v)_?b.delete(S):b.add(S);s([...b].sort())},[u,s,i]),h=y.useCallback(v=>{i||s([...v].sort())},[s,i]),g=o.toLowerCase();return l.jsxs("div",{className:tn.container,"data-testid":"mcp-tool-selector",children:[l.jsx("div",{className:tn.header,children:l.jsx("span",{className:tn.count,children:t.length===0?`Using default (${xb.length} tools)`:`${t.length} of ${_b.size} tools selected`})}),l.jsxs("div",{className:tn.presets,"data-testid":"mcp-tool-presets",children:[a4.map(v=>l.jsx("button",{type:"button",className:tn.presetButton,disabled:i,onClick:()=>h(v.tools),"data-testid":`preset-${v.name}`,children:v.label},v.name)),l.jsx("button",{type:"button",className:tn.presetButton,disabled:i,onClick:()=>s([]),"data-testid":"preset-clear",children:"Clear"})]}),l.jsx("input",{type:"text",className:tn.filterInput,placeholder:"Filter tools...",value:o,onChange:v=>c(v.target.value),disabled:i,"data-testid":"mcp-tool-filter"}),l.jsx("div",{className:tn.groups,children:s4.map(({group:v,tools:_})=>{const b=g?_.filter(T=>T.toLowerCase().includes(g)):_;if(b.length===0)return null;const S=b.every(T=>u.has(T));return l.jsxs("div",{className:tn.group,"data-testid":`tool-group-${v}`,children:[l.jsxs("label",{className:tn.groupHeader,children:[l.jsx("input",{type:"checkbox",checked:S,onChange:()=>m(b,S),disabled:i,"data-testid":`group-toggle-${v}`}),l.jsx("span",{className:tn.groupName,children:v}),l.jsxs("span",{className:tn.groupCount,children:["(",b.filter(T=>u.has(T)).length,"/",b.length,")"]})]}),l.jsx("div",{className:tn.toolList,children:b.map(T=>l.jsxs("label",{className:tn.toolItem,children:[l.jsx("input",{type:"checkbox",checked:u.has(T),onChange:()=>d(T),disabled:i,"data-testid":`tool-${T}`}),l.jsx("span",{className:tn.toolName,children:T})]},T))})]},v)})})]})}const i4="_nav_1bhou_1",o4="_tab_1bhou_24",r4="_tabIcon_1bhou_62",l4="_tabActive_1bhou_68",fc={nav:i4,tab:o4,tabIcon:r4,tabActive:l4},Is=[{path:"credentials",label:"Credentials",icon:"🔑"},{path:"personas",label:"Personas",icon:"👤"},{path:"appearance",label:"Appearance",icon:"🎨"},{path:"shortcuts",label:"Shortcuts",icon:"⌨️"},{path:"about",label:"About",icon:"ℹ️"}];function c4(){var d;const t=Ut(),s=vt(),i=y.useRef(null),o=((d=Is.find(m=>{const h=`${so}/${m.path}`;return t.pathname===h||t.pathname.startsWith(`${h}/`)}))==null?void 0:d.path)??Is[0].path,c=y.useCallback(m=>{s(`${so}/${m}`)},[s]),u=y.useCallback(m=>{var S,T;const h=(S=i.current)==null?void 0:S.querySelectorAll('[role="tab"]');if(!h)return;const g=Array.from(h).findIndex(N=>N===document.activeElement),v=g>=0?g:Is.findIndex(N=>N.path===o);let _=v;if(m.key==="ArrowDown"||m.key==="j"||m.key==="J")m.preventDefault(),_=(v+1)%Is.length;else if(m.key==="ArrowUp"||m.key==="k"||m.key==="K")m.preventDefault(),_=(v-1+Is.length)%Is.length;else if(m.key==="Home")m.preventDefault(),_=0;else if(m.key==="End")m.preventDefault(),_=Is.length-1;else return;const b=Is[_].path;s(`${so}/${b}`),(T=h[_])==null||T.focus()},[o,s]);return l.jsx("nav",{className:fc.nav,ref:i,role:"tablist","aria-orientation":"vertical","aria-label":"Settings",onKeyDown:u,children:Is.map(m=>{const h=m.path===o;return l.jsxs("button",{role:"tab",type:"button","aria-selected":h,tabIndex:h?0:-1,className:`${fc.tab} ${h?fc.tabActive:""}`,onClick:()=>c(m.path),children:[l.jsx("span",{className:fc.tabIcon,"aria-hidden":"true",children:m.icon}),m.label]},m.path)})})}function u4({tasks:t,taskStatusById:s,sessionStatusByTaskId:i}){const o=new Map;for(const u of t)if(u.parentTaskId){const d=o.get(u.parentTaskId);d?d.push(u):o.set(u.parentTaskId,[u])}const c=new Map(S0.map(u=>[u,[]]));for(const u of t){const d=Tp(u.status),m=u.dependsOn.length>0&&u.dependsOn.some(T=>s.get(T)!=="complete"),h=o.get(u.id)??[],g=h.length,v=h.filter(T=>T.status==="complete").length;let _;if(d==="paused"&&i){const T=i.get(u.id);T==="idle"?_="Needs input":T==="completed"&&(_="Ready to complete")}const b={task:u,isBlocked:m,childCount:g,doneChildCount:v,pausedSubBadge:_},S=c.get(d);S?S.push(b):c.get("not_started").push(b)}for(const u of c.values())u.sort((d,m)=>d.task.sortOrder-m.task.sortOrder);return S0.map(u=>{const d=Sa(u);return{status:u,label:d.label,style:d,tasks:c.get(u)??[]}})}const d4="_boardContainer_1c4y1_1",f4="_column_1c4y1_17",p4="_columnHeader_1c4y1_34",m4="_columnIcon_1c4y1_47",h4="_columnLabel_1c4y1_52",g4="_columnCount_1c4y1_57",v4="_cardList_1c4y1_67",y4="_emptyPlaceholder_1c4y1_76",b4="_card_1c4y1_67",_4="_cardHeader_1c4y1_107",x4="_cardStatusIcon_1c4y1_113",S4="_cardTitle_1c4y1_119",T4="_cardBadges_1c4y1_127",k4="_badge_1c4y1_134",w4="_blockedBadge_1c4y1_146",N4="_childBadge_1c4y1_151",j4="_depBadge_1c4y1_155",C4="_parentBadge_1c4y1_159",E4="_pausedSubBadge_1c4y1_166",A4="_personaBadge_1c4y1_170",D4="_envBadge_1c4y1_174",R4="_emptyCta_1c4y1_178",M4="_ctaButton_1c4y1_188",I4="_ctaDescription_1c4y1_204",tt={boardContainer:d4,column:f4,columnHeader:p4,columnIcon:m4,columnLabel:h4,columnCount:g4,cardList:v4,emptyPlaceholder:y4,card:b4,cardHeader:_4,cardStatusIcon:x4,cardTitle:S4,cardBadges:T4,badge:k4,blockedBadge:w4,childBadge:N4,depBadge:j4,parentBadge:C4,pausedSubBadge:E4,personaBadge:A4,envBadge:D4,emptyCta:R4,ctaButton:M4,ctaDescription:I4};function O4({workspaceId:t,environmentId:s,tasks:i,sessions:o,personas:c,environments:u}){const d=vt(),m=y.useMemo(()=>i.filter(b=>b.workspaceId===t),[i,t]),h=y.useMemo(()=>new Map(i.map(b=>[b.id,b.status])),[i]),g=y.useMemo(()=>new Map(m.map(b=>[b.id,b])),[m]),v=y.useMemo(()=>{const b=new Map(o.map(C=>[C.id,C])),S=new Map(c.map(C=>[C.id,C])),T=new Map(u.map(C=>[C.id,C])),N=new Map,j=new Map,w=new Map;for(const C of m)if(C.latestSessionId){const A=b.get(C.latestSessionId);if(A){if(N.set(C.id,A.endReason||A.status),A.personaId){const M=S.get(A.personaId);M&&j.set(C.id,M.name)}if(A.environmentId){const M=T.get(A.environmentId);M&&w.set(C.id,M.displayName)}}}return{sessionStatusByTaskId:N,personaNameByTaskId:j,environmentNameByTaskId:w}},[m,o,c,u]),_=y.useMemo(()=>u4({tasks:m,taskStatusById:h,sessionStatusByTaskId:v.sessionStatusByTaskId}),[m,h,v]);return m.length===0?l.jsxs("div",{className:tt.emptyCta,"data-testid":"board-empty-cta",children:[l.jsx("button",{className:tt.ctaButton,onClick:()=>d(ri(t,void 0,s)),children:"Create Task"}),l.jsx("div",{className:tt.ctaDescription,children:"Break your work into tasks and let agents tackle them"})]}):l.jsx("div",{className:tt.boardContainer,"data-testid":"board-container",children:_.map(b=>l.jsxs("section",{className:tt.column,"data-testid":`board-column-${b.status}`,"aria-label":`${b.label}, ${b.tasks.length} ${b.tasks.length===1?"task":"tasks"}`,children:[l.jsxs("div",{className:tt.columnHeader,children:[l.jsx("span",{className:tt.columnIcon,style:{color:b.style.color},children:b.style.icon}),l.jsx("span",{className:tt.columnLabel,children:b.label}),l.jsx("span",{className:tt.columnCount,"data-testid":`board-count-${b.status}`,children:b.tasks.length})]}),l.jsx("div",{className:tt.cardList,children:b.tasks.length===0?l.jsx("div",{className:tt.emptyPlaceholder,children:"No tasks"}):l.jsx(ds,{mode:"popLayout",children:b.tasks.map(S=>l.jsx(Dt.div,{layout:!0,initial:{opacity:0,y:4},animate:{opacity:1,y:0},exit:{opacity:0,y:-4},transition:{duration:.15},children:l.jsx(B4,{boardTask:S,tasksById:g,personaName:v.personaNameByTaskId.get(S.task.id),envName:v.environmentNameByTaskId.get(S.task.id),onClick:()=>d(Xn(S.task.id,void 0,t,s))})},S.task.id))})})]},b.status))})}function B4({boardTask:t,tasksById:s,personaName:i,envName:o,onClick:c}){const{task:u,isBlocked:d,childCount:m,doneChildCount:h,pausedSubBadge:g}=t,v=Sa(u.status),_=u.parentTaskId?s.get(u.parentTaskId):void 0;return l.jsxs("div",{className:tt.card,tabIndex:0,role:"button","data-testid":`board-card-${u.id}`,onClick:c,onKeyDown:b=>{(b.key==="Enter"||b.key===" ")&&(b.preventDefault(),c())},children:[l.jsxs("div",{className:tt.cardHeader,children:[l.jsx("span",{className:tt.cardStatusIcon,style:{color:v.color},children:v.icon}),l.jsx("span",{className:tt.cardTitle,children:u.title})]}),l.jsxs("div",{className:tt.cardBadges,children:[_&&l.jsx("span",{className:`${tt.badge} ${tt.parentBadge}`,title:_.title,children:_.title}),m>0&&l.jsxs("span",{className:`${tt.badge} ${tt.childBadge}`,children:[h,"/",m]}),d&&l.jsx("span",{className:`${tt.badge} ${tt.blockedBadge}`,children:"blocked"}),u.dependsOn.length>0&&!d&&l.jsx("span",{className:`${tt.badge} ${tt.depBadge}`,children:"dep"}),g&&l.jsx("span",{className:`${tt.badge} ${tt.pausedSubBadge}`,children:g}),i&&l.jsx("span",{className:`${tt.badge} ${tt.personaBadge}`,children:i}),o&&l.jsx("span",{className:`${tt.badge} ${tt.envBadge}`,children:o})]})]})}const L4="_formContent_ymnez_1",U4="_section_ymnez_13",z4="_label_ymnez_19",P4="_titleInput_ymnez_26",V4="_descriptionTextarea_ymnez_58",H4="_selectField_ymnez_94",$4="_checkboxRow_ymnez_128",G4="_checkboxLabel_ymnez_141",q4="_fieldError_ymnez_146",mt={formContent:L4,section:U4,label:z4,titleInput:P4,descriptionTextarea:V4,selectField:H4,checkboxRow:$4,checkboxLabel:G4,fieldError:q4};function F4(t,s){return{name:(t==null?void 0:t.name)??"",description:(t==null?void 0:t.description)??"",repoUrl:(t==null?void 0:t.repoUrl)??"",environmentId:(t==null?void 0:t.environmentId)??s??"",defaultPersonaId:(t==null?void 0:t.defaultPersonaId)??"",useWorktrees:(t==null?void 0:t.useWorktrees)??!0,workingDirectory:(t==null?void 0:t.workingDirectory)??""}}const Z4=100;function K4({values:t,onChange:s,environments:i,personas:o,errors:c,disabled:u,autoFocusName:d}){const m=(h,g)=>{s({...t,[h]:g})};return l.jsxs("div",{className:mt.formContent,children:[l.jsxs("div",{className:mt.section,children:[l.jsx("label",{className:mt.label,htmlFor:"ws-name",children:"Name"}),l.jsx("input",{id:"ws-name",className:mt.titleInput,type:"text",value:t.name,onChange:h=>m("name",h.target.value),placeholder:"Workspace name",maxLength:Z4,autoFocus:d,disabled:u,"data-testid":"workspace-form-name"}),(c==null?void 0:c.name)&&l.jsx("span",{className:mt.fieldError,"data-testid":"workspace-form-error-name",children:c.name})]}),l.jsxs("div",{className:mt.section,children:[l.jsx("label",{className:mt.label,htmlFor:"ws-description",children:"Description"}),l.jsx("textarea",{id:"ws-description",className:mt.descriptionTextarea,value:t.description,onChange:h=>m("description",h.target.value),placeholder:"Optional description (Markdown supported)",disabled:u,"data-testid":"workspace-form-description"})]}),l.jsxs("div",{className:mt.section,children:[l.jsx("label",{className:mt.label,htmlFor:"ws-repo",children:"Repository URL"}),l.jsx("input",{id:"ws-repo",className:mt.titleInput,type:"text",value:t.repoUrl,onChange:h=>m("repoUrl",h.target.value),placeholder:"https://github.com/org/repo",disabled:u,"data-testid":"workspace-form-repo"}),(c==null?void 0:c.repoUrl)&&l.jsx("span",{className:mt.fieldError,"data-testid":"workspace-form-error-repoUrl",children:c.repoUrl})]}),l.jsxs("div",{className:mt.section,children:[l.jsx("label",{className:mt.label,htmlFor:"ws-environment",children:"Environment"}),l.jsxs("select",{id:"ws-environment",className:mt.selectField,value:t.environmentId,onChange:h=>m("environmentId",h.target.value),disabled:u,"data-testid":"workspace-form-environment",children:[l.jsx("option",{value:"",children:"Select environment…"}),i.map(h=>l.jsx("option",{value:h.id,children:h.displayName||h.id},h.id))]}),(c==null?void 0:c.environmentId)&&l.jsx("span",{className:mt.fieldError,"data-testid":"workspace-form-error-environmentId",children:c.environmentId})]}),l.jsxs("div",{className:mt.section,children:[l.jsx("label",{className:mt.label,htmlFor:"ws-persona",children:"Default Persona"}),l.jsxs("select",{id:"ws-persona",className:mt.selectField,value:t.defaultPersonaId,onChange:h=>m("defaultPersonaId",h.target.value),disabled:u,"data-testid":"workspace-form-persona",children:[l.jsx("option",{value:"",children:"(Inherit)"}),o.map(h=>l.jsx("option",{value:h.id,children:h.name},h.id))]})]}),l.jsx("div",{className:mt.section,children:l.jsxs("label",{className:mt.checkboxRow,children:[l.jsx("input",{type:"checkbox",checked:t.useWorktrees,onChange:h=>m("useWorktrees",h.target.checked),disabled:u,"data-testid":"workspace-form-worktrees"}),l.jsx("span",{className:mt.checkboxLabel,children:"Enable worktree isolation"})]})}),l.jsxs("div",{className:mt.section,children:[l.jsx("label",{className:mt.label,htmlFor:"ws-workdir",children:"Working Directory"}),l.jsx("input",{id:"ws-workdir",className:mt.titleInput,type:"text",value:t.workingDirectory,onChange:h=>m("workingDirectory",h.target.value),placeholder:"Default (server default)",disabled:u,"data-testid":"workspace-form-workdir"})]})]})}const Lx=y.createContext(void 0),Y4=4e3;function J4({children:t}){const[s,i]=y.useState([]),o=y.useRef(0),c=y.useCallback(d=>{i(m=>m.filter(h=>h.id!==d))},[]),u=y.useCallback((d,m="info",h=Y4)=>{const g=`toast-${++o.current}`;i(v=>[...v,{id:g,message:d,variant:m,duration:h}])},[]);return l.jsx(Lx.Provider,{value:{toasts:s,showToast:u,dismissToast:c},children:t})}function dn(){const t=y.useContext(Lx);if(!t)throw new Error("useToast must be used within ToastProvider");return t}const bp="grackle-theme",Ux="grackle-prefer-system",zx="(prefers-color-scheme: dark)";let gr=[],Nc;function Pf(){Nc=void 0;for(const t of gr)t()}function _p(){return typeof window>"u"?!1:window.matchMedia(zx).matches}function Sr(){if(typeof localStorage>"u")return eb;try{const t=localStorage.getItem(bp);if(t!==null&&Ix.has(t))return t}catch{}return eb}function Uc(){if(typeof localStorage>"u")return!1;try{return localStorage.getItem(Ux)==="true"}catch{return!1}}function xp(t){return Qc.find(s=>s.variantLightId===t||s.variantDarkId===t)}function Px(t,s){const i=yp(t);if(i!=null&&i.variantDarkId)return s&&i.variantLightId?_p()?i.variantDarkId:i.variantLightId:i.variantDarkId;if(i!=null&&i.hidden&&s){const o=xp(t);if(o!=null&&o.variantLightId&&o.variantDarkId)return _p()?o.variantDarkId:o.variantLightId}return t}function Ji(t,s,i=!1){i&&document.documentElement.classList.add("no-transitions"),document.documentElement.dataset.theme=Px(t,s),i&&(document.documentElement.offsetHeight,requestAnimationFrame(()=>{document.documentElement.classList.remove("no-transitions")}))}typeof document<"u"&&Ji(Sr(),Uc());function W4(){return Nc===void 0&&(Nc={themeId:Sr(),systemDark:_p(),preferSystem:Uc()}),Nc}function X4(t){return gr=[...gr,t],()=>{gr=gr.filter(s=>s!==t)}}function Q4(){const t=y.useSyncExternalStore(X4,W4),{themeId:s,preferSystem:i}=t,o=Px(s,i),c=y.useCallback(d=>{if(Ix.has(d)){try{localStorage.setItem(bp,d)}catch{}Ji(d,Uc(),!0),Pf()}},[]),u=y.useCallback(d=>{try{localStorage.setItem(Ux,d?"true":"false")}catch{}if(d){const m=Sr(),h=yp(m);if(h!=null&&h.hidden){const g=xp(m);if(g)try{localStorage.setItem(bp,g.id)}catch{}}}Ji(Sr(),d,!0),Pf()},[]);return y.useEffect(()=>{Ji(s,i)},[s,i]),y.useEffect(()=>{if(typeof window>"u")return;const d=window.matchMedia(zx),m=()=>{const h=Sr(),g=Uc();if(g){const v=yp(h);if(v!=null&&v.variantDarkId&&v.variantLightId&&Ji(h,g),v!=null&&v.hidden){const _=xp(h);_!=null&&_.variantDarkId&&_.variantLightId&&Ji(h,g)}}Pf()};return d.addEventListener("change",m),()=>{d.removeEventListener("change",m)}},[]),{themeId:s,setTheme:c,resolvedThemeId:o,preferSystem:i,setPreferSystem:u}}const Vx=y.createContext(void 0);function eB({children:t}){const s=Q4();return l.jsx(Vx.Provider,{value:s,children:t})}function Hx(){const t=y.useContext(Vx);if(!t)throw new Error("useThemeContext must be used within ThemeProvider");return t}const $x=y.createContext(void 0),Gx=y.createContext(void 0);function tB({children:t}){const[s,i]=y.useState(void 0),o=y.useCallback(c=>{i(c)},[]);return l.jsx(Gx.Provider,{value:o,children:l.jsx($x.Provider,{value:s,children:t})})}function nB(){return y.useContext($x)}function sB(){const t=y.useContext(Gx);if(t===void 0)throw new Error("useSidebarSetter must be used within a SidebarProvider");return t}const vm=y.createContext(void 0);function rt(){const t=y.useContext(vm);if(!t)throw new Error("useGrackle must be used within GrackleProvider");return t}function qx(t){return typeof t=="object"&&t!==null&&!Array.isArray(t)}function Fx(t,s){return console.warn(`[ws] Malformed "${t}" message: ${s}`),!1}function aB(t){return qx(t)&&typeof t.sessionId=="string"&&typeof t.eventType=="string"&&typeof t.timestamp=="string"&&typeof t.content=="string"&&(t.raw===void 0||typeof t.raw=="string")}const iB=new Set(["off","subscription","api_key"]),pc=new Set(["off","on"]);function oB(t){return qx(t)&&iB.has(t.claude)&&pc.has(t.github)&&pc.has(t.copilot)&&pc.has(t.codex)&&pc.has(t.goose)}function Zx(t){switch(t){case"waiting_input":return"idle";case"completed":return"stopped";case"killed":return"stopped";case"failed":return"stopped";case"interrupted":return"stopped";case"terminated":return"stopped";default:return t}}function Kx(t){switch(t){case"completed":return"completed";case"killed":return"killed";case"failed":return"interrupted";case"interrupted":return"interrupted";case"terminated":return"terminated";default:return}}const Yi=5e3;function rB(t,s){const i=[];let o=t;const c=new Set;for(;o&&s.has(o)&&!c.has(o);){c.add(o);const u=s.get(o);i.unshift(u),o=u.parentTaskId||void 0}return i}const Vs={label:"Home",url:ai};function lB(t){return t?[Vs,{label:"Settings",url:so},{label:t,url:void 0}]:[Vs,{label:"Settings",url:void 0}]}const ym={label:"Environments",url:ao};function cB(){return[Vs,{label:"Environments",url:void 0}]}function uB(){return[Vs,{label:"New Chat",url:void 0}]}function dB(t){return[Vs,{label:`Session ${t.slice(0,8)}`,url:void 0}]}function fB(t,s,i,o){const c=i.find(d=>d.id===t),u=o.find(d=>d.id===s);return[Vs,ym,{label:(u==null?void 0:u.displayName)??"Environment",url:si(s)},{label:(c==null?void 0:c.name)??"Workspace",url:void 0}]}function pB(t,s,i,o,c){const u=rB(t,c),d=c.get(t),m=d==null?void 0:d.workspaceId,h=m?i.find(S=>S.id===m):void 0,g=s??(h==null?void 0:h.environmentId),v=g?o.find(S=>S.id===g):void 0,_=[Vs];v&&g&&(_.push(ym),_.push({label:v.displayName,url:si(g)})),h&&g&&_.push({label:h.name,url:ni(h.id,g)});for(let S=0;S<u.length-1;S++)_.push({label:u[S].title,url:Xn(u[S].id,void 0,m,g)});const b=u[u.length-1];return _.push({label:(b==null?void 0:b.title)??t,url:void 0}),_}const mB={label:"Findings",url:Fc};function hB(){return[Vs,{label:"Findings",url:void 0}]}function Yx(t,s,i,o,c){const u=[Vs];if(s&&i){const d=o.find(h=>h.id===s),m=c.find(h=>h.id===i);u.push(ym),m&&u.push({label:m.displayName,url:si(i)}),d&&u.push({label:d.name,url:ni(s,i)}),u.push({label:"Findings",url:l2(s,i)})}else u.push(mB);return u.push({label:t,url:void 0}),u}function bm(t){const s=[];for(const i of t){const o=s[s.length-1];i.eventType==="text"&&(o==null?void 0:o.eventType)==="text"?s[s.length-1]={...o,content:o.content+i.content}:s.push(i)}return s}function _m(t){const s=new Map;for(const u of t)if(u.raw)try{s.set(u,JSON.parse(u.raw))}catch{}const i=new Map;for(const u of t){if(u.eventType!=="tool_use")continue;const d=s.get(u);if(!(!d||typeof d.id!="string"))try{const m=JSON.parse(u.content);i.set(d.id,{tool:m.tool,args:m.args})}catch{}}const o=new Set;return t.map(u=>{if(u.eventType!=="tool_result")return u;const d=s.get(u);if(!d||typeof d.tool_use_id!="string")return u;const m=i.get(d.tool_use_id);if(!m)return u;o.add(d.tool_use_id);let h;const g=u.content.trim();if(g.startsWith("{"))try{const v=JSON.parse(g);typeof v.detailedContent=="string"&&(h=v.detailedContent)}catch{}return{...u,toolUseCtx:{...m,detailedResult:h}}}).filter(u=>{if(u.eventType!=="tool_use")return!0;const d=s.get(u);return d&&typeof d.id=="string"?!o.has(d.id):!0})}function gB(t,s,i){const o=t.filter(h=>h.status==="running"||h.status==="idle"||h.status==="waiting").length,c=Jx(s),u=s.filter(h=>Sp(h,c)).length,d=s.filter(h=>h.status==="paused"||h.status==="failed"||Sp(h,c)).length,m=i.filter(h=>h.status==="disconnected"||h.status==="error").length;return{activeSessions:o,blockedTasks:u,attentionTasks:d,unhealthyEnvironments:m}}function Jx(t){const s=new Map;for(const i of t)s.set(i.id,i.status);return s}function Sp(t,s){return t.dependsOn.some(i=>s.get(i)!=="complete")}function vB(t,s){var d;const i=new Map;for(const m of s)i.set(m.id,m);const o=Jx(t),c=[];for(const m of t){const h=m.workspaceId?((d=i.get(m.workspaceId))==null?void 0:d.name)??"Unknown":"Unknown";m.status==="failed"?c.push({task:m,reason:"failed",workspaceName:h}):Sp(m,o)?c.push({task:m,reason:"blocked",workspaceName:h}):m.status==="paused"&&c.push({task:m,reason:"paused",workspaceName:h})}const u={failed:0,blocked:1,paused:2};return c.sort((m,h)=>(u[m.reason]??3)-(u[h.reason]??3)),c}function yB(t,s){const i=new Map;for(const o of s)i.set(o.id,o);return t.filter(o=>o.status==="running"||o.status==="idle"||o.status==="waiting").map(o=>{var c;return{session:o,environmentName:((c=i.get(o.environmentId))==null?void 0:c.displayName)??"Unknown"}})}function bB(t,s,i){const o=new Map;for(const c of s){if(!c.workspaceId)continue;let u=o.get(c.workspaceId);u||(u={totalTasks:0,completedTasks:0,workingTasks:0,failedTasks:0},o.set(c.workspaceId,u)),u.totalTasks+=1,c.status==="complete"?u.completedTasks+=1:c.status==="working"?u.workingTasks+=1:c.status==="failed"&&(u.failedTasks+=1)}return t.map(c=>{const u=o.get(c.id)??{totalTasks:0,completedTasks:0,workingTasks:0,failedTasks:0};return{workspace:c,totalTasks:u.totalTasks,completedTasks:u.completedTasks,workingTasks:u.workingTasks,failedTasks:u.failedTasks}})}const rs=[{id:"kn-auth-flow",label:"Authentication Flow",kind:"knowledge",category:"concept",content:"The application uses JWT Bearer tokens for stateless authentication. Access tokens expire after 24h. Refresh tokens are stored in the database and rotated on use. The auth middleware verifies tokens and attaches the decoded payload to req.user.",tags:["auth","jwt","security"],workspaceId:"proj-alpha",createdAt:"2026-02-25T10:30:00Z",updatedAt:"2026-02-27T08:15:00Z",val:5},{id:"kn-db-schema",label:"Database Schema",kind:"knowledge",category:"concept",content:"PostgreSQL database with tables: users, sessions, refresh_tokens, audit_log. Uses UUID primary keys, TIMESTAMPTZ for all timestamps, and JSONB for flexible metadata columns. Connection pooling via pg-pool with per-tenant isolation.",tags:["database","postgres","schema"],workspaceId:"proj-alpha",createdAt:"2026-02-23T11:00:00Z",updatedAt:"2026-02-26T22:45:00Z",val:4},{id:"kn-error-handling",label:"Error Response Pattern",kind:"knowledge",category:"concept",content:"All API errors follow the shape { error: string, code: string, details?: unknown }. HTTP status codes map to: 400 (validation), 401 (unauthenticated), 403 (forbidden), 404 (not found), 409 (conflict), 429 (rate limited), 500 (internal).",tags:["api","errors","patterns"],workspaceId:"proj-alpha",createdAt:"2026-02-27T08:17:00Z",updatedAt:"2026-02-27T08:17:00Z",val:3},{id:"kn-rate-limiting",label:"Rate Limiting Strategy",kind:"knowledge",category:"concept",content:"Token-bucket algorithm with in-memory state per client IP. Default rate: 100 requests/minute, burst: 20. Returns 429 with Retry-After header. Redis adapter available for multi-instance deployments.",tags:["api","rate-limiting","infrastructure"],workspaceId:"proj-alpha",createdAt:"2026-02-27T09:00:00Z",updatedAt:"2026-02-27T09:00:00Z",val:2},{id:"kn-etl-pipeline",label:"ETL Pipeline Architecture",kind:"knowledge",category:"concept",content:"Data pipelines follow an Extract-Transform-Load pattern with pluggable stages. Each stage reads from a source (Postgres, S3, API), transforms via configurable mappers, and loads into a target (Parquet, BigQuery, S3). Incremental loads use high-watermark tracking.",tags:["etl","pipeline","architecture"],workspaceId:"proj-beta",createdAt:"2026-02-26T08:00:00Z",updatedAt:"2026-02-27T09:05:00Z",val:4},{id:"kn-parquet-format",label:"Parquet Output Format",kind:"knowledge",category:"concept",content:"Parquet files are written with row-group buffering (configurable batch size, default 10000 rows). Supports Snappy, ZSTD, and GZIP compression. Schema is derived from the internal column type system using Arrow type mapping.",tags:["parquet","data-format","compression"],workspaceId:"proj-beta",createdAt:"2026-02-26T08:05:00Z",updatedAt:"2026-02-26T08:15:00Z",val:3},{id:"kn-jwt-over-session",label:"JWT over Session Auth",kind:"knowledge",category:"decision",content:"Chose JWT tokens over server-side sessions for stateless auth. Rationale: (1) no session store needed, (2) works across microservices without shared state, (3) supports mobile clients natively. Trade-off: tokens can't be revoked instantly (mitigated by short expiry + refresh rotation).",tags:["auth","decision","jwt"],workspaceId:"proj-alpha",createdAt:"2026-02-25T10:00:00Z",updatedAt:"2026-02-25T10:00:00Z",val:3},{id:"kn-pg-pool-decision",label:"pg-pool over Knex",kind:"knowledge",category:"decision",content:"Chose pg-pool over Knex for connection pooling. pg-pool gives direct control over idle timeout, max connections, and health check queries. Knex wraps pg-pool and adds query-building overhead we don't need since we write raw SQL with parameterized queries.",tags:["database","decision","postgres"],workspaceId:"proj-alpha",createdAt:"2026-02-23T11:30:00Z",updatedAt:"2026-02-23T11:30:00Z",val:2},{id:"kn-watermark-decision",label:"Local Watermark Storage",kind:"knowledge",category:"decision",content:"Currently using local SQLite for watermark storage. This works for single-worker pipelines but needs to move to a shared store (Redis or Postgres) for production multi-worker scenarios. Tracked as a follow-up task.",tags:["pipeline","decision","watermarks"],workspaceId:"proj-beta",createdAt:"2026-02-27T09:05:00Z",updatedAt:"2026-02-27T09:05:00Z",val:2},{id:"kn-jwt-middleware",label:"JWT Verify Middleware",kind:"knowledge",category:"snippet",content:`\`\`\`typescript
63
63
  export function verifyToken(req: Request, res: Response, next: NextFunction): void {
64
64
  const header = req.headers.authorization;
65
65
  if (!header?.startsWith("Bearer ")) {
@@ -486,7 +486,7 @@ export function verifyToken(req: Request, res: Response, next: NextFunction): vo
486
486
 
487
487
  Tests: 3 passed, 3 total
488
488
  Time: 1.234s`,raw:JSON.stringify({tool_use_id:"tool-mock-003",is_error:!1})}},{delayMs:6400,event:{eventType:"tool_use",timestamp:je(6400),content:JSON.stringify({tool:"Grep",args:{pattern:"decoded\\.exp",path:"src/"}}),raw:JSON.stringify({id:"tool-mock-004"})}},{delayMs:7e3,event:{eventType:"tool_result",timestamp:je(7e3),content:`src/middleware/auth.ts:14: if (decoded.exp < Date.now() / 1000) {
489
- src/utils/token-refresh.ts:28: const remaining = decoded.exp - Date.now() / 1000;`,raw:JSON.stringify({tool_use_id:"tool-mock-004",is_error:!1})}},{delayMs:7800,event:{eventType:"text",timestamp:je(7800),content:"Fixed. The token expiry comparison was inverted — `decoded.exp > Date.now()` should have been `<` (a token is expired when its `exp` is in the past). The other occurrence in `token-refresh.ts` uses subtraction (not comparison), so it was already correct. All 3 auth tests pass."}},{delayMs:8400,event:{eventType:"usage",timestamp:je(8400),content:JSON.stringify({input_tokens:42600,output_tokens:1850,cost_usd:.12})}},{delayMs:8800,event:{eventType:"status",timestamp:je(8800),content:"completed"}}]}],ab=400;function EB({children:t}){const[s,i]=y.useState(xB),[o,c]=y.useState(SB),[u,d]=y.useState(TB),[m,h]=y.useState(void 0),[g,v]=y.useState(kB),[_,b]=y.useState(wB),[S,T]=y.useState(mc),[N,j]=y.useState(void 0),w=!1,[C,A]=y.useState(NB),[M,D]=y.useState({claude:"off",github:"off",copilot:"off",codex:"off",goose:"off"}),[E,$]=y.useState(jB),[z]=y.useState(CB),[K,F]=y.useState(""),[ee,ae]=y.useState(rs),[me,ie]=y.useState(va),[X,O]=y.useState(void 0),[q,te]=y.useState(void 0),[re,ue]=y.useState(""),Fe=y.useRef(void 0),Ne=y.useRef(0),ke=y.useRef(0),Me=y.useRef(new Set),le=y.useRef(new Map),ve=y.useRef(_);ve.current=_;const de=y.useRef(new Map),Ie=y.useRef(new Map),yt=y.useCallback(P=>(Ne.current+=1,`mock-${P}-${String(Ne.current).padStart(3,"0")}`),[]),fn=y.useCallback(()=>{const P=sb[ke.current%sb.length];return ke.current+=1,P},[]),B=y.useCallback((P,Q,oe)=>{const ce=setTimeout(()=>{var fe;Me.current.delete(ce),oe&&((fe=le.current.get(oe))==null||fe.delete(ce)),P()},Q);Me.current.add(ce),oe&&(le.current.has(oe)||le.current.set(oe,new Set),le.current.get(oe).add(ce))},[]),Re=y.useCallback(P=>{const Q=le.current.get(P);Q&&(Q.forEach(oe=>{clearTimeout(oe),Me.current.delete(oe)}),le.current.delete(P))},[]),Qe=y.useCallback((P,Q,oe)=>{c(ce=>ce.map(fe=>fe.id===P?{...fe,status:Q,...oe!==void 0?{endReason:oe}:{}}:fe))},[]),et=y.useCallback(P=>{d(Q=>[...Q,P])},[]),$e=y.useCallback((P,Q,oe)=>{Q.forEach((ce,fe)=>{B(()=>{const Le={sessionId:P,...ce.event,timestamp:new Date().toISOString()};if(et(Le),ce.event.eventType==="status"){const ye=Zx(ce.event.content),Ce=Kx(ce.event.content);Qe(P,ye,Ce)}fe===Q.length-1&&oe&&oe()},ce.delayMs,P)})},[B,et,Qe]),es=y.useCallback((P,Q,oe,ce)=>{console.log("[MockGrackle] spawn",{environmentId:P,prompt:Q,runtime:ce});const fe=yt("sess"),Le={id:fe,environmentId:P,runtime:ce||"claude-code",status:"running",prompt:Q,startedAt:new Date().toISOString()};c(Ce=>[...Ce,Le]),h(fe);const ye=fn();if(console.log(`[MockGrackle] Playing scenario: ${ye.label}`),ye.pauseForInput){const Ce=ye.pauseAfterStep??ye.steps.length-1,Ge=ye.steps.slice(0,Ce+1),lt=Ge.length>0?Ge[Ge.length-1].delayMs:0;$e(fe,Ge),B(()=>{Qe(fe,"idle"),et({sessionId:fe,eventType:"status",timestamp:new Date().toISOString(),content:"idle"})},lt+ab,fe),ye.resumeSteps&&de.current.set(fe,ye.resumeSteps)}else $e(fe,ye.steps)},[yt,fn,$e,B,Qe,et]),Hs=y.useCallback(P=>{console.log("[MockGrackle] kill",P),Re(P),de.current.delete(P),Qe(P,"stopped","killed"),et({sessionId:P,eventType:"status",timestamp:new Date().toISOString(),content:"killed"}),b(Q=>Q.map(oe=>oe.latestSessionId===P&&oe.status==="working"?{...oe,status:"not_started"}:oe))},[Re,Qe,et]),kn=y.useCallback(P=>{console.log("[MockGrackle] stopGraceful",P),Re(P),de.current.delete(P),Qe(P,"stopped","terminated"),et({sessionId:P,eventType:"status",timestamp:new Date().toISOString(),content:"terminated"}),b(Q=>Q.map(oe=>oe.latestSessionId===P&&oe.status==="working"?{...oe,status:"not_started"}:oe))},[Re,Qe,et]),Vn=y.useCallback(()=>{console.log("[MockGrackle] refresh")},[]),ts=y.useCallback(P=>{console.log("[MockGrackle] loadSessionEvents",P)},[]),$s=y.useCallback(()=>{console.log("[MockGrackle] clearEvents"),d([])},[]),Hn=y.useCallback((P,Q,oe,ce,fe,Le,ye,Ce,Ge)=>{console.log("[MockGrackle] createWorkspace",{name:P,description:Q});const lt={id:yt("proj"),name:P,description:Q||"",repoUrl:oe||"",environmentId:ce||"",status:"active",workingDirectory:ye||"",useWorktrees:Le??!0,defaultPersonaId:fe||"",createdAt:new Date().toISOString(),updatedAt:new Date().toISOString()};v(qe=>[...qe,lt]),Ce&&Ce()},[yt]),Ae=y.useCallback(P=>{console.log("[MockGrackle] archiveWorkspace",P),v(Q=>Q.map(oe=>oe.id===P?{...oe,status:"archived"}:oe))},[]),We=y.useCallback(P=>{console.log("[MockGrackle] loadTasks",P)},[]),zr=y.useCallback((P,Q,oe,ce,fe,Le,ye,Ce,Ge)=>{console.log("[MockGrackle] createTask",{workspaceId:P,title:Q,parentTaskId:fe}),b(lt=>{const Bt=lt.filter(dt=>dt.workspaceId===P).reduce((dt,zt)=>Math.max(dt,zt.sortOrder),0),Ht=fe?lt.find(dt=>dt.id===fe):void 0;if(fe&&!Ht)return console.warn("[MockGrackle] Parent task not found:",fe),lt;if(Ht&&!Ht.canDecompose)return console.warn("[MockGrackle] Parent task does not have decomposition rights:",fe),lt;const jt=Ht?Ht.depth+1:0,Qt={id:yt("task"),workspaceId:P,title:Q,description:oe||"",status:"not_started",branch:"",latestSessionId:"",dependsOn:ce||[],reviewNotes:void 0,sortOrder:Bt+1,createdAt:new Date().toISOString(),parentTaskId:fe||"",depth:jt,childTaskIds:[],canDecompose:ye??!fe,defaultPersonaId:Le||"",workpad:""};return[...lt,Qt]}),Ce&&Ce()},[yt]),mo=y.useCallback((P,Q,oe,ce)=>{var lt;console.log("[MockGrackle] startTask",{taskId:P});const fe=ve.current.find(qe=>qe.id===P),Le=(fe==null?void 0:fe.title)??"",ye=yt("sess"),Ce={id:ye,environmentId:"env-local-01",runtime:"claude-code",status:"running",prompt:Le||P,startedAt:new Date().toISOString()};c(qe=>[...qe,Ce]),b(qe=>qe.map(Bt=>Bt.id===P?{...Bt,status:"working",latestSessionId:ye,branch:`mock/${P.slice(0,8)}`}:Bt));const Ge=fn();if(console.log(`[MockGrackle] Playing task scenario: ${Ge.label}`),Ge.pauseForInput){const qe=Ge.pauseAfterStep??Ge.steps.length-1,Bt=Ge.steps.slice(0,qe+1),Ht=Bt.length>0?Bt[Bt.length-1].delayMs:0;if($e(ye,Bt),B(()=>{Qe(ye,"idle"),et({sessionId:ye,eventType:"status",timestamp:new Date().toISOString(),content:"idle"})},Ht+ab,ye),Ge.resumeSteps){const jt=[...Ge.resumeSteps];de.current.set(ye,jt);const Qt=jt.reduce((dt,zt)=>Math.max(dt,zt.delayMs),0);Ie.current.set(ye,{taskId:P,delayAfterResume:Qt+200})}}else{const qe=Ge.steps.length>0?Ge.steps[Ge.steps.length-1].delayMs:0;$e(ye,Ge.steps);const Bt=(lt=Ge.steps[Ge.steps.length-1])==null?void 0:lt.event.content;B(()=>{Bt==="completed"?b(Ht=>Ht.map(jt=>jt.id===P&&jt.status==="working"?{...jt,status:"paused"}:jt)):Bt==="failed"&&b(Ht=>Ht.map(jt=>jt.id===P&&jt.status==="working"?{...jt,status:"failed"}:jt))},qe+100,ye)}},[yt,fn,$e,B,Qe,et]),ho=y.useCallback((P,Q)=>{console.log("[MockGrackle] sendInput",{sessionId:P,text:Q}),et({sessionId:P,eventType:"output",timestamp:new Date().toISOString(),content:`User input: ${Q}`}),Qe(P,"running"),et({sessionId:P,eventType:"status",timestamp:new Date().toISOString(),content:"running"});const oe=de.current.get(P);if(oe)de.current.delete(P),$e(P,oe);else{const fe=[{delayMs:500,event:{eventType:"output",timestamp:new Date().toISOString(),content:"I received your input, continuing..."}},{delayMs:1500,event:{eventType:"status",timestamp:new Date().toISOString(),content:"completed"}}];$e(P,fe)}const ce=Ie.current.get(P);ce&&(Ie.current.delete(P),B(()=>{b(fe=>fe.map(Le=>Le.id===ce.taskId&&Le.status==="working"?{...Le,status:"paused"}:Le))},ce.delayAfterResume,P))},[et,Qe,$e,B]),Gs=y.useCallback(P=>{console.log("[MockGrackle] completeTask",P),b(Q=>Q.map(oe=>oe.id===P?{...oe,status:"complete"}:oe))},[]),Pr=y.useCallback(P=>{console.log("[MockGrackle] resumeTask",P)},[]),go=y.useCallback((P,Q,oe,ce,fe)=>{console.log("[MockGrackle] updateTask",{taskId:P,title:Q}),b(Le=>Le.map(ye=>ye.id===P?{...ye,title:Q.trim()||ye.title,description:oe,dependsOn:ce,...fe!==void 0?{defaultPersonaId:fe}:{}}:ye))},[]),Vr=y.useCallback(P=>{console.log("[MockGrackle] deleteTask",P),b(Q=>Q.filter(oe=>oe.id!==P))},[]),Hr=y.useCallback(P=>{console.log("[MockGrackle] loadFindings",P),T(mc.filter(Q=>Q.workspaceId===P))},[]),qs=y.useCallback(()=>{console.log("[MockGrackle] loadAllFindings"),T([...mc])},[]),Yt=y.useCallback(P=>{console.log("[MockGrackle] loadFinding",P);const Q=mc.find(oe=>oe.id===P);j(Q)},[]),$n=y.useCallback((P,Q,oe,ce,fe)=>{console.log("[MockGrackle] postFinding",{workspaceId:P,title:Q});const Le={id:yt("find"),workspaceId:P,taskId:"",sessionId:"",category:ce||"general",title:Q,content:oe,tags:fe||[],createdAt:new Date().toISOString()};T(ye=>[...ye,Le])},[yt]),Jt=y.useCallback(()=>{console.log("[MockGrackle] loadEnvironments")},[]),$r=y.useCallback((P,Q,oe)=>{console.log("[MockGrackle] addEnvironment",{displayName:P,adapterType:Q,adapterConfig:oe})},[]),Gr=y.useCallback((P,Q)=>{console.log("[MockGrackle] updateEnvironment",{environmentId:P,...Q}),i(oe=>oe.map(ce=>ce.id!==P?ce:{...ce,...Q.displayName!==void 0?{displayName:Q.displayName}:{},...Q.adapterConfig!==void 0?{adapterConfig:JSON.stringify(Q.adapterConfig)}:{}}))},[]),qr=y.useCallback(()=>{console.log("[MockGrackle] loadTokens")},[]),ja=y.useCallback((P,Q,oe,ce,fe)=>{console.log("[MockGrackle] setToken",{name:P,tokenType:oe}),A(Le=>[...Le.filter(Ce=>Ce.name!==P),{name:P,tokenType:oe,envVar:ce,filePath:fe,expiresAt:""}])},[]),Ca=y.useCallback(P=>{console.log("[MockGrackle] deleteToken",P),A(Q=>Q.filter(oe=>oe.name!==P))},[]),Ea=y.useCallback(P=>{console.log("[MockGrackle] updateCredentialProviders",P),D(P)},[]);y.useEffect(()=>()=>{Me.current.forEach(clearTimeout),Me.current.clear()},[]);const ps=y.useMemo(()=>({connected:!0,send:()=>{},environments:s,sessions:o,events:u,eventsDropped:0,lastSpawnedId:m,workspaces:g,tasks:_,findings:S,selectedFinding:N,findingLoading:w,tokens:C,credentialProviders:M,spawn:es,sendInput:ho,kill:Hs,stopGraceful:kn,refresh:Vn,loadSessionEvents:ts,clearEvents:$s,loadWorkspaces:()=>{console.log("[MockGrackle] loadWorkspaces")},createWorkspace:Hn,archiveWorkspace:Ae,updateWorkspace:(P,Q)=>{console.log("[MockGrackle] updateWorkspace",{workspaceId:P,...Q}),v(oe=>oe.map(ce=>ce.id!==P?ce:{...ce,...Q.name!==void 0?{name:Q.name}:{},...Q.description!==void 0?{description:Q.description}:{},...Q.repoUrl!==void 0?{repoUrl:Q.repoUrl}:{},...Q.environmentId!==void 0?{environmentId:Q.environmentId}:{},...Q.workingDirectory!==void 0?{workingDirectory:Q.workingDirectory}:{},...Q.useWorktrees!==void 0?{useWorktrees:Q.useWorktrees}:{},...Q.defaultPersonaId!==void 0?{defaultPersonaId:Q.defaultPersonaId}:{},updatedAt:new Date().toISOString()}))},loadTasks:We,loadAllTasks:()=>{console.log("[MockGrackle] loadAllTasks")},createTask:zr,startTask:mo,stopTask:P=>{console.log("[MockGrackle] stopTask",{taskId:P}),Gs(P)},completeTask:Gs,resumeTask:Pr,updateTask:go,deleteTask:Vr,loadFindings:Hr,loadAllFindings:qs,loadFinding:Yt,postFinding:$n,loadEnvironments:Jt,addEnvironment:$r,updateEnvironment:Gr,loadTokens:qr,setToken:ja,deleteToken:Ca,updateCredentialProviders:Ea,provisionStatus:{},provisionEnvironment:(P,Q)=>{},stopEnvironment:()=>{},removeEnvironment:()=>{},codespaces:[],codespaceError:"",codespaceListError:"",codespaceCreating:!1,listCodespaces:()=>{},createCodespace:()=>{},workspaceCreating:!1,taskStartingId:void 0,personas:E,createPersona:async(P,Q,oe,ce,fe,Le,ye,Ce,Ge)=>{console.log("[MockGrackle] createPersona",{name:P});const lt={id:`mock-persona-${Date.now()}`,name:P,description:Q,systemPrompt:oe,toolConfig:"{}",runtime:ce??"claude-code",model:fe||"",maxTurns:Le||0,mcpServers:"[]",createdAt:new Date().toISOString(),updatedAt:new Date().toISOString(),type:ye||"agent",script:Ce||"",allowedMcpTools:Ge||[]};return $(qe=>[...qe,lt]),lt},updatePersona:async(P,Q,oe,ce,fe,Le,ye,Ce,Ge,lt)=>{console.log("[MockGrackle] updatePersona",{personaId:P,name:Q});const qe=E.find(jt=>jt.id===P);if(!qe)throw new Error(`Persona not found: ${P}`);const Bt=new Date().toISOString(),Ht={...qe,...Q!==void 0?{name:Q}:{},...oe!==void 0?{description:oe}:{},...ce!==void 0?{systemPrompt:ce}:{},...fe!==void 0?{runtime:fe}:{},...Le!==void 0?{model:Le}:{},...ye!==void 0?{maxTurns:ye}:{},...Ce!==void 0?{type:Ce}:{},...Ge!==void 0?{script:Ge}:{},...lt!==void 0?{allowedMcpTools:lt}:{},updatedAt:Bt};return $(jt=>jt.map(Qt=>Qt.id===P?Ht:Qt)),Ht},deletePersona:async P=>{console.log("[MockGrackle] deletePersona",P),$(Q=>Q.filter(oe=>oe.id!==P))},taskSessions:z,loadTaskSessions:P=>{console.log("[MockGrackle] loadTaskSessions",P)},appDefaultPersonaId:K,setAppDefaultPersonaId:async P=>{console.log("[MockGrackle] setAppDefaultPersonaId",P),F(P)},onboardingCompleted:!0,completeOnboarding:async()=>{console.log("[MockGrackle] completeOnboarding")},usageCache:{"workspace:proj-alpha":{inputTokens:214500,outputTokens:44850,costUsd:1.12,sessionCount:4},"workspace:proj-beta":{inputTokens:86700,outputTokens:23800,costUsd:.48,sessionCount:3},"task:task-001":{inputTokens:126800,outputTokens:20850,costUsd:.63,sessionCount:2},"task:task-006":{inputTokens:18900,outputTokens:4500,costUsd:.1,sessionCount:1},"task_tree:task-001":{inputTokens:126800,outputTokens:20850,costUsd:.63,sessionCount:2},"task_tree:task-006":{inputTokens:18900,outputTokens:4500,costUsd:.1,sessionCount:1}},loadUsage:(P,Q)=>{console.log(`[MockGrackle] loadUsage(${P}, ${Q})`)},knowledge:{graphData:{nodes:ee,links:me},selectedNode:X,loading:!1,selectedId:q,searchQuery:re,search:P=>{if(console.log("[MockGrackle] knowledge.search",P),!P.trim()){ue(P);return}ue(P);const Q=Fe.current,oe=Q?rs.filter(ye=>!ye.workspaceId||ye.workspaceId===Q):rs,ce=P.toLowerCase(),fe=oe.filter(ye=>{var Ce,Ge,lt;return ye.label.toLowerCase().includes(ce)||((Ce=ye.content)==null?void 0:Ce.toLowerCase().includes(ce))||((Ge=ye.tags)==null?void 0:Ge.some(qe=>qe.toLowerCase().includes(ce)))||((lt=ye.category)==null?void 0:lt.toLowerCase().includes(ce))});ae(fe);const Le=new Set(fe.map(ye=>ye.id));ie(va.filter(ye=>Le.has(ye.source)&&Le.has(ye.target))),te(void 0),O(void 0)},clearSearch:()=>{console.log("[MockGrackle] knowledge.clearSearch"),ue("");const P=Fe.current,Q=P?rs.filter(ce=>!ce.workspaceId||ce.workspaceId===P):rs;ae(Q);const oe=new Set(Q.map(ce=>ce.id));ie(va.filter(ce=>oe.has(ce.source)&&oe.has(ce.target)))},selectNode:P=>{console.log("[MockGrackle] knowledge.selectNode",P),te(P);const Q=P in nb?nb[P]:void 0;if(Q)O(Q);else{const oe=rs.find(ce=>ce.id===P);if(oe){const ce=va.filter(fe=>fe.source===P||fe.target===P).map(fe=>({fromId:fe.source,toId:fe.target,type:fe.type}));O({node:oe,edges:ce})}}},clearSelection:()=>{console.log("[MockGrackle] knowledge.clearSelection"),te(void 0),O(void 0)},expandNode:P=>{console.log("[MockGrackle] knowledge.expandNode",P),ae(Q=>{const oe=new Set(Q.map(Ce=>Ce.id)),ce=va.filter(Ce=>Ce.source===P||Ce.target===P),fe=new Set;for(const Ce of ce)oe.has(Ce.source)||fe.add(Ce.source),oe.has(Ce.target)||fe.add(Ce.target);if(fe.size===0)return Q;const Le=rs.filter(Ce=>fe.has(Ce.id)),ye=new Set([...oe,...fe]);return ie(Ce=>{const Ge=new Set(Ce.map(qe=>`${qe.source}|${qe.target}|${qe.type}`)),lt=va.filter(qe=>ye.has(qe.source)&&ye.has(qe.target)&&!Ge.has(`${qe.source}|${qe.target}|${qe.type}`));return lt.length>0?[...Ce,...lt]:Ce}),[...Q,...Le]})},loadRecent:P=>{if(console.log("[MockGrackle] knowledge.loadRecent",P),Fe.current=P,P){const Q=rs.filter(ce=>!ce.workspaceId||ce.workspaceId===P);ae(Q);const oe=new Set(Q.map(ce=>ce.id));ie(va.filter(ce=>oe.has(ce.source)&&oe.has(ce.target)))}else ae(rs),ie(va);ue("")},handleEvent:()=>!1}}),[s,o,u,m,g,_,S,N,C,M,E,z,K,ee,me,X,q,re,es,ho,Hs,kn,Vn,ts,$s,Hn,Ae,We,zr,mo,Gs,Pr,go,Vr,Hr,qs,Yt,$n,Jt,$r,Gr,qr,ja,Ca,Ea]);return l.jsx(vm.Provider,{value:ps,children:t})}const AB=3e3;function DB(t){const[s,i]=y.useState(!1),o=y.useRef(t.onSessionEvent);o.current=t.onSessionEvent;const c=y.useRef(t.onDomainEvent);c.current=t.onDomainEvent;const u=y.useRef(t.onConnect);u.current=t.onConnect;const d=y.useRef(t.onDisconnect);return d.current=t.onDisconnect,y.useEffect(()=>{let m=!1,h;async function g(){var v,_;if(!m){try{const b=xe.streamEvents({});i(!0),(v=u.current)==null||v.call(u);for await(const S of b){if(m)break;const T=S.event;if(T.case==="sessionEvent"){const N=T.value;o.current({sessionId:N.sessionId,type:N.type,timestamp:N.timestamp,content:N.content,raw:N.raw})}else if(T.case==="domainEvent"){const N=T.value;c.current({id:N.id,type:N.type,timestamp:N.timestamp,payloadJson:N.payloadJson})}}}catch(b){if(b instanceof zc&&b.code===kT.Unauthenticated){window.location.href=i2;return}}m||(i(!1),(_=d.current)==null||_.call(d),h=setTimeout(()=>{g().catch(()=>{})},AB))}}return g().catch(()=>{}),()=>{m=!0,clearTimeout(h),i(!1)}},[]),{connected:s}}function RB(t){return{id:t.id,displayName:t.displayName,adapterType:t.adapterType,adapterConfig:t.adapterConfig||"{}",status:t.status,bootstrapped:t.bootstrapped}}function ib(t){return{id:t.id,environmentId:t.environmentId,runtime:t.runtime,status:t.status,prompt:t.prompt,startedAt:t.startedAt,endedAt:t.endedAt||void 0,error:t.error||void 0,endReason:t.endReason||void 0,personaId:t.personaId||void 0,inputTokens:t.inputTokens,outputTokens:t.outputTokens,costUsd:t.costUsd}}function MB(t){return{sessionId:t.sessionId,eventType:Sb(t.type),timestamp:t.timestamp,content:t.content,raw:t.raw||void 0}}function IB(t){return{id:t.id,name:t.name,description:t.description,repoUrl:t.repoUrl,environmentId:t.environmentId,status:wT(t.status),workingDirectory:t.workingDirectory,useWorktrees:t.useWorktrees,defaultPersonaId:t.defaultPersonaId,createdAt:t.createdAt,updatedAt:t.updatedAt}}function ob(t){return{id:t.id,workspaceId:t.workspaceId??void 0,title:t.title,description:t.description,status:NT(t.status),branch:t.branch,latestSessionId:t.latestSessionId,dependsOn:[...t.dependsOn],sortOrder:t.sortOrder,createdAt:t.createdAt,startedAt:t.startedAt||void 0,completedAt:t.completedAt||void 0,parentTaskId:t.parentTaskId,depth:t.depth,childTaskIds:[...t.childTaskIds],canDecompose:t.canDecompose,defaultPersonaId:t.defaultPersonaId,workpad:t.workpad}}function Hf(t){return{id:t.id,workspaceId:t.workspaceId,taskId:t.taskId,sessionId:t.sessionId,category:t.category,title:t.title,content:t.content,tags:[...t.tags],createdAt:t.createdAt}}function OB(t){return{name:t.name,tokenType:t.type,envVar:t.envVar,filePath:t.filePath,expiresAt:t.expiresAt}}function BB(t){return{claude:jT(t.claude),github:ac(t.github),copilot:ac(t.copilot),codex:ac(t.codex),goose:ac(t.goose)}}function LB(t){return{name:t.name,repository:t.repository,state:t.state,gitStatus:t.gitStatus}}function $f(t){return{id:t.id,name:t.name,description:t.description,systemPrompt:t.systemPrompt,toolConfig:t.toolConfig?JSON.stringify({allowedTools:[...t.toolConfig.allowedTools],disallowedTools:[...t.toolConfig.disallowedTools]}):"{}",runtime:t.runtime,model:t.model,maxTurns:t.maxTurns,mcpServers:JSON.stringify(t.mcpServers.map(s=>({name:s.name,command:s.command,args:[...s.args],tools:[...s.tools]}))),createdAt:t.createdAt,updatedAt:t.updatedAt,type:t.type||"agent",script:t.script,allowedMcpTools:[...t.allowedMcpTools]}}function UB(t){return{inputTokens:t.inputTokens,outputTokens:t.outputTokens,costUsd:t.costUsd,sessionCount:t.sessionCount}}function hc(t,s=0){return{id:t.id,label:t.title||t.label||t.id,kind:t.kind,category:t.category||void 0,sourceType:t.sourceType||void 0,sourceId:t.sourceId||void 0,content:t.content||void 0,tags:t.tags.length>0?[...t.tags]:void 0,workspaceId:t.workspaceId||void 0,createdAt:t.createdAt||void 0,updatedAt:t.updatedAt||void 0,val:s}}function Gf(t){return{source:t.fromId,target:t.toId,type:t.type}}const rb=5e3;function zB(){const[t,s]=y.useState([]),[i,o]=y.useState({}),c=y.useCallback(()=>{xe.listEnvironments({}).then(b=>{s(b.environments.map(RB))},()=>{})},[]),u=y.useCallback(b=>{switch(b.type){case"environment.added":return!0;case"environment.removed":{const S=b.payload.environmentId;return S&&(s(T=>T.filter(N=>N.id!==S)),o(T=>{const N={...T};return delete N[S],N})),!0}case"environment.changed":return c(),!0;case"environment.provision_progress":{const S=b.payload;if(typeof S.environmentId!="string"||typeof S.stage!="string"||typeof S.message!="string"||typeof S.progress!="number")return Fx("environment.provision_progress","invalid payload"),!0;if(o(T=>({...T,[S.environmentId]:{stage:S.stage,message:S.message,progress:S.progress}})),S.stage==="ready"){const T=S.environmentId;setTimeout(()=>{o(N=>{const j={...N};return delete j[T],j})},rb)}return!0}default:return!1}},[c]),d=y.useCallback(b=>{var S;if(b.type==="environments"){const T=Array.isArray((S=b.payload)==null?void 0:S.environments)?b.payload.environments:[];return s(T),!0}return!1},[]),m=y.useCallback((b,S,T)=>{xe.addEnvironment({displayName:b,adapterType:S,adapterConfig:JSON.stringify(T??{})}).catch(()=>{})},[]),h=y.useCallback((b,S)=>{xe.updateEnvironment({id:b,displayName:S.displayName,adapterConfig:S.adapterConfig?JSON.stringify(S.adapterConfig):void 0}).catch(()=>{})},[]),g=y.useCallback((b,S)=>{(async()=>{try{const N=xe.provisionEnvironment({id:b,force:S??!1});for await(const j of N)o(w=>({...w,[b]:{stage:j.stage,message:j.message,progress:j.progress}})),j.stage==="ready"&&setTimeout(()=>{o(w=>{const C={...w};return delete C[b],C})},rb)}catch{o(N=>{const j={...N};return delete j[b],j})}})().catch(()=>{})},[]),v=y.useCallback(b=>{xe.stopEnvironment({id:b}).catch(()=>{})},[]),_=y.useCallback(b=>{xe.removeEnvironment({id:b}).catch(()=>{})},[]);return{environments:t,provisionStatus:i,loadEnvironments:c,addEnvironment:m,updateEnvironment:h,provisionEnvironment:g,stopEnvironment:v,removeEnvironment:_,handleEvent:u,handleLegacyMessage:d}}const qf=new Set(["pending","running","idle"]),PB=new Set(["completed","failed","interrupted","hibernating","suspended"]),lb=["pending","running","idle"];function VB(){const[t,s]=y.useState([]),[i,o]=y.useState([]),[c,u]=y.useState(0),[d,m]=y.useState(void 0),[h,g]=y.useState({}),v=y.useCallback(()=>{xe.listSessions({}).then(D=>{const E=D.sessions.map(ib);s($=>{const z=new Map($.map(K=>[K.id,K]));return E.map(K=>{const F=z.get(K.id),ee=F==null?void 0:F.status;return!ee||ee===K.status?K:PB.has(ee)&&qf.has(K.status)?{...K,status:ee,...F.endReason!==void 0?{endReason:F.endReason}:{}}:qf.has(ee)&&qf.has(K.status)&&lb.indexOf(ee)>lb.indexOf(K.status)?{...K,status:ee}:K})})},()=>{})},[]),_=y.useCallback(D=>{if(D.type!=="session_event")return!1;if(!aB(D.payload))return Fx("session_event","payload is not a valid SessionEvent"),!0;const E=D.payload;let $=0;if(o(z=>{const K=[...z,E];return K.length>Yi?($=K.length-Yi,K.slice(-Yi)):K}),$>0&&u(z=>z+$),E.eventType==="usage")try{const z=JSON.parse(E.content),K=Number(z.input_tokens)||0,F=Number(z.output_tokens)||0,ee=Number(z.cost_usd)||0;(K>0||F>0||ee>0)&&s(ae=>ae.map(me=>me.id===E.sessionId?{...me,inputTokens:(me.inputTokens??0)+K,outputTokens:(me.outputTokens??0)+F,costUsd:(me.costUsd??0)+ee}:me))}catch{}if(E.eventType==="status"){const z=Zx(E.content),K=Kx(E.content);s(F=>F.some(ae=>ae.id===E.sessionId)?F.map(ae=>ae.id===E.sessionId?{...ae,status:z,...K!==void 0?{endReason:K}:{}}:ae):[...F,{id:E.sessionId,environmentId:"",runtime:"",status:z,prompt:"",startedAt:E.timestamp,...K!==void 0?{endReason:K}:{}}])}return!0},[]),b=y.useCallback(D=>{_({type:"session_event",payload:D})},[_]),S=y.useCallback(D=>{var E,$,z,K,F;switch(D.type){case"sessions":{const ee=Array.isArray((E=D.payload)==null?void 0:E.sessions)?D.payload.sessions:[];return s(ee),!0}case"spawned":{const ee=($=D.payload)==null?void 0:$.sessionId;return typeof ee=="string"&&ee&&m(ee),v(),!0}case"session_events":{const ee=Array.isArray((z=D.payload)==null?void 0:z.events)?D.payload.events:[];return ee.length>0&&o(ee),!0}case"task_sessions":{const ee=(K=D.payload)==null?void 0:K.taskId;if(typeof ee=="string"&&ee){const ae=Array.isArray((F=D.payload)==null?void 0:F.sessions)?D.payload.sessions:[];g(me=>({...me,[ee]:ae}))}return!0}default:return!1}},[v]),T=y.useCallback((D,E,$,z)=>{xe.spawnAgent({environmentId:D,prompt:E,personaId:$||"",workingDirectory:z||""}).then(K=>{m(K.id),v()},()=>{})},[v]),N=y.useCallback((D,E)=>{xe.sendInput({sessionId:D,text:E}).catch(()=>{})},[]),j=y.useCallback(D=>{xe.killAgent({id:D,graceful:!1}).catch(()=>{})},[]),w=y.useCallback(D=>{xe.killAgent({id:D,graceful:!0}).catch(()=>{})},[]),C=y.useCallback(D=>{xe.getSessionEvents({id:D}).then(E=>{const $=E.events.map(MB);if($.length>0){let z=0;o(K=>{const F=new Set;for(const me of K)me.sessionId===D&&F.add(`${me.timestamp}|${me.eventType}`);const ee=$.filter(me=>!F.has(`${me.timestamp}|${me.eventType}`)),ae=[...K,...ee].sort((me,ie)=>me.sessionId!==ie.sessionId?0:me.timestamp.localeCompare(ie.timestamp));return ae.length>Yi?(z=ae.length-Yi,ae.slice(-Yi)):ae}),z>0&&u(K=>K+z)}},()=>{})},[]),A=y.useCallback(()=>{o([]),u(0)},[]),M=y.useCallback(D=>{xe.getTaskSessions({id:D}).then(E=>{const $=E.sessions.map(ib);g(z=>({...z,[D]:$}))},()=>{})},[]);return{sessions:t,events:i,eventsDropped:c,lastSpawnedId:d,taskSessions:h,loadSessions:v,spawn:T,sendInput:N,kill:j,stopGraceful:w,loadSessionEvents:C,clearEvents:A,loadTaskSessions:M,handleMessage:_,handleSessionEvent:b,handleLegacyMessage:S}}function HB(){const[t,s]=y.useState([]),[i,o]=y.useState(!1),c=y.useCallback(()=>{xe.listWorkspaces({}).then(v=>{s(v.workspaces.map(IB))},()=>{})},[]),u=y.useCallback(v=>{switch(v.type){case"workspace.created":return o(!1),c(),!0;case"workspace.archived":case"workspace.updated":return c(),!0;default:return!1}},[c]),d=y.useCallback(()=>{o(!1)},[]),m=y.useCallback((v,_,b,S,T,N,j,w,C)=>{o(!0),xe.createWorkspace({name:v,description:_||"",repoUrl:b||"",environmentId:S||"",defaultPersonaId:T||void 0,useWorktrees:N??!0,workingDirectory:j||void 0}).then(()=>{o(!1),w==null||w()},A=>{o(!1);const M=A instanceof zc?A.message:"Failed to create workspace";C==null||C(M)})},[]),h=y.useCallback(v=>{xe.archiveWorkspace({id:v}).catch(()=>{})},[]),g=y.useCallback((v,_)=>{xe.updateWorkspace({id:v,..._}).catch(()=>{})},[]);return{workspaces:t,workspaceCreating:i,loadWorkspaces:c,createWorkspace:m,archiveWorkspace:h,updateWorkspace:g,handleEvent:u,onDisconnect:d}}function $B(){const[t,s]=y.useState([]),[i,o]=y.useState(void 0),c=y.useRef({}),u=y.useCallback(C=>{xe.listTasks({workspaceId:C}).then(A=>{const M=A.tasks.map(ob);s(D=>[...D.filter(E=>E.workspaceId!==C),...M])},()=>{})},[]),d=y.useCallback(()=>{xe.listTasks({}).then(C=>{const A=C.tasks.map(ob);s(M=>{const D=new Set(A.map(E=>E.id));return[...M.filter(E=>!D.has(E.id)),...A]})},()=>{})},[]),m=y.useCallback((C,A)=>{const M=D=>{clearTimeout(c.current[D]),c.current[D]=setTimeout(()=>{delete c.current[D],u(D)},200)};C?M(C):A&&s(D=>{const E=D.find($=>$.id===A);return E!=null&&E.workspaceId?M(E.workspaceId):d(),D})},[u,d]),h=y.useCallback(C=>{const A=C.payload;switch(C.type){case"task.created":{const M=typeof A.workspaceId=="string"?A.workspaceId:"";return M&&u(M),!0}case"task.started":{const M=typeof A.taskId=="string"?A.taskId:"",D=typeof A.sessionId=="string"?A.sessionId:"",E=typeof A.workspaceId=="string"?A.workspaceId:"";return o($=>M&&$===M?void 0:$),D&&M&&s($=>$.map(z=>z.id===M?{...z,latestSessionId:D}:z)),m(E,M),!0}case"task.completed":case"task.deleted":case"task.reparented":case"task.updated":{const M=typeof A.workspaceId=="string"?A.workspaceId:"",D=typeof A.taskId=="string"?A.taskId:"";return m(M,D),!0}default:return!1}},[u,m]),g=y.useCallback(()=>{o(void 0)},[]),v=y.useCallback(C=>{var A,M;if(C.type==="tasks"){const D=Array.isArray((A=C.payload)==null?void 0:A.tasks)?C.payload.tasks:[],E=typeof((M=C.payload)==null?void 0:M.workspaceId)=="string"&&C.payload.workspaceId?C.payload.workspaceId:"";return s(E?$=>[...$.filter(z=>z.workspaceId!==E),...D]:$=>{const z=new Set(D.map(K=>K.id));return[...$.filter(K=>!z.has(K.id)),...D]}),!0}return!1},[]),_=y.useCallback((C,A,M,D,E,$,z,K,F)=>{xe.createTask({workspaceId:C,title:A,description:M||"",dependsOn:D||[],parentTaskId:E||"",defaultPersonaId:$||void 0,canDecompose:z??void 0}).then(()=>{K==null||K()},ee=>{const ae=ee instanceof zc?ee.message:"Failed to create task";F==null||F(ae)})},[]),b=y.useCallback((C,A,M,D)=>{o(C),xe.startTask({taskId:C,personaId:A||"",environmentId:M||"",notes:D||""}).catch(()=>{o(void 0)})},[]),S=y.useCallback(C=>{xe.stopTask({id:C}).catch(()=>{})},[]),T=y.useCallback(C=>{xe.completeTask({id:C}).catch(()=>{})},[]),N=y.useCallback(C=>{xe.resumeTask({id:C}).catch(()=>{})},[]),j=y.useCallback((C,A,M,D,E)=>{xe.updateTask({id:C,title:A,description:M,dependsOn:D,...E!==void 0?{defaultPersonaId:E}:{}}).catch(()=>{})},[]),w=y.useCallback(C=>{xe.deleteTask({id:C}).catch(()=>{})},[]);return{tasks:t,taskStartingId:i,loadTasks:u,loadAllTasks:d,createTask:_,startTask:b,stopTask:S,completeTask:T,resumeTask:N,updateTask:j,deleteTask:w,handleEvent:h,onDisconnect:g,handleLegacyMessage:v}}function GB(){const[t,s]=y.useState([]),[i,o]=y.useState(void 0),[c,u]=y.useState(!1),d=y.useCallback(_=>{xe.queryFindings({workspaceId:_}).then(b=>{s(b.findings.map(Hf))},()=>{})},[]),m=y.useCallback(()=>{xe.queryFindings({workspaceId:""}).then(_=>{s(_.findings.map(Hf))},()=>{})},[]),h=y.useCallback(_=>{o(void 0),u(!0),xe.getFinding({id:_}).then(b=>{o(Hf(b)),u(!1)},()=>{o(void 0),u(!1)})},[]),g=y.useCallback(_=>{if(_.type==="finding.posted"){const b=typeof _.payload.workspaceId=="string"?_.payload.workspaceId:"";return b&&d(b),!0}return!1},[d]),v=y.useCallback((_,b,S,T,N)=>{xe.postFinding({workspaceId:_,title:b,content:S,category:T??"general",tags:N??[]}).catch(()=>{})},[]);return{findings:t,selectedFinding:i,findingLoading:c,loadFindings:d,loadAllFindings:m,loadFinding:h,postFinding:v,handleEvent:g}}function qB(){const[t,s]=y.useState([]),i=y.useCallback(()=>{xe.listTokens({}).then(d=>{s(d.tokens.map(OB))},()=>{})},[]),o=y.useCallback(d=>d.type==="token.changed"?(i(),!0):!1,[i]),c=y.useCallback((d,m,h,g,v)=>{xe.setToken({name:d,value:m,type:h,envVar:g,filePath:v}).catch(()=>{})},[]),u=y.useCallback(d=>{xe.deleteToken({name:d}).catch(()=>{})},[]);return{tokens:t,loadTokens:i,setToken:c,deleteToken:u,handleEvent:o}}function FB(){const[t,s]=y.useState({claude:"off",github:"off",copilot:"off",codex:"off",goose:"off"}),i=y.useCallback(()=>{xe.getCredentialProviders({}).then(u=>{s(BB(u))},()=>{})},[]),o=y.useCallback(u=>u.type==="credential.providers_changed"?(oB(u.payload)&&s(u.payload),!0):!1,[]),c=y.useCallback(u=>{const d=[{provider:"claude",value:u.claude},{provider:"github",value:u.github},{provider:"copilot",value:u.copilot},{provider:"codex",value:u.codex},{provider:"goose",value:u.goose}];for(const{provider:m,value:h}of d)xe.setCredentialProvider({provider:m,value:h}).catch(()=>{})},[]);return{credentialProviders:t,loadCredentials:i,updateCredentialProviders:c,handleEvent:o}}function ZB(){const[t,s]=y.useState([]),[i,o]=y.useState(""),[c,u]=y.useState(""),[d,m]=y.useState(!1),h=y.useCallback(()=>{xe.listCodespaces({}).then(v=>{s(v.codespaces.map(LB)),u(v.error)},()=>{})},[]),g=y.useCallback((v,_)=>{m(!0),o(""),xe.createCodespace({repo:v,machine:_??""}).then(()=>{m(!1),h()},b=>{m(!1);const S=b instanceof zc?b.message:"Failed to create codespace";o(S)})},[h]);return{codespaces:t,codespaceError:i,codespaceListError:c,codespaceCreating:d,listCodespaces:h,createCodespace:g}}function KB(){const[t,s]=y.useState([]),i=y.useCallback(()=>{xe.listPersonas({}).then(m=>{s(m.personas.map($f))},()=>{})},[]),o=y.useCallback(m=>{switch(m.type){case"persona.created":case"persona.updated":case"persona.deleted":return i(),!0;default:return!1}},[i]),c=y.useCallback((m,h,g,v,_,b,S,T,N)=>xe.createPersona({name:m,description:h,systemPrompt:g,runtime:v||"",model:_||"",maxTurns:b||0,type:S||"agent",script:T||"",allowedMcpTools:N||[]}).then(j=>{const w=$f(j);return s(C=>[...C.filter(A=>A.id!==w.id),w]),w}),[]),u=y.useCallback((m,h,g,v,_,b,S,T,N,j)=>{const w={id:m};return h!==void 0&&(w.name=h),g!==void 0&&(w.description=g),v!==void 0&&(w.systemPrompt=v),_!==void 0&&(w.runtime=_),b!==void 0&&(w.model=b),S!==void 0&&(w.maxTurns=S),T!==void 0&&(w.type=T),N!==void 0&&(w.script=N),j!==void 0&&(w.allowedMcpTools={tools:j}),xe.updatePersona(w).then(C=>{const A=$f(C);return s(M=>M.map(D=>D.id===A.id?A:D)),A})},[]),d=y.useCallback(async m=>{await xe.deletePersona({id:m}),s(h=>h.filter(g=>g.id!==m))},[]);return{personas:t,loadPersonas:i,createPersona:c,updatePersona:u,deletePersona:d,handleEvent:o}}function YB(t){if(t)try{return JSON.parse(t)}catch{return}}function JB(){const[t,s]=y.useState(new Map),[i,o]=y.useState([]),[c,u]=y.useState(void 0),[d,m]=y.useState(void 0),[h,g]=y.useState(!1),[v,_]=y.useState(""),b=y.useRef(""),S=y.useCallback(M=>{const D=M??"";b.current=D,_(""),g(!0),xe.listRecentKnowledgeNodes({limit:30,workspaceId:D}).then(E=>{const $=new Map,z=[];for(const K of E.nodes)$.set(K.id,hc(K));for(const K of E.edges)z.push(Gf(K));for(const K of z){const F=$.get(K.source);F&&(F.val+=1);const ee=$.get(K.target);ee&&(ee.val+=1)}s($),o(z),g(!1)},()=>{g(!1)})},[]),T=y.useCallback(M=>{M.trim()&&(_(M),m(void 0),u(void 0),g(!0),xe.searchKnowledge({query:M,limit:20,workspaceId:b.current}).then(D=>{const E=new Map,$=[];for(const z of D.results){z.node&&E.set(z.node.id,hc(z.node,z.edges.length));for(const K of z.edges)$.push(Gf(K))}s(E),o($),g(!1)},()=>{g(!1)}))},[]),N=y.useCallback(()=>{S(b.current)},[S]),j=y.useCallback(M=>{m(M),xe.getKnowledgeNode({id:M}).then(D=>{if(!D.node){u(void 0);return}u({node:hc(D.node,D.edges.length),edges:D.edges.map(E=>({fromId:E.fromId,toId:E.toId,type:E.type,metadata:YB(E.metadataJson)}))})},()=>{u(void 0)})},[]),w=y.useCallback(()=>{m(void 0),u(void 0)},[]),C=y.useCallback(M=>{xe.expandKnowledgeNode({id:M,depth:1}).then(D=>{s(E=>{const $=new Map(E);for(const z of D.nodes)$.has(z.id)||$.set(z.id,hc(z));return $}),o(E=>{const $=new Set(E.map(K=>`${K.source}:${K.target}:${K.type}`)),z=[];for(const K of D.edges){const F=Gf(K),ee=`${F.source}:${F.target}:${F.type}`;$.has(ee)||z.push(F)}return[...E,...z]})},()=>{})},[]),A=y.useCallback(M=>!1,[]);return{graphData:{nodes:[...t.values()],links:i},selectedNode:c,selectedId:d,loading:h,searchQuery:v,search:T,clearSearch:N,selectNode:j,clearSelection:w,expandNode:C,loadRecent:S,handleEvent:A}}function WB(){const[t,s]=y.useState(""),[i,o]=y.useState(void 0),[c,u]=y.useState({}),d=zB(),m=VB(),h=HB(),g=$B(),v=GB(),_=qB(),b=FB(),S=ZB(),T=KB(),N=JB(),{connected:j}=DB({onSessionEvent:F=>{m.handleSessionEvent({sessionId:F.sessionId,eventType:Sb(F.type),timestamp:F.timestamp,content:F.content,raw:F.raw||void 0})},onDomainEvent:F=>{try{const ee=JSON.parse(F.payloadJson);E({id:F.id,type:F.type,timestamp:F.timestamp,payload:ee})}catch{console.warn("[grackle] Failed to parse domain event payloadJson:",F.payloadJson)}},onConnect:$,onDisconnect:z}),w="default_persona_id",C="onboarding_completed",A=y.useCallback(async F=>{const ee=await xe.setSetting({key:w,value:F});s(ee.value)},[]),M=y.useCallback(()=>{o(!0),xe.setSetting({key:C,value:"true"}).catch(()=>{})},[]),D=y.useCallback((F,ee)=>{xe.getUsage({scope:F,id:ee}).then(ae=>{const me=`${F}:${ee}`;u(ie=>({...ie,[me]:UB(ae)}))},()=>{})},[]);function E(F){const ee=F.payload.key,ae=F.payload.value;if(F.type==="setting.changed"){ee===w&&s(ae??""),ee===C&&o(ae==="true");return}if(d.handleEvent(F)){(F.type==="environment.removed"||F.type==="environment.changed")&&m.loadSessions();return}if(!h.handleEvent(F)){if(g.handleEvent(F)){F.type==="task.started"&&m.loadSessions();return}v.handleEvent(F)||_.handleEvent(F)||b.handleEvent(F)||T.handleEvent(F)||N.handleEvent(F)}}function $(){d.loadEnvironments(),m.loadSessions(),h.loadWorkspaces(),_.loadTokens(),b.loadCredentials(),T.loadPersonas(),xe.getSetting({key:w}).then(F=>{s(F.value)},()=>{}),xe.getSetting({key:C}).then(F=>{o(F.value==="true")},()=>{}),g.loadAllTasks()}function z(){h.onDisconnect(),g.onDisconnect()}const K=y.useCallback(()=>{d.loadEnvironments(),m.loadSessions(),h.loadWorkspaces(),_.loadTokens()},[d.loadEnvironments,m.loadSessions,h.loadWorkspaces,_.loadTokens]);return{connected:j,environments:d.environments,sessions:m.sessions,events:m.events,eventsDropped:m.eventsDropped,lastSpawnedId:m.lastSpawnedId,workspaces:h.workspaces,tasks:g.tasks,findings:v.findings,selectedFinding:v.selectedFinding,findingLoading:v.findingLoading,tokens:_.tokens,spawn:m.spawn,sendInput:m.sendInput,kill:m.kill,stopGraceful:m.stopGraceful,refresh:K,loadSessionEvents:m.loadSessionEvents,clearEvents:m.clearEvents,loadWorkspaces:h.loadWorkspaces,createWorkspace:h.createWorkspace,archiveWorkspace:h.archiveWorkspace,updateWorkspace:h.updateWorkspace,loadTasks:g.loadTasks,loadAllTasks:g.loadAllTasks,createTask:g.createTask,startTask:g.startTask,stopTask:g.stopTask,completeTask:g.completeTask,resumeTask:g.resumeTask,updateTask:g.updateTask,deleteTask:g.deleteTask,loadFindings:v.loadFindings,loadAllFindings:v.loadAllFindings,loadFinding:v.loadFinding,postFinding:v.postFinding,loadEnvironments:d.loadEnvironments,addEnvironment:d.addEnvironment,updateEnvironment:d.updateEnvironment,loadTokens:_.loadTokens,setToken:_.setToken,deleteToken:_.deleteToken,credentialProviders:b.credentialProviders,updateCredentialProviders:b.updateCredentialProviders,provisionStatus:d.provisionStatus,provisionEnvironment:d.provisionEnvironment,stopEnvironment:d.stopEnvironment,removeEnvironment:d.removeEnvironment,codespaces:S.codespaces,codespaceError:S.codespaceError,codespaceListError:S.codespaceListError,codespaceCreating:S.codespaceCreating,listCodespaces:S.listCodespaces,createCodespace:S.createCodespace,workspaceCreating:h.workspaceCreating,taskStartingId:g.taskStartingId,personas:T.personas,createPersona:T.createPersona,updatePersona:T.updatePersona,deletePersona:T.deletePersona,taskSessions:m.taskSessions,loadTaskSessions:m.loadTaskSessions,appDefaultPersonaId:t,setAppDefaultPersonaId:A,onboardingCompleted:i,completeOnboarding:M,usageCache:c,loadUsage:D,knowledge:N}}function XB({children:t}){const s=WB();return l.jsx(vm.Provider,{value:s,children:t})}function QB(t,s){const i=y.useRef(null);y.useEffect(()=>{const o=i.current;if(i.current=t,o===null)return;const c=new Map;for(const d of o)c.set(d.id,d);const u=new Set;for(const d of t){u.add(d.id);const m=c.get(d.id);if(m&&m.status!==d.status&&d.status!=="sleeping"){if(d.status==="connecting"){s("Provisioning environment…","info");continue}d.status==="connected"?s("Environment connected","success"):d.status==="error"?s("Environment provision failed","error"):d.status==="disconnected"&&(m.status==="connected"?s("Environment disconnected","warning"):s("Environment stopped","info"))}}for(const d of o)u.has(d.id)||s("Environment removed","info")},[t,s])}const eL={working:{message:"Task is now running",variant:"info"},paused:{message:"Task paused",variant:"warning"},complete:{message:"Task complete",variant:"success"},failed:{message:"Task failed to complete",variant:"error"}};function tL(t){return eL[t]}function nL(t,s){if(t===void 0)return[];const i=[],o=new Map;for(const u of t)o.set(u.id,u);const c=new Set;for(const u of s){c.add(u.id);const d=o.get(u.id);if(!d||d.status===u.status)continue;const m=tL(u.status);m&&i.push(m)}for(const u of t)c.has(u.id)||i.push({message:"Task deleted",variant:"info"});return i}function sL(t,s){const i=y.useRef(void 0);y.useEffect(()=>{const o=i.current;i.current=t;const c=nL(o,t);for(const u of c)s(u.message,u.variant)},[t,s])}const aL="_dashboard_16pzm_1",iL="_kpiStrip_16pzm_11",oL="_kpiCard_16pzm_23",rL="_kpiValue_16pzm_68",lL="_kpiLabel_16pzm_76",cL="_bodyGrid_16pzm_84",uL="_section_16pzm_96",dL="_sectionHeader_16pzm_109",fL="_sectionIcon_16pzm_118",pL="_sectionTitle_16pzm_123",mL="_sectionCount_16pzm_131",hL="_sectionBody_16pzm_138",gL="_emptyHint_16pzm_143",vL="_sessionRow_16pzm_150",yL="_sessionPrompt_16pzm_177",bL="_sessionEnv_16pzm_186",_L="_sessionRuntime_16pzm_192",xL="_sessionStatus_16pzm_198",SL="_statusDot_16pzm_207",TL="_attentionRow_16pzm_233",kL="_attentionTitle_16pzm_259",wL="_attentionMeta_16pzm_267",NL="_reasonBadge_16pzm_274",jL="_bottomGrid_16pzm_301",CL="_envRow_16pzm_312",EL="_envName_16pzm_323",AL="_envStatusBadge_16pzm_333",DL="_workspaceRow_16pzm_369",RL="_workspaceTop_16pzm_395",ML="_workspaceName_16pzm_401",IL="_workspaceCounts_16pzm_407",OL="_progressBar_16pzm_415",BL="_progressFill_16pzm_422",_e={dashboard:aL,kpiStrip:iL,kpiCard:oL,kpiValue:rL,kpiLabel:lL,bodyGrid:cL,section:uL,sectionHeader:dL,sectionIcon:fL,sectionTitle:pL,sectionCount:mL,sectionBody:hL,emptyHint:gL,sessionRow:vL,sessionPrompt:yL,sessionEnv:bL,sessionRuntime:_L,sessionStatus:xL,statusDot:SL,attentionRow:TL,attentionTitle:kL,attentionMeta:wL,reasonBadge:NL,bottomGrid:jL,envRow:CL,envName:EL,envStatusBadge:AL,workspaceRow:DL,workspaceTop:RL,workspaceName:ML,workspaceCounts:IL,progressBar:OL,progressFill:BL},LL={hidden:{opacity:0,y:12},visible:t=>({opacity:1,y:0,transition:{delay:t*.06,duration:.3,ease:"easeOut"}})},gc={hidden:{opacity:0,y:16},visible:t=>({opacity:1,y:0,transition:{delay:.15+t*.08,duration:.35,ease:"easeOut"}})};function UL(t,s,i,o){const c=[`${t} of ${s} tasks completed`];return i>0&&c.push(`${i} in progress`),o>0&&c.push(`${o} failed`),c.join(", ")}function vc({value:t,label:s,accent:i,index:o,testId:c}){return l.jsxs(Dt.div,{className:_e.kpiCard,"data-accent":i,"data-testid":c,variants:LL,initial:"hidden",animate:"visible",custom:o,children:[l.jsx("span",{className:_e.kpiValue,children:t}),l.jsx("span",{className:_e.kpiLabel,children:s})]})}function zL(){const{workspaces:t,tasks:s,sessions:i,environments:o,loadTasks:c}=rt(),u=vt(),d=y.useRef(new Set);y.useEffect(()=>{for(const _ of t)d.current.has(_.id)||(d.current.add(_.id),c(_.id))},[t,c]);const m=y.useMemo(()=>gB(i,s,o),[i,s,o]),h=y.useMemo(()=>yB(i,o),[i,o]),g=y.useMemo(()=>vB(s,t),[s,t]),v=y.useMemo(()=>bB(t,s),[t,s,o]);return l.jsxs("div",{className:_e.dashboard,"data-testid":"dashboard",children:[l.jsxs("div",{className:_e.kpiStrip,"data-testid":"dashboard-kpi-strip",children:[l.jsx(vc,{value:m.activeSessions,label:"Active Sessions",accent:"green",index:0,testId:"kpi-active-sessions"}),l.jsx(vc,{value:m.blockedTasks,label:"Blocked Tasks",accent:"yellow",index:1,testId:"kpi-blocked-tasks"}),l.jsx(vc,{value:m.attentionTasks,label:"Needs Attention",accent:"red",index:2,testId:"kpi-attention-tasks"}),l.jsx(vc,{value:m.unhealthyEnvironments,label:"Unhealthy Envs",accent:"blue",index:3,testId:"kpi-unhealthy-envs"})]}),l.jsxs("div",{className:_e.bodyGrid,children:[l.jsxs(Dt.div,{className:_e.section,variants:gc,initial:"hidden",animate:"visible",custom:0,"data-testid":"dashboard-active-sessions",children:[l.jsxs("div",{className:_e.sectionHeader,children:[l.jsx("span",{className:_e.sectionIcon,"aria-hidden":"true",children:"●"}),l.jsx("span",{className:_e.sectionTitle,children:"Active Sessions"}),l.jsx("span",{className:_e.sectionCount,children:h.length})]}),l.jsx("div",{className:_e.sectionBody,children:h.length===0?l.jsx("div",{className:_e.emptyHint,children:"No active sessions"}):h.map(({session:_,environmentName:b})=>l.jsxs("button",{type:"button",className:_e.sessionRow,onClick:()=>u(Rp(_.id)),"data-testid":"session-row",children:[l.jsx("span",{className:_e.sessionPrompt,title:_.prompt,children:_.prompt||"—"}),l.jsx("span",{className:_e.sessionEnv,children:b}),l.jsx("span",{className:_e.sessionRuntime,children:_.runtime}),l.jsxs("span",{className:_e.sessionStatus,children:[l.jsx("span",{className:_e.statusDot,"data-status":_.status}),_.status]})]},_.id))})]}),l.jsxs(Dt.div,{className:_e.section,variants:gc,initial:"hidden",animate:"visible",custom:1,"data-testid":"dashboard-needs-attention",children:[l.jsxs("div",{className:_e.sectionHeader,children:[l.jsx("span",{className:_e.sectionIcon,"aria-hidden":"true",children:"⚑"}),l.jsx("span",{className:_e.sectionTitle,children:"Needs Attention"}),l.jsx("span",{className:_e.sectionCount,children:g.length})]}),l.jsx("div",{className:_e.sectionBody,children:g.length===0?l.jsx("div",{className:_e.emptyHint,children:"All clear"}):g.map(({task:_,reason:b,workspaceName:S})=>l.jsxs("button",{type:"button",className:_e.attentionRow,onClick:()=>u(Xn(_.id)),"data-testid":"attention-row",children:[l.jsxs("div",{className:_e.attentionTitle,children:[l.jsx("span",{className:_e.reasonBadge,"data-reason":b,children:b}),_.title]}),l.jsx("div",{className:_e.attentionMeta,children:l.jsx("span",{children:S})})]},_.id))})]})]}),l.jsxs("div",{className:_e.bottomGrid,children:[l.jsxs(Dt.div,{className:_e.section,variants:gc,initial:"hidden",animate:"visible",custom:2,"data-testid":"dashboard-env-health",children:[l.jsxs("div",{className:_e.sectionHeader,children:[l.jsx("span",{className:_e.sectionIcon,"aria-hidden":"true",children:"◈"}),l.jsx("span",{className:_e.sectionTitle,children:"Environment Health"}),l.jsx("span",{className:_e.sectionCount,children:o.length})]}),l.jsx("div",{className:_e.sectionBody,children:o.length===0?l.jsx("div",{className:_e.emptyHint,children:"No environments configured"}):o.map(_=>l.jsxs("div",{className:_e.envRow,"data-testid":"dashboard-env-row",children:[l.jsx("span",{className:_e.envName,children:_.displayName}),l.jsx("span",{className:_e.envStatusBadge,"data-status":_.status,children:_.status})]},_.id))})]}),l.jsxs(Dt.div,{className:_e.section,variants:gc,initial:"hidden",animate:"visible",custom:3,"data-testid":"dashboard-workspace-snapshot",children:[l.jsxs("div",{className:_e.sectionHeader,children:[l.jsx("span",{className:_e.sectionIcon,"aria-hidden":"true",children:"▦"}),l.jsx("span",{className:_e.sectionTitle,children:"Workspaces"}),l.jsx("span",{className:_e.sectionCount,children:t.length})]}),l.jsx("div",{className:_e.sectionBody,children:v.length===0?l.jsx("div",{className:_e.emptyHint,children:"No workspaces yet"}):v.map(({workspace:_,totalTasks:b,completedTasks:S,workingTasks:T,failedTasks:N})=>{const j=b>0?Math.round(S/b*100):0;return l.jsxs("button",{type:"button",className:_e.workspaceRow,onClick:()=>u(ni(_.id,_.environmentId)),"data-testid":"workspace-row",children:[l.jsxs("div",{className:_e.workspaceTop,children:[l.jsx("span",{className:_e.workspaceName,children:_.name}),l.jsxs("span",{className:_e.workspaceCounts,"aria-label":UL(S,b,T,N),children:[S,"/",b,T>0&&l.jsxs("span",{style:{color:"var(--accent-green)"},"aria-hidden":"true",children:["▸",T]}),N>0&&l.jsxs("span",{style:{color:"var(--accent-red)"},"aria-hidden":"true",children:["✗",N]})]})]}),b>0&&l.jsx("div",{className:_e.progressBar,children:l.jsx("div",{className:_e.progressFill,style:{width:`${j}%`}})})]},_.id)})})]})]})]})}const PL="_panelContainer_101ly_1",VL="_emptyState_101ly_8",HL="_fadeIn_101ly_1",$L="_workspaceSummary_101ly_17",GL="_workspaceSummaryTitle_101ly_28",qL="_workspaceSummarySubtitle_101ly_32",FL="_header_101ly_36",ZL="_headerInfo_101ly_71",KL="_killButton_101ly_77",YL="_headerTitle_101ly_106",JL="_headerActions_101ly_121",WL="_taskStatusBadge_101ly_128",XL="_taskBranch_101ly_137",QL="_taskBlockedBadge_101ly_143",e5="_btnPrimary_101ly_151",t5="_btnDanger_101ly_182",n5="_btnGhost_101ly_221",s5="_rejectInput_101ly_247",a5="_tabBar_101ly_277",i5="_tab_101ly_277",o5="_active_101ly_303",r5="_eventScroll_101ly_308",l5="_tabContent_101ly_314",c5="_noContext_101ly_319",u5="_overviewContent_101ly_325",d5="_overviewDashboard_101ly_334",f5="_overviewHero_101ly_340",p5="_statusBadge_101ly_347",m5="_statusPending_101ly_359",h5="_statusAssigned_101ly_364",g5="_statusInProgress_101ly_369",v5="_statusReview_101ly_374",y5="_statusDone_101ly_379",b5="_statusFailed_101ly_384",_5="_statusWaitingInput_101ly_389",x5="_overviewBranchPill_101ly_394",S5="_branchLink_101ly_409",T5="_overviewSection_101ly_420",k5="_overviewLabel_101ly_426",w5="_overviewValue_101ly_433",N5="_overviewMuted_101ly_438",j5="_overviewMarkdown_101ly_444",C5="_envRow_101ly_513",E5="_envDot_101ly_519",A5="_envDotGreen_101ly_526",D5="_envDotYellow_101ly_530",R5="_envDotRed_101ly_534",M5="_envDotGray_101ly_538",I5="_depList_101ly_542",O5="_depItem_101ly_548",B5="_depBlocked_101ly_555",L5="_depDone_101ly_559",U5="_timeline_101ly_563",z5="_timelineRow_101ly_569",P5="_timelineKey_101ly_576",V5="_timelineValue_101ly_582",H5="_timelineDelta_101ly_586",$5="_reviewNotes_101ly_597",G5="_overviewDescription_101ly_608",q5="_waitingMessage_101ly_614",F5="_errorMessage_101ly_618",Z5="_attemptSelector_101ly_622",K5="_attemptLabel_101ly_638",Y5="_attemptButton_101ly_642",J5="_attemptActive_101ly_659",W5="_attemptStatus_101ly_665",X5="_emptyCta_101ly_671",Q5="_ctaTitle_101ly_683",e8="_ctaDescription_101ly_689",t8="_ctaButton_101ly_696",n8="_ctaCreateForm_101ly_731",s8="_ctaCreateInput_101ly_737",a8="_ctaCreateOk_101ly_768",i8="_ctaLink_101ly_803",o8="_workspaceHeader_101ly_817",r8="_workspaceName_101ly_842",l8="_workspaceMeta_101ly_855",c8="_metaRow_101ly_863",u8="_metaLabel_101ly_876",d8="_metaValue_101ly_891",f8="_archiveButton_101ly_901",p8="_repoLink_101ly_931",m8="_metaToggle_101ly_941",h8="_metaToggleArrow_101ly_962",g8="_metaToggleArrowOpen_101ly_967",v8="_progressBarContainer_101ly_971",y8="_progressBar_101ly_971",b8="_progressFill_101ly_987",_8="_progressLabel_101ly_994",x8="_metaTimestamps_101ly_1001",S8="_metaTimestamp_101ly_1001",U={panelContainer:PL,emptyState:VL,fadeIn:HL,workspaceSummary:$L,workspaceSummaryTitle:GL,workspaceSummarySubtitle:qL,header:FL,headerInfo:ZL,killButton:KL,headerTitle:YL,headerActions:JL,taskStatusBadge:WL,taskBranch:XL,taskBlockedBadge:QL,btnPrimary:e5,btnDanger:t5,btnGhost:n5,rejectInput:s5,tabBar:a5,tab:i5,active:o5,eventScroll:r5,tabContent:l5,noContext:c5,overviewContent:u5,overviewDashboard:d5,overviewHero:f5,statusBadge:p5,statusPending:m5,statusAssigned:h5,statusInProgress:g5,statusReview:v5,statusDone:y5,statusFailed:b5,statusWaitingInput:_5,overviewBranchPill:x5,branchLink:S5,overviewSection:T5,overviewLabel:k5,overviewValue:w5,overviewMuted:N5,overviewMarkdown:j5,envRow:C5,envDot:E5,envDotGreen:A5,envDotYellow:D5,envDotRed:R5,envDotGray:M5,depList:I5,depItem:O5,depBlocked:B5,depDone:L5,timeline:U5,timelineRow:z5,timelineKey:P5,timelineValue:V5,timelineDelta:H5,reviewNotes:$5,overviewDescription:G5,waitingMessage:q5,errorMessage:F5,attemptSelector:Z5,attemptLabel:K5,attemptButton:Y5,attemptActive:J5,attemptStatus:W5,emptyCta:X5,ctaTitle:Q5,ctaDescription:e8,ctaButton:t8,ctaCreateForm:n8,ctaCreateInput:s8,ctaCreateOk:a8,ctaLink:i8,workspaceHeader:o8,workspaceName:r8,workspaceMeta:l8,metaRow:c8,metaLabel:u8,metaValue:d8,archiveButton:f8,repoLink:p8,metaToggle:m8,metaToggleArrow:h8,metaToggleArrowOpen:g8,progressBarContainer:v8,progressBar:y8,progressFill:b8,progressLabel:_8,metaTimestamps:x8,metaTimestamp:S8};function T8(){return l.jsx("div",{className:U.emptyState,children:"Select a task or click + to create one"})}function k8(){return l.jsx("div",{className:U.emptyState,children:"Select an environment to manage its workspaces, or add a new one."})}function w8(){const{workspaces:t,environments:s}=rt(),i=vt(),o=s.length>0;return t.length>0?l.jsx(zL,{}):l.jsxs("div",{className:U.emptyCta,"data-testid":"welcome-cta",children:[l.jsx("div",{className:U.ctaTitle,children:"Welcome to Grackle"}),l.jsx("div",{className:U.ctaDescription,children:"Organize your work into workspaces and let agents tackle the tasks."}),l.jsx("button",{className:U.ctaButton,onClick:()=>i($b),disabled:!o,"data-testid":"welcome-create-button",children:"Create Your First Workspace"}),!o&&l.jsx("div",{className:U.ctaDescription,children:"Add an environment first before creating a workspace."})]})}const N8="_panelContainer_19poq_1",j8="_chatHeader_19poq_8",C8="_chatHeaderInfo_19poq_37",E8="_emptyState_19poq_43",A8="_emptyTitle_19poq_55",D8="_emptyDescription_19poq_61",R8="_emptyHint_19poq_67",ei={panelContainer:N8,chatHeader:j8,chatHeaderInfo:C8,emptyState:E8,emptyTitle:A8,emptyDescription:D8,emptyHint:R8};function M8({hasLocalEnvironment:t}){return l.jsxs("div",{className:ei.emptyState,"data-testid":"chat-empty-state",children:[l.jsx("div",{className:ei.emptyTitle,children:"Welcome to Grackle"}),l.jsx("div",{className:ei.emptyDescription,children:t?"Type a message below to start chatting with the System agent. It can help you plan work, create tasks, and coordinate agents.":"Add a local environment in Settings to start chatting."}),!t&&l.jsx("div",{className:ei.emptyHint,children:"Go to Settings → Environments to add one."})]})}function I8(){const{tasks:t,sessions:s,events:i,eventsDropped:o,environments:c,loadTaskSessions:u,loadSessionEvents:d,kill:m,stopGraceful:h,taskSessions:g,sendInput:v,spawn:_,startTask:b,personas:S,provisionEnvironment:T}=rt(),{showToast:N}=dn(),j=y.useRef(void 0),[w,C]=y.useState(),A=t.find(F=>F.id===or),M=A!=null&&A.latestSessionId?s.find(F=>F.id===A.latestSessionId)??(g[or]??[]).find(F=>F.id===A.latestSessionId):void 0;y.useEffect(()=>{u(or)},[u]),y.useEffect(()=>{A!=null&&A.latestSessionId&&u(or)},[A==null?void 0:A.latestSessionId,u]),y.useEffect(()=>{M&&M.id!==j.current&&(j.current=M.id,d(M.id))},[M==null?void 0:M.id,d]);const D=y.useMemo(()=>{if(!M)return[];const F=i.filter(ee=>ee.sessionId===M.id);return _m(bm(F))},[i,M==null?void 0:M.id]),E=c.find(F=>F.adapterType==="local"&&F.status==="connected"),$=M!==void 0&&M.status!=="stopped"&&M.status!=="suspended",z=(M==null?void 0:M.status)==="idle";y.useEffect(()=>{w&&M&&z&&(v(M.id,w),C(void 0))},[w,z,M==null?void 0:M.id,v]);const K=y.useCallback((F,ee,ae,me)=>{me&&C(me),b(F,ee,ae)},[b]);return l.jsxs("div",{className:ei.panelContainer,"data-testid":"chat-page",children:[$&&l.jsxs("div",{className:ei.chatHeader,children:[l.jsxs("span",{className:ei.chatHeaderInfo,children:["Session: ",M.id.slice(0,8)," | ",M.runtime," | ",M.status]}),l.jsx(qb,{label:"Stop",onClick:()=>h(M.id),variant:"danger",size:"sm","data-testid":"stop-split-button",options:[{label:"Stop",description:"Graceful shutdown",onClick:()=>h(M.id)},{label:"Kill",description:"Force kill",onClick:()=>m(M.id)}]})]}),l.jsx(mm,{events:D,eventsDropped:o,emptyState:l.jsx(M8,{hasLocalEnvironment:!!E})}),E&&$&&l.jsx(kr,{mode:"send",sessionId:M.id,environmentId:M.environmentId,personas:S,environments:c,onSendInput:v,onSpawn:_,onStartTask:b,onProvisionEnvironment:T,onShowToast:N}),E&&!$&&l.jsx(kr,{mode:"start",taskId:or,environmentId:E.id,personas:S,environments:c,onSendInput:v,onSpawn:_,onStartTask:K,onProvisionEnvironment:T,onShowToast:N})]})}function O8(){const t=uB(),[s]=Dp(),i=s.get("env")??"",{sendInput:o,spawn:c,startTask:u,personas:d,environments:m,provisionEnvironment:h}=rt(),{showToast:g}=dn();return l.jsxs("div",{className:U.panelContainer,children:[l.jsx(fs,{segments:t}),l.jsx("div",{className:U.emptyState,children:"Enter a prompt below to start a new session"}),l.jsx(kr,{mode:"spawn",environmentId:i,showPersonaSelect:!0,personas:d,environments:m,onSendInput:o,onSpawn:c,onStartTask:u,onProvisionEnvironment:h,onShowToast:g})]})}function B8({sessionId:t,session:s,isActive:i,onStop:o,onKill:c}){return l.jsxs("div",{className:U.header,children:[l.jsxs("span",{children:["Session: ",t.slice(0,8),s&&` | ${s.runtime} | ${s.endReason||s.status}`,s!=null&&s.inputTokens||s!=null&&s.outputTokens||s!=null&&s.costUsd?` | ${Fb((s.inputTokens??0)+(s.outputTokens??0))} tokens · ${io(s.costUsd??0)}`:""]}),l.jsxs("span",{className:U.headerInfo,children:[s&&l.jsx("span",{children:s.prompt.length>60?s.prompt.slice(0,60)+"...":s.prompt}),i&&l.jsx(qb,{label:"Stop",onClick:o,variant:"danger",size:"sm","data-testid":"stop-split-button",options:[{label:"Stop",description:"Graceful shutdown",onClick:o},{label:"Kill",description:"Force kill",onClick:c}]})]})]})}function L8({session:t}){const s=t&&(t.status==="stopped"||t.status==="suspended"),i=s?`Session ${t.endReason||t.status} with no events recorded.`:"Waiting for events...";return l.jsx("div",{className:s?U.errorMessage:U.waitingMessage,children:i})}function U8(){const{sessionId:t}=Qn(),{events:s,eventsDropped:i,sessions:o,kill:c,stopGraceful:u,loadSessionEvents:d,sendInput:m,spawn:h,startTask:g,personas:v,environments:_,provisionEnvironment:b}=rt(),{showToast:S}=dn(),T=y.useRef(void 0),N=dB(t),j=o.find(A=>A.id===t)??void 0,w=y.useMemo(()=>{const A=t?s.filter(M=>M.sessionId===t):[];return _m(bm(A))},[s,t]);if(y.useEffect(()=>{t&&t!==T.current&&(T.current=t,d(t))},[t,d]),!t)return l.jsx("div",{className:U.emptyState,children:"No session selected"});const C=(j==null?void 0:j.status)==="running"||(j==null?void 0:j.status)==="idle";return l.jsxs("div",{className:U.panelContainer,children:[l.jsx(fs,{segments:N}),l.jsx(B8,{sessionId:t,session:j,isActive:C,onStop:()=>u(t),onKill:()=>c(t)}),l.jsx(mm,{events:w,eventsDropped:i,emptyState:l.jsx(L8,{session:j})}),C&&l.jsx(kr,{mode:"send",sessionId:t,environmentId:j.environmentId,personas:v,environments:_,onSendInput:m,onSpawn:h,onStartTask:g,onProvisionEnvironment:b,onShowToast:S})]})}function z8(t){if(!t)return!1;const s=t.tagName;return!!(s==="INPUT"||s==="TEXTAREA"||s==="SELECT"||t.isContentEditable)}function Us(t,s){const i=y.useRef(s);i.current=s;const{key:o,ctrl:c=!1,shift:u=!1,suppressInInputs:d=!0,enabled:m=!0}=t;y.useEffect(()=>{if(!m)return;const h=g=>{if(d&&z8(document.activeElement??void 0))return;const v=g.ctrlKey||g.metaKey;c===v&&(u&&!g.shiftKey||g.key===o&&i.current())};return document.addEventListener("keydown",h),()=>{document.removeEventListener("keydown",h)}},[o,c,u,d,m])}function cb(t){if(!t)return"";const s=new Date(t);if(isNaN(s.getTime()))return"";const o=Date.now()-s.getTime();if(o<0)return"just now";const c=Math.floor(o/6e4);if(c<1)return"just now";if(c<60)return`${c}m ago`;const u=Math.floor(c/60);if(u<24)return`${u}h ago`;const d=Math.floor(u/24);return d<30?`${d}d ago`:s.toLocaleDateString(void 0,{month:"short",day:"numeric",year:"numeric"})}const Ff=100;function P8(t){try{const s=new URL(t);return s.protocol!=="http:"&&s.protocol!=="https:"?void 0:s.toString()}catch{return}}function V8(){const{workspaceId:t,environmentId:s}=Qn(),i=vt(),{tasks:o,environments:c,workspaces:u,personas:d,sessions:m,archiveWorkspace:h,updateWorkspace:g,usageCache:v,loadUsage:_}=rt(),{resolvedThemeId:b}=Hx(),[S,T]=y.useState("tasks"),[N,j]=y.useState(!1),[w,C]=y.useState(null),[A,M]=y.useState(!1),D=y.useRef(void 0),E=u.find(X=>X.id===t),$=s??(E==null?void 0:E.environmentId)??"",z=fB(t,$,u,c);Us({key:"1"},()=>T("graph")),Us({key:"2"},()=>T("board")),Us({key:"3"},()=>T("tasks")),y.useEffect(()=>{const X=D.current;D.current=t,!(X===void 0||X===t)&&w!==null&&C(null)},[t,w]);const K=m.reduce((X,O)=>X+(O.costUsd??0),0);y.useEffect(()=>{t&&_("workspace",t)},[t,_,K]);const F=t?v[`workspace:${t}`]:void 0,ee=o.filter(X=>X.workspaceId===t),ae=ee.filter(X=>X.status==="complete").length,me=ee.length,ie=me>0?Math.round(ae/me*100):0;return l.jsxs("div",{className:U.panelContainer,children:[l.jsx(fs,{segments:z}),l.jsxs("div",{className:U.workspaceHeader,children:[l.jsx("span",{className:U.workspaceName,"data-testid":"workspace-name",children:l.jsx(Kt,{value:(E==null?void 0:E.name)||"",onSave:X=>{E&&g(E.id,{name:X})},validate:X=>{const O=X.trim();if(!O)return"Name is required";if(O.length>Ff)return`Max ${Ff} characters`},maxLength:Ff,fieldId:"name",activeFieldId:w,onActivate:C,ariaLabel:"Workspace name",renderDisplay:X=>X||t||void 0,"data-testid":"edit-name"})}),l.jsx("button",{className:U.archiveButton,onClick:()=>j(!0),title:"Archive workspace","data-testid":"archive-workspace-button",children:"Archive"})]}),l.jsxs("button",{className:U.metaToggle,onClick:()=>M(!A),"aria-expanded":!A,"aria-controls":"workspace-meta-panel","data-testid":"meta-toggle",children:[l.jsx("span",{className:`${U.metaToggleArrow} ${A?"":U.metaToggleArrowOpen}`,children:"▶"}),"Details"]}),!A&&l.jsxs("div",{className:U.workspaceMeta,"data-testid":"workspace-meta",id:"workspace-meta-panel",children:[l.jsxs("div",{className:U.metaRow,children:[l.jsx("span",{className:U.metaLabel,children:"Description"}),l.jsx("div",{className:U.metaValue,children:l.jsx(vp,{value:(E==null?void 0:E.description)||"",onSave:X=>{E&&g(E.id,{description:X})},fieldId:"description",activeFieldId:w,onActivate:C,renderDisplay:X=>X?l.jsx("span",{className:U.overviewMarkdown,children:l.jsx(Pc,{remarkPlugins:[Vc],children:X})}):void 0,placeholder:"No description",ariaLabel:"Workspace description","data-testid":"edit-description"})})]}),l.jsxs("div",{className:U.metaRow,children:[l.jsx("span",{className:U.metaLabel,children:"Repository"}),l.jsx("div",{className:U.metaValue,children:l.jsx(Kt,{value:(E==null?void 0:E.repoUrl)||"",onSave:X=>{E&&g(E.id,{repoUrl:X})},validate:X=>{const O=X.trim();if(O&&!/^https?:\/\/.+/.test(O))return"Must be a valid http(s) URL"},fieldId:"repoUrl",activeFieldId:w,onActivate:C,renderDisplay:X=>{const O=P8(X);return O?l.jsx("a",{className:U.repoLink,href:O,target:"_blank",rel:"noopener noreferrer",onClick:q=>q.stopPropagation(),children:X}):X?l.jsx("span",{children:X}):void 0},placeholder:"No repository",ariaLabel:"Workspace repository URL","data-testid":"edit-repo"})})]}),l.jsxs("div",{className:U.metaRow,children:[l.jsx("span",{className:U.metaLabel,children:"Environment"}),l.jsx("div",{className:U.metaValue,children:l.jsx(mM,{value:(E==null?void 0:E.environmentId)||"",onSave:X=>{E&&X&&g(E.id,{environmentId:X})},environments:c,fieldId:"environmentId",activeFieldId:w,onActivate:C,placeholder:"Select environment",ariaLabel:"Workspace environment","data-testid":"edit-env"})})]}),l.jsxs("div",{className:U.metaRow,children:[l.jsx("span",{className:U.metaLabel,children:"Persona"}),l.jsx("div",{className:U.metaValue,children:l.jsx(Bc,{value:(E==null?void 0:E.defaultPersonaId)||"",onSave:X=>{E&&g(E.id,{defaultPersonaId:X})},options:[{value:"",label:"(Inherit)"},...d.map(X=>({value:X.id,label:X.name}))],fieldId:"defaultPersonaId",activeFieldId:w,onActivate:C,renderDisplay:X=>{const O=d.find(q=>q.id===X);if(O)return l.jsx("span",{children:O.name})},placeholder:(E==null?void 0:E.defaultPersonaId)||"(Inherit)",ariaLabel:"Workspace default persona","data-testid":"edit-persona"})})]}),l.jsxs("div",{className:U.metaRow,children:[l.jsx("span",{className:U.metaLabel,children:"Worktrees"}),l.jsx("div",{className:U.metaValue,children:l.jsx(oM,{checked:(E==null?void 0:E.useWorktrees)??!0,onChange:X=>{E&&g(E.id,{useWorktrees:X})},label:"Enable worktree isolation","data-testid":"worktree-toggle"})})]}),l.jsxs("div",{className:U.metaRow,children:[l.jsx("span",{className:U.metaLabel,children:"Working Dir"}),l.jsx("div",{className:U.metaValue,children:l.jsx(Kt,{value:(E==null?void 0:E.workingDirectory)||"",onSave:X=>{E&&g(E.id,{workingDirectory:X})},fieldId:"workingDirectory",activeFieldId:w,onActivate:C,placeholder:"Default (server default)",ariaLabel:"Working directory","data-testid":"edit-working-directory"})})]}),E&&l.jsxs("div",{className:U.metaTimestamps,children:[l.jsxs("span",{className:U.metaTimestamp,children:["Created ",cb(E.createdAt)]}),E.updatedAt&&E.updatedAt!==E.createdAt&&l.jsxs("span",{className:U.metaTimestamp,children:["· Updated ",cb(E.updatedAt)]})]})]}),me>0&&l.jsxs("div",{className:U.progressBarContainer,"data-testid":"progress-bar",children:[l.jsx("div",{className:U.progressBar,children:l.jsx("div",{className:U.progressFill,style:{width:`${ie}%`}})}),l.jsxs("span",{className:U.progressLabel,children:[ae,"/",me]})]}),F&&F.costUsd>0&&l.jsx("div",{className:U.progressBarContainer,children:l.jsxs("span",{className:U.progressLabel,children:["Usage: ",io(F.costUsd)," (",F.sessionCount," session",F.sessionCount!==1?"s":"",")"]})}),l.jsxs("div",{className:U.tabBar,role:"tablist","aria-label":"Workspace view",children:[l.jsx("button",{role:"tab","aria-selected":S==="graph",className:`${U.tab} ${S==="graph"?U.active:""}`,onClick:()=>T("graph"),children:"Graph"}),l.jsx("button",{role:"tab","aria-selected":S==="board",className:`${U.tab} ${S==="board"?U.active:""}`,onClick:()=>T("board"),"data-testid":"board-tab",children:"Board"}),l.jsx("button",{role:"tab","aria-selected":S==="tasks",className:`${U.tab} ${S==="tasks"?U.active:""}`,onClick:()=>T("tasks"),children:"Tasks"})]}),S==="tasks"&&me>0&&l.jsxs("div",{className:U.workspaceSummary,children:[l.jsx("span",{className:U.workspaceSummaryTitle,children:`${ae}/${me} tasks complete`}),l.jsx("span",{className:U.workspaceSummarySubtitle,children:"Select a task or click + to create one"})]}),S==="tasks"&&me===0&&l.jsxs("div",{className:U.emptyCta,children:[l.jsx("button",{className:U.ctaButton,onClick:()=>i(ri(t,void 0,$)),children:"Create Task"}),l.jsx("div",{className:U.ctaDescription,children:"Break your work into tasks and let agents tackle them"})]}),S==="board"&&l.jsx(O4,{workspaceId:t,environmentId:$,tasks:o,sessions:m,personas:d,environments:c}),S==="graph"&&l.jsx(d2,{workspaceId:t,environmentId:$,tasks:o,resolvedThemeId:b}),l.jsx(ii,{isOpen:N,title:"Archive Workspace?",description:"This will hide the workspace from the sidebar. Tasks will not be deleted.",confirmLabel:"Archive",onConfirm:()=>{E&&(h(E.id),i("/",{replace:!0})),j(!1)},onCancel:()=>j(!1)})]})}const H8="_container_3pgew_1",$8="_header_3pgew_8",G8="_headerTitle_3pgew_35",q8="_headerActions_3pgew_44",F8="_body_3pgew_51",Z8="_btnPrimary_3pgew_63",K8="_btnGhost_3pgew_94",Y8="_error_3pgew_116",ya={container:H8,header:$8,headerTitle:G8,headerActions:q8,body:F8,btnPrimary:Z8,btnGhost:K8,error:Y8};function J8(t){const s={};return t.name.trim()||(s.name="Name is required"),t.repoUrl.trim()&&!/^https?:\/\/.+/i.test(t.repoUrl.trim())&&(s.repoUrl="Must be a valid http(s) URL"),t.environmentId||(s.environmentId="Environment is required"),Object.keys(s).length>0?s:void 0}const W8=[{label:"Home",url:ai},{label:"New Workspace",url:void 0}];function X8(){const[t]=Dp(),s=t.get("environment")??void 0,{environments:i,personas:o,createWorkspace:c,workspaceCreating:u}=rt(),{showToast:d}=dn(),m=vt(),[h,g]=y.useState(()=>{var j;return F4(void 0,s||((j=i[0])==null?void 0:j.id))}),[v,_]=y.useState(),[b,S]=y.useState();y.useEffect(()=>{s||h.environmentId||i.length===0||g(j=>{var w;return j.environmentId?j:{...j,environmentId:((w=i[0])==null?void 0:w.id)??""}})},[i,s,h.environmentId]);const T=()=>{const j=J8(h);if(j){_(j),S(void 0);return}_(void 0),S(void 0),c(h.name.trim(),h.description,h.repoUrl.trim(),h.environmentId,h.defaultPersonaId,h.useWorktrees,h.workingDirectory,()=>{d("Workspace created","success"),m(ai,{replace:!0})},w=>{S(w)})},N=()=>{m(s?si(s):ai,{replace:!0})};return l.jsxs("div",{className:ya.container,children:[l.jsxs("div",{className:ya.header,children:[l.jsx("div",{className:ya.headerTitle,children:l.jsx(fs,{segments:W8})}),l.jsxs("div",{className:ya.headerActions,children:[l.jsx("button",{className:ya.btnGhost,onClick:N,disabled:u,"data-testid":"workspace-create-cancel",children:"Cancel"}),l.jsx("button",{className:ya.btnPrimary,onClick:T,disabled:u||!h.name.trim()||!h.environmentId,"data-testid":"workspace-create-save",children:u?l.jsx(Sx,{size:"sm",label:"Creating"}):"Create Workspace"})]})]}),l.jsxs("div",{className:ya.body,children:[l.jsx(K4,{values:h,onChange:j=>{g(j),_(void 0),S(void 0)},environments:i,personas:o,errors:v,disabled:u,autoFocusName:!0}),b&&l.jsx("div",{className:ya.error,"data-testid":"workspace-create-submit-error",children:b})]})]})}function ub(){const{workspaceId:t,environmentId:s}=Qn(),[i]=Dp(),o=t??i.get("workspace")??"",c=i.get("parent")??void 0,{tasks:u,workspaces:d,personas:m,createTask:h,updateTask:g}=rt(),{showToast:v}=dn();return l.jsx(Ox,{mode:"new",workspaceId:o,parentTaskId:c,environmentId:s,tasks:u,workspaces:d,personas:m,onCreateTask:h,onUpdateTask:g,onShowToast:v})}function yc(t){if(!t)return"—";const s=new Date(t);return isNaN(s.getTime())?"—":s.toLocaleString(void 0,{month:"short",day:"numeric",year:"numeric",hour:"2-digit",minute:"2-digit"})}function Zf(t,s){if(!t||!s)return;const i=new Date(s).getTime()-new Date(t).getTime();if(isNaN(i)||i<0)return;const o=Math.floor(i/6e4),c=Math.floor(i%6e4/1e3);if(o===0)return`${c}s`;const u=Math.floor(o/60),d=o%60;return u===0?`${o}m ${c}s`:`${u}h ${d}m`}function db(t){const s=t.toLowerCase();return s==="ready"||s==="running"||s==="available"||s==="connected"?U.envDotGreen:s==="provisioning"||s==="starting"||s==="pending"||s==="connecting"?U.envDotYellow:s==="error"||s==="failed"||s==="disconnected"?U.envDotRed:U.envDotGray}function Q8({status:t}){const s=Sa(t),i=sk(t);return l.jsx("span",{className:`${U.statusBadge} ${U[i]??U.statusPending}`,children:s.label})}function eU({task:t,tasksById:s,environments:i,workspaces:o,taskSessions:c,selectedEnvId:u}){const{loadUsage:d,usageCache:m}=rt(),h=c.reduce((A,M)=>A+(M.costUsd??0),0);y.useEffect(()=>{d("task",t.id),t.childTaskIds.length>0&&d("task_tree",t.id)},[t.id,t.childTaskIds.length,d,h]);const g=`task:${t.id}`,v=g in m?m[g]:void 0,_=`task_tree:${t.id}`,b=t.childTaskIds.length>0&&_ in m?m[_]:void 0,S=c.length>0?c[c.length-1]:void 0,T=(S==null?void 0:S.environmentId)??"",N=T?i.find(A=>A.id===T):void 0,j=o.find(A=>A.id===t.workspaceId),w=i.find(A=>A.id===u),C=t.branch&&(j!=null&&j.repoUrl)?`${j.repoUrl.replace(/\/$/,"")}/tree/${encodeURIComponent(t.branch)}`:void 0;return l.jsxs("div",{className:U.overviewDashboard,children:[l.jsxs("div",{className:U.overviewHero,children:[l.jsx(Q8,{status:t.status}),t.branch&&l.jsx("span",{className:U.overviewBranchPill,children:C?l.jsxs("a",{href:C,target:"_blank",rel:"noreferrer noopener",className:U.branchLink,children:["🔗"," ",t.branch]}):l.jsxs("span",{children:["🔗"," ",t.branch]})})]}),typeof t.description=="string"&&t.description&&l.jsxs("div",{className:U.overviewSection,children:[l.jsx("div",{className:U.overviewLabel,children:"Description"}),l.jsx("div",{className:U.overviewMarkdown,children:l.jsx(Pc,{remarkPlugins:[Vc],children:t.description})})]}),t.workpad&&l.jsx(jO,{workpad:t.workpad}),l.jsxs("div",{className:U.overviewSection,children:[l.jsx("div",{className:U.overviewLabel,children:"Environment"}),T&&N?l.jsxs("div",{className:U.envRow,"data-testid":"task-overview-environment",children:[l.jsx("span",{className:`${U.envDot} ${db(N.status)}`,title:N.status,"aria-label":`Status: ${N.status}`,role:"img"}),l.jsx("span",{className:U.overviewValue,children:N.displayName})]}):w?l.jsxs("div",{className:U.envRow,"data-testid":"task-overview-environment",children:[l.jsx("span",{className:`${U.envDot} ${db(w.status)}`,title:w.status,"aria-label":`Status: ${w.status}`,role:"img"}),l.jsx("span",{className:U.overviewValue,children:w.displayName}),l.jsx("span",{className:U.overviewMuted,children:"(workspace default)"})]}):l.jsx("div",{className:U.overviewMuted,children:"Set in workspace settings"})]}),l.jsxs("div",{className:U.overviewSection,"data-testid":"task-overview-dependencies",children:[l.jsx("div",{className:U.overviewLabel,children:"Dependencies"}),t.dependsOn.length===0?l.jsx("div",{className:U.overviewMuted,children:"None"}):l.jsx("div",{className:U.depList,children:t.dependsOn.map(A=>{const M=s.get(A),D=(M==null?void 0:M.status)==="complete";return l.jsxs("div",{className:`${U.depItem} ${D?U.depDone:U.depBlocked}`,children:[l.jsx("span",{children:D?"✓":"○"}),l.jsx("span",{children:(M==null?void 0:M.title)??A})]},A)})})]}),l.jsxs("div",{className:U.overviewSection,children:[l.jsx("div",{className:U.overviewLabel,children:"Timeline"}),l.jsxs("div",{className:U.timeline,children:[t.createdAt&&l.jsxs("div",{className:U.timelineRow,children:[l.jsx("span",{className:U.timelineKey,children:"Created"}),l.jsx("span",{className:U.timelineValue,children:yc(t.createdAt)})]}),t.assignedAt&&(()=>{const A=Zf(t.createdAt,t.assignedAt);return l.jsxs("div",{className:U.timelineRow,children:[l.jsx("span",{className:U.timelineKey,children:"Assigned"}),l.jsx("span",{className:U.timelineValue,children:yc(t.assignedAt)}),A!==void 0&&l.jsx("span",{className:U.timelineDelta,children:A})]})})(),t.startedAt&&(()=>{const A=Zf(t.assignedAt??t.createdAt,t.startedAt);return l.jsxs("div",{className:U.timelineRow,children:[l.jsx("span",{className:U.timelineKey,children:"Started"}),l.jsx("span",{className:U.timelineValue,children:yc(t.startedAt)}),A!==void 0&&l.jsx("span",{className:U.timelineDelta,children:A})]})})(),t.completedAt&&(()=>{const A=Zf(t.startedAt,t.completedAt);return l.jsxs("div",{className:U.timelineRow,children:[l.jsx("span",{className:U.timelineKey,children:"Completed"}),l.jsx("span",{className:U.timelineValue,children:yc(t.completedAt)}),A!==void 0&&l.jsx("span",{className:U.timelineDelta,children:A})]})})(),!t.createdAt&&!t.assignedAt&&!t.startedAt&&!t.completedAt&&l.jsx("div",{className:U.overviewMuted,children:"No timing data"})]})]}),v&&v.costUsd>0&&l.jsxs("div",{className:U.overviewSection,children:[l.jsx("div",{className:U.overviewLabel,children:"Usage"}),l.jsxs("div",{className:U.timeline,children:[l.jsxs("div",{className:U.timelineRow,children:[l.jsx("span",{className:U.timelineKey,children:"Cost"}),l.jsx("span",{className:U.timelineValue,children:io(v.costUsd)}),l.jsxs("span",{className:U.timelineDelta,children:[v.sessionCount," session",v.sessionCount!==1?"s":""]})]}),b&&b.costUsd>v.costUsd&&l.jsxs("div",{className:U.timelineRow,children:[l.jsx("span",{className:U.timelineKey,children:"Total (incl. subtasks)"}),l.jsx("span",{className:U.timelineValue,children:io(b.costUsd)}),l.jsxs("span",{className:U.timelineDelta,children:[b.sessionCount," session",b.sessionCount!==1?"s":""]})]})]})]}),t.reviewNotes&&l.jsxs("div",{className:U.overviewSection,children:[l.jsx("div",{className:U.overviewLabel,children:"Review Notes"}),l.jsx("div",{className:U.reviewNotes,children:t.reviewNotes})]})]})}function tU({task:t,sessionId:s,isBlocked:i,onStart:o,onResume:c,onStop:u,onPause:d,onDelete:m,onEdit:h}){if(t.status==="not_started")return i?l.jsxs("div",{className:U.headerActions,children:[l.jsx("button",{onClick:h,className:U.btnGhost,children:"Edit"}),l.jsx("button",{onClick:m,className:U.btnDanger,children:"Delete"})]}):l.jsxs("div",{className:U.headerActions,children:[l.jsx("button",{"data-testid":"task-header-start",onClick:o,className:U.btnPrimary,children:"Start"}),l.jsx("button",{onClick:h,className:U.btnGhost,children:"Edit"}),l.jsx("button",{onClick:m,className:U.btnDanger,children:"Delete"})]});if(t.status==="working")return l.jsxs("div",{className:U.headerActions,children:[l.jsx("button",{onClick:u,className:U.btnDanger,children:"Stop"}),l.jsx("button",{onClick:d,disabled:!s,className:U.btnGhost,children:"Pause"})]});if(t.status==="paused")return l.jsxs("div",{className:U.headerActions,children:[l.jsx("button",{onClick:u,className:U.btnPrimary,children:"Stop"}),l.jsx("button",{onClick:c,className:U.btnGhost,children:"Resume"}),l.jsx("button",{onClick:m,className:U.btnDanger,children:"Delete"})]});if(t.status==="complete")return l.jsx("div",{className:U.headerActions,children:l.jsx("button",{onClick:m,className:U.btnDanger,children:"Delete"})});if(t.status==="failed")return l.jsxs("div",{className:U.headerActions,children:[l.jsx("button",{onClick:o,className:U.btnPrimary,children:"Retry"}),l.jsx("button",{onClick:m,className:U.btnDanger,children:"Delete"})]})}function nU({taskSessions:t,selectedSessionId:s,onSelect:i}){if(!(t.length<2))return l.jsxs("div",{className:U.attemptSelector,"data-testid":"attempt-selector",children:[l.jsx("span",{className:U.attemptLabel,children:"Attempts:"}),t.map((o,c)=>{const u=o.id===s,d=o.status==="stopped"&&o.endReason==="completed"?"✓":o.status==="stopped"?"✗":o.status==="running"||o.status==="idle"?"●":"";return l.jsxs("button",{className:`${U.attemptButton} ${u?U.attemptActive:""}`,onClick:()=>i(o.id),title:`Attempt #${c+1} — ${o.status}`,"aria-label":`Attempt #${c+1}, ${o.status}`,"aria-pressed":u,"data-testid":`attempt-${c+1}`,children:["#",c+1,d&&l.jsx("span",{className:U.attemptStatus,children:d})]},o.id)})]})}function ba(){const{taskId:t,workspaceId:s,environmentId:i}=Qn(),o=Ut(),c=vt(),{showToast:u}=dn(),{events:d,eventsDropped:m,tasks:h,sessions:g,environments:v,findings:_,loadSessionEvents:b,loadFindings:S,kill:T,startTask:N,stopTask:j,resumeTask:w,deleteTask:C,createTask:A,updateTask:M,workspaces:D,taskSessions:E,loadTaskSessions:$,sendInput:z,spawn:K,personas:F,provisionEnvironment:ee}=rt(),ae=y.useRef(void 0),me=y.useRef(void 0),ie=y.useRef(void 0),X=y.useRef(void 0),O=y.useRef(void 0),q=o.pathname.endsWith("/stream")?"stream":o.pathname.endsWith("/findings")?"findings":"overview",te=o.pathname.endsWith("/edit"),[re,ue]=y.useState(q),[Fe,Ne]=y.useState(!1),[ke,Me]=y.useState(void 0),[le,ve]=y.useState(""),[de,Ie]=y.useState(te),yt=y.useRef(q),fn=y.useRef(te),B=h.find(Ae=>Ae.id===t),Re=(B==null?void 0:B.workspaceId)||void 0,Qe=D.find(Ae=>Ae.id===Re);y.useEffect(()=>{q!==yt.current&&(yt.current=q,q!==re&&ue(q))},[q,re]),y.useEffect(()=>{te!==fn.current&&(fn.current=te,te!==de&&Ie(te))},[te,de]),y.useEffect(()=>{if(le===""){if(Qe!=null&&Qe.environmentId)ve(Qe.environmentId);else if(v.length>0){const Ae=v.find(We=>We.status==="connected");ve((Ae==null?void 0:Ae.id)??v[0].id)}}},[le,Qe==null?void 0:Qe.environmentId,v]);const et=B?E[B.id]??[]:[];let $e;ke&&et.some(Ae=>Ae.id===ke)?$e=ke:$e=(B==null?void 0:B.latestSessionId)||void 0;const es=()=>{Ne(!0)},Hs=()=>{if(!B)return;C(B.id),Ne(!1);const Ae=i??(Qe==null?void 0:Qe.environmentId);c(B.workspaceId&&Ae?ni(B.workspaceId,Ae):"/",{replace:!0})};y.useEffect(()=>{(B==null?void 0:B.id)!==me.current&&(me.current=B==null?void 0:B.id,Me(void 0),ve(""),Ie(te))},[B==null?void 0:B.id,te]),y.useEffect(()=>{if(!(B!=null&&B.id))return;const Ae=B.id!==X.current,We=B.latestSessionId!==O.current;(Ae||We)&&(X.current=B.id,O.current=B.latestSessionId,$(B.id))},[B==null?void 0:B.id,B==null?void 0:B.latestSessionId,$]),y.useEffect(()=>{if((B==null?void 0:B.status)!==ie.current){const Ae=ie.current===void 0;ie.current=B==null?void 0:B.status;const We=(B==null?void 0:B.status)==="not_started"?"overview":(B==null?void 0:B.status)==="working"||(B==null?void 0:B.status)==="paused"?"stream":(B==null?void 0:B.status)==="complete"?"findings":void 0;We&&We!==re&&!(Ae&&q!=="overview")&&ue(We)}},[B==null?void 0:B.status,re,q]);const kn=y.useMemo(()=>new Map(h.map(Ae=>[Ae.id,Ae])),[h]),Vn=y.useMemo(()=>{const Ae=$e?d.filter(We=>We.sessionId===$e):[];return _m(bm(Ae))},[d,$e]),ts=B?B.dependsOn.some(Ae=>{const We=kn.get(Ae);return We!==void 0&&We.status!=="complete"}):!1,$s=y.useMemo(()=>pB(t,i,D,v,kn),[t,i,D,v,kn]);y.useEffect(()=>{$e&&$e!==ae.current&&(ae.current=$e,b($e))},[$e,b]),y.useEffect(()=>{re==="findings"&&Re&&S(Re)},[re,Re,S]);const Hn=Ae=>{ue(Ae),c(Xn(t,Ae==="overview"?void 0:Ae,s,i))};return Us({key:"1"},()=>Hn("overview")),Us({key:"2"},()=>Hn("stream")),Us({key:"3"},()=>Hn("findings")),l.jsxs("div",{className:U.panelContainer,children:[l.jsx(fs,{segments:$s}),l.jsxs("div",{className:U.header,children:[l.jsxs("span",{className:U.headerTitle,children:[l.jsx("span",{"data-testid":"task-title",children:(B==null?void 0:B.title)||t}),B&&l.jsx("span",{className:U.taskStatusBadge,"data-testid":"task-status",children:B.status}),(B==null?void 0:B.branch)&&l.jsx("span",{className:U.taskBranch,children:B.branch}),ts&&l.jsx("span",{className:U.taskBlockedBadge,children:"blocked"})]}),B&&l.jsx(tU,{task:B,sessionId:$e,isBlocked:ts,onStart:()=>N(B.id,void 0,le),onResume:()=>w(B.id),onStop:()=>j(B.id),onPause:()=>$e&&T($e),onDelete:es,onEdit:()=>Ie(!0)})]}),l.jsxs("div",{className:U.tabBar,role:"tablist","aria-label":"Task view",children:[l.jsx("button",{role:"tab","aria-selected":re==="overview",className:`${U.tab} ${re==="overview"?U.active:""}`,onClick:()=>Hn("overview"),children:"Overview"}),l.jsx("button",{role:"tab","aria-selected":re==="stream",className:`${U.tab} ${re==="stream"?U.active:""}`,onClick:()=>Hn("stream"),children:"Stream"}),l.jsx("button",{role:"tab","aria-selected":re==="findings",className:`${U.tab} ${re==="findings"?U.active:""}`,onClick:()=>Hn("findings"),children:"Findings"})]}),l.jsxs(ds,{mode:"wait",children:[re==="overview"&&l.jsx(Dt.div,{initial:{opacity:0,y:4},animate:{opacity:1,y:0},exit:{opacity:0,y:-4},transition:{duration:.15},className:U.overviewContent,"data-testid":"task-overview",children:de&&B?l.jsx(Ox,{mode:"edit",taskId:B.id,workspaceId:Re,environmentId:i,tasks:h,workspaces:D,personas:F,onCreateTask:A,onUpdateTask:M,onEditDone:()=>{te?c(Xn(B.id,void 0,s,i),{replace:!0}):Ie(!1)},onShowToast:u}):B?l.jsx(eU,{task:B,tasksById:kn,environments:v,workspaces:D,taskSessions:et,selectedEnvId:le}):l.jsx("div",{className:U.waitingMessage,children:"No additional details"})},"overview"),re==="stream"&&l.jsxs(Dt.div,{initial:{opacity:0,y:4},animate:{opacity:1,y:0},exit:{opacity:0,y:-4},transition:{duration:.15},style:{display:"flex",flexDirection:"column",flex:1,overflow:"hidden"},children:[l.jsx(nU,{taskSessions:et,selectedSessionId:$e,onSelect:Ae=>Me(Ae)}),l.jsx(mm,{events:Vn,eventsDropped:m,emptyState:!$e&&B?ts?l.jsx("div",{className:U.emptyCta,"data-testid":"stream-blocked-message",children:l.jsx("div",{className:U.ctaDescription,children:"This task is blocked by incomplete dependencies"})}):l.jsxs("div",{className:U.emptyCta,children:[l.jsx("button",{"data-testid":"stream-start-cta",className:U.ctaButton,onClick:()=>N(B.id,void 0,le),children:"Start Task"}),l.jsx("div",{className:U.ctaDescription,children:"Click to begin agent execution"})]}):$e&&Vn.length===0?l.jsx("div",{className:U.waitingMessage,children:"Waiting for events..."}):void 0})]},"stream"),re==="findings"&&l.jsx(Dt.div,{initial:{opacity:0,y:4},animate:{opacity:1,y:0},exit:{opacity:0,y:-4},transition:{duration:.15},className:U.tabContent,children:Re?l.jsx(Mx,{findings:_.filter(Ae=>Ae.workspaceId===Re)}):l.jsx("div",{className:U.noContext,children:"Navigate to a task within a workspace to view findings"})},"findings")]}),(()=>{if(!B||B.status!=="working"&&B.status!=="paused")return;const Ae=$e?g.find(We=>We.id===$e):void 0;if(!(!Ae||Ae.status==="stopped"))return l.jsx(kr,{mode:"send",sessionId:Ae.id,environmentId:Ae.environmentId,personas:F,environments:v,onSendInput:z,onSpawn:K,onStartTask:N,onProvisionEnvironment:ee,onShowToast:u})})(),B&&l.jsx(ii,{isOpen:Fe,title:"Delete Task?",description:`"${B.title}" will be permanently removed.`,onConfirm:Hs,onCancel:()=>Ne(!1)})]})}function sU(){const{environments:t,addEnvironment:s,updateEnvironment:i,listCodespaces:o,codespaces:c,codespaceError:u,codespaceListError:d,codespaceCreating:m,createCodespace:h}=rt(),{showToast:g}=dn();return l.jsx(Bx,{mode:"new",environments:t,onAddEnvironment:s,onUpdateEnvironment:i,onListCodespaces:o,codespaces:c,codespaceError:u,codespaceListError:d,codespaceCreating:m,onCreateCodespace:h,onShowToast:g})}function aU(){const{environmentId:t}=Qn(),{environments:s,addEnvironment:i,updateEnvironment:o,listCodespaces:c,codespaces:u,codespaceError:d,codespaceListError:m,codespaceCreating:h,createCodespace:g}=rt(),{showToast:v}=dn();return l.jsx(Bx,{mode:"edit",environmentId:t,environments:s,onAddEnvironment:i,onUpdateEnvironment:o,onListCodespaces:c,codespaces:u,codespaceError:d,codespaceListError:m,codespaceCreating:h,onCreateCodespace:g,onShowToast:v})}const iU="_layout_11u79_1",oU="_content_11u79_8",rU="_tabPanel_11u79_14",Tr={layout:iU,content:oU,tabPanel:rU};function lU(){const t=cB();return l.jsxs("div",{className:Tr.layout,children:[l.jsx(fs,{segments:t}),l.jsx("div",{className:Tr.content,children:l.jsx(wa,{})})]})}const cU="_container_13sb6_1",uU="_envHeader_13sb6_6",dU="_envTitleRow_13sb6_10",fU="_statusDot_13sb6_16",pU="_envName_13sb6_21",mU="_statusBadge_13sb6_27",hU="_envMeta_13sb6_33",gU="_metaTag_13sb6_39",vU="_actions_13sb6_51",yU="_provisionMessage_13sb6_59",bU="_errorMessage_13sb6_64",_U="_section_13sb6_69",xU="_sectionHeader_13sb6_73",SU="_cardList_13sb6_121",TU="_card_13sb6_121",kU="_cardHeader_13sb6_138",wU="_cardName_13sb6_144",NU="_cardActions_13sb6_149",jU="_cardDescription_13sb6_154",CU="_cardMeta_13sb6_160",EU="_repoLink_13sb6_166",AU="_empty_13sb6_174",DU="_btnPrimary_13sb6_180",RU="_btnOutline_13sb6_214",MU="_btnSmall_13sb6_241",IU="_btnDanger_13sb6_267",Ve={container:cU,envHeader:uU,envTitleRow:dU,statusDot:fU,envName:pU,statusBadge:mU,envMeta:hU,metaTag:gU,actions:vU,provisionMessage:yU,errorMessage:bU,section:_U,sectionHeader:xU,cardList:SU,card:TU,cardHeader:kU,cardName:wU,cardActions:NU,cardDescription:jU,cardMeta:CU,repoLink:EU,empty:AU,btnPrimary:DU,btnOutline:RU,btnSmall:MU,btnDanger:IU},OU={connected:"var(--accent-green)",sleeping:"var(--accent-yellow)",error:"var(--accent-red)",disconnected:"var(--text-tertiary)",connecting:"var(--accent-blue)"};function BU(){const{environmentId:t}=Qn(),s=vt(),{environments:i,workspaces:o,sessions:c,provisionStatus:u,provisionEnvironment:d,stopEnvironment:m,removeEnvironment:h,archiveWorkspace:g}=rt(),[v,_]=y.useState(!1),[b,S]=y.useState(!1),[T,N]=y.useState(void 0),j=i.find(ae=>ae.id===t);if(!t||!j)return l.jsx(Wn,{to:ao,replace:!0});const w=o.filter(ae=>ae.environmentId===j.id),C=c.filter(ae=>ae.environmentId===j.id),A=C.reduce((ae,me)=>ae+(me.costUsd??0),0),M=OU[j.status]||"var(--text-tertiary)",D=j.status==="connected",E=j.status==="connecting",$=j.status==="disconnected"||j.status==="error",z=j.id in u?u[j.id]:void 0,K=()=>{h(j.id),_(!1),s(ao,{replace:!0})},F=()=>{S(!1),d(j.id,!0)},ee=ae=>{g(ae),N(void 0)};return l.jsxs("div",{className:Ve.container,children:[l.jsx(ii,{isOpen:v,title:"Delete Environment?",description:`"${j.displayName||j.id}" will be permanently removed along with all its data.`,onConfirm:K,onCancel:()=>_(!1)}),l.jsx(ii,{isOpen:b,title:"Reprovision Environment?",description:"This will kill any active session and force a fresh provision cycle. The environment will be temporarily disconnected.",confirmLabel:"Reprovision",onConfirm:F,onCancel:()=>S(!1)}),l.jsxs("div",{className:Ve.envHeader,children:[l.jsxs("div",{className:Ve.envTitleRow,children:[l.jsx("span",{className:Ve.statusDot,style:{color:M},children:"●"}),l.jsx("h2",{className:Ve.envName,children:j.displayName||j.id}),l.jsx("span",{className:Ve.statusBadge,style:{color:M},children:j.status})]}),l.jsxs("div",{className:Ve.envMeta,children:[l.jsxs("span",{className:Ve.metaTag,children:["Adapter: ",j.adapterType]}),C.length>0&&l.jsxs("span",{className:Ve.metaTag,children:[C.length," session",C.length!==1?"s":""]}),A>0&&l.jsxs("span",{className:Ve.metaTag,children:["Cost: ",io(A)]})]})]}),l.jsxs("div",{className:Ve.actions,children:[D&&l.jsxs(l.Fragment,{children:[l.jsx("button",{className:Ve.btnPrimary,onClick:()=>s(Vb(j.id)),children:"New Chat"}),l.jsx("button",{className:Ve.btnOutline,onClick:()=>m(j.id),children:"Stop"}),l.jsx("button",{className:Ve.btnOutline,onClick:()=>S(!0),disabled:z!==void 0,"data-testid":"env-reprovision-btn",children:"Reprovision"})]}),$&&l.jsx("button",{className:Ve.btnPrimary,onClick:()=>d(j.id),children:j.status==="error"?"Retry":"Connect"}),E&&z!==void 0&&l.jsx("span",{className:Ve.provisionMessage,children:z.message}),j.status==="error"&&(z==null?void 0:z.stage)==="error"&&l.jsx("span",{className:Ve.errorMessage,children:z.message}),l.jsx("button",{className:Ve.btnOutline,onClick:()=>s(t2(j.id)),"data-testid":"env-edit-btn",children:"Edit Config"}),l.jsx("button",{className:Ve.btnDanger,onClick:()=>_(!0),children:"Delete"})]}),l.jsxs("div",{className:Ve.section,children:[l.jsxs("div",{className:Ve.sectionHeader,children:[l.jsx("h3",{children:"Workspaces"}),l.jsx("button",{className:Ve.btnPrimary,onClick:()=>s(`${$b}?environment=${encodeURIComponent(j.id)}`),"data-testid":"workspace-create-button",children:"+ New Workspace"})]}),w.length===0&&l.jsx("p",{className:Ve.empty,children:"No workspaces yet. Create one to get started."}),l.jsx("div",{className:Ve.cardList,children:w.map(ae=>l.jsx(LU,{workspace:ae,confirmArchiveId:T,onOpen:()=>s(ni(ae.id,j.id)),onArchive:()=>N(ae.id),onConfirmArchive:()=>ee(ae.id),onCancelArchive:()=>N(void 0)},ae.id))})]})]})}function LU({workspace:t,confirmArchiveId:s,onOpen:i,onArchive:o,onConfirmArchive:c,onCancelArchive:u}){const d=s===t.id,m=t.repoUrl&&/^https?:\/\//.test(t.repoUrl);return l.jsxs("div",{className:Ve.card,"data-testid":"workspace-card",children:[l.jsxs("div",{className:Ve.cardHeader,children:[l.jsx("strong",{className:Ve.cardName,children:t.name}),l.jsxs("div",{className:Ve.cardActions,children:[l.jsx("button",{className:Ve.btnSmall,onClick:i,children:"Open"}),d?l.jsxs(l.Fragment,{children:[l.jsx("button",{className:Ve.btnDanger,onClick:c,children:"Confirm"}),l.jsx("button",{className:Ve.btnSmall,onClick:u,children:"Cancel"})]}):l.jsx("button",{className:Ve.btnSmall,onClick:o,children:"Archive"})]})]}),t.description&&l.jsx("p",{className:Ve.cardDescription,children:t.description}),t.repoUrl&&l.jsx("div",{className:Ve.cardMeta,children:m?l.jsx("a",{href:t.repoUrl,target:"_blank",rel:"noopener noreferrer",className:Ve.repoLink,children:t.repoUrl}):l.jsx("span",{children:t.repoUrl})})]})}const UU={credentials:"Credentials",personas:"Personas",appearance:"Appearance",about:"About",shortcuts:"Shortcuts"};function zU(){const s=Ut().pathname.replace(/^\/settings\/?/,"").split("/")[0],i=UU[s],o=lB(i);return l.jsxs("div",{className:Tr.layout,children:[l.jsx(fs,{segments:o}),l.jsx("div",{className:Tr.content,children:l.jsx("div",{className:Tr.tabPanel,children:l.jsx(wa,{})},s)})]})}function PU(){const{tokens:t,setToken:s,deleteToken:i,credentialProviders:o,updateCredentialProviders:c}=rt(),{showToast:u}=dn();return l.jsxs(l.Fragment,{children:[l.jsx(EO,{credentialProviders:o,onUpdateCredentialProviders:c}),l.jsx(TI,{tokens:t,onSetToken:s,onDeleteToken:i,onShowToast:u})]})}function VU(){const{personas:t,deletePersona:s,appDefaultPersonaId:i,setAppDefaultPersonaId:o}=rt(),{showToast:c}=dn(),u=vt();return l.jsx(HO,{personas:t,appDefaultPersonaId:i,onDeletePersona:async d=>{try{await s(d)}catch(m){throw console.error("Failed to delete persona",{personaId:d,error:m}),c("Failed to delete persona","error"),m}},onSetAppDefaultPersonaId:async d=>{try{await o(d)}catch(m){console.error("Failed to set app default persona ID",{personaId:d,error:m}),c("Failed to set app default persona","error")}},onNavigateToNew:()=>u(s2),onNavigateToPersona:d=>u(Hb(d))})}const HU="_container_1ooin_1",$U="_form_1ooin_7",GU="_formActions_1ooin_75",qU="_editableSection_1ooin_82",FU="_defaultBadge_1ooin_93",ZU="_typeToggle_1ooin_107",KU="_scriptEditor_1ooin_121",YU="_optional_1ooin_128",Yn={container:HU,form:$U,formActions:GU,editableSection:qU,defaultBadge:FU,typeToggle:ZU,scriptEditor:KU,optional:YU},fb=[{value:"claude-code",label:"claude-code"},{value:"codex",label:"codex"},{value:"copilot",label:"copilot"},{value:"goose",label:"goose"},{value:"stub",label:"stub"},{value:"claude-code-acp",label:"claude-code-acp (experimental)"},{value:"codex-acp",label:"codex-acp (experimental)"},{value:"copilot-acp",label:"copilot-acp (experimental)"}],pb=[{value:"genaiscript",label:"genaiscript"}],JU="0";function mb(){const{personaId:t}=Qn(),s=vt(),{showToast:i}=dn(),{personas:o,createPersona:c,updatePersona:u,deletePersona:d,appDefaultPersonaId:m,setAppDefaultPersonaId:h}=rt(),g=t===void 0,v=g?void 0:o.find(b=>b.id===t);if(!g&&o.length>0&&!v)return l.jsx(Wn,{to:gf,replace:!0});const _=[{label:"Settings",url:so},{label:"Personas",url:gf},{label:g?"New Persona":(v==null?void 0:v.name)??"Persona",url:void 0}];return l.jsxs("div",{className:Yn.container,children:[l.jsx(fs,{segments:_}),l.jsx(WU,{existing:v,isNew:g,appDefaultPersonaId:m,onCreatePersona:c,onUpdatePersona:u,onDeletePersona:d,onSetAppDefaultPersonaId:h,onDone:()=>{s(gf)},showToast:i})]})}function WU({existing:t,isNew:s,appDefaultPersonaId:i,onCreatePersona:o,onUpdatePersona:c,onDeletePersona:u,onSetAppDefaultPersonaId:d,onDone:m,showToast:h}){const g=vt(),[v,_]=y.useState((t==null?void 0:t.name)??""),[b,S]=y.useState((t==null?void 0:t.description)??""),[T,N]=y.useState((t==null?void 0:t.systemPrompt)??""),[j,w]=y.useState((t==null?void 0:t.runtime)??"claude-code"),[C,A]=y.useState((t==null?void 0:t.model)??"sonnet"),[M,D]=y.useState((t==null?void 0:t.maxTurns)??0),[E,$]=y.useState((t==null?void 0:t.type)==="script"?"script":"agent"),[z,K]=y.useState((t==null?void 0:t.script)??""),[F,ee]=y.useState((t==null?void 0:t.allowedMcpTools)??[]),[ae,me]=y.useState(!1),[ie,X]=y.useState(null),[O,q]=y.useState(!!s);y.useEffect(()=>{if(!s&&t&&!O){q(!0),_(t.name),S(t.description),N(t.systemPrompt);const B=t.type==="script"?"script":"agent";w(B==="script"?t.runtime||"genaiscript":t.runtime),A(t.model),D(t.maxTurns),$(B),K(t.script||""),ee(t.allowedMcpTools)}},[s,t,O]);const te=B=>{$(B),B==="script"?w("genaiscript"):j==="genaiscript"&&w("claude-code")},re=!s&&t===void 0,ue=v.trim().length>0&&!re&&T.trim().length>0&&(E==="script"?z.trim().length>0:!!j&&!!C),Fe=s&&ue,Ne=!s&&i===(t==null?void 0:t.id),ke=!s&&t&&!Ne&&E==="agent"&&!!j&&!!C,Me=(B,Re)=>{if(!B.trim())return`${Re} is required`},le=B=>{if(B.preventDefault(),!(re||!ue)){if(t){c(t.id,v,b,T,j,C,M,E,z).then(()=>{h("Persona updated","success"),m()},()=>{h("Failed to save persona","error")});return}o(v,b,T,j,C,M,E,z,F).then(Re=>{h("Persona created","success"),g(Hb(Re.id),{replace:!0})},()=>{h("Failed to save persona","error")})}},ve=()=>{t&&u(t.id).then(()=>{h("Persona deleted","success"),m()},()=>{h("Failed to delete persona","error")})},de=async(B,Re,Qe,et)=>B().then(()=>{Re(),h(Qe,"success")},()=>{h(et,"error")}),Ie=(B,Re)=>{if(!t)return;const Qe=B==="type"?String(Re):E,et=B==="runtime"?String(Re):B==="type"?String(Re)==="script"?"genaiscript":j==="genaiscript"?"claude-code":j:j,$e=B==="model"?String(Re):C,es=B==="maxTurns"?Number(Re):M,Hs=B==="systemPrompt"?String(Re):T,kn=B==="script"?String(Re):z;de(()=>c(t.id,B==="name"?String(Re):v,B==="description"?String(Re):b,Hs,et,$e,es,Qe,kn),()=>{if(B==="type"){const Vn=String(Re)==="script"?"script":"agent";$(Vn),w(et)}B==="runtime"&&w(String(Re)),B==="name"&&_(String(Re)),B==="description"&&S(String(Re)),B==="systemPrompt"&&N(String(Re)),B==="model"&&A(String(Re)),B==="maxTurns"&&D(Number(Re)),B==="script"&&K(String(Re))},"Persona updated","Failed to update persona").catch(()=>{})},yt=B=>{le(B)},fn=()=>{t&&d(t.id).then(()=>{h("Set as app default","success")},()=>{h("Failed to set app default","error")})};return l.jsxs(l.Fragment,{children:[re?l.jsxs("div",{className:Yn.form,children:[l.jsx("h3",{children:"Edit Persona"}),l.jsx("p",{children:"Loading persona..."})]}):s?l.jsxs("form",{onSubmit:yt,className:Yn.form,children:[l.jsx("h3",{children:"Create Persona"}),l.jsxs("div",{className:Yn.typeToggle,"data-testid":"persona-type-toggle",children:[l.jsxs("label",{children:[l.jsx("input",{type:"radio",name:"personaType",value:"agent",checked:E==="agent",onChange:()=>te("agent")}),"Agent"]}),l.jsxs("label",{children:[l.jsx("input",{type:"radio",name:"personaType",value:"script",checked:E==="script",onChange:()=>te("script")}),"Script"]})]}),l.jsxs("label",{children:["Name",l.jsx("input",{type:"text",value:v,onChange:B=>_(B.target.value),placeholder:E==="script"?"e.g. Nightly Report":"e.g. Frontend Engineer",required:!0,"data-testid":"persona-detail-name"})]}),l.jsxs("label",{children:["Description",l.jsx("input",{type:"text",value:b,onChange:B=>S(B.target.value),placeholder:"Brief description...","data-testid":"persona-detail-description"})]}),l.jsxs("label",{children:["Runtime",l.jsx("select",{value:j,onChange:B=>w(B.target.value),"data-testid":"persona-runtime-select",children:(E==="script"?pb:fb).map(B=>l.jsx("option",{value:B.value,children:B.label},B.value))})]}),E==="agent"&&l.jsxs(l.Fragment,{children:[l.jsxs("label",{children:["Model",l.jsx("input",{type:"text",value:C,onChange:B=>A(B.target.value),placeholder:"e.g. sonnet","data-testid":"persona-detail-model"})]}),l.jsxs("label",{children:["Max Turns",l.jsx("input",{type:"number",value:M,onChange:B=>D(parseInt(B.target.value,10)||0),min:0,"data-testid":"persona-detail-max-turns"})]}),l.jsxs("label",{children:["System Prompt",l.jsx("textarea",{value:T,onChange:B=>N(B.target.value),placeholder:"You are a senior frontend engineer...",rows:10,required:!0,"data-testid":"persona-detail-prompt"})]})]}),E==="script"&&l.jsxs(l.Fragment,{children:[l.jsxs("label",{children:["Model ",l.jsx("span",{className:Yn.optional,children:"(optional)"}),l.jsx("input",{type:"text",value:C,onChange:B=>A(B.target.value),placeholder:"e.g. sonnet (leave empty for script-only)","data-testid":"persona-detail-model"})]}),l.jsxs("label",{children:["System Prompt",l.jsx("textarea",{value:T,onChange:B=>N(B.target.value),placeholder:"Context for the script...",rows:4,required:!0,"data-testid":"persona-detail-prompt"})]}),l.jsxs("label",{children:["Script",l.jsx("textarea",{value:z,onChange:B=>K(B.target.value),placeholder:`script({ model: "openai:gpt-4o" });
489
+ src/utils/token-refresh.ts:28: const remaining = decoded.exp - Date.now() / 1000;`,raw:JSON.stringify({tool_use_id:"tool-mock-004",is_error:!1})}},{delayMs:7800,event:{eventType:"text",timestamp:je(7800),content:"Fixed. The token expiry comparison was inverted — `decoded.exp > Date.now()` should have been `<` (a token is expired when its `exp` is in the past). The other occurrence in `token-refresh.ts` uses subtraction (not comparison), so it was already correct. All 3 auth tests pass."}},{delayMs:8400,event:{eventType:"usage",timestamp:je(8400),content:JSON.stringify({input_tokens:42600,output_tokens:1850,cost_usd:.12})}},{delayMs:8800,event:{eventType:"status",timestamp:je(8800),content:"completed"}}]}],ab=400;function EB({children:t}){const[s,i]=y.useState(xB),[o,c]=y.useState(SB),[u,d]=y.useState(TB),[m,h]=y.useState(void 0),[g,v]=y.useState(kB),[_,b]=y.useState(wB),[S,T]=y.useState(mc),[N,j]=y.useState(void 0),w=!1,[C,A]=y.useState(NB),[M,D]=y.useState({claude:"off",github:"off",copilot:"off",codex:"off",goose:"off"}),[E,$]=y.useState(jB),[z]=y.useState(CB),[K,F]=y.useState(""),[ee,ae]=y.useState(rs),[me,ie]=y.useState(va),[X,O]=y.useState(void 0),[q,te]=y.useState(void 0),[re,ue]=y.useState(""),Fe=y.useRef(void 0),Ne=y.useRef(0),ke=y.useRef(0),Me=y.useRef(new Set),le=y.useRef(new Map),ve=y.useRef(_);ve.current=_;const de=y.useRef(new Map),Ie=y.useRef(new Map),yt=y.useCallback(P=>(Ne.current+=1,`mock-${P}-${String(Ne.current).padStart(3,"0")}`),[]),fn=y.useCallback(()=>{const P=sb[ke.current%sb.length];return ke.current+=1,P},[]),B=y.useCallback((P,Q,oe)=>{const ce=setTimeout(()=>{var fe;Me.current.delete(ce),oe&&((fe=le.current.get(oe))==null||fe.delete(ce)),P()},Q);Me.current.add(ce),oe&&(le.current.has(oe)||le.current.set(oe,new Set),le.current.get(oe).add(ce))},[]),Re=y.useCallback(P=>{const Q=le.current.get(P);Q&&(Q.forEach(oe=>{clearTimeout(oe),Me.current.delete(oe)}),le.current.delete(P))},[]),Qe=y.useCallback((P,Q,oe)=>{c(ce=>ce.map(fe=>fe.id===P?{...fe,status:Q,...oe!==void 0?{endReason:oe}:{}}:fe))},[]),et=y.useCallback(P=>{d(Q=>[...Q,P])},[]),$e=y.useCallback((P,Q,oe)=>{Q.forEach((ce,fe)=>{B(()=>{const Le={sessionId:P,...ce.event,timestamp:new Date().toISOString()};if(et(Le),ce.event.eventType==="status"){const ye=Zx(ce.event.content),Ce=Kx(ce.event.content);Qe(P,ye,Ce)}fe===Q.length-1&&oe&&oe()},ce.delayMs,P)})},[B,et,Qe]),es=y.useCallback((P,Q,oe,ce)=>{console.log("[MockGrackle] spawn",{environmentId:P,prompt:Q,runtime:ce});const fe=yt("sess"),Le={id:fe,environmentId:P,runtime:ce||"claude-code",status:"running",prompt:Q,startedAt:new Date().toISOString()};c(Ce=>[...Ce,Le]),h(fe);const ye=fn();if(console.log(`[MockGrackle] Playing scenario: ${ye.label}`),ye.pauseForInput){const Ce=ye.pauseAfterStep??ye.steps.length-1,Ge=ye.steps.slice(0,Ce+1),lt=Ge.length>0?Ge[Ge.length-1].delayMs:0;$e(fe,Ge),B(()=>{Qe(fe,"idle"),et({sessionId:fe,eventType:"status",timestamp:new Date().toISOString(),content:"idle"})},lt+ab,fe),ye.resumeSteps&&de.current.set(fe,ye.resumeSteps)}else $e(fe,ye.steps)},[yt,fn,$e,B,Qe,et]),Hs=y.useCallback(P=>{console.log("[MockGrackle] kill",P),Re(P),de.current.delete(P),Qe(P,"stopped","killed"),et({sessionId:P,eventType:"status",timestamp:new Date().toISOString(),content:"killed"}),b(Q=>Q.map(oe=>oe.latestSessionId===P&&oe.status==="working"?{...oe,status:"not_started"}:oe))},[Re,Qe,et]),kn=y.useCallback(P=>{console.log("[MockGrackle] stopGraceful",P),Re(P),de.current.delete(P),Qe(P,"stopped","terminated"),et({sessionId:P,eventType:"status",timestamp:new Date().toISOString(),content:"terminated"}),b(Q=>Q.map(oe=>oe.latestSessionId===P&&oe.status==="working"?{...oe,status:"not_started"}:oe))},[Re,Qe,et]),Vn=y.useCallback(()=>{console.log("[MockGrackle] refresh")},[]),ts=y.useCallback(P=>{console.log("[MockGrackle] loadSessionEvents",P)},[]),$s=y.useCallback(()=>{console.log("[MockGrackle] clearEvents"),d([])},[]),Hn=y.useCallback((P,Q,oe,ce,fe,Le,ye,Ce,Ge)=>{console.log("[MockGrackle] createWorkspace",{name:P,description:Q});const lt={id:yt("proj"),name:P,description:Q||"",repoUrl:oe||"",environmentId:ce||"",status:"active",workingDirectory:ye||"",useWorktrees:Le??!0,defaultPersonaId:fe||"",createdAt:new Date().toISOString(),updatedAt:new Date().toISOString()};v(qe=>[...qe,lt]),Ce&&Ce()},[yt]),Ae=y.useCallback(P=>{console.log("[MockGrackle] archiveWorkspace",P),v(Q=>Q.map(oe=>oe.id===P?{...oe,status:"archived"}:oe))},[]),We=y.useCallback(P=>{console.log("[MockGrackle] loadTasks",P)},[]),zr=y.useCallback((P,Q,oe,ce,fe,Le,ye,Ce,Ge)=>{console.log("[MockGrackle] createTask",{workspaceId:P,title:Q,parentTaskId:fe}),b(lt=>{const Bt=lt.filter(dt=>dt.workspaceId===P).reduce((dt,zt)=>Math.max(dt,zt.sortOrder),0),Ht=fe?lt.find(dt=>dt.id===fe):void 0;if(fe&&!Ht)return console.warn("[MockGrackle] Parent task not found:",fe),lt;if(Ht&&!Ht.canDecompose)return console.warn("[MockGrackle] Parent task does not have decomposition rights:",fe),lt;const jt=Ht?Ht.depth+1:0,Qt={id:yt("task"),workspaceId:P,title:Q,description:oe||"",status:"not_started",branch:"",latestSessionId:"",dependsOn:ce||[],reviewNotes:void 0,sortOrder:Bt+1,createdAt:new Date().toISOString(),parentTaskId:fe||"",depth:jt,childTaskIds:[],canDecompose:ye??!fe,defaultPersonaId:Le||"",workpad:""};return[...lt,Qt]}),Ce&&Ce()},[yt]),mo=y.useCallback((P,Q,oe,ce)=>{var lt;console.log("[MockGrackle] startTask",{taskId:P});const fe=ve.current.find(qe=>qe.id===P),Le=(fe==null?void 0:fe.title)??"",ye=yt("sess"),Ce={id:ye,environmentId:"env-local-01",runtime:"claude-code",status:"running",prompt:Le||P,startedAt:new Date().toISOString()};c(qe=>[...qe,Ce]),b(qe=>qe.map(Bt=>Bt.id===P?{...Bt,status:"working",latestSessionId:ye,branch:`mock/${P.slice(0,8)}`}:Bt));const Ge=fn();if(console.log(`[MockGrackle] Playing task scenario: ${Ge.label}`),Ge.pauseForInput){const qe=Ge.pauseAfterStep??Ge.steps.length-1,Bt=Ge.steps.slice(0,qe+1),Ht=Bt.length>0?Bt[Bt.length-1].delayMs:0;if($e(ye,Bt),B(()=>{Qe(ye,"idle"),et({sessionId:ye,eventType:"status",timestamp:new Date().toISOString(),content:"idle"})},Ht+ab,ye),Ge.resumeSteps){const jt=[...Ge.resumeSteps];de.current.set(ye,jt);const Qt=jt.reduce((dt,zt)=>Math.max(dt,zt.delayMs),0);Ie.current.set(ye,{taskId:P,delayAfterResume:Qt+200})}}else{const qe=Ge.steps.length>0?Ge.steps[Ge.steps.length-1].delayMs:0;$e(ye,Ge.steps);const Bt=(lt=Ge.steps[Ge.steps.length-1])==null?void 0:lt.event.content;B(()=>{Bt==="completed"?b(Ht=>Ht.map(jt=>jt.id===P&&jt.status==="working"?{...jt,status:"paused"}:jt)):Bt==="failed"&&b(Ht=>Ht.map(jt=>jt.id===P&&jt.status==="working"?{...jt,status:"failed"}:jt))},qe+100,ye)}},[yt,fn,$e,B,Qe,et]),ho=y.useCallback((P,Q)=>{console.log("[MockGrackle] sendInput",{sessionId:P,text:Q}),et({sessionId:P,eventType:"output",timestamp:new Date().toISOString(),content:`User input: ${Q}`}),Qe(P,"running"),et({sessionId:P,eventType:"status",timestamp:new Date().toISOString(),content:"running"});const oe=de.current.get(P);if(oe)de.current.delete(P),$e(P,oe);else{const fe=[{delayMs:500,event:{eventType:"output",timestamp:new Date().toISOString(),content:"I received your input, continuing..."}},{delayMs:1500,event:{eventType:"status",timestamp:new Date().toISOString(),content:"completed"}}];$e(P,fe)}const ce=Ie.current.get(P);ce&&(Ie.current.delete(P),B(()=>{b(fe=>fe.map(Le=>Le.id===ce.taskId&&Le.status==="working"?{...Le,status:"paused"}:Le))},ce.delayAfterResume,P))},[et,Qe,$e,B]),Gs=y.useCallback(P=>{console.log("[MockGrackle] completeTask",P),b(Q=>Q.map(oe=>oe.id===P?{...oe,status:"complete"}:oe))},[]),Pr=y.useCallback(P=>{console.log("[MockGrackle] resumeTask",P)},[]),go=y.useCallback((P,Q,oe,ce,fe)=>{console.log("[MockGrackle] updateTask",{taskId:P,title:Q}),b(Le=>Le.map(ye=>ye.id===P?{...ye,title:Q.trim()||ye.title,description:oe,dependsOn:ce,...fe!==void 0?{defaultPersonaId:fe}:{}}:ye))},[]),Vr=y.useCallback(P=>{console.log("[MockGrackle] deleteTask",P),b(Q=>Q.filter(oe=>oe.id!==P))},[]),Hr=y.useCallback(P=>{console.log("[MockGrackle] loadFindings",P),T(mc.filter(Q=>Q.workspaceId===P))},[]),qs=y.useCallback(()=>{console.log("[MockGrackle] loadAllFindings"),T([...mc])},[]),Yt=y.useCallback(P=>{console.log("[MockGrackle] loadFinding",P);const Q=mc.find(oe=>oe.id===P);j(Q)},[]),$n=y.useCallback((P,Q,oe,ce,fe)=>{console.log("[MockGrackle] postFinding",{workspaceId:P,title:Q});const Le={id:yt("find"),workspaceId:P,taskId:"",sessionId:"",category:ce||"general",title:Q,content:oe,tags:fe||[],createdAt:new Date().toISOString()};T(ye=>[...ye,Le])},[yt]),Jt=y.useCallback(()=>{console.log("[MockGrackle] loadEnvironments")},[]),$r=y.useCallback((P,Q,oe)=>{console.log("[MockGrackle] addEnvironment",{displayName:P,adapterType:Q,adapterConfig:oe})},[]),Gr=y.useCallback((P,Q)=>{console.log("[MockGrackle] updateEnvironment",{environmentId:P,...Q}),i(oe=>oe.map(ce=>ce.id!==P?ce:{...ce,...Q.displayName!==void 0?{displayName:Q.displayName}:{},...Q.adapterConfig!==void 0?{adapterConfig:JSON.stringify(Q.adapterConfig)}:{}}))},[]),qr=y.useCallback(()=>{console.log("[MockGrackle] loadTokens")},[]),ja=y.useCallback((P,Q,oe,ce,fe)=>{console.log("[MockGrackle] setToken",{name:P,tokenType:oe}),A(Le=>[...Le.filter(Ce=>Ce.name!==P),{name:P,tokenType:oe,envVar:ce,filePath:fe,expiresAt:""}])},[]),Ca=y.useCallback(P=>{console.log("[MockGrackle] deleteToken",P),A(Q=>Q.filter(oe=>oe.name!==P))},[]),Ea=y.useCallback(P=>{console.log("[MockGrackle] updateCredentialProviders",P),D(P)},[]);y.useEffect(()=>()=>{Me.current.forEach(clearTimeout),Me.current.clear()},[]);const ps=y.useMemo(()=>({connected:!0,send:()=>{},environments:s,sessions:o,events:u,eventsDropped:0,lastSpawnedId:m,workspaces:g,tasks:_,findings:S,selectedFinding:N,findingLoading:w,tokens:C,credentialProviders:M,spawn:es,sendInput:ho,kill:Hs,stopGraceful:kn,refresh:Vn,loadSessionEvents:ts,clearEvents:$s,loadWorkspaces:()=>{console.log("[MockGrackle] loadWorkspaces")},createWorkspace:Hn,archiveWorkspace:Ae,updateWorkspace:(P,Q)=>{console.log("[MockGrackle] updateWorkspace",{workspaceId:P,...Q}),v(oe=>oe.map(ce=>ce.id!==P?ce:{...ce,...Q.name!==void 0?{name:Q.name}:{},...Q.description!==void 0?{description:Q.description}:{},...Q.repoUrl!==void 0?{repoUrl:Q.repoUrl}:{},...Q.environmentId!==void 0?{environmentId:Q.environmentId}:{},...Q.workingDirectory!==void 0?{workingDirectory:Q.workingDirectory}:{},...Q.useWorktrees!==void 0?{useWorktrees:Q.useWorktrees}:{},...Q.defaultPersonaId!==void 0?{defaultPersonaId:Q.defaultPersonaId}:{},updatedAt:new Date().toISOString()}))},loadTasks:We,loadAllTasks:()=>{console.log("[MockGrackle] loadAllTasks")},createTask:zr,startTask:mo,stopTask:P=>{console.log("[MockGrackle] stopTask",{taskId:P}),Gs(P)},completeTask:Gs,resumeTask:Pr,updateTask:go,deleteTask:Vr,loadFindings:Hr,loadAllFindings:qs,loadFinding:Yt,postFinding:$n,loadEnvironments:Jt,addEnvironment:$r,updateEnvironment:Gr,loadTokens:qr,setToken:ja,deleteToken:Ca,updateCredentialProviders:Ea,provisionStatus:{},provisionEnvironment:(P,Q)=>{},stopEnvironment:()=>{},removeEnvironment:()=>{},codespaces:[],codespaceError:"",codespaceListError:"",codespaceCreating:!1,listCodespaces:()=>{},createCodespace:()=>{},workspaceCreating:!1,taskStartingId:void 0,personas:E,createPersona:async(P,Q,oe,ce,fe,Le,ye,Ce,Ge)=>{console.log("[MockGrackle] createPersona",{name:P});const lt={id:`mock-persona-${Date.now()}`,name:P,description:Q,systemPrompt:oe,toolConfig:"{}",runtime:ce??"claude-code",model:fe||"",maxTurns:Le||0,mcpServers:"[]",createdAt:new Date().toISOString(),updatedAt:new Date().toISOString(),type:ye||"agent",script:Ce||"",allowedMcpTools:Ge||[]};return $(qe=>[...qe,lt]),lt},updatePersona:async(P,Q,oe,ce,fe,Le,ye,Ce,Ge,lt)=>{console.log("[MockGrackle] updatePersona",{personaId:P,name:Q});const qe=E.find(jt=>jt.id===P);if(!qe)throw new Error(`Persona not found: ${P}`);const Bt=new Date().toISOString(),Ht={...qe,...Q!==void 0?{name:Q}:{},...oe!==void 0?{description:oe}:{},...ce!==void 0?{systemPrompt:ce}:{},...fe!==void 0?{runtime:fe}:{},...Le!==void 0?{model:Le}:{},...ye!==void 0?{maxTurns:ye}:{},...Ce!==void 0?{type:Ce}:{},...Ge!==void 0?{script:Ge}:{},...lt!==void 0?{allowedMcpTools:lt}:{},updatedAt:Bt};return $(jt=>jt.map(Qt=>Qt.id===P?Ht:Qt)),Ht},deletePersona:async P=>{console.log("[MockGrackle] deletePersona",P),$(Q=>Q.filter(oe=>oe.id!==P))},taskSessions:z,loadTaskSessions:P=>{console.log("[MockGrackle] loadTaskSessions",P)},appDefaultPersonaId:K,setAppDefaultPersonaId:async P=>{console.log("[MockGrackle] setAppDefaultPersonaId",P),F(P)},onboardingCompleted:!0,completeOnboarding:async()=>{console.log("[MockGrackle] completeOnboarding")},usageCache:{"workspace:proj-alpha":{inputTokens:214500,outputTokens:44850,costUsd:1.12,sessionCount:4},"workspace:proj-beta":{inputTokens:86700,outputTokens:23800,costUsd:.48,sessionCount:3},"task:task-001":{inputTokens:126800,outputTokens:20850,costUsd:.63,sessionCount:2},"task:task-006":{inputTokens:18900,outputTokens:4500,costUsd:.1,sessionCount:1},"task_tree:task-001":{inputTokens:126800,outputTokens:20850,costUsd:.63,sessionCount:2},"task_tree:task-006":{inputTokens:18900,outputTokens:4500,costUsd:.1,sessionCount:1}},loadUsage:(P,Q)=>{console.log(`[MockGrackle] loadUsage(${P}, ${Q})`)},knowledge:{graphData:{nodes:ee,links:me},selectedNode:X,loading:!1,selectedId:q,searchQuery:re,search:P=>{if(console.log("[MockGrackle] knowledge.search",P),!P.trim()){ue(P);return}ue(P);const Q=Fe.current,oe=Q?rs.filter(ye=>!ye.workspaceId||ye.workspaceId===Q):rs,ce=P.toLowerCase(),fe=oe.filter(ye=>{var Ce,Ge,lt;return ye.label.toLowerCase().includes(ce)||((Ce=ye.content)==null?void 0:Ce.toLowerCase().includes(ce))||((Ge=ye.tags)==null?void 0:Ge.some(qe=>qe.toLowerCase().includes(ce)))||((lt=ye.category)==null?void 0:lt.toLowerCase().includes(ce))});ae(fe);const Le=new Set(fe.map(ye=>ye.id));ie(va.filter(ye=>Le.has(ye.source)&&Le.has(ye.target))),te(void 0),O(void 0)},clearSearch:()=>{console.log("[MockGrackle] knowledge.clearSearch"),ue("");const P=Fe.current,Q=P?rs.filter(ce=>!ce.workspaceId||ce.workspaceId===P):rs;ae(Q);const oe=new Set(Q.map(ce=>ce.id));ie(va.filter(ce=>oe.has(ce.source)&&oe.has(ce.target)))},selectNode:P=>{console.log("[MockGrackle] knowledge.selectNode",P),te(P);const Q=P in nb?nb[P]:void 0;if(Q)O(Q);else{const oe=rs.find(ce=>ce.id===P);if(oe){const ce=va.filter(fe=>fe.source===P||fe.target===P).map(fe=>({fromId:fe.source,toId:fe.target,type:fe.type}));O({node:oe,edges:ce})}}},clearSelection:()=>{console.log("[MockGrackle] knowledge.clearSelection"),te(void 0),O(void 0)},expandNode:P=>{console.log("[MockGrackle] knowledge.expandNode",P),ae(Q=>{const oe=new Set(Q.map(Ce=>Ce.id)),ce=va.filter(Ce=>Ce.source===P||Ce.target===P),fe=new Set;for(const Ce of ce)oe.has(Ce.source)||fe.add(Ce.source),oe.has(Ce.target)||fe.add(Ce.target);if(fe.size===0)return Q;const Le=rs.filter(Ce=>fe.has(Ce.id)),ye=new Set([...oe,...fe]);return ie(Ce=>{const Ge=new Set(Ce.map(qe=>`${qe.source}|${qe.target}|${qe.type}`)),lt=va.filter(qe=>ye.has(qe.source)&&ye.has(qe.target)&&!Ge.has(`${qe.source}|${qe.target}|${qe.type}`));return lt.length>0?[...Ce,...lt]:Ce}),[...Q,...Le]})},loadRecent:P=>{if(console.log("[MockGrackle] knowledge.loadRecent",P),Fe.current=P,P){const Q=rs.filter(ce=>!ce.workspaceId||ce.workspaceId===P);ae(Q);const oe=new Set(Q.map(ce=>ce.id));ie(va.filter(ce=>oe.has(ce.source)&&oe.has(ce.target)))}else ae(rs),ie(va);ue("")},handleEvent:()=>!1}}),[s,o,u,m,g,_,S,N,C,M,E,z,K,ee,me,X,q,re,es,ho,Hs,kn,Vn,ts,$s,Hn,Ae,We,zr,mo,Gs,Pr,go,Vr,Hr,qs,Yt,$n,Jt,$r,Gr,qr,ja,Ca,Ea]);return l.jsx(vm.Provider,{value:ps,children:t})}const AB=3e3;function DB(t){const[s,i]=y.useState(!1),o=y.useRef(t.onSessionEvent);o.current=t.onSessionEvent;const c=y.useRef(t.onDomainEvent);c.current=t.onDomainEvent;const u=y.useRef(t.onConnect);u.current=t.onConnect;const d=y.useRef(t.onDisconnect);return d.current=t.onDisconnect,y.useEffect(()=>{let m=!1,h;async function g(){var v,_;if(!m){try{const b=xe.streamEvents({});i(!0),(v=u.current)==null||v.call(u);for await(const S of b){if(m)break;const T=S.event;if(T.case==="sessionEvent"){const N=T.value;o.current({sessionId:N.sessionId,type:N.type,timestamp:N.timestamp,content:N.content,raw:N.raw})}else if(T.case==="domainEvent"){const N=T.value;c.current({id:N.id,type:N.type,timestamp:N.timestamp,payloadJson:N.payloadJson})}}}catch(b){if(b instanceof zc&&b.code===kT.Unauthenticated){window.location.href=i2;return}}m||(i(!1),(_=d.current)==null||_.call(d),h=setTimeout(()=>{g().catch(()=>{})},AB))}}return g().catch(()=>{}),()=>{m=!0,clearTimeout(h),i(!1)}},[]),{connected:s}}function RB(t){return{id:t.id,displayName:t.displayName,adapterType:t.adapterType,adapterConfig:t.adapterConfig||"{}",status:t.status,bootstrapped:t.bootstrapped}}function ib(t){return{id:t.id,environmentId:t.environmentId,runtime:t.runtime,status:t.status,prompt:t.prompt,startedAt:t.startedAt,endedAt:t.endedAt||void 0,error:t.error||void 0,endReason:t.endReason||void 0,personaId:t.personaId||void 0,inputTokens:t.inputTokens,outputTokens:t.outputTokens,costUsd:t.costUsd}}function MB(t){return{sessionId:t.sessionId,eventType:Sb(t.type),timestamp:t.timestamp,content:t.content,raw:t.raw||void 0}}function IB(t){return{id:t.id,name:t.name,description:t.description,repoUrl:t.repoUrl,environmentId:t.environmentId,status:wT(t.status),workingDirectory:t.workingDirectory,useWorktrees:t.useWorktrees,defaultPersonaId:t.defaultPersonaId,createdAt:t.createdAt,updatedAt:t.updatedAt}}function ob(t){return{id:t.id,workspaceId:t.workspaceId??void 0,title:t.title,description:t.description,status:NT(t.status),branch:t.branch,latestSessionId:t.latestSessionId,dependsOn:[...t.dependsOn],sortOrder:t.sortOrder,createdAt:t.createdAt,startedAt:t.startedAt||void 0,completedAt:t.completedAt||void 0,parentTaskId:t.parentTaskId,depth:t.depth,childTaskIds:[...t.childTaskIds],canDecompose:t.canDecompose,defaultPersonaId:t.defaultPersonaId,workpad:t.workpad}}function Hf(t){return{id:t.id,workspaceId:t.workspaceId,taskId:t.taskId,sessionId:t.sessionId,category:t.category,title:t.title,content:t.content,tags:[...t.tags],createdAt:t.createdAt}}function OB(t){return{name:t.name,tokenType:t.type,envVar:t.envVar,filePath:t.filePath,expiresAt:t.expiresAt}}function BB(t){return{claude:jT(t.claude),github:ac(t.github),copilot:ac(t.copilot),codex:ac(t.codex),goose:ac(t.goose)}}function LB(t){return{name:t.name,repository:t.repository,state:t.state,gitStatus:t.gitStatus}}function $f(t){return{id:t.id,name:t.name,description:t.description,systemPrompt:t.systemPrompt,toolConfig:t.toolConfig?JSON.stringify({allowedTools:[...t.toolConfig.allowedTools],disallowedTools:[...t.toolConfig.disallowedTools]}):"{}",runtime:t.runtime,model:t.model,maxTurns:t.maxTurns,mcpServers:JSON.stringify(t.mcpServers.map(s=>({name:s.name,command:s.command,args:[...s.args],tools:[...s.tools]}))),createdAt:t.createdAt,updatedAt:t.updatedAt,type:t.type||"agent",script:t.script,allowedMcpTools:[...t.allowedMcpTools]}}function UB(t){return{inputTokens:t.inputTokens,outputTokens:t.outputTokens,costUsd:t.costUsd,sessionCount:t.sessionCount}}function hc(t,s=0){return{id:t.id,label:t.title||t.label||t.id,kind:t.kind,category:t.category||void 0,sourceType:t.sourceType||void 0,sourceId:t.sourceId||void 0,content:t.content||void 0,tags:t.tags.length>0?[...t.tags]:void 0,workspaceId:t.workspaceId||void 0,createdAt:t.createdAt||void 0,updatedAt:t.updatedAt||void 0,val:s}}function Gf(t){return{source:t.fromId,target:t.toId,type:t.type}}const rb=5e3;function zB(){const[t,s]=y.useState([]),[i,o]=y.useState({}),c=y.useCallback(()=>{xe.listEnvironments({}).then(b=>{s(b.environments.map(RB))},()=>{})},[]),u=y.useCallback(b=>{switch(b.type){case"environment.added":return!0;case"environment.removed":{const S=b.payload.environmentId;return S&&(s(T=>T.filter(N=>N.id!==S)),o(T=>{const N={...T};return delete N[S],N})),!0}case"environment.changed":return c(),!0;case"environment.provision_progress":{const S=b.payload;if(typeof S.environmentId!="string"||typeof S.stage!="string"||typeof S.message!="string"||typeof S.progress!="number")return Fx("environment.provision_progress","invalid payload"),!0;if(o(T=>({...T,[S.environmentId]:{stage:S.stage,message:S.message,progress:S.progress}})),S.stage==="ready"){const T=S.environmentId;setTimeout(()=>{o(N=>{const j={...N};return delete j[T],j})},rb)}return!0}default:return!1}},[c]),d=y.useCallback(b=>{var S;if(b.type==="environments"){const T=Array.isArray((S=b.payload)==null?void 0:S.environments)?b.payload.environments:[];return s(T),!0}return!1},[]),m=y.useCallback((b,S,T)=>{xe.addEnvironment({displayName:b,adapterType:S,adapterConfig:JSON.stringify(T??{})}).catch(()=>{})},[]),h=y.useCallback((b,S)=>{xe.updateEnvironment({id:b,displayName:S.displayName,adapterConfig:S.adapterConfig?JSON.stringify(S.adapterConfig):void 0}).catch(()=>{})},[]),g=y.useCallback((b,S)=>{(async()=>{try{const N=xe.provisionEnvironment({id:b,force:S??!1});for await(const j of N)o(w=>({...w,[b]:{stage:j.stage,message:j.message,progress:j.progress}})),j.stage==="ready"&&setTimeout(()=>{o(w=>{const C={...w};return delete C[b],C})},rb)}catch{o(N=>{const j={...N};return delete j[b],j})}})().catch(()=>{})},[]),v=y.useCallback(b=>{xe.stopEnvironment({id:b}).catch(()=>{})},[]),_=y.useCallback(b=>{xe.removeEnvironment({id:b}).catch(()=>{})},[]);return{environments:t,provisionStatus:i,loadEnvironments:c,addEnvironment:m,updateEnvironment:h,provisionEnvironment:g,stopEnvironment:v,removeEnvironment:_,handleEvent:u,handleLegacyMessage:d}}const qf=new Set(["pending","running","idle"]),PB=new Set(["completed","failed","interrupted","hibernating","suspended"]),lb=["pending","running","idle"];function VB(){const[t,s]=y.useState([]),[i,o]=y.useState([]),[c,u]=y.useState(0),[d,m]=y.useState(void 0),[h,g]=y.useState({}),v=y.useCallback(()=>{xe.listSessions({}).then(D=>{const E=D.sessions.map(ib);s($=>{const z=new Map($.map(K=>[K.id,K]));return E.map(K=>{const F=z.get(K.id),ee=F==null?void 0:F.status;return!ee||ee===K.status?K:PB.has(ee)&&qf.has(K.status)?{...K,status:ee,...F.endReason!==void 0?{endReason:F.endReason}:{}}:qf.has(ee)&&qf.has(K.status)&&lb.indexOf(ee)>lb.indexOf(K.status)?{...K,status:ee}:K})})},()=>{})},[]),_=y.useCallback(D=>{if(D.type!=="session_event")return!1;if(!aB(D.payload))return Fx("session_event","payload is not a valid SessionEvent"),!0;const E=D.payload;let $=0;if(o(z=>{const K=[...z,E];return K.length>Yi?($=K.length-Yi,K.slice(-Yi)):K}),$>0&&u(z=>z+$),E.eventType==="usage")try{const z=JSON.parse(E.content),K=Number(z.input_tokens)||0,F=Number(z.output_tokens)||0,ee=Number(z.cost_usd)||0;(K>0||F>0||ee>0)&&s(ae=>ae.map(me=>me.id===E.sessionId?{...me,inputTokens:(me.inputTokens??0)+K,outputTokens:(me.outputTokens??0)+F,costUsd:(me.costUsd??0)+ee}:me))}catch{}if(E.eventType==="status"){const z=Zx(E.content),K=Kx(E.content);s(F=>F.some(ae=>ae.id===E.sessionId)?F.map(ae=>ae.id===E.sessionId?{...ae,status:z,...K!==void 0?{endReason:K}:{}}:ae):[...F,{id:E.sessionId,environmentId:"",runtime:"",status:z,prompt:"",startedAt:E.timestamp,...K!==void 0?{endReason:K}:{}}])}return!0},[]),b=y.useCallback(D=>{_({type:"session_event",payload:D})},[_]),S=y.useCallback(D=>{var E,$,z,K,F;switch(D.type){case"sessions":{const ee=Array.isArray((E=D.payload)==null?void 0:E.sessions)?D.payload.sessions:[];return s(ee),!0}case"spawned":{const ee=($=D.payload)==null?void 0:$.sessionId;return typeof ee=="string"&&ee&&m(ee),v(),!0}case"session_events":{const ee=Array.isArray((z=D.payload)==null?void 0:z.events)?D.payload.events:[];return ee.length>0&&o(ee),!0}case"task_sessions":{const ee=(K=D.payload)==null?void 0:K.taskId;if(typeof ee=="string"&&ee){const ae=Array.isArray((F=D.payload)==null?void 0:F.sessions)?D.payload.sessions:[];g(me=>({...me,[ee]:ae}))}return!0}default:return!1}},[v]),T=y.useCallback((D,E,$,z)=>{xe.spawnAgent({environmentId:D,prompt:E,personaId:$||"",workingDirectory:z||""}).then(K=>{m(K.id),v()},()=>{})},[v]),N=y.useCallback((D,E)=>{xe.sendInput({sessionId:D,text:E}).catch(()=>{})},[]),j=y.useCallback(D=>{xe.killAgent({id:D,graceful:!1}).catch(()=>{})},[]),w=y.useCallback(D=>{xe.killAgent({id:D,graceful:!0}).catch(()=>{})},[]),C=y.useCallback(D=>{xe.getSessionEvents({id:D}).then(E=>{const $=E.events.map(MB);if($.length>0){let z=0;o(K=>{const F=new Set;for(const me of K)me.sessionId===D&&F.add(`${me.timestamp}|${me.eventType}`);const ee=$.filter(me=>!F.has(`${me.timestamp}|${me.eventType}`)),ae=[...K,...ee].sort((me,ie)=>me.sessionId!==ie.sessionId?0:me.timestamp.localeCompare(ie.timestamp));return ae.length>Yi?(z=ae.length-Yi,ae.slice(-Yi)):ae}),z>0&&u(K=>K+z)}},()=>{})},[]),A=y.useCallback(()=>{o([]),u(0)},[]),M=y.useCallback(D=>{xe.getTaskSessions({id:D}).then(E=>{const $=E.sessions.map(ib);g(z=>({...z,[D]:$}))},()=>{})},[]);return{sessions:t,events:i,eventsDropped:c,lastSpawnedId:d,taskSessions:h,loadSessions:v,spawn:T,sendInput:N,kill:j,stopGraceful:w,loadSessionEvents:C,clearEvents:A,loadTaskSessions:M,handleMessage:_,handleSessionEvent:b,handleLegacyMessage:S}}function HB(){const[t,s]=y.useState([]),[i,o]=y.useState(!1),c=y.useCallback(()=>{xe.listWorkspaces({}).then(v=>{s(v.workspaces.map(IB))},()=>{})},[]),u=y.useCallback(v=>{switch(v.type){case"workspace.created":return o(!1),c(),!0;case"workspace.archived":case"workspace.updated":return c(),!0;default:return!1}},[c]),d=y.useCallback(()=>{o(!1)},[]),m=y.useCallback((v,_,b,S,T,N,j,w,C)=>{o(!0),xe.createWorkspace({name:v,description:_||"",repoUrl:b||"",environmentId:S||"",defaultPersonaId:T||void 0,useWorktrees:N??!0,workingDirectory:j||void 0}).then(()=>{o(!1),w==null||w()},A=>{o(!1);const M=A instanceof zc?A.message:"Failed to create workspace";C==null||C(M)})},[]),h=y.useCallback(v=>{xe.archiveWorkspace({id:v}).catch(()=>{})},[]),g=y.useCallback((v,_)=>{xe.updateWorkspace({id:v,..._}).catch(()=>{})},[]);return{workspaces:t,workspaceCreating:i,loadWorkspaces:c,createWorkspace:m,archiveWorkspace:h,updateWorkspace:g,handleEvent:u,onDisconnect:d}}function $B(){const[t,s]=y.useState([]),[i,o]=y.useState(void 0),c=y.useRef({}),u=y.useCallback(C=>{xe.listTasks({workspaceId:C}).then(A=>{const M=A.tasks.map(ob);s(D=>[...D.filter(E=>E.workspaceId!==C),...M])},()=>{})},[]),d=y.useCallback(()=>{xe.listTasks({}).then(C=>{const A=C.tasks.map(ob);s(M=>{const D=new Set(A.map(E=>E.id));return[...M.filter(E=>!D.has(E.id)),...A]})},()=>{})},[]),m=y.useCallback((C,A)=>{const M=D=>{clearTimeout(c.current[D]),c.current[D]=setTimeout(()=>{delete c.current[D],u(D)},200)};C?M(C):A&&s(D=>{const E=D.find($=>$.id===A);return E!=null&&E.workspaceId?M(E.workspaceId):d(),D})},[u,d]),h=y.useCallback(C=>{const A=C.payload;switch(C.type){case"task.created":{const M=typeof A.workspaceId=="string"?A.workspaceId:"";return M&&u(M),!0}case"task.started":{const M=typeof A.taskId=="string"?A.taskId:"",D=typeof A.sessionId=="string"?A.sessionId:"",E=typeof A.workspaceId=="string"?A.workspaceId:"";return o($=>M&&$===M?void 0:$),D&&M&&s($=>$.map(z=>z.id===M?{...z,latestSessionId:D}:z)),m(E,M),!0}case"task.completed":case"task.deleted":case"task.reparented":case"task.updated":{const M=typeof A.workspaceId=="string"?A.workspaceId:"",D=typeof A.taskId=="string"?A.taskId:"";return m(M,D),!0}default:return!1}},[u,m]),g=y.useCallback(()=>{o(void 0)},[]),v=y.useCallback(C=>{var A,M;if(C.type==="tasks"){const D=Array.isArray((A=C.payload)==null?void 0:A.tasks)?C.payload.tasks:[],E=typeof((M=C.payload)==null?void 0:M.workspaceId)=="string"&&C.payload.workspaceId?C.payload.workspaceId:"";return s(E?$=>[...$.filter(z=>z.workspaceId!==E),...D]:$=>{const z=new Set(D.map(K=>K.id));return[...$.filter(K=>!z.has(K.id)),...D]}),!0}return!1},[]),_=y.useCallback((C,A,M,D,E,$,z,K,F)=>{xe.createTask({workspaceId:C,title:A,description:M||"",dependsOn:D||[],parentTaskId:E||"",defaultPersonaId:$||void 0,canDecompose:z??void 0}).then(()=>{K==null||K()},ee=>{const ae=ee instanceof zc?ee.message:"Failed to create task";F==null||F(ae)})},[]),b=y.useCallback((C,A,M,D)=>{o(C),xe.startTask({taskId:C,personaId:A||"",environmentId:M||"",notes:D||""}).catch(()=>{o(void 0)})},[]),S=y.useCallback(C=>{xe.stopTask({id:C}).catch(()=>{})},[]),T=y.useCallback(C=>{xe.completeTask({id:C}).catch(()=>{})},[]),N=y.useCallback(C=>{xe.resumeTask({id:C}).catch(()=>{})},[]),j=y.useCallback((C,A,M,D,E)=>{xe.updateTask({id:C,title:A,description:M,dependsOn:D,...E!==void 0?{defaultPersonaId:E}:{}}).catch(()=>{})},[]),w=y.useCallback(C=>{xe.deleteTask({id:C}).catch(()=>{})},[]);return{tasks:t,taskStartingId:i,loadTasks:u,loadAllTasks:d,createTask:_,startTask:b,stopTask:S,completeTask:T,resumeTask:N,updateTask:j,deleteTask:w,handleEvent:h,onDisconnect:g,handleLegacyMessage:v}}function GB(){const[t,s]=y.useState([]),[i,o]=y.useState(void 0),[c,u]=y.useState(!1),d=y.useCallback(_=>{xe.queryFindings({workspaceId:_}).then(b=>{s(b.findings.map(Hf))},()=>{})},[]),m=y.useCallback(()=>{xe.queryFindings({workspaceId:""}).then(_=>{s(_.findings.map(Hf))},()=>{})},[]),h=y.useCallback(_=>{o(void 0),u(!0),xe.getFinding({id:_}).then(b=>{o(Hf(b)),u(!1)},()=>{o(void 0),u(!1)})},[]),g=y.useCallback(_=>{if(_.type==="finding.posted"){const b=typeof _.payload.workspaceId=="string"?_.payload.workspaceId:"";return b&&d(b),!0}return!1},[d]),v=y.useCallback((_,b,S,T,N)=>{xe.postFinding({workspaceId:_,title:b,content:S,category:T??"general",tags:N??[]}).catch(()=>{})},[]);return{findings:t,selectedFinding:i,findingLoading:c,loadFindings:d,loadAllFindings:m,loadFinding:h,postFinding:v,handleEvent:g}}function qB(){const[t,s]=y.useState([]),i=y.useCallback(()=>{xe.listTokens({}).then(d=>{s(d.tokens.map(OB))},()=>{})},[]),o=y.useCallback(d=>d.type==="token.changed"?(i(),!0):!1,[i]),c=y.useCallback((d,m,h,g,v)=>{xe.setToken({name:d,value:m,type:h,envVar:g,filePath:v}).catch(()=>{})},[]),u=y.useCallback(d=>{xe.deleteToken({name:d}).catch(()=>{})},[]);return{tokens:t,loadTokens:i,setToken:c,deleteToken:u,handleEvent:o}}function FB(){const[t,s]=y.useState({claude:"off",github:"off",copilot:"off",codex:"off",goose:"off"}),i=y.useCallback(()=>{xe.getCredentialProviders({}).then(u=>{s(BB(u))},()=>{})},[]),o=y.useCallback(u=>u.type==="credential.providers_changed"?(oB(u.payload)&&s(u.payload),!0):!1,[]),c=y.useCallback(u=>{const d=[{provider:"claude",value:u.claude},{provider:"github",value:u.github},{provider:"copilot",value:u.copilot},{provider:"codex",value:u.codex},{provider:"goose",value:u.goose}];for(const{provider:m,value:h}of d)xe.setCredentialProvider({provider:m,value:h}).catch(()=>{})},[]);return{credentialProviders:t,loadCredentials:i,updateCredentialProviders:c,handleEvent:o}}function ZB(){const[t,s]=y.useState([]),[i,o]=y.useState(""),[c,u]=y.useState(""),[d,m]=y.useState(!1),h=y.useCallback(()=>{xe.listCodespaces({}).then(v=>{s(v.codespaces.map(LB)),u(v.error)},()=>{})},[]),g=y.useCallback((v,_)=>{m(!0),o(""),xe.createCodespace({repo:v,machine:_??""}).then(()=>{m(!1),h()},b=>{m(!1);const S=b instanceof zc?b.message:"Failed to create codespace";o(S)})},[h]);return{codespaces:t,codespaceError:i,codespaceListError:c,codespaceCreating:d,listCodespaces:h,createCodespace:g}}function KB(){const[t,s]=y.useState([]),i=y.useCallback(()=>{xe.listPersonas({}).then(m=>{s(m.personas.map($f))},()=>{})},[]),o=y.useCallback(m=>{switch(m.type){case"persona.created":case"persona.updated":case"persona.deleted":return i(),!0;default:return!1}},[i]),c=y.useCallback((m,h,g,v,_,b,S,T,N)=>xe.createPersona({name:m,description:h,systemPrompt:g,runtime:v||"",model:_||"",maxTurns:b||0,type:S||"agent",script:T||"",allowedMcpTools:N||[]}).then(j=>{const w=$f(j);return s(C=>[...C.filter(A=>A.id!==w.id),w]),w}),[]),u=y.useCallback((m,h,g,v,_,b,S,T,N,j)=>{const w={id:m};return h!==void 0&&(w.name=h),g!==void 0&&(w.description=g),v!==void 0&&(w.systemPrompt=v),_!==void 0&&(w.runtime=_),b!==void 0&&(w.model=b),S!==void 0&&(w.maxTurns=S),T!==void 0&&(w.type=T),N!==void 0&&(w.script=N),j!==void 0&&(w.allowedMcpTools={tools:j}),xe.updatePersona(w).then(C=>{const A=$f(C);return s(M=>M.map(D=>D.id===A.id?A:D)),A})},[]),d=y.useCallback(async m=>{await xe.deletePersona({id:m}),s(h=>h.filter(g=>g.id!==m))},[]);return{personas:t,loadPersonas:i,createPersona:c,updatePersona:u,deletePersona:d,handleEvent:o}}function YB(t){if(t)try{return JSON.parse(t)}catch{return}}function JB(){const[t,s]=y.useState(new Map),[i,o]=y.useState([]),[c,u]=y.useState(void 0),[d,m]=y.useState(void 0),[h,g]=y.useState(!1),[v,_]=y.useState(""),b=y.useRef(""),S=y.useCallback(M=>{const D=M??"";b.current=D,_(""),g(!0),xe.listRecentKnowledgeNodes({limit:30,workspaceId:D}).then(E=>{const $=new Map,z=[];for(const K of E.nodes)$.set(K.id,hc(K));for(const K of E.edges)z.push(Gf(K));for(const K of z){const F=$.get(K.source);F&&(F.val+=1);const ee=$.get(K.target);ee&&(ee.val+=1)}s($),o(z),g(!1)},()=>{g(!1)})},[]),T=y.useCallback(M=>{M.trim()&&(_(M),m(void 0),u(void 0),g(!0),xe.searchKnowledge({query:M,limit:20,workspaceId:b.current}).then(D=>{const E=new Map,$=[];for(const z of D.results){z.node&&E.set(z.node.id,hc(z.node,z.edges.length));for(const K of z.edges)$.push(Gf(K))}s(E),o($),g(!1)},()=>{g(!1)}))},[]),N=y.useCallback(()=>{S(b.current)},[S]),j=y.useCallback(M=>{m(M),xe.getKnowledgeNode({id:M}).then(D=>{if(!D.node){u(void 0);return}u({node:hc(D.node,D.edges.length),edges:D.edges.map(E=>({fromId:E.fromId,toId:E.toId,type:E.type,metadata:YB(E.metadataJson)}))})},()=>{u(void 0)})},[]),w=y.useCallback(()=>{m(void 0),u(void 0)},[]),C=y.useCallback(M=>{xe.expandKnowledgeNode({id:M,depth:1}).then(D=>{s(E=>{const $=new Map(E);for(const z of D.nodes)$.has(z.id)||$.set(z.id,hc(z));return $}),o(E=>{const $=new Set(E.map(K=>`${K.source}:${K.target}:${K.type}`)),z=[];for(const K of D.edges){const F=Gf(K),ee=`${F.source}:${F.target}:${F.type}`;$.has(ee)||z.push(F)}return[...E,...z]})},()=>{})},[]),A=y.useCallback(M=>!1,[]);return{graphData:{nodes:[...t.values()],links:i},selectedNode:c,selectedId:d,loading:h,searchQuery:v,search:T,clearSearch:N,selectNode:j,clearSelection:w,expandNode:C,loadRecent:S,handleEvent:A}}function WB(){const[t,s]=y.useState(""),[i,o]=y.useState(void 0),[c,u]=y.useState({}),d=zB(),m=VB(),h=HB(),g=$B(),v=GB(),_=qB(),b=FB(),S=ZB(),T=KB(),N=JB(),{connected:j}=DB({onSessionEvent:F=>{m.handleSessionEvent({sessionId:F.sessionId,eventType:Sb(F.type),timestamp:F.timestamp,content:F.content,raw:F.raw||void 0})},onDomainEvent:F=>{try{const ee=JSON.parse(F.payloadJson);E({id:F.id,type:F.type,timestamp:F.timestamp,payload:ee})}catch{console.warn("[grackle] Failed to parse domain event payloadJson:",F.payloadJson)}},onConnect:$,onDisconnect:z}),w="default_persona_id",C="onboarding_completed",A=y.useCallback(async F=>{const ee=await xe.setSetting({key:w,value:F});s(ee.value)},[]),M=y.useCallback(()=>{o(!0),xe.setSetting({key:C,value:"true"}).catch(()=>{})},[]),D=y.useCallback((F,ee)=>{xe.getUsage({scope:F,id:ee}).then(ae=>{const me=`${F}:${ee}`;u(ie=>({...ie,[me]:UB(ae)}))},()=>{})},[]);function E(F){const ee=F.payload.key,ae=F.payload.value;if(F.type==="setting.changed"){ee===w&&s(ae??""),ee===C&&o(ae==="true");return}if(d.handleEvent(F)){(F.type==="environment.removed"||F.type==="environment.changed")&&m.loadSessions();return}if(!h.handleEvent(F)){if(g.handleEvent(F)){F.type==="task.started"&&m.loadSessions();return}v.handleEvent(F)||_.handleEvent(F)||b.handleEvent(F)||T.handleEvent(F)||N.handleEvent(F)}}function $(){d.loadEnvironments(),m.loadSessions(),h.loadWorkspaces(),_.loadTokens(),b.loadCredentials(),T.loadPersonas(),xe.getSetting({key:w}).then(F=>{s(F.value)},()=>{}),xe.getSetting({key:C}).then(F=>{o(F.value==="true")},()=>{}),g.loadAllTasks()}function z(){h.onDisconnect(),g.onDisconnect()}const K=y.useCallback(()=>{d.loadEnvironments(),m.loadSessions(),h.loadWorkspaces(),_.loadTokens()},[d.loadEnvironments,m.loadSessions,h.loadWorkspaces,_.loadTokens]);return{connected:j,environments:d.environments,sessions:m.sessions,events:m.events,eventsDropped:m.eventsDropped,lastSpawnedId:m.lastSpawnedId,workspaces:h.workspaces,tasks:g.tasks,findings:v.findings,selectedFinding:v.selectedFinding,findingLoading:v.findingLoading,tokens:_.tokens,spawn:m.spawn,sendInput:m.sendInput,kill:m.kill,stopGraceful:m.stopGraceful,refresh:K,loadSessionEvents:m.loadSessionEvents,clearEvents:m.clearEvents,loadWorkspaces:h.loadWorkspaces,createWorkspace:h.createWorkspace,archiveWorkspace:h.archiveWorkspace,updateWorkspace:h.updateWorkspace,loadTasks:g.loadTasks,loadAllTasks:g.loadAllTasks,createTask:g.createTask,startTask:g.startTask,stopTask:g.stopTask,completeTask:g.completeTask,resumeTask:g.resumeTask,updateTask:g.updateTask,deleteTask:g.deleteTask,loadFindings:v.loadFindings,loadAllFindings:v.loadAllFindings,loadFinding:v.loadFinding,postFinding:v.postFinding,loadEnvironments:d.loadEnvironments,addEnvironment:d.addEnvironment,updateEnvironment:d.updateEnvironment,loadTokens:_.loadTokens,setToken:_.setToken,deleteToken:_.deleteToken,credentialProviders:b.credentialProviders,updateCredentialProviders:b.updateCredentialProviders,provisionStatus:d.provisionStatus,provisionEnvironment:d.provisionEnvironment,stopEnvironment:d.stopEnvironment,removeEnvironment:d.removeEnvironment,codespaces:S.codespaces,codespaceError:S.codespaceError,codespaceListError:S.codespaceListError,codespaceCreating:S.codespaceCreating,listCodespaces:S.listCodespaces,createCodespace:S.createCodespace,workspaceCreating:h.workspaceCreating,taskStartingId:g.taskStartingId,personas:T.personas,createPersona:T.createPersona,updatePersona:T.updatePersona,deletePersona:T.deletePersona,taskSessions:m.taskSessions,loadTaskSessions:m.loadTaskSessions,appDefaultPersonaId:t,setAppDefaultPersonaId:A,onboardingCompleted:i,completeOnboarding:M,usageCache:c,loadUsage:D,knowledge:N}}function XB({children:t}){const s=WB();return l.jsx(vm.Provider,{value:s,children:t})}function QB(t,s){const i=y.useRef(null);y.useEffect(()=>{const o=i.current;if(i.current=t,o===null)return;const c=new Map;for(const d of o)c.set(d.id,d);const u=new Set;for(const d of t){u.add(d.id);const m=c.get(d.id);if(m&&m.status!==d.status&&d.status!=="sleeping"){if(d.status==="connecting"){s("Provisioning environment…","info");continue}d.status==="connected"?s("Environment connected","success"):d.status==="error"?s("Environment provision failed","error"):d.status==="disconnected"&&(m.status==="connected"?s("Environment disconnected","warning"):s("Environment stopped","info"))}}for(const d of o)u.has(d.id)||s("Environment removed","info")},[t,s])}const eL={working:{message:"Task is now running",variant:"info"},paused:{message:"Task paused",variant:"warning"},complete:{message:"Task complete",variant:"success"},failed:{message:"Task failed to complete",variant:"error"}};function tL(t){return eL[t]}function nL(t,s){if(t===void 0)return[];const i=[],o=new Map;for(const u of t)o.set(u.id,u);const c=new Set;for(const u of s){c.add(u.id);const d=o.get(u.id);if(!d||d.status===u.status)continue;const m=tL(u.status);m&&i.push(m)}for(const u of t)c.has(u.id)||i.push({message:"Task deleted",variant:"info"});return i}function sL(t,s){const i=y.useRef(void 0);y.useEffect(()=>{const o=i.current;i.current=t;const c=nL(o,t);for(const u of c)s(u.message,u.variant)},[t,s])}const aL="_dashboard_16pzm_1",iL="_kpiStrip_16pzm_11",oL="_kpiCard_16pzm_23",rL="_kpiValue_16pzm_68",lL="_kpiLabel_16pzm_76",cL="_bodyGrid_16pzm_84",uL="_section_16pzm_96",dL="_sectionHeader_16pzm_109",fL="_sectionIcon_16pzm_118",pL="_sectionTitle_16pzm_123",mL="_sectionCount_16pzm_131",hL="_sectionBody_16pzm_138",gL="_emptyHint_16pzm_143",vL="_sessionRow_16pzm_150",yL="_sessionPrompt_16pzm_177",bL="_sessionEnv_16pzm_186",_L="_sessionRuntime_16pzm_192",xL="_sessionStatus_16pzm_198",SL="_statusDot_16pzm_207",TL="_attentionRow_16pzm_233",kL="_attentionTitle_16pzm_259",wL="_attentionMeta_16pzm_267",NL="_reasonBadge_16pzm_274",jL="_bottomGrid_16pzm_301",CL="_envRow_16pzm_312",EL="_envName_16pzm_323",AL="_envStatusBadge_16pzm_333",DL="_workspaceRow_16pzm_369",RL="_workspaceTop_16pzm_395",ML="_workspaceName_16pzm_401",IL="_workspaceCounts_16pzm_407",OL="_progressBar_16pzm_415",BL="_progressFill_16pzm_422",_e={dashboard:aL,kpiStrip:iL,kpiCard:oL,kpiValue:rL,kpiLabel:lL,bodyGrid:cL,section:uL,sectionHeader:dL,sectionIcon:fL,sectionTitle:pL,sectionCount:mL,sectionBody:hL,emptyHint:gL,sessionRow:vL,sessionPrompt:yL,sessionEnv:bL,sessionRuntime:_L,sessionStatus:xL,statusDot:SL,attentionRow:TL,attentionTitle:kL,attentionMeta:wL,reasonBadge:NL,bottomGrid:jL,envRow:CL,envName:EL,envStatusBadge:AL,workspaceRow:DL,workspaceTop:RL,workspaceName:ML,workspaceCounts:IL,progressBar:OL,progressFill:BL},LL={hidden:{opacity:0,y:12},visible:t=>({opacity:1,y:0,transition:{delay:t*.06,duration:.3,ease:"easeOut"}})},gc={hidden:{opacity:0,y:16},visible:t=>({opacity:1,y:0,transition:{delay:.15+t*.08,duration:.35,ease:"easeOut"}})};function UL(t,s,i,o){const c=[`${t} of ${s} tasks completed`];return i>0&&c.push(`${i} in progress`),o>0&&c.push(`${o} failed`),c.join(", ")}function vc({value:t,label:s,accent:i,index:o,testId:c}){return l.jsxs(Dt.div,{className:_e.kpiCard,"data-accent":i,"data-testid":c,variants:LL,initial:"hidden",animate:"visible",custom:o,children:[l.jsx("span",{className:_e.kpiValue,children:t}),l.jsx("span",{className:_e.kpiLabel,children:s})]})}function zL(){const{workspaces:t,tasks:s,sessions:i,environments:o,loadTasks:c}=rt(),u=vt(),d=y.useRef(new Set);y.useEffect(()=>{for(const _ of t)d.current.has(_.id)||(d.current.add(_.id),c(_.id))},[t,c]);const m=y.useMemo(()=>gB(i,s,o),[i,s,o]),h=y.useMemo(()=>yB(i,o),[i,o]),g=y.useMemo(()=>vB(s,t),[s,t]),v=y.useMemo(()=>bB(t,s),[t,s,o]);return l.jsxs("div",{className:_e.dashboard,"data-testid":"dashboard",children:[l.jsxs("div",{className:_e.kpiStrip,"data-testid":"dashboard-kpi-strip",children:[l.jsx(vc,{value:m.activeSessions,label:"Active Sessions",accent:"green",index:0,testId:"kpi-active-sessions"}),l.jsx(vc,{value:m.blockedTasks,label:"Blocked Tasks",accent:"yellow",index:1,testId:"kpi-blocked-tasks"}),l.jsx(vc,{value:m.attentionTasks,label:"Needs Attention",accent:"red",index:2,testId:"kpi-attention-tasks"}),l.jsx(vc,{value:m.unhealthyEnvironments,label:"Unhealthy Envs",accent:"blue",index:3,testId:"kpi-unhealthy-envs"})]}),l.jsxs("div",{className:_e.bodyGrid,children:[l.jsxs(Dt.div,{className:_e.section,variants:gc,initial:"hidden",animate:"visible",custom:0,"data-testid":"dashboard-active-sessions",children:[l.jsxs("div",{className:_e.sectionHeader,children:[l.jsx("span",{className:_e.sectionIcon,"aria-hidden":"true",children:"●"}),l.jsx("span",{className:_e.sectionTitle,children:"Active Sessions"}),l.jsx("span",{className:_e.sectionCount,children:h.length})]}),l.jsx("div",{className:_e.sectionBody,children:h.length===0?l.jsx("div",{className:_e.emptyHint,children:"No active sessions"}):h.map(({session:_,environmentName:b})=>l.jsxs("button",{type:"button",className:_e.sessionRow,onClick:()=>u(Rp(_.id)),"data-testid":"session-row",children:[l.jsx("span",{className:_e.sessionPrompt,title:_.prompt,children:_.prompt||"—"}),l.jsx("span",{className:_e.sessionEnv,children:b}),l.jsx("span",{className:_e.sessionRuntime,children:_.runtime}),l.jsxs("span",{className:_e.sessionStatus,children:[l.jsx("span",{className:_e.statusDot,"data-status":_.status}),_.status]})]},_.id))})]}),l.jsxs(Dt.div,{className:_e.section,variants:gc,initial:"hidden",animate:"visible",custom:1,"data-testid":"dashboard-needs-attention",children:[l.jsxs("div",{className:_e.sectionHeader,children:[l.jsx("span",{className:_e.sectionIcon,"aria-hidden":"true",children:"⚑"}),l.jsx("span",{className:_e.sectionTitle,children:"Needs Attention"}),l.jsx("span",{className:_e.sectionCount,children:g.length})]}),l.jsx("div",{className:_e.sectionBody,children:g.length===0?l.jsx("div",{className:_e.emptyHint,children:"All clear"}):g.map(({task:_,reason:b,workspaceName:S})=>l.jsxs("button",{type:"button",className:_e.attentionRow,onClick:()=>u(Xn(_.id)),"data-testid":"attention-row",children:[l.jsxs("div",{className:_e.attentionTitle,children:[l.jsx("span",{className:_e.reasonBadge,"data-reason":b,children:b}),_.title]}),l.jsx("div",{className:_e.attentionMeta,children:l.jsx("span",{children:S})})]},_.id))})]})]}),l.jsxs("div",{className:_e.bottomGrid,children:[l.jsxs(Dt.div,{className:_e.section,variants:gc,initial:"hidden",animate:"visible",custom:2,"data-testid":"dashboard-env-health",children:[l.jsxs("div",{className:_e.sectionHeader,children:[l.jsx("span",{className:_e.sectionIcon,"aria-hidden":"true",children:"◈"}),l.jsx("span",{className:_e.sectionTitle,children:"Environment Health"}),l.jsx("span",{className:_e.sectionCount,children:o.length})]}),l.jsx("div",{className:_e.sectionBody,children:o.length===0?l.jsx("div",{className:_e.emptyHint,children:"No environments configured"}):o.map(_=>l.jsxs("div",{className:_e.envRow,"data-testid":"dashboard-env-row",children:[l.jsx("span",{className:_e.envName,children:_.displayName}),l.jsx("span",{className:_e.envStatusBadge,"data-status":_.status,children:_.status})]},_.id))})]}),l.jsxs(Dt.div,{className:_e.section,variants:gc,initial:"hidden",animate:"visible",custom:3,"data-testid":"dashboard-workspace-snapshot",children:[l.jsxs("div",{className:_e.sectionHeader,children:[l.jsx("span",{className:_e.sectionIcon,"aria-hidden":"true",children:"▦"}),l.jsx("span",{className:_e.sectionTitle,children:"Workspaces"}),l.jsx("span",{className:_e.sectionCount,children:t.length})]}),l.jsx("div",{className:_e.sectionBody,children:v.length===0?l.jsx("div",{className:_e.emptyHint,children:"No workspaces yet"}):v.map(({workspace:_,totalTasks:b,completedTasks:S,workingTasks:T,failedTasks:N})=>{const j=b>0?Math.round(S/b*100):0;return l.jsxs("button",{type:"button",className:_e.workspaceRow,onClick:()=>u(ni(_.id,_.environmentId)),"data-testid":"workspace-row",children:[l.jsxs("div",{className:_e.workspaceTop,children:[l.jsx("span",{className:_e.workspaceName,children:_.name}),l.jsxs("span",{className:_e.workspaceCounts,"aria-label":UL(S,b,T,N),children:[S,"/",b,T>0&&l.jsxs("span",{style:{color:"var(--accent-green)"},"aria-hidden":"true",children:["▸",T]}),N>0&&l.jsxs("span",{style:{color:"var(--accent-red)"},"aria-hidden":"true",children:["✗",N]})]})]}),b>0&&l.jsx("div",{className:_e.progressBar,children:l.jsx("div",{className:_e.progressFill,style:{width:`${j}%`}})})]},_.id)})})]})]})]})}const PL="_panelContainer_101ly_1",VL="_emptyState_101ly_8",HL="_fadeIn_101ly_1",$L="_workspaceSummary_101ly_17",GL="_workspaceSummaryTitle_101ly_28",qL="_workspaceSummarySubtitle_101ly_32",FL="_header_101ly_36",ZL="_headerInfo_101ly_71",KL="_killButton_101ly_77",YL="_headerTitle_101ly_106",JL="_headerActions_101ly_121",WL="_taskStatusBadge_101ly_128",XL="_taskBranch_101ly_137",QL="_taskBlockedBadge_101ly_143",e5="_btnPrimary_101ly_151",t5="_btnDanger_101ly_182",n5="_btnGhost_101ly_221",s5="_rejectInput_101ly_247",a5="_tabBar_101ly_277",i5="_tab_101ly_277",o5="_active_101ly_303",r5="_eventScroll_101ly_308",l5="_tabContent_101ly_314",c5="_noContext_101ly_319",u5="_overviewContent_101ly_325",d5="_overviewDashboard_101ly_334",f5="_overviewHero_101ly_340",p5="_statusBadge_101ly_347",m5="_statusPending_101ly_359",h5="_statusAssigned_101ly_364",g5="_statusInProgress_101ly_369",v5="_statusReview_101ly_374",y5="_statusDone_101ly_379",b5="_statusFailed_101ly_384",_5="_statusWaitingInput_101ly_389",x5="_overviewBranchPill_101ly_394",S5="_branchLink_101ly_409",T5="_overviewSection_101ly_420",k5="_overviewLabel_101ly_426",w5="_overviewValue_101ly_433",N5="_overviewMuted_101ly_438",j5="_overviewMarkdown_101ly_444",C5="_envRow_101ly_513",E5="_envDot_101ly_519",A5="_envDotGreen_101ly_526",D5="_envDotYellow_101ly_530",R5="_envDotRed_101ly_534",M5="_envDotGray_101ly_538",I5="_depList_101ly_542",O5="_depItem_101ly_548",B5="_depBlocked_101ly_555",L5="_depDone_101ly_559",U5="_timeline_101ly_563",z5="_timelineRow_101ly_569",P5="_timelineKey_101ly_576",V5="_timelineValue_101ly_582",H5="_timelineDelta_101ly_586",$5="_reviewNotes_101ly_597",G5="_overviewDescription_101ly_608",q5="_waitingMessage_101ly_614",F5="_errorMessage_101ly_618",Z5="_attemptSelector_101ly_622",K5="_attemptLabel_101ly_638",Y5="_attemptButton_101ly_642",J5="_attemptActive_101ly_659",W5="_attemptStatus_101ly_665",X5="_emptyCta_101ly_671",Q5="_ctaTitle_101ly_683",e8="_ctaDescription_101ly_689",t8="_ctaButton_101ly_696",n8="_ctaCreateForm_101ly_731",s8="_ctaCreateInput_101ly_737",a8="_ctaCreateOk_101ly_768",i8="_ctaLink_101ly_803",o8="_workspaceHeader_101ly_817",r8="_workspaceName_101ly_842",l8="_workspaceMeta_101ly_855",c8="_metaRow_101ly_863",u8="_metaLabel_101ly_876",d8="_metaValue_101ly_891",f8="_archiveButton_101ly_901",p8="_repoLink_101ly_931",m8="_metaToggle_101ly_941",h8="_metaToggleArrow_101ly_962",g8="_metaToggleArrowOpen_101ly_967",v8="_progressBarContainer_101ly_971",y8="_progressBar_101ly_971",b8="_progressFill_101ly_987",_8="_progressLabel_101ly_994",x8="_metaTimestamps_101ly_1001",S8="_metaTimestamp_101ly_1001",U={panelContainer:PL,emptyState:VL,fadeIn:HL,workspaceSummary:$L,workspaceSummaryTitle:GL,workspaceSummarySubtitle:qL,header:FL,headerInfo:ZL,killButton:KL,headerTitle:YL,headerActions:JL,taskStatusBadge:WL,taskBranch:XL,taskBlockedBadge:QL,btnPrimary:e5,btnDanger:t5,btnGhost:n5,rejectInput:s5,tabBar:a5,tab:i5,active:o5,eventScroll:r5,tabContent:l5,noContext:c5,overviewContent:u5,overviewDashboard:d5,overviewHero:f5,statusBadge:p5,statusPending:m5,statusAssigned:h5,statusInProgress:g5,statusReview:v5,statusDone:y5,statusFailed:b5,statusWaitingInput:_5,overviewBranchPill:x5,branchLink:S5,overviewSection:T5,overviewLabel:k5,overviewValue:w5,overviewMuted:N5,overviewMarkdown:j5,envRow:C5,envDot:E5,envDotGreen:A5,envDotYellow:D5,envDotRed:R5,envDotGray:M5,depList:I5,depItem:O5,depBlocked:B5,depDone:L5,timeline:U5,timelineRow:z5,timelineKey:P5,timelineValue:V5,timelineDelta:H5,reviewNotes:$5,overviewDescription:G5,waitingMessage:q5,errorMessage:F5,attemptSelector:Z5,attemptLabel:K5,attemptButton:Y5,attemptActive:J5,attemptStatus:W5,emptyCta:X5,ctaTitle:Q5,ctaDescription:e8,ctaButton:t8,ctaCreateForm:n8,ctaCreateInput:s8,ctaCreateOk:a8,ctaLink:i8,workspaceHeader:o8,workspaceName:r8,workspaceMeta:l8,metaRow:c8,metaLabel:u8,metaValue:d8,archiveButton:f8,repoLink:p8,metaToggle:m8,metaToggleArrow:h8,metaToggleArrowOpen:g8,progressBarContainer:v8,progressBar:y8,progressFill:b8,progressLabel:_8,metaTimestamps:x8,metaTimestamp:S8};function T8(){return l.jsx("div",{className:U.emptyState,children:"Select a task or click + to create one"})}function k8(){return l.jsx("div",{className:U.emptyState,children:"Select an environment to manage its workspaces, or add a new one."})}function w8(){const{workspaces:t,environments:s}=rt(),i=vt(),o=s.length>0;return t.length>0?l.jsx(zL,{}):l.jsxs("div",{className:U.emptyCta,"data-testid":"welcome-cta",children:[l.jsx("div",{className:U.ctaTitle,children:"Welcome to Grackle"}),l.jsx("div",{className:U.ctaDescription,children:"Organize your work into workspaces and let agents tackle the tasks."}),l.jsx("button",{className:U.ctaButton,onClick:()=>i($b),disabled:!o,"data-testid":"welcome-create-button",children:"Create Your First Workspace"}),!o&&l.jsx("div",{className:U.ctaDescription,children:"Add an environment first before creating a workspace."})]})}const N8="_panelContainer_19poq_1",j8="_chatHeader_19poq_8",C8="_chatHeaderInfo_19poq_37",E8="_emptyState_19poq_43",A8="_emptyTitle_19poq_55",D8="_emptyDescription_19poq_61",R8="_emptyHint_19poq_67",ei={panelContainer:N8,chatHeader:j8,chatHeaderInfo:C8,emptyState:E8,emptyTitle:A8,emptyDescription:D8,emptyHint:R8};function M8({hasLocalEnvironment:t}){return l.jsxs("div",{className:ei.emptyState,"data-testid":"chat-empty-state",children:[l.jsx("div",{className:ei.emptyTitle,children:"Welcome to Grackle"}),l.jsx("div",{className:ei.emptyDescription,children:t?"Type a message below to start chatting with the System agent. It can help you plan work, create tasks, and coordinate agents.":"Add a local environment in Settings to start chatting."}),!t&&l.jsx("div",{className:ei.emptyHint,children:"Go to Settings → Environments to add one."})]})}function I8(){const{tasks:t,sessions:s,events:i,eventsDropped:o,environments:c,loadTaskSessions:u,loadSessionEvents:d,kill:m,stopGraceful:h,taskSessions:g,sendInput:v,spawn:_,startTask:b,personas:S,provisionEnvironment:T}=rt(),{showToast:N}=dn(),j=y.useRef(void 0),[w,C]=y.useState(),A=t.find(F=>F.id===or),M=A!=null&&A.latestSessionId?s.find(F=>F.id===A.latestSessionId)??(g[or]??[]).find(F=>F.id===A.latestSessionId):void 0;y.useEffect(()=>{u(or)},[u]),y.useEffect(()=>{A!=null&&A.latestSessionId&&u(or)},[A==null?void 0:A.latestSessionId,u]),y.useEffect(()=>{M&&M.id!==j.current&&(j.current=M.id,d(M.id))},[M==null?void 0:M.id,d]);const D=y.useMemo(()=>{if(!M)return[];const F=i.filter(ee=>ee.sessionId===M.id);return _m(bm(F))},[i,M==null?void 0:M.id]),E=c.find(F=>F.adapterType==="local"&&F.status==="connected"),$=M!==void 0&&M.status!=="stopped"&&M.status!=="suspended",z=(M==null?void 0:M.status)==="idle";y.useEffect(()=>{w&&M&&z&&(v(M.id,w),C(void 0))},[w,z,M==null?void 0:M.id,v]);const K=y.useCallback((F,ee,ae,me)=>{me&&C(me),b(F,ee,ae)},[b]);return l.jsxs("div",{className:ei.panelContainer,"data-testid":"chat-page",children:[$&&l.jsxs("div",{className:ei.chatHeader,children:[l.jsxs("span",{className:ei.chatHeaderInfo,children:["Session: ",M.id.slice(0,8)," | ",M.runtime," | ",M.status]}),l.jsx(qb,{label:"Stop",onClick:()=>h(M.id),variant:"danger",size:"sm","data-testid":"stop-split-button",options:[{label:"Stop",description:"Graceful shutdown",onClick:()=>h(M.id)},{label:"Kill",description:"Force kill",onClick:()=>m(M.id)}]})]}),l.jsx(mm,{events:D,eventsDropped:o,emptyState:l.jsx(M8,{hasLocalEnvironment:!!E})}),E&&$&&l.jsx(kr,{mode:"send",sessionId:M.id,environmentId:M.environmentId,personas:S,environments:c,onSendInput:v,onSpawn:_,onStartTask:b,onProvisionEnvironment:T,onShowToast:N}),E&&!$&&l.jsx(kr,{mode:"start",taskId:or,environmentId:E.id,personas:S,environments:c,onSendInput:v,onSpawn:_,onStartTask:K,onProvisionEnvironment:T,onShowToast:N})]})}function O8(){const t=uB(),[s]=Dp(),i=s.get("env")??"",{sendInput:o,spawn:c,startTask:u,personas:d,environments:m,provisionEnvironment:h}=rt(),{showToast:g}=dn();return l.jsxs("div",{className:U.panelContainer,children:[l.jsx(fs,{segments:t}),l.jsx("div",{className:U.emptyState,children:"Enter a prompt below to start a new session"}),l.jsx(kr,{mode:"spawn",environmentId:i,showPersonaSelect:!0,personas:d,environments:m,onSendInput:o,onSpawn:c,onStartTask:u,onProvisionEnvironment:h,onShowToast:g})]})}function B8({sessionId:t,session:s,isActive:i,onStop:o,onKill:c}){return l.jsxs("div",{className:U.header,children:[l.jsxs("span",{children:["Session: ",t.slice(0,8),s&&` | ${s.runtime} | ${s.endReason||s.status}`,s!=null&&s.inputTokens||s!=null&&s.outputTokens||s!=null&&s.costUsd?` | ${Fb((s.inputTokens??0)+(s.outputTokens??0))} tokens · ${io(s.costUsd??0)}`:""]}),l.jsxs("span",{className:U.headerInfo,children:[s&&l.jsx("span",{children:s.prompt.length>60?s.prompt.slice(0,60)+"...":s.prompt}),i&&l.jsx(qb,{label:"Stop",onClick:o,variant:"danger",size:"sm","data-testid":"stop-split-button",options:[{label:"Stop",description:"Graceful shutdown",onClick:o},{label:"Kill",description:"Force kill",onClick:c}]})]})]})}function L8({session:t}){const s=t&&(t.status==="stopped"||t.status==="suspended"),i=s?`Session ${t.endReason||t.status} with no events recorded.`:"Waiting for events...";return l.jsx("div",{className:s?U.errorMessage:U.waitingMessage,children:i})}function U8(){const{sessionId:t}=Qn(),{events:s,eventsDropped:i,sessions:o,kill:c,stopGraceful:u,loadSessionEvents:d,sendInput:m,spawn:h,startTask:g,personas:v,environments:_,provisionEnvironment:b}=rt(),{showToast:S}=dn(),T=y.useRef(void 0),N=dB(t),j=o.find(A=>A.id===t)??void 0,w=y.useMemo(()=>{const A=t?s.filter(M=>M.sessionId===t):[];return _m(bm(A))},[s,t]);if(y.useEffect(()=>{t&&t!==T.current&&(T.current=t,d(t))},[t,d]),!t)return l.jsx("div",{className:U.emptyState,children:"No session selected"});const C=(j==null?void 0:j.status)==="running"||(j==null?void 0:j.status)==="idle";return l.jsxs("div",{className:U.panelContainer,children:[l.jsx(fs,{segments:N}),l.jsx(B8,{sessionId:t,session:j,isActive:C,onStop:()=>u(t),onKill:()=>c(t)}),l.jsx(mm,{events:w,eventsDropped:i,emptyState:l.jsx(L8,{session:j})}),C&&l.jsx(kr,{mode:"send",sessionId:t,environmentId:j.environmentId,personas:v,environments:_,onSendInput:m,onSpawn:h,onStartTask:g,onProvisionEnvironment:b,onShowToast:S})]})}function z8(t){if(!t)return!1;const s=t.tagName;return!!(s==="INPUT"||s==="TEXTAREA"||s==="SELECT"||t.isContentEditable)}function Us(t,s){const i=y.useRef(s);i.current=s;const{key:o,ctrl:c=!1,shift:u=!1,suppressInInputs:d=!0,enabled:m=!0}=t;y.useEffect(()=>{if(!m)return;const h=g=>{if(d&&z8(document.activeElement??void 0))return;const v=g.ctrlKey||g.metaKey;c===v&&(u&&!g.shiftKey||g.key===o&&i.current())};return document.addEventListener("keydown",h),()=>{document.removeEventListener("keydown",h)}},[o,c,u,d,m])}function cb(t){if(!t)return"";const s=new Date(t);if(isNaN(s.getTime()))return"";const o=Date.now()-s.getTime();if(o<0)return"just now";const c=Math.floor(o/6e4);if(c<1)return"just now";if(c<60)return`${c}m ago`;const u=Math.floor(c/60);if(u<24)return`${u}h ago`;const d=Math.floor(u/24);return d<30?`${d}d ago`:s.toLocaleDateString(void 0,{month:"short",day:"numeric",year:"numeric"})}const Ff=100;function P8(t){try{const s=new URL(t);return s.protocol!=="http:"&&s.protocol!=="https:"?void 0:s.toString()}catch{return}}function V8(){const{workspaceId:t,environmentId:s}=Qn(),i=vt(),{tasks:o,environments:c,workspaces:u,personas:d,sessions:m,archiveWorkspace:h,updateWorkspace:g,usageCache:v,loadUsage:_}=rt(),{resolvedThemeId:b}=Hx(),[S,T]=y.useState("tasks"),[N,j]=y.useState(!1),[w,C]=y.useState(null),[A,M]=y.useState(!1),D=y.useRef(void 0),E=u.find(X=>X.id===t),$=s??(E==null?void 0:E.environmentId)??"",z=fB(t,$,u,c);Us({key:"1"},()=>T("graph")),Us({key:"2"},()=>T("board")),Us({key:"3"},()=>T("tasks")),y.useEffect(()=>{const X=D.current;D.current=t,!(X===void 0||X===t)&&w!==null&&C(null)},[t,w]);const K=m.reduce((X,O)=>X+(O.costUsd??0),0);y.useEffect(()=>{t&&_("workspace",t)},[t,_,K]);const F=t?v[`workspace:${t}`]:void 0,ee=o.filter(X=>X.workspaceId===t),ae=ee.filter(X=>X.status==="complete").length,me=ee.length,ie=me>0?Math.round(ae/me*100):0;return l.jsxs("div",{className:U.panelContainer,children:[l.jsx(fs,{segments:z}),l.jsxs("div",{className:U.workspaceHeader,children:[l.jsx("span",{className:U.workspaceName,"data-testid":"workspace-name",children:l.jsx(Kt,{value:(E==null?void 0:E.name)||"",onSave:X=>{E&&g(E.id,{name:X})},validate:X=>{const O=X.trim();if(!O)return"Name is required";if(O.length>Ff)return`Max ${Ff} characters`},maxLength:Ff,fieldId:"name",activeFieldId:w,onActivate:C,ariaLabel:"Workspace name",renderDisplay:X=>X||t||void 0,"data-testid":"edit-name"})}),l.jsx("button",{className:U.archiveButton,onClick:()=>j(!0),title:"Archive workspace","data-testid":"archive-workspace-button",children:"Archive"})]}),l.jsxs("button",{className:U.metaToggle,onClick:()=>M(!A),"aria-expanded":!A,"aria-controls":"workspace-meta-panel","data-testid":"meta-toggle",children:[l.jsx("span",{className:`${U.metaToggleArrow} ${A?"":U.metaToggleArrowOpen}`,children:"▶"}),"Details"]}),!A&&l.jsxs("div",{className:U.workspaceMeta,"data-testid":"workspace-meta",id:"workspace-meta-panel",children:[l.jsxs("div",{className:U.metaRow,children:[l.jsx("span",{className:U.metaLabel,children:"Description"}),l.jsx("div",{className:U.metaValue,children:l.jsx(vp,{value:(E==null?void 0:E.description)||"",onSave:X=>{E&&g(E.id,{description:X})},fieldId:"description",activeFieldId:w,onActivate:C,renderDisplay:X=>X?l.jsx("span",{className:U.overviewMarkdown,children:l.jsx(Pc,{remarkPlugins:[Vc],children:X})}):void 0,placeholder:"No description",ariaLabel:"Workspace description","data-testid":"edit-description"})})]}),l.jsxs("div",{className:U.metaRow,children:[l.jsx("span",{className:U.metaLabel,children:"Repository"}),l.jsx("div",{className:U.metaValue,children:l.jsx(Kt,{value:(E==null?void 0:E.repoUrl)||"",onSave:X=>{E&&g(E.id,{repoUrl:X})},validate:X=>{const O=X.trim();if(O&&!/^https?:\/\/.+/.test(O))return"Must be a valid http(s) URL"},fieldId:"repoUrl",activeFieldId:w,onActivate:C,renderDisplay:X=>{const O=P8(X);return O?l.jsx("a",{className:U.repoLink,href:O,target:"_blank",rel:"noopener noreferrer",onClick:q=>q.stopPropagation(),children:X}):X?l.jsx("span",{children:X}):void 0},placeholder:"No repository",ariaLabel:"Workspace repository URL","data-testid":"edit-repo"})})]}),l.jsxs("div",{className:U.metaRow,children:[l.jsx("span",{className:U.metaLabel,children:"Environment"}),l.jsx("div",{className:U.metaValue,children:l.jsx(mM,{value:(E==null?void 0:E.environmentId)||"",onSave:X=>{E&&X&&g(E.id,{environmentId:X})},environments:c,fieldId:"environmentId",activeFieldId:w,onActivate:C,placeholder:"Select environment",ariaLabel:"Workspace environment","data-testid":"edit-env"})})]}),l.jsxs("div",{className:U.metaRow,children:[l.jsx("span",{className:U.metaLabel,children:"Persona"}),l.jsx("div",{className:U.metaValue,children:l.jsx(Bc,{value:(E==null?void 0:E.defaultPersonaId)||"",onSave:X=>{E&&g(E.id,{defaultPersonaId:X})},options:[{value:"",label:"(Inherit)"},...d.map(X=>({value:X.id,label:X.name}))],fieldId:"defaultPersonaId",activeFieldId:w,onActivate:C,renderDisplay:X=>{const O=d.find(q=>q.id===X);if(O)return l.jsx("span",{children:O.name})},placeholder:(E==null?void 0:E.defaultPersonaId)||"(Inherit)",ariaLabel:"Workspace default persona","data-testid":"edit-persona"})})]}),l.jsxs("div",{className:U.metaRow,children:[l.jsx("span",{className:U.metaLabel,children:"Worktrees"}),l.jsx("div",{className:U.metaValue,children:l.jsx(oM,{checked:(E==null?void 0:E.useWorktrees)??!0,onChange:X=>{E&&g(E.id,{useWorktrees:X})},label:"Enable worktree isolation","data-testid":"worktree-toggle"})})]}),l.jsxs("div",{className:U.metaRow,children:[l.jsx("span",{className:U.metaLabel,children:"Working Dir"}),l.jsx("div",{className:U.metaValue,children:l.jsx(Kt,{value:(E==null?void 0:E.workingDirectory)||"",onSave:X=>{E&&g(E.id,{workingDirectory:X})},fieldId:"workingDirectory",activeFieldId:w,onActivate:C,placeholder:"Default (server default)",ariaLabel:"Working directory","data-testid":"edit-working-directory"})})]}),E&&l.jsxs("div",{className:U.metaTimestamps,children:[l.jsxs("span",{className:U.metaTimestamp,children:["Created ",cb(E.createdAt)]}),E.updatedAt&&E.updatedAt!==E.createdAt&&l.jsxs("span",{className:U.metaTimestamp,children:["· Updated ",cb(E.updatedAt)]})]})]}),me>0&&l.jsxs("div",{className:U.progressBarContainer,"data-testid":"progress-bar",children:[l.jsx("div",{className:U.progressBar,children:l.jsx("div",{className:U.progressFill,style:{width:`${ie}%`}})}),l.jsxs("span",{className:U.progressLabel,children:[ae,"/",me]})]}),F&&F.costUsd>0&&l.jsx("div",{className:U.progressBarContainer,children:l.jsxs("span",{className:U.progressLabel,children:["Usage: ",io(F.costUsd)," (",F.sessionCount," session",F.sessionCount!==1?"s":"",")"]})}),l.jsxs("div",{className:U.tabBar,role:"tablist","aria-label":"Workspace view",children:[l.jsx("button",{role:"tab","aria-selected":S==="graph",className:`${U.tab} ${S==="graph"?U.active:""}`,onClick:()=>T("graph"),children:"Graph"}),l.jsx("button",{role:"tab","aria-selected":S==="board",className:`${U.tab} ${S==="board"?U.active:""}`,onClick:()=>T("board"),"data-testid":"board-tab",children:"Board"}),l.jsx("button",{role:"tab","aria-selected":S==="tasks",className:`${U.tab} ${S==="tasks"?U.active:""}`,onClick:()=>T("tasks"),children:"Tasks"})]}),S==="tasks"&&me>0&&l.jsxs("div",{className:U.workspaceSummary,children:[l.jsx("span",{className:U.workspaceSummaryTitle,children:`${ae}/${me} tasks complete`}),l.jsx("span",{className:U.workspaceSummarySubtitle,children:"Select a task or click + to create one"})]}),S==="tasks"&&me===0&&l.jsxs("div",{className:U.emptyCta,children:[l.jsx("button",{className:U.ctaButton,onClick:()=>i(ri(t,void 0,$)),children:"Create Task"}),l.jsx("div",{className:U.ctaDescription,children:"Break your work into tasks and let agents tackle them"})]}),S==="board"&&l.jsx(O4,{workspaceId:t,environmentId:$,tasks:o,sessions:m,personas:d,environments:c}),S==="graph"&&l.jsx(d2,{workspaceId:t,environmentId:$,tasks:o,resolvedThemeId:b}),l.jsx(ii,{isOpen:N,title:"Archive Workspace?",description:"This will hide the workspace from the sidebar. Tasks will not be deleted.",confirmLabel:"Archive",onConfirm:()=>{E&&(h(E.id),i("/",{replace:!0})),j(!1)},onCancel:()=>j(!1)})]})}const H8="_container_3pgew_1",$8="_header_3pgew_8",G8="_headerTitle_3pgew_35",q8="_headerActions_3pgew_44",F8="_body_3pgew_51",Z8="_btnPrimary_3pgew_63",K8="_btnGhost_3pgew_94",Y8="_error_3pgew_116",ya={container:H8,header:$8,headerTitle:G8,headerActions:q8,body:F8,btnPrimary:Z8,btnGhost:K8,error:Y8};function J8(t){const s={};return t.name.trim()||(s.name="Name is required"),t.repoUrl.trim()&&!/^https?:\/\/.+/i.test(t.repoUrl.trim())&&(s.repoUrl="Must be a valid http(s) URL"),t.environmentId||(s.environmentId="Environment is required"),Object.keys(s).length>0?s:void 0}const W8=[{label:"Home",url:ai},{label:"New Workspace",url:void 0}];function X8(){const[t]=Dp(),s=t.get("environment")??void 0,{environments:i,personas:o,createWorkspace:c,workspaceCreating:u}=rt(),{showToast:d}=dn(),m=vt(),[h,g]=y.useState(()=>{var j;return F4(void 0,s||((j=i[0])==null?void 0:j.id))}),[v,_]=y.useState(),[b,S]=y.useState();y.useEffect(()=>{s||h.environmentId||i.length===0||g(j=>{var w;return j.environmentId?j:{...j,environmentId:((w=i[0])==null?void 0:w.id)??""}})},[i,s,h.environmentId]);const T=()=>{const j=J8(h);if(j){_(j),S(void 0);return}_(void 0),S(void 0),c(h.name.trim(),h.description,h.repoUrl.trim(),h.environmentId,h.defaultPersonaId,h.useWorktrees,h.workingDirectory,()=>{d("Workspace created","success"),m(ai,{replace:!0})},w=>{S(w)})},N=()=>{m(s?si(s):ai,{replace:!0})};return l.jsxs("div",{className:ya.container,children:[l.jsxs("div",{className:ya.header,children:[l.jsx("div",{className:ya.headerTitle,children:l.jsx(fs,{segments:W8})}),l.jsxs("div",{className:ya.headerActions,children:[l.jsx("button",{className:ya.btnGhost,onClick:N,disabled:u,"data-testid":"workspace-create-cancel",children:"Cancel"}),l.jsx("button",{className:ya.btnPrimary,onClick:T,disabled:u||!h.name.trim()||!h.environmentId,"data-testid":"workspace-create-save",children:u?l.jsx(Sx,{size:"sm",label:"Creating"}):"Create Workspace"})]})]}),l.jsxs("div",{className:ya.body,children:[l.jsx(K4,{values:h,onChange:j=>{g(j),_(void 0),S(void 0)},environments:i,personas:o,errors:v,disabled:u,autoFocusName:!0}),b&&l.jsx("div",{className:ya.error,"data-testid":"workspace-create-submit-error",children:b})]})]})}function ub(){const{workspaceId:t,environmentId:s}=Qn(),[i]=Dp(),o=t??i.get("workspace")??"",c=i.get("parent")??void 0,{tasks:u,workspaces:d,personas:m,createTask:h,updateTask:g}=rt(),{showToast:v}=dn();return l.jsx(Ox,{mode:"new",workspaceId:o,parentTaskId:c,environmentId:s,tasks:u,workspaces:d,personas:m,onCreateTask:h,onUpdateTask:g,onShowToast:v})}function yc(t){if(!t)return"—";const s=new Date(t);return isNaN(s.getTime())?"—":s.toLocaleString(void 0,{month:"short",day:"numeric",year:"numeric",hour:"2-digit",minute:"2-digit"})}function Zf(t,s){if(!t||!s)return;const i=new Date(s).getTime()-new Date(t).getTime();if(isNaN(i)||i<0)return;const o=Math.floor(i/6e4),c=Math.floor(i%6e4/1e3);if(o===0)return`${c}s`;const u=Math.floor(o/60),d=o%60;return u===0?`${o}m ${c}s`:`${u}h ${d}m`}function db(t){const s=t.toLowerCase();return s==="ready"||s==="running"||s==="available"||s==="connected"?U.envDotGreen:s==="provisioning"||s==="starting"||s==="pending"||s==="connecting"?U.envDotYellow:s==="error"||s==="failed"||s==="disconnected"?U.envDotRed:U.envDotGray}function Q8({status:t}){const s=Sa(t),i=sk(t);return l.jsx("span",{className:`${U.statusBadge} ${U[i]??U.statusPending}`,children:s.label})}function eU({task:t,tasksById:s,environments:i,workspaces:o,taskSessions:c,selectedEnvId:u}){const{loadUsage:d,usageCache:m}=rt(),h=c.reduce((A,M)=>A+(M.costUsd??0),0);y.useEffect(()=>{d("task",t.id),t.childTaskIds.length>0&&d("task_tree",t.id)},[t.id,t.childTaskIds.length,d,h]);const g=`task:${t.id}`,v=g in m?m[g]:void 0,_=`task_tree:${t.id}`,b=t.childTaskIds.length>0&&_ in m?m[_]:void 0,S=c.length>0?c[c.length-1]:void 0,T=(S==null?void 0:S.environmentId)??"",N=T?i.find(A=>A.id===T):void 0,j=o.find(A=>A.id===t.workspaceId),w=i.find(A=>A.id===u),C=t.branch&&(j!=null&&j.repoUrl)?`${j.repoUrl.replace(/\/$/,"")}/tree/${encodeURIComponent(t.branch)}`:void 0;return l.jsxs("div",{className:U.overviewDashboard,children:[l.jsxs("div",{className:U.overviewHero,children:[l.jsx(Q8,{status:t.status}),t.branch&&l.jsx("span",{className:U.overviewBranchPill,children:C?l.jsxs("a",{href:C,target:"_blank",rel:"noreferrer noopener",className:U.branchLink,children:["🔗"," ",t.branch]}):l.jsxs("span",{children:["🔗"," ",t.branch]})})]}),typeof t.description=="string"&&t.description&&l.jsxs("div",{className:U.overviewSection,children:[l.jsx("div",{className:U.overviewLabel,children:"Description"}),l.jsx("div",{className:U.overviewMarkdown,children:l.jsx(Pc,{remarkPlugins:[Vc],children:t.description})})]}),t.workpad&&l.jsx(jO,{workpad:t.workpad}),l.jsxs("div",{className:U.overviewSection,children:[l.jsx("div",{className:U.overviewLabel,children:"Environment"}),T&&N?l.jsxs("div",{className:U.envRow,"data-testid":"task-overview-environment",children:[l.jsx("span",{className:`${U.envDot} ${db(N.status)}`,title:N.status,"aria-label":`Status: ${N.status}`,role:"img"}),l.jsx("span",{className:U.overviewValue,children:N.displayName})]}):w?l.jsxs("div",{className:U.envRow,"data-testid":"task-overview-environment",children:[l.jsx("span",{className:`${U.envDot} ${db(w.status)}`,title:w.status,"aria-label":`Status: ${w.status}`,role:"img"}),l.jsx("span",{className:U.overviewValue,children:w.displayName}),l.jsx("span",{className:U.overviewMuted,children:"(workspace default)"})]}):l.jsx("div",{className:U.overviewMuted,children:"Set in workspace settings"})]}),l.jsxs("div",{className:U.overviewSection,"data-testid":"task-overview-dependencies",children:[l.jsx("div",{className:U.overviewLabel,children:"Dependencies"}),t.dependsOn.length===0?l.jsx("div",{className:U.overviewMuted,children:"None"}):l.jsx("div",{className:U.depList,children:t.dependsOn.map(A=>{const M=s.get(A),D=(M==null?void 0:M.status)==="complete";return l.jsxs("div",{className:`${U.depItem} ${D?U.depDone:U.depBlocked}`,children:[l.jsx("span",{children:D?"✓":"○"}),l.jsx("span",{children:(M==null?void 0:M.title)??A})]},A)})})]}),l.jsxs("div",{className:U.overviewSection,children:[l.jsx("div",{className:U.overviewLabel,children:"Timeline"}),l.jsxs("div",{className:U.timeline,children:[t.createdAt&&l.jsxs("div",{className:U.timelineRow,children:[l.jsx("span",{className:U.timelineKey,children:"Created"}),l.jsx("span",{className:U.timelineValue,children:yc(t.createdAt)})]}),t.assignedAt&&(()=>{const A=Zf(t.createdAt,t.assignedAt);return l.jsxs("div",{className:U.timelineRow,children:[l.jsx("span",{className:U.timelineKey,children:"Assigned"}),l.jsx("span",{className:U.timelineValue,children:yc(t.assignedAt)}),A!==void 0&&l.jsx("span",{className:U.timelineDelta,children:A})]})})(),t.startedAt&&(()=>{const A=Zf(t.assignedAt??t.createdAt,t.startedAt);return l.jsxs("div",{className:U.timelineRow,children:[l.jsx("span",{className:U.timelineKey,children:"Started"}),l.jsx("span",{className:U.timelineValue,children:yc(t.startedAt)}),A!==void 0&&l.jsx("span",{className:U.timelineDelta,children:A})]})})(),t.completedAt&&(()=>{const A=Zf(t.startedAt,t.completedAt);return l.jsxs("div",{className:U.timelineRow,children:[l.jsx("span",{className:U.timelineKey,children:"Completed"}),l.jsx("span",{className:U.timelineValue,children:yc(t.completedAt)}),A!==void 0&&l.jsx("span",{className:U.timelineDelta,children:A})]})})(),!t.createdAt&&!t.assignedAt&&!t.startedAt&&!t.completedAt&&l.jsx("div",{className:U.overviewMuted,children:"No timing data"})]})]}),v&&v.costUsd>0&&l.jsxs("div",{className:U.overviewSection,children:[l.jsx("div",{className:U.overviewLabel,children:"Usage"}),l.jsxs("div",{className:U.timeline,children:[l.jsxs("div",{className:U.timelineRow,children:[l.jsx("span",{className:U.timelineKey,children:"Cost"}),l.jsx("span",{className:U.timelineValue,children:io(v.costUsd)}),l.jsxs("span",{className:U.timelineDelta,children:[v.sessionCount," session",v.sessionCount!==1?"s":""]})]}),b&&b.costUsd>v.costUsd&&l.jsxs("div",{className:U.timelineRow,children:[l.jsx("span",{className:U.timelineKey,children:"Total (incl. subtasks)"}),l.jsx("span",{className:U.timelineValue,children:io(b.costUsd)}),l.jsxs("span",{className:U.timelineDelta,children:[b.sessionCount," session",b.sessionCount!==1?"s":""]})]})]})]}),t.reviewNotes&&l.jsxs("div",{className:U.overviewSection,children:[l.jsx("div",{className:U.overviewLabel,children:"Review Notes"}),l.jsx("div",{className:U.reviewNotes,children:t.reviewNotes})]})]})}function tU({task:t,sessionId:s,isBlocked:i,onStart:o,onResume:c,onStop:u,onPause:d,onDelete:m,onEdit:h}){if(t.status==="not_started")return i?l.jsxs("div",{className:U.headerActions,children:[l.jsx("button",{onClick:h,className:U.btnGhost,children:"Edit"}),l.jsx("button",{onClick:m,className:U.btnDanger,children:"Delete"})]}):l.jsxs("div",{className:U.headerActions,children:[l.jsx("button",{"data-testid":"task-header-start",onClick:o,className:U.btnPrimary,children:"Start"}),l.jsx("button",{onClick:h,className:U.btnGhost,children:"Edit"}),l.jsx("button",{onClick:m,className:U.btnDanger,children:"Delete"})]});if(t.status==="working")return l.jsxs("div",{className:U.headerActions,children:[l.jsx("button",{onClick:u,className:U.btnDanger,children:"Stop"}),l.jsx("button",{onClick:d,disabled:!s,className:U.btnGhost,children:"Pause"})]});if(t.status==="paused")return l.jsxs("div",{className:U.headerActions,children:[l.jsx("button",{onClick:u,className:U.btnPrimary,children:"Stop"}),l.jsx("button",{onClick:c,className:U.btnGhost,children:"Resume"}),l.jsx("button",{onClick:m,className:U.btnDanger,children:"Delete"})]});if(t.status==="complete")return l.jsx("div",{className:U.headerActions,children:l.jsx("button",{onClick:m,className:U.btnDanger,children:"Delete"})});if(t.status==="failed")return l.jsxs("div",{className:U.headerActions,children:[l.jsx("button",{onClick:o,className:U.btnPrimary,children:"Retry"}),l.jsx("button",{onClick:m,className:U.btnDanger,children:"Delete"})]})}function nU({taskSessions:t,selectedSessionId:s,onSelect:i}){if(!(t.length<2))return l.jsxs("div",{className:U.attemptSelector,"data-testid":"attempt-selector",children:[l.jsx("span",{className:U.attemptLabel,children:"Attempts:"}),t.map((o,c)=>{const u=o.id===s,d=o.status==="stopped"&&o.endReason==="completed"?"✓":o.status==="stopped"?"✗":o.status==="running"||o.status==="idle"?"●":"";return l.jsxs("button",{className:`${U.attemptButton} ${u?U.attemptActive:""}`,onClick:()=>i(o.id),title:`Attempt #${c+1} — ${o.status}`,"aria-label":`Attempt #${c+1}, ${o.status}`,"aria-pressed":u,"data-testid":`attempt-${c+1}`,children:["#",c+1,d&&l.jsx("span",{className:U.attemptStatus,children:d})]},o.id)})]})}function ba(){const{taskId:t,workspaceId:s,environmentId:i}=Qn(),o=Ut(),c=vt(),{showToast:u}=dn(),{events:d,eventsDropped:m,tasks:h,sessions:g,environments:v,findings:_,loadSessionEvents:b,loadFindings:S,kill:T,startTask:N,stopTask:j,resumeTask:w,deleteTask:C,createTask:A,updateTask:M,workspaces:D,taskSessions:E,loadTaskSessions:$,sendInput:z,spawn:K,personas:F,provisionEnvironment:ee}=rt(),ae=y.useRef(void 0),me=y.useRef(void 0),ie=y.useRef(void 0),X=y.useRef(void 0),O=y.useRef(void 0),q=o.pathname.endsWith("/stream")?"stream":o.pathname.endsWith("/findings")?"findings":"overview",te=o.pathname.endsWith("/edit"),[re,ue]=y.useState(q),[Fe,Ne]=y.useState(!1),[ke,Me]=y.useState(void 0),[le,ve]=y.useState(""),[de,Ie]=y.useState(te),yt=y.useRef(q),fn=y.useRef(te),B=h.find(Ae=>Ae.id===t),Re=(B==null?void 0:B.workspaceId)||void 0,Qe=D.find(Ae=>Ae.id===Re);y.useEffect(()=>{q!==yt.current&&(yt.current=q,q!==re&&ue(q))},[q,re]),y.useEffect(()=>{te!==fn.current&&(fn.current=te,te!==de&&Ie(te))},[te,de]),y.useEffect(()=>{if(le===""){if(Qe!=null&&Qe.environmentId)ve(Qe.environmentId);else if(v.length>0){const Ae=v.find(We=>We.status==="connected");ve((Ae==null?void 0:Ae.id)??v[0].id)}}},[le,Qe==null?void 0:Qe.environmentId,v]);const et=B?E[B.id]??[]:[];let $e;ke&&et.some(Ae=>Ae.id===ke)?$e=ke:$e=(B==null?void 0:B.latestSessionId)||void 0;const es=()=>{Ne(!0)},Hs=()=>{if(!B)return;C(B.id),Ne(!1);const Ae=i??(Qe==null?void 0:Qe.environmentId);c(B.workspaceId&&Ae?ni(B.workspaceId,Ae):"/",{replace:!0})};y.useEffect(()=>{(B==null?void 0:B.id)!==me.current&&(me.current=B==null?void 0:B.id,Me(void 0),ve(""),Ie(te))},[B==null?void 0:B.id,te]),y.useEffect(()=>{if(!(B!=null&&B.id))return;const Ae=B.id!==X.current,We=B.latestSessionId!==O.current;(Ae||We)&&(X.current=B.id,O.current=B.latestSessionId,$(B.id))},[B==null?void 0:B.id,B==null?void 0:B.latestSessionId,$]),y.useEffect(()=>{if((B==null?void 0:B.status)!==ie.current){const Ae=ie.current===void 0;ie.current=B==null?void 0:B.status;const We=(B==null?void 0:B.status)==="not_started"?"overview":(B==null?void 0:B.status)==="working"||(B==null?void 0:B.status)==="paused"?"stream":(B==null?void 0:B.status)==="complete"?"findings":void 0;We&&We!==re&&!(Ae&&q!=="overview")&&ue(We)}},[B==null?void 0:B.status,re,q]);const kn=y.useMemo(()=>new Map(h.map(Ae=>[Ae.id,Ae])),[h]),Vn=y.useMemo(()=>{const Ae=$e?d.filter(We=>We.sessionId===$e):[];return _m(bm(Ae))},[d,$e]),ts=B?B.dependsOn.some(Ae=>{const We=kn.get(Ae);return We!==void 0&&We.status!=="complete"}):!1,$s=y.useMemo(()=>pB(t,i,D,v,kn),[t,i,D,v,kn]);y.useEffect(()=>{$e&&$e!==ae.current&&(ae.current=$e,b($e))},[$e,b]),y.useEffect(()=>{re==="findings"&&Re&&S(Re)},[re,Re,S]);const Hn=Ae=>{ue(Ae),c(Xn(t,Ae==="overview"?void 0:Ae,s,i))};return Us({key:"1"},()=>Hn("overview")),Us({key:"2"},()=>Hn("stream")),Us({key:"3"},()=>Hn("findings")),l.jsxs("div",{className:U.panelContainer,children:[l.jsx(fs,{segments:$s}),l.jsxs("div",{className:U.header,children:[l.jsxs("span",{className:U.headerTitle,children:[l.jsx("span",{"data-testid":"task-title",children:(B==null?void 0:B.title)||t}),B&&l.jsx("span",{className:U.taskStatusBadge,"data-testid":"task-status",children:B.status}),(B==null?void 0:B.branch)&&l.jsx("span",{className:U.taskBranch,children:B.branch}),ts&&l.jsx("span",{className:U.taskBlockedBadge,children:"blocked"})]}),B&&l.jsx(tU,{task:B,sessionId:$e,isBlocked:ts,onStart:()=>N(B.id,void 0,le),onResume:()=>w(B.id),onStop:()=>j(B.id),onPause:()=>$e&&T($e),onDelete:es,onEdit:()=>Ie(!0)})]}),l.jsxs("div",{className:U.tabBar,role:"tablist","aria-label":"Task view",children:[l.jsx("button",{role:"tab","aria-selected":re==="overview",className:`${U.tab} ${re==="overview"?U.active:""}`,onClick:()=>Hn("overview"),children:"Overview"}),l.jsx("button",{role:"tab","aria-selected":re==="stream",className:`${U.tab} ${re==="stream"?U.active:""}`,onClick:()=>Hn("stream"),children:"Stream"}),l.jsx("button",{role:"tab","aria-selected":re==="findings",className:`${U.tab} ${re==="findings"?U.active:""}`,onClick:()=>Hn("findings"),children:"Findings"})]}),l.jsxs(ds,{mode:"wait",children:[re==="overview"&&l.jsx(Dt.div,{initial:{opacity:0,y:4},animate:{opacity:1,y:0},exit:{opacity:0,y:-4},transition:{duration:.15},className:U.overviewContent,"data-testid":"task-overview",children:de&&B?l.jsx(Ox,{mode:"edit",taskId:B.id,workspaceId:Re,environmentId:i,tasks:h,workspaces:D,personas:F,onCreateTask:A,onUpdateTask:M,onEditDone:()=>{te?c(Xn(B.id,void 0,s,i),{replace:!0}):Ie(!1)},onShowToast:u}):B?l.jsx(eU,{task:B,tasksById:kn,environments:v,workspaces:D,taskSessions:et,selectedEnvId:le}):l.jsx("div",{className:U.waitingMessage,children:"No additional details"})},"overview"),re==="stream"&&l.jsxs(Dt.div,{initial:{opacity:0,y:4},animate:{opacity:1,y:0},exit:{opacity:0,y:-4},transition:{duration:.15},style:{display:"flex",flexDirection:"column",flex:1,overflow:"hidden"},children:[l.jsx(nU,{taskSessions:et,selectedSessionId:$e,onSelect:Ae=>Me(Ae)}),l.jsx(mm,{events:Vn,eventsDropped:m,emptyState:!$e&&B?ts?l.jsx("div",{className:U.emptyCta,"data-testid":"stream-blocked-message",children:l.jsx("div",{className:U.ctaDescription,children:"This task is blocked by incomplete dependencies"})}):l.jsxs("div",{className:U.emptyCta,children:[l.jsx("button",{"data-testid":"stream-start-cta",className:U.ctaButton,onClick:()=>N(B.id,void 0,le),children:"Start Task"}),l.jsx("div",{className:U.ctaDescription,children:"Click to begin agent execution"})]}):$e&&Vn.length===0?l.jsx("div",{className:U.waitingMessage,children:"Waiting for events..."}):void 0})]},"stream"),re==="findings"&&l.jsx(Dt.div,{initial:{opacity:0,y:4},animate:{opacity:1,y:0},exit:{opacity:0,y:-4},transition:{duration:.15},className:U.tabContent,children:Re?l.jsx(Mx,{findings:_.filter(Ae=>Ae.workspaceId===Re)}):l.jsx("div",{className:U.noContext,children:"Navigate to a task within a workspace to view findings"})},"findings")]}),(()=>{if(!B||B.status!=="working"&&B.status!=="paused")return;const Ae=$e?g.find(We=>We.id===$e):void 0;if(!(!Ae||Ae.status==="stopped"))return l.jsx(kr,{mode:"send",sessionId:Ae.id,environmentId:Ae.environmentId,personas:F,environments:v,onSendInput:z,onSpawn:K,onStartTask:N,onProvisionEnvironment:ee,onShowToast:u})})(),B&&l.jsx(ii,{isOpen:Fe,title:"Delete Task?",description:`"${B.title}" will be permanently removed.`,onConfirm:Hs,onCancel:()=>Ne(!1)})]})}function sU(){const{environments:t,addEnvironment:s,updateEnvironment:i,listCodespaces:o,codespaces:c,codespaceError:u,codespaceListError:d,codespaceCreating:m,createCodespace:h}=rt(),{showToast:g}=dn();return l.jsx(Bx,{mode:"new",environments:t,onAddEnvironment:s,onUpdateEnvironment:i,onListCodespaces:o,codespaces:c,codespaceError:u,codespaceListError:d,codespaceCreating:m,onCreateCodespace:h,onShowToast:g})}function aU(){const{environmentId:t}=Qn(),{environments:s,addEnvironment:i,updateEnvironment:o,listCodespaces:c,codespaces:u,codespaceError:d,codespaceListError:m,codespaceCreating:h,createCodespace:g}=rt(),{showToast:v}=dn();return l.jsx(Bx,{mode:"edit",environmentId:t,environments:s,onAddEnvironment:i,onUpdateEnvironment:o,onListCodespaces:c,codespaces:u,codespaceError:d,codespaceListError:m,codespaceCreating:h,onCreateCodespace:g,onShowToast:v})}const iU="_layout_11u79_1",oU="_content_11u79_8",rU="_tabPanel_11u79_14",Tr={layout:iU,content:oU,tabPanel:rU};function lU(){const t=cB();return l.jsxs("div",{className:Tr.layout,children:[l.jsx(fs,{segments:t}),l.jsx("div",{className:Tr.content,children:l.jsx(wa,{})})]})}const cU="_container_13sb6_1",uU="_envHeader_13sb6_6",dU="_envTitleRow_13sb6_10",fU="_statusDot_13sb6_16",pU="_envName_13sb6_21",mU="_statusBadge_13sb6_27",hU="_envMeta_13sb6_33",gU="_metaTag_13sb6_39",vU="_actions_13sb6_51",yU="_provisionMessage_13sb6_59",bU="_errorMessage_13sb6_64",_U="_section_13sb6_69",xU="_sectionHeader_13sb6_73",SU="_cardList_13sb6_121",TU="_card_13sb6_121",kU="_cardHeader_13sb6_138",wU="_cardName_13sb6_144",NU="_cardActions_13sb6_149",jU="_cardDescription_13sb6_154",CU="_cardMeta_13sb6_160",EU="_repoLink_13sb6_166",AU="_empty_13sb6_174",DU="_btnPrimary_13sb6_180",RU="_btnOutline_13sb6_214",MU="_btnSmall_13sb6_241",IU="_btnDanger_13sb6_267",Ve={container:cU,envHeader:uU,envTitleRow:dU,statusDot:fU,envName:pU,statusBadge:mU,envMeta:hU,metaTag:gU,actions:vU,provisionMessage:yU,errorMessage:bU,section:_U,sectionHeader:xU,cardList:SU,card:TU,cardHeader:kU,cardName:wU,cardActions:NU,cardDescription:jU,cardMeta:CU,repoLink:EU,empty:AU,btnPrimary:DU,btnOutline:RU,btnSmall:MU,btnDanger:IU},OU={connected:"var(--accent-green)",sleeping:"var(--accent-yellow)",error:"var(--accent-red)",disconnected:"var(--text-tertiary)",connecting:"var(--accent-blue)"};function BU(){const{environmentId:t}=Qn(),s=vt(),{environments:i,workspaces:o,sessions:c,provisionStatus:u,provisionEnvironment:d,stopEnvironment:m,removeEnvironment:h,archiveWorkspace:g}=rt(),[v,_]=y.useState(!1),[b,S]=y.useState(!1),[T,N]=y.useState(void 0),j=i.find(ae=>ae.id===t);if(!t||!j)return l.jsx(Wn,{to:ao,replace:!0});const w=o.filter(ae=>ae.environmentId===j.id),C=c.filter(ae=>ae.environmentId===j.id),A=C.reduce((ae,me)=>ae+(me.costUsd??0),0),M=OU[j.status]||"var(--text-tertiary)",D=j.status==="connected",E=j.status==="connecting",$=j.status==="disconnected"||j.status==="error"||j.status==="sleeping",z=j.id in u?u[j.id]:void 0,K=()=>{h(j.id),_(!1),s(ao,{replace:!0})},F=()=>{S(!1),d(j.id,!0)},ee=ae=>{g(ae),N(void 0)};return l.jsxs("div",{className:Ve.container,children:[l.jsx(ii,{isOpen:v,title:"Delete Environment?",description:`"${j.displayName||j.id}" will be permanently removed along with all its data.`,onConfirm:K,onCancel:()=>_(!1)}),l.jsx(ii,{isOpen:b,title:"Reprovision Environment?",description:"This will kill any active session and force a fresh provision cycle. The environment will be temporarily disconnected.",confirmLabel:"Reprovision",onConfirm:F,onCancel:()=>S(!1)}),l.jsxs("div",{className:Ve.envHeader,children:[l.jsxs("div",{className:Ve.envTitleRow,children:[l.jsx("span",{className:Ve.statusDot,style:{color:M},children:"●"}),l.jsx("h2",{className:Ve.envName,children:j.displayName||j.id}),l.jsx("span",{className:Ve.statusBadge,style:{color:M},children:j.status})]}),l.jsxs("div",{className:Ve.envMeta,children:[l.jsxs("span",{className:Ve.metaTag,children:["Adapter: ",j.adapterType]}),C.length>0&&l.jsxs("span",{className:Ve.metaTag,children:[C.length," session",C.length!==1?"s":""]}),A>0&&l.jsxs("span",{className:Ve.metaTag,children:["Cost: ",io(A)]})]})]}),l.jsxs("div",{className:Ve.actions,children:[D&&l.jsxs(l.Fragment,{children:[l.jsx("button",{className:Ve.btnPrimary,onClick:()=>s(Vb(j.id)),children:"New Chat"}),l.jsx("button",{className:Ve.btnOutline,onClick:()=>m(j.id),children:"Stop"}),l.jsx("button",{className:Ve.btnOutline,onClick:()=>S(!0),disabled:z!==void 0,"data-testid":"env-reprovision-btn",children:"Reprovision"})]}),$&&l.jsx("button",{className:Ve.btnPrimary,onClick:()=>d(j.id),children:j.status==="error"?"Retry":j.status==="sleeping"?"Wake":"Connect"}),E&&z!==void 0&&l.jsx("span",{className:Ve.provisionMessage,children:z.message}),j.status==="error"&&(z==null?void 0:z.stage)==="error"&&l.jsx("span",{className:Ve.errorMessage,children:z.message}),l.jsx("button",{className:Ve.btnOutline,onClick:()=>s(t2(j.id)),"data-testid":"env-edit-btn",children:"Edit Config"}),l.jsx("button",{className:Ve.btnDanger,onClick:()=>_(!0),children:"Delete"})]}),l.jsxs("div",{className:Ve.section,children:[l.jsxs("div",{className:Ve.sectionHeader,children:[l.jsx("h3",{children:"Workspaces"}),l.jsx("button",{className:Ve.btnPrimary,onClick:()=>s(`${$b}?environment=${encodeURIComponent(j.id)}`),"data-testid":"workspace-create-button",children:"+ New Workspace"})]}),w.length===0&&l.jsx("p",{className:Ve.empty,children:"No workspaces yet. Create one to get started."}),l.jsx("div",{className:Ve.cardList,children:w.map(ae=>l.jsx(LU,{workspace:ae,confirmArchiveId:T,onOpen:()=>s(ni(ae.id,j.id)),onArchive:()=>N(ae.id),onConfirmArchive:()=>ee(ae.id),onCancelArchive:()=>N(void 0)},ae.id))})]})]})}function LU({workspace:t,confirmArchiveId:s,onOpen:i,onArchive:o,onConfirmArchive:c,onCancelArchive:u}){const d=s===t.id,m=t.repoUrl&&/^https?:\/\//.test(t.repoUrl);return l.jsxs("div",{className:Ve.card,"data-testid":"workspace-card",children:[l.jsxs("div",{className:Ve.cardHeader,children:[l.jsx("strong",{className:Ve.cardName,children:t.name}),l.jsxs("div",{className:Ve.cardActions,children:[l.jsx("button",{className:Ve.btnSmall,onClick:i,children:"Open"}),d?l.jsxs(l.Fragment,{children:[l.jsx("button",{className:Ve.btnDanger,onClick:c,children:"Confirm"}),l.jsx("button",{className:Ve.btnSmall,onClick:u,children:"Cancel"})]}):l.jsx("button",{className:Ve.btnSmall,onClick:o,children:"Archive"})]})]}),t.description&&l.jsx("p",{className:Ve.cardDescription,children:t.description}),t.repoUrl&&l.jsx("div",{className:Ve.cardMeta,children:m?l.jsx("a",{href:t.repoUrl,target:"_blank",rel:"noopener noreferrer",className:Ve.repoLink,children:t.repoUrl}):l.jsx("span",{children:t.repoUrl})})]})}const UU={credentials:"Credentials",personas:"Personas",appearance:"Appearance",about:"About",shortcuts:"Shortcuts"};function zU(){const s=Ut().pathname.replace(/^\/settings\/?/,"").split("/")[0],i=UU[s],o=lB(i);return l.jsxs("div",{className:Tr.layout,children:[l.jsx(fs,{segments:o}),l.jsx("div",{className:Tr.content,children:l.jsx("div",{className:Tr.tabPanel,children:l.jsx(wa,{})},s)})]})}function PU(){const{tokens:t,setToken:s,deleteToken:i,credentialProviders:o,updateCredentialProviders:c}=rt(),{showToast:u}=dn();return l.jsxs(l.Fragment,{children:[l.jsx(EO,{credentialProviders:o,onUpdateCredentialProviders:c}),l.jsx(TI,{tokens:t,onSetToken:s,onDeleteToken:i,onShowToast:u})]})}function VU(){const{personas:t,deletePersona:s,appDefaultPersonaId:i,setAppDefaultPersonaId:o}=rt(),{showToast:c}=dn(),u=vt();return l.jsx(HO,{personas:t,appDefaultPersonaId:i,onDeletePersona:async d=>{try{await s(d)}catch(m){throw console.error("Failed to delete persona",{personaId:d,error:m}),c("Failed to delete persona","error"),m}},onSetAppDefaultPersonaId:async d=>{try{await o(d)}catch(m){console.error("Failed to set app default persona ID",{personaId:d,error:m}),c("Failed to set app default persona","error")}},onNavigateToNew:()=>u(s2),onNavigateToPersona:d=>u(Hb(d))})}const HU="_container_1ooin_1",$U="_form_1ooin_7",GU="_formActions_1ooin_75",qU="_editableSection_1ooin_82",FU="_defaultBadge_1ooin_93",ZU="_typeToggle_1ooin_107",KU="_scriptEditor_1ooin_121",YU="_optional_1ooin_128",Yn={container:HU,form:$U,formActions:GU,editableSection:qU,defaultBadge:FU,typeToggle:ZU,scriptEditor:KU,optional:YU},fb=[{value:"claude-code",label:"claude-code"},{value:"codex",label:"codex"},{value:"copilot",label:"copilot"},{value:"goose",label:"goose"},{value:"stub",label:"stub"},{value:"claude-code-acp",label:"claude-code-acp (experimental)"},{value:"codex-acp",label:"codex-acp (experimental)"},{value:"copilot-acp",label:"copilot-acp (experimental)"}],pb=[{value:"genaiscript",label:"genaiscript"}],JU="0";function mb(){const{personaId:t}=Qn(),s=vt(),{showToast:i}=dn(),{personas:o,createPersona:c,updatePersona:u,deletePersona:d,appDefaultPersonaId:m,setAppDefaultPersonaId:h}=rt(),g=t===void 0,v=g?void 0:o.find(b=>b.id===t);if(!g&&o.length>0&&!v)return l.jsx(Wn,{to:gf,replace:!0});const _=[{label:"Settings",url:so},{label:"Personas",url:gf},{label:g?"New Persona":(v==null?void 0:v.name)??"Persona",url:void 0}];return l.jsxs("div",{className:Yn.container,children:[l.jsx(fs,{segments:_}),l.jsx(WU,{existing:v,isNew:g,appDefaultPersonaId:m,onCreatePersona:c,onUpdatePersona:u,onDeletePersona:d,onSetAppDefaultPersonaId:h,onDone:()=>{s(gf)},showToast:i})]})}function WU({existing:t,isNew:s,appDefaultPersonaId:i,onCreatePersona:o,onUpdatePersona:c,onDeletePersona:u,onSetAppDefaultPersonaId:d,onDone:m,showToast:h}){const g=vt(),[v,_]=y.useState((t==null?void 0:t.name)??""),[b,S]=y.useState((t==null?void 0:t.description)??""),[T,N]=y.useState((t==null?void 0:t.systemPrompt)??""),[j,w]=y.useState((t==null?void 0:t.runtime)??"claude-code"),[C,A]=y.useState((t==null?void 0:t.model)??"sonnet"),[M,D]=y.useState((t==null?void 0:t.maxTurns)??0),[E,$]=y.useState((t==null?void 0:t.type)==="script"?"script":"agent"),[z,K]=y.useState((t==null?void 0:t.script)??""),[F,ee]=y.useState((t==null?void 0:t.allowedMcpTools)??[]),[ae,me]=y.useState(!1),[ie,X]=y.useState(null),[O,q]=y.useState(!!s);y.useEffect(()=>{if(!s&&t&&!O){q(!0),_(t.name),S(t.description),N(t.systemPrompt);const B=t.type==="script"?"script":"agent";w(B==="script"?t.runtime||"genaiscript":t.runtime),A(t.model),D(t.maxTurns),$(B),K(t.script||""),ee(t.allowedMcpTools)}},[s,t,O]);const te=B=>{$(B),B==="script"?w("genaiscript"):j==="genaiscript"&&w("claude-code")},re=!s&&t===void 0,ue=v.trim().length>0&&!re&&T.trim().length>0&&(E==="script"?z.trim().length>0:!!j&&!!C),Fe=s&&ue,Ne=!s&&i===(t==null?void 0:t.id),ke=!s&&t&&!Ne&&E==="agent"&&!!j&&!!C,Me=(B,Re)=>{if(!B.trim())return`${Re} is required`},le=B=>{if(B.preventDefault(),!(re||!ue)){if(t){c(t.id,v,b,T,j,C,M,E,z).then(()=>{h("Persona updated","success"),m()},()=>{h("Failed to save persona","error")});return}o(v,b,T,j,C,M,E,z,F).then(Re=>{h("Persona created","success"),g(Hb(Re.id),{replace:!0})},()=>{h("Failed to save persona","error")})}},ve=()=>{t&&u(t.id).then(()=>{h("Persona deleted","success"),m()},()=>{h("Failed to delete persona","error")})},de=async(B,Re,Qe,et)=>B().then(()=>{Re(),h(Qe,"success")},()=>{h(et,"error")}),Ie=(B,Re)=>{if(!t)return;const Qe=B==="type"?String(Re):E,et=B==="runtime"?String(Re):B==="type"?String(Re)==="script"?"genaiscript":j==="genaiscript"?"claude-code":j:j,$e=B==="model"?String(Re):C,es=B==="maxTurns"?Number(Re):M,Hs=B==="systemPrompt"?String(Re):T,kn=B==="script"?String(Re):z;de(()=>c(t.id,B==="name"?String(Re):v,B==="description"?String(Re):b,Hs,et,$e,es,Qe,kn),()=>{if(B==="type"){const Vn=String(Re)==="script"?"script":"agent";$(Vn),w(et)}B==="runtime"&&w(String(Re)),B==="name"&&_(String(Re)),B==="description"&&S(String(Re)),B==="systemPrompt"&&N(String(Re)),B==="model"&&A(String(Re)),B==="maxTurns"&&D(Number(Re)),B==="script"&&K(String(Re))},"Persona updated","Failed to update persona").catch(()=>{})},yt=B=>{le(B)},fn=()=>{t&&d(t.id).then(()=>{h("Set as app default","success")},()=>{h("Failed to set app default","error")})};return l.jsxs(l.Fragment,{children:[re?l.jsxs("div",{className:Yn.form,children:[l.jsx("h3",{children:"Edit Persona"}),l.jsx("p",{children:"Loading persona..."})]}):s?l.jsxs("form",{onSubmit:yt,className:Yn.form,children:[l.jsx("h3",{children:"Create Persona"}),l.jsxs("div",{className:Yn.typeToggle,"data-testid":"persona-type-toggle",children:[l.jsxs("label",{children:[l.jsx("input",{type:"radio",name:"personaType",value:"agent",checked:E==="agent",onChange:()=>te("agent")}),"Agent"]}),l.jsxs("label",{children:[l.jsx("input",{type:"radio",name:"personaType",value:"script",checked:E==="script",onChange:()=>te("script")}),"Script"]})]}),l.jsxs("label",{children:["Name",l.jsx("input",{type:"text",value:v,onChange:B=>_(B.target.value),placeholder:E==="script"?"e.g. Nightly Report":"e.g. Frontend Engineer",required:!0,"data-testid":"persona-detail-name"})]}),l.jsxs("label",{children:["Description",l.jsx("input",{type:"text",value:b,onChange:B=>S(B.target.value),placeholder:"Brief description...","data-testid":"persona-detail-description"})]}),l.jsxs("label",{children:["Runtime",l.jsx("select",{value:j,onChange:B=>w(B.target.value),"data-testid":"persona-runtime-select",children:(E==="script"?pb:fb).map(B=>l.jsx("option",{value:B.value,children:B.label},B.value))})]}),E==="agent"&&l.jsxs(l.Fragment,{children:[l.jsxs("label",{children:["Model",l.jsx("input",{type:"text",value:C,onChange:B=>A(B.target.value),placeholder:"e.g. sonnet","data-testid":"persona-detail-model"})]}),l.jsxs("label",{children:["Max Turns",l.jsx("input",{type:"number",value:M,onChange:B=>D(parseInt(B.target.value,10)||0),min:0,"data-testid":"persona-detail-max-turns"})]}),l.jsxs("label",{children:["System Prompt",l.jsx("textarea",{value:T,onChange:B=>N(B.target.value),placeholder:"You are a senior frontend engineer...",rows:10,required:!0,"data-testid":"persona-detail-prompt"})]})]}),E==="script"&&l.jsxs(l.Fragment,{children:[l.jsxs("label",{children:["Model ",l.jsx("span",{className:Yn.optional,children:"(optional)"}),l.jsx("input",{type:"text",value:C,onChange:B=>A(B.target.value),placeholder:"e.g. sonnet (leave empty for script-only)","data-testid":"persona-detail-model"})]}),l.jsxs("label",{children:["System Prompt",l.jsx("textarea",{value:T,onChange:B=>N(B.target.value),placeholder:"Context for the script...",rows:4,required:!0,"data-testid":"persona-detail-prompt"})]}),l.jsxs("label",{children:["Script",l.jsx("textarea",{value:z,onChange:B=>K(B.target.value),placeholder:`script({ model: "openai:gpt-4o" });
490
490
 
491
491
  const grackle = await host.mcpServer({
492
492
  id: "grackle",
@@ -500,4 +500,4 @@ const grackle = await host.mcpServer({
500
500
  url: env.vars.GRACKLE_MCP_URL,
501
501
  });
502
502
 
503
- $\`Summarize the current tasks.\`;`,ariaLabel:"Persona script","data-testid":"persona-script-editor"})]}),E==="agent"&&l.jsxs("div",{children:[l.jsx("label",{children:"Allowed MCP Tools"}),l.jsx(tb,{selectedTools:F,onChange:B=>{ee(B),de(()=>c(t.id,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,B),()=>{},"MCP tools updated","Failed to update MCP tools").catch(()=>{})}})]})]}),!ke&&!Ne&&l.jsx("p",{style:{fontSize:"var(--font-size-xs)",color:"var(--text-tertiary)",marginTop:"var(--space-xs)"},children:"Only agent personas with a runtime and model can be set as app default."})]}):null,l.jsx(ii,{isOpen:ae,title:"Delete Persona?",description:`"${t==null?void 0:t.name}" will be permanently removed.`,confirmLabel:"Delete",onConfirm:ve,onCancel:()=>me(!1)})]})}function XU(){const{themeId:t,resolvedThemeId:s,setTheme:i,preferSystem:o,setPreferSystem:c}=Hx();return l.jsx(kI,{themeId:t,resolvedThemeId:s,onSetTheme:i,preferSystem:o,onSetPreferSystem:c})}function QU(){const[t,s]=y.useState(void 0);return y.useEffect(()=>{let i=!1;return xe.getVersionStatus({}).then(o=>{i||s({currentVersion:o.currentVersion,latestVersion:o.latestVersion,updateAvailable:o.updateAvailable,isDocker:o.isDocker})},()=>{}),()=>{i=!0}},[]),t}function e7(){const{connected:t,environments:s,sessions:i}=rt(),o=QU();return l.jsxs(l.Fragment,{children:[o&&l.jsx(C6,{currentVersion:o.currentVersion,latestVersion:o.latestVersion,updateAvailable:o.updateAvailable,isDocker:o.isDocker}),l.jsx(wI,{connected:t,environments:s,sessions:i})]})}function t7(){return l.jsx(xO,{})}const hb=ri();function n7(){const t=vt();return Us({key:"?"},()=>{t(a2)}),Us({key:"n"},()=>{t(hb)}),Us({key:"N"},()=>{t(hb)}),l.jsx(l.Fragment,{})}function Ur(t){const s=sB();y.useLayoutEffect(()=>(s(t),()=>{s(void 0)}),[t,s])}function s7(){const{workspaces:t,tasks:s}=rt(),i=y.useMemo(()=>l.jsx(a6,{workspaces:t,tasks:s}),[t,s]);return Ur(i),l.jsx(wa,{})}function a7(){const{environments:t}=rt(),s=y.useMemo(()=>l.jsx(m3,{environments:t}),[t]);return Ur(s),l.jsx(wa,{})}function i7(){const t=y.useMemo(()=>l.jsx(c4,{}),[]);return Ur(t),l.jsx(wa,{})}function o7(){const{findings:t,loadFindings:s,loadAllFindings:i}=rt(),{workspaceId:o,environmentId:c}=Qn();y.useEffect(()=>{o?s(o):i()},[o,s,i]);const u=y.useMemo(()=>l.jsx(w3,{findings:t,workspaceId:o,environmentId:c}),[t,o,c]);return Ur(u),l.jsx(wa,{})}function r7(){const{knowledge:t,workspaces:s}=rt(),i=y.useCallback(m=>{t.search(m)},[t]),o=y.useCallback(()=>{t.clearSearch()},[t]),c=y.useCallback(m=>{t.selectNode(m)},[t]),u=y.useCallback(m=>{t.loadRecent(m||void 0)},[t]),d=y.useMemo(()=>l.jsx(jM,{nodes:t.graphData.nodes,workspaces:s,loading:t.loading,searchQuery:t.searchQuery,onSearch:i,onClearSearch:o,onSelectNode:c,onWorkspaceChange:u}),[t,s,i,o,c,u]);return Ur(d),l.jsx(wa,{})}const l7="_container_ce571_1",c7="_title_ce571_6",gb={container:l7,title:c7};function vb(){const{environmentId:t,workspaceId:s}=Qn(),{findings:i,loadFindings:o,workspaces:c,environments:u}=rt(),d=vt();y.useEffect(()=>{s&&o(s)},[s,o]);const m=y.useCallback(g=>{d(Qf(g,s,t))},[d,s,t]),h=s&&t?Yx("Findings",s,t,c,u).slice(0,-1):hB();return l.jsxs("div",{className:gb.container,"data-testid":"findings-list-page",children:[l.jsx(fs,{segments:h}),l.jsx("h1",{className:gb.title,children:"Findings"}),l.jsx(Mx,{findings:i,onFindingClick:m})]})}const u7="_container_1wwpb_1",d7="_notFound_1wwpb_6",f7="_header_1wwpb_12",p7="_categoryBadge_1wwpb_19",m7="_title_1wwpb_28",h7="_content_1wwpb_35",g7="_tags_1wwpb_77",v7="_tag_1wwpb_77",y7="_meta_1wwpb_92",b7="_metaTimestamp_1wwpb_100",_7="_metaLink_1wwpb_105",nn={container:u7,notFound:d7,header:f7,categoryBadge:p7,title:m7,content:h7,tags:g7,tag:v7,meta:y7,metaTimestamp:b7,metaLink:_7};function yb(){const{findingId:t,environmentId:s,workspaceId:i}=Qn(),{selectedFinding:o,findingLoading:c,loadFinding:u,workspaces:d,environments:m}=rt(),h=vt();if(y.useEffect(()=>{t&&u(t)},[t,u]),c)return l.jsx("div",{className:nn.container,"data-testid":"finding-detail-page",children:l.jsx("div",{className:nn.notFound,children:"Loading..."})});if(!o)return l.jsx("div",{className:nn.container,"data-testid":"finding-detail-page",children:l.jsx("div",{className:nn.notFound,children:"Finding not found."})});const g=Yx(o.title,i,s,d,m),v=Lc(o.category);return l.jsxs("div",{className:nn.container,"data-testid":"finding-detail-page",children:[l.jsx(fs,{segments:g}),l.jsxs("div",{className:nn.header,children:[l.jsx("span",{className:nn.categoryBadge,style:{background:v.bg,color:v.text},children:o.category}),l.jsx("h1",{className:nn.title,children:o.title})]}),o.content&&l.jsx("div",{className:nn.content,children:l.jsx(Pc,{remarkPlugins:[Vc],children:o.content})}),o.tags.length>0&&l.jsx("div",{className:nn.tags,children:o.tags.map(_=>l.jsx("span",{className:nn.tag,children:_},_))}),l.jsxs("div",{className:nn.meta,children:[l.jsx("span",{className:nn.metaTimestamp,title:o.createdAt,children:gm(o.createdAt)}),o.taskId&&l.jsx("button",{type:"button",className:nn.metaLink,onClick:()=>{h(Xn(o.taskId))},children:"View Task"}),o.sessionId&&l.jsx("button",{type:"button",className:nn.metaLink,onClick:()=>{h(Rp(o.sessionId))},children:"View Session"})]})]})}const x7="_wizard_1260s_1",S7="_container_1260s_10",T7="_stepContent_1260s_19",k7="_logoArea_1260s_28",w7="_logoImage_1260s_32",N7="_heading_1260s_41",j7="_tagline_1260s_49",C7="_subtitle_1260s_56",E7="_featureList_1260s_64",A7="_runtimeGrid_1260s_89",D7="_runtimeCard_1260s_101",R7="_runtimeName_1260s_133",M7="_runtimeDescription_1260s_139",I7="_buttonRow_1260s_144",O7="_primaryButton_1260s_151",B7="_ghostButton_1260s_185",L7="_dots_1260s_213",U7="_dot_1260s_213",ut={wizard:x7,container:S7,stepContent:T7,logoArea:k7,logoImage:w7,heading:N7,tagline:j7,subtitle:C7,featureList:E7,runtimeGrid:A7,runtimeCard:D7,runtimeName:R7,runtimeDescription:M7,buttonRow:I7,primaryButton:O7,ghostButton:B7,dots:L7,dot:U7};function z7({onNext:t}){return l.jsxs("div",{className:ut.stepContent,"data-testid":"setup-welcome",children:[l.jsx("div",{className:ut.logoArea,children:l.jsx("img",{src:"/grackle-logo.png",alt:"Grackle",className:ut.logoImage})}),l.jsx("h1",{className:ut.heading,children:"Welcome to Grackle"}),l.jsx("p",{className:ut.tagline,children:"Multi-agent orchestration for software teams"}),l.jsx("button",{type:"button",className:ut.primaryButton,onClick:t,"data-testid":"setup-get-started",children:"Get Started"})]})}function P7({onNext:t,onBack:s}){return l.jsxs("div",{className:ut.stepContent,"data-testid":"setup-about",children:[l.jsx("h2",{className:ut.heading,children:"What is Grackle?"}),l.jsxs("ul",{className:ut.featureList,children:[l.jsx("li",{children:"Run Claude, Copilot, and Codex agents side by side"}),l.jsx("li",{children:"Provision and control dev environments — SSH, Codespaces, or local"}),l.jsx("li",{children:"Organize work into workspaces with agent-executable tasks"}),l.jsx("li",{children:"Customize agent behavior with personas, tools, and MCP servers"}),l.jsx("li",{children:"Live-stream agent sessions with full terminal replay"})]}),l.jsxs("div",{className:ut.buttonRow,children:[l.jsx("button",{type:"button",className:ut.ghostButton,onClick:s,children:"Back"}),l.jsx("button",{type:"button",className:ut.primaryButton,onClick:t,"data-testid":"setup-about-next",children:"Next"})]})]})}const V7=[{id:"claude-code",name:"Claude Code",description:"Anthropic's agentic coding tool"},{id:"copilot",name:"Copilot Coding Agent",description:"GitHub's AI pair programmer"},{id:"codex",name:"Codex CLI",description:"OpenAI's coding agent"},{id:"goose",name:"Goose",description:"Block's open-source AI coding agent"}];function H7({currentRuntime:t,onFinish:s,onBack:i,finishDisabled:o}){const[c,u]=y.useState(t||"claude-code");return y.useEffect(()=>{t&&u(t)},[t]),l.jsxs("div",{className:ut.stepContent,"data-testid":"setup-runtime",children:[l.jsx("h2",{className:ut.heading,children:"Choose Your Runtime"}),l.jsx("p",{className:ut.subtitle,children:"Select the primary agent runtime for your workspace. You can change this later."}),l.jsx("div",{className:ut.runtimeGrid,children:V7.map(d=>l.jsxs("button",{type:"button",className:ut.runtimeCard,"data-selected":c===d.id,"aria-pressed":c===d.id,"data-testid":`runtime-card-${d.id}`,onClick:()=>u(d.id),children:[l.jsx("span",{className:ut.runtimeName,children:d.name}),l.jsx("span",{className:ut.runtimeDescription,children:d.description})]},d.id))}),l.jsxs("div",{className:ut.buttonRow,children:[l.jsx("button",{type:"button",className:ut.ghostButton,onClick:i,children:"Back"}),l.jsx("button",{type:"button",className:ut.primaryButton,onClick:()=>{s(c)},disabled:o,"data-testid":"setup-finish",children:"Finish"})]})]})}const $7=3,bb={"claude-code":"sonnet",copilot:"gpt-4o",codex:"o3",goose:""};function G7(){const{personas:t,updatePersona:s,completeOnboarding:i,onboardingCompleted:o}=rt(),{showToast:c}=dn(),u=vt(),[d,m]=y.useState(0),[h,g]=y.useState(!1),v=t.find(b=>b.id==="claude-code"),_=y.useCallback(b=>{g(!0);const S=[];if(v&&b!==v.runtime){const N=bb[b]??"sonnet";S.push(s(v.id,void 0,void 0,void 0,b,N))}const T=t.find(N=>N.id===m0);if(T&&b!==T.runtime){const N=bb[b]??"sonnet";S.push(s(m0,void 0,void 0,void 0,b,N))}Promise.all(S).then(()=>i()).then(()=>{u("/",{replace:!0})},()=>{c("Failed to update runtime -- please try again","error"),g(!1)})},[v,t,s,i,u,c]);return o===!0?l.jsx(Wn,{to:"/",replace:!0}):l.jsx("div",{className:ut.wizard,"data-testid":"setup-wizard",children:l.jsxs("div",{className:ut.container,children:[l.jsx(ds,{mode:"wait",children:l.jsxs(Dt.div,{initial:{opacity:0,x:40},animate:{opacity:1,x:0},exit:{opacity:0,x:-40},transition:{duration:.2,ease:"easeInOut"},children:[d===0&&l.jsx(z7,{onNext:()=>m(1)}),d===1&&l.jsx(P7,{onNext:()=>m(2),onBack:()=>m(0)}),d===2&&l.jsx(H7,{currentRuntime:(v==null?void 0:v.runtime)??"claude-code",onFinish:_,onBack:()=>m(1),finishDisabled:!v||h})]},d)}),l.jsx("div",{className:ut.dots,children:Array.from({length:$7},(b,S)=>l.jsx("span",{className:ut.dot,"data-active":S===d},S))})]})})}const q7="_root_zndgp_1",F7="_body_zndgp_7",Z7="_main_zndgp_19",K7="_sidebarWrapper_zndgp_26",Y7="_overlay_zndgp_51",vr={root:q7,body:F7,main:Z7,sidebarWrapper:K7,overlay:Y7},J7=y.lazy(()=>zT(()=>import("./KnowledgePage-UHkf3T0n.js"),__vite__mapDeps([0,1,2,3,4])).then(t=>({default:t.KnowledgePage}))),Wx=typeof window<"u"&&new URLSearchParams(window.location.search).has("mock");function W7(){const{connected:t,environments:s,sessions:i,tasks:o}=rt(),{toasts:c,dismissToast:u}=dn(),d=Ut(),m=nB(),h=m!==void 0,[g,v]=y.useState(!1),_=y.useCallback(()=>v(b=>!b),[]);return y.useEffect(()=>{v(!1)},[d.pathname]),y.useEffect(()=>{if(!g)return;const b=S=>{S.key==="Escape"&&v(!1)};return document.addEventListener("keydown",b),()=>{document.removeEventListener("keydown",b)}},[g]),l.jsxs(l.Fragment,{children:[l.jsx(LM,{connected:t,environments:s,sessions:i,onToggleSidebar:h?_:void 0,sidebarOpen:g}),l.jsx(GM,{}),l.jsxs("div",{className:vr.body,children:[h&&l.jsx("div",{className:vr.sidebarWrapper,"data-sidebar-open":g,children:l.jsx(JM,{content:m})}),h&&g&&l.jsx("div",{className:vr.overlay,"data-testid":"drawer-overlay",onClick:()=>v(!1)}),l.jsxs("div",{className:vr.main,children:[l.jsx(wa,{}),l.jsx(a3,{sessions:i,tasks:o,environments:s})]})]}),l.jsx(v6,{toasts:c,onDismiss:u}),l.jsx(n7,{})]})}function X7(){const{lastSpawnedId:t,environments:s,tasks:i,connected:o,onboardingCompleted:c}=rt(),{showToast:u}=dn();QB(s,u),sL(i,u);const d=vt(),m=Ut();return y.useEffect(()=>{t&&!m.pathname.includes("/tasks/")&&d(Rp(t),{replace:!0})},[t,d,m.pathname]),o&&c===!1?l.jsx(Wn,{to:"/setup",replace:!0}):l.jsx(tB,{children:l.jsxs("div",{className:vr.root,children:[Wx&&l.jsx(I2,{}),l.jsx(W7,{})]})})}function Kf(){const{workspaceId:t}=Qn(),{workspaces:s}=rt(),i=Ut(),o=s.find(h=>h.id===t);if(!(o!=null&&o.environmentId))return s.length===0?void 0:l.jsx(Wn,{to:"/environments",replace:!0});const c=encodeURIComponent(t),u=`/workspaces/${c}`,d=i.pathname.startsWith(u)?i.pathname.slice(u.length):"",m=`/environments/${encodeURIComponent(o.environmentId)}/workspaces/${c}${d}${i.search}${i.hash}`;return l.jsx(Wn,{to:m,replace:!0})}function Q7(){return l.jsxs(bw,{children:[l.jsx(Te,{path:"setup",element:l.jsx(G7,{})}),l.jsxs(Te,{element:l.jsx(X7,{}),children:[l.jsx(Te,{index:!0,element:l.jsx(w8,{})}),l.jsx(Te,{path:"chat",element:l.jsx(I8,{})}),l.jsx(Te,{path:"sessions/new",element:l.jsx(O8,{})}),l.jsx(Te,{path:"sessions/:sessionId",element:l.jsx(U8,{})}),l.jsx(Te,{element:l.jsx(r7,{}),children:l.jsx(Te,{path:"knowledge",element:l.jsx(y.Suspense,{fallback:l.jsx(Tx,{}),children:l.jsx(J7,{})})})}),l.jsxs(Te,{element:l.jsx(s7,{}),children:[l.jsx(Te,{path:"tasks",element:l.jsx(T8,{})}),l.jsx(Te,{path:"tasks/new",element:l.jsx(ub,{})}),l.jsx(Te,{path:"tasks/:taskId",element:l.jsx(ba,{})}),l.jsx(Te,{path:"tasks/:taskId/edit",element:l.jsx(ba,{})}),l.jsx(Te,{path:"tasks/:taskId/stream",element:l.jsx(ba,{})}),l.jsx(Te,{path:"tasks/:taskId/findings",element:l.jsx(ba,{})})]}),l.jsxs(Te,{element:l.jsx(o7,{}),children:[l.jsx(Te,{path:"findings",element:l.jsx(vb,{})}),l.jsx(Te,{path:"findings/:findingId",element:l.jsx(yb,{})}),l.jsx(Te,{path:"environments/:environmentId/workspaces/:workspaceId/findings",element:l.jsx(vb,{})}),l.jsx(Te,{path:"environments/:environmentId/workspaces/:workspaceId/findings/:findingId",element:l.jsx(yb,{})})]}),l.jsxs(Te,{element:l.jsx(a7,{}),children:[l.jsx(Te,{path:"workspaces",element:l.jsx(Wn,{to:"/environments",replace:!0})}),l.jsx(Te,{path:"workspaces/new",element:l.jsx(X8,{})}),l.jsx(Te,{path:"workspaces/:workspaceId",element:l.jsx(Kf,{})}),l.jsx(Te,{path:"workspaces/:workspaceId/tasks/:taskId",element:l.jsx(Kf,{})}),l.jsx(Te,{path:"workspaces/:workspaceId/tasks/:taskId/*",element:l.jsx(Kf,{})}),l.jsx(Te,{path:"environments/:environmentId/workspaces/:workspaceId",element:l.jsx(V8,{})}),l.jsx(Te,{path:"environments/:environmentId/workspaces/:workspaceId/tasks/new",element:l.jsx(ub,{})}),l.jsx(Te,{path:"environments/:environmentId/workspaces/:workspaceId/tasks/:taskId",element:l.jsx(ba,{})}),l.jsx(Te,{path:"environments/:environmentId/workspaces/:workspaceId/tasks/:taskId/edit",element:l.jsx(ba,{})}),l.jsx(Te,{path:"environments/:environmentId/workspaces/:workspaceId/tasks/:taskId/stream",element:l.jsx(ba,{})}),l.jsx(Te,{path:"environments/:environmentId/workspaces/:workspaceId/tasks/:taskId/findings",element:l.jsx(ba,{})}),l.jsxs(Te,{path:"environments",element:l.jsx(lU,{}),children:[l.jsx(Te,{index:!0,element:l.jsx(k8,{})}),l.jsx(Te,{path:"new",element:l.jsx(sU,{})}),l.jsx(Te,{path:":environmentId",element:l.jsx(BU,{})}),l.jsx(Te,{path:":environmentId/edit",element:l.jsx(aU,{})})]})]}),l.jsx(Te,{element:l.jsx(i7,{}),children:l.jsxs(Te,{path:"settings",element:l.jsx(zU,{}),children:[l.jsx(Te,{index:!0,element:l.jsx(Wn,{to:"credentials",replace:!0})}),l.jsx(Te,{path:"environments",element:l.jsx(Wn,{to:"/environments",replace:!0})}),l.jsx(Te,{path:"credentials",element:l.jsx(PU,{})}),l.jsx(Te,{path:"tokens",element:l.jsx(Wn,{to:"../credentials",replace:!0})}),l.jsx(Te,{path:"personas",element:l.jsx(VU,{})}),l.jsx(Te,{path:"personas/new",element:l.jsx(mb,{})}),l.jsx(Te,{path:"personas/:personaId",element:l.jsx(mb,{})}),l.jsx(Te,{path:"appearance",element:l.jsx(XU,{})}),l.jsx(Te,{path:"shortcuts",element:l.jsx(t7,{})}),l.jsx(Te,{path:"about",element:l.jsx(e7,{})})]})}),l.jsx(Te,{path:"*",element:l.jsx(Wn,{to:"/",replace:!0})})]})]})}const ez=1e4;function tz(){const{onboardingCompleted:t}=rt(),[s,i]=y.useState(!1);y.useEffect(()=>{if(t!==void 0)return;const c=setTimeout(()=>i(!0),ez);return()=>clearTimeout(c)},[t]);const o=t===void 0&&!s;return l.jsx(ds,{mode:"wait",children:o?l.jsx(Dt.div,{initial:{opacity:1},exit:{opacity:0},transition:{duration:.25},children:l.jsx(Tx,{})},"splash"):l.jsx(Dt.div,{initial:{opacity:0},animate:{opacity:1},transition:{duration:.25},style:{minHeight:"100vh"},children:l.jsx(Gw,{basename:"/".replace(/\/$/,""),children:l.jsx(Q7,{})})},"app")})}function nz(){const t=Wx?EB:XB;return l.jsx(eB,{children:l.jsx(J4,{children:l.jsx(t,{children:l.jsx(tz,{})})})})}BT.createRoot(document.getElementById("root")).render(l.jsx(y.StrictMode,{children:l.jsx(nz,{})}));export{fs as B,Gb as K,rt as a,Qf as f,Rp as s,Xn as t,vt as u};
503
+ $\`Summarize the current tasks.\`;`,ariaLabel:"Persona script","data-testid":"persona-script-editor"})]}),E==="agent"&&l.jsxs("div",{children:[l.jsx("label",{children:"Allowed MCP Tools"}),l.jsx(tb,{selectedTools:F,onChange:B=>{ee(B),de(()=>c(t.id,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,B),()=>{},"MCP tools updated","Failed to update MCP tools").catch(()=>{})}})]})]}),!ke&&!Ne&&l.jsx("p",{style:{fontSize:"var(--font-size-xs)",color:"var(--text-tertiary)",marginTop:"var(--space-xs)"},children:"Only agent personas with a runtime and model can be set as app default."})]}):null,l.jsx(ii,{isOpen:ae,title:"Delete Persona?",description:`"${t==null?void 0:t.name}" will be permanently removed.`,confirmLabel:"Delete",onConfirm:ve,onCancel:()=>me(!1)})]})}function XU(){const{themeId:t,resolvedThemeId:s,setTheme:i,preferSystem:o,setPreferSystem:c}=Hx();return l.jsx(kI,{themeId:t,resolvedThemeId:s,onSetTheme:i,preferSystem:o,onSetPreferSystem:c})}function QU(){const[t,s]=y.useState(void 0);return y.useEffect(()=>{let i=!1;return xe.getVersionStatus({}).then(o=>{i||s({currentVersion:o.currentVersion,latestVersion:o.latestVersion,updateAvailable:o.updateAvailable,isDocker:o.isDocker})},()=>{}),()=>{i=!0}},[]),t}function e7(){const{connected:t,environments:s,sessions:i}=rt(),o=QU();return l.jsxs(l.Fragment,{children:[o&&l.jsx(C6,{currentVersion:o.currentVersion,latestVersion:o.latestVersion,updateAvailable:o.updateAvailable,isDocker:o.isDocker}),l.jsx(wI,{connected:t,environments:s,sessions:i})]})}function t7(){return l.jsx(xO,{})}const hb=ri();function n7(){const t=vt();return Us({key:"?"},()=>{t(a2)}),Us({key:"n"},()=>{t(hb)}),Us({key:"N"},()=>{t(hb)}),l.jsx(l.Fragment,{})}function Ur(t){const s=sB();y.useLayoutEffect(()=>(s(t),()=>{s(void 0)}),[t,s])}function s7(){const{workspaces:t,tasks:s}=rt(),i=y.useMemo(()=>l.jsx(a6,{workspaces:t,tasks:s}),[t,s]);return Ur(i),l.jsx(wa,{})}function a7(){const{environments:t}=rt(),s=y.useMemo(()=>l.jsx(m3,{environments:t}),[t]);return Ur(s),l.jsx(wa,{})}function i7(){const t=y.useMemo(()=>l.jsx(c4,{}),[]);return Ur(t),l.jsx(wa,{})}function o7(){const{findings:t,loadFindings:s,loadAllFindings:i}=rt(),{workspaceId:o,environmentId:c}=Qn();y.useEffect(()=>{o?s(o):i()},[o,s,i]);const u=y.useMemo(()=>l.jsx(w3,{findings:t,workspaceId:o,environmentId:c}),[t,o,c]);return Ur(u),l.jsx(wa,{})}function r7(){const{knowledge:t,workspaces:s}=rt(),i=y.useCallback(m=>{t.search(m)},[t]),o=y.useCallback(()=>{t.clearSearch()},[t]),c=y.useCallback(m=>{t.selectNode(m)},[t]),u=y.useCallback(m=>{t.loadRecent(m||void 0)},[t]),d=y.useMemo(()=>l.jsx(jM,{nodes:t.graphData.nodes,workspaces:s,loading:t.loading,searchQuery:t.searchQuery,onSearch:i,onClearSearch:o,onSelectNode:c,onWorkspaceChange:u}),[t,s,i,o,c,u]);return Ur(d),l.jsx(wa,{})}const l7="_container_ce571_1",c7="_title_ce571_6",gb={container:l7,title:c7};function vb(){const{environmentId:t,workspaceId:s}=Qn(),{findings:i,loadFindings:o,workspaces:c,environments:u}=rt(),d=vt();y.useEffect(()=>{s&&o(s)},[s,o]);const m=y.useCallback(g=>{d(Qf(g,s,t))},[d,s,t]),h=s&&t?Yx("Findings",s,t,c,u).slice(0,-1):hB();return l.jsxs("div",{className:gb.container,"data-testid":"findings-list-page",children:[l.jsx(fs,{segments:h}),l.jsx("h1",{className:gb.title,children:"Findings"}),l.jsx(Mx,{findings:i,onFindingClick:m})]})}const u7="_container_1wwpb_1",d7="_notFound_1wwpb_6",f7="_header_1wwpb_12",p7="_categoryBadge_1wwpb_19",m7="_title_1wwpb_28",h7="_content_1wwpb_35",g7="_tags_1wwpb_77",v7="_tag_1wwpb_77",y7="_meta_1wwpb_92",b7="_metaTimestamp_1wwpb_100",_7="_metaLink_1wwpb_105",nn={container:u7,notFound:d7,header:f7,categoryBadge:p7,title:m7,content:h7,tags:g7,tag:v7,meta:y7,metaTimestamp:b7,metaLink:_7};function yb(){const{findingId:t,environmentId:s,workspaceId:i}=Qn(),{selectedFinding:o,findingLoading:c,loadFinding:u,workspaces:d,environments:m}=rt(),h=vt();if(y.useEffect(()=>{t&&u(t)},[t,u]),c)return l.jsx("div",{className:nn.container,"data-testid":"finding-detail-page",children:l.jsx("div",{className:nn.notFound,children:"Loading..."})});if(!o)return l.jsx("div",{className:nn.container,"data-testid":"finding-detail-page",children:l.jsx("div",{className:nn.notFound,children:"Finding not found."})});const g=Yx(o.title,i,s,d,m),v=Lc(o.category);return l.jsxs("div",{className:nn.container,"data-testid":"finding-detail-page",children:[l.jsx(fs,{segments:g}),l.jsxs("div",{className:nn.header,children:[l.jsx("span",{className:nn.categoryBadge,style:{background:v.bg,color:v.text},children:o.category}),l.jsx("h1",{className:nn.title,children:o.title})]}),o.content&&l.jsx("div",{className:nn.content,children:l.jsx(Pc,{remarkPlugins:[Vc],children:o.content})}),o.tags.length>0&&l.jsx("div",{className:nn.tags,children:o.tags.map(_=>l.jsx("span",{className:nn.tag,children:_},_))}),l.jsxs("div",{className:nn.meta,children:[l.jsx("span",{className:nn.metaTimestamp,title:o.createdAt,children:gm(o.createdAt)}),o.taskId&&l.jsx("button",{type:"button",className:nn.metaLink,onClick:()=>{h(Xn(o.taskId))},children:"View Task"}),o.sessionId&&l.jsx("button",{type:"button",className:nn.metaLink,onClick:()=>{h(Rp(o.sessionId))},children:"View Session"})]})]})}const x7="_wizard_1260s_1",S7="_container_1260s_10",T7="_stepContent_1260s_19",k7="_logoArea_1260s_28",w7="_logoImage_1260s_32",N7="_heading_1260s_41",j7="_tagline_1260s_49",C7="_subtitle_1260s_56",E7="_featureList_1260s_64",A7="_runtimeGrid_1260s_89",D7="_runtimeCard_1260s_101",R7="_runtimeName_1260s_133",M7="_runtimeDescription_1260s_139",I7="_buttonRow_1260s_144",O7="_primaryButton_1260s_151",B7="_ghostButton_1260s_185",L7="_dots_1260s_213",U7="_dot_1260s_213",ut={wizard:x7,container:S7,stepContent:T7,logoArea:k7,logoImage:w7,heading:N7,tagline:j7,subtitle:C7,featureList:E7,runtimeGrid:A7,runtimeCard:D7,runtimeName:R7,runtimeDescription:M7,buttonRow:I7,primaryButton:O7,ghostButton:B7,dots:L7,dot:U7};function z7({onNext:t}){return l.jsxs("div",{className:ut.stepContent,"data-testid":"setup-welcome",children:[l.jsx("div",{className:ut.logoArea,children:l.jsx("img",{src:"/grackle-logo.png",alt:"Grackle",className:ut.logoImage})}),l.jsx("h1",{className:ut.heading,children:"Welcome to Grackle"}),l.jsx("p",{className:ut.tagline,children:"Multi-agent orchestration for software teams"}),l.jsx("button",{type:"button",className:ut.primaryButton,onClick:t,"data-testid":"setup-get-started",children:"Get Started"})]})}function P7({onNext:t,onBack:s}){return l.jsxs("div",{className:ut.stepContent,"data-testid":"setup-about",children:[l.jsx("h2",{className:ut.heading,children:"What is Grackle?"}),l.jsxs("ul",{className:ut.featureList,children:[l.jsx("li",{children:"Run Claude, Copilot, and Codex agents side by side"}),l.jsx("li",{children:"Provision and control dev environments — SSH, Codespaces, or local"}),l.jsx("li",{children:"Organize work into workspaces with agent-executable tasks"}),l.jsx("li",{children:"Customize agent behavior with personas, tools, and MCP servers"}),l.jsx("li",{children:"Live-stream agent sessions with full terminal replay"})]}),l.jsxs("div",{className:ut.buttonRow,children:[l.jsx("button",{type:"button",className:ut.ghostButton,onClick:s,children:"Back"}),l.jsx("button",{type:"button",className:ut.primaryButton,onClick:t,"data-testid":"setup-about-next",children:"Next"})]})]})}const V7=[{id:"claude-code",name:"Claude Code",description:"Anthropic's agentic coding tool"},{id:"copilot",name:"Copilot Coding Agent",description:"GitHub's AI pair programmer"},{id:"codex",name:"Codex CLI",description:"OpenAI's coding agent"},{id:"goose",name:"Goose",description:"Block's open-source AI coding agent"}];function H7({currentRuntime:t,onFinish:s,onBack:i,finishDisabled:o}){const[c,u]=y.useState(t||"claude-code");return y.useEffect(()=>{t&&u(t)},[t]),l.jsxs("div",{className:ut.stepContent,"data-testid":"setup-runtime",children:[l.jsx("h2",{className:ut.heading,children:"Choose Your Runtime"}),l.jsx("p",{className:ut.subtitle,children:"Select the primary agent runtime for your workspace. You can change this later."}),l.jsx("div",{className:ut.runtimeGrid,children:V7.map(d=>l.jsxs("button",{type:"button",className:ut.runtimeCard,"data-selected":c===d.id,"aria-pressed":c===d.id,"data-testid":`runtime-card-${d.id}`,onClick:()=>u(d.id),children:[l.jsx("span",{className:ut.runtimeName,children:d.name}),l.jsx("span",{className:ut.runtimeDescription,children:d.description})]},d.id))}),l.jsxs("div",{className:ut.buttonRow,children:[l.jsx("button",{type:"button",className:ut.ghostButton,onClick:i,children:"Back"}),l.jsx("button",{type:"button",className:ut.primaryButton,onClick:()=>{s(c)},disabled:o,"data-testid":"setup-finish",children:"Finish"})]})]})}const $7=3,bb={"claude-code":"sonnet",copilot:"gpt-4o",codex:"o3",goose:""};function G7(){const{personas:t,updatePersona:s,completeOnboarding:i,onboardingCompleted:o}=rt(),{showToast:c}=dn(),u=vt(),[d,m]=y.useState(0),[h,g]=y.useState(!1),v=t.find(b=>b.id==="claude-code"),_=y.useCallback(b=>{g(!0);const S=[];if(v&&b!==v.runtime){const N=bb[b]??"sonnet";S.push(s(v.id,void 0,void 0,void 0,b,N))}const T=t.find(N=>N.id===m0);if(T&&b!==T.runtime){const N=bb[b]??"sonnet";S.push(s(m0,void 0,void 0,void 0,b,N))}Promise.all(S).then(()=>i()).then(()=>{u("/",{replace:!0})},()=>{c("Failed to update runtime -- please try again","error"),g(!1)})},[v,t,s,i,u,c]);return o===!0?l.jsx(Wn,{to:"/",replace:!0}):l.jsx("div",{className:ut.wizard,"data-testid":"setup-wizard",children:l.jsxs("div",{className:ut.container,children:[l.jsx(ds,{mode:"wait",children:l.jsxs(Dt.div,{initial:{opacity:0,x:40},animate:{opacity:1,x:0},exit:{opacity:0,x:-40},transition:{duration:.2,ease:"easeInOut"},children:[d===0&&l.jsx(z7,{onNext:()=>m(1)}),d===1&&l.jsx(P7,{onNext:()=>m(2),onBack:()=>m(0)}),d===2&&l.jsx(H7,{currentRuntime:(v==null?void 0:v.runtime)??"claude-code",onFinish:_,onBack:()=>m(1),finishDisabled:!v||h})]},d)}),l.jsx("div",{className:ut.dots,children:Array.from({length:$7},(b,S)=>l.jsx("span",{className:ut.dot,"data-active":S===d},S))})]})})}const q7="_root_zndgp_1",F7="_body_zndgp_7",Z7="_main_zndgp_19",K7="_sidebarWrapper_zndgp_26",Y7="_overlay_zndgp_51",vr={root:q7,body:F7,main:Z7,sidebarWrapper:K7,overlay:Y7},J7=y.lazy(()=>zT(()=>import("./KnowledgePage-CLcFJZi2.js"),__vite__mapDeps([0,1,2,3,4])).then(t=>({default:t.KnowledgePage}))),Wx=typeof window<"u"&&new URLSearchParams(window.location.search).has("mock");function W7(){const{connected:t,environments:s,sessions:i,tasks:o}=rt(),{toasts:c,dismissToast:u}=dn(),d=Ut(),m=nB(),h=m!==void 0,[g,v]=y.useState(!1),_=y.useCallback(()=>v(b=>!b),[]);return y.useEffect(()=>{v(!1)},[d.pathname]),y.useEffect(()=>{if(!g)return;const b=S=>{S.key==="Escape"&&v(!1)};return document.addEventListener("keydown",b),()=>{document.removeEventListener("keydown",b)}},[g]),l.jsxs(l.Fragment,{children:[l.jsx(LM,{connected:t,environments:s,sessions:i,onToggleSidebar:h?_:void 0,sidebarOpen:g}),l.jsx(GM,{}),l.jsxs("div",{className:vr.body,children:[h&&l.jsx("div",{className:vr.sidebarWrapper,"data-sidebar-open":g,children:l.jsx(JM,{content:m})}),h&&g&&l.jsx("div",{className:vr.overlay,"data-testid":"drawer-overlay",onClick:()=>v(!1)}),l.jsxs("div",{className:vr.main,children:[l.jsx(wa,{}),l.jsx(a3,{sessions:i,tasks:o,environments:s})]})]}),l.jsx(v6,{toasts:c,onDismiss:u}),l.jsx(n7,{})]})}function X7(){const{lastSpawnedId:t,environments:s,tasks:i,connected:o,onboardingCompleted:c}=rt(),{showToast:u}=dn();QB(s,u),sL(i,u);const d=vt(),m=Ut();return y.useEffect(()=>{t&&!m.pathname.includes("/tasks/")&&d(Rp(t),{replace:!0})},[t,d,m.pathname]),o&&c===!1?l.jsx(Wn,{to:"/setup",replace:!0}):l.jsx(tB,{children:l.jsxs("div",{className:vr.root,children:[Wx&&l.jsx(I2,{}),l.jsx(W7,{})]})})}function Kf(){const{workspaceId:t}=Qn(),{workspaces:s}=rt(),i=Ut(),o=s.find(h=>h.id===t);if(!(o!=null&&o.environmentId))return s.length===0?void 0:l.jsx(Wn,{to:"/environments",replace:!0});const c=encodeURIComponent(t),u=`/workspaces/${c}`,d=i.pathname.startsWith(u)?i.pathname.slice(u.length):"",m=`/environments/${encodeURIComponent(o.environmentId)}/workspaces/${c}${d}${i.search}${i.hash}`;return l.jsx(Wn,{to:m,replace:!0})}function Q7(){return l.jsxs(bw,{children:[l.jsx(Te,{path:"setup",element:l.jsx(G7,{})}),l.jsxs(Te,{element:l.jsx(X7,{}),children:[l.jsx(Te,{index:!0,element:l.jsx(w8,{})}),l.jsx(Te,{path:"chat",element:l.jsx(I8,{})}),l.jsx(Te,{path:"sessions/new",element:l.jsx(O8,{})}),l.jsx(Te,{path:"sessions/:sessionId",element:l.jsx(U8,{})}),l.jsx(Te,{element:l.jsx(r7,{}),children:l.jsx(Te,{path:"knowledge",element:l.jsx(y.Suspense,{fallback:l.jsx(Tx,{}),children:l.jsx(J7,{})})})}),l.jsxs(Te,{element:l.jsx(s7,{}),children:[l.jsx(Te,{path:"tasks",element:l.jsx(T8,{})}),l.jsx(Te,{path:"tasks/new",element:l.jsx(ub,{})}),l.jsx(Te,{path:"tasks/:taskId",element:l.jsx(ba,{})}),l.jsx(Te,{path:"tasks/:taskId/edit",element:l.jsx(ba,{})}),l.jsx(Te,{path:"tasks/:taskId/stream",element:l.jsx(ba,{})}),l.jsx(Te,{path:"tasks/:taskId/findings",element:l.jsx(ba,{})})]}),l.jsxs(Te,{element:l.jsx(o7,{}),children:[l.jsx(Te,{path:"findings",element:l.jsx(vb,{})}),l.jsx(Te,{path:"findings/:findingId",element:l.jsx(yb,{})}),l.jsx(Te,{path:"environments/:environmentId/workspaces/:workspaceId/findings",element:l.jsx(vb,{})}),l.jsx(Te,{path:"environments/:environmentId/workspaces/:workspaceId/findings/:findingId",element:l.jsx(yb,{})})]}),l.jsxs(Te,{element:l.jsx(a7,{}),children:[l.jsx(Te,{path:"workspaces",element:l.jsx(Wn,{to:"/environments",replace:!0})}),l.jsx(Te,{path:"workspaces/new",element:l.jsx(X8,{})}),l.jsx(Te,{path:"workspaces/:workspaceId",element:l.jsx(Kf,{})}),l.jsx(Te,{path:"workspaces/:workspaceId/tasks/:taskId",element:l.jsx(Kf,{})}),l.jsx(Te,{path:"workspaces/:workspaceId/tasks/:taskId/*",element:l.jsx(Kf,{})}),l.jsx(Te,{path:"environments/:environmentId/workspaces/:workspaceId",element:l.jsx(V8,{})}),l.jsx(Te,{path:"environments/:environmentId/workspaces/:workspaceId/tasks/new",element:l.jsx(ub,{})}),l.jsx(Te,{path:"environments/:environmentId/workspaces/:workspaceId/tasks/:taskId",element:l.jsx(ba,{})}),l.jsx(Te,{path:"environments/:environmentId/workspaces/:workspaceId/tasks/:taskId/edit",element:l.jsx(ba,{})}),l.jsx(Te,{path:"environments/:environmentId/workspaces/:workspaceId/tasks/:taskId/stream",element:l.jsx(ba,{})}),l.jsx(Te,{path:"environments/:environmentId/workspaces/:workspaceId/tasks/:taskId/findings",element:l.jsx(ba,{})}),l.jsxs(Te,{path:"environments",element:l.jsx(lU,{}),children:[l.jsx(Te,{index:!0,element:l.jsx(k8,{})}),l.jsx(Te,{path:"new",element:l.jsx(sU,{})}),l.jsx(Te,{path:":environmentId",element:l.jsx(BU,{})}),l.jsx(Te,{path:":environmentId/edit",element:l.jsx(aU,{})})]})]}),l.jsx(Te,{element:l.jsx(i7,{}),children:l.jsxs(Te,{path:"settings",element:l.jsx(zU,{}),children:[l.jsx(Te,{index:!0,element:l.jsx(Wn,{to:"credentials",replace:!0})}),l.jsx(Te,{path:"environments",element:l.jsx(Wn,{to:"/environments",replace:!0})}),l.jsx(Te,{path:"credentials",element:l.jsx(PU,{})}),l.jsx(Te,{path:"tokens",element:l.jsx(Wn,{to:"../credentials",replace:!0})}),l.jsx(Te,{path:"personas",element:l.jsx(VU,{})}),l.jsx(Te,{path:"personas/new",element:l.jsx(mb,{})}),l.jsx(Te,{path:"personas/:personaId",element:l.jsx(mb,{})}),l.jsx(Te,{path:"appearance",element:l.jsx(XU,{})}),l.jsx(Te,{path:"shortcuts",element:l.jsx(t7,{})}),l.jsx(Te,{path:"about",element:l.jsx(e7,{})})]})}),l.jsx(Te,{path:"*",element:l.jsx(Wn,{to:"/",replace:!0})})]})]})}const ez=1e4;function tz(){const{onboardingCompleted:t}=rt(),[s,i]=y.useState(!1);y.useEffect(()=>{if(t!==void 0)return;const c=setTimeout(()=>i(!0),ez);return()=>clearTimeout(c)},[t]);const o=t===void 0&&!s;return l.jsx(ds,{mode:"wait",children:o?l.jsx(Dt.div,{initial:{opacity:1},exit:{opacity:0},transition:{duration:.25},children:l.jsx(Tx,{})},"splash"):l.jsx(Dt.div,{initial:{opacity:0},animate:{opacity:1},transition:{duration:.25},style:{minHeight:"100vh"},children:l.jsx(Gw,{basename:"/".replace(/\/$/,""),children:l.jsx(Q7,{})})},"app")})}function nz(){const t=Wx?EB:XB;return l.jsx(eB,{children:l.jsx(J4,{children:l.jsx(t,{children:l.jsx(tz,{})})})})}BT.createRoot(document.getElementById("root")).render(l.jsx(y.StrictMode,{children:l.jsx(nz,{})}));export{fs as B,Gb as K,rt as a,Qf as f,Rp as s,Xn as t,vt as u};