aitable-workflow-cli 0.1.17 → 0.1.18-beta.1786440467350
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -57,7 +57,7 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
|
|
|
57
57
|
}
|
|
58
58
|
`),()=>{document.head.removeChild(d)}},[t]),a.jsx(KM,{isPresent:t,childRef:r,sizeRef:s,children:b.cloneElement(e,{ref:r})})}const qM=({children:e,initial:t,isPresent:n,onExitComplete:r,custom:s,presenceAffectsLayout:i,mode:o})=>{const l=Jm(YM),c=b.useId(),u=b.useCallback(f=>{l.set(f,!0);for(const h of l.values())if(!h)return;r&&r()},[l,r]),d=b.useMemo(()=>({id:c,initial:t,isPresent:n,custom:s,onExitComplete:u,register:f=>(l.set(f,!1),()=>l.delete(f))}),i?[Math.random(),u]:[n,u]);return b.useMemo(()=>{l.forEach((f,h)=>l.set(h,!1))},[n]),b.useEffect(()=>{!n&&!l.size&&r&&r()},[n]),o==="popLayout"&&(e=a.jsx(GM,{isPresent:n,children:e})),a.jsx(Ju.Provider,{value:d,children:e})};function YM(){return new Map}function jj(e=!0){const t=b.useContext(Ju);if(t===null)return[!0,null];const{isPresent:n,onExitComplete:r,register:s}=t,i=b.useId();b.useEffect(()=>{e&&s(i)},[e]);const o=b.useCallback(()=>e&&r&&r(i),[i,r,e]);return!n&&r?[!1,o]:[!0]}const El=e=>e.key||"";function Qy(e){const t=[];return b.Children.forEach(e,n=>{b.isValidElement(n)&&t.push(n)}),t}const tg=typeof window<"u",Sj=tg?b.useLayoutEffect:b.useEffect,Ho=({children:e,custom:t,initial:n=!0,onExitComplete:r,presenceAffectsLayout:s=!0,mode:i="sync",propagate:o=!1})=>{const[l,c]=jj(o),u=b.useMemo(()=>Qy(e),[e]),d=o&&!l?[]:u.map(El),f=b.useRef(!0),h=b.useRef(u),p=Jm(()=>new Map),[v,x]=b.useState(u),[w,g]=b.useState(u);Sj(()=>{f.current=!1,h.current=u;for(let _=0;_<w.length;_++){const j=El(w[_]);d.includes(j)?p.delete(j):p.get(j)!==!0&&p.set(j,!1)}},[w,d.length,d.join("-")]);const y=[];if(u!==v){let _=[...u];for(let j=0;j<w.length;j++){const N=w[j],k=El(N);d.includes(k)||(_.splice(j,0,N),y.push(N))}i==="wait"&&y.length&&(_=y),g(Qy(_)),x(u);return}const{forceRender:m}=b.useContext(Zm);return a.jsx(a.Fragment,{children:w.map(_=>{const j=El(_),N=o&&!l?!1:u===w||d.includes(j),k=()=>{if(p.has(j))p.set(j,!0);else return;let S=!0;p.forEach(P=>{P||(S=!1)}),S&&(m==null||m(),g(h.current),o&&(c==null||c()),r&&r())};return a.jsx(qM,{isPresent:N,initial:!f.current||n?void 0:!1,custom:N?void 0:t,presenceAffectsLayout:s,mode:i,onExitComplete:N?void 0:k,children:_},j)})})},Et=e=>e;let kj=Et;const XM={useManualTiming:!1};function QM(e){let t=new Set,n=new Set,r=!1,s=!1;const i=new WeakSet;let o={delta:0,timestamp:0,isProcessing:!1};function l(u){i.has(u)&&(c.schedule(u),e()),u(o)}const c={schedule:(u,d=!1,f=!1)=>{const p=f&&r?t:n;return d&&i.add(u),p.has(u)||p.add(u),u},cancel:u=>{n.delete(u),i.delete(u)},process:u=>{if(o=u,r){s=!0;return}r=!0,[t,n]=[n,t],t.forEach(l),t.clear(),r=!1,s&&(s=!1,c.process(u))}};return c}const Cl=["read","resolveKeyframes","update","preRender","render","postRender"],ZM=40;function Nj(e,t){let n=!1,r=!0;const s={delta:0,timestamp:0,isProcessing:!1},i=()=>n=!0,o=Cl.reduce((g,y)=>(g[y]=QM(i),g),{}),{read:l,resolveKeyframes:c,update:u,preRender:d,render:f,postRender:h}=o,p=()=>{const g=performance.now();n=!1,s.delta=r?1e3/60:Math.max(Math.min(g-s.timestamp,ZM),1),s.timestamp=g,s.isProcessing=!0,l.process(s),c.process(s),u.process(s),d.process(s),f.process(s),h.process(s),s.isProcessing=!1,n&&t&&(r=!1,e(p))},v=()=>{n=!0,r=!0,s.isProcessing||e(p)};return{schedule:Cl.reduce((g,y)=>{const m=o[y];return g[y]=(_,j=!1,N=!1)=>(n||v(),m.schedule(_,j,N)),g},{}),cancel:g=>{for(let y=0;y<Cl.length;y++)o[Cl[y]].cancel(g)},state:s,steps:o}}const{schedule:ke,cancel:Br,state:qe,steps:sf}=Nj(typeof requestAnimationFrame<"u"?requestAnimationFrame:Et,!0),Ej=b.createContext({strict:!1}),Zy={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"]},Di={};for(const e in Zy)Di[e]={isEnabled:t=>Zy[e].some(n=>!!t[n])};function JM(e){for(const t in e)Di[t]={...Di[t],...e[t]}}const eI=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 nu(e){return e.startsWith("while")||e.startsWith("drag")&&e!=="draggable"||e.startsWith("layout")||e.startsWith("onTap")||e.startsWith("onPan")||e.startsWith("onLayout")||eI.has(e)}let Cj=e=>!nu(e);function tI(e){e&&(Cj=t=>t.startsWith("on")?!nu(t):e(t))}try{tI(require("@emotion/is-prop-valid").default)}catch{}function nI(e,t,n){const r={};for(const s in e)s==="values"&&typeof e.values=="object"||(Cj(s)||n===!0&&nu(s)||!t&&!nu(s)||e.draggable&&s.startsWith("onDrag"))&&(r[s]=e[s]);return r}function rI(e){if(typeof Proxy>"u")return e;const t=new Map,n=(...r)=>e(...r);return new Proxy(n,{get:(r,s)=>s==="create"?e:(t.has(s)||t.set(s,e(s)),t.get(s))})}const ed=b.createContext({});function va(e){return typeof e=="string"||Array.isArray(e)}function td(e){return e!==null&&typeof e=="object"&&typeof e.start=="function"}const ng=["animate","whileInView","whileFocus","whileHover","whileTap","whileDrag","exit"],rg=["initial",...ng];function nd(e){return td(e.animate)||rg.some(t=>va(e[t]))}function Aj(e){return!!(nd(e)||e.variants)}function sI(e,t){if(nd(e)){const{initial:n,animate:r}=e;return{initial:n===!1||va(n)?n:void 0,animate:va(r)?r:void 0}}return e.inherit!==!1?t:{}}function iI(e){const{initial:t,animate:n}=sI(e,b.useContext(ed));return b.useMemo(()=>({initial:t,animate:n}),[Jy(t),Jy(n)])}function Jy(e){return Array.isArray(e)?e.join(" "):e}const oI=Symbol.for("motionComponentSymbol");function di(e){return e&&typeof e=="object"&&Object.prototype.hasOwnProperty.call(e,"current")}function aI(e,t,n){return b.useCallback(r=>{r&&e.onMount&&e.onMount(r),t&&(r?t.mount(r):t.unmount()),n&&(typeof n=="function"?n(r):di(n)&&(n.current=r))},[t])}const sg=e=>e.replace(/([a-z])([A-Z])/gu,"$1-$2").toLowerCase(),lI="framerAppearId",Tj="data-"+sg(lI),{schedule:ig}=Nj(queueMicrotask,!1),Pj=b.createContext({});function cI(e,t,n,r,s){var i,o;const{visualElement:l}=b.useContext(ed),c=b.useContext(Ej),u=b.useContext(Ju),d=b.useContext(eg).reducedMotion,f=b.useRef(null);r=r||c.renderer,!f.current&&r&&(f.current=r(e,{visualState:t,parent:l,props:n,presenceContext:u,blockInitialAnimation:u?u.initial===!1:!1,reducedMotionConfig:d}));const h=f.current,p=b.useContext(Pj);h&&!h.projection&&s&&(h.type==="html"||h.type==="svg")&&uI(f.current,n,s,p);const v=b.useRef(!1);b.useInsertionEffect(()=>{h&&v.current&&h.update(n,u)});const x=n[Tj],w=b.useRef(!!x&&!(!((i=window.MotionHandoffIsComplete)===null||i===void 0)&&i.call(window,x))&&((o=window.MotionHasOptimisedAnimation)===null||o===void 0?void 0:o.call(window,x)));return Sj(()=>{h&&(v.current=!0,window.MotionIsMounted=!0,h.updateFeatures(),ig.render(h.render),w.current&&h.animationState&&h.animationState.animateChanges())}),b.useEffect(()=>{h&&(!w.current&&h.animationState&&h.animationState.animateChanges(),w.current&&(queueMicrotask(()=>{var g;(g=window.MotionHandoffMarkAsComplete)===null||g===void 0||g.call(window,x)}),w.current=!1))}),h}function uI(e,t,n,r){const{layoutId:s,layout:i,drag:o,dragConstraints:l,layoutScroll:c,layoutRoot:u}=t;e.projection=new n(e.latestValues,t["data-framer-portal-id"]?void 0:Mj(e.parent)),e.projection.setOptions({layoutId:s,layout:i,alwaysMeasureLayout:!!o||l&&di(l),visualElement:e,animationType:typeof i=="string"?i:"both",initialPromotionConfig:r,layoutScroll:c,layoutRoot:u})}function Mj(e){if(e)return e.options.allowProjection!==!1?e.projection:Mj(e.parent)}function dI({preloadedFeatures:e,createVisualElement:t,useRender:n,useVisualState:r,Component:s}){var i,o;e&&JM(e);function l(u,d){let f;const h={...b.useContext(eg),...u,layoutId:fI(u)},{isStatic:p}=h,v=iI(u),x=r(u,p);if(!p&&tg){hI();const w=pI(h);f=w.MeasureLayout,v.visualElement=cI(s,x,h,t,w.ProjectionNode)}return a.jsxs(ed.Provider,{value:v,children:[f&&v.visualElement?a.jsx(f,{visualElement:v.visualElement,...h}):null,n(s,u,aI(x,v.visualElement,d),x,p,v.visualElement)]})}l.displayName=`motion.${typeof s=="string"?s:`create(${(o=(i=s.displayName)!==null&&i!==void 0?i:s.name)!==null&&o!==void 0?o:""})`}`;const c=b.forwardRef(l);return c[oI]=s,c}function fI({layoutId:e}){const t=b.useContext(Zm).id;return t&&e!==void 0?t+"-"+e:e}function hI(e,t){b.useContext(Ej).strict}function pI(e){const{drag:t,layout:n}=Di;if(!t&&!n)return{};const r={...t,...n};return{MeasureLayout:t!=null&&t.isEnabled(e)||n!=null&&n.isEnabled(e)?r.MeasureLayout:void 0,ProjectionNode:r.ProjectionNode}}const mI=["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 og(e){return typeof e!="string"||e.includes("-")?!1:!!(mI.indexOf(e)>-1||/[A-Z]/u.test(e))}function e0(e){const t=[{},{}];return e==null||e.values.forEach((n,r)=>{t[0][r]=n.get(),t[1][r]=n.getVelocity()}),t}function ag(e,t,n,r){if(typeof t=="function"){const[s,i]=e0(r);t=t(n!==void 0?n:e.custom,s,i)}if(typeof t=="string"&&(t=e.variants&&e.variants[t]),typeof t=="function"){const[s,i]=e0(r);t=t(n!==void 0?n:e.custom,s,i)}return t}const Qh=e=>Array.isArray(e),gI=e=>!!(e&&typeof e=="object"&&e.mix&&e.toValue),vI=e=>Qh(e)?e[e.length-1]||0:e,nt=e=>!!(e&&e.getVelocity);function cc(e){const t=nt(e)?e.get():e;return gI(t)?t.toValue():t}function yI({scrapeMotionValuesFromProps:e,createRenderState:t,onUpdate:n},r,s,i){const o={latestValues:_I(r,s,i,e),renderState:t()};return n&&(o.onMount=l=>n({props:r,current:l,...o}),o.onUpdate=l=>n(l)),o}const Ij=e=>(t,n)=>{const r=b.useContext(ed),s=b.useContext(Ju),i=()=>yI(e,t,r,s);return n?i():Jm(i)};function _I(e,t,n,r){const s={},i=r(e,{});for(const h in i)s[h]=cc(i[h]);let{initial:o,animate:l}=e;const c=nd(e),u=Aj(e);t&&u&&!c&&e.inherit!==!1&&(o===void 0&&(o=t.initial),l===void 0&&(l=t.animate));let d=n?n.initial===!1:!1;d=d||o===!1;const f=d?l:o;if(f&&typeof f!="boolean"&&!td(f)){const h=Array.isArray(f)?f:[f];for(let p=0;p<h.length;p++){const v=ag(e,h[p]);if(v){const{transitionEnd:x,transition:w,...g}=v;for(const y in g){let m=g[y];if(Array.isArray(m)){const _=d?m.length-1:0;m=m[_]}m!==null&&(s[y]=m)}for(const y in x)s[y]=x[y]}}}return s}const to=["transformPerspective","x","y","z","translateX","translateY","translateZ","scale","scaleX","scaleY","rotate","rotateX","rotateY","rotateZ","skew","skewX","skewY"],Fs=new Set(to),Rj=e=>t=>typeof t=="string"&&t.startsWith(e),Oj=Rj("--"),xI=Rj("var(--"),lg=e=>xI(e)?wI.test(e.split("/*")[0].trim()):!1,wI=/var\(--(?:[\w-]+\s*|[\w-]+\s*,(?:\s*[^)(\s]|\s*\((?:[^)(]|\([^)(]*\))*\))+\s*)\)$/iu,$j=(e,t)=>t&&typeof e=="number"?t.transform(e):e,dr=(e,t,n)=>n>t?t:n<e?e:n,no={test:e=>typeof e=="number",parse:parseFloat,transform:e=>e},ya={...no,transform:e=>dr(0,1,e)},Al={...no,default:1},Ga=e=>({test:t=>typeof t=="string"&&t.endsWith(e)&&t.split(" ").length===1,parse:parseFloat,transform:t=>`${t}${e}`}),_r=Ga("deg"),In=Ga("%"),se=Ga("px"),bI=Ga("vh"),jI=Ga("vw"),t0={...In,parse:e=>In.parse(e)/100,transform:e=>In.transform(e*100)},SI={borderWidth:se,borderTopWidth:se,borderRightWidth:se,borderBottomWidth:se,borderLeftWidth:se,borderRadius:se,radius:se,borderTopLeftRadius:se,borderTopRightRadius:se,borderBottomRightRadius:se,borderBottomLeftRadius:se,width:se,maxWidth:se,height:se,maxHeight:se,top:se,right:se,bottom:se,left:se,padding:se,paddingTop:se,paddingRight:se,paddingBottom:se,paddingLeft:se,margin:se,marginTop:se,marginRight:se,marginBottom:se,marginLeft:se,backgroundPositionX:se,backgroundPositionY:se},kI={rotate:_r,rotateX:_r,rotateY:_r,rotateZ:_r,scale:Al,scaleX:Al,scaleY:Al,scaleZ:Al,skew:_r,skewX:_r,skewY:_r,distance:se,translateX:se,translateY:se,translateZ:se,x:se,y:se,z:se,perspective:se,transformPerspective:se,opacity:ya,originX:t0,originY:t0,originZ:se},n0={...no,transform:Math.round},cg={...SI,...kI,zIndex:n0,size:se,fillOpacity:ya,strokeOpacity:ya,numOctaves:n0},NI={x:"translateX",y:"translateY",z:"translateZ",transformPerspective:"perspective"},EI=to.length;function CI(e,t,n){let r="",s=!0;for(let i=0;i<EI;i++){const o=to[i],l=e[o];if(l===void 0)continue;let c=!0;if(typeof l=="number"?c=l===(o.startsWith("scale")?1:0):c=parseFloat(l)===0,!c||n){const u=$j(l,cg[o]);if(!c){s=!1;const d=NI[o]||o;r+=`${d}(${u}) `}n&&(t[o]=u)}}return r=r.trim(),n?r=n(t,s?"":r):s&&(r="none"),r}function ug(e,t,n){const{style:r,vars:s,transformOrigin:i}=e;let o=!1,l=!1;for(const c in t){const u=t[c];if(Fs.has(c)){o=!0;continue}else if(Oj(c)){s[c]=u;continue}else{const d=$j(u,cg[c]);c.startsWith("origin")?(l=!0,i[c]=d):r[c]=d}}if(t.transform||(o||n?r.transform=CI(t,e.transform,n):r.transform&&(r.transform="none")),l){const{originX:c="50%",originY:u="50%",originZ:d=0}=i;r.transformOrigin=`${c} ${u} ${d}`}}const AI={offset:"stroke-dashoffset",array:"stroke-dasharray"},TI={offset:"strokeDashoffset",array:"strokeDasharray"};function PI(e,t,n=1,r=0,s=!0){e.pathLength=1;const i=s?AI:TI;e[i.offset]=se.transform(-r);const o=se.transform(t),l=se.transform(n);e[i.array]=`${o} ${l}`}function r0(e,t,n){return typeof e=="string"?e:se.transform(t+n*e)}function MI(e,t,n){const r=r0(t,e.x,e.width),s=r0(n,e.y,e.height);return`${r} ${s}`}function dg(e,{attrX:t,attrY:n,attrScale:r,originX:s,originY:i,pathLength:o,pathSpacing:l=1,pathOffset:c=0,...u},d,f){if(ug(e,u,f),d){e.style.viewBox&&(e.attrs.viewBox=e.style.viewBox);return}e.attrs=e.style,e.style={};const{attrs:h,style:p,dimensions:v}=e;h.transform&&(v&&(p.transform=h.transform),delete h.transform),v&&(s!==void 0||i!==void 0||p.transform)&&(p.transformOrigin=MI(v,s!==void 0?s:.5,i!==void 0?i:.5)),t!==void 0&&(h.x=t),n!==void 0&&(h.y=n),r!==void 0&&(h.scale=r),o!==void 0&&PI(h,o,l,c,!1)}const fg=()=>({style:{},transform:{},transformOrigin:{},vars:{}}),Lj=()=>({...fg(),attrs:{}}),hg=e=>typeof e=="string"&&e.toLowerCase()==="svg";function Dj(e,{style:t,vars:n},r,s){Object.assign(e.style,t,s&&s.getProjectionStyles(r));for(const i in n)e.style.setProperty(i,n[i])}const zj=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 Vj(e,t,n,r){Dj(e,t,void 0,r);for(const s in t.attrs)e.setAttribute(zj.has(s)?s:sg(s),t.attrs[s])}const ru={};function II(e){Object.assign(ru,e)}function Fj(e,{layout:t,layoutId:n}){return Fs.has(e)||e.startsWith("origin")||(t||n!==void 0)&&(!!ru[e]||e==="opacity")}function pg(e,t,n){var r;const{style:s}=e,i={};for(const o in s)(nt(s[o])||t.style&&nt(t.style[o])||Fj(o,e)||((r=n==null?void 0:n.getValue(o))===null||r===void 0?void 0:r.liveStyle)!==void 0)&&(i[o]=s[o]);return i}function Bj(e,t,n){const r=pg(e,t,n);for(const s in e)if(nt(e[s])||nt(t[s])){const i=to.indexOf(s)!==-1?"attr"+s.charAt(0).toUpperCase()+s.substring(1):s;r[i]=e[s]}return r}function RI(e,t){try{t.dimensions=typeof e.getBBox=="function"?e.getBBox():e.getBoundingClientRect()}catch{t.dimensions={x:0,y:0,width:0,height:0}}}const s0=["x","y","width","height","cx","cy","r"],OI={useVisualState:Ij({scrapeMotionValuesFromProps:Bj,createRenderState:Lj,onUpdate:({props:e,prevProps:t,current:n,renderState:r,latestValues:s})=>{if(!n)return;let i=!!e.drag;if(!i){for(const l in s)if(Fs.has(l)){i=!0;break}}if(!i)return;let o=!t;if(t)for(let l=0;l<s0.length;l++){const c=s0[l];e[c]!==t[c]&&(o=!0)}o&&ke.read(()=>{RI(n,r),ke.render(()=>{dg(r,s,hg(n.tagName),e.transformTemplate),Vj(n,r)})})}})},$I={useVisualState:Ij({scrapeMotionValuesFromProps:pg,createRenderState:fg})};function Hj(e,t,n){for(const r in t)!nt(t[r])&&!Fj(r,n)&&(e[r]=t[r])}function LI({transformTemplate:e},t){return b.useMemo(()=>{const n=fg();return ug(n,t,e),Object.assign({},n.vars,n.style)},[t])}function DI(e,t){const n=e.style||{},r={};return Hj(r,n,e),Object.assign(r,LI(e,t)),r}function zI(e,t){const n={},r=DI(e,t);return e.drag&&e.dragListener!==!1&&(n.draggable=!1,r.userSelect=r.WebkitUserSelect=r.WebkitTouchCallout="none",r.touchAction=e.drag===!0?"none":`pan-${e.drag==="x"?"y":"x"}`),e.tabIndex===void 0&&(e.onTap||e.onTapStart||e.whileTap)&&(n.tabIndex=0),n.style=r,n}function VI(e,t,n,r){const s=b.useMemo(()=>{const i=Lj();return dg(i,t,hg(r),e.transformTemplate),{...i.attrs,style:{...i.style}}},[t]);if(e.style){const i={};Hj(i,e.style,e),s.style={...i,...s.style}}return s}function FI(e=!1){return(n,r,s,{latestValues:i},o)=>{const c=(og(n)?VI:zI)(r,i,o,n),u=nI(r,typeof n=="string",e),d=n!==b.Fragment?{...u,...c,ref:s}:{},{children:f}=r,h=b.useMemo(()=>nt(f)?f.get():f,[f]);return b.createElement(n,{...d,children:h})}}function BI(e,t){return function(r,{forwardMotionProps:s}={forwardMotionProps:!1}){const o={...og(r)?OI:$I,preloadedFeatures:e,useRender:FI(s),createVisualElement:t,Component:r};return dI(o)}}function Uj(e,t){if(!Array.isArray(t))return!1;const n=t.length;if(n!==e.length)return!1;for(let r=0;r<n;r++)if(t[r]!==e[r])return!1;return!0}function rd(e,t,n){const r=e.getProps();return ag(r,t,n!==void 0?n:r.custom,e)}function mg(e,t){return e?e[t]||e.default||e:void 0}const Wj=new Set(["width","height","top","left","right","bottom",...to]);let uc;function HI(){uc=void 0}const Rn={now:()=>(uc===void 0&&Rn.set(qe.isProcessing||XM.useManualTiming?qe.timestamp:performance.now()),uc),set:e=>{uc=e,queueMicrotask(HI)}};function gg(e,t){e.indexOf(t)===-1&&e.push(t)}function vg(e,t){const n=e.indexOf(t);n>-1&&e.splice(n,1)}class yg{constructor(){this.subscriptions=[]}add(t){return gg(this.subscriptions,t),()=>vg(this.subscriptions,t)}notify(t,n,r){const s=this.subscriptions.length;if(s)if(s===1)this.subscriptions[0](t,n,r);else for(let i=0;i<s;i++){const o=this.subscriptions[i];o&&o(t,n,r)}}getSize(){return this.subscriptions.length}clear(){this.subscriptions.length=0}}function Kj(e,t){return t?e*(1e3/t):0}const i0=30,UI=e=>!isNaN(parseFloat(e));class WI{constructor(t,n={}){this.version="11.18.2",this.canTrackVelocity=null,this.events={},this.updateAndNotify=(r,s=!0)=>{const i=Rn.now();this.updatedAt!==i&&this.setPrevFrameValue(),this.prev=this.current,this.setCurrent(r),this.current!==this.prev&&this.events.change&&this.events.change.notify(this.current),s&&this.events.renderRequest&&this.events.renderRequest.notify(this.current)},this.hasAnimated=!1,this.setCurrent(t),this.owner=n.owner}setCurrent(t){this.current=t,this.updatedAt=Rn.now(),this.canTrackVelocity===null&&t!==void 0&&(this.canTrackVelocity=UI(this.current))}setPrevFrameValue(t=this.current){this.prevFrameValue=t,this.prevUpdatedAt=this.updatedAt}onChange(t){return this.on("change",t)}on(t,n){this.events[t]||(this.events[t]=new yg);const r=this.events[t].add(n);return t==="change"?()=>{r(),ke.read(()=>{this.events.change.getSize()||this.stop()})}:r}clearListeners(){for(const t in this.events)this.events[t].clear()}attach(t,n){this.passiveEffect=t,this.stopPassiveEffect=n}set(t,n=!0){!n||!this.passiveEffect?this.updateAndNotify(t,n):this.passiveEffect(t,this.updateAndNotify)}setWithVelocity(t,n,r){this.set(n),this.prev=void 0,this.prevFrameValue=t,this.prevUpdatedAt=this.updatedAt-r}jump(t,n=!0){this.updateAndNotify(t),this.prev=t,this.prevUpdatedAt=this.prevFrameValue=void 0,n&&this.stop(),this.stopPassiveEffect&&this.stopPassiveEffect()}get(){return this.current}getPrevious(){return this.prev}getVelocity(){const t=Rn.now();if(!this.canTrackVelocity||this.prevFrameValue===void 0||t-this.updatedAt>i0)return 0;const n=Math.min(this.updatedAt-this.prevUpdatedAt,i0);return Kj(parseFloat(this.current)-parseFloat(this.prevFrameValue),n)}start(t){return this.stop(),new Promise(n=>{this.hasAnimated=!0,this.animation=t(n),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 _a(e,t){return new WI(e,t)}function KI(e,t,n){e.hasValue(t)?e.getValue(t).set(n):e.addValue(t,_a(n))}function GI(e,t){const n=rd(e,t);let{transitionEnd:r={},transition:s={},...i}=n||{};i={...i,...r};for(const o in i){const l=vI(i[o]);KI(e,o,l)}}function qI(e){return!!(nt(e)&&e.add)}function Zh(e,t){const n=e.getValue("willChange");if(qI(n))return n.add(t)}function Gj(e){return e.props[Tj]}function _g(e){let t;return()=>(t===void 0&&(t=e()),t)}const YI=_g(()=>window.ScrollTimeline!==void 0);class XI{constructor(t){this.stop=()=>this.runAll("stop"),this.animations=t.filter(Boolean)}get finished(){return Promise.all(this.animations.map(t=>"finished"in t?t.finished:t))}getAll(t){return this.animations[0][t]}setAll(t,n){for(let r=0;r<this.animations.length;r++)this.animations[r][t]=n}attachTimeline(t,n){const r=this.animations.map(s=>{if(YI()&&s.attachTimeline)return s.attachTimeline(t);if(typeof n=="function")return n(s)});return()=>{r.forEach((s,i)=>{s&&s(),this.animations[i].stop()})}}get time(){return this.getAll("time")}set time(t){this.setAll("time",t)}get speed(){return this.getAll("speed")}set speed(t){this.setAll("speed",t)}get startTime(){return this.getAll("startTime")}get duration(){let t=0;for(let n=0;n<this.animations.length;n++)t=Math.max(t,this.animations[n].duration);return t}runAll(t){this.animations.forEach(n=>n[t]())}flatten(){this.runAll("flatten")}play(){this.runAll("play")}pause(){this.runAll("pause")}cancel(){this.runAll("cancel")}complete(){this.runAll("complete")}}class QI extends XI{then(t,n){return Promise.all(this.animations).then(t).catch(n)}}const nr=e=>e*1e3,rr=e=>e/1e3;function xg(e){return typeof e=="function"}function o0(e,t){e.timeline=t,e.onfinish=null}const wg=e=>Array.isArray(e)&&typeof e[0]=="number",ZI={linearEasing:void 0};function JI(e,t){const n=_g(e);return()=>{var r;return(r=ZI[t])!==null&&r!==void 0?r:n()}}const su=JI(()=>{try{document.createElement("div").animate({opacity:0},{easing:"linear(0, 1)"})}catch{return!1}return!0},"linearEasing"),zi=(e,t,n)=>{const r=t-e;return r===0?1:(n-e)/r},qj=(e,t,n=10)=>{let r="";const s=Math.max(Math.round(t/n),2);for(let i=0;i<s;i++)r+=e(zi(0,s-1,i))+", ";return`linear(${r.substring(0,r.length-2)})`};function Yj(e){return!!(typeof e=="function"&&su()||!e||typeof e=="string"&&(e in Jh||su())||wg(e)||Array.isArray(e)&&e.every(Yj))}const ko=([e,t,n,r])=>`cubic-bezier(${e}, ${t}, ${n}, ${r})`,Jh={linear:"linear",ease:"ease",easeIn:"ease-in",easeOut:"ease-out",easeInOut:"ease-in-out",circIn:ko([0,.65,.55,1]),circOut:ko([.55,0,1,.45]),backIn:ko([.31,.01,.66,-.59]),backOut:ko([.33,1.53,.69,.99])};function Xj(e,t){if(e)return typeof e=="function"&&su()?qj(e,t):wg(e)?ko(e):Array.isArray(e)?e.map(n=>Xj(n,t)||Jh.easeOut):Jh[e]}const Qj=(e,t,n)=>(((1-3*n+3*t)*e+(3*n-6*t))*e+3*t)*e,eR=1e-7,tR=12;function nR(e,t,n,r,s){let i,o,l=0;do o=t+(n-t)/2,i=Qj(o,r,s)-e,i>0?n=o:t=o;while(Math.abs(i)>eR&&++l<tR);return o}function qa(e,t,n,r){if(e===t&&n===r)return Et;const s=i=>nR(i,0,1,e,n);return i=>i===0||i===1?i:Qj(s(i),t,r)}const Zj=e=>t=>t<=.5?e(2*t)/2:(2-e(2*(1-t)))/2,Jj=e=>t=>1-e(1-t),eS=qa(.33,1.53,.69,.99),bg=Jj(eS),tS=Zj(bg),nS=e=>(e*=2)<1?.5*bg(e):.5*(2-Math.pow(2,-10*(e-1))),jg=e=>1-Math.sin(Math.acos(e)),rS=Jj(jg),sS=Zj(jg),iS=e=>/^0[^.\s]+$/u.test(e);function rR(e){return typeof e=="number"?e===0:e!==null?e==="none"||e==="0"||iS(e):!0}const Uo=e=>Math.round(e*1e5)/1e5,Sg=/-?(?:\d+(?:\.\d+)?|\.\d+)/gu;function sR(e){return e==null}const iR=/^(?:#[\da-f]{3,8}|(?:rgb|hsl)a?\((?:-?[\d.]+%?[,\s]+){2}-?[\d.]+%?\s*(?:[,/]\s*)?(?:\b\d+(?:\.\d+)?|\.\d+)?%?\))$/iu,kg=(e,t)=>n=>!!(typeof n=="string"&&iR.test(n)&&n.startsWith(e)||t&&!sR(n)&&Object.prototype.hasOwnProperty.call(n,t)),oS=(e,t,n)=>r=>{if(typeof r!="string")return r;const[s,i,o,l]=r.match(Sg);return{[e]:parseFloat(s),[t]:parseFloat(i),[n]:parseFloat(o),alpha:l!==void 0?parseFloat(l):1}},oR=e=>dr(0,255,e),of={...no,transform:e=>Math.round(oR(e))},ds={test:kg("rgb","red"),parse:oS("red","green","blue"),transform:({red:e,green:t,blue:n,alpha:r=1})=>"rgba("+of.transform(e)+", "+of.transform(t)+", "+of.transform(n)+", "+Uo(ya.transform(r))+")"};function aR(e){let t="",n="",r="",s="";return e.length>5?(t=e.substring(1,3),n=e.substring(3,5),r=e.substring(5,7),s=e.substring(7,9)):(t=e.substring(1,2),n=e.substring(2,3),r=e.substring(3,4),s=e.substring(4,5),t+=t,n+=n,r+=r,s+=s),{red:parseInt(t,16),green:parseInt(n,16),blue:parseInt(r,16),alpha:s?parseInt(s,16)/255:1}}const ep={test:kg("#"),parse:aR,transform:ds.transform},fi={test:kg("hsl","hue"),parse:oS("hue","saturation","lightness"),transform:({hue:e,saturation:t,lightness:n,alpha:r=1})=>"hsla("+Math.round(e)+", "+In.transform(Uo(t))+", "+In.transform(Uo(n))+", "+Uo(ya.transform(r))+")"},et={test:e=>ds.test(e)||ep.test(e)||fi.test(e),parse:e=>ds.test(e)?ds.parse(e):fi.test(e)?fi.parse(e):ep.parse(e),transform:e=>typeof e=="string"?e:e.hasOwnProperty("red")?ds.transform(e):fi.transform(e)},lR=/(?:#[\da-f]{3,8}|(?:rgb|hsl)a?\((?:-?[\d.]+%?[,\s]+){2}-?[\d.]+%?\s*(?:[,/]\s*)?(?:\b\d+(?:\.\d+)?|\.\d+)?%?\))/giu;function cR(e){var t,n;return isNaN(e)&&typeof e=="string"&&(((t=e.match(Sg))===null||t===void 0?void 0:t.length)||0)+(((n=e.match(lR))===null||n===void 0?void 0:n.length)||0)>0}const aS="number",lS="color",uR="var",dR="var(",a0="${}",fR=/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 xa(e){const t=e.toString(),n=[],r={color:[],number:[],var:[]},s=[];let i=0;const l=t.replace(fR,c=>(et.test(c)?(r.color.push(i),s.push(lS),n.push(et.parse(c))):c.startsWith(dR)?(r.var.push(i),s.push(uR),n.push(c)):(r.number.push(i),s.push(aS),n.push(parseFloat(c))),++i,a0)).split(a0);return{values:n,split:l,indexes:r,types:s}}function cS(e){return xa(e).values}function uS(e){const{split:t,types:n}=xa(e),r=t.length;return s=>{let i="";for(let o=0;o<r;o++)if(i+=t[o],s[o]!==void 0){const l=n[o];l===aS?i+=Uo(s[o]):l===lS?i+=et.transform(s[o]):i+=s[o]}return i}}const hR=e=>typeof e=="number"?0:e;function pR(e){const t=cS(e);return uS(e)(t.map(hR))}const Hr={test:cR,parse:cS,createTransformer:uS,getAnimatableNone:pR},mR=new Set(["brightness","contrast","saturate","opacity"]);function gR(e){const[t,n]=e.slice(0,-1).split("(");if(t==="drop-shadow")return e;const[r]=n.match(Sg)||[];if(!r)return e;const s=n.replace(r,"");let i=mR.has(t)?1:0;return r!==n&&(i*=100),t+"("+i+s+")"}const vR=/\b([a-z-]*)\(.*?\)/gu,tp={...Hr,getAnimatableNone:e=>{const t=e.match(vR);return t?t.map(gR).join(" "):e}},yR={...cg,color:et,backgroundColor:et,outlineColor:et,fill:et,stroke:et,borderColor:et,borderTopColor:et,borderRightColor:et,borderBottomColor:et,borderLeftColor:et,filter:tp,WebkitFilter:tp},Ng=e=>yR[e];function dS(e,t){let n=Ng(e);return n!==tp&&(n=Hr),n.getAnimatableNone?n.getAnimatableNone(t):void 0}const _R=new Set(["auto","none","0"]);function xR(e,t,n){let r=0,s;for(;r<e.length&&!s;){const i=e[r];typeof i=="string"&&!_R.has(i)&&xa(i).values.length&&(s=e[r]),r++}if(s&&n)for(const i of t)e[i]=dS(n,s)}const l0=e=>e===no||e===se,c0=(e,t)=>parseFloat(e.split(", ")[t]),u0=(e,t)=>(n,{transform:r})=>{if(r==="none"||!r)return 0;const s=r.match(/^matrix3d\((.+)\)$/u);if(s)return c0(s[1],t);{const i=r.match(/^matrix\((.+)\)$/u);return i?c0(i[1],e):0}},wR=new Set(["x","y","z"]),bR=to.filter(e=>!wR.has(e));function jR(e){const t=[];return bR.forEach(n=>{const r=e.getValue(n);r!==void 0&&(t.push([n,r.get()]),r.set(n.startsWith("scale")?1:0))}),t}const Vi={width:({x:e},{paddingLeft:t="0",paddingRight:n="0"})=>e.max-e.min-parseFloat(t)-parseFloat(n),height:({y:e},{paddingTop:t="0",paddingBottom:n="0"})=>e.max-e.min-parseFloat(t)-parseFloat(n),top:(e,{top:t})=>parseFloat(t),left:(e,{left:t})=>parseFloat(t),bottom:({y:e},{top:t})=>parseFloat(t)+(e.max-e.min),right:({x:e},{left:t})=>parseFloat(t)+(e.max-e.min),x:u0(4,13),y:u0(5,14)};Vi.translateX=Vi.x;Vi.translateY=Vi.y;const gs=new Set;let np=!1,rp=!1;function fS(){if(rp){const e=Array.from(gs).filter(r=>r.needsMeasurement),t=new Set(e.map(r=>r.element)),n=new Map;t.forEach(r=>{const s=jR(r);s.length&&(n.set(r,s),r.render())}),e.forEach(r=>r.measureInitialState()),t.forEach(r=>{r.render();const s=n.get(r);s&&s.forEach(([i,o])=>{var l;(l=r.getValue(i))===null||l===void 0||l.set(o)})}),e.forEach(r=>r.measureEndState()),e.forEach(r=>{r.suspendedScrollY!==void 0&&window.scrollTo(0,r.suspendedScrollY)})}rp=!1,np=!1,gs.forEach(e=>e.complete()),gs.clear()}function hS(){gs.forEach(e=>{e.readKeyframes(),e.needsMeasurement&&(rp=!0)})}function SR(){hS(),fS()}class Eg{constructor(t,n,r,s,i,o=!1){this.isComplete=!1,this.isAsync=!1,this.needsMeasurement=!1,this.isScheduled=!1,this.unresolvedKeyframes=[...t],this.onComplete=n,this.name=r,this.motionValue=s,this.element=i,this.isAsync=o}scheduleResolve(){this.isScheduled=!0,this.isAsync?(gs.add(this),np||(np=!0,ke.read(hS),ke.resolveKeyframes(fS))):(this.readKeyframes(),this.complete())}readKeyframes(){const{unresolvedKeyframes:t,name:n,element:r,motionValue:s}=this;for(let i=0;i<t.length;i++)if(t[i]===null)if(i===0){const o=s==null?void 0:s.get(),l=t[t.length-1];if(o!==void 0)t[0]=o;else if(r&&n){const c=r.readValue(n,l);c!=null&&(t[0]=c)}t[0]===void 0&&(t[0]=l),s&&o===void 0&&s.set(t[0])}else t[i]=t[i-1]}setFinalKeyframe(){}measureInitialState(){}renderEndStyles(){}measureEndState(){}complete(){this.isComplete=!0,this.onComplete(this.unresolvedKeyframes,this.finalKeyframe),gs.delete(this)}cancel(){this.isComplete||(this.isScheduled=!1,gs.delete(this))}resume(){this.isComplete||this.scheduleResolve()}}const pS=e=>/^-?(?:\d+(?:\.\d+)?|\.\d+)$/u.test(e),kR=/^var\(--(?:([\w-]+)|([\w-]+), ?([a-zA-Z\d ()%#.,-]+))\)/u;function NR(e){const t=kR.exec(e);if(!t)return[,];const[,n,r,s]=t;return[`--${n??r}`,s]}function mS(e,t,n=1){const[r,s]=NR(e);if(!r)return;const i=window.getComputedStyle(t).getPropertyValue(r);if(i){const o=i.trim();return pS(o)?parseFloat(o):o}return lg(s)?mS(s,t,n+1):s}const gS=e=>t=>t.test(e),ER={test:e=>e==="auto",parse:e=>e},vS=[no,se,In,_r,jI,bI,ER],d0=e=>vS.find(gS(e));class yS extends Eg{constructor(t,n,r,s,i){super(t,n,r,s,i,!0)}readKeyframes(){const{unresolvedKeyframes:t,element:n,name:r}=this;if(!n||!n.current)return;super.readKeyframes();for(let c=0;c<t.length;c++){let u=t[c];if(typeof u=="string"&&(u=u.trim(),lg(u))){const d=mS(u,n.current);d!==void 0&&(t[c]=d),c===t.length-1&&(this.finalKeyframe=u)}}if(this.resolveNoneKeyframes(),!Wj.has(r)||t.length!==2)return;const[s,i]=t,o=d0(s),l=d0(i);if(o!==l)if(l0(o)&&l0(l))for(let c=0;c<t.length;c++){const u=t[c];typeof u=="string"&&(t[c]=parseFloat(u))}else this.needsMeasurement=!0}resolveNoneKeyframes(){const{unresolvedKeyframes:t,name:n}=this,r=[];for(let s=0;s<t.length;s++)rR(t[s])&&r.push(s);r.length&&xR(t,r,n)}measureInitialState(){const{element:t,unresolvedKeyframes:n,name:r}=this;if(!t||!t.current)return;r==="height"&&(this.suspendedScrollY=window.pageYOffset),this.measuredOrigin=Vi[r](t.measureViewportBox(),window.getComputedStyle(t.current)),n[0]=this.measuredOrigin;const s=n[n.length-1];s!==void 0&&t.getValue(r,s).jump(s,!1)}measureEndState(){var t;const{element:n,name:r,unresolvedKeyframes:s}=this;if(!n||!n.current)return;const i=n.getValue(r);i&&i.jump(this.measuredOrigin,!1);const o=s.length-1,l=s[o];s[o]=Vi[r](n.measureViewportBox(),window.getComputedStyle(n.current)),l!==null&&this.finalKeyframe===void 0&&(this.finalKeyframe=l),!((t=this.removedTransforms)===null||t===void 0)&&t.length&&this.removedTransforms.forEach(([c,u])=>{n.getValue(c).set(u)}),this.resolveNoneKeyframes()}}const f0=(e,t)=>t==="zIndex"?!1:!!(typeof e=="number"||Array.isArray(e)||typeof e=="string"&&(Hr.test(e)||e==="0")&&!e.startsWith("url("));function CR(e){const t=e[0];if(e.length===1)return!0;for(let n=0;n<e.length;n++)if(e[n]!==t)return!0}function AR(e,t,n,r){const s=e[0];if(s===null)return!1;if(t==="display"||t==="visibility")return!0;const i=e[e.length-1],o=f0(s,t),l=f0(i,t);return!o||!l?!1:CR(e)||(n==="spring"||xg(n))&&r}const TR=e=>e!==null;function sd(e,{repeat:t,repeatType:n="loop"},r){const s=e.filter(TR),i=t&&n!=="loop"&&t%2===1?0:s.length-1;return!i||r===void 0?s[i]:r}const PR=40;class _S{constructor({autoplay:t=!0,delay:n=0,type:r="keyframes",repeat:s=0,repeatDelay:i=0,repeatType:o="loop",...l}){this.isStopped=!1,this.hasAttemptedResolve=!1,this.createdAt=Rn.now(),this.options={autoplay:t,delay:n,type:r,repeat:s,repeatDelay:i,repeatType:o,...l},this.updateFinishedPromise()}calcStartTime(){return this.resolvedAt?this.resolvedAt-this.createdAt>PR?this.resolvedAt:this.createdAt:this.createdAt}get resolved(){return!this._resolved&&!this.hasAttemptedResolve&&SR(),this._resolved}onKeyframesResolved(t,n){this.resolvedAt=Rn.now(),this.hasAttemptedResolve=!0;const{name:r,type:s,velocity:i,delay:o,onComplete:l,onUpdate:c,isGenerator:u}=this.options;if(!u&&!AR(t,r,s,i))if(o)this.options.duration=0;else{c&&c(sd(t,this.options,n)),l&&l(),this.resolveFinishedPromise();return}const d=this.initPlayback(t,n);d!==!1&&(this._resolved={keyframes:t,finalKeyframe:n,...d},this.onPostResolved())}onPostResolved(){}then(t,n){return this.currentFinishedPromise.then(t,n)}flatten(){this.options.type="keyframes",this.options.ease="linear"}updateFinishedPromise(){this.currentFinishedPromise=new Promise(t=>{this.resolveFinishedPromise=t})}}const sp=2e4;function xS(e){let t=0;const n=50;let r=e.next(t);for(;!r.done&&t<sp;)t+=n,r=e.next(t);return t>=sp?1/0:t}const Te=(e,t,n)=>e+(t-e)*n;function af(e,t,n){return n<0&&(n+=1),n>1&&(n-=1),n<1/6?e+(t-e)*6*n:n<1/2?t:n<2/3?e+(t-e)*(2/3-n)*6:e}function MR({hue:e,saturation:t,lightness:n,alpha:r}){e/=360,t/=100,n/=100;let s=0,i=0,o=0;if(!t)s=i=o=n;else{const l=n<.5?n*(1+t):n+t-n*t,c=2*n-l;s=af(c,l,e+1/3),i=af(c,l,e),o=af(c,l,e-1/3)}return{red:Math.round(s*255),green:Math.round(i*255),blue:Math.round(o*255),alpha:r}}function iu(e,t){return n=>n>0?t:e}const lf=(e,t,n)=>{const r=e*e,s=n*(t*t-r)+r;return s<0?0:Math.sqrt(s)},IR=[ep,ds,fi],RR=e=>IR.find(t=>t.test(e));function h0(e){const t=RR(e);if(!t)return!1;let n=t.parse(e);return t===fi&&(n=MR(n)),n}const p0=(e,t)=>{const n=h0(e),r=h0(t);if(!n||!r)return iu(e,t);const s={...n};return i=>(s.red=lf(n.red,r.red,i),s.green=lf(n.green,r.green,i),s.blue=lf(n.blue,r.blue,i),s.alpha=Te(n.alpha,r.alpha,i),ds.transform(s))},OR=(e,t)=>n=>t(e(n)),Ya=(...e)=>e.reduce(OR),ip=new Set(["none","hidden"]);function $R(e,t){return ip.has(e)?n=>n<=0?e:t:n=>n>=1?t:e}function LR(e,t){return n=>Te(e,t,n)}function Cg(e){return typeof e=="number"?LR:typeof e=="string"?lg(e)?iu:et.test(e)?p0:VR:Array.isArray(e)?wS:typeof e=="object"?et.test(e)?p0:DR:iu}function wS(e,t){const n=[...e],r=n.length,s=e.map((i,o)=>Cg(i)(i,t[o]));return i=>{for(let o=0;o<r;o++)n[o]=s[o](i);return n}}function DR(e,t){const n={...e,...t},r={};for(const s in n)e[s]!==void 0&&t[s]!==void 0&&(r[s]=Cg(e[s])(e[s],t[s]));return s=>{for(const i in r)n[i]=r[i](s);return n}}function zR(e,t){var n;const r=[],s={color:0,var:0,number:0};for(let i=0;i<t.values.length;i++){const o=t.types[i],l=e.indexes[o][s[o]],c=(n=e.values[l])!==null&&n!==void 0?n:0;r[i]=c,s[o]++}return r}const VR=(e,t)=>{const n=Hr.createTransformer(t),r=xa(e),s=xa(t);return r.indexes.var.length===s.indexes.var.length&&r.indexes.color.length===s.indexes.color.length&&r.indexes.number.length>=s.indexes.number.length?ip.has(e)&&!s.values.length||ip.has(t)&&!r.values.length?$R(e,t):Ya(wS(zR(r,s),s.values),n):iu(e,t)};function bS(e,t,n){return typeof e=="number"&&typeof t=="number"&&typeof n=="number"?Te(e,t,n):Cg(e)(e,t)}const FR=5;function jS(e,t,n){const r=Math.max(t-FR,0);return Kj(n-e(r),t-r)}const Oe={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},cf=.001;function BR({duration:e=Oe.duration,bounce:t=Oe.bounce,velocity:n=Oe.velocity,mass:r=Oe.mass}){let s,i,o=1-t;o=dr(Oe.minDamping,Oe.maxDamping,o),e=dr(Oe.minDuration,Oe.maxDuration,rr(e)),o<1?(s=u=>{const d=u*o,f=d*e,h=d-n,p=op(u,o),v=Math.exp(-f);return cf-h/p*v},i=u=>{const f=u*o*e,h=f*n+n,p=Math.pow(o,2)*Math.pow(u,2)*e,v=Math.exp(-f),x=op(Math.pow(u,2),o);return(-s(u)+cf>0?-1:1)*((h-p)*v)/x}):(s=u=>{const d=Math.exp(-u*e),f=(u-n)*e+1;return-cf+d*f},i=u=>{const d=Math.exp(-u*e),f=(n-u)*(e*e);return d*f});const l=5/e,c=UR(s,i,l);if(e=nr(e),isNaN(c))return{stiffness:Oe.stiffness,damping:Oe.damping,duration:e};{const u=Math.pow(c,2)*r;return{stiffness:u,damping:o*2*Math.sqrt(r*u),duration:e}}}const HR=12;function UR(e,t,n){let r=n;for(let s=1;s<HR;s++)r=r-e(r)/t(r);return r}function op(e,t){return e*Math.sqrt(1-t*t)}const WR=["duration","bounce"],KR=["stiffness","damping","mass"];function m0(e,t){return t.some(n=>e[n]!==void 0)}function GR(e){let t={velocity:Oe.velocity,stiffness:Oe.stiffness,damping:Oe.damping,mass:Oe.mass,isResolvedFromDuration:!1,...e};if(!m0(e,KR)&&m0(e,WR))if(e.visualDuration){const n=e.visualDuration,r=2*Math.PI/(n*1.2),s=r*r,i=2*dr(.05,1,1-(e.bounce||0))*Math.sqrt(s);t={...t,mass:Oe.mass,stiffness:s,damping:i}}else{const n=BR(e);t={...t,...n,mass:Oe.mass},t.isResolvedFromDuration=!0}return t}function SS(e=Oe.visualDuration,t=Oe.bounce){const n=typeof e!="object"?{visualDuration:e,keyframes:[0,1],bounce:t}:e;let{restSpeed:r,restDelta:s}=n;const i=n.keyframes[0],o=n.keyframes[n.keyframes.length-1],l={done:!1,value:i},{stiffness:c,damping:u,mass:d,duration:f,velocity:h,isResolvedFromDuration:p}=GR({...n,velocity:-rr(n.velocity||0)}),v=h||0,x=u/(2*Math.sqrt(c*d)),w=o-i,g=rr(Math.sqrt(c/d)),y=Math.abs(w)<5;r||(r=y?Oe.restSpeed.granular:Oe.restSpeed.default),s||(s=y?Oe.restDelta.granular:Oe.restDelta.default);let m;if(x<1){const j=op(g,x);m=N=>{const k=Math.exp(-x*g*N);return o-k*((v+x*g*w)/j*Math.sin(j*N)+w*Math.cos(j*N))}}else if(x===1)m=j=>o-Math.exp(-g*j)*(w+(v+g*w)*j);else{const j=g*Math.sqrt(x*x-1);m=N=>{const k=Math.exp(-x*g*N),S=Math.min(j*N,300);return o-k*((v+x*g*w)*Math.sinh(S)+j*w*Math.cosh(S))/j}}const _={calculatedDuration:p&&f||null,next:j=>{const N=m(j);if(p)l.done=j>=f;else{let k=0;x<1&&(k=j===0?nr(v):jS(m,j,N));const S=Math.abs(k)<=r,P=Math.abs(o-N)<=s;l.done=S&&P}return l.value=l.done?o:N,l},toString:()=>{const j=Math.min(xS(_),sp),N=qj(k=>_.next(j*k).value,j,30);return j+"ms "+N}};return _}function g0({keyframes:e,velocity:t=0,power:n=.8,timeConstant:r=325,bounceDamping:s=10,bounceStiffness:i=500,modifyTarget:o,min:l,max:c,restDelta:u=.5,restSpeed:d}){const f=e[0],h={done:!1,value:f},p=S=>l!==void 0&&S<l||c!==void 0&&S>c,v=S=>l===void 0?c:c===void 0||Math.abs(l-S)<Math.abs(c-S)?l:c;let x=n*t;const w=f+x,g=o===void 0?w:o(w);g!==w&&(x=g-f);const y=S=>-x*Math.exp(-S/r),m=S=>g+y(S),_=S=>{const P=y(S),$=m(S);h.done=Math.abs(P)<=u,h.value=h.done?g:$};let j,N;const k=S=>{p(h.value)&&(j=S,N=SS({keyframes:[h.value,v(h.value)],velocity:jS(m,S,h.value),damping:s,stiffness:i,restDelta:u,restSpeed:d}))};return k(0),{calculatedDuration:null,next:S=>{let P=!1;return!N&&j===void 0&&(P=!0,_(S),k(S)),j!==void 0&&S>=j?N.next(S-j):(!P&&_(S),h)}}}const qR=qa(.42,0,1,1),YR=qa(0,0,.58,1),kS=qa(.42,0,.58,1),XR=e=>Array.isArray(e)&&typeof e[0]!="number",QR={linear:Et,easeIn:qR,easeInOut:kS,easeOut:YR,circIn:jg,circInOut:sS,circOut:rS,backIn:bg,backInOut:tS,backOut:eS,anticipate:nS},v0=e=>{if(wg(e)){kj(e.length===4);const[t,n,r,s]=e;return qa(t,n,r,s)}else if(typeof e=="string")return QR[e];return e};function ZR(e,t,n){const r=[],s=n||bS,i=e.length-1;for(let o=0;o<i;o++){let l=s(e[o],e[o+1]);if(t){const c=Array.isArray(t)?t[o]||Et:t;l=Ya(c,l)}r.push(l)}return r}function JR(e,t,{clamp:n=!0,ease:r,mixer:s}={}){const i=e.length;if(kj(i===t.length),i===1)return()=>t[0];if(i===2&&t[0]===t[1])return()=>t[1];const o=e[0]===e[1];e[0]>e[i-1]&&(e=[...e].reverse(),t=[...t].reverse());const l=ZR(t,r,s),c=l.length,u=d=>{if(o&&d<e[0])return t[0];let f=0;if(c>1)for(;f<e.length-2&&!(d<e[f+1]);f++);const h=zi(e[f],e[f+1],d);return l[f](h)};return n?d=>u(dr(e[0],e[i-1],d)):u}function eO(e,t){const n=e[e.length-1];for(let r=1;r<=t;r++){const s=zi(0,t,r);e.push(Te(n,1,s))}}function tO(e){const t=[0];return eO(t,e.length-1),t}function nO(e,t){return e.map(n=>n*t)}function rO(e,t){return e.map(()=>t||kS).splice(0,e.length-1)}function ou({duration:e=300,keyframes:t,times:n,ease:r="easeInOut"}){const s=XR(r)?r.map(v0):v0(r),i={done:!1,value:t[0]},o=nO(n&&n.length===t.length?n:tO(t),e),l=JR(o,t,{ease:Array.isArray(s)?s:rO(t,s)});return{calculatedDuration:e,next:c=>(i.value=l(c),i.done=c>=e,i)}}const sO=e=>{const t=({timestamp:n})=>e(n);return{start:()=>ke.update(t,!0),stop:()=>Br(t),now:()=>qe.isProcessing?qe.timestamp:Rn.now()}},iO={decay:g0,inertia:g0,tween:ou,keyframes:ou,spring:SS},oO=e=>e/100;class Ag extends _S{constructor(t){super(t),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:c}=this.options;c&&c()};const{name:n,motionValue:r,element:s,keyframes:i}=this.options,o=(s==null?void 0:s.KeyframeResolver)||Eg,l=(c,u)=>this.onKeyframesResolved(c,u);this.resolver=new o(i,l,n,r,s),this.resolver.scheduleResolve()}flatten(){super.flatten(),this._resolved&&Object.assign(this._resolved,this.initPlayback(this._resolved.keyframes))}initPlayback(t){const{type:n="keyframes",repeat:r=0,repeatDelay:s=0,repeatType:i,velocity:o=0}=this.options,l=xg(n)?n:iO[n]||ou;let c,u;l!==ou&&typeof t[0]!="number"&&(c=Ya(oO,bS(t[0],t[1])),t=[0,100]);const d=l({...this.options,keyframes:t});i==="mirror"&&(u=l({...this.options,keyframes:[...t].reverse(),velocity:-o})),d.calculatedDuration===null&&(d.calculatedDuration=xS(d));const{calculatedDuration:f}=d,h=f+s,p=h*(r+1)-s;return{generator:d,mirroredGenerator:u,mapPercentToKeyframes:c,calculatedDuration:f,resolvedDuration:h,totalDuration:p}}onPostResolved(){const{autoplay:t=!0}=this.options;this.play(),this.pendingPlayState==="paused"||!t?this.pause():this.state=this.pendingPlayState}tick(t,n=!1){const{resolved:r}=this;if(!r){const{keyframes:S}=this.options;return{done:!0,value:S[S.length-1]}}const{finalKeyframe:s,generator:i,mirroredGenerator:o,mapPercentToKeyframes:l,keyframes:c,calculatedDuration:u,totalDuration:d,resolvedDuration:f}=r;if(this.startTime===null)return i.next(0);const{delay:h,repeat:p,repeatType:v,repeatDelay:x,onUpdate:w}=this.options;this.speed>0?this.startTime=Math.min(this.startTime,t):this.speed<0&&(this.startTime=Math.min(t-d/this.speed,this.startTime)),n?this.currentTime=t:this.holdTime!==null?this.currentTime=this.holdTime:this.currentTime=Math.round(t-this.startTime)*this.speed;const g=this.currentTime-h*(this.speed>=0?1:-1),y=this.speed>=0?g<0:g>d;this.currentTime=Math.max(g,0),this.state==="finished"&&this.holdTime===null&&(this.currentTime=d);let m=this.currentTime,_=i;if(p){const S=Math.min(this.currentTime,d)/f;let P=Math.floor(S),$=S%1;!$&&S>=1&&($=1),$===1&&P--,P=Math.min(P,p+1),!!(P%2)&&(v==="reverse"?($=1-$,x&&($-=x/f)):v==="mirror"&&(_=o)),m=dr(0,1,$)*f}const j=y?{done:!1,value:c[0]}:_.next(m);l&&(j.value=l(j.value));let{done:N}=j;!y&&u!==null&&(N=this.speed>=0?this.currentTime>=d:this.currentTime<=0);const k=this.holdTime===null&&(this.state==="finished"||this.state==="running"&&N);return k&&s!==void 0&&(j.value=sd(c,this.options,s)),w&&w(j.value),k&&this.finish(),j}get duration(){const{resolved:t}=this;return t?rr(t.calculatedDuration):0}get time(){return rr(this.currentTime)}set time(t){t=nr(t),this.currentTime=t,this.holdTime!==null||this.speed===0?this.holdTime=t:this.driver&&(this.startTime=this.driver.now()-t/this.speed)}get speed(){return this.playbackSpeed}set speed(t){const n=this.playbackSpeed!==t;this.playbackSpeed=t,n&&(this.time=rr(this.currentTime))}play(){if(this.resolver.isScheduled||this.resolver.resume(),!this._resolved){this.pendingPlayState="running";return}if(this.isStopped)return;const{driver:t=sO,onPlay:n,startTime:r}=this.options;this.driver||(this.driver=t(i=>this.tick(i))),n&&n();const s=this.driver.now();this.holdTime!==null?this.startTime=s-this.holdTime:this.startTime?this.state==="finished"&&(this.startTime=s):this.startTime=r??this.calcStartTime(),this.state==="finished"&&this.updateFinishedPromise(),this.cancelTime=this.startTime,this.holdTime=null,this.state="running",this.driver.start()}pause(){var t;if(!this._resolved){this.pendingPlayState="paused";return}this.state="paused",this.holdTime=(t=this.currentTime)!==null&&t!==void 0?t:0}complete(){this.state!=="running"&&this.play(),this.pendingPlayState=this.state="finished",this.holdTime=null}finish(){this.teardown(),this.state="finished";const{onComplete:t}=this.options;t&&t()}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(t){return this.startTime=0,this.tick(t,!0)}}const aO=new Set(["opacity","clipPath","filter","transform"]);function lO(e,t,n,{delay:r=0,duration:s=300,repeat:i=0,repeatType:o="loop",ease:l="easeInOut",times:c}={}){const u={[t]:n};c&&(u.offset=c);const d=Xj(l,s);return Array.isArray(d)&&(u.easing=d),e.animate(u,{delay:r,duration:s,easing:Array.isArray(d)?"linear":d,fill:"both",iterations:i+1,direction:o==="reverse"?"alternate":"normal"})}const cO=_g(()=>Object.hasOwnProperty.call(Element.prototype,"animate")),au=10,uO=2e4;function dO(e){return xg(e.type)||e.type==="spring"||!Yj(e.ease)}function fO(e,t){const n=new Ag({...t,keyframes:e,repeat:0,delay:0,isGenerator:!0});let r={done:!1,value:e[0]};const s=[];let i=0;for(;!r.done&&i<uO;)r=n.sample(i),s.push(r.value),i+=au;return{times:void 0,keyframes:s,duration:i-au,ease:"linear"}}const NS={anticipate:nS,backInOut:tS,circInOut:sS};function hO(e){return e in NS}class y0 extends _S{constructor(t){super(t);const{name:n,motionValue:r,element:s,keyframes:i}=this.options;this.resolver=new yS(i,(o,l)=>this.onKeyframesResolved(o,l),n,r,s),this.resolver.scheduleResolve()}initPlayback(t,n){let{duration:r=300,times:s,ease:i,type:o,motionValue:l,name:c,startTime:u}=this.options;if(!l.owner||!l.owner.current)return!1;if(typeof i=="string"&&su()&&hO(i)&&(i=NS[i]),dO(this.options)){const{onComplete:f,onUpdate:h,motionValue:p,element:v,...x}=this.options,w=fO(t,x);t=w.keyframes,t.length===1&&(t[1]=t[0]),r=w.duration,s=w.times,i=w.ease,o="keyframes"}const d=lO(l.owner.current,c,t,{...this.options,duration:r,times:s,ease:i});return d.startTime=u??this.calcStartTime(),this.pendingTimeline?(o0(d,this.pendingTimeline),this.pendingTimeline=void 0):d.onfinish=()=>{const{onComplete:f}=this.options;l.set(sd(t,this.options,n)),f&&f(),this.cancel(),this.resolveFinishedPromise()},{animation:d,duration:r,times:s,type:o,ease:i,keyframes:t}}get duration(){const{resolved:t}=this;if(!t)return 0;const{duration:n}=t;return rr(n)}get time(){const{resolved:t}=this;if(!t)return 0;const{animation:n}=t;return rr(n.currentTime||0)}set time(t){const{resolved:n}=this;if(!n)return;const{animation:r}=n;r.currentTime=nr(t)}get speed(){const{resolved:t}=this;if(!t)return 1;const{animation:n}=t;return n.playbackRate}set speed(t){const{resolved:n}=this;if(!n)return;const{animation:r}=n;r.playbackRate=t}get state(){const{resolved:t}=this;if(!t)return"idle";const{animation:n}=t;return n.playState}get startTime(){const{resolved:t}=this;if(!t)return null;const{animation:n}=t;return n.startTime}attachTimeline(t){if(!this._resolved)this.pendingTimeline=t;else{const{resolved:n}=this;if(!n)return Et;const{animation:r}=n;o0(r,t)}return Et}play(){if(this.isStopped)return;const{resolved:t}=this;if(!t)return;const{animation:n}=t;n.playState==="finished"&&this.updateFinishedPromise(),n.play()}pause(){const{resolved:t}=this;if(!t)return;const{animation:n}=t;n.pause()}stop(){if(this.resolver.cancel(),this.isStopped=!0,this.state==="idle")return;this.resolveFinishedPromise(),this.updateFinishedPromise();const{resolved:t}=this;if(!t)return;const{animation:n,keyframes:r,duration:s,type:i,ease:o,times:l}=t;if(n.playState==="idle"||n.playState==="finished")return;if(this.time){const{motionValue:u,onUpdate:d,onComplete:f,element:h,...p}=this.options,v=new Ag({...p,keyframes:r,duration:s,type:i,ease:o,times:l,isGenerator:!0}),x=nr(this.time);u.setWithVelocity(v.sample(x-au).value,v.sample(x).value,au)}const{onStop:c}=this.options;c&&c(),this.cancel()}complete(){const{resolved:t}=this;t&&t.animation.finish()}cancel(){const{resolved:t}=this;t&&t.animation.cancel()}static supports(t){const{motionValue:n,name:r,repeatDelay:s,repeatType:i,damping:o,type:l}=t;if(!n||!n.owner||!(n.owner.current instanceof HTMLElement))return!1;const{onUpdate:c,transformTemplate:u}=n.owner.getProps();return cO()&&r&&aO.has(r)&&!c&&!u&&!s&&i!=="mirror"&&o!==0&&l!=="inertia"}}const pO={type:"spring",stiffness:500,damping:25,restSpeed:10},mO=e=>({type:"spring",stiffness:550,damping:e===0?2*Math.sqrt(550):30,restSpeed:10}),gO={type:"keyframes",duration:.8},vO={type:"keyframes",ease:[.25,.1,.35,1],duration:.3},yO=(e,{keyframes:t})=>t.length>2?gO:Fs.has(e)?e.startsWith("scale")?mO(t[1]):pO:vO;function _O({when:e,delay:t,delayChildren:n,staggerChildren:r,staggerDirection:s,repeat:i,repeatType:o,repeatDelay:l,from:c,elapsed:u,...d}){return!!Object.keys(d).length}const Tg=(e,t,n,r={},s,i)=>o=>{const l=mg(r,e)||{},c=l.delay||r.delay||0;let{elapsed:u=0}=r;u=u-nr(c);let d={keyframes:Array.isArray(n)?n:[null,n],ease:"easeOut",velocity:t.getVelocity(),...l,delay:-u,onUpdate:h=>{t.set(h),l.onUpdate&&l.onUpdate(h)},onComplete:()=>{o(),l.onComplete&&l.onComplete()},name:e,motionValue:t,element:i?void 0:s};_O(l)||(d={...d,...yO(e,d)}),d.duration&&(d.duration=nr(d.duration)),d.repeatDelay&&(d.repeatDelay=nr(d.repeatDelay)),d.from!==void 0&&(d.keyframes[0]=d.from);let f=!1;if((d.type===!1||d.duration===0&&!d.repeatDelay)&&(d.duration=0,d.delay===0&&(f=!0)),f&&!i&&t.get()!==void 0){const h=sd(d.keyframes,l);if(h!==void 0)return ke.update(()=>{d.onUpdate(h),d.onComplete()}),new QI([])}return!i&&y0.supports(d)?new y0(d):new Ag(d)};function xO({protectedKeys:e,needsAnimating:t},n){const r=e.hasOwnProperty(n)&&t[n]!==!0;return t[n]=!1,r}function ES(e,t,{delay:n=0,transitionOverride:r,type:s}={}){var i;let{transition:o=e.getDefaultTransition(),transitionEnd:l,...c}=t;r&&(o=r);const u=[],d=s&&e.animationState&&e.animationState.getState()[s];for(const f in c){const h=e.getValue(f,(i=e.latestValues[f])!==null&&i!==void 0?i:null),p=c[f];if(p===void 0||d&&xO(d,f))continue;const v={delay:n,...mg(o||{},f)};let x=!1;if(window.MotionHandoffAnimation){const g=Gj(e);if(g){const y=window.MotionHandoffAnimation(g,f,ke);y!==null&&(v.startTime=y,x=!0)}}Zh(e,f),h.start(Tg(f,h,p,e.shouldReduceMotion&&Wj.has(f)?{type:!1}:v,e,x));const w=h.animation;w&&u.push(w)}return l&&Promise.all(u).then(()=>{ke.update(()=>{l&&GI(e,l)})}),u}function ap(e,t,n={}){var r;const s=rd(e,t,n.type==="exit"?(r=e.presenceContext)===null||r===void 0?void 0:r.custom:void 0);let{transition:i=e.getDefaultTransition()||{}}=s||{};n.transitionOverride&&(i=n.transitionOverride);const o=s?()=>Promise.all(ES(e,s,n)):()=>Promise.resolve(),l=e.variantChildren&&e.variantChildren.size?(u=0)=>{const{delayChildren:d=0,staggerChildren:f,staggerDirection:h}=i;return wO(e,t,d+u,f,h,n)}:()=>Promise.resolve(),{when:c}=i;if(c){const[u,d]=c==="beforeChildren"?[o,l]:[l,o];return u().then(()=>d())}else return Promise.all([o(),l(n.delay)])}function wO(e,t,n=0,r=0,s=1,i){const o=[],l=(e.variantChildren.size-1)*r,c=s===1?(u=0)=>u*r:(u=0)=>l-u*r;return Array.from(e.variantChildren).sort(bO).forEach((u,d)=>{u.notify("AnimationStart",t),o.push(ap(u,t,{...i,delay:n+c(d)}).then(()=>u.notify("AnimationComplete",t)))}),Promise.all(o)}function bO(e,t){return e.sortNodePosition(t)}function jO(e,t,n={}){e.notify("AnimationStart",t);let r;if(Array.isArray(t)){const s=t.map(i=>ap(e,i,n));r=Promise.all(s)}else if(typeof t=="string")r=ap(e,t,n);else{const s=typeof t=="function"?rd(e,t,n.custom):t;r=Promise.all(ES(e,s,n))}return r.then(()=>{e.notify("AnimationComplete",t)})}const SO=rg.length;function CS(e){if(!e)return;if(!e.isControllingVariants){const n=e.parent?CS(e.parent)||{}:{};return e.props.initial!==void 0&&(n.initial=e.props.initial),n}const t={};for(let n=0;n<SO;n++){const r=rg[n],s=e.props[r];(va(s)||s===!1)&&(t[r]=s)}return t}const kO=[...ng].reverse(),NO=ng.length;function EO(e){return t=>Promise.all(t.map(({animation:n,options:r})=>jO(e,n,r)))}function CO(e){let t=EO(e),n=_0(),r=!0;const s=c=>(u,d)=>{var f;const h=rd(e,d,c==="exit"?(f=e.presenceContext)===null||f===void 0?void 0:f.custom:void 0);if(h){const{transition:p,transitionEnd:v,...x}=h;u={...u,...x,...v}}return u};function i(c){t=c(e)}function o(c){const{props:u}=e,d=CS(e.parent)||{},f=[],h=new Set;let p={},v=1/0;for(let w=0;w<NO;w++){const g=kO[w],y=n[g],m=u[g]!==void 0?u[g]:d[g],_=va(m),j=g===c?y.isActive:null;j===!1&&(v=w);let N=m===d[g]&&m!==u[g]&&_;if(N&&r&&e.manuallyAnimateOnMount&&(N=!1),y.protectedKeys={...p},!y.isActive&&j===null||!m&&!y.prevProp||td(m)||typeof m=="boolean")continue;const k=AO(y.prevProp,m);let S=k||g===c&&y.isActive&&!N&&_||w>v&&_,P=!1;const $=Array.isArray(m)?m:[m];let D=$.reduce(s(g),{});j===!1&&(D={});const{prevResolvedValues:I={}}=y,O={...I,...D},E=M=>{S=!0,h.has(M)&&(P=!0,h.delete(M)),y.needsAnimating[M]=!0;const T=e.getValue(M);T&&(T.liveStyle=!1)};for(const M in O){const T=D[M],R=I[M];if(p.hasOwnProperty(M))continue;let B=!1;Qh(T)&&Qh(R)?B=!Uj(T,R):B=T!==R,B?T!=null?E(M):h.add(M):T!==void 0&&h.has(M)?E(M):y.protectedKeys[M]=!0}y.prevProp=m,y.prevResolvedValues=D,y.isActive&&(p={...p,...D}),r&&e.blockInitialAnimation&&(S=!1),S&&(!(N&&k)||P)&&f.push(...$.map(M=>({animation:M,options:{type:g}})))}if(h.size){const w={};h.forEach(g=>{const y=e.getBaseTarget(g),m=e.getValue(g);m&&(m.liveStyle=!0),w[g]=y??null}),f.push({animation:w})}let x=!!f.length;return r&&(u.initial===!1||u.initial===u.animate)&&!e.manuallyAnimateOnMount&&(x=!1),r=!1,x?t(f):Promise.resolve()}function l(c,u){var d;if(n[c].isActive===u)return Promise.resolve();(d=e.variantChildren)===null||d===void 0||d.forEach(h=>{var p;return(p=h.animationState)===null||p===void 0?void 0:p.setActive(c,u)}),n[c].isActive=u;const f=o(c);for(const h in n)n[h].protectedKeys={};return f}return{animateChanges:o,setActive:l,setAnimateFunction:i,getState:()=>n,reset:()=>{n=_0(),r=!0}}}function AO(e,t){return typeof t=="string"?t!==e:Array.isArray(t)?!Uj(t,e):!1}function Jr(e=!1){return{isActive:e,protectedKeys:{},needsAnimating:{},prevResolvedValues:{}}}function _0(){return{animate:Jr(!0),whileInView:Jr(),whileHover:Jr(),whileTap:Jr(),whileDrag:Jr(),whileFocus:Jr(),exit:Jr()}}class Yr{constructor(t){this.isMounted=!1,this.node=t}update(){}}class TO extends Yr{constructor(t){super(t),t.animationState||(t.animationState=CO(t))}updateAnimationControlsSubscription(){const{animate:t}=this.node.getProps();td(t)&&(this.unmountControls=t.subscribe(this.node))}mount(){this.updateAnimationControlsSubscription()}update(){const{animate:t}=this.node.getProps(),{animate:n}=this.node.prevProps||{};t!==n&&this.updateAnimationControlsSubscription()}unmount(){var t;this.node.animationState.reset(),(t=this.unmountControls)===null||t===void 0||t.call(this)}}let PO=0;class MO extends Yr{constructor(){super(...arguments),this.id=PO++}update(){if(!this.node.presenceContext)return;const{isPresent:t,onExitComplete:n}=this.node.presenceContext,{isPresent:r}=this.node.prevPresenceContext||{};if(!this.node.animationState||t===r)return;const s=this.node.animationState.setActive("exit",!t);n&&!t&&s.then(()=>n(this.id))}mount(){const{register:t}=this.node.presenceContext||{};t&&(this.unmount=t(this.id))}unmount(){}}const IO={animation:{Feature:TO},exit:{Feature:MO}},Zt={x:!1,y:!1};function AS(){return Zt.x||Zt.y}function RO(e){return e==="x"||e==="y"?Zt[e]?null:(Zt[e]=!0,()=>{Zt[e]=!1}):Zt.x||Zt.y?null:(Zt.x=Zt.y=!0,()=>{Zt.x=Zt.y=!1})}const Pg=e=>e.pointerType==="mouse"?typeof e.button!="number"||e.button<=0:e.isPrimary!==!1;function wa(e,t,n,r={passive:!0}){return e.addEventListener(t,n,r),()=>e.removeEventListener(t,n)}function Xa(e){return{point:{x:e.pageX,y:e.pageY}}}const OO=e=>t=>Pg(t)&&e(t,Xa(t));function Wo(e,t,n,r){return wa(e,t,OO(n),r)}const x0=(e,t)=>Math.abs(e-t);function $O(e,t){const n=x0(e.x,t.x),r=x0(e.y,t.y);return Math.sqrt(n**2+r**2)}class TS{constructor(t,n,{transformPagePoint:r,contextWindow:s,dragSnapToOrigin:i=!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 f=df(this.lastMoveEventInfo,this.history),h=this.startEvent!==null,p=$O(f.offset,{x:0,y:0})>=3;if(!h&&!p)return;const{point:v}=f,{timestamp:x}=qe;this.history.push({...v,timestamp:x});const{onStart:w,onMove:g}=this.handlers;h||(w&&w(this.lastMoveEvent,f),this.startEvent=this.lastMoveEvent),g&&g(this.lastMoveEvent,f)},this.handlePointerMove=(f,h)=>{this.lastMoveEvent=f,this.lastMoveEventInfo=uf(h,this.transformPagePoint),ke.update(this.updatePoint,!0)},this.handlePointerUp=(f,h)=>{this.end();const{onEnd:p,onSessionEnd:v,resumeAnimation:x}=this.handlers;if(this.dragSnapToOrigin&&x&&x(),!(this.lastMoveEvent&&this.lastMoveEventInfo))return;const w=df(f.type==="pointercancel"?this.lastMoveEventInfo:uf(h,this.transformPagePoint),this.history);this.startEvent&&p&&p(f,w),v&&v(f,w)},!Pg(t))return;this.dragSnapToOrigin=i,this.handlers=n,this.transformPagePoint=r,this.contextWindow=s||window;const o=Xa(t),l=uf(o,this.transformPagePoint),{point:c}=l,{timestamp:u}=qe;this.history=[{...c,timestamp:u}];const{onSessionStart:d}=n;d&&d(t,df(l,this.history)),this.removeListeners=Ya(Wo(this.contextWindow,"pointermove",this.handlePointerMove),Wo(this.contextWindow,"pointerup",this.handlePointerUp),Wo(this.contextWindow,"pointercancel",this.handlePointerUp))}updateHandlers(t){this.handlers=t}end(){this.removeListeners&&this.removeListeners(),Br(this.updatePoint)}}function uf(e,t){return t?{point:t(e.point)}:e}function w0(e,t){return{x:e.x-t.x,y:e.y-t.y}}function df({point:e},t){return{point:e,delta:w0(e,PS(t)),offset:w0(e,LO(t)),velocity:DO(t,.1)}}function LO(e){return e[0]}function PS(e){return e[e.length-1]}function DO(e,t){if(e.length<2)return{x:0,y:0};let n=e.length-1,r=null;const s=PS(e);for(;n>=0&&(r=e[n],!(s.timestamp-r.timestamp>nr(t)));)n--;if(!r)return{x:0,y:0};const i=rr(s.timestamp-r.timestamp);if(i===0)return{x:0,y:0};const o={x:(s.x-r.x)/i,y:(s.y-r.y)/i};return o.x===1/0&&(o.x=0),o.y===1/0&&(o.y=0),o}const MS=1e-4,zO=1-MS,VO=1+MS,IS=.01,FO=0-IS,BO=0+IS;function At(e){return e.max-e.min}function HO(e,t,n){return Math.abs(e-t)<=n}function b0(e,t,n,r=.5){e.origin=r,e.originPoint=Te(t.min,t.max,e.origin),e.scale=At(n)/At(t),e.translate=Te(n.min,n.max,e.origin)-e.originPoint,(e.scale>=zO&&e.scale<=VO||isNaN(e.scale))&&(e.scale=1),(e.translate>=FO&&e.translate<=BO||isNaN(e.translate))&&(e.translate=0)}function Ko(e,t,n,r){b0(e.x,t.x,n.x,r?r.originX:void 0),b0(e.y,t.y,n.y,r?r.originY:void 0)}function j0(e,t,n){e.min=n.min+t.min,e.max=e.min+At(t)}function UO(e,t,n){j0(e.x,t.x,n.x),j0(e.y,t.y,n.y)}function S0(e,t,n){e.min=t.min-n.min,e.max=e.min+At(t)}function Go(e,t,n){S0(e.x,t.x,n.x),S0(e.y,t.y,n.y)}function WO(e,{min:t,max:n},r){return t!==void 0&&e<t?e=r?Te(t,e,r.min):Math.max(e,t):n!==void 0&&e>n&&(e=r?Te(n,e,r.max):Math.min(e,n)),e}function k0(e,t,n){return{min:t!==void 0?e.min+t:void 0,max:n!==void 0?e.max+n-(e.max-e.min):void 0}}function KO(e,{top:t,left:n,bottom:r,right:s}){return{x:k0(e.x,n,s),y:k0(e.y,t,r)}}function N0(e,t){let n=t.min-e.min,r=t.max-e.max;return t.max-t.min<e.max-e.min&&([n,r]=[r,n]),{min:n,max:r}}function GO(e,t){return{x:N0(e.x,t.x),y:N0(e.y,t.y)}}function qO(e,t){let n=.5;const r=At(e),s=At(t);return s>r?n=zi(t.min,t.max-r,e.min):r>s&&(n=zi(e.min,e.max-s,t.min)),dr(0,1,n)}function YO(e,t){const n={};return t.min!==void 0&&(n.min=t.min-e.min),t.max!==void 0&&(n.max=t.max-e.min),n}const lp=.35;function XO(e=lp){return e===!1?e=0:e===!0&&(e=lp),{x:E0(e,"left","right"),y:E0(e,"top","bottom")}}function E0(e,t,n){return{min:C0(e,t),max:C0(e,n)}}function C0(e,t){return typeof e=="number"?e:e[t]||0}const A0=()=>({translate:0,scale:1,origin:0,originPoint:0}),hi=()=>({x:A0(),y:A0()}),T0=()=>({min:0,max:0}),Le=()=>({x:T0(),y:T0()});function Lt(e){return[e("x"),e("y")]}function RS({top:e,left:t,right:n,bottom:r}){return{x:{min:t,max:n},y:{min:e,max:r}}}function QO({x:e,y:t}){return{top:t.min,right:e.max,bottom:t.max,left:e.min}}function ZO(e,t){if(!t)return e;const n=t({x:e.left,y:e.top}),r=t({x:e.right,y:e.bottom});return{top:n.y,left:n.x,bottom:r.y,right:r.x}}function ff(e){return e===void 0||e===1}function cp({scale:e,scaleX:t,scaleY:n}){return!ff(e)||!ff(t)||!ff(n)}function rs(e){return cp(e)||OS(e)||e.z||e.rotate||e.rotateX||e.rotateY||e.skewX||e.skewY}function OS(e){return P0(e.x)||P0(e.y)}function P0(e){return e&&e!=="0%"}function lu(e,t,n){const r=e-n,s=t*r;return n+s}function M0(e,t,n,r,s){return s!==void 0&&(e=lu(e,s,r)),lu(e,n,r)+t}function up(e,t=0,n=1,r,s){e.min=M0(e.min,t,n,r,s),e.max=M0(e.max,t,n,r,s)}function $S(e,{x:t,y:n}){up(e.x,t.translate,t.scale,t.originPoint),up(e.y,n.translate,n.scale,n.originPoint)}const I0=.999999999999,R0=1.0000000000001;function JO(e,t,n,r=!1){const s=n.length;if(!s)return;t.x=t.y=1;let i,o;for(let l=0;l<s;l++){i=n[l],o=i.projectionDelta;const{visualElement:c}=i.options;c&&c.props.style&&c.props.style.display==="contents"||(r&&i.options.layoutScroll&&i.scroll&&i!==i.root&&mi(e,{x:-i.scroll.offset.x,y:-i.scroll.offset.y}),o&&(t.x*=o.x.scale,t.y*=o.y.scale,$S(e,o)),r&&rs(i.latestValues)&&mi(e,i.latestValues))}t.x<R0&&t.x>I0&&(t.x=1),t.y<R0&&t.y>I0&&(t.y=1)}function pi(e,t){e.min=e.min+t,e.max=e.max+t}function O0(e,t,n,r,s=.5){const i=Te(e.min,e.max,s);up(e,t,n,i,r)}function mi(e,t){O0(e.x,t.x,t.scaleX,t.scale,t.originX),O0(e.y,t.y,t.scaleY,t.scale,t.originY)}function LS(e,t){return RS(ZO(e.getBoundingClientRect(),t))}function e$(e,t,n){const r=LS(e,n),{scroll:s}=t;return s&&(pi(r.x,s.offset.x),pi(r.y,s.offset.y)),r}const DS=({current:e})=>e?e.ownerDocument.defaultView:null,t$=new WeakMap;class n${constructor(t){this.openDragLock=null,this.isDragging=!1,this.currentDirection=null,this.originPoint={x:0,y:0},this.constraints=!1,this.hasMutatedConstraints=!1,this.elastic=Le(),this.visualElement=t}start(t,{snapToCursor:n=!1}={}){const{presenceContext:r}=this.visualElement;if(r&&r.isPresent===!1)return;const s=d=>{const{dragSnapToOrigin:f}=this.getProps();f?this.pauseAnimation():this.stopAnimation(),n&&this.snapToCursor(Xa(d).point)},i=(d,f)=>{const{drag:h,dragPropagation:p,onDragStart:v}=this.getProps();if(h&&!p&&(this.openDragLock&&this.openDragLock(),this.openDragLock=RO(h),!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),Lt(w=>{let g=this.getAxisMotionValue(w).get()||0;if(In.test(g)){const{projection:y}=this.visualElement;if(y&&y.layout){const m=y.layout.layoutBox[w];m&&(g=At(m)*(parseFloat(g)/100))}}this.originPoint[w]=g}),v&&ke.postRender(()=>v(d,f)),Zh(this.visualElement,"transform");const{animationState:x}=this.visualElement;x&&x.setActive("whileDrag",!0)},o=(d,f)=>{const{dragPropagation:h,dragDirectionLock:p,onDirectionLock:v,onDrag:x}=this.getProps();if(!h&&!this.openDragLock)return;const{offset:w}=f;if(p&&this.currentDirection===null){this.currentDirection=r$(w),this.currentDirection!==null&&v&&v(this.currentDirection);return}this.updateAxis("x",f.point,w),this.updateAxis("y",f.point,w),this.visualElement.render(),x&&x(d,f)},l=(d,f)=>this.stop(d,f),c=()=>Lt(d=>{var f;return this.getAnimationState(d)==="paused"&&((f=this.getAxisMotionValue(d).animation)===null||f===void 0?void 0:f.play())}),{dragSnapToOrigin:u}=this.getProps();this.panSession=new TS(t,{onSessionStart:s,onStart:i,onMove:o,onSessionEnd:l,resumeAnimation:c},{transformPagePoint:this.visualElement.getTransformPagePoint(),dragSnapToOrigin:u,contextWindow:DS(this.visualElement)})}stop(t,n){const r=this.isDragging;if(this.cancel(),!r)return;const{velocity:s}=n;this.startAnimation(s);const{onDragEnd:i}=this.getProps();i&&ke.postRender(()=>i(t,n))}cancel(){this.isDragging=!1;const{projection:t,animationState:n}=this.visualElement;t&&(t.isAnimationBlocked=!1),this.panSession&&this.panSession.end(),this.panSession=void 0;const{dragPropagation:r}=this.getProps();!r&&this.openDragLock&&(this.openDragLock(),this.openDragLock=null),n&&n.setActive("whileDrag",!1)}updateAxis(t,n,r){const{drag:s}=this.getProps();if(!r||!Tl(t,s,this.currentDirection))return;const i=this.getAxisMotionValue(t);let o=this.originPoint[t]+r[t];this.constraints&&this.constraints[t]&&(o=WO(o,this.constraints[t],this.elastic[t])),i.set(o)}resolveConstraints(){var t;const{dragConstraints:n,dragElastic:r}=this.getProps(),s=this.visualElement.projection&&!this.visualElement.projection.layout?this.visualElement.projection.measure(!1):(t=this.visualElement.projection)===null||t===void 0?void 0:t.layout,i=this.constraints;n&&di(n)?this.constraints||(this.constraints=this.resolveRefConstraints()):n&&s?this.constraints=KO(s.layoutBox,n):this.constraints=!1,this.elastic=XO(r),i!==this.constraints&&s&&this.constraints&&!this.hasMutatedConstraints&&Lt(o=>{this.constraints!==!1&&this.getAxisMotionValue(o)&&(this.constraints[o]=YO(s.layoutBox[o],this.constraints[o]))})}resolveRefConstraints(){const{dragConstraints:t,onMeasureDragConstraints:n}=this.getProps();if(!t||!di(t))return!1;const r=t.current,{projection:s}=this.visualElement;if(!s||!s.layout)return!1;const i=e$(r,s.root,this.visualElement.getTransformPagePoint());let o=GO(s.layout.layoutBox,i);if(n){const l=n(QO(o));this.hasMutatedConstraints=!!l,l&&(o=RS(l))}return o}startAnimation(t){const{drag:n,dragMomentum:r,dragElastic:s,dragTransition:i,dragSnapToOrigin:o,onDragTransitionEnd:l}=this.getProps(),c=this.constraints||{},u=Lt(d=>{if(!Tl(d,n,this.currentDirection))return;let f=c&&c[d]||{};o&&(f={min:0,max:0});const h=s?200:1e6,p=s?40:1e7,v={type:"inertia",velocity:r?t[d]:0,bounceStiffness:h,bounceDamping:p,timeConstant:750,restDelta:1,restSpeed:10,...i,...f};return this.startAxisValueAnimation(d,v)});return Promise.all(u).then(l)}startAxisValueAnimation(t,n){const r=this.getAxisMotionValue(t);return Zh(this.visualElement,t),r.start(Tg(t,r,0,n,this.visualElement,!1))}stopAnimation(){Lt(t=>this.getAxisMotionValue(t).stop())}pauseAnimation(){Lt(t=>{var n;return(n=this.getAxisMotionValue(t).animation)===null||n===void 0?void 0:n.pause()})}getAnimationState(t){var n;return(n=this.getAxisMotionValue(t).animation)===null||n===void 0?void 0:n.state}getAxisMotionValue(t){const n=`_drag${t.toUpperCase()}`,r=this.visualElement.getProps(),s=r[n];return s||this.visualElement.getValue(t,(r.initial?r.initial[t]:void 0)||0)}snapToCursor(t){Lt(n=>{const{drag:r}=this.getProps();if(!Tl(n,r,this.currentDirection))return;const{projection:s}=this.visualElement,i=this.getAxisMotionValue(n);if(s&&s.layout){const{min:o,max:l}=s.layout.layoutBox[n];i.set(t[n]-Te(o,l,.5))}})}scalePositionWithinConstraints(){if(!this.visualElement.current)return;const{drag:t,dragConstraints:n}=this.getProps(),{projection:r}=this.visualElement;if(!di(n)||!r||!this.constraints)return;this.stopAnimation();const s={x:0,y:0};Lt(o=>{const l=this.getAxisMotionValue(o);if(l&&this.constraints!==!1){const c=l.get();s[o]=qO({min:c,max:c},this.constraints[o])}});const{transformTemplate:i}=this.visualElement.getProps();this.visualElement.current.style.transform=i?i({},""):"none",r.root&&r.root.updateScroll(),r.updateLayout(),this.resolveConstraints(),Lt(o=>{if(!Tl(o,t,null))return;const l=this.getAxisMotionValue(o),{min:c,max:u}=this.constraints[o];l.set(Te(c,u,s[o]))})}addListeners(){if(!this.visualElement.current)return;t$.set(this.visualElement,this);const t=this.visualElement.current,n=Wo(t,"pointerdown",c=>{const{drag:u,dragListener:d=!0}=this.getProps();u&&d&&this.start(c)}),r=()=>{const{dragConstraints:c}=this.getProps();di(c)&&c.current&&(this.constraints=this.resolveRefConstraints())},{projection:s}=this.visualElement,i=s.addEventListener("measure",r);s&&!s.layout&&(s.root&&s.root.updateScroll(),s.updateLayout()),ke.read(r);const o=wa(window,"resize",()=>this.scalePositionWithinConstraints()),l=s.addEventListener("didUpdate",({delta:c,hasLayoutChanged:u})=>{this.isDragging&&u&&(Lt(d=>{const f=this.getAxisMotionValue(d);f&&(this.originPoint[d]+=c[d].translate,f.set(f.get()+c[d].translate))}),this.visualElement.render())});return()=>{o(),n(),i(),l&&l()}}getProps(){const t=this.visualElement.getProps(),{drag:n=!1,dragDirectionLock:r=!1,dragPropagation:s=!1,dragConstraints:i=!1,dragElastic:o=lp,dragMomentum:l=!0}=t;return{...t,drag:n,dragDirectionLock:r,dragPropagation:s,dragConstraints:i,dragElastic:o,dragMomentum:l}}}function Tl(e,t,n){return(t===!0||t===e)&&(n===null||n===e)}function r$(e,t=10){let n=null;return Math.abs(e.y)>t?n="y":Math.abs(e.x)>t&&(n="x"),n}class s$ extends Yr{constructor(t){super(t),this.removeGroupControls=Et,this.removeListeners=Et,this.controls=new n$(t)}mount(){const{dragControls:t}=this.node.getProps();t&&(this.removeGroupControls=t.subscribe(this.controls)),this.removeListeners=this.controls.addListeners()||Et}unmount(){this.removeGroupControls(),this.removeListeners()}}const $0=e=>(t,n)=>{e&&ke.postRender(()=>e(t,n))};class i$ extends Yr{constructor(){super(...arguments),this.removePointerDownListener=Et}onPointerDown(t){this.session=new TS(t,this.createPanHandlers(),{transformPagePoint:this.node.getTransformPagePoint(),contextWindow:DS(this.node)})}createPanHandlers(){const{onPanSessionStart:t,onPanStart:n,onPan:r,onPanEnd:s}=this.node.getProps();return{onSessionStart:$0(t),onStart:$0(n),onMove:r,onEnd:(i,o)=>{delete this.session,s&&ke.postRender(()=>s(i,o))}}}mount(){this.removePointerDownListener=Wo(this.node.current,"pointerdown",t=>this.onPointerDown(t))}update(){this.session&&this.session.updateHandlers(this.createPanHandlers())}unmount(){this.removePointerDownListener(),this.session&&this.session.end()}}const dc={hasAnimatedSinceResize:!0,hasEverUpdated:!1};function L0(e,t){return t.max===t.min?0:e/(t.max-t.min)*100}const go={correct:(e,t)=>{if(!t.target)return e;if(typeof e=="string")if(se.test(e))e=parseFloat(e);else return e;const n=L0(e,t.target.x),r=L0(e,t.target.y);return`${n}% ${r}%`}},o$={correct:(e,{treeScale:t,projectionDelta:n})=>{const r=e,s=Hr.parse(e);if(s.length>5)return r;const i=Hr.createTransformer(e),o=typeof s[0]!="number"?1:0,l=n.x.scale*t.x,c=n.y.scale*t.y;s[0+o]/=l,s[1+o]/=c;const u=Te(l,c,.5);return typeof s[2+o]=="number"&&(s[2+o]/=u),typeof s[3+o]=="number"&&(s[3+o]/=u),i(s)}};class a$ extends b.Component{componentDidMount(){const{visualElement:t,layoutGroup:n,switchLayoutGroup:r,layoutId:s}=this.props,{projection:i}=t;II(l$),i&&(n.group&&n.group.add(i),r&&r.register&&s&&r.register(i),i.root.didUpdate(),i.addEventListener("animationComplete",()=>{this.safeToRemove()}),i.setOptions({...i.options,onExitComplete:()=>this.safeToRemove()})),dc.hasEverUpdated=!0}getSnapshotBeforeUpdate(t){const{layoutDependency:n,visualElement:r,drag:s,isPresent:i}=this.props,o=r.projection;return o&&(o.isPresent=i,s||t.layoutDependency!==n||n===void 0?o.willUpdate():this.safeToRemove(),t.isPresent!==i&&(i?o.promote():o.relegate()||ke.postRender(()=>{const l=o.getStack();(!l||!l.members.length)&&this.safeToRemove()}))),null}componentDidUpdate(){const{projection:t}=this.props.visualElement;t&&(t.root.didUpdate(),ig.postRender(()=>{!t.currentAnimation&&t.isLead()&&this.safeToRemove()}))}componentWillUnmount(){const{visualElement:t,layoutGroup:n,switchLayoutGroup:r}=this.props,{projection:s}=t;s&&(s.scheduleCheckAfterUnmount(),n&&n.group&&n.group.remove(s),r&&r.deregister&&r.deregister(s))}safeToRemove(){const{safeToRemove:t}=this.props;t&&t()}render(){return null}}function zS(e){const[t,n]=jj(),r=b.useContext(Zm);return a.jsx(a$,{...e,layoutGroup:r,switchLayoutGroup:b.useContext(Pj),isPresent:t,safeToRemove:n})}const l$={borderRadius:{...go,applyTo:["borderTopLeftRadius","borderTopRightRadius","borderBottomLeftRadius","borderBottomRightRadius"]},borderTopLeftRadius:go,borderTopRightRadius:go,borderBottomLeftRadius:go,borderBottomRightRadius:go,boxShadow:o$};function c$(e,t,n){const r=nt(e)?e:_a(e);return r.start(Tg("",r,t,n)),r.animation}function u$(e){return e instanceof SVGElement&&e.tagName!=="svg"}const d$=(e,t)=>e.depth-t.depth;class f${constructor(){this.children=[],this.isDirty=!1}add(t){gg(this.children,t),this.isDirty=!0}remove(t){vg(this.children,t),this.isDirty=!0}forEach(t){this.isDirty&&this.children.sort(d$),this.isDirty=!1,this.children.forEach(t)}}function h$(e,t){const n=Rn.now(),r=({timestamp:s})=>{const i=s-n;i>=t&&(Br(r),e(i-t))};return ke.read(r,!0),()=>Br(r)}const VS=["TopLeft","TopRight","BottomLeft","BottomRight"],p$=VS.length,D0=e=>typeof e=="string"?parseFloat(e):e,z0=e=>typeof e=="number"||se.test(e);function m$(e,t,n,r,s,i){s?(e.opacity=Te(0,n.opacity!==void 0?n.opacity:1,g$(r)),e.opacityExit=Te(t.opacity!==void 0?t.opacity:1,0,v$(r))):i&&(e.opacity=Te(t.opacity!==void 0?t.opacity:1,n.opacity!==void 0?n.opacity:1,r));for(let o=0;o<p$;o++){const l=`border${VS[o]}Radius`;let c=V0(t,l),u=V0(n,l);if(c===void 0&&u===void 0)continue;c||(c=0),u||(u=0),c===0||u===0||z0(c)===z0(u)?(e[l]=Math.max(Te(D0(c),D0(u),r),0),(In.test(u)||In.test(c))&&(e[l]+="%")):e[l]=u}(t.rotate||n.rotate)&&(e.rotate=Te(t.rotate||0,n.rotate||0,r))}function V0(e,t){return e[t]!==void 0?e[t]:e.borderRadius}const g$=FS(0,.5,rS),v$=FS(.5,.95,Et);function FS(e,t,n){return r=>r<e?0:r>t?1:n(zi(e,t,r))}function F0(e,t){e.min=t.min,e.max=t.max}function Ot(e,t){F0(e.x,t.x),F0(e.y,t.y)}function B0(e,t){e.translate=t.translate,e.scale=t.scale,e.originPoint=t.originPoint,e.origin=t.origin}function H0(e,t,n,r,s){return e-=t,e=lu(e,1/n,r),s!==void 0&&(e=lu(e,1/s,r)),e}function y$(e,t=0,n=1,r=.5,s,i=e,o=e){if(In.test(t)&&(t=parseFloat(t),t=Te(o.min,o.max,t/100)-o.min),typeof t!="number")return;let l=Te(i.min,i.max,r);e===i&&(l-=t),e.min=H0(e.min,t,n,l,s),e.max=H0(e.max,t,n,l,s)}function U0(e,t,[n,r,s],i,o){y$(e,t[n],t[r],t[s],t.scale,i,o)}const _$=["x","scaleX","originX"],x$=["y","scaleY","originY"];function W0(e,t,n,r){U0(e.x,t,_$,n?n.x:void 0,r?r.x:void 0),U0(e.y,t,x$,n?n.y:void 0,r?r.y:void 0)}function K0(e){return e.translate===0&&e.scale===1}function BS(e){return K0(e.x)&&K0(e.y)}function G0(e,t){return e.min===t.min&&e.max===t.max}function w$(e,t){return G0(e.x,t.x)&&G0(e.y,t.y)}function q0(e,t){return Math.round(e.min)===Math.round(t.min)&&Math.round(e.max)===Math.round(t.max)}function HS(e,t){return q0(e.x,t.x)&&q0(e.y,t.y)}function Y0(e){return At(e.x)/At(e.y)}function X0(e,t){return e.translate===t.translate&&e.scale===t.scale&&e.originPoint===t.originPoint}class b${constructor(){this.members=[]}add(t){gg(this.members,t),t.scheduleRender()}remove(t){if(vg(this.members,t),t===this.prevLead&&(this.prevLead=void 0),t===this.lead){const n=this.members[this.members.length-1];n&&this.promote(n)}}relegate(t){const n=this.members.findIndex(s=>t===s);if(n===0)return!1;let r;for(let s=n;s>=0;s--){const i=this.members[s];if(i.isPresent!==!1){r=i;break}}return r?(this.promote(r),!0):!1}promote(t,n){const r=this.lead;if(t!==r&&(this.prevLead=r,this.lead=t,t.show(),r)){r.instance&&r.scheduleRender(),t.scheduleRender(),t.resumeFrom=r,n&&(t.resumeFrom.preserveOpacity=!0),r.snapshot&&(t.snapshot=r.snapshot,t.snapshot.latestValues=r.animationValues||r.latestValues),t.root&&t.root.isUpdating&&(t.isLayoutDirty=!0);const{crossfade:s}=t.options;s===!1&&r.hide()}}exitAnimationComplete(){this.members.forEach(t=>{const{options:n,resumingFrom:r}=t;n.onExitComplete&&n.onExitComplete(),r&&r.options.onExitComplete&&r.options.onExitComplete()})}scheduleRender(){this.members.forEach(t=>{t.instance&&t.scheduleRender(!1)})}removeLeadSnapshot(){this.lead&&this.lead.snapshot&&(this.lead.snapshot=void 0)}}function j$(e,t,n){let r="";const s=e.x.translate/t.x,i=e.y.translate/t.y,o=(n==null?void 0:n.z)||0;if((s||i||o)&&(r=`translate3d(${s}px, ${i}px, ${o}px) `),(t.x!==1||t.y!==1)&&(r+=`scale(${1/t.x}, ${1/t.y}) `),n){const{transformPerspective:u,rotate:d,rotateX:f,rotateY:h,skewX:p,skewY:v}=n;u&&(r=`perspective(${u}px) ${r}`),d&&(r+=`rotate(${d}deg) `),f&&(r+=`rotateX(${f}deg) `),h&&(r+=`rotateY(${h}deg) `),p&&(r+=`skewX(${p}deg) `),v&&(r+=`skewY(${v}deg) `)}const l=e.x.scale*t.x,c=e.y.scale*t.y;return(l!==1||c!==1)&&(r+=`scale(${l}, ${c})`),r||"none"}const ss={type:"projectionFrame",totalNodes:0,resolvedTargetDeltas:0,recalculatedProjection:0},No=typeof window<"u"&&window.MotionDebug!==void 0,hf=["","X","Y","Z"],S$={visibility:"hidden"},Q0=1e3;let k$=0;function pf(e,t,n,r){const{latestValues:s}=t;s[e]&&(n[e]=s[e],t.setStaticValue(e,0),r&&(r[e]=0))}function US(e){if(e.hasCheckedOptimisedAppear=!0,e.root===e)return;const{visualElement:t}=e.options;if(!t)return;const n=Gj(t);if(window.MotionHasOptimisedAnimation(n,"transform")){const{layout:s,layoutId:i}=e.options;window.MotionCancelOptimisedAnimation(n,"transform",ke,!(s||i))}const{parent:r}=e;r&&!r.hasCheckedOptimisedAppear&&US(r)}function WS({attachResizeListener:e,defaultParent:t,measureScroll:n,checkIsScrollRoot:r,resetTransform:s}){return class{constructor(o={},l=t==null?void 0:t()){this.id=k$++,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,No&&(ss.totalNodes=ss.resolvedTargetDeltas=ss.recalculatedProjection=0),this.nodes.forEach(C$),this.nodes.forEach(I$),this.nodes.forEach(R$),this.nodes.forEach(A$),No&&window.MotionDebug.record(ss)},this.resolvedRelativeTargetAt=0,this.hasProjected=!1,this.isVisible=!0,this.animationProgress=0,this.sharedNodes=new Map,this.latestValues=o,this.root=l?l.root||l:this,this.path=l?[...l.path,l]:[],this.parent=l,this.depth=l?l.depth+1:0;for(let c=0;c<this.path.length;c++)this.path[c].shouldResetTransform=!0;this.root===this&&(this.nodes=new f$)}addEventListener(o,l){return this.eventHandlers.has(o)||this.eventHandlers.set(o,new yg),this.eventHandlers.get(o).add(l)}notifyListeners(o,...l){const c=this.eventHandlers.get(o);c&&c.notify(...l)}hasListeners(o){return this.eventHandlers.has(o)}mount(o,l=this.root.hasTreeAnimated){if(this.instance)return;this.isSVG=u$(o),this.instance=o;const{layoutId:c,layout:u,visualElement:d}=this.options;if(d&&!d.current&&d.mount(o),this.root.nodes.add(this),this.parent&&this.parent.children.add(this),l&&(u||c)&&(this.isLayoutDirty=!0),e){let f;const h=()=>this.root.updateBlockedByResize=!1;e(o,()=>{this.root.updateBlockedByResize=!0,f&&f(),f=h$(h,250),dc.hasAnimatedSinceResize&&(dc.hasAnimatedSinceResize=!1,this.nodes.forEach(J0))})}c&&this.root.registerSharedNode(c,this),this.options.animate!==!1&&d&&(c||u)&&this.addEventListener("didUpdate",({delta:f,hasLayoutChanged:h,hasRelativeTargetChanged:p,layout:v})=>{if(this.isTreeAnimationBlocked()){this.target=void 0,this.relativeTarget=void 0;return}const x=this.options.transition||d.getDefaultTransition()||z$,{onLayoutAnimationStart:w,onLayoutAnimationComplete:g}=d.getProps(),y=!this.targetLayout||!HS(this.targetLayout,v)||p,m=!h&&p;if(this.options.layoutRoot||this.resumeFrom&&this.resumeFrom.instance||m||h&&(y||!this.currentAnimation)){this.resumeFrom&&(this.resumingFrom=this.resumeFrom,this.resumingFrom.resumingFrom=void 0),this.setAnimationOrigin(f,m);const _={...mg(x,"layout"),onPlay:w,onComplete:g};(d.shouldReduceMotion||this.options.layoutRoot)&&(_.delay=0,_.type=!1),this.startAnimation(_)}else h||J0(this),this.isLead()&&this.options.onExitComplete&&this.options.onExitComplete();this.targetLayout=v})}unmount(){this.options.layoutId&&this.willUpdate(),this.root.nodes.remove(this);const o=this.getStack();o&&o.remove(this),this.parent&&this.parent.children.delete(this),this.instance=void 0,Br(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(O$),this.animationId++)}getTransformTemplate(){const{visualElement:o}=this.options;return o&&o.getProps().transformTemplate}willUpdate(o=!0){if(this.root.hasTreeAnimated=!0,this.root.isUpdateBlocked()){this.options.onExitComplete&&this.options.onExitComplete();return}if(window.MotionCancelOptimisedAnimation&&!this.hasCheckedOptimisedAppear&&US(this),!this.root.isUpdating&&this.root.startUpdate(),this.isLayoutDirty)return;this.isLayoutDirty=!0;for(let d=0;d<this.path.length;d++){const f=this.path[d];f.shouldResetTransform=!0,f.updateScroll("snapshot"),f.options.layoutRoot&&f.willUpdate(!1)}const{layoutId:l,layout:c}=this.options;if(l===void 0&&!c)return;const u=this.getTransformTemplate();this.prevTransformTemplateValue=u?u(this.latestValues,""):void 0,this.updateSnapshot(),o&&this.notifyListeners("willUpdate")}update(){if(this.updateScheduled=!1,this.isUpdateBlocked()){this.unblockUpdate(),this.clearAllSnapshots(),this.nodes.forEach(Z0);return}this.isUpdating||this.nodes.forEach(P$),this.isUpdating=!1,this.nodes.forEach(M$),this.nodes.forEach(N$),this.nodes.forEach(E$),this.clearAllSnapshots();const l=Rn.now();qe.delta=dr(0,1e3/60,l-qe.timestamp),qe.timestamp=l,qe.isProcessing=!0,sf.update.process(qe),sf.preRender.process(qe),sf.render.process(qe),qe.isProcessing=!1}didUpdate(){this.updateScheduled||(this.updateScheduled=!0,ig.read(this.scheduleUpdate))}clearAllSnapshots(){this.nodes.forEach(T$),this.sharedNodes.forEach($$)}scheduleUpdateProjection(){this.projectionUpdateScheduled||(this.projectionUpdateScheduled=!0,ke.preRender(this.updateProjection,!1,!0))}scheduleCheckAfterUnmount(){ke.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 c=0;c<this.path.length;c++)this.path[c].updateScroll();const o=this.layout;this.layout=this.measure(!1),this.layoutCorrected=Le(),this.isLayoutDirty=!1,this.projectionDelta=void 0,this.notifyListeners("measure",this.layout.layoutBox);const{visualElement:l}=this.options;l&&l.notify("LayoutMeasure",this.layout.layoutBox,o?o.layoutBox:void 0)}updateScroll(o="measure"){let l=!!(this.options.layoutScroll&&this.instance);if(this.scroll&&this.scroll.animationId===this.root.animationId&&this.scroll.phase===o&&(l=!1),l){const c=r(this.instance);this.scroll={animationId:this.root.animationId,phase:o,isRoot:c,offset:n(this.instance),wasRoot:this.scroll?this.scroll.isRoot:c}}}resetTransform(){if(!s)return;const o=this.isLayoutDirty||this.shouldResetTransform||this.options.alwaysMeasureLayout,l=this.projectionDelta&&!BS(this.projectionDelta),c=this.getTransformTemplate(),u=c?c(this.latestValues,""):void 0,d=u!==this.prevTransformTemplateValue;o&&(l||rs(this.latestValues)||d)&&(s(this.instance,u),this.shouldResetTransform=!1,this.scheduleRender())}measure(o=!0){const l=this.measurePageBox();let c=this.removeElementScroll(l);return o&&(c=this.removeTransform(c)),V$(c),{animationId:this.root.animationId,measuredBox:l,layoutBox:c,latestValues:{},source:this.id}}measurePageBox(){var o;const{visualElement:l}=this.options;if(!l)return Le();const c=l.measureViewportBox();if(!(((o=this.scroll)===null||o===void 0?void 0:o.wasRoot)||this.path.some(F$))){const{scroll:d}=this.root;d&&(pi(c.x,d.offset.x),pi(c.y,d.offset.y))}return c}removeElementScroll(o){var l;const c=Le();if(Ot(c,o),!((l=this.scroll)===null||l===void 0)&&l.wasRoot)return c;for(let u=0;u<this.path.length;u++){const d=this.path[u],{scroll:f,options:h}=d;d!==this.root&&f&&h.layoutScroll&&(f.wasRoot&&Ot(c,o),pi(c.x,f.offset.x),pi(c.y,f.offset.y))}return c}applyTransform(o,l=!1){const c=Le();Ot(c,o);for(let u=0;u<this.path.length;u++){const d=this.path[u];!l&&d.options.layoutScroll&&d.scroll&&d!==d.root&&mi(c,{x:-d.scroll.offset.x,y:-d.scroll.offset.y}),rs(d.latestValues)&&mi(c,d.latestValues)}return rs(this.latestValues)&&mi(c,this.latestValues),c}removeTransform(o){const l=Le();Ot(l,o);for(let c=0;c<this.path.length;c++){const u=this.path[c];if(!u.instance||!rs(u.latestValues))continue;cp(u.latestValues)&&u.updateSnapshot();const d=Le(),f=u.measurePageBox();Ot(d,f),W0(l,u.latestValues,u.snapshot?u.snapshot.layoutBox:void 0,d)}return rs(this.latestValues)&&W0(l,this.latestValues),l}setTargetDelta(o){this.targetDelta=o,this.root.scheduleUpdateProjection(),this.isProjectionDirty=!0}setOptions(o){this.options={...this.options,...o,crossfade:o.crossfade!==void 0?o.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!==qe.timestamp&&this.relativeParent.resolveTargetDelta(!0)}resolveTargetDelta(o=!1){var l;const c=this.getLead();this.isProjectionDirty||(this.isProjectionDirty=c.isProjectionDirty),this.isTransformDirty||(this.isTransformDirty=c.isTransformDirty),this.isSharedProjectionDirty||(this.isSharedProjectionDirty=c.isSharedProjectionDirty);const u=!!this.resumingFrom||this!==c;if(!(o||u&&this.isSharedProjectionDirty||this.isProjectionDirty||!((l=this.parent)===null||l===void 0)&&l.isProjectionDirty||this.attemptToResolveRelativeTarget||this.root.updateBlockedByResize))return;const{layout:f,layoutId:h}=this.options;if(!(!this.layout||!(f||h))){if(this.resolvedRelativeTargetAt=qe.timestamp,!this.targetDelta&&!this.relativeTarget){const p=this.getClosestProjectingParent();p&&p.layout&&this.animationProgress!==1?(this.relativeParent=p,this.forceRelativeParentToResolveTarget(),this.relativeTarget=Le(),this.relativeTargetOrigin=Le(),Go(this.relativeTargetOrigin,this.layout.layoutBox,p.layout.layoutBox),Ot(this.relativeTarget,this.relativeTargetOrigin)):this.relativeParent=this.relativeTarget=void 0}if(!(!this.relativeTarget&&!this.targetDelta)){if(this.target||(this.target=Le(),this.targetWithTransforms=Le()),this.relativeTarget&&this.relativeTargetOrigin&&this.relativeParent&&this.relativeParent.target?(this.forceRelativeParentToResolveTarget(),UO(this.target,this.relativeTarget,this.relativeParent.target)):this.targetDelta?(this.resumingFrom?this.target=this.applyTransform(this.layout.layoutBox):Ot(this.target,this.layout.layoutBox),$S(this.target,this.targetDelta)):Ot(this.target,this.layout.layoutBox),this.attemptToResolveRelativeTarget){this.attemptToResolveRelativeTarget=!1;const p=this.getClosestProjectingParent();p&&!!p.resumingFrom==!!this.resumingFrom&&!p.options.layoutScroll&&p.target&&this.animationProgress!==1?(this.relativeParent=p,this.forceRelativeParentToResolveTarget(),this.relativeTarget=Le(),this.relativeTargetOrigin=Le(),Go(this.relativeTargetOrigin,this.target,p.target),Ot(this.relativeTarget,this.relativeTargetOrigin)):this.relativeParent=this.relativeTarget=void 0}No&&ss.resolvedTargetDeltas++}}}getClosestProjectingParent(){if(!(!this.parent||cp(this.parent.latestValues)||OS(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 o;const l=this.getLead(),c=!!this.resumingFrom||this!==l;let u=!0;if((this.isProjectionDirty||!((o=this.parent)===null||o===void 0)&&o.isProjectionDirty)&&(u=!1),c&&(this.isSharedProjectionDirty||this.isTransformDirty)&&(u=!1),this.resolvedRelativeTargetAt===qe.timestamp&&(u=!1),u)return;const{layout:d,layoutId:f}=this.options;if(this.isTreeAnimating=!!(this.parent&&this.parent.isTreeAnimating||this.currentAnimation||this.pendingAnimation),this.isTreeAnimating||(this.targetDelta=this.relativeTarget=void 0),!this.layout||!(d||f))return;Ot(this.layoutCorrected,this.layout.layoutBox);const h=this.treeScale.x,p=this.treeScale.y;JO(this.layoutCorrected,this.treeScale,this.path,c),l.layout&&!l.target&&(this.treeScale.x!==1||this.treeScale.y!==1)&&(l.target=l.layout.layoutBox,l.targetWithTransforms=Le());const{target:v}=l;if(!v){this.prevProjectionDelta&&(this.createProjectionDeltas(),this.scheduleRender());return}!this.projectionDelta||!this.prevProjectionDelta?this.createProjectionDeltas():(B0(this.prevProjectionDelta.x,this.projectionDelta.x),B0(this.prevProjectionDelta.y,this.projectionDelta.y)),Ko(this.projectionDelta,this.layoutCorrected,v,this.latestValues),(this.treeScale.x!==h||this.treeScale.y!==p||!X0(this.projectionDelta.x,this.prevProjectionDelta.x)||!X0(this.projectionDelta.y,this.prevProjectionDelta.y))&&(this.hasProjected=!0,this.scheduleRender(),this.notifyListeners("projectionUpdate",v)),No&&ss.recalculatedProjection++}hide(){this.isVisible=!1}show(){this.isVisible=!0}scheduleRender(o=!0){var l;if((l=this.options.visualElement)===null||l===void 0||l.scheduleRender(),o){const c=this.getStack();c&&c.scheduleRender()}this.resumingFrom&&!this.resumingFrom.instance&&(this.resumingFrom=void 0)}createProjectionDeltas(){this.prevProjectionDelta=hi(),this.projectionDelta=hi(),this.projectionDeltaWithTransform=hi()}setAnimationOrigin(o,l=!1){const c=this.snapshot,u=c?c.latestValues:{},d={...this.latestValues},f=hi();(!this.relativeParent||!this.relativeParent.options.layoutRoot)&&(this.relativeTarget=this.relativeTargetOrigin=void 0),this.attemptToResolveRelativeTarget=!l;const h=Le(),p=c?c.source:void 0,v=this.layout?this.layout.source:void 0,x=p!==v,w=this.getStack(),g=!w||w.members.length<=1,y=!!(x&&!g&&this.options.crossfade===!0&&!this.path.some(D$));this.animationProgress=0;let m;this.mixTargetDelta=_=>{const j=_/1e3;e_(f.x,o.x,j),e_(f.y,o.y,j),this.setTargetDelta(f),this.relativeTarget&&this.relativeTargetOrigin&&this.layout&&this.relativeParent&&this.relativeParent.layout&&(Go(h,this.layout.layoutBox,this.relativeParent.layout.layoutBox),L$(this.relativeTarget,this.relativeTargetOrigin,h,j),m&&w$(this.relativeTarget,m)&&(this.isProjectionDirty=!1),m||(m=Le()),Ot(m,this.relativeTarget)),x&&(this.animationValues=d,m$(d,u,this.latestValues,j,y,g)),this.root.scheduleUpdateProjection(),this.scheduleRender(),this.animationProgress=j},this.mixTargetDelta(this.options.layoutRoot?1e3:0)}startAnimation(o){this.notifyListeners("animationStart"),this.currentAnimation&&this.currentAnimation.stop(),this.resumingFrom&&this.resumingFrom.currentAnimation&&this.resumingFrom.currentAnimation.stop(),this.pendingAnimation&&(Br(this.pendingAnimation),this.pendingAnimation=void 0),this.pendingAnimation=ke.update(()=>{dc.hasAnimatedSinceResize=!0,this.currentAnimation=c$(0,Q0,{...o,onUpdate:l=>{this.mixTargetDelta(l),o.onUpdate&&o.onUpdate(l)},onComplete:()=>{o.onComplete&&o.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 o=this.getStack();o&&o.exitAnimationComplete(),this.resumingFrom=this.currentAnimation=this.animationValues=void 0,this.notifyListeners("animationComplete")}finishAnimation(){this.currentAnimation&&(this.mixTargetDelta&&this.mixTargetDelta(Q0),this.currentAnimation.stop()),this.completeAnimation()}applyTransformsToTarget(){const o=this.getLead();let{targetWithTransforms:l,target:c,layout:u,latestValues:d}=o;if(!(!l||!c||!u)){if(this!==o&&this.layout&&u&&KS(this.options.animationType,this.layout.layoutBox,u.layoutBox)){c=this.target||Le();const f=At(this.layout.layoutBox.x);c.x.min=o.target.x.min,c.x.max=c.x.min+f;const h=At(this.layout.layoutBox.y);c.y.min=o.target.y.min,c.y.max=c.y.min+h}Ot(l,c),mi(l,d),Ko(this.projectionDeltaWithTransform,this.layoutCorrected,l,d)}}registerSharedNode(o,l){this.sharedNodes.has(o)||this.sharedNodes.set(o,new b$),this.sharedNodes.get(o).add(l);const u=l.options.initialPromotionConfig;l.promote({transition:u?u.transition:void 0,preserveFollowOpacity:u&&u.shouldPreserveFollowOpacity?u.shouldPreserveFollowOpacity(l):void 0})}isLead(){const o=this.getStack();return o?o.lead===this:!0}getLead(){var o;const{layoutId:l}=this.options;return l?((o=this.getStack())===null||o===void 0?void 0:o.lead)||this:this}getPrevLead(){var o;const{layoutId:l}=this.options;return l?(o=this.getStack())===null||o===void 0?void 0:o.prevLead:void 0}getStack(){const{layoutId:o}=this.options;if(o)return this.root.sharedNodes.get(o)}promote({needsReset:o,transition:l,preserveFollowOpacity:c}={}){const u=this.getStack();u&&u.promote(this,c),o&&(this.projectionDelta=void 0,this.needsReset=!0),l&&this.setOptions({transition:l})}relegate(){const o=this.getStack();return o?o.relegate(this):!1}resetSkewAndRotation(){const{visualElement:o}=this.options;if(!o)return;let l=!1;const{latestValues:c}=o;if((c.z||c.rotate||c.rotateX||c.rotateY||c.rotateZ||c.skewX||c.skewY)&&(l=!0),!l)return;const u={};c.z&&pf("z",o,u,this.animationValues);for(let d=0;d<hf.length;d++)pf(`rotate${hf[d]}`,o,u,this.animationValues),pf(`skew${hf[d]}`,o,u,this.animationValues);o.render();for(const d in u)o.setStaticValue(d,u[d]),this.animationValues&&(this.animationValues[d]=u[d]);o.scheduleRender()}getProjectionStyles(o){var l,c;if(!this.instance||this.isSVG)return;if(!this.isVisible)return S$;const u={visibility:""},d=this.getTransformTemplate();if(this.needsReset)return this.needsReset=!1,u.opacity="",u.pointerEvents=cc(o==null?void 0:o.pointerEvents)||"",u.transform=d?d(this.latestValues,""):"none",u;const f=this.getLead();if(!this.projectionDelta||!this.layout||!f.target){const x={};return this.options.layoutId&&(x.opacity=this.latestValues.opacity!==void 0?this.latestValues.opacity:1,x.pointerEvents=cc(o==null?void 0:o.pointerEvents)||""),this.hasProjected&&!rs(this.latestValues)&&(x.transform=d?d({},""):"none",this.hasProjected=!1),x}const h=f.animationValues||f.latestValues;this.applyTransformsToTarget(),u.transform=j$(this.projectionDeltaWithTransform,this.treeScale,h),d&&(u.transform=d(h,u.transform));const{x:p,y:v}=this.projectionDelta;u.transformOrigin=`${p.origin*100}% ${v.origin*100}% 0`,f.animationValues?u.opacity=f===this?(c=(l=h.opacity)!==null&&l!==void 0?l:this.latestValues.opacity)!==null&&c!==void 0?c:1:this.preserveOpacity?this.latestValues.opacity:h.opacityExit:u.opacity=f===this?h.opacity!==void 0?h.opacity:"":h.opacityExit!==void 0?h.opacityExit:0;for(const x in ru){if(h[x]===void 0)continue;const{correct:w,applyTo:g}=ru[x],y=u.transform==="none"?h[x]:w(h[x],f);if(g){const m=g.length;for(let _=0;_<m;_++)u[g[_]]=y}else u[x]=y}return this.options.layoutId&&(u.pointerEvents=f===this?cc(o==null?void 0:o.pointerEvents)||"":"none"),u}clearSnapshot(){this.resumeFrom=this.snapshot=void 0}resetTree(){this.root.nodes.forEach(o=>{var l;return(l=o.currentAnimation)===null||l===void 0?void 0:l.stop()}),this.root.nodes.forEach(Z0),this.root.sharedNodes.clear()}}}function N$(e){e.updateLayout()}function E$(e){var t;const n=((t=e.resumeFrom)===null||t===void 0?void 0:t.snapshot)||e.snapshot;if(e.isLead()&&e.layout&&n&&e.hasListeners("didUpdate")){const{layoutBox:r,measuredBox:s}=e.layout,{animationType:i}=e.options,o=n.source!==e.layout.source;i==="size"?Lt(f=>{const h=o?n.measuredBox[f]:n.layoutBox[f],p=At(h);h.min=r[f].min,h.max=h.min+p}):KS(i,n.layoutBox,r)&&Lt(f=>{const h=o?n.measuredBox[f]:n.layoutBox[f],p=At(r[f]);h.max=h.min+p,e.relativeTarget&&!e.currentAnimation&&(e.isProjectionDirty=!0,e.relativeTarget[f].max=e.relativeTarget[f].min+p)});const l=hi();Ko(l,r,n.layoutBox);const c=hi();o?Ko(c,e.applyTransform(s,!0),n.measuredBox):Ko(c,r,n.layoutBox);const u=!BS(l);let d=!1;if(!e.resumeFrom){const f=e.getClosestProjectingParent();if(f&&!f.resumeFrom){const{snapshot:h,layout:p}=f;if(h&&p){const v=Le();Go(v,n.layoutBox,h.layoutBox);const x=Le();Go(x,r,p.layoutBox),HS(v,x)||(d=!0),f.options.layoutRoot&&(e.relativeTarget=x,e.relativeTargetOrigin=v,e.relativeParent=f)}}}e.notifyListeners("didUpdate",{layout:r,snapshot:n,delta:c,layoutDelta:l,hasLayoutChanged:u,hasRelativeTargetChanged:d})}else if(e.isLead()){const{onExitComplete:r}=e.options;r&&r()}e.options.transition=void 0}function C$(e){No&&ss.totalNodes++,e.parent&&(e.isProjecting()||(e.isProjectionDirty=e.parent.isProjectionDirty),e.isSharedProjectionDirty||(e.isSharedProjectionDirty=!!(e.isProjectionDirty||e.parent.isProjectionDirty||e.parent.isSharedProjectionDirty)),e.isTransformDirty||(e.isTransformDirty=e.parent.isTransformDirty))}function A$(e){e.isProjectionDirty=e.isSharedProjectionDirty=e.isTransformDirty=!1}function T$(e){e.clearSnapshot()}function Z0(e){e.clearMeasurements()}function P$(e){e.isLayoutDirty=!1}function M$(e){const{visualElement:t}=e.options;t&&t.getProps().onBeforeLayoutMeasure&&t.notify("BeforeLayoutMeasure"),e.resetTransform()}function J0(e){e.finishAnimation(),e.targetDelta=e.relativeTarget=e.target=void 0,e.isProjectionDirty=!0}function I$(e){e.resolveTargetDelta()}function R$(e){e.calcProjection()}function O$(e){e.resetSkewAndRotation()}function $$(e){e.removeLeadSnapshot()}function e_(e,t,n){e.translate=Te(t.translate,0,n),e.scale=Te(t.scale,1,n),e.origin=t.origin,e.originPoint=t.originPoint}function t_(e,t,n,r){e.min=Te(t.min,n.min,r),e.max=Te(t.max,n.max,r)}function L$(e,t,n,r){t_(e.x,t.x,n.x,r),t_(e.y,t.y,n.y,r)}function D$(e){return e.animationValues&&e.animationValues.opacityExit!==void 0}const z$={duration:.45,ease:[.4,0,.1,1]},n_=e=>typeof navigator<"u"&&navigator.userAgent&&navigator.userAgent.toLowerCase().includes(e),r_=n_("applewebkit/")&&!n_("chrome/")?Math.round:Et;function s_(e){e.min=r_(e.min),e.max=r_(e.max)}function V$(e){s_(e.x),s_(e.y)}function KS(e,t,n){return e==="position"||e==="preserve-aspect"&&!HO(Y0(t),Y0(n),.2)}function F$(e){var t;return e!==e.root&&((t=e.scroll)===null||t===void 0?void 0:t.wasRoot)}const B$=WS({attachResizeListener:(e,t)=>wa(e,"resize",t),measureScroll:()=>({x:document.documentElement.scrollLeft||document.body.scrollLeft,y:document.documentElement.scrollTop||document.body.scrollTop}),checkIsScrollRoot:()=>!0}),mf={current:void 0},GS=WS({measureScroll:e=>({x:e.scrollLeft,y:e.scrollTop}),defaultParent:()=>{if(!mf.current){const e=new B$({});e.mount(window),e.setOptions({layoutScroll:!0}),mf.current=e}return mf.current},resetTransform:(e,t)=>{e.style.transform=t!==void 0?t:"none"},checkIsScrollRoot:e=>window.getComputedStyle(e).position==="fixed"}),H$={pan:{Feature:i$},drag:{Feature:s$,ProjectionNode:GS,MeasureLayout:zS}};function U$(e,t,n){var r;if(e instanceof Element)return[e];if(typeof e=="string"){let s=document;const i=(r=void 0)!==null&&r!==void 0?r:s.querySelectorAll(e);return i?Array.from(i):[]}return Array.from(e)}function qS(e,t){const n=U$(e),r=new AbortController,s={passive:!0,...t,signal:r.signal};return[n,s,()=>r.abort()]}function i_(e){return t=>{t.pointerType==="touch"||AS()||e(t)}}function W$(e,t,n={}){const[r,s,i]=qS(e,n),o=i_(l=>{const{target:c}=l,u=t(l);if(typeof u!="function"||!c)return;const d=i_(f=>{u(f),c.removeEventListener("pointerleave",d)});c.addEventListener("pointerleave",d,s)});return r.forEach(l=>{l.addEventListener("pointerenter",o,s)}),i}function o_(e,t,n){const{props:r}=e;e.animationState&&r.whileHover&&e.animationState.setActive("whileHover",n==="Start");const s="onHover"+n,i=r[s];i&&ke.postRender(()=>i(t,Xa(t)))}class K$ extends Yr{mount(){const{current:t}=this.node;t&&(this.unmount=W$(t,n=>(o_(this.node,n,"Start"),r=>o_(this.node,r,"End"))))}unmount(){}}class G$ extends Yr{constructor(){super(...arguments),this.isActive=!1}onFocus(){let t=!1;try{t=this.node.current.matches(":focus-visible")}catch{t=!0}!t||!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=Ya(wa(this.node.current,"focus",()=>this.onFocus()),wa(this.node.current,"blur",()=>this.onBlur()))}unmount(){}}const YS=(e,t)=>t?e===t?!0:YS(e,t.parentElement):!1,q$=new Set(["BUTTON","INPUT","SELECT","TEXTAREA","A"]);function Y$(e){return q$.has(e.tagName)||e.tabIndex!==-1}const Eo=new WeakSet;function a_(e){return t=>{t.key==="Enter"&&e(t)}}function gf(e,t){e.dispatchEvent(new PointerEvent("pointer"+t,{isPrimary:!0,bubbles:!0}))}const X$=(e,t)=>{const n=e.currentTarget;if(!n)return;const r=a_(()=>{if(Eo.has(n))return;gf(n,"down");const s=a_(()=>{gf(n,"up")}),i=()=>gf(n,"cancel");n.addEventListener("keyup",s,t),n.addEventListener("blur",i,t)});n.addEventListener("keydown",r,t),n.addEventListener("blur",()=>n.removeEventListener("keydown",r),t)};function l_(e){return Pg(e)&&!AS()}function Q$(e,t,n={}){const[r,s,i]=qS(e,n),o=l=>{const c=l.currentTarget;if(!l_(l)||Eo.has(c))return;Eo.add(c);const u=t(l),d=(p,v)=>{window.removeEventListener("pointerup",f),window.removeEventListener("pointercancel",h),!(!l_(p)||!Eo.has(c))&&(Eo.delete(c),typeof u=="function"&&u(p,{success:v}))},f=p=>{d(p,n.useGlobalTarget||YS(c,p.target))},h=p=>{d(p,!1)};window.addEventListener("pointerup",f,s),window.addEventListener("pointercancel",h,s)};return r.forEach(l=>{!Y$(l)&&l.getAttribute("tabindex")===null&&(l.tabIndex=0),(n.useGlobalTarget?window:l).addEventListener("pointerdown",o,s),l.addEventListener("focus",u=>X$(u,s),s)}),i}function c_(e,t,n){const{props:r}=e;e.animationState&&r.whileTap&&e.animationState.setActive("whileTap",n==="Start");const s="onTap"+(n==="End"?"":n),i=r[s];i&&ke.postRender(()=>i(t,Xa(t)))}class Z$ extends Yr{mount(){const{current:t}=this.node;t&&(this.unmount=Q$(t,n=>(c_(this.node,n,"Start"),(r,{success:s})=>c_(this.node,r,s?"End":"Cancel")),{useGlobalTarget:this.node.props.globalTapTarget}))}unmount(){}}const dp=new WeakMap,vf=new WeakMap,J$=e=>{const t=dp.get(e.target);t&&t(e)},eL=e=>{e.forEach(J$)};function tL({root:e,...t}){const n=e||document;vf.has(n)||vf.set(n,{});const r=vf.get(n),s=JSON.stringify(t);return r[s]||(r[s]=new IntersectionObserver(eL,{root:e,...t})),r[s]}function nL(e,t,n){const r=tL(t);return dp.set(e,n),r.observe(e),()=>{dp.delete(e),r.unobserve(e)}}const rL={some:0,all:1};class sL extends Yr{constructor(){super(...arguments),this.hasEnteredView=!1,this.isInView=!1}startObserver(){this.unmount();const{viewport:t={}}=this.node.getProps(),{root:n,margin:r,amount:s="some",once:i}=t,o={root:n?n.current:void 0,rootMargin:r,threshold:typeof s=="number"?s:rL[s]},l=c=>{const{isIntersecting:u}=c;if(this.isInView===u||(this.isInView=u,i&&!u&&this.hasEnteredView))return;u&&(this.hasEnteredView=!0),this.node.animationState&&this.node.animationState.setActive("whileInView",u);const{onViewportEnter:d,onViewportLeave:f}=this.node.getProps(),h=u?d:f;h&&h(c)};return nL(this.node.current,o,l)}mount(){this.startObserver()}update(){if(typeof IntersectionObserver>"u")return;const{props:t,prevProps:n}=this.node;["amount","margin","root"].some(iL(t,n))&&this.startObserver()}unmount(){}}function iL({viewport:e={}},{viewport:t={}}={}){return n=>e[n]!==t[n]}const oL={inView:{Feature:sL},tap:{Feature:Z$},focus:{Feature:G$},hover:{Feature:K$}},aL={layout:{ProjectionNode:GS,MeasureLayout:zS}},fp={current:null},XS={current:!1};function lL(){if(XS.current=!0,!!tg)if(window.matchMedia){const e=window.matchMedia("(prefers-reduced-motion)"),t=()=>fp.current=e.matches;e.addListener(t),t()}else fp.current=!1}const cL=[...vS,et,Hr],uL=e=>cL.find(gS(e)),u_=new WeakMap;function dL(e,t,n){for(const r in t){const s=t[r],i=n[r];if(nt(s))e.addValue(r,s);else if(nt(i))e.addValue(r,_a(s,{owner:e}));else if(i!==s)if(e.hasValue(r)){const o=e.getValue(r);o.liveStyle===!0?o.jump(s):o.hasAnimated||o.set(s)}else{const o=e.getStaticValue(r);e.addValue(r,_a(o!==void 0?o:s,{owner:e}))}}for(const r in n)t[r]===void 0&&e.removeValue(r);return t}const d_=["AnimationStart","AnimationComplete","Update","BeforeLayoutMeasure","LayoutMeasure","LayoutAnimationStart","LayoutAnimationComplete"];class fL{scrapeMotionValuesFromProps(t,n,r){return{}}constructor({parent:t,props:n,presenceContext:r,reducedMotionConfig:s,blockInitialAnimation:i,visualState:o},l={}){this.current=null,this.children=new Set,this.isVariantNode=!1,this.isControllingVariants=!1,this.shouldReduceMotion=null,this.values=new Map,this.KeyframeResolver=Eg,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 p=Rn.now();this.renderScheduledAt<p&&(this.renderScheduledAt=p,ke.render(this.render,!1,!0))};const{latestValues:c,renderState:u,onUpdate:d}=o;this.onUpdate=d,this.latestValues=c,this.baseTarget={...c},this.initialValues=n.initial?{...c}:{},this.renderState=u,this.parent=t,this.props=n,this.presenceContext=r,this.depth=t?t.depth+1:0,this.reducedMotionConfig=s,this.options=l,this.blockInitialAnimation=!!i,this.isControllingVariants=nd(n),this.isVariantNode=Aj(n),this.isVariantNode&&(this.variantChildren=new Set),this.manuallyAnimateOnMount=!!(t&&t.current);const{willChange:f,...h}=this.scrapeMotionValuesFromProps(n,{},this);for(const p in h){const v=h[p];c[p]!==void 0&&nt(v)&&v.set(c[p],!1)}}mount(t){this.current=t,u_.set(t,this),this.projection&&!this.projection.instance&&this.projection.mount(t),this.parent&&this.isVariantNode&&!this.isControllingVariants&&(this.removeFromVariantTree=this.parent.addVariantChild(this)),this.values.forEach((n,r)=>this.bindToMotionValue(r,n)),XS.current||lL(),this.shouldReduceMotion=this.reducedMotionConfig==="never"?!1:this.reducedMotionConfig==="always"?!0:fp.current,this.parent&&this.parent.children.add(this),this.update(this.props,this.presenceContext)}unmount(){u_.delete(this.current),this.projection&&this.projection.unmount(),Br(this.notifyUpdate),Br(this.render),this.valueSubscriptions.forEach(t=>t()),this.valueSubscriptions.clear(),this.removeFromVariantTree&&this.removeFromVariantTree(),this.parent&&this.parent.children.delete(this);for(const t in this.events)this.events[t].clear();for(const t in this.features){const n=this.features[t];n&&(n.unmount(),n.isMounted=!1)}this.current=null}bindToMotionValue(t,n){this.valueSubscriptions.has(t)&&this.valueSubscriptions.get(t)();const r=Fs.has(t),s=n.on("change",l=>{this.latestValues[t]=l,this.props.onUpdate&&ke.preRender(this.notifyUpdate),r&&this.projection&&(this.projection.isTransformDirty=!0)}),i=n.on("renderRequest",this.scheduleRender);let o;window.MotionCheckAppearSync&&(o=window.MotionCheckAppearSync(this,t,n)),this.valueSubscriptions.set(t,()=>{s(),i(),o&&o(),n.owner&&n.stop()})}sortNodePosition(t){return!this.current||!this.sortInstanceNodePosition||this.type!==t.type?0:this.sortInstanceNodePosition(this.current,t.current)}updateFeatures(){let t="animation";for(t in Di){const n=Di[t];if(!n)continue;const{isEnabled:r,Feature:s}=n;if(!this.features[t]&&s&&r(this.props)&&(this.features[t]=new s(this)),this.features[t]){const i=this.features[t];i.isMounted?i.update():(i.mount(),i.isMounted=!0)}}}triggerBuild(){this.build(this.renderState,this.latestValues,this.props)}measureViewportBox(){return this.current?this.measureInstanceViewportBox(this.current,this.props):Le()}getStaticValue(t){return this.latestValues[t]}setStaticValue(t,n){this.latestValues[t]=n}update(t,n){(t.transformTemplate||this.props.transformTemplate)&&this.scheduleRender(),this.prevProps=this.props,this.props=t,this.prevPresenceContext=this.presenceContext,this.presenceContext=n;for(let r=0;r<d_.length;r++){const s=d_[r];this.propEventSubscriptions[s]&&(this.propEventSubscriptions[s](),delete this.propEventSubscriptions[s]);const i="on"+s,o=t[i];o&&(this.propEventSubscriptions[s]=this.on(s,o))}this.prevMotionValues=dL(this,this.scrapeMotionValuesFromProps(t,this.prevProps,this),this.prevMotionValues),this.handleChildMotionValue&&this.handleChildMotionValue(),this.onUpdate&&this.onUpdate(this)}getProps(){return this.props}getVariant(t){return this.props.variants?this.props.variants[t]: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(t){const n=this.getClosestVariantNode();if(n)return n.variantChildren&&n.variantChildren.add(t),()=>n.variantChildren.delete(t)}addValue(t,n){const r=this.values.get(t);n!==r&&(r&&this.removeValue(t),this.bindToMotionValue(t,n),this.values.set(t,n),this.latestValues[t]=n.get())}removeValue(t){this.values.delete(t);const n=this.valueSubscriptions.get(t);n&&(n(),this.valueSubscriptions.delete(t)),delete this.latestValues[t],this.removeValueFromRenderState(t,this.renderState)}hasValue(t){return this.values.has(t)}getValue(t,n){if(this.props.values&&this.props.values[t])return this.props.values[t];let r=this.values.get(t);return r===void 0&&n!==void 0&&(r=_a(n===null?void 0:n,{owner:this}),this.addValue(t,r)),r}readValue(t,n){var r;let s=this.latestValues[t]!==void 0||!this.current?this.latestValues[t]:(r=this.getBaseTargetFromProps(this.props,t))!==null&&r!==void 0?r:this.readValueFromInstance(this.current,t,this.options);return s!=null&&(typeof s=="string"&&(pS(s)||iS(s))?s=parseFloat(s):!uL(s)&&Hr.test(n)&&(s=dS(t,n)),this.setBaseTarget(t,nt(s)?s.get():s)),nt(s)?s.get():s}setBaseTarget(t,n){this.baseTarget[t]=n}getBaseTarget(t){var n;const{initial:r}=this.props;let s;if(typeof r=="string"||typeof r=="object"){const o=ag(this.props,r,(n=this.presenceContext)===null||n===void 0?void 0:n.custom);o&&(s=o[t])}if(r&&s!==void 0)return s;const i=this.getBaseTargetFromProps(this.props,t);return i!==void 0&&!nt(i)?i:this.initialValues[t]!==void 0&&s===void 0?void 0:this.baseTarget[t]}on(t,n){return this.events[t]||(this.events[t]=new yg),this.events[t].add(n)}notify(t,...n){this.events[t]&&this.events[t].notify(...n)}}class QS extends fL{constructor(){super(...arguments),this.KeyframeResolver=yS}sortInstanceNodePosition(t,n){return t.compareDocumentPosition(n)&2?1:-1}getBaseTargetFromProps(t,n){return t.style?t.style[n]:void 0}removeValueFromRenderState(t,{vars:n,style:r}){delete n[t],delete r[t]}handleChildMotionValue(){this.childSubscription&&(this.childSubscription(),delete this.childSubscription);const{children:t}=this.props;nt(t)&&(this.childSubscription=t.on("change",n=>{this.current&&(this.current.textContent=`${n}`)}))}}function hL(e){return window.getComputedStyle(e)}class pL extends QS{constructor(){super(...arguments),this.type="html",this.renderInstance=Dj}readValueFromInstance(t,n){if(Fs.has(n)){const r=Ng(n);return r&&r.default||0}else{const r=hL(t),s=(Oj(n)?r.getPropertyValue(n):r[n])||0;return typeof s=="string"?s.trim():s}}measureInstanceViewportBox(t,{transformPagePoint:n}){return LS(t,n)}build(t,n,r){ug(t,n,r.transformTemplate)}scrapeMotionValuesFromProps(t,n,r){return pg(t,n,r)}}class mL extends QS{constructor(){super(...arguments),this.type="svg",this.isSVGTag=!1,this.measureInstanceViewportBox=Le}getBaseTargetFromProps(t,n){return t[n]}readValueFromInstance(t,n){if(Fs.has(n)){const r=Ng(n);return r&&r.default||0}return n=zj.has(n)?n:sg(n),t.getAttribute(n)}scrapeMotionValuesFromProps(t,n,r){return Bj(t,n,r)}build(t,n,r){dg(t,n,this.isSVGTag,r.transformTemplate)}renderInstance(t,n,r,s){Vj(t,n,r,s)}mount(t){this.isSVGTag=hg(t.tagName),super.mount(t)}}const gL=(e,t)=>og(e)?new mL(t):new pL(t,{allowProjection:e!==b.Fragment}),vL=BI({...IO,...oL,...H$,...aL},gL),Ye=rI(vL),yL="local-app".toLowerCase();function _L(e,t){return e==="mock"||e==="app"||e==="local"?e:"local"}const ZS=_L(yL),ue=ZS!=="mock",it=ZS==="app",f_={"workflow.yml":"流程编排","aitable-workflow.config.yml":"运行配置","coding-agents.config.json":"执行引擎","views.yml":"视图方案",".gitkeep":"目录占位"};function JS(e){return{label:xL(e.toolName,e.toolInput),detail:wL(e.toolName,e.toolInput,e.projectId)}}function xL(e,t){if(!e)return"处理生成进度";const n=e.toLowerCase();if(n==="bash")return bL(hp(t));if(n.includes("write")||n.includes("edit")){const r=id(hp(t));return r?r.name:"更新生成文件"}return n.includes("read")?"读取上下文":n.includes("mkdir")?"创建目录":n.includes("grep")||n.includes("search")?"检索项目内容":"执行生成动作"}function wL(e,t,n){const r=hp(t);if((e==null?void 0:e.toLowerCase())==="bash"&&r)return jL(r,n);const s=r?id(r):null;return s?s.purpose:t?Mg(t.replace(/\s+/g," "),64):void 0}function id(e){var l;const t=e.indexOf("recipes/");if(t>=0){const c=(l=e.slice(t).match(/^[^\s'\"]+/))==null?void 0:l[0];if(c)return{name:c.split("/").pop()??c,purpose:"步骤脚本"}}const n=e.match(/(?:^|[/\\])([^/\\\s'"]+\.(?:yml|yaml|json|ts|tsx|md))$/);if(n!=null&&n[1]){const c=n[1];return{name:c,purpose:f_[c]??"项目文件"}}const r=e.match(/(?:^|\s)(?:[~./\w-]+\/)?((?:recipes\/)?[^\s'\"]+\.(?:yml|yaml|json|ts|tsx|md))/);if(!(r!=null&&r[1]))return null;const s=r[1].replace(/^.*?(recipes\/)/u,"$1"),i=s.split("/").pop()??s,o=s.startsWith("recipes/")?"步骤脚本":f_[i]??"项目文件";return{name:i,purpose:o}}function Mg(e,t){return e.length>t?`${e.slice(0,t-1)}…`:e}function bL(e){const t=e.trim().toLowerCase();return/^mkdir\b/.test(t)?"创建目录":/^(install|touch)\b/.test(t)?"准备生成文件":/^(ls|find|test|cat|pwd)\b/.test(t)?"检查生成结果":/\b(pnpm|npm|tsx|tsc|node|vitest)\b/.test(t)?"校验生成文件":"执行生成命令"}function jL(e,t){const n=e.replace(/\s+/g," ").trim(),r=t?SL(n,t):null;if(r)return r;const s=id(n);return s?`${s.purpose} · ${s.name}`:`命令 · ${Mg(kL(n),72)}`}function hp(e){if(!e)return"";const t=e.trim();try{const n=JSON.parse(t);for(const r of["file_path","path","command","cmd"]){const s=n[r];if(typeof s=="string"&&s.trim())return s}}catch{}return t}function SL(e,t){var i;const n=NL(t),r=e.match(new RegExp(`(?:^|[\\s'"])(?:[^\\s'"]*/)?${n}(?:/([^\\s'"]+))?`));if(!r)return null;const s=((i=r[1])==null?void 0:i.replace(/^\/+/,""))??"";return s?`${t}/${s}`:t}function kL(e){return e.replace(/\/Users\/[^/\s]+\/Documents\/Work\/code\/[^\s]+\/?/g,"").replace(/\/private\/var\/folders\/[^\s]+\/?/g,"").replace(/\/var\/folders\/[^\s]+\/?/g,"")}function NL(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}const EL=300,pp=200,CL=4e3;function h_(e,t=pp){return e.length>t?`${e.slice(0,t)}…`:e}function p_(e,t=CL){return e.length>t?`${e.slice(0,t)}…`:e}function AL(e,t,n=EL){if(!t.length)return e;const r=[...e,...t];return r.length>n?r.slice(r.length-n):r}function TL(e,t){var n,r,s,i,o,l,c,u;switch(e.type){case"text":{const d=(n=e.content)==null?void 0:n.trim();return d?{kind:"text",text:d,round:t}:null}case"thinking":{const d=(r=e.content)==null?void 0:r.trim();return d?{kind:"thinking",text:d,round:t}:null}case"tool_use":{const d=JS({toolName:e.toolName,toolInput:e.toolInput});return{kind:"tool",text:d.detail?`${d.label} — ${d.detail}`:d.label,toolName:e.toolName,round:t}}case"tool_result":{const d=(s=e.content)==null?void 0:s.trim(),f=((i=e.toolName)==null?void 0:i.trim())||void 0,h=d?`↩ ${h_(d)}`:f?`↩ ${f} 返回结果`:"↩ 工具返回结果",p=d&&d.length>pp?p_(d):void 0;return p?{kind:"tool_result",text:h,toolName:f,round:t,fullText:p}:{kind:"tool_result",text:h,toolName:f,round:t}}case"permission_request":{const d=((o=e.toolName)==null?void 0:o.trim())||void 0,f=(l=e.content)==null?void 0:l.trim(),h=d?`${d} 待授权`:"待授权请求",p=f?`${h} — ${h_(f)}`:h,v=f&&f.length>pp?p_(f):void 0;return v?{kind:"permission",text:p,toolName:d,round:t,fullText:v}:{kind:"permission",text:p,toolName:d,round:t}}case"result":{const d=(c=e.content)==null?void 0:c.trim();return d?{kind:"status",text:d,round:t}:null}case"error":return{kind:"status",text:((u=e.content)==null?void 0:u.trim())||"执行出错",round:t};default:return null}}function PL(e){var t,n,r;switch(e.type){case"setup.progress":{const s=(t=e.message)==null?void 0:t.trim();return s?{kind:"status",text:`[setup] ${s}`}:null}case"setup.done":return{kind:"status",text:"[setup] 完成",boundary:!0};case"error":return{kind:"status",text:`[setup] 错误: ${((r=(n=e.error)==null?void 0:n.message)==null?void 0:r.trim())||"未知错误"}`};default:return null}}function ML(e){var t,n,r,s,i,o,l,c,u,d,f;switch(e.type){case"run.step.started":{const h=((t=e.stepName)==null?void 0:t.trim())||e.stepId||"步骤";return{kind:"tool",text:`[run] ▶ ${h}`,toolName:h}}case"run.step.succeeded":return{kind:"status",text:`[run] ✓ ${((n=e.stepName)==null?void 0:n.trim())||e.stepId||"步骤"}`};case"run.step.failed":{const h=((r=e.stepName)==null?void 0:r.trim())||e.stepId||"步骤",p=(s=e.error)==null?void 0:s.trim();return{kind:"status",text:p?`[run] ✗ ${h}:${p}`:`[run] ✗ ${h}`}}case"run.record.blocked":{const h=((i=e.stepName)==null?void 0:i.trim())||e.stepId||"步骤",p=(o=e.reason)==null?void 0:o.trim();return{kind:"status",text:p?`[run] ✗ ${h}:${p}`:`[run] ✗ ${h}`}}case"run.record.detected":return{kind:"status",text:`[run] 记录: ${((c=(l=e.record)==null?void 0:l.title)==null?void 0:c.trim())||((u=e.record)==null?void 0:u.id)||"记录"}`};case"run.stopped":return{kind:"status",text:"[run] 停止",boundary:!0};case"error":return{kind:"status",text:`[run] 错误: ${((f=(d=e.error)==null?void 0:d.message)==null?void 0:f.trim())||"未知错误"}`};default:return null}}function IL(e){const t=[];let n=!1,r,s=!1;for(const i of e){if(i.boundary){n=!0;continue}const o=i.round!==r;(!s||n||o)&&(t.push({round:i.round,items:[]}),n=!1,r=i.round,s=!0);const l=t[t.length-1].items;if(i.kind==="text"||i.kind==="thinking"){const u=l[l.length-1];if(u&&u.kind===i.kind){u.text+=i.text;continue}l.push({kind:i.kind,text:i.text});continue}const c={kind:i.kind,text:i.text,toolName:i.toolName};i.fullText!==void 0&&(c.fullText=i.fullText),l.push(c)}return t}function RL(e){return{projectId:e,activeStage:null,stages:{},updatedAt:new Date().toISOString()}}function vs(e,t,n){const r=e.projectState??RL(e.projectId),s=n.status==="running"||n.status==="blocked";return{...r,activeStage:s?t:r.activeStage===t?null:r.activeStage,stages:{...r.stages,[t]:{task:n}},updatedAt:new Date().toISOString()}}function rn(e,t,n){const r=Ig(e,t),s=new Date().toISOString(),i=r?{...r,...n,updatedAt:s}:{id:`${t}_live`,projectId:e.projectId,stage:t,status:"running",attempt:1,startedAt:s,updatedAt:s,...n};return vs(e,t,i)}function Ig(e,t){var n,r;return(r=(n=e.projectState)==null?void 0:n.stages[t])==null?void 0:r.task}function OL(e,t){var n,r;switch(t.type){case"task.started":case"task.snapshot":case"task.succeeded":return{projectState:vs(e,"design",t.task)};case"task.blocked":return{projectState:vs(e,"design",t.task),live:{designMessage:((n=t.task.block)==null?void 0:n.message)??"等待确认需求澄清"}};case"task.failed":return{projectState:vs(e,"design",t.task),live:{designMessage:((r=t.task.error)==null?void 0:r.message)??"真实设计失败,可重新生成"}};case"error":return{projectState:rn(e,"design",{status:"failed",currentAction:`真实设计中断:${t.error.message}`,error:{code:t.error.code,message:t.error.message,retryable:!0,details:t.error.details}}),live:{designMessage:`真实设计中断:${t.error.message}`}};case"design.started":return{live:{designProgressStep:"discovery",designMessage:"真实设计服务已连接,等待需求摘要"}};case"design.discovery":return{live:{designProgressStep:"design",designMessage:"已形成需求摘要,准备启动 Coding Agent"}};case"design.progress":{const s=Ig(e,"design");return{projectState:rn(e,"design",{status:!s||s.status==="idle"?"running":s.status,checkpoint:t.phase,currentAction:t.message}),live:{designMessage:t.message}}}case"design.round_start":return{live:{designProgressStep:"design",designRound:t.round,designMessage:`第 ${t.round} 轮真实 Agent 执行中`}};case"design.agent_event":{const s=e.live.designAgentEvents+1,i=e.live.designRound??1;return{live:{designAgentEvents:s,designMessage:t.event.type==="tool_use"?`第 ${i} 轮收到工具调用`:`第 ${i} 轮收到 Agent 输出`}}}case"design.validation":return{live:{designProgressStep:"render",designRound:t.round,designMessage:t.validation.valid?"流程方案校验通过":`校验发现 ${t.validation.errors.length} 个问题,等待修复轮`}};case"design.files":return{files:t.files,live:{designMessage:`同步 ${t.files.length} 个生成文件`}};case"design.done":return{live:{designProgressStep:t.success?"done":e.live.designProgressStep,designRounds:t.rounds,designRound:null,designMessage:t.success?`真实设计完成:${t.rounds} 轮,${e.live.designAgentEvents} 个 Agent 事件`:`真实设计未通过:${t.rounds} 轮,${e.live.designAgentEvents} 个 Agent 事件`}};default:return{}}}function $L(e,t){switch(t.type){case"task.started":case"task.snapshot":case"task.blocked":case"task.failed":case"task.succeeded":return{projectState:vs(e,"setup",t.task)};case"task.progress":return{projectState:rn(e,"setup",{status:"running",checkpoint:t.checkpoint,currentAction:t.message})};case"error":return{projectState:rn(e,"setup",{status:"failed",error:{code:t.error.code,message:t.error.message,retryable:!0,details:t.error.details}})};case"setup.done":{const n=Ig(e,"setup");return{projectState:rn(e,"setup",{status:"succeeded",completedAt:new Date().toISOString(),checkpoint:"done",currentAction:`AI 表格已就绪:${t.tableId}`,outputs:{...n==null?void 0:n.outputs,tableUrl:t.tableUrl,baseId:t.baseId,tableId:t.tableId,schema:t.schema}})}}default:return{}}}const LL=300;function DL(e,t,n={}){var s;const r=zL(n);if(t.type==="run.record.detected")return{records:VL(e.records,{id:t.record.id,title:t.record.title||t.record.id,state:t.record.state,status:t.record.currentStep?"running":"todo",currentStepId:t.record.currentStep,doneStepIds:[],createdAt:r.now(),updatedAt:r.now()}),logs:is(e.logs,t.record.id,t.record.currentStep??"run","info",`发现待处理记录:${t.record.title||t.record.id}`,r)};if(t.type==="run.step.started"){const i=((s=n.stepLevel)==null?void 0:s.call(n,t.stepId,t))??"ai";return{records:vo(e.records,t.itemId,o=>({...o,status:o.status==="done"?o.status:"running",currentStepId:o.status==="done"?o.currentStepId:t.stepId,updatedAt:r.now()})),logs:is(e.logs,t.itemId,t.stepId,i,`开始执行步骤:${t.stepName}`,r)}}return t.type==="run.step.succeeded"?{records:vo(e.records,t.itemId,i=>({...i,doneStepIds:m_(i.doneStepIds,t.stepId),updatedAt:r.now()})),logs:yf(is(e.logs,t.itemId,t.stepId,"ok",`步骤完成:${t.stepName}`,r),t.itemId,t.stepId,"info",t.logs,r)}:t.type==="run.step.failed"?{records:vo(e.records,t.itemId,i=>({...i,status:i.status==="done"?i.status:"blocked",currentStepId:i.status==="done"?i.currentStepId:t.stepId,updatedAt:r.now()})),logs:yf(is(e.logs,t.itemId,t.stepId,"error",`步骤失败:${t.stepName} · ${t.error}`,r),t.itemId,t.stepId,"error",t.logs,r)}:t.type==="run.record.blocked"?{records:vo(e.records,t.itemId,i=>({...i,status:i.status==="done"?i.status:t.reason.includes("人工")?"review":"blocked",currentStepId:i.status==="done"?i.currentStepId:t.stepId,doneStepIds:m_(i.doneStepIds,t.stepId),updatedAt:r.now()})),logs:yf(is(e.logs,t.itemId,t.stepId,"warn",`${t.stepName}:${t.reason}`,r),t.itemId,t.stepId,"info",t.logs,r)}:t.type==="run.record.completed"?{records:vo(e.records,t.itemId,i=>({...i,status:"done",currentStepId:null,updatedAt:r.now()})),logs:is(e.logs,t.itemId,"run","ok","流程完成",r)}:e}function zL(e){return{now:e.now??Date.now,id:e.id??FL,maxLogs:e.maxLogs??LL}}function VL(e,t){return e.findIndex(r=>r.id===t.id)<0?[...e,t]:e.map(r=>r.id===t.id?{...r,...t,doneStepIds:r.doneStepIds,status:r.status==="done"?r.status:t.status,currentStepId:r.status==="done"?r.currentStepId:t.currentStepId,createdAt:r.createdAt}:r)}function vo(e,t,n){return e.map(r=>r.id===t?n(r):r)}function m_(e,t){return e.includes(t)?e:[...e,t]}function is(e,t,n,r,s,i){return e.some(l=>l.itemId===t&&l.stepId===n&&l.level===r&&l.text===s)?e:[...e,{id:i.id(),ts:i.now(),itemId:t,stepId:n,level:r,text:s}].slice(-i.maxLogs)}function yf(e,t,n,r,s,i){return s!=null&&s.length?s.reduce((o,l)=>is(o,t,n,r,l,i),e):e}function FL(){return`run_${Date.now().toString(36)}_${Math.random().toString(36).slice(2,7)}`}function BL(e,t){var n;switch(t.type){case"task.started":case"task.snapshot":case"task.succeeded":case"task.blocked":return{projectState:vs(e,"run",t.task)};case"task.progress":return{projectState:rn(e,"run",{status:"running",checkpoint:t.checkpoint,currentAction:t.message})};case"task.failed":{const r=((n=t.task.error)==null?void 0:n.message)??t.task.currentAction??"真实运行失败";return{projectState:vs(e,"run",t.task),live:{logs:Gs(e.live.logs,qs("error",r))}}}case"run.started":{const r=`${t.workflowName} 已启动,${t.stepCount} 个步骤,监听间隔 ${Math.round(t.intervalMs/1e3)} 秒`;return{projectState:rn(e,"run",{status:"running",checkpoint:"started",currentAction:r}),live:{logs:Gs(e.live.logs,qs("ok",r))}}}case"run.progress":return{projectState:rn(e,"run",{status:"running",checkpoint:"listening",currentAction:t.message}),live:{logs:Gs(e.live.logs,qs("ai",t.message))}};case"run.stopped":return{projectState:rn(e,"run",{status:"succeeded",checkpoint:"stopped",currentAction:t.message}),live:{logs:Gs(e.live.logs,qs("ok",t.message))}};case"error":return{projectState:rn(e,"run",{status:"failed",checkpoint:"failed",error:{code:t.error.code,message:t.error.message,retryable:!0,details:t.error.details}}),live:{logs:Gs(e.live.logs,qs("error",t.error.message))}};default:{if(!XL(t))return{};const r=DL(QL(e),t,{stepLevel:s=>{var i,o;return(o=(i=e.steps)==null?void 0:i.find(l=>l.id===s))!=null&&o.requiresAgent?"ai":"info"}});return{live:ZL(r)}}}}function HL(e,t){const n=t.desiredState==="stopped",r=n&&!t.machineId,s=n?t.machineId?"已请求停止,等待执行机器优雅退出":"运行已停止":t.stalled?"无可用执行机器认领本工作流,请检查 daemon 是否在线":t.online?`运行中 · 执行机器 ${t.machineId??"未知"}`:"已请求运行,等待执行机器认领";return{projectState:rn(e,"run",{status:r?"succeeded":"running",checkpoint:n?"stopped":t.online?"listening":"waiting_machine",currentAction:s})}}function UL(e,t){return{live:{tickets:t.map(n=>({id:n.itemId,title:n.title??n.itemId,customer:n.itemId,category:"真实记录",priority:n.state??"",status:n.status??WL(n),currentStepId:n.currentStepId,doneStepIds:n.doneStepIds,createdAt:Date.parse(n.updatedAt)||Date.now()}))}}}function WL(e){return e.completedAt?"done":e.currentStepId?"running":"todo"}function KL(e,t){const n=`evt_${t.seq}`;return e.live.logs.some(r=>r.id===n)?{}:{live:{logs:[...e.live.logs,{id:n,ts:Date.parse(t.at)||Date.now(),ticketId:t.itemId??"run",stepId:t.stepId??"run",level:qL(t.type),text:YL(t)}]}}}function GL(e,t){return e.live.logs.some(n=>n.ticketId==="run"&&n.text===t)?{}:{live:{logs:Gs(e.live.logs,qs("error",t))}}}function qL(e){return e.endsWith("failed")?"error":e.endsWith("blocked")?"warn":e.endsWith("succeeded")||e.endsWith("completed")?"ok":"info"}function YL(e){const t=typeof e.payload.stepName=="string"?e.payload.stepName:e.stepId,n=typeof e.payload.error=="string"?e.payload.error:null,r=typeof e.payload.reason=="string"?e.payload.reason:null;switch(e.type){case"record.observed":return`发现工单 ${e.itemId??""}`.trim();case"step.started":return`开始步骤:${t??""}`.trim();case"step.succeeded":return`步骤完成:${t??""}`.trim();case"step.failed":return`步骤失败:${t??""}${n?` — ${n}`:""}`;case"record.blocked":return`工单受阻${r?`:${r}`:""}`;case"record.completed":return"工单已完成";default:return e.type}}function XL(e){return e.type==="run.record.detected"||e.type==="run.step.started"||e.type==="run.step.succeeded"||e.type==="run.step.failed"||e.type==="run.record.blocked"||e.type==="run.record.completed"}function QL(e){return{records:e.live.tickets.map(t=>({id:t.id,title:t.title,state:t.priority,status:t.status,currentStepId:t.currentStepId,doneStepIds:t.doneStepIds,createdAt:t.createdAt,updatedAt:t.createdAt})),logs:e.live.logs.map(t=>({id:t.id,ts:t.ts,itemId:t.ticketId,stepId:t.stepId,level:t.level,text:t.text}))}}function ZL(e){return{tickets:e.records.map(t=>({id:t.id,title:t.title,customer:t.id,category:"真实记录",priority:t.state,status:t.status,currentStepId:t.currentStepId,doneStepIds:t.doneStepIds,createdAt:t.createdAt})),logs:e.logs.map(t=>({id:t.id,ts:t.ts,ticketId:t.itemId,stepId:t.stepId,level:t.level,text:t.text}))}}function Gs(e,t){return e.some(r=>r.ticketId===t.ticketId&&r.stepId===t.stepId&&r.level===t.level&&r.text===t.text)?e:[...e,t]}function qs(e,t,n="run",r="run"){return{id:`run_${Date.now().toString(36)}_${Math.random().toString(36).slice(2,7)}`,ts:Date.now(),ticketId:n,stepId:r,level:e,text:t}}function JL(e){if(!Ur(e)||!Ur(e.schema))return null;const t=Array.isArray(e.schema.fields)?e.schema.fields.filter(iD):[],n=Array.isArray(e.schema.views)?e.schema.views.filter(oD):[];return{fields:t,views:n}}function eD(e,t){var s,i;const n=(s=e==null?void 0:e.stages.design)==null?void 0:s.task;if(t.status!=="blocked"||t.checkpoint!=="discovery_waiting_user"||(n==null?void 0:n.status)!=="blocked")return null;const r=(i=n.outputs)==null?void 0:i.discovery;return!Ur(r)||!aD(r.form)||typeof r.summary!="string"||!Ur(r.answers)||typeof r.confirmed!="boolean"?null:{form:r.form,answers:r.answers,summary:r.summary,confirmed:r.confirmed,clarifications:typeof r.clarifications=="string"?r.clarifications:void 0}}function tD(e){var u;const t=(u=e.find(d=>d.path==="aitable-workflow.config.yml"))==null?void 0:u.content;if(!t)return null;const n=Un(t,"name")??"",r=Un(t,"base_id"),s=Un(t,"table_id")??"",i=Un(t,"provider"),o=Un(t,"model"),l=Un(t,"engine"),c=rD(t,"scene")??"";return!r&&!i&&!o?null:{name:n,agentsSelected:l==="qoder"||l==="codex"?[l]:["claude"],selectedMachineId:"",tableConnected:!!r,tableBaseId:r??"",tableId:s,llmProvider:i??"",llmModel:o??"",roles:nD(e),sop:c}}function nD(e){return e.filter(t=>t.path.startsWith("roles/")&&t.path.endsWith(".role.yml")&&t.content).map(t=>{const n=Un(t.content,"id")??"",r=Un(t.content,"name")??"",s=Un(t.content,"persona")??"";return{id:n,name:r,persona:s,skills:[],knowledge:[]}}).filter(t=>t.id&&t.name)}function Un(e,t){const n=new RegExp(`^\\s*${t}:\\s*(?:"([^"]*)"|'([^']*)'|([^#\\n]*))`,"m"),r=e.match(n),s=(r==null?void 0:r[1])??(r==null?void 0:r[2])??(r==null?void 0:r[3]),i=s==null?void 0:s.trim();return i||null}function rD(e,t){const n=new RegExp(`^${t}:\\s*\\|\\n([\\s\\S]*?)(?=\\n\\S|$)`,"m"),r=e.match(n);return r!=null&&r[1]&&r[1].split(`
|
|
59
59
|
`).map(i=>i.replace(/^ /,"")).join(`
|
|
60
|
-
`).trim()||null}function sD(e,t){if(!Ur(e))return null;const n=e[t];return typeof n=="string"&&n.trim()?n:null}function iD(e){return Ur(e)&&typeof e.id=="string"&&typeof e.name=="string"&&typeof e.type=="string"&&(e.group==="business"||e.group==="process")}function oD(e){return Ur(e)&&typeof e.id=="string"&&typeof e.name=="string"&&(e.kind==="grid"||e.kind==="kanban"||e.kind==="calendar"||e.kind==="form"||e.kind==="gantt")&&typeof e.desc=="string"}function Ur(e){return typeof e=="object"&&e!==null}function aD(e){return Ur(e)&&typeof e.id=="string"&&typeof e.title=="string"&&Array.isArray(e.questions)}function lD(e){return e==="home"||e==="init"||e==="design"||e==="setup"||e==="adjust"||e==="test"||e==="run"||e==="account"||e==="engines"}const jr={init:"尚未开始配置",design:"尚未开始设计",setup:"尚未开始搭建",adjust:"尚未开始参数调整",test:"尚未开始试运行",run:"尚未开始运行"},ek={init:{status:"idle",message:jr.init},design:{status:"idle",message:jr.design},setup:{status:"idle",message:jr.setup},adjust:{status:"idle",message:jr.adjust,local:!0},test:{status:"idle",message:jr.test,local:!0},run:{status:"idle",message:jr.run}};function cD(){return{...ek}}const tk=["init","design","setup","run"];function uD(e,t){var s,i,o;if(!e)return{status:"idle",message:jr[t]};const{task:n,recoveryAction:r}=e;return{status:n.status,taskId:n.id,checkpoint:n.checkpoint,message:((s=n.block)==null?void 0:s.message)??((i=n.error)==null?void 0:i.message)??n.currentAction??dD(n.status,t),retryable:((o=n.error)==null?void 0:o.retryable)??(n.status==="blocked"||n.status==="failed"),block:n.block,error:n.error,recoveryAction:r}}function dD(e,t){return e==="running"?"任务运行中":e==="blocked"?"任务等待处理":e==="failed"?"任务失败":e==="succeeded"?"任务完成":e==="cancelled"?"任务已取消":jr[t]}function od(e){var r;const t=(r=e.projectState)==null?void 0:r.stages;if(!t)return cD();const n={...ek};for(const s of tk)n[s]=uD(t[s],s);return n.init.status==="idle"&&fD(e)&&(n.init={status:"succeeded",message:"配置已完成",retryable:!1}),n}function fD(e){var t;return!!((t=e.projectState)!=null&&t.stages.design)||Rg(e)||e.files.some(n=>n.path==="views.yml"||n.path.startsWith("recipes/"))}function Rg(e){return e.files.some(t=>t.path==="workflow.yml"||t.path.endsWith("/workflow.yml"))}function nk(e){return Rg(e)&&(!!e.workflow||e.files.some(t=>t.path.endsWith("/workflow.yml")))}function hD(e){var r,s,i,o;if(e.mode!=="live")return{kind:"unsupported",message:"演示模式不提供设计能力,请切换到真实模式"};const t=e.runtime??od(e.snapshot).design,n=eD(e.snapshot.projectState,t);if(n)return{kind:"discovery_waiting_user",discovery:n,submitLabel:((r=t.recoveryAction)==null?void 0:r.label)??"确认并开始设计"};switch(t.status){case"idle":return{kind:"not_started"};case"running":return t.checkpoint==="discovery_confirmed"||e.live.designRound!==null?{kind:"generating",checkpoint:t.checkpoint,message:e.live.designMessage||t.message,round:e.live.designRound,agentEvents:e.live.designAgentEvents}:{kind:"discovery_preparing",message:e.live.designMessage||t.message};case"blocked":return{kind:"discovery_preparing",message:((s=t.block)==null?void 0:s.message)??t.message};case"succeeded":return{kind:"done",rounds:e.live.designRounds,agentEvents:e.live.designAgentEvents};case"failed":case"cancelled":return{kind:"failed",message:((i=t.error)==null?void 0:i.message)??t.message,retryable:((o=t.error)==null?void 0:o.retryable)??t.retryable??!0}}}function pD(e,t,n){var s;return n!=="live"?{kind:"open"}:t.design.status==="succeeded"||Rg(e)||(((s=e.workflow)==null?void 0:s.steps.length)??0)>0?{kind:"open"}:{kind:"blocked",reason:"搭建阶段必须使用当前流程生成的 workflow 和 recipes,请先完成设计阶段。",backTo:"design"}}function g_(e,t,n){return t!=="live"||e.setup.status==="succeeded"?{kind:"open"}:{kind:"blocked",reason:n,backTo:"setup"}}function mD(e,t){var n;return t!=="live"?null:e.setup.status==="failed"&&((n=e.setup.error)==null?void 0:n.code)==="TABLE_ID_NOT_RETURNED"?"manual_table_id":e.setup.status==="failed"||e.setup.status==="blocked"?"retry":null}function gD(e){var n;const t=(n=e.projectState)==null?void 0:n.runSnapshot;return{tickets:(t==null?void 0:t.records.map(r=>({id:r.id,title:r.title,customer:r.id,category:"真实记录",priority:r.state,status:r.status,currentStepId:r.currentStepId,doneStepIds:r.doneStepIds,createdAt:r.createdAt})))??[],logs:(t==null?void 0:t.logs.map(r=>({id:r.id,ts:r.ts,ticketId:r.itemId,stepId:r.stepId,level:r.level,text:r.text})))??[]}}function rk(e){var t,n;return sD((n=(t=e.projectState)==null?void 0:t.stages.setup)==null?void 0:n.task.outputs,"tableUrl")}function vD(e){var r;const t=e.projectState;if(!t)return null;if(t.activeStage&&t.stages[t.activeStage])return t.activeStage;let n=null;for(const s of tk){const i=(r=t.stages[s])==null?void 0:r.task;i&&(!n||i.updatedAt.localeCompare(n.updatedAt)>=0)&&(n={stage:s,updatedAt:i.updatedAt})}return(n==null?void 0:n.stage)??null}function sk(e,t="init"){const n=od(e);if(n.setup.status==="blocked"||n.setup.status==="failed")return"setup";const r=vD(e);return r==="design"&&n.design.status==="succeeded"&&nk(e)?"setup":r??t}function yD(e){for(const t of["design","setup","run"])if(e[t].status==="running")return{stage:t,taskId:e[t].taskId??null};return null}const _D=["init","design","setup","adjust","test","run"];function xD(e){return _D.includes(e)}function wD(e){var r,s;const{route:t}=e;if(t==="home")return{kind:"home"};if(t==="account")return{kind:"account"};if(t==="engines")return{kind:"engines"};if(e.loading.phase==="loading")return{kind:"loading",projectId:e.loading.projectId};if(e.loading.phase==="error")return{kind:"load_error",projectId:e.loading.projectId,message:e.loading.error??"项目加载失败"};if(t==="adjust")return{kind:"adjust"};if(!e.snapshot.projectId)return{kind:"no_project",intended:xD(t)?t:"init"};const n=od(e.snapshot);switch(t){case"init":return{kind:"init",runtime:n.init,config:e.initDraft,complete:n.init.status==="succeeded"};case"design":return{kind:"design",runtime:n.design,sub:hD({snapshot:e.snapshot,live:e.live,mode:e.mode,runtime:n.design}),hasArtifacts:nk(e.snapshot)};case"setup":return{kind:"setup",runtime:n.setup,gate:pD(e.snapshot,n,e.mode),schema:e.mode==="mock"&&e.mockSetup?{fields:e.mockSetup.fields,views:e.mockSetup.views}:JL((s=(r=e.snapshot.projectState)==null?void 0:r.stages.setup)==null?void 0:s.task.outputs)??{fields:[],views:[]},tableUrl:e.mode==="mock"&&e.mockSetup?e.mockSetup.tableUrl:rk(e.snapshot),recovery:mD(n,e.mode)};case"test":return{kind:"test",runtime:n.test,gate:g_(n,e.mode,"试运行必须基于已搭建完成的 AI 表格,请先完成搭建阶段。")};case"run":return{kind:"run",runtime:n.run,gate:g_(n,e.mode,"正式运行必须基于已搭建完成的 AI 表格,请先完成搭建阶段。"),tickets:e.live.tickets,logs:e.live.logs}}}function as(){return{projectId:null,projects:[],files:[],projectState:null,workflow:null,workflows:[],currentWorkflowId:null,workflowFiles:[],engineBinding:null,init:null}}function Pl(){return{designRound:null,designRounds:null,designAgentEvents:0,designProgressStep:null,designMessage:"",tickets:[],logs:[]}}aj({enforceActions:"always",computedRequiresReaction:!1});const v_="aitable-workflow:shell-state:v2",bD="aitable-workflow:state:v1",_f={name:"",agentsSelected:[],selectedMachineId:"",tableConnected:!1,tableBaseId:"",tableId:"",llmProvider:"",llmModel:"",roles:[],sop:""};class jD{constructor(){le(this,"route","home");le(this,"theme","light");le(this,"layout",{railCollapsed:!1,chatCollapsed:!1,chatWidth:460});le(this,"projectSource","new");le(this,"agentTraceOpen",!1);le(this,"agentTraceLog",[]);le(this,"initDraft",{..._f});le(this,"validation",{});le(this,"stepStatus",{});le(this,"mockSetup",{fields:[],views:[],tableUrl:null});le(this,"mode",ue?"live":"mock");le(this,"snapshot",as());le(this,"loading",{phase:"idle",projectId:null});le(this,"live",Pl());le(this,"persistedProjectId",null);le(this,"persistedWorkflowId",null);uj(this,{route:ve,theme:ve,layout:ve,projectSource:ve,agentTraceOpen:ve,agentTraceLog:ve.ref,initDraft:ve,validation:ve,stepStatus:ve,mockSetup:ve,snapshot:ve,loading:ve,live:ve,view:bn,stageRuntime:bn,stream:bn,recommendedStage:bn,steps:bn,edges:bn,setRoute:ie,toggleTheme:ie,setRailCollapsed:ie,setChatCollapsed:ie,setChatWidth:ie,setProjectSource:ie,setAgentTraceOpen:ie,toggleAgentTrace:ie,appendAgentTrace:ie,clearAgentTrace:ie,patchInitDraft:ie,setValidation:ie,setStepStatus:ie,addMockField:ie,addMockView:ie,setMockTableUrl:ie,addTicket:ie,updateTicket:ie,appendLog:ie,startNewWorkflow:ie,beginNewProject:ie,setEngineBinding:ie,reset:ie,beginLoad:ie,failLoad:ie,applyLoadedProject:ie,applySnapshotPatch:ie,applyServerFiles:ie,applyServerWorkflow:ie,setCurrentWorkflow:ie,setProjects:ie,setWorkflows:ie,clearProject:ie,patchLive:ie,applyDesignEvent:ie,applySetupEvent:ie,applyRunEvent:ie,applyRunRecords:ie,applyRunSchedule:ie,appendRunTimelineEntry:ie,appendRunPollError:ie}),this.hydrateFromStorage(),this.installPersistence()}get view(){return wD({route:this.route,loading:this.loading,snapshot:this.snapshot,live:this.live,mode:this.mode,initDraft:this.initDraft,mockSetup:this.mockSetup})}get stageRuntime(){return od(this.snapshot)}get stream(){return yD(this.stageRuntime)}get recommendedStage(){return sk(this.snapshot)}get steps(){var n;return(((n=this.snapshot.workflow)==null?void 0:n.steps)??[]).map(r=>this.stepStatus[r.id]?{...r,status:this.stepStatus[r.id]}:r)}get edges(){var t;return((t=this.snapshot.workflow)==null?void 0:t.edges)??[]}get validationContext(){return{steps:this.steps,init:this.initDraft,stageRuntime:this.stageRuntime}}get tableUrl(){return this.mode==="mock"?this.mockSetup.tableUrl:rk(this.snapshot)}get projectId(){return this.snapshot.projectId}get projects(){return this.snapshot.projects}get projectFiles(){return this.snapshot.files}get workflows(){return this.snapshot.workflows}get currentWorkflowId(){return this.snapshot.currentWorkflowId}get workflowFiles(){return this.snapshot.workflowFiles}setRoute(t){this.route=t}toggleTheme(){this.theme=this.theme==="light"?"dark":"light",typeof document<"u"&&document.documentElement.setAttribute("data-theme",this.theme)}setRailCollapsed(t){this.layout={...this.layout,railCollapsed:t}}setChatCollapsed(t){this.layout={...this.layout,chatCollapsed:t}}setChatWidth(t){this.layout={...this.layout,chatWidth:t,chatCollapsed:!1}}setProjectSource(t){this.projectSource=t}setAgentTraceOpen(t){this.agentTraceOpen=t}toggleAgentTrace(){this.agentTraceOpen=!this.agentTraceOpen}appendAgentTrace(t){const n=AL(this.agentTraceLog,Array.isArray(t)?t:[t]);n!==this.agentTraceLog&&(this.agentTraceLog=n)}clearAgentTrace(){this.agentTraceLog.length!==0&&(this.agentTraceLog=[])}patchInitDraft(t){this.initDraft={...this.initDraft,...t}}setValidation(t,n){this.validation={...this.validation,[t]:n}}setStepStatus(t,n){const r={...this.stepStatus};n?r[t]=n:delete r[t],this.stepStatus=r}addMockField(t){this.mockSetup={...this.mockSetup,fields:[...this.mockSetup.fields,t]}}addMockView(t){this.mockSetup={...this.mockSetup,views:[...this.mockSetup.views,t]}}setMockTableUrl(t){this.mockSetup={...this.mockSetup,tableUrl:t}}addTicket(t){this.live={...this.live,tickets:[t,...this.live.tickets]}}updateTicket(t,n){this.live={...this.live,tickets:this.live.tickets.map(r=>r.id===t?{...r,...n}:r)}}appendLog(t){this.live={...this.live,logs:[...this.live.logs,t]}}beginNewProject(t,n){this.startNewWorkflow(),this.projectSource="new",this.snapshot={...as(),projects:this.snapshot.projects,projectId:t},this.initDraft={..._f,name:n},this.loading={phase:"ready",projectId:t}}startNewWorkflow(){this.route="init",this.initDraft={..._f},this.live=Pl(),this.stepStatus={},this.mockSetup={fields:[],views:[],tableUrl:null},this.validation={},this.agentTraceLog=[],this.snapshot={...as(),projects:this.snapshot.projects,projectId:this.snapshot.projectId}}reset(){this.route="home",this.projectSource="new",this.startNewWorkflow(),this.route="home",this.snapshot={...as(),projects:this.snapshot.projects},this.loading={phase:"idle",projectId:null}}beginLoad(t){this.loading={phase:"loading",projectId:t}}failLoad(t,n){this.loading={phase:"error",projectId:t,error:n}}applyLoadedProject(t){this.snapshot=t.snapshot,this.live={...Pl(),...t.live},this.stepStatus={},t.snapshot.init&&(this.initDraft=t.snapshot.init),t.route&&(this.route=t.route),this.loading={phase:"ready",projectId:t.snapshot.projectId}}applySnapshotPatch(t,n){return this.snapshot.projectId!==t?!1:(this.snapshot={...this.snapshot,...n},!0)}applyServerFiles(t,n){return this.applySnapshotPatch(t,{files:n})}applyServerWorkflow(t,n){return this.applySnapshotPatch(t,{workflow:n})}setCurrentWorkflow(t,n){this.snapshot={...this.snapshot,currentWorkflowId:t,workflowFiles:n}}setProjects(t){this.snapshot={...this.snapshot,projects:t}}setWorkflows(t){this.snapshot={...this.snapshot,workflows:t}}setEngineBinding(t,n){this.applySnapshotPatch(t,{engineBinding:n})}clearProject(t){this.snapshot={...as(),projects:t},this.live=Pl(),this.stepStatus={},this.loading={phase:"idle",projectId:null},this.route="home",this.projectSource="new"}patchLive(t,n){return this.snapshot.projectId!==t?!1:(this.live={...this.live,...n},!0)}applyDesignEvent(t,n){return this.applyReducerPatch(t,r=>OL(r,n))}applySetupEvent(t,n){return this.applyReducerPatch(t,r=>$L(r,n))}applyRunEvent(t,n){return this.applyReducerPatch(t,r=>BL(r,n))}applyRunSchedule(t,n){return this.applyReducerPatch(t,r=>HL(r,n))}applyRunRecords(t,n){return this.applyReducerPatch(t,r=>UL(r,n))}appendRunTimelineEntry(t,n){return this.applyReducerPatch(t,r=>KL(r,n))}appendRunPollError(t,n){return this.applyReducerPatch(t,r=>GL(r,n))}applyReducerPatch(t,n){if(this.snapshot.projectId!==t)return!1;const r=n({projectId:t,projectState:this.snapshot.projectState,live:this.live,steps:this.steps});return(r.projectState||r.files)&&(this.snapshot={...this.snapshot,...r.projectState?{projectState:r.projectState}:{},...r.files?{files:r.files}:{}}),r.live&&(this.live={...this.live,...r.live}),!0}hydrateFromStorage(){if(!(typeof window>"u"))try{const t=window.localStorage.getItem(v_)??window.localStorage.getItem(bD);if(!t)return;const n=JSON.parse(t);if(typeof n!="object"||n===null)return;const r=n,s=lD(r.stage)?r.stage:"home",i=typeof r.projectId=="string"&&r.projectId.trim()?r.projectId:null,o=s!=="home"&&s!=="account"&&s!=="engines";K2(()=>{this.route=o&&!i?"home":s,(r.theme==="dark"||r.theme==="light")&&(this.theme=r.theme),typeof r.layout=="object"&&r.layout!==null&&(this.layout={...this.layout,...r.layout}),this.persistedProjectId=i,this.persistedWorkflowId=typeof r.currentWorkflowId=="string"&&r.currentWorkflowId.trim()?r.currentWorkflowId:null})}catch{}}installPersistence(){typeof window>"u"||sj(()=>{const t={version:2,stage:this.route,theme:this.theme,layout:this.layout,projectId:this.snapshot.projectId,currentWorkflowId:this.snapshot.currentWorkflowId};try{window.localStorage.setItem(v_,JSON.stringify(t))}catch{}})}}const z=new jD,SD={sparkle:"M12 2l1.9 5.8L20 9.7l-5.1 3.7L16 20l-4-3.6L8 20l1.1-6.6L4 9.7l6.1-1.9z",check:"M4 12l5 5L20 6","chevron-right":"M9 6l6 6-6 6","chevron-down":"M6 9l6 6 6-6","chevron-left":"M15 6l-6 6 6 6","chevron-up":"M6 15l6-6 6 6",plus:"M12 5v14M5 12h14",play:"M7 5v14l12-7z",pause:"M8 5v14M16 5v14",refresh:"M23 4v6h-6 M1 20v-6h6 M3.51 9a9 9 0 0114.85-3.36L23 10 M1 14l4.64 4.36A9 9 0 0020.49 15",moon:"M21 12.8A9 9 0 1111.2 3a7 7 0 009.8 9.8z",sun:"M12 4V2M12 22v-2M4 12H2M22 12h-2M5.6 5.6L4.2 4.2M19.8 19.8l-1.4-1.4M18.4 5.6l1.4-1.4M4.2 19.8l1.4-1.4M12 8a4 4 0 100 8 4 4 0 000-8z",table:"M3 5h18v14H3zM3 10h18M9 10v9M15 10v9",flow:"M5 5h5v5H5zM14 14h5v5h-5zM10 7h4M12 10v4",robot:"M12 3v3M7 6h10a2 2 0 012 2v9a2 2 0 01-2 2H7a2 2 0 01-2-2V8a2 2 0 012-2zM9 12h.01M15 12h.01",lock:"M6 11V8a6 6 0 0112 0v3M5 11h14v9H5z",bolt:"M13 2L4 14h6l-1 8 9-12h-6z",file:"M6 2h8l4 4v16H6zM14 2v4h4",folder:"M3 6h6l2 2h10v12H3z",link:"M10 13a5 5 0 007 0l2-2a5 5 0 00-7-7l-1 1M14 11a5 5 0 00-7 0l-2 2a5 5 0 007 7l1-1",send:"M22 2L11 13M22 2l-7 20-4-9-9-4z",user:"M12 12a4 4 0 100-8 4 4 0 000 8zM4 21a8 8 0 0116 0",warn:"M12 3l10 18H2zM12 10v5M12 18h.01",close:"M6 6l12 12M18 6L6 18",dot:"M12 12h.01"};function V({name:e,size:t=16,color:n="currentColor",style:r}){const s=e==="play"||e==="pause"||e==="sparkle"||e==="bolt";return a.jsx("svg",{width:t,height:t,viewBox:"0 0 24 24",fill:s?n:"none",stroke:s?"none":n,strokeWidth:1.8,strokeLinecap:"round",strokeLinejoin:"round",style:r,"aria-hidden":!0,children:a.jsx("path",{d:SD[e]})})}const kD="";async function ND(e,t){return await(await ik("/api/auth/register",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({username:e,password:t})})).json()}async function ED(e,t){return await(await ik("/api/auth/login",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({username:e,password:t})})).json()}async function ik(e,t){var r;let n;try{n=await fetch(`${kD}${e}`,t)}catch(s){const i=s instanceof Error?s.message:String(s);throw new Error(`无法连接后端服务(当前站点):${i}`)}if(!n.ok){const s=await n.text();try{const i=JSON.parse(s);if((r=i.error)!=null&&r.message)throw new Error(i.error.message)}catch(i){if(i instanceof Error&&i.message!==s)throw i}throw new Error(s||`HTTP ${n.status}`)}return n}const mp="aitable-auth:v1";function CD(){if(typeof window>"u")return{token:null,user:null};try{const e=window.localStorage.getItem(mp);if(!e)return{token:null,user:null};const t=JSON.parse(e);return{token:typeof t.token=="string"?t.token:null,user:t.user??null}}catch{return{token:null,user:null}}}function AD(e){if(!(typeof window>"u"))try{e.token?window.localStorage.setItem(mp,JSON.stringify(e)):window.localStorage.removeItem(mp)}catch{}}let xr=CD();const gp=new Set;function xf(){AD(xr);for(const e of gp)e()}const As={get(){return xr},isLoggedIn(){return xr.token!==null&&xr.user!==null},async login(e,t){const n=await ED(e,t);xr={token:n.token,user:n.user},xf()},async register(e,t){const n=await ND(e,t);xr={token:n.token,user:n.user},xf()},logout(){xr={token:null,user:null},xf()},getToken(){return xr.token},subscribe(e){return gp.add(e),()=>{gp.delete(e)}}},TD={token:null,user:null};function Og(){return b.useSyncExternalStore(As.subscribe,()=>As.get(),()=>TD)}let cu=null;function PD(e){cu=e}function MD(){return cu!==null}function ID(){const t=new URLSearchParams(window.location.search).get("token");if(t){PD(t);const n=new URL(window.location.href);return n.searchParams.delete("token"),window.history.replaceState({},"",n.toString()),!0}return!1}async function Bs(e,t){if(!cu)throw new Error("Dev token not set");const n=await fetch(e,{...t,headers:{...t==null?void 0:t.headers,Authorization:`Bearer ${cu}`}});if(!n.ok){const r=await n.text();try{const s=JSON.parse(r);if(s.error)throw new Error(s.error)}catch(s){if(s instanceof Error&&s.message!==r)throw s}throw new Error(r||`HTTP ${n.status}`)}return n}async function y_(e){return await(await Bs("/dev/config/save",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({updates:e})})).json()}async function RD(){await Bs("/dev/setup/complete",{method:"POST"})}async function OD(e,t){return await(await Bs("/dev/kb/upload",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({roleId:e,files:t})})).json()}async function $D(e,t){return await(await Bs("/dev/kb/ingest",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({roleId:e,source:t})})).json()}async function LD(){return await(await Bs("/dev/config/enriched")).json()}async function DD(e){return await(await Bs(`/dev/file/read?path=${encodeURIComponent(e)}`)).json()}async function zD(e,t){return await(await Bs("/dev/file/write",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({path:e,content:t})})).json()}const VD=[{id:"init",label:"配置"},{id:"design",label:"设计"},{id:"setup",label:"搭建"},{id:"test",label:"试运行"},{id:"run",label:"运行"}],FD=[{id:"adjust",label:"参数调整"}],BD=ut(function(){const t=z.route,n=z.stageRuntime,r=z.projectSource,s=MD()?FD:VD;return a.jsx("nav",{className:"stepper","aria-label":"阶段进度",children:s.map((i,o)=>{const l=i.id===t,c=n[i.id].status==="succeeded",u=r==="imported"&&(i.id==="init"||i.id==="design"||i.id==="setup");return a.jsxs(b.Fragment,{children:[o>0&&a.jsx("span",{className:"stepper__sep"}),a.jsxs("button",{type:"button",className:"stepper__item"+(l?" is-active":"")+(c||u?" is-done":""),onClick:()=>z.setRoute(i.id),title:u?"已随包导入":void 0,children:[a.jsx("span",{className:"stepper__num",children:c||u?a.jsx(V,{name:"check",size:12}):o+1}),i.label]})]},i.id)})})}),HD="";async function $g(){return(await(await ye("/api/projects",{method:"POST"})).json()).project}async function UD(e,t){const n={};return e&&e.trim()&&(n.title=e.trim()),t&&t.length>0&&(n.files=t),await(await ye("/api/projects",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify(n)})).json()}async function WD(e){return await(await ye(`/api/projects/${e}`,{method:"DELETE"})).json()}async function KD(e){return await(await ye(`/api/projects/${e}/export`)).json()}async function GD(e){return await(await ye(`/api/projects/${e}/validate`,{method:"POST"})).json()}async function vp(e){return(await(await ye(`/api/projects/${e}/workflows`)).json()).workflows}async function qD(e,t){const n={name:t.name};return t.templatePath&&(n.templatePath=t.templatePath),t.files&&t.files.length>0&&(n.files=t.files),await(await ye(`/api/projects/${e}/workflows`,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify(n)})).json()}async function yp(e,t){return await(await ye(`/api/projects/${e}/workflows/${t}`)).json()}async function YD(e,t){return await(await ye(`/api/projects/${e}/workflows/${t}`,{method:"DELETE"})).json()}async function ok(){await ye("/api/health")}async function XD(){return await(await ye("/api/agents")).json()}async function ak(){return(await(await ye("/api/projects")).json()).projects}async function QD(e,t){return(await(await ye(`/api/projects/${e}`,{method:"PATCH",headers:{"content-type":"application/json"},body:JSON.stringify({title:t})})).json()).project}async function Lg(e){return await(await ye(`/api/projects/${e}/state`)).json()}async function ZD(e,t){return await(await ye(`/api/projects/${e}/init`,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify(t)})).json()}async function JD(e,t){return await(await ye(`/api/projects/${e}/table-id`,{method:"PATCH",headers:{"content-type":"application/json"},body:JSON.stringify({tableId:t})})).json()}async function e3(e){return await(await ye(`/api/projects/${e}/design/discovery`,{method:"POST"})).json()}async function t3(e,t){return await(await ye(`/api/projects/${e}/design/discovery/confirm`,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({answers:t})})).json()}async function ad(e,t){const n=t?`?workflowId=${encodeURIComponent(t)}`:"",s=await(await ye(`/api/projects/${e}/workflow${n}`)).json();return p3(s.workflow)}async function Dg(e){return(await(await ye(`/api/projects/${e}/files`)).json()).files}async function n3(e,t){await ck(`/api/projects/${e}/design`,t)}async function r3(e,t){await ck(`/api/projects/${e}/setup`,t)}async function s3(e,t,n){const r=`/api/projects/${e}/run`,s=await ye(r,{method:"POST",signal:n==null?void 0:n.signal});return c3(s)?{mode:"lease",schedule:(await s.json()).schedule}:(await uk(r,s,t,n),{mode:"local"})}async function i3(e){return await(await ye(`/api/projects/${e}/run/stop`,{method:"POST"})).json()}async function o3(e){return await(await ye(`/api/projects/${e}/run/status`)).json()}async function a3(e,t){return await(await ye(`/api/projects/${e}/run/records`)).json()}async function l3(e,t){const n=new URLSearchParams;t!=null&&t.afterSeq&&n.set("afterSeq",String(t.afterSeq)),t!=null&&t.limit&&n.set("limit",String(t.limit));const r=n.size>0?`?${n.toString()}`:"";return await(await ye(`/api/projects/${e}/run/events${r}`)).json()}function c3(e){return(e.headers.get("content-type")??"").includes("application/json")}async function u3(e,t,n){return(await(await ye(`/api/projects/${e}/run/records/${t}/human-action`,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({action:n})})).json()).state}async function fc(e){return await(await ye(`/api/projects/${e}/engine`)).json()}async function lk(e,t){await ye(`/api/projects/${e}/engine`,{method:"PUT",headers:{"content-type":"application/json"},body:JSON.stringify({machineId:t})})}async function ye(e,t){var s;const n=As.getToken();if(n){const i=new Headers(t==null?void 0:t.headers);i.set("Authorization",`Bearer ${n}`),t={...t,headers:i}}let r;try{r=await fetch(`${HD}${e}`,t)}catch(i){const o=i instanceof Error?i.message:String(i);throw new Error(`无法连接真实后端服务(当前站点):${o}`)}if(!r.ok){const i=await r.text();try{const o=JSON.parse(i);if((s=o.error)!=null&&s.message)throw new Error(o.error.message)}catch(o){if(o instanceof Error&&o.message!==i)throw o}throw new Error(i||`HTTP ${r.status}`)}return r}const d3=5,f3=500,h3=8e3;async function ck(e,t,n){const r=await ye(e,{method:"POST",signal:n==null?void 0:n.signal});await uk(e,r,t,n)}async function uk(e,t,n,r){var l,c;let s=null,i=0,o=t;for(;;){if((l=r==null?void 0:r.signal)!=null&&l.aborted)return;try{if(!o){const h=s?`${e}${e.includes("?")?"&":"?"}cursor=${encodeURIComponent(s)}`:e;o=await ye(h,{method:"POST",signal:r==null?void 0:r.signal})}if(!o.body)return;const u=o.body.getReader(),d=new TextDecoder;let f="";for(;;){const{done:h,value:p}=await u.read();if(h)return;i=0,f+=d.decode(p,{stream:!0});const v=f.split(`
|
|
60
|
+
`).trim()||null}function sD(e,t){if(!Ur(e))return null;const n=e[t];return typeof n=="string"&&n.trim()?n:null}function iD(e){return Ur(e)&&typeof e.id=="string"&&typeof e.name=="string"&&typeof e.type=="string"&&(e.group==="business"||e.group==="process")}function oD(e){return Ur(e)&&typeof e.id=="string"&&typeof e.name=="string"&&(e.kind==="grid"||e.kind==="kanban"||e.kind==="calendar"||e.kind==="form"||e.kind==="gantt")&&typeof e.desc=="string"}function Ur(e){return typeof e=="object"&&e!==null}function aD(e){return Ur(e)&&typeof e.id=="string"&&typeof e.title=="string"&&Array.isArray(e.questions)}function lD(e){return e==="home"||e==="init"||e==="design"||e==="setup"||e==="adjust"||e==="test"||e==="run"||e==="account"||e==="engines"}const jr={init:"尚未开始配置",design:"尚未开始设计",setup:"尚未开始搭建",adjust:"尚未开始参数调整",test:"尚未开始试运行",run:"尚未开始运行"},ek={init:{status:"idle",message:jr.init},design:{status:"idle",message:jr.design},setup:{status:"idle",message:jr.setup},adjust:{status:"idle",message:jr.adjust,local:!0},test:{status:"idle",message:jr.test,local:!0},run:{status:"idle",message:jr.run}};function cD(){return{...ek}}const tk=["init","design","setup","run"];function uD(e,t){var s,i,o;if(!e)return{status:"idle",message:jr[t]};const{task:n,recoveryAction:r}=e;return{status:n.status,taskId:n.id,checkpoint:n.checkpoint,message:((s=n.block)==null?void 0:s.message)??((i=n.error)==null?void 0:i.message)??n.currentAction??dD(n.status,t),retryable:((o=n.error)==null?void 0:o.retryable)??(n.status==="blocked"||n.status==="failed"),block:n.block,error:n.error,recoveryAction:r}}function dD(e,t){return e==="running"?"任务运行中":e==="blocked"?"任务等待处理":e==="failed"?"任务失败":e==="succeeded"?"任务完成":e==="cancelled"?"任务已取消":jr[t]}function od(e){var r;const t=(r=e.projectState)==null?void 0:r.stages;if(!t)return cD();const n={...ek};for(const s of tk)n[s]=uD(t[s],s);return n.init.status==="idle"&&fD(e)&&(n.init={status:"succeeded",message:"配置已完成",retryable:!1}),n}function fD(e){var t;return!!((t=e.projectState)!=null&&t.stages.design)||Rg(e)||e.files.some(n=>n.path==="views.yml"||n.path.startsWith("recipes/"))}function Rg(e){return e.files.some(t=>t.path==="workflow.yml"||t.path.endsWith("/workflow.yml"))}function nk(e){return Rg(e)&&(!!e.workflow||e.files.some(t=>t.path.endsWith("/workflow.yml")))}function hD(e){var r,s,i,o;if(e.mode!=="live")return{kind:"unsupported",message:"演示模式不提供设计能力,请切换到真实模式"};const t=e.runtime??od(e.snapshot).design,n=eD(e.snapshot.projectState,t);if(n)return{kind:"discovery_waiting_user",discovery:n,submitLabel:((r=t.recoveryAction)==null?void 0:r.label)??"确认并开始设计"};switch(t.status){case"idle":return{kind:"not_started"};case"running":return t.checkpoint==="discovery_confirmed"||e.live.designRound!==null?{kind:"generating",checkpoint:t.checkpoint,message:e.live.designMessage||t.message,round:e.live.designRound,agentEvents:e.live.designAgentEvents}:{kind:"discovery_preparing",message:e.live.designMessage||t.message};case"blocked":return{kind:"discovery_preparing",message:((s=t.block)==null?void 0:s.message)??t.message};case"succeeded":return{kind:"done",rounds:e.live.designRounds,agentEvents:e.live.designAgentEvents};case"failed":case"cancelled":return{kind:"failed",message:((i=t.error)==null?void 0:i.message)??t.message,retryable:((o=t.error)==null?void 0:o.retryable)??t.retryable??!0}}}function pD(e,t,n){var s;return n!=="live"?{kind:"open"}:t.design.status==="succeeded"||Rg(e)||(((s=e.workflow)==null?void 0:s.steps.length)??0)>0?{kind:"open"}:{kind:"blocked",reason:"搭建阶段必须使用当前流程生成的 workflow 和 recipes,请先完成设计阶段。",backTo:"design"}}function g_(e,t,n){return t!=="live"||e.setup.status==="succeeded"?{kind:"open"}:{kind:"blocked",reason:n,backTo:"setup"}}function mD(e,t){var n;return t!=="live"?null:e.setup.status==="failed"&&((n=e.setup.error)==null?void 0:n.code)==="TABLE_ID_NOT_RETURNED"?"manual_table_id":e.setup.status==="failed"||e.setup.status==="blocked"?"retry":null}function gD(e){var n;const t=(n=e.projectState)==null?void 0:n.runSnapshot;return{tickets:(t==null?void 0:t.records.map(r=>({id:r.id,title:r.title,customer:r.id,category:"真实记录",priority:r.state,status:r.status,currentStepId:r.currentStepId,doneStepIds:r.doneStepIds,createdAt:r.createdAt})))??[],logs:(t==null?void 0:t.logs.map(r=>({id:r.id,ts:r.ts,ticketId:r.itemId,stepId:r.stepId,level:r.level,text:r.text})))??[]}}function rk(e){var t,n;return sD((n=(t=e.projectState)==null?void 0:t.stages.setup)==null?void 0:n.task.outputs,"tableUrl")}function vD(e){var r;const t=e.projectState;if(!t)return null;if(t.activeStage&&t.stages[t.activeStage])return t.activeStage;let n=null;for(const s of tk){const i=(r=t.stages[s])==null?void 0:r.task;i&&(!n||i.updatedAt.localeCompare(n.updatedAt)>=0)&&(n={stage:s,updatedAt:i.updatedAt})}return(n==null?void 0:n.stage)??null}function sk(e,t="init"){const n=od(e);if(n.setup.status==="blocked"||n.setup.status==="failed")return"setup";const r=vD(e);return r==="design"&&n.design.status==="succeeded"&&nk(e)?"setup":r??t}function yD(e){for(const t of["design","setup","run"])if(e[t].status==="running")return{stage:t,taskId:e[t].taskId??null};return null}const _D=["init","design","setup","adjust","test","run"];function xD(e){return _D.includes(e)}function wD(e){var r,s;const{route:t}=e;if(t==="home")return{kind:"home"};if(t==="account")return{kind:"account"};if(t==="engines")return{kind:"engines"};if(t==="adjust")return{kind:"adjust"};if(e.loading.phase==="loading")return{kind:"loading",projectId:e.loading.projectId};if(e.loading.phase==="error")return{kind:"load_error",projectId:e.loading.projectId,message:e.loading.error??"项目加载失败"};if(!e.snapshot.projectId)return{kind:"no_project",intended:xD(t)?t:"init"};const n=od(e.snapshot);switch(t){case"init":return{kind:"init",runtime:n.init,config:e.initDraft,complete:n.init.status==="succeeded"};case"design":return{kind:"design",runtime:n.design,sub:hD({snapshot:e.snapshot,live:e.live,mode:e.mode,runtime:n.design}),hasArtifacts:nk(e.snapshot)};case"setup":return{kind:"setup",runtime:n.setup,gate:pD(e.snapshot,n,e.mode),schema:e.mode==="mock"&&e.mockSetup?{fields:e.mockSetup.fields,views:e.mockSetup.views}:JL((s=(r=e.snapshot.projectState)==null?void 0:r.stages.setup)==null?void 0:s.task.outputs)??{fields:[],views:[]},tableUrl:e.mode==="mock"&&e.mockSetup?e.mockSetup.tableUrl:rk(e.snapshot),recovery:mD(n,e.mode)};case"test":return{kind:"test",runtime:n.test,gate:g_(n,e.mode,"试运行必须基于已搭建完成的 AI 表格,请先完成搭建阶段。")};case"run":return{kind:"run",runtime:n.run,gate:g_(n,e.mode,"正式运行必须基于已搭建完成的 AI 表格,请先完成搭建阶段。"),tickets:e.live.tickets,logs:e.live.logs}}}function as(){return{projectId:null,projects:[],files:[],projectState:null,workflow:null,workflows:[],currentWorkflowId:null,workflowFiles:[],engineBinding:null,init:null}}function Pl(){return{designRound:null,designRounds:null,designAgentEvents:0,designProgressStep:null,designMessage:"",tickets:[],logs:[]}}aj({enforceActions:"always",computedRequiresReaction:!1});const v_="aitable-workflow:shell-state:v2",bD="aitable-workflow:state:v1",_f={name:"",agentsSelected:[],selectedMachineId:"",tableConnected:!1,tableBaseId:"",tableId:"",llmProvider:"",llmModel:"",roles:[],sop:""};class jD{constructor(){le(this,"route","home");le(this,"theme","light");le(this,"layout",{railCollapsed:!1,chatCollapsed:!1,chatWidth:460});le(this,"projectSource","new");le(this,"agentTraceOpen",!1);le(this,"agentTraceLog",[]);le(this,"initDraft",{..._f});le(this,"validation",{});le(this,"stepStatus",{});le(this,"mockSetup",{fields:[],views:[],tableUrl:null});le(this,"mode",ue?"live":"mock");le(this,"snapshot",as());le(this,"loading",{phase:"idle",projectId:null});le(this,"live",Pl());le(this,"persistedProjectId",null);le(this,"persistedWorkflowId",null);uj(this,{route:ve,theme:ve,layout:ve,projectSource:ve,agentTraceOpen:ve,agentTraceLog:ve.ref,initDraft:ve,validation:ve,stepStatus:ve,mockSetup:ve,snapshot:ve,loading:ve,live:ve,view:bn,stageRuntime:bn,stream:bn,recommendedStage:bn,steps:bn,edges:bn,setRoute:ie,toggleTheme:ie,setRailCollapsed:ie,setChatCollapsed:ie,setChatWidth:ie,setProjectSource:ie,setAgentTraceOpen:ie,toggleAgentTrace:ie,appendAgentTrace:ie,clearAgentTrace:ie,patchInitDraft:ie,setValidation:ie,setStepStatus:ie,addMockField:ie,addMockView:ie,setMockTableUrl:ie,addTicket:ie,updateTicket:ie,appendLog:ie,startNewWorkflow:ie,beginNewProject:ie,setEngineBinding:ie,reset:ie,beginLoad:ie,failLoad:ie,applyLoadedProject:ie,applySnapshotPatch:ie,applyServerFiles:ie,applyServerWorkflow:ie,setCurrentWorkflow:ie,setProjects:ie,setWorkflows:ie,clearProject:ie,patchLive:ie,applyDesignEvent:ie,applySetupEvent:ie,applyRunEvent:ie,applyRunRecords:ie,applyRunSchedule:ie,appendRunTimelineEntry:ie,appendRunPollError:ie}),this.hydrateFromStorage(),this.installPersistence()}get view(){return wD({route:this.route,loading:this.loading,snapshot:this.snapshot,live:this.live,mode:this.mode,initDraft:this.initDraft,mockSetup:this.mockSetup})}get stageRuntime(){return od(this.snapshot)}get stream(){return yD(this.stageRuntime)}get recommendedStage(){return sk(this.snapshot)}get steps(){var n;return(((n=this.snapshot.workflow)==null?void 0:n.steps)??[]).map(r=>this.stepStatus[r.id]?{...r,status:this.stepStatus[r.id]}:r)}get edges(){var t;return((t=this.snapshot.workflow)==null?void 0:t.edges)??[]}get validationContext(){return{steps:this.steps,init:this.initDraft,stageRuntime:this.stageRuntime}}get tableUrl(){return this.mode==="mock"?this.mockSetup.tableUrl:rk(this.snapshot)}get projectId(){return this.snapshot.projectId}get projects(){return this.snapshot.projects}get projectFiles(){return this.snapshot.files}get workflows(){return this.snapshot.workflows}get currentWorkflowId(){return this.snapshot.currentWorkflowId}get workflowFiles(){return this.snapshot.workflowFiles}setRoute(t){this.route=t}toggleTheme(){this.theme=this.theme==="light"?"dark":"light",typeof document<"u"&&document.documentElement.setAttribute("data-theme",this.theme)}setRailCollapsed(t){this.layout={...this.layout,railCollapsed:t}}setChatCollapsed(t){this.layout={...this.layout,chatCollapsed:t}}setChatWidth(t){this.layout={...this.layout,chatWidth:t,chatCollapsed:!1}}setProjectSource(t){this.projectSource=t}setAgentTraceOpen(t){this.agentTraceOpen=t}toggleAgentTrace(){this.agentTraceOpen=!this.agentTraceOpen}appendAgentTrace(t){const n=AL(this.agentTraceLog,Array.isArray(t)?t:[t]);n!==this.agentTraceLog&&(this.agentTraceLog=n)}clearAgentTrace(){this.agentTraceLog.length!==0&&(this.agentTraceLog=[])}patchInitDraft(t){this.initDraft={...this.initDraft,...t}}setValidation(t,n){this.validation={...this.validation,[t]:n}}setStepStatus(t,n){const r={...this.stepStatus};n?r[t]=n:delete r[t],this.stepStatus=r}addMockField(t){this.mockSetup={...this.mockSetup,fields:[...this.mockSetup.fields,t]}}addMockView(t){this.mockSetup={...this.mockSetup,views:[...this.mockSetup.views,t]}}setMockTableUrl(t){this.mockSetup={...this.mockSetup,tableUrl:t}}addTicket(t){this.live={...this.live,tickets:[t,...this.live.tickets]}}updateTicket(t,n){this.live={...this.live,tickets:this.live.tickets.map(r=>r.id===t?{...r,...n}:r)}}appendLog(t){this.live={...this.live,logs:[...this.live.logs,t]}}beginNewProject(t,n){this.startNewWorkflow(),this.projectSource="new",this.snapshot={...as(),projects:this.snapshot.projects,projectId:t},this.initDraft={..._f,name:n},this.loading={phase:"ready",projectId:t}}startNewWorkflow(){this.route="init",this.initDraft={..._f},this.live=Pl(),this.stepStatus={},this.mockSetup={fields:[],views:[],tableUrl:null},this.validation={},this.agentTraceLog=[],this.snapshot={...as(),projects:this.snapshot.projects,projectId:this.snapshot.projectId}}reset(){this.route="home",this.projectSource="new",this.startNewWorkflow(),this.route="home",this.snapshot={...as(),projects:this.snapshot.projects},this.loading={phase:"idle",projectId:null}}beginLoad(t){this.loading={phase:"loading",projectId:t}}failLoad(t,n){this.loading={phase:"error",projectId:t,error:n}}applyLoadedProject(t){this.snapshot=t.snapshot,this.live={...Pl(),...t.live},this.stepStatus={},t.snapshot.init&&(this.initDraft=t.snapshot.init),t.route&&(this.route=t.route),this.loading={phase:"ready",projectId:t.snapshot.projectId}}applySnapshotPatch(t,n){return this.snapshot.projectId!==t?!1:(this.snapshot={...this.snapshot,...n},!0)}applyServerFiles(t,n){return this.applySnapshotPatch(t,{files:n})}applyServerWorkflow(t,n){return this.applySnapshotPatch(t,{workflow:n})}setCurrentWorkflow(t,n){this.snapshot={...this.snapshot,currentWorkflowId:t,workflowFiles:n}}setProjects(t){this.snapshot={...this.snapshot,projects:t}}setWorkflows(t){this.snapshot={...this.snapshot,workflows:t}}setEngineBinding(t,n){this.applySnapshotPatch(t,{engineBinding:n})}clearProject(t){this.snapshot={...as(),projects:t},this.live=Pl(),this.stepStatus={},this.loading={phase:"idle",projectId:null},this.route="home",this.projectSource="new"}patchLive(t,n){return this.snapshot.projectId!==t?!1:(this.live={...this.live,...n},!0)}applyDesignEvent(t,n){return this.applyReducerPatch(t,r=>OL(r,n))}applySetupEvent(t,n){return this.applyReducerPatch(t,r=>$L(r,n))}applyRunEvent(t,n){return this.applyReducerPatch(t,r=>BL(r,n))}applyRunSchedule(t,n){return this.applyReducerPatch(t,r=>HL(r,n))}applyRunRecords(t,n){return this.applyReducerPatch(t,r=>UL(r,n))}appendRunTimelineEntry(t,n){return this.applyReducerPatch(t,r=>KL(r,n))}appendRunPollError(t,n){return this.applyReducerPatch(t,r=>GL(r,n))}applyReducerPatch(t,n){if(this.snapshot.projectId!==t)return!1;const r=n({projectId:t,projectState:this.snapshot.projectState,live:this.live,steps:this.steps});return(r.projectState||r.files)&&(this.snapshot={...this.snapshot,...r.projectState?{projectState:r.projectState}:{},...r.files?{files:r.files}:{}}),r.live&&(this.live={...this.live,...r.live}),!0}hydrateFromStorage(){if(!(typeof window>"u"))try{const t=window.localStorage.getItem(v_)??window.localStorage.getItem(bD);if(!t)return;const n=JSON.parse(t);if(typeof n!="object"||n===null)return;const r=n,s=lD(r.stage)?r.stage:"home",i=typeof r.projectId=="string"&&r.projectId.trim()?r.projectId:null,o=s!=="home"&&s!=="account"&&s!=="engines";K2(()=>{this.route=o&&!i?"home":s,(r.theme==="dark"||r.theme==="light")&&(this.theme=r.theme),typeof r.layout=="object"&&r.layout!==null&&(this.layout={...this.layout,...r.layout}),this.persistedProjectId=i,this.persistedWorkflowId=typeof r.currentWorkflowId=="string"&&r.currentWorkflowId.trim()?r.currentWorkflowId:null})}catch{}}installPersistence(){typeof window>"u"||sj(()=>{const t={version:2,stage:this.route,theme:this.theme,layout:this.layout,projectId:this.snapshot.projectId,currentWorkflowId:this.snapshot.currentWorkflowId};try{window.localStorage.setItem(v_,JSON.stringify(t))}catch{}})}}const z=new jD,SD={sparkle:"M12 2l1.9 5.8L20 9.7l-5.1 3.7L16 20l-4-3.6L8 20l1.1-6.6L4 9.7l6.1-1.9z",check:"M4 12l5 5L20 6","chevron-right":"M9 6l6 6-6 6","chevron-down":"M6 9l6 6 6-6","chevron-left":"M15 6l-6 6 6 6","chevron-up":"M6 15l6-6 6 6",plus:"M12 5v14M5 12h14",play:"M7 5v14l12-7z",pause:"M8 5v14M16 5v14",refresh:"M23 4v6h-6 M1 20v-6h6 M3.51 9a9 9 0 0114.85-3.36L23 10 M1 14l4.64 4.36A9 9 0 0020.49 15",moon:"M21 12.8A9 9 0 1111.2 3a7 7 0 009.8 9.8z",sun:"M12 4V2M12 22v-2M4 12H2M22 12h-2M5.6 5.6L4.2 4.2M19.8 19.8l-1.4-1.4M18.4 5.6l1.4-1.4M4.2 19.8l1.4-1.4M12 8a4 4 0 100 8 4 4 0 000-8z",table:"M3 5h18v14H3zM3 10h18M9 10v9M15 10v9",flow:"M5 5h5v5H5zM14 14h5v5h-5zM10 7h4M12 10v4",robot:"M12 3v3M7 6h10a2 2 0 012 2v9a2 2 0 01-2 2H7a2 2 0 01-2-2V8a2 2 0 012-2zM9 12h.01M15 12h.01",lock:"M6 11V8a6 6 0 0112 0v3M5 11h14v9H5z",bolt:"M13 2L4 14h6l-1 8 9-12h-6z",file:"M6 2h8l4 4v16H6zM14 2v4h4",folder:"M3 6h6l2 2h10v12H3z",link:"M10 13a5 5 0 007 0l2-2a5 5 0 00-7-7l-1 1M14 11a5 5 0 00-7 0l-2 2a5 5 0 007 7l1-1",send:"M22 2L11 13M22 2l-7 20-4-9-9-4z",user:"M12 12a4 4 0 100-8 4 4 0 000 8zM4 21a8 8 0 0116 0",warn:"M12 3l10 18H2zM12 10v5M12 18h.01",close:"M6 6l12 12M18 6L6 18",dot:"M12 12h.01"};function V({name:e,size:t=16,color:n="currentColor",style:r}){const s=e==="play"||e==="pause"||e==="sparkle"||e==="bolt";return a.jsx("svg",{width:t,height:t,viewBox:"0 0 24 24",fill:s?n:"none",stroke:s?"none":n,strokeWidth:1.8,strokeLinecap:"round",strokeLinejoin:"round",style:r,"aria-hidden":!0,children:a.jsx("path",{d:SD[e]})})}const kD="";async function ND(e,t){return await(await ik("/api/auth/register",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({username:e,password:t})})).json()}async function ED(e,t){return await(await ik("/api/auth/login",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({username:e,password:t})})).json()}async function ik(e,t){var r;let n;try{n=await fetch(`${kD}${e}`,t)}catch(s){const i=s instanceof Error?s.message:String(s);throw new Error(`无法连接后端服务(当前站点):${i}`)}if(!n.ok){const s=await n.text();try{const i=JSON.parse(s);if((r=i.error)!=null&&r.message)throw new Error(i.error.message)}catch(i){if(i instanceof Error&&i.message!==s)throw i}throw new Error(s||`HTTP ${n.status}`)}return n}const mp="aitable-auth:v1";function CD(){if(typeof window>"u")return{token:null,user:null};try{const e=window.localStorage.getItem(mp);if(!e)return{token:null,user:null};const t=JSON.parse(e);return{token:typeof t.token=="string"?t.token:null,user:t.user??null}}catch{return{token:null,user:null}}}function AD(e){if(!(typeof window>"u"))try{e.token?window.localStorage.setItem(mp,JSON.stringify(e)):window.localStorage.removeItem(mp)}catch{}}let xr=CD();const gp=new Set;function xf(){AD(xr);for(const e of gp)e()}const As={get(){return xr},isLoggedIn(){return xr.token!==null&&xr.user!==null},async login(e,t){const n=await ED(e,t);xr={token:n.token,user:n.user},xf()},async register(e,t){const n=await ND(e,t);xr={token:n.token,user:n.user},xf()},logout(){xr={token:null,user:null},xf()},getToken(){return xr.token},subscribe(e){return gp.add(e),()=>{gp.delete(e)}}},TD={token:null,user:null};function Og(){return b.useSyncExternalStore(As.subscribe,()=>As.get(),()=>TD)}let cu=null;function PD(e){cu=e}function MD(){return cu!==null}function ID(){const t=new URLSearchParams(window.location.search).get("token");if(t){PD(t);const n=new URL(window.location.href);return n.searchParams.delete("token"),window.history.replaceState({},"",n.toString()),!0}return!1}async function Bs(e,t){if(!cu)throw new Error("Dev token not set");const n=await fetch(e,{...t,headers:{...t==null?void 0:t.headers,Authorization:`Bearer ${cu}`}});if(!n.ok){const r=await n.text();try{const s=JSON.parse(r);if(s.error)throw new Error(s.error)}catch(s){if(s instanceof Error&&s.message!==r)throw s}throw new Error(r||`HTTP ${n.status}`)}return n}async function y_(e){return await(await Bs("/dev/config/save",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({updates:e})})).json()}async function RD(){await Bs("/dev/setup/complete",{method:"POST"})}async function OD(e,t){return await(await Bs("/dev/kb/upload",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({roleId:e,files:t})})).json()}async function $D(e,t){return await(await Bs("/dev/kb/ingest",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({roleId:e,source:t})})).json()}async function LD(){return await(await Bs("/dev/config/enriched")).json()}async function DD(e){return await(await Bs(`/dev/file/read?path=${encodeURIComponent(e)}`)).json()}async function zD(e,t){return await(await Bs("/dev/file/write",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({path:e,content:t})})).json()}const VD=[{id:"init",label:"配置"},{id:"design",label:"设计"},{id:"setup",label:"搭建"},{id:"test",label:"试运行"},{id:"run",label:"运行"}],FD=[{id:"adjust",label:"参数调整"}],BD=ut(function(){const t=z.route,n=z.stageRuntime,r=z.projectSource,s=MD()?FD:VD;return a.jsx("nav",{className:"stepper","aria-label":"阶段进度",children:s.map((i,o)=>{const l=i.id===t,c=n[i.id].status==="succeeded",u=r==="imported"&&(i.id==="init"||i.id==="design"||i.id==="setup");return a.jsxs(b.Fragment,{children:[o>0&&a.jsx("span",{className:"stepper__sep"}),a.jsxs("button",{type:"button",className:"stepper__item"+(l?" is-active":"")+(c||u?" is-done":""),onClick:()=>z.setRoute(i.id),title:u?"已随包导入":void 0,children:[a.jsx("span",{className:"stepper__num",children:c||u?a.jsx(V,{name:"check",size:12}):o+1}),i.label]})]},i.id)})})}),HD="";async function $g(){return(await(await ye("/api/projects",{method:"POST"})).json()).project}async function UD(e,t){const n={};return e&&e.trim()&&(n.title=e.trim()),t&&t.length>0&&(n.files=t),await(await ye("/api/projects",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify(n)})).json()}async function WD(e){return await(await ye(`/api/projects/${e}`,{method:"DELETE"})).json()}async function KD(e){return await(await ye(`/api/projects/${e}/export`)).json()}async function GD(e){return await(await ye(`/api/projects/${e}/validate`,{method:"POST"})).json()}async function vp(e){return(await(await ye(`/api/projects/${e}/workflows`)).json()).workflows}async function qD(e,t){const n={name:t.name};return t.templatePath&&(n.templatePath=t.templatePath),t.files&&t.files.length>0&&(n.files=t.files),await(await ye(`/api/projects/${e}/workflows`,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify(n)})).json()}async function yp(e,t){return await(await ye(`/api/projects/${e}/workflows/${t}`)).json()}async function YD(e,t){return await(await ye(`/api/projects/${e}/workflows/${t}`,{method:"DELETE"})).json()}async function ok(){await ye("/api/health")}async function XD(){return await(await ye("/api/agents")).json()}async function ak(){return(await(await ye("/api/projects")).json()).projects}async function QD(e,t){return(await(await ye(`/api/projects/${e}`,{method:"PATCH",headers:{"content-type":"application/json"},body:JSON.stringify({title:t})})).json()).project}async function Lg(e){return await(await ye(`/api/projects/${e}/state`)).json()}async function ZD(e,t){return await(await ye(`/api/projects/${e}/init`,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify(t)})).json()}async function JD(e,t){return await(await ye(`/api/projects/${e}/table-id`,{method:"PATCH",headers:{"content-type":"application/json"},body:JSON.stringify({tableId:t})})).json()}async function e3(e){return await(await ye(`/api/projects/${e}/design/discovery`,{method:"POST"})).json()}async function t3(e,t){return await(await ye(`/api/projects/${e}/design/discovery/confirm`,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({answers:t})})).json()}async function ad(e,t){const n=t?`?workflowId=${encodeURIComponent(t)}`:"",s=await(await ye(`/api/projects/${e}/workflow${n}`)).json();return p3(s.workflow)}async function Dg(e){return(await(await ye(`/api/projects/${e}/files`)).json()).files}async function n3(e,t){await ck(`/api/projects/${e}/design`,t)}async function r3(e,t){await ck(`/api/projects/${e}/setup`,t)}async function s3(e,t,n){const r=`/api/projects/${e}/run`,s=await ye(r,{method:"POST",signal:n==null?void 0:n.signal});return c3(s)?{mode:"lease",schedule:(await s.json()).schedule}:(await uk(r,s,t,n),{mode:"local"})}async function i3(e){return await(await ye(`/api/projects/${e}/run/stop`,{method:"POST"})).json()}async function o3(e){return await(await ye(`/api/projects/${e}/run/status`)).json()}async function a3(e,t){return await(await ye(`/api/projects/${e}/run/records`)).json()}async function l3(e,t){const n=new URLSearchParams;t!=null&&t.afterSeq&&n.set("afterSeq",String(t.afterSeq)),t!=null&&t.limit&&n.set("limit",String(t.limit));const r=n.size>0?`?${n.toString()}`:"";return await(await ye(`/api/projects/${e}/run/events${r}`)).json()}function c3(e){return(e.headers.get("content-type")??"").includes("application/json")}async function u3(e,t,n){return(await(await ye(`/api/projects/${e}/run/records/${t}/human-action`,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({action:n})})).json()).state}async function fc(e){return await(await ye(`/api/projects/${e}/engine`)).json()}async function lk(e,t){await ye(`/api/projects/${e}/engine`,{method:"PUT",headers:{"content-type":"application/json"},body:JSON.stringify({machineId:t})})}async function ye(e,t){var s;const n=As.getToken();if(n){const i=new Headers(t==null?void 0:t.headers);i.set("Authorization",`Bearer ${n}`),t={...t,headers:i}}let r;try{r=await fetch(`${HD}${e}`,t)}catch(i){const o=i instanceof Error?i.message:String(i);throw new Error(`无法连接真实后端服务(当前站点):${o}`)}if(!r.ok){const i=await r.text();try{const o=JSON.parse(i);if((s=o.error)!=null&&s.message)throw new Error(o.error.message)}catch(o){if(o instanceof Error&&o.message!==i)throw o}throw new Error(i||`HTTP ${r.status}`)}return r}const d3=5,f3=500,h3=8e3;async function ck(e,t,n){const r=await ye(e,{method:"POST",signal:n==null?void 0:n.signal});await uk(e,r,t,n)}async function uk(e,t,n,r){var l,c;let s=null,i=0,o=t;for(;;){if((l=r==null?void 0:r.signal)!=null&&l.aborted)return;try{if(!o){const h=s?`${e}${e.includes("?")?"&":"?"}cursor=${encodeURIComponent(s)}`:e;o=await ye(h,{method:"POST",signal:r==null?void 0:r.signal})}if(!o.body)return;const u=o.body.getReader(),d=new TextDecoder;let f="";for(;;){const{done:h,value:p}=await u.read();if(h)return;i=0,f+=d.decode(p,{stream:!0});const v=f.split(`
|
|
61
61
|
|
|
62
62
|
`);f=v.pop()??"";for(const x of v){const w=x.split(`
|
|
63
63
|
`),g=w.find(m=>m.startsWith("id: "));g&&(s=g.slice(4).trim());const y=w.find(m=>m.startsWith("data: "));y&&await n(JSON.parse(y.slice(6)))}}}catch(u){if((c=r==null?void 0:r.signal)!=null&&c.aborted)return;if(o=null,i+=1,i>d3)throw u;const d=Math.min(h3,f3*2**(i-1));await new Promise(f=>setTimeout(f,d))}}}function p3(e){return{steps:e.steps.map(t=>({id:t.id,name:t.name,recipe:t.recipe??"",engine:m3(t.engine),auto:t.auto,requiresAgent:!!t.requires_agent,needsHuman:!!t.needs_human,inputs:Object.values(t.input_mapping??{}),outputs:Object.values(t.output_mapping??{}),status:"idle"})),edges:e.edges.filter(t=>t.from!=="__start__"&&t.to!=="__end__")}}function m3(e){return e==="claude"||e==="codex"||e==="qoder"||e==="qwenwork"||e==="llm_only"?e:"llm_only"}async function g3(e,t){const n=await vp(e);if(n.length===0)return{workflows:[],currentWorkflowId:null,workflowFiles:[]};const r=t&&n.some(i=>i.id===t)?t:n[0].id;let s=[];try{s=(await yp(e,r)).files}catch{}return{workflows:n,currentWorkflowId:r,workflowFiles:s}}async function ba(e,t={}){if(!ue)return;const n=e??"@first",r=wf.get(n);if(r)return r;const s=v3(e,t).finally(()=>{wf.delete(n)});return wf.set(n,s),s}const wf=new Map;async function v3(e,t){z.beginLoad(e);try{await ok();const n=await ak();if(e&&!n.some(o=>o.id===e)){z.clearProject(n);return}const r=e?n.find(o=>o.id===e):n[0];if(!r){z.clearProject(n);return}const s=await _3(r.id,n),i=t.applyRecommendedStage===!1?void 0:sk(s,x3(t.fallbackRoute));z.applyLoadedProject({snapshot:s,live:gD(s),route:i})}catch(n){z.failLoad(e,n instanceof Error?n.message:String(n))}}async function __(e){if(!ue)return;const t=await Lg(e).catch(()=>null);t&&z.applySnapshotPatch(e,{projectState:t})}async function y3(e,t={}){const n=t.intervalMs??2e3,r=t.timeoutMs??10*60*1e3,s=Date.now()+r;for(;Date.now()<s;){if(await new Promise(o=>setTimeout(o,n)),z.projectId!==e)return;const i=await Lg(e).catch(()=>null);if(i&&(!z.applySnapshotPatch(e,{projectState:i})||!z.stream))return}}async function _3(e,t){const n=await Dg(e),r=await Lg(e).catch(()=>null),s=await g3(e,z.persistedWorkflowId).catch(()=>({workflows:[],currentWorkflowId:null,workflowFiles:[]})),i=n.some(c=>c.path==="workflow.yml"||c.path.endsWith("/workflow.yml"))?await ad(e,s.currentWorkflowId).catch(()=>null):null,o=it?await fc(e).catch(()=>null):null,l=tD(n);return l&&(o!=null&&o.machineId)&&(l.selectedMachineId=o.machineId),{...as(),projectId:e,projects:t,files:n,projectState:r,workflow:i,workflows:s.workflows,currentWorkflowId:s.currentWorkflowId,workflowFiles:s.workflowFiles,engineBinding:o,init:l}}function x3(e){return e&&e!=="home"&&e!=="account"&&e!=="engines"?e:void 0}function dk({onConfirm:e,onCancel:t}){const[n,r]=b.useState("未命名项目");return a.jsx("div",{className:"modal-overlay",onClick:t,children:a.jsxs("div",{className:"import-panel",style:{maxWidth:400},onClick:s=>s.stopPropagation(),children:[a.jsxs("div",{className:"import-panel__head",children:[a.jsx("span",{className:"import-panel__title",children:"新建项目"}),a.jsx("button",{type:"button",className:"modal-card__close",onClick:t,children:a.jsx(V,{name:"close",size:14})})]}),a.jsx("div",{className:"import-panel__body",children:a.jsxs("div",{className:"role-field",children:[a.jsx("label",{className:"role-field__label",children:"项目名称"}),a.jsx("input",{className:"import-confirm__input",value:n,onChange:s=>r(s.target.value),placeholder:"输入项目名称",autoFocus:!0,onKeyDown:s=>{s.key==="Enter"&&n.trim()&&e(n.trim())}})]})}),a.jsxs("div",{className:"import-panel__foot",children:[a.jsx("button",{type:"button",className:"modal-card__btn",onClick:t,children:"取消"}),a.jsx("button",{type:"button",className:"primary modal-card__btn",disabled:!n.trim(),onClick:()=>e(n.trim()),children:"创建项目"})]})]})})}var x_={},w3=function(e,t,n,r,s){var i=new Worker(x_[t]||(x_[t]=URL.createObjectURL(new Blob([e+';addEventListener("error",function(e){e=e.error;postMessage({$e$:[e.message,e.code,e.stack]})})'],{type:"text/javascript"}))));return i.onmessage=function(o){var l=o.data,c=l.$e$;if(c){var u=new Error(c[0]);u.code=c[1],u.stack=c[2],s(u,null)}else s(null,l)},i.postMessage(n,r),i},Ce=Uint8Array,ot=Uint16Array,Qa=Int32Array,ro=new Ce([0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0,0,0,0]),so=new Ce([0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13,0,0]),ja=new Ce([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),fk=function(e,t){for(var n=new ot(31),r=0;r<31;++r)n[r]=t+=1<<e[r-1];for(var s=new Qa(n[30]),r=1;r<30;++r)for(var i=n[r];i<n[r+1];++i)s[i]=i-n[r]<<5|r;return{b:n,r:s}},hk=fk(ro,2),zg=hk.b,uu=hk.r;zg[28]=258,uu[258]=28;var pk=fk(so,0),mk=pk.b,_p=pk.r,Sa=new ot(32768);for(var je=0;je<32768;++je){var gr=(je&43690)>>1|(je&21845)<<1;gr=(gr&52428)>>2|(gr&13107)<<2,gr=(gr&61680)>>4|(gr&3855)<<4,Sa[je]=((gr&65280)>>8|(gr&255)<<8)>>1}var Gt=function(e,t,n){for(var r=e.length,s=0,i=new ot(t);s<r;++s)e[s]&&++i[e[s]-1];var o=new ot(t);for(s=1;s<t;++s)o[s]=o[s-1]+i[s-1]<<1;var l;if(n){l=new ot(1<<t);var c=15-t;for(s=0;s<r;++s)if(e[s])for(var u=s<<4|e[s],d=t-e[s],f=o[e[s]-1]++<<d,h=f|(1<<d)-1;f<=h;++f)l[Sa[f]>>c]=u}else for(l=new ot(r),s=0;s<r;++s)e[s]&&(l[s]=Sa[o[e[s]-1]++]>>15-e[s]);return l},fr=new Ce(288);for(var je=0;je<144;++je)fr[je]=8;for(var je=144;je<256;++je)fr[je]=9;for(var je=256;je<280;++je)fr[je]=7;for(var je=280;je<288;++je)fr[je]=8;var Fi=new Ce(32);for(var je=0;je<32;++je)Fi[je]=5;var gk=Gt(fr,9,0),vk=Gt(fr,9,1),yk=Gt(Fi,5,0),_k=Gt(Fi,5,1),hc=function(e){for(var t=e[0],n=1;n<e.length;++n)e[n]>t&&(t=e[n]);return t},$t=function(e,t,n){var r=t/8|0;return(e[r]|e[r+1]<<8)>>(t&7)&n},pc=function(e,t){var n=t/8|0;return(e[n]|e[n+1]<<8|e[n+2]<<16)>>(t&7)},Za=function(e){return(e+7)/8|0},Hs=function(e,t,n){return(t==null||t<0)&&(t=0),(n==null||n>e.length)&&(n=e.length),new Ce(e.subarray(t,n))},xk=["unexpected EOF","invalid block type","invalid length/literal","invalid distance","stream finished","no stream handler",,"no callback","invalid UTF-8 data","extra field too long","date not in range 1980-2099","filename too long","stream finishing","invalid zip data"],De=function(e,t,n){var r=new Error(t||xk[e]);if(r.code=e,Error.captureStackTrace&&Error.captureStackTrace(r,De),!n)throw r;return r},wk=function(e,t,n,r){var s=e.length,i=r?r.length:0;if(!s||t.f&&!t.l)return n||new Ce(0);var o=!n,l=o||t.i!=2,c=t.i;o&&(n=new Ce(s*3));var u=function(te){var ee=n.length;if(te>ee){var X=new Ce(Math.max(ee*2,te));X.set(n),n=X}},d=t.f||0,f=t.p||0,h=t.b||0,p=t.l,v=t.d,x=t.m,w=t.n,g=s*8;do{if(!p){d=$t(e,f,1);var y=$t(e,f+1,3);if(f+=3,y)if(y==1)p=vk,v=_k,x=9,w=5;else if(y==2){var N=$t(e,f,31)+257,k=$t(e,f+10,15)+4,S=N+$t(e,f+5,31)+1;f+=14;for(var P=new Ce(S),$=new Ce(19),D=0;D<k;++D)$[ja[D]]=$t(e,f+D*3,7);f+=k*3;for(var I=hc($),O=(1<<I)-1,E=Gt($,I,1),D=0;D<S;){var A=E[$t(e,f,O)];f+=A&15;var m=A>>4;if(m<16)P[D++]=m;else{var C=0,M=0;for(m==16?(M=3+$t(e,f,3),f+=2,C=P[D-1]):m==17?(M=3+$t(e,f,7),f+=3):m==18&&(M=11+$t(e,f,127),f+=7);M--;)P[D++]=C}}var T=P.subarray(0,N),R=P.subarray(N);x=hc(T),w=hc(R),p=Gt(T,x,1),v=Gt(R,w,1)}else De(1);else{var m=Za(f)+4,_=e[m-4]|e[m-3]<<8,j=m+_;if(j>s){c&&De(0);break}l&&u(h+_),n.set(e.subarray(m,j),h),t.b=h+=_,t.p=f=j*8,t.f=d;continue}if(f>g){c&&De(0);break}}l&&u(h+131072);for(var B=(1<<x)-1,L=(1<<w)-1,F=f;;F=f){var C=p[pc(e,f)&B],W=C>>4;if(f+=C&15,f>g){c&&De(0);break}if(C||De(2),W<256)n[h++]=W;else if(W==256){F=f,p=null;break}else{var U=W-254;if(W>264){var D=W-257,K=ro[D];U=$t(e,f,(1<<K)-1)+zg[D],f+=K}var Q=v[pc(e,f)&L],J=Q>>4;Q||De(3),f+=Q&15;var R=mk[J];if(J>3){var K=so[J];R+=pc(e,f)&(1<<K)-1,f+=K}if(f>g){c&&De(0);break}l&&u(h+131072);var H=h+U;if(h<R){var q=i-R,ne=Math.min(R,H);for(q+h<0&&De(3);h<ne;++h)n[h]=r[q+h]}for(;h<H;++h)n[h]=n[h-R]}}t.l=p,t.p=F,t.b=h,t.f=d,p&&(d=1,t.m=x,t.d=v,t.n=w)}while(!d);return h!=n.length&&o?Hs(n,0,h):n.subarray(0,h)},xn=function(e,t,n){n<<=t&7;var r=t/8|0;e[r]|=n,e[r+1]|=n>>8},Ys=function(e,t,n){n<<=t&7;var r=t/8|0;e[r]|=n,e[r+1]|=n>>8,e[r+2]|=n>>16},mc=function(e,t){for(var n=[],r=0;r<e.length;++r)e[r]&&n.push({s:r,f:e[r]});var s=n.length,i=n.slice();if(!s)return{t:Fg,l:0};if(s==1){var o=new Ce(n[0].s+1);return o[n[0].s]=1,{t:o,l:1}}n.sort(function(j,N){return j.f-N.f}),n.push({s:-1,f:25001});var l=n[0],c=n[1],u=0,d=1,f=2;for(n[0]={s:-1,f:l.f+c.f,l,r:c};d!=s-1;)l=n[n[u].f<n[f].f?u++:f++],c=n[u!=d&&n[u].f<n[f].f?u++:f++],n[d++]={s:-1,f:l.f+c.f,l,r:c};for(var h=i[0].s,r=1;r<s;++r)i[r].s>h&&(h=i[r].s);var p=new ot(h+1),v=du(n[d-1],p,0);if(v>t){var r=0,x=0,w=v-t,g=1<<w;for(i.sort(function(N,k){return p[k.s]-p[N.s]||N.f-k.f});r<s;++r){var y=i[r].s;if(p[y]>t)x+=g-(1<<v-p[y]),p[y]=t;else break}for(x>>=w;x>0;){var m=i[r].s;p[m]<t?x-=1<<t-p[m]++-1:++r}for(;r>=0&&x;--r){var _=i[r].s;p[_]==t&&(--p[_],++x)}v=t}return{t:new Ce(p),l:v}},du=function(e,t,n){return e.s==-1?Math.max(du(e.l,t,n+1),du(e.r,t,n+1)):t[e.s]=n},xp=function(e){for(var t=e.length;t&&!e[--t];);for(var n=new ot(++t),r=0,s=e[0],i=1,o=function(c){n[r++]=c},l=1;l<=t;++l)if(e[l]==s&&l!=t)++i;else{if(!s&&i>2){for(;i>138;i-=138)o(32754);i>2&&(o(i>10?i-11<<5|28690:i-3<<5|12305),i=0)}else if(i>3){for(o(s),--i;i>6;i-=6)o(8304);i>2&&(o(i-3<<5|8208),i=0)}for(;i--;)o(s);i=1,s=e[l]}return{c:n.subarray(0,r),n:t}},Xs=function(e,t){for(var n=0,r=0;r<t.length;++r)n+=e[r]*t[r];return n},Vg=function(e,t,n){var r=n.length,s=Za(t+2);e[s]=r&255,e[s+1]=r>>8,e[s+2]=e[s]^255,e[s+3]=e[s+1]^255;for(var i=0;i<r;++i)e[s+i+4]=n[i];return(s+4+r)*8},wp=function(e,t,n,r,s,i,o,l,c,u,d){xn(t,d++,n),++s[256];for(var f=mc(s,15),h=f.t,p=f.l,v=mc(i,15),x=v.t,w=v.l,g=xp(h),y=g.c,m=g.n,_=xp(x),j=_.c,N=_.n,k=new ot(19),S=0;S<y.length;++S)++k[y[S]&31];for(var S=0;S<j.length;++S)++k[j[S]&31];for(var P=mc(k,7),$=P.t,D=P.l,I=19;I>4&&!$[ja[I-1]];--I);var O=u+5<<3,E=Xs(s,fr)+Xs(i,Fi)+o,A=Xs(s,h)+Xs(i,x)+o+14+3*I+Xs(k,$)+2*k[16]+3*k[17]+7*k[18];if(c>=0&&O<=E&&O<=A)return Vg(t,d,e.subarray(c,c+u));var C,M,T,R;if(xn(t,d,1+(A<E)),d+=2,A<E){C=Gt(h,p,0),M=h,T=Gt(x,w,0),R=x;var B=Gt($,D,0);xn(t,d,m-257),xn(t,d+5,N-1),xn(t,d+10,I-4),d+=14;for(var S=0;S<I;++S)xn(t,d+3*S,$[ja[S]]);d+=3*I;for(var L=[y,j],F=0;F<2;++F)for(var W=L[F],S=0;S<W.length;++S){var U=W[S]&31;xn(t,d,B[U]),d+=$[U],U>15&&(xn(t,d,W[S]>>5&127),d+=W[S]>>12)}}else C=gk,M=fr,T=yk,R=Fi;for(var S=0;S<l;++S){var K=r[S];if(K>255){var U=K>>18&31;Ys(t,d,C[U+257]),d+=M[U+257],U>7&&(xn(t,d,K>>23&31),d+=ro[U]);var Q=K&31;Ys(t,d,T[Q]),d+=R[Q],Q>3&&(Ys(t,d,K>>5&8191),d+=so[Q])}else Ys(t,d,C[K]),d+=M[K]}return Ys(t,d,C[256]),d+M[256]},bk=new Qa([65540,131080,131088,131104,262176,1048704,1048832,2114560,2117632]),Fg=new Ce(0),jk=function(e,t,n,r,s,i){var o=i.z||e.length,l=new Ce(r+o+5*(1+Math.ceil(o/7e3))+s),c=l.subarray(r,l.length-s),u=i.l,d=(i.r||0)&7;if(t){d&&(c[0]=i.r>>3);for(var f=bk[t-1],h=f>>13,p=f&8191,v=(1<<n)-1,x=i.p||new ot(32768),w=i.h||new ot(v+1),g=Math.ceil(n/3),y=2*g,m=function(ae){return(e[ae]^e[ae+1]<<g^e[ae+2]<<y)&v},_=new Qa(25e3),j=new ot(288),N=new ot(32),k=0,S=0,P=i.i||0,$=0,D=i.w||0,I=0;P+2<o;++P){var O=m(P),E=P&32767,A=w[O];if(x[E]=A,w[O]=E,D<=P){var C=o-P;if((k>7e3||$>24576)&&(C>423||!u)){d=wp(e,c,0,_,j,N,S,$,I,P-I,d),$=k=S=0,I=P;for(var M=0;M<286;++M)j[M]=0;for(var M=0;M<30;++M)N[M]=0}var T=2,R=0,B=p,L=E-A&32767;if(C>2&&O==m(P-L))for(var F=Math.min(h,C)-1,W=Math.min(32767,P),U=Math.min(258,C);L<=W&&--B&&E!=A;){if(e[P+T]==e[P+T-L]){for(var K=0;K<U&&e[P+K]==e[P+K-L];++K);if(K>T){if(T=K,R=L,K>F)break;for(var Q=Math.min(L,K-2),J=0,M=0;M<Q;++M){var H=P-L+M&32767,q=x[H],ne=H-q&32767;ne>J&&(J=ne,A=H)}}}E=A,A=x[E],L+=E-A&32767}if(R){_[$++]=268435456|uu[T]<<18|_p[R];var te=uu[T]&31,ee=_p[R]&31;S+=ro[te]+so[ee],++j[257+te],++N[ee],D=P+T,++k}else _[$++]=e[P],++j[e[P]]}}for(P=Math.max(P,D);P<o;++P)_[$++]=e[P],++j[e[P]];d=wp(e,c,u,_,j,N,S,$,I,P-I,d),u||(i.r=d&7|c[d/8|0]<<3,d-=7,i.h=w,i.p=x,i.i=P,i.w=D)}else{for(var P=i.w||0;P<o+u;P+=65535){var X=P+65535;X>=o&&(c[d/8|0]=u,X=o),d=Vg(c,d+1,e.subarray(P,X))}i.i=o}return Hs(l,0,r+Za(d)+s)},b3=function(){for(var e=new Int32Array(256),t=0;t<256;++t){for(var n=t,r=9;--r;)n=(n&1&&-306674912)^n>>>1;e[t]=n}return e}(),j3=function(){var e=-1;return{p:function(t){for(var n=e,r=0;r<t.length;++r)n=b3[n&255^t[r]]^n>>>8;e=n},d:function(){return~e}}},Sk=function(e,t,n,r,s){if(!s&&(s={l:1},t.dictionary)){var i=t.dictionary.subarray(-32768),o=new Ce(i.length+e.length);o.set(i),o.set(e,i.length),e=o,s.w=i.length}return jk(e,t.level==null?6:t.level,t.mem==null?s.l?Math.ceil(Math.max(8,Math.min(13,Math.log(e.length)))*1.5):20:12+t.mem,n,r,s)},Bg=function(e,t){var n={};for(var r in e)n[r]=e[r];for(var r in t)n[r]=t[r];return n},w_=function(e,t,n){for(var r=e(),s=e.toString(),i=s.slice(s.indexOf("[")+1,s.lastIndexOf("]")).replace(/\s+/g,"").split(","),o=0;o<r.length;++o){var l=r[o],c=i[o];if(typeof l=="function"){t+=";"+c+"=";var u=l.toString();if(l.prototype)if(u.indexOf("[native code]")!=-1){var d=u.indexOf(" ",8)+1;t+=u.slice(d,u.indexOf("(",d))}else{t+=u;for(var f in l.prototype)t+=";"+c+".prototype."+f+"="+l.prototype[f].toString()}else t+=u}else n[c]=l}return t},Ml=[],S3=function(e){var t=[];for(var n in e)e[n].buffer&&t.push((e[n]=new e[n].constructor(e[n])).buffer);return t},k3=function(e,t,n,r){if(!Ml[n]){for(var s="",i={},o=e.length-1,l=0;l<o;++l)s=w_(e[l],s,i);Ml[n]={c:w_(e[o],s,i),e:i}}var c=Bg({},Ml[n].e);return w3(Ml[n].c+";onmessage=function(e){for(var k in e.data)self[k]=e.data[k];onmessage="+t.toString()+"}",n,c,S3(c),r)},N3=function(){return[Ce,ot,Qa,ro,so,ja,zg,mk,vk,_k,Sa,xk,Gt,hc,$t,pc,Za,Hs,De,wk,Ug,ld,kk]},E3=function(){return[Ce,ot,Qa,ro,so,ja,uu,_p,gk,fr,yk,Fi,Sa,bk,Fg,Gt,xn,Ys,mc,du,xp,Xs,Vg,wp,Za,Hs,jk,Sk,Hg,ld]},ld=function(e){return postMessage(e,[e.buffer])},kk=function(e){return e&&{out:e.size&&new Ce(e.size),dictionary:e.dictionary}},Nk=function(e,t,n,r,s,i){var o=k3(n,r,s,function(l,c){o.terminate(),i(l,c)});return o.postMessage([e,t],t.consume?[e.buffer]:[]),function(){o.terminate()}},Nn=function(e,t){return e[t]|e[t+1]<<8},Dt=function(e,t){return(e[t]|e[t+1]<<8|e[t+2]<<16|e[t+3]<<24)>>>0},bf=function(e,t){return Dt(e,t)+Dt(e,t+4)*4294967296},Ge=function(e,t,n){for(;n;++t)e[t]=n,n>>>=8};function C3(e,t,n){return n||(n=t,t={}),typeof n!="function"&&De(7),Nk(e,t,[E3],function(r){return ld(Hg(r.data[0],r.data[1]))},0,n)}function Hg(e,t){return Sk(e,t||{},0,0)}function A3(e,t,n){return n||(n=t,t={}),typeof n!="function"&&De(7),Nk(e,t,[N3],function(r){return ld(Ug(r.data[0],kk(r.data[1])))},1,n)}function Ug(e,t){return wk(e,{i:2},t&&t.out,t&&t.dictionary)}var Ek=function(e,t,n,r){for(var s in e){var i=e[s],o=t+s,l=r;Array.isArray(i)&&(l=Bg(r,i[1]),i=i[0]),ArrayBuffer.isView(i)?n[o]=[i,l]:(n[o+="/"]=[new Ce(0),l],Ek(i,o,n,r))}},b_=typeof TextEncoder<"u"&&new TextEncoder,bp=typeof TextDecoder<"u"&&new TextDecoder,T3=0;try{bp.decode(Fg,{stream:!0}),T3=1}catch{}var P3=function(e){for(var t="",n=0;;){var r=e[n++],s=(r>127)+(r>223)+(r>239);if(n+s>e.length)return{s:t,r:Hs(e,n-1)};s?s==3?(r=((r&15)<<18|(e[n++]&63)<<12|(e[n++]&63)<<6|e[n++]&63)-65536,t+=String.fromCharCode(55296|r>>10,56320|r&1023)):s&1?t+=String.fromCharCode((r&31)<<6|e[n++]&63):t+=String.fromCharCode((r&15)<<12|(e[n++]&63)<<6|e[n++]&63):t+=String.fromCharCode(r)}};function jp(e,t){var n;if(b_)return b_.encode(e);for(var r=e.length,s=new Ce(e.length+(e.length>>1)),i=0,o=function(u){s[i++]=u},n=0;n<r;++n){if(i+5>s.length){var l=new Ce(i+8+(r-n<<1));l.set(s),s=l}var c=e.charCodeAt(n);c<128||t?o(c):c<2048?(o(192|c>>6),o(128|c&63)):c>55295&&c<57344?(c=65536+(c&1047552)|e.charCodeAt(++n)&1023,o(240|c>>18),o(128|c>>12&63),o(128|c>>6&63),o(128|c&63)):(o(224|c>>12),o(128|c>>6&63),o(128|c&63))}return Hs(s,0,i)}function Ck(e,t){if(t){for(var n="",r=0;r<e.length;r+=16384)n+=String.fromCharCode.apply(null,e.subarray(r,r+16384));return n}else{if(bp)return bp.decode(e);var s=P3(e),i=s.s,n=s.r;return n.length&&De(8),i}}var M3=function(e,t){return t+30+Nn(e,t+26)+Nn(e,t+28)},I3=function(e,t,n){var r=Nn(e,t+28),s=Nn(e,t+30),i=Ck(e.subarray(t+46,t+46+r),!(Nn(e,t+8)&2048)),o=t+46+r,l=R3(e,o,s,n,Dt(e,t+20),Dt(e,t+24),Dt(e,t+42)),c=l[0],u=l[1],d=l[2];return[Nn(e,t+10),c,u,i,o+s+Nn(e,t+32),d]},R3=function(e,t,n,r,s,i,o){var l=s==4294967295,c=i==4294967295,u=o==4294967295,d=t+n,f=l+c+u;if(r&&f){for(;t+4<d;t+=4+Nn(e,t+2))if(Nn(e,t)==1)return[l?bf(e,t+4+8*c):s,c?bf(e,t+4):i,u?bf(e,t+4+8*(c+l)):o,1];r<2&&De(13)}return[s,i,o,0]},Sp=function(e){var t=0;if(e)for(var n in e){var r=e[n].length;r>65535&&De(9),t+=r+4}return t},j_=function(e,t,n,r,s,i,o,l){var c=r.length,u=n.extra,d=l&&l.length,f=Sp(u);Ge(e,t,o!=null?33639248:67324752),t+=4,o!=null&&(e[t++]=20,e[t++]=n.os),e[t]=20,t+=2,e[t++]=n.flag<<1|(i<0&&8),e[t++]=s&&8,e[t++]=n.compression&255,e[t++]=n.compression>>8;var h=new Date(n.mtime==null?Date.now():n.mtime),p=h.getFullYear()-1980;if((p<0||p>119)&&De(10),Ge(e,t,p<<25|h.getMonth()+1<<21|h.getDate()<<16|h.getHours()<<11|h.getMinutes()<<5|h.getSeconds()>>1),t+=4,i!=-1&&(Ge(e,t,n.crc),Ge(e,t+4,i<0?-i-2:i),Ge(e,t+8,n.size)),Ge(e,t+12,c),Ge(e,t+14,f),t+=16,o!=null&&(Ge(e,t,d),Ge(e,t+6,n.attrs),Ge(e,t+10,o),t+=14),e.set(r,t),t+=c,f)for(var v in u){var x=u[v],w=x.length;Ge(e,t,+v),Ge(e,t+2,w),e.set(x,t+4),t+=4+w}return d&&(e.set(l,t),t+=d),t},O3=function(e,t,n,r,s){Ge(e,t,101010256),Ge(e,t+8,n),Ge(e,t+10,n),Ge(e,t+12,r),Ge(e,t+16,s)};function $3(e,t,n){n||(n=t,t={}),typeof n!="function"&&De(7);var r={};Ek(e,"",r,t);var s=Object.keys(r),i=s.length,o=0,l=0,c=i,u=new Array(i),d=[],f=function(){for(var w=0;w<d.length;++w)d[w]()},h=function(w,g){fu(function(){n(w,g)})};fu(function(){h=n});var p=function(){var w=new Ce(l+22),g=o,y=l-o;l=0;for(var m=0;m<c;++m){var _=u[m];try{var j=_.c.length;j_(w,l,_,_.f,_.u,j);var N=30+_.f.length+Sp(_.extra),k=l+N;w.set(_.c,k),j_(w,o,_,_.f,_.u,j,l,_.m),o+=16+N+(_.m?_.m.length:0),l=k+j}catch(S){return h(S,null)}}O3(w,o,u.length,y,g),h(null,w)};i||p();for(var v=function(w){var g=s[w],y=r[g],m=y[0],_=y[1],j=j3(),N=m.length;j.p(m);var k=jp(g),S=k.length,P=_.comment,$=P&&jp(P),D=$&&$.length,I=Sp(_.extra),O=_.level==0?0:8,E=function(A,C){if(A)f(),h(A,null);else{var M=C.length;u[w]=Bg(_,{size:N,crc:j.d(),c:C,f:k,m:$,u:S!=g.length||$&&P.length!=D,compression:O}),o+=30+S+I+M,l+=76+2*(S+I)+(D||0)+M,--i||p()}};if(S>65535&&E(De(11,0,1),null),!O)E(null,m);else if(N<16e4)try{E(null,Hg(m,_))}catch(A){E(A,null)}else d.push(C3(m,_,E))},x=0;x<c;++x)v(x);return f}var fu=typeof queueMicrotask=="function"?queueMicrotask:typeof setTimeout=="function"?setTimeout:function(e){e()};function L3(e,t,n){n||(n=t,t={}),typeof n!="function"&&De(7);var r=[],s=function(){for(var w=0;w<r.length;++w)r[w]()},i={},o=function(w,g){fu(function(){n(w,g)})};fu(function(){o=n});for(var l=e.length-22;Dt(e,l)!=101010256;--l)if(!l||e.length-l>65558)return o(De(13,0,1),null),s;var c=Nn(e,l+8);if(c){var u=c,d=Dt(e,l+16),f=Dt(e,l-20)==117853008;if(f){var h=Dt(e,l-12);f=Dt(e,h)==101075792,f&&(u=c=Dt(e,h+32),d=Dt(e,h+48))}for(var p=t&&t.filter,v=function(w){var g=I3(e,d,f),y=g[0],m=g[1],_=g[2],j=g[3],N=g[4],k=g[5],S=M3(e,k);d=N;var P=function(D,I){D?(s(),o(D,null)):(I&&(i[j]=I),--c||o(null,i))};if(!p||p({name:j,size:m,originalSize:_,compression:y}))if(!y)P(null,Hs(e,S,S+m));else if(y==8){var $=e.subarray(S,S+m);if(_<524288||m>.8*_)try{P(null,Ug($,{out:new Ce(_)}))}catch(D){P(D,null)}else r.push(A3($,{size:_},P))}else P(De(14,"unknown compression type "+y,1),null);else P(null,null)},x=0;x<u;++x)v(x)}else o(null,{});return s}const kp="project-manifest.json",D3=".aitable-workflow.zip",z3=/\.(json|ya?ml|ts|js|md|txt)$/i,V3=new Set(["runtime","traces","node_modules"]),Ak=/(^|\/)\.(_|DS_Store)/;async function F3(e){const{project:t,files:n,checksums:r,exportedAt:s}=e,i={};for(const l of n)Pk(l.path)||Ak.test(l.path)||(i[l.path]=l.content);const o={version:1,title:t.title??"",scene:G3(n),checksums:r,exportedAt:s,projectId:t.id};return i[kp]=JSON.stringify(o,null,2),B3(i)}function B3(e){const t={};for(const[n,r]of Object.entries(e))t[n]=jp(r);return new Promise((n,r)=>{$3(t,{level:6},(s,i)=>{s?r(s):n(new Blob([i.slice()],{type:"application/zip"}))})})}async function Tk(e){let t;e instanceof Uint8Array?t=e:e instanceof ArrayBuffer?t=new Uint8Array(e):t=new Uint8Array(await e.arrayBuffer());const n=await new Promise((s,i)=>{L3(t,(o,l)=>o?i(o):s(l))}),r={};for(const[s,i]of Object.entries(n))s.endsWith("/")||(r[s]=Ck(i));return r}function H3(e,t){const n=URL.createObjectURL(e),r=document.createElement("a");r.href=n,r.download=t,r.rel="noopener",document.body.appendChild(r),r.click(),r.remove(),setTimeout(()=>URL.revokeObjectURL(n),0)}async function U3(e){const t=await Tk(e);let n;const r=t[kp];if(r!==void 0)try{n=JSON.parse(r)}catch{n=void 0}const s=[];for(const[o,l]of Object.entries(t)){if(o===kp)continue;const c=o.replace(/^\/+/,"");!c||Ak.test(c)||Pk(c)||!z3.test(c)||s.push({path:c,content:l})}s.sort((o,l)=>o.path.localeCompare(l.path));const i=await K3(n,s);return{title:(n==null?void 0:n.title)??"",files:s,manifest:n,checksumWarnings:i}}async function W3(e){try{const t=new TextEncoder().encode(e),n=await crypto.subtle.digest("SHA-256",t);return Array.from(new Uint8Array(n)).map(r=>r.toString(16).padStart(2,"0")).join("")}catch{return null}}async function K3(e,t){if(!(e!=null&&e.checksums)||e.checksums.length===0)return[];const n=[],r=new Map(t.map(s=>[s.path,s.content]));for(const s of e.checksums){const i=r.get(s.path);if(i===void 0){n.push(`manifest 记录的文件缺失:${s.path}`);continue}const o=await W3(i);o&&o!==s.sha256&&n.push(`checksum 不一致:${s.path}`)}return n}function G3(e){const t=e.find(r=>r.path==="aitable-workflow.config.yml"||r.path.endsWith(".config.yml"));if(!t)return;const n=/^[ \t]*scene[ \t]*:[ \t]*(.+)$/m.exec(t.content);if(n)return n[1].trim().replace(/^['"]/,"").replace(/['"]$/,"").replace(/\s+#.*$/,"")||void 0}function Pk(e){const t=e.split("/")[0]??"";return V3.has(t)}function q3(e){return e.trim().replace(/[^\w一-龥.\- ]+/g,"_").replace(/_{2,}/g,"_")||"project"}function Y3(e){return`${q3(e)}${D3}`}function ka(e,t){const n=e.filter(r=>r.id!==t.id);return[t,...n].sort((r,s)=>s.updatedAt.localeCompare(r.updatedAt))}function S_(e,t){var n;return(n=e.title)!=null&&n.trim()?e.title.trim():`工作流 #${t+1} · ${e.id.slice(-6)}`}const X3=ut(function(){const t=z.workflows,n=z.currentWorkflowId,r=z.workflowFiles,s=z.projectId,[i,o]=b.useState(!1),[l,c]=b.useState(null),[u,d]=b.useState(!1),[f,h]=b.useState(null),p=g=>{if(!g)return null;const y=t.find(m=>m.id===g);return(y==null?void 0:y.fileCount)!=null?y.fileCount:g!==n?null:r.length};async function v(g){if(!(!s||g===n)){d(!0),h(null);try{const[y,m]=await Promise.all([yp(s,g),ad(s,g).catch(()=>null)]);z.setCurrentWorkflow(g,y.files),m&&z.applyServerWorkflow(s,m)}catch(y){h(y instanceof Error?y.message:String(y))}finally{d(!1)}}}async function x(){if(s)try{const g=await vp(s);z.setWorkflows(g)}catch{}}async function w(){if(!(!l||!s)){d(!0),h(null);try{await YD(s,l);const g=await vp(s);if(l===n){const m=g[0];if(m)try{const _=await yp(s,m.id);z.setWorkflows(g),z.setCurrentWorkflow(m.id,_.files)}catch{z.setWorkflows(g),z.setCurrentWorkflow(m.id,[])}else z.setWorkflows(g),z.setCurrentWorkflow(null,[])}else z.setWorkflows(g);c(null)}catch(g){const y=g instanceof Error?g.message:String(g);h(/运行中|project_busy|活跃|无法删除/i.test(y)?"项目运行中,无法删除工作流":y)}finally{d(!1)}}}return t.length===0?a.jsxs("div",{className:"rail__workflow-empty",children:[a.jsxs("button",{type:"button",className:"rail__item rail__item--workflow rail__workflow-new",onClick:()=>o(!0),children:[a.jsx(V,{name:"plus",size:14,style:{flex:"0 0 auto"}}),a.jsx("span",{children:"新建工作流"})]}),f&&a.jsx("div",{className:"rail__workflow-error",children:f}),i&&a.jsx(k_,{onCancel:()=>o(!1),onCreated:async()=>{o(!1),await x()}})]}):a.jsxs("div",{className:"rail__workflow-list",children:[t.map(g=>{const y=g.id===n,m=p(g.id);return a.jsxs("div",{className:"rail__workflow-card-wrap",children:[a.jsxs("button",{type:"button",className:"rail__item rail__item--workflow"+(y?" is-active":""),onClick:()=>void v(g.id),disabled:u,title:`${g.name}${g.domain?" · "+g.domain:""}${g.tableId?" · "+g.tableId:""}`,children:[a.jsx(V,{name:"flow",size:14,style:{flex:"0 0 auto"}}),a.jsxs("span",{className:"rail__item-copy",children:[a.jsx("span",{className:"rail__item-title",children:g.name}),a.jsx("span",{className:"rail__item-sub",children:[g.domain,g.tableId].filter(Boolean).join(" · ")||g.id})]}),m!==null&&a.jsx("span",{className:"rail__badge",children:m})]}),a.jsx("button",{type:"button",className:"rail__item-delete",title:"删除工作流","aria-label":"删除工作流",disabled:u,onClick:()=>{c(g.id),h(null)},children:a.jsx(V,{name:"close",size:12})})]},g.id)}),a.jsxs("button",{type:"button",className:"rail__item rail__workflow-add",onClick:()=>o(!0),children:[a.jsx(V,{name:"plus",size:14,style:{flex:"0 0 auto"}}),a.jsx("span",{children:"新建工作流"})]}),f&&a.jsx("div",{className:"rail__workflow-error",children:f}),i&&a.jsx(k_,{onCancel:()=>o(!1),onCreated:async()=>{o(!1),await x()}}),l&&a.jsx("div",{className:"modal-overlay",onClick:()=>!u&&c(null),children:a.jsxs("div",{className:"modal-card",onClick:g=>g.stopPropagation(),children:[a.jsxs("div",{className:"modal-card__head",children:[a.jsx("span",{className:"modal-card__title",children:"删除工作流?"}),a.jsx("button",{type:"button",className:"modal-card__close",onClick:()=>c(null),disabled:u,children:a.jsx(V,{name:"close",size:14})})]}),a.jsxs("div",{className:"modal-card__body",children:[a.jsx("p",{className:"cfg-muted",children:"删除后该工作流的 workflow.yml / recipes / views 将一并移除,且不可恢复。"}),f&&a.jsxs("div",{className:"import-env-warn",children:[a.jsx(V,{name:"warn",size:13}),f]})]}),a.jsxs("div",{className:"modal-card__foot",children:[a.jsx("button",{type:"button",className:"modal-card__btn",onClick:()=>c(null),disabled:u,children:"取消"}),a.jsx("button",{type:"button",className:"primary modal-card__btn",disabled:u,onClick:()=>void w(),children:u?"删除中...":"确认删除"})]})]})})]})});function k_({onCancel:e,onCreated:t}){const n=z.projectId,[r,s]=b.useState(""),[i,o]=b.useState(""),[l,c]=b.useState(""),[u,d]=b.useState(!1),[f,h]=b.useState(null),p=b.useRef(null);async function v(w){if(!w||w.length===0)return[];const g=Array.from(w),y=[];for(const m of g){const _=m.webkitRelativePath||m.name,j=await m.text();y.push({path:Mk(_),content:j})}return y}function x(){if(!n)return;const w=r.trim();if(!w){h("工作流名称不能为空");return}d(!0),h(null),(async()=>{var g;try{const y=[];if(i.trim()&&y.push({path:"workflow.yml",content:i}),l.trim()){const _=Q3(l);y.push(..._)}if((g=p.current)!=null&&g.files){const _=await v(p.current.files);y.push(..._)}const m=await qD(n,{name:w,files:y.length>0?y:void 0});await t(m.workflow)}catch(y){h(y instanceof Error?y.message:String(y))}finally{d(!1)}})()}return a.jsx("div",{className:"modal-overlay",onClick:()=>!u&&e(),children:a.jsxs("div",{className:"modal-card",onClick:w=>w.stopPropagation(),style:{maxWidth:560},children:[a.jsxs("div",{className:"modal-card__head",children:[a.jsx("span",{className:"modal-card__title",children:"新建工作流"}),a.jsx("button",{type:"button",className:"modal-card__close",onClick:e,disabled:u,children:a.jsx(V,{name:"close",size:14})})]}),a.jsxs("div",{className:"modal-card__body",children:[a.jsxs("label",{className:"cfg-label",children:["工作流名称",a.jsx("input",{className:"cfg-input",value:r,placeholder:"例如:合同审批流程",onChange:w=>s(w.target.value),disabled:u})]}),a.jsxs("label",{className:"cfg-label",style:{marginTop:12},children:["workflow.yml(可选,留空则后端用默认模板)",a.jsx("textarea",{className:"cfg-textarea",rows:8,value:i,placeholder:`workflow:
|
|
@@ -318,4 +318,4 @@ export default recipe;
|
|
|
318
318
|
4. 超时、失败、风险命中时通知谁?
|
|
319
319
|
5. 哪些话术、动作或自动化行为必须避免?`,onChange:A=>z.patchInitDraft({sop:A.target.value})}),a.jsx("span",{className:"cfg-muted",children:"可以先写要点,不需要一次写完;Design 阶段会继续澄清。"})]})}),P||d?a.jsxs("div",{className:"cfg-cta",children:[a.jsxs("div",{className:"cfg-cta__text",children:[a.jsx(V,{name:"check",size:16}),"配置完成,可以进入设计阶段"]}),a.jsx("button",{type:"button",className:"primary cfg-cta__btn",onClick:()=>void O(),disabled:o,children:o?"写入配置中...":"下一步:设计 →"})]}):a.jsxs("div",{className:"cfg-cta cfg-cta--pending",children:[a.jsxs("div",{className:"cfg-cta__text cfg-cta__text--pending",children:[a.jsx(V,{name:"warn",size:16}),s.roles.length===0?"请至少添加一个角色后继续":"请完成上方配置后继续"]}),a.jsx("button",{type:"button",className:"primary cfg-cta__btn",disabled:!0,children:"下一步:设计 →"})]})]}),$&&!$.ok&&a.jsx(Bk,{title:"无法进入设计阶段",missing:$.missing,warnings:$.warnings,onClose:()=>D(null),onLocate:A=>{D(null)}})]});return a.jsx(hu,{chat:n,chatTitle:"一次性配置向导",chatSubtitle:`${it?"执行引擎 · ":""}角色 · SOP · ${ue?"真实模式":"演示模式"}`,work:E})}),ir=FU(),gv=(ir==null?void 0:ir.fields)??[],Vf=(ir==null?void 0:ir.views)??[],qx=gv.filter(e=>e.group==="business"),Yx=gv.filter(e=>e.group==="process");function Xx(e){return[{kind:"do",run:()=>z.addMockField(e)},{kind:"wait",ms:130}]}function dW(e){return[{kind:"do",run:()=>z.addMockView(e)},{kind:"wait",ms:260}]}const fW=[{kind:"say",text:"开始搭建演示 AI 表格。我会依次创建字段、视图,并绑定事件源。"},{kind:"todo",items:["创建业务字段","创建流程字段","创建视图","绑定事件源 · 生成链接"]},{kind:"tool",label:"创建业务字段",detail:`${qx.length} 个`,ms:520},...qx.flatMap(Xx),{kind:"todo-advance"},{kind:"tool",label:"创建流程字段",detail:`${Yx.length} 个`,ms:520},...Yx.flatMap(Xx),{kind:"todo-advance"},{kind:"tool",label:"创建视图",detail:`${Vf.length} 个`,ms:520},...Vf.flatMap(dW),{kind:"todo-advance"},{kind:"tool",label:"绑定事件源 · 新记录触发",detail:"on_record_created",ms:760},{kind:"do",run:()=>{if(!ir)return;const e=z.initDraft,t=e.tableBaseId||ir.tableBaseId,n=e.tableId||ir.tableSheetId;z.setMockTableUrl(WE(t,n))}},{kind:"todo-advance"},{kind:"say",text:`搭建完成:${gv.length} 字段 · ${Vf.length} 视图已就绪,事件源已绑定。可打开 AI 表格,或进入「运行」阶段启动工作流。`}];function Qx(e){return e.isLive?String(e.current):`${e.current}/${e.mockTotal}`}const hW={grid:"表格",kanban:"看板",calendar:"日历",form:"表单",gantt:"甘特"},Zx={text:"文本",single_select:"单选",user:"成员",datetime:"日期",number:"数字"},pW=ut(function(){var I,O,E,A,C;const t=b.useRef();t.current||(t.current=new Gg);const n=t.current,r=b.useRef(!1),[s,i]=b.useState(!1),[o,l]=b.useState(""),[c,u]=b.useState(!1),d=z.view,f=d.kind==="setup"?d:null,h=(f==null?void 0:f.schema.fields)??[],p=(f==null?void 0:f.schema.views)??[],v=(f==null?void 0:f.tableUrl)??null,x=z.mode,w=z.projectId,g=z.stageRuntime.setup,y=x==="live",m=((f==null?void 0:f.gate.kind)??"open")==="open";Yg("setup",n),b.useEffect(()=>{r.current||!m||(r.current=!0,n.run([{kind:"say",text:"工作流已就绪。准备好后点击右侧「开始搭建」,我会自动创建 AI 表格的字段与视图。"}]))},[n,m]),b.useEffect(()=>{(g.status==="blocked"||g.status==="failed"||g.status==="succeeded")&&i(!1)},[g.status]);function _(){if(x==="live"&&!m){n.run([{kind:"say",text:"当前流程还没有完成设计,请先回到设计阶段生成 workflow 和 recipes。"}]);return}const M=g.status==="blocked"||g.status==="failed";if(!(g.status==="running"||s&&!M)){if(i(!0),x==="live"){w?Na("setup",w,n).finally(()=>i(!1)):(i(!1),n.run([{kind:"say",text:"缺少真实项目工作区,请先返回 Init 阶段完成真实配置。"}]));return}n.run(fW).finally(()=>i(!1))}}async function j(){const M=o.trim();if(!(!w||!M||c||s&&g.status==="running")){u(!0);try{const T=await JD(w,M);z.applySnapshotPatch(w,{files:T.files,projectState:T.state}),z.patchInitDraft({tableConnected:!0,tableId:M}),await n.run([{kind:"say",text:`已写回 Table Id:${M},继续搭建字段与视图。`}]),i(!0),await Na("setup",w,n)}catch(T){const R=T instanceof Error?T.message:String(T);await n.run([{kind:"say",text:`写回 Table Id 失败:${R}`}])}finally{u(!1),i(!1)}}}const N=h.filter(M=>M.group==="business"),k=h.filter(M=>M.group==="process"),S=x==="live"?g.status==="succeeded":!!v||g.status==="succeeded",P=s||g.status!=="idle"||S,$=(f==null?void 0:f.recovery)==="manual_table_id";if(!m)return a.jsx(hu,{chat:n,chatTitle:"AI 表格搭建",chatSubtitle:"创建字段 · 视图 · 绑定事件源",chatEmptyHint:"当前流程尚未到达搭建阶段",onSend:M=>{n.addUserMessage(M),n.run([{kind:"say",text:"当前流程还没有完成设计,请先回到设计阶段生成工作流。"}])},workHead:a.jsxs("div",{className:"work-head",children:[a.jsx(V,{name:"table",size:16}),a.jsx("div",{className:"work-head__title",children:"AI 表格"}),a.jsx("div",{className:"work-head__sub",children:"未到达"})]}),work:a.jsx("div",{className:"work-body setup-theater",children:a.jsxs("div",{className:"setup-intro",children:[a.jsx("div",{className:"setup-intro__icon",children:a.jsx(V,{name:"flow",size:30,color:"#fff"})}),a.jsx("h3",{className:"setup-intro__title",children:"当前流程尚未完成设计"}),a.jsx("p",{className:"setup-intro__desc",children:"搭建阶段必须使用当前流程实例生成的 workflow 和 recipes。请先回到设计阶段完成真实工作流生成。"}),a.jsxs("button",{type:"button",className:"primary setup-intro__cta",onClick:()=>z.setRoute("design"),children:[a.jsx(V,{name:"chevron-right",size:15,color:"#fff"}),"返回设计阶段"]})]})})});const D=a.jsx("div",{className:"work-body setup-theater",children:P?a.jsxs(a.Fragment,{children:[a.jsxs("div",{className:"setup-section",children:[a.jsxs("div",{className:"setup-section__head",children:[a.jsx(V,{name:g.status==="blocked"||g.status==="failed"?"sparkle":"table",size:14}),g.status==="blocked"?"等待授权":g.status==="failed"?"搭建失败":g.status==="succeeded"?"搭建完成":"搭建进度"]}),a.jsx("p",{className:"setup-intro__desc",children:g.message}),((I=g.block)==null?void 0:I.help)&&a.jsx("p",{className:"setup-intro__desc",children:g.block.help}),$&&a.jsxs("div",{className:"setup-recovery-card",children:[a.jsx("div",{className:"setup-recovery-card__title",children:"如果数据表已创建,请填入 Table Id 后继续"}),a.jsx("p",{className:"setup-recovery-card__desc",children:"当前失败点在建表返回值解析,直接重试可能会重复失败。请先到 AI 表格确认目标数据表,复制 table_id 后继续创建字段与视图。"}),a.jsxs("div",{className:"setup-recovery-card__form",children:[a.jsx("input",{value:o,onChange:M=>l(M.target.value),placeholder:"例如:tblxxxxxxxxxxxx","aria-label":"Table Id"}),a.jsxs("button",{type:"button",className:"primary",onClick:()=>{j()},disabled:!o.trim()||c||s&&g.status==="running",children:[a.jsx(V,{name:"play",size:15,color:"#fff"}),c?"保存中…":"保存并继续搭建"]})]})]}),(g.status==="blocked"||g.status==="failed")&&a.jsxs("button",{type:"button",className:"primary setup-intro__cta",onClick:_,children:[a.jsx(V,{name:"play",size:15,color:"#fff"}),((O=g.recoveryAction)==null?void 0:O.label)??((E=g.block)==null?void 0:E.actionLabel)??"重试搭建"]})]}),S&&a.jsxs(Ye.div,{className:"table-link-card",variants:St,initial:"hidden",animate:"visible",children:[a.jsxs("div",{className:"table-link-card__info",children:[a.jsx("span",{className:"table-link-card__badge",children:a.jsx(V,{name:"check",size:13,color:"#fff"})}),a.jsxs("div",{children:[a.jsx("div",{className:"table-link-card__title",children:"AI 表格已就绪"}),a.jsxs("div",{className:"table-link-card__sub",children:[h.length," 字段 · ",p.length," 视图 · 事件源已绑定"]})]})]}),a.jsxs("a",{className:"primary table-link-card__open",href:v??"#",target:"_blank",rel:"noreferrer",children:[a.jsx(V,{name:"link",size:14,color:"#fff"}),"打开 AI 表格"]})]}),a.jsxs("div",{className:"setup-section",children:[a.jsxs("div",{className:"setup-section__head",children:[a.jsx(V,{name:"table",size:14}),"字段",a.jsx("span",{className:"setup-section__count",children:Qx({current:h.length,mockTotal:((A=zf())==null?void 0:A.fieldCount)??0,isLive:y})})]}),N.length>0&&a.jsx("div",{className:"setup-group-label",children:"业务字段"}),a.jsx("div",{className:"field-grid",children:N.map(M=>a.jsxs(Ye.div,{className:"field-chip",variants:St,initial:"hidden",animate:"visible",children:[a.jsx("span",{className:"field-chip__name",children:M.name}),a.jsx("span",{className:"field-chip__type",children:Zx[M.type]??M.type})]},M.id))}),k.length>0&&a.jsx("div",{className:"setup-group-label",children:"流程字段"}),a.jsx("div",{className:"field-grid",children:k.map(M=>a.jsxs(Ye.div,{className:"field-chip field-chip--process",variants:St,initial:"hidden",animate:"visible",children:[a.jsx("span",{className:"field-chip__name",children:M.name}),a.jsx("span",{className:"field-chip__type",children:Zx[M.type]??M.type})]},M.id))})]}),p.length>0&&a.jsxs("div",{className:"setup-section",children:[a.jsxs("div",{className:"setup-section__head",children:[a.jsx(V,{name:"flow",size:14}),"视图",a.jsx("span",{className:"setup-section__count",children:Qx({current:p.length,mockTotal:((C=zf())==null?void 0:C.viewCount)??0,isLive:y})})]}),a.jsx("div",{className:"view-grid",children:p.map(M=>a.jsxs(Ye.div,{className:"view-card",variants:St,initial:"hidden",animate:"visible",children:[a.jsx("span",{className:`view-card__kind view-card__kind--${M.kind}`,children:hW[M.kind]}),a.jsx("div",{className:"view-card__name",children:M.name}),a.jsx("div",{className:"view-card__desc",children:M.desc})]},M.id))})]}),S&&a.jsxs("div",{className:"cfg-cta",children:[a.jsxs("div",{className:"cfg-cta__text",children:[a.jsx(V,{name:"check",size:16}),"表格搭建完成,可进入试运行验证流程。"]}),a.jsxs("button",{type:"button",className:"primary",onClick:()=>z.setRoute("test"),children:["进入试运行",a.jsx(V,{name:"chevron-right",size:15,color:"#fff"})]})]})]}):a.jsxs("div",{className:"setup-intro",children:[a.jsx("div",{className:"setup-intro__icon",children:a.jsx(V,{name:"table",size:30,color:"#fff"})}),a.jsx("h3",{className:"setup-intro__title",children:x==="live"?"搭建真实 AI 表格结构":"搭建演示 AI 表格结构"}),a.jsx("p",{className:"setup-intro__desc",children:x==="live"?"将根据真实工作流方案创建字段与视图,并绑定新记录触发方式。":(()=>{const M=zf();return`将创建 ${(M==null?void 0:M.fieldCount)??0} 个示例字段、${(M==null?void 0:M.viewCount)??0} 个示例视图,并绑定新记录触发方式。`})()}),a.jsxs("button",{type:"button",className:"primary setup-intro__cta",onClick:_,children:[a.jsx(V,{name:"play",size:15,color:"#fff"}),"开始搭建"]})]})});return a.jsx(hu,{chat:n,chatTitle:"AI 表格搭建",chatSubtitle:"创建字段 · 视图 · 绑定事件源",chatEmptyHint:"agent 正在准备建表…",onSend:M=>{n.addUserMessage(M),n.run([{kind:"say",text:"好的,我会据此调整表结构。"}])},workHead:a.jsxs("div",{className:"work-head",children:[a.jsx(V,{name:"table",size:16}),a.jsx("div",{className:"work-head__title",children:"AI 表格"}),a.jsx("div",{className:"work-head__sub",children:S?"已就绪":g.status==="blocked"?"等待授权":g.status==="failed"?"可重试":P?"搭建中":"待搭建"})]}),work:D})}),Ff=e=>new Promise(t=>setTimeout(t,e));async function mW(e,t,n){for(let r=0;r<e.length;r++){if(n!=null&&n.aborted)return;const s=e[r];if(t({type:"step-start",stepIndex:r,step:s}),await Ff(300),n!=null&&n.aborted||(t({type:"step-ai",stepIndex:r,step:s}),await Ff(500),n!=null&&n.aborted)||(t({type:"step-done",stepIndex:r,step:s}),r<e.length-1&&(await Ff(400),n!=null&&n.aborted)))return}t({type:"all-done",stepIndex:e.length-1})}const gW={info:"dot",ai:"sparkle",ok:"check",warn:"warn",error:"close"},vW=ut(function(){const t=z.view,n=t.kind==="test"?t:null,r=z.steps;z.mode,z.projectId;const s=z.tableUrl,i=((n==null?void 0:n.gate.kind)??"open")==="open",[o,l]=b.useState("guide"),[c,u]=b.useState([]),[d,f]=b.useState(-1),[h,p]=b.useState(null),v=b.useRef(null);if(!i)return a.jsx("div",{className:"split split--chatonly",children:a.jsxs("div",{className:"split__work",children:[a.jsxs("div",{className:"work-head",children:[a.jsx(V,{name:"sparkle",size:16}),a.jsx("div",{className:"work-head__title",children:"试运行"}),a.jsx("div",{className:"work-head__sub",children:"未到达"})]}),a.jsx("div",{className:"work-body",children:a.jsxs("div",{className:"test-intro",children:[a.jsx("div",{className:"test-intro__icon",children:a.jsx(V,{name:"table",size:28,color:"#fff"})}),a.jsx("h3",{className:"test-intro__title",children:"当前流程尚未完成搭建"}),a.jsx("p",{className:"test-intro__desc",children:"试运行阶段必须基于已搭建完成的 AI 表格。请先完成搭建阶段。"}),a.jsxs("button",{type:"button",className:"primary test-intro__cta",onClick:()=>z.setRoute("setup"),children:[a.jsx(V,{name:"chevron-right",size:15,color:"#fff"}),"返回搭建阶段"]})]})})]})});async function x(){var g;l("running"),u([]),f(0),p(null),(g=v.current)==null||g.abort();const w=new AbortController;v.current=w,await mW(r,y=>{y.type==="step-start"?(f(y.stepIndex),u(m=>[...m,{id:`log_${y.step.id}_start_${Date.now().toString(36)}`,ts:Date.now(),ticketId:"test",stepId:y.step.id,level:"info",text:`开始执行步骤: ${y.step.name}`}])):y.type==="step-ai"?u(m=>[...m,{id:`log_${y.step.id}_ai_${Date.now().toString(36)}`,ts:Date.now(),ticketId:"test",stepId:y.step.id,level:y.step.requiresAgent?"ai":"info",text:y.step.requiresAgent?`AI Agent 执行 ${y.step.recipe}...`:`自动处理 ${y.step.recipe}...`}]):y.type==="step-done"?u(m=>[...m,{id:`log_${y.step.id}_done_${Date.now().toString(36)}`,ts:Date.now(),ticketId:"test",stepId:y.step.id,level:"ok",text:`步骤 ${y.step.name} 完成`}]):y.type==="all-done"&&(l("success"),f(-1),u(m=>[...m,{id:`log_test_done_${Date.now().toString(36)}`,ts:Date.now(),ticketId:"test",stepId:"test",level:"ok",text:"全部步骤执行成功,试运行通过!"}]))},w.signal)}return a.jsxs("div",{className:"test-stage",children:[a.jsxs("div",{className:"test-main",children:[a.jsxs("div",{className:"test-main__head",children:[a.jsx(V,{name:"sparkle",size:16}),a.jsx("div",{className:"work-head__title",children:"试运行"}),a.jsx("div",{className:"work-head__sub",children:o==="guide"?"待开始":o==="running"?"执行中":o==="success"?"通过":"失败"}),o==="success"&&a.jsxs("button",{type:"button",className:"primary work-head__cta",onClick:()=>z.setRoute("run"),children:["进入正式运行",a.jsx(V,{name:"chevron-right",size:14,color:"#fff"})]})]}),o==="guide"&&a.jsxs("div",{className:"test-guide",children:[a.jsx("div",{className:"test-guide__icon",children:a.jsx(V,{name:"sparkle",size:30,color:"#fff"})}),a.jsx("h3",{className:"test-guide__title",children:"用一条真实记录验证整条流程"}),a.jsxs("div",{className:"test-guide__steps",children:[a.jsxs("div",{className:"test-guide__step",children:[a.jsx("span",{className:"test-guide__step-num",children:"1"}),a.jsx("span",{children:"打开 AI 表格"}),a.jsxs("a",{className:"test-guide__link",href:s??"#",target:"_blank",rel:"noreferrer",children:[a.jsx(V,{name:"link",size:12})," 打开表格"]})]}),a.jsxs("div",{className:"test-guide__step",children:[a.jsx("span",{className:"test-guide__step-num",children:"2"}),a.jsx("span",{children:"新增一条记录,填写必选字段"})]}),a.jsxs("div",{className:"test-guide__step",children:[a.jsx("span",{className:"test-guide__step-num",children:"3"}),a.jsx("span",{children:"回到这里点「开始试运行」"})]})]}),a.jsxs("button",{type:"button",className:"primary test-guide__cta",onClick:()=>void x(),children:[a.jsx(V,{name:"play",size:15,color:"#fff"}),"开始试运行"]})]}),o==="success"&&a.jsxs("div",{className:"test-result test-result--success",children:[a.jsx("span",{className:"test-result__icon test-result__icon--success",children:a.jsx(V,{name:"check",size:24,color:"#fff"})}),a.jsx("h3",{className:"test-result__title",children:"试运行通过"}),a.jsxs("p",{className:"test-result__desc",children:["全部 ",r.length," 个步骤执行成功。可以进入正式运行阶段。"]}),a.jsxs("button",{type:"button",className:"primary test-result__cta",onClick:()=>z.setRoute("run"),children:["进入正式运行",a.jsx(V,{name:"chevron-right",size:14,color:"#fff"})]})]}),o==="failed"&&h&&a.jsxs("div",{className:"test-result test-result--failed",children:[a.jsx("span",{className:"test-result__icon test-result__icon--failed",children:a.jsx(V,{name:"close",size:24,color:"#fff"})}),a.jsxs("h3",{className:"test-result__title",children:["试运行在「",h.step.name,"」步骤失败"]}),a.jsx("p",{className:"test-result__desc",children:h.reason}),a.jsxs("div",{className:"test-result__actions",children:[a.jsx("button",{type:"button",className:"test-result__btn",onClick:()=>{l("guide")},children:"查看完整日志"}),a.jsx("button",{type:"button",className:"primary test-result__btn",onClick:()=>z.setRoute("design"),children:"去修正该步骤配置 →"})]})]})]}),a.jsxs("div",{className:"test-flow",children:[a.jsx("div",{className:"test-flow__head",children:"步骤流转"}),a.jsx("div",{className:"step-chain",children:r.map((w,g)=>{const y=o==="success"||g<d?"done":g===d?"active":"pending";return a.jsxs("div",{className:`chain-node is-${y}`,children:[g>0&&a.jsx("div",{className:`chain-node__line is-${y}`}),a.jsxs("div",{className:"chain-node__row",children:[a.jsx("span",{className:"chain-node__dot",children:y==="done"?a.jsx(V,{name:"check",size:12,color:"#fff"}):y==="active"?a.jsx("span",{className:"chain-node__pulse"}):a.jsx("span",{className:"chain-node__idle"})}),a.jsxs("div",{className:"chain-node__body",children:[a.jsxs("div",{className:"chain-node__name",children:[a.jsx("span",{className:"chain-node__label",children:w.name}),w.requiresAgent&&a.jsx("span",{className:"chain-node__engine",style:{"--c":"var(--agent-llm)"},children:"AI"}),!w.requiresAgent&&a.jsx("span",{className:"pill pill--muted",children:"自动"})]}),a.jsx("div",{className:"chain-node__recipe",children:w.recipe})]})]})]},w.id)})})]}),a.jsxs("div",{className:"test-logs",children:[a.jsxs("div",{className:"test-logs__head",children:[a.jsx(V,{name:"file",size:14}),"试运行日志"]}),a.jsx("div",{className:"test-logs__body",children:c.length===0?a.jsx("div",{className:"empty-hint",style:{padding:20},children:"点击「开始试运行」后,这里会显示实时执行日志"}):a.jsx(Ho,{initial:!1,children:c.map(w=>{var g;return a.jsxs(Ye.div,{layout:!0,variants:St,initial:"hidden",animate:"visible",className:`log-line log-line--${w.level}`,children:[a.jsx("span",{className:"log-line__icon",children:a.jsx(V,{name:gW[w.level],size:11})}),a.jsxs("div",{className:"log-line__content",children:[a.jsx("span",{className:"log-line__step",children:((g=r.find(y=>y.id===w.stepId))==null?void 0:g.name)??w.stepId}),a.jsx("span",{className:"log-line__text",children:w.text})]})]},w.id)})})})]})]})}),yW={classify:[{level:"info",text:"读取工单「{title}」标题与问题描述"},{level:"ai",text:"调用分类模型判定问题类型与紧急程度…"},{level:"ok",text:"判定为「{category}」· {priority}"}],investigate:[{level:"info",text:"检索知识库与历史相似工单"},{level:"ai",text:"Qoder 分析根因,生成排查路径…"},{level:"ok",text:"定位可能原因,产出解决方案草案"}],draft_reply:[{level:"info",text:"载入解决方案与客户「{customer}」信息"},{level:"ai",text:"以「亲和友好」语气生成回复草稿…"},{level:"ok",text:"回复草稿已生成,进入质检"}],quality_check:[{level:"warn",text:"命中人工审核卡点,暂停等待复核"},{level:"info",text:"请在步骤卡片点击「通过」或「驳回」"}],send_reply:[{level:"ai",text:"渲染最终回复并校验敏感词…"},{level:"ok",text:"已发送给客户「{customer}」,工单关闭"}]},_W=[{level:"warn",text:"人工驳回,退回「草拟回复」重写"},{level:"ai",text:"参考驳回意见重新生成回复…"},{level:"ok",text:"新草稿已生成,再次送审"}],xW={classify:1400,investigate:2e3,draft_reply:1700,quality_check:0,send_reply:1400},wW=3200,bW=520;function jW(e,t){return e.replace("{title}",t.title).replace("{customer}",t.customer).replace("{category}",t.category).replace("{priority}",t.priority)}const Ei=KE(),SW=(Ei==null?void 0:Ei.steps)??[],Bf=(Ei==null?void 0:Ei.incomingTickets)??[],Hf=e=>new Promise(t=>setTimeout(t,e));let kW=0;const Jx=e=>`${e}_${(kW++).toString(36)}`;class NW{constructor(){le(this,"state",{running:!1,arrived:0,total:Bf.length});le(this,"listeners",new Set);le(this,"approvals",new Map);le(this,"subscribe",t=>(this.listeners.add(t),()=>this.listeners.delete(t)));le(this,"getState",()=>this.state)}emit(){this.listeners.forEach(t=>t())}set(t){this.state={...this.state,...t},this.emit()}log(t,n,r,s){z.appendLog({id:Jx("log"),ts:Date.now(),ticketId:t,stepId:n,level:r,text:s})}start(){this.state.running||(this.set({running:!0}),this.spawn())}isAwaiting(t){return this.approvals.has(t)}approve(t){var n;(n=this.approvals.get(t))==null||n(!0)}reject(t){var n;(n=this.approvals.get(t))==null||n(!1)}async spawn(){for(let t=0;t<Bf.length;t++){if(!this.state.running)return;const n=Bf[t],r={id:Jx("tk"),title:n.title,customer:n.customer,category:n.category,priority:n.priority,status:"todo",currentStepId:null,doneStepIds:[],createdAt:Date.now()};z.addTicket(r),this.set({arrived:this.state.arrived+1}),this.process(r.id,n),await Hf(wW)}}markDone(t,n){const r=z.live.tickets.find(s=>s.id===t);r&&z.updateTicket(t,{doneStepIds:[...r.doneStepIds,n]})}async streamLogs(t,n,r,s){for(const i of s){if(!this.state.running)return;this.log(t,n,i.level,jW(i.text,r)),await Hf(bW)}}async process(t,n){for(const r of SW){if(!this.state.running)return;const s=r.needsHuman?"review":"running";if(z.updateTicket(t,{currentStepId:r.id,status:s}),await this.streamLogs(t,r.id,n,yW[r.id]??[]),r.needsHuman){let i=!1;for(;!i&&this.state.running;)if(i=await this.awaitApproval(t),!i){z.updateTicket(t,{currentStepId:"draft_reply",status:"running"});const o=z.live.tickets.find(l=>l.id===t);o&&z.updateTicket(t,{doneStepIds:o.doneStepIds.filter(l=>l!=="draft_reply")}),await this.streamLogs(t,"draft_reply",n,_W),this.markDone(t,"draft_reply"),z.updateTicket(t,{currentStepId:r.id,status:"review"})}if(!this.state.running)return}else await Hf(xW[r.id]??1200);this.markDone(t,r.id)}z.updateTicket(t,{status:"done",currentStepId:null})}awaitApproval(t){return new Promise(n=>{this.approvals.set(t,r=>{this.approvals.delete(t),this.emit(),n(r)}),this.emit()})}stop(){this.set({running:!1}),this.approvals.forEach(t=>t(!0)),this.approvals.clear()}}function EW(e){return b.useSyncExternalStore(e.subscribe,e.getState,e.getState)}const ew={todo:{label:"待处理",cls:"muted"},running:{label:"处理中",cls:"blue"},review:{label:"审核中",cls:"amber"},done:{label:"已完成",cls:"green"},blocked:{label:"受阻",cls:"red"}},tw={info:"dot",ai:"sparkle",ok:"check",warn:"warn",error:"close"};function nw(e,t){return e.doneStepIds.includes(t)?"done":e.currentStepId===t?"active":"pending"}const CW=ut(function(){const t=b.useRef();t.current||(t.current=new NW);const n=t.current,r=EW(n),s=z.view,i=s.kind==="run"?s:null,o=(i==null?void 0:i.tickets)??z.live.tickets,l=(i==null?void 0:i.logs)??z.live.logs,c=z.steps,u=z.mode,d=z.projectId,f=z.stageRuntime.run,[h,p]=b.useState(null),[v,x]=b.useState(!1),[w,g]=b.useState(!1),[y,m]=b.useState(null),_=u==="live",j=((i==null?void 0:i.gate.kind)??"open")==="open",N=KE(),k=_||c.length>0?c:(N==null?void 0:N.steps)??[],S=_?f.status==="running"||v:r.running;b.useEffect(()=>{!h&&o.length>0&&p(o[o.length-1].id)},[o,h]);const P=o.find(C=>C.id===h)??null,$=l.filter(C=>C.ticketId===h),D=b.useRef(null);b.useEffect(()=>{var C;(C=D.current)==null||C.scrollIntoView({behavior:"smooth",block:"end"})},[$.length]),Yg("run"),b.useEffect(()=>()=>{d&&I_("run",d)},[d]);const I={running:o.filter(C=>C.status==="running").length,review:o.filter(C=>C.status==="review").length,done:o.filter(C=>C.status==="done").length};function O(){if(_){if(!j)return;if(!d){z.appendLog(Uf("缺少真实项目工作区,请先从配置阶段重新进入真实设计。"));return}if(k.length===0){z.appendLog(Uf("当前流程没有可运行的真实 workflow,请先返回设计阶段重新生成。"));return}x(!0),Na("run",d).finally(()=>x(!1));return}n.start()}async function E(){if(!(!d||w)){g(!0);try{I_("run",d),(await i3(d)).mode==="local"&&await __(d)}catch(C){z.appendLog(Uf(C instanceof Error?C.message:String(C)))}finally{g(!1),x(!1)}}}async function A(C,M){if(!(!d||y)){m(M);try{await u3(d,C,M),await __(d)}catch(T){const R=T instanceof Error?T.message:String(T);z.appendLog({id:`human_action_${Date.now().toString(36)}`,ts:Date.now(),ticketId:C,stepId:(P==null?void 0:P.currentStepId)??"run",level:"error",text:R})}finally{m(null)}}}if(_&&j){const C=l.filter(L=>L.ticketId==="run"),M=P??o[0]??null,T=M?l.filter(L=>L.ticketId===M.id):C,R=f.status==="running"?"blue":f.status==="succeeded"?"green":f.status==="failed"?"red":"muted",B=f.status==="running"?"监听中":f.status==="failed"?"启动失败":f.status==="succeeded"?"已停止":"待启动";return a.jsxs("div",{className:"run-stage run-stage--live",children:[a.jsxs("div",{className:"run-board",children:[a.jsxs("div",{className:"run-board__head",children:[a.jsx("span",{children:"运行记录"}),a.jsx("span",{className:"run-board__stat",children:o.length?`${o.length} 条`:B})]}),a.jsx("div",{className:"run-board__list",children:o.length===0?a.jsxs("button",{type:"button",className:"ticket-card is-selected",children:[a.jsxs("div",{className:"ticket-card__top",children:[a.jsx("span",{className:`pill pill--${R}`,children:B}),a.jsx("span",{className:"ticket-card__prio",children:f.checkpoint??"run"})]}),a.jsx("div",{className:"ticket-card__title",children:"真实 AI 表格监听"}),a.jsx("div",{className:"ticket-card__meta",children:f.message}),a.jsxs("div",{className:"ticket-card__progress",children:[k.length," 个步骤 · ",C.length," 条服务日志"]})]}):o.map(L=>{const F=ew[L.status];return a.jsxs("button",{type:"button",className:`ticket-card${L.id===(M==null?void 0:M.id)?" is-selected":""}`,onClick:()=>p(L.id),children:[a.jsxs("div",{className:"ticket-card__top",children:[a.jsx("span",{className:`pill pill--${F.cls}`,children:F.label}),a.jsx("span",{className:"ticket-card__prio",children:L.priority})]}),a.jsx("div",{className:"ticket-card__title",children:L.title}),a.jsxs("div",{className:"ticket-card__meta",children:[L.customer," · ",L.category]}),a.jsxs("div",{className:"ticket-card__progress",children:[L.doneStepIds.length,"/",k.length," 步",L.status==="review"&&a.jsx("span",{className:"ticket-card__await",children:"待人工"})]})]},L.id)})}),a.jsxs("div",{className:"run-board__foot",children:[a.jsxs("button",{type:"button",className:"primary run-live-start",onClick:O,disabled:S,children:[a.jsx(V,{name:"play",size:15,color:"#fff"}),f.status==="failed"?"重试运行":S?"运行中":"启动运行"]}),S&&a.jsxs("button",{type:"button",className:"ghost run-live-stop",onClick:E,disabled:w,children:[a.jsx(V,{name:"close",size:13}),w?"停止中…":"停止运行"]})]})]}),a.jsxs("div",{className:"run-flow",children:[a.jsxs("div",{className:"run-flow__head",children:[a.jsx("div",{className:"run-flow__title",children:M?M.title:"当前 workflow"}),a.jsx("div",{className:"run-flow__sub",children:M?`${M.customer} · ${M.status}`:`${k.length} 个真实步骤 · ${f.checkpoint??"未启动"}`})]}),a.jsx("div",{className:"step-chain",children:k.map((L,F)=>{const W=!!M&&M.status==="review"&&M.currentStepId===L.id&&!!L.needsHuman,U=M?W?"active":nw(M,L.id):f.status==="succeeded"?"done":f.status==="running"&&F===0?"active":"pending";return a.jsxs("div",{className:`chain-node is-${U}`,children:[F>0&&a.jsx("div",{className:`chain-node__line is-${U}`}),a.jsxs("div",{className:"chain-node__row",children:[a.jsx("span",{className:"chain-node__dot",children:U==="done"?a.jsx(V,{name:"check",size:12,color:"#fff"}):U==="active"?a.jsx("span",{className:"chain-node__pulse"}):a.jsx("span",{className:"chain-node__idle"})}),a.jsxs("div",{className:"chain-node__body",children:[a.jsxs("div",{className:"chain-node__name",children:[a.jsx("span",{className:"chain-node__label",children:L.name}),L.requiresAgent&&a.jsx("span",{className:"chain-node__engine",style:{"--c":"var(--agent-llm)"},children:"AI"}),L.needsHuman&&a.jsx("span",{className:"pill pill--amber",children:"人工"}),!L.requiresAgent&&!L.needsHuman&&a.jsx("span",{className:"pill pill--muted",children:"自动"})]}),a.jsx("div",{className:"chain-node__recipe",children:L.recipe||"自动处理"}),W&&a.jsxs("div",{className:"chain-node__approve",children:[a.jsxs("button",{type:"button",className:"primary btn-approve",disabled:y!==null,onClick:()=>void A(M.id,"confirm"),children:[a.jsx(V,{name:"check",size:13,color:"#fff"})," 确认发送"]}),a.jsxs("button",{type:"button",className:"btn-reject",disabled:y!==null,onClick:()=>void A(M.id,"terminate"),children:[a.jsx(V,{name:"close",size:13})," 终止流程"]})]})]})]})]},L.id)})})]}),a.jsxs("div",{className:"run-logs",children:[a.jsxs("div",{className:"run-logs__head",children:[a.jsx(V,{name:"file",size:14}),M?"记录执行日志":"真实运行日志",a.jsx("span",{className:"run-logs__sub",children:(M==null?void 0:M.title)??f.checkpoint??"run"})]}),a.jsx("div",{className:"run-logs__body",children:T.length===0?a.jsx("div",{className:"empty-hint",style:{padding:20},children:M?"等待该记录的执行日志…":"启动后这里会显示服务端 SSE 返回的真实运行日志"}):a.jsx(Ho,{initial:!1,children:T.map(L=>{var F;return a.jsxs(Ye.div,{layout:!0,variants:St,initial:"hidden",animate:"visible",className:`log-line log-line--${L.level}`,children:[a.jsx("span",{className:"log-line__icon",children:a.jsx(V,{name:tw[L.level],size:11})}),a.jsxs("div",{className:"log-line__content",children:[a.jsx("span",{className:"log-line__step",children:((F=k.find(W=>W.id===L.stepId))==null?void 0:F.name)??L.stepId}),a.jsx("span",{className:"log-line__text",children:L.text})]})]},L.id)})})})]})]})}return j?!S&&o.length===0?a.jsx("div",{className:"split split--chatonly",children:a.jsxs("div",{className:"split__work",children:[a.jsxs("div",{className:"work-head",children:[a.jsx(V,{name:"play",size:16}),a.jsx("div",{className:"work-head__title",children:"运行监控"}),a.jsx("div",{className:"work-head__sub",children:"待启动"})]}),a.jsx("div",{className:"work-body",children:a.jsxs("div",{className:"run-intro",children:[a.jsx("div",{className:"run-intro__icon",children:a.jsx(V,{name:"play",size:28,color:"#fff"})}),a.jsx("h3",{className:"run-intro__title",children:_?"启动真实工作流":"启动模拟工作流"}),a.jsx("p",{className:"run-intro__desc",children:_?"启动后会连接真实运行服务,监听 AI 表格中的待处理记录,并按当前流程方案执行。":"启动后记录将陆续进入,系统自动执行分类、处理、审核与发送,人工把关环节会等待确认。"}),a.jsxs("button",{type:"button",className:"primary run-intro__cta",onClick:O,children:[a.jsx(V,{name:"play",size:15,color:"#fff"}),_?"启动真实运行":"启动模拟运行"]})]})})]})}):a.jsxs("div",{className:"run-stage",children:[a.jsxs("div",{className:"run-board",children:[a.jsxs("div",{className:"run-board__head",children:[a.jsx("span",{children:"工单队列"}),a.jsx("span",{className:"run-board__stat",children:_?S?"1/1 已连接":"0/1 待连接":`${r.arrived}/${r.total} 进入`})]}),a.jsx("div",{className:"run-board__list",children:a.jsx(Ho,{initial:!1,children:o.map(C=>{const M=ew[C.status];return a.jsxs(Ye.button,{type:"button",layout:!0,variants:St,initial:"hidden",animate:"visible",exit:"exit",className:`ticket-card${C.id===h?" is-selected":""}`,onClick:()=>p(C.id),children:[a.jsxs("div",{className:"ticket-card__top",children:[a.jsx("span",{className:`pill pill--${M.cls}`,children:M.label}),a.jsx("span",{className:"ticket-card__prio",children:C.priority})]}),a.jsx("div",{className:"ticket-card__title",children:C.title}),a.jsxs("div",{className:"ticket-card__meta",children:[C.customer," · ",C.category]}),a.jsxs("div",{className:"ticket-card__progress",children:[C.doneStepIds.length,"/",k.length," 步",!_&&n.isAwaiting(C.id)&&a.jsx("span",{className:"ticket-card__await",children:"待审批"})]})]},C.id)})})}),a.jsxs("div",{className:"run-board__foot",children:["处理中 ",I.running," · 审核中 ",I.review," · 已完成 ",I.done]})]}),a.jsxs("div",{className:"run-flow",children:[a.jsx("div",{className:"run-flow__head",children:P?a.jsxs(a.Fragment,{children:[a.jsx("div",{className:"run-flow__title",children:P.title}),a.jsx("div",{className:"run-flow__sub",children:P.customer})]}):a.jsx("div",{className:"run-flow__sub",children:"选择左侧工单查看步骤流转"})}),P&&a.jsx("div",{className:"step-chain",children:k.map((C,M)=>{const T=nw(P,C.id),R=!_&&T==="active"&&C.needsHuman&&n.isAwaiting(P.id);return a.jsxs("div",{className:`chain-node is-${T}`,children:[M>0&&a.jsx("div",{className:`chain-node__line is-${T}`}),a.jsxs("div",{className:"chain-node__row",children:[a.jsx("span",{className:"chain-node__dot",children:T==="done"?a.jsx(V,{name:"check",size:12,color:"#fff"}):T==="active"?a.jsx("span",{className:"chain-node__pulse"}):a.jsx("span",{className:"chain-node__idle"})}),a.jsxs("div",{className:"chain-node__body",children:[a.jsxs("div",{className:"chain-node__name",children:[a.jsx("span",{className:"chain-node__label",children:C.name}),C.requiresAgent&&a.jsx("span",{className:"chain-node__engine",style:{"--c":"var(--agent-llm)"},children:"AI"}),C.needsHuman&&a.jsx("span",{className:"pill pill--amber",children:"人工"}),!C.requiresAgent&&!C.needsHuman&&a.jsx("span",{className:"pill pill--muted",children:"自动"})]}),a.jsx("div",{className:"chain-node__recipe",children:C.recipe||"自动处理"}),R&&a.jsxs("div",{className:"chain-node__approve",children:[a.jsxs("button",{type:"button",className:"primary btn-approve",onClick:()=>n.approve(P.id),children:[a.jsx(V,{name:"check",size:13,color:"#fff"})," 通过"]}),a.jsxs("button",{type:"button",className:"btn-reject",onClick:()=>n.reject(P.id),children:[a.jsx(V,{name:"close",size:13})," 驳回"]})]})]})]})]},C.id)})})]}),a.jsxs("div",{className:"run-logs",children:[a.jsxs("div",{className:"run-logs__head",children:[a.jsx(V,{name:"file",size:14}),"执行日志",P&&a.jsx("span",{className:"run-logs__sub",children:P.title})]}),a.jsxs("div",{className:"run-logs__body",children:[$.length===0?a.jsx("div",{className:"empty-hint",style:{padding:20},children:P?"等待执行日志…":"选择工单查看日志"}):a.jsx(Ho,{initial:!1,children:$.map(C=>{const M=k.find(T=>T.id===C.stepId);return a.jsxs(Ye.div,{layout:!0,variants:St,initial:"hidden",animate:"visible",className:`log-line log-line--${C.level}`,children:[a.jsx("span",{className:"log-line__icon",children:a.jsx(V,{name:tw[C.level],size:11})}),a.jsxs("div",{className:"log-line__content",children:[a.jsx("span",{className:"log-line__step",children:(M==null?void 0:M.name)??C.stepId}),a.jsx("span",{className:"log-line__text",children:C.text})]})]},C.id)})}),a.jsx("div",{ref:D})]})]})]}):a.jsx("div",{className:"split split--chatonly",children:a.jsxs("div",{className:"split__work",children:[a.jsxs("div",{className:"work-head",children:[a.jsx(V,{name:"play",size:16}),a.jsx("div",{className:"work-head__title",children:"运行监控"}),a.jsx("div",{className:"work-head__sub",children:"未到达"})]}),a.jsx("div",{className:"work-body",children:a.jsxs("div",{className:"run-intro",children:[a.jsx("div",{className:"run-intro__icon",children:a.jsx(V,{name:"table",size:28,color:"#fff"})}),a.jsx("h3",{className:"run-intro__title",children:"当前流程尚未完成搭建"}),a.jsx("p",{className:"run-intro__desc",children:"运行阶段必须基于当前流程实例已搭建完成的 AI 表格。请先完成搭建阶段,再启动真实运行监听。"}),a.jsxs("button",{type:"button",className:"primary run-intro__cta",onClick:()=>z.setRoute("setup"),children:[a.jsx(V,{name:"chevron-right",size:15,color:"#fff"}),"返回搭建阶段"]})]})})]})})});function Uf(e){return{id:`run_preflight_${Date.now().toString(36)}`,ts:Date.now(),ticketId:"run",stepId:"run",level:"error",text:e}}const rw=[{id:"hr-onboarding",name:"HR 入职协同",steps:[{id:"classify",name:"信息校验",recipe:"validate-onboarding",engine:"llm_only",auto:!0,inputs:["员工姓名","身份证号","入职日期"],outputs:["校验结论","异常项"]},{id:"investigate",name:"权限准备",recipe:"prepare-access",engine:"qoder",auto:!0,inputs:["员工姓名","部门","岗位","校验结论"],outputs:["权限清单"]},{id:"draft_reply",name:"入职指引草拟",recipe:"draft-onboarding-guide",engine:"llm_only",auto:!0,inputs:["员工姓名","部门","岗位","权限清单"],outputs:["入职指引"]},{id:"quality_check",name:"法务与 HR 复核",recipe:"hr-legal-review",engine:"llm_only",auto:!1,needsHuman:!0,inputs:["入职指引","异常项"],outputs:["复核结论"]},{id:"send_reply",name:"发送入职通知",recipe:"send-onboarding-notice",engine:"llm_only",auto:!0,inputs:["员工姓名","入职指引","复核结论"],outputs:["发送状态"]}],edges:[{from:"classify",to:"investigate"},{from:"investigate",to:"draft_reply"},{from:"draft_reply",to:"quality_check"},{from:"quality_check",to:"send_reply"}]},{id:"customer-service",name:"客服工单处理",steps:[{id:"classify",name:"工单分类",recipe:"classify-ticket",engine:"llm_only",auto:!0,inputs:["标题","描述"],outputs:["类型","紧急度"]},{id:"investigate",name:"问题排查",recipe:"investigate",engine:"qoder",auto:!0,inputs:["标题","类型"],outputs:["解决方案"]},{id:"draft_reply",name:"草拟回复",recipe:"draft-reply",engine:"llm_only",auto:!0,inputs:["客户","解决方案"],outputs:["回复内容"]},{id:"quality_check",name:"质量审核",recipe:"quality-check",engine:"llm_only",auto:!1,needsHuman:!0,inputs:["回复内容"],outputs:["审核结论"]},{id:"send_reply",name:"发送回复",recipe:"send-reply",engine:"llm_only",auto:!0,inputs:["客户","回复内容"],outputs:["发送状态"]}],edges:[{from:"classify",to:"investigate"},{from:"investigate",to:"draft_reply"},{from:"draft_reply",to:"quality_check"},{from:"quality_check",to:"send_reply"}]},{id:"message-triage",name:"消息分诊",steps:[{id:"investigate",name:"深度调查",recipe:"investigate",engine:"qoder",auto:!0,inputs:["消息内容","发送人"],outputs:["调查结论"]},{id:"reply",name:"群内回复",recipe:"reply-to-group",engine:"llm_only",auto:!0,inputs:["调查结论","对话ID"],outputs:["回复状态"]}],edges:[{from:"investigate",to:"reply"}]},{id:"daily-digest",name:"每日摘要",steps:[{id:"collect",name:"收集当日数据",recipe:"collect-daily",engine:"llm_only",auto:!0,inputs:["日期"],outputs:["统计数据"]},{id:"generate",name:"生成摘要",recipe:"generate-digest",engine:"llm_only",auto:!0,inputs:["统计数据"],outputs:["摘要内容"]},{id:"send",name:"发送到群",recipe:"send-to-group",engine:"llm_only",auto:!0,inputs:["摘要内容"],outputs:["发送状态"]}],edges:[{from:"collect",to:"generate"},{from:"generate",to:"send"}]},{id:"kb-im",name:"知识库问答",steps:[{id:"check_relevance",name:"判断问题相关性",recipe:"check-relevance",engine:"llm_only",auto:!0,inputs:["消息内容"],outputs:["是否相关"]},{id:"generate_answer",name:"生成回答",recipe:"generate-answer",engine:"qoder",auto:!0,inputs:["消息内容","知识库文章"],outputs:["回答内容"]},{id:"reply_to_group",name:"回复群消息",recipe:"reply-to-group",engine:"llm_only",auto:!0,inputs:["回答内容","群ID"],outputs:["发送状态"]}],edges:[{from:"check_relevance",to:"generate_answer"},{from:"generate_answer",to:"reply_to_group"}]},{id:"discovery-demo",name:"需求发现演示",steps:[{id:"classify",name:"工单分类",recipe:"classify",engine:"llm_only",auto:!0,inputs:["消息内容"],outputs:["问题类型","紧急程度"]},{id:"enrich",name:"信息补全",recipe:"enrich",engine:"qoder",auto:!0,inputs:["消息内容","订单号"],outputs:["客户记录","历史工单"]},{id:"draft",name:"回复草拟",recipe:"draft-reply",engine:"llm_only",auto:!0,inputs:["客户记录","历史工单"],outputs:["回复内容"]},{id:"review",name:"质检审核",recipe:"quality-check",engine:"llm_only",auto:!1,needsHuman:!0,inputs:["回复内容"],outputs:["审核结果"]},{id:"send",name:"发送回复",recipe:"send-reply",engine:"llm_only",auto:!0,inputs:["回复内容"],outputs:["发送状态"]}],edges:[{from:"classify",to:"enrich"},{from:"enrich",to:"draft"},{from:"draft",to:"review"},{from:"review",to:"send"}]},{id:"plugin-i18n-upgrade",name:"插件国际化升级",steps:[{id:"prepare_workspace",name:"准备工作空间",recipe:"prepare-workspace",engine:"qoder",auto:!0,inputs:["插件名称","仓库地址"],outputs:["目标分支"]},{id:"upgrade_i18n",name:"国际化升级",recipe:"upgrade-i18n",engine:"qoder",auto:!0,inputs:["插件名称","目标分支"],outputs:["升级日志"]},{id:"submit_review",name:"提交代码评审",recipe:"submit-review",engine:"qoder",auto:!0,inputs:["目标分支"],outputs:["MR链接"]}],edges:[{from:"prepare_workspace",to:"upgrade_i18n"},{from:"upgrade_i18n",to:"submit_review"}]}];function QE(){return rw}function Wf(e){return QE().find(n=>n.id===e)??null}const sw=/\.(json|ya?ml|ts|js|md|txt)$/i,AW=new Set(["runtime","traces","node_modules"]),iw=/(^|\/)\.(_|DS_Store)/;function ow(e){const t=e.split("/")[0]??"";return AW.has(t)}async function TW(e){const t=Array.from(e),n=[];for(const s of t)if(s.name.toLowerCase().endsWith(".zip")){const o=await Tk(s),l=MW(Object.keys(o));for(const[c,u]of Object.entries(o)){const d=l(c).replace(/^\/+/,"");!d||iw.test(d)||ow(d)||!sw.test(d)||n.push({path:d,content:u})}}else{const o=PW(s);if(!o||iw.test(o)||ow(o)||!sw.test(o))continue;const l=await s.text();n.push({path:o,content:l})}const r=new Map;for(const s of n)r.set(s.path,s);return Array.from(r.values()).sort((s,i)=>s.path.localeCompare(i.path))}function PW(e){var n;const t=(n=e.webkitRelativePath)==null?void 0:n.trim();return t&&t.includes("/")?ZE(t):e.name}function MW(e){if(e.length===0)return s=>s;const t=e.map(s=>s.split("/")).filter(s=>s.length>1).map(s=>s[0]);if(t.length===0)return s=>s;const n=t[0];return t.every(s=>s===n)?s=>ZE(s):s=>s}function ZE(e){const t=e.split("/");return t.length>1?t.slice(1).join("/"):e}function aw(e,t,n){return{id:`imported_${t}`,projectId:e,stage:t,status:"succeeded",attempt:1,startedAt:n,updatedAt:n,completedAt:n,currentAction:"已随包导入",checkpoint:"done"}}function IW(e){const t=[],n=[];for(const o of e)t.push({path:o.path,status:"ok"});if(!e.some(o=>o.path==="aitable-workflow.config.yml"||o.path.endsWith(".config.yml")))t.push({path:"aitable-workflow.config.yml",status:"warning",detail:"缺失主配置文件,导入后可在「配置」阶段补齐"});else{const o=e.find(c=>c.path==="aitable-workflow.config.yml"||c.path.endsWith(".config.yml"));o&&!/^[ \t]*scene[ \t]*:[ \t]*\S/m.test(o.content)&&!/^[ \t]*scene[ \t]*:[ \t]*\|/m.test(o.content)&&t.push({path:"scene",status:"warning",detail:"config 缺少 scene 字段(业务场景描述)"})}return e.some(o=>o.path.startsWith("roles/")&&o.path.endsWith(".role.yml"))||t.push({path:"roles/",status:"warning",detail:"未检测到角色定义,可后续添加"}),e.some(o=>o.path==="workflow.yml"||o.path.endsWith("/workflow.yml"))||t.push({path:"workflow.yml",status:"warning",detail:"未包含工作流,导入后可在「设计」阶段生成"}),{items:t,envMissing:n}}function RW({onClose:e}){const t=QE(),n=b.useRef(null),[r,s]=b.useState("upload"),[i,o]=b.useState(!1),[l,c]=b.useState(!1),[u,d]=b.useState(null),[f,h]=b.useState([]),[p,v]=b.useState([]),[x,w]=b.useState([]),[g,y]=b.useState(null),[m,_]=b.useState(!1),[j,N]=b.useState(!1),[k,S]=b.useState(null),[P,$]=b.useState("");async function D(T){var R,B,L,F,W;c(!0),d(null);try{const U=Array.from(T),K=U.length>=1&&U.every(X=>/\.aitable-workflow\.zip$|\.zip$/i.test(X.name))?await I(U).catch(()=>null):null,Q=(K==null?void 0:K.files)??await TW(T);if(Q.length===0){d("未解析到可导入的文件(仅支持 .json/.yml/.yaml/.ts/.js/.md/.txt,且不能位于 runtime/traces/node_modules)"),o(!1),h([]),v([]),w([]);return}const{items:J,envMissing:H}=IW(Q);for(const X of(K==null?void 0:K.checksumWarnings)??[])J.push({path:X,status:"warning",detail:"checksum 校验"});h(Q),v(J),w(H),o(!0);const q=(R=K==null?void 0:K.title)==null?void 0:R.trim(),ne=(B=Q.find(X=>X.path==="aitable-workflow.config.yml"||X.path.endsWith(".config.yml")))==null?void 0:B.content,te=ne?((L=/^name:\s*(?:"([^"]*)"|'([^']*)'|([^#\n]*))/m.exec(ne))==null?void 0:L[1])??((F=/^name:\s*(?:"([^"]*)"|'([^']*)'|([^#\n]*))/m.exec(ne))==null?void 0:F[3]):null,ee=q||(te!=null&&te.trim()?te.trim():"")||((W=U.find(X=>/\.zip$/i.test(X.name)))==null?void 0:W.name.replace(/\.aitable-workflow\.zip$|\.zip$/i,""))||"导入项目";$(ee)}catch(U){d(U instanceof Error?U.message:String(U)),o(!1)}finally{c(!1)}}async function I(T){const R=[];let B;const L=[];let F=!1;const W=new Map;for(const U of T)try{const K=await U3(U);if(!K.manifest)continue;F=!0,!B&&K.title&&(B=K.title);for(const Q of K.checksumWarnings)L.push(Q);for(const Q of K.files)W.set(Q.path,Q)}catch{}if(!F)return null;for(const U of W.values())R.push(U);return R.sort((U,K)=>U.path.localeCompare(K.path)),{files:R,title:B,checksumWarnings:L}}function O(T){!T.target.files||T.target.files.length===0||(D(T.target.files),T.target.value="")}function E(T){y(T);const R=Wf(T);$((R==null?void 0:R.name)??T),h([]),d(null),v([{path:`examples/${T}/config.yml`,status:"ok"},{path:`examples/${T}/workflow.yml`,status:"ok"},{path:`examples/${T}/recipes/`,status:"ok"},{path:`examples/${T}/roles/`,status:"ok"}]),w([]),o(!0)}function A(){if(!P){const T=g?Wf(g):null;$((T==null?void 0:T.name)??"导入项目")}_(!0)}async function C(){if(N(!0),S(null),ue)try{const{project:F}=await UD(P,f);z.setProjectSource("imported"),await ba(F.id,{fallbackRoute:"init"}),e();return}catch(F){S(F instanceof Error?F.message:String(F)),N(!1);return}const T=`mock-imported-${Date.now()}`,R=g?Wf(g):null,B=((R==null?void 0:R.steps.length)??0)>0,L=new Date().toISOString();z.setProjectSource("imported"),z.applyLoadedProject({snapshot:{...as(),projectId:T,projects:ka(z.projects,{id:T,title:P,dir:"",createdAt:L,updatedAt:L}),files:f,workflow:R?{steps:R.steps,edges:R.edges}:null,projectState:{projectId:T,activeStage:null,stages:{init:{task:aw(T,"init",L)},...B?{design:{task:aw(T,"design",L)}}:{}},updatedAt:L},init:{name:P,agentsSelected:[],selectedMachineId:"",tableConnected:!1,tableBaseId:"",tableId:"",llmProvider:"",llmModel:"",roles:[],sop:""}},route:B?"setup":"design"}),e()}const M=i&&(r==="upload"||g);return a.jsx("div",{className:"modal-overlay",onClick:e,children:a.jsxs("div",{className:"import-panel",onClick:T=>T.stopPropagation(),children:[a.jsxs("div",{className:"import-panel__head",children:[a.jsx("span",{className:"import-panel__title",children:"导入已有项目"}),a.jsx("button",{type:"button",className:"modal-card__close",onClick:e,children:a.jsx(V,{name:"close",size:14})})]}),a.jsx("div",{className:"import-panel__body",children:m?a.jsxs("div",{className:"import-confirm",children:[a.jsx("div",{className:"import-confirm__icon",children:a.jsx(V,{name:"file",size:22})}),a.jsx("h4",{className:"import-confirm__title",children:"确认导入到我的项目?"}),a.jsxs("p",{className:"import-confirm__desc",children:["将在你的账号下新建项目,并导入已解析的工作流配置。",g&&a.jsxs(a.Fragment,{children:[a.jsx("br",{}),a.jsx("span",{className:"cfg-muted",children:"导入后需在「搭建」阶段配置 AI 表格。"})]})]}),a.jsxs("div",{className:"role-field",children:[a.jsx("label",{className:"role-field__label",children:"项目名称"}),a.jsx("input",{className:"import-confirm__input",value:P,onChange:T=>$(T.target.value),placeholder:"输入项目名称"})]}),k&&a.jsxs("div",{className:"import-env-warn",children:[a.jsx(V,{name:"warn",size:13}),k]})]}):a.jsxs(a.Fragment,{children:[a.jsxs("div",{className:"import-panel__sources",children:[a.jsxs("label",{className:`import-source${r==="upload"?" is-selected":""}`,children:[a.jsx("input",{type:"radio",name:"source",checked:r==="upload",onChange:()=>{s("upload"),o(!1),y(null),d(null),h([]),v([])}}),"上传项目包"]}),a.jsxs("label",{className:`import-source${r==="template"?" is-selected":""}`,children:[a.jsx("input",{type:"radio",name:"source",checked:r==="template",onChange:()=>{s("template"),o(!1),d(null),h([])}}),"从模板库选择"]})]}),r==="upload"&&a.jsxs(a.Fragment,{children:[a.jsx("input",{ref:n,type:"file",multiple:!0,accept:".zip,.json,.yml,.yaml,.ts,.js,.md,.txt",style:{display:"none"},onChange:O}),a.jsxs("button",{type:"button",className:"import-drop",disabled:l,onClick:()=>{var T;return(T=n.current)==null?void 0:T.click()},children:[a.jsx(V,{name:"plus",size:20}),a.jsx("span",{children:l?"解析中...":i?"重新选择文件 (.zip / 多选 / 目录)":"拖拽或点击上传 (.zip / 多选)"})]}),u&&a.jsxs("div",{className:"import-env-warn",children:[a.jsx(V,{name:"warn",size:13}),u]})]}),r==="template"&&a.jsx("div",{className:"import-templates",children:t.map(T=>a.jsxs("button",{type:"button",className:`import-template${g===T.id?" is-selected":""}`,onClick:()=>E(T.id),children:[a.jsx("span",{className:"import-template__icon",children:a.jsx(V,{name:"flow",size:14})}),a.jsx("span",{className:"import-template__name",children:T.name}),a.jsxs("span",{className:"cfg-muted",children:["examples/",T.id]})]},T.id))}),i&&a.jsxs("div",{className:"import-preview",children:[a.jsxs("div",{className:"import-preview__title",children:["解析结果预览(",f.length||p.length," 项):"]}),a.jsx("ul",{className:"import-preview__list",children:p.map(T=>a.jsxs("li",{className:`import-preview__item import-preview__item--${T.status}`,children:[a.jsx("span",{className:"import-preview__icon",children:T.status==="ok"?"✓":T.status==="warning"?"⚠":"✗"}),a.jsx("span",{className:"import-preview__path",children:T.path}),T.detail&&a.jsx("span",{className:"import-preview__detail",children:T.detail})]},T.path))}),x.length>0&&a.jsxs("div",{className:"import-env-warn",children:[a.jsx(V,{name:"warn",size:13}),"需要补齐 ",x.length," 个环境变量"]})]})]})}),a.jsx("div",{className:"import-panel__foot",children:m?a.jsxs(a.Fragment,{children:[a.jsx("button",{type:"button",className:"modal-card__btn",onClick:()=>_(!1),children:"返回"}),a.jsx("button",{type:"button",className:"primary modal-card__btn",disabled:!P.trim()||j,onClick:()=>void C(),children:j?"导入中...":"确认导入"})]}):a.jsxs(a.Fragment,{children:[a.jsx("button",{type:"button",className:"modal-card__btn",onClick:e,children:"取消"}),a.jsx("button",{type:"button",className:"primary modal-card__btn",disabled:!M,onClick:A,children:"下一步 →"})]})})]})})}function OW({summary:e,allPassed:t,saving:n,onComplete:r}){return a.jsxs("div",{className:`cfg-summary${t?" cfg-summary--ok":""}`,children:[a.jsxs("div",{className:"cfg-summary__stats",children:[a.jsxs("span",{className:"cfg-summary__stat",children:[a.jsx(V,{name:"check",size:14,color:"var(--green)"}),e.passedModules,"/",e.totalModules," 模块通过"]}),e.errors>0&&a.jsxs("span",{className:"cfg-summary__stat cfg-summary__stat--error",children:[e.errors," 错误"]}),e.warnings>0&&a.jsxs("span",{className:"cfg-summary__stat cfg-summary__stat--warn",children:[e.warnings," 警告"]})]}),a.jsx("button",{type:"button",className:"primary cfg-summary__btn",disabled:!t||n,onClick:r,children:n?"完成中…":t?"保存配置,继续搭建 →":"请先修复所有错误"})]})}const $W=".md,.txt,.text,.rst,.csv,.json,.yaml,.yml,.xml,.html,.htm,.docx,.pdf,.xlsx",LW=new Set([".docx",".pdf",".xlsx"]);let DW=0;function zW(e){const t=new Uint8Array(e);let n="";for(let r=0;r<t.length;r++)n+=String.fromCharCode(t[r]);return btoa(n)}function VW(e){const t=e.lastIndexOf(".");return t>=0?e.slice(t).toLowerCase():""}function FW({roleId:e,onIngestUrl:t,onUploadFiles:n}){const[r,s]=b.useState([]),[i,o]=b.useState([]),[l,c]=b.useState(!1),u=b.useRef(null),d=b.useRef(null),f=b.useRef(null),h=b.useCallback(()=>{s(_=>[..._,{id:++DW,type:"file",url:"",files:[]}])},[]),p=b.useCallback(_=>{s(j=>j.filter(N=>N.id!==_))},[]),v=b.useCallback((_,j)=>{s(N=>N.map(k=>k.id===_?{...k,type:j,url:"",files:[]}:k))},[]),x=b.useCallback((_,j)=>{s(N=>N.map(k=>k.id===_?{...k,url:j}:k))},[]),w=b.useCallback((_,j)=>{var N,k;f.current=_,j==="folder"?(N=d.current)==null||N.click():(k=u.current)==null||k.click()},[]),g=b.useCallback(_=>{const j=f.current;if(j===null)return;const N=Array.from(_.target.files??[]);N.length>0&&s(k=>k.map(S=>S.id===j?{...S,files:N}:S)),_.target.value=""},[]),y=b.useCallback(async()=>{if(l)return;c(!0);const _=[];for(const j of r)if(j.type==="url"){if(!j.url.trim())continue;try{const N=await t(e,j.url.trim());_.push({ok:N.ok,message:N.message??(N.ok?"导入成功":"导入失败")})}catch(N){_.push({ok:!1,message:N instanceof Error?N.message:"导入失败"})}}else{if(j.files.length===0)continue;try{const N=[];for(const S of j.files){const P=VW(S.name),$=S.webkitRelativePath||S.name;if(LW.has(P)){const D=await S.arrayBuffer();N.push({name:S.name,relativePath:$,content:zW(D),encoding:"base64"})}else{const D=await S.text();N.push({name:S.name,relativePath:$,content:D,encoding:"utf8"})}}const k=await n(e,N);_.push({ok:k.ok,message:k.message??(k.ok?`导入成功 (${j.files.length} 个文件)`:"导入失败")})}catch(N){_.push({ok:!1,message:N instanceof Error?N.message:"文件上传失败"})}}o(j=>[...j,..._]),s([]),c(!1)},[l,r,e,t,n]),m=r.some(_=>_.type==="url"&&_.url.trim()||_.type==="file"&&_.files.length>0);return a.jsxs("div",{className:"kb-panel",children:[a.jsx("input",{ref:u,type:"file",multiple:!0,accept:$W,style:{display:"none"},onChange:g}),a.jsx("input",{ref:d,type:"file",webkitdirectory:"",directory:"",multiple:!0,style:{display:"none"},onChange:g}),i.length>0&&a.jsx("div",{className:"kb-panel__results",children:i.map((_,j)=>a.jsxs("div",{className:`kb-panel__result ${_.ok?"is-ok":"is-error"}`,children:[a.jsx(V,{name:_.ok?"check":"warn",size:12,color:_.ok?"var(--green)":"var(--red)"}),a.jsx("span",{children:_.message})]},j))}),r.length>0&&a.jsx("div",{className:"kb-panel__rows",children:r.map(_=>a.jsxs("div",{className:"kb-panel__row",children:[a.jsxs("select",{className:"kb-panel__type-select",value:_.type,onChange:j=>v(_.id,j.target.value),disabled:l,children:[a.jsx("option",{value:"file",children:"本地文件"}),a.jsx("option",{value:"url",children:"在线文档链接"})]}),_.type==="file"?a.jsxs("div",{className:"kb-panel__file-area",children:[_.files.length>0?a.jsxs("span",{className:"kb-panel__file-info",title:_.files.map(j=>j.name).join(`
|
|
320
320
|
`),children:["已选 ",_.files.length," 个文件"]}):a.jsx("span",{className:"kb-panel__file-placeholder",children:"未选择文件"}),a.jsx("button",{type:"button",className:"kb-panel__file-btn",onClick:()=>w(_.id,"file"),disabled:l,children:"选择文件"}),a.jsx("button",{type:"button",className:"kb-panel__file-btn",onClick:()=>w(_.id,"folder"),disabled:l,children:"选择文件夹"})]}):a.jsx("input",{type:"text",className:"qf-input kb-panel__url-input",value:_.url,placeholder:"输入在线文档链接",onChange:j=>x(_.id,j.target.value),disabled:l}),a.jsx("button",{type:"button",className:"kb-panel__row-remove",onClick:()=>p(_.id),disabled:l,title:"删除此行",children:a.jsx(V,{name:"close",size:12})})]},_.id))}),a.jsxs("div",{className:"kb-panel__actions",children:[a.jsx("button",{type:"button",className:"cfg-item__edit-btn cfg-item__kb-btn",onClick:h,disabled:l,children:r.length>0||i.length>0?"继续添加知识库":"添加知识库"}),r.length>0&&a.jsx("button",{type:"button",className:"primary kb-panel__import-btn",onClick:()=>void y(),disabled:l||!m,children:l?"导入中…":"导入"})]})]})}function BW({fileRef:e}){const[t,n]=b.useState(!1),[r,s]=b.useState(null),[i,o]=b.useState(""),[l,c]=b.useState(!1),[u,d]=b.useState(!1),[f,h]=b.useState(!1),[p,v]=b.useState(null),[x,w]=b.useState(!1);async function g(){if(t){n(!1);return}if(n(!0),r===null){d(!0),v(null);try{const _=await DD(e.path);s(_.content),o(_.content)}catch(_){v(_ instanceof Error?_.message:String(_))}finally{d(!1)}}}async function y(){h(!0),v(null);try{await zD(e.path,i),s(i),c(!1),w(!0),setTimeout(()=>w(!1),2400)}catch(_){v(_ instanceof Error?_.message:String(_))}finally{h(!1)}}const m=(e.summary??[]).map(_=>_.count!==void 0?`${_.key} ${_.count}`:_.key).join(" · ");return a.jsxs("div",{className:"file-ref",children:[a.jsxs("button",{type:"button",className:"file-ref__toggle",onClick:()=>void g(),children:[a.jsx("span",{className:`file-ref__chevron${t?" is-open":""}`,children:a.jsx(V,{name:"chevron-right",size:11})}),a.jsx(V,{name:"file",size:12,color:"var(--text-muted)"}),a.jsx("code",{className:"file-ref__path",children:e.path}),e.exists?m&&a.jsx("span",{className:"file-ref__summary",children:m}):a.jsx("span",{className:"file-ref__missing",children:"文件不存在,展开可创建"})]}),e.exists&&a.jsxs("div",{className:"file-ref__locked-hint",children:[a.jsx(V,{name:"lock",size:11,color:"var(--text-muted)"}),a.jsx("span",{children:"该配置指向上方文件,路径不可改;展开文件编辑其内容"})]}),t&&a.jsxs("div",{className:"file-ref__body",children:[u&&a.jsx("div",{className:"file-ref__hint",children:"读取中…"}),p&&a.jsxs("div",{className:"file-ref__error",children:[a.jsx(V,{name:"warn",size:13,color:"var(--red)"}),a.jsx("span",{children:p})]}),!u&&r!==null&&!l&&a.jsxs(a.Fragment,{children:[a.jsx("pre",{className:"file-ref__pre",children:r||"(空文件)"}),a.jsxs("div",{className:"file-ref__actions",children:[a.jsx("button",{type:"button",className:"file-ref__btn",onClick:()=>{o(r),c(!0),v(null)},children:"编辑内容"}),x&&a.jsxs("span",{className:"file-ref__saved",children:[a.jsx(V,{name:"check",size:12,color:"var(--green)"})," 已保存"]})]})]}),!u&&l&&a.jsxs(a.Fragment,{children:[a.jsx("textarea",{className:"qf-textarea file-ref__editor",value:i,spellCheck:!1,onChange:_=>o(_.target.value),autoFocus:!0}),a.jsxs("div",{className:"file-ref__actions",children:[a.jsx("button",{type:"button",className:"primary file-ref__btn",onClick:()=>void y(),disabled:f,children:f?"保存中…":`保存${e.format==="json"?" JSON":" YAML"}`}),a.jsx("button",{type:"button",className:"file-ref__btn",onClick:()=>{o(r??""),c(!1),v(null)},disabled:f,children:"取消"}),a.jsxs("span",{className:"file-ref__hint file-ref__hint--inline",children:["保存前会校验",e.format==="json"?" JSON":" YAML","语法,语法错误不会写入"]})]})]})]})]})}const HW=/secret|token|password|api_key/i;let JE=1;function UW(e,t){if(!e.trim())return[];try{const n=JSON.parse(e);return!n||typeof n!="object"||Array.isArray(n)?[]:Object.entries(n).map(([r,s])=>{const i={},o=[...t.valueFields];for(const l of Object.keys(s??{}))o.includes(l)||o.push(l);for(const l of o){const c=(s??{})[l];i[l]=c==null?"":String(c)}return{id:JE++,name:r,fields:i}})}catch{return[]}}function lw(e){const t={};for(const n of e.valueFields)t[n]="";return{id:JE++,name:"",fields:t}}function WW({spec:e,initialValue:t,saving:n,onSave:r,onCancel:s}){const[i,o]=b.useState(()=>{const p=UW(t,e);return p.length>0?p:[lw(e)]}),l=e.keyLabel??"名称",c=b.useMemo(()=>{const p=i.map(v=>v.name.trim());return p.some(v=>!v)?`每一项都需要填写「${l}」`:new Set(p).size!==p.length?`「${l}」不能重复`:null},[i,l]);function u(p,v){o(x=>x.map(w=>w.id===p?{...w,...v}:w))}function d(p,v,x){o(w=>w.map(g=>g.id===p?{...g,fields:{...g.fields,[v]:x}}:g))}function f(p){o(v=>v.filter(x=>x.id!==p))}async function h(){if(c)return;const p={};for(const v of i)p[v.name.trim()]=v.fields;await r(JSON.stringify(p))}return a.jsxs("div",{className:"env-map",children:[a.jsxs("p",{className:"env-map__hint",children:["按项填写,每项包含 ",e.valueFields.map(p=>a.jsx("code",{children:p},p)),",保存后自动写回配置。"]}),i.map((p,v)=>a.jsxs("div",{className:"env-map__entry",children:[a.jsxs("div",{className:"env-map__entry-head",children:[a.jsxs("span",{className:"env-map__entry-index",children:["#",v+1]}),a.jsx("input",{type:"text",className:"qf-input env-map__key-input",placeholder:l,value:p.name,onChange:x=>u(p.id,{name:x.target.value}),autoFocus:!p.name}),a.jsx("button",{type:"button",className:"env-map__remove-btn",title:"删除此项",onClick:()=>f(p.id),disabled:n,children:a.jsx(V,{name:"close",size:13})})]}),a.jsx("div",{className:"env-map__fields",children:Object.keys(p.fields).map(x=>a.jsxs("label",{className:"env-map__field",children:[a.jsx("span",{className:"env-map__field-name",children:x}),a.jsx("input",{type:HW.test(x)?"password":"text",className:"qf-input env-map__field-input",placeholder:`输入 ${x}`,value:p.fields[x]??"",onChange:w=>d(p.id,x,w.target.value)})]},x))})]},p.id)),a.jsxs("button",{type:"button",className:"env-map__add-btn",onClick:()=>o(p=>[...p,lw(e)]),disabled:n,children:[a.jsx(V,{name:"plus",size:13}),"添加一项"]}),c&&i.length>0&&a.jsx("div",{className:"env-map__error",children:c}),a.jsxs("div",{className:"cfg-item__edit-actions",children:[a.jsx("button",{type:"button",className:"primary cfg-item__save-btn",onClick:()=>void h(),disabled:n||!!c||i.length===0,children:n?"保存中…":"保存"}),a.jsx("button",{type:"button",className:"cfg-item__cancel-btn",onClick:s,disabled:n,children:"取消"})]})]})}const cw={ok:{icon:"check",color:"var(--green)"},error:{icon:"warn",color:"var(--red)"},warn:{icon:"warn",color:"var(--amber)"},suggestion:{icon:"dot",color:"var(--blue)"}},uw=".knowledge_scope.kb_collections";function KW(e){if(!e.endsWith(uw))return null;const t=e.slice(0,-uw.length),n=t.lastIndexOf(".");return n>=0?t.slice(n+1):t}function Gn({item:e,onSave:t,onKbIngest:n,onKbUpload:r,suggestedDefault:s}){var N,k,S,P,$,D,I,O,E,A,C,M;const[i,o]=b.useState(!1),[l,c]=b.useState(Po(e)),[u,d]=b.useState(!1),f=((N=e.surface)==null?void 0:N.label)??e.key,h=((k=e.surface)==null?void 0:k.description)??e.message,p=e.writeTarget&&((S=e.surface)==null?void 0:S.editable)!==!1,v=e.sensitive,x=cw[e.status]??cw.suggestion,w=KW(e.key),y=w!==null&&n&&r,m=(P=e.surface)==null?void 0:P.envJsonSpec;async function _(T){if(!(!e.writeTarget||!T.trim())){d(!0);try{await t(e.writeTarget,T),o(!1)}finally{d(!1)}}}async function j(){await _(l)}return a.jsxs("div",{className:`cfg-item cfg-item--${e.status}`,children:[a.jsxs("div",{className:"cfg-item__head",children:[a.jsx("span",{className:"cfg-item__status",children:a.jsx(V,{name:x.icon,size:14,color:x.color})}),a.jsx("span",{className:"cfg-item__label",children:f}),v&&a.jsx("span",{className:"cfg-item__badge cfg-item__badge--sensitive",children:"敏感"}),(($=e.surface)==null?void 0:$.required)&&a.jsx("span",{className:"cfg-item__badge cfg-item__badge--required",children:"必填"})]}),h&&!i&&a.jsx("div",{className:"cfg-item__desc",children:h}),!i&&a.jsxs("div",{className:"cfg-item__value-row",children:[a.jsx("span",{className:`cfg-item__value${((D=e.surface)==null?void 0:D.valueType)==="text"?" cfg-item__value--multiline":""}`,children:m?GW(e,m.keyLabel):v&&e.value?"***":e.value!==void 0&&String(e.value)!==""?String(e.value):"—"}),p&&a.jsx("button",{type:"button",className:"cfg-item__edit-btn",onClick:()=>{c(v?"":Po(e)||s||""),o(!0)},children:"编辑"})]}),!i&&p&&s&&!Po(e)&&a.jsxs("div",{className:"cfg-item__suggest",children:["默认沿用已配置的 Base ID:",a.jsx("code",{children:s}),"(点“编辑”已自动预填,直接保存即可)"]}),!i&&((I=e.surface)==null?void 0:I.fileRef)&&a.jsx(BW,{fileRef:e.surface.fileRef}),i&&m&&a.jsx("div",{className:"cfg-item__edit",children:a.jsx(WW,{spec:m,initialValue:v?"":Po(e),saving:u,onSave:_,onCancel:()=>o(!1)})}),i&&!m&&a.jsxs("div",{className:"cfg-item__edit",children:[((O=e.surface)==null?void 0:O.valueType)==="string[]"||((E=e.surface)==null?void 0:E.valueType)==="text"?a.jsx("textarea",{className:"qf-textarea cfg-item__input",rows:((A=e.surface)==null?void 0:A.valueType)==="text"?10:3,value:l,placeholder:((C=e.surface)==null?void 0:C.valueType)==="text"?`输入 ${f}`:"每行一个值,或用逗号分隔",onChange:T=>c(T.target.value),autoFocus:!0}):a.jsx("input",{type:v?"password":"text",className:"qf-input cfg-item__input",value:l,placeholder:((M=e.surface)==null?void 0:M.description)??`输入 ${f}`,onChange:T=>c(T.target.value),onKeyDown:T=>{T.key==="Enter"&&j()},autoFocus:!0}),a.jsxs("div",{className:"cfg-item__edit-actions",children:[a.jsx("button",{type:"button",className:"primary cfg-item__save-btn",onClick:()=>void j(),disabled:u||!l.trim(),children:u?"保存中…":"保存"}),a.jsx("button",{type:"button",className:"cfg-item__cancel-btn",onClick:()=>o(!1),disabled:u,children:"取消"})]})]}),y&&!p&&a.jsx(FW,{roleId:w,onIngestUrl:n,onUploadFiles:r})]})}function Po(e){return e.value===void 0||e.value===null?"":Array.isArray(e.value)?e.value.join(", "):String(e.value)}function GW(e,t){const n=Po(e);if(!n.trim())return"—";try{const r=JSON.parse(n),s=Object.keys(r);return s.length===0?"—":`已配 ${s.length} 项(${t??"名称"}: ${s.join(", ")})`}catch{return n}}function Nu({items:e}){const[t,n]=b.useState(!1);if(e.length===0)return null;const r=e.map(i=>`[${i.status}] ${i.key}: ${i.message}`).join(`
|
|
321
|
-
`);async function s(){try{await navigator.clipboard.writeText(r),n(!0),setTimeout(()=>n(!1),2e3)}catch{}}return a.jsxs("section",{className:"process-errors",children:[a.jsxs("div",{className:"process-errors__head",children:[a.jsx(V,{name:"warn",size:14,color:"var(--red)"}),a.jsx("span",{children:"过程错误"}),a.jsx("button",{type:"button",className:"process-errors__copy",onClick:()=>void s(),children:t?"已复制":"复制"})]}),e.map((i,o)=>a.jsxs("div",{className:`process-errors__item process-errors__item--${i.status}`,children:[a.jsx("span",{className:"process-errors__icon",children:a.jsx(V,{name:"warn",size:13,color:i.status==="error"?"var(--red)":"var(--amber)"})}),a.jsxs("div",{className:"process-errors__body",children:[i.key&&a.jsx("code",{className:"process-errors__key",children:i.key}),a.jsx("span",{className:"process-errors__msg",children:i.message})]})]},i.key??`pe-${o}`))]})}const qW=new Set(["workflow","agent.engine"]);function YW({config:e,engines:t,projectEnvRefs:n,onSave:r,onBatchSave:s}){const i=e.modules.find(m=>m.id==="project"),o=e.modules.find(m=>m.id==="coding_agent"),l=e.modules.find(m=>m.id==="env"),c=o==null?void 0:o.items.find(m=>m.key==="coding_agent.engine"),u=o==null?void 0:o.items.find(m=>m.key==="coding_agent.config.enabled"),d=c==null?void 0:c.value,[f,h]=b.useState(!1),p=b.useRef(!1),v=b.useCallback(async m=>{if(!(!(c!=null&&c.writeTarget)||!m)){h(!0);try{const _=[{writeTarget:c.writeTarget,value:m}];(u==null?void 0:u.status)==="error"&&u.writeTarget&&_.push({writeTarget:u.writeTarget,value:"true"}),await s(_)}finally{h(!1)}}},[c,u,s]);b.useEffect(()=>{p.current||(c==null?void 0:c.status)==="error"&&d&&t.available.some(m=>m.engine===d)&&c.writeTarget&&(p.current=!0,v(d))},[c,d,t.available,v]);const x=((i==null?void 0:i.items)??[]).filter(m=>!qW.has(m.key)&&(m.status!=="ok"||m.writeTarget)),w=((l==null?void 0:l.items)??[]).filter(m=>m.writeTarget&&(!n||n.includes(m.key))),g=((o==null?void 0:o.items)??[]).filter(m=>m.key!=="coding_agent.engine"&&m.writeTarget&&m.status==="error"),y=[...(i==null?void 0:i.items)??[],...(o==null?void 0:o.items)??[],...e.modules.filter(m=>m.id==="profile").flatMap(m=>m.items),...(l==null?void 0:l.items)??[]].filter(m=>!m.writeTarget&&(m.status==="error"||m.status==="warn"));return a.jsxs("div",{className:"adjust__tab-inner",children:[a.jsxs("section",{className:"adjust__section",children:[a.jsxs("h3",{className:"adjust__section-title",children:[a.jsx(V,{name:"robot",size:15}),"编码引擎"]}),a.jsxs("div",{className:"adjust__engine-row",children:[a.jsxs("select",{className:"qf-select adjust__engine-select",value:d??"",onChange:m=>void v(m.target.value),disabled:f,children:[a.jsx("option",{value:"",children:"请选择…"}),t.available.map(m=>a.jsxs("option",{value:m.engine,children:[m.engine," (",m.cmd,m.version?` v${m.version}`:"",")"]},m.engine)),!t.available.some(m=>m.engine==="llm_only")&&a.jsx("option",{value:"llm_only",children:"llm_only (无需本地 CLI)"})]}),(c==null?void 0:c.status)==="error"&&a.jsxs("span",{className:"adjust__engine-warn",children:[a.jsx(V,{name:"warn",size:13,color:"var(--red)"}),c.message]}),(c==null?void 0:c.status)==="ok"&&a.jsx("span",{className:"adjust__engine-ok",children:a.jsx(V,{name:"check",size:13,color:"var(--green)"})}),f&&a.jsx("span",{className:"adjust__engine-saving",children:"保存中…"})]}),t.recommended&&d!==t.recommended&&a.jsxs("p",{className:"adjust__hint-text",children:["推荐:",t.recommended]})]}),g.length>0&&a.jsxs("section",{className:"adjust__section",children:[a.jsxs("h3",{className:"adjust__section-title",children:[a.jsx(V,{name:"robot",size:15}),"引擎配置"]}),g.map(m=>a.jsx(Gn,{item:m,onSave:r},m.key))]}),(x.length>0||w.length>0)&&a.jsxs("section",{className:"adjust__section",children:[a.jsxs("h3",{className:"adjust__section-title",children:[a.jsx(V,{name:"folder",size:15}),"项目参数"]}),x.map(m=>a.jsx(Gn,{item:m,onSave:r},m.key)),w.map(m=>a.jsx(Gn,{item:m,onSave:r},m.key))]}),x.length===0&&w.length===0&&g.length===0&&(c==null?void 0:c.status)==="ok"&&a.jsxs("div",{className:"adjust__empty",children:[a.jsx(V,{name:"check",size:20,color:"var(--green)"}),a.jsx("span",{children:"项目参数已完整"})]}),a.jsx(Nu,{items:y})]})}const Gp=new Set(["roles.enabled","roles_dir","roles"]);function XW(e){const t=new Map;for(const n of e){if(Gp.has(n.key))continue;const r=n.key.match(/^role\.([^.]+)/);if(!r)continue;const s=r[1];t.has(s)||t.set(s,[]),t.get(s).push(n)}return Array.from(t.entries()).map(([n,r])=>({roleId:n,items:r}))}function QW({config:e,onSave:t,onKbIngest:n,onKbUpload:r}){const s=e.modules.find(u=>u.id==="roles");if(!s)return a.jsx("div",{className:"adjust__empty",children:"角色系统未启用"});const o=s.items.filter(u=>Gp.has(u.key)).find(u=>u.status==="error");if(o){const u=((s==null?void 0:s.items)??[]).filter(d=>!d.writeTarget&&d.status!=="ok"&&d!==o);return a.jsxs("div",{className:"adjust__tab-inner",children:[a.jsxs("div",{className:"adjust__error",children:[a.jsx(V,{name:"warn",size:16,color:"var(--red)"}),a.jsx("span",{children:o.message})]}),a.jsx(Nu,{items:u})]})}const l=XW(s.items);if(l.length===0)return a.jsx("div",{className:"adjust__tab-inner",children:a.jsxs("div",{className:"adjust__empty",children:[a.jsx(V,{name:"user",size:20,color:"var(--text-muted)"}),a.jsx("span",{children:"暂无角色配置"})]})});const c=((s==null?void 0:s.items)??[]).filter(u=>Gp.has(u.key)&&!u.writeTarget&&u.status!=="ok");return a.jsxs("div",{className:"adjust__tab-inner",children:[l.map(u=>a.jsx(ZW,{role:u,onSave:t,onKbIngest:n,onKbUpload:r},u.roleId)),a.jsx(Nu,{items:c})]})}function ZW({role:e,onSave:t,onKbIngest:n,onKbUpload:r}){const s=e.items.find(l=>l.key===`role.${e.roleId}`),i=(s==null?void 0:s.status)==="ok",o=e.items.filter(l=>l.key!==`role.${e.roleId}`);return a.jsxs("div",{className:`role-card${i?" is-ok":""}`,children:[a.jsxs("div",{className:"role-card__head",children:[a.jsx(V,{name:"user",size:15}),a.jsx("span",{className:"role-card__name",children:e.roleId}),a.jsx("span",{className:`role-card__status${i?" is-ok":""}`,children:i?a.jsxs(a.Fragment,{children:[a.jsx(V,{name:"check",size:12})," 通过"]}):"需配置"})]}),o.length>0&&a.jsx("div",{className:"role-card__body",children:o.map(l=>a.jsx(Gn,{item:l,onSave:t,onKbIngest:n,onKbUpload:r},l.key))})]})}function bc(e){const t=e.slice(e.lastIndexOf(".")+1);return t==="base_id"||t==="baseId"}function JW({config:e,workflowTopology:t,onSave:n}){const r=e.modules.find(u=>u.id==="workflow"),s=e.modules.find(u=>u.id==="env"),[i,o]=b.useState(null),l=(r==null?void 0:r.workflows)??[],c=b.useMemo(()=>{for(const u of l)for(const d of u.items)if(bc(d.key)&&typeof d.value=="string"&&d.value.trim())return d.value.trim()},[l]);return l.length===0?a.jsx("div",{className:"adjust__tab-inner",children:a.jsxs("div",{className:"adjust__empty",children:[a.jsx(V,{name:"flow",size:20,color:"var(--text-muted)"}),a.jsx("span",{children:"暂无工作流"})]})}):a.jsx("div",{className:"adjust__tab-inner",children:l.map(u=>a.jsx(e7,{workflow:u,topology:t[u.id],envItems:(s==null?void 0:s.items)??[],suggestedBaseId:c,isOpen:i===u.id,onToggle:()=>o(d=>d===u.id?null:u.id),onSave:n},u.id))})}function e7({workflow:e,topology:t,envItems:n,suggestedBaseId:r,isOpen:s,onToggle:i,onSave:o}){const[l,c]=b.useState(null),u=e.items.filter(k=>k.key==="tracker.base_id"||k.key==="tracker.table_id"),d=e.items.filter(k=>k.key.startsWith("event_source.")&&k.writeTarget),f=b.useMemo(()=>{const k=new Set((t==null?void 0:t.envRefs)??[]);for(const S of Object.values((t==null?void 0:t.stepEnvRefs)??{}))for(const P of S){const $=n.find(D=>D.key===P);$&&$.status==="error"&&k.add(P)}return[...k].map(S=>n.find(P=>P.key===S)).filter(S=>!!S&&!!S.writeTarget)},[t,n]),h=b.useMemo(()=>{const k=new Set((t==null?void 0:t.envRefs)??[]);for(const S of Object.values((t==null?void 0:t.stepEnvRefs)??{}))for(const P of S)k.add(P);return n.filter(S=>k.has(S.key)&&S.status==="error")},[t,n]),p=e.ok&&h.length===0,v=e.items.filter(k=>k.writeTarget&&k.status==="error").length+h.filter(k=>k.writeTarget).length,x=e.items.filter(k=>!k.writeTarget&&k.status==="error").length+h.filter(k=>!k.writeTarget).length,w=b.useMemo(()=>{const k=new Set((t==null?void 0:t.envRefs)??[]);for(const S of Object.values((t==null?void 0:t.stepEnvRefs)??{}))for(const P of S)k.add(P);return[...e.items.filter(S=>!S.writeTarget&&(S.status==="error"||S.status==="warn")),...n.filter(S=>k.has(S.key)&&!S.writeTarget&&(S.status==="error"||S.status==="warn"))]},[t,n,e.items]),g=b.useMemo(()=>t?t.steps.map(k=>{const S=e.items.filter(P=>P.key.startsWith(`step.${k.id}.config.`)&&P.status==="error");return{id:k.id,name:k.name,recipe:k.recipe??"",engine:k.engine??"llm_only",auto:k.auto,inputs:[],outputs:[],configStatus:S.length>0?"missing":"ok",missingConfigKeys:S.map(P=>P.key)}}):[],[t,e.items]),y=b.useMemo(()=>t?t.edges:[],[t]),m=b.useMemo(()=>l?e.items.filter(k=>k.key.startsWith(`step.${l}.config.`)&&k.writeTarget):[],[l,e.items]),_=b.useMemo(()=>!l||!t?[]:(t.stepEnvRefs[l]??[]).map(S=>n.find(P=>P.key===S)).filter(S=>!!S&&S.status!=="ok"),[l,t,n]),j=t==null?void 0:t.steps.find(k=>k.id===l),N=l&&(m.length>0||_.length>0);return a.jsxs("div",{className:`wf-card${p?" is-done":""}`,children:[a.jsxs("button",{type:"button",className:"wf-card__head",onClick:i,children:[a.jsx("span",{className:"wf-card__icon",children:a.jsx(V,{name:"flow",size:15})}),a.jsx("span",{className:"wf-card__name",children:e.name}),v>0&&a.jsxs("span",{className:"wf-card__badge",children:[v," 项需配置"]}),x>0&&a.jsxs("span",{className:"wf-card__badge wf-card__badge--process",children:[x," 项过程错误"]}),a.jsx("span",{className:`wf-card__status${p?" is-ok":""}`,children:p?a.jsxs(a.Fragment,{children:[a.jsx(V,{name:"check",size:12})," 通过"]}):v>0?"需配置":"有异常"}),a.jsx("span",{className:`wf-card__chevron${s?" is-open":""}`,children:a.jsx(V,{name:"chevron-right",size:12})})]}),s&&a.jsxs("div",{className:"wf-card__body",children:[u.length>0&&a.jsx("div",{className:"wf-card__tracker",children:u.map(k=>a.jsx(Gn,{item:k,onSave:o,suggestedDefault:bc(k.key)?r:void 0},k.key))}),t&&g.length>0&&a.jsxs("div",{className:`wf-card__canvas-row${N?" has-panel":""}`,children:[a.jsx("div",{className:"wf-card__canvas",children:a.jsx(IE,{steps:g,edges:y,selectedId:l,onSelect:c})}),N&&j&&a.jsxs("div",{className:"wf-card__panel",children:[a.jsxs("div",{className:"wf-card__panel-head",children:[a.jsx(V,{name:"bolt",size:14}),a.jsxs("span",{children:["步骤配置 · ",j.name]}),a.jsx("button",{type:"button",className:"wf-card__panel-close",onClick:()=>c(null),children:a.jsx(V,{name:"close",size:14})})]}),a.jsxs("div",{className:"wf-card__panel-body",children:[m.map(k=>a.jsx(Gn,{item:k,onSave:o,suggestedDefault:bc(k.key)?r:void 0},k.key)),_.length>0&&a.jsxs(a.Fragment,{children:[a.jsx("div",{className:"wf-card__panel-divider",children:"参数与凭据"}),_.map(k=>a.jsx(Gn,{item:k,onSave:o},k.key))]})]})]}),l&&!N&&j&&a.jsxs("div",{className:"wf-card__panel",children:[a.jsxs("div",{className:"wf-card__panel-head",children:[a.jsx(V,{name:"bolt",size:14}),a.jsxs("span",{children:["步骤配置 · ",j.name]}),a.jsx("button",{type:"button",className:"wf-card__panel-close",onClick:()=>c(null),children:a.jsx(V,{name:"close",size:14})})]}),a.jsx("div",{className:"wf-card__panel-body",children:a.jsxs("div",{className:"adjust__empty",style:{padding:"24px 16px"},children:[a.jsx(V,{name:"check",size:16,color:"var(--green)"}),a.jsx("span",{children:"此步骤配置完整"})]})})]})]}),d.length>0&&a.jsxs("div",{className:"wf-card__events",children:[a.jsxs("div",{className:"wf-card__events-title",children:[a.jsx(V,{name:"bolt",size:13,color:"var(--text-muted)"}),"事件源配置"]}),d.map(k=>a.jsx(Gn,{item:k,onSave:o,suggestedDefault:bc(k.key)?r:void 0},k.key))]}),f.length>0&&a.jsxs("div",{className:"wf-card__events",children:[a.jsxs("div",{className:"wf-card__events-title",children:[a.jsx(V,{name:"lock",size:13,color:"var(--text-muted)"}),"参数与凭据"]}),f.map(k=>a.jsx(Gn,{item:k,onSave:o},k.key))]}),a.jsx(Nu,{items:w})]})]})}const t7=[{id:"project",label:"项目配置",icon:"folder"},{id:"roles",label:"角色配置",icon:"user"},{id:"workflows",label:"工作流配置",icon:"flow"}];function n7(){const[e,t]=b.useState(null),[n,r]=b.useState(!0),[s,i]=b.useState(null),[o,l]=b.useState(!1),[c,u]=b.useState(!1),[d,f]=b.useState("project"),[h,p]=b.useState(!1),v=b.useRef(!1),x=b.useCallback(async()=>{var j,N,k;r(!0),i(null);try{const S=await LD();if(t(S),!S.config.ok){const P=((j=S.config.modules.find(I=>I.id==="project"))==null?void 0:j.ok)??!0,$=((N=S.config.modules.find(I=>I.id==="coding_agent"))==null?void 0:N.ok)??!0,D=((k=S.config.modules.find(I=>I.id==="roles"))==null?void 0:k.ok)??!0;f(!P||!$?"project":D?"workflows":"roles")}}catch(S){i(S instanceof Error?S.message:String(S))}finally{r(!1)}},[]);b.useEffect(()=>{x()},[x]),b.useEffect(()=>{if(e&&!c){const j=N=>{N.preventDefault()};return window.addEventListener("beforeunload",j),()=>window.removeEventListener("beforeunload",j)}},[e,c]);const w=b.useCallback(async()=>{if(!(v.current||c)){v.current=!0,l(!0);try{await RD(),u(!0)}catch(j){i(j instanceof Error?j.message:String(j))}finally{l(!1),v.current=!1}}},[c]),g=b.useCallback(async(j,N)=>{const k=await y_([{writeTarget:j,value:N}]);t(S=>S&&{...S,config:k.recheck})},[]),y=b.useCallback(async j=>{const N=await y_(j);t(k=>k&&{...k,config:N.recheck})},[]),m=b.useCallback(async(j,N)=>{try{const k=await $D(j,N);return t(S=>S&&{...S,config:k.recheck}),{ok:k.ok,message:k.message}}catch(k){const S=k instanceof Error?k.message:"知识库导入失败";return i(S),{ok:!1,message:S}}},[]),_=b.useCallback(async(j,N)=>{try{const k=await OD(j,N);return t(S=>S&&{...S,config:k.recheck}),{ok:k.ok,message:k.message}}catch(k){const S=k instanceof Error?k.message:"文件上传失败";return i(S),{ok:!1,message:S}}},[]);return c?a.jsx("div",{className:"adjust",children:a.jsxs("div",{className:"adjust__done",children:[a.jsx("span",{className:"adjust__done-icon",children:a.jsx(V,{name:"check",size:32,color:"var(--green)"})}),a.jsx("h2",{className:"adjust__done-title",children:"配置完成"}),a.jsx("p",{className:"adjust__done-text",children:"所有配置项已保存到本地文件,CLI 将继续 setup 流程。"}),a.jsx("p",{className:"adjust__done-hint",children:"可以关闭此页面。"})]})}):a.jsxs("div",{className:"adjust",children:[a.jsxs("div",{className:"adjust__head",children:[a.jsx("h1",{className:"adjust__title",children:"参数调整"}),a.jsx("p",{className:"adjust__sub",children:"配置项目参数、角色和工作流"})]}),n&&a.jsx("div",{className:"adjust__loading",children:"正在加载配置状态…"}),s&&a.jsxs("div",{className:"adjust__error",children:[a.jsx(V,{name:"warn",size:16,color:"var(--red)"}),a.jsx("span",{children:s}),a.jsx("button",{type:"button",className:"adjust__retry",onClick:()=>void x(),children:"重试"})]}),e&&a.jsxs(a.Fragment,{children:[a.jsxs("div",{className:"adjust__hint",children:[a.jsx(V,{name:"folder",size:14,color:"var(--text-muted)"}),a.jsx("code",{children:e.config.projectPath})]}),a.jsxs("div",{className:"adjust__tab-area",children:[a.jsx("div",{className:"adjust__tabs",children:t7.map(j=>{var D,I,O,E,A;const N=((D=e.config.modules.find(C=>C.id==="env"))==null?void 0:D.items)??[],k=new Set(e.projectEnvRefs??N.map(C=>C.key)),S=new Set;for(const C of Object.values(e.workflowTopology)){for(const M of C.envRefs??[])S.add(M);for(const M of Object.values(C.stepEnvRefs??{}))for(const T of M)S.add(T)}const P=C=>N.some(M=>M.status==="error"&&C.has(M.key)),$=j.id==="project"?(((I=e.config.modules.find(C=>C.id==="project"))==null?void 0:I.ok)??!0)&&(((O=e.config.modules.find(C=>C.id==="coding_agent"))==null?void 0:O.ok)??!0)&&!P(k):j.id==="roles"?((E=e.config.modules.find(C=>C.id==="roles"))==null?void 0:E.ok)??!0:(((A=e.config.modules.find(C=>C.id==="workflow"))==null?void 0:A.ok)??!0)&&!P(S);return a.jsxs("button",{type:"button",className:`adjust__tab${d===j.id?" is-active":""}${$?"":" has-error"}`,onClick:()=>f(j.id),children:[a.jsx(V,{name:j.icon,size:13}),j.label,!$&&a.jsx("span",{className:"adjust__tab-dot"})]},j.id)})}),a.jsxs("div",{className:"adjust__tab-content",children:[d==="project"&&a.jsx(YW,{config:e.config,engines:e.engines,projectEnvRefs:e.projectEnvRefs,onSave:g,onBatchSave:y}),d==="roles"&&a.jsx(QW,{config:e.config,onSave:g,onKbIngest:m,onKbUpload:_}),d==="workflows"&&a.jsx(JW,{config:e.config,workflowTopology:e.workflowTopology,onSave:g})]})]}),a.jsx(OW,{summary:e.config.summary,allPassed:e.config.ok,saving:o,onComplete:()=>p(!0)}),h&&a.jsx("div",{className:"modal-overlay",onClick:()=>p(!1),children:a.jsxs("div",{className:"modal-card",onClick:j=>j.stopPropagation(),children:[a.jsxs("div",{className:"modal-card__head",children:[a.jsx("span",{className:"modal-card__icon",style:{background:"var(--accent-tint)",color:"var(--accent)"},children:a.jsx(V,{name:"check",size:16})}),a.jsx("span",{className:"modal-card__title",children:"确认进入搭建"}),a.jsx("button",{type:"button",className:"modal-card__close",onClick:()=>p(!1),children:a.jsx(V,{name:"close",size:14})})]}),a.jsx("div",{className:"modal-card__body",children:a.jsx("p",{style:{margin:0,fontSize:14,color:"var(--text)"},children:"确认不再修改配置,进入下一步搭建流程?"})}),a.jsxs("div",{className:"modal-card__foot",children:[a.jsx("button",{type:"button",className:"modal-card__btn",onClick:()=>p(!1),children:"继续修改"}),a.jsx("button",{type:"button",className:"primary modal-card__btn",disabled:o,onClick:()=>{p(!1),w()},children:o?"完成中…":"确认,继续搭建"})]})]})})]})]})}function r7({onSwitchToRegister:e}){const[t,n]=b.useState(""),[r,s]=b.useState(""),[i,o]=b.useState(""),[l,c]=b.useState(!1);async function u(d){if(d.preventDefault(),!(!t||!r)){o(""),c(!0);try{await As.login(t,r)}catch(f){o(f instanceof Error?f.message:String(f))}finally{c(!1)}}}return a.jsx("div",{className:"auth-page",children:a.jsxs("form",{className:"auth-card",onSubmit:u,children:[a.jsxs("div",{className:"auth-card__brand",children:[a.jsx("span",{className:"auth-card__brand-mark",children:a.jsx(V,{name:"sparkle",size:18,color:"#fff"})}),a.jsx("span",{className:"auth-card__brand-name",children:"AITable Agent"})]}),a.jsx("h2",{className:"auth-card__title",children:"登录"}),i&&a.jsx("div",{className:"auth-error",children:i}),a.jsxs("div",{className:"auth-field",children:[a.jsx("label",{className:"auth-field__label",children:"用户名"}),a.jsx("input",{className:"auth-field__input",type:"text",placeholder:"请输入用户名",value:t,onChange:d=>n(d.target.value),autoComplete:"username",autoFocus:!0})]}),a.jsxs("div",{className:"auth-field",children:[a.jsx("label",{className:"auth-field__label",children:"密码"}),a.jsx("input",{className:"auth-field__input",type:"password",placeholder:"请输入密码",value:r,onChange:d=>s(d.target.value),autoComplete:"current-password"})]}),a.jsxs("button",{type:"submit",className:"primary auth-submit",disabled:l||!t||!r,children:[l&&a.jsx("span",{className:"auth-spinner"}),l?"登录中...":"登录"]}),a.jsxs("div",{className:"auth-footer",children:["没有账号?",a.jsx("button",{type:"button",className:"auth-footer__link",onClick:e,children:"注册"})]})]})})}function s7({onSwitchToLogin:e}){const[t,n]=b.useState(""),[r,s]=b.useState(""),[i,o]=b.useState(""),[l,c]=b.useState(""),[u,d]=b.useState({}),[f,h]=b.useState(!1);function p(){const x={};return(t.length<3||t.length>32)&&(x.username="用户名长度需在 3-32 个字符之间"),r.length<6&&(x.password="密码长度至少 6 个字符"),r!==i&&(x.confirm="两次输入的密码不一致"),d(x),Object.keys(x).length===0}async function v(x){if(x.preventDefault(),c(""),!!p()){h(!0);try{await As.register(t,r)}catch(w){c(w instanceof Error?w.message:String(w))}finally{h(!1)}}}return a.jsx("div",{className:"auth-page",children:a.jsxs("form",{className:"auth-card",onSubmit:v,children:[a.jsxs("div",{className:"auth-card__brand",children:[a.jsx("span",{className:"auth-card__brand-mark",children:a.jsx(V,{name:"sparkle",size:18,color:"#fff"})}),a.jsx("span",{className:"auth-card__brand-name",children:"AITable Agent"})]}),a.jsx("h2",{className:"auth-card__title",children:"注册"}),l&&a.jsx("div",{className:"auth-error",children:l}),a.jsxs("div",{className:"auth-field",children:[a.jsx("label",{className:"auth-field__label",children:"用户名"}),a.jsx("input",{className:`auth-field__input${u.username?" is-error":""}`,type:"text",placeholder:"3-32 个字符",value:t,onChange:x=>{n(x.target.value),u.username&&d(w=>({...w,username:void 0}))},autoComplete:"username",autoFocus:!0}),u.username&&a.jsx("div",{className:"auth-field__hint",children:u.username})]}),a.jsxs("div",{className:"auth-field",children:[a.jsx("label",{className:"auth-field__label",children:"密码"}),a.jsx("input",{className:`auth-field__input${u.password?" is-error":""}`,type:"password",placeholder:"至少 6 个字符",value:r,onChange:x=>{s(x.target.value),u.password&&d(w=>({...w,password:void 0}))},autoComplete:"new-password"}),u.password&&a.jsx("div",{className:"auth-field__hint",children:u.password})]}),a.jsxs("div",{className:"auth-field",children:[a.jsx("label",{className:"auth-field__label",children:"确认密码"}),a.jsx("input",{className:`auth-field__input${u.confirm?" is-error":""}`,type:"password",placeholder:"再次输入密码",value:i,onChange:x=>{o(x.target.value),u.confirm&&d(w=>({...w,confirm:void 0}))},autoComplete:"new-password"}),u.confirm&&a.jsx("div",{className:"auth-field__hint",children:u.confirm})]}),a.jsxs("button",{type:"submit",className:"primary auth-submit",disabled:f||!t||!r||!i,children:[f&&a.jsx("span",{className:"auth-spinner"}),f?"注册中...":"注册"]}),a.jsxs("div",{className:"auth-footer",children:["已有账号?",a.jsx("button",{type:"button",className:"auth-footer__link",onClick:e,children:"登录"})]})]})})}function qp({machineKey:e,ownerToken:t,machineName:n,title:r,persistent:s,onClose:i}){const[o,l]=b.useState(!1),[c,u]=b.useState(!1),[d,f]=b.useState(!1),h=!!t,p=t??e??"",v=h?"Owner Token":"Machine Key",x=zz(),w=h?Fz(t,n||void 0):Vz(e??"");function g(y,m){navigator.clipboard.writeText(y).then(()=>{m(!0),setTimeout(()=>m(!1),2e3)})}return a.jsxs("div",{className:"daemon-connect-card",children:[a.jsxs("div",{className:"daemon-connect-card__header",children:[a.jsx(V,{name:"check",size:16,color:"var(--green)"}),a.jsx("span",{className:"daemon-connect-card__title",children:r??(h?"添加执行引擎":`机器「${n??""}」创建成功`)})]}),a.jsxs("div",{className:"daemon-connect-card__warn",children:[a.jsx(V,{name:"warn",size:14}),h?"该 owner-token 是账号级长期凭证,请妥善保管勿外泄(可在账号中心轮换)":s?"该命令含接入密钥,请妥善保管勿外泄":"密钥仅此一次展示,请立即复制保管"]}),a.jsxs("div",{className:"daemon-connect-card__section",children:[a.jsx("div",{className:"daemon-connect-card__label",children:v}),a.jsxs("div",{className:"daemon-connect-card__copyable",children:[a.jsx("code",{className:"daemon-connect-card__code",children:p}),a.jsxs("button",{type:"button",className:"daemon-connect-card__copy-btn",onClick:()=>g(p,l),title:"复制凭证",children:[o?a.jsx(V,{name:"check",size:12}):a.jsx(V,{name:"link",size:12}),o?"已复制":"复制"]})]})]}),a.jsxs("div",{className:"daemon-connect-card__section",children:[a.jsx("div",{className:"daemon-connect-card__label",children:"首次安装(一次性)"}),a.jsxs("div",{className:"daemon-connect-card__copyable daemon-connect-card__copyable--cmd",children:[a.jsx("pre",{className:"daemon-connect-card__pre",children:x}),a.jsxs("button",{type:"button",className:"daemon-connect-card__copy-btn",onClick:()=>g(x,f),title:"复制安装命令",children:[d?a.jsx(V,{name:"check",size:12}):a.jsx(V,{name:"link",size:12}),d?"已复制":"复制"]})]}),a.jsx("div",{className:"daemon-connect-card__hint",children:"仅首次安装或升级 CLI 时执行一次,之后无需重复。"})]}),a.jsxs("div",{className:"daemon-connect-card__section",children:[a.jsx("div",{className:"daemon-connect-card__label",children:"Daemon 接入命令(后台运行)"}),a.jsxs("div",{className:"daemon-connect-card__copyable daemon-connect-card__copyable--cmd",children:[a.jsx("pre",{className:"daemon-connect-card__pre",children:w}),a.jsxs("button",{type:"button",className:"daemon-connect-card__copy-btn",onClick:()=>g(w,u),title:"复制命令",children:[c?a.jsx(V,{name:"check",size:12}):a.jsx(V,{name:"link",size:12}),c?"已复制":"复制"]})]}),a.jsx("div",{className:"daemon-connect-card__hint",children:h?a.jsxs(a.Fragment,{children:["将 ",a.jsx("code",{children:"<此机器名>"})," 改为该机器的稳定名称(相同名字复用同一台,不同名字新增一台), 在目标机器上执行即可:保存凭证 → ",a.jsx("strong",{children:"后台启动 daemon"}),", 终端随后打印 status / logs / stop 等常用命令指引。工作区默认为"," ",a.jsx("code",{children:"~/.aitable-workflow/workspaces/<机器名>"}),",如需自定义可加"," ",a.jsx("code",{children:"--workspace-root <目录>"}),"。",a.jsx("br",{}),"多网关 / 多台机器请为每台使用",a.jsxs("strong",{children:["不同的 ",a.jsx("code",{children:"--name"})]}),"(相同 name 连不同 gateway 会覆盖本机凭证)。"]}):a.jsxs(a.Fragment,{children:["在目标机器上执行即可:保存凭证 → ",a.jsx("strong",{children:"后台启动 daemon"}),", 终端随后打印 status / logs / stop 等常用命令指引。工作区默认为"," ",a.jsx("code",{children:"~/.aitable-workflow/workspaces/<机器名>"}),",如需自定义可加"," ",a.jsx("code",{children:"--workspace-root <目录>"}),"。",a.jsx("br",{}),"多网关 / 多台机器请为每台使用",a.jsxs("strong",{children:["不同的 ",a.jsx("code",{children:"--name"})]}),"(相同 name 连不同 gateway 会覆盖本机凭证)。"]})})]}),a.jsx("div",{className:"daemon-connect-card__actions",children:a.jsx("button",{type:"button",className:"daemon-connect-card__close",onClick:i,children:"我已复制,关闭"})})]})}function i7(e){const t=Date.now(),n=new Date(e).getTime(),r=t-n;if(Number.isNaN(r))return e;const s=Math.floor(r/1e3);if(s<60)return"刚刚";const i=Math.floor(s/60);if(i<60)return`${i}分钟前`;const o=Math.floor(i/60);if(o<24)return`${o}小时前`;const l=Math.floor(o/24);if(l<30)return`${l}天前`;const c=Math.floor(l/30);return c<12?`${c}个月前`:`${Math.floor(c/12)}年前`}function o7(e){return e.length<=12?e:e.slice(0,6)+"..."+e.slice(-4)}const a7={claudecode:"Claude",codex:"Codex",qoder:"Qoder",codebuddy:"Codebuddy",opencode:"OpenCode",qwen:"Qwen",deepseek:"DeepSeek",trae:"Trae",qwenwork:"千问办公"};function l7({machine:e,onRevoke:t,onUpdated:n}){const[r,s]=b.useState(!1),[i,o]=b.useState(!1),[l,c]=b.useState(""),[u,d]=b.useState(!1),[f,h]=b.useState(null),[p,v]=b.useState(null);function x(){navigator.clipboard.writeText(e.machineId).then(()=>{s(!0),setTimeout(()=>s(!1),1500)})}async function w(){d(!0);try{const S=await Vk();h(S)}catch(S){window.alert("获取接入指令失败:"+(S instanceof Error?S.message:String(S)))}finally{d(!1)}}async function g(){if(window.confirm(`确定要为「${e.displayName||e.name}」重新生成密钥吗?旧密钥将立即失效,需用新密钥重新接入。`)){d(!0);try{const P=await Oz(e.machineId);v(P)}catch(P){window.alert("重新生成失败:"+(P instanceof Error?P.message:String(P)))}finally{d(!1)}}}function y(){window.confirm(`确定要撤销执行引擎「${e.displayName||e.name}」吗?撤销后该机器将无法连接。`)&&t(e.machineId)}function m(){c(e.displayName||e.name),o(!0)}async function _(){const S=l.trim();if(S){try{await Rz(e.machineId,{displayName:S}),n==null||n(e.machineId,{displayName:S})}catch(P){window.alert("修改失败:"+(P instanceof Error?P.message:String(P)))}o(!1)}}const j=e.displayName||e.name,N=e.status==="online",k=e.runtimes??[];return a.jsxs("div",{className:"machine-card",children:[a.jsxs("div",{className:"machine-card__header",children:[a.jsx("span",{className:`machine-status ${N?"machine-status--online":"machine-status--offline"}`}),i?a.jsxs("span",{className:"machine-card__edit-row",children:[a.jsx("input",{className:"machine-card__edit-input",type:"text",value:l,onChange:S=>c(S.target.value),onKeyDown:S=>{S.key==="Enter"&&_(),S.key==="Escape"&&o(!1)},autoFocus:!0}),a.jsx("button",{type:"button",className:"machine-card__edit-save",onClick:()=>void _(),title:"保存",children:a.jsx(V,{name:"check",size:12})}),a.jsx("button",{type:"button",className:"machine-card__edit-cancel",onClick:()=>o(!1),title:"取消",children:a.jsx(V,{name:"close",size:12})})]}):a.jsxs(a.Fragment,{children:[a.jsx("span",{className:"machine-card__name",onDoubleClick:m,title:"双击编辑名称",children:j}),e.displayName&&e.name!==e.displayName&&a.jsx("span",{className:"machine-card__slug",children:e.name})]})]}),e.description&&a.jsx("div",{className:"machine-card__desc",children:e.description}),k.length>0?a.jsxs("div",{className:`machine-card__runtimes${N?"":" machine-card__runtimes--offline"}`,children:[k.map(S=>a.jsx("span",{className:"machine-card__runtime-tag",children:a7[S]??S},S)),e.hasDws&&a.jsx("span",{className:"machine-card__runtime-tag machine-card__runtime-tag--dws",children:"dws"})]}):a.jsx("div",{className:"machine-card__runtimes machine-card__runtimes--offline",children:a.jsx("span",{className:"machine-card__runtime-hint",children:"未探测到引擎"})}),a.jsxs("div",{className:"machine-card__meta",children:[a.jsxs("span",{className:"machine-card__id",title:e.machineId,children:["ID: ",o7(e.machineId),a.jsx("button",{type:"button",className:"machine-card__copy",onClick:x,title:"复制 Machine ID",children:r?a.jsx(V,{name:"check",size:12}):a.jsx(V,{name:"link",size:12})})]}),a.jsx("span",{className:"machine-card__seen",children:N?"在线":e.lastSeen?`最后在线 ${i7(e.lastSeen)}`:"从未连接"})]}),a.jsxs("div",{className:"machine-card__actions",children:[a.jsxs("button",{type:"button",className:"machine-card__action-btn",onClick:m,title:"编辑名称",children:[a.jsx(V,{name:"file",size:12})," 编辑"]}),a.jsxs("button",{type:"button",className:"machine-card__action-btn",onClick:()=>void w(),disabled:u,title:"查看该机器的接入指令(Key + 启动命令)",children:[a.jsx(V,{name:"link",size:12})," 查看指令"]}),a.jsxs("button",{type:"button",className:"machine-card__action-btn",onClick:()=>void g(),disabled:u,title:"重新生成密钥(旧密钥失效)",children:[a.jsx(V,{name:"refresh",size:12})," 重生成密钥"]}),a.jsx("button",{type:"button",className:"machine-card__revoke",onClick:y,children:"撤销"})]}),f&&a.jsx(qp,{ownerToken:f,machineName:e.name,title:`「${j}」接入指令`,onClose:()=>h(null)}),p&&a.jsx(qp,{machineKey:p,machineName:j,title:`「${j}」新密钥已生成`,onClose:()=>v(null)})]})}function eC(){const[e,t]=b.useState([]),[n,r]=b.useState(!0),[s,i]=b.useState(""),[o,l]=b.useState(!1),[c,u]=b.useState(null);async function d(){r(!0),i("");try{const w=await qg();t(w)}catch(w){i(w instanceof Error?w.message:String(w))}finally{r(!1)}}b.useEffect(()=>{d()},[]);async function f(){l(!0);try{const w=await Vk();u(w)}catch(w){window.alert("获取接入指令失败:"+(w instanceof Error?w.message:String(w)))}finally{l(!1)}}async function h(w){try{await Iz(w),t(g=>g.filter(y=>y.machineId!==w))}catch(g){window.alert("撤销失败:"+(g instanceof Error?g.message:String(g)))}}function p(w,g){t(y=>y.map(m=>m.machineId===w?{...m,...g}:m))}if(n)return a.jsx("div",{className:"machine-list__loading",children:"加载中..."});if(s)return a.jsxs("div",{className:"machine-list__error",children:[a.jsx("span",{children:s}),a.jsx("button",{type:"button",className:"machine-list__retry",onClick:()=>void d(),children:"重试"})]});const v=e.filter(w=>w.status==="online"||w.lastSeen),x=v.filter(w=>w.status==="online").length;return a.jsxs("div",{className:"machine-list",children:[a.jsxs("div",{className:"machine-list__header",children:[a.jsxs("span",{className:"machine-list__count",children:["已接入 ",v.length," 台 · 在线 ",x," 台"]}),a.jsxs("div",{className:"machine-list__header-actions",children:[a.jsxs("button",{type:"button",className:"machine-list__refresh",onClick:()=>void d(),title:"刷新(daemon 接入后点此更新列表)",children:[a.jsx(V,{name:"refresh",size:14}),"刷新"]}),a.jsxs("button",{type:"button",className:"primary machine-list__add",onClick:()=>void f(),disabled:o,children:[a.jsx(V,{name:"plus",size:14}),o?"获取中...":"添加引擎"]})]})]}),c&&a.jsx(qp,{ownerToken:c,title:"添加执行引擎",onClose:()=>u(null)}),v.length===0&&!c?a.jsx("div",{className:"machine-list__empty",children:"暂无已接入的执行引擎。点击「添加引擎」获取自注册接入指令,在目标机器上执行 daemon 启动命令(填入机器名);接入成功后点「刷新」即可看到。"}):a.jsx("div",{className:"machine-list__grid",children:v.map(w=>a.jsx(l7,{machine:w,onRevoke:h,onUpdated:p},w.machineId))})]})}const c7={admin:"管理员",user:"普通用户"};function u7(e){try{return new Date(e).toLocaleDateString("zh-CN",{year:"numeric",month:"long",day:"numeric"})}catch{return e}}function d7(){var c,u;const e=Og(),[t,n]=b.useState(null),[r,s]=b.useState(!0);b.useEffect(()=>{(async()=>{try{const d=await Mz();n(d)}catch{}finally{s(!1)}})()},[]);const i=(t==null?void 0:t.username)??((c=e.user)==null?void 0:c.username)??"---",o=(t==null?void 0:t.role)??((u=e.user)==null?void 0:u.role)??"user",l=(t==null?void 0:t.createdAt)??null;return a.jsx("div",{className:"split split--chatonly",children:a.jsxs("div",{className:"split__work",children:[a.jsx("div",{className:"work-head",children:a.jsxs("div",{className:"work-head__left",children:[a.jsxs("button",{type:"button",className:"account-back-btn",onClick:()=>z.setRoute("home"),title:"返回首页",children:[a.jsx(V,{name:"chevron-left",size:16}),"返回"]}),a.jsxs("div",{children:[a.jsx("div",{className:"work-head__title",children:"用户中心"}),a.jsx("div",{className:"work-head__sub",children:"管理账号信息与执行引擎"})]})]})}),a.jsx("div",{className:"work-body",children:a.jsxs("div",{className:"account-page",children:[a.jsxs("section",{className:"account-section",children:[a.jsx("h3",{className:"account-section__title",children:"账号信息"}),a.jsx("div",{className:"account-card",children:r?a.jsx("div",{className:"account-card__loading",children:"加载中..."}):a.jsxs(a.Fragment,{children:[a.jsxs("div",{className:"account-card__row",children:[a.jsx("span",{className:"account-card__avatar",children:a.jsx(V,{name:"user",size:24})}),a.jsxs("div",{className:"account-card__info",children:[a.jsx("span",{className:"account-card__username",children:i}),a.jsx("span",{className:`account-card__role account-card__role--${o}`,children:c7[o]??o})]})]}),l&&a.jsxs("div",{className:"account-card__detail",children:[a.jsx("span",{className:"account-card__label",children:"注册时间"}),a.jsx("span",{className:"account-card__value",children:u7(l)})]})]})})]}),a.jsxs("section",{className:"account-section",children:[a.jsx("h3",{className:"account-section__title",children:"执行引擎管理"}),a.jsx(eC,{})]})]})})]})})}function f7(){return a.jsx("div",{className:"split split--chatonly",children:a.jsxs("div",{className:"split__work",children:[a.jsx("div",{className:"work-head",children:a.jsxs("div",{className:"work-head__left",children:[a.jsxs("button",{type:"button",className:"account-back-btn",onClick:()=>z.setRoute("home"),title:"返回首页",children:[a.jsx(V,{name:"chevron-left",size:16}),"返回"]}),a.jsxs("div",{children:[a.jsx("div",{className:"work-head__title",children:"执行引擎"}),a.jsx("div",{className:"work-head__sub",children:"生成接入密钥、查看启动命令,管理已接入的引擎"})]})]})}),a.jsx("div",{className:"work-body",children:a.jsx("div",{className:"account-page",children:a.jsx("section",{className:"account-section",children:a.jsx(eC,{})})})})]})})}const h7={init:{title:"一次性配置",sub:"Agent · 角色 · SOP"},design:{title:"工作流设计",sub:"需求对齐后可视化编排流程方案"},setup:{title:"AI 表格搭建",sub:"自动创建字段与视图"},adjust:{title:"参数调整",sub:"确认并补全项目配置"},test:{title:"试运行",sub:"用一条真实记录验证整条流程"},run:{title:"运行监控",sub:"任务流转 · 步骤日志 · 人工审批"}};function p7({stage:e}){const t=h7[e];return a.jsx("div",{className:"split split--chatonly",children:a.jsxs("div",{className:"split__work",children:[a.jsx("div",{className:"work-head",children:a.jsxs("div",{children:[a.jsx("div",{className:"work-head__title",children:t.title}),a.jsx("div",{className:"work-head__sub",children:t.sub})]})}),a.jsx("div",{className:"work-body",children:a.jsxs("div",{className:"empty-hint",children:["当前没有可用的项目。",a.jsx("div",{style:{marginTop:16},children:a.jsx("button",{type:"button",className:"primary",onClick:()=>z.setRoute("home"),children:"回到首页"})})]})})]})})}const m7=[{icon:"robot",label:"配置",stage:"init",desc:"发现并接入 Agent、角色、SOP"},{icon:"flow",label:"设计",stage:"design",desc:"问答对齐后可视化编排工作流"},{icon:"table",label:"搭建",stage:"setup",desc:"自动创建字段与视图"},{icon:"sparkle",label:"试运行",stage:"test",desc:"用一条真实记录验证流程"}];function g7(){const[e,t]=b.useState(!1),[n,r]=b.useState(!1);async function s(i){if(!ue){z.beginNewProject(`mock-${Date.now()}`,i);return}const o=await $g();z.beginNewProject(o.id,i),z.setProjects(ka(z.projects,o))}return a.jsxs("div",{className:"home-hero",children:[a.jsx(Ye.span,{className:"home-hero__mark",variants:dz,initial:"hidden",animate:"visible",children:a.jsx(V,{name:"sparkle",size:28,color:"#fff"})}),a.jsx("h1",{className:"home-hero__title",children:"用对话搭建你的 AI 表格工作流"}),a.jsxs("p",{className:"home-hero__desc",children:["从配置、设计、搭建到试运行,全程对话式引导。",a.jsx("br",{}),"以 HR、法务等专业岗位协作为例,四步落地一条可运行的业务流程。"]}),a.jsxs("div",{className:"home-hero__ctas",children:[a.jsxs("button",{type:"button",className:"primary home-hero__cta",onClick:()=>r(!0),children:[a.jsx(V,{name:"play",size:16,color:"#fff"}),"新建项目"]}),a.jsxs("button",{type:"button",className:"home-hero__cta home-hero__cta--ghost",onClick:()=>t(!0),children:[a.jsx(V,{name:"plus",size:16}),"导入已有项目"]})]}),a.jsx(Ye.div,{className:"home-beats",variants:Ik,initial:"hidden",animate:"visible",children:m7.map((i,o)=>a.jsxs(Ye.button,{type:"button",className:"home-beat",variants:St,onClick:()=>z.setRoute(i.stage),children:[a.jsx("span",{className:"home-beat__idx",children:o+1}),a.jsx("span",{className:"home-beat__icon",children:a.jsx(V,{name:i.icon,size:18})}),a.jsx("span",{className:"home-beat__label",children:i.label}),a.jsx("span",{className:"home-beat__desc",children:i.desc})]},i.stage))}),e&&a.jsx(RW,{onClose:()=>t(!1)}),n&&a.jsx(dk,{onConfirm:i=>{s(i),r(!1)},onCancel:()=>r(!1)})]})}const v7=ut(function(){const t=Og(),[n,r]=b.useState("login"),[s]=b.useState(()=>ID());return b.useEffect(()=>{s&&z.setRoute("adjust")},[s]),it&&!t.token&&!s?n==="register"?a.jsx(s7,{onSwitchToLogin:()=>r("login")}):a.jsx(r7,{onSwitchToRegister:()=>r("register")}):a.jsx(y7,{})}),y7=ut(function(){b.useEffect(()=>{if(!ue)return;const n=z.persistedProjectId;!n&&z.route!=="home"||ba(n,{fallbackRoute:z.route})},[]);const t=z.view;return a.jsx(az,{children:t.kind==="loading"?a.jsx(cz,{stage:z.route}):t.kind==="load_error"?a.jsx(uz,{message:t.message,onRetry:()=>void ba(t.projectId,{fallbackRoute:z.route})}):t.kind==="home"?a.jsx(g7,{}):t.kind==="no_project"?a.jsx(p7,{stage:t.intended}):t.kind==="init"?a.jsx(uW,{}):t.kind==="design"?a.jsx(ZU,{},z.projectId??"__no_project__"):t.kind==="setup"?a.jsx(pW,{}):t.kind==="adjust"?a.jsx(n7,{}):t.kind==="test"?a.jsx(vW,{}):t.kind==="run"?a.jsx(CW,{}):t.kind==="account"?a.jsx(d7,{}):a.jsx(f7,{})})});$z();kb(document.getElementById("root")).render(a.jsx(b.StrictMode,{children:a.jsx(v7,{})}));
|
|
321
|
+
`);async function s(){try{await navigator.clipboard.writeText(r),n(!0),setTimeout(()=>n(!1),2e3)}catch{}}return a.jsxs("section",{className:"process-errors",children:[a.jsxs("div",{className:"process-errors__head",children:[a.jsx(V,{name:"warn",size:14,color:"var(--red)"}),a.jsx("span",{children:"过程错误"}),a.jsx("button",{type:"button",className:"process-errors__copy",onClick:()=>void s(),children:t?"已复制":"复制"})]}),e.map((i,o)=>a.jsxs("div",{className:`process-errors__item process-errors__item--${i.status}`,children:[a.jsx("span",{className:"process-errors__icon",children:a.jsx(V,{name:"warn",size:13,color:i.status==="error"?"var(--red)":"var(--amber)"})}),a.jsxs("div",{className:"process-errors__body",children:[i.key&&a.jsx("code",{className:"process-errors__key",children:i.key}),a.jsx("span",{className:"process-errors__msg",children:i.message})]})]},i.key??`pe-${o}`))]})}const qW=new Set(["workflow","agent.engine"]);function YW({config:e,engines:t,projectEnvRefs:n,onSave:r,onBatchSave:s}){const i=e.modules.find(m=>m.id==="project"),o=e.modules.find(m=>m.id==="coding_agent"),l=e.modules.find(m=>m.id==="env"),c=o==null?void 0:o.items.find(m=>m.key==="coding_agent.engine"),u=o==null?void 0:o.items.find(m=>m.key==="coding_agent.config.enabled"),d=c==null?void 0:c.value,[f,h]=b.useState(!1),p=b.useRef(!1),v=b.useCallback(async m=>{if(!(!(c!=null&&c.writeTarget)||!m)){h(!0);try{const _=[{writeTarget:c.writeTarget,value:m}];(u==null?void 0:u.status)==="error"&&u.writeTarget&&_.push({writeTarget:u.writeTarget,value:"true"}),await s(_)}finally{h(!1)}}},[c,u,s]);b.useEffect(()=>{p.current||(c==null?void 0:c.status)==="error"&&d&&t.available.some(m=>m.engine===d)&&c.writeTarget&&(p.current=!0,v(d))},[c,d,t.available,v]);const x=((i==null?void 0:i.items)??[]).filter(m=>!qW.has(m.key)&&(m.status!=="ok"||m.writeTarget)),w=((l==null?void 0:l.items)??[]).filter(m=>m.writeTarget&&(!n||n.includes(m.key))),g=((o==null?void 0:o.items)??[]).filter(m=>m.key!=="coding_agent.engine"&&m.writeTarget&&m.status==="error"),y=[...(i==null?void 0:i.items)??[],...(o==null?void 0:o.items)??[],...e.modules.filter(m=>m.id==="profile").flatMap(m=>m.items),...(l==null?void 0:l.items)??[]].filter(m=>!m.writeTarget&&(m.status==="error"||m.status==="warn"));return a.jsxs("div",{className:"adjust__tab-inner",children:[a.jsxs("section",{className:"adjust__section",children:[a.jsxs("h3",{className:"adjust__section-title",children:[a.jsx(V,{name:"robot",size:15}),"编码引擎"]}),a.jsxs("div",{className:"adjust__engine-row",children:[a.jsxs("select",{className:"qf-select adjust__engine-select",value:d??"",onChange:m=>void v(m.target.value),disabled:f,children:[a.jsx("option",{value:"",children:"请选择…"}),t.available.map(m=>a.jsxs("option",{value:m.engine,children:[m.engine," (",m.cmd,m.version?` v${m.version}`:"",")"]},m.engine)),!t.available.some(m=>m.engine==="llm_only")&&a.jsx("option",{value:"llm_only",children:"llm_only (无需本地 CLI)"})]}),(c==null?void 0:c.status)==="error"&&a.jsxs("span",{className:"adjust__engine-warn",children:[a.jsx(V,{name:"warn",size:13,color:"var(--red)"}),c.message]}),(c==null?void 0:c.status)==="ok"&&a.jsx("span",{className:"adjust__engine-ok",children:a.jsx(V,{name:"check",size:13,color:"var(--green)"})}),f&&a.jsx("span",{className:"adjust__engine-saving",children:"保存中…"})]}),t.recommended&&d!==t.recommended&&a.jsxs("p",{className:"adjust__hint-text",children:["推荐:",t.recommended]})]}),g.length>0&&a.jsxs("section",{className:"adjust__section",children:[a.jsxs("h3",{className:"adjust__section-title",children:[a.jsx(V,{name:"robot",size:15}),"引擎配置"]}),g.map(m=>a.jsx(Gn,{item:m,onSave:r},m.key))]}),(x.length>0||w.length>0)&&a.jsxs("section",{className:"adjust__section",children:[a.jsxs("h3",{className:"adjust__section-title",children:[a.jsx(V,{name:"folder",size:15}),"项目参数"]}),x.map(m=>a.jsx(Gn,{item:m,onSave:r},m.key)),w.map(m=>a.jsx(Gn,{item:m,onSave:r},m.key))]}),x.length===0&&w.length===0&&g.length===0&&(c==null?void 0:c.status)==="ok"&&a.jsxs("div",{className:"adjust__empty",children:[a.jsx(V,{name:"check",size:20,color:"var(--green)"}),a.jsx("span",{children:"项目参数已完整"})]}),a.jsx(Nu,{items:y})]})}const Gp=new Set(["roles.enabled","roles_dir","roles"]);function XW(e){const t=new Map;for(const n of e){if(Gp.has(n.key))continue;const r=n.key.match(/^role\.([^.]+)/);if(!r)continue;const s=r[1];t.has(s)||t.set(s,[]),t.get(s).push(n)}return Array.from(t.entries()).map(([n,r])=>({roleId:n,items:r}))}function QW({config:e,onSave:t,onKbIngest:n,onKbUpload:r}){const s=e.modules.find(u=>u.id==="roles");if(!s)return a.jsx("div",{className:"adjust__empty",children:"角色系统未启用"});const o=s.items.filter(u=>Gp.has(u.key)).find(u=>u.status==="error");if(o){const u=((s==null?void 0:s.items)??[]).filter(d=>!d.writeTarget&&d.status!=="ok"&&d!==o);return a.jsxs("div",{className:"adjust__tab-inner",children:[a.jsxs("div",{className:"adjust__error",children:[a.jsx(V,{name:"warn",size:16,color:"var(--red)"}),a.jsx("span",{children:o.message})]}),a.jsx(Nu,{items:u})]})}const l=XW(s.items);if(l.length===0)return a.jsx("div",{className:"adjust__tab-inner",children:a.jsxs("div",{className:"adjust__empty",children:[a.jsx(V,{name:"user",size:20,color:"var(--text-muted)"}),a.jsx("span",{children:"暂无角色配置"})]})});const c=((s==null?void 0:s.items)??[]).filter(u=>Gp.has(u.key)&&!u.writeTarget&&u.status!=="ok");return a.jsxs("div",{className:"adjust__tab-inner",children:[l.map(u=>a.jsx(ZW,{role:u,onSave:t,onKbIngest:n,onKbUpload:r},u.roleId)),a.jsx(Nu,{items:c})]})}function ZW({role:e,onSave:t,onKbIngest:n,onKbUpload:r}){const s=e.items.find(l=>l.key===`role.${e.roleId}`),i=(s==null?void 0:s.status)==="ok",o=e.items.filter(l=>l.key!==`role.${e.roleId}`);return a.jsxs("div",{className:`role-card${i?" is-ok":""}`,children:[a.jsxs("div",{className:"role-card__head",children:[a.jsx(V,{name:"user",size:15}),a.jsx("span",{className:"role-card__name",children:e.roleId}),a.jsx("span",{className:`role-card__status${i?" is-ok":""}`,children:i?a.jsxs(a.Fragment,{children:[a.jsx(V,{name:"check",size:12})," 通过"]}):"需配置"})]}),o.length>0&&a.jsx("div",{className:"role-card__body",children:o.map(l=>a.jsx(Gn,{item:l,onSave:t,onKbIngest:n,onKbUpload:r},l.key))})]})}function bc(e){const t=e.slice(e.lastIndexOf(".")+1);return t==="base_id"||t==="baseId"}function JW({config:e,workflowTopology:t,onSave:n}){const r=e.modules.find(u=>u.id==="workflow"),s=e.modules.find(u=>u.id==="env"),[i,o]=b.useState(null),l=(r==null?void 0:r.workflows)??[],c=b.useMemo(()=>{for(const u of l)for(const d of u.items)if(bc(d.key)&&typeof d.value=="string"&&d.value.trim())return d.value.trim()},[l]);return l.length===0?a.jsx("div",{className:"adjust__tab-inner",children:a.jsxs("div",{className:"adjust__empty",children:[a.jsx(V,{name:"flow",size:20,color:"var(--text-muted)"}),a.jsx("span",{children:"暂无工作流"})]})}):a.jsx("div",{className:"adjust__tab-inner",children:l.map(u=>a.jsx(e7,{workflow:u,topology:t[u.id],envItems:(s==null?void 0:s.items)??[],suggestedBaseId:c,isOpen:i===u.id,onToggle:()=>o(d=>d===u.id?null:u.id),onSave:n},u.id))})}function e7({workflow:e,topology:t,envItems:n,suggestedBaseId:r,isOpen:s,onToggle:i,onSave:o}){const[l,c]=b.useState(null),u=e.items.filter(k=>k.key==="tracker.base_id"||k.key==="tracker.table_id"),d=e.items.filter(k=>k.key.startsWith("event_source.")&&k.writeTarget),f=b.useMemo(()=>{const k=new Set((t==null?void 0:t.envRefs)??[]);for(const S of Object.values((t==null?void 0:t.stepEnvRefs)??{}))for(const P of S){const $=n.find(D=>D.key===P);$&&$.status==="error"&&k.add(P)}return[...k].map(S=>n.find(P=>P.key===S)).filter(S=>!!S&&!!S.writeTarget)},[t,n]),h=b.useMemo(()=>{const k=new Set((t==null?void 0:t.envRefs)??[]);for(const S of Object.values((t==null?void 0:t.stepEnvRefs)??{}))for(const P of S)k.add(P);return n.filter(S=>k.has(S.key)&&S.status==="error")},[t,n]),p=e.ok&&h.length===0,v=e.items.filter(k=>k.writeTarget&&k.status==="error").length+h.filter(k=>k.writeTarget).length,x=e.items.filter(k=>!k.writeTarget&&k.status==="error").length+h.filter(k=>!k.writeTarget).length,w=b.useMemo(()=>{const k=new Set((t==null?void 0:t.envRefs)??[]);for(const S of Object.values((t==null?void 0:t.stepEnvRefs)??{}))for(const P of S)k.add(P);return[...e.items.filter(S=>!S.writeTarget&&(S.status==="error"||S.status==="warn")),...n.filter(S=>k.has(S.key)&&!S.writeTarget&&(S.status==="error"||S.status==="warn"))]},[t,n,e.items]),g=b.useMemo(()=>t?t.steps.map(k=>{const S=e.items.filter(P=>P.key.startsWith(`step.${k.id}.config.`)&&P.status==="error");return{id:k.id,name:k.name,recipe:k.recipe??"",engine:k.engine??"llm_only",auto:k.auto,inputs:[],outputs:[],configStatus:S.length>0?"missing":"ok",missingConfigKeys:S.map(P=>P.key)}}):[],[t,e.items]),y=b.useMemo(()=>t?t.edges:[],[t]),m=b.useMemo(()=>l?e.items.filter(k=>k.key.startsWith(`step.${l}.config.`)&&k.writeTarget):[],[l,e.items]),_=b.useMemo(()=>!l||!t?[]:(t.stepEnvRefs[l]??[]).map(S=>n.find(P=>P.key===S)).filter(S=>!!S&&S.status!=="ok"),[l,t,n]),j=t==null?void 0:t.steps.find(k=>k.id===l),N=l&&(m.length>0||_.length>0);return a.jsxs("div",{className:`wf-card${p?" is-done":""}`,children:[a.jsxs("button",{type:"button",className:"wf-card__head",onClick:i,children:[a.jsx("span",{className:"wf-card__icon",children:a.jsx(V,{name:"flow",size:15})}),a.jsx("span",{className:"wf-card__name",children:e.name}),v>0&&a.jsxs("span",{className:"wf-card__badge",children:[v," 项需配置"]}),x>0&&a.jsxs("span",{className:"wf-card__badge wf-card__badge--process",children:[x," 项过程错误"]}),a.jsx("span",{className:`wf-card__status${p?" is-ok":""}`,children:p?a.jsxs(a.Fragment,{children:[a.jsx(V,{name:"check",size:12})," 通过"]}):v>0?"需配置":"有异常"}),a.jsx("span",{className:`wf-card__chevron${s?" is-open":""}`,children:a.jsx(V,{name:"chevron-right",size:12})})]}),s&&a.jsxs("div",{className:"wf-card__body",children:[u.length>0&&a.jsx("div",{className:"wf-card__tracker",children:u.map(k=>a.jsx(Gn,{item:k,onSave:o,suggestedDefault:bc(k.key)?r:void 0},k.key))}),t&&g.length>0&&a.jsxs("div",{className:`wf-card__canvas-row${N?" has-panel":""}`,children:[a.jsx("div",{className:"wf-card__canvas",children:a.jsx(IE,{steps:g,edges:y,selectedId:l,onSelect:c})}),N&&j&&a.jsxs("div",{className:"wf-card__panel",children:[a.jsxs("div",{className:"wf-card__panel-head",children:[a.jsx(V,{name:"bolt",size:14}),a.jsxs("span",{children:["步骤配置 · ",j.name]}),a.jsx("button",{type:"button",className:"wf-card__panel-close",onClick:()=>c(null),children:a.jsx(V,{name:"close",size:14})})]}),a.jsxs("div",{className:"wf-card__panel-body",children:[m.map(k=>a.jsx(Gn,{item:k,onSave:o,suggestedDefault:bc(k.key)?r:void 0},k.key)),_.length>0&&a.jsxs(a.Fragment,{children:[a.jsx("div",{className:"wf-card__panel-divider",children:"参数与凭据"}),_.map(k=>a.jsx(Gn,{item:k,onSave:o},k.key))]})]})]}),l&&!N&&j&&a.jsxs("div",{className:"wf-card__panel",children:[a.jsxs("div",{className:"wf-card__panel-head",children:[a.jsx(V,{name:"bolt",size:14}),a.jsxs("span",{children:["步骤配置 · ",j.name]}),a.jsx("button",{type:"button",className:"wf-card__panel-close",onClick:()=>c(null),children:a.jsx(V,{name:"close",size:14})})]}),a.jsx("div",{className:"wf-card__panel-body",children:a.jsxs("div",{className:"adjust__empty",style:{padding:"24px 16px"},children:[a.jsx(V,{name:"check",size:16,color:"var(--green)"}),a.jsx("span",{children:"此步骤配置完整"})]})})]})]}),d.length>0&&a.jsxs("div",{className:"wf-card__events",children:[a.jsxs("div",{className:"wf-card__events-title",children:[a.jsx(V,{name:"bolt",size:13,color:"var(--text-muted)"}),"事件源配置"]}),d.map(k=>a.jsx(Gn,{item:k,onSave:o,suggestedDefault:bc(k.key)?r:void 0},k.key))]}),f.length>0&&a.jsxs("div",{className:"wf-card__events",children:[a.jsxs("div",{className:"wf-card__events-title",children:[a.jsx(V,{name:"lock",size:13,color:"var(--text-muted)"}),"参数与凭据"]}),f.map(k=>a.jsx(Gn,{item:k,onSave:o},k.key))]}),a.jsx(Nu,{items:w})]})]})}const t7=[{id:"project",label:"项目配置",icon:"folder"},{id:"roles",label:"角色配置",icon:"user"},{id:"workflows",label:"工作流配置",icon:"flow"}];function n7(){const[e,t]=b.useState(null),[n,r]=b.useState(!0),[s,i]=b.useState(null),[o,l]=b.useState(!1),[c,u]=b.useState(!1),[d,f]=b.useState("project"),[h,p]=b.useState(!1),v=b.useRef(!1),x=b.useCallback(async()=>{var j,N,k;r(!0),i(null);try{const S=await LD();if(t(S),!S.config.ok){const P=((j=S.config.modules.find(I=>I.id==="project"))==null?void 0:j.ok)??!0,$=((N=S.config.modules.find(I=>I.id==="coding_agent"))==null?void 0:N.ok)??!0,D=((k=S.config.modules.find(I=>I.id==="roles"))==null?void 0:k.ok)??!0;f(!P||!$?"project":D?"workflows":"roles")}}catch(S){i(S instanceof Error?S.message:String(S))}finally{r(!1)}},[]);b.useEffect(()=>{x()},[x]),b.useEffect(()=>{if(e&&!c){const j=N=>{N.preventDefault()};return window.addEventListener("beforeunload",j),()=>window.removeEventListener("beforeunload",j)}},[e,c]);const w=b.useCallback(async()=>{if(!(v.current||c)){v.current=!0,l(!0);try{await RD(),u(!0)}catch(j){i(j instanceof Error?j.message:String(j))}finally{l(!1),v.current=!1}}},[c]),g=b.useCallback(async(j,N)=>{const k=await y_([{writeTarget:j,value:N}]);t(S=>S&&{...S,config:k.recheck})},[]),y=b.useCallback(async j=>{const N=await y_(j);t(k=>k&&{...k,config:N.recheck})},[]),m=b.useCallback(async(j,N)=>{try{const k=await $D(j,N);return t(S=>S&&{...S,config:k.recheck}),{ok:k.ok,message:k.message}}catch(k){const S=k instanceof Error?k.message:"知识库导入失败";return i(S),{ok:!1,message:S}}},[]),_=b.useCallback(async(j,N)=>{try{const k=await OD(j,N);return t(S=>S&&{...S,config:k.recheck}),{ok:k.ok,message:k.message}}catch(k){const S=k instanceof Error?k.message:"文件上传失败";return i(S),{ok:!1,message:S}}},[]);return c?a.jsx("div",{className:"adjust",children:a.jsxs("div",{className:"adjust__done",children:[a.jsx("span",{className:"adjust__done-icon",children:a.jsx(V,{name:"check",size:32,color:"var(--green)"})}),a.jsx("h2",{className:"adjust__done-title",children:"配置完成"}),a.jsx("p",{className:"adjust__done-text",children:"所有配置项已保存到本地文件,CLI 将继续 setup 流程。"}),a.jsx("p",{className:"adjust__done-hint",children:"可以关闭此页面。"})]})}):a.jsxs("div",{className:"adjust",children:[a.jsxs("div",{className:"adjust__head",children:[a.jsx("h1",{className:"adjust__title",children:"参数调整"}),a.jsx("p",{className:"adjust__sub",children:"配置项目参数、角色和工作流"})]}),n&&a.jsx("div",{className:"adjust__loading",children:"正在加载配置状态…"}),s&&a.jsxs("div",{className:"adjust__error",children:[a.jsx(V,{name:"warn",size:16,color:"var(--red)"}),a.jsx("span",{children:s}),a.jsx("button",{type:"button",className:"adjust__retry",onClick:()=>void x(),children:"重试"})]}),e&&a.jsxs(a.Fragment,{children:[a.jsxs("div",{className:"adjust__hint",children:[a.jsx(V,{name:"folder",size:14,color:"var(--text-muted)"}),a.jsx("code",{children:e.config.projectPath})]}),a.jsxs("div",{className:"adjust__tab-area",children:[a.jsx("div",{className:"adjust__tabs",children:t7.map(j=>{var D,I,O,E,A;const N=((D=e.config.modules.find(C=>C.id==="env"))==null?void 0:D.items)??[],k=new Set(e.projectEnvRefs??N.map(C=>C.key)),S=new Set;for(const C of Object.values(e.workflowTopology)){for(const M of C.envRefs??[])S.add(M);for(const M of Object.values(C.stepEnvRefs??{}))for(const T of M)S.add(T)}const P=C=>N.some(M=>M.status==="error"&&C.has(M.key)),$=j.id==="project"?(((I=e.config.modules.find(C=>C.id==="project"))==null?void 0:I.ok)??!0)&&(((O=e.config.modules.find(C=>C.id==="coding_agent"))==null?void 0:O.ok)??!0)&&!P(k):j.id==="roles"?((E=e.config.modules.find(C=>C.id==="roles"))==null?void 0:E.ok)??!0:(((A=e.config.modules.find(C=>C.id==="workflow"))==null?void 0:A.ok)??!0)&&!P(S);return a.jsxs("button",{type:"button",className:`adjust__tab${d===j.id?" is-active":""}${$?"":" has-error"}`,onClick:()=>f(j.id),children:[a.jsx(V,{name:j.icon,size:13}),j.label,!$&&a.jsx("span",{className:"adjust__tab-dot"})]},j.id)})}),a.jsxs("div",{className:"adjust__tab-content",children:[d==="project"&&a.jsx(YW,{config:e.config,engines:e.engines,projectEnvRefs:e.projectEnvRefs,onSave:g,onBatchSave:y}),d==="roles"&&a.jsx(QW,{config:e.config,onSave:g,onKbIngest:m,onKbUpload:_}),d==="workflows"&&a.jsx(JW,{config:e.config,workflowTopology:e.workflowTopology,onSave:g})]})]}),a.jsx(OW,{summary:e.config.summary,allPassed:e.config.ok,saving:o,onComplete:()=>p(!0)}),h&&a.jsx("div",{className:"modal-overlay",onClick:()=>p(!1),children:a.jsxs("div",{className:"modal-card",onClick:j=>j.stopPropagation(),children:[a.jsxs("div",{className:"modal-card__head",children:[a.jsx("span",{className:"modal-card__icon",style:{background:"var(--accent-tint)",color:"var(--accent)"},children:a.jsx(V,{name:"check",size:16})}),a.jsx("span",{className:"modal-card__title",children:"确认进入搭建"}),a.jsx("button",{type:"button",className:"modal-card__close",onClick:()=>p(!1),children:a.jsx(V,{name:"close",size:14})})]}),a.jsx("div",{className:"modal-card__body",children:a.jsx("p",{style:{margin:0,fontSize:14,color:"var(--text)"},children:"确认不再修改配置,进入下一步搭建流程?"})}),a.jsxs("div",{className:"modal-card__foot",children:[a.jsx("button",{type:"button",className:"modal-card__btn",onClick:()=>p(!1),children:"继续修改"}),a.jsx("button",{type:"button",className:"primary modal-card__btn",disabled:o,onClick:()=>{p(!1),w()},children:o?"完成中…":"确认,继续搭建"})]})]})})]})]})}function r7({onSwitchToRegister:e}){const[t,n]=b.useState(""),[r,s]=b.useState(""),[i,o]=b.useState(""),[l,c]=b.useState(!1);async function u(d){if(d.preventDefault(),!(!t||!r)){o(""),c(!0);try{await As.login(t,r)}catch(f){o(f instanceof Error?f.message:String(f))}finally{c(!1)}}}return a.jsx("div",{className:"auth-page",children:a.jsxs("form",{className:"auth-card",onSubmit:u,children:[a.jsxs("div",{className:"auth-card__brand",children:[a.jsx("span",{className:"auth-card__brand-mark",children:a.jsx(V,{name:"sparkle",size:18,color:"#fff"})}),a.jsx("span",{className:"auth-card__brand-name",children:"AITable Agent"})]}),a.jsx("h2",{className:"auth-card__title",children:"登录"}),i&&a.jsx("div",{className:"auth-error",children:i}),a.jsxs("div",{className:"auth-field",children:[a.jsx("label",{className:"auth-field__label",children:"用户名"}),a.jsx("input",{className:"auth-field__input",type:"text",placeholder:"请输入用户名",value:t,onChange:d=>n(d.target.value),autoComplete:"username",autoFocus:!0})]}),a.jsxs("div",{className:"auth-field",children:[a.jsx("label",{className:"auth-field__label",children:"密码"}),a.jsx("input",{className:"auth-field__input",type:"password",placeholder:"请输入密码",value:r,onChange:d=>s(d.target.value),autoComplete:"current-password"})]}),a.jsxs("button",{type:"submit",className:"primary auth-submit",disabled:l||!t||!r,children:[l&&a.jsx("span",{className:"auth-spinner"}),l?"登录中...":"登录"]}),a.jsxs("div",{className:"auth-footer",children:["没有账号?",a.jsx("button",{type:"button",className:"auth-footer__link",onClick:e,children:"注册"})]})]})})}function s7({onSwitchToLogin:e}){const[t,n]=b.useState(""),[r,s]=b.useState(""),[i,o]=b.useState(""),[l,c]=b.useState(""),[u,d]=b.useState({}),[f,h]=b.useState(!1);function p(){const x={};return(t.length<3||t.length>32)&&(x.username="用户名长度需在 3-32 个字符之间"),r.length<6&&(x.password="密码长度至少 6 个字符"),r!==i&&(x.confirm="两次输入的密码不一致"),d(x),Object.keys(x).length===0}async function v(x){if(x.preventDefault(),c(""),!!p()){h(!0);try{await As.register(t,r)}catch(w){c(w instanceof Error?w.message:String(w))}finally{h(!1)}}}return a.jsx("div",{className:"auth-page",children:a.jsxs("form",{className:"auth-card",onSubmit:v,children:[a.jsxs("div",{className:"auth-card__brand",children:[a.jsx("span",{className:"auth-card__brand-mark",children:a.jsx(V,{name:"sparkle",size:18,color:"#fff"})}),a.jsx("span",{className:"auth-card__brand-name",children:"AITable Agent"})]}),a.jsx("h2",{className:"auth-card__title",children:"注册"}),l&&a.jsx("div",{className:"auth-error",children:l}),a.jsxs("div",{className:"auth-field",children:[a.jsx("label",{className:"auth-field__label",children:"用户名"}),a.jsx("input",{className:`auth-field__input${u.username?" is-error":""}`,type:"text",placeholder:"3-32 个字符",value:t,onChange:x=>{n(x.target.value),u.username&&d(w=>({...w,username:void 0}))},autoComplete:"username",autoFocus:!0}),u.username&&a.jsx("div",{className:"auth-field__hint",children:u.username})]}),a.jsxs("div",{className:"auth-field",children:[a.jsx("label",{className:"auth-field__label",children:"密码"}),a.jsx("input",{className:`auth-field__input${u.password?" is-error":""}`,type:"password",placeholder:"至少 6 个字符",value:r,onChange:x=>{s(x.target.value),u.password&&d(w=>({...w,password:void 0}))},autoComplete:"new-password"}),u.password&&a.jsx("div",{className:"auth-field__hint",children:u.password})]}),a.jsxs("div",{className:"auth-field",children:[a.jsx("label",{className:"auth-field__label",children:"确认密码"}),a.jsx("input",{className:`auth-field__input${u.confirm?" is-error":""}`,type:"password",placeholder:"再次输入密码",value:i,onChange:x=>{o(x.target.value),u.confirm&&d(w=>({...w,confirm:void 0}))},autoComplete:"new-password"}),u.confirm&&a.jsx("div",{className:"auth-field__hint",children:u.confirm})]}),a.jsxs("button",{type:"submit",className:"primary auth-submit",disabled:f||!t||!r||!i,children:[f&&a.jsx("span",{className:"auth-spinner"}),f?"注册中...":"注册"]}),a.jsxs("div",{className:"auth-footer",children:["已有账号?",a.jsx("button",{type:"button",className:"auth-footer__link",onClick:e,children:"登录"})]})]})})}function qp({machineKey:e,ownerToken:t,machineName:n,title:r,persistent:s,onClose:i}){const[o,l]=b.useState(!1),[c,u]=b.useState(!1),[d,f]=b.useState(!1),h=!!t,p=t??e??"",v=h?"Owner Token":"Machine Key",x=zz(),w=h?Fz(t,n||void 0):Vz(e??"");function g(y,m){navigator.clipboard.writeText(y).then(()=>{m(!0),setTimeout(()=>m(!1),2e3)})}return a.jsxs("div",{className:"daemon-connect-card",children:[a.jsxs("div",{className:"daemon-connect-card__header",children:[a.jsx(V,{name:"check",size:16,color:"var(--green)"}),a.jsx("span",{className:"daemon-connect-card__title",children:r??(h?"添加执行引擎":`机器「${n??""}」创建成功`)})]}),a.jsxs("div",{className:"daemon-connect-card__warn",children:[a.jsx(V,{name:"warn",size:14}),h?"该 owner-token 是账号级长期凭证,请妥善保管勿外泄(可在账号中心轮换)":s?"该命令含接入密钥,请妥善保管勿外泄":"密钥仅此一次展示,请立即复制保管"]}),a.jsxs("div",{className:"daemon-connect-card__section",children:[a.jsx("div",{className:"daemon-connect-card__label",children:v}),a.jsxs("div",{className:"daemon-connect-card__copyable",children:[a.jsx("code",{className:"daemon-connect-card__code",children:p}),a.jsxs("button",{type:"button",className:"daemon-connect-card__copy-btn",onClick:()=>g(p,l),title:"复制凭证",children:[o?a.jsx(V,{name:"check",size:12}):a.jsx(V,{name:"link",size:12}),o?"已复制":"复制"]})]})]}),a.jsxs("div",{className:"daemon-connect-card__section",children:[a.jsx("div",{className:"daemon-connect-card__label",children:"首次安装(一次性)"}),a.jsxs("div",{className:"daemon-connect-card__copyable daemon-connect-card__copyable--cmd",children:[a.jsx("pre",{className:"daemon-connect-card__pre",children:x}),a.jsxs("button",{type:"button",className:"daemon-connect-card__copy-btn",onClick:()=>g(x,f),title:"复制安装命令",children:[d?a.jsx(V,{name:"check",size:12}):a.jsx(V,{name:"link",size:12}),d?"已复制":"复制"]})]}),a.jsx("div",{className:"daemon-connect-card__hint",children:"仅首次安装或升级 CLI 时执行一次,之后无需重复。"})]}),a.jsxs("div",{className:"daemon-connect-card__section",children:[a.jsx("div",{className:"daemon-connect-card__label",children:"Daemon 接入命令(后台运行)"}),a.jsxs("div",{className:"daemon-connect-card__copyable daemon-connect-card__copyable--cmd",children:[a.jsx("pre",{className:"daemon-connect-card__pre",children:w}),a.jsxs("button",{type:"button",className:"daemon-connect-card__copy-btn",onClick:()=>g(w,u),title:"复制命令",children:[c?a.jsx(V,{name:"check",size:12}):a.jsx(V,{name:"link",size:12}),c?"已复制":"复制"]})]}),a.jsx("div",{className:"daemon-connect-card__hint",children:h?a.jsxs(a.Fragment,{children:["将 ",a.jsx("code",{children:"<此机器名>"})," 改为该机器的稳定名称(相同名字复用同一台,不同名字新增一台), 在目标机器上执行即可:保存凭证 → ",a.jsx("strong",{children:"后台启动 daemon"}),", 终端随后打印 status / logs / stop 等常用命令指引。工作区默认为"," ",a.jsx("code",{children:"~/.aitable-workflow/workspaces/<机器名>"}),",如需自定义可加"," ",a.jsx("code",{children:"--workspace-root <目录>"}),"。",a.jsx("br",{}),"多网关 / 多台机器请为每台使用",a.jsxs("strong",{children:["不同的 ",a.jsx("code",{children:"--name"})]}),"(相同 name 连不同 gateway 会覆盖本机凭证)。"]}):a.jsxs(a.Fragment,{children:["在目标机器上执行即可:保存凭证 → ",a.jsx("strong",{children:"后台启动 daemon"}),", 终端随后打印 status / logs / stop 等常用命令指引。工作区默认为"," ",a.jsx("code",{children:"~/.aitable-workflow/workspaces/<机器名>"}),",如需自定义可加"," ",a.jsx("code",{children:"--workspace-root <目录>"}),"。",a.jsx("br",{}),"多网关 / 多台机器请为每台使用",a.jsxs("strong",{children:["不同的 ",a.jsx("code",{children:"--name"})]}),"(相同 name 连不同 gateway 会覆盖本机凭证)。"]})})]}),a.jsx("div",{className:"daemon-connect-card__actions",children:a.jsx("button",{type:"button",className:"daemon-connect-card__close",onClick:i,children:"我已复制,关闭"})})]})}function i7(e){const t=Date.now(),n=new Date(e).getTime(),r=t-n;if(Number.isNaN(r))return e;const s=Math.floor(r/1e3);if(s<60)return"刚刚";const i=Math.floor(s/60);if(i<60)return`${i}分钟前`;const o=Math.floor(i/60);if(o<24)return`${o}小时前`;const l=Math.floor(o/24);if(l<30)return`${l}天前`;const c=Math.floor(l/30);return c<12?`${c}个月前`:`${Math.floor(c/12)}年前`}function o7(e){return e.length<=12?e:e.slice(0,6)+"..."+e.slice(-4)}const a7={claudecode:"Claude",codex:"Codex",qoder:"Qoder",codebuddy:"Codebuddy",opencode:"OpenCode",qwen:"Qwen",deepseek:"DeepSeek",trae:"Trae",qwenwork:"千问办公"};function l7({machine:e,onRevoke:t,onUpdated:n}){const[r,s]=b.useState(!1),[i,o]=b.useState(!1),[l,c]=b.useState(""),[u,d]=b.useState(!1),[f,h]=b.useState(null),[p,v]=b.useState(null);function x(){navigator.clipboard.writeText(e.machineId).then(()=>{s(!0),setTimeout(()=>s(!1),1500)})}async function w(){d(!0);try{const S=await Vk();h(S)}catch(S){window.alert("获取接入指令失败:"+(S instanceof Error?S.message:String(S)))}finally{d(!1)}}async function g(){if(window.confirm(`确定要为「${e.displayName||e.name}」重新生成密钥吗?旧密钥将立即失效,需用新密钥重新接入。`)){d(!0);try{const P=await Oz(e.machineId);v(P)}catch(P){window.alert("重新生成失败:"+(P instanceof Error?P.message:String(P)))}finally{d(!1)}}}function y(){window.confirm(`确定要撤销执行引擎「${e.displayName||e.name}」吗?撤销后该机器将无法连接。`)&&t(e.machineId)}function m(){c(e.displayName||e.name),o(!0)}async function _(){const S=l.trim();if(S){try{await Rz(e.machineId,{displayName:S}),n==null||n(e.machineId,{displayName:S})}catch(P){window.alert("修改失败:"+(P instanceof Error?P.message:String(P)))}o(!1)}}const j=e.displayName||e.name,N=e.status==="online",k=e.runtimes??[];return a.jsxs("div",{className:"machine-card",children:[a.jsxs("div",{className:"machine-card__header",children:[a.jsx("span",{className:`machine-status ${N?"machine-status--online":"machine-status--offline"}`}),i?a.jsxs("span",{className:"machine-card__edit-row",children:[a.jsx("input",{className:"machine-card__edit-input",type:"text",value:l,onChange:S=>c(S.target.value),onKeyDown:S=>{S.key==="Enter"&&_(),S.key==="Escape"&&o(!1)},autoFocus:!0}),a.jsx("button",{type:"button",className:"machine-card__edit-save",onClick:()=>void _(),title:"保存",children:a.jsx(V,{name:"check",size:12})}),a.jsx("button",{type:"button",className:"machine-card__edit-cancel",onClick:()=>o(!1),title:"取消",children:a.jsx(V,{name:"close",size:12})})]}):a.jsxs(a.Fragment,{children:[a.jsx("span",{className:"machine-card__name",onDoubleClick:m,title:"双击编辑名称",children:j}),e.displayName&&e.name!==e.displayName&&a.jsx("span",{className:"machine-card__slug",children:e.name})]})]}),e.description&&a.jsx("div",{className:"machine-card__desc",children:e.description}),k.length>0?a.jsxs("div",{className:`machine-card__runtimes${N?"":" machine-card__runtimes--offline"}`,children:[k.map(S=>a.jsx("span",{className:"machine-card__runtime-tag",children:a7[S]??S},S)),e.hasDws&&a.jsx("span",{className:"machine-card__runtime-tag machine-card__runtime-tag--dws",children:"dws"})]}):a.jsx("div",{className:"machine-card__runtimes machine-card__runtimes--offline",children:a.jsx("span",{className:"machine-card__runtime-hint",children:"未探测到引擎"})}),a.jsxs("div",{className:"machine-card__meta",children:[a.jsxs("span",{className:"machine-card__id",title:e.machineId,children:["ID: ",o7(e.machineId),a.jsx("button",{type:"button",className:"machine-card__copy",onClick:x,title:"复制 Machine ID",children:r?a.jsx(V,{name:"check",size:12}):a.jsx(V,{name:"link",size:12})})]}),a.jsx("span",{className:"machine-card__seen",children:N?"在线":e.lastSeen?`最后在线 ${i7(e.lastSeen)}`:"从未连接"})]}),a.jsxs("div",{className:"machine-card__actions",children:[a.jsxs("button",{type:"button",className:"machine-card__action-btn",onClick:m,title:"编辑名称",children:[a.jsx(V,{name:"file",size:12})," 编辑"]}),a.jsxs("button",{type:"button",className:"machine-card__action-btn",onClick:()=>void w(),disabled:u,title:"查看该机器的接入指令(Key + 启动命令)",children:[a.jsx(V,{name:"link",size:12})," 查看指令"]}),a.jsxs("button",{type:"button",className:"machine-card__action-btn",onClick:()=>void g(),disabled:u,title:"重新生成密钥(旧密钥失效)",children:[a.jsx(V,{name:"refresh",size:12})," 重生成密钥"]}),a.jsx("button",{type:"button",className:"machine-card__revoke",onClick:y,children:"撤销"})]}),f&&a.jsx(qp,{ownerToken:f,machineName:e.name,title:`「${j}」接入指令`,onClose:()=>h(null)}),p&&a.jsx(qp,{machineKey:p,machineName:j,title:`「${j}」新密钥已生成`,onClose:()=>v(null)})]})}function eC(){const[e,t]=b.useState([]),[n,r]=b.useState(!0),[s,i]=b.useState(""),[o,l]=b.useState(!1),[c,u]=b.useState(null);async function d(){r(!0),i("");try{const w=await qg();t(w)}catch(w){i(w instanceof Error?w.message:String(w))}finally{r(!1)}}b.useEffect(()=>{d()},[]);async function f(){l(!0);try{const w=await Vk();u(w)}catch(w){window.alert("获取接入指令失败:"+(w instanceof Error?w.message:String(w)))}finally{l(!1)}}async function h(w){try{await Iz(w),t(g=>g.filter(y=>y.machineId!==w))}catch(g){window.alert("撤销失败:"+(g instanceof Error?g.message:String(g)))}}function p(w,g){t(y=>y.map(m=>m.machineId===w?{...m,...g}:m))}if(n)return a.jsx("div",{className:"machine-list__loading",children:"加载中..."});if(s)return a.jsxs("div",{className:"machine-list__error",children:[a.jsx("span",{children:s}),a.jsx("button",{type:"button",className:"machine-list__retry",onClick:()=>void d(),children:"重试"})]});const v=e.filter(w=>w.status==="online"||w.lastSeen),x=v.filter(w=>w.status==="online").length;return a.jsxs("div",{className:"machine-list",children:[a.jsxs("div",{className:"machine-list__header",children:[a.jsxs("span",{className:"machine-list__count",children:["已接入 ",v.length," 台 · 在线 ",x," 台"]}),a.jsxs("div",{className:"machine-list__header-actions",children:[a.jsxs("button",{type:"button",className:"machine-list__refresh",onClick:()=>void d(),title:"刷新(daemon 接入后点此更新列表)",children:[a.jsx(V,{name:"refresh",size:14}),"刷新"]}),a.jsxs("button",{type:"button",className:"primary machine-list__add",onClick:()=>void f(),disabled:o,children:[a.jsx(V,{name:"plus",size:14}),o?"获取中...":"添加引擎"]})]})]}),c&&a.jsx(qp,{ownerToken:c,title:"添加执行引擎",onClose:()=>u(null)}),v.length===0&&!c?a.jsx("div",{className:"machine-list__empty",children:"暂无已接入的执行引擎。点击「添加引擎」获取自注册接入指令,在目标机器上执行 daemon 启动命令(填入机器名);接入成功后点「刷新」即可看到。"}):a.jsx("div",{className:"machine-list__grid",children:v.map(w=>a.jsx(l7,{machine:w,onRevoke:h,onUpdated:p},w.machineId))})]})}const c7={admin:"管理员",user:"普通用户"};function u7(e){try{return new Date(e).toLocaleDateString("zh-CN",{year:"numeric",month:"long",day:"numeric"})}catch{return e}}function d7(){var c,u;const e=Og(),[t,n]=b.useState(null),[r,s]=b.useState(!0);b.useEffect(()=>{(async()=>{try{const d=await Mz();n(d)}catch{}finally{s(!1)}})()},[]);const i=(t==null?void 0:t.username)??((c=e.user)==null?void 0:c.username)??"---",o=(t==null?void 0:t.role)??((u=e.user)==null?void 0:u.role)??"user",l=(t==null?void 0:t.createdAt)??null;return a.jsx("div",{className:"split split--chatonly",children:a.jsxs("div",{className:"split__work",children:[a.jsx("div",{className:"work-head",children:a.jsxs("div",{className:"work-head__left",children:[a.jsxs("button",{type:"button",className:"account-back-btn",onClick:()=>z.setRoute("home"),title:"返回首页",children:[a.jsx(V,{name:"chevron-left",size:16}),"返回"]}),a.jsxs("div",{children:[a.jsx("div",{className:"work-head__title",children:"用户中心"}),a.jsx("div",{className:"work-head__sub",children:"管理账号信息与执行引擎"})]})]})}),a.jsx("div",{className:"work-body",children:a.jsxs("div",{className:"account-page",children:[a.jsxs("section",{className:"account-section",children:[a.jsx("h3",{className:"account-section__title",children:"账号信息"}),a.jsx("div",{className:"account-card",children:r?a.jsx("div",{className:"account-card__loading",children:"加载中..."}):a.jsxs(a.Fragment,{children:[a.jsxs("div",{className:"account-card__row",children:[a.jsx("span",{className:"account-card__avatar",children:a.jsx(V,{name:"user",size:24})}),a.jsxs("div",{className:"account-card__info",children:[a.jsx("span",{className:"account-card__username",children:i}),a.jsx("span",{className:`account-card__role account-card__role--${o}`,children:c7[o]??o})]})]}),l&&a.jsxs("div",{className:"account-card__detail",children:[a.jsx("span",{className:"account-card__label",children:"注册时间"}),a.jsx("span",{className:"account-card__value",children:u7(l)})]})]})})]}),a.jsxs("section",{className:"account-section",children:[a.jsx("h3",{className:"account-section__title",children:"执行引擎管理"}),a.jsx(eC,{})]})]})})]})})}function f7(){return a.jsx("div",{className:"split split--chatonly",children:a.jsxs("div",{className:"split__work",children:[a.jsx("div",{className:"work-head",children:a.jsxs("div",{className:"work-head__left",children:[a.jsxs("button",{type:"button",className:"account-back-btn",onClick:()=>z.setRoute("home"),title:"返回首页",children:[a.jsx(V,{name:"chevron-left",size:16}),"返回"]}),a.jsxs("div",{children:[a.jsx("div",{className:"work-head__title",children:"执行引擎"}),a.jsx("div",{className:"work-head__sub",children:"生成接入密钥、查看启动命令,管理已接入的引擎"})]})]})}),a.jsx("div",{className:"work-body",children:a.jsx("div",{className:"account-page",children:a.jsx("section",{className:"account-section",children:a.jsx(eC,{})})})})]})})}const h7={init:{title:"一次性配置",sub:"Agent · 角色 · SOP"},design:{title:"工作流设计",sub:"需求对齐后可视化编排流程方案"},setup:{title:"AI 表格搭建",sub:"自动创建字段与视图"},adjust:{title:"参数调整",sub:"确认并补全项目配置"},test:{title:"试运行",sub:"用一条真实记录验证整条流程"},run:{title:"运行监控",sub:"任务流转 · 步骤日志 · 人工审批"}};function p7({stage:e}){const t=h7[e];return a.jsx("div",{className:"split split--chatonly",children:a.jsxs("div",{className:"split__work",children:[a.jsx("div",{className:"work-head",children:a.jsxs("div",{children:[a.jsx("div",{className:"work-head__title",children:t.title}),a.jsx("div",{className:"work-head__sub",children:t.sub})]})}),a.jsx("div",{className:"work-body",children:a.jsxs("div",{className:"empty-hint",children:["当前没有可用的项目。",a.jsx("div",{style:{marginTop:16},children:a.jsx("button",{type:"button",className:"primary",onClick:()=>z.setRoute("home"),children:"回到首页"})})]})})]})})}const m7=[{icon:"robot",label:"配置",stage:"init",desc:"发现并接入 Agent、角色、SOP"},{icon:"flow",label:"设计",stage:"design",desc:"问答对齐后可视化编排工作流"},{icon:"table",label:"搭建",stage:"setup",desc:"自动创建字段与视图"},{icon:"sparkle",label:"试运行",stage:"test",desc:"用一条真实记录验证流程"}];function g7(){const[e,t]=b.useState(!1),[n,r]=b.useState(!1);async function s(i){if(!ue){z.beginNewProject(`mock-${Date.now()}`,i);return}const o=await $g();z.beginNewProject(o.id,i),z.setProjects(ka(z.projects,o))}return a.jsxs("div",{className:"home-hero",children:[a.jsx(Ye.span,{className:"home-hero__mark",variants:dz,initial:"hidden",animate:"visible",children:a.jsx(V,{name:"sparkle",size:28,color:"#fff"})}),a.jsx("h1",{className:"home-hero__title",children:"用对话搭建你的 AI 表格工作流"}),a.jsxs("p",{className:"home-hero__desc",children:["从配置、设计、搭建到试运行,全程对话式引导。",a.jsx("br",{}),"以 HR、法务等专业岗位协作为例,四步落地一条可运行的业务流程。"]}),a.jsxs("div",{className:"home-hero__ctas",children:[a.jsxs("button",{type:"button",className:"primary home-hero__cta",onClick:()=>r(!0),children:[a.jsx(V,{name:"play",size:16,color:"#fff"}),"新建项目"]}),a.jsxs("button",{type:"button",className:"home-hero__cta home-hero__cta--ghost",onClick:()=>t(!0),children:[a.jsx(V,{name:"plus",size:16}),"导入已有项目"]})]}),a.jsx(Ye.div,{className:"home-beats",variants:Ik,initial:"hidden",animate:"visible",children:m7.map((i,o)=>a.jsxs(Ye.button,{type:"button",className:"home-beat",variants:St,onClick:()=>z.setRoute(i.stage),children:[a.jsx("span",{className:"home-beat__idx",children:o+1}),a.jsx("span",{className:"home-beat__icon",children:a.jsx(V,{name:i.icon,size:18})}),a.jsx("span",{className:"home-beat__label",children:i.label}),a.jsx("span",{className:"home-beat__desc",children:i.desc})]},i.stage))}),e&&a.jsx(RW,{onClose:()=>t(!1)}),n&&a.jsx(dk,{onConfirm:i=>{s(i),r(!1)},onCancel:()=>r(!1)})]})}const v7=ut(function(){const t=Og(),[n,r]=b.useState("login"),[s]=b.useState(()=>ID());return b.useEffect(()=>{s&&z.setRoute("adjust")},[s]),it&&!t.token&&!s?n==="register"?a.jsx(s7,{onSwitchToLogin:()=>r("login")}):a.jsx(r7,{onSwitchToRegister:()=>r("register")}):a.jsx(y7,{devMode:s})}),y7=ut(function({devMode:t}){b.useEffect(()=>{if(t||!ue)return;const r=z.persistedProjectId;!r&&z.route!=="home"||ba(r,{fallbackRoute:z.route})},[t]);const n=z.view;return a.jsx(az,{children:n.kind==="loading"?a.jsx(cz,{stage:z.route}):n.kind==="load_error"?a.jsx(uz,{message:n.message,onRetry:()=>void ba(n.projectId,{fallbackRoute:z.route})}):n.kind==="home"?a.jsx(g7,{}):n.kind==="no_project"?a.jsx(p7,{stage:n.intended}):n.kind==="init"?a.jsx(uW,{}):n.kind==="design"?a.jsx(ZU,{},z.projectId??"__no_project__"):n.kind==="setup"?a.jsx(pW,{}):n.kind==="adjust"?a.jsx(n7,{}):n.kind==="test"?a.jsx(vW,{}):n.kind==="run"?a.jsx(CW,{}):n.kind==="account"?a.jsx(d7,{}):a.jsx(f7,{})})}),_7=new URLSearchParams(window.location.search).has("token");_7||$z();kb(document.getElementById("root")).render(a.jsx(b.StrictMode,{children:a.jsx(v7,{})}));
|