@clawos-dev/clawd 0.2.376 → 0.2.378

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.
@@ -92,7 +92,7 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
92
92
  0 -6px 16px 0 rgba(0, 0, 0, 0.08),
93
93
  0 -3px 6px -4px rgba(0, 0, 0, 0.12),
94
94
  0 -9px 28px 8px rgba(0, 0, 0, 0.05)
95
- `,boxShadowTabsOverflowLeft:"inset 10px 0 8px -8px rgba(0, 0, 0, 0.08)",boxShadowTabsOverflowRight:"inset -10px 0 8px -8px rgba(0, 0, 0, 0.08)",boxShadowTabsOverflowTop:"inset 0 10px 8px -8px rgba(0, 0, 0, 0.08)",boxShadowTabsOverflowBottom:"inset 0 -10px 8px -8px rgba(0, 0, 0, 0.08)"}),r)}var Jb=function(e,t){var n={};for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(e!=null&&typeof Object.getOwnPropertySymbols=="function")for(var i=0,r=Object.getOwnPropertySymbols(e);i<r.length;i++)t.indexOf(r[i])<0&&Object.prototype.propertyIsEnumerable.call(e,r[i])&&(n[r[i]]=e[r[i]]);return n};const ED={lineHeight:!0,lineHeightSM:!0,lineHeightLG:!0,lineHeightHeading1:!0,lineHeightHeading2:!0,lineHeightHeading3:!0,lineHeightHeading4:!0,lineHeightHeading5:!0,opacityLoading:!0,fontWeightStrong:!0,zIndexPopupBase:!0,zIndexBase:!0,opacityImage:!0},TD={motionBase:!0,motionUnit:!0},ND={screenXS:!0,screenXSMin:!0,screenXSMax:!0,screenSM:!0,screenSMMin:!0,screenSMMax:!0,screenMD:!0,screenMDMin:!0,screenMDMax:!0,screenLG:!0,screenLGMin:!0,screenLGMax:!0,screenXL:!0,screenXLMin:!0,screenXLMax:!0,screenXXL:!0,screenXXLMin:!0},GT=(e,t,n)=>{const r=n.getDerivativeToken(e),{override:i}=t,s=Jb(t,["override"]);let o=Object.assign(Object.assign({},r),{override:i});return o=KT(o),s&&Object.entries(s).forEach(([a,l])=>{const{theme:c}=l,u=Jb(l,["theme"]);let d=u;c&&(d=GT(Object.assign(Object.assign({},o),u),{override:u},c)),o[a]=d}),o};function YT(){const{token:e,hashed:t,theme:n,override:r,cssVar:i}=Ze.useContext(VT),s=`${kD}-${t||""}`,o=n||WT,[a,l,c]=pj(o,[Fc,e],{salt:s,override:r,getComputedToken:GT,formatToken:KT,cssVar:i&&{prefix:i.prefix,key:i.key,unitless:ED,ignore:TD,preserve:ND}});return[o,c,t?l:"",a,i]}const PD=()=>({display:"inline-flex",alignItems:"center",color:"inherit",fontStyle:"normal",lineHeight:0,textAlign:"center",textTransform:"none",verticalAlign:"-0.125em",textRendering:"optimizeLegibility","-webkit-font-smoothing":"antialiased","-moz-osx-font-smoothing":"grayscale","> *":{lineHeight:1},svg:{display:"inline-block"}}),ID=e=>({[`.${e}`]:Object.assign(Object.assign({},PD()),{[`.${e} .${e}-icon`]:{display:"block"}})}),RD=(e,t)=>{const[n,r]=YT();return Hj({token:r,hashId:"",path:["ant-design-icons",e],nonce:()=>t==null?void 0:t.nonce,layer:{name:"antd"}},()=>ID(e))},MD=Object.assign({},Qa),{useId:ew}=MD,AD=()=>"",LD=typeof ew>"u"?AD:ew;function jD(e,t,n){var r;const i=e||{},s=i.inherit===!1||!t?Object.assign(Object.assign({},zh),{hashed:(r=t==null?void 0:t.hashed)!==null&&r!==void 0?r:zh.hashed,cssVar:t==null?void 0:t.cssVar}):t,o=LD();return fT(()=>{var a,l;if(!e)return t;const c=Object.assign({},s.components);Object.keys(e.components||{}).forEach(f=>{c[f]=Object.assign(Object.assign({},c[f]),e.components[f])});const u=`css-var-${o.replace(/:/g,"")}`,d=((a=i.cssVar)!==null&&a!==void 0?a:s.cssVar)&&Object.assign(Object.assign(Object.assign({prefix:n==null?void 0:n.prefixCls},typeof s.cssVar=="object"?s.cssVar:{}),typeof i.cssVar=="object"?i.cssVar:{}),{key:typeof i.cssVar=="object"&&((l=i.cssVar)===null||l===void 0?void 0:l.key)||u});return Object.assign(Object.assign(Object.assign({},s),i),{token:Object.assign(Object.assign({},s.token),i.token),components:c,cssVar:d})},[i,s],(a,l)=>a.some((c,u)=>{const d=l[u];return!HL(c,d,!0)}))}var DD=["children"],XT=g.createContext({});function OD(e){var t=e.children,n=Pv(e,DD);return g.createElement(XT.Provider,{value:n},t)}var BD=function(e){mT(n,e);var t=vT(n);function n(){return tl(this,n),t.apply(this,arguments)}return nl(n,[{key:"render",value:function(){return this.props.children}}]),n}(g.Component);function zD(e){var t=g.useReducer(function(a){return a+1},0),n=Je(t,2),r=n[1],i=g.useRef(e),s=Qv(function(){return i.current}),o=Qv(function(a){i.current=typeof a=="function"?a(i.current):a,r()});return[s,o]}var ts="none",id="appear",sd="enter",od="leave",tw="none",Tr="prepare",fa="start",pa="active",Rx="end",QT="prepared";function nw(e,t){var n={};return n[e.toLowerCase()]=t.toLowerCase(),n["Webkit".concat(e)]="webkit".concat(t),n["Moz".concat(e)]="moz".concat(t),n["ms".concat(e)]="MS".concat(t),n["O".concat(e)]="o".concat(t.toLowerCase()),n}function $D(e,t){var n={animationend:nw("Animation","AnimationEnd"),transitionend:nw("Transition","TransitionEnd")};return e&&("AnimationEvent"in t||delete n.animationend.animation,"TransitionEvent"in t||delete n.transitionend.transition),n}var FD=$D(Bi(),typeof window<"u"?window:{}),ZT={};if(Bi()){var HD=document.createElement("div");ZT=HD.style}var ad={};function JT(e){if(ad[e])return ad[e];var t=FD[e];if(t)for(var n=Object.keys(t),r=n.length,i=0;i<r;i+=1){var s=n[i];if(Object.prototype.hasOwnProperty.call(t,s)&&s in ZT)return ad[e]=t[s],ad[e]}return""}var eN=JT("animationend"),tN=JT("transitionend"),nN=!!(eN&&tN),rw=eN||"animationend",iw=tN||"transitionend";function sw(e,t){if(!e)return null;if(Ct(e)==="object"){var n=t.replace(/-\w/g,function(r){return r[1].toUpperCase()});return e[n]}return"".concat(e,"-").concat(t)}const UD=function(e){var t=g.useRef();function n(i){i&&(i.removeEventListener(iw,e),i.removeEventListener(rw,e))}function r(i){t.current&&t.current!==i&&n(t.current),i&&i!==t.current&&(i.addEventListener(iw,e),i.addEventListener(rw,e),t.current=i)}return g.useEffect(function(){return function(){n(t.current)}},[]),[r,n]};var rN=Bi()?g.useLayoutEffect:g.useEffect;const WD=function(){var e=g.useRef(null);function t(){Tv.cancel(e.current)}function n(r){var i=arguments.length>1&&arguments[1]!==void 0?arguments[1]:2;t();var s=Tv(function(){i<=1?r({isCanceled:function(){return s!==e.current}}):n(r,i-1)});e.current=s}return g.useEffect(function(){return function(){t()}},[]),[n,t]};var VD=[Tr,fa,pa,Rx],qD=[Tr,QT],iN=!1,KD=!0;function sN(e){return e===pa||e===Rx}const GD=function(e,t,n){var r=Zv(tw),i=Je(r,2),s=i[0],o=i[1],a=WD(),l=Je(a,2),c=l[0],u=l[1];function d(){o(Tr,!0)}var f=t?qD:VD;return rN(function(){if(s!==tw&&s!==Rx){var p=f.indexOf(s),m=f[p+1],v=n(s);v===iN?o(m,!0):m&&c(function(b){function _(){b.isCanceled()||o(m,!0)}v===!0?_():Promise.resolve(v).then(_)})}},[e,s]),g.useEffect(function(){return function(){u()}},[]),[d,s]};function YD(e,t,n,r){var i=r.motionEnter,s=i===void 0?!0:i,o=r.motionAppear,a=o===void 0?!0:o,l=r.motionLeave,c=l===void 0?!0:l,u=r.motionDeadline,d=r.motionLeaveImmediately,f=r.onAppearPrepare,p=r.onEnterPrepare,m=r.onLeavePrepare,v=r.onAppearStart,b=r.onEnterStart,_=r.onLeaveStart,x=r.onAppearActive,y=r.onEnterActive,w=r.onLeaveActive,C=r.onAppearEnd,k=r.onEnterEnd,T=r.onLeaveEnd,N=r.onVisibleChanged,z=Zv(),P=Je(z,2),B=P[0],R=P[1],I=zD(ts),j=Je(I,2),L=j[0],$=j[1],F=Zv(null),D=Je(F,2),O=D[0],E=D[1],H=L(),V=g.useRef(!1),A=g.useRef(null);function ne(){return n()}var ae=g.useRef(!1);function G(){$(ts),E(null,!0)}var ye=Qv(function(Qe){var st=L();if(st!==ts){var wt=ne();if(!(Qe&&!Qe.deadline&&Qe.target!==wt)){var pn=ae.current,on;st===id&&pn?on=C==null?void 0:C(wt,Qe):st===sd&&pn?on=k==null?void 0:k(wt,Qe):st===od&&pn&&(on=T==null?void 0:T(wt,Qe)),pn&&on!==!1&&G()}}}),Fe=UD(ye),ue=Je(Fe,1),Ie=ue[0],Re=function(st){switch(st){case id:return Ce(Ce(Ce({},Tr,f),fa,v),pa,x);case sd:return Ce(Ce(Ce({},Tr,p),fa,b),pa,y);case od:return Ce(Ce(Ce({},Tr,m),fa,_),pa,w);default:return{}}},Ke=g.useMemo(function(){return Re(H)},[H]),ve=GD(H,!e,function(Qe){if(Qe===Tr){var st=Ke[Tr];return st?st(ne()):iN}if(it in Ke){var wt;E(((wt=Ke[it])===null||wt===void 0?void 0:wt.call(Ke,ne(),null))||null)}return it===pa&&H!==ts&&(Ie(ne()),u>0&&(clearTimeout(A.current),A.current=setTimeout(function(){ye({deadline:!0})},u))),it===QT&&G(),KD}),ze=Je(ve,2),fn=ze[0],it=ze[1],Rt=sN(it);ae.current=Rt;var Gt=g.useRef(null);rN(function(){if(!(V.current&&Gt.current===t)){R(t);var Qe=V.current;V.current=!0;var st;!Qe&&t&&a&&(st=id),Qe&&t&&s&&(st=sd),(Qe&&!t&&c||!Qe&&d&&!t&&c)&&(st=od);var wt=Re(st);st&&(e||wt[Tr])?($(st),fn()):$(ts),Gt.current=t}},[t]),g.useEffect(function(){(H===id&&!a||H===sd&&!s||H===od&&!c)&&$(ts)},[a,s,c]),g.useEffect(function(){return function(){V.current=!1,clearTimeout(A.current)}},[]);var Mt=g.useRef(!1);g.useEffect(function(){B&&(Mt.current=!0),B!==void 0&&H===ts&&((Mt.current||B)&&(N==null||N(B)),Mt.current=!0)},[B,H]);var bt=O;return Ke[Tr]&&it===fa&&(bt=$e({transition:"none"},bt)),[H,it,bt,B??t]}function XD(e){var t=e;Ct(e)==="object"&&(t=e.transitionSupport);function n(i,s){return!!(i.motionName&&t&&s!==!1)}var r=g.forwardRef(function(i,s){var o=i.visible,a=o===void 0?!0:o,l=i.removeOnLeave,c=l===void 0?!0:l,u=i.forceRender,d=i.children,f=i.motionName,p=i.leavedClassName,m=i.eventProps,v=g.useContext(XT),b=v.motion,_=n(i,b),x=g.useRef(),y=g.useRef();function w(){try{return x.current instanceof HTMLElement?x.current:CL(y.current)}catch{return null}}var C=YD(_,a,w,i),k=Je(C,4),T=k[0],N=k[1],z=k[2],P=k[3],B=g.useRef(P);P&&(B.current=!0);var R=g.useCallback(function(D){x.current=D,PL(s,D)},[s]),I,j=$e($e({},m),{},{visible:a});if(!d)I=null;else if(T===ts)P?I=d($e({},j),R):!c&&B.current&&p?I=d($e($e({},j),{},{className:p}),R):u||!c&&!p?I=d($e($e({},j),{},{style:{display:"none"}}),R):I=null;else{var L;N===Tr?L="prepare":sN(N)?L="active":N===fa&&(L="start");var $=sw(f,"".concat(T,"-").concat(L));I=d($e($e({},j),{},{className:fL(sw(f,T),Ce(Ce({},$,$&&L),f,typeof f=="string")),style:z}),R)}if(g.isValidElement(I)&&IL(I)){var F=RL(I);F||(I=g.cloneElement(I,{ref:R}))}return g.createElement(BD,{ref:y},I)});return r.displayName="CSSMotion",r}const QD=XD(nN);var Jv="add",e0="keep",t0="remove",Cm="removed";function ZD(e){var t;return e&&Ct(e)==="object"&&"key"in e?t=e:t={key:e},$e($e({},t),{},{key:String(t.key)})}function n0(){var e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:[];return e.map(ZD)}function JD(){var e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:[],t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:[],n=[],r=0,i=t.length,s=n0(e),o=n0(t);s.forEach(function(c){for(var u=!1,d=r;d<i;d+=1){var f=o[d];if(f.key===c.key){r<d&&(n=n.concat(o.slice(r,d).map(function(p){return $e($e({},p),{},{status:Jv})})),r=d),n.push($e($e({},f),{},{status:e0})),r+=1,u=!0;break}}u||n.push($e($e({},c),{},{status:t0}))}),r<i&&(n=n.concat(o.slice(r).map(function(c){return $e($e({},c),{},{status:Jv})})));var a={};n.forEach(function(c){var u=c.key;a[u]=(a[u]||0)+1});var l=Object.keys(a).filter(function(c){return a[c]>1});return l.forEach(function(c){n=n.filter(function(u){var d=u.key,f=u.status;return d!==c||f!==t0}),n.forEach(function(u){u.key===c&&(u.status=e0)})}),n}var eO=["component","children","onVisibleChanged","onAllRemoved"],tO=["status"],nO=["eventProps","visible","children","motionName","motionAppear","motionEnter","motionLeave","motionLeaveImmediately","motionDeadline","removeOnLeave","leavedClassName","onAppearPrepare","onAppearStart","onAppearActive","onAppearEnd","onEnterStart","onEnterActive","onEnterEnd","onLeaveStart","onLeaveActive","onLeaveEnd"];function rO(e){var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:QD,n=function(r){mT(s,r);var i=vT(s);function s(){var o;tl(this,s);for(var a=arguments.length,l=new Array(a),c=0;c<a;c++)l[c]=arguments[c];return o=i.call.apply(i,[this].concat(l)),Ce(Cv(o),"state",{keyEntities:[]}),Ce(Cv(o),"removeKey",function(u){o.setState(function(d){var f=d.keyEntities.map(function(p){return p.key!==u?p:$e($e({},p),{},{status:Cm})});return{keyEntities:f}},function(){var d=o.state.keyEntities,f=d.filter(function(p){var m=p.status;return m!==Cm}).length;f===0&&o.props.onAllRemoved&&o.props.onAllRemoved()})}),o}return nl(s,[{key:"render",value:function(){var a=this,l=this.state.keyEntities,c=this.props,u=c.component,d=c.children,f=c.onVisibleChanged;c.onAllRemoved;var p=Pv(c,eO),m=u||g.Fragment,v={};return nO.forEach(function(b){v[b]=p[b],delete p[b]}),delete p.keys,g.createElement(m,p,l.map(function(b,_){var x=b.status,y=Pv(b,tO),w=x===Jv||x===e0;return g.createElement(t,Dh({},v,{key:y.key,visible:w,eventProps:y,onVisibleChanged:function(k){f==null||f(k,{key:y.key}),k||a.removeKey(y.key)}}),function(C,k){return d($e($e({},C),{},{index:_}),k)})}))}}],[{key:"getDerivedStateFromProps",value:function(a,l){var c=a.keys,u=l.keyEntities,d=n0(c),f=JD(u,d);return{keyEntities:f.filter(function(p){var m=u.find(function(v){var b=v.key;return p.key===b});return!(m&&m.status===Cm&&p.status===t0)})}}}]),s}(g.Component);return Ce(n,"defaultProps",{component:"div"}),n}rO(nN);const ow=g.createContext(!0);function iO(e){const t=g.useContext(ow),{children:n}=e,[,r]=YT(),{motion:i}=r,s=g.useRef(!1);return s.current||(s.current=t!==i),s.current?g.createElement(ow.Provider,{value:i},g.createElement(OD,{motion:i},n)):n}const sO=()=>null;var oO=function(e,t){var n={};for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(e!=null&&typeof Object.getOwnPropertySymbols=="function")for(var i=0,r=Object.getOwnPropertySymbols(e);i<r.length;i++)t.indexOf(r[i])<0&&Object.prototype.propertyIsEnumerable.call(e,r[i])&&(n[r[i]]=e[r[i]]);return n};const aO=["getTargetContainer","getPopupContainer","renderEmpty","input","pagination","form","select","button"];let oN;function lO(){return oN||Yv}function cO(e){return Object.keys(e).some(t=>t.endsWith("Color"))}const uO=e=>{const{prefixCls:t,iconPrefixCls:n,theme:r,holderRender:i}=e;t!==void 0&&(oN=t),r&&cO(r)&&_D(lO(),r)},dO=e=>{const{children:t,csp:n,autoInsertSpaceInButton:r,alert:i,anchor:s,form:o,locale:a,componentSize:l,direction:c,space:u,splitter:d,virtual:f,dropdownMatchSelectWidth:p,popupMatchSelectWidth:m,popupOverflow:v,legacyLocale:b,parentContext:_,iconPrefixCls:x,theme:y,componentDisabled:w,segmented:C,statistic:k,spin:T,calendar:N,carousel:z,cascader:P,collapse:B,typography:R,checkbox:I,descriptions:j,divider:L,drawer:$,skeleton:F,steps:D,image:O,layout:E,list:H,mentions:V,modal:A,progress:ne,result:ae,slider:G,breadcrumb:ye,menu:Fe,pagination:ue,input:Ie,textArea:Re,empty:Ke,badge:ve,radio:ze,rate:fn,switch:it,transfer:Rt,avatar:Gt,message:Mt,tag:bt,table:Qe,card:st,tabs:wt,timeline:pn,timePicker:on,upload:U,notification:Z,tree:_e,colorPicker:ke,datePicker:He,rangePicker:Nt,flex:Yt,wave:Xt,dropdown:se,warning:q,tour:we,tooltip:ht,popover:an,popconfirm:_l,floatButton:xl,floatButtonGroup:zo,variant:Hp,inputNumber:ju,treeSelect:Du}=e,Ou=g.useCallback((oe,de)=>{const{prefixCls:je}=e;if(de)return de;const $t=je||_.getPrefixCls("");return oe?`${$t}-${oe}`:$t},[_.getPrefixCls,e.prefixCls]),zs=x||_.iconPrefixCls||qT,Wi=n||_.csp;RD(zs,Wi);const yl=jD(y,_.theme,{prefixCls:Ou("")}),Vi={csp:Wi,autoInsertSpaceInButton:r,alert:i,anchor:s,locale:a||b,direction:c,space:u,splitter:d,virtual:f,popupMatchSelectWidth:m??p,popupOverflow:v,getPrefixCls:Ou,iconPrefixCls:zs,theme:yl,segmented:C,statistic:k,spin:T,calendar:N,carousel:z,cascader:P,collapse:B,typography:R,checkbox:I,descriptions:j,divider:L,drawer:$,skeleton:F,steps:D,image:O,input:Ie,textArea:Re,layout:E,list:H,mentions:V,modal:A,progress:ne,result:ae,slider:G,breadcrumb:ye,menu:Fe,pagination:ue,empty:Ke,badge:ve,radio:ze,rate:fn,switch:it,transfer:Rt,avatar:Gt,message:Mt,tag:bt,table:Qe,card:st,tabs:wt,timeline:pn,timePicker:on,upload:U,notification:Z,tree:_e,colorPicker:ke,datePicker:He,rangePicker:Nt,flex:Yt,wave:Xt,dropdown:se,warning:q,tour:we,tooltip:ht,popover:an,popconfirm:_l,floatButton:xl,floatButtonGroup:zo,variant:Hp,inputNumber:ju,treeSelect:Du},qi=Object.assign({},_);Object.keys(Vi).forEach(oe=>{Vi[oe]!==void 0&&(qi[oe]=Vi[oe])}),aO.forEach(oe=>{const de=e[oe];de&&(qi[oe]=de)}),typeof r<"u"&&(qi.button=Object.assign({autoInsertSpace:r},qi.button));const Ki=fT(()=>qi,qi,(oe,de)=>{const je=Object.keys(oe),$t=Object.keys(de);return je.length!==$t.length||je.some($s=>oe[$s]!==de[$s])}),{layer:$o}=g.useContext(Xf),Fo=g.useMemo(()=>({prefixCls:zs,csp:Wi,layer:$o?"antd":void 0}),[zs,Wi,$o]);let zt=g.createElement(g.Fragment,null,g.createElement(sO,{dropdownMatchSelectWidth:p}),t);const bl=g.useMemo(()=>{var oe,de,je,$t;return Xj(((oe=Jf.Form)===null||oe===void 0?void 0:oe.defaultValidateMessages)||{},((je=(de=Ki.locale)===null||de===void 0?void 0:de.Form)===null||je===void 0?void 0:je.defaultValidateMessages)||{},(($t=Ki.form)===null||$t===void 0?void 0:$t.validateMessages)||{},(o==null?void 0:o.validateMessages)||{})},[Ki,o==null?void 0:o.validateMessages]);Object.keys(bl).length>0&&(zt=g.createElement(Zj.Provider,{value:bl},zt)),a&&(zt=g.createElement(tD,{locale:a,_ANT_MARK__:eD},zt)),zt=g.createElement(qj.Provider,{value:Fo},zt),l&&(zt=g.createElement(yD,{size:l},zt)),zt=g.createElement(iO,null,zt);const te=g.useMemo(()=>{const oe=yl||{},{algorithm:de,token:je,components:$t,cssVar:$s}=oe,R5=oO(oe,["algorithm","token","components","cssVar"]),f1=de&&(!Array.isArray(de)||de.length>0)?Rv(de):WT,Up={};Object.entries($t||{}).forEach(([M5,A5])=>{const fi=Object.assign({},A5);"algorithm"in fi&&(fi.algorithm===!0?fi.theme=f1:(Array.isArray(fi.algorithm)||typeof fi.algorithm=="function")&&(fi.theme=Rv(fi.algorithm)),delete fi.algorithm),Up[M5]=fi});const p1=Object.assign(Object.assign({},Fc),je);return Object.assign(Object.assign({},R5),{theme:f1,token:p1,components:Up,override:Object.assign({override:p1},Up),cssVar:$s})},[yl]);return y&&(zt=g.createElement(VT.Provider,{value:te},zt)),Ki.warning&&(zt=g.createElement(Qj.Provider,{value:Ki.warning},zt)),w!==void 0&&(zt=g.createElement(xD,{disabled:w},zt)),g.createElement(ep.Provider,{value:Ki},zt)},il=e=>{const t=g.useContext(ep),n=g.useContext($T);return g.createElement(dO,Object.assign({parentContext:t,legacyLocale:n},e))};il.ConfigContext=ep;il.SizeContext=Hc;il.config=uO;il.useConfig=bD;Object.defineProperty(il,"SizeContext",{get:()=>Hc});const ar=(e,t)=>new _t(e).setA(t).toRgbString(),Wo=(e,t)=>new _t(e).lighten(t).toHexString(),hO=e=>{const t=Ba(e,{theme:"dark"});return{1:t[0],2:t[1],3:t[2],4:t[3],5:t[6],6:t[5],7:t[4],8:t[6],9:t[5],10:t[4]}},fO=(e,t)=>{const n=e||"#000",r=t||"#fff";return{colorBgBase:n,colorTextBase:r,colorText:ar(r,.85),colorTextSecondary:ar(r,.65),colorTextTertiary:ar(r,.45),colorTextQuaternary:ar(r,.25),colorFill:ar(r,.18),colorFillSecondary:ar(r,.12),colorFillTertiary:ar(r,.08),colorFillQuaternary:ar(r,.04),colorBgSolid:ar(r,.95),colorBgSolidHover:ar(r,1),colorBgSolidActive:ar(r,.9),colorBgElevated:Wo(n,12),colorBgContainer:Wo(n,8),colorBgLayout:Wo(n,0),colorBgSpotlight:Wo(n,26),colorBgBlur:ar(r,.04),colorBorder:Wo(n,26),colorBorderSecondary:Wo(n,19)}},pO=(e,t)=>{const n=Object.keys(Px).map(s=>{const o=Ba(e[s],{theme:"dark"});return Array.from({length:10},()=>1).reduce((a,l,c)=>(a[`${s}-${c+1}`]=o[c],a[`${s}${c+1}`]=o[c],a),{})}).reduce((s,o)=>(s=Object.assign(Object.assign({},s),o),s),{}),r=t??Ix(e),i=UT(e,{generateColorPalettes:hO,generateNeutralColorPalettes:fO});return Object.assign(Object.assign(Object.assign(Object.assign({},r),n),i),{colorPrimaryBg:i.colorPrimaryBorder,colorPrimaryBgHover:i.colorPrimaryBorderHover})},aw={defaultSeed:zh.token,defaultAlgorithm:Ix,darkAlgorithm:pO};function lw({children:e}){const t=bx(),[n,r]=g.useState(t.theme);return g.useEffect(()=>t.onThemeChange(r),[t]),h.jsx(il,{theme:{algorithm:n.mode==="dark"?aw.darkAlgorithm:aw.defaultAlgorithm,token:{colorPrimary:n.colorPrimary,colorBgContainer:n.colorBgContainer,colorText:n.colorText,colorBorder:n.colorBorder}},children:e})}var Ye;(function(e){e.assertEqual=i=>{};function t(i){}e.assertIs=t;function n(i){throw new Error}e.assertNever=n,e.arrayToEnum=i=>{const s={};for(const o of i)s[o]=o;return s},e.getValidEnumValues=i=>{const s=e.objectKeys(i).filter(a=>typeof i[i[a]]!="number"),o={};for(const a of s)o[a]=i[a];return e.objectValues(o)},e.objectValues=i=>e.objectKeys(i).map(function(s){return i[s]}),e.objectKeys=typeof Object.keys=="function"?i=>Object.keys(i):i=>{const s=[];for(const o in i)Object.prototype.hasOwnProperty.call(i,o)&&s.push(o);return s},e.find=(i,s)=>{for(const o of i)if(s(o))return o},e.isInteger=typeof Number.isInteger=="function"?i=>Number.isInteger(i):i=>typeof i=="number"&&Number.isFinite(i)&&Math.floor(i)===i;function r(i,s=" | "){return i.map(o=>typeof o=="string"?`'${o}'`:o).join(s)}e.joinValues=r,e.jsonStringifyReplacer=(i,s)=>typeof s=="bigint"?s.toString():s})(Ye||(Ye={}));var cw;(function(e){e.mergeShapes=(t,n)=>({...t,...n})})(cw||(cw={}));const ce=Ye.arrayToEnum(["string","nan","number","integer","float","boolean","date","bigint","symbol","function","undefined","null","array","object","unknown","promise","void","never","map","set"]),ss=e=>{switch(typeof e){case"undefined":return ce.undefined;case"string":return ce.string;case"number":return Number.isNaN(e)?ce.nan:ce.number;case"boolean":return ce.boolean;case"function":return ce.function;case"bigint":return ce.bigint;case"symbol":return ce.symbol;case"object":return Array.isArray(e)?ce.array:e===null?ce.null:e.then&&typeof e.then=="function"&&e.catch&&typeof e.catch=="function"?ce.promise:typeof Map<"u"&&e instanceof Map?ce.map:typeof Set<"u"&&e instanceof Set?ce.set:typeof Date<"u"&&e instanceof Date?ce.date:ce.object;default:return ce.unknown}},Y=Ye.arrayToEnum(["invalid_type","invalid_literal","custom","invalid_union","invalid_union_discriminator","invalid_enum_value","unrecognized_keys","invalid_arguments","invalid_return_type","invalid_date","invalid_string","too_small","too_big","invalid_intersection_types","not_multiple_of","not_finite"]);class Ai extends Error{get errors(){return this.issues}constructor(t){super(),this.issues=[],this.addIssue=r=>{this.issues=[...this.issues,r]},this.addIssues=(r=[])=>{this.issues=[...this.issues,...r]};const n=new.target.prototype;Object.setPrototypeOf?Object.setPrototypeOf(this,n):this.__proto__=n,this.name="ZodError",this.issues=t}format(t){const n=t||function(s){return s.message},r={_errors:[]},i=s=>{for(const o of s.issues)if(o.code==="invalid_union")o.unionErrors.map(i);else if(o.code==="invalid_return_type")i(o.returnTypeError);else if(o.code==="invalid_arguments")i(o.argumentsError);else if(o.path.length===0)r._errors.push(n(o));else{let a=r,l=0;for(;l<o.path.length;){const c=o.path[l];l===o.path.length-1?(a[c]=a[c]||{_errors:[]},a[c]._errors.push(n(o))):a[c]=a[c]||{_errors:[]},a=a[c],l++}}};return i(this),r}static assert(t){if(!(t instanceof Ai))throw new Error(`Not a ZodError: ${t}`)}toString(){return this.message}get message(){return JSON.stringify(this.issues,Ye.jsonStringifyReplacer,2)}get isEmpty(){return this.issues.length===0}flatten(t=n=>n.message){const n={},r=[];for(const i of this.issues)if(i.path.length>0){const s=i.path[0];n[s]=n[s]||[],n[s].push(t(i))}else r.push(t(i));return{formErrors:r,fieldErrors:n}}get formErrors(){return this.flatten()}}Ai.create=e=>new Ai(e);const r0=(e,t)=>{let n;switch(e.code){case Y.invalid_type:e.received===ce.undefined?n="Required":n=`Expected ${e.expected}, received ${e.received}`;break;case Y.invalid_literal:n=`Invalid literal value, expected ${JSON.stringify(e.expected,Ye.jsonStringifyReplacer)}`;break;case Y.unrecognized_keys:n=`Unrecognized key(s) in object: ${Ye.joinValues(e.keys,", ")}`;break;case Y.invalid_union:n="Invalid input";break;case Y.invalid_union_discriminator:n=`Invalid discriminator value. Expected ${Ye.joinValues(e.options)}`;break;case Y.invalid_enum_value:n=`Invalid enum value. Expected ${Ye.joinValues(e.options)}, received '${e.received}'`;break;case Y.invalid_arguments:n="Invalid function arguments";break;case Y.invalid_return_type:n="Invalid function return type";break;case Y.invalid_date:n="Invalid date";break;case Y.invalid_string:typeof e.validation=="object"?"includes"in e.validation?(n=`Invalid input: must include "${e.validation.includes}"`,typeof e.validation.position=="number"&&(n=`${n} at one or more positions greater than or equal to ${e.validation.position}`)):"startsWith"in e.validation?n=`Invalid input: must start with "${e.validation.startsWith}"`:"endsWith"in e.validation?n=`Invalid input: must end with "${e.validation.endsWith}"`:Ye.assertNever(e.validation):e.validation!=="regex"?n=`Invalid ${e.validation}`:n="Invalid";break;case Y.too_small:e.type==="array"?n=`Array must contain ${e.exact?"exactly":e.inclusive?"at least":"more than"} ${e.minimum} element(s)`:e.type==="string"?n=`String must contain ${e.exact?"exactly":e.inclusive?"at least":"over"} ${e.minimum} character(s)`:e.type==="number"?n=`Number must be ${e.exact?"exactly equal to ":e.inclusive?"greater than or equal to ":"greater than "}${e.minimum}`:e.type==="bigint"?n=`Number must be ${e.exact?"exactly equal to ":e.inclusive?"greater than or equal to ":"greater than "}${e.minimum}`:e.type==="date"?n=`Date must be ${e.exact?"exactly equal to ":e.inclusive?"greater than or equal to ":"greater than "}${new Date(Number(e.minimum))}`:n="Invalid input";break;case Y.too_big:e.type==="array"?n=`Array must contain ${e.exact?"exactly":e.inclusive?"at most":"less than"} ${e.maximum} element(s)`:e.type==="string"?n=`String must contain ${e.exact?"exactly":e.inclusive?"at most":"under"} ${e.maximum} character(s)`:e.type==="number"?n=`Number must be ${e.exact?"exactly":e.inclusive?"less than or equal to":"less than"} ${e.maximum}`:e.type==="bigint"?n=`BigInt must be ${e.exact?"exactly":e.inclusive?"less than or equal to":"less than"} ${e.maximum}`:e.type==="date"?n=`Date must be ${e.exact?"exactly":e.inclusive?"smaller than or equal to":"smaller than"} ${new Date(Number(e.maximum))}`:n="Invalid input";break;case Y.custom:n="Invalid input";break;case Y.invalid_intersection_types:n="Intersection results could not be merged";break;case Y.not_multiple_of:n=`Number must be a multiple of ${e.multipleOf}`;break;case Y.not_finite:n="Number must be finite";break;default:n=t.defaultError,Ye.assertNever(e)}return{message:n}};let mO=r0;function gO(){return mO}const vO=e=>{const{data:t,path:n,errorMaps:r,issueData:i}=e,s=[...n,...i.path||[]],o={...i,path:s};if(i.message!==void 0)return{...i,path:s,message:i.message};let a="";const l=r.filter(c=>!!c).slice().reverse();for(const c of l)a=c(o,{data:t,defaultError:a}).message;return{...i,path:s,message:a}};function re(e,t){const n=gO(),r=vO({issueData:t,data:e.data,path:e.path,errorMaps:[e.common.contextualErrorMap,e.schemaErrorMap,n,n===r0?void 0:r0].filter(i=>!!i)});e.common.issues.push(r)}class Pn{constructor(){this.value="valid"}dirty(){this.value==="valid"&&(this.value="dirty")}abort(){this.value!=="aborted"&&(this.value="aborted")}static mergeArray(t,n){const r=[];for(const i of n){if(i.status==="aborted")return Te;i.status==="dirty"&&t.dirty(),r.push(i.value)}return{status:t.value,value:r}}static async mergeObjectAsync(t,n){const r=[];for(const i of n){const s=await i.key,o=await i.value;r.push({key:s,value:o})}return Pn.mergeObjectSync(t,r)}static mergeObjectSync(t,n){const r={};for(const i of n){const{key:s,value:o}=i;if(s.status==="aborted"||o.status==="aborted")return Te;s.status==="dirty"&&t.dirty(),o.status==="dirty"&&t.dirty(),s.value!=="__proto__"&&(typeof o.value<"u"||i.alwaysSet)&&(r[s.value]=o.value)}return{status:t.value,value:r}}}const Te=Object.freeze({status:"aborted"}),Kl=e=>({status:"dirty",value:e}),wr=e=>({status:"valid",value:e}),uw=e=>e.status==="aborted",dw=e=>e.status==="dirty",za=e=>e.status==="valid",$h=e=>typeof Promise<"u"&&e instanceof Promise;var ge;(function(e){e.errToObj=t=>typeof t=="string"?{message:t}:t||{},e.toString=t=>typeof t=="string"?t:t==null?void 0:t.message})(ge||(ge={}));class ii{constructor(t,n,r,i){this._cachedPath=[],this.parent=t,this.data=n,this._path=r,this._key=i}get path(){return this._cachedPath.length||(Array.isArray(this._key)?this._cachedPath.push(...this._path,...this._key):this._cachedPath.push(...this._path,this._key)),this._cachedPath}}const hw=(e,t)=>{if(za(t))return{success:!0,data:t.value};if(!e.common.issues.length)throw new Error("Validation failed but no issues detected.");return{success:!1,get error(){if(this._error)return this._error;const n=new Ai(e.common.issues);return this._error=n,this._error}}};function Le(e){if(!e)return{};const{errorMap:t,invalid_type_error:n,required_error:r,description:i}=e;if(t&&(n||r))throw new Error(`Can't use "invalid_type_error" or "required_error" in conjunction with custom error map.`);return t?{errorMap:t,description:i}:{errorMap:(o,a)=>{const{message:l}=e;return o.code==="invalid_enum_value"?{message:l??a.defaultError}:typeof a.data>"u"?{message:l??r??a.defaultError}:o.code!=="invalid_type"?{message:a.defaultError}:{message:l??n??a.defaultError}},description:i}}class qe{get description(){return this._def.description}_getType(t){return ss(t.data)}_getOrReturnCtx(t,n){return n||{common:t.parent.common,data:t.data,parsedType:ss(t.data),schemaErrorMap:this._def.errorMap,path:t.path,parent:t.parent}}_processInputParams(t){return{status:new Pn,ctx:{common:t.parent.common,data:t.data,parsedType:ss(t.data),schemaErrorMap:this._def.errorMap,path:t.path,parent:t.parent}}}_parseSync(t){const n=this._parse(t);if($h(n))throw new Error("Synchronous parse encountered promise.");return n}_parseAsync(t){const n=this._parse(t);return Promise.resolve(n)}parse(t,n){const r=this.safeParse(t,n);if(r.success)return r.data;throw r.error}safeParse(t,n){const r={common:{issues:[],async:(n==null?void 0:n.async)??!1,contextualErrorMap:n==null?void 0:n.errorMap},path:(n==null?void 0:n.path)||[],schemaErrorMap:this._def.errorMap,parent:null,data:t,parsedType:ss(t)},i=this._parseSync({data:t,path:r.path,parent:r});return hw(r,i)}"~validate"(t){var r,i;const n={common:{issues:[],async:!!this["~standard"].async},path:[],schemaErrorMap:this._def.errorMap,parent:null,data:t,parsedType:ss(t)};if(!this["~standard"].async)try{const s=this._parseSync({data:t,path:[],parent:n});return za(s)?{value:s.value}:{issues:n.common.issues}}catch(s){(i=(r=s==null?void 0:s.message)==null?void 0:r.toLowerCase())!=null&&i.includes("encountered")&&(this["~standard"].async=!0),n.common={issues:[],async:!0}}return this._parseAsync({data:t,path:[],parent:n}).then(s=>za(s)?{value:s.value}:{issues:n.common.issues})}async parseAsync(t,n){const r=await this.safeParseAsync(t,n);if(r.success)return r.data;throw r.error}async safeParseAsync(t,n){const r={common:{issues:[],contextualErrorMap:n==null?void 0:n.errorMap,async:!0},path:(n==null?void 0:n.path)||[],schemaErrorMap:this._def.errorMap,parent:null,data:t,parsedType:ss(t)},i=this._parse({data:t,path:r.path,parent:r}),s=await($h(i)?i:Promise.resolve(i));return hw(r,s)}refine(t,n){const r=i=>typeof n=="string"||typeof n>"u"?{message:n}:typeof n=="function"?n(i):n;return this._refinement((i,s)=>{const o=t(i),a=()=>s.addIssue({code:Y.custom,...r(i)});return typeof Promise<"u"&&o instanceof Promise?o.then(l=>l?!0:(a(),!1)):o?!0:(a(),!1)})}refinement(t,n){return this._refinement((r,i)=>t(r)?!0:(i.addIssue(typeof n=="function"?n(r,i):n),!1))}_refinement(t){return new go({schema:this,typeName:Ne.ZodEffects,effect:{type:"refinement",refinement:t}})}superRefine(t){return this._refinement(t)}constructor(t){this.spa=this.safeParseAsync,this._def=t,this.parse=this.parse.bind(this),this.safeParse=this.safeParse.bind(this),this.parseAsync=this.parseAsync.bind(this),this.safeParseAsync=this.safeParseAsync.bind(this),this.spa=this.spa.bind(this),this.refine=this.refine.bind(this),this.refinement=this.refinement.bind(this),this.superRefine=this.superRefine.bind(this),this.optional=this.optional.bind(this),this.nullable=this.nullable.bind(this),this.nullish=this.nullish.bind(this),this.array=this.array.bind(this),this.promise=this.promise.bind(this),this.or=this.or.bind(this),this.and=this.and.bind(this),this.transform=this.transform.bind(this),this.brand=this.brand.bind(this),this.default=this.default.bind(this),this.catch=this.catch.bind(this),this.describe=this.describe.bind(this),this.pipe=this.pipe.bind(this),this.readonly=this.readonly.bind(this),this.isNullable=this.isNullable.bind(this),this.isOptional=this.isOptional.bind(this),this["~standard"]={version:1,vendor:"zod",validate:n=>this["~validate"](n)}}optional(){return Ti.create(this,this._def)}nullable(){return vo.create(this,this._def)}nullish(){return this.nullable().optional()}array(){return ei.create(this)}promise(){return qh.create(this,this._def)}or(t){return Hh.create([this,t],this._def)}and(t){return Uh.create(this,t,this._def)}transform(t){return new go({...Le(this._def),schema:this,typeName:Ne.ZodEffects,effect:{type:"transform",transform:t}})}default(t){const n=typeof t=="function"?t:()=>t;return new Kh({...Le(this._def),innerType:this,defaultValue:n,typeName:Ne.ZodDefault})}brand(){return new uN({typeName:Ne.ZodBranded,type:this,...Le(this._def)})}catch(t){const n=typeof t=="function"?t:()=>t;return new Gh({...Le(this._def),innerType:this,catchValue:n,typeName:Ne.ZodCatch})}describe(t){const n=this.constructor;return new n({...this._def,description:t})}pipe(t){return Ax.create(this,t)}readonly(){return Yh.create(this)}isOptional(){return this.safeParse(void 0).success}isNullable(){return this.safeParse(null).success}}const _O=/^c[^\s-]{8,}$/i,xO=/^[0-9a-z]+$/,yO=/^[0-9A-HJKMNP-TV-Z]{26}$/i,bO=/^[0-9a-fA-F]{8}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{12}$/i,wO=/^[a-z0-9_-]{21}$/i,SO=/^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$/,kO=/^[-+]?P(?!$)(?:(?:[-+]?\d+Y)|(?:[-+]?\d+[.,]\d+Y$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:(?:[-+]?\d+W)|(?:[-+]?\d+[.,]\d+W$))?(?:(?:[-+]?\d+D)|(?:[-+]?\d+[.,]\d+D$))?(?:T(?=[\d+-])(?:(?:[-+]?\d+H)|(?:[-+]?\d+[.,]\d+H$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:[-+]?\d+(?:[.,]\d+)?S)?)??$/,CO=/^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i,EO="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$";let Em;const TO=/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])$/,NO=/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\/(3[0-2]|[12]?[0-9])$/,PO=/^(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))$/,IO=/^(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/,RO=/^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,MO=/^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$/,aN="((\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-((0[13578]|1[02])-(0[1-9]|[12]\\d|3[01])|(0[469]|11)-(0[1-9]|[12]\\d|30)|(02)-(0[1-9]|1\\d|2[0-8])))",AO=new RegExp(`^${aN}$`);function lN(e){let t="[0-5]\\d";e.precision?t=`${t}\\.\\d{${e.precision}}`:e.precision==null&&(t=`${t}(\\.\\d+)?`);const n=e.precision?"+":"?";return`([01]\\d|2[0-3]):[0-5]\\d(:${t})${n}`}function LO(e){return new RegExp(`^${lN(e)}$`)}function jO(e){let t=`${aN}T${lN(e)}`;const n=[];return n.push(e.local?"Z?":"Z"),e.offset&&n.push("([+-]\\d{2}:?\\d{2})"),t=`${t}(${n.join("|")})`,new RegExp(`^${t}$`)}function DO(e,t){return!!((t==="v4"||!t)&&TO.test(e)||(t==="v6"||!t)&&PO.test(e))}function OO(e,t){if(!SO.test(e))return!1;try{const[n]=e.split(".");if(!n)return!1;const r=n.replace(/-/g,"+").replace(/_/g,"/").padEnd(n.length+(4-n.length%4)%4,"="),i=JSON.parse(atob(r));return!(typeof i!="object"||i===null||"typ"in i&&(i==null?void 0:i.typ)!=="JWT"||!i.alg||t&&i.alg!==t)}catch{return!1}}function BO(e,t){return!!((t==="v4"||!t)&&NO.test(e)||(t==="v6"||!t)&&IO.test(e))}class Si extends qe{_parse(t){if(this._def.coerce&&(t.data=String(t.data)),this._getType(t)!==ce.string){const s=this._getOrReturnCtx(t);return re(s,{code:Y.invalid_type,expected:ce.string,received:s.parsedType}),Te}const r=new Pn;let i;for(const s of this._def.checks)if(s.kind==="min")t.data.length<s.value&&(i=this._getOrReturnCtx(t,i),re(i,{code:Y.too_small,minimum:s.value,type:"string",inclusive:!0,exact:!1,message:s.message}),r.dirty());else if(s.kind==="max")t.data.length>s.value&&(i=this._getOrReturnCtx(t,i),re(i,{code:Y.too_big,maximum:s.value,type:"string",inclusive:!0,exact:!1,message:s.message}),r.dirty());else if(s.kind==="length"){const o=t.data.length>s.value,a=t.data.length<s.value;(o||a)&&(i=this._getOrReturnCtx(t,i),o?re(i,{code:Y.too_big,maximum:s.value,type:"string",inclusive:!0,exact:!0,message:s.message}):a&&re(i,{code:Y.too_small,minimum:s.value,type:"string",inclusive:!0,exact:!0,message:s.message}),r.dirty())}else if(s.kind==="email")CO.test(t.data)||(i=this._getOrReturnCtx(t,i),re(i,{validation:"email",code:Y.invalid_string,message:s.message}),r.dirty());else if(s.kind==="emoji")Em||(Em=new RegExp(EO,"u")),Em.test(t.data)||(i=this._getOrReturnCtx(t,i),re(i,{validation:"emoji",code:Y.invalid_string,message:s.message}),r.dirty());else if(s.kind==="uuid")bO.test(t.data)||(i=this._getOrReturnCtx(t,i),re(i,{validation:"uuid",code:Y.invalid_string,message:s.message}),r.dirty());else if(s.kind==="nanoid")wO.test(t.data)||(i=this._getOrReturnCtx(t,i),re(i,{validation:"nanoid",code:Y.invalid_string,message:s.message}),r.dirty());else if(s.kind==="cuid")_O.test(t.data)||(i=this._getOrReturnCtx(t,i),re(i,{validation:"cuid",code:Y.invalid_string,message:s.message}),r.dirty());else if(s.kind==="cuid2")xO.test(t.data)||(i=this._getOrReturnCtx(t,i),re(i,{validation:"cuid2",code:Y.invalid_string,message:s.message}),r.dirty());else if(s.kind==="ulid")yO.test(t.data)||(i=this._getOrReturnCtx(t,i),re(i,{validation:"ulid",code:Y.invalid_string,message:s.message}),r.dirty());else if(s.kind==="url")try{new URL(t.data)}catch{i=this._getOrReturnCtx(t,i),re(i,{validation:"url",code:Y.invalid_string,message:s.message}),r.dirty()}else s.kind==="regex"?(s.regex.lastIndex=0,s.regex.test(t.data)||(i=this._getOrReturnCtx(t,i),re(i,{validation:"regex",code:Y.invalid_string,message:s.message}),r.dirty())):s.kind==="trim"?t.data=t.data.trim():s.kind==="includes"?t.data.includes(s.value,s.position)||(i=this._getOrReturnCtx(t,i),re(i,{code:Y.invalid_string,validation:{includes:s.value,position:s.position},message:s.message}),r.dirty()):s.kind==="toLowerCase"?t.data=t.data.toLowerCase():s.kind==="toUpperCase"?t.data=t.data.toUpperCase():s.kind==="startsWith"?t.data.startsWith(s.value)||(i=this._getOrReturnCtx(t,i),re(i,{code:Y.invalid_string,validation:{startsWith:s.value},message:s.message}),r.dirty()):s.kind==="endsWith"?t.data.endsWith(s.value)||(i=this._getOrReturnCtx(t,i),re(i,{code:Y.invalid_string,validation:{endsWith:s.value},message:s.message}),r.dirty()):s.kind==="datetime"?jO(s).test(t.data)||(i=this._getOrReturnCtx(t,i),re(i,{code:Y.invalid_string,validation:"datetime",message:s.message}),r.dirty()):s.kind==="date"?AO.test(t.data)||(i=this._getOrReturnCtx(t,i),re(i,{code:Y.invalid_string,validation:"date",message:s.message}),r.dirty()):s.kind==="time"?LO(s).test(t.data)||(i=this._getOrReturnCtx(t,i),re(i,{code:Y.invalid_string,validation:"time",message:s.message}),r.dirty()):s.kind==="duration"?kO.test(t.data)||(i=this._getOrReturnCtx(t,i),re(i,{validation:"duration",code:Y.invalid_string,message:s.message}),r.dirty()):s.kind==="ip"?DO(t.data,s.version)||(i=this._getOrReturnCtx(t,i),re(i,{validation:"ip",code:Y.invalid_string,message:s.message}),r.dirty()):s.kind==="jwt"?OO(t.data,s.alg)||(i=this._getOrReturnCtx(t,i),re(i,{validation:"jwt",code:Y.invalid_string,message:s.message}),r.dirty()):s.kind==="cidr"?BO(t.data,s.version)||(i=this._getOrReturnCtx(t,i),re(i,{validation:"cidr",code:Y.invalid_string,message:s.message}),r.dirty()):s.kind==="base64"?RO.test(t.data)||(i=this._getOrReturnCtx(t,i),re(i,{validation:"base64",code:Y.invalid_string,message:s.message}),r.dirty()):s.kind==="base64url"?MO.test(t.data)||(i=this._getOrReturnCtx(t,i),re(i,{validation:"base64url",code:Y.invalid_string,message:s.message}),r.dirty()):Ye.assertNever(s);return{status:r.value,value:t.data}}_regex(t,n,r){return this.refinement(i=>t.test(i),{validation:n,code:Y.invalid_string,...ge.errToObj(r)})}_addCheck(t){return new Si({...this._def,checks:[...this._def.checks,t]})}email(t){return this._addCheck({kind:"email",...ge.errToObj(t)})}url(t){return this._addCheck({kind:"url",...ge.errToObj(t)})}emoji(t){return this._addCheck({kind:"emoji",...ge.errToObj(t)})}uuid(t){return this._addCheck({kind:"uuid",...ge.errToObj(t)})}nanoid(t){return this._addCheck({kind:"nanoid",...ge.errToObj(t)})}cuid(t){return this._addCheck({kind:"cuid",...ge.errToObj(t)})}cuid2(t){return this._addCheck({kind:"cuid2",...ge.errToObj(t)})}ulid(t){return this._addCheck({kind:"ulid",...ge.errToObj(t)})}base64(t){return this._addCheck({kind:"base64",...ge.errToObj(t)})}base64url(t){return this._addCheck({kind:"base64url",...ge.errToObj(t)})}jwt(t){return this._addCheck({kind:"jwt",...ge.errToObj(t)})}ip(t){return this._addCheck({kind:"ip",...ge.errToObj(t)})}cidr(t){return this._addCheck({kind:"cidr",...ge.errToObj(t)})}datetime(t){return typeof t=="string"?this._addCheck({kind:"datetime",precision:null,offset:!1,local:!1,message:t}):this._addCheck({kind:"datetime",precision:typeof(t==null?void 0:t.precision)>"u"?null:t==null?void 0:t.precision,offset:(t==null?void 0:t.offset)??!1,local:(t==null?void 0:t.local)??!1,...ge.errToObj(t==null?void 0:t.message)})}date(t){return this._addCheck({kind:"date",message:t})}time(t){return typeof t=="string"?this._addCheck({kind:"time",precision:null,message:t}):this._addCheck({kind:"time",precision:typeof(t==null?void 0:t.precision)>"u"?null:t==null?void 0:t.precision,...ge.errToObj(t==null?void 0:t.message)})}duration(t){return this._addCheck({kind:"duration",...ge.errToObj(t)})}regex(t,n){return this._addCheck({kind:"regex",regex:t,...ge.errToObj(n)})}includes(t,n){return this._addCheck({kind:"includes",value:t,position:n==null?void 0:n.position,...ge.errToObj(n==null?void 0:n.message)})}startsWith(t,n){return this._addCheck({kind:"startsWith",value:t,...ge.errToObj(n)})}endsWith(t,n){return this._addCheck({kind:"endsWith",value:t,...ge.errToObj(n)})}min(t,n){return this._addCheck({kind:"min",value:t,...ge.errToObj(n)})}max(t,n){return this._addCheck({kind:"max",value:t,...ge.errToObj(n)})}length(t,n){return this._addCheck({kind:"length",value:t,...ge.errToObj(n)})}nonempty(t){return this.min(1,ge.errToObj(t))}trim(){return new Si({...this._def,checks:[...this._def.checks,{kind:"trim"}]})}toLowerCase(){return new Si({...this._def,checks:[...this._def.checks,{kind:"toLowerCase"}]})}toUpperCase(){return new Si({...this._def,checks:[...this._def.checks,{kind:"toUpperCase"}]})}get isDatetime(){return!!this._def.checks.find(t=>t.kind==="datetime")}get isDate(){return!!this._def.checks.find(t=>t.kind==="date")}get isTime(){return!!this._def.checks.find(t=>t.kind==="time")}get isDuration(){return!!this._def.checks.find(t=>t.kind==="duration")}get isEmail(){return!!this._def.checks.find(t=>t.kind==="email")}get isURL(){return!!this._def.checks.find(t=>t.kind==="url")}get isEmoji(){return!!this._def.checks.find(t=>t.kind==="emoji")}get isUUID(){return!!this._def.checks.find(t=>t.kind==="uuid")}get isNANOID(){return!!this._def.checks.find(t=>t.kind==="nanoid")}get isCUID(){return!!this._def.checks.find(t=>t.kind==="cuid")}get isCUID2(){return!!this._def.checks.find(t=>t.kind==="cuid2")}get isULID(){return!!this._def.checks.find(t=>t.kind==="ulid")}get isIP(){return!!this._def.checks.find(t=>t.kind==="ip")}get isCIDR(){return!!this._def.checks.find(t=>t.kind==="cidr")}get isBase64(){return!!this._def.checks.find(t=>t.kind==="base64")}get isBase64url(){return!!this._def.checks.find(t=>t.kind==="base64url")}get minLength(){let t=null;for(const n of this._def.checks)n.kind==="min"&&(t===null||n.value>t)&&(t=n.value);return t}get maxLength(){let t=null;for(const n of this._def.checks)n.kind==="max"&&(t===null||n.value<t)&&(t=n.value);return t}}Si.create=e=>new Si({checks:[],typeName:Ne.ZodString,coerce:(e==null?void 0:e.coerce)??!1,...Le(e)});function zO(e,t){const n=(e.toString().split(".")[1]||"").length,r=(t.toString().split(".")[1]||"").length,i=n>r?n:r,s=Number.parseInt(e.toFixed(i).replace(".","")),o=Number.parseInt(t.toFixed(i).replace(".",""));return s%o/10**i}class $a extends qe{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte,this.step=this.multipleOf}_parse(t){if(this._def.coerce&&(t.data=Number(t.data)),this._getType(t)!==ce.number){const s=this._getOrReturnCtx(t);return re(s,{code:Y.invalid_type,expected:ce.number,received:s.parsedType}),Te}let r;const i=new Pn;for(const s of this._def.checks)s.kind==="int"?Ye.isInteger(t.data)||(r=this._getOrReturnCtx(t,r),re(r,{code:Y.invalid_type,expected:"integer",received:"float",message:s.message}),i.dirty()):s.kind==="min"?(s.inclusive?t.data<s.value:t.data<=s.value)&&(r=this._getOrReturnCtx(t,r),re(r,{code:Y.too_small,minimum:s.value,type:"number",inclusive:s.inclusive,exact:!1,message:s.message}),i.dirty()):s.kind==="max"?(s.inclusive?t.data>s.value:t.data>=s.value)&&(r=this._getOrReturnCtx(t,r),re(r,{code:Y.too_big,maximum:s.value,type:"number",inclusive:s.inclusive,exact:!1,message:s.message}),i.dirty()):s.kind==="multipleOf"?zO(t.data,s.value)!==0&&(r=this._getOrReturnCtx(t,r),re(r,{code:Y.not_multiple_of,multipleOf:s.value,message:s.message}),i.dirty()):s.kind==="finite"?Number.isFinite(t.data)||(r=this._getOrReturnCtx(t,r),re(r,{code:Y.not_finite,message:s.message}),i.dirty()):Ye.assertNever(s);return{status:i.value,value:t.data}}gte(t,n){return this.setLimit("min",t,!0,ge.toString(n))}gt(t,n){return this.setLimit("min",t,!1,ge.toString(n))}lte(t,n){return this.setLimit("max",t,!0,ge.toString(n))}lt(t,n){return this.setLimit("max",t,!1,ge.toString(n))}setLimit(t,n,r,i){return new $a({...this._def,checks:[...this._def.checks,{kind:t,value:n,inclusive:r,message:ge.toString(i)}]})}_addCheck(t){return new $a({...this._def,checks:[...this._def.checks,t]})}int(t){return this._addCheck({kind:"int",message:ge.toString(t)})}positive(t){return this._addCheck({kind:"min",value:0,inclusive:!1,message:ge.toString(t)})}negative(t){return this._addCheck({kind:"max",value:0,inclusive:!1,message:ge.toString(t)})}nonpositive(t){return this._addCheck({kind:"max",value:0,inclusive:!0,message:ge.toString(t)})}nonnegative(t){return this._addCheck({kind:"min",value:0,inclusive:!0,message:ge.toString(t)})}multipleOf(t,n){return this._addCheck({kind:"multipleOf",value:t,message:ge.toString(n)})}finite(t){return this._addCheck({kind:"finite",message:ge.toString(t)})}safe(t){return this._addCheck({kind:"min",inclusive:!0,value:Number.MIN_SAFE_INTEGER,message:ge.toString(t)})._addCheck({kind:"max",inclusive:!0,value:Number.MAX_SAFE_INTEGER,message:ge.toString(t)})}get minValue(){let t=null;for(const n of this._def.checks)n.kind==="min"&&(t===null||n.value>t)&&(t=n.value);return t}get maxValue(){let t=null;for(const n of this._def.checks)n.kind==="max"&&(t===null||n.value<t)&&(t=n.value);return t}get isInt(){return!!this._def.checks.find(t=>t.kind==="int"||t.kind==="multipleOf"&&Ye.isInteger(t.value))}get isFinite(){let t=null,n=null;for(const r of this._def.checks){if(r.kind==="finite"||r.kind==="int"||r.kind==="multipleOf")return!0;r.kind==="min"?(n===null||r.value>n)&&(n=r.value):r.kind==="max"&&(t===null||r.value<t)&&(t=r.value)}return Number.isFinite(n)&&Number.isFinite(t)}}$a.create=e=>new $a({checks:[],typeName:Ne.ZodNumber,coerce:(e==null?void 0:e.coerce)||!1,...Le(e)});class Uc extends qe{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte}_parse(t){if(this._def.coerce)try{t.data=BigInt(t.data)}catch{return this._getInvalidInput(t)}if(this._getType(t)!==ce.bigint)return this._getInvalidInput(t);let r;const i=new Pn;for(const s of this._def.checks)s.kind==="min"?(s.inclusive?t.data<s.value:t.data<=s.value)&&(r=this._getOrReturnCtx(t,r),re(r,{code:Y.too_small,type:"bigint",minimum:s.value,inclusive:s.inclusive,message:s.message}),i.dirty()):s.kind==="max"?(s.inclusive?t.data>s.value:t.data>=s.value)&&(r=this._getOrReturnCtx(t,r),re(r,{code:Y.too_big,type:"bigint",maximum:s.value,inclusive:s.inclusive,message:s.message}),i.dirty()):s.kind==="multipleOf"?t.data%s.value!==BigInt(0)&&(r=this._getOrReturnCtx(t,r),re(r,{code:Y.not_multiple_of,multipleOf:s.value,message:s.message}),i.dirty()):Ye.assertNever(s);return{status:i.value,value:t.data}}_getInvalidInput(t){const n=this._getOrReturnCtx(t);return re(n,{code:Y.invalid_type,expected:ce.bigint,received:n.parsedType}),Te}gte(t,n){return this.setLimit("min",t,!0,ge.toString(n))}gt(t,n){return this.setLimit("min",t,!1,ge.toString(n))}lte(t,n){return this.setLimit("max",t,!0,ge.toString(n))}lt(t,n){return this.setLimit("max",t,!1,ge.toString(n))}setLimit(t,n,r,i){return new Uc({...this._def,checks:[...this._def.checks,{kind:t,value:n,inclusive:r,message:ge.toString(i)}]})}_addCheck(t){return new Uc({...this._def,checks:[...this._def.checks,t]})}positive(t){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!1,message:ge.toString(t)})}negative(t){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!1,message:ge.toString(t)})}nonpositive(t){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!0,message:ge.toString(t)})}nonnegative(t){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!0,message:ge.toString(t)})}multipleOf(t,n){return this._addCheck({kind:"multipleOf",value:t,message:ge.toString(n)})}get minValue(){let t=null;for(const n of this._def.checks)n.kind==="min"&&(t===null||n.value>t)&&(t=n.value);return t}get maxValue(){let t=null;for(const n of this._def.checks)n.kind==="max"&&(t===null||n.value<t)&&(t=n.value);return t}}Uc.create=e=>new Uc({checks:[],typeName:Ne.ZodBigInt,coerce:(e==null?void 0:e.coerce)??!1,...Le(e)});class i0 extends qe{_parse(t){if(this._def.coerce&&(t.data=!!t.data),this._getType(t)!==ce.boolean){const r=this._getOrReturnCtx(t);return re(r,{code:Y.invalid_type,expected:ce.boolean,received:r.parsedType}),Te}return wr(t.data)}}i0.create=e=>new i0({typeName:Ne.ZodBoolean,coerce:(e==null?void 0:e.coerce)||!1,...Le(e)});class Fh extends qe{_parse(t){if(this._def.coerce&&(t.data=new Date(t.data)),this._getType(t)!==ce.date){const s=this._getOrReturnCtx(t);return re(s,{code:Y.invalid_type,expected:ce.date,received:s.parsedType}),Te}if(Number.isNaN(t.data.getTime())){const s=this._getOrReturnCtx(t);return re(s,{code:Y.invalid_date}),Te}const r=new Pn;let i;for(const s of this._def.checks)s.kind==="min"?t.data.getTime()<s.value&&(i=this._getOrReturnCtx(t,i),re(i,{code:Y.too_small,message:s.message,inclusive:!0,exact:!1,minimum:s.value,type:"date"}),r.dirty()):s.kind==="max"?t.data.getTime()>s.value&&(i=this._getOrReturnCtx(t,i),re(i,{code:Y.too_big,message:s.message,inclusive:!0,exact:!1,maximum:s.value,type:"date"}),r.dirty()):Ye.assertNever(s);return{status:r.value,value:new Date(t.data.getTime())}}_addCheck(t){return new Fh({...this._def,checks:[...this._def.checks,t]})}min(t,n){return this._addCheck({kind:"min",value:t.getTime(),message:ge.toString(n)})}max(t,n){return this._addCheck({kind:"max",value:t.getTime(),message:ge.toString(n)})}get minDate(){let t=null;for(const n of this._def.checks)n.kind==="min"&&(t===null||n.value>t)&&(t=n.value);return t!=null?new Date(t):null}get maxDate(){let t=null;for(const n of this._def.checks)n.kind==="max"&&(t===null||n.value<t)&&(t=n.value);return t!=null?new Date(t):null}}Fh.create=e=>new Fh({checks:[],coerce:(e==null?void 0:e.coerce)||!1,typeName:Ne.ZodDate,...Le(e)});class fw extends qe{_parse(t){if(this._getType(t)!==ce.symbol){const r=this._getOrReturnCtx(t);return re(r,{code:Y.invalid_type,expected:ce.symbol,received:r.parsedType}),Te}return wr(t.data)}}fw.create=e=>new fw({typeName:Ne.ZodSymbol,...Le(e)});class s0 extends qe{_parse(t){if(this._getType(t)!==ce.undefined){const r=this._getOrReturnCtx(t);return re(r,{code:Y.invalid_type,expected:ce.undefined,received:r.parsedType}),Te}return wr(t.data)}}s0.create=e=>new s0({typeName:Ne.ZodUndefined,...Le(e)});class o0 extends qe{_parse(t){if(this._getType(t)!==ce.null){const r=this._getOrReturnCtx(t);return re(r,{code:Y.invalid_type,expected:ce.null,received:r.parsedType}),Te}return wr(t.data)}}o0.create=e=>new o0({typeName:Ne.ZodNull,...Le(e)});class pw extends qe{constructor(){super(...arguments),this._any=!0}_parse(t){return wr(t.data)}}pw.create=e=>new pw({typeName:Ne.ZodAny,...Le(e)});class a0 extends qe{constructor(){super(...arguments),this._unknown=!0}_parse(t){return wr(t.data)}}a0.create=e=>new a0({typeName:Ne.ZodUnknown,...Le(e)});class Ts extends qe{_parse(t){const n=this._getOrReturnCtx(t);return re(n,{code:Y.invalid_type,expected:ce.never,received:n.parsedType}),Te}}Ts.create=e=>new Ts({typeName:Ne.ZodNever,...Le(e)});class mw extends qe{_parse(t){if(this._getType(t)!==ce.undefined){const r=this._getOrReturnCtx(t);return re(r,{code:Y.invalid_type,expected:ce.void,received:r.parsedType}),Te}return wr(t.data)}}mw.create=e=>new mw({typeName:Ne.ZodVoid,...Le(e)});class ei extends qe{_parse(t){const{ctx:n,status:r}=this._processInputParams(t),i=this._def;if(n.parsedType!==ce.array)return re(n,{code:Y.invalid_type,expected:ce.array,received:n.parsedType}),Te;if(i.exactLength!==null){const o=n.data.length>i.exactLength.value,a=n.data.length<i.exactLength.value;(o||a)&&(re(n,{code:o?Y.too_big:Y.too_small,minimum:a?i.exactLength.value:void 0,maximum:o?i.exactLength.value:void 0,type:"array",inclusive:!0,exact:!0,message:i.exactLength.message}),r.dirty())}if(i.minLength!==null&&n.data.length<i.minLength.value&&(re(n,{code:Y.too_small,minimum:i.minLength.value,type:"array",inclusive:!0,exact:!1,message:i.minLength.message}),r.dirty()),i.maxLength!==null&&n.data.length>i.maxLength.value&&(re(n,{code:Y.too_big,maximum:i.maxLength.value,type:"array",inclusive:!0,exact:!1,message:i.maxLength.message}),r.dirty()),n.common.async)return Promise.all([...n.data].map((o,a)=>i.type._parseAsync(new ii(n,o,n.path,a)))).then(o=>Pn.mergeArray(r,o));const s=[...n.data].map((o,a)=>i.type._parseSync(new ii(n,o,n.path,a)));return Pn.mergeArray(r,s)}get element(){return this._def.type}min(t,n){return new ei({...this._def,minLength:{value:t,message:ge.toString(n)}})}max(t,n){return new ei({...this._def,maxLength:{value:t,message:ge.toString(n)}})}length(t,n){return new ei({...this._def,exactLength:{value:t,message:ge.toString(n)}})}nonempty(t){return this.min(1,t)}}ei.create=(e,t)=>new ei({type:e,minLength:null,maxLength:null,exactLength:null,typeName:Ne.ZodArray,...Le(t)});function Jo(e){if(e instanceof jt){const t={};for(const n in e.shape){const r=e.shape[n];t[n]=Ti.create(Jo(r))}return new jt({...e._def,shape:()=>t})}else return e instanceof ei?new ei({...e._def,type:Jo(e.element)}):e instanceof Ti?Ti.create(Jo(e.unwrap())):e instanceof vo?vo.create(Jo(e.unwrap())):e instanceof po?po.create(e.items.map(t=>Jo(t))):e}class jt extends qe{constructor(){super(...arguments),this._cached=null,this.nonstrict=this.passthrough,this.augment=this.extend}_getCached(){if(this._cached!==null)return this._cached;const t=this._def.shape(),n=Ye.objectKeys(t);return this._cached={shape:t,keys:n},this._cached}_parse(t){if(this._getType(t)!==ce.object){const c=this._getOrReturnCtx(t);return re(c,{code:Y.invalid_type,expected:ce.object,received:c.parsedType}),Te}const{status:r,ctx:i}=this._processInputParams(t),{shape:s,keys:o}=this._getCached(),a=[];if(!(this._def.catchall instanceof Ts&&this._def.unknownKeys==="strip"))for(const c in i.data)o.includes(c)||a.push(c);const l=[];for(const c of o){const u=s[c],d=i.data[c];l.push({key:{status:"valid",value:c},value:u._parse(new ii(i,d,i.path,c)),alwaysSet:c in i.data})}if(this._def.catchall instanceof Ts){const c=this._def.unknownKeys;if(c==="passthrough")for(const u of a)l.push({key:{status:"valid",value:u},value:{status:"valid",value:i.data[u]}});else if(c==="strict")a.length>0&&(re(i,{code:Y.unrecognized_keys,keys:a}),r.dirty());else if(c!=="strip")throw new Error("Internal ZodObject error: invalid unknownKeys value.")}else{const c=this._def.catchall;for(const u of a){const d=i.data[u];l.push({key:{status:"valid",value:u},value:c._parse(new ii(i,d,i.path,u)),alwaysSet:u in i.data})}}return i.common.async?Promise.resolve().then(async()=>{const c=[];for(const u of l){const d=await u.key,f=await u.value;c.push({key:d,value:f,alwaysSet:u.alwaysSet})}return c}).then(c=>Pn.mergeObjectSync(r,c)):Pn.mergeObjectSync(r,l)}get shape(){return this._def.shape()}strict(t){return ge.errToObj,new jt({...this._def,unknownKeys:"strict",...t!==void 0?{errorMap:(n,r)=>{var s,o;const i=((o=(s=this._def).errorMap)==null?void 0:o.call(s,n,r).message)??r.defaultError;return n.code==="unrecognized_keys"?{message:ge.errToObj(t).message??i}:{message:i}}}:{}})}strip(){return new jt({...this._def,unknownKeys:"strip"})}passthrough(){return new jt({...this._def,unknownKeys:"passthrough"})}extend(t){return new jt({...this._def,shape:()=>({...this._def.shape(),...t})})}merge(t){return new jt({unknownKeys:t._def.unknownKeys,catchall:t._def.catchall,shape:()=>({...this._def.shape(),...t._def.shape()}),typeName:Ne.ZodObject})}setKey(t,n){return this.augment({[t]:n})}catchall(t){return new jt({...this._def,catchall:t})}pick(t){const n={};for(const r of Ye.objectKeys(t))t[r]&&this.shape[r]&&(n[r]=this.shape[r]);return new jt({...this._def,shape:()=>n})}omit(t){const n={};for(const r of Ye.objectKeys(this.shape))t[r]||(n[r]=this.shape[r]);return new jt({...this._def,shape:()=>n})}deepPartial(){return Jo(this)}partial(t){const n={};for(const r of Ye.objectKeys(this.shape)){const i=this.shape[r];t&&!t[r]?n[r]=i:n[r]=i.optional()}return new jt({...this._def,shape:()=>n})}required(t){const n={};for(const r of Ye.objectKeys(this.shape))if(t&&!t[r])n[r]=this.shape[r];else{let s=this.shape[r];for(;s instanceof Ti;)s=s._def.innerType;n[r]=s}return new jt({...this._def,shape:()=>n})}keyof(){return cN(Ye.objectKeys(this.shape))}}jt.create=(e,t)=>new jt({shape:()=>e,unknownKeys:"strip",catchall:Ts.create(),typeName:Ne.ZodObject,...Le(t)});jt.strictCreate=(e,t)=>new jt({shape:()=>e,unknownKeys:"strict",catchall:Ts.create(),typeName:Ne.ZodObject,...Le(t)});jt.lazycreate=(e,t)=>new jt({shape:e,unknownKeys:"strip",catchall:Ts.create(),typeName:Ne.ZodObject,...Le(t)});class Hh extends qe{_parse(t){const{ctx:n}=this._processInputParams(t),r=this._def.options;function i(s){for(const a of s)if(a.result.status==="valid")return a.result;for(const a of s)if(a.result.status==="dirty")return n.common.issues.push(...a.ctx.common.issues),a.result;const o=s.map(a=>new Ai(a.ctx.common.issues));return re(n,{code:Y.invalid_union,unionErrors:o}),Te}if(n.common.async)return Promise.all(r.map(async s=>{const o={...n,common:{...n.common,issues:[]},parent:null};return{result:await s._parseAsync({data:n.data,path:n.path,parent:o}),ctx:o}})).then(i);{let s;const o=[];for(const l of r){const c={...n,common:{...n.common,issues:[]},parent:null},u=l._parseSync({data:n.data,path:n.path,parent:c});if(u.status==="valid")return u;u.status==="dirty"&&!s&&(s={result:u,ctx:c}),c.common.issues.length&&o.push(c.common.issues)}if(s)return n.common.issues.push(...s.ctx.common.issues),s.result;const a=o.map(l=>new Ai(l));return re(n,{code:Y.invalid_union,unionErrors:a}),Te}}get options(){return this._def.options}}Hh.create=(e,t)=>new Hh({options:e,typeName:Ne.ZodUnion,...Le(t)});const vi=e=>e instanceof c0?vi(e.schema):e instanceof go?vi(e.innerType()):e instanceof Vh?[e.value]:e instanceof mo?e.options:e instanceof u0?Ye.objectValues(e.enum):e instanceof Kh?vi(e._def.innerType):e instanceof s0?[void 0]:e instanceof o0?[null]:e instanceof Ti?[void 0,...vi(e.unwrap())]:e instanceof vo?[null,...vi(e.unwrap())]:e instanceof uN||e instanceof Yh?vi(e.unwrap()):e instanceof Gh?vi(e._def.innerType):[];class Mx extends qe{_parse(t){const{ctx:n}=this._processInputParams(t);if(n.parsedType!==ce.object)return re(n,{code:Y.invalid_type,expected:ce.object,received:n.parsedType}),Te;const r=this.discriminator,i=n.data[r],s=this.optionsMap.get(i);return s?n.common.async?s._parseAsync({data:n.data,path:n.path,parent:n}):s._parseSync({data:n.data,path:n.path,parent:n}):(re(n,{code:Y.invalid_union_discriminator,options:Array.from(this.optionsMap.keys()),path:[r]}),Te)}get discriminator(){return this._def.discriminator}get options(){return this._def.options}get optionsMap(){return this._def.optionsMap}static create(t,n,r){const i=new Map;for(const s of n){const o=vi(s.shape[t]);if(!o.length)throw new Error(`A discriminator value for key \`${t}\` could not be extracted from all schema options`);for(const a of o){if(i.has(a))throw new Error(`Discriminator property ${String(t)} has duplicate value ${String(a)}`);i.set(a,s)}}return new Mx({typeName:Ne.ZodDiscriminatedUnion,discriminator:t,options:n,optionsMap:i,...Le(r)})}}function l0(e,t){const n=ss(e),r=ss(t);if(e===t)return{valid:!0,data:e};if(n===ce.object&&r===ce.object){const i=Ye.objectKeys(t),s=Ye.objectKeys(e).filter(a=>i.indexOf(a)!==-1),o={...e,...t};for(const a of s){const l=l0(e[a],t[a]);if(!l.valid)return{valid:!1};o[a]=l.data}return{valid:!0,data:o}}else if(n===ce.array&&r===ce.array){if(e.length!==t.length)return{valid:!1};const i=[];for(let s=0;s<e.length;s++){const o=e[s],a=t[s],l=l0(o,a);if(!l.valid)return{valid:!1};i.push(l.data)}return{valid:!0,data:i}}else return n===ce.date&&r===ce.date&&+e==+t?{valid:!0,data:e}:{valid:!1}}class Uh extends qe{_parse(t){const{status:n,ctx:r}=this._processInputParams(t),i=(s,o)=>{if(uw(s)||uw(o))return Te;const a=l0(s.value,o.value);return a.valid?((dw(s)||dw(o))&&n.dirty(),{status:n.value,value:a.data}):(re(r,{code:Y.invalid_intersection_types}),Te)};return r.common.async?Promise.all([this._def.left._parseAsync({data:r.data,path:r.path,parent:r}),this._def.right._parseAsync({data:r.data,path:r.path,parent:r})]).then(([s,o])=>i(s,o)):i(this._def.left._parseSync({data:r.data,path:r.path,parent:r}),this._def.right._parseSync({data:r.data,path:r.path,parent:r}))}}Uh.create=(e,t,n)=>new Uh({left:e,right:t,typeName:Ne.ZodIntersection,...Le(n)});class po extends qe{_parse(t){const{status:n,ctx:r}=this._processInputParams(t);if(r.parsedType!==ce.array)return re(r,{code:Y.invalid_type,expected:ce.array,received:r.parsedType}),Te;if(r.data.length<this._def.items.length)return re(r,{code:Y.too_small,minimum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),Te;!this._def.rest&&r.data.length>this._def.items.length&&(re(r,{code:Y.too_big,maximum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),n.dirty());const s=[...r.data].map((o,a)=>{const l=this._def.items[a]||this._def.rest;return l?l._parse(new ii(r,o,r.path,a)):null}).filter(o=>!!o);return r.common.async?Promise.all(s).then(o=>Pn.mergeArray(n,o)):Pn.mergeArray(n,s)}get items(){return this._def.items}rest(t){return new po({...this._def,rest:t})}}po.create=(e,t)=>{if(!Array.isArray(e))throw new Error("You must pass an array of schemas to z.tuple([ ... ])");return new po({items:e,typeName:Ne.ZodTuple,rest:null,...Le(t)})};class Wh extends qe{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(t){const{status:n,ctx:r}=this._processInputParams(t);if(r.parsedType!==ce.object)return re(r,{code:Y.invalid_type,expected:ce.object,received:r.parsedType}),Te;const i=[],s=this._def.keyType,o=this._def.valueType;for(const a in r.data)i.push({key:s._parse(new ii(r,a,r.path,a)),value:o._parse(new ii(r,r.data[a],r.path,a)),alwaysSet:a in r.data});return r.common.async?Pn.mergeObjectAsync(n,i):Pn.mergeObjectSync(n,i)}get element(){return this._def.valueType}static create(t,n,r){return n instanceof qe?new Wh({keyType:t,valueType:n,typeName:Ne.ZodRecord,...Le(r)}):new Wh({keyType:Si.create(),valueType:t,typeName:Ne.ZodRecord,...Le(n)})}}class gw extends qe{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(t){const{status:n,ctx:r}=this._processInputParams(t);if(r.parsedType!==ce.map)return re(r,{code:Y.invalid_type,expected:ce.map,received:r.parsedType}),Te;const i=this._def.keyType,s=this._def.valueType,o=[...r.data.entries()].map(([a,l],c)=>({key:i._parse(new ii(r,a,r.path,[c,"key"])),value:s._parse(new ii(r,l,r.path,[c,"value"]))}));if(r.common.async){const a=new Map;return Promise.resolve().then(async()=>{for(const l of o){const c=await l.key,u=await l.value;if(c.status==="aborted"||u.status==="aborted")return Te;(c.status==="dirty"||u.status==="dirty")&&n.dirty(),a.set(c.value,u.value)}return{status:n.value,value:a}})}else{const a=new Map;for(const l of o){const c=l.key,u=l.value;if(c.status==="aborted"||u.status==="aborted")return Te;(c.status==="dirty"||u.status==="dirty")&&n.dirty(),a.set(c.value,u.value)}return{status:n.value,value:a}}}}gw.create=(e,t,n)=>new gw({valueType:t,keyType:e,typeName:Ne.ZodMap,...Le(n)});class Wc extends qe{_parse(t){const{status:n,ctx:r}=this._processInputParams(t);if(r.parsedType!==ce.set)return re(r,{code:Y.invalid_type,expected:ce.set,received:r.parsedType}),Te;const i=this._def;i.minSize!==null&&r.data.size<i.minSize.value&&(re(r,{code:Y.too_small,minimum:i.minSize.value,type:"set",inclusive:!0,exact:!1,message:i.minSize.message}),n.dirty()),i.maxSize!==null&&r.data.size>i.maxSize.value&&(re(r,{code:Y.too_big,maximum:i.maxSize.value,type:"set",inclusive:!0,exact:!1,message:i.maxSize.message}),n.dirty());const s=this._def.valueType;function o(l){const c=new Set;for(const u of l){if(u.status==="aborted")return Te;u.status==="dirty"&&n.dirty(),c.add(u.value)}return{status:n.value,value:c}}const a=[...r.data.values()].map((l,c)=>s._parse(new ii(r,l,r.path,c)));return r.common.async?Promise.all(a).then(l=>o(l)):o(a)}min(t,n){return new Wc({...this._def,minSize:{value:t,message:ge.toString(n)}})}max(t,n){return new Wc({...this._def,maxSize:{value:t,message:ge.toString(n)}})}size(t,n){return this.min(t,n).max(t,n)}nonempty(t){return this.min(1,t)}}Wc.create=(e,t)=>new Wc({valueType:e,minSize:null,maxSize:null,typeName:Ne.ZodSet,...Le(t)});class c0 extends qe{get schema(){return this._def.getter()}_parse(t){const{ctx:n}=this._processInputParams(t);return this._def.getter()._parse({data:n.data,path:n.path,parent:n})}}c0.create=(e,t)=>new c0({getter:e,typeName:Ne.ZodLazy,...Le(t)});class Vh extends qe{_parse(t){if(t.data!==this._def.value){const n=this._getOrReturnCtx(t);return re(n,{received:n.data,code:Y.invalid_literal,expected:this._def.value}),Te}return{status:"valid",value:t.data}}get value(){return this._def.value}}Vh.create=(e,t)=>new Vh({value:e,typeName:Ne.ZodLiteral,...Le(t)});function cN(e,t){return new mo({values:e,typeName:Ne.ZodEnum,...Le(t)})}class mo extends qe{_parse(t){if(typeof t.data!="string"){const n=this._getOrReturnCtx(t),r=this._def.values;return re(n,{expected:Ye.joinValues(r),received:n.parsedType,code:Y.invalid_type}),Te}if(this._cache||(this._cache=new Set(this._def.values)),!this._cache.has(t.data)){const n=this._getOrReturnCtx(t),r=this._def.values;return re(n,{received:n.data,code:Y.invalid_enum_value,options:r}),Te}return wr(t.data)}get options(){return this._def.values}get enum(){const t={};for(const n of this._def.values)t[n]=n;return t}get Values(){const t={};for(const n of this._def.values)t[n]=n;return t}get Enum(){const t={};for(const n of this._def.values)t[n]=n;return t}extract(t,n=this._def){return mo.create(t,{...this._def,...n})}exclude(t,n=this._def){return mo.create(this.options.filter(r=>!t.includes(r)),{...this._def,...n})}}mo.create=cN;class u0 extends qe{_parse(t){const n=Ye.getValidEnumValues(this._def.values),r=this._getOrReturnCtx(t);if(r.parsedType!==ce.string&&r.parsedType!==ce.number){const i=Ye.objectValues(n);return re(r,{expected:Ye.joinValues(i),received:r.parsedType,code:Y.invalid_type}),Te}if(this._cache||(this._cache=new Set(Ye.getValidEnumValues(this._def.values))),!this._cache.has(t.data)){const i=Ye.objectValues(n);return re(r,{received:r.data,code:Y.invalid_enum_value,options:i}),Te}return wr(t.data)}get enum(){return this._def.values}}u0.create=(e,t)=>new u0({values:e,typeName:Ne.ZodNativeEnum,...Le(t)});class qh extends qe{unwrap(){return this._def.type}_parse(t){const{ctx:n}=this._processInputParams(t);if(n.parsedType!==ce.promise&&n.common.async===!1)return re(n,{code:Y.invalid_type,expected:ce.promise,received:n.parsedType}),Te;const r=n.parsedType===ce.promise?n.data:Promise.resolve(n.data);return wr(r.then(i=>this._def.type.parseAsync(i,{path:n.path,errorMap:n.common.contextualErrorMap})))}}qh.create=(e,t)=>new qh({type:e,typeName:Ne.ZodPromise,...Le(t)});class go extends qe{innerType(){return this._def.schema}sourceType(){return this._def.schema._def.typeName===Ne.ZodEffects?this._def.schema.sourceType():this._def.schema}_parse(t){const{status:n,ctx:r}=this._processInputParams(t),i=this._def.effect||null,s={addIssue:o=>{re(r,o),o.fatal?n.abort():n.dirty()},get path(){return r.path}};if(s.addIssue=s.addIssue.bind(s),i.type==="preprocess"){const o=i.transform(r.data,s);if(r.common.async)return Promise.resolve(o).then(async a=>{if(n.value==="aborted")return Te;const l=await this._def.schema._parseAsync({data:a,path:r.path,parent:r});return l.status==="aborted"?Te:l.status==="dirty"||n.value==="dirty"?Kl(l.value):l});{if(n.value==="aborted")return Te;const a=this._def.schema._parseSync({data:o,path:r.path,parent:r});return a.status==="aborted"?Te:a.status==="dirty"||n.value==="dirty"?Kl(a.value):a}}if(i.type==="refinement"){const o=a=>{const l=i.refinement(a,s);if(r.common.async)return Promise.resolve(l);if(l instanceof Promise)throw new Error("Async refinement encountered during synchronous parse operation. Use .parseAsync instead.");return a};if(r.common.async===!1){const a=this._def.schema._parseSync({data:r.data,path:r.path,parent:r});return a.status==="aborted"?Te:(a.status==="dirty"&&n.dirty(),o(a.value),{status:n.value,value:a.value})}else return this._def.schema._parseAsync({data:r.data,path:r.path,parent:r}).then(a=>a.status==="aborted"?Te:(a.status==="dirty"&&n.dirty(),o(a.value).then(()=>({status:n.value,value:a.value}))))}if(i.type==="transform")if(r.common.async===!1){const o=this._def.schema._parseSync({data:r.data,path:r.path,parent:r});if(!za(o))return Te;const a=i.transform(o.value,s);if(a instanceof Promise)throw new Error("Asynchronous transform encountered during synchronous parse operation. Use .parseAsync instead.");return{status:n.value,value:a}}else return this._def.schema._parseAsync({data:r.data,path:r.path,parent:r}).then(o=>za(o)?Promise.resolve(i.transform(o.value,s)).then(a=>({status:n.value,value:a})):Te);Ye.assertNever(i)}}go.create=(e,t,n)=>new go({schema:e,typeName:Ne.ZodEffects,effect:t,...Le(n)});go.createWithPreprocess=(e,t,n)=>new go({schema:t,effect:{type:"preprocess",transform:e},typeName:Ne.ZodEffects,...Le(n)});class Ti extends qe{_parse(t){return this._getType(t)===ce.undefined?wr(void 0):this._def.innerType._parse(t)}unwrap(){return this._def.innerType}}Ti.create=(e,t)=>new Ti({innerType:e,typeName:Ne.ZodOptional,...Le(t)});class vo extends qe{_parse(t){return this._getType(t)===ce.null?wr(null):this._def.innerType._parse(t)}unwrap(){return this._def.innerType}}vo.create=(e,t)=>new vo({innerType:e,typeName:Ne.ZodNullable,...Le(t)});class Kh extends qe{_parse(t){const{ctx:n}=this._processInputParams(t);let r=n.data;return n.parsedType===ce.undefined&&(r=this._def.defaultValue()),this._def.innerType._parse({data:r,path:n.path,parent:n})}removeDefault(){return this._def.innerType}}Kh.create=(e,t)=>new Kh({innerType:e,typeName:Ne.ZodDefault,defaultValue:typeof t.default=="function"?t.default:()=>t.default,...Le(t)});class Gh extends qe{_parse(t){const{ctx:n}=this._processInputParams(t),r={...n,common:{...n.common,issues:[]}},i=this._def.innerType._parse({data:r.data,path:r.path,parent:{...r}});return $h(i)?i.then(s=>({status:"valid",value:s.status==="valid"?s.value:this._def.catchValue({get error(){return new Ai(r.common.issues)},input:r.data})})):{status:"valid",value:i.status==="valid"?i.value:this._def.catchValue({get error(){return new Ai(r.common.issues)},input:r.data})}}removeCatch(){return this._def.innerType}}Gh.create=(e,t)=>new Gh({innerType:e,typeName:Ne.ZodCatch,catchValue:typeof t.catch=="function"?t.catch:()=>t.catch,...Le(t)});class vw extends qe{_parse(t){if(this._getType(t)!==ce.nan){const r=this._getOrReturnCtx(t);return re(r,{code:Y.invalid_type,expected:ce.nan,received:r.parsedType}),Te}return{status:"valid",value:t.data}}}vw.create=e=>new vw({typeName:Ne.ZodNaN,...Le(e)});class uN extends qe{_parse(t){const{ctx:n}=this._processInputParams(t),r=n.data;return this._def.type._parse({data:r,path:n.path,parent:n})}unwrap(){return this._def.type}}class Ax extends qe{_parse(t){const{status:n,ctx:r}=this._processInputParams(t);if(r.common.async)return(async()=>{const s=await this._def.in._parseAsync({data:r.data,path:r.path,parent:r});return s.status==="aborted"?Te:s.status==="dirty"?(n.dirty(),Kl(s.value)):this._def.out._parseAsync({data:s.value,path:r.path,parent:r})})();{const i=this._def.in._parseSync({data:r.data,path:r.path,parent:r});return i.status==="aborted"?Te:i.status==="dirty"?(n.dirty(),{status:"dirty",value:i.value}):this._def.out._parseSync({data:i.value,path:r.path,parent:r})}}static create(t,n){return new Ax({in:t,out:n,typeName:Ne.ZodPipeline})}}class Yh extends qe{_parse(t){const n=this._def.innerType._parse(t),r=i=>(za(i)&&(i.value=Object.freeze(i.value)),i);return $h(n)?n.then(i=>r(i)):r(n)}unwrap(){return this._def.innerType}}Yh.create=(e,t)=>new Yh({innerType:e,typeName:Ne.ZodReadonly,...Le(t)});var Ne;(function(e){e.ZodString="ZodString",e.ZodNumber="ZodNumber",e.ZodNaN="ZodNaN",e.ZodBigInt="ZodBigInt",e.ZodBoolean="ZodBoolean",e.ZodDate="ZodDate",e.ZodSymbol="ZodSymbol",e.ZodUndefined="ZodUndefined",e.ZodNull="ZodNull",e.ZodAny="ZodAny",e.ZodUnknown="ZodUnknown",e.ZodNever="ZodNever",e.ZodVoid="ZodVoid",e.ZodArray="ZodArray",e.ZodObject="ZodObject",e.ZodUnion="ZodUnion",e.ZodDiscriminatedUnion="ZodDiscriminatedUnion",e.ZodIntersection="ZodIntersection",e.ZodTuple="ZodTuple",e.ZodRecord="ZodRecord",e.ZodMap="ZodMap",e.ZodSet="ZodSet",e.ZodFunction="ZodFunction",e.ZodLazy="ZodLazy",e.ZodLiteral="ZodLiteral",e.ZodEnum="ZodEnum",e.ZodEffects="ZodEffects",e.ZodNativeEnum="ZodNativeEnum",e.ZodOptional="ZodOptional",e.ZodNullable="ZodNullable",e.ZodDefault="ZodDefault",e.ZodCatch="ZodCatch",e.ZodPromise="ZodPromise",e.ZodBranded="ZodBranded",e.ZodPipeline="ZodPipeline",e.ZodReadonly="ZodReadonly"})(Ne||(Ne={}));const S=Si.create,K=$a.create,Se=i0.create,oo=a0.create;Ts.create;const xe=ei.create,M=jt.create;Hh.create;const li=Mx.create;Uh.create;po.create;const sl=Wh.create,J=Vh.create,We=mo.create;qh.create;Ti.create;vo.create;new Set("ABCDEFGHIJKLMNOPQRSTUVXYZabcdefghijklmnopqrstuvxyz0123456789");const $O=["owner"],FO=["agent","owner","user-upload"],dN=M({id:S().min(1),relPath:S().min(1),from:We(FO),label:S().optional(),size:K().int().nonnegative(),mime:S().min(1),addedAt:K().int().nonnegative(),lastEditedAt:K().int().nonnegative().optional(),stale:Se().optional()});M({sessionId:S().min(1),relPath:S().min(1),ttlSeconds:K().int().positive().nullable().optional(),view:We(["raw","md-rendered"]).optional()});M({url:S().min(1),expiresAt:K().int().nonnegative().nullable()});M({sessionId:S().min(1),relPath:S().min(1),label:S().optional(),origin:J("agent").optional()});M({entry:dN});M({sessionId:S().min(1),relPath:S().min(1)});M({removed:J(!0)});M({sessionId:S().min(1)});M({entries:xe(dN)});M({attachmentId:S().min(1),url:S().min(1),relPath:S().min(1),sizeBytes:K().int().nonnegative(),mimeType:S().min(1)});const HO=li("type",[M({type:J("persona"),id:S().min(1)}).strict(),M({type:J("chat"),id:S().min(1)}).strict(),M({type:J("*")}).strict()]),UO=We(["read","send","admin"]),Lx=M({resource:HO,actions:xe(UO).min(1)}).strict(),WO=M({id:S().min(1),secretHash:S().regex(/^[a-f0-9]{64}$/),displayName:S(),grants:xe(Lx),issuedAt:K().int().nonnegative(),expiresAt:K().int().positive().optional(),maxUses:K().int().positive().optional(),usedCount:K().int().nonnegative(),peerOwnerId:S().min(1).optional(),firstUsedByPeerAt:K().int().positive().optional(),peerDisplayName:S().optional()}).strict(),VO=WO.omit({secretHash:!0});M({type:J("whoami:ok"),owner:M({id:S(),kind:We(["owner","guest"]),displayName:S(),ownerId:S(),provider:S()}).strict(),capability:VO,grantedPersonas:xe(M({id:S().min(1),displayName:S()}).strict())}).strict();M({selfUrl:S().min(1)});M({type:J("contact:handshake:ok"),owner:M({id:S(),ownerId:S(),provider:S(),displayName:S()}),grants:xe(Lx)});M({deviceId:S().min(1),remoteAccessAllowed:Se()}).strict();M({type:J("contact:setRemoteAccess:ok"),deviceId:S().min(1),remoteAccessAllowed:Se()}).strict();M({type:J("contact:remote-access-updated"),deviceId:S().min(1),remoteAccessAllowed:Se()}).strict();const qO=M({deviceId:S().min(1),ownerId:S().min(1),provider:S().min(1),displayName:S(),remoteUrl:S().min(1),connectToken:S(),grants:xe(Lx),addedAt:K().int().nonnegative(),pinnedAt:K().int().nullable().default(null),remoteAccessAllowed:Se().default(!1)}).strict(),hN=qO;M({deviceId:S().min(1)}).strict();M({type:J("contact:remove:ok"),deviceId:S().min(1)}).strict();M({type:J("contact:list:ok"),contacts:xe(hN)}).strict();M({type:J("contact:added"),contact:hN}).strict();M({type:J("contact:removed"),deviceId:S().min(1)}).strict();M({deviceId:S().min(1),pinned:Se()}).strict();M({type:J("contact:pin:ok"),deviceId:S().min(1),pinnedAt:K().int().nullable()}).strict();M({type:J("contact:pinned"),deviceId:S().min(1),pinnedAt:K().int().nullable()}).strict();const KO=M({deviceId:S().min(1),name:S().min(1),url:S().min(1)});M({type:J("device:list:ok"),devices:xe(KO)});M({deviceId:S().min(1),url:S().min(1).optional(),name:S().optional()});M({type:J("device:connect:ok"),deviceId:S(),name:S(),url:S()});const fN=M({ownerId:S().min(1),provider:S().min(1),displayName:S().min(1),avatarUrl:S().optional(),unionId:S().optional()});M({type:J("auth:login:start:ok"),authUrl:S().min(1),state:S().min(1)});M({type:J("auth:getIdentity:ok"),identity:fN.nullable(),deviceId:S().min(1),ttcTokenExpiresAt:K().nullable().optional()});M({type:J("auth:logout:ok")});M({type:J("auth:login:done"),identity:fN});M({type:J("auth:login:failed"),reason:S()});const jx=li("kind",[M({kind:J("success"),text:S(),filePaths:xe(S()).optional()}),M({kind:J("failure"),reason:S()})]);M({targetPersona:S().min(1).optional(),dispatchId:S().min(1).optional(),prompt:S(),targetDeviceId:S().min(1).optional(),model:S().min(1).optional(),sessionLabel:S().min(1).max(60).optional()}).refine(e=>e.targetPersona!==void 0||e.dispatchId!==void 0,{message:"either targetPersona (new dispatch) or dispatchId (follow-up) is required"}).refine(e=>!(e.dispatchId!==void 0&&e.targetDeviceId!==void 0),{message:"cross-device dispatch cannot be continued (dispatchId + targetDeviceId are mutually exclusive)"});M({dispatchId:S().min(1),outcome:jx});const GO=["running","completed","failed"],pN=We(GO),YO=M({dispatchId:S().min(1),sourceSessionId:S().min(1),sourcePersonaId:S().min(1).optional(),targetPersonaId:S().min(1),workerSessionId:S().min(1).optional(),taskText:S(),status:pN,outcome:jx.optional(),meta:sl(oo()).optional(),createdAt:S().min(1),completedAt:S().min(1).optional(),deliveredAt:S().min(1).optional()});M({sourceSessionId:S().min(1).optional()});M({records:xe(YO)});M({dispatchId:S().min(1)});M({type:J("personaDispatch:get:ok"),status:pN,outcome:jx.optional()});const XO=/^[a-z0-9][a-z0-9-]*$/;We(["stopped","starting","running","crashed","invalid"]);const QO=new Set(["localhost","127.0.0.1"]);function ZO(e){let t;try{t=new URL(e)}catch{return!1}return!!(t.protocol==="https:"||t.protocol==="http:"&&QO.has(t.hostname))}const ld=M({id:S().regex(XO),name:S().min(1),version:S().min(1),apiVersion:J("1"),runtime:M({startCommand:S().min(1)}).passthrough().optional(),entry:M({url:S().url().refine(ZO,{message:"INVALID_URL_SCHEME: only https or http://localhost is allowed"})}).strict().optional()}).passthrough().superRefine((e,t)=>{var i;const n=!!e.runtime,r=!!((i=e.entry)!=null&&i.url);n&&r&&t.addIssue({code:Y.custom,message:"INVALID_MANIFEST: entry.url and runtime cannot coexist"}),!n&&!r&&t.addIssue({code:Y.custom,message:"INVALID_MANIFEST: must have either entry.url or runtime"})}),JO=li("kind",[M({kind:J("local"),port:K().int().min(1).max(65535)}),M({kind:J("hosted"),url:S().url()})]);li("state",[M({extId:S(),manifest:ld,state:J("stopped")}),M({extId:S(),manifest:ld,state:J("starting")}),M({extId:S(),manifest:ld,state:J("running"),target:JO}),M({extId:S(),manifest:ld,state:J("crashed")}),M({extId:S(),manifest:oo().nullable(),state:J("invalid"),invalidReason:S().min(1)})]);M({snapshotHash:S().min(1),version:S().min(1),publishedAt:K()});const e6=li("kind",[M({kind:J("p2p-tunnel"),ownerPrincipalId:S().min(1),extId:S().min(1)})]);li("kind",[M({kind:J("p2p-tunnel"),ownerPrincipalId:S().min(1),extId:S().min(1),snapshotHash:S().min(1)})]);M({extId:S().min(1),name:S().min(1),version:S().min(1),contentHash:S().min(1),publishedAt:K()});const t6=li("kind",[M({kind:J("clean")}),M({kind:J("ready-new-version"),fromVersion:S().min(1),toVersion:S().min(1)}),M({kind:J("error-same-hash"),version:S().min(1)}),M({kind:J("error-version-not-bumped"),localVersion:S().min(1),publishedVersion:S().min(1)}),M({kind:J("error-version-regression"),localVersion:S().min(1),publishedVersion:S().min(1)})]);M({localManifest:M({name:S().min(1),version:S().min(1),contentHash:S().min(1)}),publishState:li("kind",[M({kind:J("unpublished")}),M({kind:J("published"),version:S().min(1),contentHash:S().min(1),publishedAt:K()})]),check:t6});M({extId:S().min(1),newVersion:S().min(1).nullish()});M({extId:S().min(1)});M({extId:S().min(1),snapshotHash:S().min(1)});M({channelRef:e6,snapshotHash:S().min(1),zipBase64:S().min(1)});M({id:S().min(1),peerDeviceId:S().min(1),senderDeviceId:S().min(1),text:S().min(1),createdAt:K().int().nonnegative(),readBy:sl(S().min(1),K().int().positive()).default({}),origin:M({kind:J("persona"),personaId:S().min(1)}).optional()}).strict();M({peerDeviceId:S().min(1).optional(),id:S().min(1),text:S().min(1),createdAt:K().int().nonnegative(),origin:M({kind:J("persona"),personaId:S().min(1)}).optional()}).strict();M({peerDeviceId:S().min(1),sinceCreatedAt:K().int().nonnegative().optional()}).strict();M({peerDeviceId:S().min(1),upToCreatedAt:K().int().nonnegative()}).strict();M({peerDeviceId:S().min(1).optional(),text:S().min(1)});M({peerDeviceId:S().min(1).optional(),command:S().min(1),timeoutMs:K().int().positive().optional()}).strict();M({type:J("peerExec:run:ok"),stdout:S(),stderr:S(),exitCode:K().int().nullable(),timedOut:Se(),stdoutTruncated:Se(),stderrTruncated:Se()}).strict();const mN=li("kind",[M({kind:J("at"),at:S().min(1)}),M({kind:J("every"),everyMs:K().int().positive(),anchorMs:K().int().nonnegative().optional()}),M({kind:J("cron"),expr:S().min(1),tz:S().min(1).optional()})]),pu=S().trim().min(1);M({personaId:pu,name:S().min(1),schedule:mN,prompt:S().min(1),targetPersona:S().min(1).optional(),timeoutMs:K().int().positive().optional()});M({personaId:pu,onlyMine:Se().optional()});M({personaId:pu,shiftId:S().min(1)});const n6=M({name:S().min(1).optional(),schedule:mN.optional(),prompt:S().min(1).optional(),targetPersona:S().min(1).optional(),timeoutMs:K().int().positive().optional(),enabled:Se().optional()});M({personaId:pu,shiftId:S().min(1),patch:n6});M({personaId:pu,shiftId:S().min(1),limit:K().int().positive().optional()});const r6=["created","review-requested"],gN=/^[A-Za-z0-9._-]+$/,ol=S().min(1).regex(gN),al=S().min(1).regex(gN),mu=K().int().positive();M({role:We(r6)});M({owner:ol,repo:al,number:mu});M({owner:ol,repo:al,number:mu,expectedHeadSha:S().min(1)});M({owner:ol,repo:al,number:mu,body:S().min(1)});M({owner:ol,repo:al,number:mu,ready:Se()});M({owner:ol,repo:al});M({owner:ol,repo:al,number:mu,reviewers:xe(S().min(1)).min(1)});M({personaId:S().min(1)});const i6=["expired","cancelled","access_denied","lark_protocol_error","cloud_unreachable","internal_error"],s6=We(i6);M({personaId:S().min(1),appId:S().min(1),appSecret:S().min(1),botName:S().min(1).optional()});const o6=M({chatId:S().min(1),chatName:S().optional(),lastActiveAt:K().int().optional()}),a6=M({state:We(["unbound","provisioning","bound","broken"]),appId:S().optional(),botName:S().optional(),brokenReason:S().optional(),qrUrl:S().optional(),errorReason:s6.optional(),groups:xe(o6)});a6.extend({personaId:S().min(1)});M({});M({onboardingCompletedAt:K()});M({});M({tools:xe(M({id:We(["claude","codex"]),available:Se(),version:S().optional(),path:S().optional()}))});M({});const l6=M({tool:We(["claude","codex"]),cwd:S(),toolSessionId:S(),label:S().optional(),createdAt:S(),updatedAt:S(),turns:K()});M({candidates:xe(l6)});M({});M({registered:Se()});const c6=M({personaId:S(),label:S(),model:S().optional(),effort:S().optional(),public:Se(),iconKey:S().optional(),tool:S().optional(),createdAt:K(),updatedAt:K()}).strict(),u6=M({name:S().min(1),description:S().optional()}),d6=M({id:S().min(1)}),h6=M({permissions:M({defaultMode:S().optional(),allow:xe(S()).optional(),deny:xe(S()).optional()}).optional(),sandbox:M({enabled:Se().optional(),autoAllowBashIfSandboxed:Se().optional(),allowUnsandboxedCommands:Se().optional(),excludedCommands:xe(S()).optional(),filesystem:M({denyRead:xe(S()).optional(),allowRead:xe(S()).optional(),denyWrite:xe(S()).optional(),allowWrite:xe(S()).optional()}).optional(),network:M({allowedDomains:xe(S()).optional(),allowLocalBinding:Se().optional()}).optional()}).optional()});c6.extend({personality:S().optional(),skills:xe(u6).optional(),plugins:xe(d6).optional(),sandboxSettings:h6.nullable().optional()});M({slug:S().regex(/^[a-z0-9]+(-[a-z0-9]+)*$/).max(32),label:S().min(1),personality:S(),model:S().optional(),effort:S().optional(),tool:S().optional(),public:Se().optional(),iconKey:S().optional()}).strict();M({personaId:S().min(1)});M({personaId:S().min(1),patch:M({label:S().min(1).optional(),model:S().optional(),effort:S().optional(),tool:S().optional(),personality:S().optional(),public:Se().optional(),iconKey:S().nullable().optional()}).strict()}).strict();M({writableRoots:xe(S()).optional(),denyRead:xe(S()).optional(),network:Se().optional()}).strict();const vN=["ready","session:info","session:status","session:event","session:deleted","session:rewound","session:cleared","permission:request","session:question","session:question:cleared","pong","error","subscribed","unsubscribed","auth:ok","tunnel:ready","tunnel:exited","tunnel:unavailable","session:control","session:pty","contact:added","contact:pinned","contact:removed","contact:remote-access-updated","inbox:event","friend:reverseTokenOffered","auth:login:done","auth:login:failed","appBuilder:project-updated","appBuilder:publish-progress","appBuilder:publish-failed","larkBot:state"],_N=["idle","running","running-idle","stopped","error","observing"],f6=["task-notification","slash-command","local-command","system-reminder","skill-hint","meta-text","attachment-skills","attachment-deferred-tools"],p6=["builtin","global","project","plugin"],m6=["builtin","global","project","policy","plugin"],xN=We(["owner","guest"]);M({id:S().min(1),kind:xN,displayName:S(),feishuUnionId:S().optional()}).strict();const g6=M({did:S().min(1),displayName:S(),feishuUnionId:S().optional(),principal:xN}).strict(),v6=We(_N),_6=M({input_tokens:K().int().nonnegative().optional(),cache_read_input_tokens:K().int().nonnegative().optional(),cache_creation_input_tokens:K().int().nonnegative().optional(),output_tokens:K().int().nonnegative().optional()}),x6=M({inputTokens:K().int().nonnegative(),outputTokens:K().int().nonnegative(),cacheReadTokens:K().int().nonnegative().optional(),cacheCreateTokens:K().int().nonnegative().optional()}),yN={gitBranch:S().optional(),resolvedModel:S().optional(),resolvedEffort:S().optional(),contextUsage:x6.optional(),contextWindowSize:K().int().positive().optional(),aiLabel:S().optional()},y6=M(yN),bN=M({value:S(),label:S(),description:S().optional()}),b6=M({id:S().min(1),label:S().min(1),description:S().optional(),contextWindowSize:K().int().positive(),default:Se().optional(),efforts:xe(bN).optional(),defaultEffort:S().optional()}),w6=M({id:S().min(1),label:S().min(1),description:S().optional()}),S6=M({name:S().min(1),type:We(["string","select","toggle"]),label:S().min(1),description:S().optional(),options:xe(bN).optional(),default:oo().optional(),scope:We(["core","tool-specific"])});M({tool:S().min(1)});const k6=M({rewind:Se(),subagents:Se(),tui:Se(),observe:Se(),fileSharing:Se(),fork:Se()});M({tool:S().min(1),toolSessionIdLabel:S().optional(),models:xe(b6),permissionModes:xe(w6),configSchema:xe(S6),features:k6});const C6=M({tool:S().min(1),pattern:S().min(1),createdAt:S().min(1).optional()});M({sessionId:S().min(1),cwd:S().min(1),tool:J("claude").or(S().min(1)).default("claude"),toolSessionId:S().optional(),label:S().optional(),model:S().optional(),permissionMode:S().optional(),effort:S().optional(),...yN,aiLabelGeneratedAt:S().optional(),permissionRules:xe(C6).optional(),pinnedAt:K().int().nonnegative().nullable().optional(),archivedAt:K().int().nonnegative().nullable().optional(),pinSortOrder:K().int().nullable().optional(),unreadAt:S().min(1).nullable().optional(),iconKey:S().optional(),forkedFromSessionId:S().min(1).optional(),ephemeral:Se().optional(),ownerPersonaId:S().min(1).optional(),projectPath:S().min(1).optional(),appBuilderProject:S().regex(/^[a-z][a-z0-9-]{0,39}$/).optional(),chatId:S().min(1).optional(),creatorPrincipalId:S().min(1).optional(),creatorDisplayName:S().min(1).optional(),creatorFeishuUnionId:S().min(1).optional(),originOwnerPrincipalId:S().min(1).optional(),originOwnerPersonaId:S().min(1).optional(),dispatchedFromSessionId:S().min(1).optional(),shiftFiredFromSessionId:S().min(1).optional(),larkChatId:S().min(1).optional(),larkChatName:S().min(1).optional(),larkChatType:We(["p2p","group"]).optional(),createdAt:S().min(1),updatedAt:S().min(1)});const jn={seq:K().int().nonnegative().optional(),ts:S().optional(),uuid:S().optional()},E6=We(f6),T6=M({readCount:K().int().nonnegative().optional(),searchCount:K().int().nonnegative().optional(),bashCount:K().int().nonnegative().optional(),editFileCount:K().int().nonnegative().optional(),linesAdded:K().int().nonnegative().optional(),linesRemoved:K().int().nonnegative().optional(),otherToolCount:K().int().nonnegative().optional()}),N6=M({oldStart:K().int().nonnegative(),oldLines:K().int().nonnegative(),newStart:K().int().nonnegative(),newLines:K().int().nonnegative(),lines:xe(S())}),P6=M({agentId:S().optional(),agentType:S().optional(),status:S().optional(),prompt:S().optional(),filePath:S().optional(),structuredPatch:xe(N6).optional(),stats:M({durationMs:K().int().nonnegative().optional(),tokens:K().int().nonnegative().optional(),toolUseCount:K().int().nonnegative().optional(),toolStats:T6.optional(),usage:_6.optional()}).optional()}),I6=M({path:S(),content:S(),mtimeMs:K().optional()}),R6=M({label:S().min(1),description:S().optional()}),wN=M({question:S().min(1),multiSelect:Se(),options:xe(R6).min(1)}),M6=["completed","interrupted"];li("kind",[M({...jn,kind:J("session_init"),toolSessionId:S().optional()}),M({...jn,kind:J("thinking"),text:S(),partialId:S().optional()}),M({...jn,kind:J("text"),text:S(),partialId:S().optional()}),M({...jn,kind:J("user_text"),text:S(),meta:E6.optional(),taskId:S().optional(),parentToolUseId:S().optional(),sender:g6.optional()}),M({...jn,kind:J("tool_call"),toolUseId:S(),tool:S(),toolKind:S().optional(),input:oo()}),M({...jn,kind:J("tool_result"),toolUseId:S(),output:oo().optional(),error:S().optional(),toolResultExtra:P6.optional(),sourceToolAssistantUUID:S().optional(),askQuestionAnswers:sl(S(),S()).optional()}),M({...jn,kind:J("attachment_memories"),memories:xe(I6)}),M({...jn,kind:J("permission_request"),requestId:S(),tool:S(),input:oo(),toolUseId:S().optional()}),M({...jn,kind:J("ask_user_question"),toolUseId:S(),questions:xe(wN)}),M({...jn,kind:J("turn_end"),durationMs:K().int().nonnegative().optional(),reason:We(M6).optional()}),M({...jn,kind:J("subagent_progress"),toolUseId:S(),agentId:S(),status:We(["started","running","completed","failed"]),description:S().optional(),lastToolName:S().optional(),prompt:S().optional(),stats:M({durationMs:K().int().nonnegative().optional(),tokens:K().int().nonnegative().optional(),toolUseCount:K().int().nonnegative().optional()}).optional()}),M({...jn,kind:J("error"),message:S()}),M({...jn,kind:J("meta_update"),patch:y6}),M({...jn,kind:J("meta-text"),text:S(),metaSource:We(["cc","owner"]).optional()})]);M({cwd:S().min(1).optional(),tool:S().optional(),label:S().optional(),aiLabel:S().optional(),model:S().optional(),permissionMode:S().optional(),effort:S().optional(),iconKey:S().optional(),forkedFromSessionId:S().min(1).optional(),ephemeral:Se().optional(),ownerPersonaId:S().min(1).optional(),projectPath:S().min(1).optional()}).refine(e=>e.cwd!=null||e.ownerPersonaId!=null||e.projectPath!=null,{message:"cwd / ownerPersonaId / projectPath 至少传一个"});M({path:S().min(1),name:S().min(1),createdAt:S().datetime()});M({path:S().min(1).optional(),name:S().min(1).optional()}).refine(e=>e.path!=null||e.name!=null,{message:"path 与 name 至少给一个"});M({cwd:S().min(1),tool:S().min(1),toolSessionId:S().min(1),label:S().optional(),aiLabel:S().optional(),iconKey:S().optional(),createdAt:S().datetime(),updatedAt:S().datetime(),ownerPersonaId:S().min(1).optional()});M({originOnly:Se().optional(),ownerPersonaId:S().min(1).optional(),limit:K().int().positive().optional(),offset:K().int().nonnegative().optional()});M({sessionId:S().min(1)});M({sessionId:S().min(1),patch:M({label:S().optional(),model:S().optional(),permissionMode:S().optional(),effort:S().optional(),cwd:S().optional(),iconKey:S().optional(),ephemeral:J(!1).optional()})});M({sessionId:S().min(1),text:S()});M({sessionId:S().min(1),userMessageId:S().min(1),dryRun:Se().optional()});M({canRewind:Se(),error:S().optional(),filesChanged:xe(S()).optional(),insertions:K().int().nonnegative().optional(),deletions:K().int().nonnegative().optional()});M({sessionId:S().min(1),userMessageId:S().min(1)});const A6=M({oldStart:K().int().nonnegative(),oldLines:K().int().nonnegative(),newStart:K().int().nonnegative(),newLines:K().int().nonnegative(),lines:xe(S())}),L6=M({filePath:S().min(1),hunks:xe(A6),insertions:K().int().nonnegative(),deletions:K().int().nonnegative(),status:We(["modified","added","deleted"]).optional()});M({canRewind:Se(),error:S().optional(),files:xe(L6),totalInsertions:K().int().nonnegative(),totalDeletions:K().int().nonnegative()});M({userMessageIds:xe(S())});M({sessionId:S().min(1),toolSessionId:S().min(1)});M({cwd:S().min(1),toolSessionId:S().min(1),messageUuid:S().min(1),targetCwd:S().min(1).optional()});M({forkedToolSessionId:S().min(1),forkedFilePath:S().min(1)});M({sessionId:S().min(1),toolSessionId:S().min(1),jsonlPath:S().optional()});M({sessionId:S().min(1),afterSeq:K().int().min(-1)});M({sessionId:S().min(1),permissionRequestId:S().min(1),allow:Se(),permanent:Se().optional(),pattern:S().optional()});M({projectPath:S().min(1)});M({sessionId:S().min(1),limit:K().int().positive().max(5e3).optional(),offset:K().int().nonnegative().optional(),slim:Se().optional()});M({cwd:S().min(1),toolSessionId:S().min(1)});M({cwd:S().min(1),toolSessionId:S().min(1),subagentId:S().min(1)});M({cwd:S().min(1).optional(),path:S().optional(),showHidden:Se().optional()});M({cwd:S().min(1),path:S().min(1)});M({cwd:S().min(1),tool:S().optional()});M({name:S().min(1),source:We(p6),path:S().optional(),description:S().optional(),plugin:S().optional()});const j6=M({name:S().min(1),source:We(m6),path:S().optional(),description:S().optional(),whenToUse:S().optional(),plugin:S().optional()});M({cwd:S().min(1),tool:S().optional()});M({agents:xe(j6)});M({sessionId:S().optional()});M({sessionId:S().min(1).optional()});M({sessionId:S().min(1),pinned:Se()});M({sessionId:S().min(1),archived:Se()});M({type:J("peerSession:upsert:ok")});M({sessionId:S().min(1)});M({type:J("peerSession:remove:ok")});M({orderedIds:xe(S().min(1)).min(1)});M({cwd:S().min(1)});M({isGitRoot:Se(),gitRoot:S().nullable()});M({cwd:S().min(1)});M({branch:S().nullable()});M({cwd:S().min(1)});M({branches:xe(S()),head:S().nullable()});M({}).optional();const D6=M({cwd:S().min(1),updatedAt:S().min(1)});M({dirs:xe(D6)});M({type:J("session:question"),sessionId:S().min(1),toolUseId:S().min(1),requestId:S().min(1),questions:xe(wN).min(1)});M({type:J("session:question:cleared"),sessionId:S().min(1),toolUseId:S().min(1),answers:sl(S(),S()).optional()});M({sessionId:S().min(1),toolUseId:S().min(1),answers:sl(S(),S())});M({ok:J(!0)});M({sessionId:S().min(1),toolUseId:S().min(1)});M({ok:J(!0)});const SN=M({name:S().min(1),version:S().min(1),instanceId:S().min(1),deviceLabel:S().transform(e=>e.trim().slice(0,64)).optional()});M({type:J("auth"),token:S().min(1),scheme:J("bearer").optional(),clientInfo:SN.optional()});M({type:J("auth:ok"),version:S().min(1).optional(),protocolVersion:K().int().nonnegative().optional()});const O6=M({clientId:S().min(1),connectedAt:K().int().nonnegative(),self:Se(),clientInfo:SN.optional()});M({type:J("device:connections:ok"),connections:xe(O6)});M({type:J("tunnel:ready"),url:S().min(1),subdomain:S().min(1)});M({type:J("tunnel:exited"),code:K().int().nullable(),subdomain:S().nullable(),url:S().nullable()});M({type:J("tunnel:unavailable"),reason:S().min(1),failedAt:S().min(1)});const B6=M({sessionId:S().min(1),status:v6,freshSpawn:Se(),pendingPermissionRequestIds:xe(S().min(1)),pendingQuestionToolUseIds:xe(S().min(1))});M({type:J("info"),version:S(),protocolVersion:K(),hostname:S(),os:S(),tools:xe(M({id:S(),available:Se()})),runningSessions:xe(B6),tokenRole:We($O).optional(),isLoopback:Se().optional(),httpBaseUrl:S().optional(),httpToken:S().optional(),daemonSource:We(["ota","packaged"]).optional(),globalCliVersion:S().nullable().optional()});const z6=6173,$6=6272,ll=/^[a-z][a-z0-9-]{0,39}$/,gu=M({name:S().regex(ll,{message:"kebab-case, 小写字母开头,只允许小写字母 / 数字 / -,最长 40 字符"}),port:K().int().min(z6).max($6),createdAt:S().datetime(),devCommand:S().min(1),prodUrl:S().url().optional(),readyPattern:S().optional(),publishJob:M({jobId:S().min(1),stage:We(["build","deploy","verify"]),startedAt:K().int().nonnegative()}).optional()}),F6=["install-pending","installing","starting-dev-server","running","stopped","failed"],kN=We(F6),Dx=gu.extend({isRunning:Se(),boundSessionId:S().nullable(),stage:kN.optional(),stageReason:S().optional(),publishJob:M({jobId:S().min(1),stage:We(["build","deploy","verify"]),startedAt:K().int().nonnegative(),status:We(["in-flight","interrupted"])}).optional()});M({}).strict();M({projects:xe(Dx)}).strict();M({sessionId:S().min(1)}).strict();M({project:Dx.nullable()}).strict();M({sessionId:S().min(1),name:S().min(1)}).strict();M({project:gu}).strict();M({name:S()}).strict();M({}).strict();M({name:S(),newPort:K().int()}).strict();M({project:gu}).strict();M({name:S().regex(ll),url:S().url()}).strict();M({project:gu}).strict();M({sessionId:S().min(1),force:Se().optional()}).strict();M({project:gu}).strict();const H6=["installing","failed"];M({sessionId:S().min(1),stage:We(H6),reason:S().optional()}).strict();M({ok:J(!0)}).strict();M({sessionId:S().min(1)}).strict();M({ok:J(!0)}).strict();M({type:J("appBuilder:project-updated"),project:Dx,stage:kN,stageReason:S().optional()}).strict();M({name:S().regex(ll)});M({jobId:S().min(1),status:We(["started","already-publishing"])}).strict();M({name:S().regex(ll)});M({ok:J(!0)}).strict();M({type:J("appBuilder:publish-progress"),name:S().regex(ll),jobId:S().min(1),stage:We(["build","deploy","verify"]),status:We(["started","completed"])}).strict();M({type:J("appBuilder:publish-failed"),name:S().regex(ll),jobId:S().min(1),stage:We(["build","deploy","verify","unknown"]),errorSummary:S()}).strict();M({});M({method:S().min(1).optional()});const U6=["allowed","conditional","denied"],W6=We(U6),V6=M({name:S().min(1),status:W6,description:S().min(1),args:xe(M({name:S(),required:Se()})).nullable(),argsSchema:sl(oo()).optional(),reason:S().optional()});M({type:J("meta:methods"),methods:xe(V6)});const _w=1,q6=["daemon","main","renderer"],K6=We(q6),G6=["debug","info","warn","error"],Y6=We(G6);M({ts:K().int(),source:K6,level:Y6,msg:S(),ownerPrincipalId:S(),deviceId:S(),appVersion:S(),daemonVersion:S().optional(),os:S(),meta_json:S().optional(),sessionId:S().optional()});M({v:J(1),visitorId:S().min(1),displayName:S(),provider:S(),iat:K(),exp:K()});const X6=M({visitorId:S(),displayName:S(),avatarUrl:S().optional(),provider:S(),firstSeen:K(),lastSeen:K()});M({visitors:xe(X6)});const Q6=/<system-reminder>此消息来自飞书群成员 (.+?)<\/system-reminder>\s*$/,Z6=new Set(["localhost","127.0.0.1","0.0.0.0","::1"]);let pi=null;function J6(){if(pi!==null)return pi;if(typeof window>"u")return pi=!1,!1;if(Z6.has(window.location.hostname)||window.location.protocol==="file:")return pi=!0,!0;if(new URLSearchParams(window.location.search).get("debug")==="1"){pi=!0;try{sessionStorage.setItem("debug","1")}catch{}}else try{pi=sessionStorage.getItem("debug")==="1"}catch{pi=!1}return pi}function Ae(e,...t){J6()&&console.log(`[${e}][${new Date().toISOString()}]`,...t)}function cd(e){if(!e)return"<none>";let t=0;for(let n=0;n<e.length;n++)t=(t<<5)-t+e.charCodeAt(n)|0;return`<len:${e.length} hash:${(t>>>0).toString(16)}>`}const eB=e=>{const t=[1e3,2e3,4e3,8e3,16e3,3e4];return t[Math.min(e,t.length-1)]},tB=new Set(["auth:ok","pong","error"]),xw=new Set(vN.filter(e=>!tB.has(e)));let nB=0;const yw=()=>`r${++nB}`;function rB(e){let t=e.url,n=e.authToken,r=e.selfIdentity;const i=e.clientInfo,s=e.requestTimeoutMs??3e4,o=e.pingIntervalMs??3e4,a=e.watchdogMs??6e4,l=e.authTimeoutMs??1e4,c=e.backoffMs??eB;let u=null,d=!1,f=0,p=null,m=null,v=null,b=null,_=!1,x="disconnected";const y=new Map,w=new Map;let C=null;const k=(O,E)=>{var H;O==="ready"&&(C=E),(H=w.get(O))==null||H.forEach(V=>{try{V(E)}catch{}})},T=O=>{x!==O&&(x=O,k("status",O))},N=(O,E)=>{const H=w.get(O)??new Set;if(H.add(E),w.set(O,H),O==="ready"&&C!==null)try{E(C)}catch{}return()=>H.delete(E)},z=()=>{m&&(clearInterval(m),m=null),v&&(clearTimeout(v),v=null),b&&(clearTimeout(b),b=null)},P=()=>{v&&clearTimeout(v),v=setTimeout(()=>{try{u==null||u.close(4e3,"pong watchdog")}catch{}},a)},B=()=>{m&&clearInterval(m),m=setInterval(()=>{(u==null?void 0:u.readyState)===1&&u.send(JSON.stringify({type:"ping",requestId:yw()}))},o),P()},R=O=>{for(const[,E]of y)clearTimeout(E.timer),E.reject(new Error(O));y.clear()},I=[],j=()=>{if(I.length===0)return;const O=I.splice(0);for(const E of O)(u==null?void 0:u.readyState)===1&&!_?E.doSend():(clearTimeout(E.timer),E.reject(new Error("NOT_CONNECTED")))},L=O=>{if(I.length===0)return;const E=I.splice(0);for(const H of E)clearTimeout(H.timer),H.reject(new Error(O))},$=()=>{if(d)return;const O=c(f);O<0||(k("daemon:reconnecting",{attempt:f+1,nextDelayMs:O,scheduledAt:Date.now()}),p&&clearTimeout(p),p=setTimeout(()=>{f+=1,D()},O))},F=O=>{P();const E=String(O.type??"");if(E==="auth:ok"){Ae("daemon-client","auth:ok received → connected",{url:t}),b&&(clearTimeout(b),b=null),_=!1,f=0,T("connected"),k("daemon:connected",{url:t}),B(),j();return}if(E==="pong")return;if(E==="ready"){const V=Number(O.protocolVersion??-1);V!==_w&&k("daemon:version-mismatch",{daemonProtocol:V,supportedProtocol:_w}),k("ready",O);return}const H=O.requestId;if(typeof H=="string"&&y.has(H)){const V=y.get(H);if(y.delete(H),clearTimeout(V.timer),E==="error"){const A=String(O.code??"ERR"),ne=String(O.message??"unknown");V.reject(new Error(`${A}: ${ne}`))}else xw.has(E)&&k(E,O),V.resolve(O);return}xw.has(E)&&k(E,O)},D=()=>{p&&(clearTimeout(p),p=null),Ae("daemon-client","connect →",{url:t,token:cd(n),attempt:f}),T("connecting");let O;try{O=new WebSocket(t)}catch(E){T("disconnected"),k("daemon:disconnected",{reason:(E==null?void 0:E.message)??"ws constructor failed"}),$();return}u=O,_=!!n,O.onopen=()=>{if(O!==u){Ae("daemon-client","onopen → stale (replaced before opened), ignore");return}if(n){Ae("daemon-client","onopen → send auth frame",{token:cd(n)});const E={type:"auth",token:n};r!=null&&r.principalId&&(E.selfPrincipalId=r.principalId),r!=null&&r.displayName&&(E.selfDisplayName=r.displayName),i&&(E.clientInfo=i),O.send(JSON.stringify(E)),b=setTimeout(()=>{try{O.close(4001,"auth handshake timeout")}catch{}},l)}else Ae("daemon-client","onopen → no token, treat as connected (daemon authMode=none)"),f=0,T("connected"),k("daemon:connected",{url:t}),B(),j()},O.onclose=E=>{if(O!==u){Ae("daemon-client","onclose → stale, ignore",{code:E.code,reason:E.reason});return}const H=E.reason||(E.code===1008?"auth failed":`close ${E.code}`);if(Ae("daemon-client","onclose →",{code:E.code,reason:H,awaitingAuth:_,manualStop:d}),z(),R(`connection closed: ${H}`),u=null,E.code===4401?T("revoked"):T("disconnected"),k("daemon:disconnected",{reason:H}),E.code===1008||E.code===4401){L(`connection closed: ${H}`);return}d?L(`connection closed: ${H}`):$()},O.onerror=()=>{},O.onmessage=E=>{if(O!==u)return;let H;try{H=JSON.parse(String(E.data))}catch{return}F(H)}};return{start(){d=!1,f=0,D()},stop(){d=!0,p&&(clearTimeout(p),p=null),z();try{u==null||u.close(1e3,"shutdown")}catch{}u=null,R("shutdown"),L("shutdown"),T("disconnected")},switchProfile(O){Ae("daemon-client","switchProfile →",{url:O.url,token:cd(O.authToken)},"prev:",{url:t,token:cd(n)}),t=O.url,n=O.authToken,O.selfIdentity!==void 0&&(r=O.selfIdentity),f=0,d=!0,p&&(clearTimeout(p),p=null),z(),R("switch profile"),L("switch profile");try{u==null||u.close(1e3,"switch profile")}catch{}u=null,d=!1,D()},request(O,E){return new Promise((H,V)=>{const A=yw(),ne=setTimeout(()=>{y.delete(A);const G=I.findIndex(ye=>ye.timer===ne);G>=0&&I.splice(G,1),V(new Error(`request timeout: ${O}`))},s),ae=()=>{y.set(A,{resolve:G=>H(G),reject:V,timer:ne}),u.send(JSON.stringify({...E,type:O,requestId:A}))};(u==null?void 0:u.readyState)===1&&!_?ae():d||u==null&&p==null?(clearTimeout(ne),V(new Error("NOT_CONNECTED"))):I.push({doSend:ae,reject:V,timer:ne})})},on:N,get isOpen(){return(u==null?void 0:u.readyState)===1&&!_},get url(){return t},getStatus(){return x}}}function iB(e){if(!e)return"<none>";let t=0;for(let n=0;n<e.length;n++)t=(t<<5)-t+e.charCodeAt(n)|0;return`<len:${e.length} hash:${(t>>>0).toString(16)}>`}function sB(e){return e?{id:e.id,mode:e.mode,url:e.url,token:iB(e.token),name:e.name}:null}function ud(e){return e?Array.isArray(e)?e.map(sB):{_notArray:typeof e,_value:e}:null}function bw(e){return e==null?null:typeof e=="object"&&"value"in e?e.value:e}const oB="ws://127.0.0.1:18790",ww="daemon:profiles",Sw="daemon:active-profile-id";function aB(){return Math.random().toString(36).slice(2,10)}function lB(e){const t=e.trim(),n=t.indexOf("#");if(n<0)return{url:t};const r=t.slice(0,n),i=new URLSearchParams(t.slice(n+1)).get("token")??void 0;return{url:r,token:i}}function cB(e){if(!e||typeof e!="object")return!1;const t=e;return typeof t.id=="string"&&typeof t.name=="string"&&(t.mode==="localhost"||t.mode==="remote")&&typeof t.url=="string"&&(t.token===void 0||typeof t.token=="string")}function CN(e){let t={profiles:[],activeId:null},n=!1,r=null;const i=new Set,s=()=>{for(const l of i)l(t)},o=async()=>{Ae("profile-store","persist →",ud(t.profiles),"active:",t.activeId),await e.kv.set(ww,t.profiles),await e.kv.set(Sw,t.activeId)},a=async()=>{if(!n){if(r){await r;return}r=(async()=>{var l;try{let c=null;try{const d=await e.kv.get(ww);c=bw(d)}catch{c=null}let u=null;try{const d=await e.kv.get(Sw);u=bw(d)??null}catch{u=null}if(Ae("profile-store","ensureLoaded read kv →","profiles:",ud(c),"activeId:",u),Array.isArray(c)&&c.length>0){const d=c.filter(cB),f=u&&d.some(p=>p.id===u)?u:((l=d[0])==null?void 0:l.id)??null;t={profiles:d,activeId:f},n=!0,Ae("profile-store","ensureLoaded → use kv profiles",ud(d),"active:",f);return}t={profiles:[{id:"default",name:"本机",mode:"localhost",url:oB}],activeId:"default"},Ae("profile-store","ensureLoaded → fallback synthesized default (NO token)",ud(t.profiles)),n=!0,await o()}finally{r=null}})(),await r}};return{async load(){return await a(),s(),t},async snapshot(){return await a(),t},async upsert(l){var b;await a();let c=l.url,u=l.token;if(c&&c.includes("#")){const _=lB(c);c=_.url,!u&&_.token&&(u=_.token)}const d=l.id?t.profiles.find(_=>_.id===l.id):void 0,f=u!=null&&u.trim()?u.trim():d==null?void 0:d.token;if(l.mode==="remote"&&!f)throw new Error("remote mode requires token");const p=l.id??aB(),m={id:p,name:((b=l.name)==null?void 0:b.trim())||(d==null?void 0:d.name)||(l.mode==="remote"?"远程":"本机"),mode:l.mode,url:c.trim(),token:f};return t={profiles:[...t.profiles.filter(_=>_.id!==p),m],activeId:p},await o(),s(),m},async delete(l){var d;await a();const c=t.profiles.filter(f=>f.id!==l);let u=t.activeId;u===l&&(u=((d=c[0])==null?void 0:d.id)??null),t={profiles:c,activeId:u},await o(),s()},async activate(l){await a(),t.profiles.some(c=>c.id===l)&&(t={...t,activeId:l},await o(),s())},subscribe(l){return i.add(l),()=>i.delete(l)},getActive(){return n?t.profiles.find(l=>l.id===t.activeId)??null:null}}}const kw="clawd.client-instance-id";let uB={name:"clawd-web",version:"unknown"};function dB(){let e=null;try{e=localStorage.getItem(kw),e||(e=crypto.randomUUID(),localStorage.setItem(kw,e))}catch{e=e??crypto.randomUUID()}return{...uB,instanceId:e}}function Cw(e){if(!e)return"<none>";let t=0;for(let n=0;n<e.length;n++)t=(t<<5)-t+e.charCodeAt(n)|0;return`<len:${e.length} hash:${(t>>>0).toString(16)}>`}const EN=g.createContext(null);function hB({host:e,children:t}){const[n,r]=g.useState(null),i=g.useMemo(()=>async()=>{const s=CN(e),o=await s.load(),a=o.profiles.find(c=>c.id===o.activeId)??o.profiles[0];if(!a)throw new Error("DaemonProvider: profile store has no profiles after load");return Ae("daemon-context","bootstrap → createDaemonClient",{id:a.id,url:a.url,token:Cw(a.token)}),{client:rB({url:a.url,authToken:a.token,clientInfo:dB()}),store:s}},[e]);return g.useEffect(()=>{let s=!0,o=null,a=null;return i().then(l=>{s&&(l.client.start(),o=l,r(l),a=l.store.subscribe(()=>{const c=l.store.getActive();if(!c){Ae("daemon-context","subscribe → no active profile, skip switchProfile");return}Ae("daemon-context","subscribe → switchProfile",{id:c.id,url:c.url,token:Cw(c.token)}),l.client.switchProfile({url:c.url,authToken:c.token})}))}),()=>{s=!1,a==null||a(),o==null||o.client.stop()}},[i]),n?h.jsx(EN.Provider,{value:n,children:t}):null}function ci(){const e=g.useContext(EN);if(!e)throw new Error("useDaemonClient must be used inside <DaemonProvider>");return e.client}function fB(){const e=ci(),[t,n]=g.useState(void 0);return g.useEffect(()=>e.on("ready",i=>{const s=i.mode,o=s==="tui"?"tui":"sdk";Ae("daemon-context","useDaemonMode ready.mode =",{rawMode:s,resolved:o}),n(o)}),[e]),t}function pB(){const e=ci(),[t,n]=g.useState(void 0);return g.useEffect(()=>e.on("ready",i=>{const s=i;s.version!==void 0&&n(s.principalKind==="guest"?"guest":"owner")}),[e]),t}const TN=g.createContext(null);function mB({cache:e,children:t}){return g.createElement(TN.Provider,{value:e},t)}function Io(){const e=g.useContext(TN);if(!e)throw new Error("useCache must be used inside <CacheProvider>");return e}function si(e){const t=Io(),n=g.useCallback(i=>t.observe(e,()=>i()),[t,e]),r=g.useCallback(()=>t.read(e),[t,e]);return g.useSyncExternalStore(n,r,r)}const NN={actionsLevel:"none",httpBaseUrl:null,httpToken:null},PN=g.createContext(NN);function tp(){return g.useContext(PN)}function gB(e){return e!=null&&e.httpBaseUrl?{actionsLevel:e.tokenRole==="owner"?"owner":"none",httpBaseUrl:e.httpBaseUrl,httpToken:e.httpToken??null}:NN}function vB(){const e=si("daemon-info");return g.useMemo(()=>gB(e),[e])}function _B({children:e}){const t=vB();return Ze.createElement(PN.Provider,{value:t},e)}function xB(e,t,n){if(!e.httpBaseUrl)return null;const r=encodeURIComponent(n);return`${e.httpBaseUrl}/session/${encodeURIComponent(t.sessionId)}/files?path=${r}`}function yB(e){const t=new Map;return{observe(n,r){let i=t.get(n);i||(i={data:void 0,hasData:!1,listeners:new Set},t.set(n,i));const s=l=>r(l);i.listeners.add(s);const o=i.listeners.size===1;s(i.hasData?i.data:void 0),o&&e.onFirstObserver(n);let a=!1;return()=>{if(a)return;a=!0;const l=t.get(n);l&&(l.listeners.delete(s),l.listeners.size===0&&(t.delete(n),e.onLastObserver(n)))}},read(n){const r=t.get(n);return r!=null&&r.hasData?r.data:void 0},setData(n,r){const i=t.get(n);if(!i)return;const s=i.hasData?i.data:void 0,o=r(s);i.data=o,i.hasData=!0;for(const a of i.listeners)a(o)}}}function bB(){const e=[],t=new Map,n=r=>{for(const i of e)if(i.pattern.test(r))return i.source;return null};return{register(r,i){e.push({pattern:r,source:i})},activate(r){if(t.has(r))return;const i=n(r);if(!i)throw new Error(`no source registered for key: ${r}`);t.set(r,i.start(r))},deactivate(r){const i=t.get(r);i&&(t.delete(r),i())}}}function wB(e){return{request:(t,n)=>e.request(t,n),onFrame(t){const n=[];for(const r of vN)n.push(e.on(r,i=>t(r,i)));return()=>{for(const r of n)r()}},onConnect(t){return e.on("daemon:connected",()=>t())},get isConnected(){return e.isOpen}}}function IN(e){const t=(e??"claude")==="claude";return{rewind:t,subagents:t,tui:t,observe:t,fileSharing:t,fork:t}}const SB=e=>({tool:e,models:[{id:"",label:"未指定",contextWindowSize:2e5,default:!0}],permissionModes:[{id:"",label:"未指定"}],configSchema:[],features:IN(e)});function kB(e,t){return{start(n){const r=n.replace(/^capabilities\//,"");let i=!1;const s=async()=>{try{const a=await e.request("capabilities:get",{tool:r});if(i)return;t(n,()=>a)}catch{if(i)return;t(n,()=>SB(r))}},o=e.onConnect(()=>{s()});return s(),()=>{i=!0,o()}}}}function CB(e,t){return{start(n){let r=!1;const i=async()=>{try{const a=await e.request("session:list",void 0);if(r)return;t(n,()=>a.sessions??[])}catch{}},s=e.onFrame((a,l)=>{if(a==="session:info"){const c=l;if(c.chatId!==void 0)return;t(n,u=>[c,...(u??[]).filter(d=>d.sessionId!==c.sessionId)])}else if(a==="session:deleted"){const c=l;t(n,u=>(u??[]).filter(d=>d.sessionId!==c.sessionId))}}),o=e.onConnect(()=>{i()});return i(),()=>{r=!0,s(),o()}}}}const Vc={sessionId:null,events:[],lastSeq:-1,pendingPermissions:[],status:"idle",pendingQuestions:{}};function Tm(e,t){const n=t;if(n.kind==="permission_request"&&typeof n.requestId=="string"){if(e.some(i=>i.requestId===n.requestId))return e;const r={requestId:n.requestId,tool:typeof n.tool=="string"?n.tool:"",input:n.input,...typeof n.toolUseId=="string"&&n.toolUseId?{toolUseId:n.toolUseId}:{}};return[...e,r]}if(n.kind==="tool_result"&&typeof n.toolUseId=="string"&&n.toolUseId){const r=e.findIndex(i=>i.toolUseId===n.toolUseId);if(r>=0)return e.filter((i,s)=>s!==r)}return e}function RN(e,t,n){const r=n===void 0?e.sessionId:n;switch(t.type){case"session:change":return{...Vc,sessionId:t.sessionId};case"session:event":{if(!r||t.sessionId!==r)return e;const i=typeof t.event.seq=="number"?t.event.seq:-1,s=[...e.events,t.event],o=i>e.lastSeq?i:e.lastSeq,a=Tm(e.pendingPermissions,t.event);return{...e,events:s,lastSeq:o,pendingPermissions:a}}case"session:status":return!r||t.sessionId!==r?e:{...e,status:t.status};case"session:events":{if(!r||t.sessionId!==r)return e;const i=t.events.map(o=>o.event),s=i.reduce((o,a)=>Tm(o,a),[]);return{...e,sessionId:t.sessionId,events:i,lastSeq:t.latestSeq,pendingPermissions:s}}case"session:events:append":{if(!r||t.sessionId!==r)return e;const i=new Set;for(const c of e.events){const u=c.seq;typeof u=="number"&&i.add(u)}const s=[];for(const c of t.events)typeof c.seq=="number"&&(i.has(c.seq)||s.push(c.event));const o=t.latestSeq>e.lastSeq?t.latestSeq:e.lastSeq;if(s.length===0)return o===e.lastSeq?e:{...e,lastSeq:o};const a=[...e.events,...s].sort((c,u)=>{const d=c.seq??-1,f=u.seq??-1;return d-f}),l=s.reduce((c,u)=>Tm(c,u),e.pendingPermissions);return{...e,events:a,lastSeq:o,pendingPermissions:l}}case"permission:request":{if(!r||t.sessionId!==r||e.pendingPermissions.some(s=>s.requestId===t.requestId))return e;const i={requestId:t.requestId,tool:t.tool,input:t.input,...t.toolUseId?{toolUseId:t.toolUseId}:{}};return{...e,pendingPermissions:[...e.pendingPermissions,i]}}case"permission:clear":{if(!r||r!==t.sessionId)return e;const i=t.requestId,s=e.pendingPermissions.findIndex(c=>c.requestId===i),o=s>=0?e.pendingPermissions.filter((c,u)=>u!==s):e.pendingPermissions;if(e.events.length===0)return o===e.pendingPermissions?e:{...e,pendingPermissions:o};const a=e.events.length-1,l=e.events[a];return l.kind==="permission_request"&&l.requestId===i?{...e,pendingPermissions:o,events:e.events.slice(0,a)}:o===e.pendingPermissions?e:{...e,pendingPermissions:o}}case"session:question":return!r||t.sessionId!==r?e:{...e,pendingQuestions:{...e.pendingQuestions,[t.toolUseId]:{toolUseId:t.toolUseId,requestId:t.requestId,questions:t.questions}}};case"session:question:clear":{if(!r||t.sessionId!==r||!(t.toolUseId in e.pendingQuestions))return e;const{[t.toolUseId]:i,...s}=e.pendingQuestions;return{...e,pendingQuestions:s}}case"session:question:submitted":{if(!r||t.sessionId!==r)return e;const i=e.pendingQuestions[t.toolUseId];return i?{...e,pendingQuestions:{...e.pendingQuestions,[t.toolUseId]:{...i,submittedAnswers:t.answers}}}:e}case"session:rewound":return!r||t.sessionId!==r?e:{...e,pendingPermissions:[],status:"idle"};case"ready":{if(!r)return e;const i=t.runningSessions.find(o=>o.sessionId===r);if(i!=null&&i.freshSpawn)return{...Vc,sessionId:r};const s=(i==null?void 0:i.status)??"idle";return s===e.status?e:{...e,status:s}}case"daemon:disconnected":return{...e,pendingPermissions:[]};default:return e}}const EB="session/";function TB(e){return{sid:e.slice(EB.length)}}const NB=new Set(_N);function MN(e){return NB.has(e)}function Ew(e){return MN(e)?e:"idle"}function PB(e,t){return{start(n){const{sid:r}=TB(n);let i=!1,s=-1;const o=f=>{t(n,p=>RN(p??Vc,f,r))},a=async f=>{const p=f==="baseline"?-1:s;try{const m=await e.request("session:events",{sessionId:r,afterSeq:p});if(i)return;const v=m.events??[],b=m.latestSeq??-1;if(f==="baseline")o({type:"session:events",sessionId:r,events:v,latestSeq:b}),s=b;else{const _=m.bufferStartSeq??0,x=b<p||_>p+1;o({type:x?"session:events":"session:events:append",sessionId:r,events:v,latestSeq:b}),s=Math.max(s,b)}}catch{}},l=async()=>{try{const f=await e.request("info");if(i)return;o({type:"ready",runningSessions:(f.runningSessions??[]).map(p=>({sessionId:p.sessionId,freshSpawn:p.freshSpawn,status:Ew(p.status)}))})}catch{}},c=async()=>{try{await e.request("session:subscribe",{sessionId:r})}catch{}i||(await a(s<0?"baseline":"delta"),!i&&await l())},u=e.onFrame((f,p)=>{if(!i)if(f==="session:event"){const m=p;if(m.sessionId!==r)return;const v=m.event.seq;Ae("session-events","push session:event",{sid:r,kind:m.event.kind,seq:v,lastSeqBefore:s}),o({type:"session:event",sessionId:m.sessionId,event:m.event}),typeof v=="number"&&v>s&&(s=v)}else if(f==="session:status"){const m=p;if(m.sessionId!==r)return;if(!MN(m.status)){Ae("session-events","push session:status drop",{sid:r,status:m.status});return}Ae("session-events","push session:status",{sid:r,status:m.status}),o({type:"session:status",sessionId:m.sessionId,status:m.status})}else if(f==="session:cleared"){if(p.sessionId!==r)return;Ae("session-events","push session:cleared",{sid:r}),o({type:"session:change",sessionId:r}),s=-1}else if(f==="permission:request"){const m=p;if(m.sessionId!==r)return;o({type:"permission:request",sessionId:m.sessionId,requestId:m.requestId,tool:m.tool,input:m.input,...typeof m.toolUseId=="string"&&m.toolUseId?{toolUseId:m.toolUseId}:{}})}else if(f==="session:question"){const m=p;if(m.sessionId!==r)return;o({type:"session:question",sessionId:m.sessionId,toolUseId:m.toolUseId,requestId:m.requestId,questions:m.questions})}else if(f==="session:question:cleared"){const m=p;if(m.sessionId!==r)return;m.answers&&Object.keys(m.answers).length>0?o({type:"session:question:submitted",sessionId:m.sessionId,toolUseId:m.toolUseId,answers:m.answers}):o({type:"session:question:clear",sessionId:m.sessionId,toolUseId:m.toolUseId})}else if(f==="session:rewound"){const m=p;if(m.sessionId!==r)return;o({type:"session:rewound",sessionId:m.sessionId,userMessageId:m.userMessageId})}else f==="ready"&&o({type:"ready",runningSessions:(p.runningSessions??[]).map(v=>({sessionId:v.sessionId,freshSpawn:v.freshSpawn,status:Ew(v.status)}))})}),d=e.onConnect(()=>{c()});return e.isConnected&&c(),()=>{i=!0,u(),d(),e.request("session:unsubscribe",{sessionId:r}).catch(()=>{})}}}}const IB=new Set(["tunnel:ready","tunnel:exited","tunnel:unavailable"]);function RB(e,t){return{start(n){let r=!1;const i=async()=>{try{const a=await e.request("info",void 0);if(r)return;t(n,()=>a)}catch{}},s=e.onConnect(()=>{i()}),o=e.onFrame(a=>{IB.has(a)&&i()});return i(),()=>{r=!0,s(),o()}}}}function MB(){return{start(){return()=>{}}}}function AB(e,t){return{start(n){let r=!1;const i=async()=>{try{const o=await e.request("persona:list",{});if(r)return;t(n,()=>o.personas??[])}catch{}},s=e.onConnect(()=>{i()});return i(),()=>{r=!0,s()}}}}function LB(e){const t=wB(e),n=bB();let r=null;const i=(o,a)=>{r==null||r.setData(o,a)};n.register(/^capabilities\//,kB(t,i)),n.register(/^sessions$/,CB(t,i)),n.register(/^session\//,PB(t,i)),n.register(/^personas$/,AB(t,i)),n.register(/^persona-detail\//,MB()),n.register(/^daemon-info$/,RB(t,i));const s=yB({onFirstObserver:o=>{o&&n.activate(o)},onLastObserver:o=>{o&&n.deactivate(o)}});return r=s,{cache:s,channel:t}}class Ox{constructor(t){this.client=t}info(){return this.client.request("info")}attachmentSignUrl(t){return this.client.request("attachment.signUrl",t)}attachmentGroupAdd(t,n,r){return this.client.request("attachment.groupAdd",{sessionId:t,relPath:n,...r?{label:r}:{}})}attachmentGroupRemove(t,n){return this.client.request("attachment.groupRemove",{sessionId:t,relPath:n})}attachmentGroupList(t){return this.client.request("attachment.groupList",{sessionId:t})}sessionCreate(t){return this.client.request("session:create",t)}projectList(){return this.client.request("project:list")}projectCreate(t){return this.client.request("project:create",{...t.path?{path:t.path}:{},...t.name?{name:t.name}:{}})}appBuilderListProjects(){return this.client.request("appBuilder:listProjects",{})}appBuilderGetProject(t){return this.client.request("appBuilder:getProject",{sessionId:t})}appBuilderUpdateProjectPort(t,n){return this.client.request("appBuilder:updateProjectPort",{name:t,newPort:n})}appBuilderStartDevServer(t,n){return this.client.request("appBuilder:startDevServer",{sessionId:t,...n!=null&&n.force?{force:!0}:{}})}appBuilderStopDevServer(t){return this.client.request("appBuilder:stopDevServer",{sessionId:t})}appBuilderPublish(t){return this.client.request("appBuilder:publish",{name:t})}appBuilderDismissPublishJob(t){return this.client.request("appBuilder:dismissPublishJob",{name:t})}sessionList(){return this.client.request("session:list")}sessionGet(t){return this.client.request("session:get",{sessionId:t})}sessionUpdate(t,n){return this.client.request("session:update",{sessionId:t,patch:n})}sessionDelete(t){return this.client.request("session:delete",{sessionId:t})}sessionSend(t,n){return this.client.request("session:send",{sessionId:t,text:n})}sessionStop(t){return this.client.request("session:stop",{sessionId:t})}sessionInterrupt(t){return this.client.request("session:interrupt",{sessionId:t})}sessionRewind(t){return this.client.request("session:rewind",t)}sessionRewindableMessageIds(t){return this.client.request("session:rewindable-message-ids",{sessionId:t})}sessionRewindDiff(t){return this.client.request("session:rewind-diff",t)}sessionNew(t){return this.client.request("session:new",{sessionId:t})}sessionFork(t){return this.client.request("session:fork",t)}sessionResume(t,n){return this.client.request("session:resume",{sessionId:t,toolSessionId:n})}sessionObserve(t){return this.client.request("session:observe",t)}sessionEvents(t,n){return this.client.request("session:events",{sessionId:t,afterSeq:n})}sessionSubscribe(t){return this.client.request("session:subscribe",{sessionId:t})}sessionUnsubscribe(t){return this.client.request("session:unsubscribe",{sessionId:t})}pinSession(t,n){return this.client.request("session:pin",{sessionId:t,pinned:n})}archiveSession(t,n){return this.client.request("session:archive",{sessionId:t,archived:n})}markSessionRead(t){return this.client.request("session:markRead",{sessionId:t})}reorderPins(t){return this.client.request("session:reorderPins",{orderedIds:t})}peerSessionUpsert(t){return this.client.request("peerSession:upsert",t)}peerSessionRemove(t){return this.client.request("peerSession:remove",{sessionId:t})}permissionRespond(t){return this.client.request("permission:respond",t)}answerQuestion(t){return this.client.request("session:answerQuestion",t)}cancelQuestion(t){return this.client.request("session:cancelQuestion",t)}historyProjects(){return this.client.request("history:projects")}historyList(t){return this.client.request("history:list",{projectPath:t})}historyRead(t){return this.client.request("history:read",t)}historySubagents(t){return this.client.request("history:subagents",t)}historySubagentRead(t){return this.client.request("history:subagent-read",t)}listRecentDirs(){return this.client.request("history:recentDirs",{})}getGitRoot(t){return this.client.request("git:root",{cwd:t})}getGitBranch(t){return this.client.request("git:branch",{cwd:t})}listGitBranches(t){return this.client.request("git:branches",{cwd:t})}personaCreate(t){return this.client.request("persona:create",t)}personaList(){return this.client.request("persona:list",{})}personaGet(t){return this.client.request("persona:get",{personaId:t})}personaUpdate(t,n){return this.client.request("persona:update",{personaId:t,patch:n})}personaDelete(t){return this.client.request("persona:delete",{personaId:t})}larkBotBindManual(t,n,r){return this.client.request("larkBot:bindManual",{personaId:t,appId:n,appSecret:r})}larkBotUnbind(t){return this.client.request("larkBot:unbind",{personaId:t})}larkBotStatus(t){return this.client.request("larkBot:status",{personaId:t})}toolsProbe(){return this.client.request("tools:probe",{})}sessionExternalScan(){return this.client.request("session:externalScan",{})}sessionImportExternal(t){return this.client.request("session:importExternal",t)}onboardingComplete(){return this.client.request("onboarding:complete",{})}onboardingIosInterest(){return this.client.request("onboarding:iosInterest",{})}visitorList(){return this.client.request("visitor:list",{})}workspaceList(t={}){return this.client.request("workspace:list",t)}workspaceRead(t){return this.client.request("workspace:read",t)}skillsList(t,n){return this.client.request("skills:list",{cwd:t,...n?{tool:n}:{}})}agentsList(t,n){return this.client.request("agents:list",{cwd:t,...n?{tool:n}:{}})}capabilitiesGet(t="claude"){return this.client.request("capabilities:get",{tool:t})}shiftList(){return this.client.request("shift:list")}githubStatus(){return this.client.request("github:status")}githubPrList(t){return this.client.request("github:prList",{role:t})}githubPrDetail(t){return this.client.request("github:prDetail",{...t})}githubPrMerge(t){return this.client.request("github:prMerge",{...t})}githubPrComment(t){return this.client.request("github:prComment",{...t})}githubPrSetReady(t){return this.client.request("github:prSetReady",{...t})}githubCollaborators(t){return this.client.request("github:collaborators",{...t})}githubPrRequestReviewers(t){return this.client.request("github:prRequestReviewers",{...t})}}function jB(e){const[t,n]=g.useState(e.isOpen?{kind:"connected",url:""}:{kind:"connecting"});return g.useEffect(()=>{const r=e.on("ready",l=>{const c=l;n(u=>({kind:"connected",url:u.kind==="connected"?u.url:"",mode:u.kind==="connected"?u.mode:void 0,daemonVersion:c.version,protocolVersion:c.protocolVersion,daemonSource:c.daemonSource,globalCliVersion:c.globalCliVersion,onboardingCompletedAt:c.onboardingCompletedAt}))}),i=e.on("daemon:connected",l=>{const c=l;n(u=>({kind:"connected",url:c.url,mode:c.mode,daemonVersion:u.kind==="connected"?u.daemonVersion:void 0,protocolVersion:u.kind==="connected"?u.protocolVersion:void 0,daemonSource:u.kind==="connected"?u.daemonSource:void 0,globalCliVersion:u.kind==="connected"?u.globalCliVersion:void 0,onboardingCompletedAt:u.kind==="connected"?u.onboardingCompletedAt:void 0}))}),s=e.on("daemon:disconnected",l=>{const c=(l==null?void 0:l.reason)??"";/auth failed|auth timeout|auth required|auth handshake timeout/i.test(c)?n({kind:"auth-failed",reason:c}):n({kind:"disconnected",reason:c})}),o=e.on("daemon:reconnecting",l=>{const c=l;n({kind:"reconnecting",attempt:c.attempt,nextDelayMs:c.nextDelayMs,scheduledAt:c.scheduledAt??Date.now()})}),a=e.on("daemon:version-mismatch",l=>{const c=l;n({kind:"version-mismatch",daemonProtocol:c.daemonProtocol,supportedProtocol:c.supportedProtocol})});return()=>{r(),i(),s(),o(),a()}},[e]),t}function DB(e){const t=Io(),n=si(e.kind==="connected"?"sessions":""),r=g.useCallback(async()=>{t.setData("sessions",i=>i??[])},[t]);return{sessions:n??[],loading:!1,loaded:n!==void 0,error:null,refresh:r}}function cl(){const e=ci();return g.useMemo(()=>new Ox(e),[e])}function AN(e){return{personaId:e.personaId,label:e.label,model:e.model,effort:e.effort,tool:e.tool,public:e.public,createdAt:e.createdAt,updatedAt:e.updatedAt}}function LN(){const e=Io(),t=cl(),n=si("personas")??[],r=g.useMemo(()=>n.map(s=>AN(s)),[n]),i=g.useCallback(async()=>{const s=await t.personaList();e.setData("personas",()=>s.personas??[])},[t,e]);return{personas:r,raw:n,loaded:si("personas")!==void 0,refresh:i}}function jN(e){const{raw:t}=LN(),n=Io(),r=cl(),i=e?t.find(a=>a.personaId===e)??null:null,s=i?AN(i):null,o=g.useCallback(async()=>{if(!e)return;const a=await r.personaList();n.setData("personas",()=>a.personas??[])},[e,r,n]);return{persona:s,raw:i,loaded:!!s,refresh:o}}function OB(e){const t=cl(),n=Io(),r=e?`persona-detail/${e}`:"",i=si(r),s=g.useCallback(async()=>{const o={personality:"",skills:[],plugins:[],sandboxSettings:null};if(!e)return o;const a=await t.personaGet(e);let l;if("persona"in a&&a.persona===null)l=o;else{const c=a;l={personality:c.personality??"",skills:c.skills??[],plugins:c.plugins??[],sandboxSettings:c.sandboxSettings??null}}return n.setData(r,()=>l),l},[t,n,e,r]);return g.useEffect(()=>{e&&s()},[e,s]),{personality:(i==null?void 0:i.personality)??"",skills:(i==null?void 0:i.skills)??[],plugins:(i==null?void 0:i.plugins)??[],sandboxSettings:(i==null?void 0:i.sandboxSettings)??null,loaded:i!==void 0,refresh:s}}function DN(){const e=Io(),t=cl();return g.useCallback(async()=>{const n=await t.personaList();e.setData("personas",()=>n.personas??[])},[e,t])}function BB(){const e=cl(),t=DN();return g.useCallback(async(n,r)=>{const i=await e.personaUpdate(n,r);return await t(),i},[e,t])}function zB(){const e=cl(),t=DN();return g.useCallback(async n=>{await e.personaDelete(n),await t()},[e,t])}const Tw="clawd:sidebar:tree-collapsed";function $B(e){return e&&typeof e=="object"&&"value"in e?e.value:e}function FB(e){const t=$B(e);if(!Array.isArray(t))return new Set;const n=new Set;for(const r of t)typeof r=="string"&&n.add(r);return n}function HB(){const e=bx(),[t,n]=g.useState(()=>new Set),r=g.useRef(t);r.current=t,g.useEffect(()=>{let l=!1;return(async()=>{try{const c=await e.kv.get(Tw);if(l)return;n(FB(c))}catch{}})(),()=>{l=!0}},[e]);const i=g.useCallback(l=>{e.kv.set(Tw,[...l]).catch(()=>{})},[e]),s=g.useCallback(l=>r.current.has(l),[]),o=g.useCallback(l=>{n(c=>{const u=new Set(c);return u.has(l)?u.delete(l):u.add(l),i(u),u})},[i]),a=g.useCallback(l=>{n(c=>{let u=!1;const d=new Set;for(const f of c)l.has(f)?d.add(f):u=!0;return u?(i(d),d):c})},[i]);return{isCollapsed:s,toggle:o,prune:a}}const Bx=g.createContext(null);function UB(){const e=g.useContext(Bx);if(!e)throw new Error("SessionTreeCollapsedContext.Provider missing — wrap SessionTreeNode tree with <SessionTreeCollapsedContext.Provider value={useSessionTreeCollapsed()}>");return e}/**
95
+ `,boxShadowTabsOverflowLeft:"inset 10px 0 8px -8px rgba(0, 0, 0, 0.08)",boxShadowTabsOverflowRight:"inset -10px 0 8px -8px rgba(0, 0, 0, 0.08)",boxShadowTabsOverflowTop:"inset 0 10px 8px -8px rgba(0, 0, 0, 0.08)",boxShadowTabsOverflowBottom:"inset 0 -10px 8px -8px rgba(0, 0, 0, 0.08)"}),r)}var Jb=function(e,t){var n={};for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(e!=null&&typeof Object.getOwnPropertySymbols=="function")for(var i=0,r=Object.getOwnPropertySymbols(e);i<r.length;i++)t.indexOf(r[i])<0&&Object.prototype.propertyIsEnumerable.call(e,r[i])&&(n[r[i]]=e[r[i]]);return n};const ED={lineHeight:!0,lineHeightSM:!0,lineHeightLG:!0,lineHeightHeading1:!0,lineHeightHeading2:!0,lineHeightHeading3:!0,lineHeightHeading4:!0,lineHeightHeading5:!0,opacityLoading:!0,fontWeightStrong:!0,zIndexPopupBase:!0,zIndexBase:!0,opacityImage:!0},TD={motionBase:!0,motionUnit:!0},ND={screenXS:!0,screenXSMin:!0,screenXSMax:!0,screenSM:!0,screenSMMin:!0,screenSMMax:!0,screenMD:!0,screenMDMin:!0,screenMDMax:!0,screenLG:!0,screenLGMin:!0,screenLGMax:!0,screenXL:!0,screenXLMin:!0,screenXLMax:!0,screenXXL:!0,screenXXLMin:!0},GT=(e,t,n)=>{const r=n.getDerivativeToken(e),{override:i}=t,s=Jb(t,["override"]);let o=Object.assign(Object.assign({},r),{override:i});return o=KT(o),s&&Object.entries(s).forEach(([a,l])=>{const{theme:c}=l,u=Jb(l,["theme"]);let d=u;c&&(d=GT(Object.assign(Object.assign({},o),u),{override:u},c)),o[a]=d}),o};function YT(){const{token:e,hashed:t,theme:n,override:r,cssVar:i}=Ze.useContext(VT),s=`${kD}-${t||""}`,o=n||WT,[a,l,c]=pj(o,[Fc,e],{salt:s,override:r,getComputedToken:GT,formatToken:KT,cssVar:i&&{prefix:i.prefix,key:i.key,unitless:ED,ignore:TD,preserve:ND}});return[o,c,t?l:"",a,i]}const PD=()=>({display:"inline-flex",alignItems:"center",color:"inherit",fontStyle:"normal",lineHeight:0,textAlign:"center",textTransform:"none",verticalAlign:"-0.125em",textRendering:"optimizeLegibility","-webkit-font-smoothing":"antialiased","-moz-osx-font-smoothing":"grayscale","> *":{lineHeight:1},svg:{display:"inline-block"}}),ID=e=>({[`.${e}`]:Object.assign(Object.assign({},PD()),{[`.${e} .${e}-icon`]:{display:"block"}})}),RD=(e,t)=>{const[n,r]=YT();return Hj({token:r,hashId:"",path:["ant-design-icons",e],nonce:()=>t==null?void 0:t.nonce,layer:{name:"antd"}},()=>ID(e))},MD=Object.assign({},Qa),{useId:ew}=MD,AD=()=>"",LD=typeof ew>"u"?AD:ew;function jD(e,t,n){var r;const i=e||{},s=i.inherit===!1||!t?Object.assign(Object.assign({},zh),{hashed:(r=t==null?void 0:t.hashed)!==null&&r!==void 0?r:zh.hashed,cssVar:t==null?void 0:t.cssVar}):t,o=LD();return fT(()=>{var a,l;if(!e)return t;const c=Object.assign({},s.components);Object.keys(e.components||{}).forEach(f=>{c[f]=Object.assign(Object.assign({},c[f]),e.components[f])});const u=`css-var-${o.replace(/:/g,"")}`,d=((a=i.cssVar)!==null&&a!==void 0?a:s.cssVar)&&Object.assign(Object.assign(Object.assign({prefix:n==null?void 0:n.prefixCls},typeof s.cssVar=="object"?s.cssVar:{}),typeof i.cssVar=="object"?i.cssVar:{}),{key:typeof i.cssVar=="object"&&((l=i.cssVar)===null||l===void 0?void 0:l.key)||u});return Object.assign(Object.assign(Object.assign({},s),i),{token:Object.assign(Object.assign({},s.token),i.token),components:c,cssVar:d})},[i,s],(a,l)=>a.some((c,u)=>{const d=l[u];return!HL(c,d,!0)}))}var DD=["children"],XT=g.createContext({});function OD(e){var t=e.children,n=Pv(e,DD);return g.createElement(XT.Provider,{value:n},t)}var BD=function(e){mT(n,e);var t=vT(n);function n(){return tl(this,n),t.apply(this,arguments)}return nl(n,[{key:"render",value:function(){return this.props.children}}]),n}(g.Component);function zD(e){var t=g.useReducer(function(a){return a+1},0),n=Je(t,2),r=n[1],i=g.useRef(e),s=Qv(function(){return i.current}),o=Qv(function(a){i.current=typeof a=="function"?a(i.current):a,r()});return[s,o]}var ts="none",id="appear",sd="enter",od="leave",tw="none",Tr="prepare",fa="start",pa="active",Rx="end",QT="prepared";function nw(e,t){var n={};return n[e.toLowerCase()]=t.toLowerCase(),n["Webkit".concat(e)]="webkit".concat(t),n["Moz".concat(e)]="moz".concat(t),n["ms".concat(e)]="MS".concat(t),n["O".concat(e)]="o".concat(t.toLowerCase()),n}function $D(e,t){var n={animationend:nw("Animation","AnimationEnd"),transitionend:nw("Transition","TransitionEnd")};return e&&("AnimationEvent"in t||delete n.animationend.animation,"TransitionEvent"in t||delete n.transitionend.transition),n}var FD=$D(Bi(),typeof window<"u"?window:{}),ZT={};if(Bi()){var HD=document.createElement("div");ZT=HD.style}var ad={};function JT(e){if(ad[e])return ad[e];var t=FD[e];if(t)for(var n=Object.keys(t),r=n.length,i=0;i<r;i+=1){var s=n[i];if(Object.prototype.hasOwnProperty.call(t,s)&&s in ZT)return ad[e]=t[s],ad[e]}return""}var eN=JT("animationend"),tN=JT("transitionend"),nN=!!(eN&&tN),rw=eN||"animationend",iw=tN||"transitionend";function sw(e,t){if(!e)return null;if(Ct(e)==="object"){var n=t.replace(/-\w/g,function(r){return r[1].toUpperCase()});return e[n]}return"".concat(e,"-").concat(t)}const UD=function(e){var t=g.useRef();function n(i){i&&(i.removeEventListener(iw,e),i.removeEventListener(rw,e))}function r(i){t.current&&t.current!==i&&n(t.current),i&&i!==t.current&&(i.addEventListener(iw,e),i.addEventListener(rw,e),t.current=i)}return g.useEffect(function(){return function(){n(t.current)}},[]),[r,n]};var rN=Bi()?g.useLayoutEffect:g.useEffect;const WD=function(){var e=g.useRef(null);function t(){Tv.cancel(e.current)}function n(r){var i=arguments.length>1&&arguments[1]!==void 0?arguments[1]:2;t();var s=Tv(function(){i<=1?r({isCanceled:function(){return s!==e.current}}):n(r,i-1)});e.current=s}return g.useEffect(function(){return function(){t()}},[]),[n,t]};var VD=[Tr,fa,pa,Rx],qD=[Tr,QT],iN=!1,KD=!0;function sN(e){return e===pa||e===Rx}const GD=function(e,t,n){var r=Zv(tw),i=Je(r,2),s=i[0],o=i[1],a=WD(),l=Je(a,2),c=l[0],u=l[1];function d(){o(Tr,!0)}var f=t?qD:VD;return rN(function(){if(s!==tw&&s!==Rx){var p=f.indexOf(s),m=f[p+1],v=n(s);v===iN?o(m,!0):m&&c(function(b){function _(){b.isCanceled()||o(m,!0)}v===!0?_():Promise.resolve(v).then(_)})}},[e,s]),g.useEffect(function(){return function(){u()}},[]),[d,s]};function YD(e,t,n,r){var i=r.motionEnter,s=i===void 0?!0:i,o=r.motionAppear,a=o===void 0?!0:o,l=r.motionLeave,c=l===void 0?!0:l,u=r.motionDeadline,d=r.motionLeaveImmediately,f=r.onAppearPrepare,p=r.onEnterPrepare,m=r.onLeavePrepare,v=r.onAppearStart,b=r.onEnterStart,_=r.onLeaveStart,x=r.onAppearActive,y=r.onEnterActive,w=r.onLeaveActive,C=r.onAppearEnd,k=r.onEnterEnd,T=r.onLeaveEnd,N=r.onVisibleChanged,z=Zv(),P=Je(z,2),B=P[0],R=P[1],I=zD(ts),j=Je(I,2),L=j[0],$=j[1],F=Zv(null),D=Je(F,2),O=D[0],E=D[1],H=L(),V=g.useRef(!1),A=g.useRef(null);function ne(){return n()}var ae=g.useRef(!1);function G(){$(ts),E(null,!0)}var ye=Qv(function(Qe){var st=L();if(st!==ts){var wt=ne();if(!(Qe&&!Qe.deadline&&Qe.target!==wt)){var pn=ae.current,on;st===id&&pn?on=C==null?void 0:C(wt,Qe):st===sd&&pn?on=k==null?void 0:k(wt,Qe):st===od&&pn&&(on=T==null?void 0:T(wt,Qe)),pn&&on!==!1&&G()}}}),Fe=UD(ye),ue=Je(Fe,1),Ie=ue[0],Re=function(st){switch(st){case id:return Ce(Ce(Ce({},Tr,f),fa,v),pa,x);case sd:return Ce(Ce(Ce({},Tr,p),fa,b),pa,y);case od:return Ce(Ce(Ce({},Tr,m),fa,_),pa,w);default:return{}}},Ke=g.useMemo(function(){return Re(H)},[H]),ve=GD(H,!e,function(Qe){if(Qe===Tr){var st=Ke[Tr];return st?st(ne()):iN}if(it in Ke){var wt;E(((wt=Ke[it])===null||wt===void 0?void 0:wt.call(Ke,ne(),null))||null)}return it===pa&&H!==ts&&(Ie(ne()),u>0&&(clearTimeout(A.current),A.current=setTimeout(function(){ye({deadline:!0})},u))),it===QT&&G(),KD}),ze=Je(ve,2),fn=ze[0],it=ze[1],Rt=sN(it);ae.current=Rt;var Gt=g.useRef(null);rN(function(){if(!(V.current&&Gt.current===t)){R(t);var Qe=V.current;V.current=!0;var st;!Qe&&t&&a&&(st=id),Qe&&t&&s&&(st=sd),(Qe&&!t&&c||!Qe&&d&&!t&&c)&&(st=od);var wt=Re(st);st&&(e||wt[Tr])?($(st),fn()):$(ts),Gt.current=t}},[t]),g.useEffect(function(){(H===id&&!a||H===sd&&!s||H===od&&!c)&&$(ts)},[a,s,c]),g.useEffect(function(){return function(){V.current=!1,clearTimeout(A.current)}},[]);var Mt=g.useRef(!1);g.useEffect(function(){B&&(Mt.current=!0),B!==void 0&&H===ts&&((Mt.current||B)&&(N==null||N(B)),Mt.current=!0)},[B,H]);var bt=O;return Ke[Tr]&&it===fa&&(bt=$e({transition:"none"},bt)),[H,it,bt,B??t]}function XD(e){var t=e;Ct(e)==="object"&&(t=e.transitionSupport);function n(i,s){return!!(i.motionName&&t&&s!==!1)}var r=g.forwardRef(function(i,s){var o=i.visible,a=o===void 0?!0:o,l=i.removeOnLeave,c=l===void 0?!0:l,u=i.forceRender,d=i.children,f=i.motionName,p=i.leavedClassName,m=i.eventProps,v=g.useContext(XT),b=v.motion,_=n(i,b),x=g.useRef(),y=g.useRef();function w(){try{return x.current instanceof HTMLElement?x.current:CL(y.current)}catch{return null}}var C=YD(_,a,w,i),k=Je(C,4),T=k[0],N=k[1],z=k[2],P=k[3],B=g.useRef(P);P&&(B.current=!0);var R=g.useCallback(function(D){x.current=D,PL(s,D)},[s]),I,j=$e($e({},m),{},{visible:a});if(!d)I=null;else if(T===ts)P?I=d($e({},j),R):!c&&B.current&&p?I=d($e($e({},j),{},{className:p}),R):u||!c&&!p?I=d($e($e({},j),{},{style:{display:"none"}}),R):I=null;else{var L;N===Tr?L="prepare":sN(N)?L="active":N===fa&&(L="start");var $=sw(f,"".concat(T,"-").concat(L));I=d($e($e({},j),{},{className:fL(sw(f,T),Ce(Ce({},$,$&&L),f,typeof f=="string")),style:z}),R)}if(g.isValidElement(I)&&IL(I)){var F=RL(I);F||(I=g.cloneElement(I,{ref:R}))}return g.createElement(BD,{ref:y},I)});return r.displayName="CSSMotion",r}const QD=XD(nN);var Jv="add",e0="keep",t0="remove",Cm="removed";function ZD(e){var t;return e&&Ct(e)==="object"&&"key"in e?t=e:t={key:e},$e($e({},t),{},{key:String(t.key)})}function n0(){var e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:[];return e.map(ZD)}function JD(){var e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:[],t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:[],n=[],r=0,i=t.length,s=n0(e),o=n0(t);s.forEach(function(c){for(var u=!1,d=r;d<i;d+=1){var f=o[d];if(f.key===c.key){r<d&&(n=n.concat(o.slice(r,d).map(function(p){return $e($e({},p),{},{status:Jv})})),r=d),n.push($e($e({},f),{},{status:e0})),r+=1,u=!0;break}}u||n.push($e($e({},c),{},{status:t0}))}),r<i&&(n=n.concat(o.slice(r).map(function(c){return $e($e({},c),{},{status:Jv})})));var a={};n.forEach(function(c){var u=c.key;a[u]=(a[u]||0)+1});var l=Object.keys(a).filter(function(c){return a[c]>1});return l.forEach(function(c){n=n.filter(function(u){var d=u.key,f=u.status;return d!==c||f!==t0}),n.forEach(function(u){u.key===c&&(u.status=e0)})}),n}var eO=["component","children","onVisibleChanged","onAllRemoved"],tO=["status"],nO=["eventProps","visible","children","motionName","motionAppear","motionEnter","motionLeave","motionLeaveImmediately","motionDeadline","removeOnLeave","leavedClassName","onAppearPrepare","onAppearStart","onAppearActive","onAppearEnd","onEnterStart","onEnterActive","onEnterEnd","onLeaveStart","onLeaveActive","onLeaveEnd"];function rO(e){var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:QD,n=function(r){mT(s,r);var i=vT(s);function s(){var o;tl(this,s);for(var a=arguments.length,l=new Array(a),c=0;c<a;c++)l[c]=arguments[c];return o=i.call.apply(i,[this].concat(l)),Ce(Cv(o),"state",{keyEntities:[]}),Ce(Cv(o),"removeKey",function(u){o.setState(function(d){var f=d.keyEntities.map(function(p){return p.key!==u?p:$e($e({},p),{},{status:Cm})});return{keyEntities:f}},function(){var d=o.state.keyEntities,f=d.filter(function(p){var m=p.status;return m!==Cm}).length;f===0&&o.props.onAllRemoved&&o.props.onAllRemoved()})}),o}return nl(s,[{key:"render",value:function(){var a=this,l=this.state.keyEntities,c=this.props,u=c.component,d=c.children,f=c.onVisibleChanged;c.onAllRemoved;var p=Pv(c,eO),m=u||g.Fragment,v={};return nO.forEach(function(b){v[b]=p[b],delete p[b]}),delete p.keys,g.createElement(m,p,l.map(function(b,_){var x=b.status,y=Pv(b,tO),w=x===Jv||x===e0;return g.createElement(t,Dh({},v,{key:y.key,visible:w,eventProps:y,onVisibleChanged:function(k){f==null||f(k,{key:y.key}),k||a.removeKey(y.key)}}),function(C,k){return d($e($e({},C),{},{index:_}),k)})}))}}],[{key:"getDerivedStateFromProps",value:function(a,l){var c=a.keys,u=l.keyEntities,d=n0(c),f=JD(u,d);return{keyEntities:f.filter(function(p){var m=u.find(function(v){var b=v.key;return p.key===b});return!(m&&m.status===Cm&&p.status===t0)})}}}]),s}(g.Component);return Ce(n,"defaultProps",{component:"div"}),n}rO(nN);const ow=g.createContext(!0);function iO(e){const t=g.useContext(ow),{children:n}=e,[,r]=YT(),{motion:i}=r,s=g.useRef(!1);return s.current||(s.current=t!==i),s.current?g.createElement(ow.Provider,{value:i},g.createElement(OD,{motion:i},n)):n}const sO=()=>null;var oO=function(e,t){var n={};for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(e!=null&&typeof Object.getOwnPropertySymbols=="function")for(var i=0,r=Object.getOwnPropertySymbols(e);i<r.length;i++)t.indexOf(r[i])<0&&Object.prototype.propertyIsEnumerable.call(e,r[i])&&(n[r[i]]=e[r[i]]);return n};const aO=["getTargetContainer","getPopupContainer","renderEmpty","input","pagination","form","select","button"];let oN;function lO(){return oN||Yv}function cO(e){return Object.keys(e).some(t=>t.endsWith("Color"))}const uO=e=>{const{prefixCls:t,iconPrefixCls:n,theme:r,holderRender:i}=e;t!==void 0&&(oN=t),r&&cO(r)&&_D(lO(),r)},dO=e=>{const{children:t,csp:n,autoInsertSpaceInButton:r,alert:i,anchor:s,form:o,locale:a,componentSize:l,direction:c,space:u,splitter:d,virtual:f,dropdownMatchSelectWidth:p,popupMatchSelectWidth:m,popupOverflow:v,legacyLocale:b,parentContext:_,iconPrefixCls:x,theme:y,componentDisabled:w,segmented:C,statistic:k,spin:T,calendar:N,carousel:z,cascader:P,collapse:B,typography:R,checkbox:I,descriptions:j,divider:L,drawer:$,skeleton:F,steps:D,image:O,layout:E,list:H,mentions:V,modal:A,progress:ne,result:ae,slider:G,breadcrumb:ye,menu:Fe,pagination:ue,input:Ie,textArea:Re,empty:Ke,badge:ve,radio:ze,rate:fn,switch:it,transfer:Rt,avatar:Gt,message:Mt,tag:bt,table:Qe,card:st,tabs:wt,timeline:pn,timePicker:on,upload:U,notification:Z,tree:_e,colorPicker:ke,datePicker:He,rangePicker:Nt,flex:Yt,wave:Xt,dropdown:se,warning:K,tour:we,tooltip:ht,popover:an,popconfirm:_l,floatButton:xl,floatButtonGroup:zo,variant:Hp,inputNumber:ju,treeSelect:Du}=e,Ou=g.useCallback((oe,de)=>{const{prefixCls:je}=e;if(de)return de;const $t=je||_.getPrefixCls("");return oe?`${$t}-${oe}`:$t},[_.getPrefixCls,e.prefixCls]),zs=x||_.iconPrefixCls||qT,Wi=n||_.csp;RD(zs,Wi);const yl=jD(y,_.theme,{prefixCls:Ou("")}),Vi={csp:Wi,autoInsertSpaceInButton:r,alert:i,anchor:s,locale:a||b,direction:c,space:u,splitter:d,virtual:f,popupMatchSelectWidth:m??p,popupOverflow:v,getPrefixCls:Ou,iconPrefixCls:zs,theme:yl,segmented:C,statistic:k,spin:T,calendar:N,carousel:z,cascader:P,collapse:B,typography:R,checkbox:I,descriptions:j,divider:L,drawer:$,skeleton:F,steps:D,image:O,input:Ie,textArea:Re,layout:E,list:H,mentions:V,modal:A,progress:ne,result:ae,slider:G,breadcrumb:ye,menu:Fe,pagination:ue,empty:Ke,badge:ve,radio:ze,rate:fn,switch:it,transfer:Rt,avatar:Gt,message:Mt,tag:bt,table:Qe,card:st,tabs:wt,timeline:pn,timePicker:on,upload:U,notification:Z,tree:_e,colorPicker:ke,datePicker:He,rangePicker:Nt,flex:Yt,wave:Xt,dropdown:se,warning:K,tour:we,tooltip:ht,popover:an,popconfirm:_l,floatButton:xl,floatButtonGroup:zo,variant:Hp,inputNumber:ju,treeSelect:Du},qi=Object.assign({},_);Object.keys(Vi).forEach(oe=>{Vi[oe]!==void 0&&(qi[oe]=Vi[oe])}),aO.forEach(oe=>{const de=e[oe];de&&(qi[oe]=de)}),typeof r<"u"&&(qi.button=Object.assign({autoInsertSpace:r},qi.button));const Ki=fT(()=>qi,qi,(oe,de)=>{const je=Object.keys(oe),$t=Object.keys(de);return je.length!==$t.length||je.some($s=>oe[$s]!==de[$s])}),{layer:$o}=g.useContext(Xf),Fo=g.useMemo(()=>({prefixCls:zs,csp:Wi,layer:$o?"antd":void 0}),[zs,Wi,$o]);let zt=g.createElement(g.Fragment,null,g.createElement(sO,{dropdownMatchSelectWidth:p}),t);const bl=g.useMemo(()=>{var oe,de,je,$t;return Xj(((oe=Jf.Form)===null||oe===void 0?void 0:oe.defaultValidateMessages)||{},((je=(de=Ki.locale)===null||de===void 0?void 0:de.Form)===null||je===void 0?void 0:je.defaultValidateMessages)||{},(($t=Ki.form)===null||$t===void 0?void 0:$t.validateMessages)||{},(o==null?void 0:o.validateMessages)||{})},[Ki,o==null?void 0:o.validateMessages]);Object.keys(bl).length>0&&(zt=g.createElement(Zj.Provider,{value:bl},zt)),a&&(zt=g.createElement(tD,{locale:a,_ANT_MARK__:eD},zt)),zt=g.createElement(qj.Provider,{value:Fo},zt),l&&(zt=g.createElement(yD,{size:l},zt)),zt=g.createElement(iO,null,zt);const te=g.useMemo(()=>{const oe=yl||{},{algorithm:de,token:je,components:$t,cssVar:$s}=oe,R5=oO(oe,["algorithm","token","components","cssVar"]),f1=de&&(!Array.isArray(de)||de.length>0)?Rv(de):WT,Up={};Object.entries($t||{}).forEach(([M5,A5])=>{const fi=Object.assign({},A5);"algorithm"in fi&&(fi.algorithm===!0?fi.theme=f1:(Array.isArray(fi.algorithm)||typeof fi.algorithm=="function")&&(fi.theme=Rv(fi.algorithm)),delete fi.algorithm),Up[M5]=fi});const p1=Object.assign(Object.assign({},Fc),je);return Object.assign(Object.assign({},R5),{theme:f1,token:p1,components:Up,override:Object.assign({override:p1},Up),cssVar:$s})},[yl]);return y&&(zt=g.createElement(VT.Provider,{value:te},zt)),Ki.warning&&(zt=g.createElement(Qj.Provider,{value:Ki.warning},zt)),w!==void 0&&(zt=g.createElement(xD,{disabled:w},zt)),g.createElement(ep.Provider,{value:Ki},zt)},il=e=>{const t=g.useContext(ep),n=g.useContext($T);return g.createElement(dO,Object.assign({parentContext:t,legacyLocale:n},e))};il.ConfigContext=ep;il.SizeContext=Hc;il.config=uO;il.useConfig=bD;Object.defineProperty(il,"SizeContext",{get:()=>Hc});const ar=(e,t)=>new _t(e).setA(t).toRgbString(),Wo=(e,t)=>new _t(e).lighten(t).toHexString(),hO=e=>{const t=Ba(e,{theme:"dark"});return{1:t[0],2:t[1],3:t[2],4:t[3],5:t[6],6:t[5],7:t[4],8:t[6],9:t[5],10:t[4]}},fO=(e,t)=>{const n=e||"#000",r=t||"#fff";return{colorBgBase:n,colorTextBase:r,colorText:ar(r,.85),colorTextSecondary:ar(r,.65),colorTextTertiary:ar(r,.45),colorTextQuaternary:ar(r,.25),colorFill:ar(r,.18),colorFillSecondary:ar(r,.12),colorFillTertiary:ar(r,.08),colorFillQuaternary:ar(r,.04),colorBgSolid:ar(r,.95),colorBgSolidHover:ar(r,1),colorBgSolidActive:ar(r,.9),colorBgElevated:Wo(n,12),colorBgContainer:Wo(n,8),colorBgLayout:Wo(n,0),colorBgSpotlight:Wo(n,26),colorBgBlur:ar(r,.04),colorBorder:Wo(n,26),colorBorderSecondary:Wo(n,19)}},pO=(e,t)=>{const n=Object.keys(Px).map(s=>{const o=Ba(e[s],{theme:"dark"});return Array.from({length:10},()=>1).reduce((a,l,c)=>(a[`${s}-${c+1}`]=o[c],a[`${s}${c+1}`]=o[c],a),{})}).reduce((s,o)=>(s=Object.assign(Object.assign({},s),o),s),{}),r=t??Ix(e),i=UT(e,{generateColorPalettes:hO,generateNeutralColorPalettes:fO});return Object.assign(Object.assign(Object.assign(Object.assign({},r),n),i),{colorPrimaryBg:i.colorPrimaryBorder,colorPrimaryBgHover:i.colorPrimaryBorderHover})},aw={defaultSeed:zh.token,defaultAlgorithm:Ix,darkAlgorithm:pO};function lw({children:e}){const t=bx(),[n,r]=g.useState(t.theme);return g.useEffect(()=>t.onThemeChange(r),[t]),h.jsx(il,{theme:{algorithm:n.mode==="dark"?aw.darkAlgorithm:aw.defaultAlgorithm,token:{colorPrimary:n.colorPrimary,colorBgContainer:n.colorBgContainer,colorText:n.colorText,colorBorder:n.colorBorder}},children:e})}var Ye;(function(e){e.assertEqual=i=>{};function t(i){}e.assertIs=t;function n(i){throw new Error}e.assertNever=n,e.arrayToEnum=i=>{const s={};for(const o of i)s[o]=o;return s},e.getValidEnumValues=i=>{const s=e.objectKeys(i).filter(a=>typeof i[i[a]]!="number"),o={};for(const a of s)o[a]=i[a];return e.objectValues(o)},e.objectValues=i=>e.objectKeys(i).map(function(s){return i[s]}),e.objectKeys=typeof Object.keys=="function"?i=>Object.keys(i):i=>{const s=[];for(const o in i)Object.prototype.hasOwnProperty.call(i,o)&&s.push(o);return s},e.find=(i,s)=>{for(const o of i)if(s(o))return o},e.isInteger=typeof Number.isInteger=="function"?i=>Number.isInteger(i):i=>typeof i=="number"&&Number.isFinite(i)&&Math.floor(i)===i;function r(i,s=" | "){return i.map(o=>typeof o=="string"?`'${o}'`:o).join(s)}e.joinValues=r,e.jsonStringifyReplacer=(i,s)=>typeof s=="bigint"?s.toString():s})(Ye||(Ye={}));var cw;(function(e){e.mergeShapes=(t,n)=>({...t,...n})})(cw||(cw={}));const ce=Ye.arrayToEnum(["string","nan","number","integer","float","boolean","date","bigint","symbol","function","undefined","null","array","object","unknown","promise","void","never","map","set"]),ss=e=>{switch(typeof e){case"undefined":return ce.undefined;case"string":return ce.string;case"number":return Number.isNaN(e)?ce.nan:ce.number;case"boolean":return ce.boolean;case"function":return ce.function;case"bigint":return ce.bigint;case"symbol":return ce.symbol;case"object":return Array.isArray(e)?ce.array:e===null?ce.null:e.then&&typeof e.then=="function"&&e.catch&&typeof e.catch=="function"?ce.promise:typeof Map<"u"&&e instanceof Map?ce.map:typeof Set<"u"&&e instanceof Set?ce.set:typeof Date<"u"&&e instanceof Date?ce.date:ce.object;default:return ce.unknown}},Y=Ye.arrayToEnum(["invalid_type","invalid_literal","custom","invalid_union","invalid_union_discriminator","invalid_enum_value","unrecognized_keys","invalid_arguments","invalid_return_type","invalid_date","invalid_string","too_small","too_big","invalid_intersection_types","not_multiple_of","not_finite"]);class Ai extends Error{get errors(){return this.issues}constructor(t){super(),this.issues=[],this.addIssue=r=>{this.issues=[...this.issues,r]},this.addIssues=(r=[])=>{this.issues=[...this.issues,...r]};const n=new.target.prototype;Object.setPrototypeOf?Object.setPrototypeOf(this,n):this.__proto__=n,this.name="ZodError",this.issues=t}format(t){const n=t||function(s){return s.message},r={_errors:[]},i=s=>{for(const o of s.issues)if(o.code==="invalid_union")o.unionErrors.map(i);else if(o.code==="invalid_return_type")i(o.returnTypeError);else if(o.code==="invalid_arguments")i(o.argumentsError);else if(o.path.length===0)r._errors.push(n(o));else{let a=r,l=0;for(;l<o.path.length;){const c=o.path[l];l===o.path.length-1?(a[c]=a[c]||{_errors:[]},a[c]._errors.push(n(o))):a[c]=a[c]||{_errors:[]},a=a[c],l++}}};return i(this),r}static assert(t){if(!(t instanceof Ai))throw new Error(`Not a ZodError: ${t}`)}toString(){return this.message}get message(){return JSON.stringify(this.issues,Ye.jsonStringifyReplacer,2)}get isEmpty(){return this.issues.length===0}flatten(t=n=>n.message){const n={},r=[];for(const i of this.issues)if(i.path.length>0){const s=i.path[0];n[s]=n[s]||[],n[s].push(t(i))}else r.push(t(i));return{formErrors:r,fieldErrors:n}}get formErrors(){return this.flatten()}}Ai.create=e=>new Ai(e);const r0=(e,t)=>{let n;switch(e.code){case Y.invalid_type:e.received===ce.undefined?n="Required":n=`Expected ${e.expected}, received ${e.received}`;break;case Y.invalid_literal:n=`Invalid literal value, expected ${JSON.stringify(e.expected,Ye.jsonStringifyReplacer)}`;break;case Y.unrecognized_keys:n=`Unrecognized key(s) in object: ${Ye.joinValues(e.keys,", ")}`;break;case Y.invalid_union:n="Invalid input";break;case Y.invalid_union_discriminator:n=`Invalid discriminator value. Expected ${Ye.joinValues(e.options)}`;break;case Y.invalid_enum_value:n=`Invalid enum value. Expected ${Ye.joinValues(e.options)}, received '${e.received}'`;break;case Y.invalid_arguments:n="Invalid function arguments";break;case Y.invalid_return_type:n="Invalid function return type";break;case Y.invalid_date:n="Invalid date";break;case Y.invalid_string:typeof e.validation=="object"?"includes"in e.validation?(n=`Invalid input: must include "${e.validation.includes}"`,typeof e.validation.position=="number"&&(n=`${n} at one or more positions greater than or equal to ${e.validation.position}`)):"startsWith"in e.validation?n=`Invalid input: must start with "${e.validation.startsWith}"`:"endsWith"in e.validation?n=`Invalid input: must end with "${e.validation.endsWith}"`:Ye.assertNever(e.validation):e.validation!=="regex"?n=`Invalid ${e.validation}`:n="Invalid";break;case Y.too_small:e.type==="array"?n=`Array must contain ${e.exact?"exactly":e.inclusive?"at least":"more than"} ${e.minimum} element(s)`:e.type==="string"?n=`String must contain ${e.exact?"exactly":e.inclusive?"at least":"over"} ${e.minimum} character(s)`:e.type==="number"?n=`Number must be ${e.exact?"exactly equal to ":e.inclusive?"greater than or equal to ":"greater than "}${e.minimum}`:e.type==="bigint"?n=`Number must be ${e.exact?"exactly equal to ":e.inclusive?"greater than or equal to ":"greater than "}${e.minimum}`:e.type==="date"?n=`Date must be ${e.exact?"exactly equal to ":e.inclusive?"greater than or equal to ":"greater than "}${new Date(Number(e.minimum))}`:n="Invalid input";break;case Y.too_big:e.type==="array"?n=`Array must contain ${e.exact?"exactly":e.inclusive?"at most":"less than"} ${e.maximum} element(s)`:e.type==="string"?n=`String must contain ${e.exact?"exactly":e.inclusive?"at most":"under"} ${e.maximum} character(s)`:e.type==="number"?n=`Number must be ${e.exact?"exactly":e.inclusive?"less than or equal to":"less than"} ${e.maximum}`:e.type==="bigint"?n=`BigInt must be ${e.exact?"exactly":e.inclusive?"less than or equal to":"less than"} ${e.maximum}`:e.type==="date"?n=`Date must be ${e.exact?"exactly":e.inclusive?"smaller than or equal to":"smaller than"} ${new Date(Number(e.maximum))}`:n="Invalid input";break;case Y.custom:n="Invalid input";break;case Y.invalid_intersection_types:n="Intersection results could not be merged";break;case Y.not_multiple_of:n=`Number must be a multiple of ${e.multipleOf}`;break;case Y.not_finite:n="Number must be finite";break;default:n=t.defaultError,Ye.assertNever(e)}return{message:n}};let mO=r0;function gO(){return mO}const vO=e=>{const{data:t,path:n,errorMaps:r,issueData:i}=e,s=[...n,...i.path||[]],o={...i,path:s};if(i.message!==void 0)return{...i,path:s,message:i.message};let a="";const l=r.filter(c=>!!c).slice().reverse();for(const c of l)a=c(o,{data:t,defaultError:a}).message;return{...i,path:s,message:a}};function re(e,t){const n=gO(),r=vO({issueData:t,data:e.data,path:e.path,errorMaps:[e.common.contextualErrorMap,e.schemaErrorMap,n,n===r0?void 0:r0].filter(i=>!!i)});e.common.issues.push(r)}class Pn{constructor(){this.value="valid"}dirty(){this.value==="valid"&&(this.value="dirty")}abort(){this.value!=="aborted"&&(this.value="aborted")}static mergeArray(t,n){const r=[];for(const i of n){if(i.status==="aborted")return Te;i.status==="dirty"&&t.dirty(),r.push(i.value)}return{status:t.value,value:r}}static async mergeObjectAsync(t,n){const r=[];for(const i of n){const s=await i.key,o=await i.value;r.push({key:s,value:o})}return Pn.mergeObjectSync(t,r)}static mergeObjectSync(t,n){const r={};for(const i of n){const{key:s,value:o}=i;if(s.status==="aborted"||o.status==="aborted")return Te;s.status==="dirty"&&t.dirty(),o.status==="dirty"&&t.dirty(),s.value!=="__proto__"&&(typeof o.value<"u"||i.alwaysSet)&&(r[s.value]=o.value)}return{status:t.value,value:r}}}const Te=Object.freeze({status:"aborted"}),Kl=e=>({status:"dirty",value:e}),wr=e=>({status:"valid",value:e}),uw=e=>e.status==="aborted",dw=e=>e.status==="dirty",za=e=>e.status==="valid",$h=e=>typeof Promise<"u"&&e instanceof Promise;var ge;(function(e){e.errToObj=t=>typeof t=="string"?{message:t}:t||{},e.toString=t=>typeof t=="string"?t:t==null?void 0:t.message})(ge||(ge={}));class ii{constructor(t,n,r,i){this._cachedPath=[],this.parent=t,this.data=n,this._path=r,this._key=i}get path(){return this._cachedPath.length||(Array.isArray(this._key)?this._cachedPath.push(...this._path,...this._key):this._cachedPath.push(...this._path,this._key)),this._cachedPath}}const hw=(e,t)=>{if(za(t))return{success:!0,data:t.value};if(!e.common.issues.length)throw new Error("Validation failed but no issues detected.");return{success:!1,get error(){if(this._error)return this._error;const n=new Ai(e.common.issues);return this._error=n,this._error}}};function Le(e){if(!e)return{};const{errorMap:t,invalid_type_error:n,required_error:r,description:i}=e;if(t&&(n||r))throw new Error(`Can't use "invalid_type_error" or "required_error" in conjunction with custom error map.`);return t?{errorMap:t,description:i}:{errorMap:(o,a)=>{const{message:l}=e;return o.code==="invalid_enum_value"?{message:l??a.defaultError}:typeof a.data>"u"?{message:l??r??a.defaultError}:o.code!=="invalid_type"?{message:a.defaultError}:{message:l??n??a.defaultError}},description:i}}class qe{get description(){return this._def.description}_getType(t){return ss(t.data)}_getOrReturnCtx(t,n){return n||{common:t.parent.common,data:t.data,parsedType:ss(t.data),schemaErrorMap:this._def.errorMap,path:t.path,parent:t.parent}}_processInputParams(t){return{status:new Pn,ctx:{common:t.parent.common,data:t.data,parsedType:ss(t.data),schemaErrorMap:this._def.errorMap,path:t.path,parent:t.parent}}}_parseSync(t){const n=this._parse(t);if($h(n))throw new Error("Synchronous parse encountered promise.");return n}_parseAsync(t){const n=this._parse(t);return Promise.resolve(n)}parse(t,n){const r=this.safeParse(t,n);if(r.success)return r.data;throw r.error}safeParse(t,n){const r={common:{issues:[],async:(n==null?void 0:n.async)??!1,contextualErrorMap:n==null?void 0:n.errorMap},path:(n==null?void 0:n.path)||[],schemaErrorMap:this._def.errorMap,parent:null,data:t,parsedType:ss(t)},i=this._parseSync({data:t,path:r.path,parent:r});return hw(r,i)}"~validate"(t){var r,i;const n={common:{issues:[],async:!!this["~standard"].async},path:[],schemaErrorMap:this._def.errorMap,parent:null,data:t,parsedType:ss(t)};if(!this["~standard"].async)try{const s=this._parseSync({data:t,path:[],parent:n});return za(s)?{value:s.value}:{issues:n.common.issues}}catch(s){(i=(r=s==null?void 0:s.message)==null?void 0:r.toLowerCase())!=null&&i.includes("encountered")&&(this["~standard"].async=!0),n.common={issues:[],async:!0}}return this._parseAsync({data:t,path:[],parent:n}).then(s=>za(s)?{value:s.value}:{issues:n.common.issues})}async parseAsync(t,n){const r=await this.safeParseAsync(t,n);if(r.success)return r.data;throw r.error}async safeParseAsync(t,n){const r={common:{issues:[],contextualErrorMap:n==null?void 0:n.errorMap,async:!0},path:(n==null?void 0:n.path)||[],schemaErrorMap:this._def.errorMap,parent:null,data:t,parsedType:ss(t)},i=this._parse({data:t,path:r.path,parent:r}),s=await($h(i)?i:Promise.resolve(i));return hw(r,s)}refine(t,n){const r=i=>typeof n=="string"||typeof n>"u"?{message:n}:typeof n=="function"?n(i):n;return this._refinement((i,s)=>{const o=t(i),a=()=>s.addIssue({code:Y.custom,...r(i)});return typeof Promise<"u"&&o instanceof Promise?o.then(l=>l?!0:(a(),!1)):o?!0:(a(),!1)})}refinement(t,n){return this._refinement((r,i)=>t(r)?!0:(i.addIssue(typeof n=="function"?n(r,i):n),!1))}_refinement(t){return new go({schema:this,typeName:Ne.ZodEffects,effect:{type:"refinement",refinement:t}})}superRefine(t){return this._refinement(t)}constructor(t){this.spa=this.safeParseAsync,this._def=t,this.parse=this.parse.bind(this),this.safeParse=this.safeParse.bind(this),this.parseAsync=this.parseAsync.bind(this),this.safeParseAsync=this.safeParseAsync.bind(this),this.spa=this.spa.bind(this),this.refine=this.refine.bind(this),this.refinement=this.refinement.bind(this),this.superRefine=this.superRefine.bind(this),this.optional=this.optional.bind(this),this.nullable=this.nullable.bind(this),this.nullish=this.nullish.bind(this),this.array=this.array.bind(this),this.promise=this.promise.bind(this),this.or=this.or.bind(this),this.and=this.and.bind(this),this.transform=this.transform.bind(this),this.brand=this.brand.bind(this),this.default=this.default.bind(this),this.catch=this.catch.bind(this),this.describe=this.describe.bind(this),this.pipe=this.pipe.bind(this),this.readonly=this.readonly.bind(this),this.isNullable=this.isNullable.bind(this),this.isOptional=this.isOptional.bind(this),this["~standard"]={version:1,vendor:"zod",validate:n=>this["~validate"](n)}}optional(){return Ti.create(this,this._def)}nullable(){return vo.create(this,this._def)}nullish(){return this.nullable().optional()}array(){return ei.create(this)}promise(){return qh.create(this,this._def)}or(t){return Hh.create([this,t],this._def)}and(t){return Uh.create(this,t,this._def)}transform(t){return new go({...Le(this._def),schema:this,typeName:Ne.ZodEffects,effect:{type:"transform",transform:t}})}default(t){const n=typeof t=="function"?t:()=>t;return new Kh({...Le(this._def),innerType:this,defaultValue:n,typeName:Ne.ZodDefault})}brand(){return new uN({typeName:Ne.ZodBranded,type:this,...Le(this._def)})}catch(t){const n=typeof t=="function"?t:()=>t;return new Gh({...Le(this._def),innerType:this,catchValue:n,typeName:Ne.ZodCatch})}describe(t){const n=this.constructor;return new n({...this._def,description:t})}pipe(t){return Ax.create(this,t)}readonly(){return Yh.create(this)}isOptional(){return this.safeParse(void 0).success}isNullable(){return this.safeParse(null).success}}const _O=/^c[^\s-]{8,}$/i,xO=/^[0-9a-z]+$/,yO=/^[0-9A-HJKMNP-TV-Z]{26}$/i,bO=/^[0-9a-fA-F]{8}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{12}$/i,wO=/^[a-z0-9_-]{21}$/i,SO=/^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$/,kO=/^[-+]?P(?!$)(?:(?:[-+]?\d+Y)|(?:[-+]?\d+[.,]\d+Y$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:(?:[-+]?\d+W)|(?:[-+]?\d+[.,]\d+W$))?(?:(?:[-+]?\d+D)|(?:[-+]?\d+[.,]\d+D$))?(?:T(?=[\d+-])(?:(?:[-+]?\d+H)|(?:[-+]?\d+[.,]\d+H$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:[-+]?\d+(?:[.,]\d+)?S)?)??$/,CO=/^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i,EO="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$";let Em;const TO=/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])$/,NO=/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\/(3[0-2]|[12]?[0-9])$/,PO=/^(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))$/,IO=/^(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/,RO=/^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,MO=/^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$/,aN="((\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-((0[13578]|1[02])-(0[1-9]|[12]\\d|3[01])|(0[469]|11)-(0[1-9]|[12]\\d|30)|(02)-(0[1-9]|1\\d|2[0-8])))",AO=new RegExp(`^${aN}$`);function lN(e){let t="[0-5]\\d";e.precision?t=`${t}\\.\\d{${e.precision}}`:e.precision==null&&(t=`${t}(\\.\\d+)?`);const n=e.precision?"+":"?";return`([01]\\d|2[0-3]):[0-5]\\d(:${t})${n}`}function LO(e){return new RegExp(`^${lN(e)}$`)}function jO(e){let t=`${aN}T${lN(e)}`;const n=[];return n.push(e.local?"Z?":"Z"),e.offset&&n.push("([+-]\\d{2}:?\\d{2})"),t=`${t}(${n.join("|")})`,new RegExp(`^${t}$`)}function DO(e,t){return!!((t==="v4"||!t)&&TO.test(e)||(t==="v6"||!t)&&PO.test(e))}function OO(e,t){if(!SO.test(e))return!1;try{const[n]=e.split(".");if(!n)return!1;const r=n.replace(/-/g,"+").replace(/_/g,"/").padEnd(n.length+(4-n.length%4)%4,"="),i=JSON.parse(atob(r));return!(typeof i!="object"||i===null||"typ"in i&&(i==null?void 0:i.typ)!=="JWT"||!i.alg||t&&i.alg!==t)}catch{return!1}}function BO(e,t){return!!((t==="v4"||!t)&&NO.test(e)||(t==="v6"||!t)&&IO.test(e))}class Si extends qe{_parse(t){if(this._def.coerce&&(t.data=String(t.data)),this._getType(t)!==ce.string){const s=this._getOrReturnCtx(t);return re(s,{code:Y.invalid_type,expected:ce.string,received:s.parsedType}),Te}const r=new Pn;let i;for(const s of this._def.checks)if(s.kind==="min")t.data.length<s.value&&(i=this._getOrReturnCtx(t,i),re(i,{code:Y.too_small,minimum:s.value,type:"string",inclusive:!0,exact:!1,message:s.message}),r.dirty());else if(s.kind==="max")t.data.length>s.value&&(i=this._getOrReturnCtx(t,i),re(i,{code:Y.too_big,maximum:s.value,type:"string",inclusive:!0,exact:!1,message:s.message}),r.dirty());else if(s.kind==="length"){const o=t.data.length>s.value,a=t.data.length<s.value;(o||a)&&(i=this._getOrReturnCtx(t,i),o?re(i,{code:Y.too_big,maximum:s.value,type:"string",inclusive:!0,exact:!0,message:s.message}):a&&re(i,{code:Y.too_small,minimum:s.value,type:"string",inclusive:!0,exact:!0,message:s.message}),r.dirty())}else if(s.kind==="email")CO.test(t.data)||(i=this._getOrReturnCtx(t,i),re(i,{validation:"email",code:Y.invalid_string,message:s.message}),r.dirty());else if(s.kind==="emoji")Em||(Em=new RegExp(EO,"u")),Em.test(t.data)||(i=this._getOrReturnCtx(t,i),re(i,{validation:"emoji",code:Y.invalid_string,message:s.message}),r.dirty());else if(s.kind==="uuid")bO.test(t.data)||(i=this._getOrReturnCtx(t,i),re(i,{validation:"uuid",code:Y.invalid_string,message:s.message}),r.dirty());else if(s.kind==="nanoid")wO.test(t.data)||(i=this._getOrReturnCtx(t,i),re(i,{validation:"nanoid",code:Y.invalid_string,message:s.message}),r.dirty());else if(s.kind==="cuid")_O.test(t.data)||(i=this._getOrReturnCtx(t,i),re(i,{validation:"cuid",code:Y.invalid_string,message:s.message}),r.dirty());else if(s.kind==="cuid2")xO.test(t.data)||(i=this._getOrReturnCtx(t,i),re(i,{validation:"cuid2",code:Y.invalid_string,message:s.message}),r.dirty());else if(s.kind==="ulid")yO.test(t.data)||(i=this._getOrReturnCtx(t,i),re(i,{validation:"ulid",code:Y.invalid_string,message:s.message}),r.dirty());else if(s.kind==="url")try{new URL(t.data)}catch{i=this._getOrReturnCtx(t,i),re(i,{validation:"url",code:Y.invalid_string,message:s.message}),r.dirty()}else s.kind==="regex"?(s.regex.lastIndex=0,s.regex.test(t.data)||(i=this._getOrReturnCtx(t,i),re(i,{validation:"regex",code:Y.invalid_string,message:s.message}),r.dirty())):s.kind==="trim"?t.data=t.data.trim():s.kind==="includes"?t.data.includes(s.value,s.position)||(i=this._getOrReturnCtx(t,i),re(i,{code:Y.invalid_string,validation:{includes:s.value,position:s.position},message:s.message}),r.dirty()):s.kind==="toLowerCase"?t.data=t.data.toLowerCase():s.kind==="toUpperCase"?t.data=t.data.toUpperCase():s.kind==="startsWith"?t.data.startsWith(s.value)||(i=this._getOrReturnCtx(t,i),re(i,{code:Y.invalid_string,validation:{startsWith:s.value},message:s.message}),r.dirty()):s.kind==="endsWith"?t.data.endsWith(s.value)||(i=this._getOrReturnCtx(t,i),re(i,{code:Y.invalid_string,validation:{endsWith:s.value},message:s.message}),r.dirty()):s.kind==="datetime"?jO(s).test(t.data)||(i=this._getOrReturnCtx(t,i),re(i,{code:Y.invalid_string,validation:"datetime",message:s.message}),r.dirty()):s.kind==="date"?AO.test(t.data)||(i=this._getOrReturnCtx(t,i),re(i,{code:Y.invalid_string,validation:"date",message:s.message}),r.dirty()):s.kind==="time"?LO(s).test(t.data)||(i=this._getOrReturnCtx(t,i),re(i,{code:Y.invalid_string,validation:"time",message:s.message}),r.dirty()):s.kind==="duration"?kO.test(t.data)||(i=this._getOrReturnCtx(t,i),re(i,{validation:"duration",code:Y.invalid_string,message:s.message}),r.dirty()):s.kind==="ip"?DO(t.data,s.version)||(i=this._getOrReturnCtx(t,i),re(i,{validation:"ip",code:Y.invalid_string,message:s.message}),r.dirty()):s.kind==="jwt"?OO(t.data,s.alg)||(i=this._getOrReturnCtx(t,i),re(i,{validation:"jwt",code:Y.invalid_string,message:s.message}),r.dirty()):s.kind==="cidr"?BO(t.data,s.version)||(i=this._getOrReturnCtx(t,i),re(i,{validation:"cidr",code:Y.invalid_string,message:s.message}),r.dirty()):s.kind==="base64"?RO.test(t.data)||(i=this._getOrReturnCtx(t,i),re(i,{validation:"base64",code:Y.invalid_string,message:s.message}),r.dirty()):s.kind==="base64url"?MO.test(t.data)||(i=this._getOrReturnCtx(t,i),re(i,{validation:"base64url",code:Y.invalid_string,message:s.message}),r.dirty()):Ye.assertNever(s);return{status:r.value,value:t.data}}_regex(t,n,r){return this.refinement(i=>t.test(i),{validation:n,code:Y.invalid_string,...ge.errToObj(r)})}_addCheck(t){return new Si({...this._def,checks:[...this._def.checks,t]})}email(t){return this._addCheck({kind:"email",...ge.errToObj(t)})}url(t){return this._addCheck({kind:"url",...ge.errToObj(t)})}emoji(t){return this._addCheck({kind:"emoji",...ge.errToObj(t)})}uuid(t){return this._addCheck({kind:"uuid",...ge.errToObj(t)})}nanoid(t){return this._addCheck({kind:"nanoid",...ge.errToObj(t)})}cuid(t){return this._addCheck({kind:"cuid",...ge.errToObj(t)})}cuid2(t){return this._addCheck({kind:"cuid2",...ge.errToObj(t)})}ulid(t){return this._addCheck({kind:"ulid",...ge.errToObj(t)})}base64(t){return this._addCheck({kind:"base64",...ge.errToObj(t)})}base64url(t){return this._addCheck({kind:"base64url",...ge.errToObj(t)})}jwt(t){return this._addCheck({kind:"jwt",...ge.errToObj(t)})}ip(t){return this._addCheck({kind:"ip",...ge.errToObj(t)})}cidr(t){return this._addCheck({kind:"cidr",...ge.errToObj(t)})}datetime(t){return typeof t=="string"?this._addCheck({kind:"datetime",precision:null,offset:!1,local:!1,message:t}):this._addCheck({kind:"datetime",precision:typeof(t==null?void 0:t.precision)>"u"?null:t==null?void 0:t.precision,offset:(t==null?void 0:t.offset)??!1,local:(t==null?void 0:t.local)??!1,...ge.errToObj(t==null?void 0:t.message)})}date(t){return this._addCheck({kind:"date",message:t})}time(t){return typeof t=="string"?this._addCheck({kind:"time",precision:null,message:t}):this._addCheck({kind:"time",precision:typeof(t==null?void 0:t.precision)>"u"?null:t==null?void 0:t.precision,...ge.errToObj(t==null?void 0:t.message)})}duration(t){return this._addCheck({kind:"duration",...ge.errToObj(t)})}regex(t,n){return this._addCheck({kind:"regex",regex:t,...ge.errToObj(n)})}includes(t,n){return this._addCheck({kind:"includes",value:t,position:n==null?void 0:n.position,...ge.errToObj(n==null?void 0:n.message)})}startsWith(t,n){return this._addCheck({kind:"startsWith",value:t,...ge.errToObj(n)})}endsWith(t,n){return this._addCheck({kind:"endsWith",value:t,...ge.errToObj(n)})}min(t,n){return this._addCheck({kind:"min",value:t,...ge.errToObj(n)})}max(t,n){return this._addCheck({kind:"max",value:t,...ge.errToObj(n)})}length(t,n){return this._addCheck({kind:"length",value:t,...ge.errToObj(n)})}nonempty(t){return this.min(1,ge.errToObj(t))}trim(){return new Si({...this._def,checks:[...this._def.checks,{kind:"trim"}]})}toLowerCase(){return new Si({...this._def,checks:[...this._def.checks,{kind:"toLowerCase"}]})}toUpperCase(){return new Si({...this._def,checks:[...this._def.checks,{kind:"toUpperCase"}]})}get isDatetime(){return!!this._def.checks.find(t=>t.kind==="datetime")}get isDate(){return!!this._def.checks.find(t=>t.kind==="date")}get isTime(){return!!this._def.checks.find(t=>t.kind==="time")}get isDuration(){return!!this._def.checks.find(t=>t.kind==="duration")}get isEmail(){return!!this._def.checks.find(t=>t.kind==="email")}get isURL(){return!!this._def.checks.find(t=>t.kind==="url")}get isEmoji(){return!!this._def.checks.find(t=>t.kind==="emoji")}get isUUID(){return!!this._def.checks.find(t=>t.kind==="uuid")}get isNANOID(){return!!this._def.checks.find(t=>t.kind==="nanoid")}get isCUID(){return!!this._def.checks.find(t=>t.kind==="cuid")}get isCUID2(){return!!this._def.checks.find(t=>t.kind==="cuid2")}get isULID(){return!!this._def.checks.find(t=>t.kind==="ulid")}get isIP(){return!!this._def.checks.find(t=>t.kind==="ip")}get isCIDR(){return!!this._def.checks.find(t=>t.kind==="cidr")}get isBase64(){return!!this._def.checks.find(t=>t.kind==="base64")}get isBase64url(){return!!this._def.checks.find(t=>t.kind==="base64url")}get minLength(){let t=null;for(const n of this._def.checks)n.kind==="min"&&(t===null||n.value>t)&&(t=n.value);return t}get maxLength(){let t=null;for(const n of this._def.checks)n.kind==="max"&&(t===null||n.value<t)&&(t=n.value);return t}}Si.create=e=>new Si({checks:[],typeName:Ne.ZodString,coerce:(e==null?void 0:e.coerce)??!1,...Le(e)});function zO(e,t){const n=(e.toString().split(".")[1]||"").length,r=(t.toString().split(".")[1]||"").length,i=n>r?n:r,s=Number.parseInt(e.toFixed(i).replace(".","")),o=Number.parseInt(t.toFixed(i).replace(".",""));return s%o/10**i}class $a extends qe{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte,this.step=this.multipleOf}_parse(t){if(this._def.coerce&&(t.data=Number(t.data)),this._getType(t)!==ce.number){const s=this._getOrReturnCtx(t);return re(s,{code:Y.invalid_type,expected:ce.number,received:s.parsedType}),Te}let r;const i=new Pn;for(const s of this._def.checks)s.kind==="int"?Ye.isInteger(t.data)||(r=this._getOrReturnCtx(t,r),re(r,{code:Y.invalid_type,expected:"integer",received:"float",message:s.message}),i.dirty()):s.kind==="min"?(s.inclusive?t.data<s.value:t.data<=s.value)&&(r=this._getOrReturnCtx(t,r),re(r,{code:Y.too_small,minimum:s.value,type:"number",inclusive:s.inclusive,exact:!1,message:s.message}),i.dirty()):s.kind==="max"?(s.inclusive?t.data>s.value:t.data>=s.value)&&(r=this._getOrReturnCtx(t,r),re(r,{code:Y.too_big,maximum:s.value,type:"number",inclusive:s.inclusive,exact:!1,message:s.message}),i.dirty()):s.kind==="multipleOf"?zO(t.data,s.value)!==0&&(r=this._getOrReturnCtx(t,r),re(r,{code:Y.not_multiple_of,multipleOf:s.value,message:s.message}),i.dirty()):s.kind==="finite"?Number.isFinite(t.data)||(r=this._getOrReturnCtx(t,r),re(r,{code:Y.not_finite,message:s.message}),i.dirty()):Ye.assertNever(s);return{status:i.value,value:t.data}}gte(t,n){return this.setLimit("min",t,!0,ge.toString(n))}gt(t,n){return this.setLimit("min",t,!1,ge.toString(n))}lte(t,n){return this.setLimit("max",t,!0,ge.toString(n))}lt(t,n){return this.setLimit("max",t,!1,ge.toString(n))}setLimit(t,n,r,i){return new $a({...this._def,checks:[...this._def.checks,{kind:t,value:n,inclusive:r,message:ge.toString(i)}]})}_addCheck(t){return new $a({...this._def,checks:[...this._def.checks,t]})}int(t){return this._addCheck({kind:"int",message:ge.toString(t)})}positive(t){return this._addCheck({kind:"min",value:0,inclusive:!1,message:ge.toString(t)})}negative(t){return this._addCheck({kind:"max",value:0,inclusive:!1,message:ge.toString(t)})}nonpositive(t){return this._addCheck({kind:"max",value:0,inclusive:!0,message:ge.toString(t)})}nonnegative(t){return this._addCheck({kind:"min",value:0,inclusive:!0,message:ge.toString(t)})}multipleOf(t,n){return this._addCheck({kind:"multipleOf",value:t,message:ge.toString(n)})}finite(t){return this._addCheck({kind:"finite",message:ge.toString(t)})}safe(t){return this._addCheck({kind:"min",inclusive:!0,value:Number.MIN_SAFE_INTEGER,message:ge.toString(t)})._addCheck({kind:"max",inclusive:!0,value:Number.MAX_SAFE_INTEGER,message:ge.toString(t)})}get minValue(){let t=null;for(const n of this._def.checks)n.kind==="min"&&(t===null||n.value>t)&&(t=n.value);return t}get maxValue(){let t=null;for(const n of this._def.checks)n.kind==="max"&&(t===null||n.value<t)&&(t=n.value);return t}get isInt(){return!!this._def.checks.find(t=>t.kind==="int"||t.kind==="multipleOf"&&Ye.isInteger(t.value))}get isFinite(){let t=null,n=null;for(const r of this._def.checks){if(r.kind==="finite"||r.kind==="int"||r.kind==="multipleOf")return!0;r.kind==="min"?(n===null||r.value>n)&&(n=r.value):r.kind==="max"&&(t===null||r.value<t)&&(t=r.value)}return Number.isFinite(n)&&Number.isFinite(t)}}$a.create=e=>new $a({checks:[],typeName:Ne.ZodNumber,coerce:(e==null?void 0:e.coerce)||!1,...Le(e)});class Uc extends qe{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte}_parse(t){if(this._def.coerce)try{t.data=BigInt(t.data)}catch{return this._getInvalidInput(t)}if(this._getType(t)!==ce.bigint)return this._getInvalidInput(t);let r;const i=new Pn;for(const s of this._def.checks)s.kind==="min"?(s.inclusive?t.data<s.value:t.data<=s.value)&&(r=this._getOrReturnCtx(t,r),re(r,{code:Y.too_small,type:"bigint",minimum:s.value,inclusive:s.inclusive,message:s.message}),i.dirty()):s.kind==="max"?(s.inclusive?t.data>s.value:t.data>=s.value)&&(r=this._getOrReturnCtx(t,r),re(r,{code:Y.too_big,type:"bigint",maximum:s.value,inclusive:s.inclusive,message:s.message}),i.dirty()):s.kind==="multipleOf"?t.data%s.value!==BigInt(0)&&(r=this._getOrReturnCtx(t,r),re(r,{code:Y.not_multiple_of,multipleOf:s.value,message:s.message}),i.dirty()):Ye.assertNever(s);return{status:i.value,value:t.data}}_getInvalidInput(t){const n=this._getOrReturnCtx(t);return re(n,{code:Y.invalid_type,expected:ce.bigint,received:n.parsedType}),Te}gte(t,n){return this.setLimit("min",t,!0,ge.toString(n))}gt(t,n){return this.setLimit("min",t,!1,ge.toString(n))}lte(t,n){return this.setLimit("max",t,!0,ge.toString(n))}lt(t,n){return this.setLimit("max",t,!1,ge.toString(n))}setLimit(t,n,r,i){return new Uc({...this._def,checks:[...this._def.checks,{kind:t,value:n,inclusive:r,message:ge.toString(i)}]})}_addCheck(t){return new Uc({...this._def,checks:[...this._def.checks,t]})}positive(t){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!1,message:ge.toString(t)})}negative(t){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!1,message:ge.toString(t)})}nonpositive(t){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!0,message:ge.toString(t)})}nonnegative(t){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!0,message:ge.toString(t)})}multipleOf(t,n){return this._addCheck({kind:"multipleOf",value:t,message:ge.toString(n)})}get minValue(){let t=null;for(const n of this._def.checks)n.kind==="min"&&(t===null||n.value>t)&&(t=n.value);return t}get maxValue(){let t=null;for(const n of this._def.checks)n.kind==="max"&&(t===null||n.value<t)&&(t=n.value);return t}}Uc.create=e=>new Uc({checks:[],typeName:Ne.ZodBigInt,coerce:(e==null?void 0:e.coerce)??!1,...Le(e)});class i0 extends qe{_parse(t){if(this._def.coerce&&(t.data=!!t.data),this._getType(t)!==ce.boolean){const r=this._getOrReturnCtx(t);return re(r,{code:Y.invalid_type,expected:ce.boolean,received:r.parsedType}),Te}return wr(t.data)}}i0.create=e=>new i0({typeName:Ne.ZodBoolean,coerce:(e==null?void 0:e.coerce)||!1,...Le(e)});class Fh extends qe{_parse(t){if(this._def.coerce&&(t.data=new Date(t.data)),this._getType(t)!==ce.date){const s=this._getOrReturnCtx(t);return re(s,{code:Y.invalid_type,expected:ce.date,received:s.parsedType}),Te}if(Number.isNaN(t.data.getTime())){const s=this._getOrReturnCtx(t);return re(s,{code:Y.invalid_date}),Te}const r=new Pn;let i;for(const s of this._def.checks)s.kind==="min"?t.data.getTime()<s.value&&(i=this._getOrReturnCtx(t,i),re(i,{code:Y.too_small,message:s.message,inclusive:!0,exact:!1,minimum:s.value,type:"date"}),r.dirty()):s.kind==="max"?t.data.getTime()>s.value&&(i=this._getOrReturnCtx(t,i),re(i,{code:Y.too_big,message:s.message,inclusive:!0,exact:!1,maximum:s.value,type:"date"}),r.dirty()):Ye.assertNever(s);return{status:r.value,value:new Date(t.data.getTime())}}_addCheck(t){return new Fh({...this._def,checks:[...this._def.checks,t]})}min(t,n){return this._addCheck({kind:"min",value:t.getTime(),message:ge.toString(n)})}max(t,n){return this._addCheck({kind:"max",value:t.getTime(),message:ge.toString(n)})}get minDate(){let t=null;for(const n of this._def.checks)n.kind==="min"&&(t===null||n.value>t)&&(t=n.value);return t!=null?new Date(t):null}get maxDate(){let t=null;for(const n of this._def.checks)n.kind==="max"&&(t===null||n.value<t)&&(t=n.value);return t!=null?new Date(t):null}}Fh.create=e=>new Fh({checks:[],coerce:(e==null?void 0:e.coerce)||!1,typeName:Ne.ZodDate,...Le(e)});class fw extends qe{_parse(t){if(this._getType(t)!==ce.symbol){const r=this._getOrReturnCtx(t);return re(r,{code:Y.invalid_type,expected:ce.symbol,received:r.parsedType}),Te}return wr(t.data)}}fw.create=e=>new fw({typeName:Ne.ZodSymbol,...Le(e)});class s0 extends qe{_parse(t){if(this._getType(t)!==ce.undefined){const r=this._getOrReturnCtx(t);return re(r,{code:Y.invalid_type,expected:ce.undefined,received:r.parsedType}),Te}return wr(t.data)}}s0.create=e=>new s0({typeName:Ne.ZodUndefined,...Le(e)});class o0 extends qe{_parse(t){if(this._getType(t)!==ce.null){const r=this._getOrReturnCtx(t);return re(r,{code:Y.invalid_type,expected:ce.null,received:r.parsedType}),Te}return wr(t.data)}}o0.create=e=>new o0({typeName:Ne.ZodNull,...Le(e)});class pw extends qe{constructor(){super(...arguments),this._any=!0}_parse(t){return wr(t.data)}}pw.create=e=>new pw({typeName:Ne.ZodAny,...Le(e)});class a0 extends qe{constructor(){super(...arguments),this._unknown=!0}_parse(t){return wr(t.data)}}a0.create=e=>new a0({typeName:Ne.ZodUnknown,...Le(e)});class Ts extends qe{_parse(t){const n=this._getOrReturnCtx(t);return re(n,{code:Y.invalid_type,expected:ce.never,received:n.parsedType}),Te}}Ts.create=e=>new Ts({typeName:Ne.ZodNever,...Le(e)});class mw extends qe{_parse(t){if(this._getType(t)!==ce.undefined){const r=this._getOrReturnCtx(t);return re(r,{code:Y.invalid_type,expected:ce.void,received:r.parsedType}),Te}return wr(t.data)}}mw.create=e=>new mw({typeName:Ne.ZodVoid,...Le(e)});class ei extends qe{_parse(t){const{ctx:n,status:r}=this._processInputParams(t),i=this._def;if(n.parsedType!==ce.array)return re(n,{code:Y.invalid_type,expected:ce.array,received:n.parsedType}),Te;if(i.exactLength!==null){const o=n.data.length>i.exactLength.value,a=n.data.length<i.exactLength.value;(o||a)&&(re(n,{code:o?Y.too_big:Y.too_small,minimum:a?i.exactLength.value:void 0,maximum:o?i.exactLength.value:void 0,type:"array",inclusive:!0,exact:!0,message:i.exactLength.message}),r.dirty())}if(i.minLength!==null&&n.data.length<i.minLength.value&&(re(n,{code:Y.too_small,minimum:i.minLength.value,type:"array",inclusive:!0,exact:!1,message:i.minLength.message}),r.dirty()),i.maxLength!==null&&n.data.length>i.maxLength.value&&(re(n,{code:Y.too_big,maximum:i.maxLength.value,type:"array",inclusive:!0,exact:!1,message:i.maxLength.message}),r.dirty()),n.common.async)return Promise.all([...n.data].map((o,a)=>i.type._parseAsync(new ii(n,o,n.path,a)))).then(o=>Pn.mergeArray(r,o));const s=[...n.data].map((o,a)=>i.type._parseSync(new ii(n,o,n.path,a)));return Pn.mergeArray(r,s)}get element(){return this._def.type}min(t,n){return new ei({...this._def,minLength:{value:t,message:ge.toString(n)}})}max(t,n){return new ei({...this._def,maxLength:{value:t,message:ge.toString(n)}})}length(t,n){return new ei({...this._def,exactLength:{value:t,message:ge.toString(n)}})}nonempty(t){return this.min(1,t)}}ei.create=(e,t)=>new ei({type:e,minLength:null,maxLength:null,exactLength:null,typeName:Ne.ZodArray,...Le(t)});function Jo(e){if(e instanceof jt){const t={};for(const n in e.shape){const r=e.shape[n];t[n]=Ti.create(Jo(r))}return new jt({...e._def,shape:()=>t})}else return e instanceof ei?new ei({...e._def,type:Jo(e.element)}):e instanceof Ti?Ti.create(Jo(e.unwrap())):e instanceof vo?vo.create(Jo(e.unwrap())):e instanceof po?po.create(e.items.map(t=>Jo(t))):e}class jt extends qe{constructor(){super(...arguments),this._cached=null,this.nonstrict=this.passthrough,this.augment=this.extend}_getCached(){if(this._cached!==null)return this._cached;const t=this._def.shape(),n=Ye.objectKeys(t);return this._cached={shape:t,keys:n},this._cached}_parse(t){if(this._getType(t)!==ce.object){const c=this._getOrReturnCtx(t);return re(c,{code:Y.invalid_type,expected:ce.object,received:c.parsedType}),Te}const{status:r,ctx:i}=this._processInputParams(t),{shape:s,keys:o}=this._getCached(),a=[];if(!(this._def.catchall instanceof Ts&&this._def.unknownKeys==="strip"))for(const c in i.data)o.includes(c)||a.push(c);const l=[];for(const c of o){const u=s[c],d=i.data[c];l.push({key:{status:"valid",value:c},value:u._parse(new ii(i,d,i.path,c)),alwaysSet:c in i.data})}if(this._def.catchall instanceof Ts){const c=this._def.unknownKeys;if(c==="passthrough")for(const u of a)l.push({key:{status:"valid",value:u},value:{status:"valid",value:i.data[u]}});else if(c==="strict")a.length>0&&(re(i,{code:Y.unrecognized_keys,keys:a}),r.dirty());else if(c!=="strip")throw new Error("Internal ZodObject error: invalid unknownKeys value.")}else{const c=this._def.catchall;for(const u of a){const d=i.data[u];l.push({key:{status:"valid",value:u},value:c._parse(new ii(i,d,i.path,u)),alwaysSet:u in i.data})}}return i.common.async?Promise.resolve().then(async()=>{const c=[];for(const u of l){const d=await u.key,f=await u.value;c.push({key:d,value:f,alwaysSet:u.alwaysSet})}return c}).then(c=>Pn.mergeObjectSync(r,c)):Pn.mergeObjectSync(r,l)}get shape(){return this._def.shape()}strict(t){return ge.errToObj,new jt({...this._def,unknownKeys:"strict",...t!==void 0?{errorMap:(n,r)=>{var s,o;const i=((o=(s=this._def).errorMap)==null?void 0:o.call(s,n,r).message)??r.defaultError;return n.code==="unrecognized_keys"?{message:ge.errToObj(t).message??i}:{message:i}}}:{}})}strip(){return new jt({...this._def,unknownKeys:"strip"})}passthrough(){return new jt({...this._def,unknownKeys:"passthrough"})}extend(t){return new jt({...this._def,shape:()=>({...this._def.shape(),...t})})}merge(t){return new jt({unknownKeys:t._def.unknownKeys,catchall:t._def.catchall,shape:()=>({...this._def.shape(),...t._def.shape()}),typeName:Ne.ZodObject})}setKey(t,n){return this.augment({[t]:n})}catchall(t){return new jt({...this._def,catchall:t})}pick(t){const n={};for(const r of Ye.objectKeys(t))t[r]&&this.shape[r]&&(n[r]=this.shape[r]);return new jt({...this._def,shape:()=>n})}omit(t){const n={};for(const r of Ye.objectKeys(this.shape))t[r]||(n[r]=this.shape[r]);return new jt({...this._def,shape:()=>n})}deepPartial(){return Jo(this)}partial(t){const n={};for(const r of Ye.objectKeys(this.shape)){const i=this.shape[r];t&&!t[r]?n[r]=i:n[r]=i.optional()}return new jt({...this._def,shape:()=>n})}required(t){const n={};for(const r of Ye.objectKeys(this.shape))if(t&&!t[r])n[r]=this.shape[r];else{let s=this.shape[r];for(;s instanceof Ti;)s=s._def.innerType;n[r]=s}return new jt({...this._def,shape:()=>n})}keyof(){return cN(Ye.objectKeys(this.shape))}}jt.create=(e,t)=>new jt({shape:()=>e,unknownKeys:"strip",catchall:Ts.create(),typeName:Ne.ZodObject,...Le(t)});jt.strictCreate=(e,t)=>new jt({shape:()=>e,unknownKeys:"strict",catchall:Ts.create(),typeName:Ne.ZodObject,...Le(t)});jt.lazycreate=(e,t)=>new jt({shape:e,unknownKeys:"strip",catchall:Ts.create(),typeName:Ne.ZodObject,...Le(t)});class Hh extends qe{_parse(t){const{ctx:n}=this._processInputParams(t),r=this._def.options;function i(s){for(const a of s)if(a.result.status==="valid")return a.result;for(const a of s)if(a.result.status==="dirty")return n.common.issues.push(...a.ctx.common.issues),a.result;const o=s.map(a=>new Ai(a.ctx.common.issues));return re(n,{code:Y.invalid_union,unionErrors:o}),Te}if(n.common.async)return Promise.all(r.map(async s=>{const o={...n,common:{...n.common,issues:[]},parent:null};return{result:await s._parseAsync({data:n.data,path:n.path,parent:o}),ctx:o}})).then(i);{let s;const o=[];for(const l of r){const c={...n,common:{...n.common,issues:[]},parent:null},u=l._parseSync({data:n.data,path:n.path,parent:c});if(u.status==="valid")return u;u.status==="dirty"&&!s&&(s={result:u,ctx:c}),c.common.issues.length&&o.push(c.common.issues)}if(s)return n.common.issues.push(...s.ctx.common.issues),s.result;const a=o.map(l=>new Ai(l));return re(n,{code:Y.invalid_union,unionErrors:a}),Te}}get options(){return this._def.options}}Hh.create=(e,t)=>new Hh({options:e,typeName:Ne.ZodUnion,...Le(t)});const vi=e=>e instanceof c0?vi(e.schema):e instanceof go?vi(e.innerType()):e instanceof Vh?[e.value]:e instanceof mo?e.options:e instanceof u0?Ye.objectValues(e.enum):e instanceof Kh?vi(e._def.innerType):e instanceof s0?[void 0]:e instanceof o0?[null]:e instanceof Ti?[void 0,...vi(e.unwrap())]:e instanceof vo?[null,...vi(e.unwrap())]:e instanceof uN||e instanceof Yh?vi(e.unwrap()):e instanceof Gh?vi(e._def.innerType):[];class Mx extends qe{_parse(t){const{ctx:n}=this._processInputParams(t);if(n.parsedType!==ce.object)return re(n,{code:Y.invalid_type,expected:ce.object,received:n.parsedType}),Te;const r=this.discriminator,i=n.data[r],s=this.optionsMap.get(i);return s?n.common.async?s._parseAsync({data:n.data,path:n.path,parent:n}):s._parseSync({data:n.data,path:n.path,parent:n}):(re(n,{code:Y.invalid_union_discriminator,options:Array.from(this.optionsMap.keys()),path:[r]}),Te)}get discriminator(){return this._def.discriminator}get options(){return this._def.options}get optionsMap(){return this._def.optionsMap}static create(t,n,r){const i=new Map;for(const s of n){const o=vi(s.shape[t]);if(!o.length)throw new Error(`A discriminator value for key \`${t}\` could not be extracted from all schema options`);for(const a of o){if(i.has(a))throw new Error(`Discriminator property ${String(t)} has duplicate value ${String(a)}`);i.set(a,s)}}return new Mx({typeName:Ne.ZodDiscriminatedUnion,discriminator:t,options:n,optionsMap:i,...Le(r)})}}function l0(e,t){const n=ss(e),r=ss(t);if(e===t)return{valid:!0,data:e};if(n===ce.object&&r===ce.object){const i=Ye.objectKeys(t),s=Ye.objectKeys(e).filter(a=>i.indexOf(a)!==-1),o={...e,...t};for(const a of s){const l=l0(e[a],t[a]);if(!l.valid)return{valid:!1};o[a]=l.data}return{valid:!0,data:o}}else if(n===ce.array&&r===ce.array){if(e.length!==t.length)return{valid:!1};const i=[];for(let s=0;s<e.length;s++){const o=e[s],a=t[s],l=l0(o,a);if(!l.valid)return{valid:!1};i.push(l.data)}return{valid:!0,data:i}}else return n===ce.date&&r===ce.date&&+e==+t?{valid:!0,data:e}:{valid:!1}}class Uh extends qe{_parse(t){const{status:n,ctx:r}=this._processInputParams(t),i=(s,o)=>{if(uw(s)||uw(o))return Te;const a=l0(s.value,o.value);return a.valid?((dw(s)||dw(o))&&n.dirty(),{status:n.value,value:a.data}):(re(r,{code:Y.invalid_intersection_types}),Te)};return r.common.async?Promise.all([this._def.left._parseAsync({data:r.data,path:r.path,parent:r}),this._def.right._parseAsync({data:r.data,path:r.path,parent:r})]).then(([s,o])=>i(s,o)):i(this._def.left._parseSync({data:r.data,path:r.path,parent:r}),this._def.right._parseSync({data:r.data,path:r.path,parent:r}))}}Uh.create=(e,t,n)=>new Uh({left:e,right:t,typeName:Ne.ZodIntersection,...Le(n)});class po extends qe{_parse(t){const{status:n,ctx:r}=this._processInputParams(t);if(r.parsedType!==ce.array)return re(r,{code:Y.invalid_type,expected:ce.array,received:r.parsedType}),Te;if(r.data.length<this._def.items.length)return re(r,{code:Y.too_small,minimum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),Te;!this._def.rest&&r.data.length>this._def.items.length&&(re(r,{code:Y.too_big,maximum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),n.dirty());const s=[...r.data].map((o,a)=>{const l=this._def.items[a]||this._def.rest;return l?l._parse(new ii(r,o,r.path,a)):null}).filter(o=>!!o);return r.common.async?Promise.all(s).then(o=>Pn.mergeArray(n,o)):Pn.mergeArray(n,s)}get items(){return this._def.items}rest(t){return new po({...this._def,rest:t})}}po.create=(e,t)=>{if(!Array.isArray(e))throw new Error("You must pass an array of schemas to z.tuple([ ... ])");return new po({items:e,typeName:Ne.ZodTuple,rest:null,...Le(t)})};class Wh extends qe{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(t){const{status:n,ctx:r}=this._processInputParams(t);if(r.parsedType!==ce.object)return re(r,{code:Y.invalid_type,expected:ce.object,received:r.parsedType}),Te;const i=[],s=this._def.keyType,o=this._def.valueType;for(const a in r.data)i.push({key:s._parse(new ii(r,a,r.path,a)),value:o._parse(new ii(r,r.data[a],r.path,a)),alwaysSet:a in r.data});return r.common.async?Pn.mergeObjectAsync(n,i):Pn.mergeObjectSync(n,i)}get element(){return this._def.valueType}static create(t,n,r){return n instanceof qe?new Wh({keyType:t,valueType:n,typeName:Ne.ZodRecord,...Le(r)}):new Wh({keyType:Si.create(),valueType:t,typeName:Ne.ZodRecord,...Le(n)})}}class gw extends qe{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(t){const{status:n,ctx:r}=this._processInputParams(t);if(r.parsedType!==ce.map)return re(r,{code:Y.invalid_type,expected:ce.map,received:r.parsedType}),Te;const i=this._def.keyType,s=this._def.valueType,o=[...r.data.entries()].map(([a,l],c)=>({key:i._parse(new ii(r,a,r.path,[c,"key"])),value:s._parse(new ii(r,l,r.path,[c,"value"]))}));if(r.common.async){const a=new Map;return Promise.resolve().then(async()=>{for(const l of o){const c=await l.key,u=await l.value;if(c.status==="aborted"||u.status==="aborted")return Te;(c.status==="dirty"||u.status==="dirty")&&n.dirty(),a.set(c.value,u.value)}return{status:n.value,value:a}})}else{const a=new Map;for(const l of o){const c=l.key,u=l.value;if(c.status==="aborted"||u.status==="aborted")return Te;(c.status==="dirty"||u.status==="dirty")&&n.dirty(),a.set(c.value,u.value)}return{status:n.value,value:a}}}}gw.create=(e,t,n)=>new gw({valueType:t,keyType:e,typeName:Ne.ZodMap,...Le(n)});class Wc extends qe{_parse(t){const{status:n,ctx:r}=this._processInputParams(t);if(r.parsedType!==ce.set)return re(r,{code:Y.invalid_type,expected:ce.set,received:r.parsedType}),Te;const i=this._def;i.minSize!==null&&r.data.size<i.minSize.value&&(re(r,{code:Y.too_small,minimum:i.minSize.value,type:"set",inclusive:!0,exact:!1,message:i.minSize.message}),n.dirty()),i.maxSize!==null&&r.data.size>i.maxSize.value&&(re(r,{code:Y.too_big,maximum:i.maxSize.value,type:"set",inclusive:!0,exact:!1,message:i.maxSize.message}),n.dirty());const s=this._def.valueType;function o(l){const c=new Set;for(const u of l){if(u.status==="aborted")return Te;u.status==="dirty"&&n.dirty(),c.add(u.value)}return{status:n.value,value:c}}const a=[...r.data.values()].map((l,c)=>s._parse(new ii(r,l,r.path,c)));return r.common.async?Promise.all(a).then(l=>o(l)):o(a)}min(t,n){return new Wc({...this._def,minSize:{value:t,message:ge.toString(n)}})}max(t,n){return new Wc({...this._def,maxSize:{value:t,message:ge.toString(n)}})}size(t,n){return this.min(t,n).max(t,n)}nonempty(t){return this.min(1,t)}}Wc.create=(e,t)=>new Wc({valueType:e,minSize:null,maxSize:null,typeName:Ne.ZodSet,...Le(t)});class c0 extends qe{get schema(){return this._def.getter()}_parse(t){const{ctx:n}=this._processInputParams(t);return this._def.getter()._parse({data:n.data,path:n.path,parent:n})}}c0.create=(e,t)=>new c0({getter:e,typeName:Ne.ZodLazy,...Le(t)});class Vh extends qe{_parse(t){if(t.data!==this._def.value){const n=this._getOrReturnCtx(t);return re(n,{received:n.data,code:Y.invalid_literal,expected:this._def.value}),Te}return{status:"valid",value:t.data}}get value(){return this._def.value}}Vh.create=(e,t)=>new Vh({value:e,typeName:Ne.ZodLiteral,...Le(t)});function cN(e,t){return new mo({values:e,typeName:Ne.ZodEnum,...Le(t)})}class mo extends qe{_parse(t){if(typeof t.data!="string"){const n=this._getOrReturnCtx(t),r=this._def.values;return re(n,{expected:Ye.joinValues(r),received:n.parsedType,code:Y.invalid_type}),Te}if(this._cache||(this._cache=new Set(this._def.values)),!this._cache.has(t.data)){const n=this._getOrReturnCtx(t),r=this._def.values;return re(n,{received:n.data,code:Y.invalid_enum_value,options:r}),Te}return wr(t.data)}get options(){return this._def.values}get enum(){const t={};for(const n of this._def.values)t[n]=n;return t}get Values(){const t={};for(const n of this._def.values)t[n]=n;return t}get Enum(){const t={};for(const n of this._def.values)t[n]=n;return t}extract(t,n=this._def){return mo.create(t,{...this._def,...n})}exclude(t,n=this._def){return mo.create(this.options.filter(r=>!t.includes(r)),{...this._def,...n})}}mo.create=cN;class u0 extends qe{_parse(t){const n=Ye.getValidEnumValues(this._def.values),r=this._getOrReturnCtx(t);if(r.parsedType!==ce.string&&r.parsedType!==ce.number){const i=Ye.objectValues(n);return re(r,{expected:Ye.joinValues(i),received:r.parsedType,code:Y.invalid_type}),Te}if(this._cache||(this._cache=new Set(Ye.getValidEnumValues(this._def.values))),!this._cache.has(t.data)){const i=Ye.objectValues(n);return re(r,{received:r.data,code:Y.invalid_enum_value,options:i}),Te}return wr(t.data)}get enum(){return this._def.values}}u0.create=(e,t)=>new u0({values:e,typeName:Ne.ZodNativeEnum,...Le(t)});class qh extends qe{unwrap(){return this._def.type}_parse(t){const{ctx:n}=this._processInputParams(t);if(n.parsedType!==ce.promise&&n.common.async===!1)return re(n,{code:Y.invalid_type,expected:ce.promise,received:n.parsedType}),Te;const r=n.parsedType===ce.promise?n.data:Promise.resolve(n.data);return wr(r.then(i=>this._def.type.parseAsync(i,{path:n.path,errorMap:n.common.contextualErrorMap})))}}qh.create=(e,t)=>new qh({type:e,typeName:Ne.ZodPromise,...Le(t)});class go extends qe{innerType(){return this._def.schema}sourceType(){return this._def.schema._def.typeName===Ne.ZodEffects?this._def.schema.sourceType():this._def.schema}_parse(t){const{status:n,ctx:r}=this._processInputParams(t),i=this._def.effect||null,s={addIssue:o=>{re(r,o),o.fatal?n.abort():n.dirty()},get path(){return r.path}};if(s.addIssue=s.addIssue.bind(s),i.type==="preprocess"){const o=i.transform(r.data,s);if(r.common.async)return Promise.resolve(o).then(async a=>{if(n.value==="aborted")return Te;const l=await this._def.schema._parseAsync({data:a,path:r.path,parent:r});return l.status==="aborted"?Te:l.status==="dirty"||n.value==="dirty"?Kl(l.value):l});{if(n.value==="aborted")return Te;const a=this._def.schema._parseSync({data:o,path:r.path,parent:r});return a.status==="aborted"?Te:a.status==="dirty"||n.value==="dirty"?Kl(a.value):a}}if(i.type==="refinement"){const o=a=>{const l=i.refinement(a,s);if(r.common.async)return Promise.resolve(l);if(l instanceof Promise)throw new Error("Async refinement encountered during synchronous parse operation. Use .parseAsync instead.");return a};if(r.common.async===!1){const a=this._def.schema._parseSync({data:r.data,path:r.path,parent:r});return a.status==="aborted"?Te:(a.status==="dirty"&&n.dirty(),o(a.value),{status:n.value,value:a.value})}else return this._def.schema._parseAsync({data:r.data,path:r.path,parent:r}).then(a=>a.status==="aborted"?Te:(a.status==="dirty"&&n.dirty(),o(a.value).then(()=>({status:n.value,value:a.value}))))}if(i.type==="transform")if(r.common.async===!1){const o=this._def.schema._parseSync({data:r.data,path:r.path,parent:r});if(!za(o))return Te;const a=i.transform(o.value,s);if(a instanceof Promise)throw new Error("Asynchronous transform encountered during synchronous parse operation. Use .parseAsync instead.");return{status:n.value,value:a}}else return this._def.schema._parseAsync({data:r.data,path:r.path,parent:r}).then(o=>za(o)?Promise.resolve(i.transform(o.value,s)).then(a=>({status:n.value,value:a})):Te);Ye.assertNever(i)}}go.create=(e,t,n)=>new go({schema:e,typeName:Ne.ZodEffects,effect:t,...Le(n)});go.createWithPreprocess=(e,t,n)=>new go({schema:t,effect:{type:"preprocess",transform:e},typeName:Ne.ZodEffects,...Le(n)});class Ti extends qe{_parse(t){return this._getType(t)===ce.undefined?wr(void 0):this._def.innerType._parse(t)}unwrap(){return this._def.innerType}}Ti.create=(e,t)=>new Ti({innerType:e,typeName:Ne.ZodOptional,...Le(t)});class vo extends qe{_parse(t){return this._getType(t)===ce.null?wr(null):this._def.innerType._parse(t)}unwrap(){return this._def.innerType}}vo.create=(e,t)=>new vo({innerType:e,typeName:Ne.ZodNullable,...Le(t)});class Kh extends qe{_parse(t){const{ctx:n}=this._processInputParams(t);let r=n.data;return n.parsedType===ce.undefined&&(r=this._def.defaultValue()),this._def.innerType._parse({data:r,path:n.path,parent:n})}removeDefault(){return this._def.innerType}}Kh.create=(e,t)=>new Kh({innerType:e,typeName:Ne.ZodDefault,defaultValue:typeof t.default=="function"?t.default:()=>t.default,...Le(t)});class Gh extends qe{_parse(t){const{ctx:n}=this._processInputParams(t),r={...n,common:{...n.common,issues:[]}},i=this._def.innerType._parse({data:r.data,path:r.path,parent:{...r}});return $h(i)?i.then(s=>({status:"valid",value:s.status==="valid"?s.value:this._def.catchValue({get error(){return new Ai(r.common.issues)},input:r.data})})):{status:"valid",value:i.status==="valid"?i.value:this._def.catchValue({get error(){return new Ai(r.common.issues)},input:r.data})}}removeCatch(){return this._def.innerType}}Gh.create=(e,t)=>new Gh({innerType:e,typeName:Ne.ZodCatch,catchValue:typeof t.catch=="function"?t.catch:()=>t.catch,...Le(t)});class vw extends qe{_parse(t){if(this._getType(t)!==ce.nan){const r=this._getOrReturnCtx(t);return re(r,{code:Y.invalid_type,expected:ce.nan,received:r.parsedType}),Te}return{status:"valid",value:t.data}}}vw.create=e=>new vw({typeName:Ne.ZodNaN,...Le(e)});class uN extends qe{_parse(t){const{ctx:n}=this._processInputParams(t),r=n.data;return this._def.type._parse({data:r,path:n.path,parent:n})}unwrap(){return this._def.type}}class Ax extends qe{_parse(t){const{status:n,ctx:r}=this._processInputParams(t);if(r.common.async)return(async()=>{const s=await this._def.in._parseAsync({data:r.data,path:r.path,parent:r});return s.status==="aborted"?Te:s.status==="dirty"?(n.dirty(),Kl(s.value)):this._def.out._parseAsync({data:s.value,path:r.path,parent:r})})();{const i=this._def.in._parseSync({data:r.data,path:r.path,parent:r});return i.status==="aborted"?Te:i.status==="dirty"?(n.dirty(),{status:"dirty",value:i.value}):this._def.out._parseSync({data:i.value,path:r.path,parent:r})}}static create(t,n){return new Ax({in:t,out:n,typeName:Ne.ZodPipeline})}}class Yh extends qe{_parse(t){const n=this._def.innerType._parse(t),r=i=>(za(i)&&(i.value=Object.freeze(i.value)),i);return $h(n)?n.then(i=>r(i)):r(n)}unwrap(){return this._def.innerType}}Yh.create=(e,t)=>new Yh({innerType:e,typeName:Ne.ZodReadonly,...Le(t)});var Ne;(function(e){e.ZodString="ZodString",e.ZodNumber="ZodNumber",e.ZodNaN="ZodNaN",e.ZodBigInt="ZodBigInt",e.ZodBoolean="ZodBoolean",e.ZodDate="ZodDate",e.ZodSymbol="ZodSymbol",e.ZodUndefined="ZodUndefined",e.ZodNull="ZodNull",e.ZodAny="ZodAny",e.ZodUnknown="ZodUnknown",e.ZodNever="ZodNever",e.ZodVoid="ZodVoid",e.ZodArray="ZodArray",e.ZodObject="ZodObject",e.ZodUnion="ZodUnion",e.ZodDiscriminatedUnion="ZodDiscriminatedUnion",e.ZodIntersection="ZodIntersection",e.ZodTuple="ZodTuple",e.ZodRecord="ZodRecord",e.ZodMap="ZodMap",e.ZodSet="ZodSet",e.ZodFunction="ZodFunction",e.ZodLazy="ZodLazy",e.ZodLiteral="ZodLiteral",e.ZodEnum="ZodEnum",e.ZodEffects="ZodEffects",e.ZodNativeEnum="ZodNativeEnum",e.ZodOptional="ZodOptional",e.ZodNullable="ZodNullable",e.ZodDefault="ZodDefault",e.ZodCatch="ZodCatch",e.ZodPromise="ZodPromise",e.ZodBranded="ZodBranded",e.ZodPipeline="ZodPipeline",e.ZodReadonly="ZodReadonly"})(Ne||(Ne={}));const S=Si.create,q=$a.create,Se=i0.create,oo=a0.create;Ts.create;const xe=ei.create,M=jt.create;Hh.create;const li=Mx.create;Uh.create;po.create;const sl=Wh.create,J=Vh.create,We=mo.create;qh.create;Ti.create;vo.create;new Set("ABCDEFGHIJKLMNOPQRSTUVXYZabcdefghijklmnopqrstuvxyz0123456789");const $O=["owner"],FO=["agent","owner","user-upload"],dN=M({id:S().min(1),relPath:S().min(1),from:We(FO),label:S().optional(),size:q().int().nonnegative(),mime:S().min(1),addedAt:q().int().nonnegative(),lastEditedAt:q().int().nonnegative().optional(),stale:Se().optional()});M({sessionId:S().min(1),relPath:S().min(1),ttlSeconds:q().int().positive().nullable().optional(),view:We(["raw","md-rendered"]).optional()});M({url:S().min(1),expiresAt:q().int().nonnegative().nullable()});M({sessionId:S().min(1),relPath:S().min(1),label:S().optional(),origin:J("agent").optional()});M({entry:dN});M({sessionId:S().min(1),relPath:S().min(1)});M({removed:J(!0)});M({sessionId:S().min(1)});M({entries:xe(dN)});M({attachmentId:S().min(1),url:S().min(1),relPath:S().min(1),sizeBytes:q().int().nonnegative(),mimeType:S().min(1)});const HO=li("type",[M({type:J("persona"),id:S().min(1)}).strict(),M({type:J("chat"),id:S().min(1)}).strict(),M({type:J("*")}).strict()]),UO=We(["read","send","admin"]),Lx=M({resource:HO,actions:xe(UO).min(1)}).strict(),WO=M({id:S().min(1),secretHash:S().regex(/^[a-f0-9]{64}$/),displayName:S(),grants:xe(Lx),issuedAt:q().int().nonnegative(),expiresAt:q().int().positive().optional(),maxUses:q().int().positive().optional(),usedCount:q().int().nonnegative(),peerOwnerId:S().min(1).optional(),firstUsedByPeerAt:q().int().positive().optional(),peerDisplayName:S().optional()}).strict(),VO=WO.omit({secretHash:!0});M({type:J("whoami:ok"),owner:M({id:S(),kind:We(["owner","guest"]),displayName:S(),ownerId:S(),provider:S()}).strict(),capability:VO,grantedPersonas:xe(M({id:S().min(1),displayName:S()}).strict())}).strict();M({selfUrl:S().min(1)});M({type:J("contact:handshake:ok"),owner:M({id:S(),ownerId:S(),provider:S(),displayName:S()}),grants:xe(Lx)});M({deviceId:S().min(1),remoteAccessAllowed:Se()}).strict();M({type:J("contact:setRemoteAccess:ok"),deviceId:S().min(1),remoteAccessAllowed:Se()}).strict();M({type:J("contact:remote-access-updated"),deviceId:S().min(1),remoteAccessAllowed:Se()}).strict();const qO=M({deviceId:S().min(1),ownerId:S().min(1),provider:S().min(1),displayName:S(),remoteUrl:S().min(1),connectToken:S(),grants:xe(Lx),addedAt:q().int().nonnegative(),pinnedAt:q().int().nullable().default(null),remoteAccessAllowed:Se().default(!1)}).strict(),hN=qO;M({deviceId:S().min(1)}).strict();M({type:J("contact:remove:ok"),deviceId:S().min(1)}).strict();M({type:J("contact:list:ok"),contacts:xe(hN)}).strict();M({type:J("contact:added"),contact:hN}).strict();M({type:J("contact:removed"),deviceId:S().min(1)}).strict();M({deviceId:S().min(1),pinned:Se()}).strict();M({type:J("contact:pin:ok"),deviceId:S().min(1),pinnedAt:q().int().nullable()}).strict();M({type:J("contact:pinned"),deviceId:S().min(1),pinnedAt:q().int().nullable()}).strict();const KO=M({deviceId:S().min(1),name:S().min(1),url:S().min(1)});M({type:J("device:list:ok"),devices:xe(KO)});M({deviceId:S().min(1),url:S().min(1).optional(),name:S().optional()});M({type:J("device:connect:ok"),deviceId:S(),name:S(),url:S()});const fN=M({ownerId:S().min(1),provider:S().min(1),displayName:S().min(1),avatarUrl:S().optional(),unionId:S().optional()});M({type:J("auth:login:start:ok"),authUrl:S().min(1),state:S().min(1)});M({type:J("auth:getIdentity:ok"),identity:fN.nullable(),deviceId:S().min(1),ttcTokenExpiresAt:q().nullable().optional()});M({type:J("auth:logout:ok")});M({type:J("auth:login:done"),identity:fN});M({type:J("auth:login:failed"),reason:S()});const jx=li("kind",[M({kind:J("success"),text:S(),filePaths:xe(S()).optional()}),M({kind:J("failure"),reason:S()})]);M({targetPersona:S().min(1).optional(),dispatchId:S().min(1).optional(),prompt:S(),targetDeviceId:S().min(1).optional(),model:S().min(1).optional(),sessionLabel:S().min(1).max(60).optional()}).refine(e=>e.targetPersona!==void 0||e.dispatchId!==void 0,{message:"either targetPersona (new dispatch) or dispatchId (follow-up) is required"}).refine(e=>!(e.dispatchId!==void 0&&e.targetDeviceId!==void 0),{message:"cross-device dispatch cannot be continued (dispatchId + targetDeviceId are mutually exclusive)"});M({dispatchId:S().min(1),outcome:jx});const GO=["running","completed","failed"],pN=We(GO),YO=M({dispatchId:S().min(1),sourceSessionId:S().min(1),sourcePersonaId:S().min(1).optional(),targetPersonaId:S().min(1),workerSessionId:S().min(1).optional(),taskText:S(),status:pN,outcome:jx.optional(),meta:sl(oo()).optional(),createdAt:S().min(1),completedAt:S().min(1).optional(),deliveredAt:S().min(1).optional()});M({sourceSessionId:S().min(1).optional()});M({records:xe(YO)});M({dispatchId:S().min(1)});M({type:J("personaDispatch:get:ok"),status:pN,outcome:jx.optional()});const XO=/^[a-z0-9][a-z0-9-]*$/;We(["stopped","starting","running","crashed","invalid"]);const QO=new Set(["localhost","127.0.0.1"]);function ZO(e){let t;try{t=new URL(e)}catch{return!1}return!!(t.protocol==="https:"||t.protocol==="http:"&&QO.has(t.hostname))}const ld=M({id:S().regex(XO),name:S().min(1),version:S().min(1),apiVersion:J("1"),runtime:M({startCommand:S().min(1)}).passthrough().optional(),entry:M({url:S().url().refine(ZO,{message:"INVALID_URL_SCHEME: only https or http://localhost is allowed"})}).strict().optional()}).passthrough().superRefine((e,t)=>{var i;const n=!!e.runtime,r=!!((i=e.entry)!=null&&i.url);n&&r&&t.addIssue({code:Y.custom,message:"INVALID_MANIFEST: entry.url and runtime cannot coexist"}),!n&&!r&&t.addIssue({code:Y.custom,message:"INVALID_MANIFEST: must have either entry.url or runtime"})}),JO=li("kind",[M({kind:J("local"),port:q().int().min(1).max(65535)}),M({kind:J("hosted"),url:S().url()})]);li("state",[M({extId:S(),manifest:ld,state:J("stopped")}),M({extId:S(),manifest:ld,state:J("starting")}),M({extId:S(),manifest:ld,state:J("running"),target:JO}),M({extId:S(),manifest:ld,state:J("crashed")}),M({extId:S(),manifest:oo().nullable(),state:J("invalid"),invalidReason:S().min(1)})]);M({snapshotHash:S().min(1),version:S().min(1),publishedAt:q()});const e6=li("kind",[M({kind:J("p2p-tunnel"),ownerPrincipalId:S().min(1),extId:S().min(1)})]);li("kind",[M({kind:J("p2p-tunnel"),ownerPrincipalId:S().min(1),extId:S().min(1),snapshotHash:S().min(1)})]);M({extId:S().min(1),name:S().min(1),version:S().min(1),contentHash:S().min(1),publishedAt:q()});const t6=li("kind",[M({kind:J("clean")}),M({kind:J("ready-new-version"),fromVersion:S().min(1),toVersion:S().min(1)}),M({kind:J("error-same-hash"),version:S().min(1)}),M({kind:J("error-version-not-bumped"),localVersion:S().min(1),publishedVersion:S().min(1)}),M({kind:J("error-version-regression"),localVersion:S().min(1),publishedVersion:S().min(1)})]);M({localManifest:M({name:S().min(1),version:S().min(1),contentHash:S().min(1)}),publishState:li("kind",[M({kind:J("unpublished")}),M({kind:J("published"),version:S().min(1),contentHash:S().min(1),publishedAt:q()})]),check:t6});M({extId:S().min(1),newVersion:S().min(1).nullish()});M({extId:S().min(1)});M({extId:S().min(1),snapshotHash:S().min(1)});M({channelRef:e6,snapshotHash:S().min(1),zipBase64:S().min(1)});M({id:S().min(1),peerDeviceId:S().min(1),senderDeviceId:S().min(1),text:S().min(1),createdAt:q().int().nonnegative(),readBy:sl(S().min(1),q().int().positive()).default({}),origin:M({kind:J("persona"),personaId:S().min(1)}).optional()}).strict();M({peerDeviceId:S().min(1).optional(),id:S().min(1),text:S().min(1),createdAt:q().int().nonnegative(),origin:M({kind:J("persona"),personaId:S().min(1)}).optional()}).strict();M({peerDeviceId:S().min(1),sinceCreatedAt:q().int().nonnegative().optional()}).strict();M({peerDeviceId:S().min(1),upToCreatedAt:q().int().nonnegative()}).strict();M({peerDeviceId:S().min(1).optional(),text:S().min(1)});M({peerDeviceId:S().min(1).optional(),command:S().min(1),timeoutMs:q().int().positive().optional()}).strict();M({type:J("peerExec:run:ok"),stdout:S(),stderr:S(),exitCode:q().int().nullable(),timedOut:Se(),stdoutTruncated:Se(),stderrTruncated:Se()}).strict();const mN=li("kind",[M({kind:J("at"),at:S().min(1)}),M({kind:J("every"),everyMs:q().int().positive(),anchorMs:q().int().nonnegative().optional()}),M({kind:J("cron"),expr:S().min(1),tz:S().min(1).optional()})]),pu=S().trim().min(1);M({personaId:pu,name:S().min(1),schedule:mN,prompt:S().min(1),targetPersona:S().min(1).optional(),timeoutMs:q().int().positive().optional()});M({personaId:pu,onlyMine:Se().optional()});M({personaId:pu,shiftId:S().min(1)});const n6=M({name:S().min(1).optional(),schedule:mN.optional(),prompt:S().min(1).optional(),targetPersona:S().min(1).optional(),timeoutMs:q().int().positive().optional(),enabled:Se().optional()});M({personaId:pu,shiftId:S().min(1),patch:n6});M({personaId:pu,shiftId:S().min(1),limit:q().int().positive().optional()});const r6=["created","review-requested"],gN=/^[A-Za-z0-9._-]+$/,ol=S().min(1).regex(gN),al=S().min(1).regex(gN),mu=q().int().positive();M({role:We(r6)});M({owner:ol,repo:al,number:mu});M({owner:ol,repo:al,number:mu,expectedHeadSha:S().min(1)});M({owner:ol,repo:al,number:mu,body:S().min(1)});M({owner:ol,repo:al,number:mu,ready:Se()});M({owner:ol,repo:al});M({owner:ol,repo:al,number:mu,reviewers:xe(S().min(1)).min(1)});M({personaId:S().min(1)});const i6=["expired","cancelled","access_denied","lark_protocol_error","cloud_unreachable","internal_error"],s6=We(i6);M({personaId:S().min(1),appId:S().min(1),appSecret:S().min(1),botName:S().min(1).optional()});const o6=M({chatId:S().min(1),chatName:S().optional(),lastActiveAt:q().int().optional()}),a6=M({state:We(["unbound","provisioning","bound","broken"]),appId:S().optional(),botName:S().optional(),brokenReason:S().optional(),qrUrl:S().optional(),errorReason:s6.optional(),groups:xe(o6)});a6.extend({personaId:S().min(1)});M({});M({onboardingCompletedAt:q()});M({});M({tools:xe(M({id:We(["claude","codex"]),available:Se(),version:S().optional(),path:S().optional()}))});M({});const l6=M({tool:We(["claude","codex"]),cwd:S(),toolSessionId:S(),label:S().optional(),createdAt:S(),updatedAt:S(),turns:q()});M({candidates:xe(l6)});M({});M({registered:Se()});const c6=M({personaId:S(),label:S(),model:S().optional(),effort:S().optional(),public:Se(),iconKey:S().optional(),tool:S().optional(),createdAt:q(),updatedAt:q()}).strict(),u6=M({name:S().min(1),description:S().optional()}),d6=M({id:S().min(1)}),h6=M({permissions:M({defaultMode:S().optional(),allow:xe(S()).optional(),deny:xe(S()).optional()}).optional(),sandbox:M({enabled:Se().optional(),autoAllowBashIfSandboxed:Se().optional(),allowUnsandboxedCommands:Se().optional(),excludedCommands:xe(S()).optional(),filesystem:M({denyRead:xe(S()).optional(),allowRead:xe(S()).optional(),denyWrite:xe(S()).optional(),allowWrite:xe(S()).optional()}).optional(),network:M({allowedDomains:xe(S()).optional(),allowLocalBinding:Se().optional()}).optional()}).optional()});c6.extend({personality:S().optional(),skills:xe(u6).optional(),plugins:xe(d6).optional(),sandboxSettings:h6.nullable().optional()});M({slug:S().regex(/^[a-z0-9]+(-[a-z0-9]+)*$/).max(32),label:S().min(1),personality:S(),model:S().optional(),effort:S().optional(),tool:S().optional(),public:Se().optional(),iconKey:S().optional()}).strict();M({personaId:S().min(1)});M({personaId:S().min(1),patch:M({label:S().min(1).optional(),model:S().optional(),effort:S().optional(),tool:S().optional(),personality:S().optional(),public:Se().optional(),iconKey:S().nullable().optional()}).strict()}).strict();M({writableRoots:xe(S()).optional(),denyRead:xe(S()).optional(),network:Se().optional()}).strict();const vN=["ready","session:info","session:status","session:event","session:deleted","session:rewound","session:cleared","permission:request","session:question","session:question:cleared","pong","error","subscribed","unsubscribed","auth:ok","tunnel:ready","tunnel:exited","tunnel:unavailable","session:control","session:pty","contact:added","contact:pinned","contact:removed","contact:remote-access-updated","inbox:event","friend:reverseTokenOffered","auth:login:done","auth:login:failed","appBuilder:project-updated","appBuilder:publish-progress","appBuilder:publish-failed","larkBot:state"],_N=["idle","running","running-idle","stopped","error","observing"],f6=["task-notification","slash-command","local-command","system-reminder","skill-hint","meta-text","attachment-skills","attachment-deferred-tools"],p6=["builtin","global","project","plugin"],m6=["builtin","global","project","policy","plugin"],xN=We(["owner","guest"]);M({id:S().min(1),kind:xN,displayName:S(),feishuUnionId:S().optional()}).strict();const g6=M({did:S().min(1),displayName:S(),feishuUnionId:S().optional(),principal:xN}).strict(),v6=We(_N),_6=M({input_tokens:q().int().nonnegative().optional(),cache_read_input_tokens:q().int().nonnegative().optional(),cache_creation_input_tokens:q().int().nonnegative().optional(),output_tokens:q().int().nonnegative().optional()}),x6=M({inputTokens:q().int().nonnegative(),outputTokens:q().int().nonnegative(),cacheReadTokens:q().int().nonnegative().optional(),cacheCreateTokens:q().int().nonnegative().optional()}),yN={gitBranch:S().optional(),resolvedModel:S().optional(),resolvedEffort:S().optional(),contextUsage:x6.optional(),contextWindowSize:q().int().positive().optional(),aiLabel:S().optional()},y6=M(yN),bN=M({value:S(),label:S(),description:S().optional()}),b6=M({id:S().min(1),label:S().min(1),description:S().optional(),contextWindowSize:q().int().positive(),default:Se().optional(),efforts:xe(bN).optional(),defaultEffort:S().optional()}),w6=M({id:S().min(1),label:S().min(1),description:S().optional()}),S6=M({name:S().min(1),type:We(["string","select","toggle"]),label:S().min(1),description:S().optional(),options:xe(bN).optional(),default:oo().optional(),scope:We(["core","tool-specific"])});M({tool:S().min(1)});const k6=M({rewind:Se(),subagents:Se(),tui:Se(),observe:Se(),fileSharing:Se(),fork:Se()});M({tool:S().min(1),toolSessionIdLabel:S().optional(),models:xe(b6),permissionModes:xe(w6),configSchema:xe(S6),features:k6});const C6=M({tool:S().min(1),pattern:S().min(1),createdAt:S().min(1).optional()});M({sessionId:S().min(1),cwd:S().min(1),tool:J("claude").or(S().min(1)).default("claude"),toolSessionId:S().optional(),label:S().optional(),model:S().optional(),permissionMode:S().optional(),effort:S().optional(),...yN,aiLabelGeneratedAt:S().optional(),permissionRules:xe(C6).optional(),pinnedAt:q().int().nonnegative().nullable().optional(),archivedAt:q().int().nonnegative().nullable().optional(),pinSortOrder:q().int().nullable().optional(),unreadAt:S().min(1).nullable().optional(),iconKey:S().optional(),forkedFromSessionId:S().min(1).optional(),ephemeral:Se().optional(),ownerPersonaId:S().min(1).optional(),projectPath:S().min(1).optional(),appBuilderProject:S().regex(/^[a-z][a-z0-9-]{0,39}$/).optional(),chatId:S().min(1).optional(),creatorPrincipalId:S().min(1).optional(),creatorDisplayName:S().min(1).optional(),creatorFeishuUnionId:S().min(1).optional(),originOwnerPrincipalId:S().min(1).optional(),originOwnerPersonaId:S().min(1).optional(),dispatchedFromSessionId:S().min(1).optional(),shiftFiredFromSessionId:S().min(1).optional(),larkChatId:S().min(1).optional(),larkChatName:S().min(1).optional(),larkChatType:We(["p2p","group"]).optional(),createdAt:S().min(1),updatedAt:S().min(1)});const jn={seq:q().int().nonnegative().optional(),ts:S().optional(),uuid:S().optional()},E6=We(f6),T6=M({readCount:q().int().nonnegative().optional(),searchCount:q().int().nonnegative().optional(),bashCount:q().int().nonnegative().optional(),editFileCount:q().int().nonnegative().optional(),linesAdded:q().int().nonnegative().optional(),linesRemoved:q().int().nonnegative().optional(),otherToolCount:q().int().nonnegative().optional()}),N6=M({oldStart:q().int().nonnegative(),oldLines:q().int().nonnegative(),newStart:q().int().nonnegative(),newLines:q().int().nonnegative(),lines:xe(S())}),P6=M({agentId:S().optional(),agentType:S().optional(),status:S().optional(),prompt:S().optional(),filePath:S().optional(),structuredPatch:xe(N6).optional(),stats:M({durationMs:q().int().nonnegative().optional(),tokens:q().int().nonnegative().optional(),toolUseCount:q().int().nonnegative().optional(),toolStats:T6.optional(),usage:_6.optional()}).optional()}),I6=M({path:S(),content:S(),mtimeMs:q().optional()}),R6=M({label:S().min(1),description:S().optional()}),wN=M({question:S().min(1),multiSelect:Se(),options:xe(R6).min(1)}),M6=["completed","interrupted"];li("kind",[M({...jn,kind:J("session_init"),toolSessionId:S().optional()}),M({...jn,kind:J("thinking"),text:S(),partialId:S().optional()}),M({...jn,kind:J("text"),text:S(),partialId:S().optional()}),M({...jn,kind:J("user_text"),text:S(),meta:E6.optional(),taskId:S().optional(),parentToolUseId:S().optional(),sender:g6.optional()}),M({...jn,kind:J("tool_call"),toolUseId:S(),tool:S(),toolKind:S().optional(),input:oo()}),M({...jn,kind:J("tool_result"),toolUseId:S(),output:oo().optional(),error:S().optional(),toolResultExtra:P6.optional(),sourceToolAssistantUUID:S().optional(),askQuestionAnswers:sl(S(),S()).optional()}),M({...jn,kind:J("attachment_memories"),memories:xe(I6)}),M({...jn,kind:J("permission_request"),requestId:S(),tool:S(),input:oo(),toolUseId:S().optional()}),M({...jn,kind:J("ask_user_question"),toolUseId:S(),questions:xe(wN)}),M({...jn,kind:J("turn_end"),durationMs:q().int().nonnegative().optional(),reason:We(M6).optional()}),M({...jn,kind:J("subagent_progress"),toolUseId:S(),agentId:S(),status:We(["started","running","completed","failed"]),description:S().optional(),lastToolName:S().optional(),prompt:S().optional(),stats:M({durationMs:q().int().nonnegative().optional(),tokens:q().int().nonnegative().optional(),toolUseCount:q().int().nonnegative().optional()}).optional()}),M({...jn,kind:J("error"),message:S()}),M({...jn,kind:J("meta_update"),patch:y6}),M({...jn,kind:J("meta-text"),text:S(),metaSource:We(["cc","owner"]).optional()})]);M({cwd:S().min(1).optional(),tool:S().optional(),label:S().optional(),aiLabel:S().optional(),model:S().optional(),permissionMode:S().optional(),effort:S().optional(),iconKey:S().optional(),forkedFromSessionId:S().min(1).optional(),ephemeral:Se().optional(),ownerPersonaId:S().min(1).optional(),projectPath:S().min(1).optional()}).refine(e=>e.cwd!=null||e.ownerPersonaId!=null||e.projectPath!=null,{message:"cwd / ownerPersonaId / projectPath 至少传一个"});M({path:S().min(1),name:S().min(1),createdAt:S().datetime(),pinnedAt:q().optional()});M({path:S().min(1),pinnedAt:q().nullable()});M({path:S().min(1)});M({path:S().min(1).optional(),name:S().min(1).optional()}).refine(e=>e.path!=null||e.name!=null,{message:"path 与 name 至少给一个"});M({cwd:S().min(1),tool:S().min(1),toolSessionId:S().min(1),label:S().optional(),aiLabel:S().optional(),iconKey:S().optional(),createdAt:S().datetime(),updatedAt:S().datetime(),ownerPersonaId:S().min(1).optional()});M({originOnly:Se().optional(),ownerPersonaId:S().min(1).optional(),limit:q().int().positive().optional(),offset:q().int().nonnegative().optional()});M({sessionId:S().min(1)});M({sessionId:S().min(1),patch:M({label:S().optional(),model:S().optional(),permissionMode:S().optional(),effort:S().optional(),cwd:S().optional(),iconKey:S().optional(),ephemeral:J(!1).optional()})});M({sessionId:S().min(1),text:S()});M({sessionId:S().min(1),userMessageId:S().min(1),dryRun:Se().optional()});M({canRewind:Se(),error:S().optional(),filesChanged:xe(S()).optional(),insertions:q().int().nonnegative().optional(),deletions:q().int().nonnegative().optional()});M({sessionId:S().min(1),userMessageId:S().min(1)});const A6=M({oldStart:q().int().nonnegative(),oldLines:q().int().nonnegative(),newStart:q().int().nonnegative(),newLines:q().int().nonnegative(),lines:xe(S())}),L6=M({filePath:S().min(1),hunks:xe(A6),insertions:q().int().nonnegative(),deletions:q().int().nonnegative(),status:We(["modified","added","deleted"]).optional()});M({canRewind:Se(),error:S().optional(),files:xe(L6),totalInsertions:q().int().nonnegative(),totalDeletions:q().int().nonnegative()});M({userMessageIds:xe(S())});M({sessionId:S().min(1),toolSessionId:S().min(1)});M({cwd:S().min(1),toolSessionId:S().min(1),messageUuid:S().min(1),targetCwd:S().min(1).optional()});M({forkedToolSessionId:S().min(1),forkedFilePath:S().min(1)});M({sessionId:S().min(1),toolSessionId:S().min(1),jsonlPath:S().optional()});M({sessionId:S().min(1),afterSeq:q().int().min(-1)});M({sessionId:S().min(1),permissionRequestId:S().min(1),allow:Se(),permanent:Se().optional(),pattern:S().optional()});M({projectPath:S().min(1)});M({sessionId:S().min(1),limit:q().int().positive().max(5e3).optional(),offset:q().int().nonnegative().optional(),slim:Se().optional()});M({cwd:S().min(1),toolSessionId:S().min(1)});M({cwd:S().min(1),toolSessionId:S().min(1),subagentId:S().min(1)});M({cwd:S().min(1).optional(),path:S().optional(),showHidden:Se().optional()});M({cwd:S().min(1),path:S().min(1)});M({cwd:S().min(1),tool:S().optional()});M({name:S().min(1),source:We(p6),path:S().optional(),description:S().optional(),plugin:S().optional()});const j6=M({name:S().min(1),source:We(m6),path:S().optional(),description:S().optional(),whenToUse:S().optional(),plugin:S().optional()});M({cwd:S().min(1),tool:S().optional()});M({agents:xe(j6)});M({sessionId:S().optional()});M({sessionId:S().min(1).optional()});M({sessionId:S().min(1),pinned:Se()});M({sessionId:S().min(1),archived:Se()});M({type:J("peerSession:upsert:ok")});M({sessionId:S().min(1)});M({type:J("peerSession:remove:ok")});M({orderedIds:xe(S().min(1)).min(1)});M({cwd:S().min(1)});M({isGitRoot:Se(),gitRoot:S().nullable()});M({cwd:S().min(1)});M({branch:S().nullable()});M({cwd:S().min(1)});M({branches:xe(S()),head:S().nullable()});M({}).optional();const D6=M({cwd:S().min(1),updatedAt:S().min(1)});M({dirs:xe(D6)});M({type:J("session:question"),sessionId:S().min(1),toolUseId:S().min(1),requestId:S().min(1),questions:xe(wN).min(1)});M({type:J("session:question:cleared"),sessionId:S().min(1),toolUseId:S().min(1),answers:sl(S(),S()).optional()});M({sessionId:S().min(1),toolUseId:S().min(1),answers:sl(S(),S())});M({ok:J(!0)});M({sessionId:S().min(1),toolUseId:S().min(1)});M({ok:J(!0)});const SN=M({name:S().min(1),version:S().min(1),instanceId:S().min(1),deviceLabel:S().transform(e=>e.trim().slice(0,64)).optional()});M({type:J("auth"),token:S().min(1),scheme:J("bearer").optional(),clientInfo:SN.optional()});M({type:J("auth:ok"),version:S().min(1).optional(),protocolVersion:q().int().nonnegative().optional()});const O6=M({clientId:S().min(1),connectedAt:q().int().nonnegative(),self:Se(),clientInfo:SN.optional()});M({type:J("device:connections:ok"),connections:xe(O6)});M({type:J("tunnel:ready"),url:S().min(1),subdomain:S().min(1)});M({type:J("tunnel:exited"),code:q().int().nullable(),subdomain:S().nullable(),url:S().nullable()});M({type:J("tunnel:unavailable"),reason:S().min(1),failedAt:S().min(1)});const B6=M({sessionId:S().min(1),status:v6,freshSpawn:Se(),pendingPermissionRequestIds:xe(S().min(1)),pendingQuestionToolUseIds:xe(S().min(1))});M({type:J("info"),version:S(),protocolVersion:q(),hostname:S(),os:S(),tools:xe(M({id:S(),available:Se()})),runningSessions:xe(B6),tokenRole:We($O).optional(),isLoopback:Se().optional(),httpBaseUrl:S().optional(),httpToken:S().optional(),daemonSource:We(["ota","packaged"]).optional(),globalCliVersion:S().nullable().optional()});const z6=6173,$6=6272,ll=/^[a-z][a-z0-9-]{0,39}$/,gu=M({name:S().regex(ll,{message:"kebab-case, 小写字母开头,只允许小写字母 / 数字 / -,最长 40 字符"}),port:q().int().min(z6).max($6),createdAt:S().datetime(),devCommand:S().min(1),prodUrl:S().url().optional(),readyPattern:S().optional(),publishJob:M({jobId:S().min(1),stage:We(["build","deploy","verify"]),startedAt:q().int().nonnegative()}).optional()}),F6=["install-pending","installing","starting-dev-server","running","stopped","failed"],kN=We(F6),Dx=gu.extend({isRunning:Se(),boundSessionId:S().nullable(),stage:kN.optional(),stageReason:S().optional(),publishJob:M({jobId:S().min(1),stage:We(["build","deploy","verify"]),startedAt:q().int().nonnegative(),status:We(["in-flight","interrupted"])}).optional()});M({}).strict();M({projects:xe(Dx)}).strict();M({sessionId:S().min(1)}).strict();M({project:Dx.nullable()}).strict();M({sessionId:S().min(1),name:S().min(1)}).strict();M({project:gu}).strict();M({name:S()}).strict();M({}).strict();M({name:S(),newPort:q().int()}).strict();M({project:gu}).strict();M({name:S().regex(ll),url:S().url()}).strict();M({project:gu}).strict();M({sessionId:S().min(1),force:Se().optional()}).strict();M({project:gu}).strict();const H6=["installing","failed"];M({sessionId:S().min(1),stage:We(H6),reason:S().optional()}).strict();M({ok:J(!0)}).strict();M({sessionId:S().min(1)}).strict();M({ok:J(!0)}).strict();M({type:J("appBuilder:project-updated"),project:Dx,stage:kN,stageReason:S().optional()}).strict();M({name:S().regex(ll)});M({jobId:S().min(1),status:We(["started","already-publishing"])}).strict();M({name:S().regex(ll)});M({ok:J(!0)}).strict();M({type:J("appBuilder:publish-progress"),name:S().regex(ll),jobId:S().min(1),stage:We(["build","deploy","verify"]),status:We(["started","completed"])}).strict();M({type:J("appBuilder:publish-failed"),name:S().regex(ll),jobId:S().min(1),stage:We(["build","deploy","verify","unknown"]),errorSummary:S()}).strict();M({});M({method:S().min(1).optional()});const U6=["allowed","conditional","denied"],W6=We(U6),V6=M({name:S().min(1),status:W6,description:S().min(1),args:xe(M({name:S(),required:Se()})).nullable(),argsSchema:sl(oo()).optional(),reason:S().optional()});M({type:J("meta:methods"),methods:xe(V6)});const _w=1,q6=["daemon","main","renderer"],K6=We(q6),G6=["debug","info","warn","error"],Y6=We(G6);M({ts:q().int(),source:K6,level:Y6,msg:S(),ownerPrincipalId:S(),deviceId:S(),appVersion:S(),daemonVersion:S().optional(),os:S(),meta_json:S().optional(),sessionId:S().optional()});M({v:J(1),visitorId:S().min(1),displayName:S(),provider:S(),iat:q(),exp:q()});const X6=M({visitorId:S(),displayName:S(),avatarUrl:S().optional(),provider:S(),firstSeen:q(),lastSeen:q()});M({visitors:xe(X6)});const Q6=/<system-reminder>此消息来自飞书群成员 (.+?)<\/system-reminder>\s*$/,Z6=new Set(["localhost","127.0.0.1","0.0.0.0","::1"]);let pi=null;function J6(){if(pi!==null)return pi;if(typeof window>"u")return pi=!1,!1;if(Z6.has(window.location.hostname)||window.location.protocol==="file:")return pi=!0,!0;if(new URLSearchParams(window.location.search).get("debug")==="1"){pi=!0;try{sessionStorage.setItem("debug","1")}catch{}}else try{pi=sessionStorage.getItem("debug")==="1"}catch{pi=!1}return pi}function Ae(e,...t){J6()&&console.log(`[${e}][${new Date().toISOString()}]`,...t)}function cd(e){if(!e)return"<none>";let t=0;for(let n=0;n<e.length;n++)t=(t<<5)-t+e.charCodeAt(n)|0;return`<len:${e.length} hash:${(t>>>0).toString(16)}>`}const eB=e=>{const t=[1e3,2e3,4e3,8e3,16e3,3e4];return t[Math.min(e,t.length-1)]},tB=new Set(["auth:ok","pong","error"]),xw=new Set(vN.filter(e=>!tB.has(e)));let nB=0;const yw=()=>`r${++nB}`;function rB(e){let t=e.url,n=e.authToken,r=e.selfIdentity;const i=e.clientInfo,s=e.requestTimeoutMs??3e4,o=e.pingIntervalMs??3e4,a=e.watchdogMs??6e4,l=e.authTimeoutMs??1e4,c=e.backoffMs??eB;let u=null,d=!1,f=0,p=null,m=null,v=null,b=null,_=!1,x="disconnected";const y=new Map,w=new Map;let C=null;const k=(O,E)=>{var H;O==="ready"&&(C=E),(H=w.get(O))==null||H.forEach(V=>{try{V(E)}catch{}})},T=O=>{x!==O&&(x=O,k("status",O))},N=(O,E)=>{const H=w.get(O)??new Set;if(H.add(E),w.set(O,H),O==="ready"&&C!==null)try{E(C)}catch{}return()=>H.delete(E)},z=()=>{m&&(clearInterval(m),m=null),v&&(clearTimeout(v),v=null),b&&(clearTimeout(b),b=null)},P=()=>{v&&clearTimeout(v),v=setTimeout(()=>{try{u==null||u.close(4e3,"pong watchdog")}catch{}},a)},B=()=>{m&&clearInterval(m),m=setInterval(()=>{(u==null?void 0:u.readyState)===1&&u.send(JSON.stringify({type:"ping",requestId:yw()}))},o),P()},R=O=>{for(const[,E]of y)clearTimeout(E.timer),E.reject(new Error(O));y.clear()},I=[],j=()=>{if(I.length===0)return;const O=I.splice(0);for(const E of O)(u==null?void 0:u.readyState)===1&&!_?E.doSend():(clearTimeout(E.timer),E.reject(new Error("NOT_CONNECTED")))},L=O=>{if(I.length===0)return;const E=I.splice(0);for(const H of E)clearTimeout(H.timer),H.reject(new Error(O))},$=()=>{if(d)return;const O=c(f);O<0||(k("daemon:reconnecting",{attempt:f+1,nextDelayMs:O,scheduledAt:Date.now()}),p&&clearTimeout(p),p=setTimeout(()=>{f+=1,D()},O))},F=O=>{P();const E=String(O.type??"");if(E==="auth:ok"){Ae("daemon-client","auth:ok received → connected",{url:t}),b&&(clearTimeout(b),b=null),_=!1,f=0,T("connected"),k("daemon:connected",{url:t}),B(),j();return}if(E==="pong")return;if(E==="ready"){const V=Number(O.protocolVersion??-1);V!==_w&&k("daemon:version-mismatch",{daemonProtocol:V,supportedProtocol:_w}),k("ready",O);return}const H=O.requestId;if(typeof H=="string"&&y.has(H)){const V=y.get(H);if(y.delete(H),clearTimeout(V.timer),E==="error"){const A=String(O.code??"ERR"),ne=String(O.message??"unknown");V.reject(new Error(`${A}: ${ne}`))}else xw.has(E)&&k(E,O),V.resolve(O);return}xw.has(E)&&k(E,O)},D=()=>{p&&(clearTimeout(p),p=null),Ae("daemon-client","connect →",{url:t,token:cd(n),attempt:f}),T("connecting");let O;try{O=new WebSocket(t)}catch(E){T("disconnected"),k("daemon:disconnected",{reason:(E==null?void 0:E.message)??"ws constructor failed"}),$();return}u=O,_=!!n,O.onopen=()=>{if(O!==u){Ae("daemon-client","onopen → stale (replaced before opened), ignore");return}if(n){Ae("daemon-client","onopen → send auth frame",{token:cd(n)});const E={type:"auth",token:n};r!=null&&r.principalId&&(E.selfPrincipalId=r.principalId),r!=null&&r.displayName&&(E.selfDisplayName=r.displayName),i&&(E.clientInfo=i),O.send(JSON.stringify(E)),b=setTimeout(()=>{try{O.close(4001,"auth handshake timeout")}catch{}},l)}else Ae("daemon-client","onopen → no token, treat as connected (daemon authMode=none)"),f=0,T("connected"),k("daemon:connected",{url:t}),B(),j()},O.onclose=E=>{if(O!==u){Ae("daemon-client","onclose → stale, ignore",{code:E.code,reason:E.reason});return}const H=E.reason||(E.code===1008?"auth failed":`close ${E.code}`);if(Ae("daemon-client","onclose →",{code:E.code,reason:H,awaitingAuth:_,manualStop:d}),z(),R(`connection closed: ${H}`),u=null,E.code===4401?T("revoked"):T("disconnected"),k("daemon:disconnected",{reason:H}),E.code===1008||E.code===4401){L(`connection closed: ${H}`);return}d?L(`connection closed: ${H}`):$()},O.onerror=()=>{},O.onmessage=E=>{if(O!==u)return;let H;try{H=JSON.parse(String(E.data))}catch{return}F(H)}};return{start(){d=!1,f=0,D()},stop(){d=!0,p&&(clearTimeout(p),p=null),z();try{u==null||u.close(1e3,"shutdown")}catch{}u=null,R("shutdown"),L("shutdown"),T("disconnected")},switchProfile(O){Ae("daemon-client","switchProfile →",{url:O.url,token:cd(O.authToken)},"prev:",{url:t,token:cd(n)}),t=O.url,n=O.authToken,O.selfIdentity!==void 0&&(r=O.selfIdentity),f=0,d=!0,p&&(clearTimeout(p),p=null),z(),R("switch profile"),L("switch profile");try{u==null||u.close(1e3,"switch profile")}catch{}u=null,d=!1,D()},request(O,E){return new Promise((H,V)=>{const A=yw(),ne=setTimeout(()=>{y.delete(A);const G=I.findIndex(ye=>ye.timer===ne);G>=0&&I.splice(G,1),V(new Error(`request timeout: ${O}`))},s),ae=()=>{y.set(A,{resolve:G=>H(G),reject:V,timer:ne}),u.send(JSON.stringify({...E,type:O,requestId:A}))};(u==null?void 0:u.readyState)===1&&!_?ae():d||u==null&&p==null?(clearTimeout(ne),V(new Error("NOT_CONNECTED"))):I.push({doSend:ae,reject:V,timer:ne})})},on:N,get isOpen(){return(u==null?void 0:u.readyState)===1&&!_},get url(){return t},getStatus(){return x}}}function iB(e){if(!e)return"<none>";let t=0;for(let n=0;n<e.length;n++)t=(t<<5)-t+e.charCodeAt(n)|0;return`<len:${e.length} hash:${(t>>>0).toString(16)}>`}function sB(e){return e?{id:e.id,mode:e.mode,url:e.url,token:iB(e.token),name:e.name}:null}function ud(e){return e?Array.isArray(e)?e.map(sB):{_notArray:typeof e,_value:e}:null}function bw(e){return e==null?null:typeof e=="object"&&"value"in e?e.value:e}const oB="ws://127.0.0.1:18790",ww="daemon:profiles",Sw="daemon:active-profile-id";function aB(){return Math.random().toString(36).slice(2,10)}function lB(e){const t=e.trim(),n=t.indexOf("#");if(n<0)return{url:t};const r=t.slice(0,n),i=new URLSearchParams(t.slice(n+1)).get("token")??void 0;return{url:r,token:i}}function cB(e){if(!e||typeof e!="object")return!1;const t=e;return typeof t.id=="string"&&typeof t.name=="string"&&(t.mode==="localhost"||t.mode==="remote")&&typeof t.url=="string"&&(t.token===void 0||typeof t.token=="string")}function CN(e){let t={profiles:[],activeId:null},n=!1,r=null;const i=new Set,s=()=>{for(const l of i)l(t)},o=async()=>{Ae("profile-store","persist →",ud(t.profiles),"active:",t.activeId),await e.kv.set(ww,t.profiles),await e.kv.set(Sw,t.activeId)},a=async()=>{if(!n){if(r){await r;return}r=(async()=>{var l;try{let c=null;try{const d=await e.kv.get(ww);c=bw(d)}catch{c=null}let u=null;try{const d=await e.kv.get(Sw);u=bw(d)??null}catch{u=null}if(Ae("profile-store","ensureLoaded read kv →","profiles:",ud(c),"activeId:",u),Array.isArray(c)&&c.length>0){const d=c.filter(cB),f=u&&d.some(p=>p.id===u)?u:((l=d[0])==null?void 0:l.id)??null;t={profiles:d,activeId:f},n=!0,Ae("profile-store","ensureLoaded → use kv profiles",ud(d),"active:",f);return}t={profiles:[{id:"default",name:"本机",mode:"localhost",url:oB}],activeId:"default"},Ae("profile-store","ensureLoaded → fallback synthesized default (NO token)",ud(t.profiles)),n=!0,await o()}finally{r=null}})(),await r}};return{async load(){return await a(),s(),t},async snapshot(){return await a(),t},async upsert(l){var b;await a();let c=l.url,u=l.token;if(c&&c.includes("#")){const _=lB(c);c=_.url,!u&&_.token&&(u=_.token)}const d=l.id?t.profiles.find(_=>_.id===l.id):void 0,f=u!=null&&u.trim()?u.trim():d==null?void 0:d.token;if(l.mode==="remote"&&!f)throw new Error("remote mode requires token");const p=l.id??aB(),m={id:p,name:((b=l.name)==null?void 0:b.trim())||(d==null?void 0:d.name)||(l.mode==="remote"?"远程":"本机"),mode:l.mode,url:c.trim(),token:f};return t={profiles:[...t.profiles.filter(_=>_.id!==p),m],activeId:p},await o(),s(),m},async delete(l){var d;await a();const c=t.profiles.filter(f=>f.id!==l);let u=t.activeId;u===l&&(u=((d=c[0])==null?void 0:d.id)??null),t={profiles:c,activeId:u},await o(),s()},async activate(l){await a(),t.profiles.some(c=>c.id===l)&&(t={...t,activeId:l},await o(),s())},subscribe(l){return i.add(l),()=>i.delete(l)},getActive(){return n?t.profiles.find(l=>l.id===t.activeId)??null:null}}}const kw="clawd.client-instance-id";let uB={name:"clawd-web",version:"unknown"};function dB(){let e=null;try{e=localStorage.getItem(kw),e||(e=crypto.randomUUID(),localStorage.setItem(kw,e))}catch{e=e??crypto.randomUUID()}return{...uB,instanceId:e}}function Cw(e){if(!e)return"<none>";let t=0;for(let n=0;n<e.length;n++)t=(t<<5)-t+e.charCodeAt(n)|0;return`<len:${e.length} hash:${(t>>>0).toString(16)}>`}const EN=g.createContext(null);function hB({host:e,children:t}){const[n,r]=g.useState(null),i=g.useMemo(()=>async()=>{const s=CN(e),o=await s.load(),a=o.profiles.find(c=>c.id===o.activeId)??o.profiles[0];if(!a)throw new Error("DaemonProvider: profile store has no profiles after load");return Ae("daemon-context","bootstrap → createDaemonClient",{id:a.id,url:a.url,token:Cw(a.token)}),{client:rB({url:a.url,authToken:a.token,clientInfo:dB()}),store:s}},[e]);return g.useEffect(()=>{let s=!0,o=null,a=null;return i().then(l=>{s&&(l.client.start(),o=l,r(l),a=l.store.subscribe(()=>{const c=l.store.getActive();if(!c){Ae("daemon-context","subscribe → no active profile, skip switchProfile");return}Ae("daemon-context","subscribe → switchProfile",{id:c.id,url:c.url,token:Cw(c.token)}),l.client.switchProfile({url:c.url,authToken:c.token})}))}),()=>{s=!1,a==null||a(),o==null||o.client.stop()}},[i]),n?h.jsx(EN.Provider,{value:n,children:t}):null}function ci(){const e=g.useContext(EN);if(!e)throw new Error("useDaemonClient must be used inside <DaemonProvider>");return e.client}function fB(){const e=ci(),[t,n]=g.useState(void 0);return g.useEffect(()=>e.on("ready",i=>{const s=i.mode,o=s==="tui"?"tui":"sdk";Ae("daemon-context","useDaemonMode ready.mode =",{rawMode:s,resolved:o}),n(o)}),[e]),t}function pB(){const e=ci(),[t,n]=g.useState(void 0);return g.useEffect(()=>e.on("ready",i=>{const s=i;s.version!==void 0&&n(s.principalKind==="guest"?"guest":"owner")}),[e]),t}const TN=g.createContext(null);function mB({cache:e,children:t}){return g.createElement(TN.Provider,{value:e},t)}function Io(){const e=g.useContext(TN);if(!e)throw new Error("useCache must be used inside <CacheProvider>");return e}function si(e){const t=Io(),n=g.useCallback(i=>t.observe(e,()=>i()),[t,e]),r=g.useCallback(()=>t.read(e),[t,e]);return g.useSyncExternalStore(n,r,r)}const NN={actionsLevel:"none",httpBaseUrl:null,httpToken:null},PN=g.createContext(NN);function tp(){return g.useContext(PN)}function gB(e){return e!=null&&e.httpBaseUrl?{actionsLevel:e.tokenRole==="owner"?"owner":"none",httpBaseUrl:e.httpBaseUrl,httpToken:e.httpToken??null}:NN}function vB(){const e=si("daemon-info");return g.useMemo(()=>gB(e),[e])}function _B({children:e}){const t=vB();return Ze.createElement(PN.Provider,{value:t},e)}function xB(e,t,n){if(!e.httpBaseUrl)return null;const r=encodeURIComponent(n);return`${e.httpBaseUrl}/session/${encodeURIComponent(t.sessionId)}/files?path=${r}`}function yB(e){const t=new Map;return{observe(n,r){let i=t.get(n);i||(i={data:void 0,hasData:!1,listeners:new Set},t.set(n,i));const s=l=>r(l);i.listeners.add(s);const o=i.listeners.size===1;s(i.hasData?i.data:void 0),o&&e.onFirstObserver(n);let a=!1;return()=>{if(a)return;a=!0;const l=t.get(n);l&&(l.listeners.delete(s),l.listeners.size===0&&(t.delete(n),e.onLastObserver(n)))}},read(n){const r=t.get(n);return r!=null&&r.hasData?r.data:void 0},setData(n,r){const i=t.get(n);if(!i)return;const s=i.hasData?i.data:void 0,o=r(s);i.data=o,i.hasData=!0;for(const a of i.listeners)a(o)}}}function bB(){const e=[],t=new Map,n=r=>{for(const i of e)if(i.pattern.test(r))return i.source;return null};return{register(r,i){e.push({pattern:r,source:i})},activate(r){if(t.has(r))return;const i=n(r);if(!i)throw new Error(`no source registered for key: ${r}`);t.set(r,i.start(r))},deactivate(r){const i=t.get(r);i&&(t.delete(r),i())}}}function wB(e){return{request:(t,n)=>e.request(t,n),onFrame(t){const n=[];for(const r of vN)n.push(e.on(r,i=>t(r,i)));return()=>{for(const r of n)r()}},onConnect(t){return e.on("daemon:connected",()=>t())},get isConnected(){return e.isOpen}}}function IN(e){const t=(e??"claude")==="claude";return{rewind:t,subagents:t,tui:t,observe:t,fileSharing:t,fork:t}}const SB=e=>({tool:e,models:[{id:"",label:"未指定",contextWindowSize:2e5,default:!0}],permissionModes:[{id:"",label:"未指定"}],configSchema:[],features:IN(e)});function kB(e,t){return{start(n){const r=n.replace(/^capabilities\//,"");let i=!1;const s=async()=>{try{const a=await e.request("capabilities:get",{tool:r});if(i)return;t(n,()=>a)}catch{if(i)return;t(n,()=>SB(r))}},o=e.onConnect(()=>{s()});return s(),()=>{i=!0,o()}}}}function CB(e,t){return{start(n){let r=!1;const i=async()=>{try{const a=await e.request("session:list",void 0);if(r)return;t(n,()=>a.sessions??[])}catch{}},s=e.onFrame((a,l)=>{if(a==="session:info"){const c=l;if(c.chatId!==void 0)return;t(n,u=>[c,...(u??[]).filter(d=>d.sessionId!==c.sessionId)])}else if(a==="session:deleted"){const c=l;t(n,u=>(u??[]).filter(d=>d.sessionId!==c.sessionId))}}),o=e.onConnect(()=>{i()});return i(),()=>{r=!0,s(),o()}}}}const Vc={sessionId:null,events:[],lastSeq:-1,pendingPermissions:[],status:"idle",pendingQuestions:{}};function Tm(e,t){const n=t;if(n.kind==="permission_request"&&typeof n.requestId=="string"){if(e.some(i=>i.requestId===n.requestId))return e;const r={requestId:n.requestId,tool:typeof n.tool=="string"?n.tool:"",input:n.input,...typeof n.toolUseId=="string"&&n.toolUseId?{toolUseId:n.toolUseId}:{}};return[...e,r]}if(n.kind==="tool_result"&&typeof n.toolUseId=="string"&&n.toolUseId){const r=e.findIndex(i=>i.toolUseId===n.toolUseId);if(r>=0)return e.filter((i,s)=>s!==r)}return e}function RN(e,t,n){const r=n===void 0?e.sessionId:n;switch(t.type){case"session:change":return{...Vc,sessionId:t.sessionId};case"session:event":{if(!r||t.sessionId!==r)return e;const i=typeof t.event.seq=="number"?t.event.seq:-1,s=[...e.events,t.event],o=i>e.lastSeq?i:e.lastSeq,a=Tm(e.pendingPermissions,t.event);return{...e,events:s,lastSeq:o,pendingPermissions:a}}case"session:status":return!r||t.sessionId!==r?e:{...e,status:t.status};case"session:events":{if(!r||t.sessionId!==r)return e;const i=t.events.map(o=>o.event),s=i.reduce((o,a)=>Tm(o,a),[]);return{...e,sessionId:t.sessionId,events:i,lastSeq:t.latestSeq,pendingPermissions:s}}case"session:events:append":{if(!r||t.sessionId!==r)return e;const i=new Set;for(const c of e.events){const u=c.seq;typeof u=="number"&&i.add(u)}const s=[];for(const c of t.events)typeof c.seq=="number"&&(i.has(c.seq)||s.push(c.event));const o=t.latestSeq>e.lastSeq?t.latestSeq:e.lastSeq;if(s.length===0)return o===e.lastSeq?e:{...e,lastSeq:o};const a=[...e.events,...s].sort((c,u)=>{const d=c.seq??-1,f=u.seq??-1;return d-f}),l=s.reduce((c,u)=>Tm(c,u),e.pendingPermissions);return{...e,events:a,lastSeq:o,pendingPermissions:l}}case"permission:request":{if(!r||t.sessionId!==r||e.pendingPermissions.some(s=>s.requestId===t.requestId))return e;const i={requestId:t.requestId,tool:t.tool,input:t.input,...t.toolUseId?{toolUseId:t.toolUseId}:{}};return{...e,pendingPermissions:[...e.pendingPermissions,i]}}case"permission:clear":{if(!r||r!==t.sessionId)return e;const i=t.requestId,s=e.pendingPermissions.findIndex(c=>c.requestId===i),o=s>=0?e.pendingPermissions.filter((c,u)=>u!==s):e.pendingPermissions;if(e.events.length===0)return o===e.pendingPermissions?e:{...e,pendingPermissions:o};const a=e.events.length-1,l=e.events[a];return l.kind==="permission_request"&&l.requestId===i?{...e,pendingPermissions:o,events:e.events.slice(0,a)}:o===e.pendingPermissions?e:{...e,pendingPermissions:o}}case"session:question":return!r||t.sessionId!==r?e:{...e,pendingQuestions:{...e.pendingQuestions,[t.toolUseId]:{toolUseId:t.toolUseId,requestId:t.requestId,questions:t.questions}}};case"session:question:clear":{if(!r||t.sessionId!==r||!(t.toolUseId in e.pendingQuestions))return e;const{[t.toolUseId]:i,...s}=e.pendingQuestions;return{...e,pendingQuestions:s}}case"session:question:submitted":{if(!r||t.sessionId!==r)return e;const i=e.pendingQuestions[t.toolUseId];return i?{...e,pendingQuestions:{...e.pendingQuestions,[t.toolUseId]:{...i,submittedAnswers:t.answers}}}:e}case"session:rewound":return!r||t.sessionId!==r?e:{...e,pendingPermissions:[],status:"idle"};case"ready":{if(!r)return e;const i=t.runningSessions.find(o=>o.sessionId===r);if(i!=null&&i.freshSpawn)return{...Vc,sessionId:r};const s=(i==null?void 0:i.status)??"idle";return s===e.status?e:{...e,status:s}}case"daemon:disconnected":return{...e,pendingPermissions:[]};default:return e}}const EB="session/";function TB(e){return{sid:e.slice(EB.length)}}const NB=new Set(_N);function MN(e){return NB.has(e)}function Ew(e){return MN(e)?e:"idle"}function PB(e,t){return{start(n){const{sid:r}=TB(n);let i=!1,s=-1;const o=f=>{t(n,p=>RN(p??Vc,f,r))},a=async f=>{const p=f==="baseline"?-1:s;try{const m=await e.request("session:events",{sessionId:r,afterSeq:p});if(i)return;const v=m.events??[],b=m.latestSeq??-1;if(f==="baseline")o({type:"session:events",sessionId:r,events:v,latestSeq:b}),s=b;else{const _=m.bufferStartSeq??0,x=b<p||_>p+1;o({type:x?"session:events":"session:events:append",sessionId:r,events:v,latestSeq:b}),s=Math.max(s,b)}}catch{}},l=async()=>{try{const f=await e.request("info");if(i)return;o({type:"ready",runningSessions:(f.runningSessions??[]).map(p=>({sessionId:p.sessionId,freshSpawn:p.freshSpawn,status:Ew(p.status)}))})}catch{}},c=async()=>{try{await e.request("session:subscribe",{sessionId:r})}catch{}i||(await a(s<0?"baseline":"delta"),!i&&await l())},u=e.onFrame((f,p)=>{if(!i)if(f==="session:event"){const m=p;if(m.sessionId!==r)return;const v=m.event.seq;Ae("session-events","push session:event",{sid:r,kind:m.event.kind,seq:v,lastSeqBefore:s}),o({type:"session:event",sessionId:m.sessionId,event:m.event}),typeof v=="number"&&v>s&&(s=v)}else if(f==="session:status"){const m=p;if(m.sessionId!==r)return;if(!MN(m.status)){Ae("session-events","push session:status drop",{sid:r,status:m.status});return}Ae("session-events","push session:status",{sid:r,status:m.status}),o({type:"session:status",sessionId:m.sessionId,status:m.status})}else if(f==="session:cleared"){if(p.sessionId!==r)return;Ae("session-events","push session:cleared",{sid:r}),o({type:"session:change",sessionId:r}),s=-1}else if(f==="permission:request"){const m=p;if(m.sessionId!==r)return;o({type:"permission:request",sessionId:m.sessionId,requestId:m.requestId,tool:m.tool,input:m.input,...typeof m.toolUseId=="string"&&m.toolUseId?{toolUseId:m.toolUseId}:{}})}else if(f==="session:question"){const m=p;if(m.sessionId!==r)return;o({type:"session:question",sessionId:m.sessionId,toolUseId:m.toolUseId,requestId:m.requestId,questions:m.questions})}else if(f==="session:question:cleared"){const m=p;if(m.sessionId!==r)return;m.answers&&Object.keys(m.answers).length>0?o({type:"session:question:submitted",sessionId:m.sessionId,toolUseId:m.toolUseId,answers:m.answers}):o({type:"session:question:clear",sessionId:m.sessionId,toolUseId:m.toolUseId})}else if(f==="session:rewound"){const m=p;if(m.sessionId!==r)return;o({type:"session:rewound",sessionId:m.sessionId,userMessageId:m.userMessageId})}else f==="ready"&&o({type:"ready",runningSessions:(p.runningSessions??[]).map(v=>({sessionId:v.sessionId,freshSpawn:v.freshSpawn,status:Ew(v.status)}))})}),d=e.onConnect(()=>{c()});return e.isConnected&&c(),()=>{i=!0,u(),d(),e.request("session:unsubscribe",{sessionId:r}).catch(()=>{})}}}}const IB=new Set(["tunnel:ready","tunnel:exited","tunnel:unavailable"]);function RB(e,t){return{start(n){let r=!1;const i=async()=>{try{const a=await e.request("info",void 0);if(r)return;t(n,()=>a)}catch{}},s=e.onConnect(()=>{i()}),o=e.onFrame(a=>{IB.has(a)&&i()});return i(),()=>{r=!0,s(),o()}}}}function MB(){return{start(){return()=>{}}}}function AB(e,t){return{start(n){let r=!1;const i=async()=>{try{const o=await e.request("persona:list",{});if(r)return;t(n,()=>o.personas??[])}catch{}},s=e.onConnect(()=>{i()});return i(),()=>{r=!0,s()}}}}function LB(e){const t=wB(e),n=bB();let r=null;const i=(o,a)=>{r==null||r.setData(o,a)};n.register(/^capabilities\//,kB(t,i)),n.register(/^sessions$/,CB(t,i)),n.register(/^session\//,PB(t,i)),n.register(/^personas$/,AB(t,i)),n.register(/^persona-detail\//,MB()),n.register(/^daemon-info$/,RB(t,i));const s=yB({onFirstObserver:o=>{o&&n.activate(o)},onLastObserver:o=>{o&&n.deactivate(o)}});return r=s,{cache:s,channel:t}}class Ox{constructor(t){this.client=t}info(){return this.client.request("info")}attachmentSignUrl(t){return this.client.request("attachment.signUrl",t)}attachmentGroupAdd(t,n,r){return this.client.request("attachment.groupAdd",{sessionId:t,relPath:n,...r?{label:r}:{}})}attachmentGroupRemove(t,n){return this.client.request("attachment.groupRemove",{sessionId:t,relPath:n})}attachmentGroupList(t){return this.client.request("attachment.groupList",{sessionId:t})}sessionCreate(t){return this.client.request("session:create",t)}projectList(){return this.client.request("project:list")}projectCreate(t){return this.client.request("project:create",{...t.path?{path:t.path}:{},...t.name?{name:t.name}:{}})}projectPatch(t){return this.client.request("project:patch",t)}projectReveal(t){return this.client.request("project:reveal",{path:t})}appBuilderListProjects(){return this.client.request("appBuilder:listProjects",{})}appBuilderGetProject(t){return this.client.request("appBuilder:getProject",{sessionId:t})}appBuilderUpdateProjectPort(t,n){return this.client.request("appBuilder:updateProjectPort",{name:t,newPort:n})}appBuilderStartDevServer(t,n){return this.client.request("appBuilder:startDevServer",{sessionId:t,...n!=null&&n.force?{force:!0}:{}})}appBuilderStopDevServer(t){return this.client.request("appBuilder:stopDevServer",{sessionId:t})}appBuilderPublish(t){return this.client.request("appBuilder:publish",{name:t})}appBuilderDismissPublishJob(t){return this.client.request("appBuilder:dismissPublishJob",{name:t})}sessionList(){return this.client.request("session:list")}sessionGet(t){return this.client.request("session:get",{sessionId:t})}sessionUpdate(t,n){return this.client.request("session:update",{sessionId:t,patch:n})}sessionDelete(t){return this.client.request("session:delete",{sessionId:t})}sessionSend(t,n){return this.client.request("session:send",{sessionId:t,text:n})}sessionStop(t){return this.client.request("session:stop",{sessionId:t})}sessionInterrupt(t){return this.client.request("session:interrupt",{sessionId:t})}sessionRewind(t){return this.client.request("session:rewind",t)}sessionRewindableMessageIds(t){return this.client.request("session:rewindable-message-ids",{sessionId:t})}sessionRewindDiff(t){return this.client.request("session:rewind-diff",t)}sessionNew(t){return this.client.request("session:new",{sessionId:t})}sessionFork(t){return this.client.request("session:fork",t)}sessionResume(t,n){return this.client.request("session:resume",{sessionId:t,toolSessionId:n})}sessionObserve(t){return this.client.request("session:observe",t)}sessionEvents(t,n){return this.client.request("session:events",{sessionId:t,afterSeq:n})}sessionSubscribe(t){return this.client.request("session:subscribe",{sessionId:t})}sessionUnsubscribe(t){return this.client.request("session:unsubscribe",{sessionId:t})}pinSession(t,n){return this.client.request("session:pin",{sessionId:t,pinned:n})}archiveSession(t,n){return this.client.request("session:archive",{sessionId:t,archived:n})}markSessionRead(t){return this.client.request("session:markRead",{sessionId:t})}reorderPins(t){return this.client.request("session:reorderPins",{orderedIds:t})}peerSessionUpsert(t){return this.client.request("peerSession:upsert",t)}peerSessionRemove(t){return this.client.request("peerSession:remove",{sessionId:t})}permissionRespond(t){return this.client.request("permission:respond",t)}answerQuestion(t){return this.client.request("session:answerQuestion",t)}cancelQuestion(t){return this.client.request("session:cancelQuestion",t)}historyProjects(){return this.client.request("history:projects")}historyList(t){return this.client.request("history:list",{projectPath:t})}historyRead(t){return this.client.request("history:read",t)}historySubagents(t){return this.client.request("history:subagents",t)}historySubagentRead(t){return this.client.request("history:subagent-read",t)}listRecentDirs(){return this.client.request("history:recentDirs",{})}getGitRoot(t){return this.client.request("git:root",{cwd:t})}getGitBranch(t){return this.client.request("git:branch",{cwd:t})}listGitBranches(t){return this.client.request("git:branches",{cwd:t})}personaCreate(t){return this.client.request("persona:create",t)}personaList(){return this.client.request("persona:list",{})}personaGet(t){return this.client.request("persona:get",{personaId:t})}personaUpdate(t,n){return this.client.request("persona:update",{personaId:t,patch:n})}personaDelete(t){return this.client.request("persona:delete",{personaId:t})}larkBotBindManual(t,n,r){return this.client.request("larkBot:bindManual",{personaId:t,appId:n,appSecret:r})}larkBotUnbind(t){return this.client.request("larkBot:unbind",{personaId:t})}larkBotStatus(t){return this.client.request("larkBot:status",{personaId:t})}toolsProbe(){return this.client.request("tools:probe",{})}sessionExternalScan(){return this.client.request("session:externalScan",{})}sessionImportExternal(t){return this.client.request("session:importExternal",t)}onboardingComplete(){return this.client.request("onboarding:complete",{})}onboardingIosInterest(){return this.client.request("onboarding:iosInterest",{})}visitorList(){return this.client.request("visitor:list",{})}workspaceList(t={}){return this.client.request("workspace:list",t)}workspaceRead(t){return this.client.request("workspace:read",t)}skillsList(t,n){return this.client.request("skills:list",{cwd:t,...n?{tool:n}:{}})}agentsList(t,n){return this.client.request("agents:list",{cwd:t,...n?{tool:n}:{}})}capabilitiesGet(t="claude"){return this.client.request("capabilities:get",{tool:t})}shiftList(){return this.client.request("shift:list")}githubStatus(){return this.client.request("github:status")}githubPrList(t){return this.client.request("github:prList",{role:t})}githubPrDetail(t){return this.client.request("github:prDetail",{...t})}githubPrMerge(t){return this.client.request("github:prMerge",{...t})}githubPrComment(t){return this.client.request("github:prComment",{...t})}githubPrSetReady(t){return this.client.request("github:prSetReady",{...t})}githubCollaborators(t){return this.client.request("github:collaborators",{...t})}githubPrRequestReviewers(t){return this.client.request("github:prRequestReviewers",{...t})}}function jB(e){const[t,n]=g.useState(e.isOpen?{kind:"connected",url:""}:{kind:"connecting"});return g.useEffect(()=>{const r=e.on("ready",l=>{const c=l;n(u=>({kind:"connected",url:u.kind==="connected"?u.url:"",mode:u.kind==="connected"?u.mode:void 0,daemonVersion:c.version,protocolVersion:c.protocolVersion,daemonSource:c.daemonSource,globalCliVersion:c.globalCliVersion,onboardingCompletedAt:c.onboardingCompletedAt}))}),i=e.on("daemon:connected",l=>{const c=l;n(u=>({kind:"connected",url:c.url,mode:c.mode,daemonVersion:u.kind==="connected"?u.daemonVersion:void 0,protocolVersion:u.kind==="connected"?u.protocolVersion:void 0,daemonSource:u.kind==="connected"?u.daemonSource:void 0,globalCliVersion:u.kind==="connected"?u.globalCliVersion:void 0,onboardingCompletedAt:u.kind==="connected"?u.onboardingCompletedAt:void 0}))}),s=e.on("daemon:disconnected",l=>{const c=(l==null?void 0:l.reason)??"";/auth failed|auth timeout|auth required|auth handshake timeout/i.test(c)?n({kind:"auth-failed",reason:c}):n({kind:"disconnected",reason:c})}),o=e.on("daemon:reconnecting",l=>{const c=l;n({kind:"reconnecting",attempt:c.attempt,nextDelayMs:c.nextDelayMs,scheduledAt:c.scheduledAt??Date.now()})}),a=e.on("daemon:version-mismatch",l=>{const c=l;n({kind:"version-mismatch",daemonProtocol:c.daemonProtocol,supportedProtocol:c.supportedProtocol})});return()=>{r(),i(),s(),o(),a()}},[e]),t}function DB(e){const t=Io(),n=si(e.kind==="connected"?"sessions":""),r=g.useCallback(async()=>{t.setData("sessions",i=>i??[])},[t]);return{sessions:n??[],loading:!1,loaded:n!==void 0,error:null,refresh:r}}function cl(){const e=ci();return g.useMemo(()=>new Ox(e),[e])}function AN(e){return{personaId:e.personaId,label:e.label,model:e.model,effort:e.effort,tool:e.tool,public:e.public,createdAt:e.createdAt,updatedAt:e.updatedAt}}function LN(){const e=Io(),t=cl(),n=si("personas")??[],r=g.useMemo(()=>n.map(s=>AN(s)),[n]),i=g.useCallback(async()=>{const s=await t.personaList();e.setData("personas",()=>s.personas??[])},[t,e]);return{personas:r,raw:n,loaded:si("personas")!==void 0,refresh:i}}function jN(e){const{raw:t}=LN(),n=Io(),r=cl(),i=e?t.find(a=>a.personaId===e)??null:null,s=i?AN(i):null,o=g.useCallback(async()=>{if(!e)return;const a=await r.personaList();n.setData("personas",()=>a.personas??[])},[e,r,n]);return{persona:s,raw:i,loaded:!!s,refresh:o}}function OB(e){const t=cl(),n=Io(),r=e?`persona-detail/${e}`:"",i=si(r),s=g.useCallback(async()=>{const o={personality:"",skills:[],plugins:[],sandboxSettings:null};if(!e)return o;const a=await t.personaGet(e);let l;if("persona"in a&&a.persona===null)l=o;else{const c=a;l={personality:c.personality??"",skills:c.skills??[],plugins:c.plugins??[],sandboxSettings:c.sandboxSettings??null}}return n.setData(r,()=>l),l},[t,n,e,r]);return g.useEffect(()=>{e&&s()},[e,s]),{personality:(i==null?void 0:i.personality)??"",skills:(i==null?void 0:i.skills)??[],plugins:(i==null?void 0:i.plugins)??[],sandboxSettings:(i==null?void 0:i.sandboxSettings)??null,loaded:i!==void 0,refresh:s}}function DN(){const e=Io(),t=cl();return g.useCallback(async()=>{const n=await t.personaList();e.setData("personas",()=>n.personas??[])},[e,t])}function BB(){const e=cl(),t=DN();return g.useCallback(async(n,r)=>{const i=await e.personaUpdate(n,r);return await t(),i},[e,t])}function zB(){const e=cl(),t=DN();return g.useCallback(async n=>{await e.personaDelete(n),await t()},[e,t])}const Tw="clawd:sidebar:tree-collapsed";function $B(e){return e&&typeof e=="object"&&"value"in e?e.value:e}function FB(e){const t=$B(e);if(!Array.isArray(t))return new Set;const n=new Set;for(const r of t)typeof r=="string"&&n.add(r);return n}function HB(){const e=bx(),[t,n]=g.useState(()=>new Set),r=g.useRef(t);r.current=t,g.useEffect(()=>{let l=!1;return(async()=>{try{const c=await e.kv.get(Tw);if(l)return;n(FB(c))}catch{}})(),()=>{l=!0}},[e]);const i=g.useCallback(l=>{e.kv.set(Tw,[...l]).catch(()=>{})},[e]),s=g.useCallback(l=>r.current.has(l),[]),o=g.useCallback(l=>{n(c=>{const u=new Set(c);return u.has(l)?u.delete(l):u.add(l),i(u),u})},[i]),a=g.useCallback(l=>{n(c=>{let u=!1;const d=new Set;for(const f of c)l.has(f)?d.add(f):u=!0;return u?(i(d),d):c})},[i]);return{isCollapsed:s,toggle:o,prune:a}}const Bx=g.createContext(null);function UB(){const e=g.useContext(Bx);if(!e)throw new Error("SessionTreeCollapsedContext.Provider missing — wrap SessionTreeNode tree with <SessionTreeCollapsedContext.Provider value={useSessionTreeCollapsed()}>");return e}/**
96
96
  * @license lucide-react v0.577.0 - ISC
97
97
  *
98
98
  * This source code is licensed under the ISC license.
@@ -480,7 +480,7 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
480
480
  `)},m7=0,Ko=[];function g7(e){var t=g.useRef([]),n=g.useRef([0,0]),r=g.useRef(),i=g.useState(m7++)[0],s=g.useState(JP)[0],o=g.useRef(e);g.useEffect(function(){o.current=e},[e]),g.useEffect(function(){if(e.inert){document.body.classList.add("block-interactivity-".concat(i));var v=O9([e.lockRef.current],(e.shards||[]).map(aS),!0).filter(Boolean);return v.forEach(function(b){return b.classList.add("allow-interactivity-".concat(i))}),function(){document.body.classList.remove("block-interactivity-".concat(i)),v.forEach(function(b){return b.classList.remove("allow-interactivity-".concat(i))})}}},[e.inert,e.lockRef.current,e.shards]);var a=g.useCallback(function(v,b){if("touches"in v&&v.touches.length===2||v.type==="wheel"&&v.ctrlKey)return!o.current.allowPinchZoom;var _=_d(v),x=n.current,y="deltaX"in v?v.deltaX:x[0]-_[0],w="deltaY"in v?v.deltaY:x[1]-_[1],C,k=v.target,T=Math.abs(y)>Math.abs(w)?"h":"v";if("touches"in v&&T==="h"&&k.type==="range")return!1;var N=window.getSelection(),z=N&&N.anchorNode,P=z?z===k||z.contains(k):!1;if(P)return!1;var B=sS(T,k);if(!B)return!0;if(B?C=T:(C=T==="v"?"h":"v",B=sS(T,k)),!B)return!1;if(!r.current&&"changedTouches"in v&&(y||w)&&(r.current=C),!C)return!0;var R=r.current||C;return h7(R,b,v,R==="h"?y:w)},[]),l=g.useCallback(function(v){var b=v;if(!(!Ko.length||Ko[Ko.length-1]!==s)){var _="deltaY"in b?oS(b):_d(b),x=t.current.filter(function(C){return C.name===b.type&&(C.target===b.target||b.target===C.shadowParent)&&f7(C.delta,_)})[0];if(x&&x.should){b.cancelable&&b.preventDefault();return}if(!x){var y=(o.current.shards||[]).map(aS).filter(Boolean).filter(function(C){return C.contains(b.target)}),w=y.length>0?a(b,y[0]):!o.current.noIsolation;w&&b.cancelable&&b.preventDefault()}}},[]),c=g.useCallback(function(v,b,_,x){var y={name:v,delta:b,target:_,should:x,shadowParent:v7(_)};t.current.push(y),setTimeout(function(){t.current=t.current.filter(function(w){return w!==y})},1)},[]),u=g.useCallback(function(v){n.current=_d(v),r.current=void 0},[]),d=g.useCallback(function(v){c(v.type,oS(v),v.target,a(v,e.lockRef.current))},[]),f=g.useCallback(function(v){c(v.type,_d(v),v.target,a(v,e.lockRef.current))},[]);g.useEffect(function(){return Ko.push(s),e.setCallbacks({onScrollCapture:d,onWheelCapture:d,onTouchMoveCapture:f}),document.addEventListener("wheel",l,qo),document.addEventListener("touchmove",l,qo),document.addEventListener("touchstart",u,qo),function(){Ko=Ko.filter(function(v){return v!==s}),document.removeEventListener("wheel",l,qo),document.removeEventListener("touchmove",l,qo),document.removeEventListener("touchstart",u,qo)}},[]);var p=e.removeScrollBar,m=e.inert;return g.createElement(g.Fragment,null,m?g.createElement(s,{styles:p7(i)}):null,p?g.createElement(s7,{noRelative:e.noRelative,gapMode:e.gapMode}):null)}function v7(e){for(var t=null;e!==null;)e instanceof ShadowRoot&&(t=e.host,e=e.host),e=e.parentNode;return t}const _7=q9(ZP,g7);var ry=g.forwardRef(function(e,t){return g.createElement(fp,Gr({},e,{ref:t,sideCar:_7}))});ry.classNames=fp.classNames;var x0=["Enter"," "],x7=["ArrowDown","PageUp","Home"],rI=["ArrowUp","PageDown","End"],y7=[...x7,...rI],b7={ltr:[...x0,"ArrowRight"],rtl:[...x0,"ArrowLeft"]},w7={ltr:["ArrowLeft"],rtl:["ArrowRight"]},bu="Menu",[Xc,S7,k7]=hP(bu),[Lo,iI]=Ao(bu,[k7,hp,UP]),wu=hp(),sI=UP(),[oI,Ds]=Lo(bu),[C7,Su]=Lo(bu),aI=e=>{const{__scopeMenu:t,open:n=!1,children:r,dir:i,onOpenChange:s,modal:o=!0}=e,a=wu(t),[l,c]=g.useState(null),u=g.useRef(!1),d=oi(s),f=fP(i);return g.useEffect(()=>{const p=()=>{u.current=!0,document.addEventListener("pointerdown",m,{capture:!0,once:!0}),document.addEventListener("pointermove",m,{capture:!0,once:!0})},m=()=>u.current=!1;return document.addEventListener("keydown",p,{capture:!0}),()=>{document.removeEventListener("keydown",p,{capture:!0}),document.removeEventListener("pointerdown",m,{capture:!0}),document.removeEventListener("pointermove",m,{capture:!0})}},[]),h.jsx(ty,{...a,children:h.jsx(oI,{scope:t,open:n,onOpenChange:d,content:l,onContentChange:c,children:h.jsx(C7,{scope:t,onClose:g.useCallback(()=>d(!1),[d]),isUsingKeyboardRef:u,dir:f,modal:o,children:r})})})};aI.displayName=bu;var E7="MenuAnchor",iy=g.forwardRef((e,t)=>{const{__scopeMenu:n,...r}=e,i=wu(n);return h.jsx(zP,{...i,...r,ref:t})});iy.displayName=E7;var sy="MenuPortal",[T7,lI]=Lo(sy,{forceMount:void 0}),cI=e=>{const{__scopeMenu:t,forceMount:n,children:r,container:i}=e,s=Ds(sy,t);return h.jsx(T7,{scope:t,forceMount:n,children:h.jsx($i,{present:n||s.open,children:h.jsx(ny,{asChild:!0,container:i,children:r})})})};cI.displayName=sy;var gr="MenuContent",[N7,oy]=Lo(gr),uI=g.forwardRef((e,t)=>{const n=lI(gr,e.__scopeMenu),{forceMount:r=n.forceMount,...i}=e,s=Ds(gr,e.__scopeMenu),o=Su(gr,e.__scopeMenu);return h.jsx(Xc.Provider,{scope:e.__scopeMenu,children:h.jsx($i,{present:r||s.open,children:h.jsx(Xc.Slot,{scope:e.__scopeMenu,children:o.modal?h.jsx(P7,{...i,ref:t}):h.jsx(I7,{...i,ref:t})})})})}),P7=g.forwardRef((e,t)=>{const n=Ds(gr,e.__scopeMenu),r=g.useRef(null),i=qt(t,r);return g.useEffect(()=>{const s=r.current;if(s)return YP(s)},[]),h.jsx(ay,{...e,ref:i,trapFocus:n.open,disableOutsidePointerEvents:n.open,disableOutsideScroll:!0,onFocusOutside:Pe(e.onFocusOutside,s=>s.preventDefault(),{checkForDefaultPrevented:!1}),onDismiss:()=>n.onOpenChange(!1)})}),I7=g.forwardRef((e,t)=>{const n=Ds(gr,e.__scopeMenu);return h.jsx(ay,{...e,ref:t,trapFocus:!1,disableOutsidePointerEvents:!1,disableOutsideScroll:!1,onDismiss:()=>n.onOpenChange(!1)})}),R7=Gc("MenuContent.ScrollLock"),ay=g.forwardRef((e,t)=>{const{__scopeMenu:n,loop:r=!1,trapFocus:i,onOpenAutoFocus:s,onCloseAutoFocus:o,disableOutsidePointerEvents:a,onEntryFocus:l,onEscapeKeyDown:c,onPointerDownOutside:u,onFocusOutside:d,onInteractOutside:f,onDismiss:p,disableOutsideScroll:m,...v}=e,b=Ds(gr,n),_=Su(gr,n),x=wu(n),y=sI(n),w=S7(n),[C,k]=g.useState(null),T=g.useRef(null),N=qt(t,T,b.onContentChange),z=g.useRef(0),P=g.useRef(""),B=g.useRef(0),R=g.useRef(null),I=g.useRef("right"),j=g.useRef(0),L=m?ry:g.Fragment,$=m?{as:R7,allowPinchZoom:!0}:void 0,F=O=>{var ye,Fe;const E=P.current+O,H=w().filter(ue=>!ue.disabled),V=document.activeElement,A=(ye=H.find(ue=>ue.ref.current===V))==null?void 0:ye.textValue,ne=H.map(ue=>ue.textValue),ae=U7(ne,E,A),G=(Fe=H.find(ue=>ue.textValue===ae))==null?void 0:Fe.ref.current;(function ue(Ie){P.current=Ie,window.clearTimeout(z.current),Ie!==""&&(z.current=window.setTimeout(()=>ue(""),1e3))})(E),G&&setTimeout(()=>G.focus())};g.useEffect(()=>()=>window.clearTimeout(z.current),[]),gP();const D=g.useCallback(O=>{var H,V;return I.current===((H=R.current)==null?void 0:H.side)&&V7(O,(V=R.current)==null?void 0:V.area)},[]);return h.jsx(N7,{scope:n,searchRef:P,onItemEnter:g.useCallback(O=>{D(O)&&O.preventDefault()},[D]),onItemLeave:g.useCallback(O=>{var E;D(O)||((E=T.current)==null||E.focus(),k(null))},[D]),onTriggerLeave:g.useCallback(O=>{D(O)&&O.preventDefault()},[D]),pointerGraceTimerRef:B,onPointerGraceIntentChange:g.useCallback(O=>{R.current=O},[]),children:h.jsx(L,{...$,children:h.jsx(qx,{asChild:!0,trapped:i,onMountAutoFocus:Pe(s,O=>{var E;O.preventDefault(),(E=T.current)==null||E.focus({preventScroll:!0})}),onUnmountAutoFocus:o,children:h.jsx(ap,{asChild:!0,disableOutsidePointerEvents:a,onEscapeKeyDown:c,onPointerDownOutside:u,onFocusOutside:d,onInteractOutside:f,onDismiss:p,children:h.jsx(M9,{asChild:!0,...y,dir:_.dir,orientation:"vertical",loop:r,currentTabStopId:C,onCurrentTabStopIdChange:k,onEntryFocus:Pe(l,O=>{_.isUsingKeyboardRef.current||O.preventDefault()}),preventScrollOnEntryFocus:!0,children:h.jsx($P,{role:"menu","aria-orientation":"vertical","data-state":TI(b.open),"data-radix-menu-content":"",dir:_.dir,...x,...v,ref:N,style:{outline:"none",...v.style},onKeyDown:Pe(v.onKeyDown,O=>{const H=O.target.closest("[data-radix-menu-content]")===O.currentTarget,V=O.ctrlKey||O.altKey||O.metaKey,A=O.key.length===1;H&&(O.key==="Tab"&&O.preventDefault(),!V&&A&&F(O.key));const ne=T.current;if(O.target!==ne||!y7.includes(O.key))return;O.preventDefault();const G=w().filter(ye=>!ye.disabled).map(ye=>ye.ref.current);rI.includes(O.key)&&G.reverse(),F7(G)}),onBlur:Pe(e.onBlur,O=>{O.currentTarget.contains(O.target)||(window.clearTimeout(z.current),P.current="")}),onPointerMove:Pe(e.onPointerMove,Qc(O=>{const E=O.target,H=j.current!==O.clientX;if(O.currentTarget.contains(E)&&H){const V=O.clientX>j.current?"right":"left";I.current=V,j.current=O.clientX}}))})})})})})})});uI.displayName=gr;var M7="MenuGroup",ly=g.forwardRef((e,t)=>{const{__scopeMenu:n,...r}=e;return h.jsx(Et.div,{role:"group",...r,ref:t})});ly.displayName=M7;var A7="MenuLabel",dI=g.forwardRef((e,t)=>{const{__scopeMenu:n,...r}=e;return h.jsx(Et.div,{...r,ref:t})});dI.displayName=A7;var tf="MenuItem",lS="menu.itemSelect",pp=g.forwardRef((e,t)=>{const{disabled:n=!1,onSelect:r,...i}=e,s=g.useRef(null),o=Su(tf,e.__scopeMenu),a=oy(tf,e.__scopeMenu),l=qt(t,s),c=g.useRef(!1),u=()=>{const d=s.current;if(!n&&d){const f=new CustomEvent(lS,{bubbles:!0,cancelable:!0});d.addEventListener(lS,p=>r==null?void 0:r(p),{once:!0}),dP(d,f),f.defaultPrevented?c.current=!1:o.onClose()}};return h.jsx(hI,{...i,ref:l,disabled:n,onClick:Pe(e.onClick,u),onPointerDown:d=>{var f;(f=e.onPointerDown)==null||f.call(e,d),c.current=!0},onPointerUp:Pe(e.onPointerUp,d=>{var f;c.current||(f=d.currentTarget)==null||f.click()}),onKeyDown:Pe(e.onKeyDown,d=>{const f=a.searchRef.current!=="";n||f&&d.key===" "||x0.includes(d.key)&&(d.currentTarget.click(),d.preventDefault())})})});pp.displayName=tf;var hI=g.forwardRef((e,t)=>{const{__scopeMenu:n,disabled:r=!1,textValue:i,...s}=e,o=oy(tf,n),a=sI(n),l=g.useRef(null),c=qt(t,l),[u,d]=g.useState(!1),[f,p]=g.useState("");return g.useEffect(()=>{const m=l.current;m&&p((m.textContent??"").trim())},[s.children]),h.jsx(Xc.ItemSlot,{scope:n,disabled:r,textValue:i??f,children:h.jsx(A9,{asChild:!0,...a,focusable:!r,children:h.jsx(Et.div,{role:"menuitem","data-highlighted":u?"":void 0,"aria-disabled":r||void 0,"data-disabled":r?"":void 0,...s,ref:c,onPointerMove:Pe(e.onPointerMove,Qc(m=>{r?o.onItemLeave(m):(o.onItemEnter(m),m.defaultPrevented||m.currentTarget.focus({preventScroll:!0}))})),onPointerLeave:Pe(e.onPointerLeave,Qc(m=>o.onItemLeave(m))),onFocus:Pe(e.onFocus,()=>d(!0)),onBlur:Pe(e.onBlur,()=>d(!1))})})})}),L7="MenuCheckboxItem",fI=g.forwardRef((e,t)=>{const{checked:n=!1,onCheckedChange:r,...i}=e;return h.jsx(_I,{scope:e.__scopeMenu,checked:n,children:h.jsx(pp,{role:"menuitemcheckbox","aria-checked":nf(n)?"mixed":n,...i,ref:t,"data-state":dy(n),onSelect:Pe(i.onSelect,()=>r==null?void 0:r(nf(n)?!0:!n),{checkForDefaultPrevented:!1})})})});fI.displayName=L7;var pI="MenuRadioGroup",[j7,D7]=Lo(pI,{value:void 0,onValueChange:()=>{}}),mI=g.forwardRef((e,t)=>{const{value:n,onValueChange:r,...i}=e,s=oi(r);return h.jsx(j7,{scope:e.__scopeMenu,value:n,onValueChange:s,children:h.jsx(ly,{...i,ref:t})})});mI.displayName=pI;var gI="MenuRadioItem",vI=g.forwardRef((e,t)=>{const{value:n,...r}=e,i=D7(gI,e.__scopeMenu),s=n===i.value;return h.jsx(_I,{scope:e.__scopeMenu,checked:s,children:h.jsx(pp,{role:"menuitemradio","aria-checked":s,...r,ref:t,"data-state":dy(s),onSelect:Pe(r.onSelect,()=>{var o;return(o=i.onValueChange)==null?void 0:o.call(i,n)},{checkForDefaultPrevented:!1})})})});vI.displayName=gI;var cy="MenuItemIndicator",[_I,O7]=Lo(cy,{checked:!1}),xI=g.forwardRef((e,t)=>{const{__scopeMenu:n,forceMount:r,...i}=e,s=O7(cy,n);return h.jsx($i,{present:r||nf(s.checked)||s.checked===!0,children:h.jsx(Et.span,{...i,ref:t,"data-state":dy(s.checked)})})});xI.displayName=cy;var B7="MenuSeparator",yI=g.forwardRef((e,t)=>{const{__scopeMenu:n,...r}=e;return h.jsx(Et.div,{role:"separator","aria-orientation":"horizontal",...r,ref:t})});yI.displayName=B7;var z7="MenuArrow",bI=g.forwardRef((e,t)=>{const{__scopeMenu:n,...r}=e,i=wu(n);return h.jsx(FP,{...i,...r,ref:t})});bI.displayName=z7;var uy="MenuSub",[$7,wI]=Lo(uy),SI=e=>{const{__scopeMenu:t,children:n,open:r=!1,onOpenChange:i}=e,s=Ds(uy,t),o=wu(t),[a,l]=g.useState(null),[c,u]=g.useState(null),d=oi(i);return g.useEffect(()=>(s.open===!1&&d(!1),()=>d(!1)),[s.open,d]),h.jsx(ty,{...o,children:h.jsx(oI,{scope:t,open:r,onOpenChange:d,content:c,onContentChange:u,children:h.jsx($7,{scope:t,contentId:Ni(),triggerId:Ni(),trigger:a,onTriggerChange:l,children:n})})})};SI.displayName=uy;var Gl="MenuSubTrigger",kI=g.forwardRef((e,t)=>{const n=Ds(Gl,e.__scopeMenu),r=Su(Gl,e.__scopeMenu),i=wI(Gl,e.__scopeMenu),s=oy(Gl,e.__scopeMenu),o=g.useRef(null),{pointerGraceTimerRef:a,onPointerGraceIntentChange:l}=s,c={__scopeMenu:e.__scopeMenu},u=g.useCallback(()=>{o.current&&window.clearTimeout(o.current),o.current=null},[]);return g.useEffect(()=>u,[u]),g.useEffect(()=>{const d=a.current;return()=>{window.clearTimeout(d),l(null)}},[a,l]),h.jsx(iy,{asChild:!0,...c,children:h.jsx(hI,{id:i.triggerId,"aria-haspopup":"menu","aria-expanded":n.open,"aria-controls":i.contentId,"data-state":TI(n.open),...e,ref:vu(t,i.onTriggerChange),onClick:d=>{var f;(f=e.onClick)==null||f.call(e,d),!(e.disabled||d.defaultPrevented)&&(d.currentTarget.focus(),n.open||n.onOpenChange(!0))},onPointerMove:Pe(e.onPointerMove,Qc(d=>{s.onItemEnter(d),!d.defaultPrevented&&!e.disabled&&!n.open&&!o.current&&(s.onPointerGraceIntentChange(null),o.current=window.setTimeout(()=>{n.onOpenChange(!0),u()},100))})),onPointerLeave:Pe(e.onPointerLeave,Qc(d=>{var p,m;u();const f=(p=n.content)==null?void 0:p.getBoundingClientRect();if(f){const v=(m=n.content)==null?void 0:m.dataset.side,b=v==="right",_=b?-5:5,x=f[b?"left":"right"],y=f[b?"right":"left"];s.onPointerGraceIntentChange({area:[{x:d.clientX+_,y:d.clientY},{x,y:f.top},{x:y,y:f.top},{x:y,y:f.bottom},{x,y:f.bottom}],side:v}),window.clearTimeout(a.current),a.current=window.setTimeout(()=>s.onPointerGraceIntentChange(null),300)}else{if(s.onTriggerLeave(d),d.defaultPrevented)return;s.onPointerGraceIntentChange(null)}})),onKeyDown:Pe(e.onKeyDown,d=>{var p;const f=s.searchRef.current!=="";e.disabled||f&&d.key===" "||b7[r.dir].includes(d.key)&&(n.onOpenChange(!0),(p=n.content)==null||p.focus(),d.preventDefault())})})})});kI.displayName=Gl;var CI="MenuSubContent",EI=g.forwardRef((e,t)=>{const n=lI(gr,e.__scopeMenu),{forceMount:r=n.forceMount,...i}=e,s=Ds(gr,e.__scopeMenu),o=Su(gr,e.__scopeMenu),a=wI(CI,e.__scopeMenu),l=g.useRef(null),c=qt(t,l);return h.jsx(Xc.Provider,{scope:e.__scopeMenu,children:h.jsx($i,{present:r||s.open,children:h.jsx(Xc.Slot,{scope:e.__scopeMenu,children:h.jsx(ay,{id:a.contentId,"aria-labelledby":a.triggerId,...i,ref:c,align:"start",side:o.dir==="rtl"?"left":"right",disableOutsidePointerEvents:!1,disableOutsideScroll:!1,trapFocus:!1,onOpenAutoFocus:u=>{var d;o.isUsingKeyboardRef.current&&((d=l.current)==null||d.focus()),u.preventDefault()},onCloseAutoFocus:u=>u.preventDefault(),onFocusOutside:Pe(e.onFocusOutside,u=>{u.target!==a.trigger&&s.onOpenChange(!1)}),onEscapeKeyDown:Pe(e.onEscapeKeyDown,u=>{o.onClose(),u.preventDefault()}),onKeyDown:Pe(e.onKeyDown,u=>{var p;const d=u.currentTarget.contains(u.target),f=w7[o.dir].includes(u.key);d&&f&&(s.onOpenChange(!1),(p=a.trigger)==null||p.focus(),u.preventDefault())})})})})})});EI.displayName=CI;function TI(e){return e?"open":"closed"}function nf(e){return e==="indeterminate"}function dy(e){return nf(e)?"indeterminate":e?"checked":"unchecked"}function F7(e){const t=document.activeElement;for(const n of e)if(n===t||(n.focus(),document.activeElement!==t))return}function H7(e,t){return e.map((n,r)=>e[(t+r)%e.length])}function U7(e,t,n){const i=t.length>1&&Array.from(t).every(c=>c===t[0])?t[0]:t,s=n?e.indexOf(n):-1;let o=H7(e,Math.max(s,0));i.length===1&&(o=o.filter(c=>c!==n));const l=o.find(c=>c.toLowerCase().startsWith(i.toLowerCase()));return l!==n?l:void 0}function W7(e,t){const{x:n,y:r}=e;let i=!1;for(let s=0,o=t.length-1;s<t.length;o=s++){const a=t[s],l=t[o],c=a.x,u=a.y,d=l.x,f=l.y;u>r!=f>r&&n<(d-c)*(r-u)/(f-u)+c&&(i=!i)}return i}function V7(e,t){if(!t)return!1;const n={x:e.clientX,y:e.clientY};return W7(n,t)}function Qc(e){return t=>t.pointerType==="mouse"?e(t):void 0}var q7=aI,K7=iy,G7=cI,Y7=uI,X7=ly,Q7=dI,Z7=pp,J7=fI,eH=mI,tH=vI,nH=xI,rH=yI,iH=bI,sH=SI,oH=kI,aH=EI,mp="DropdownMenu",[lH]=Ao(mp,[iI]),wn=iI(),[cH,NI]=lH(mp),PI=e=>{const{__scopeDropdownMenu:t,children:n,dir:r,open:i,defaultOpen:s,onOpenChange:o,modal:a=!0}=e,l=wn(t),c=g.useRef(null),[u,d]=_u({prop:i,defaultProp:s??!1,onChange:o,caller:mp});return h.jsx(cH,{scope:t,triggerId:Ni(),triggerRef:c,contentId:Ni(),open:u,onOpenChange:d,onOpenToggle:g.useCallback(()=>d(f=>!f),[d]),modal:a,children:h.jsx(q7,{...l,open:u,onOpenChange:d,dir:r,modal:a,children:n})})};PI.displayName=mp;var II="DropdownMenuTrigger",RI=g.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,disabled:r=!1,...i}=e,s=NI(II,n),o=wn(n);return h.jsx(K7,{asChild:!0,...o,children:h.jsx(Et.button,{type:"button",id:s.triggerId,"aria-haspopup":"menu","aria-expanded":s.open,"aria-controls":s.open?s.contentId:void 0,"data-state":s.open?"open":"closed","data-disabled":r?"":void 0,disabled:r,...i,ref:vu(t,s.triggerRef),onPointerDown:Pe(e.onPointerDown,a=>{!r&&a.button===0&&a.ctrlKey===!1&&(s.onOpenToggle(),s.open||a.preventDefault())}),onKeyDown:Pe(e.onKeyDown,a=>{r||(["Enter"," "].includes(a.key)&&s.onOpenToggle(),a.key==="ArrowDown"&&s.onOpenChange(!0),["Enter"," ","ArrowDown"].includes(a.key)&&a.preventDefault())})})})});RI.displayName=II;var uH="DropdownMenuPortal",MI=e=>{const{__scopeDropdownMenu:t,...n}=e,r=wn(t);return h.jsx(G7,{...r,...n})};MI.displayName=uH;var AI="DropdownMenuContent",LI=g.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,i=NI(AI,n),s=wn(n),o=g.useRef(!1);return h.jsx(Y7,{id:i.contentId,"aria-labelledby":i.triggerId,...s,...r,ref:t,onCloseAutoFocus:Pe(e.onCloseAutoFocus,a=>{var l;o.current||(l=i.triggerRef.current)==null||l.focus(),o.current=!1,a.preventDefault()}),onInteractOutside:Pe(e.onInteractOutside,a=>{const l=a.detail.originalEvent,c=l.button===0&&l.ctrlKey===!0,u=l.button===2||c;(!i.modal||u)&&(o.current=!0)}),style:{...e.style,"--radix-dropdown-menu-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-dropdown-menu-content-available-width":"var(--radix-popper-available-width)","--radix-dropdown-menu-content-available-height":"var(--radix-popper-available-height)","--radix-dropdown-menu-trigger-width":"var(--radix-popper-anchor-width)","--radix-dropdown-menu-trigger-height":"var(--radix-popper-anchor-height)"}})});LI.displayName=AI;var dH="DropdownMenuGroup",hH=g.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,i=wn(n);return h.jsx(X7,{...i,...r,ref:t})});hH.displayName=dH;var fH="DropdownMenuLabel",jI=g.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,i=wn(n);return h.jsx(Q7,{...i,...r,ref:t})});jI.displayName=fH;var pH="DropdownMenuItem",DI=g.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,i=wn(n);return h.jsx(Z7,{...i,...r,ref:t})});DI.displayName=pH;var mH="DropdownMenuCheckboxItem",OI=g.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,i=wn(n);return h.jsx(J7,{...i,...r,ref:t})});OI.displayName=mH;var gH="DropdownMenuRadioGroup",vH=g.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,i=wn(n);return h.jsx(eH,{...i,...r,ref:t})});vH.displayName=gH;var _H="DropdownMenuRadioItem",xH=g.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,i=wn(n);return h.jsx(tH,{...i,...r,ref:t})});xH.displayName=_H;var yH="DropdownMenuItemIndicator",BI=g.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,i=wn(n);return h.jsx(nH,{...i,...r,ref:t})});BI.displayName=yH;var bH="DropdownMenuSeparator",zI=g.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,i=wn(n);return h.jsx(rH,{...i,...r,ref:t})});zI.displayName=bH;var wH="DropdownMenuArrow",SH=g.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,i=wn(n);return h.jsx(iH,{...i,...r,ref:t})});SH.displayName=wH;var kH=e=>{const{__scopeDropdownMenu:t,children:n,open:r,onOpenChange:i,defaultOpen:s}=e,o=wn(t),[a,l]=_u({prop:r,defaultProp:s??!1,onChange:i,caller:"DropdownMenuSub"});return h.jsx(sH,{...o,open:a,onOpenChange:l,children:n})},CH="DropdownMenuSubTrigger",$I=g.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,i=wn(n);return h.jsx(oH,{...i,...r,ref:t})});$I.displayName=CH;var EH="DropdownMenuSubContent",FI=g.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,i=wn(n);return h.jsx(aH,{...i,...r,ref:t,style:{...e.style,"--radix-dropdown-menu-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-dropdown-menu-content-available-width":"var(--radix-popper-available-width)","--radix-dropdown-menu-content-available-height":"var(--radix-popper-available-height)","--radix-dropdown-menu-trigger-width":"var(--radix-popper-anchor-width)","--radix-dropdown-menu-trigger-height":"var(--radix-popper-anchor-height)"}})});FI.displayName=EH;var TH=PI,NH=RI,HI=MI,UI=LI,WI=jI,VI=DI,qI=OI,PH=BI,KI=zI,IH=kH,GI=$I,YI=FI;const hy=TH,fy=NH,gp=g.forwardRef(({className:e,sideOffset:t=4,...n},r)=>h.jsx(HI,{children:h.jsx(UI,{ref:r,sideOffset:t,className:fe("z-50 min-w-[8rem] overflow-hidden rounded-md border border-border bg-elevated p-1","text-text-100 shadow-md",e),...n})}));gp.displayName=UI.displayName;const RH=IH,XI=g.forwardRef(({className:e,...t},n)=>h.jsx(GI,{ref:n,className:fe("relative flex cursor-default select-none items-center rounded-sm px-2 py-1.5 text-sm outline-none","focus:bg-bg-200 focus:text-text-100 data-[highlighted]:bg-bg-200 data-[highlighted]:text-text-100 data-[state=open]:bg-bg-200","data-[disabled]:pointer-events-none data-[disabled]:opacity-50",e),...t}));XI.displayName=GI.displayName;const QI=g.forwardRef(({className:e,...t},n)=>h.jsx(HI,{children:h.jsx(YI,{ref:n,className:fe("z-50 min-w-[6rem] overflow-hidden rounded-md border border-border bg-elevated p-1","text-text-100 shadow-md",e),...t})}));QI.displayName=YI.displayName;const yi=g.forwardRef(({className:e,inset:t,...n},r)=>h.jsx(VI,{ref:r,className:fe("relative flex cursor-default select-none items-center rounded-sm px-2 py-1.5 text-sm outline-none","focus:bg-bg-200 focus:text-text-100 data-[highlighted]:bg-bg-200 data-[highlighted]:text-text-100","data-[disabled]:pointer-events-none data-[disabled]:opacity-50",t&&"pl-8",e),...n}));yi.displayName=VI.displayName;const MH=g.forwardRef(({className:e,children:t,checked:n,...r},i)=>h.jsxs(qI,{ref:i,checked:n,className:fe("relative flex cursor-default select-none items-center rounded-sm py-1.5 pl-7 pr-2 text-sm outline-none","focus:bg-bg-200 focus:text-text-100 data-[highlighted]:bg-bg-200 data-[highlighted]:text-text-100","data-[disabled]:pointer-events-none data-[disabled]:opacity-50",e),...r,children:[h.jsx("span",{className:"absolute left-2 flex h-3.5 w-3.5 items-center justify-center",children:h.jsx(PH,{children:h.jsx(ul,{className:"h-3.5 w-3.5"})})}),t]}));MH.displayName=qI.displayName;const ZI=g.forwardRef(({className:e,...t},n)=>h.jsx(KI,{ref:n,className:fe("-mx-1 my-1 h-px bg-border",e),...t}));ZI.displayName=KI.displayName;const AH=g.forwardRef(({className:e,...t},n)=>h.jsx(WI,{ref:n,className:fe("px-2 py-1.5 text-xs font-semibold text-text-400",e),...t}));AH.displayName=WI.displayName;function LH({tool:e,className:t}){const n=E8(e);return h.jsx("span",{"data-testid":n?`session-icon-${e}`:"session-icon-default","aria-label":n?Wx(e):"未知引擎",className:fe("w-3.5 h-3.5 shrink-0 inline-flex items-center justify-center",op(e),t),children:h.jsx(sp,{tool:e,className:"w-full h-full"})})}function JI(e){return e.compositionActive||!!e.nativeIsComposing||e.keyCode===229}function eR(e){return e.key==="Enter"&&!e.shiftKey&&!JI(e)}function ku(e,t){const n=g.useRef(!1),r=g.useCallback(()=>{n.current=!0},[]),i=g.useCallback(()=>{setTimeout(()=>{n.current=!1},0)},[]);return{onKeyDown:g.useCallback(o=>{const a=o.nativeEvent;if(eR({key:o.key,shiftKey:o.shiftKey,compositionActive:n.current,nativeIsComposing:a.isComposing,keyCode:a.keyCode})){o.preventDefault(),e();return}t&&o.key==="Escape"&&(o.preventDefault(),t())},[e,t]),onCompositionStart:r,onCompositionEnd:i}}function jH({open:e,initialLabel:t,placeholder:n,onSubmit:r,onCancel:i}){const[s,o]=g.useState(t);g.useEffect(()=>{e&&o(t)},[e,t]);const a=ku(()=>r({label:s.trim()}),i);return e?el.createPortal(h.jsx("div",{className:"fixed inset-0 z-[10000] flex items-center justify-center bg-bg-0/40 backdrop-blur-[2px]",onClick:i,"data-testid":"session-edit-dialog-overlay",children:h.jsxs("div",{"data-testid":"session-edit-dialog",className:"w-[420px] max-w-[calc(100vw-32px)] rounded-2xl border border-text-100/[0.12] flex flex-col gap-4 p-5",style:{backgroundColor:"var(--bg-0)",boxShadow:"0 12px 40px rgba(0,0,0,0.04)"},onClick:l=>l.stopPropagation(),children:[h.jsx("div",{className:"text-[15px] font-semibold text-text-100",children:"Edit session"}),h.jsxs("div",{children:[h.jsx("label",{className:"block text-[12px] font-semibold text-text-200 mb-1",children:"Label"}),h.jsx("input",{autoFocus:!0,type:"text",value:s,onChange:l=>o(l.target.value),...a,placeholder:n,"data-testid":"session-edit-dialog-label",className:"w-full px-3 py-2 text-[13px] bg-bg-50 border border-bg-300 rounded-lg focus:outline-none focus:border-text-300 transition-colors"})]}),h.jsxs("div",{className:"flex justify-end gap-2 pt-1",children:[h.jsx("button",{type:"button",onClick:i,className:"px-4 py-1.5 text-[12px] text-text-300 rounded-lg hover:bg-text-100/5 transition-colors cursor-pointer",children:"Cancel"}),h.jsx("button",{type:"button",onClick:()=>r({label:s.trim()}),"data-testid":"session-edit-dialog-save",className:"px-4 py-1.5 text-[12px] font-medium text-bg-0 rounded-lg bg-text-100 hover:bg-text-200 transition-colors cursor-pointer",children:"Save"})]})]})}),document.body):null}var DH=Object.freeze({position:"absolute",border:0,width:1,height:1,padding:0,margin:-1,overflow:"hidden",clip:"rect(0, 0, 0, 0)",whiteSpace:"nowrap",wordWrap:"normal"}),OH="VisuallyHidden",tR=g.forwardRef((e,t)=>h.jsx(Et.span,{...e,ref:t,style:{...DH,...e.style}}));tR.displayName=OH;var BH=tR,[vp]=Ao("Tooltip",[hp]),_p=hp(),nR="TooltipProvider",zH=700,y0="tooltip.open",[$H,py]=vp(nR),rR=e=>{const{__scopeTooltip:t,delayDuration:n=zH,skipDelayDuration:r=300,disableHoverableContent:i=!1,children:s}=e,o=g.useRef(!0),a=g.useRef(!1),l=g.useRef(0);return g.useEffect(()=>{const c=l.current;return()=>window.clearTimeout(c)},[]),h.jsx($H,{scope:t,isOpenDelayedRef:o,delayDuration:n,onOpen:g.useCallback(()=>{window.clearTimeout(l.current),o.current=!1},[]),onClose:g.useCallback(()=>{window.clearTimeout(l.current),l.current=window.setTimeout(()=>o.current=!0,r)},[r]),isPointerInTransitRef:a,onPointerInTransitChange:g.useCallback(c=>{a.current=c},[]),disableHoverableContent:i,children:s})};rR.displayName=nR;var Zc="Tooltip",[FH,xp]=vp(Zc),iR=e=>{const{__scopeTooltip:t,children:n,open:r,defaultOpen:i,onOpenChange:s,disableHoverableContent:o,delayDuration:a}=e,l=py(Zc,e.__scopeTooltip),c=_p(t),[u,d]=g.useState(null),f=Ni(),p=g.useRef(0),m=o??l.disableHoverableContent,v=a??l.delayDuration,b=g.useRef(!1),[_,x]=_u({prop:r,defaultProp:i??!1,onChange:T=>{T?(l.onOpen(),document.dispatchEvent(new CustomEvent(y0))):l.onClose(),s==null||s(T)},caller:Zc}),y=g.useMemo(()=>_?b.current?"delayed-open":"instant-open":"closed",[_]),w=g.useCallback(()=>{window.clearTimeout(p.current),p.current=0,b.current=!1,x(!0)},[x]),C=g.useCallback(()=>{window.clearTimeout(p.current),p.current=0,x(!1)},[x]),k=g.useCallback(()=>{window.clearTimeout(p.current),p.current=window.setTimeout(()=>{b.current=!0,x(!0),p.current=0},v)},[v,x]);return g.useEffect(()=>()=>{p.current&&(window.clearTimeout(p.current),p.current=0)},[]),h.jsx(ty,{...c,children:h.jsx(FH,{scope:t,contentId:f,open:_,stateAttribute:y,trigger:u,onTriggerChange:d,onTriggerEnter:g.useCallback(()=>{l.isOpenDelayedRef.current?k():w()},[l.isOpenDelayedRef,k,w]),onTriggerLeave:g.useCallback(()=>{m?C():(window.clearTimeout(p.current),p.current=0)},[C,m]),onOpen:w,onClose:C,disableHoverableContent:m,children:n})})};iR.displayName=Zc;var b0="TooltipTrigger",sR=g.forwardRef((e,t)=>{const{__scopeTooltip:n,...r}=e,i=xp(b0,n),s=py(b0,n),o=_p(n),a=g.useRef(null),l=qt(t,a,i.onTriggerChange),c=g.useRef(!1),u=g.useRef(!1),d=g.useCallback(()=>c.current=!1,[]);return g.useEffect(()=>()=>document.removeEventListener("pointerup",d),[d]),h.jsx(zP,{asChild:!0,...o,children:h.jsx(Et.button,{"aria-describedby":i.open?i.contentId:void 0,"data-state":i.stateAttribute,...r,ref:l,onPointerMove:Pe(e.onPointerMove,f=>{f.pointerType!=="touch"&&!u.current&&!s.isPointerInTransitRef.current&&(i.onTriggerEnter(),u.current=!0)}),onPointerLeave:Pe(e.onPointerLeave,()=>{i.onTriggerLeave(),u.current=!1}),onPointerDown:Pe(e.onPointerDown,()=>{i.open&&i.onClose(),c.current=!0,document.addEventListener("pointerup",d,{once:!0})}),onFocus:Pe(e.onFocus,()=>{c.current||i.onOpen()}),onBlur:Pe(e.onBlur,i.onClose),onClick:Pe(e.onClick,i.onClose)})})});sR.displayName=b0;var HH="TooltipPortal",[Wse,UH]=vp(HH,{forceMount:void 0}),Ha="TooltipContent",oR=g.forwardRef((e,t)=>{const n=UH(Ha,e.__scopeTooltip),{forceMount:r=n.forceMount,side:i="top",...s}=e,o=xp(Ha,e.__scopeTooltip);return h.jsx($i,{present:r||o.open,children:o.disableHoverableContent?h.jsx(aR,{side:i,...s,ref:t}):h.jsx(WH,{side:i,...s,ref:t})})}),WH=g.forwardRef((e,t)=>{const n=xp(Ha,e.__scopeTooltip),r=py(Ha,e.__scopeTooltip),i=g.useRef(null),s=qt(t,i),[o,a]=g.useState(null),{trigger:l,onClose:c}=n,u=i.current,{onPointerInTransitChange:d}=r,f=g.useCallback(()=>{a(null),d(!1)},[d]),p=g.useCallback((m,v)=>{const b=m.currentTarget,_={x:m.clientX,y:m.clientY},x=YH(_,b.getBoundingClientRect()),y=XH(_,x),w=QH(v.getBoundingClientRect()),C=JH([...y,...w]);a(C),d(!0)},[d]);return g.useEffect(()=>()=>f(),[f]),g.useEffect(()=>{if(l&&u){const m=b=>p(b,u),v=b=>p(b,l);return l.addEventListener("pointerleave",m),u.addEventListener("pointerleave",v),()=>{l.removeEventListener("pointerleave",m),u.removeEventListener("pointerleave",v)}}},[l,u,p,f]),g.useEffect(()=>{if(o){const m=v=>{const b=v.target,_={x:v.clientX,y:v.clientY},x=(l==null?void 0:l.contains(b))||(u==null?void 0:u.contains(b)),y=!ZH(_,o);x?f():y&&(f(),c())};return document.addEventListener("pointermove",m),()=>document.removeEventListener("pointermove",m)}},[l,u,o,c,f]),h.jsx(aR,{...e,ref:s})}),[VH,qH]=vp(Zc,{isInside:!1}),KH=D8("TooltipContent"),aR=g.forwardRef((e,t)=>{const{__scopeTooltip:n,children:r,"aria-label":i,onEscapeKeyDown:s,onPointerDownOutside:o,...a}=e,l=xp(Ha,n),c=_p(n),{onClose:u}=l;return g.useEffect(()=>(document.addEventListener(y0,u),()=>document.removeEventListener(y0,u)),[u]),g.useEffect(()=>{if(l.trigger){const d=f=>{const p=f.target;p!=null&&p.contains(l.trigger)&&u()};return window.addEventListener("scroll",d,{capture:!0}),()=>window.removeEventListener("scroll",d,{capture:!0})}},[l.trigger,u]),h.jsx(ap,{asChild:!0,disableOutsidePointerEvents:!1,onEscapeKeyDown:s,onPointerDownOutside:o,onFocusOutside:d=>d.preventDefault(),onDismiss:u,children:h.jsxs($P,{"data-state":l.stateAttribute,...c,...a,ref:t,style:{...a.style,"--radix-tooltip-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-tooltip-content-available-width":"var(--radix-popper-available-width)","--radix-tooltip-content-available-height":"var(--radix-popper-available-height)","--radix-tooltip-trigger-width":"var(--radix-popper-anchor-width)","--radix-tooltip-trigger-height":"var(--radix-popper-anchor-height)"},children:[h.jsx(KH,{children:r}),h.jsx(VH,{scope:n,isInside:!0,children:h.jsx(BH,{id:l.contentId,role:"tooltip",children:i||r})})]})})});oR.displayName=Ha;var lR="TooltipArrow",GH=g.forwardRef((e,t)=>{const{__scopeTooltip:n,...r}=e,i=_p(n);return qH(lR,n).isInside?null:h.jsx(FP,{...i,...r,ref:t})});GH.displayName=lR;function YH(e,t){const n=Math.abs(t.top-e.y),r=Math.abs(t.bottom-e.y),i=Math.abs(t.right-e.x),s=Math.abs(t.left-e.x);switch(Math.min(n,r,i,s)){case s:return"left";case i:return"right";case n:return"top";case r:return"bottom";default:throw new Error("unreachable")}}function XH(e,t,n=5){const r=[];switch(t){case"top":r.push({x:e.x-n,y:e.y+n},{x:e.x+n,y:e.y+n});break;case"bottom":r.push({x:e.x-n,y:e.y-n},{x:e.x+n,y:e.y-n});break;case"left":r.push({x:e.x+n,y:e.y-n},{x:e.x+n,y:e.y+n});break;case"right":r.push({x:e.x-n,y:e.y-n},{x:e.x-n,y:e.y+n});break}return r}function QH(e){const{top:t,right:n,bottom:r,left:i}=e;return[{x:i,y:t},{x:n,y:t},{x:n,y:r},{x:i,y:r}]}function ZH(e,t){const{x:n,y:r}=e;let i=!1;for(let s=0,o=t.length-1;s<t.length;o=s++){const a=t[s],l=t[o],c=a.x,u=a.y,d=l.x,f=l.y;u>r!=f>r&&n<(d-c)*(r-u)/(f-u)+c&&(i=!i)}return i}function JH(e){const t=e.slice();return t.sort((n,r)=>n.x<r.x?-1:n.x>r.x?1:n.y<r.y?-1:n.y>r.y?1:0),eU(t)}function eU(e){if(e.length<=1)return e.slice();const t=[];for(let r=0;r<e.length;r++){const i=e[r];for(;t.length>=2;){const s=t[t.length-1],o=t[t.length-2];if((s.x-o.x)*(i.y-o.y)>=(s.y-o.y)*(i.x-o.x))t.pop();else break}t.push(i)}t.pop();const n=[];for(let r=e.length-1;r>=0;r--){const i=e[r];for(;n.length>=2;){const s=n[n.length-1],o=n[n.length-2];if((s.x-o.x)*(i.y-o.y)>=(s.y-o.y)*(i.x-o.x))n.pop();else break}n.push(i)}return n.pop(),t.length===1&&n.length===1&&t[0].x===n[0].x&&t[0].y===n[0].y?t:t.concat(n)}var tU=rR,nU=iR,rU=sR,cR=oR;const rf=tU,yp=nU,bp=rU,Cu=g.forwardRef(({className:e,sideOffset:t=4,...n},r)=>h.jsx(cR,{ref:r,sideOffset:t,className:fe("z-50 overflow-hidden rounded-sm border border-border bg-bg-0 px-2 py-1 text-xs text-text-300 shadow-md",e),...n}));Cu.displayName=cR.displayName;const iU={held:!1,indexBySessionId:new Map},sU=g.createContext(iU);function oU(){return g.useContext(sU)}const aU=Array.from({length:9},(e,t)=>({id:`switch-session-${t+1}`,combo:{key:String(t+1),mod:!0},label:`切换到第 ${t+1} 个会话`,group:"会话",desktopOnly:!0,hiddenInList:!0})),lU=[{id:"new-session",combo:{key:"n",mod:!0},label:"新建任务",description:"打开快捷新建弹窗",group:"通用",desktopOnly:!0},...aU,{id:"archive-session",combo:{key:"Backspace",mod:!0,shift:!0},label:"归档当前会话",description:"归档当前聊天区的会话,Enter 确认 / Esc 取消",group:"会话",desktopOnly:!0},{id:"tab-prev",combo:{key:"ArrowLeft",mod:!0,shift:!0},label:"上一个标签页",description:"连按快速移动,停下或松开修饰键后切换",group:"标签页"},{id:"tab-next",combo:{key:"ArrowRight",mod:!0,shift:!0},label:"下一个标签页",description:"连按快速移动,停下或松开修饰键后切换",group:"标签页"},{id:"send-message",combo:{key:"Enter"},label:"发送消息",description:"在输入框中发送当前内容",group:"输入",displayOnly:!0},{id:"newline",combo:{key:"Enter",shift:!0},label:"换行",description:"在输入框中插入换行",group:"输入",displayOnly:!0},{id:"interrupt",combo:{key:"Escape"},label:"打断回复",description:"打断当前回复;2 秒内按两次停止任务",group:"输入",displayOnly:!0}];lU.filter(e=>!e.displayOnly);function cU(){return/Mac|iP(hone|od|ad)/.test(navigator.platform)}const uU=10,dU=20,hU=16,fU=20,pU=60,mU=4;function xd({testId:e,label:t,children:n}){return h.jsxs(yp,{children:[h.jsx(bp,{asChild:!0,children:h.jsx("span",{"data-testid":e,role:"img","aria-label":t,tabIndex:0,className:"inline-flex shrink-0",children:n})}),h.jsx(Cu,{side:"bottom",children:t})]})}function gU({session:e,active:t,hasUnread:n,running:r=!1,awaitingUser:i=!1,onSelect:s,onEdit:o,onDelete:a,onPin:l,onArchive:c,archiveShortcut:u=!1,depth:d=0,chevron:f,showCopyResume:p=!0,contactDisplayName:m,ownerPrincipalId:v,creatorDisplayName:b,dispatchedFromSessionTitle:_}){const[x,y]=g.useState(!1),w=oU(),C=w.held?w.indexBySessionId.get(e.sessionId):void 0,k=!!e.pinnedAt,T=d===0,N=d===0&&!!c,z=uU+d*dU,P=g.useCallback(async()=>{const L=cP(e);if(L)try{await navigator.clipboard.writeText(L)}catch{}},[e]),B=Vx(e),R=e.originOwnerPrincipalId,I=R?`@${m??`…${R.slice(-8)}`}`:null,j=!!(e.ownerPersonaId&&v&&e.creatorPrincipalId&&e.creatorPrincipalId!==v&&!e.larkChatId&&!e.shiftFiredFromSessionId&&!e.dispatchedFromSessionId);return h.jsxs(h.Fragment,{children:[h.jsxs("div",{"data-testid":`session-item-${e.sessionId}`,onClick:s,style:{paddingLeft:z,display:"grid",gridTemplateColumns:`${hU}px ${fU}px 1fr auto ${pU}px`,gridTemplateAreas:'"chev icon name dot time"',columnGap:`${mU}px`,alignItems:"center"},className:fe("group relative rounded-lg cursor-pointer transition-all duration-150 pr-2.5 py-1.5",t?"bg-accent-dim":"hover:bg-sidebar-hover-bg"),children:[t?h.jsx("span",{"aria-hidden":"true",className:"absolute left-0 top-1/2 -translate-y-1/2 w-[3px] h-7 rounded-r-full bg-accent"}):null,h.jsx("div",{style:{gridArea:"chev"},className:"flex items-center justify-center",children:f??null}),h.jsx("div",{style:{gridArea:"icon"},className:"flex items-center justify-center",children:h.jsx(LH,{tool:e.tool})}),h.jsxs("div",{style:{gridArea:"name"},className:"flex items-center gap-1 min-w-0",children:[h.jsxs(rf,{delayDuration:200,skipDelayDuration:100,children:[e.dispatchedFromSessionId?h.jsx(xd,{testId:`dispatched-icon-${e.sessionId}`,label:`来自【${_??"另一会话"}】dispatch`,children:h.jsx(wz,{"aria-hidden":"true",className:"w-3 h-3 text-accent",strokeWidth:2.25})}):null,e.shiftFiredFromSessionId?h.jsx(xd,{testId:`shift-fired-icon-${e.sessionId}`,label:"定时任务",children:h.jsx(XB,{"aria-hidden":"true",className:"w-3 h-3 text-accent",strokeWidth:2.25})}):null,e.larkChatId?h.jsx(xd,{testId:`lark-chat-icon-${e.sessionId}`,label:e.larkChatType==="p2p"?"来自飞书DM":"来自飞书群",children:h.jsx(Gz,{"aria-hidden":"true",className:"w-3 h-3 text-accent",strokeWidth:2.25})}):null,j?h.jsx(xd,{testId:`guest-created-icon-${e.sessionId}`,label:b?`${b}创建`:"其他人创建",children:h.jsx(N$,{"aria-hidden":"true",className:"w-3 h-3 text-accent",strokeWidth:2.25})}):null]}),h.jsx("span",{"data-testid":`session-title-${e.sessionId}`,className:fe("text-[13px] truncate min-w-0","group-hover:whitespace-normal group-hover:overflow-visible group-hover:break-words",t?"text-text-100 font-medium":"text-text-200"),children:B}),I?h.jsx("span",{"data-testid":`session-mirror-chip-${e.sessionId}`,title:`在 ${I.replace(/^@/,"")} 的设备上`,className:"shrink-0 inline-flex items-center px-1.5 py-0 rounded text-[10px] bg-accent-dim/40 text-accent border border-accent/20 max-w-[120px] truncate",children:I}):null]}),i?h.jsx(rz,{"data-testid":`awaiting-dot-${e.sessionId}`,style:{gridArea:"dot"},className:"w-3 h-3 text-warning shrink-0 animate-pulse",strokeWidth:2.25,"aria-label":"awaiting user"}):n?h.jsx("span",{"data-testid":`unread-dot-${e.sessionId}`,style:{gridArea:"dot"},className:"w-2 h-2 rounded-full bg-error shrink-0","aria-label":"unread"}):r?h.jsx("span",{"data-testid":`running-dot-${e.sessionId}`,style:{gridArea:"dot"},className:"w-2 h-2 rounded-full bg-success shrink-0 animate-pulse","aria-label":"running"}):null,C!=null?h.jsx("span",{style:{gridArea:"time"},"data-testid":`session-quick-switch-badge-${e.sessionId}`,className:"text-right shrink-0 transition-opacity duration-150 group-hover:opacity-0",children:h.jsx("span",{className:"inline-flex items-center justify-center h-[18px] px-1.5 rounded-[5px] border border-border bg-bg-200/70 text-[11px] text-text-200 font-medium leading-none",children:cU()?`⌘${C}`:`Ctrl+${C}`})}):h.jsx("span",{style:{gridArea:"time"},className:fe("text-[11px] text-text-400/70 text-right shrink-0","transition-opacity duration-150 group-hover:opacity-0"),children:e.updatedAt?T8(e.updatedAt):""}),o||a||l||c?h.jsxs("div",{className:"absolute right-2 top-[3px] flex items-center opacity-0 group-hover:opacity-100 data-[state=open]:opacity-100 transition-opacity",children:[u&&N&&c?h.jsx(rf,{delayDuration:200,skipDelayDuration:100,children:h.jsxs(yp,{children:[h.jsx(bp,{asChild:!0,children:h.jsx("button",{type:"button",onClick:L=>{L.stopPropagation(),c(e.sessionId,!0)},className:"flex items-center justify-center w-7 h-7 rounded-md text-text-400 hover:text-text-100 hover:bg-text-100/5 transition-colors cursor-pointer","aria-label":"archive session","data-testid":`archive-shortcut-${e.sessionId}`,children:h.jsx(Pw,{className:"w-4 h-4"})})}),h.jsx(Cu,{side:"bottom",children:"归档"})]})}):null,h.jsxs(hy,{modal:!1,children:[h.jsx(fy,{asChild:!0,children:h.jsx("button",{type:"button",onClick:L=>L.stopPropagation(),className:"flex items-center justify-center w-7 h-7 rounded-md text-text-400 hover:text-text-100 hover:bg-text-100/5 transition-colors cursor-pointer","aria-label":"session actions","data-testid":`session-menu-${e.sessionId}`,children:h.jsx(zN,{className:"w-4 h-4"})})}),h.jsxs(gp,{align:"end",onClick:L=>L.stopPropagation(),children:[l&&T&&h.jsxs(yi,{onSelect:()=>l(e.sessionId,!k),"data-testid":`session-${k?"unpin":"pin"}-${e.sessionId}`,children:[k?h.jsx(r$,{className:"w-3 h-3 mr-2 text-text-400"}):h.jsx(s$,{className:"w-3 h-3 mr-2 text-text-400"}),k?"Unpin":"Pin"]}),N&&c&&h.jsxs(yi,{onSelect:()=>c(e.sessionId,!0),"data-testid":`session-archive-${e.sessionId}`,children:[h.jsx(Pw,{className:"w-3 h-3 mr-2 text-text-400"}),"Archive"]}),o&&h.jsxs(yi,{onSelect:()=>y(!0),"data-testid":`session-rename-${e.sessionId}`,children:[h.jsx(HN,{className:"w-3 h-3 mr-2 text-text-400"}),"Rename"]}),p&&e.toolSessionId?h.jsxs(yi,{onSelect:()=>void P(),"data-testid":`session-copy-resume-${e.sessionId}`,children:[h.jsx(ip,{className:"w-3 h-3 mr-2 text-text-400"}),"Copy Resume Command"]}):null,(l||o||p&&e.toolSessionId)&&a&&h.jsx(ZI,{}),a&&h.jsxs(yi,{onSelect:()=>void a(e.sessionId),className:"text-destructive focus:text-destructive focus:bg-destructive/10","data-testid":`session-delete-${e.sessionId}`,children:[h.jsx(Fx,{className:"w-3 h-3 mr-2"}),"Delete"]})]})]})]}):null]}),o?h.jsx(jH,{open:x,initialLabel:e.label??"",placeholder:e.cwd.split("/").pop()||"",onSubmit:L=>{o(e.sessionId,L),y(!1)},onCancel:()=>y(!1)}):null]})}function my({node:e,depth:t=0,activeId:n,unreadIds:r,runningIds:i,awaitingIds:s,onSelect:o,onEdit:a,onDelete:l,onPin:c,onArchive:u,archiveShortcut:d,getContactDisplayName:f,showCopyResume:p,ownerPrincipalId:m,getCreatorDisplayName:v,getSessionDisplayName:b,parentSession:_}){const x=e.children.length>0,{isCollapsed:y,toggle:w}=UB(),C=!y(e.session.sessionId),k=g.useCallback(N=>{N.stopPropagation(),w(e.session.sessionId)},[w,e.session.sessionId]),T=x?h.jsx("button",{type:"button",onClick:k,"data-testid":`session-chevron-${e.session.sessionId}`,"aria-label":C?"collapse":"expand","aria-expanded":C,className:"shrink-0 flex items-center justify-center w-4 h-4 text-text-400 hover:text-text-100 cursor-pointer",children:C?h.jsx(ir,{className:"w-3 h-3"}):h.jsx(Un,{className:"w-3 h-3"})}):null;return h.jsxs("div",{"data-testid":`session-tree-node-${e.session.sessionId}`,children:[h.jsx(gU,{session:e.session,active:n===e.session.sessionId,hasUnread:(r==null?void 0:r.has(e.session.sessionId))??!1,running:(i==null?void 0:i.has(e.session.sessionId))??!1,awaitingUser:(s==null?void 0:s.has(e.session.sessionId))??!1,onSelect:()=>o(e.session.sessionId),onEdit:a,onDelete:l,onPin:c,onArchive:u,archiveShortcut:d,showCopyResume:p,ownerPrincipalId:m,creatorDisplayName:e.session.creatorPrincipalId?v==null?void 0:v(e.session.creatorPrincipalId):void 0,dispatchedFromSessionTitle:e.session.dispatchedFromSessionId?(b==null?void 0:b(e.session.dispatchedFromSessionId))??((_==null?void 0:_.sessionId)===e.session.dispatchedFromSessionId?Vx(_):void 0):void 0,depth:t,chevron:T,contactDisplayName:e.session.originOwnerPrincipalId?f==null?void 0:f(e.session.originOwnerPrincipalId):void 0}),x&&C?h.jsx("div",{"data-testid":`session-tree-children-${e.session.sessionId}`,children:e.children.map(N=>h.jsx(my,{node:N,depth:t+1,activeId:n,unreadIds:r,runningIds:i,awaitingIds:s,onSelect:o,onEdit:a,onDelete:l,onPin:c,onArchive:u,archiveShortcut:d,getContactDisplayName:f,showCopyResume:p,ownerPrincipalId:m,getCreatorDisplayName:v,getSessionDisplayName:b,parentSession:e.session},N.session.sessionId))}):null]})}function vU(e){return e.forkedFromSessionId??e.dispatchedFromSessionId??e.shiftFiredFromSessionId}function uR(e){e=e.filter(s=>!s.ephemeral);const t=new Map;for(const s of e)t.set(s.sessionId,s);const n=new Map,r=[];for(const s of e){const o=vU(s);if(o&&t.has(o)){const a=n.get(o)??[];a.push(s),n.set(o,a)}else r.push(s)}const i=s=>{const a=[...n.get(s.sessionId)??[]].sort((l,c)=>l.createdAt<c.createdAt?-1:l.createdAt>c.createdAt?1:0);return{session:s,children:a.map(i)}};return[...r].sort(_U).map(i)}function dR(e){return[...e].sort((t,n)=>t.session.updatedAt<n.session.updatedAt?1:t.session.updatedAt>n.session.updatedAt?-1:0)}function _U(e,t){const n=typeof e.pinnedAt=="number",r=typeof t.pinnedAt=="number";if(n&&r){const i=typeof e.pinSortOrder=="number",s=typeof t.pinSortOrder=="number";return i&&s?e.pinSortOrder-t.pinSortOrder:i?-1:s?1:t.pinnedAt-e.pinnedAt}return n?-1:r||e.updatedAt<t.updatedAt?1:e.updatedAt>t.updatedAt?-1:0}function xU(e){return e.appBuilderProject?`[app] ${e.appBuilderProject}`:e.label?e.label:e.aiLabel?e.aiLabel:e.cwd.split("/").filter(Boolean).pop()??""}function cS(e,t){const n=t.trim().toLowerCase();return n===""?!0:e.toLowerCase().includes(n)}const yU={isCollapsed:()=>!1,toggle:()=>{},prune:()=>{}};function bU({personas:e,activePersonaId:t,onSelectPersona:n,onCreateSession:r,sessions:i,activeSessionId:s,awaitingIds:o,runningIds:a,unreadIds:l,onSelectSession:c,onDeleteSession:u,ownerPrincipalId:d,creatorDisplayNameByOwnerId:f,isPersonaExpanded:p,onTogglePersonaExpanded:m,onEditSession:v,onPinSession:b,showCopyResume:_,treatSessionsAsRoots:x,searchQuery:y}){const[w,C]=g.useState(null),[k,T]=g.useState(()=>new Set),N=p??(L=>k.has(L)),z=g.useCallback(L=>{if(m){m(L);return}T($=>{const F=new Set($);return F.has(L)?F.delete(L):F.add(L),F})},[m]),P=g.useMemo(()=>i==null?void 0:i.filter(L=>!L.ephemeral),[i]),B=g.useMemo(()=>new Map((P??[]).map(L=>[L.sessionId,Vx(L)])),[P]),R=g.useCallback(L=>f==null?void 0:f.get(L),[f]),I=g.useCallback(L=>B.get(L),[B]);if(e.length===0)return h.jsx(wU,{});const j=(y??"").trim();return j?h.jsx(Bx.Provider,{value:yU,children:h.jsx("div",{"data-testid":"my-personas-list",className:"flex flex-col gap-0.5",children:e.map(L=>{const $=P?P.filter(E=>E.ownerPersonaId===L.personaId).sort((E,H)=>H.updatedAt>E.updatedAt?1:-1):[],F=cS(L.label,j),D=$.filter(E=>cS(xU(E),j));if(!F&&D.length===0)return null;const O=F?$:D;return h.jsx(uS,{persona:L,active:L.personaId===t,editing:!1,onSelectPersona:n,onSubmitCreateSession:()=>{},onCancelCreateSession:()=>{},personaSessions:O,collapsed:!1,onToggleCollapsed:()=>{},activeSessionId:s??null,awaitingIds:o,runningIds:a,unreadIds:l,onSelectSession:c,onDeleteSession:u,onEditSession:v,onPinSession:b,showCopyResume:_,treatSessionsAsRoots:x,ownerPrincipalId:d,creatorDisplayNameByOwnerId:f,getCreatorDisplayName:R,getSessionDisplayName:I},L.personaId)})})}):h.jsx("div",{"data-testid":"my-personas-list",className:"flex flex-col gap-0.5",children:e.map(L=>{const $=P?P.filter(F=>F.ownerPersonaId===L.personaId).sort((F,D)=>D.updatedAt>F.updatedAt?1:-1):[];return h.jsx(uS,{persona:L,active:L.personaId===t,editing:L.personaId===w,onSelectPersona:n,onStartCreateSession:r?()=>C(L.personaId):void 0,onSubmitCreateSession:F=>{C(null),r==null||r(L.personaId,F)},onCancelCreateSession:()=>C(null),personaSessions:$,collapsed:!N(L.personaId),onToggleCollapsed:()=>z(L.personaId),activeSessionId:s??null,awaitingIds:o,runningIds:a,unreadIds:l,onSelectSession:c,onDeleteSession:u,onEditSession:v,onPinSession:b,showCopyResume:_,treatSessionsAsRoots:x,ownerPrincipalId:d,creatorDisplayNameByOwnerId:f,getCreatorDisplayName:R,getSessionDisplayName:I},L.personaId)})})}function wU(){return h.jsx("div",{className:"px-3 py-3 text-[11px] leading-relaxed text-text-400",children:"还没有 persona。点上方 Personas 标题右侧 + 创建第一个。"})}function uS({persona:e,active:t,editing:n,onSelectPersona:r,onStartCreateSession:i,onSubmitCreateSession:s,onCancelCreateSession:o,personaSessions:a,collapsed:l,onToggleCollapsed:c,activeSessionId:u,awaitingIds:d,runningIds:f,unreadIds:p,onSelectSession:m,onDeleteSession:v,onEditSession:b,onPinSession:_,showCopyResume:x,treatSessionsAsRoots:y,ownerPrincipalId:w,creatorDisplayNameByOwnerId:C,getCreatorDisplayName:k,getSessionDisplayName:T}){const N=a.length>0,z=!l,P=g.useMemo(()=>{const I=[],j=new Map;for(const L of a){const $=L.creatorPrincipalId;if(L.larkChatId!=null||!$||w&&$===w){I.push(L);continue}const F=$,D=(C==null?void 0:C.get(F))??`…${F.slice(-8)}`,O=j.get(F);O?O.sessions.push(L):j.set(F,{groupKey:F,displayName:D,sessions:[L]})}return{self:I,byPeer:[...j.values()]}},[a,w,C]),B=P.byPeer.length>0,R=g.useMemo(()=>z&&!B?dR(uR(a)):[],[z,B,a]);return h.jsxs("div",{"data-testid":`persona-node-${e.personaId}`,children:[h.jsxs("div",{className:fe("group flex items-center gap-1 px-2 py-1.5 cursor-pointer",t?"bg-accent-dim text-text-100":"hover:bg-bg-200 text-text-200"),onClick:()=>r==null?void 0:r(e.personaId),role:"button",tabIndex:0,children:[N?h.jsx("button",{type:"button",onClick:I=>{I.stopPropagation(),c()},"aria-label":z?"collapse":"expand","aria-expanded":z,"data-testid":`persona-chevron-${e.personaId}`,className:"flex h-4 w-4 shrink-0 items-center justify-center text-text-400 hover:text-text-100",children:z?h.jsx(ir,{className:"h-3 w-3"}):h.jsx(Un,{className:"h-3 w-3"})}):h.jsx("span",{className:"h-4 w-4 shrink-0","aria-hidden":"true"}),h.jsx(sp,{tool:e.tool,className:fe("h-3.5 w-3.5 shrink-0",op(e.tool))}),h.jsx("span",{className:"flex-1 truncate text-[13px]",children:e.label}),N?h.jsx("span",{className:"shrink-0 text-[10px] text-text-400 tabular-nums","aria-label":`${a.length} sessions`,children:a.length}):null,i?h.jsx("button",{type:"button",onClick:I=>{I.stopPropagation(),i()},"aria-label":"新建会话",title:"新建会话","data-testid":`persona-create-session-${e.personaId}`,className:"flex h-5 w-5 shrink-0 items-center justify-center rounded text-text-400 opacity-0 hover:bg-text-100/10 hover:text-text-100 focus-visible:opacity-100 group-hover:opacity-100",children:h.jsx(c$,{className:"h-3.5 w-3.5"})}):null]}),n?h.jsx(SU,{personaId:e.personaId,tool:e.tool,onSubmit:s,onCancel:o}):null,N&&z?h.jsx("div",{"data-testid":`persona-sessions-${e.personaId}`,children:B?h.jsxs(h.Fragment,{children:[P.self.length>0&&h.jsx(dS,{groupKey:`${e.personaId}-self`,label:"我自己",testId:`persona-sessions-${e.personaId}-self`,sessions:P.self,activeSessionId:u,awaitingIds:d,runningIds:f,unreadIds:p,onSelectSession:m,onDeleteSession:v,onEditSession:b,onPinSession:_,showCopyResume:x,ownerPrincipalId:w,getCreatorDisplayName:k,getSessionDisplayName:T}),P.byPeer.map(I=>h.jsx(dS,{groupKey:`${e.personaId}-peer-${I.groupKey}`,label:I.displayName,testId:`persona-sessions-${e.personaId}-peer-${I.groupKey}`,sessions:I.sessions,activeSessionId:u,awaitingIds:d,runningIds:f,unreadIds:p,onSelectSession:m,onDeleteSession:v,onEditSession:b,onPinSession:_,showCopyResume:x,ownerPrincipalId:w,getCreatorDisplayName:k,getSessionDisplayName:T},`${e.personaId}-peer-${I.groupKey}`))]}):R.map(I=>h.jsx(my,{node:I,depth:y?0:1,activeId:u,unreadIds:p,runningIds:f,awaitingIds:d,onSelect:j=>m==null?void 0:m(j),onDelete:v,onEdit:b,onPin:_,showCopyResume:x,ownerPrincipalId:w,getCreatorDisplayName:k,getSessionDisplayName:T},I.session.sessionId))}):null]})}function dS({label:e,testId:t,sessions:n,activeSessionId:r,awaitingIds:i,runningIds:s,unreadIds:o,onSelectSession:a,onDeleteSession:l,onEditSession:c,onPinSession:u,showCopyResume:d,ownerPrincipalId:f,getCreatorDisplayName:p,getSessionDisplayName:m}){const[v,b]=g.useState(!1),_=!v,x=g.useMemo(()=>_?dR(uR(n)):[],[_,n]);return h.jsxs("div",{"data-testid":t,children:[h.jsxs("button",{type:"button",onClick:()=>b(y=>!y),"aria-label":_?"collapse":"expand","aria-expanded":_,"data-testid":`${t}-chevron`,className:"flex items-center gap-1 w-full pl-7 pr-2 py-0.5 text-[11px] text-text-400 hover:text-text-200 transition-colors",children:[_?h.jsx(ir,{className:"h-3 w-3"}):h.jsx(Un,{className:"h-3 w-3"}),h.jsx(VN,{className:"h-3 w-3","aria-hidden":!0}),h.jsx("span",{className:"truncate",children:e}),h.jsx("span",{className:"ml-auto tabular-nums",children:n.length})]}),_&&h.jsx("div",{children:x.map(y=>h.jsx(my,{node:y,depth:2,activeId:r,unreadIds:o,runningIds:s,awaitingIds:i,onSelect:w=>a==null?void 0:a(w),onDelete:l,onEdit:c,onPin:u,showCopyResume:d,ownerPrincipalId:f,getCreatorDisplayName:p,getSessionDisplayName:m},y.session.sessionId))})]})}function SU({personaId:e,tool:t,onSubmit:n,onCancel:r}){const[i,s]=g.useState(""),o=g.useRef(null),a=i.trim(),l=a.length>0;g.useEffect(()=>{var d;(d=o.current)==null||d.focus()},[]);const c=g.useCallback(()=>{l&&n(a)},[l,a,n]),u=ku(c,r);return h.jsxs("div",{className:"flex items-center gap-1.5 pl-9 pr-2 py-1","data-testid":`persona-new-session-row-${e}`,children:[h.jsx(sp,{tool:t,className:fe("h-3 w-3 shrink-0",op(t))}),h.jsx("input",{ref:o,type:"text",value:i,onChange:d=>s(d.target.value),...u,onBlur:r,placeholder:"session label...","data-testid":`persona-new-session-input-${e}`,className:"flex-1 min-w-0 bg-bg-100 border border-text-100/15 rounded px-1.5 py-0.5 text-[12px] text-text-100 placeholder:text-text-400 focus:outline-none focus:border-text-100/40"}),h.jsx("button",{type:"button",onMouseDown:d=>{d.preventDefault(),c()},disabled:!l,"aria-label":"确认",title:"确认(Enter)","data-testid":`persona-new-session-confirm-${e}`,className:"flex h-4 w-4 shrink-0 items-center justify-center rounded text-text-300 hover:bg-text-100/10 hover:text-text-100 disabled:opacity-30 disabled:hover:bg-transparent disabled:hover:text-text-300",children:h.jsx(ul,{className:"h-3 w-3"})}),h.jsx("button",{type:"button",onMouseDown:d=>{d.preventDefault(),r()},"aria-label":"取消",title:"取消(Esc)","data-testid":`persona-new-session-cancel-${e}`,className:"flex h-4 w-4 shrink-0 items-center justify-center rounded text-text-300 hover:bg-text-100/10 hover:text-text-100",children:h.jsx(Dr,{className:"h-3 w-3"})})]})}function kU(e,t){const n=getComputedStyle(e),r=parseFloat(n.fontSize);return t*r}function CU(e,t){const n=getComputedStyle(e.ownerDocument.documentElement),r=parseFloat(n.fontSize);return t*r}function EU(e){return e/100*window.innerHeight}function TU(e){return e/100*window.innerWidth}function NU(e){switch(typeof e){case"number":return[e,"px"];case"string":{const t=parseFloat(e);return e.endsWith("%")?[t,"%"]:e.endsWith("px")?[t,"px"]:e.endsWith("rem")?[t,"rem"]:e.endsWith("em")?[t,"em"]:e.endsWith("vh")?[t,"vh"]:e.endsWith("vw")?[t,"vw"]:[t,"%"]}}}function Yl({groupSize:e,panelElement:t,styleProp:n}){let r;const[i,s]=NU(n);switch(s){case"%":{r=i/100*e;break}case"px":{r=i;break}case"rem":{r=CU(t,i);break}case"em":{r=kU(t,i);break}case"vh":{r=EU(i);break}case"vw":{r=TU(i);break}}return r}function Tn(e){return parseFloat(e.toFixed(3))}function Ua({group:e}){const{orientation:t,panels:n}=e;return n.reduce((r,i)=>(r+=t==="horizontal"?i.element.offsetWidth:i.element.offsetHeight,r),0)}function w0(e){const{panels:t}=e,n=Ua({group:e});return n===0?t.map(r=>({groupResizeBehavior:r.panelConstraints.groupResizeBehavior,collapsedSize:0,collapsible:r.panelConstraints.collapsible===!0,defaultSize:void 0,disabled:r.panelConstraints.disabled,minSize:0,maxSize:100,panelId:r.id})):t.map(r=>{const{element:i,panelConstraints:s}=r;let o=0;if(s.collapsedSize!==void 0){const u=Yl({groupSize:n,panelElement:i,styleProp:s.collapsedSize});o=Tn(u/n*100)}let a;if(s.defaultSize!==void 0){const u=Yl({groupSize:n,panelElement:i,styleProp:s.defaultSize});a=Tn(u/n*100)}let l=0;if(s.minSize!==void 0){const u=Yl({groupSize:n,panelElement:i,styleProp:s.minSize});l=Tn(u/n*100)}let c=100;if(s.maxSize!==void 0){const u=Yl({groupSize:n,panelElement:i,styleProp:s.maxSize});c=Tn(u/n*100)}return{groupResizeBehavior:s.groupResizeBehavior,collapsedSize:o,collapsible:s.collapsible===!0,defaultSize:a,disabled:s.disabled,minSize:l,maxSize:c,panelId:r.id}})}function rt(e,t="Assertion error"){if(!e)throw Error(t)}function S0(e,t){return Array.from(t).sort(e==="horizontal"?PU:IU)}function PU(e,t){const n=e.element.offsetLeft-t.element.offsetLeft;return n!==0?n:e.element.offsetWidth-t.element.offsetWidth}function IU(e,t){const n=e.element.offsetTop-t.element.offsetTop;return n!==0?n:e.element.offsetHeight-t.element.offsetHeight}function hR(e){return e!==null&&typeof e=="object"&&"nodeType"in e&&e.nodeType===Node.ELEMENT_NODE}function fR(e,t){return{x:e.x>=t.left&&e.x<=t.right?0:Math.min(Math.abs(e.x-t.left),Math.abs(e.x-t.right)),y:e.y>=t.top&&e.y<=t.bottom?0:Math.min(Math.abs(e.y-t.top),Math.abs(e.y-t.bottom))}}function RU({orientation:e,rects:t,targetRect:n}){const r={x:n.x+n.width/2,y:n.y+n.height/2};let i,s=Number.MAX_VALUE;for(const o of t){const{x:a,y:l}=fR(r,o),c=e==="horizontal"?a:l;c<s&&(s=c,i=o)}return rt(i,"No rect found"),i}let yd;function MU(){return yd===void 0&&(typeof matchMedia=="function"?yd=!!matchMedia("(pointer:coarse)").matches:yd=!1),yd}function pR(e){const{element:t,orientation:n,panels:r,separators:i}=e,s=S0(n,Array.from(t.children).filter(hR).map(m=>({element:m}))).map(({element:m})=>m),o=[];let a=!1,l=!1,c=-1,u=-1,d=0,f,p=[];{let m=-1;for(const v of s)v.hasAttribute("data-panel")&&(m++,v.hasAttribute("data-disabled")||(d++,c===-1&&(c=m),u=m))}if(d>1){let m=-1;for(const v of s)if(v.hasAttribute("data-panel")){m++;const b=r.find(_=>_.element===v);if(b){if(f){const _=f.element.getBoundingClientRect(),x=v.getBoundingClientRect();let y;if(l){const w=n==="horizontal"?new DOMRect(_.right,_.top,0,_.height):new DOMRect(_.left,_.bottom,_.width,0),C=n==="horizontal"?new DOMRect(x.left,x.top,0,x.height):new DOMRect(x.left,x.top,x.width,0);switch(p.length){case 0:{y=[w,C];break}case 1:{const k=p[0],T=RU({orientation:n,rects:[_,x],targetRect:k.element.getBoundingClientRect()});y=[k,T===_?C:w];break}default:{y=p;break}}}else p.length?y=p:y=[n==="horizontal"?new DOMRect(_.right,x.top,x.left-_.right,x.height):new DOMRect(x.left,_.bottom,x.width,x.top-_.bottom)];for(const w of y){let C="width"in w?w:w.element.getBoundingClientRect();const k=MU()?e.resizeTargetMinimumSize.coarse:e.resizeTargetMinimumSize.fine;if(C.width<k){const N=k-C.width;C=new DOMRect(C.x-N/2,C.y,C.width+N,C.height)}if(C.height<k){const N=k-C.height;C=new DOMRect(C.x,C.y-N/2,C.width,C.height+N)}const T=m<=c||m>u;!a&&!T&&o.push({group:e,groupSize:Ua({group:e}),panels:[f,b],separator:"width"in w?void 0:w,rect:C}),a=!1}}l=!1,f=b,p=[]}}else if(v.hasAttribute("data-separator")){v.ariaDisabled!==null&&(a=!0);const b=i.find(_=>_.element===v);b?p.push(b):(f=void 0,p=[])}else l=!0}return o}var cs;class mR{constructor(){v1(this,cs,{})}addListener(t,n){const r=wl(this,cs)[t];return r===void 0?wl(this,cs)[t]=[n]:r.includes(n)||r.push(n),()=>{this.removeListener(t,n)}}emit(t,n){const r=wl(this,cs)[t];if(r!==void 0)if(r.length===1)r[0].call(null,n);else{let i=!1,s=null;const o=Array.from(r);for(let a=0;a<o.length;a++){const l=o[a];try{l.call(null,n)}catch(c){s===null&&(i=!0,s=c)}}if(i)throw s}}removeAllListeners(){_1(this,cs,{})}removeListener(t,n){const r=wl(this,cs)[t];if(r!==void 0){const i=r.indexOf(n);i>=0&&r.splice(i,1)}}}cs=new WeakMap;let Ea={cursorFlags:0,state:"inactive"};const gy=new mR;function xo(){return Ea}function AU(e){return gy.addListener("change",e)}function LU(e){const t=Ea,n={...Ea};n.cursorFlags=e,Ea=n,gy.emit("change",{prev:t,next:n})}function Ta(e){const t=Ea;Ea=e,gy.emit("change",{prev:t,next:e})}const jU=e=>e,Fm=()=>{},gR=1,vR=2,_R=4,xR=8,hS=3,fS=12;let bd;function pS(){return bd===void 0&&(bd=!1,typeof window<"u"&&(window.navigator.userAgent.includes("Chrome")||window.navigator.userAgent.includes("Firefox"))&&(bd=!0)),bd}function DU({cursorFlags:e,groups:t,state:n}){let r=0,i=0;switch(n){case"active":case"hover":t.forEach(s=>{if(!s.mutableState.disableCursor)switch(s.orientation){case"horizontal":{r++;break}case"vertical":{i++;break}}})}if(!(r===0&&i===0)){switch(n){case"active":{if(e&&pS()){const s=(e&gR)!==0,o=(e&vR)!==0,a=(e&_R)!==0,l=(e&xR)!==0;if(s)return a?"se-resize":l?"ne-resize":"e-resize";if(o)return a?"sw-resize":l?"nw-resize":"w-resize";if(a)return"s-resize";if(l)return"n-resize"}break}}return pS()?r>0&&i>0?"move":r>0?"ew-resize":"ns-resize":r>0&&i>0?"grab":r>0?"col-resize":"row-resize"}}const mS=new WeakMap;function vy(e){if(e.defaultView===null||e.defaultView===void 0)return;let{prevStyle:t,styleSheet:n}=mS.get(e)??{};n===void 0&&(n=new e.defaultView.CSSStyleSheet,e.adoptedStyleSheets&&(Object.isExtensible(e.adoptedStyleSheets)?e.adoptedStyleSheets.push(n):e.adoptedStyleSheets=[...e.adoptedStyleSheets,n]));const r=xo();switch(r.state){case"active":case"hover":{const i=DU({cursorFlags:r.cursorFlags,groups:r.hitRegions.map(o=>o.group),state:r.state}),s=`*, *:hover {cursor: ${i} !important; }`;if(t===s)return;t=s,i?n.cssRules.length===0?n.insertRule(s):n.replaceSync(s):n.cssRules.length===1&&n.deleteRule(0);break}case"inactive":{t=void 0,n.cssRules.length===1&&n.deleteRule(0);break}}mS.set(e,{prevStyle:t,styleSheet:n})}let Xr=new Map;const yR=new mR;function OU(e){Xr=new Map(Xr),Xr.delete(e)}function gS(e,t){for(const[n]of Xr)if(n.id===e)return n}function Ss(e,t){for(const[n,r]of Xr)if(n.id===e)return r;if(t)throw Error(`Could not find data for Group with id ${e}`)}function jo(){return Xr}function _y(e,t){return yR.addListener("groupChange",n=>{n.group.id===e&&t(n)})}function Di(e,t,n){const r=Xr.get(e);Xr=new Map(Xr),Xr.set(e,t),yR.emit("groupChange",{group:e,isUserInteraction:(n==null?void 0:n.isUserInteraction)===!0,prev:r,next:t})}function bR(e){const t=xo();let n=!1;switch(t.state){case"active":Ta({cursorFlags:0,state:"inactive"}),t.hitRegions.length>0&&(vy(e),n=!0,t.hitRegions.forEach(r=>{const i=Ss(r.group.id,!0);Di(r.group,i,{isUserInteraction:!0})}))}return n}function vS(e){e.defaultPrevented||bR(e.currentTarget)}function BU(e,t,n){let r,i={x:1/0,y:1/0};for(const s of t){const o=fR(n,s.rect);switch(e){case"horizontal":{o.x<=i.x&&(r=s,i=o);break}case"vertical":{o.y<=i.y&&(r=s,i=o);break}}}return r?{distance:i,hitRegion:r}:void 0}function zU(e){return e!==null&&typeof e=="object"&&"nodeType"in e&&e.nodeType===Node.DOCUMENT_FRAGMENT_NODE}function $U(e,t){if(e===t)throw new Error("Cannot compare node with itself");const n={a:yS(e),b:yS(t)};let r;for(;n.a.at(-1)===n.b.at(-1);)r=n.a.pop(),n.b.pop();rt(r,"Stacking order can only be calculated for elements with a common ancestor");const i={a:xS(_S(n.a)),b:xS(_S(n.b))};if(i.a===i.b){const s=r.childNodes,o={a:n.a.at(-1),b:n.b.at(-1)};let a=s.length;for(;a--;){const l=s[a];if(l===o.a)return 1;if(l===o.b)return-1}}return Math.sign(i.a-i.b)}const FU=/\b(?:position|zIndex|opacity|transform|webkitTransform|mixBlendMode|filter|webkitFilter|isolation)\b/;function HU(e){const t=getComputedStyle(wR(e)??e).display;return t==="flex"||t==="inline-flex"}function UU(e){const t=getComputedStyle(e);return!!(t.position==="fixed"||t.zIndex!=="auto"&&(t.position!=="static"||HU(e))||+t.opacity<1||"transform"in t&&t.transform!=="none"||"webkitTransform"in t&&t.webkitTransform!=="none"||"mixBlendMode"in t&&t.mixBlendMode!=="normal"||"filter"in t&&t.filter!=="none"||"webkitFilter"in t&&t.webkitFilter!=="none"||"isolation"in t&&t.isolation==="isolate"||FU.test(t.willChange)||t.webkitOverflowScrolling==="touch")}function _S(e){let t=e.length;for(;t--;){const n=e[t];if(rt(n,"Missing node"),UU(n))return n}return null}function xS(e){return e&&Number(getComputedStyle(e).zIndex)||0}function yS(e){const t=[];for(;e;)t.push(e),e=wR(e);return t}function wR(e){const{parentNode:t}=e;return zU(t)?t.host:t}function WU(e,t){return e.x<t.x+t.width&&e.x+e.width>t.x&&e.y<t.y+t.height&&e.y+e.height>t.y}function VU({groupElement:e,hitRegion:t,pointerEventTarget:n}){if(!hR(n)||n.contains(e)||e.contains(n))return!0;if($U(n,e)>0){let r=n;for(;r;){if(r.contains(e))return!0;if(WU(r.getBoundingClientRect(),t))return!1;r=r.parentElement}}return!0}function xy(e,t){const n=[];return t.forEach((r,i)=>{if(i.disabled)return;const s=pR(i),o=BU(i.orientation,s,{x:e.clientX,y:e.clientY});o&&o.distance.x<=0&&o.distance.y<=0&&VU({groupElement:i.element,hitRegion:o.hitRegion.rect,pointerEventTarget:e.target})&&n.push(o.hitRegion)}),n}function qU(e,t){if(e.length!==t.length)return!1;for(let n=0;n<e.length;n++)if(e[n]!=t[n])return!1;return!0}function _n(e,t,n=0){return Math.abs(Tn(e)-Tn(t))<=n}function qr(e,t){return _n(e,t)?0:e>t?1:-1}function ma({overrideDisabledPanels:e,panelConstraints:t,prevSize:n,size:r}){const{collapsedSize:i=0,collapsible:s,disabled:o,maxSize:a=100,minSize:l=0}=t;if(o&&!e)return n;if(qr(r,l)<0)if(s){const c=(i+l)/2;qr(r,c)<0?r=i:r=l}else r=l;return r=Math.min(a,r),r=Tn(r),r}function Jc({delta:e,initialLayout:t,panelConstraints:n,pivotIndices:r,prevLayout:i,trigger:s}){if(_n(e,0))return t;const o=s==="imperative-api",a=Object.values(t),l=Object.values(i),c=[...a],[u,d]=r;rt(u!=null,"Invalid first pivot index"),rt(d!=null,"Invalid second pivot index");let f=0;switch(s){case"keyboard":{{const v=e<0?d:u,b=n[v];rt(b,`Panel constraints not found for index ${v}`);const{collapsedSize:_=0,collapsible:x,minSize:y=0}=b;if(x){const w=a[v];if(rt(w!=null,`Previous layout not found for panel index ${v}`),_n(w,_)){const C=y-w;qr(C,Math.abs(e))>0&&(e=e<0?0-C:C)}}}{const v=e<0?u:d,b=n[v];rt(b,`No panel constraints found for index ${v}`);const{collapsedSize:_=0,collapsible:x,minSize:y=0}=b;if(x){const w=a[v];if(rt(w!=null,`Previous layout not found for panel index ${v}`),_n(w,y)){const C=w-_;qr(C,Math.abs(e))>0&&(e=e<0?0-C:C)}}}break}default:{const v=e<0?d:u,b=n[v];rt(b,`Panel constraints not found for index ${v}`);const _=a[v],{collapsible:x,collapsedSize:y,minSize:w}=b;if(x&&qr(_,w)<0)if(e>0){const C=w-y,k=C/2,T=_+e;qr(T,w)<0&&(e=qr(e,k)<=0?0:C)}else{const C=w-y,k=100-C/2,T=_-e;qr(T,w)<0&&(e=qr(100+e,k)>0?0:-C)}break}}{const v=e<0?1:-1;let b=e<0?d:u,_=0;for(;;){const y=a[b];rt(y!=null,`Previous layout not found for panel index ${b}`);const w=ma({overrideDisabledPanels:o,panelConstraints:n[b],prevSize:y,size:100})-y;if(_+=w,b+=v,b<0||b>=n.length)break}const x=Math.min(Math.abs(e),Math.abs(_));e=e<0?0-x:x}{let v=e<0?u:d;for(;v>=0&&v<n.length;){const b=Math.abs(e)-Math.abs(f),_=a[v];rt(_!=null,`Previous layout not found for panel index ${v}`);const x=_-b,y=ma({overrideDisabledPanels:o,panelConstraints:n[v],prevSize:_,size:x});if(!_n(_,y)&&(f+=_-y,c[v]=y,f.toFixed(3).localeCompare(Math.abs(e).toFixed(3),void 0,{numeric:!0})>=0))break;e<0?v--:v++}}if(qU(l,c))return i;{const v=e<0?d:u,b=a[v];rt(b!=null,`Previous layout not found for panel index ${v}`);const _=b+f,x=ma({overrideDisabledPanels:o,panelConstraints:n[v],prevSize:b,size:_});if(c[v]=x,!_n(x,_)){let y=_-x,w=e<0?d:u;for(;w>=0&&w<n.length;){const C=c[w];rt(C!=null,`Previous layout not found for panel index ${w}`);const k=C+y,T=ma({overrideDisabledPanels:o,panelConstraints:n[w],prevSize:C,size:k});if(_n(C,T)||(y-=T-C,c[w]=T),_n(y,0))break;e>0?w--:w++}}}const p=Object.values(c).reduce((v,b)=>b+v,0);if(!_n(p,100,.1))return i;const m=Object.keys(i);return c.reduce((v,b,_)=>(v[m[_]]=b,v),{})}function yo(e,t){if(Object.keys(e).length!==Object.keys(t).length)return!1;for(const n in e)if(t[n]===void 0||qr(e[n],t[n])!==0)return!1;return!0}function bo({layout:e,panelConstraints:t}){const n=Object.values(e),r=[...n],i=r.reduce((a,l)=>a+l,0);if(r.length!==t.length)throw Error(`Invalid ${t.length} panel layout: ${r.map(a=>`${a}%`).join(", ")}`);if(!_n(i,100)&&r.length>0)for(let a=0;a<t.length;a++){const l=r[a];rt(l!=null,`No layout data found for index ${a}`);const c=100/i*l;r[a]=c}let s=0;for(let a=0;a<t.length;a++){const l=n[a];rt(l!=null,`No layout data found for index ${a}`);const c=r[a];rt(c!=null,`No layout data found for index ${a}`);const u=ma({overrideDisabledPanels:!0,panelConstraints:t[a],prevSize:l,size:c});c!=u&&(s+=c-u,r[a]=u)}if(!_n(s,0))for(let a=0;a<t.length;a++){const l=r[a];rt(l!=null,`No layout data found for index ${a}`);const c=l+s,u=ma({overrideDisabledPanels:!0,panelConstraints:t[a],prevSize:l,size:c});if(l!==u&&(s-=u-l,r[a]=u,_n(s,0)))break}const o=Object.keys(e);return r.reduce((a,l,c)=>(a[o[c]]=l,a),{})}function SR({groupId:e,panelId:t}){const n=()=>{const l=jo();for(const[c,{defaultLayoutDeferred:u,derivedPanelConstraints:d,layout:f,groupSize:p,separatorToPanels:m}]of l)if(c.id===e)return{defaultLayoutDeferred:u,derivedPanelConstraints:d,group:c,groupSize:p,layout:f,separatorToPanels:m};throw Error(`Group ${e} not found`)},r=()=>{const l=n().derivedPanelConstraints.find(c=>c.panelId===t);if(l!==void 0)return l;throw Error(`Panel constraints not found for Panel ${t}`)},i=()=>{const l=n().group.panels.find(c=>c.id===t);if(l!==void 0)return l;throw Error(`Layout not found for Panel ${t}`)},s=()=>{const l=n().layout[t];if(l!==void 0)return l;throw Error(`Layout not found for Panel ${t}`)},o=({nextSize:l,panels:c,prevLayout:u,derivedPanelConstraints:d})=>{const f=s(),p=c.findIndex(b=>b.id===t),m=p===0,v=p===c.length-1;if(v&&l<f&&(m||c.slice(0,p).every((b,_)=>{const x=d[_];return(x==null?void 0:x.collapsible)&&_n(x.collapsedSize,u[x.panelId])}))){const b=c.slice(0,p).reduce((_,x)=>_+u[x.id],0);return{...u,[t]:Tn(100-b)}}return Jc({delta:v?f-l:l-f,initialLayout:u,panelConstraints:d,pivotIndices:v?[p-1,p]:[p,p+1],prevLayout:u,trigger:"imperative-api"})},a=l=>{const c=s();if(l===c)return;const{defaultLayoutDeferred:u,derivedPanelConstraints:d,group:f,groupSize:p,layout:m,separatorToPanels:v}=n(),b=o({nextSize:l,panels:f.panels,prevLayout:m,derivedPanelConstraints:d}),_=bo({layout:b,panelConstraints:d});yo(m,_)||Di(f,{defaultLayoutDeferred:u,derivedPanelConstraints:d,groupSize:p,layout:_,separatorToPanels:v})};return{collapse:()=>{const{collapsible:l,collapsedSize:c}=r(),{mutableValues:u}=i(),d=s();l&&d!==c&&(u.expandToSize=d,a(c))},expand:()=>{const{collapsible:l,collapsedSize:c,minSize:u}=r(),{mutableValues:d}=i(),f=s();if(l&&f===c){let p=d.expandToSize??u;p===0&&(p=1),a(p)}},getSize:()=>{const{group:l}=n(),c=s(),{element:u}=i(),d=l.orientation==="horizontal"?u.offsetWidth:u.offsetHeight;return{asPercentage:c,inPixels:d}},isCollapsed:()=>{const{collapsible:l,collapsedSize:c}=r(),u=s();return l&&_n(c,u)},resize:l=>{const{group:c}=n(),{element:u}=i(),d=Ua({group:c}),f=Yl({groupSize:d,panelElement:u,styleProp:l}),p=Tn(f/d*100);a(p)}}}function bS(e){if(e.defaultPrevented)return;const t=jo();xy(e,t).forEach(n=>{if(n.separator&&!n.separator.disableDoubleClick){const r=n.panels.find(i=>i.panelConstraints.defaultSize!==void 0);if(r){const i=r.panelConstraints.defaultSize,s=SR({groupId:n.group.id,panelId:r.id});s&&i!==void 0&&(s.resize(i),e.preventDefault())}}})}function nh(e){const t=jo();for(const[n]of t)if(n.separators.some(r=>r.element===e))return n;throw Error("Could not find parent Group for separator element")}function kR({groupId:e}){const t=()=>{const n=jo();for(const[r,i]of n)if(r.id===e)return{group:r,...i};throw Error(`Could not find Group with id "${e}"`)};return{getLayout(){const{defaultLayoutDeferred:n,layout:r}=t();return n?{}:r},setLayout(n){const{defaultLayoutDeferred:r,derivedPanelConstraints:i,group:s,groupSize:o,layout:a,separatorToPanels:l}=t(),c=bo({layout:n,panelConstraints:i});return r?a:(yo(a,c)||Di(s,{defaultLayoutDeferred:r,derivedPanelConstraints:i,groupSize:o,layout:c,separatorToPanels:l}),c)}}}function Us(e,t){const n=nh(e),r=Ss(n.id,!0),i=n.separators.find(u=>u.element===e);rt(i,"Matching separator not found");const s=r.separatorToPanels.get(i);rt(s,"Matching panels not found");const o=s.map(u=>n.panels.indexOf(u)),a=kR({groupId:n.id}).getLayout(),l=Jc({delta:t,initialLayout:a,panelConstraints:r.derivedPanelConstraints,pivotIndices:o,prevLayout:a,trigger:"keyboard"}),c=bo({layout:l,panelConstraints:r.derivedPanelConstraints});yo(a,c)||Di(n,{defaultLayoutDeferred:r.defaultLayoutDeferred,derivedPanelConstraints:r.derivedPanelConstraints,groupSize:r.groupSize,layout:c,separatorToPanels:r.separatorToPanels},{isUserInteraction:!0})}function wS(e){if(e.defaultPrevented)return;const t=e.currentTarget,n=nh(t);if(!n.disabled)switch(e.key){case"ArrowDown":{e.preventDefault(),n.orientation==="vertical"&&Us(t,5);break}case"ArrowLeft":{e.preventDefault(),n.orientation==="horizontal"&&Us(t,-5);break}case"ArrowRight":{e.preventDefault(),n.orientation==="horizontal"&&Us(t,5);break}case"ArrowUp":{e.preventDefault(),n.orientation==="vertical"&&Us(t,-5);break}case"End":{e.preventDefault(),Us(t,100);break}case"Enter":{e.preventDefault();const r=nh(t),i=Ss(r.id,!0),{derivedPanelConstraints:s,layout:o,separatorToPanels:a}=i,l=r.separators.find(f=>f.element===t);rt(l,"Matching separator not found");const c=a.get(l);rt(c,"Matching panels not found");const u=c[0],d=s.find(f=>f.panelId===u.id);if(rt(d,"Panel metadata not found"),d.collapsible){const f=o[u.id],p=d.collapsedSize===f?r.mutableState.expandedPanelSizes[u.id]??d.minSize:d.collapsedSize;Us(t,p-f)}break}case"F6":{e.preventDefault();const r=nh(t).separators.map(o=>o.element),i=Array.from(r).findIndex(o=>o===e.currentTarget);rt(i!==null,"Index not found");const s=e.shiftKey?i>0?i-1:r.length-1:i+1<r.length?i+1:0;r[s].focus({preventScroll:!0});break}case"Home":{e.preventDefault(),Us(t,-100);break}}}function SS(e){if(e.defaultPrevented||e.pointerType==="mouse"&&e.button>0)return;const t=jo(),n=xy(e,t),r=new Map;let i=!1;n.forEach(s=>{s.separator&&(i||(i=!0,s.separator.element.focus({focusVisible:!1,preventScroll:!0})));const o=t.get(s.group);o&&r.set(s.group,o.layout)}),Ta({cursorFlags:0,hitRegions:n,initialLayoutMap:r,pointerDownAtPoint:{x:e.clientX,y:e.clientY},state:"active"}),n.length&&e.preventDefault()}function CR({document:e,event:t,hitRegions:n,initialLayoutMap:r,mountedGroups:i,pointerDownAtPoint:s,prevCursorFlags:o}){let a=0;n.forEach(c=>{const{group:u,groupSize:d}=c,{orientation:f,panels:p}=u,{disableCursor:m}=u.mutableState;let v=0;s?f==="horizontal"?v=(t.clientX-s.x)/d*100:v=(t.clientY-s.y)/d*100:f==="horizontal"?v=t.clientX<0?-100:100:v=t.clientY<0?-100:100;const b=r.get(u),_=i.get(u);if(!b||!_)return;const{defaultLayoutDeferred:x,derivedPanelConstraints:y,groupSize:w,layout:C,separatorToPanels:k}=_;if(y&&C&&k){const T=Jc({delta:v,initialLayout:b,panelConstraints:y,pivotIndices:c.panels.map(N=>p.indexOf(N)),prevLayout:C,trigger:"mouse-or-touch"});if(yo(T,C)){if(v!==0&&!m)switch(f){case"horizontal":{a|=v<0?gR:vR;break}case"vertical":{a|=v<0?_R:xR;break}}}else Di(c.group,{defaultLayoutDeferred:x,derivedPanelConstraints:y,groupSize:w,layout:T,separatorToPanels:k})}});let l=0;t.movementX===0?l|=o&hS:l|=a&hS,t.movementY===0?l|=o&fS:l|=a&fS,LU(l),vy(e)}function kS(e){const t=jo(),n=xo();switch(n.state){case"active":CR({document:e.currentTarget,event:e,hitRegions:n.hitRegions,initialLayoutMap:n.initialLayoutMap,mountedGroups:t,prevCursorFlags:n.cursorFlags})}}function CS(e){var r,i;if(e.defaultPrevented)return;const t=xo(),n=jo();switch(t.state){case"active":{if(e.buttons===0){Ta({cursorFlags:0,state:"inactive"}),t.hitRegions.forEach(s=>{const o=Ss(s.group.id,!0);Di(s.group,o,{isUserInteraction:!0})});return}for(const s of t.hitRegions)if(s.separator){const{element:o}=s.separator;(r=o.hasPointerCapture)!=null&&r.call(o,e.pointerId)||((i=o.setPointerCapture)==null||i.call(o,e.pointerId))}CR({document:e.currentTarget,event:e,hitRegions:t.hitRegions,initialLayoutMap:t.initialLayoutMap,mountedGroups:n,pointerDownAtPoint:t.pointerDownAtPoint,prevCursorFlags:t.cursorFlags});break}default:{const s=xy(e,n);s.length===0?t.state!=="inactive"&&Ta({cursorFlags:0,state:"inactive"}):Ta({cursorFlags:0,hitRegions:s,state:"hover"}),vy(e.currentTarget);break}}}function ES(e){if(e.relatedTarget instanceof HTMLIFrameElement)switch(xo().state){case"hover":Ta({cursorFlags:0,state:"inactive"})}}function TS(e){e.defaultPrevented||e.pointerType==="mouse"&&e.button>0||bR(e.currentTarget)&&e.preventDefault()}function NS(e){let t=0,n=0;const r={};for(const s of e)if(s.defaultSize!==void 0){t++;const o=Tn(s.defaultSize);n+=o,r[s.panelId]=o}else r[s.panelId]=void 0;const i=e.length-t;if(i!==0){const s=Tn((100-n)/i);for(const o of e)o.defaultSize===void 0&&(r[o.panelId]=s)}return r}function KU(e,t,n){if(!n[0])return;const r=e.panels.find(l=>l.element===t);if(!r||!r.onResize)return;const i=Ua({group:e}),s=e.orientation==="horizontal"?r.element.offsetWidth:r.element.offsetHeight,o=r.mutableValues.prevSize,a={asPercentage:Tn(s/i*100),inPixels:s};r.mutableValues.prevSize=a,r.onResize(a,r.id,o)}function GU(e,t){if(Object.keys(e).length!==Object.keys(t).length)return!1;for(const n in e)if(e[n]!==t[n])return!1;return!0}function YU({group:e,nextGroupSize:t,prevGroupSize:n,prevLayout:r}){if(n<=0||t<=0||n===t)return r;let i=0,s=0,o=!1;const a=new Map,l=[];for(const d of e.panels){const f=r[d.id]??0;switch(d.panelConstraints.groupResizeBehavior){case"preserve-pixel-size":{o=!0;const p=f/100*n,m=Tn(p/t*100);a.set(d.id,m),i+=m;break}case"preserve-relative-size":default:{l.push(d.id),s+=f;break}}}if(!o||l.length===0)return r;const c=100-i,u={...r};if(a.forEach((d,f)=>{u[f]=d}),s>0)for(const d of l){const f=r[d]??0;u[d]=Tn(f/s*c)}else{const d=Tn(c/l.length);for(const f of l)u[f]=d}return u}function XU(e,t){const n=e.map(i=>i.id),r=Object.keys(t);if(n.length!==r.length)return!1;for(const i of n)if(!r.includes(i))return!1;return!0}const Go=new Map;function QU(e){let t=!0;rt(e.element.ownerDocument.defaultView,"Cannot register an unmounted Group");const n=e.element.ownerDocument.defaultView.ResizeObserver,r=new Set,i=new Set,s=new n(m=>{for(const v of m){const{borderBoxSize:b,target:_}=v;if(_===e.element){if(t){const x=Ua({group:e});if(x===0)return;const y=Ss(e.id);if(!y)return;const w=w0(e),C=y.defaultLayoutDeferred?NS(w):y.layout,k=YU({group:e,nextGroupSize:x,prevGroupSize:y.groupSize,prevLayout:C}),T=bo({layout:k,panelConstraints:w});if(!y.defaultLayoutDeferred&&yo(y.layout,T)&&GU(y.derivedPanelConstraints,w)&&y.groupSize===x)return;Di(e,{defaultLayoutDeferred:!1,derivedPanelConstraints:w,groupSize:x,layout:T,separatorToPanels:y.separatorToPanels})}}else KU(e,_,b)}});s.observe(e.element),e.panels.forEach(m=>{rt(!r.has(m.id),`Panel ids must be unique; id "${m.id}" was used more than once`),r.add(m.id),m.onResize&&s.observe(m.element)});const o=Ua({group:e}),a=w0(e),l=e.panels.map(({id:m})=>m).join(",");let c=e.mutableState.defaultLayout;c&&(XU(e.panels,c)||(c=void 0));const u=e.mutableState.layouts[l]??c??NS(a),d=bo({layout:u,panelConstraints:a}),f=e.element.ownerDocument;Go.set(f,(Go.get(f)??0)+1);const p=new Map;return pR(e).forEach(m=>{m.separator&&p.set(m.separator,m.panels)}),Di(e,{defaultLayoutDeferred:o===0,derivedPanelConstraints:a,groupSize:o,layout:d,separatorToPanels:p}),e.separators.forEach(m=>{rt(!i.has(m.id),`Separator ids must be unique; id "${m.id}" was used more than once`),i.add(m.id),m.element.addEventListener("keydown",wS)}),Go.get(f)===1&&(f.addEventListener("contextmenu",vS,!0),f.addEventListener("dblclick",bS,!0),f.addEventListener("pointerdown",SS,!0),f.addEventListener("pointerleave",kS),f.addEventListener("pointermove",CS),f.addEventListener("pointerout",ES),f.addEventListener("pointerup",TS,!0)),function(){t=!1,Go.set(f,Math.max(0,(Go.get(f)??0)-1)),OU(e),e.separators.forEach(m=>{m.element.removeEventListener("keydown",wS)}),Go.get(f)||(f.removeEventListener("contextmenu",vS,!0),f.removeEventListener("dblclick",bS,!0),f.removeEventListener("pointerdown",SS,!0),f.removeEventListener("pointerleave",kS),f.removeEventListener("pointermove",CS),f.removeEventListener("pointerout",ES),f.removeEventListener("pointerup",TS,!0)),s.disconnect()}}function ZU(){const[e,t]=g.useState({}),n=g.useCallback(()=>t({}),[]);return[e,n]}function yy(e){const t=g.useId();return`${e??t}`}const Do=typeof window<"u"?g.useLayoutEffect:g.useEffect;function mc(e){const t=g.useRef(e);return Do(()=>{t.current=e},[e]),g.useCallback((...n)=>{var r;return(r=t.current)==null?void 0:r.call(t,...n)},[t])}function by(...e){return mc(t=>{e.forEach(n=>{if(n)switch(typeof n){case"function":{n(t);break}case"object":{n.current=t;break}}})})}function wy(e){const t=g.useRef({...e});return Do(()=>{for(const n in e)t.current[n]=e[n]},[e]),t.current}const ER=g.createContext(null);function JU(e,t){const n=g.useRef({getLayout:()=>({}),setLayout:jU});g.useImperativeHandle(t,()=>n.current,[]),Do(()=>{Object.assign(n.current,kR({groupId:e}))})}function Sy({children:e,className:t,defaultLayout:n,disableCursor:r,disabled:i,elementRef:s,groupRef:o,id:a,onLayoutChange:l,onLayoutChanged:c,orientation:u="horizontal",resizeTargetMinimumSize:d={coarse:20,fine:10},style:f,...p}){const m=g.useRef({onLayoutChange:{},onLayoutChanged:{}}),v=mc(B=>{yo(m.current.onLayoutChange,B)||(m.current.onLayoutChange=B,l==null||l(B))}),b=mc((B,R)=>{yo(m.current.onLayoutChanged,B)||(m.current.onLayoutChanged=B,c==null||c(B,{isUserInteraction:R}))}),_=yy(a),x=g.useRef(null),[y,w]=ZU(),C=g.useRef({lastExpandedPanelSizes:{},layouts:{},panels:[],resizeTargetMinimumSize:d,separators:[]}),k=by(x,s);JU(_,o);const T=mc((B,R)=>{const I=xo(),j=gS(B),L=Ss(B);if(L){let $=!1;switch(I.state){case"active":{$=I.hitRegions.some(F=>F.group===j);break}}return{flexGrow:L.layout[R]??1,pointerEvents:$?"none":void 0}}if(n!=null&&n[R])return{flexGrow:n==null?void 0:n[R]}}),N=wy({defaultLayout:n,disableCursor:r}),z=g.useMemo(()=>({get disableCursor(){return!!N.disableCursor},getPanelStyles:T,id:_,orientation:u,registerPanel:B=>{const R=C.current;return R.panels=S0(u,[...R.panels,B]),w(),()=>{R.panels=R.panels.filter(I=>I!==B),w()}},registerSeparator:B=>{const R=C.current;return R.separators=S0(u,[...R.separators,B]),w(),()=>{R.separators=R.separators.filter(I=>I!==B),w()}},updatePanelProps:(B,{disabled:R})=>{const I=C.current.panels.find($=>$.id===B);I&&(I.panelConstraints.disabled=R);const j=gS(_),L=Ss(_);j&&L&&Di(j,{...L,derivedPanelConstraints:w0(j)})},updateSeparatorProps:(B,{disabled:R,disableDoubleClick:I})=>{const j=C.current.separators.find(L=>L.id===B);j&&(j.disabled=R,j.disableDoubleClick=I)}}),[T,_,w,u,N]),P=g.useRef(null);return Do(()=>{const B=x.current;if(B===null)return;const R=C.current;let I;if(N.defaultLayout!==void 0&&Object.keys(N.defaultLayout).length===R.panels.length){I={};for(const E of R.panels){const H=N.defaultLayout[E.id];H!==void 0&&(I[E.id]=H)}}const j={disabled:!!i,element:B,id:_,mutableState:{defaultLayout:I,disableCursor:!!N.disableCursor,expandedPanelSizes:C.current.lastExpandedPanelSizes,layouts:C.current.layouts},orientation:u,panels:R.panels,resizeTargetMinimumSize:R.resizeTargetMinimumSize,separators:R.separators};P.current=j;const L=QU(j),{defaultLayoutDeferred:$,derivedPanelConstraints:F,layout:D}=Ss(j.id,!0);!$&&F.length>0&&(v(D),b(D,!1));const O=_y(_,E=>{const{defaultLayoutDeferred:H,derivedPanelConstraints:V,layout:A}=E.next;if(H||V.length===0)return;const ne=j.panels.map(({id:G})=>G).join(",");j.mutableState.layouts[ne]=A,V.forEach(G=>{if(G.collapsible){const{layout:ye}=E.prev??{};if(ye){const Fe=_n(G.collapsedSize,A[G.panelId]),ue=_n(G.collapsedSize,ye[G.panelId]);Fe&&!ue&&(j.mutableState.expandedPanelSizes[G.panelId]=ye[G.panelId])}}});const ae=xo().state!=="active";v(A),ae&&b(A,E.isUserInteraction)});return()=>{P.current=null,L(),O()}},[i,_,b,v,u,y,N]),g.useEffect(()=>{const B=P.current;B&&(B.mutableState.defaultLayout=n,B.mutableState.disableCursor=!!r)}),h.jsx(ER.Provider,{value:z,children:h.jsx("div",{...p,className:t,"data-group":!0,"data-testid":_,id:_,ref:k,style:{height:"100%",width:"100%",overflow:"hidden",...f,display:"flex",flexDirection:u==="horizontal"?"row":"column",flexWrap:"nowrap",touchAction:u==="horizontal"?"pan-y":"pan-x"},children:e})})}Sy.displayName="Group";function ky(){const e=g.useContext(ER);return rt(e,"Group Context not found; did you render a Panel or Separator outside of a Group?"),e}function eW(e,t){const{id:n}=ky(),r=g.useRef({collapse:Fm,expand:Fm,getSize:()=>({asPercentage:0,inPixels:0}),isCollapsed:()=>!1,resize:Fm});g.useImperativeHandle(t,()=>r.current,[]),Do(()=>{Object.assign(r.current,SR({groupId:n,panelId:e}))})}function sf({children:e,className:t,collapsedSize:n="0%",collapsible:r=!1,defaultSize:i,disabled:s,elementRef:o,groupResizeBehavior:a="preserve-relative-size",id:l,maxSize:c="100%",minSize:u="0%",onResize:d,panelRef:f,style:p,...m}){const v=!!l,b=yy(l),_=wy({disabled:s}),x=g.useRef(null),y=by(x,o),{getPanelStyles:w,id:C,orientation:k,registerPanel:T,updatePanelProps:N}=ky(),z=d!==null,P=mc((j,L,$)=>{d==null||d(j,l,$)});Do(()=>{const j=x.current;if(j!==null){const L={element:j,id:b,idIsStable:v,mutableValues:{expandToSize:void 0,prevSize:void 0},onResize:z?P:void 0,panelConstraints:{groupResizeBehavior:a,collapsedSize:n,collapsible:r,defaultSize:i,disabled:_.disabled,maxSize:c,minSize:u}};return T(L)}},[a,n,r,i,z,b,v,c,u,P,T,_]),g.useEffect(()=>{N(b,{disabled:s})},[s,b,N]),eW(b,f);const B=()=>{const j=w(C,b);if(j)return JSON.stringify(j)},R=g.useSyncExternalStore(j=>_y(C,j),B,B);let I;return R?I=JSON.parse(R):i!==void 0?I={flexGrow:void 0,flexShrink:void 0,flexBasis:i}:I={flexGrow:1},h.jsx("div",{...m,"data-disabled":s||void 0,"data-panel":!0,"data-testid":b,id:b,ref:y,style:{...tW,display:"flex",flexBasis:0,flexShrink:1,overflow:"visible",...I},children:h.jsx("div",{className:t,style:{maxHeight:"100%",maxWidth:"100%",flexGrow:1,overflow:"auto",...p,touchAction:k==="horizontal"?"pan-y":"pan-x"},children:e})})}sf.displayName="Panel";const tW={minHeight:0,maxHeight:"100%",height:"auto",minWidth:0,maxWidth:"100%",width:"auto",border:"none",borderWidth:0,padding:0,margin:0};function nW({layout:e,panelConstraints:t,panelId:n,panelIndex:r}){let i,s;const o=e[n],a=t.find(l=>l.panelId===n);if(a){const l=a.maxSize,c=a.collapsible?a.collapsedSize:a.minSize,u=[r,r+1];s=bo({layout:Jc({delta:c-o,initialLayout:e,panelConstraints:t,pivotIndices:u,prevLayout:e}),panelConstraints:t})[n],i=bo({layout:Jc({delta:l-o,initialLayout:e,panelConstraints:t,pivotIndices:u,prevLayout:e}),panelConstraints:t})[n]}return{valueControls:n,valueMax:i,valueMin:s,valueNow:o}}function TR({children:e,className:t,disabled:n,disableDoubleClick:r,elementRef:i,id:s,style:o,...a}){const l=yy(s),c=wy({disabled:n,disableDoubleClick:r}),[u,d]=g.useState({}),[f,p]=g.useState("inactive"),[m,v]=g.useState(!1),b=g.useRef(null),_=by(b,i),{disableCursor:x,id:y,orientation:w,registerSeparator:C,updateSeparatorProps:k}=ky(),T=w==="horizontal"?"vertical":"horizontal";Do(()=>{const P=b.current;if(P!==null){const B={disabled:c.disabled,disableDoubleClick:c.disableDoubleClick,element:P,id:l},R=C(B),I=AU(L=>{p(L.next.state!=="inactive"&&L.next.hitRegions.some($=>$.separator===B)?L.next.state:"inactive")}),j=_y(y,L=>{const{derivedPanelConstraints:$,layout:F,separatorToPanels:D}=L.next,O=D.get(B);if(O){const E=O[0],H=O.indexOf(E);d(nW({layout:F,panelConstraints:$,panelId:E.id,panelIndex:H}))}});return()=>{I(),j(),R()}}},[y,l,C,c]),g.useEffect(()=>{k(l,{disabled:n,disableDoubleClick:r})},[n,r,l,k]);let N;n&&!x&&(N="not-allowed");let z;if(n)z="disabled";else switch(f){case"active":{z="active";break}default:m?z="focus":z=f}return h.jsx("div",{...a,"aria-controls":u.valueControls,"aria-disabled":n||void 0,"aria-orientation":T,"aria-valuemax":u.valueMax,"aria-valuemin":u.valueMin,"aria-valuenow":u.valueNow,children:e,className:t,"data-separator":z,"data-testid":l,id:l,onBlur:()=>v(!1),onFocus:()=>v(!0),ref:_,role:"separator",style:{flexBasis:"auto",cursor:N,...o,flexGrow:0,flexShrink:0,touchAction:"none"},tabIndex:n?void 0:0})}TR.displayName="Separator";function rW(e,t,n,r=!0){const i=g.useRef({sid:null,tsid:void 0});g.useEffect(()=>{const s=i.current;i.current={sid:t,tsid:n},!(!r||!n||s.sid===t&&(s.tsid===void 0||s.tsid===null)&&typeof n=="string")&&e.sessionObserve({sessionId:t,toolSessionId:n}).catch(()=>{})},[e,t,n,r])}function iW(e,t,n){const r=g.useRef(e),i=g.useRef(t),s=g.useRef(n);s.current=n,g.useEffect(()=>{const o=r.current,a=i.current;r.current=e,i.current=t;const l=o!==e,c=typeof a=="string"&&t==null;!l&&!c||s.current()},[e,t])}const sW=/^Scheduled (?:recurring job|one-shot task) ([0-9a-f]{8}) \(([^)]+)\)/;function oW(e){const t=new Map,n=new Map,r=new Map;for(const i of e)if(i.kind==="tool_call"&&i.tool==="CronCreate"){const s=i.input;if(!s||typeof s.cron!="string"||typeof s.prompt!="string")continue;const o=i.ts;t.set(i.toolUseId,{cron:s.cron,prompt:s.prompt,recurring:s.recurring!==!1,ts:typeof o=="string"?o:"",toolUseId:i.toolUseId})}else if(i.kind==="tool_call"&&i.tool==="CronDelete"){const s=i.input;if(!s||typeof s.id!="string")continue;n.set(i.toolUseId,s.id)}else if(i.kind==="tool_result"){const s=t.get(i.toolUseId);if(s){if(t.delete(i.toolUseId),i.error||typeof i.output!="string")continue;const a=i.output.match(sW);if(!a)continue;r.set(a[1],{id:a[1],cron:s.cron,prompt:s.prompt,recurring:s.recurring,humanSchedule:a[2],createdAt:s.ts,toolUseId:s.toolUseId});continue}const o=n.get(i.toolUseId);o!==void 0&&(n.delete(i.toolUseId),i.error||r.delete(o))}return Array.from(r.values()).sort((i,s)=>i.createdAt.localeCompare(s.createdAt))}const aW=["TaskCreate","TaskUpdate","TaskList","TaskGet"];function lW(e){return aW.includes(e)}function NR(e){return e==="in_progress"||e==="completed"?e:"pending"}function cW(e,t){if(!t||typeof t!="object")return e;const n=t,r=typeof n.subject=="string"&&n.subject?n.subject:typeof n.content=="string"&&n.content?n.content:null;if(!r)return e;const i=typeof n.activeForm=="string"?n.activeForm:void 0,s=typeof n.description=="string"?n.description:void 0;return[...e,{id:String(e.length+1),content:r,status:NR(n.status),activeForm:i,description:s}]}function uW(e,t){if(!t||typeof t!="object")return e;const n=t,r=typeof n.taskId=="string"&&n.taskId?n.taskId:typeof n.id=="string"&&n.id?n.id:null;if(!r)return e;const i=e.findIndex(a=>a.id===r);if(i<0)return e;const s=[...e],o={...s[i]};return"status"in n&&(o.status=NR(n.status)),typeof n.subject=="string"&&(o.content=n.subject),typeof n.content=="string"&&(o.content=n.content),typeof n.activeForm=="string"&&(o.activeForm=n.activeForm),typeof n.description=="string"&&(o.description=n.description),s[i]=o,s}function dW(e){let t=[],n=-1;for(let r=0;r<e.length;r++){const i=e[r];if(i.kind==="task-event")switch(n=r,i.name){case"TaskCreate":t=cW(t,i.input);break;case"TaskUpdate":t=uW(t,i.input);break}}return{tasks:t,lastEventIndex:n}}function hW(e){const{tasks:t,lastEventIndex:n}=dW(e);let r=-1;for(let c=e.length-1;c>=0;c--)if(e[c].kind==="todo-checklist"){r=c;break}const i=[],s=new Map,o=new Map,a=new Map,l=(c,u)=>{var f,p,m,v,b;if(((f=c.progress)==null?void 0:f.status)==="completed"||((p=c.progress)==null?void 0:p.status)==="failed")return;const d={agentId:u.agentId,status:u.status};u.description?d.description=u.description:(m=c.progress)!=null&&m.description&&(d.description=c.progress.description),u.lastToolName?d.lastToolName=u.lastToolName:(v=c.progress)!=null&&v.lastToolName&&(d.lastToolName=c.progress.lastToolName),u.stats?d.stats=u.stats:(b=c.progress)!=null&&b.stats&&(d.stats=c.progress.stats),c.progress=d,(u.status==="completed"||u.status==="failed")&&(c.pending=!1)};for(let c=0;c<e.length;c++){const u=e[c];switch(u.kind){case"tool-call":{const d={kind:"merged-tool",seq:u.seq,tool:u.tool,toolKind:u.toolKind,toolUseId:u.toolUseId,input:u.input,pending:!0};s.set(u.toolUseId,i.length),i.push(d);break}case"tool-result":{const d=s.get(u.toolUseId);if(d!==void 0){const p=i[d];p.output=u.output,p.error=u.error,p.pending=!1,s.delete(u.toolUseId);break}const f=o.get(u.toolUseId);if(f!==void 0){const p=i[f];p.output=u.output,p.error=u.error,p.pending=!1,u.toolResultExtra&&(p.toolResultExtra=u.toolResultExtra);break}break}case"agent-call":{const d={kind:"merged-agent",seq:u.seq,toolUseId:u.toolUseId,description:u.description,input:u.input,pending:!0,notifications:[]};o.set(u.toolUseId,i.length),i.push(d);const f=a.get(u.toolUseId);f&&(l(d,f),a.delete(u.toolUseId));break}case"agent-progress":{const d=o.get(u.toolUseId);if(d!==void 0){l(i[d],u);break}const f=a.get(u.toolUseId);if((f==null?void 0:f.status)==="completed"||(f==null?void 0:f.status)==="failed")break;a.set(u.toolUseId,u);break}case"agent-notification":{const d=u.parentToolUseId;if(d){const f=o.get(d);if(f!==void 0){i[f].notifications.push({text:u.text,taskId:u.taskId});break}}i.push({kind:"agent-notification",seq:u.seq,text:u.text,taskId:u.taskId,parentToolUseId:u.parentToolUseId});break}case"todo-checklist":{c===r&&u.todos.length>0&&i.push({kind:"todo-checklist",seq:u.seq,toolUseId:u.toolUseId,todos:u.todos});break}case"task-event":{c===n&&t.length>0&&i.push({kind:"plan-card",seq:u.seq,tasks:t});break}default:i.push(u)}}return i}const fW=new Set(["permission-inline","question-card"]);function pW(e){return e.kind==="user-text"?!0:e.kind==="user-meta"&&e.metaKind==="slash-command"}function mW(e){return e.kind==="user-text"&&e.continuesTurn===!0}function gW(e,t={}){const n=[];let r=null;const i=(s,o)=>{r&&(n.push(vW(r,s,o)),r=null)};for(const s of e){if(s.kind==="turn-end"){i(s,!0);continue}if(pW(s)&&(r===null||!mW(s))){i(void 0,!0),r={query:s,body:[]};continue}r===null?r={body:[s]}:r.body.push(s)}return i(void 0,t.closeTrailing===!0),n}function vW(e,t,n){const{query:r,body:i}=e,s=_W(i,t,n),o=xW(i,s),a=bW(i,o),l=r??i[0]??t,c={kind:"turn",seq:l?l.seq:0,status:s,process:a,tail:o};return r&&(c.query=r),(t==null?void 0:t.durationMs)!==void 0&&(c.durationMs=t.durationMs),c}function _W(e,t,n){if(!n)return"running";if((t==null?void 0:t.reason)==="interrupted")return"interrupted";const r=k0(e,i=>i.kind==="error");return r>=0&&!e.slice(r+1).some(s=>s.kind==="assistant-text")?"error":"done"}function xW(e,t){if(t==="running"){const i=[];for(let s=e.length-1;s>=0&&fW.has(e[s].kind);s--)i.unshift(e[s]);return i}const n=[];e.forEach((i,s)=>{i.kind==="merged-agent"&&i.pending&&n.push(s)});const r=t==="error"?k0(e,i=>i.kind==="error"):k0(e,i=>i.kind==="assistant-text");return r>=0&&n.push(r),n.sort((i,s)=>i-s).map(i=>e[i])}const yW=new Set(["assistant-thinking","user-meta"]);function bW(e,t){const n=new Set(t),r=[];let i=null;const s=()=>{i&&(r.push({kind:"tool-group",seq:i[0].seq,items:i}),i=null)};for(const o of e){if(n.has(o)){s();continue}if(o.kind==="merged-tool"){i?i.push(o):i=[o];continue}if(yW.has(o.kind)){r.push(o);continue}s(),r.push(o)}return s(),r}function k0(e,t){for(let n=e.length-1;n>=0;n--)if(t(e[n]))return n;return-1}const wW={Read:["正在读取","已读取"],Bash:["正在运行","已运行"],Grep:["正在搜索","已搜索"],Glob:["正在搜索","已搜索"],Edit:["正在编辑","已编辑"],Write:["正在写入","已写入"],WebFetch:["正在抓取","已抓取"],WebSearch:["正在搜索","已搜索"],Skill:["正在读取","已读取"]};function SW(e){if(!e||typeof e!="object")return"";const t=e,n=t.command??t.file_path??t.path??t.pattern??t.query??t.url??t.description;if(typeof n=="string")return n;for(const r of Object.values(t))if(typeof r=="string"&&r)return r;return""}function PR(e){const t=wW[e.tool],n=t?e.pending?t[0]:t[1]:e.pending?`正在执行 ${e.tool}`:`已执行 ${e.tool}`,r=SW(e.input);return r?`${n} ${r}`:n}function kW({item:e,renderItemDetail:t}){const[n,r]=g.useState(!1),i=n?ir:Un,s=n?(t==null?void 0:t(e))??null:null;return h.jsxs("div",{className:"min-w-0 max-w-full",children:[h.jsxs("button",{type:"button",onClick:()=>r(o=>!o),"aria-expanded":n,"data-testid":"tool-call-group-row",className:fe("flex w-full items-center gap-1.5 text-left cursor-pointer min-w-0 py-0.5 text-[13px] hover:text-text-200",e.error?"text-destructive/80":"text-text-400"),children:[e.pending?h.jsx(In,{className:"w-3.5 h-3.5 animate-spin shrink-0"}):h.jsx(i,{className:"w-3.5 h-3.5 shrink-0 opacity-60"}),h.jsx("span",{className:"truncate min-w-0",children:PR(e)})]}),n?h.jsx("div",{"data-testid":"tool-call-group-row-detail",className:"pl-5 py-1 min-w-0 space-y-1.5 text-[12px] text-text-300",children:s!==null?s:h.jsxs(h.Fragment,{children:[h.jsx("pre",{className:"min-w-0 max-w-full overflow-auto whitespace-pre-wrap font-mono",children:JSON.stringify(e.input,null,2)}),e.output!==void 0?h.jsx("pre",{className:"min-w-0 max-w-full overflow-auto whitespace-pre-wrap font-mono text-text-400",children:typeof e.output=="string"?e.output:JSON.stringify(e.output,null,2)}):null,e.error?h.jsx("pre",{className:"min-w-0 max-w-full overflow-auto whitespace-pre-wrap font-mono text-destructive",children:e.error}):null]})}):null]})}function CW({items:e,defaultExpanded:t=!1,renderItemDetail:n}){const[r,i]=g.useState(t);if(e.length===0)return null;const s=e.some(c=>c.pending),o=s?[...e].reverse().find(c=>c.pending):e[e.length-1],a=!s&&e.length>1?` 等 ${e.length} 项`:"",l=r?ir:Un;return h.jsxs("div",{"data-testid":"tool-call-group",className:"min-w-0 max-w-full",children:[h.jsxs("button",{type:"button",onClick:()=>i(c=>!c),"aria-expanded":r,"data-testid":"tool-call-group-header",className:"flex w-full items-center gap-1.5 text-left cursor-pointer min-w-0 py-0.5 text-[13px] text-text-400 hover:text-text-200",children:[s&&!r?h.jsx(In,{className:"w-3.5 h-3.5 animate-spin shrink-0"}):h.jsx(l,{className:"w-3.5 h-3.5 shrink-0"}),r?h.jsx("span",{className:"min-w-0 truncate opacity-70",children:s?"正在执行":`${e.length} 项`}):h.jsxs("span",{className:fe("truncate min-w-0",s&&"text-text-300"),children:[PR(o),a]})]}),r?h.jsx("div",{className:"mt-0.5 flex flex-col pl-5",children:e.map(c=>h.jsx(kW,{item:c,renderItemDetail:n},c.toolUseId))}):null]})}function EW(e){const t=Math.round(e/1e3);if(t<60)return`${t}秒`;const n=Math.floor(t/60),r=t%60;return r>0?`${n}分${r}秒`:`${n}分钟`}function TW(e,t){const n=t!==void 0?`耗时 ${EW(t)}`:"";switch(e){case"interrupted":return n?`已中断 · ${n}`:"已中断";case"error":return n?`出错 · ${n}`:"出错";default:return n||"已完成"}}function NW({status:e="done",durationMs:t,defaultExpanded:n=!1,children:r}){const[i,s]=g.useState(n),o=i?ir:Un;return h.jsxs("div",{"data-testid":"turn-process-block",className:"min-w-0 max-w-full border-t border-border pt-2",children:[h.jsxs("button",{type:"button",onClick:()=>s(a=>!a),"aria-expanded":i,"data-testid":"turn-process-block-header",className:fe("flex w-full items-center gap-1 text-left cursor-pointer min-w-0 py-0.5 text-[13px]",e!=="done"?"text-destructive/80 hover:text-destructive":"text-text-400 hover:text-text-200"),children:[h.jsx("span",{className:"truncate min-w-0",children:TW(e,t)}),h.jsx(o,{className:"w-3.5 h-3.5 shrink-0"})]}),i?h.jsx("div",{"data-testid":"turn-process-body",className:"mt-2 flex flex-col gap-2 border-l-2 border-border pl-3",children:r}):null]})}const PW=/<(system-reminder|related-dir|clawd-shift-fire)\b[^>]*>[\s\S]*?<\/\1>/gi,IW=/<builder-preview\b[^>]*\/>/gi;function IR(e){return e?e.replace(PW,"").replace(IW,"").trim():""}const RW=IR;function MW(e,t){const n={};return(e[e.length-1]===""?[...e,""]:e).join((n.padRight?" ":"")+","+(n.padLeft===!1?"":" ")).trim()}const AW=/^[$_\p{ID_Start}][$_\u{200C}\u{200D}\p{ID_Continue}]*$/u,LW=/^[$_\p{ID_Start}][-$_\u{200C}\u{200D}\p{ID_Continue}]*$/u,jW={};function PS(e,t){return(jW.jsx?LW:AW).test(e)}const DW=/[ \t\n\f\r]/g;function OW(e){return typeof e=="object"?e.type==="text"?IS(e.value):!1:IS(e)}function IS(e){return e.replace(DW,"")===""}class Eu{constructor(t,n,r){this.normal=n,this.property=t,r&&(this.space=r)}}Eu.prototype.normal={};Eu.prototype.property={};Eu.prototype.space=void 0;function RR(e,t){const n={},r={};for(const i of e)Object.assign(n,i.property),Object.assign(r,i.normal);return new Eu(n,r,t)}function C0(e){return e.toLowerCase()}class Wn{constructor(t,n){this.attribute=n,this.property=t}}Wn.prototype.attribute="";Wn.prototype.booleanish=!1;Wn.prototype.boolean=!1;Wn.prototype.commaOrSpaceSeparated=!1;Wn.prototype.commaSeparated=!1;Wn.prototype.defined=!1;Wn.prototype.mustUseProperty=!1;Wn.prototype.number=!1;Wn.prototype.overloadedBoolean=!1;Wn.prototype.property="";Wn.prototype.spaceSeparated=!1;Wn.prototype.space=void 0;let BW=0;const Me=Oo(),At=Oo(),E0=Oo(),Q=Oo(),at=Oo(),Na=Oo(),Gn=Oo();function Oo(){return 2**++BW}const T0=Object.freeze(Object.defineProperty({__proto__:null,boolean:Me,booleanish:At,commaOrSpaceSeparated:Gn,commaSeparated:Na,number:Q,overloadedBoolean:E0,spaceSeparated:at},Symbol.toStringTag,{value:"Module"})),Hm=Object.keys(T0);class Cy extends Wn{constructor(t,n,r,i){let s=-1;if(super(t,n),RS(this,"space",i),typeof r=="number")for(;++s<Hm.length;){const o=Hm[s];RS(this,Hm[s],(r&T0[o])===T0[o])}}}Cy.prototype.defined=!0;function RS(e,t,n){n&&(e[t]=n)}function fl(e){const t={},n={};for(const[r,i]of Object.entries(e.properties)){const s=new Cy(r,e.transform(e.attributes||{},r),i,e.space);e.mustUseProperty&&e.mustUseProperty.includes(r)&&(s.mustUseProperty=!0),t[r]=s,n[C0(r)]=r,n[C0(s.attribute)]=r}return new Eu(t,n,e.space)}const MR=fl({properties:{ariaActiveDescendant:null,ariaAtomic:At,ariaAutoComplete:null,ariaBusy:At,ariaChecked:At,ariaColCount:Q,ariaColIndex:Q,ariaColSpan:Q,ariaControls:at,ariaCurrent:null,ariaDescribedBy:at,ariaDetails:null,ariaDisabled:At,ariaDropEffect:at,ariaErrorMessage:null,ariaExpanded:At,ariaFlowTo:at,ariaGrabbed:At,ariaHasPopup:null,ariaHidden:At,ariaInvalid:null,ariaKeyShortcuts:null,ariaLabel:null,ariaLabelledBy:at,ariaLevel:Q,ariaLive:null,ariaModal:At,ariaMultiLine:At,ariaMultiSelectable:At,ariaOrientation:null,ariaOwns:at,ariaPlaceholder:null,ariaPosInSet:Q,ariaPressed:At,ariaReadOnly:At,ariaRelevant:null,ariaRequired:At,ariaRoleDescription:at,ariaRowCount:Q,ariaRowIndex:Q,ariaRowSpan:Q,ariaSelected:At,ariaSetSize:Q,ariaSort:null,ariaValueMax:Q,ariaValueMin:Q,ariaValueNow:Q,ariaValueText:null,role:null},transform(e,t){return t==="role"?t:"aria-"+t.slice(4).toLowerCase()}});function AR(e,t){return t in e?e[t]:t}function LR(e,t){return AR(e,t.toLowerCase())}const zW=fl({attributes:{acceptcharset:"accept-charset",classname:"class",htmlfor:"for",httpequiv:"http-equiv"},mustUseProperty:["checked","multiple","muted","selected"],properties:{abbr:null,accept:Na,acceptCharset:at,accessKey:at,action:null,allow:null,allowFullScreen:Me,allowPaymentRequest:Me,allowUserMedia:Me,alt:null,as:null,async:Me,autoCapitalize:null,autoComplete:at,autoFocus:Me,autoPlay:Me,blocking:at,capture:null,charSet:null,checked:Me,cite:null,className:at,cols:Q,colSpan:null,content:null,contentEditable:At,controls:Me,controlsList:at,coords:Q|Na,crossOrigin:null,data:null,dateTime:null,decoding:null,default:Me,defer:Me,dir:null,dirName:null,disabled:Me,download:E0,draggable:At,encType:null,enterKeyHint:null,fetchPriority:null,form:null,formAction:null,formEncType:null,formMethod:null,formNoValidate:Me,formTarget:null,headers:at,height:Q,hidden:E0,high:Q,href:null,hrefLang:null,htmlFor:at,httpEquiv:at,id:null,imageSizes:null,imageSrcSet:null,inert:Me,inputMode:null,integrity:null,is:null,isMap:Me,itemId:null,itemProp:at,itemRef:at,itemScope:Me,itemType:at,kind:null,label:null,lang:null,language:null,list:null,loading:null,loop:Me,low:Q,manifest:null,max:null,maxLength:Q,media:null,method:null,min:null,minLength:Q,multiple:Me,muted:Me,name:null,nonce:null,noModule:Me,noValidate:Me,onAbort:null,onAfterPrint:null,onAuxClick:null,onBeforeMatch:null,onBeforePrint:null,onBeforeToggle:null,onBeforeUnload:null,onBlur:null,onCancel:null,onCanPlay:null,onCanPlayThrough:null,onChange:null,onClick:null,onClose:null,onContextLost:null,onContextMenu:null,onContextRestored:null,onCopy:null,onCueChange:null,onCut:null,onDblClick:null,onDrag:null,onDragEnd:null,onDragEnter:null,onDragExit:null,onDragLeave:null,onDragOver:null,onDragStart:null,onDrop:null,onDurationChange:null,onEmptied:null,onEnded:null,onError:null,onFocus:null,onFormData:null,onHashChange:null,onInput:null,onInvalid:null,onKeyDown:null,onKeyPress:null,onKeyUp:null,onLanguageChange:null,onLoad:null,onLoadedData:null,onLoadedMetadata:null,onLoadEnd:null,onLoadStart:null,onMessage:null,onMessageError:null,onMouseDown:null,onMouseEnter:null,onMouseLeave:null,onMouseMove:null,onMouseOut:null,onMouseOver:null,onMouseUp:null,onOffline:null,onOnline:null,onPageHide:null,onPageShow:null,onPaste:null,onPause:null,onPlay:null,onPlaying:null,onPopState:null,onProgress:null,onRateChange:null,onRejectionHandled:null,onReset:null,onResize:null,onScroll:null,onScrollEnd:null,onSecurityPolicyViolation:null,onSeeked:null,onSeeking:null,onSelect:null,onSlotChange:null,onStalled:null,onStorage:null,onSubmit:null,onSuspend:null,onTimeUpdate:null,onToggle:null,onUnhandledRejection:null,onUnload:null,onVolumeChange:null,onWaiting:null,onWheel:null,open:Me,optimum:Q,pattern:null,ping:at,placeholder:null,playsInline:Me,popover:null,popoverTarget:null,popoverTargetAction:null,poster:null,preload:null,readOnly:Me,referrerPolicy:null,rel:at,required:Me,reversed:Me,rows:Q,rowSpan:Q,sandbox:at,scope:null,scoped:Me,seamless:Me,selected:Me,shadowRootClonable:Me,shadowRootDelegatesFocus:Me,shadowRootMode:null,shape:null,size:Q,sizes:null,slot:null,span:Q,spellCheck:At,src:null,srcDoc:null,srcLang:null,srcSet:null,start:Q,step:null,style:null,tabIndex:Q,target:null,title:null,translate:null,type:null,typeMustMatch:Me,useMap:null,value:At,width:Q,wrap:null,writingSuggestions:null,align:null,aLink:null,archive:at,axis:null,background:null,bgColor:null,border:Q,borderColor:null,bottomMargin:Q,cellPadding:null,cellSpacing:null,char:null,charOff:null,classId:null,clear:null,code:null,codeBase:null,codeType:null,color:null,compact:Me,declare:Me,event:null,face:null,frame:null,frameBorder:null,hSpace:Q,leftMargin:Q,link:null,longDesc:null,lowSrc:null,marginHeight:Q,marginWidth:Q,noResize:Me,noHref:Me,noShade:Me,noWrap:Me,object:null,profile:null,prompt:null,rev:null,rightMargin:Q,rules:null,scheme:null,scrolling:At,standby:null,summary:null,text:null,topMargin:Q,valueType:null,version:null,vAlign:null,vLink:null,vSpace:Q,allowTransparency:null,autoCorrect:null,autoSave:null,disablePictureInPicture:Me,disableRemotePlayback:Me,prefix:null,property:null,results:Q,security:null,unselectable:null},space:"html",transform:LR}),$W=fl({attributes:{accentHeight:"accent-height",alignmentBaseline:"alignment-baseline",arabicForm:"arabic-form",baselineShift:"baseline-shift",capHeight:"cap-height",className:"class",clipPath:"clip-path",clipRule:"clip-rule",colorInterpolation:"color-interpolation",colorInterpolationFilters:"color-interpolation-filters",colorProfile:"color-profile",colorRendering:"color-rendering",crossOrigin:"crossorigin",dataType:"datatype",dominantBaseline:"dominant-baseline",enableBackground:"enable-background",fillOpacity:"fill-opacity",fillRule:"fill-rule",floodColor:"flood-color",floodOpacity:"flood-opacity",fontFamily:"font-family",fontSize:"font-size",fontSizeAdjust:"font-size-adjust",fontStretch:"font-stretch",fontStyle:"font-style",fontVariant:"font-variant",fontWeight:"font-weight",glyphName:"glyph-name",glyphOrientationHorizontal:"glyph-orientation-horizontal",glyphOrientationVertical:"glyph-orientation-vertical",hrefLang:"hreflang",horizAdvX:"horiz-adv-x",horizOriginX:"horiz-origin-x",horizOriginY:"horiz-origin-y",imageRendering:"image-rendering",letterSpacing:"letter-spacing",lightingColor:"lighting-color",markerEnd:"marker-end",markerMid:"marker-mid",markerStart:"marker-start",navDown:"nav-down",navDownLeft:"nav-down-left",navDownRight:"nav-down-right",navLeft:"nav-left",navNext:"nav-next",navPrev:"nav-prev",navRight:"nav-right",navUp:"nav-up",navUpLeft:"nav-up-left",navUpRight:"nav-up-right",onAbort:"onabort",onActivate:"onactivate",onAfterPrint:"onafterprint",onBeforePrint:"onbeforeprint",onBegin:"onbegin",onCancel:"oncancel",onCanPlay:"oncanplay",onCanPlayThrough:"oncanplaythrough",onChange:"onchange",onClick:"onclick",onClose:"onclose",onCopy:"oncopy",onCueChange:"oncuechange",onCut:"oncut",onDblClick:"ondblclick",onDrag:"ondrag",onDragEnd:"ondragend",onDragEnter:"ondragenter",onDragExit:"ondragexit",onDragLeave:"ondragleave",onDragOver:"ondragover",onDragStart:"ondragstart",onDrop:"ondrop",onDurationChange:"ondurationchange",onEmptied:"onemptied",onEnd:"onend",onEnded:"onended",onError:"onerror",onFocus:"onfocus",onFocusIn:"onfocusin",onFocusOut:"onfocusout",onHashChange:"onhashchange",onInput:"oninput",onInvalid:"oninvalid",onKeyDown:"onkeydown",onKeyPress:"onkeypress",onKeyUp:"onkeyup",onLoad:"onload",onLoadedData:"onloadeddata",onLoadedMetadata:"onloadedmetadata",onLoadStart:"onloadstart",onMessage:"onmessage",onMouseDown:"onmousedown",onMouseEnter:"onmouseenter",onMouseLeave:"onmouseleave",onMouseMove:"onmousemove",onMouseOut:"onmouseout",onMouseOver:"onmouseover",onMouseUp:"onmouseup",onMouseWheel:"onmousewheel",onOffline:"onoffline",onOnline:"ononline",onPageHide:"onpagehide",onPageShow:"onpageshow",onPaste:"onpaste",onPause:"onpause",onPlay:"onplay",onPlaying:"onplaying",onPopState:"onpopstate",onProgress:"onprogress",onRateChange:"onratechange",onRepeat:"onrepeat",onReset:"onreset",onResize:"onresize",onScroll:"onscroll",onSeeked:"onseeked",onSeeking:"onseeking",onSelect:"onselect",onShow:"onshow",onStalled:"onstalled",onStorage:"onstorage",onSubmit:"onsubmit",onSuspend:"onsuspend",onTimeUpdate:"ontimeupdate",onToggle:"ontoggle",onUnload:"onunload",onVolumeChange:"onvolumechange",onWaiting:"onwaiting",onZoom:"onzoom",overlinePosition:"overline-position",overlineThickness:"overline-thickness",paintOrder:"paint-order",panose1:"panose-1",pointerEvents:"pointer-events",referrerPolicy:"referrerpolicy",renderingIntent:"rendering-intent",shapeRendering:"shape-rendering",stopColor:"stop-color",stopOpacity:"stop-opacity",strikethroughPosition:"strikethrough-position",strikethroughThickness:"strikethrough-thickness",strokeDashArray:"stroke-dasharray",strokeDashOffset:"stroke-dashoffset",strokeLineCap:"stroke-linecap",strokeLineJoin:"stroke-linejoin",strokeMiterLimit:"stroke-miterlimit",strokeOpacity:"stroke-opacity",strokeWidth:"stroke-width",tabIndex:"tabindex",textAnchor:"text-anchor",textDecoration:"text-decoration",textRendering:"text-rendering",transformOrigin:"transform-origin",typeOf:"typeof",underlinePosition:"underline-position",underlineThickness:"underline-thickness",unicodeBidi:"unicode-bidi",unicodeRange:"unicode-range",unitsPerEm:"units-per-em",vAlphabetic:"v-alphabetic",vHanging:"v-hanging",vIdeographic:"v-ideographic",vMathematical:"v-mathematical",vectorEffect:"vector-effect",vertAdvY:"vert-adv-y",vertOriginX:"vert-origin-x",vertOriginY:"vert-origin-y",wordSpacing:"word-spacing",writingMode:"writing-mode",xHeight:"x-height",playbackOrder:"playbackorder",timelineBegin:"timelinebegin"},properties:{about:Gn,accentHeight:Q,accumulate:null,additive:null,alignmentBaseline:null,alphabetic:Q,amplitude:Q,arabicForm:null,ascent:Q,attributeName:null,attributeType:null,azimuth:Q,bandwidth:null,baselineShift:null,baseFrequency:null,baseProfile:null,bbox:null,begin:null,bias:Q,by:null,calcMode:null,capHeight:Q,className:at,clip:null,clipPath:null,clipPathUnits:null,clipRule:null,color:null,colorInterpolation:null,colorInterpolationFilters:null,colorProfile:null,colorRendering:null,content:null,contentScriptType:null,contentStyleType:null,crossOrigin:null,cursor:null,cx:null,cy:null,d:null,dataType:null,defaultAction:null,descent:Q,diffuseConstant:Q,direction:null,display:null,dur:null,divisor:Q,dominantBaseline:null,download:Me,dx:null,dy:null,edgeMode:null,editable:null,elevation:Q,enableBackground:null,end:null,event:null,exponent:Q,externalResourcesRequired:null,fill:null,fillOpacity:Q,fillRule:null,filter:null,filterRes:null,filterUnits:null,floodColor:null,floodOpacity:null,focusable:null,focusHighlight:null,fontFamily:null,fontSize:null,fontSizeAdjust:null,fontStretch:null,fontStyle:null,fontVariant:null,fontWeight:null,format:null,fr:null,from:null,fx:null,fy:null,g1:Na,g2:Na,glyphName:Na,glyphOrientationHorizontal:null,glyphOrientationVertical:null,glyphRef:null,gradientTransform:null,gradientUnits:null,handler:null,hanging:Q,hatchContentUnits:null,hatchUnits:null,height:null,href:null,hrefLang:null,horizAdvX:Q,horizOriginX:Q,horizOriginY:Q,id:null,ideographic:Q,imageRendering:null,initialVisibility:null,in:null,in2:null,intercept:Q,k:Q,k1:Q,k2:Q,k3:Q,k4:Q,kernelMatrix:Gn,kernelUnitLength:null,keyPoints:null,keySplines:null,keyTimes:null,kerning:null,lang:null,lengthAdjust:null,letterSpacing:null,lightingColor:null,limitingConeAngle:Q,local:null,markerEnd:null,markerMid:null,markerStart:null,markerHeight:null,markerUnits:null,markerWidth:null,mask:null,maskContentUnits:null,maskUnits:null,mathematical:null,max:null,media:null,mediaCharacterEncoding:null,mediaContentEncodings:null,mediaSize:Q,mediaTime:null,method:null,min:null,mode:null,name:null,navDown:null,navDownLeft:null,navDownRight:null,navLeft:null,navNext:null,navPrev:null,navRight:null,navUp:null,navUpLeft:null,navUpRight:null,numOctaves:null,observer:null,offset:null,onAbort:null,onActivate:null,onAfterPrint:null,onBeforePrint:null,onBegin:null,onCancel:null,onCanPlay:null,onCanPlayThrough:null,onChange:null,onClick:null,onClose:null,onCopy:null,onCueChange:null,onCut:null,onDblClick:null,onDrag:null,onDragEnd:null,onDragEnter:null,onDragExit:null,onDragLeave:null,onDragOver:null,onDragStart:null,onDrop:null,onDurationChange:null,onEmptied:null,onEnd:null,onEnded:null,onError:null,onFocus:null,onFocusIn:null,onFocusOut:null,onHashChange:null,onInput:null,onInvalid:null,onKeyDown:null,onKeyPress:null,onKeyUp:null,onLoad:null,onLoadedData:null,onLoadedMetadata:null,onLoadStart:null,onMessage:null,onMouseDown:null,onMouseEnter:null,onMouseLeave:null,onMouseMove:null,onMouseOut:null,onMouseOver:null,onMouseUp:null,onMouseWheel:null,onOffline:null,onOnline:null,onPageHide:null,onPageShow:null,onPaste:null,onPause:null,onPlay:null,onPlaying:null,onPopState:null,onProgress:null,onRateChange:null,onRepeat:null,onReset:null,onResize:null,onScroll:null,onSeeked:null,onSeeking:null,onSelect:null,onShow:null,onStalled:null,onStorage:null,onSubmit:null,onSuspend:null,onTimeUpdate:null,onToggle:null,onUnload:null,onVolumeChange:null,onWaiting:null,onZoom:null,opacity:null,operator:null,order:null,orient:null,orientation:null,origin:null,overflow:null,overlay:null,overlinePosition:Q,overlineThickness:Q,paintOrder:null,panose1:null,path:null,pathLength:Q,patternContentUnits:null,patternTransform:null,patternUnits:null,phase:null,ping:at,pitch:null,playbackOrder:null,pointerEvents:null,points:null,pointsAtX:Q,pointsAtY:Q,pointsAtZ:Q,preserveAlpha:null,preserveAspectRatio:null,primitiveUnits:null,propagate:null,property:Gn,r:null,radius:null,referrerPolicy:null,refX:null,refY:null,rel:Gn,rev:Gn,renderingIntent:null,repeatCount:null,repeatDur:null,requiredExtensions:Gn,requiredFeatures:Gn,requiredFonts:Gn,requiredFormats:Gn,resource:null,restart:null,result:null,rotate:null,rx:null,ry:null,scale:null,seed:null,shapeRendering:null,side:null,slope:null,snapshotTime:null,specularConstant:Q,specularExponent:Q,spreadMethod:null,spacing:null,startOffset:null,stdDeviation:null,stemh:null,stemv:null,stitchTiles:null,stopColor:null,stopOpacity:null,strikethroughPosition:Q,strikethroughThickness:Q,string:null,stroke:null,strokeDashArray:Gn,strokeDashOffset:null,strokeLineCap:null,strokeLineJoin:null,strokeMiterLimit:Q,strokeOpacity:Q,strokeWidth:null,style:null,surfaceScale:Q,syncBehavior:null,syncBehaviorDefault:null,syncMaster:null,syncTolerance:null,syncToleranceDefault:null,systemLanguage:Gn,tabIndex:Q,tableValues:null,target:null,targetX:Q,targetY:Q,textAnchor:null,textDecoration:null,textRendering:null,textLength:null,timelineBegin:null,title:null,transformBehavior:null,type:null,typeOf:Gn,to:null,transform:null,transformOrigin:null,u1:null,u2:null,underlinePosition:Q,underlineThickness:Q,unicode:null,unicodeBidi:null,unicodeRange:null,unitsPerEm:Q,values:null,vAlphabetic:Q,vMathematical:Q,vectorEffect:null,vHanging:Q,vIdeographic:Q,version:null,vertAdvY:Q,vertOriginX:Q,vertOriginY:Q,viewBox:null,viewTarget:null,visibility:null,width:null,widths:null,wordSpacing:null,writingMode:null,x:null,x1:null,x2:null,xChannelSelector:null,xHeight:Q,y:null,y1:null,y2:null,yChannelSelector:null,z:null,zoomAndPan:null},space:"svg",transform:AR}),jR=fl({properties:{xLinkActuate:null,xLinkArcRole:null,xLinkHref:null,xLinkRole:null,xLinkShow:null,xLinkTitle:null,xLinkType:null},space:"xlink",transform(e,t){return"xlink:"+t.slice(5).toLowerCase()}}),DR=fl({attributes:{xmlnsxlink:"xmlns:xlink"},properties:{xmlnsXLink:null,xmlns:null},space:"xmlns",transform:LR}),OR=fl({properties:{xmlBase:null,xmlLang:null,xmlSpace:null},space:"xml",transform(e,t){return"xml:"+t.slice(3).toLowerCase()}}),FW={classId:"classID",dataType:"datatype",itemId:"itemID",strokeDashArray:"strokeDasharray",strokeDashOffset:"strokeDashoffset",strokeLineCap:"strokeLinecap",strokeLineJoin:"strokeLinejoin",strokeMiterLimit:"strokeMiterlimit",typeOf:"typeof",xLinkActuate:"xlinkActuate",xLinkArcRole:"xlinkArcrole",xLinkHref:"xlinkHref",xLinkRole:"xlinkRole",xLinkShow:"xlinkShow",xLinkTitle:"xlinkTitle",xLinkType:"xlinkType",xmlnsXLink:"xmlnsXlink"},HW=/[A-Z]/g,MS=/-[a-z]/g,UW=/^data[-\w.:]+$/i;function WW(e,t){const n=C0(t);let r=t,i=Wn;if(n in e.normal)return e.property[e.normal[n]];if(n.length>4&&n.slice(0,4)==="data"&&UW.test(t)){if(t.charAt(4)==="-"){const s=t.slice(5).replace(MS,qW);r="data"+s.charAt(0).toUpperCase()+s.slice(1)}else{const s=t.slice(4);if(!MS.test(s)){let o=s.replace(HW,VW);o.charAt(0)!=="-"&&(o="-"+o),t="data"+o}}i=Cy}return new i(r,t)}function VW(e){return"-"+e.toLowerCase()}function qW(e){return e.charAt(1).toUpperCase()}const KW=RR([MR,zW,jR,DR,OR],"html"),Ey=RR([MR,$W,jR,DR,OR],"svg");function GW(e){return e.join(" ").trim()}var Ty={},AS=/\/\*[^*]*\*+([^/*][^*]*\*+)*\//g,YW=/\n/g,XW=/^\s*/,QW=/^(\*?[-#/*\\\w]+(\[[0-9a-z_-]+\])?)\s*/,ZW=/^:\s*/,JW=/^((?:'(?:\\'|.)*?'|"(?:\\"|.)*?"|\([^)]*?\)|[^};])+)/,eV=/^[;\s]*/,tV=/^\s+|\s+$/g,nV=`
481
481
  `,LS="/",jS="*",Qs="",rV="comment",iV="declaration";function sV(e,t){if(typeof e!="string")throw new TypeError("First argument must be a string");if(!e)return[];t=t||{};var n=1,r=1;function i(m){var v=m.match(YW);v&&(n+=v.length);var b=m.lastIndexOf(nV);r=~b?m.length-b:r+m.length}function s(){var m={line:n,column:r};return function(v){return v.position=new o(m),c(),v}}function o(m){this.start=m,this.end={line:n,column:r},this.source=t.source}o.prototype.content=e;function a(m){var v=new Error(t.source+":"+n+":"+r+": "+m);if(v.reason=m,v.filename=t.source,v.line=n,v.column=r,v.source=e,!t.silent)throw v}function l(m){var v=m.exec(e);if(v){var b=v[0];return i(b),e=e.slice(b.length),v}}function c(){l(XW)}function u(m){var v;for(m=m||[];v=d();)v!==!1&&m.push(v);return m}function d(){var m=s();if(!(LS!=e.charAt(0)||jS!=e.charAt(1))){for(var v=2;Qs!=e.charAt(v)&&(jS!=e.charAt(v)||LS!=e.charAt(v+1));)++v;if(v+=2,Qs===e.charAt(v-1))return a("End of comment missing");var b=e.slice(2,v-2);return r+=2,i(b),e=e.slice(v),r+=2,m({type:rV,comment:b})}}function f(){var m=s(),v=l(QW);if(v){if(d(),!l(ZW))return a("property missing ':'");var b=l(JW),_=m({type:iV,property:DS(v[0].replace(AS,Qs)),value:b?DS(b[0].replace(AS,Qs)):Qs});return l(eV),_}}function p(){var m=[];u(m);for(var v;v=f();)v!==!1&&(m.push(v),u(m));return m}return c(),p()}function DS(e){return e?e.replace(tV,Qs):Qs}var oV=sV,aV=dh&&dh.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(Ty,"__esModule",{value:!0});Ty.default=cV;const lV=aV(oV);function cV(e,t){let n=null;if(!e||typeof e!="string")return n;const r=(0,lV.default)(e),i=typeof t=="function";return r.forEach(s=>{if(s.type!=="declaration")return;const{property:o,value:a}=s;i?t(o,a,s):a&&(n=n||{},n[o]=a)}),n}var wp={};Object.defineProperty(wp,"__esModule",{value:!0});wp.camelCase=void 0;var uV=/^--[a-zA-Z0-9_-]+$/,dV=/-([a-z])/g,hV=/^[^-]+$/,fV=/^-(webkit|moz|ms|o|khtml)-/,pV=/^-(ms)-/,mV=function(e){return!e||hV.test(e)||uV.test(e)},gV=function(e,t){return t.toUpperCase()},OS=function(e,t){return"".concat(t,"-")},vV=function(e,t){return t===void 0&&(t={}),mV(e)?e:(e=e.toLowerCase(),t.reactCompat?e=e.replace(pV,OS):e=e.replace(fV,OS),e.replace(dV,gV))};wp.camelCase=vV;var _V=dh&&dh.__importDefault||function(e){return e&&e.__esModule?e:{default:e}},xV=_V(Ty),yV=wp;function N0(e,t){var n={};return!e||typeof e!="string"||(0,xV.default)(e,function(r,i){r&&i&&(n[(0,yV.camelCase)(r,t)]=i)}),n}N0.default=N0;var bV=N0;const wV=lu(bV),BR=zR("end"),Ny=zR("start");function zR(e){return t;function t(n){const r=n&&n.position&&n.position[e]||{};if(typeof r.line=="number"&&r.line>0&&typeof r.column=="number"&&r.column>0)return{line:r.line,column:r.column,offset:typeof r.offset=="number"&&r.offset>-1?r.offset:void 0}}}function SV(e){const t=Ny(e),n=BR(e);if(t&&n)return{start:t,end:n}}function gc(e){return!e||typeof e!="object"?"":"position"in e||"type"in e?BS(e.position):"start"in e||"end"in e?BS(e):"line"in e||"column"in e?P0(e):""}function P0(e){return zS(e&&e.line)+":"+zS(e&&e.column)}function BS(e){return P0(e&&e.start)+"-"+P0(e&&e.end)}function zS(e){return e&&typeof e=="number"?e:1}class Sn extends Error{constructor(t,n,r){super(),typeof n=="string"&&(r=n,n=void 0);let i="",s={},o=!1;if(n&&("line"in n&&"column"in n?s={place:n}:"start"in n&&"end"in n?s={place:n}:"type"in n?s={ancestors:[n],place:n.position}:s={...n}),typeof t=="string"?i=t:!s.cause&&t&&(o=!0,i=t.message,s.cause=t),!s.ruleId&&!s.source&&typeof r=="string"){const l=r.indexOf(":");l===-1?s.ruleId=r:(s.source=r.slice(0,l),s.ruleId=r.slice(l+1))}if(!s.place&&s.ancestors&&s.ancestors){const l=s.ancestors[s.ancestors.length-1];l&&(s.place=l.position)}const a=s.place&&"start"in s.place?s.place.start:s.place;this.ancestors=s.ancestors||void 0,this.cause=s.cause||void 0,this.column=a?a.column:void 0,this.fatal=void 0,this.file="",this.message=i,this.line=a?a.line:void 0,this.name=gc(s.place)||"1:1",this.place=s.place||void 0,this.reason=this.message,this.ruleId=s.ruleId||void 0,this.source=s.source||void 0,this.stack=o&&s.cause&&typeof s.cause.stack=="string"?s.cause.stack:"",this.actual=void 0,this.expected=void 0,this.note=void 0,this.url=void 0}}Sn.prototype.file="";Sn.prototype.name="";Sn.prototype.reason="";Sn.prototype.message="";Sn.prototype.stack="";Sn.prototype.column=void 0;Sn.prototype.line=void 0;Sn.prototype.ancestors=void 0;Sn.prototype.cause=void 0;Sn.prototype.fatal=void 0;Sn.prototype.place=void 0;Sn.prototype.ruleId=void 0;Sn.prototype.source=void 0;const Py={}.hasOwnProperty,kV=new Map,CV=/[A-Z]/g,EV=new Set(["table","tbody","thead","tfoot","tr"]),TV=new Set(["td","th"]),$R="https://github.com/syntax-tree/hast-util-to-jsx-runtime";function NV(e,t){if(!t||t.Fragment===void 0)throw new TypeError("Expected `Fragment` in options");const n=t.filePath||void 0;let r;if(t.development){if(typeof t.jsxDEV!="function")throw new TypeError("Expected `jsxDEV` in options when `development: true`");r=DV(n,t.jsxDEV)}else{if(typeof t.jsx!="function")throw new TypeError("Expected `jsx` in production options");if(typeof t.jsxs!="function")throw new TypeError("Expected `jsxs` in production options");r=jV(n,t.jsx,t.jsxs)}const i={Fragment:t.Fragment,ancestors:[],components:t.components||{},create:r,elementAttributeNameCase:t.elementAttributeNameCase||"react",evaluater:t.createEvaluater?t.createEvaluater():void 0,filePath:n,ignoreInvalidStyle:t.ignoreInvalidStyle||!1,passKeys:t.passKeys!==!1,passNode:t.passNode||!1,schema:t.space==="svg"?Ey:KW,stylePropertyNameCase:t.stylePropertyNameCase||"dom",tableCellAlignToStyle:t.tableCellAlignToStyle!==!1},s=FR(i,e,void 0);return s&&typeof s!="string"?s:i.create(e,i.Fragment,{children:s||void 0},void 0)}function FR(e,t,n){if(t.type==="element")return PV(e,t,n);if(t.type==="mdxFlowExpression"||t.type==="mdxTextExpression")return IV(e,t);if(t.type==="mdxJsxFlowElement"||t.type==="mdxJsxTextElement")return MV(e,t,n);if(t.type==="mdxjsEsm")return RV(e,t);if(t.type==="root")return AV(e,t,n);if(t.type==="text")return LV(e,t)}function PV(e,t,n){const r=e.schema;let i=r;t.tagName.toLowerCase()==="svg"&&r.space==="html"&&(i=Ey,e.schema=i),e.ancestors.push(t);const s=UR(e,t.tagName,!1),o=OV(e,t);let a=Ry(e,t);return EV.has(t.tagName)&&(a=a.filter(function(l){return typeof l=="string"?!OW(l):!0})),HR(e,o,s,t),Iy(o,a),e.ancestors.pop(),e.schema=r,e.create(t,s,o,n)}function IV(e,t){if(t.data&&t.data.estree&&e.evaluater){const r=t.data.estree.body[0];return r.type,e.evaluater.evaluateExpression(r.expression)}eu(e,t.position)}function RV(e,t){if(t.data&&t.data.estree&&e.evaluater)return e.evaluater.evaluateProgram(t.data.estree);eu(e,t.position)}function MV(e,t,n){const r=e.schema;let i=r;t.name==="svg"&&r.space==="html"&&(i=Ey,e.schema=i),e.ancestors.push(t);const s=t.name===null?e.Fragment:UR(e,t.name,!0),o=BV(e,t),a=Ry(e,t);return HR(e,o,s,t),Iy(o,a),e.ancestors.pop(),e.schema=r,e.create(t,s,o,n)}function AV(e,t,n){const r={};return Iy(r,Ry(e,t)),e.create(t,e.Fragment,r,n)}function LV(e,t){return t.value}function HR(e,t,n,r){typeof n!="string"&&n!==e.Fragment&&e.passNode&&(t.node=r)}function Iy(e,t){if(t.length>0){const n=t.length>1?t:t[0];n&&(e.children=n)}}function jV(e,t,n){return r;function r(i,s,o,a){const c=Array.isArray(o.children)?n:t;return a?c(s,o,a):c(s,o)}}function DV(e,t){return n;function n(r,i,s,o){const a=Array.isArray(s.children),l=Ny(r);return t(i,s,o,a,{columnNumber:l?l.column-1:void 0,fileName:e,lineNumber:l?l.line:void 0},void 0)}}function OV(e,t){const n={};let r,i;for(i in t.properties)if(i!=="children"&&Py.call(t.properties,i)){const s=zV(e,i,t.properties[i]);if(s){const[o,a]=s;e.tableCellAlignToStyle&&o==="align"&&typeof a=="string"&&TV.has(t.tagName)?r=a:n[o]=a}}if(r){const s=n.style||(n.style={});s[e.stylePropertyNameCase==="css"?"text-align":"textAlign"]=r}return n}function BV(e,t){const n={};for(const r of t.attributes)if(r.type==="mdxJsxExpressionAttribute")if(r.data&&r.data.estree&&e.evaluater){const s=r.data.estree.body[0];s.type;const o=s.expression;o.type;const a=o.properties[0];a.type,Object.assign(n,e.evaluater.evaluateExpression(a.argument))}else eu(e,t.position);else{const i=r.name;let s;if(r.value&&typeof r.value=="object")if(r.value.data&&r.value.data.estree&&e.evaluater){const a=r.value.data.estree.body[0];a.type,s=e.evaluater.evaluateExpression(a.expression)}else eu(e,t.position);else s=r.value===null?!0:r.value;n[i]=s}return n}function Ry(e,t){const n=[];let r=-1;const i=e.passKeys?new Map:kV;for(;++r<t.children.length;){const s=t.children[r];let o;if(e.passKeys){const l=s.type==="element"?s.tagName:s.type==="mdxJsxFlowElement"||s.type==="mdxJsxTextElement"?s.name:void 0;if(l){const c=i.get(l)||0;o=l+"-"+c,i.set(l,c+1)}}const a=FR(e,s,o);a!==void 0&&n.push(a)}return n}function zV(e,t,n){const r=WW(e.schema,t);if(!(n==null||typeof n=="number"&&Number.isNaN(n))){if(Array.isArray(n)&&(n=r.commaSeparated?MW(n):GW(n)),r.property==="style"){let i=typeof n=="object"?n:$V(e,String(n));return e.stylePropertyNameCase==="css"&&(i=FV(i)),["style",i]}return[e.elementAttributeNameCase==="react"&&r.space?FW[r.property]||r.property:r.attribute,n]}}function $V(e,t){try{return wV(t,{reactCompat:!0})}catch(n){if(e.ignoreInvalidStyle)return{};const r=n,i=new Sn("Cannot parse `style` attribute",{ancestors:e.ancestors,cause:r,ruleId:"style",source:"hast-util-to-jsx-runtime"});throw i.file=e.filePath||void 0,i.url=$R+"#cannot-parse-style-attribute",i}}function UR(e,t,n){let r;if(!n)r={type:"Literal",value:t};else if(t.includes(".")){const i=t.split(".");let s=-1,o;for(;++s<i.length;){const a=PS(i[s])?{type:"Identifier",name:i[s]}:{type:"Literal",value:i[s]};o=o?{type:"MemberExpression",object:o,property:a,computed:!!(s&&a.type==="Literal"),optional:!1}:a}r=o}else r=PS(t)&&!/^[a-z]/.test(t)?{type:"Identifier",name:t}:{type:"Literal",value:t};if(r.type==="Literal"){const i=r.value;return Py.call(e.components,i)?e.components[i]:i}if(e.evaluater)return e.evaluater.evaluateExpression(r);eu(e)}function eu(e,t){const n=new Sn("Cannot handle MDX estrees without `createEvaluater`",{ancestors:e.ancestors,place:t,ruleId:"mdx-estree",source:"hast-util-to-jsx-runtime"});throw n.file=e.filePath||void 0,n.url=$R+"#cannot-handle-mdx-estrees-without-createevaluater",n}function FV(e){const t={};let n;for(n in e)Py.call(e,n)&&(t[HV(n)]=e[n]);return t}function HV(e){let t=e.replace(CV,UV);return t.slice(0,3)==="ms-"&&(t="-"+t),t}function UV(e){return"-"+e.toLowerCase()}const Um={action:["form"],cite:["blockquote","del","ins","q"],data:["object"],formAction:["button","input"],href:["a","area","base","link"],icon:["menuitem"],itemId:null,manifest:["html"],ping:["a","area"],poster:["video"],src:["audio","embed","iframe","img","input","script","source","track","video"]},WV={};function My(e,t){const n=WV,r=typeof n.includeImageAlt=="boolean"?n.includeImageAlt:!0,i=typeof n.includeHtml=="boolean"?n.includeHtml:!0;return WR(e,r,i)}function WR(e,t,n){if(VV(e)){if("value"in e)return e.type==="html"&&!n?"":e.value;if(t&&"alt"in e&&e.alt)return e.alt;if("children"in e)return $S(e.children,t,n)}return Array.isArray(e)?$S(e,t,n):""}function $S(e,t,n){const r=[];let i=-1;for(;++i<e.length;)r[i]=WR(e[i],t,n);return r.join("")}function VV(e){return!!(e&&typeof e=="object")}const FS=document.createElement("i");function Ay(e){const t="&"+e+";";FS.innerHTML=t;const n=FS.textContent;return n.charCodeAt(n.length-1)===59&&e!=="semi"||n===t?!1:n}function er(e,t,n,r){const i=e.length;let s=0,o;if(t<0?t=-t>i?0:i+t:t=t>i?i:t,n=n>0?n:0,r.length<1e4)o=Array.from(r),o.unshift(t,n),e.splice(...o);else for(n&&e.splice(t,n);s<r.length;)o=r.slice(s,s+1e4),o.unshift(t,0),e.splice(...o),s+=1e4,t+=1e4}function fr(e,t){return e.length>0?(er(e,e.length,0,t),e):t}const HS={}.hasOwnProperty;function VR(e){const t={};let n=-1;for(;++n<e.length;)qV(t,e[n]);return t}function qV(e,t){let n;for(n in t){const i=(HS.call(e,n)?e[n]:void 0)||(e[n]={}),s=t[n];let o;if(s)for(o in s){HS.call(i,o)||(i[o]=[]);const a=s[o];KV(i[o],Array.isArray(a)?a:a?[a]:[])}}}function KV(e,t){let n=-1;const r=[];for(;++n<t.length;)(t[n].add==="after"?e:r).push(t[n]);er(e,0,0,r)}function qR(e,t){const n=Number.parseInt(e,t);return n<9||n===11||n>13&&n<32||n>126&&n<160||n>55295&&n<57344||n>64975&&n<65008||(n&65535)===65535||(n&65535)===65534||n>1114111?"�":String.fromCodePoint(n)}function Mr(e){return e.replace(/[\t\n\r ]+/g," ").replace(/^ | $/g,"").toLowerCase().toUpperCase()}const En=Os(/[A-Za-z]/),yn=Os(/[\dA-Za-z]/),GV=Os(/[#-'*+\--9=?A-Z^-~]/);function of(e){return e!==null&&(e<32||e===127)}const I0=Os(/\d/),YV=Os(/[\dA-Fa-f]/),XV=Os(/[!-/:-@[-`{-~]/);function be(e){return e!==null&&e<-2}function ot(e){return e!==null&&(e<0||e===32)}function Ue(e){return e===-2||e===-1||e===32}const Sp=Os(new RegExp("\\p{P}|\\p{S}","u")),wo=Os(/\s/);function Os(e){return t;function t(n){return n!==null&&n>-1&&e.test(String.fromCharCode(n))}}function pl(e){const t=[];let n=-1,r=0,i=0;for(;++n<e.length;){const s=e.charCodeAt(n);let o="";if(s===37&&yn(e.charCodeAt(n+1))&&yn(e.charCodeAt(n+2)))i=2;else if(s<128)/[!#$&-;=?-Z_a-z~]/.test(String.fromCharCode(s))||(o=String.fromCharCode(s));else if(s>55295&&s<57344){const a=e.charCodeAt(n+1);s<56320&&a>56319&&a<57344?(o=String.fromCharCode(s,a),i=1):o="�"}else o=String.fromCharCode(s);o&&(t.push(e.slice(r,n),encodeURIComponent(o)),r=n+i+1,o=""),i&&(n+=i,i=0)}return t.join("")+e.slice(r)}function Ge(e,t,n,r){const i=r?r-1:Number.POSITIVE_INFINITY;let s=0;return o;function o(l){return Ue(l)?(e.enter(n),a(l)):t(l)}function a(l){return Ue(l)&&s++<i?(e.consume(l),a):(e.exit(n),t(l))}}const QV={tokenize:ZV};function ZV(e){const t=e.attempt(this.parser.constructs.contentInitial,r,i);let n;return t;function r(a){if(a===null){e.consume(a);return}return e.enter("lineEnding"),e.consume(a),e.exit("lineEnding"),Ge(e,t,"linePrefix")}function i(a){return e.enter("paragraph"),s(a)}function s(a){const l=e.enter("chunkText",{contentType:"text",previous:n});return n&&(n.next=l),n=l,o(a)}function o(a){if(a===null){e.exit("chunkText"),e.exit("paragraph"),e.consume(a);return}return be(a)?(e.consume(a),e.exit("chunkText"),s):(e.consume(a),o)}}const JV={tokenize:eq},US={tokenize:tq};function eq(e){const t=this,n=[];let r=0,i,s,o;return a;function a(y){if(r<n.length){const w=n[r];return t.containerState=w[1],e.attempt(w[0].continuation,l,c)(y)}return c(y)}function l(y){if(r++,t.containerState._closeFlow){t.containerState._closeFlow=void 0,i&&x();const w=t.events.length;let C=w,k;for(;C--;)if(t.events[C][0]==="exit"&&t.events[C][1].type==="chunkFlow"){k=t.events[C][1].end;break}_(r);let T=w;for(;T<t.events.length;)t.events[T][1].end={...k},T++;return er(t.events,C+1,0,t.events.slice(w)),t.events.length=T,c(y)}return a(y)}function c(y){if(r===n.length){if(!i)return f(y);if(i.currentConstruct&&i.currentConstruct.concrete)return m(y);t.interrupt=!!(i.currentConstruct&&!i._gfmTableDynamicInterruptHack)}return t.containerState={},e.check(US,u,d)(y)}function u(y){return i&&x(),_(r),f(y)}function d(y){return t.parser.lazy[t.now().line]=r!==n.length,o=t.now().offset,m(y)}function f(y){return t.containerState={},e.attempt(US,p,m)(y)}function p(y){return r++,n.push([t.currentConstruct,t.containerState]),f(y)}function m(y){if(y===null){i&&x(),_(0),e.consume(y);return}return i=i||t.parser.flow(t.now()),e.enter("chunkFlow",{_tokenizer:i,contentType:"flow",previous:s}),v(y)}function v(y){if(y===null){b(e.exit("chunkFlow"),!0),_(0),e.consume(y);return}return be(y)?(e.consume(y),b(e.exit("chunkFlow")),r=0,t.interrupt=void 0,a):(e.consume(y),v)}function b(y,w){const C=t.sliceStream(y);if(w&&C.push(null),y.previous=s,s&&(s.next=y),s=y,i.defineSkip(y.start),i.write(C),t.parser.lazy[y.start.line]){let k=i.events.length;for(;k--;)if(i.events[k][1].start.offset<o&&(!i.events[k][1].end||i.events[k][1].end.offset>o))return;const T=t.events.length;let N=T,z,P;for(;N--;)if(t.events[N][0]==="exit"&&t.events[N][1].type==="chunkFlow"){if(z){P=t.events[N][1].end;break}z=!0}for(_(r),k=T;k<t.events.length;)t.events[k][1].end={...P},k++;er(t.events,N+1,0,t.events.slice(T)),t.events.length=k}}function _(y){let w=n.length;for(;w-- >y;){const C=n[w];t.containerState=C[1],C[0].exit.call(t,e)}n.length=y}function x(){i.write([null]),s=void 0,i=void 0,t.containerState._closeFlow=void 0}}function tq(e,t,n){return Ge(e,e.attempt(this.parser.constructs.document,t,n),"linePrefix",this.parser.constructs.disable.null.includes("codeIndented")?void 0:4)}function Wa(e){if(e===null||ot(e)||wo(e))return 1;if(Sp(e))return 2}function kp(e,t,n){const r=[];let i=-1;for(;++i<e.length;){const s=e[i].resolveAll;s&&!r.includes(s)&&(t=s(t,n),r.push(s))}return t}const R0={name:"attention",resolveAll:nq,tokenize:rq};function nq(e,t){let n=-1,r,i,s,o,a,l,c,u;for(;++n<e.length;)if(e[n][0]==="enter"&&e[n][1].type==="attentionSequence"&&e[n][1]._close){for(r=n;r--;)if(e[r][0]==="exit"&&e[r][1].type==="attentionSequence"&&e[r][1]._open&&t.sliceSerialize(e[r][1]).charCodeAt(0)===t.sliceSerialize(e[n][1]).charCodeAt(0)){if((e[r][1]._close||e[n][1]._open)&&(e[n][1].end.offset-e[n][1].start.offset)%3&&!((e[r][1].end.offset-e[r][1].start.offset+e[n][1].end.offset-e[n][1].start.offset)%3))continue;l=e[r][1].end.offset-e[r][1].start.offset>1&&e[n][1].end.offset-e[n][1].start.offset>1?2:1;const d={...e[r][1].end},f={...e[n][1].start};WS(d,-l),WS(f,l),o={type:l>1?"strongSequence":"emphasisSequence",start:d,end:{...e[r][1].end}},a={type:l>1?"strongSequence":"emphasisSequence",start:{...e[n][1].start},end:f},s={type:l>1?"strongText":"emphasisText",start:{...e[r][1].end},end:{...e[n][1].start}},i={type:l>1?"strong":"emphasis",start:{...o.start},end:{...a.end}},e[r][1].end={...o.start},e[n][1].start={...a.end},c=[],e[r][1].end.offset-e[r][1].start.offset&&(c=fr(c,[["enter",e[r][1],t],["exit",e[r][1],t]])),c=fr(c,[["enter",i,t],["enter",o,t],["exit",o,t],["enter",s,t]]),c=fr(c,kp(t.parser.constructs.insideSpan.null,e.slice(r+1,n),t)),c=fr(c,[["exit",s,t],["enter",a,t],["exit",a,t],["exit",i,t]]),e[n][1].end.offset-e[n][1].start.offset?(u=2,c=fr(c,[["enter",e[n][1],t],["exit",e[n][1],t]])):u=0,er(e,r-1,n-r+3,c),n=r+c.length-u-2;break}}for(n=-1;++n<e.length;)e[n][1].type==="attentionSequence"&&(e[n][1].type="data");return e}function rq(e,t){const n=this.parser.constructs.attentionMarkers.null,r=this.previous,i=Wa(r);let s;return o;function o(l){return s=l,e.enter("attentionSequence"),a(l)}function a(l){if(l===s)return e.consume(l),a;const c=e.exit("attentionSequence"),u=Wa(l),d=!u||u===2&&i||n.includes(l),f=!i||i===2&&u||n.includes(r);return c._open=!!(s===42?d:d&&(i||!f)),c._close=!!(s===42?f:f&&(u||!d)),t(l)}}function WS(e,t){e.column+=t,e.offset+=t,e._bufferIndex+=t}const iq={name:"autolink",tokenize:sq};function sq(e,t,n){let r=0;return i;function i(p){return e.enter("autolink"),e.enter("autolinkMarker"),e.consume(p),e.exit("autolinkMarker"),e.enter("autolinkProtocol"),s}function s(p){return En(p)?(e.consume(p),o):p===64?n(p):c(p)}function o(p){return p===43||p===45||p===46||yn(p)?(r=1,a(p)):c(p)}function a(p){return p===58?(e.consume(p),r=0,l):(p===43||p===45||p===46||yn(p))&&r++<32?(e.consume(p),a):(r=0,c(p))}function l(p){return p===62?(e.exit("autolinkProtocol"),e.enter("autolinkMarker"),e.consume(p),e.exit("autolinkMarker"),e.exit("autolink"),t):p===null||p===32||p===60||of(p)?n(p):(e.consume(p),l)}function c(p){return p===64?(e.consume(p),u):GV(p)?(e.consume(p),c):n(p)}function u(p){return yn(p)?d(p):n(p)}function d(p){return p===46?(e.consume(p),r=0,u):p===62?(e.exit("autolinkProtocol").type="autolinkEmail",e.enter("autolinkMarker"),e.consume(p),e.exit("autolinkMarker"),e.exit("autolink"),t):f(p)}function f(p){if((p===45||yn(p))&&r++<63){const m=p===45?f:d;return e.consume(p),m}return n(p)}}const Tu={partial:!0,tokenize:oq};function oq(e,t,n){return r;function r(s){return Ue(s)?Ge(e,i,"linePrefix")(s):i(s)}function i(s){return s===null||be(s)?t(s):n(s)}}const KR={continuation:{tokenize:lq},exit:cq,name:"blockQuote",tokenize:aq};function aq(e,t,n){const r=this;return i;function i(o){if(o===62){const a=r.containerState;return a.open||(e.enter("blockQuote",{_container:!0}),a.open=!0),e.enter("blockQuotePrefix"),e.enter("blockQuoteMarker"),e.consume(o),e.exit("blockQuoteMarker"),s}return n(o)}function s(o){return Ue(o)?(e.enter("blockQuotePrefixWhitespace"),e.consume(o),e.exit("blockQuotePrefixWhitespace"),e.exit("blockQuotePrefix"),t):(e.exit("blockQuotePrefix"),t(o))}}function lq(e,t,n){const r=this;return i;function i(o){return Ue(o)?Ge(e,s,"linePrefix",r.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(o):s(o)}function s(o){return e.attempt(KR,t,n)(o)}}function cq(e){e.exit("blockQuote")}const GR={name:"characterEscape",tokenize:uq};function uq(e,t,n){return r;function r(s){return e.enter("characterEscape"),e.enter("escapeMarker"),e.consume(s),e.exit("escapeMarker"),i}function i(s){return XV(s)?(e.enter("characterEscapeValue"),e.consume(s),e.exit("characterEscapeValue"),e.exit("characterEscape"),t):n(s)}}const YR={name:"characterReference",tokenize:dq};function dq(e,t,n){const r=this;let i=0,s,o;return a;function a(d){return e.enter("characterReference"),e.enter("characterReferenceMarker"),e.consume(d),e.exit("characterReferenceMarker"),l}function l(d){return d===35?(e.enter("characterReferenceMarkerNumeric"),e.consume(d),e.exit("characterReferenceMarkerNumeric"),c):(e.enter("characterReferenceValue"),s=31,o=yn,u(d))}function c(d){return d===88||d===120?(e.enter("characterReferenceMarkerHexadecimal"),e.consume(d),e.exit("characterReferenceMarkerHexadecimal"),e.enter("characterReferenceValue"),s=6,o=YV,u):(e.enter("characterReferenceValue"),s=7,o=I0,u(d))}function u(d){if(d===59&&i){const f=e.exit("characterReferenceValue");return o===yn&&!Ay(r.sliceSerialize(f))?n(d):(e.enter("characterReferenceMarker"),e.consume(d),e.exit("characterReferenceMarker"),e.exit("characterReference"),t)}return o(d)&&i++<s?(e.consume(d),u):n(d)}}const VS={partial:!0,tokenize:fq},qS={concrete:!0,name:"codeFenced",tokenize:hq};function hq(e,t,n){const r=this,i={partial:!0,tokenize:C};let s=0,o=0,a;return l;function l(k){return c(k)}function c(k){const T=r.events[r.events.length-1];return s=T&&T[1].type==="linePrefix"?T[2].sliceSerialize(T[1],!0).length:0,a=k,e.enter("codeFenced"),e.enter("codeFencedFence"),e.enter("codeFencedFenceSequence"),u(k)}function u(k){return k===a?(o++,e.consume(k),u):o<3?n(k):(e.exit("codeFencedFenceSequence"),Ue(k)?Ge(e,d,"whitespace")(k):d(k))}function d(k){return k===null||be(k)?(e.exit("codeFencedFence"),r.interrupt?t(k):e.check(VS,v,w)(k)):(e.enter("codeFencedFenceInfo"),e.enter("chunkString",{contentType:"string"}),f(k))}function f(k){return k===null||be(k)?(e.exit("chunkString"),e.exit("codeFencedFenceInfo"),d(k)):Ue(k)?(e.exit("chunkString"),e.exit("codeFencedFenceInfo"),Ge(e,p,"whitespace")(k)):k===96&&k===a?n(k):(e.consume(k),f)}function p(k){return k===null||be(k)?d(k):(e.enter("codeFencedFenceMeta"),e.enter("chunkString",{contentType:"string"}),m(k))}function m(k){return k===null||be(k)?(e.exit("chunkString"),e.exit("codeFencedFenceMeta"),d(k)):k===96&&k===a?n(k):(e.consume(k),m)}function v(k){return e.attempt(i,w,b)(k)}function b(k){return e.enter("lineEnding"),e.consume(k),e.exit("lineEnding"),_}function _(k){return s>0&&Ue(k)?Ge(e,x,"linePrefix",s+1)(k):x(k)}function x(k){return k===null||be(k)?e.check(VS,v,w)(k):(e.enter("codeFlowValue"),y(k))}function y(k){return k===null||be(k)?(e.exit("codeFlowValue"),x(k)):(e.consume(k),y)}function w(k){return e.exit("codeFenced"),t(k)}function C(k,T,N){let z=0;return P;function P(L){return k.enter("lineEnding"),k.consume(L),k.exit("lineEnding"),B}function B(L){return k.enter("codeFencedFence"),Ue(L)?Ge(k,R,"linePrefix",r.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(L):R(L)}function R(L){return L===a?(k.enter("codeFencedFenceSequence"),I(L)):N(L)}function I(L){return L===a?(z++,k.consume(L),I):z>=o?(k.exit("codeFencedFenceSequence"),Ue(L)?Ge(k,j,"whitespace")(L):j(L)):N(L)}function j(L){return L===null||be(L)?(k.exit("codeFencedFence"),T(L)):N(L)}}}function fq(e,t,n){const r=this;return i;function i(o){return o===null?n(o):(e.enter("lineEnding"),e.consume(o),e.exit("lineEnding"),s)}function s(o){return r.parser.lazy[r.now().line]?n(o):t(o)}}const Wm={name:"codeIndented",tokenize:mq},pq={partial:!0,tokenize:gq};function mq(e,t,n){const r=this;return i;function i(c){return e.enter("codeIndented"),Ge(e,s,"linePrefix",5)(c)}function s(c){const u=r.events[r.events.length-1];return u&&u[1].type==="linePrefix"&&u[2].sliceSerialize(u[1],!0).length>=4?o(c):n(c)}function o(c){return c===null?l(c):be(c)?e.attempt(pq,o,l)(c):(e.enter("codeFlowValue"),a(c))}function a(c){return c===null||be(c)?(e.exit("codeFlowValue"),o(c)):(e.consume(c),a)}function l(c){return e.exit("codeIndented"),t(c)}}function gq(e,t,n){const r=this;return i;function i(o){return r.parser.lazy[r.now().line]?n(o):be(o)?(e.enter("lineEnding"),e.consume(o),e.exit("lineEnding"),i):Ge(e,s,"linePrefix",5)(o)}function s(o){const a=r.events[r.events.length-1];return a&&a[1].type==="linePrefix"&&a[2].sliceSerialize(a[1],!0).length>=4?t(o):be(o)?i(o):n(o)}}const vq={name:"codeText",previous:xq,resolve:_q,tokenize:yq};function _q(e){let t=e.length-4,n=3,r,i;if((e[n][1].type==="lineEnding"||e[n][1].type==="space")&&(e[t][1].type==="lineEnding"||e[t][1].type==="space")){for(r=n;++r<t;)if(e[r][1].type==="codeTextData"){e[n][1].type="codeTextPadding",e[t][1].type="codeTextPadding",n+=2,t-=2;break}}for(r=n-1,t++;++r<=t;)i===void 0?r!==t&&e[r][1].type!=="lineEnding"&&(i=r):(r===t||e[r][1].type==="lineEnding")&&(e[i][1].type="codeTextData",r!==i+2&&(e[i][1].end=e[r-1][1].end,e.splice(i+2,r-i-2),t-=r-i-2,r=i+2),i=void 0);return e}function xq(e){return e!==96||this.events[this.events.length-1][1].type==="characterEscape"}function yq(e,t,n){let r=0,i,s;return o;function o(d){return e.enter("codeText"),e.enter("codeTextSequence"),a(d)}function a(d){return d===96?(e.consume(d),r++,a):(e.exit("codeTextSequence"),l(d))}function l(d){return d===null?n(d):d===32?(e.enter("space"),e.consume(d),e.exit("space"),l):d===96?(s=e.enter("codeTextSequence"),i=0,u(d)):be(d)?(e.enter("lineEnding"),e.consume(d),e.exit("lineEnding"),l):(e.enter("codeTextData"),c(d))}function c(d){return d===null||d===32||d===96||be(d)?(e.exit("codeTextData"),l(d)):(e.consume(d),c)}function u(d){return d===96?(e.consume(d),i++,u):i===r?(e.exit("codeTextSequence"),e.exit("codeText"),t(d)):(s.type="codeTextData",c(d))}}class bq{constructor(t){this.left=t?[...t]:[],this.right=[]}get(t){if(t<0||t>=this.left.length+this.right.length)throw new RangeError("Cannot access index `"+t+"` in a splice buffer of size `"+(this.left.length+this.right.length)+"`");return t<this.left.length?this.left[t]:this.right[this.right.length-t+this.left.length-1]}get length(){return this.left.length+this.right.length}shift(){return this.setCursor(0),this.right.pop()}slice(t,n){const r=n??Number.POSITIVE_INFINITY;return r<this.left.length?this.left.slice(t,r):t>this.left.length?this.right.slice(this.right.length-r+this.left.length,this.right.length-t+this.left.length).reverse():this.left.slice(t).concat(this.right.slice(this.right.length-r+this.left.length).reverse())}splice(t,n,r){const i=n||0;this.setCursor(Math.trunc(t));const s=this.right.splice(this.right.length-i,Number.POSITIVE_INFINITY);return r&&Ll(this.left,r),s.reverse()}pop(){return this.setCursor(Number.POSITIVE_INFINITY),this.left.pop()}push(t){this.setCursor(Number.POSITIVE_INFINITY),this.left.push(t)}pushMany(t){this.setCursor(Number.POSITIVE_INFINITY),Ll(this.left,t)}unshift(t){this.setCursor(0),this.right.push(t)}unshiftMany(t){this.setCursor(0),Ll(this.right,t.reverse())}setCursor(t){if(!(t===this.left.length||t>this.left.length&&this.right.length===0||t<0&&this.left.length===0))if(t<this.left.length){const n=this.left.splice(t,Number.POSITIVE_INFINITY);Ll(this.right,n.reverse())}else{const n=this.right.splice(this.left.length+this.right.length-t,Number.POSITIVE_INFINITY);Ll(this.left,n.reverse())}}}function Ll(e,t){let n=0;if(t.length<1e4)e.push(...t);else for(;n<t.length;)e.push(...t.slice(n,n+1e4)),n+=1e4}function XR(e){const t={};let n=-1,r,i,s,o,a,l,c;const u=new bq(e);for(;++n<u.length;){for(;n in t;)n=t[n];if(r=u.get(n),n&&r[1].type==="chunkFlow"&&u.get(n-1)[1].type==="listItemPrefix"&&(l=r[1]._tokenizer.events,s=0,s<l.length&&l[s][1].type==="lineEndingBlank"&&(s+=2),s<l.length&&l[s][1].type==="content"))for(;++s<l.length&&l[s][1].type!=="content";)l[s][1].type==="chunkText"&&(l[s][1]._isInFirstContentOfListItem=!0,s++);if(r[0]==="enter")r[1].contentType&&(Object.assign(t,wq(u,n)),n=t[n],c=!0);else if(r[1]._container){for(s=n,i=void 0;s--;)if(o=u.get(s),o[1].type==="lineEnding"||o[1].type==="lineEndingBlank")o[0]==="enter"&&(i&&(u.get(i)[1].type="lineEndingBlank"),o[1].type="lineEnding",i=s);else if(!(o[1].type==="linePrefix"||o[1].type==="listItemIndent"))break;i&&(r[1].end={...u.get(i)[1].start},a=u.slice(i,n),a.unshift(r),u.splice(i,n-i+1,a))}}return er(e,0,Number.POSITIVE_INFINITY,u.slice(0)),!c}function wq(e,t){const n=e.get(t)[1],r=e.get(t)[2];let i=t-1;const s=[];let o=n._tokenizer;o||(o=r.parser[n.contentType](n.start),n._contentTypeTextTrailing&&(o._contentTypeTextTrailing=!0));const a=o.events,l=[],c={};let u,d,f=-1,p=n,m=0,v=0;const b=[v];for(;p;){for(;e.get(++i)[1]!==p;);s.push(i),p._tokenizer||(u=r.sliceStream(p),p.next||u.push(null),d&&o.defineSkip(p.start),p._isInFirstContentOfListItem&&(o._gfmTasklistFirstContentOfListItem=!0),o.write(u),p._isInFirstContentOfListItem&&(o._gfmTasklistFirstContentOfListItem=void 0)),d=p,p=p.next}for(p=n;++f<a.length;)a[f][0]==="exit"&&a[f-1][0]==="enter"&&a[f][1].type===a[f-1][1].type&&a[f][1].start.line!==a[f][1].end.line&&(v=f+1,b.push(v),p._tokenizer=void 0,p.previous=void 0,p=p.next);for(o.events=[],p?(p._tokenizer=void 0,p.previous=void 0):b.pop(),f=b.length;f--;){const _=a.slice(b[f],b[f+1]),x=s.pop();l.push([x,x+_.length-1]),e.splice(x,2,_)}for(l.reverse(),f=-1;++f<l.length;)c[m+l[f][0]]=m+l[f][1],m+=l[f][1]-l[f][0]-1;return c}const Sq={resolve:Cq,tokenize:Eq},kq={partial:!0,tokenize:Tq};function Cq(e){return XR(e),e}function Eq(e,t){let n;return r;function r(a){return e.enter("content"),n=e.enter("chunkContent",{contentType:"content"}),i(a)}function i(a){return a===null?s(a):be(a)?e.check(kq,o,s)(a):(e.consume(a),i)}function s(a){return e.exit("chunkContent"),e.exit("content"),t(a)}function o(a){return e.consume(a),e.exit("chunkContent"),n.next=e.enter("chunkContent",{contentType:"content",previous:n}),n=n.next,i}}function Tq(e,t,n){const r=this;return i;function i(o){return e.exit("chunkContent"),e.enter("lineEnding"),e.consume(o),e.exit("lineEnding"),Ge(e,s,"linePrefix")}function s(o){if(o===null||be(o))return n(o);const a=r.events[r.events.length-1];return!r.parser.constructs.disable.null.includes("codeIndented")&&a&&a[1].type==="linePrefix"&&a[2].sliceSerialize(a[1],!0).length>=4?t(o):e.interrupt(r.parser.constructs.flow,n,t)(o)}}function QR(e,t,n,r,i,s,o,a,l){const c=l||Number.POSITIVE_INFINITY;let u=0;return d;function d(_){return _===60?(e.enter(r),e.enter(i),e.enter(s),e.consume(_),e.exit(s),f):_===null||_===32||_===41||of(_)?n(_):(e.enter(r),e.enter(o),e.enter(a),e.enter("chunkString",{contentType:"string"}),v(_))}function f(_){return _===62?(e.enter(s),e.consume(_),e.exit(s),e.exit(i),e.exit(r),t):(e.enter(a),e.enter("chunkString",{contentType:"string"}),p(_))}function p(_){return _===62?(e.exit("chunkString"),e.exit(a),f(_)):_===null||_===60||be(_)?n(_):(e.consume(_),_===92?m:p)}function m(_){return _===60||_===62||_===92?(e.consume(_),p):p(_)}function v(_){return!u&&(_===null||_===41||ot(_))?(e.exit("chunkString"),e.exit(a),e.exit(o),e.exit(r),t(_)):u<c&&_===40?(e.consume(_),u++,v):_===41?(e.consume(_),u--,v):_===null||_===32||_===40||of(_)?n(_):(e.consume(_),_===92?b:v)}function b(_){return _===40||_===41||_===92?(e.consume(_),v):v(_)}}function ZR(e,t,n,r,i,s){const o=this;let a=0,l;return c;function c(p){return e.enter(r),e.enter(i),e.consume(p),e.exit(i),e.enter(s),u}function u(p){return a>999||p===null||p===91||p===93&&!l||p===94&&!a&&"_hiddenFootnoteSupport"in o.parser.constructs?n(p):p===93?(e.exit(s),e.enter(i),e.consume(p),e.exit(i),e.exit(r),t):be(p)?(e.enter("lineEnding"),e.consume(p),e.exit("lineEnding"),u):(e.enter("chunkString",{contentType:"string"}),d(p))}function d(p){return p===null||p===91||p===93||be(p)||a++>999?(e.exit("chunkString"),u(p)):(e.consume(p),l||(l=!Ue(p)),p===92?f:d)}function f(p){return p===91||p===92||p===93?(e.consume(p),a++,d):d(p)}}function JR(e,t,n,r,i,s){let o;return a;function a(f){return f===34||f===39||f===40?(e.enter(r),e.enter(i),e.consume(f),e.exit(i),o=f===40?41:f,l):n(f)}function l(f){return f===o?(e.enter(i),e.consume(f),e.exit(i),e.exit(r),t):(e.enter(s),c(f))}function c(f){return f===o?(e.exit(s),l(o)):f===null?n(f):be(f)?(e.enter("lineEnding"),e.consume(f),e.exit("lineEnding"),Ge(e,c,"linePrefix")):(e.enter("chunkString",{contentType:"string"}),u(f))}function u(f){return f===o||f===null||be(f)?(e.exit("chunkString"),c(f)):(e.consume(f),f===92?d:u)}function d(f){return f===o||f===92?(e.consume(f),u):u(f)}}function vc(e,t){let n;return r;function r(i){return be(i)?(e.enter("lineEnding"),e.consume(i),e.exit("lineEnding"),n=!0,r):Ue(i)?Ge(e,r,n?"linePrefix":"lineSuffix")(i):t(i)}}const Nq={name:"definition",tokenize:Iq},Pq={partial:!0,tokenize:Rq};function Iq(e,t,n){const r=this;let i;return s;function s(p){return e.enter("definition"),o(p)}function o(p){return ZR.call(r,e,a,n,"definitionLabel","definitionLabelMarker","definitionLabelString")(p)}function a(p){return i=Mr(r.sliceSerialize(r.events[r.events.length-1][1]).slice(1,-1)),p===58?(e.enter("definitionMarker"),e.consume(p),e.exit("definitionMarker"),l):n(p)}function l(p){return ot(p)?vc(e,c)(p):c(p)}function c(p){return QR(e,u,n,"definitionDestination","definitionDestinationLiteral","definitionDestinationLiteralMarker","definitionDestinationRaw","definitionDestinationString")(p)}function u(p){return e.attempt(Pq,d,d)(p)}function d(p){return Ue(p)?Ge(e,f,"whitespace")(p):f(p)}function f(p){return p===null||be(p)?(e.exit("definition"),r.parser.defined.push(i),t(p)):n(p)}}function Rq(e,t,n){return r;function r(a){return ot(a)?vc(e,i)(a):n(a)}function i(a){return JR(e,s,n,"definitionTitle","definitionTitleMarker","definitionTitleString")(a)}function s(a){return Ue(a)?Ge(e,o,"whitespace")(a):o(a)}function o(a){return a===null||be(a)?t(a):n(a)}}const Mq={name:"hardBreakEscape",tokenize:Aq};function Aq(e,t,n){return r;function r(s){return e.enter("hardBreakEscape"),e.consume(s),i}function i(s){return be(s)?(e.exit("hardBreakEscape"),t(s)):n(s)}}const Lq={name:"headingAtx",resolve:jq,tokenize:Dq};function jq(e,t){let n=e.length-2,r=3,i,s;return e[r][1].type==="whitespace"&&(r+=2),n-2>r&&e[n][1].type==="whitespace"&&(n-=2),e[n][1].type==="atxHeadingSequence"&&(r===n-1||n-4>r&&e[n-2][1].type==="whitespace")&&(n-=r+1===n?2:4),n>r&&(i={type:"atxHeadingText",start:e[r][1].start,end:e[n][1].end},s={type:"chunkText",start:e[r][1].start,end:e[n][1].end,contentType:"text"},er(e,r,n-r+1,[["enter",i,t],["enter",s,t],["exit",s,t],["exit",i,t]])),e}function Dq(e,t,n){let r=0;return i;function i(u){return e.enter("atxHeading"),s(u)}function s(u){return e.enter("atxHeadingSequence"),o(u)}function o(u){return u===35&&r++<6?(e.consume(u),o):u===null||ot(u)?(e.exit("atxHeadingSequence"),a(u)):n(u)}function a(u){return u===35?(e.enter("atxHeadingSequence"),l(u)):u===null||be(u)?(e.exit("atxHeading"),t(u)):Ue(u)?Ge(e,a,"whitespace")(u):(e.enter("atxHeadingText"),c(u))}function l(u){return u===35?(e.consume(u),l):(e.exit("atxHeadingSequence"),a(u))}function c(u){return u===null||u===35||ot(u)?(e.exit("atxHeadingText"),a(u)):(e.consume(u),c)}}const Oq=["address","article","aside","base","basefont","blockquote","body","caption","center","col","colgroup","dd","details","dialog","dir","div","dl","dt","fieldset","figcaption","figure","footer","form","frame","frameset","h1","h2","h3","h4","h5","h6","head","header","hr","html","iframe","legend","li","link","main","menu","menuitem","nav","noframes","ol","optgroup","option","p","param","search","section","summary","table","tbody","td","tfoot","th","thead","title","tr","track","ul"],KS=["pre","script","style","textarea"],Bq={concrete:!0,name:"htmlFlow",resolveTo:Fq,tokenize:Hq},zq={partial:!0,tokenize:Wq},$q={partial:!0,tokenize:Uq};function Fq(e){let t=e.length;for(;t--&&!(e[t][0]==="enter"&&e[t][1].type==="htmlFlow"););return t>1&&e[t-2][1].type==="linePrefix"&&(e[t][1].start=e[t-2][1].start,e[t+1][1].start=e[t-2][1].start,e.splice(t-2,2)),e}function Hq(e,t,n){const r=this;let i,s,o,a,l;return c;function c(A){return u(A)}function u(A){return e.enter("htmlFlow"),e.enter("htmlFlowData"),e.consume(A),d}function d(A){return A===33?(e.consume(A),f):A===47?(e.consume(A),s=!0,v):A===63?(e.consume(A),i=3,r.interrupt?t:E):En(A)?(e.consume(A),o=String.fromCharCode(A),b):n(A)}function f(A){return A===45?(e.consume(A),i=2,p):A===91?(e.consume(A),i=5,a=0,m):En(A)?(e.consume(A),i=4,r.interrupt?t:E):n(A)}function p(A){return A===45?(e.consume(A),r.interrupt?t:E):n(A)}function m(A){const ne="CDATA[";return A===ne.charCodeAt(a++)?(e.consume(A),a===ne.length?r.interrupt?t:R:m):n(A)}function v(A){return En(A)?(e.consume(A),o=String.fromCharCode(A),b):n(A)}function b(A){if(A===null||A===47||A===62||ot(A)){const ne=A===47,ae=o.toLowerCase();return!ne&&!s&&KS.includes(ae)?(i=1,r.interrupt?t(A):R(A)):Oq.includes(o.toLowerCase())?(i=6,ne?(e.consume(A),_):r.interrupt?t(A):R(A)):(i=7,r.interrupt&&!r.parser.lazy[r.now().line]?n(A):s?x(A):y(A))}return A===45||yn(A)?(e.consume(A),o+=String.fromCharCode(A),b):n(A)}function _(A){return A===62?(e.consume(A),r.interrupt?t:R):n(A)}function x(A){return Ue(A)?(e.consume(A),x):P(A)}function y(A){return A===47?(e.consume(A),P):A===58||A===95||En(A)?(e.consume(A),w):Ue(A)?(e.consume(A),y):P(A)}function w(A){return A===45||A===46||A===58||A===95||yn(A)?(e.consume(A),w):C(A)}function C(A){return A===61?(e.consume(A),k):Ue(A)?(e.consume(A),C):y(A)}function k(A){return A===null||A===60||A===61||A===62||A===96?n(A):A===34||A===39?(e.consume(A),l=A,T):Ue(A)?(e.consume(A),k):N(A)}function T(A){return A===l?(e.consume(A),l=null,z):A===null||be(A)?n(A):(e.consume(A),T)}function N(A){return A===null||A===34||A===39||A===47||A===60||A===61||A===62||A===96||ot(A)?C(A):(e.consume(A),N)}function z(A){return A===47||A===62||Ue(A)?y(A):n(A)}function P(A){return A===62?(e.consume(A),B):n(A)}function B(A){return A===null||be(A)?R(A):Ue(A)?(e.consume(A),B):n(A)}function R(A){return A===45&&i===2?(e.consume(A),$):A===60&&i===1?(e.consume(A),F):A===62&&i===4?(e.consume(A),H):A===63&&i===3?(e.consume(A),E):A===93&&i===5?(e.consume(A),O):be(A)&&(i===6||i===7)?(e.exit("htmlFlowData"),e.check(zq,V,I)(A)):A===null||be(A)?(e.exit("htmlFlowData"),I(A)):(e.consume(A),R)}function I(A){return e.check($q,j,V)(A)}function j(A){return e.enter("lineEnding"),e.consume(A),e.exit("lineEnding"),L}function L(A){return A===null||be(A)?I(A):(e.enter("htmlFlowData"),R(A))}function $(A){return A===45?(e.consume(A),E):R(A)}function F(A){return A===47?(e.consume(A),o="",D):R(A)}function D(A){if(A===62){const ne=o.toLowerCase();return KS.includes(ne)?(e.consume(A),H):R(A)}return En(A)&&o.length<8?(e.consume(A),o+=String.fromCharCode(A),D):R(A)}function O(A){return A===93?(e.consume(A),E):R(A)}function E(A){return A===62?(e.consume(A),H):A===45&&i===2?(e.consume(A),E):R(A)}function H(A){return A===null||be(A)?(e.exit("htmlFlowData"),V(A)):(e.consume(A),H)}function V(A){return e.exit("htmlFlow"),t(A)}}function Uq(e,t,n){const r=this;return i;function i(o){return be(o)?(e.enter("lineEnding"),e.consume(o),e.exit("lineEnding"),s):n(o)}function s(o){return r.parser.lazy[r.now().line]?n(o):t(o)}}function Wq(e,t,n){return r;function r(i){return e.enter("lineEnding"),e.consume(i),e.exit("lineEnding"),e.attempt(Tu,t,n)}}const Vq={name:"htmlText",tokenize:qq};function qq(e,t,n){const r=this;let i,s,o;return a;function a(E){return e.enter("htmlText"),e.enter("htmlTextData"),e.consume(E),l}function l(E){return E===33?(e.consume(E),c):E===47?(e.consume(E),C):E===63?(e.consume(E),y):En(E)?(e.consume(E),N):n(E)}function c(E){return E===45?(e.consume(E),u):E===91?(e.consume(E),s=0,m):En(E)?(e.consume(E),x):n(E)}function u(E){return E===45?(e.consume(E),p):n(E)}function d(E){return E===null?n(E):E===45?(e.consume(E),f):be(E)?(o=d,F(E)):(e.consume(E),d)}function f(E){return E===45?(e.consume(E),p):d(E)}function p(E){return E===62?$(E):E===45?f(E):d(E)}function m(E){const H="CDATA[";return E===H.charCodeAt(s++)?(e.consume(E),s===H.length?v:m):n(E)}function v(E){return E===null?n(E):E===93?(e.consume(E),b):be(E)?(o=v,F(E)):(e.consume(E),v)}function b(E){return E===93?(e.consume(E),_):v(E)}function _(E){return E===62?$(E):E===93?(e.consume(E),_):v(E)}function x(E){return E===null||E===62?$(E):be(E)?(o=x,F(E)):(e.consume(E),x)}function y(E){return E===null?n(E):E===63?(e.consume(E),w):be(E)?(o=y,F(E)):(e.consume(E),y)}function w(E){return E===62?$(E):y(E)}function C(E){return En(E)?(e.consume(E),k):n(E)}function k(E){return E===45||yn(E)?(e.consume(E),k):T(E)}function T(E){return be(E)?(o=T,F(E)):Ue(E)?(e.consume(E),T):$(E)}function N(E){return E===45||yn(E)?(e.consume(E),N):E===47||E===62||ot(E)?z(E):n(E)}function z(E){return E===47?(e.consume(E),$):E===58||E===95||En(E)?(e.consume(E),P):be(E)?(o=z,F(E)):Ue(E)?(e.consume(E),z):$(E)}function P(E){return E===45||E===46||E===58||E===95||yn(E)?(e.consume(E),P):B(E)}function B(E){return E===61?(e.consume(E),R):be(E)?(o=B,F(E)):Ue(E)?(e.consume(E),B):z(E)}function R(E){return E===null||E===60||E===61||E===62||E===96?n(E):E===34||E===39?(e.consume(E),i=E,I):be(E)?(o=R,F(E)):Ue(E)?(e.consume(E),R):(e.consume(E),j)}function I(E){return E===i?(e.consume(E),i=void 0,L):E===null?n(E):be(E)?(o=I,F(E)):(e.consume(E),I)}function j(E){return E===null||E===34||E===39||E===60||E===61||E===96?n(E):E===47||E===62||ot(E)?z(E):(e.consume(E),j)}function L(E){return E===47||E===62||ot(E)?z(E):n(E)}function $(E){return E===62?(e.consume(E),e.exit("htmlTextData"),e.exit("htmlText"),t):n(E)}function F(E){return e.exit("htmlTextData"),e.enter("lineEnding"),e.consume(E),e.exit("lineEnding"),D}function D(E){return Ue(E)?Ge(e,O,"linePrefix",r.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(E):O(E)}function O(E){return e.enter("htmlTextData"),o(E)}}const Ly={name:"labelEnd",resolveAll:Xq,resolveTo:Qq,tokenize:Zq},Kq={tokenize:Jq},Gq={tokenize:eK},Yq={tokenize:tK};function Xq(e){let t=-1;const n=[];for(;++t<e.length;){const r=e[t][1];if(n.push(e[t]),r.type==="labelImage"||r.type==="labelLink"||r.type==="labelEnd"){const i=r.type==="labelImage"?4:2;r.type="data",t+=i}}return e.length!==n.length&&er(e,0,e.length,n),e}function Qq(e,t){let n=e.length,r=0,i,s,o,a;for(;n--;)if(i=e[n][1],s){if(i.type==="link"||i.type==="labelLink"&&i._inactive)break;e[n][0]==="enter"&&i.type==="labelLink"&&(i._inactive=!0)}else if(o){if(e[n][0]==="enter"&&(i.type==="labelImage"||i.type==="labelLink")&&!i._balanced&&(s=n,i.type!=="labelLink")){r=2;break}}else i.type==="labelEnd"&&(o=n);const l={type:e[s][1].type==="labelLink"?"link":"image",start:{...e[s][1].start},end:{...e[e.length-1][1].end}},c={type:"label",start:{...e[s][1].start},end:{...e[o][1].end}},u={type:"labelText",start:{...e[s+r+2][1].end},end:{...e[o-2][1].start}};return a=[["enter",l,t],["enter",c,t]],a=fr(a,e.slice(s+1,s+r+3)),a=fr(a,[["enter",u,t]]),a=fr(a,kp(t.parser.constructs.insideSpan.null,e.slice(s+r+4,o-3),t)),a=fr(a,[["exit",u,t],e[o-2],e[o-1],["exit",c,t]]),a=fr(a,e.slice(o+1)),a=fr(a,[["exit",l,t]]),er(e,s,e.length,a),e}function Zq(e,t,n){const r=this;let i=r.events.length,s,o;for(;i--;)if((r.events[i][1].type==="labelImage"||r.events[i][1].type==="labelLink")&&!r.events[i][1]._balanced){s=r.events[i][1];break}return a;function a(f){return s?s._inactive?d(f):(o=r.parser.defined.includes(Mr(r.sliceSerialize({start:s.end,end:r.now()}))),e.enter("labelEnd"),e.enter("labelMarker"),e.consume(f),e.exit("labelMarker"),e.exit("labelEnd"),l):n(f)}function l(f){return f===40?e.attempt(Kq,u,o?u:d)(f):f===91?e.attempt(Gq,u,o?c:d)(f):o?u(f):d(f)}function c(f){return e.attempt(Yq,u,d)(f)}function u(f){return t(f)}function d(f){return s._balanced=!0,n(f)}}function Jq(e,t,n){return r;function r(d){return e.enter("resource"),e.enter("resourceMarker"),e.consume(d),e.exit("resourceMarker"),i}function i(d){return ot(d)?vc(e,s)(d):s(d)}function s(d){return d===41?u(d):QR(e,o,a,"resourceDestination","resourceDestinationLiteral","resourceDestinationLiteralMarker","resourceDestinationRaw","resourceDestinationString",32)(d)}function o(d){return ot(d)?vc(e,l)(d):u(d)}function a(d){return n(d)}function l(d){return d===34||d===39||d===40?JR(e,c,n,"resourceTitle","resourceTitleMarker","resourceTitleString")(d):u(d)}function c(d){return ot(d)?vc(e,u)(d):u(d)}function u(d){return d===41?(e.enter("resourceMarker"),e.consume(d),e.exit("resourceMarker"),e.exit("resource"),t):n(d)}}function eK(e,t,n){const r=this;return i;function i(a){return ZR.call(r,e,s,o,"reference","referenceMarker","referenceString")(a)}function s(a){return r.parser.defined.includes(Mr(r.sliceSerialize(r.events[r.events.length-1][1]).slice(1,-1)))?t(a):n(a)}function o(a){return n(a)}}function tK(e,t,n){return r;function r(s){return e.enter("reference"),e.enter("referenceMarker"),e.consume(s),e.exit("referenceMarker"),i}function i(s){return s===93?(e.enter("referenceMarker"),e.consume(s),e.exit("referenceMarker"),e.exit("reference"),t):n(s)}}const nK={name:"labelStartImage",resolveAll:Ly.resolveAll,tokenize:rK};function rK(e,t,n){const r=this;return i;function i(a){return e.enter("labelImage"),e.enter("labelImageMarker"),e.consume(a),e.exit("labelImageMarker"),s}function s(a){return a===91?(e.enter("labelMarker"),e.consume(a),e.exit("labelMarker"),e.exit("labelImage"),o):n(a)}function o(a){return a===94&&"_hiddenFootnoteSupport"in r.parser.constructs?n(a):t(a)}}const iK={name:"labelStartLink",resolveAll:Ly.resolveAll,tokenize:sK};function sK(e,t,n){const r=this;return i;function i(o){return e.enter("labelLink"),e.enter("labelMarker"),e.consume(o),e.exit("labelMarker"),e.exit("labelLink"),s}function s(o){return o===94&&"_hiddenFootnoteSupport"in r.parser.constructs?n(o):t(o)}}const Vm={name:"lineEnding",tokenize:oK};function oK(e,t){return n;function n(r){return e.enter("lineEnding"),e.consume(r),e.exit("lineEnding"),Ge(e,t,"linePrefix")}}const rh={name:"thematicBreak",tokenize:aK};function aK(e,t,n){let r=0,i;return s;function s(c){return e.enter("thematicBreak"),o(c)}function o(c){return i=c,a(c)}function a(c){return c===i?(e.enter("thematicBreakSequence"),l(c)):r>=3&&(c===null||be(c))?(e.exit("thematicBreak"),t(c)):n(c)}function l(c){return c===i?(e.consume(c),r++,l):(e.exit("thematicBreakSequence"),Ue(c)?Ge(e,a,"whitespace")(c):a(c))}}const On={continuation:{tokenize:dK},exit:fK,name:"list",tokenize:uK},lK={partial:!0,tokenize:pK},cK={partial:!0,tokenize:hK};function uK(e,t,n){const r=this,i=r.events[r.events.length-1];let s=i&&i[1].type==="linePrefix"?i[2].sliceSerialize(i[1],!0).length:0,o=0;return a;function a(p){const m=r.containerState.type||(p===42||p===43||p===45?"listUnordered":"listOrdered");if(m==="listUnordered"?!r.containerState.marker||p===r.containerState.marker:I0(p)){if(r.containerState.type||(r.containerState.type=m,e.enter(m,{_container:!0})),m==="listUnordered")return e.enter("listItemPrefix"),p===42||p===45?e.check(rh,n,c)(p):c(p);if(!r.interrupt||p===49)return e.enter("listItemPrefix"),e.enter("listItemValue"),l(p)}return n(p)}function l(p){return I0(p)&&++o<10?(e.consume(p),l):(!r.interrupt||o<2)&&(r.containerState.marker?p===r.containerState.marker:p===41||p===46)?(e.exit("listItemValue"),c(p)):n(p)}function c(p){return e.enter("listItemMarker"),e.consume(p),e.exit("listItemMarker"),r.containerState.marker=r.containerState.marker||p,e.check(Tu,r.interrupt?n:u,e.attempt(lK,f,d))}function u(p){return r.containerState.initialBlankLine=!0,s++,f(p)}function d(p){return Ue(p)?(e.enter("listItemPrefixWhitespace"),e.consume(p),e.exit("listItemPrefixWhitespace"),f):n(p)}function f(p){return r.containerState.size=s+r.sliceSerialize(e.exit("listItemPrefix"),!0).length,t(p)}}function dK(e,t,n){const r=this;return r.containerState._closeFlow=void 0,e.check(Tu,i,s);function i(a){return r.containerState.furtherBlankLines=r.containerState.furtherBlankLines||r.containerState.initialBlankLine,Ge(e,t,"listItemIndent",r.containerState.size+1)(a)}function s(a){return r.containerState.furtherBlankLines||!Ue(a)?(r.containerState.furtherBlankLines=void 0,r.containerState.initialBlankLine=void 0,o(a)):(r.containerState.furtherBlankLines=void 0,r.containerState.initialBlankLine=void 0,e.attempt(cK,t,o)(a))}function o(a){return r.containerState._closeFlow=!0,r.interrupt=void 0,Ge(e,e.attempt(On,t,n),"linePrefix",r.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(a)}}function hK(e,t,n){const r=this;return Ge(e,i,"listItemIndent",r.containerState.size+1);function i(s){const o=r.events[r.events.length-1];return o&&o[1].type==="listItemIndent"&&o[2].sliceSerialize(o[1],!0).length===r.containerState.size?t(s):n(s)}}function fK(e){e.exit(this.containerState.type)}function pK(e,t,n){const r=this;return Ge(e,i,"listItemPrefixWhitespace",r.parser.constructs.disable.null.includes("codeIndented")?void 0:5);function i(s){const o=r.events[r.events.length-1];return!Ue(s)&&o&&o[1].type==="listItemPrefixWhitespace"?t(s):n(s)}}const GS={name:"setextUnderline",resolveTo:mK,tokenize:gK};function mK(e,t){let n=e.length,r,i,s;for(;n--;)if(e[n][0]==="enter"){if(e[n][1].type==="content"){r=n;break}e[n][1].type==="paragraph"&&(i=n)}else e[n][1].type==="content"&&e.splice(n,1),!s&&e[n][1].type==="definition"&&(s=n);const o={type:"setextHeading",start:{...e[r][1].start},end:{...e[e.length-1][1].end}};return e[i][1].type="setextHeadingText",s?(e.splice(i,0,["enter",o,t]),e.splice(s+1,0,["exit",e[r][1],t]),e[r][1].end={...e[s][1].end}):e[r][1]=o,e.push(["exit",o,t]),e}function gK(e,t,n){const r=this;let i;return s;function s(c){let u=r.events.length,d;for(;u--;)if(r.events[u][1].type!=="lineEnding"&&r.events[u][1].type!=="linePrefix"&&r.events[u][1].type!=="content"){d=r.events[u][1].type==="paragraph";break}return!r.parser.lazy[r.now().line]&&(r.interrupt||d)?(e.enter("setextHeadingLine"),i=c,o(c)):n(c)}function o(c){return e.enter("setextHeadingLineSequence"),a(c)}function a(c){return c===i?(e.consume(c),a):(e.exit("setextHeadingLineSequence"),Ue(c)?Ge(e,l,"lineSuffix")(c):l(c))}function l(c){return c===null||be(c)?(e.exit("setextHeadingLine"),t(c)):n(c)}}const vK={tokenize:_K};function _K(e){const t=this,n=e.attempt(Tu,r,e.attempt(this.parser.constructs.flowInitial,i,Ge(e,e.attempt(this.parser.constructs.flow,i,e.attempt(Sq,i)),"linePrefix")));return n;function r(s){if(s===null){e.consume(s);return}return e.enter("lineEndingBlank"),e.consume(s),e.exit("lineEndingBlank"),t.currentConstruct=void 0,n}function i(s){if(s===null){e.consume(s);return}return e.enter("lineEnding"),e.consume(s),e.exit("lineEnding"),t.currentConstruct=void 0,n}}const xK={resolveAll:tM()},yK=eM("string"),bK=eM("text");function eM(e){return{resolveAll:tM(e==="text"?wK:void 0),tokenize:t};function t(n){const r=this,i=this.parser.constructs[e],s=n.attempt(i,o,a);return o;function o(u){return c(u)?s(u):a(u)}function a(u){if(u===null){n.consume(u);return}return n.enter("data"),n.consume(u),l}function l(u){return c(u)?(n.exit("data"),s(u)):(n.consume(u),l)}function c(u){if(u===null)return!0;const d=i[u];let f=-1;if(d)for(;++f<d.length;){const p=d[f];if(!p.previous||p.previous.call(r,r.previous))return!0}return!1}}}function tM(e){return t;function t(n,r){let i=-1,s;for(;++i<=n.length;)s===void 0?n[i]&&n[i][1].type==="data"&&(s=i,i++):(!n[i]||n[i][1].type!=="data")&&(i!==s+2&&(n[s][1].end=n[i-1][1].end,n.splice(s+2,i-s-2),i=s+2),s=void 0);return e?e(n,r):n}}function wK(e,t){let n=0;for(;++n<=e.length;)if((n===e.length||e[n][1].type==="lineEnding")&&e[n-1][1].type==="data"){const r=e[n-1][1],i=t.sliceStream(r);let s=i.length,o=-1,a=0,l;for(;s--;){const c=i[s];if(typeof c=="string"){for(o=c.length;c.charCodeAt(o-1)===32;)a++,o--;if(o)break;o=-1}else if(c===-2)l=!0,a++;else if(c!==-1){s++;break}}if(t._contentTypeTextTrailing&&n===e.length&&(a=0),a){const c={type:n===e.length||l||a<2?"lineSuffix":"hardBreakTrailing",start:{_bufferIndex:s?o:r.start._bufferIndex+o,_index:r.start._index+s,line:r.end.line,column:r.end.column-a,offset:r.end.offset-a},end:{...r.end}};r.end={...c.start},r.start.offset===r.end.offset?Object.assign(r,c):(e.splice(n,0,["enter",c,t],["exit",c,t]),n+=2)}n++}return e}const SK={42:On,43:On,45:On,48:On,49:On,50:On,51:On,52:On,53:On,54:On,55:On,56:On,57:On,62:KR},kK={91:Nq},CK={[-2]:Wm,[-1]:Wm,32:Wm},EK={35:Lq,42:rh,45:[GS,rh],60:Bq,61:GS,95:rh,96:qS,126:qS},TK={38:YR,92:GR},NK={[-5]:Vm,[-4]:Vm,[-3]:Vm,33:nK,38:YR,42:R0,60:[iq,Vq],91:iK,92:[Mq,GR],93:Ly,95:R0,96:vq},PK={null:[R0,xK]},IK={null:[42,95]},RK={null:[]},MK=Object.freeze(Object.defineProperty({__proto__:null,attentionMarkers:IK,contentInitial:kK,disable:RK,document:SK,flow:EK,flowInitial:CK,insideSpan:PK,string:TK,text:NK},Symbol.toStringTag,{value:"Module"}));function AK(e,t,n){let r={_bufferIndex:-1,_index:0,line:n&&n.line||1,column:n&&n.column||1,offset:n&&n.offset||0};const i={},s=[];let o=[],a=[];const l={attempt:T(C),check:T(k),consume:x,enter:y,exit:w,interrupt:T(k,{interrupt:!0})},c={code:null,containerState:{},defineSkip:v,events:[],now:m,parser:e,previous:null,sliceSerialize:f,sliceStream:p,write:d};let u=t.tokenize.call(c,l);return t.resolveAll&&s.push(t),c;function d(B){return o=fr(o,B),b(),o[o.length-1]!==null?[]:(N(t,0),c.events=kp(s,c.events,c),c.events)}function f(B,R){return jK(p(B),R)}function p(B){return LK(o,B)}function m(){const{_bufferIndex:B,_index:R,line:I,column:j,offset:L}=r;return{_bufferIndex:B,_index:R,line:I,column:j,offset:L}}function v(B){i[B.line]=B.column,P()}function b(){let B;for(;r._index<o.length;){const R=o[r._index];if(typeof R=="string")for(B=r._index,r._bufferIndex<0&&(r._bufferIndex=0);r._index===B&&r._bufferIndex<R.length;)_(R.charCodeAt(r._bufferIndex));else _(R)}}function _(B){u=u(B)}function x(B){be(B)?(r.line++,r.column=1,r.offset+=B===-3?2:1,P()):B!==-1&&(r.column++,r.offset++),r._bufferIndex<0?r._index++:(r._bufferIndex++,r._bufferIndex===o[r._index].length&&(r._bufferIndex=-1,r._index++)),c.previous=B}function y(B,R){const I=R||{};return I.type=B,I.start=m(),c.events.push(["enter",I,c]),a.push(I),I}function w(B){const R=a.pop();return R.end=m(),c.events.push(["exit",R,c]),R}function C(B,R){N(B,R.from)}function k(B,R){R.restore()}function T(B,R){return I;function I(j,L,$){let F,D,O,E;return Array.isArray(j)?V(j):"tokenize"in j?V([j]):H(j);function H(G){return ye;function ye(Fe){const ue=Fe!==null&&G[Fe],Ie=Fe!==null&&G.null,Re=[...Array.isArray(ue)?ue:ue?[ue]:[],...Array.isArray(Ie)?Ie:Ie?[Ie]:[]];return V(Re)(Fe)}}function V(G){return F=G,D=0,G.length===0?$:A(G[D])}function A(G){return ye;function ye(Fe){return E=z(),O=G,G.partial||(c.currentConstruct=G),G.name&&c.parser.constructs.disable.null.includes(G.name)?ae():G.tokenize.call(R?Object.assign(Object.create(c),R):c,l,ne,ae)(Fe)}}function ne(G){return B(O,E),L}function ae(G){return E.restore(),++D<F.length?A(F[D]):$}}}function N(B,R){B.resolveAll&&!s.includes(B)&&s.push(B),B.resolve&&er(c.events,R,c.events.length-R,B.resolve(c.events.slice(R),c)),B.resolveTo&&(c.events=B.resolveTo(c.events,c))}function z(){const B=m(),R=c.previous,I=c.currentConstruct,j=c.events.length,L=Array.from(a);return{from:j,restore:$};function $(){r=B,c.previous=R,c.currentConstruct=I,c.events.length=j,a=L,P()}}function P(){r.line in i&&r.column<2&&(r.column=i[r.line],r.offset+=i[r.line]-1)}}function LK(e,t){const n=t.start._index,r=t.start._bufferIndex,i=t.end._index,s=t.end._bufferIndex;let o;if(n===i)o=[e[n].slice(r,s)];else{if(o=e.slice(n,i),r>-1){const a=o[0];typeof a=="string"?o[0]=a.slice(r):o.shift()}s>0&&o.push(e[i].slice(0,s))}return o}function jK(e,t){let n=-1;const r=[];let i;for(;++n<e.length;){const s=e[n];let o;if(typeof s=="string")o=s;else switch(s){case-5:{o="\r";break}case-4:{o=`
482
482
  `;break}case-3:{o=`\r
483
- `;break}case-2:{o=t?" ":" ";break}case-1:{if(!t&&i)continue;o=" ";break}default:o=String.fromCharCode(s)}i=s===-2,r.push(o)}return r.join("")}function DK(e){const r={constructs:VR([MK,...(e||{}).extensions||[]]),content:i(QV),defined:[],document:i(JV),flow:i(vK),lazy:{},string:i(yK),text:i(bK)};return r;function i(s){return o;function o(a){return AK(r,s,a)}}}function OK(e){for(;!XR(e););return e}const YS=/[\0\t\n\r]/g;function BK(){let e=1,t="",n=!0,r;return i;function i(s,o,a){const l=[];let c,u,d,f,p;for(s=t+(typeof s=="string"?s.toString():new TextDecoder(o||void 0).decode(s)),d=0,t="",n&&(s.charCodeAt(0)===65279&&d++,n=void 0);d<s.length;){if(YS.lastIndex=d,c=YS.exec(s),f=c&&c.index!==void 0?c.index:s.length,p=s.charCodeAt(f),!c){t=s.slice(d);break}if(p===10&&d===f&&r)l.push(-3),r=void 0;else switch(r&&(l.push(-5),r=void 0),d<f&&(l.push(s.slice(d,f)),e+=f-d),p){case 0:{l.push(65533),e++;break}case 9:{for(u=Math.ceil(e/4)*4,l.push(-2);e++<u;)l.push(-1);break}case 10:{l.push(-4),e=1;break}default:r=!0,e=1}d=f+1}return a&&(r&&l.push(-5),t&&l.push(t),l.push(null)),l}}const zK=/\\([!-/:-@[-`{-~])|&(#(?:\d{1,7}|x[\da-f]{1,6})|[\da-z]{1,31});/gi;function $K(e){return e.replace(zK,FK)}function FK(e,t,n){if(t)return t;if(n.charCodeAt(0)===35){const i=n.charCodeAt(1),s=i===120||i===88;return qR(n.slice(s?2:1),s?16:10)}return Ay(n)||e}const nM={}.hasOwnProperty;function HK(e,t,n){return t&&typeof t=="object"&&(n=t,t=void 0),UK(n)(OK(DK(n).document().write(BK()(e,t,!0))))}function UK(e){const t={transforms:[],canContainEols:["emphasis","fragment","heading","paragraph","strong"],enter:{autolink:s(Mt),autolinkProtocol:z,autolinkEmail:z,atxHeading:s(fn),blockQuote:s(Ie),characterEscape:z,characterReference:z,codeFenced:s(Re),codeFencedFenceInfo:o,codeFencedFenceMeta:o,codeIndented:s(Re,o),codeText:s(Ke,o),codeTextData:z,data:z,codeFlowValue:z,definition:s(ve),definitionDestinationString:o,definitionLabelString:o,definitionTitleString:o,emphasis:s(ze),hardBreakEscape:s(it),hardBreakTrailing:s(it),htmlFlow:s(Rt,o),htmlFlowData:z,htmlText:s(Rt,o),htmlTextData:z,image:s(Gt),label:o,link:s(Mt),listItem:s(Qe),listItemValue:f,listOrdered:s(bt,d),listUnordered:s(bt),paragraph:s(st),reference:A,referenceString:o,resourceDestinationString:o,resourceTitleString:o,setextHeading:s(fn),strong:s(wt),thematicBreak:s(on)},exit:{atxHeading:l(),atxHeadingSequence:C,autolink:l(),autolinkEmail:ue,autolinkProtocol:Fe,blockQuote:l(),characterEscapeValue:P,characterReferenceMarkerHexadecimal:ae,characterReferenceMarkerNumeric:ae,characterReferenceValue:G,characterReference:ye,codeFenced:l(b),codeFencedFence:v,codeFencedFenceInfo:p,codeFencedFenceMeta:m,codeFlowValue:P,codeIndented:l(_),codeText:l(L),codeTextData:P,data:P,definition:l(),definitionDestinationString:w,definitionLabelString:x,definitionTitleString:y,emphasis:l(),hardBreakEscape:l(R),hardBreakTrailing:l(R),htmlFlow:l(I),htmlFlowData:P,htmlText:l(j),htmlTextData:P,image:l(F),label:O,labelText:D,lineEnding:B,link:l($),listItem:l(),listOrdered:l(),listUnordered:l(),paragraph:l(),referenceString:ne,resourceDestinationString:E,resourceTitleString:H,resource:V,setextHeading:l(N),setextHeadingLineSequence:T,setextHeadingText:k,strong:l(),thematicBreak:l()}};rM(t,(e||{}).mdastExtensions||[]);const n={};return r;function r(U){let Z={type:"root",children:[]};const _e={stack:[Z],tokenStack:[],config:t,enter:a,exit:c,buffer:o,resume:u,data:n},ke=[];let He=-1;for(;++He<U.length;)if(U[He][1].type==="listOrdered"||U[He][1].type==="listUnordered")if(U[He][0]==="enter")ke.push(He);else{const Nt=ke.pop();He=i(U,Nt,He)}for(He=-1;++He<U.length;){const Nt=t[U[He][0]];nM.call(Nt,U[He][1].type)&&Nt[U[He][1].type].call(Object.assign({sliceSerialize:U[He][2].sliceSerialize},_e),U[He][1])}if(_e.tokenStack.length>0){const Nt=_e.tokenStack[_e.tokenStack.length-1];(Nt[1]||XS).call(_e,void 0,Nt[0])}for(Z.position={start:Qi(U.length>0?U[0][1].start:{line:1,column:1,offset:0}),end:Qi(U.length>0?U[U.length-2][1].end:{line:1,column:1,offset:0})},He=-1;++He<t.transforms.length;)Z=t.transforms[He](Z)||Z;return Z}function i(U,Z,_e){let ke=Z-1,He=-1,Nt=!1,Yt,Xt,se,q;for(;++ke<=_e;){const we=U[ke];switch(we[1].type){case"listUnordered":case"listOrdered":case"blockQuote":{we[0]==="enter"?He++:He--,q=void 0;break}case"lineEndingBlank":{we[0]==="enter"&&(Yt&&!q&&!He&&!se&&(se=ke),q=void 0);break}case"linePrefix":case"listItemValue":case"listItemMarker":case"listItemPrefix":case"listItemPrefixWhitespace":break;default:q=void 0}if(!He&&we[0]==="enter"&&we[1].type==="listItemPrefix"||He===-1&&we[0]==="exit"&&(we[1].type==="listUnordered"||we[1].type==="listOrdered")){if(Yt){let ht=ke;for(Xt=void 0;ht--;){const an=U[ht];if(an[1].type==="lineEnding"||an[1].type==="lineEndingBlank"){if(an[0]==="exit")continue;Xt&&(U[Xt][1].type="lineEndingBlank",Nt=!0),an[1].type="lineEnding",Xt=ht}else if(!(an[1].type==="linePrefix"||an[1].type==="blockQuotePrefix"||an[1].type==="blockQuotePrefixWhitespace"||an[1].type==="blockQuoteMarker"||an[1].type==="listItemIndent"))break}se&&(!Xt||se<Xt)&&(Yt._spread=!0),Yt.end=Object.assign({},Xt?U[Xt][1].start:we[1].end),U.splice(Xt||ke,0,["exit",Yt,we[2]]),ke++,_e++}if(we[1].type==="listItemPrefix"){const ht={type:"listItem",_spread:!1,start:Object.assign({},we[1].start),end:void 0};Yt=ht,U.splice(ke,0,["enter",ht,we[2]]),ke++,_e++,se=void 0,q=!0}}}return U[Z][1]._spread=Nt,_e}function s(U,Z){return _e;function _e(ke){a.call(this,U(ke),ke),Z&&Z.call(this,ke)}}function o(){this.stack.push({type:"fragment",children:[]})}function a(U,Z,_e){this.stack[this.stack.length-1].children.push(U),this.stack.push(U),this.tokenStack.push([Z,_e||void 0]),U.position={start:Qi(Z.start),end:void 0}}function l(U){return Z;function Z(_e){U&&U.call(this,_e),c.call(this,_e)}}function c(U,Z){const _e=this.stack.pop(),ke=this.tokenStack.pop();if(ke)ke[0].type!==U.type&&(Z?Z.call(this,U,ke[0]):(ke[1]||XS).call(this,U,ke[0]));else throw new Error("Cannot close `"+U.type+"` ("+gc({start:U.start,end:U.end})+"): it’s not open");_e.position.end=Qi(U.end)}function u(){return My(this.stack.pop())}function d(){this.data.expectingFirstListItemValue=!0}function f(U){if(this.data.expectingFirstListItemValue){const Z=this.stack[this.stack.length-2];Z.start=Number.parseInt(this.sliceSerialize(U),10),this.data.expectingFirstListItemValue=void 0}}function p(){const U=this.resume(),Z=this.stack[this.stack.length-1];Z.lang=U}function m(){const U=this.resume(),Z=this.stack[this.stack.length-1];Z.meta=U}function v(){this.data.flowCodeInside||(this.buffer(),this.data.flowCodeInside=!0)}function b(){const U=this.resume(),Z=this.stack[this.stack.length-1];Z.value=U.replace(/^(\r?\n|\r)|(\r?\n|\r)$/g,""),this.data.flowCodeInside=void 0}function _(){const U=this.resume(),Z=this.stack[this.stack.length-1];Z.value=U.replace(/(\r?\n|\r)$/g,"")}function x(U){const Z=this.resume(),_e=this.stack[this.stack.length-1];_e.label=Z,_e.identifier=Mr(this.sliceSerialize(U)).toLowerCase()}function y(){const U=this.resume(),Z=this.stack[this.stack.length-1];Z.title=U}function w(){const U=this.resume(),Z=this.stack[this.stack.length-1];Z.url=U}function C(U){const Z=this.stack[this.stack.length-1];if(!Z.depth){const _e=this.sliceSerialize(U).length;Z.depth=_e}}function k(){this.data.setextHeadingSlurpLineEnding=!0}function T(U){const Z=this.stack[this.stack.length-1];Z.depth=this.sliceSerialize(U).codePointAt(0)===61?1:2}function N(){this.data.setextHeadingSlurpLineEnding=void 0}function z(U){const _e=this.stack[this.stack.length-1].children;let ke=_e[_e.length-1];(!ke||ke.type!=="text")&&(ke=pn(),ke.position={start:Qi(U.start),end:void 0},_e.push(ke)),this.stack.push(ke)}function P(U){const Z=this.stack.pop();Z.value+=this.sliceSerialize(U),Z.position.end=Qi(U.end)}function B(U){const Z=this.stack[this.stack.length-1];if(this.data.atHardBreak){const _e=Z.children[Z.children.length-1];_e.position.end=Qi(U.end),this.data.atHardBreak=void 0;return}!this.data.setextHeadingSlurpLineEnding&&t.canContainEols.includes(Z.type)&&(z.call(this,U),P.call(this,U))}function R(){this.data.atHardBreak=!0}function I(){const U=this.resume(),Z=this.stack[this.stack.length-1];Z.value=U}function j(){const U=this.resume(),Z=this.stack[this.stack.length-1];Z.value=U}function L(){const U=this.resume(),Z=this.stack[this.stack.length-1];Z.value=U}function $(){const U=this.stack[this.stack.length-1];if(this.data.inReference){const Z=this.data.referenceType||"shortcut";U.type+="Reference",U.referenceType=Z,delete U.url,delete U.title}else delete U.identifier,delete U.label;this.data.referenceType=void 0}function F(){const U=this.stack[this.stack.length-1];if(this.data.inReference){const Z=this.data.referenceType||"shortcut";U.type+="Reference",U.referenceType=Z,delete U.url,delete U.title}else delete U.identifier,delete U.label;this.data.referenceType=void 0}function D(U){const Z=this.sliceSerialize(U),_e=this.stack[this.stack.length-2];_e.label=$K(Z),_e.identifier=Mr(Z).toLowerCase()}function O(){const U=this.stack[this.stack.length-1],Z=this.resume(),_e=this.stack[this.stack.length-1];if(this.data.inReference=!0,_e.type==="link"){const ke=U.children;_e.children=ke}else _e.alt=Z}function E(){const U=this.resume(),Z=this.stack[this.stack.length-1];Z.url=U}function H(){const U=this.resume(),Z=this.stack[this.stack.length-1];Z.title=U}function V(){this.data.inReference=void 0}function A(){this.data.referenceType="collapsed"}function ne(U){const Z=this.resume(),_e=this.stack[this.stack.length-1];_e.label=Z,_e.identifier=Mr(this.sliceSerialize(U)).toLowerCase(),this.data.referenceType="full"}function ae(U){this.data.characterReferenceType=U.type}function G(U){const Z=this.sliceSerialize(U),_e=this.data.characterReferenceType;let ke;_e?(ke=qR(Z,_e==="characterReferenceMarkerNumeric"?10:16),this.data.characterReferenceType=void 0):ke=Ay(Z);const He=this.stack[this.stack.length-1];He.value+=ke}function ye(U){const Z=this.stack.pop();Z.position.end=Qi(U.end)}function Fe(U){P.call(this,U);const Z=this.stack[this.stack.length-1];Z.url=this.sliceSerialize(U)}function ue(U){P.call(this,U);const Z=this.stack[this.stack.length-1];Z.url="mailto:"+this.sliceSerialize(U)}function Ie(){return{type:"blockquote",children:[]}}function Re(){return{type:"code",lang:null,meta:null,value:""}}function Ke(){return{type:"inlineCode",value:""}}function ve(){return{type:"definition",identifier:"",label:null,title:null,url:""}}function ze(){return{type:"emphasis",children:[]}}function fn(){return{type:"heading",depth:0,children:[]}}function it(){return{type:"break"}}function Rt(){return{type:"html",value:""}}function Gt(){return{type:"image",title:null,url:"",alt:null}}function Mt(){return{type:"link",title:null,url:"",children:[]}}function bt(U){return{type:"list",ordered:U.type==="listOrdered",start:null,spread:U._spread,children:[]}}function Qe(U){return{type:"listItem",spread:U._spread,checked:null,children:[]}}function st(){return{type:"paragraph",children:[]}}function wt(){return{type:"strong",children:[]}}function pn(){return{type:"text",value:""}}function on(){return{type:"thematicBreak"}}}function Qi(e){return{line:e.line,column:e.column,offset:e.offset}}function rM(e,t){let n=-1;for(;++n<t.length;){const r=t[n];Array.isArray(r)?rM(e,r):WK(e,r)}}function WK(e,t){let n;for(n in t)if(nM.call(t,n))switch(n){case"canContainEols":{const r=t[n];r&&e[n].push(...r);break}case"transforms":{const r=t[n];r&&e[n].push(...r);break}case"enter":case"exit":{const r=t[n];r&&Object.assign(e[n],r);break}}}function XS(e,t){throw e?new Error("Cannot close `"+e.type+"` ("+gc({start:e.start,end:e.end})+"): a different token (`"+t.type+"`, "+gc({start:t.start,end:t.end})+") is open"):new Error("Cannot close document, a token (`"+t.type+"`, "+gc({start:t.start,end:t.end})+") is still open")}function VK(e){const t=this;t.parser=n;function n(r){return HK(r,{...t.data("settings"),...e,extensions:t.data("micromarkExtensions")||[],mdastExtensions:t.data("fromMarkdownExtensions")||[]})}}function qK(e,t){const n={type:"element",tagName:"blockquote",properties:{},children:e.wrap(e.all(t),!0)};return e.patch(t,n),e.applyData(t,n)}function KK(e,t){const n={type:"element",tagName:"br",properties:{},children:[]};return e.patch(t,n),[e.applyData(t,n),{type:"text",value:`
483
+ `;break}case-2:{o=t?" ":" ";break}case-1:{if(!t&&i)continue;o=" ";break}default:o=String.fromCharCode(s)}i=s===-2,r.push(o)}return r.join("")}function DK(e){const r={constructs:VR([MK,...(e||{}).extensions||[]]),content:i(QV),defined:[],document:i(JV),flow:i(vK),lazy:{},string:i(yK),text:i(bK)};return r;function i(s){return o;function o(a){return AK(r,s,a)}}}function OK(e){for(;!XR(e););return e}const YS=/[\0\t\n\r]/g;function BK(){let e=1,t="",n=!0,r;return i;function i(s,o,a){const l=[];let c,u,d,f,p;for(s=t+(typeof s=="string"?s.toString():new TextDecoder(o||void 0).decode(s)),d=0,t="",n&&(s.charCodeAt(0)===65279&&d++,n=void 0);d<s.length;){if(YS.lastIndex=d,c=YS.exec(s),f=c&&c.index!==void 0?c.index:s.length,p=s.charCodeAt(f),!c){t=s.slice(d);break}if(p===10&&d===f&&r)l.push(-3),r=void 0;else switch(r&&(l.push(-5),r=void 0),d<f&&(l.push(s.slice(d,f)),e+=f-d),p){case 0:{l.push(65533),e++;break}case 9:{for(u=Math.ceil(e/4)*4,l.push(-2);e++<u;)l.push(-1);break}case 10:{l.push(-4),e=1;break}default:r=!0,e=1}d=f+1}return a&&(r&&l.push(-5),t&&l.push(t),l.push(null)),l}}const zK=/\\([!-/:-@[-`{-~])|&(#(?:\d{1,7}|x[\da-f]{1,6})|[\da-z]{1,31});/gi;function $K(e){return e.replace(zK,FK)}function FK(e,t,n){if(t)return t;if(n.charCodeAt(0)===35){const i=n.charCodeAt(1),s=i===120||i===88;return qR(n.slice(s?2:1),s?16:10)}return Ay(n)||e}const nM={}.hasOwnProperty;function HK(e,t,n){return t&&typeof t=="object"&&(n=t,t=void 0),UK(n)(OK(DK(n).document().write(BK()(e,t,!0))))}function UK(e){const t={transforms:[],canContainEols:["emphasis","fragment","heading","paragraph","strong"],enter:{autolink:s(Mt),autolinkProtocol:z,autolinkEmail:z,atxHeading:s(fn),blockQuote:s(Ie),characterEscape:z,characterReference:z,codeFenced:s(Re),codeFencedFenceInfo:o,codeFencedFenceMeta:o,codeIndented:s(Re,o),codeText:s(Ke,o),codeTextData:z,data:z,codeFlowValue:z,definition:s(ve),definitionDestinationString:o,definitionLabelString:o,definitionTitleString:o,emphasis:s(ze),hardBreakEscape:s(it),hardBreakTrailing:s(it),htmlFlow:s(Rt,o),htmlFlowData:z,htmlText:s(Rt,o),htmlTextData:z,image:s(Gt),label:o,link:s(Mt),listItem:s(Qe),listItemValue:f,listOrdered:s(bt,d),listUnordered:s(bt),paragraph:s(st),reference:A,referenceString:o,resourceDestinationString:o,resourceTitleString:o,setextHeading:s(fn),strong:s(wt),thematicBreak:s(on)},exit:{atxHeading:l(),atxHeadingSequence:C,autolink:l(),autolinkEmail:ue,autolinkProtocol:Fe,blockQuote:l(),characterEscapeValue:P,characterReferenceMarkerHexadecimal:ae,characterReferenceMarkerNumeric:ae,characterReferenceValue:G,characterReference:ye,codeFenced:l(b),codeFencedFence:v,codeFencedFenceInfo:p,codeFencedFenceMeta:m,codeFlowValue:P,codeIndented:l(_),codeText:l(L),codeTextData:P,data:P,definition:l(),definitionDestinationString:w,definitionLabelString:x,definitionTitleString:y,emphasis:l(),hardBreakEscape:l(R),hardBreakTrailing:l(R),htmlFlow:l(I),htmlFlowData:P,htmlText:l(j),htmlTextData:P,image:l(F),label:O,labelText:D,lineEnding:B,link:l($),listItem:l(),listOrdered:l(),listUnordered:l(),paragraph:l(),referenceString:ne,resourceDestinationString:E,resourceTitleString:H,resource:V,setextHeading:l(N),setextHeadingLineSequence:T,setextHeadingText:k,strong:l(),thematicBreak:l()}};rM(t,(e||{}).mdastExtensions||[]);const n={};return r;function r(U){let Z={type:"root",children:[]};const _e={stack:[Z],tokenStack:[],config:t,enter:a,exit:c,buffer:o,resume:u,data:n},ke=[];let He=-1;for(;++He<U.length;)if(U[He][1].type==="listOrdered"||U[He][1].type==="listUnordered")if(U[He][0]==="enter")ke.push(He);else{const Nt=ke.pop();He=i(U,Nt,He)}for(He=-1;++He<U.length;){const Nt=t[U[He][0]];nM.call(Nt,U[He][1].type)&&Nt[U[He][1].type].call(Object.assign({sliceSerialize:U[He][2].sliceSerialize},_e),U[He][1])}if(_e.tokenStack.length>0){const Nt=_e.tokenStack[_e.tokenStack.length-1];(Nt[1]||XS).call(_e,void 0,Nt[0])}for(Z.position={start:Qi(U.length>0?U[0][1].start:{line:1,column:1,offset:0}),end:Qi(U.length>0?U[U.length-2][1].end:{line:1,column:1,offset:0})},He=-1;++He<t.transforms.length;)Z=t.transforms[He](Z)||Z;return Z}function i(U,Z,_e){let ke=Z-1,He=-1,Nt=!1,Yt,Xt,se,K;for(;++ke<=_e;){const we=U[ke];switch(we[1].type){case"listUnordered":case"listOrdered":case"blockQuote":{we[0]==="enter"?He++:He--,K=void 0;break}case"lineEndingBlank":{we[0]==="enter"&&(Yt&&!K&&!He&&!se&&(se=ke),K=void 0);break}case"linePrefix":case"listItemValue":case"listItemMarker":case"listItemPrefix":case"listItemPrefixWhitespace":break;default:K=void 0}if(!He&&we[0]==="enter"&&we[1].type==="listItemPrefix"||He===-1&&we[0]==="exit"&&(we[1].type==="listUnordered"||we[1].type==="listOrdered")){if(Yt){let ht=ke;for(Xt=void 0;ht--;){const an=U[ht];if(an[1].type==="lineEnding"||an[1].type==="lineEndingBlank"){if(an[0]==="exit")continue;Xt&&(U[Xt][1].type="lineEndingBlank",Nt=!0),an[1].type="lineEnding",Xt=ht}else if(!(an[1].type==="linePrefix"||an[1].type==="blockQuotePrefix"||an[1].type==="blockQuotePrefixWhitespace"||an[1].type==="blockQuoteMarker"||an[1].type==="listItemIndent"))break}se&&(!Xt||se<Xt)&&(Yt._spread=!0),Yt.end=Object.assign({},Xt?U[Xt][1].start:we[1].end),U.splice(Xt||ke,0,["exit",Yt,we[2]]),ke++,_e++}if(we[1].type==="listItemPrefix"){const ht={type:"listItem",_spread:!1,start:Object.assign({},we[1].start),end:void 0};Yt=ht,U.splice(ke,0,["enter",ht,we[2]]),ke++,_e++,se=void 0,K=!0}}}return U[Z][1]._spread=Nt,_e}function s(U,Z){return _e;function _e(ke){a.call(this,U(ke),ke),Z&&Z.call(this,ke)}}function o(){this.stack.push({type:"fragment",children:[]})}function a(U,Z,_e){this.stack[this.stack.length-1].children.push(U),this.stack.push(U),this.tokenStack.push([Z,_e||void 0]),U.position={start:Qi(Z.start),end:void 0}}function l(U){return Z;function Z(_e){U&&U.call(this,_e),c.call(this,_e)}}function c(U,Z){const _e=this.stack.pop(),ke=this.tokenStack.pop();if(ke)ke[0].type!==U.type&&(Z?Z.call(this,U,ke[0]):(ke[1]||XS).call(this,U,ke[0]));else throw new Error("Cannot close `"+U.type+"` ("+gc({start:U.start,end:U.end})+"): it’s not open");_e.position.end=Qi(U.end)}function u(){return My(this.stack.pop())}function d(){this.data.expectingFirstListItemValue=!0}function f(U){if(this.data.expectingFirstListItemValue){const Z=this.stack[this.stack.length-2];Z.start=Number.parseInt(this.sliceSerialize(U),10),this.data.expectingFirstListItemValue=void 0}}function p(){const U=this.resume(),Z=this.stack[this.stack.length-1];Z.lang=U}function m(){const U=this.resume(),Z=this.stack[this.stack.length-1];Z.meta=U}function v(){this.data.flowCodeInside||(this.buffer(),this.data.flowCodeInside=!0)}function b(){const U=this.resume(),Z=this.stack[this.stack.length-1];Z.value=U.replace(/^(\r?\n|\r)|(\r?\n|\r)$/g,""),this.data.flowCodeInside=void 0}function _(){const U=this.resume(),Z=this.stack[this.stack.length-1];Z.value=U.replace(/(\r?\n|\r)$/g,"")}function x(U){const Z=this.resume(),_e=this.stack[this.stack.length-1];_e.label=Z,_e.identifier=Mr(this.sliceSerialize(U)).toLowerCase()}function y(){const U=this.resume(),Z=this.stack[this.stack.length-1];Z.title=U}function w(){const U=this.resume(),Z=this.stack[this.stack.length-1];Z.url=U}function C(U){const Z=this.stack[this.stack.length-1];if(!Z.depth){const _e=this.sliceSerialize(U).length;Z.depth=_e}}function k(){this.data.setextHeadingSlurpLineEnding=!0}function T(U){const Z=this.stack[this.stack.length-1];Z.depth=this.sliceSerialize(U).codePointAt(0)===61?1:2}function N(){this.data.setextHeadingSlurpLineEnding=void 0}function z(U){const _e=this.stack[this.stack.length-1].children;let ke=_e[_e.length-1];(!ke||ke.type!=="text")&&(ke=pn(),ke.position={start:Qi(U.start),end:void 0},_e.push(ke)),this.stack.push(ke)}function P(U){const Z=this.stack.pop();Z.value+=this.sliceSerialize(U),Z.position.end=Qi(U.end)}function B(U){const Z=this.stack[this.stack.length-1];if(this.data.atHardBreak){const _e=Z.children[Z.children.length-1];_e.position.end=Qi(U.end),this.data.atHardBreak=void 0;return}!this.data.setextHeadingSlurpLineEnding&&t.canContainEols.includes(Z.type)&&(z.call(this,U),P.call(this,U))}function R(){this.data.atHardBreak=!0}function I(){const U=this.resume(),Z=this.stack[this.stack.length-1];Z.value=U}function j(){const U=this.resume(),Z=this.stack[this.stack.length-1];Z.value=U}function L(){const U=this.resume(),Z=this.stack[this.stack.length-1];Z.value=U}function $(){const U=this.stack[this.stack.length-1];if(this.data.inReference){const Z=this.data.referenceType||"shortcut";U.type+="Reference",U.referenceType=Z,delete U.url,delete U.title}else delete U.identifier,delete U.label;this.data.referenceType=void 0}function F(){const U=this.stack[this.stack.length-1];if(this.data.inReference){const Z=this.data.referenceType||"shortcut";U.type+="Reference",U.referenceType=Z,delete U.url,delete U.title}else delete U.identifier,delete U.label;this.data.referenceType=void 0}function D(U){const Z=this.sliceSerialize(U),_e=this.stack[this.stack.length-2];_e.label=$K(Z),_e.identifier=Mr(Z).toLowerCase()}function O(){const U=this.stack[this.stack.length-1],Z=this.resume(),_e=this.stack[this.stack.length-1];if(this.data.inReference=!0,_e.type==="link"){const ke=U.children;_e.children=ke}else _e.alt=Z}function E(){const U=this.resume(),Z=this.stack[this.stack.length-1];Z.url=U}function H(){const U=this.resume(),Z=this.stack[this.stack.length-1];Z.title=U}function V(){this.data.inReference=void 0}function A(){this.data.referenceType="collapsed"}function ne(U){const Z=this.resume(),_e=this.stack[this.stack.length-1];_e.label=Z,_e.identifier=Mr(this.sliceSerialize(U)).toLowerCase(),this.data.referenceType="full"}function ae(U){this.data.characterReferenceType=U.type}function G(U){const Z=this.sliceSerialize(U),_e=this.data.characterReferenceType;let ke;_e?(ke=qR(Z,_e==="characterReferenceMarkerNumeric"?10:16),this.data.characterReferenceType=void 0):ke=Ay(Z);const He=this.stack[this.stack.length-1];He.value+=ke}function ye(U){const Z=this.stack.pop();Z.position.end=Qi(U.end)}function Fe(U){P.call(this,U);const Z=this.stack[this.stack.length-1];Z.url=this.sliceSerialize(U)}function ue(U){P.call(this,U);const Z=this.stack[this.stack.length-1];Z.url="mailto:"+this.sliceSerialize(U)}function Ie(){return{type:"blockquote",children:[]}}function Re(){return{type:"code",lang:null,meta:null,value:""}}function Ke(){return{type:"inlineCode",value:""}}function ve(){return{type:"definition",identifier:"",label:null,title:null,url:""}}function ze(){return{type:"emphasis",children:[]}}function fn(){return{type:"heading",depth:0,children:[]}}function it(){return{type:"break"}}function Rt(){return{type:"html",value:""}}function Gt(){return{type:"image",title:null,url:"",alt:null}}function Mt(){return{type:"link",title:null,url:"",children:[]}}function bt(U){return{type:"list",ordered:U.type==="listOrdered",start:null,spread:U._spread,children:[]}}function Qe(U){return{type:"listItem",spread:U._spread,checked:null,children:[]}}function st(){return{type:"paragraph",children:[]}}function wt(){return{type:"strong",children:[]}}function pn(){return{type:"text",value:""}}function on(){return{type:"thematicBreak"}}}function Qi(e){return{line:e.line,column:e.column,offset:e.offset}}function rM(e,t){let n=-1;for(;++n<t.length;){const r=t[n];Array.isArray(r)?rM(e,r):WK(e,r)}}function WK(e,t){let n;for(n in t)if(nM.call(t,n))switch(n){case"canContainEols":{const r=t[n];r&&e[n].push(...r);break}case"transforms":{const r=t[n];r&&e[n].push(...r);break}case"enter":case"exit":{const r=t[n];r&&Object.assign(e[n],r);break}}}function XS(e,t){throw e?new Error("Cannot close `"+e.type+"` ("+gc({start:e.start,end:e.end})+"): a different token (`"+t.type+"`, "+gc({start:t.start,end:t.end})+") is open"):new Error("Cannot close document, a token (`"+t.type+"`, "+gc({start:t.start,end:t.end})+") is still open")}function VK(e){const t=this;t.parser=n;function n(r){return HK(r,{...t.data("settings"),...e,extensions:t.data("micromarkExtensions")||[],mdastExtensions:t.data("fromMarkdownExtensions")||[]})}}function qK(e,t){const n={type:"element",tagName:"blockquote",properties:{},children:e.wrap(e.all(t),!0)};return e.patch(t,n),e.applyData(t,n)}function KK(e,t){const n={type:"element",tagName:"br",properties:{},children:[]};return e.patch(t,n),[e.applyData(t,n),{type:"text",value:`
484
484
  `}]}function GK(e,t){const n=t.value?t.value+`
485
485
  `:"",r={},i=t.lang?t.lang.split(/\s+/):[];i.length>0&&(r.className=["language-"+i[0]]);let s={type:"element",tagName:"code",properties:r,children:[{type:"text",value:n}]};return t.meta&&(s.data={meta:t.meta}),e.patch(t,s),s=e.applyData(t,s),s={type:"element",tagName:"pre",properties:{},children:[s]},e.patch(t,s),s}function YK(e,t){const n={type:"element",tagName:"del",properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)}function XK(e,t){const n={type:"element",tagName:"em",properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)}function QK(e,t){const n=typeof e.options.clobberPrefix=="string"?e.options.clobberPrefix:"user-content-",r=String(t.identifier).toUpperCase(),i=pl(r.toLowerCase()),s=e.footnoteOrder.indexOf(r);let o,a=e.footnoteCounts.get(r);a===void 0?(a=0,e.footnoteOrder.push(r),o=e.footnoteOrder.length):o=s+1,a+=1,e.footnoteCounts.set(r,a);const l={type:"element",tagName:"a",properties:{href:"#"+n+"fn-"+i,id:n+"fnref-"+i+(a>1?"-"+a:""),dataFootnoteRef:!0,ariaDescribedBy:["footnote-label"]},children:[{type:"text",value:String(o)}]};e.patch(t,l);const c={type:"element",tagName:"sup",properties:{},children:[l]};return e.patch(t,c),e.applyData(t,c)}function ZK(e,t){const n={type:"element",tagName:"h"+t.depth,properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)}function JK(e,t){if(e.options.allowDangerousHtml){const n={type:"raw",value:t.value};return e.patch(t,n),e.applyData(t,n)}}function iM(e,t){const n=t.referenceType;let r="]";if(n==="collapsed"?r+="[]":n==="full"&&(r+="["+(t.label||t.identifier)+"]"),t.type==="imageReference")return[{type:"text",value:"!["+t.alt+r}];const i=e.all(t),s=i[0];s&&s.type==="text"?s.value="["+s.value:i.unshift({type:"text",value:"["});const o=i[i.length-1];return o&&o.type==="text"?o.value+=r:i.push({type:"text",value:r}),i}function eG(e,t){const n=String(t.identifier).toUpperCase(),r=e.definitionById.get(n);if(!r)return iM(e,t);const i={src:pl(r.url||""),alt:t.alt};r.title!==null&&r.title!==void 0&&(i.title=r.title);const s={type:"element",tagName:"img",properties:i,children:[]};return e.patch(t,s),e.applyData(t,s)}function tG(e,t){const n={src:pl(t.url)};t.alt!==null&&t.alt!==void 0&&(n.alt=t.alt),t.title!==null&&t.title!==void 0&&(n.title=t.title);const r={type:"element",tagName:"img",properties:n,children:[]};return e.patch(t,r),e.applyData(t,r)}function nG(e,t){const n={type:"text",value:t.value.replace(/\r?\n|\r/g," ")};e.patch(t,n);const r={type:"element",tagName:"code",properties:{},children:[n]};return e.patch(t,r),e.applyData(t,r)}function rG(e,t){const n=String(t.identifier).toUpperCase(),r=e.definitionById.get(n);if(!r)return iM(e,t);const i={href:pl(r.url||"")};r.title!==null&&r.title!==void 0&&(i.title=r.title);const s={type:"element",tagName:"a",properties:i,children:e.all(t)};return e.patch(t,s),e.applyData(t,s)}function iG(e,t){const n={href:pl(t.url)};t.title!==null&&t.title!==void 0&&(n.title=t.title);const r={type:"element",tagName:"a",properties:n,children:e.all(t)};return e.patch(t,r),e.applyData(t,r)}function sG(e,t,n){const r=e.all(t),i=n?oG(n):sM(t),s={},o=[];if(typeof t.checked=="boolean"){const u=r[0];let d;u&&u.type==="element"&&u.tagName==="p"?d=u:(d={type:"element",tagName:"p",properties:{},children:[]},r.unshift(d)),d.children.length>0&&d.children.unshift({type:"text",value:" "}),d.children.unshift({type:"element",tagName:"input",properties:{type:"checkbox",checked:t.checked,disabled:!0},children:[]}),s.className=["task-list-item"]}let a=-1;for(;++a<r.length;){const u=r[a];(i||a!==0||u.type!=="element"||u.tagName!=="p")&&o.push({type:"text",value:`
486
486
  `}),u.type==="element"&&u.tagName==="p"&&!i?o.push(...u.children):o.push(u)}const l=r[r.length-1];l&&(i||l.type!=="element"||l.tagName!=="p")&&o.push({type:"text",value:`
@@ -508,7 +508,7 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
508
508
  `))}function l(p,m,v,b){const _=v.enter("tableCell"),x=v.enter("phrasing"),y=v.containerPhrasing(p,{...b,before:s,after:s});return x(),_(),y}function c(p,m){return GY(p,{align:m,alignDelimiters:r,padding:n,stringLength:i})}function u(p,m,v){const b=p.children;let _=-1;const x=[],y=m.enter("table");for(;++_<b.length;)x[_]=d(b[_],m,v);return y(),x}function d(p,m,v){const b=p.children;let _=-1;const x=[],y=m.enter("tableRow");for(;++_<b.length;)x[_]=l(b[_],p,m,v);return y(),x}function f(p,m,v){let b=NM.inlineCode(p,m,v);return v.stack.includes("tableCell")&&(b=b.replace(/\|/g,"\\$&")),b}}function jX(){return{exit:{taskListCheckValueChecked:wk,taskListCheckValueUnchecked:wk,paragraph:OX}}}function DX(){return{unsafe:[{atBreak:!0,character:"-",after:"[:|-]"}],handlers:{listItem:BX}}}function wk(e){const t=this.stack[this.stack.length-2];t.type,t.checked=e.type==="taskListCheckValueChecked"}function OX(e){const t=this.stack[this.stack.length-2];if(t&&t.type==="listItem"&&typeof t.checked=="boolean"){const n=this.stack[this.stack.length-1];n.type;const r=n.children[0];if(r&&r.type==="text"){const i=t.children;let s=-1,o;for(;++s<i.length;){const a=i[s];if(a.type==="paragraph"){o=a;break}}o===n&&(r.value=r.value.slice(1),r.value.length===0?n.children.shift():n.position&&r.position&&typeof r.position.start.offset=="number"&&(r.position.start.column++,r.position.start.offset++,n.position.start=Object.assign({},r.position.start)))}}this.exit(e)}function BX(e,t,n,r){const i=e.children[0],s=typeof e.checked=="boolean"&&i&&i.type==="paragraph",o="["+(e.checked?"x":" ")+"] ",a=n.createTracker(r);s&&a.move(o);let l=NM.listItem(e,t,n,{...r,...a.current()});return s&&(l=l.replace(/^(?:[*+-]|\d+\.)([\r\n]| {1,3})/,c)),l;function c(u){return u+o}}function zX(){return[vY(),BY(),HY(),NX(),jX()]}function $X(e){return{extensions:[_Y(),zY(e),UY(),LX(e),DX()]}}const FX={tokenize:KX,partial:!0},PM={tokenize:GX,partial:!0},IM={tokenize:YX,partial:!0},RM={tokenize:XX,partial:!0},HX={tokenize:QX,partial:!0},MM={name:"wwwAutolink",tokenize:VX,previous:LM},AM={name:"protocolAutolink",tokenize:qX,previous:jM},Fi={name:"emailAutolink",tokenize:WX,previous:DM},di={};function UX(){return{text:di}}let Ws=48;for(;Ws<123;)di[Ws]=Fi,Ws++,Ws===58?Ws=65:Ws===91&&(Ws=97);di[43]=Fi;di[45]=Fi;di[46]=Fi;di[95]=Fi;di[72]=[Fi,AM];di[104]=[Fi,AM];di[87]=[Fi,MM];di[119]=[Fi,MM];function WX(e,t,n){const r=this;let i,s;return o;function o(d){return!D0(d)||!DM.call(r,r.previous)||Uy(r.events)?n(d):(e.enter("literalAutolink"),e.enter("literalAutolinkEmail"),a(d))}function a(d){return D0(d)?(e.consume(d),a):d===64?(e.consume(d),l):n(d)}function l(d){return d===46?e.check(HX,u,c)(d):d===45||d===95||yn(d)?(s=!0,e.consume(d),l):u(d)}function c(d){return e.consume(d),i=!0,l}function u(d){return s&&i&&En(r.previous)?(e.exit("literalAutolinkEmail"),e.exit("literalAutolink"),t(d)):n(d)}}function VX(e,t,n){const r=this;return i;function i(o){return o!==87&&o!==119||!LM.call(r,r.previous)||Uy(r.events)?n(o):(e.enter("literalAutolink"),e.enter("literalAutolinkWww"),e.check(FX,e.attempt(PM,e.attempt(IM,s),n),n)(o))}function s(o){return e.exit("literalAutolinkWww"),e.exit("literalAutolink"),t(o)}}function qX(e,t,n){const r=this;let i="",s=!1;return o;function o(d){return(d===72||d===104)&&jM.call(r,r.previous)&&!Uy(r.events)?(e.enter("literalAutolink"),e.enter("literalAutolinkHttp"),i+=String.fromCodePoint(d),e.consume(d),a):n(d)}function a(d){if(En(d)&&i.length<5)return i+=String.fromCodePoint(d),e.consume(d),a;if(d===58){const f=i.toLowerCase();if(f==="http"||f==="https")return e.consume(d),l}return n(d)}function l(d){return d===47?(e.consume(d),s?c:(s=!0,l)):n(d)}function c(d){return d===null||of(d)||ot(d)||wo(d)||Sp(d)?n(d):e.attempt(PM,e.attempt(IM,u),n)(d)}function u(d){return e.exit("literalAutolinkHttp"),e.exit("literalAutolink"),t(d)}}function KX(e,t,n){let r=0;return i;function i(o){return(o===87||o===119)&&r<3?(r++,e.consume(o),i):o===46&&r===3?(e.consume(o),s):n(o)}function s(o){return o===null?n(o):t(o)}}function GX(e,t,n){let r,i,s;return o;function o(c){return c===46||c===95?e.check(RM,l,a)(c):c===null||ot(c)||wo(c)||c!==45&&Sp(c)?l(c):(s=!0,e.consume(c),o)}function a(c){return c===95?r=!0:(i=r,r=void 0),e.consume(c),o}function l(c){return i||r||!s?n(c):t(c)}}function YX(e,t){let n=0,r=0;return i;function i(o){return o===40?(n++,e.consume(o),i):o===41&&r<n?s(o):o===33||o===34||o===38||o===39||o===41||o===42||o===44||o===46||o===58||o===59||o===60||o===63||o===93||o===95||o===126?e.check(RM,t,s)(o):o===null||ot(o)||wo(o)?t(o):(e.consume(o),i)}function s(o){return o===41&&r++,e.consume(o),i}}function XX(e,t,n){return r;function r(a){return a===33||a===34||a===39||a===41||a===42||a===44||a===46||a===58||a===59||a===63||a===95||a===126?(e.consume(a),r):a===38?(e.consume(a),s):a===93?(e.consume(a),i):a===60||a===null||ot(a)||wo(a)?t(a):n(a)}function i(a){return a===null||a===40||a===91||ot(a)||wo(a)?t(a):r(a)}function s(a){return En(a)?o(a):n(a)}function o(a){return a===59?(e.consume(a),r):En(a)?(e.consume(a),o):n(a)}}function QX(e,t,n){return r;function r(s){return e.consume(s),i}function i(s){return yn(s)?n(s):t(s)}}function LM(e){return e===null||e===40||e===42||e===95||e===91||e===93||e===126||ot(e)}function jM(e){return!En(e)}function DM(e){return!(e===47||D0(e))}function D0(e){return e===43||e===45||e===46||e===95||yn(e)}function Uy(e){let t=e.length,n=!1;for(;t--;){const r=e[t][1];if((r.type==="labelLink"||r.type==="labelImage")&&!r._balanced){n=!0;break}if(r._gfmAutolinkLiteralWalkedInto){n=!1;break}}return e.length>0&&!n&&(e[e.length-1][1]._gfmAutolinkLiteralWalkedInto=!0),n}const ZX={tokenize:oQ,partial:!0};function JX(){return{document:{91:{name:"gfmFootnoteDefinition",tokenize:rQ,continuation:{tokenize:iQ},exit:sQ}},text:{91:{name:"gfmFootnoteCall",tokenize:nQ},93:{name:"gfmPotentialFootnoteCall",add:"after",tokenize:eQ,resolveTo:tQ}}}}function eQ(e,t,n){const r=this;let i=r.events.length;const s=r.parser.gfmFootnotes||(r.parser.gfmFootnotes=[]);let o;for(;i--;){const l=r.events[i][1];if(l.type==="labelImage"){o=l;break}if(l.type==="gfmFootnoteCall"||l.type==="labelLink"||l.type==="label"||l.type==="image"||l.type==="link")break}return a;function a(l){if(!o||!o._balanced)return n(l);const c=Mr(r.sliceSerialize({start:o.end,end:r.now()}));return c.codePointAt(0)!==94||!s.includes(c.slice(1))?n(l):(e.enter("gfmFootnoteCallLabelMarker"),e.consume(l),e.exit("gfmFootnoteCallLabelMarker"),t(l))}}function tQ(e,t){let n=e.length;for(;n--;)if(e[n][1].type==="labelImage"&&e[n][0]==="enter"){e[n][1];break}e[n+1][1].type="data",e[n+3][1].type="gfmFootnoteCallLabelMarker";const r={type:"gfmFootnoteCall",start:Object.assign({},e[n+3][1].start),end:Object.assign({},e[e.length-1][1].end)},i={type:"gfmFootnoteCallMarker",start:Object.assign({},e[n+3][1].end),end:Object.assign({},e[n+3][1].end)};i.end.column++,i.end.offset++,i.end._bufferIndex++;const s={type:"gfmFootnoteCallString",start:Object.assign({},i.end),end:Object.assign({},e[e.length-1][1].start)},o={type:"chunkString",contentType:"string",start:Object.assign({},s.start),end:Object.assign({},s.end)},a=[e[n+1],e[n+2],["enter",r,t],e[n+3],e[n+4],["enter",i,t],["exit",i,t],["enter",s,t],["enter",o,t],["exit",o,t],["exit",s,t],e[e.length-2],e[e.length-1],["exit",r,t]];return e.splice(n,e.length-n+1,...a),e}function nQ(e,t,n){const r=this,i=r.parser.gfmFootnotes||(r.parser.gfmFootnotes=[]);let s=0,o;return a;function a(d){return e.enter("gfmFootnoteCall"),e.enter("gfmFootnoteCallLabelMarker"),e.consume(d),e.exit("gfmFootnoteCallLabelMarker"),l}function l(d){return d!==94?n(d):(e.enter("gfmFootnoteCallMarker"),e.consume(d),e.exit("gfmFootnoteCallMarker"),e.enter("gfmFootnoteCallString"),e.enter("chunkString").contentType="string",c)}function c(d){if(s>999||d===93&&!o||d===null||d===91||ot(d))return n(d);if(d===93){e.exit("chunkString");const f=e.exit("gfmFootnoteCallString");return i.includes(Mr(r.sliceSerialize(f)))?(e.enter("gfmFootnoteCallLabelMarker"),e.consume(d),e.exit("gfmFootnoteCallLabelMarker"),e.exit("gfmFootnoteCall"),t):n(d)}return ot(d)||(o=!0),s++,e.consume(d),d===92?u:c}function u(d){return d===91||d===92||d===93?(e.consume(d),s++,c):c(d)}}function rQ(e,t,n){const r=this,i=r.parser.gfmFootnotes||(r.parser.gfmFootnotes=[]);let s,o=0,a;return l;function l(m){return e.enter("gfmFootnoteDefinition")._container=!0,e.enter("gfmFootnoteDefinitionLabel"),e.enter("gfmFootnoteDefinitionLabelMarker"),e.consume(m),e.exit("gfmFootnoteDefinitionLabelMarker"),c}function c(m){return m===94?(e.enter("gfmFootnoteDefinitionMarker"),e.consume(m),e.exit("gfmFootnoteDefinitionMarker"),e.enter("gfmFootnoteDefinitionLabelString"),e.enter("chunkString").contentType="string",u):n(m)}function u(m){if(o>999||m===93&&!a||m===null||m===91||ot(m))return n(m);if(m===93){e.exit("chunkString");const v=e.exit("gfmFootnoteDefinitionLabelString");return s=Mr(r.sliceSerialize(v)),e.enter("gfmFootnoteDefinitionLabelMarker"),e.consume(m),e.exit("gfmFootnoteDefinitionLabelMarker"),e.exit("gfmFootnoteDefinitionLabel"),f}return ot(m)||(a=!0),o++,e.consume(m),m===92?d:u}function d(m){return m===91||m===92||m===93?(e.consume(m),o++,u):u(m)}function f(m){return m===58?(e.enter("definitionMarker"),e.consume(m),e.exit("definitionMarker"),i.includes(s)||i.push(s),Ge(e,p,"gfmFootnoteDefinitionWhitespace")):n(m)}function p(m){return t(m)}}function iQ(e,t,n){return e.check(Tu,t,e.attempt(ZX,t,n))}function sQ(e){e.exit("gfmFootnoteDefinition")}function oQ(e,t,n){const r=this;return Ge(e,i,"gfmFootnoteDefinitionIndent",5);function i(s){const o=r.events[r.events.length-1];return o&&o[1].type==="gfmFootnoteDefinitionIndent"&&o[2].sliceSerialize(o[1],!0).length===4?t(s):n(s)}}function aQ(e){let n=(e||{}).singleTilde;const r={name:"strikethrough",tokenize:s,resolveAll:i};return n==null&&(n=!0),{text:{126:r},insideSpan:{null:[r]},attentionMarkers:{null:[126]}};function i(o,a){let l=-1;for(;++l<o.length;)if(o[l][0]==="enter"&&o[l][1].type==="strikethroughSequenceTemporary"&&o[l][1]._close){let c=l;for(;c--;)if(o[c][0]==="exit"&&o[c][1].type==="strikethroughSequenceTemporary"&&o[c][1]._open&&o[l][1].end.offset-o[l][1].start.offset===o[c][1].end.offset-o[c][1].start.offset){o[l][1].type="strikethroughSequence",o[c][1].type="strikethroughSequence";const u={type:"strikethrough",start:Object.assign({},o[c][1].start),end:Object.assign({},o[l][1].end)},d={type:"strikethroughText",start:Object.assign({},o[c][1].end),end:Object.assign({},o[l][1].start)},f=[["enter",u,a],["enter",o[c][1],a],["exit",o[c][1],a],["enter",d,a]],p=a.parser.constructs.insideSpan.null;p&&er(f,f.length,0,kp(p,o.slice(c+1,l),a)),er(f,f.length,0,[["exit",d,a],["enter",o[l][1],a],["exit",o[l][1],a],["exit",u,a]]),er(o,c-1,l-c+3,f),l=c+f.length-2;break}}for(l=-1;++l<o.length;)o[l][1].type==="strikethroughSequenceTemporary"&&(o[l][1].type="data");return o}function s(o,a,l){const c=this.previous,u=this.events;let d=0;return f;function f(m){return c===126&&u[u.length-1][1].type!=="characterEscape"?l(m):(o.enter("strikethroughSequenceTemporary"),p(m))}function p(m){const v=Wa(c);if(m===126)return d>1?l(m):(o.consume(m),d++,p);if(d<2&&!n)return l(m);const b=o.exit("strikethroughSequenceTemporary"),_=Wa(m);return b._open=!_||_===2&&!!v,b._close=!v||v===2&&!!_,a(m)}}}class lQ{constructor(){this.map=[]}add(t,n,r){cQ(this,t,n,r)}consume(t){if(this.map.sort(function(s,o){return s[0]-o[0]}),this.map.length===0)return;let n=this.map.length;const r=[];for(;n>0;)n-=1,r.push(t.slice(this.map[n][0]+this.map[n][1]),this.map[n][2]),t.length=this.map[n][0];r.push(t.slice()),t.length=0;let i=r.pop();for(;i;){for(const s of i)t.push(s);i=r.pop()}this.map.length=0}}function cQ(e,t,n,r){let i=0;if(!(n===0&&r.length===0)){for(;i<e.map.length;){if(e.map[i][0]===t){e.map[i][1]+=n,e.map[i][2].push(...r);return}i+=1}e.map.push([t,n,r])}}function uQ(e,t){let n=!1;const r=[];for(;t<e.length;){const i=e[t];if(n){if(i[0]==="enter")i[1].type==="tableContent"&&r.push(e[t+1][1].type==="tableDelimiterMarker"?"left":"none");else if(i[1].type==="tableContent"){if(e[t-1][1].type==="tableDelimiterMarker"){const s=r.length-1;r[s]=r[s]==="left"?"center":"right"}}else if(i[1].type==="tableDelimiterRow")break}else i[0]==="enter"&&i[1].type==="tableDelimiterRow"&&(n=!0);t+=1}return r}function dQ(){return{flow:{null:{name:"table",tokenize:hQ,resolveAll:fQ}}}}function hQ(e,t,n){const r=this;let i=0,s=0,o;return a;function a(P){let B=r.events.length-1;for(;B>-1;){const j=r.events[B][1].type;if(j==="lineEnding"||j==="linePrefix")B--;else break}const R=B>-1?r.events[B][1].type:null,I=R==="tableHead"||R==="tableRow"?k:l;return I===k&&r.parser.lazy[r.now().line]?n(P):I(P)}function l(P){return e.enter("tableHead"),e.enter("tableRow"),c(P)}function c(P){return P===124||(o=!0,s+=1),u(P)}function u(P){return P===null?n(P):be(P)?s>1?(s=0,r.interrupt=!0,e.exit("tableRow"),e.enter("lineEnding"),e.consume(P),e.exit("lineEnding"),p):n(P):Ue(P)?Ge(e,u,"whitespace")(P):(s+=1,o&&(o=!1,i+=1),P===124?(e.enter("tableCellDivider"),e.consume(P),e.exit("tableCellDivider"),o=!0,u):(e.enter("data"),d(P)))}function d(P){return P===null||P===124||ot(P)?(e.exit("data"),u(P)):(e.consume(P),P===92?f:d)}function f(P){return P===92||P===124?(e.consume(P),d):d(P)}function p(P){return r.interrupt=!1,r.parser.lazy[r.now().line]?n(P):(e.enter("tableDelimiterRow"),o=!1,Ue(P)?Ge(e,m,"linePrefix",r.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(P):m(P))}function m(P){return P===45||P===58?b(P):P===124?(o=!0,e.enter("tableCellDivider"),e.consume(P),e.exit("tableCellDivider"),v):C(P)}function v(P){return Ue(P)?Ge(e,b,"whitespace")(P):b(P)}function b(P){return P===58?(s+=1,o=!0,e.enter("tableDelimiterMarker"),e.consume(P),e.exit("tableDelimiterMarker"),_):P===45?(s+=1,_(P)):P===null||be(P)?w(P):C(P)}function _(P){return P===45?(e.enter("tableDelimiterFiller"),x(P)):C(P)}function x(P){return P===45?(e.consume(P),x):P===58?(o=!0,e.exit("tableDelimiterFiller"),e.enter("tableDelimiterMarker"),e.consume(P),e.exit("tableDelimiterMarker"),y):(e.exit("tableDelimiterFiller"),y(P))}function y(P){return Ue(P)?Ge(e,w,"whitespace")(P):w(P)}function w(P){return P===124?m(P):P===null||be(P)?!o||i!==s?C(P):(e.exit("tableDelimiterRow"),e.exit("tableHead"),t(P)):C(P)}function C(P){return n(P)}function k(P){return e.enter("tableRow"),T(P)}function T(P){return P===124?(e.enter("tableCellDivider"),e.consume(P),e.exit("tableCellDivider"),T):P===null||be(P)?(e.exit("tableRow"),t(P)):Ue(P)?Ge(e,T,"whitespace")(P):(e.enter("data"),N(P))}function N(P){return P===null||P===124||ot(P)?(e.exit("data"),T(P)):(e.consume(P),P===92?z:N)}function z(P){return P===92||P===124?(e.consume(P),N):N(P)}}function fQ(e,t){let n=-1,r=!0,i=0,s=[0,0,0,0],o=[0,0,0,0],a=!1,l=0,c,u,d;const f=new lQ;for(;++n<e.length;){const p=e[n],m=p[1];p[0]==="enter"?m.type==="tableHead"?(a=!1,l!==0&&(Sk(f,t,l,c,u),u=void 0,l=0),c={type:"table",start:Object.assign({},m.start),end:Object.assign({},m.end)},f.add(n,0,[["enter",c,t]])):m.type==="tableRow"||m.type==="tableDelimiterRow"?(r=!0,d=void 0,s=[0,0,0,0],o=[0,n+1,0,0],a&&(a=!1,u={type:"tableBody",start:Object.assign({},m.start),end:Object.assign({},m.end)},f.add(n,0,[["enter",u,t]])),i=m.type==="tableDelimiterRow"?2:u?3:1):i&&(m.type==="data"||m.type==="tableDelimiterMarker"||m.type==="tableDelimiterFiller")?(r=!1,o[2]===0&&(s[1]!==0&&(o[0]=o[1],d=Cd(f,t,s,i,void 0,d),s=[0,0,0,0]),o[2]=n)):m.type==="tableCellDivider"&&(r?r=!1:(s[1]!==0&&(o[0]=o[1],d=Cd(f,t,s,i,void 0,d)),s=o,o=[s[1],n,0,0])):m.type==="tableHead"?(a=!0,l=n):m.type==="tableRow"||m.type==="tableDelimiterRow"?(l=n,s[1]!==0?(o[0]=o[1],d=Cd(f,t,s,i,n,d)):o[1]!==0&&(d=Cd(f,t,o,i,n,d)),i=0):i&&(m.type==="data"||m.type==="tableDelimiterMarker"||m.type==="tableDelimiterFiller")&&(o[3]=n)}for(l!==0&&Sk(f,t,l,c,u),f.consume(t.events),n=-1;++n<t.events.length;){const p=t.events[n];p[0]==="enter"&&p[1].type==="table"&&(p[1]._align=uQ(t.events,n))}return e}function Cd(e,t,n,r,i,s){const o=r===1?"tableHeader":r===2?"tableDelimiter":"tableData",a="tableContent";n[0]!==0&&(s.end=Object.assign({},ea(t.events,n[0])),e.add(n[0],0,[["exit",s,t]]));const l=ea(t.events,n[1]);if(s={type:o,start:Object.assign({},l),end:Object.assign({},l)},e.add(n[1],0,[["enter",s,t]]),n[2]!==0){const c=ea(t.events,n[2]),u=ea(t.events,n[3]),d={type:a,start:Object.assign({},c),end:Object.assign({},u)};if(e.add(n[2],0,[["enter",d,t]]),r!==2){const f=t.events[n[2]],p=t.events[n[3]];if(f[1].end=Object.assign({},p[1].end),f[1].type="chunkText",f[1].contentType="text",n[3]>n[2]+1){const m=n[2]+1,v=n[3]-n[2]-1;e.add(m,v,[])}}e.add(n[3]+1,0,[["exit",d,t]])}return i!==void 0&&(s.end=Object.assign({},ea(t.events,i)),e.add(i,0,[["exit",s,t]]),s=void 0),s}function Sk(e,t,n,r,i){const s=[],o=ea(t.events,n);i&&(i.end=Object.assign({},o),s.push(["exit",i,t])),r.end=Object.assign({},o),s.push(["exit",r,t]),e.add(n+1,0,s)}function ea(e,t){const n=e[t],r=n[0]==="enter"?"start":"end";return n[1][r]}const pQ={name:"tasklistCheck",tokenize:gQ};function mQ(){return{text:{91:pQ}}}function gQ(e,t,n){const r=this;return i;function i(l){return r.previous!==null||!r._gfmTasklistFirstContentOfListItem?n(l):(e.enter("taskListCheck"),e.enter("taskListCheckMarker"),e.consume(l),e.exit("taskListCheckMarker"),s)}function s(l){return ot(l)?(e.enter("taskListCheckValueUnchecked"),e.consume(l),e.exit("taskListCheckValueUnchecked"),o):l===88||l===120?(e.enter("taskListCheckValueChecked"),e.consume(l),e.exit("taskListCheckValueChecked"),o):n(l)}function o(l){return l===93?(e.enter("taskListCheckMarker"),e.consume(l),e.exit("taskListCheckMarker"),e.exit("taskListCheck"),a):n(l)}function a(l){return be(l)?t(l):Ue(l)?e.check({tokenize:vQ},t,n)(l):n(l)}}function vQ(e,t,n){return Ge(e,r,"whitespace");function r(i){return i===null?n(i):t(i)}}function _Q(e){return VR([UX(),JX(),aQ(e),dQ(),mQ()])}const xQ={};function ru(e){const t=this,n=e||xQ,r=t.data(),i=r.micromarkExtensions||(r.micromarkExtensions=[]),s=r.fromMarkdownExtensions||(r.fromMarkdownExtensions=[]),o=r.toMarkdownExtensions||(r.toMarkdownExtensions=[]);i.push(_Q(n)),s.push(zX()),o.push($X(n))}const yQ=/<command-name>([\s\S]*?)<\/command-name>/i,bQ=/<command-message>([\s\S]*?)<\/command-message>/i,wQ=/<command-args>([\s\S]*?)<\/command-args>/i,SQ=/<(local-command-[a-z]+|command-(?:stdout|stderr))>[\s\S]*?<\/\1>/gi;function Np(e){if(!e)return{commandName:null,commandMessage:null,commandArgs:null,body:""};const t=e.match(yQ),n=e.match(bQ),r=e.match(wQ);let i=e;return t&&(i=i.replace(t[0],"")),n&&(i=i.replace(n[0],"")),r&&(i=i.replace(r[0],"")),i=i.replace(SQ,""),i=i.trim(),{commandName:t?t[1].trim():null,commandMessage:n?n[1].trim():null,commandArgs:r?r[1].trim():null,body:i}}function Pp(e){if(!e)return!1;const n=e.split("#")[0].split("?")[0].toLowerCase();return n.endsWith(".md")||n.endsWith(".markdown")}function kQ(e){if(!e)return null;let t;if(e.startsWith("file://")){const n=e.slice(7);t=n.startsWith("/")?n:`/${n.split("/").slice(1).join("/")}`}else{if(/^[a-z][a-z0-9+.-]*:/i.test(e))return null;if(e.startsWith("/"))t=e;else return null}try{return decodeURIComponent(t)}catch{return t}}const CQ=/\.(png|jpe?g|webp|gif|svg)$/i;function EQ(e,t){if((typeof t=="string"?t:null)!==e)return!1;try{const r=new URL(e);return CQ.test(r.pathname)}catch{return!1}}function TQ(e){try{return new URL(e).pathname.split("/").filter(Boolean).pop()??""}catch{return""}}const So={a:({node:e,href:t,children:n,...r})=>typeof t=="string"&&EQ(t,n)?h.jsxs("span",{className:"my-1 inline-flex flex-col items-start gap-1 align-top",children:[h.jsx("img",{src:t,alt:TQ(t),className:"max-w-full h-auto rounded border border-border"}),h.jsx("a",{href:t,target:"_blank",rel:"noopener noreferrer",className:"max-w-full truncate text-[11px] text-text-300 underline decoration-dotted underline-offset-2 hover:text-text-100",children:t})]}):h.jsx("a",{...r,href:t,target:"_blank",rel:"noopener noreferrer",children:n})};function NQ(e){return e.startsWith("file://")?e:fM(e)}function PQ(e){return{...So,a:t=>{const{href:n,children:r}=t,i=typeof n=="string"?kQ(n):null;if(i===null){const s=So.a;return h.jsx(s,{...t})}return h.jsx("a",{href:n,"data-testid":"assistant-file-link",title:i,onClick:s=>{s.preventDefault(),e(i)},children:r})}}}function IQ({text:e,forkTarget:t,onOpenFilePath:n}){const{body:r}=Np(e),i=Ze.useMemo(()=>n?PQ(n):So,[n]);return r?h.jsxs("div",{className:"group relative flex min-w-0 max-w-full flex-col items-start","data-testid":"msg-line-assistant-wrapper",children:[h.jsx("div",{"data-testid":"msg-line-assistant",className:"assistant-markdown w-full min-w-0 max-w-full py-1 break-words",children:h.jsx(tu,{remarkPlugins:[ru],components:i,...n?{urlTransform:NQ}:{},children:r})}),t?h.jsxs("div",{className:"mt-1 flex flex-row items-center gap-1 md:absolute md:top-full md:mt-0 md:pt-0.5 md:z-10 md:rounded-md md:pointer-events-none md:group-hover:pointer-events-auto md:group-hover:bg-bg-100",children:[t.onFork?h.jsxs("button",{type:"button","data-testid":"assistant-msg-fork","aria-label":"fork from this message",title:"从这条消息派生新 session(截断之后的对话)",onClick:()=>t.onFork(t.messageUuid),className:"inline-flex items-center justify-start gap-1 h-7 w-7 md:h-6 md:w-auto md:px-1.5 rounded-md text-[11px] text-text-400/60 md:text-text-400 hover:bg-text-100/5 hover:text-text-200 md:opacity-0 md:group-hover:opacity-100 md:transition-opacity cursor-pointer",children:[h.jsx(zx,{className:"w-3 h-3",strokeWidth:2}),h.jsx("span",{className:"hidden md:inline",children:"Fork"})]}):null,t.onQuickAsk?h.jsxs("button",{type:"button","data-testid":"assistant-msg-quick-ask","aria-label":"quick ask from this message",title:"快速问答:从这条消息派生临时会话,关闭即删",onClick:()=>t.onQuickAsk(t.messageUuid),className:"inline-flex items-center justify-start gap-1 h-7 w-7 md:h-6 md:w-auto md:px-1.5 rounded-md text-[11px] text-text-400/60 md:text-text-400 hover:bg-text-100/5 hover:text-text-200 md:opacity-0 md:group-hover:opacity-100 md:transition-opacity cursor-pointer",children:[h.jsx(Wz,{className:"w-3 h-3",strokeWidth:2}),h.jsx("span",{className:"hidden md:inline",children:"问一下"})]}):null]}):null]}):null}function RQ({text:e}){const[t,n]=g.useState(!1);return e?h.jsxs("div",{"data-testid":"msg-line-thinking",className:"text-[12px] text-text-400",children:[h.jsxs("button",{type:"button",onClick:()=>n(r=>!r),className:"flex items-center gap-1 hover:text-text-300 transition-colors cursor-pointer","aria-expanded":t,"data-testid":"msg-line-thinking-toggle",children:[t?h.jsx(ir,{className:"w-3 h-3"}):h.jsx(Un,{className:"w-3 h-3"}),h.jsx("span",{children:"💭 Thinking"})]}),t?h.jsx("div",{className:"ml-4 mt-1 italic text-text-400 whitespace-pre-wrap break-words",children:e}):null]}):null}const MQ=new Set(["Write","Edit","MultiEdit","NotebookEdit"]);function O0(e){return MQ.has(e)}function AQ({tool:e,relPath:t,scope:n,onShareFile:r}){if(!O0(e)||!t||!n||!r)return null;const i=Pp(t)?"md-rendered":"raw";return h.jsx("span",{"data-testid":"file-edit-hover-row",className:"inline-flex shrink-0 items-center gap-1",children:h.jsx("span",{role:"button",tabIndex:0,"data-testid":"file-edit-share-btn","aria-label":"Share link",title:"Share link",onClick:s=>{s.stopPropagation(),r(t,i)},onKeyDown:s=>{(s.key==="Enter"||s.key===" ")&&(s.stopPropagation(),s.preventDefault(),r(t,i))},className:"inline-flex h-3.5 w-3.5 items-center justify-center text-text-400 hover:text-text-200 cursor-pointer",children:h.jsx($x,{className:"h-3.5 w-3.5"})})})}function LQ(e){if(!e||typeof e!="object")return null;const t=e;return typeof t.file_path=="string"&&t.file_path||typeof t.notebook_path=="string"&&t.notebook_path||typeof t.path=="string"&&t.path||null||null}function OM(e,t){const[n,r]=g.useState({kind:"idle"});return g.useEffect(()=>{let i=!1,s=null;r({kind:"loading"});const o={};return t&&(o.Authorization=`Bearer ${t}`),fetch(e,{headers:o,credentials:"omit"}).then(async a=>{if(!a.ok)throw new Error(`HTTP ${a.status}`);return a.blob()}).then(a=>{if(i)return;const l=URL.createObjectURL(a);s=l,r({kind:"ready",objectUrl:l})}).catch(a=>{i||r({kind:"error",message:a.message})}),()=>{i=!0,s&&URL.revokeObjectURL(s)}},[e,t]),n}function jQ({url:e,bearerToken:t,alt:n,className:r}){const i=OM(e,t);return h.jsxs("div",{"data-testid":"blob-image","data-state":i.kind,className:fe("relative inline-flex items-center justify-center rounded-md border border-border bg-bg-0",r),children:[i.kind==="loading"?h.jsx("div",{className:"flex h-24 w-32 items-center justify-center",children:h.jsx(In,{className:"h-4 w-4 animate-spin text-text-400"})}):null,i.kind==="error"?h.jsxs("div",{className:"flex h-24 w-32 items-center justify-center gap-1 px-2 text-[11px] text-text-400",children:[h.jsx(Ls,{className:"h-3 w-3"}),h.jsx("span",{title:i.message,children:"加载失败"})]}):null,i.kind==="ready"?h.jsx("img",{src:i.objectUrl,alt:n,className:"block max-h-[180px] max-w-[420px] rounded-md object-contain"}):null]})}function DQ({url:e,bearerToken:t,className:n}){const r=OM(e,t);return h.jsxs("div",{"data-testid":"blob-video","data-state":r.kind,className:fe("relative inline-flex items-center justify-center rounded-md border border-border bg-bg-0",n),children:[r.kind==="loading"?h.jsx(In,{className:"h-4 w-4 animate-spin text-text-400"}):null,r.kind==="error"?h.jsx("span",{className:"px-2 text-[11px] text-text-400",children:"加载失败"}):null,r.kind==="ready"?h.jsx("video",{src:r.objectUrl,controls:!0,className:"block max-h-[240px] max-w-[420px] rounded-md"}):null]})}const OQ=new Set([".png",".jpg",".jpeg",".gif",".webp",".svg"]),BQ=new Set([".mp4",".webm",".mov"]),zQ=new Set([".pdf"]);function $Q(e){const t=e.lastIndexOf("."),n=t>=0?e.slice(t).toLowerCase():"";return OQ.has(n)?"image":BQ.has(n)?"video":zQ.has(n)?"pdf":"binary"}function BM(e){return e<1024?`${e} B`:e<1024*1024?`${(e/1024).toFixed(1)} KB`:`${(e/1024/1024).toFixed(1)} MB`}function FQ({relPath:e,scope:t,size:n}){const r=tp();if(r.actionsLevel==="none")return null;const i=xB(r,t,e);if(!i)return null;const s=$Q(e);return s==="image"?h.jsx("div",{"data-testid":"file-edit-inline-preview","data-kind":"image",className:"mt-2",children:h.jsx(jQ,{url:i,bearerToken:r.httpToken,alt:e})}):s==="video"?h.jsx("div",{"data-testid":"file-edit-inline-preview","data-kind":"video",className:"mt-2",children:h.jsx(DQ,{url:i,bearerToken:r.httpToken})}):s==="pdf"?h.jsx(HQ,{relPath:e,url:i,size:n}):typeof n=="number"&&n>=1024*1024?h.jsxs("div",{"data-testid":"file-edit-inline-preview","data-kind":"binary",className:"mt-2 inline-flex items-center gap-1.5 rounded border border-border bg-bg-50 px-2 py-1 text-[11px] text-text-400",children:[h.jsx(Ro,{className:"h-3 w-3"}),h.jsx("span",{className:"font-mono",children:e.split("/").pop()}),h.jsx("span",{children:"·"}),h.jsx("span",{children:BM(n)})]}):null}function HQ({relPath:e,url:t,size:n}){return h.jsxs("a",{"data-testid":"file-edit-inline-preview","data-kind":"pdf",href:t,target:"_blank",rel:"noopener noreferrer",className:"mt-2 inline-flex items-center gap-1.5 rounded border border-border bg-bg-50 px-2 py-1 text-[11px] text-text-300 hover:bg-bg-100",children:[h.jsx(Ro,{className:"h-3 w-3"}),h.jsx("span",{className:"font-mono",children:e.split("/").pop()}),typeof n=="number"?h.jsxs(h.Fragment,{children:[h.jsx("span",{children:"·"}),h.jsx("span",{children:BM(n)})]}):null,h.jsx(qc,{className:"h-3 w-3"})]})}const UQ={Bash:UN,Read:Ro,Edit:HN,Write:Nz,Grep:Rw,Glob:Rw};function WQ(e){return UQ[e]??R$}function VQ(e){if(!e||typeof e!="object")return"";const t=e,n=t.command??t.file_path??t.path??t.pattern??t.query??t.url??t.description;if(typeof n=="string")return n;for(const r of Object.values(t))if(typeof r=="string"&&r)return r;return""}function zM({tool:e,input:t,output:n,error:r,pending:i=!1,expandedBody:s,fileScope:o,onOpenInTab:a,onPreviewMarkdown:l,onShareFile:c}){const[u,d]=g.useState(!1),f=!!r,p=WQ(e),m=VQ(t),v=LQ(t);return h.jsxs("div",{"data-testid":"msg-line-tool","data-tool":e,className:fe("group min-w-0 max-w-full rounded-md border px-3 py-2 text-[13px]",f?"border-destructive/40 bg-destructive/5":"border-border bg-bg-50"),children:[h.jsxs("button",{type:"button",onClick:()=>d(b=>!b),"aria-expanded":u,"data-testid":"msg-line-tool-header",className:"flex w-full items-center gap-2 text-left cursor-pointer min-w-0",children:[f?h.jsx(Ls,{className:"w-4 h-4 text-destructive shrink-0"}):h.jsx(p,{className:fe("w-4 h-4 shrink-0",i?"text-text-400":"text-text-300")}),h.jsx("span",{className:"font-medium text-text-100 shrink-0",children:e}),m?(()=>{if(f||!O0(e)||!v)return null;const _=Pp(v)&&l?l:a;return _?h.jsx("span",{role:"button",tabIndex:0,"data-testid":"msg-line-tool-preview","data-clickable":"true",title:m,onClick:x=>{x.stopPropagation(),_(v)},onKeyDown:x=>{(x.key==="Enter"||x.key===" ")&&(x.stopPropagation(),x.preventDefault(),_(v))},className:"text-[12px] text-accent font-mono truncate min-w-0 max-w-full cursor-pointer underline underline-offset-2 hover:opacity-80",children:m}):null})()??h.jsx("span",{"data-testid":"msg-line-tool-preview",className:"text-[12px] text-text-400 font-mono truncate min-w-0 max-w-full",title:m,children:m}):null,h.jsx("span",{"aria-hidden":"true","data-testid":"msg-line-tool-header-spacer",className:"flex-1 min-w-0 self-stretch"}),i?h.jsx(In,{"data-testid":"msg-line-tool-pending",className:"w-3 h-3 text-text-400 animate-spin shrink-0"}):null,!f&&o?h.jsx(AQ,{tool:e,relPath:v,scope:o,...c?{onShareFile:c}:{}}):null]}),u?s!==void 0?h.jsxs("div",{"data-testid":"msg-line-tool-body",className:"mt-2 min-w-0 text-[12px]",children:[s,f?h.jsxs("div",{className:"mt-2",children:[h.jsx("div",{className:"text-destructive mb-0.5",children:"error"}),h.jsx("pre",{className:"min-w-0 max-w-full bg-bg-0 border border-destructive/40 rounded p-2 overflow-auto text-destructive",children:String(r)})]}):null]}):h.jsxs("div",{"data-testid":"msg-line-tool-body",className:"mt-2 min-w-0 space-y-1 text-[12px]",children:[h.jsxs("div",{children:[h.jsx("div",{className:"text-text-400 mb-0.5",children:"input"}),h.jsx("pre",{className:"min-w-0 max-w-full bg-bg-0 border border-border rounded p-2 overflow-auto text-text-200",children:JSON.stringify(t,null,2)})]}),n!==void 0?h.jsxs("div",{children:[h.jsx("div",{className:"text-text-400 mb-0.5",children:"output"}),h.jsx("pre",{className:"min-w-0 max-w-full bg-bg-0 border border-border rounded p-2 overflow-auto text-text-200",children:typeof n=="string"?n:JSON.stringify(n,null,2)})]}):null,f?h.jsxs("div",{children:[h.jsx("div",{className:"text-destructive mb-0.5",children:"error"}),h.jsx("pre",{className:"min-w-0 max-w-full bg-bg-0 border border-destructive/40 rounded p-2 overflow-auto text-destructive",children:String(r)})]}):null]}):null,!f&&o&&v&&O0(e)?h.jsx(FQ,{relPath:v,scope:o}):null]})}var qQ=Symbol.for("react.lazy"),uf=Qa[" use ".trim().toString()];function KQ(e){return typeof e=="object"&&e!==null&&"then"in e}function $M(e){return e!=null&&typeof e=="object"&&"$$typeof"in e&&e.$$typeof===qQ&&"_payload"in e&&KQ(e._payload)}function GQ(e){const t=XQ(e),n=g.forwardRef((r,i)=>{let{children:s,...o}=r;$M(s)&&typeof uf=="function"&&(s=uf(s._payload));const a=g.Children.toArray(s),l=a.find(ZQ);if(l){const c=l.props.children,u=a.map(d=>d===l?g.Children.count(c)>1?g.Children.only(null):g.isValidElement(c)?c.props.children:null:d);return h.jsx(t,{...o,ref:i,children:g.isValidElement(c)?g.cloneElement(c,void 0,u):null})}return h.jsx(t,{...o,ref:i,children:s})});return n.displayName=`${e}.Slot`,n}var YQ=GQ("Slot");function XQ(e){const t=g.forwardRef((n,r)=>{let{children:i,...s}=n;if($M(i)&&typeof uf=="function"&&(i=uf(i._payload)),g.isValidElement(i)){const o=eZ(i),a=JQ(s,i.props);return i.type!==g.Fragment&&(a.ref=r?vu(r,o):o),g.cloneElement(i,a)}return g.Children.count(i)>1?g.Children.only(null):null});return t.displayName=`${e}.SlotClone`,t}var QQ=Symbol("radix.slottable");function ZQ(e){return g.isValidElement(e)&&typeof e.type=="function"&&"__radixId"in e.type&&e.type.__radixId===QQ}function JQ(e,t){const n={...t};for(const r in t){const i=e[r],s=t[r];/^on[A-Z]/.test(r)?i&&s?n[r]=(...a)=>{const l=s(...a);return i(...a),l}:i&&(n[r]=i):r==="style"?n[r]={...i,...s}:r==="className"&&(n[r]=[i,s].filter(Boolean).join(" "))}return{...e,...n}}function eZ(e){var r,i;let t=(r=Object.getOwnPropertyDescriptor(e.props,"ref"))==null?void 0:r.get,n=t&&"isReactWarning"in t&&t.isReactWarning;return n?e.ref:(t=(i=Object.getOwnPropertyDescriptor(e,"ref"))==null?void 0:i.get,n=t&&"isReactWarning"in t&&t.isReactWarning,n?e.props.ref:e.props.ref||e.ref)}const kk=e=>typeof e=="boolean"?`${e}`:e===0?"0":e,Ck=KN,tZ=(e,t)=>n=>{var r;if((t==null?void 0:t.variants)==null)return Ck(e,n==null?void 0:n.class,n==null?void 0:n.className);const{variants:i,defaultVariants:s}=t,o=Object.keys(i).map(c=>{const u=n==null?void 0:n[c],d=s==null?void 0:s[c];if(u===null)return null;const f=kk(u)||kk(d);return i[c][f]}),a=n&&Object.entries(n).reduce((c,u)=>{let[d,f]=u;return f===void 0||(c[d]=f),c},{}),l=t==null||(r=t.compoundVariants)===null||r===void 0?void 0:r.reduce((c,u)=>{let{class:d,className:f,...p}=u;return Object.entries(p).every(m=>{let[v,b]=m;return Array.isArray(b)?b.includes({...s,...a}[v]):{...s,...a}[v]===b})?[...c,d,f]:c},[]);return Ck(e,o,l,n==null?void 0:n.class,n==null?void 0:n.className)},nZ=tZ("inline-flex items-center justify-center whitespace-nowrap rounded-md text-sm font-medium transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50",{variants:{variant:{default:"bg-accent text-accent-contrast hover:bg-accent-hover",destructive:"bg-destructive text-white hover:bg-destructive-hover",outline:"border border-border bg-transparent text-text-100 hover:bg-bg-200",ghost:"bg-transparent text-text-200 hover:bg-bg-200 hover:text-text-100"},size:{sm:"h-8 px-3 text-xs",md:"h-9 px-4",lg:"h-11 px-6 text-base"}},defaultVariants:{variant:"default",size:"md"}}),ni=g.forwardRef(({className:e,variant:t,size:n,asChild:r=!1,...i},s)=>{const o=r?YQ:"button";return h.jsx(o,{ref:s,className:fe(nZ({variant:t,size:n}),e),...i})});ni.displayName="Button";function rZ({tool:e,input:t,onRespond:n,onInterrupt:r}){return h.jsxs("div",{"data-testid":"msg-line-permission",className:"min-w-0 max-w-full rounded-md border border-warning/40 bg-warning-dim/60 px-3 py-2.5 text-[13px]",children:[h.jsxs("div",{className:"flex min-w-0 items-center gap-2 mb-1.5",children:[h.jsx(v$,{className:"w-4 h-4 text-warning shrink-0"}),h.jsxs("span",{className:"min-w-0 font-medium text-text-100 truncate",children:["权限请求:",e]}),r?h.jsx("button",{type:"button",onClick:r,"data-testid":"msg-line-permission-interrupt","aria-label":"interrupt current turn",title:"中断当前轮次(不杀进程)",className:"ml-auto h-6 w-6 rounded-md flex items-center justify-center text-text-400 hover:bg-text-100/10 hover:text-text-200 transition-colors cursor-pointer",children:h.jsx(FN,{className:"w-3.5 h-3.5",strokeWidth:2})}):null]}),h.jsx("pre",{className:"min-w-0 max-w-full bg-bg-0 border border-border rounded p-2 mb-2 max-h-[140px] overflow-auto text-[12px] text-text-200",children:JSON.stringify(t,null,2)}),h.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[h.jsx(ni,{size:"sm",variant:"default",onClick:()=>n(!0,!1),"data-testid":"msg-line-permission-allow",children:"Allow"}),h.jsx(ni,{size:"sm",variant:"outline",onClick:()=>n(!0,!0),"data-testid":"msg-line-permission-allow-always",children:"Allow Always"}),h.jsx(ni,{size:"sm",variant:"destructive",onClick:()=>n(!1,!1),"data-testid":"msg-line-permission-deny",children:"Deny"})]})]})}function iZ({message:e}){return h.jsxs("div",{"data-testid":"msg-line-error",className:"flex min-w-0 max-w-full items-start gap-2 text-destructive text-[13px] rounded-md border border-destructive/40 bg-destructive/5 px-3 py-2",children:[h.jsx(Kc,{className:"w-4 h-4 shrink-0 mt-0.5"}),h.jsx("span",{className:"min-w-0 whitespace-pre-wrap break-words [overflow-wrap:anywhere]",children:e})]})}const Ek=/\[attachment:(image|file):([^\]]+)\]/g;function sZ(e){const t=[];let n;for(;(n=Ek.exec(e))!==null;){const i=n[2],s=decodeURIComponent(i.split("/").pop()??"file");t.push({type:n[1],url:i,fileName:s})}const r=e.replace(Ek,"").trim();return{attachments:t,text:r}}function oZ(e,t){const n=t.filter(i=>i.status==="done"&&i.url);return n.length===0?e:n.map(i=>`[attachment:${i.mimeType.startsWith("image/")?"image":"file"}:${i.url}]`).join(`
509
509
  `)+`
510
510
  `+e}const aZ=/\[skill:(.+?):(\/[^\]]+)\]/g;function lZ(e){const t=[],n=e.replace(aZ,(r,i)=>(t.push(i),""));return{skills:t,text:t.length>0?n.trim():e}}function cZ({text:e,senderDisplayName:t,rewindTarget:n}){const r=IR(e),{attachments:i,text:s}=sZ(r),{skills:o,text:a}=lZ(s),{commandName:l,body:c}=Np(a),u=c.length>0;return u||i.length>0||!!l||o.length>0?(l||o.length>0)&&!u&&i.length===0?h.jsxs("div",{className:"flex min-w-0 max-w-full justify-end gap-1.5 py-2 mt-2","data-testid":"msg-line-user",children:[o.map((f,p)=>h.jsxs("span",{"data-testid":"user-skill-chip",className:"inline-flex items-center rounded-md bg-bg-200/60 px-2 py-0.5 text-[11px] font-mono text-text-300",children:["/",f]},`${f}-${p}`)),l?h.jsx("span",{className:"inline-flex items-center rounded-md bg-bg-200/60 px-2 py-0.5 text-[11px] font-mono text-text-300",children:l}):null]}):h.jsxs("div",{className:"group flex min-w-0 max-w-full flex-col items-end py-2 mt-2","data-testid":"msg-line-user",children:[h.jsxs("div",{className:"min-w-0 max-w-[85%] rounded-2xl rounded-br-sm bg-accent px-3.5 py-2 whitespace-pre-wrap break-words [overflow-wrap:anywhere]",children:[i.length>0?h.jsx(uZ,{attachments:i}):null,o.length>0?h.jsx("div",{className:fe("flex flex-wrap gap-1.5",(u||l)&&"mb-1.5"),children:o.map((f,p)=>h.jsxs("span",{"data-testid":"user-skill-chip",className:"inline-flex items-center rounded-md bg-white/15 px-2 py-0.5 text-[11px] font-mono text-white/90",children:["/",f]},`${f}-${p}`))}):null,l?h.jsx("div",{className:fe("flex",u&&"mb-1.5"),children:h.jsx("span",{"data-testid":"user-command-chip",className:"inline-flex items-center rounded-md bg-white/15 px-2 py-0.5 text-[11px] font-mono text-white/90",children:l})}):null,u?h.jsx("div",{className:"text-[14px] text-white font-medium leading-relaxed",children:c}):null]}),t?h.jsx("div",{"data-testid":"user-msg-sender-label",className:"mt-1 text-[11px] text-text-400",children:t}):null,n?h.jsxs("button",{type:"button","data-testid":"user-msg-rewind","aria-label":"rewind to this message",title:"回退到这条消息(会撤销之后 CC 的文件编辑)",onClick:()=>n.onRewind(n.userMessageId),className:"mt-1 inline-flex items-center gap-1 h-6 px-1.5 rounded-md text-[11px] text-text-400 hover:bg-text-100/5 hover:text-text-200 opacity-0 group-hover:opacity-100 transition-opacity cursor-pointer",children:[h.jsx(WN,{className:"w-3 h-3",strokeWidth:2}),h.jsx("span",{children:"Rewind"})]}):null]}):null}function uZ({attachments:e}){return h.jsx("div",{className:"flex flex-wrap gap-1.5 mb-1.5","data-testid":"user-attachment-row",children:e.map(t=>h.jsx(dZ,{attachment:t},t.url))})}function dZ({attachment:e}){return e.type==="image"?h.jsx("img",{src:e.url,alt:e.fileName,"data-testid":"user-attachment-image",className:"h-16 w-16 rounded object-cover shrink-0 border border-bg-300/50"}):h.jsxs("div",{"data-testid":"user-attachment-file",className:"flex items-center gap-1.5 rounded-md border border-bg-300 bg-bg-100/60 px-2 py-1 text-[12px] text-text-200",children:[h.jsx(Ro,{className:"h-3.5 w-3.5 text-text-400 shrink-0"}),h.jsx("span",{className:"max-w-[140px] truncate",children:e.fileName})]})}const hZ={"task-notification":"子任务通知","slash-command":"斜杠命令","local-command":"本地命令输出","system-reminder":"系统提醒","skill-hint":"Skill 注入","meta-text":"系统消息","attachment-skills":"技能列表","attachment-deferred-tools":"Deferred 工具变更"},fZ={"task-notification":Iw,"slash-command":y$,"local-command":UN,"system-reminder":Iw,"skill-hint":d0,"meta-text":$N,"attachment-skills":d0,"attachment-deferred-tools":a$};function pZ({metaKind:e,text:t}){const[n,r]=g.useState(!1),i=fZ[e];if(e==="slash-command"){const{commandName:o,commandMessage:a,commandArgs:l,body:c}=Np(t),u=o??(a?`/${a}`:null),d=!!(l&&l.length>0),f=c.length>0;return!u&&!d&&!f?null:h.jsxs("div",{"data-testid":"msg-line-user-meta","data-meta-kind":e,className:"flex min-w-0 max-w-full flex-col items-end gap-0.5 py-1",children:[h.jsxs("div",{className:"flex min-w-0 items-center gap-2 max-w-full",children:[u?h.jsxs("span",{className:"inline-flex items-center gap-1.5 rounded-md bg-bg-200/60 px-2 py-0.5 text-[11px] font-mono text-text-300 shrink-0",children:[h.jsx(i,{className:"w-3 h-3 opacity-70"}),u]}):null,d?h.jsx("span",{"data-testid":"user-meta-command-args",className:"min-w-0 text-[12px] text-text-200 whitespace-pre-wrap break-words max-w-[70ch] [overflow-wrap:anywhere]",children:l}):null]}),f?h.jsx("span",{className:"ml-2 max-w-[60%] truncate text-[11px] text-text-400",children:c}):null]})}const s=t.replace(/\s+/g," ").trim().slice(0,80);return h.jsxs("div",{"data-testid":"msg-line-user-meta","data-meta-kind":e,className:"flex min-w-0 max-w-full flex-col items-start gap-1 py-1",children:[h.jsxs("button",{type:"button","aria-expanded":n,onClick:()=>r(o=>!o),className:fe("group inline-flex items-center gap-1.5 rounded-md border border-bg-200/60 bg-bg-100/40","px-2 py-1 text-[11px] text-text-400 hover:bg-bg-200/40 transition-colors max-w-full"),children:[h.jsx(i,{className:"w-3 h-3 opacity-70 shrink-0"}),h.jsx("span",{className:"font-medium shrink-0",children:hZ[e]}),h.jsx("span",{className:"truncate text-text-400/80 max-w-[60ch]",children:s}),n?h.jsx(ir,{className:"w-3 h-3 opacity-60 shrink-0"}):h.jsx(Un,{className:"w-3 h-3 opacity-60 shrink-0"})]}),n?h.jsx("pre",{"data-testid":"user-meta-body",className:"w-full max-w-full whitespace-pre-wrap break-words text-[11px] text-text-400 bg-bg-50/60 rounded-md p-2 border border-bg-200/60 [overflow-wrap:anywhere]",children:t}):null]})}function mZ({text:e,metaSource:t}){return t==="owner"?h.jsx("div",{className:"flex min-w-0 max-w-full flex-col items-start py-1.5","data-testid":"msg-line-owner-meta",children:h.jsxs("div",{className:fe("inline-flex min-w-0 max-w-[85%] items-start gap-2 rounded-md","border-l-[3px] border-accent bg-accent-dim px-3 py-2"),children:[h.jsx(qz,{className:"mt-0.5 h-3.5 w-3.5 shrink-0 text-accent","aria-label":"补充信息"}),h.jsx("span",{className:"min-w-0 text-[12px] leading-relaxed text-text-100 whitespace-pre-wrap break-words [overflow-wrap:anywhere]",children:e})]})}):h.jsxs("div",{className:"flex min-w-0 max-w-full items-start gap-1.5 py-1 text-[11px] text-text-400","data-testid":"msg-line-cc-meta",children:[h.jsx($N,{className:"mt-0.5 h-3 w-3 shrink-0"}),h.jsx("span",{className:"min-w-0 whitespace-pre-wrap break-words [overflow-wrap:anywhere]",children:e})]})}function zr(e,t){const r=new RegExp(`<${t}\\b[^>]*>([\\s\\S]*?)</${t}>`,"i").exec(e);if(!r)return;const i=r[1].trim();return i||void 0}function rg(e,t){const r=new RegExp(`${t}\\s*=\\s*"([^"]+)"`,"i").exec(e);if(!r)return;const i=Number(r[1]);return Number.isFinite(i)?i:void 0}function FM(e){var i,s,o;const t={};if(!e)return t;t.taskId=zr(e,"task-id"),t.toolUseId=zr(e,"tool-use-id"),t.outputFile=zr(e,"output-file"),t.status=zr(e,"status"),t.summary=zr(e,"summary"),t.result=zr(e,"result");const n=zr(e,"usage");if(n){const a=(i=/<total_tokens>\s*(\d+)\s*<\/total_tokens>/i.exec(n))==null?void 0:i[1],l=(s=/<tool_uses>\s*(\d+)\s*<\/tool_uses>/i.exec(n))==null?void 0:s[1],c=(o=/<duration_ms>\s*(\d+)\s*<\/duration_ms>/i.exec(n))==null?void 0:o[1];a&&(t.totalTokens=Number(a)),l&&(t.toolUses=Number(l)),c&&(t.durationMs=Number(c))}const r=zr(e,"worktree");if(r)t.worktreePath=zr(r,"worktreePath"),t.worktreeBranch=zr(r,"worktreeBranch");else{const a=/<worktree\b([^>]*)\/>/i.exec(e);if(a){const l=a[1],c=/worktreePath\s*=\s*"([^"]+)"/i.exec(l),u=/worktreeBranch\s*=\s*"([^"]+)"/i.exec(l);c&&(t.worktreePath=c[1]),u&&(t.worktreeBranch=u[1])}}if(t.totalTokens===void 0&&t.toolUses===void 0&&t.durationMs===void 0){const a=rg(e,"total_tokens"),l=rg(e,"tool_uses"),c=rg(e,"duration_ms");a!==void 0&&(t.totalTokens=a),l!==void 0&&(t.toolUses=l),c!==void 0&&(t.durationMs=c)}return t}function gZ(e){if(!e||!Number.isFinite(e))return null;if(e<1e3)return`${e}ms`;const t=e/1e3;if(t<60)return`${t.toFixed(1)}s`;const n=Math.floor(t/60),r=Math.round(t-n*60);return`${n}m${r.toString().padStart(2,"0")}s`}function vZ({text:e,taskId:t,parentToolUseId:n}){const r=g.useMemo(()=>FM(e),[e]),[i,s]=g.useState(!1),o=t??r.taskId,a=n??r.toolUseId,l=r.status==="failed"?h.jsx(Ls,{className:"w-3.5 h-3.5 text-error"}):r.status==="completed"?h.jsx(rp,{className:"w-3.5 h-3.5 text-success"}):h.jsx(np,{className:"w-3.5 h-3.5 text-text-400"}),c=r.status??"unknown",u=gZ(r.durationMs);return h.jsxs("div",{"data-testid":"msg-line-agent-notification","data-task-id":o??"","data-parent-tool-use-id":a??"",className:"my-1 min-w-0 max-w-full rounded-md border border-bg-200/60 bg-bg-100/40",children:[h.jsxs("button",{type:"button","aria-expanded":i,onClick:()=>s(d=>!d),className:fe("flex w-full min-w-0 items-start gap-2 px-2.5 py-1.5 text-left text-[12px]","hover:bg-bg-200/40 rounded-md transition-colors"),children:[h.jsx("span",{className:"mt-[2px] shrink-0",children:l}),h.jsxs("span",{className:"flex-1 min-w-0",children:[h.jsxs("span",{className:"flex items-center gap-2 flex-wrap",children:[h.jsx("span",{className:"font-medium text-text-200",children:"子任务"}),h.jsx("span",{className:"text-text-400 text-[11px] font-mono",children:o?o.slice(0,12):"未知"}),h.jsx("span",{className:"text-text-400 text-[11px] uppercase tracking-wide",children:c}),u?h.jsxs("span",{className:"text-text-400 text-[11px] tabular-nums",children:["· ",u]}):null,r.totalTokens?h.jsxs("span",{className:"text-text-400 text-[11px] tabular-nums",children:["· ",r.totalTokens," tok"]}):null,r.toolUses?h.jsxs("span",{className:"text-text-400 text-[11px] tabular-nums",children:["· ",r.toolUses," tools"]}):null]}),r.summary?h.jsx("span",{className:"block truncate text-text-300 text-[12px] mt-0.5",children:r.summary}):null]}),i?h.jsx(ir,{className:"w-3.5 h-3.5 mt-[3px] text-text-400 shrink-0"}):h.jsx(Un,{className:"w-3.5 h-3.5 mt-[3px] text-text-400 shrink-0"})]}),i?h.jsxs("div",{"data-testid":"agent-notification-body",className:"min-w-0 border-t border-bg-200/60 px-3 py-2 text-[12px] text-text-300 space-y-2",children:[r.worktreePath||r.worktreeBranch?h.jsxs("div",{className:"flex items-center gap-2 text-[11px] text-text-400",children:[h.jsx(zx,{className:"w-3 h-3"}),r.worktreeBranch?h.jsx("span",{className:"font-mono",children:r.worktreeBranch}):null,r.worktreePath?h.jsx("span",{className:"truncate font-mono",children:r.worktreePath}):null]}):null,r.outputFile?h.jsxs("div",{className:"text-[11px] text-text-400",children:[h.jsx("span",{children:"输出文件:"}),h.jsx("span",{className:"font-mono",children:r.outputFile})]}):null,a?h.jsxs("div",{className:"text-[11px] text-text-400",children:[h.jsx("span",{children:"父工具调用:"}),h.jsx("span",{className:"font-mono",children:a})]}):null,r.result?h.jsx("div",{"data-testid":"agent-notification-result",className:"assistant-markdown text-[12px] leading-relaxed break-words",children:h.jsx(tu,{remarkPlugins:[ru],components:So,children:r.result})}):h.jsx("div",{className:"text-[11px] text-text-400 italic",children:"无详细结果"})]}):null]})}const HM=g.createContext(null);function _Z({children:e}){const[t,n]=g.useState({agentId:null}),r=g.useCallback((o,a)=>{n({agentId:o,agentType:a})},[]),i=g.useCallback(()=>{n(o=>({agentId:null,agentType:o.agentType}))},[]),s=g.useMemo(()=>({state:t,open:r,close:i}),[t,r,i]);return h.jsx(HM.Provider,{value:s,children:e})}function UM(){return g.useContext(HM)}function xZ(e){if(e==null)return null;if(typeof e=="string")return e;if(Array.isArray(e)){const t=[];for(const n of e)if(n&&typeof n=="object"){const r=n;r.type==="text"&&typeof r.text=="string"&&t.push(r.text)}else typeof n=="string"&&t.push(n);return t.length?t.join(`
511
- `):null}if(typeof e=="object"){const t=e;if(typeof t.text=="string")return t.text}return null}function Tk(e){if(!e||!Number.isFinite(e))return null;if(e<1e3)return`${e}ms`;const t=e/1e3;if(t<60)return`${t.toFixed(1)}s`;const n=Math.floor(t/60),r=Math.round(t-n*60);return`${n}m${r.toString().padStart(2,"0")}s`}function yZ(e){return!e||!Number.isFinite(e)?null:e<1e3?`${e} tok`:e<1e4?`${(e/1e3).toFixed(1)}k tok`:`${Math.round(e/1e3)}k tok`}const bZ={readCount:"read",searchCount:"search",bashCount:"bash",editFileCount:"edit",linesAdded:"+lines",linesRemoved:"-lines",otherToolCount:"other"};function wZ(e){if(!e)return[];const t=[];for(const[n,r]of Object.entries(e)){if(!r||r<=0)continue;const i=bZ[n]??n;t.push(`${i}:${r}`)}return t}function SZ({description:e,input:t,output:n,error:r,pending:i,notifications:s,toolResultExtra:o,progress:a}){const[l,c]=g.useState(!1),u=UM(),d=g.useMemo(()=>{if(!t||typeof t!="object")return null;const P=t;return typeof P.prompt=="string"?P.prompt:null},[t]),f=g.useMemo(()=>{if(!t||typeof t!="object")return;const P=t.agentId;return typeof P=="string"&&P.length>0?P:void 0},[t]),p=(o==null?void 0:o.prompt)??d,m=g.useMemo(()=>xZ(n),[n]),v=o==null?void 0:o.stats,b=a==null?void 0:a.stats,_=Tk((v==null?void 0:v.durationMs)??(b==null?void 0:b.durationMs)),x=yZ((v==null?void 0:v.tokens)??(b==null?void 0:b.tokens)),y=wZ(v==null?void 0:v.toolStats),w=i&&(a!=null&&a.lastToolName)?`now:${a.lastToolName}`:null,C=!!(o!=null&&o.agentType||_||x||y.length>0||w),k=(o==null?void 0:o.agentId)??(a==null?void 0:a.agentId)??f,T=!!(r||(a==null?void 0:a.status)==="failed"),N=g.useMemo(()=>s.map(P=>({taskId:P.taskId,text:P.text,parsed:FM(P.text)})),[s]),z=T?h.jsx(Ls,{className:"w-3.5 h-3.5 text-error"}):i?h.jsx(In,{className:"w-3.5 h-3.5 text-blue-400 animate-spin"}):h.jsx(rp,{className:"w-3.5 h-3.5 text-green-500"});return h.jsxs("div",{"data-testid":"msg-line-agent-call","data-pending":i?"true":"false","data-has-error":T?"true":"false","data-notification-count":s.length,"data-has-stats":C?"true":"false","data-agent-id":k??"",className:"my-1 min-w-0 max-w-full rounded-md border border-bg-200/60 bg-bg-100/30",children:[h.jsxs("button",{type:"button","aria-expanded":l,onClick:()=>c(P=>!P),className:fe("flex w-full min-w-0 items-center gap-2 px-2.5 py-1.5 text-left text-[13px]","hover:bg-bg-200/40 rounded-md transition-colors"),children:[h.jsx("span",{className:"w-5 h-5 flex items-center justify-center text-[10px] rounded bg-violet-500/10 text-violet-500 shrink-0","aria-hidden":!0,children:h.jsx(L$,{className:"w-3 h-3"})}),h.jsx("span",{className:"shrink-0",children:z}),h.jsx("span",{className:"flex-1 min-w-0 truncate font-medium text-text-200",children:e}),C?null:s.length>0?h.jsxs("span",{className:"text-[11px] text-text-400 tabular-nums shrink-0",children:[s.length," 次通知"]}):null,k&&(u!=null&&u.open)?h.jsx("span",{role:"button",tabIndex:0,"data-testid":"open-subagent-btn-header","data-agent-id":k,"aria-label":"打开子 agent 对话",onClick:P=>{P.stopPropagation(),u.open(k,o==null?void 0:o.agentType)},onKeyDown:P=>{(P.key==="Enter"||P.key===" ")&&(P.stopPropagation(),P.preventDefault(),u.open(k,o==null?void 0:o.agentType))},className:"shrink-0 inline-flex items-center justify-center w-3.5 h-3.5 text-text-400 hover:text-text-200",children:h.jsx(qc,{className:"w-3.5 h-3.5"})}):null,l?h.jsx(ir,{className:"w-3.5 h-3.5 text-text-400 shrink-0"}):h.jsx(Un,{className:"w-3.5 h-3.5 text-text-400 shrink-0"})]}),i&&(a!=null&&a.description)?h.jsx("div",{"data-testid":"agent-call-progress-desc",className:"px-3 pt-0 pb-1 text-[12px] text-text-300 truncate",children:a.description}):null,C?h.jsxs("div",{"data-testid":"agent-call-stats",className:"flex items-center gap-1.5 flex-wrap px-3 pb-1.5 pt-0 text-[11px] text-text-400",children:[o!=null&&o.agentType?h.jsx("span",{"data-testid":"agent-call-stats-type",className:"inline-flex items-center rounded-sm bg-violet-500/10 px-1.5 py-0.5 text-violet-400 font-medium",children:o.agentType}):null,_?h.jsx("span",{className:"tabular-nums",children:_}):null,x?h.jsx("span",{className:"tabular-nums",children:x}):null,w?h.jsx("span",{"data-testid":"agent-call-stats-now",className:"font-mono tabular-nums text-blue-400",children:w}):null,y.map(P=>h.jsx("span",{className:"font-mono tabular-nums text-text-400/80",children:P},P)),s.length>0?h.jsxs("span",{className:"tabular-nums text-text-400/70",children:["· ",s.length," 次通知"]}):null]}):null,l?h.jsxs("div",{"data-testid":"agent-call-body",className:"min-w-0 border-t border-bg-200/60 px-3 py-2 space-y-3",children:[r?h.jsx("div",{className:"text-[12px] text-error whitespace-pre-wrap",children:r}):null,N.map((P,B)=>{const R=P.parsed,I=Tk(R.durationMs);return h.jsxs("div",{"data-testid":"agent-call-notification","data-task-id":P.taskId??"",className:"min-w-0 rounded-md border border-bg-200/60 bg-bg-0/40 p-2 space-y-1.5",children:[h.jsxs("div",{className:"flex items-center gap-2 text-[11px] text-text-400 flex-wrap",children:[h.jsx("span",{className:"font-mono",children:(P.taskId??R.taskId??"未知").slice(0,12)}),h.jsx("span",{className:"uppercase tracking-wide",children:R.status??"unknown"}),I?h.jsxs("span",{className:"tabular-nums",children:["· ",I]}):null,R.totalTokens?h.jsxs("span",{className:"tabular-nums",children:["· ",R.totalTokens," tok"]}):null,R.toolUses?h.jsxs("span",{className:"tabular-nums",children:["· ",R.toolUses," tools"]}):null,R.worktreeBranch?h.jsxs("span",{className:"font-mono",children:["· ",R.worktreeBranch]}):null]}),R.summary?h.jsx("div",{className:"text-[12px] text-text-300",children:R.summary}):null,R.result?h.jsx("div",{"data-testid":"agent-call-notification-result",className:"assistant-markdown text-[12px] leading-relaxed break-words",children:h.jsx(tu,{remarkPlugins:[ru],components:So,children:R.result})}):null]},`${P.taskId??"n"}-${B}`)}),p?h.jsxs("div",{"data-testid":"agent-call-prompt-block",className:"min-w-0 space-y-1",children:[h.jsx("div",{className:"text-[11px] text-text-400 font-medium",children:"任务指令"}),h.jsx("pre",{"data-testid":"agent-call-prompt",className:"max-w-full whitespace-pre-wrap break-words text-[11px] text-text-300 bg-bg-50/60 rounded p-2 border border-bg-200/60 max-h-64 overflow-auto [overflow-wrap:anywhere]",children:p})]}):null,m?h.jsxs("div",{"data-testid":"agent-call-result-block",className:"min-w-0 space-y-1",children:[h.jsx("div",{className:"text-[11px] text-text-400 font-medium",children:"子 agent 报告"}),h.jsx("div",{"data-testid":"agent-call-result",className:"assistant-markdown text-[12px] leading-relaxed break-words",children:h.jsx(tu,{remarkPlugins:[ru],components:So,children:m})})]}):null,!m&&N.length===0&&!r&&!p?h.jsx("div",{className:"text-[11px] text-text-400 italic",children:"无详细信息"}):null,k&&(u!=null&&u.open)?h.jsx("div",{className:"flex justify-end",children:h.jsxs("button",{type:"button","data-testid":"open-subagent-btn","data-agent-id":k,onClick:()=>u.open(k,o==null?void 0:o.agentType),className:fe("inline-flex items-center gap-1 rounded-md border border-bg-200/60","bg-bg-100/40 hover:bg-bg-200/40 transition-colors","px-2 py-1 text-[11px] text-text-300"),children:[h.jsx(qc,{className:"w-3 h-3"}),h.jsx("span",{children:"打开子 agent 对话"})]})}):null]}):null]})}function WM({title:e,items:t,live:n,progressColor:r="bg-green-500",listKind:i,children:s}){const[o,a]=g.useState(!!n),l=t.length,c=t.filter(d=>d.status==="completed").length,u=l>0?Math.round(c/l*100):0;return h.jsxs("div",{"data-testid":"msg-line-checklist","data-list-kind":i,className:"min-w-0 max-w-full py-1",children:[h.jsxs("button",{type:"button",onClick:()=>a(d=>!d),"aria-expanded":o,className:"flex items-center gap-2.5 w-full text-left rounded-md px-1.5 py-1 hover:bg-text-100/5 cursor-pointer",children:[o?h.jsx(ir,{className:"w-3.5 h-3.5 text-text-400 shrink-0"}):h.jsx(Un,{className:"w-3.5 h-3.5 text-text-400 shrink-0"}),h.jsx("span",{className:"text-[13px] font-medium text-text-200",children:e}),h.jsxs("span",{className:"text-[11px] text-text-400 tabular-nums",children:[c,"/",l]}),h.jsx("div",{className:"flex-1 max-w-[120px] h-1.5 rounded-full bg-text-100/10 overflow-hidden",children:h.jsx("div",{className:fe("h-full rounded-full transition-all duration-300",r),style:{width:`${u}%`}})})]}),o?h.jsxs("div",{"data-testid":"checklist-body",className:"ml-6 mt-0.5",children:[h.jsx("div",{className:"space-y-px",children:t.map((d,f)=>h.jsxs("div",{className:"flex min-w-0 items-start gap-2 py-0.5 px-1",children:[h.jsx("span",{className:"w-4 h-4 mt-0.5 flex items-center justify-center shrink-0",children:d.status==="completed"?h.jsx(ul,{className:"w-3.5 h-3.5 text-green-500"}):d.status==="in_progress"&&n?h.jsx(In,{className:"w-3.5 h-3.5 text-blue-400 animate-spin"}):h.jsx("span",{className:"w-2 h-2 rounded-full border border-text-400/40"})}),h.jsx("span",{className:fe("min-w-0 text-[13px] leading-snug break-words [overflow-wrap:anywhere]",d.status==="completed"?"text-text-400 line-through":"text-text-200"),children:d.status==="in_progress"&&d.activeForm?d.activeForm:d.content})]},`${f}-${d.content}`))}),s]}):null]})}function kZ({todos:e,live:t}){return h.jsx(WM,{title:"Tasks",items:e,live:t,progressColor:"bg-green-500",listKind:"todo"})}function CZ({tasks:e,live:t}){return h.jsx(WM,{title:"Plan",items:e,live:t,progressColor:"bg-blue-500",listKind:"plan"})}function EZ(e){if(!e||!Number.isFinite(e))return null;const t=Date.now()-e;if(t<0)return null;const n=Math.floor(t/1e3);if(n<60)return`${n}s ago`;const r=Math.floor(n/60);if(r<60)return`${r}m ago`;const i=Math.floor(r/60);if(i<24)return`${i}h ago`;const s=Math.floor(i/24);if(s<7)return`${s}d ago`;const o=Math.floor(s/7);return o<5?`${o}w ago`:new Date(e).toISOString().slice(0,10)}function TZ(e){return(e.split("/").pop()??e)||e}function NZ({memories:e}){return!e||e.length===0?null:h.jsxs("div",{"data-testid":"memory-callout",className:"my-1 min-w-0 max-w-full rounded-md border border-bg-200/60 bg-bg-100/30",children:[h.jsxs("div",{className:"flex items-center gap-1.5 px-2.5 py-1.5 text-[12px] text-text-300 border-b border-bg-200/60",children:[h.jsx(oz,{className:"w-3.5 h-3.5 text-amber-500 shrink-0"}),h.jsx("span",{className:"font-medium",children:"项目记忆"}),h.jsxs("span",{className:"text-text-400 tabular-nums",children:["· ",e.length]})]}),h.jsx("ul",{className:"divide-y divide-bg-200/40",children:e.map(t=>h.jsx(PZ,{memory:t},t.path))})]})}function PZ({memory:e}){const[t,n]=g.useState(!1),r=EZ(e.mtimeMs),i=e.content.replace(/\s+/g," ").trim().slice(0,80);return h.jsxs("li",{className:"px-2.5 py-1.5",children:[h.jsxs("button",{type:"button","aria-expanded":t,onClick:()=>n(s=>!s),className:fe("flex w-full items-center gap-1.5 text-left text-[12px]","hover:bg-bg-200/30 rounded-sm py-0.5"),children:[t?h.jsx(ir,{className:"w-3 h-3 text-text-400 shrink-0"}):h.jsx(Un,{className:"w-3 h-3 text-text-400 shrink-0"}),h.jsx("span",{className:"font-mono text-text-300 shrink-0 max-w-[20ch] truncate",title:e.path,children:TZ(e.path)}),h.jsx("span",{className:"flex-1 min-w-0 truncate text-text-400/80",children:i}),r?h.jsx("span",{className:"shrink-0 text-[11px] text-text-400 tabular-nums",children:r}):null]}),t?h.jsx("pre",{"data-testid":"memory-callout-body",className:"mt-1 max-w-full whitespace-pre-wrap break-words text-[12px] text-text-300 bg-bg-50/60 rounded-md p-2 border border-bg-200/60 [overflow-wrap:anywhere]",children:e.content}):null]})}function IZ({toolUseId:e,questions:t,onSubmit:n,onCancel:r,submittedAnswers:i}){const[s,o]=g.useState({}),[a,l]=g.useState({}),[c,u]=g.useState({}),[d,f]=g.useState(!1),[p,m]=g.useState(!1),v=i!==void 0&&Object.keys(i).length>0,b=v||p,_=!n&&!v,x=(k,T)=>{const N={labels:new Set,freeText:""};if(!v||!i)return N;const z=i[k];if(typeof z!="string")return N;const P=z.split(",").map(j=>j.trim()).filter(Boolean),B=new Set(T.map(j=>j.label)),R=new Set,I=[];for(const j of P)B.has(j)?R.add(j):I.push(j);return{labels:R,freeText:I.join(", ")}},y=g.useMemo(()=>t.every(k=>{if((c[k.question]??"").trim().length>0)return!0;if(k.multiSelect){const N=a[k.question];return!!(N&&N.size>0)}return typeof s[k.question]=="string"&&s[k.question].length>0}),[t,s,a,c]),w=async()=>{if(!y||d||b||_||!n)return;const k={};for(const T of t){const N=(c[T.question]??"").trim();if(T.multiSelect){const z=a[T.question],P=z?T.options.filter(B=>z.has(B.label)).map(B=>B.label):[];if(N.length>0&&P.push(N),P.length===0)continue;k[T.question]=P.join(", ")}else if(N.length>0)k[T.question]=N;else{const z=s[T.question];typeof z=="string"&&(k[T.question]=z)}}f(!0);try{await n(k),m(!0)}finally{f(!1)}},C=ku(()=>{w()});return h.jsxs("div",{"data-testid":"msg-line-question","data-tool-use-id":e,className:"min-w-0 max-w-full rounded-md border border-accent/40 bg-accent/5 px-3 py-2.5 text-[13px]",children:[h.jsxs("div",{className:"flex min-w-0 items-center gap-2 mb-2",children:[h.jsx(gz,{className:"w-4 h-4 text-accent shrink-0"}),h.jsx("span",{className:"min-w-0 font-medium text-text-100",children:"需要你的回答 / Need your answer"}),t.length>1?h.jsxs("span",{className:"ml-auto text-[12px] text-text-400","data-testid":"msg-line-question-count",children:[t.length," 个问题"]}):null]}),h.jsx("div",{className:"flex flex-col gap-3 mb-3",children:t.map((k,T)=>{const N=`q-${T}`,z=`${e}-${T}`,P=x(k.question,k.options),B=b||_,R=c[k.question]??"",I=v?P.freeText:p?(c[k.question]??"").trim():"";return h.jsxs("div",{"data-testid":"msg-line-question-item",children:[k.question?h.jsx("div",{className:"text-text-200 mb-1.5",children:k.question}):null,h.jsx("div",{className:"flex flex-col gap-1",children:k.options.map((j,L)=>{var D;const $=`${N}-${L}`,F=v?P.labels.has(j.label):k.multiSelect?!!((D=a[k.question])!=null&&D.has(j.label)):s[k.question]===j.label;return h.jsxs("label",{className:"flex min-w-0 items-start gap-2 cursor-pointer select-none py-1 px-2 rounded hover:bg-bg-100",children:[h.jsx("input",{type:k.multiSelect?"checkbox":"radio",name:z,value:j.label,checked:F,disabled:b||_,onChange:()=>{b||_||(k.multiSelect?l(O=>{const E=new Set(O[k.question]??[]);return E.has(j.label)?E.delete(j.label):E.add(j.label),{...O,[k.question]:E}}):o(O=>({...O,[k.question]:j.label})))},className:"mt-0.5","data-testid":"msg-line-question-option"}),h.jsxs("span",{className:"flex min-w-0 flex-col",children:[h.jsx("span",{className:"text-text-100 [overflow-wrap:anywhere]",children:j.label}),j.description?h.jsx("span",{className:"text-[12px] text-text-400 [overflow-wrap:anywhere]",children:j.description}):null]})]},$)})}),B?I.length>0?h.jsx("div",{className:"mt-2 rounded-lg border border-accent/15 bg-bg-100/60 px-3 py-2 text-[13px] leading-relaxed text-text-200 [overflow-wrap:anywhere]","data-testid":"msg-line-question-freetext-result",children:I}):null:h.jsx("textarea",{rows:3,value:R,placeholder:"或自行输入回答...",onChange:j=>{const L=j.target.value;u($=>({...$,[k.question]:L}))},...C,className:"mt-2 w-full resize-y rounded-lg border border-accent/20 bg-bg-000/60 px-3 py-2 text-[13px] leading-relaxed text-text-100 placeholder:text-text-400 outline-none transition-colors focus:border-accent/60 focus:bg-bg-000","data-testid":"msg-line-question-freetext"})]},N)})}),h.jsxs("div",{className:"flex items-center gap-2",children:[h.jsx(ni,{size:"sm",variant:"default",onClick:()=>void w(),disabled:!y||d||b||_,"data-testid":"msg-line-question-submit",children:b?"已提交 / Submitted":_?"已结束 / Ended":"提交 / Submit"}),r&&!b&&!_?h.jsx(ni,{size:"sm",variant:"ghost",onClick:()=>void r(),disabled:d,"data-testid":"msg-line-question-cancel",children:"跳过 / Skip"}):null]})]})}function RZ({toolUseId:e,questions:t,historicalAnswers:n,realtimeAnswers:r,onSubmit:i,onCancel:s}){const o=r??n,a=g.useCallback(async c=>{i&&await i(e,c)},[i,e]),l=g.useCallback(async()=>{s&&await s(e)},[s,e]);return h.jsx(IZ,{toolUseId:e,questions:t,onSubmit:i?a:void 0,...s?{onCancel:l}:{},submittedAnswers:o})}function MZ(){const e=new Map,t=(n,r)=>`${n}::${r}`;return{register(n,r,i){e.set(t(n,r),i)},resolve(n,r){return n?e.get(t(n,r))??null:null},reset(){e.clear()}}}const ml=MZ();function VM({lines:e,onPermissionRespond:t,onPermissionInterrupt:n,topSlot:r,onRewind:i,rewindableUserMessageIds:s,onFork:o,onQuickAsk:a,realtimeQuestionAnswers:l,onSubmitQuestion:c,onCancelQuestion:u,liveQuestionToolUseIds:d,fileSharingScope:f,onShareFile:p,onOpenInTab:m,onPreviewMarkdown:v,onOpenFilePath:b,turnCollapse:_}){const x=g.useMemo(()=>hW(e),[e]),y=g.useMemo(()=>_?gW(x,_):null,[x,_]),w={onRewind:i,rewindableUserMessageIds:s,onPermissionRespond:t,onPermissionInterrupt:n,onFork:o,onQuickAsk:a,realtimeQuestionAnswers:l,onSubmitQuestion:c,onCancelQuestion:u,liveQuestionToolUseIds:d,fileSharingScope:f,onShareFile:p,onOpenInTab:m,onPreviewMarkdown:v,onOpenFilePath:b};return h.jsxs("div",{"data-testid":"message-list",className:"flex w-full min-w-0 max-w-full flex-col gap-2 px-4 py-3",children:[r,y!==null?y.map(C=>AZ(C,w)):x.map(C=>df(C,w))]})}function AZ(e,t){const n=`turn-${e.seq}`,r=e.query?df(e.query,t):null,i=e.process.map(o=>LZ(o,t)),s=e.tail.map(o=>df(o,t));return e.status==="running"?h.jsxs(Ze.Fragment,{children:[r,i,s]},n):h.jsxs(Ze.Fragment,{children:[r,h.jsx(NW,{status:e.status,...e.durationMs!==void 0?{durationMs:e.durationMs}:{},children:i}),s]},n)}function LZ(e,t){return e.kind==="tool-group"?h.jsx(CW,{items:e.items,renderItemDetail:n=>jZ(n,t)},`tool-group-${e.seq}`):df(e,t)}function jZ(e,t){const n=ml.resolve(e.toolKind,e.tool);return n?n.render({input:e.input,output:e.output,error:e.error,pending:e.pending,toolUseId:e.toolUseId,...t.fileSharingScope?{fileScope:t.fileSharingScope}:{},...t.onShareFile?{onShareFile:t.onShareFile}:{},...t.onOpenInTab?{onOpenInTab:t.onOpenInTab}:{},...t.onPreviewMarkdown?{onPreviewMarkdown:t.onPreviewMarkdown}:{}}):null}function df(e,t){const{onRewind:n,rewindableUserMessageIds:r,onPermissionRespond:i,onPermissionInterrupt:s,onFork:o,onQuickAsk:a,realtimeQuestionAnswers:l,onSubmitQuestion:c,onCancelQuestion:u,liveQuestionToolUseIds:d,fileSharingScope:f,onShareFile:p,onOpenInTab:m,onPreviewMarkdown:v,onOpenFilePath:b}=t,_=`${e.kind}-${e.seq}`;switch(e.kind){case"session-init":return null;case"user-text":{const x=typeof e.uuid=="string"?e.uuid:void 0,y=!!(n&&x&&(!r||r.has(x)));return h.jsx(cZ,{text:e.text,senderDisplayName:e.senderDisplayName,rewindTarget:y&&x&&n?{userMessageId:x,onRewind:n}:void 0},_)}case"user-meta":return h.jsx(pZ,{metaKind:e.metaKind,text:e.text},_);case"meta-text":return h.jsx(mZ,{text:e.text,metaSource:e.metaSource},_);case"agent-notification":return h.jsx(vZ,{text:e.text,taskId:e.taskId,parentToolUseId:e.parentToolUseId},_);case"assistant-text":{const x=typeof e.uuid=="string"?e.uuid:void 0,y=x&&(o||a)?{messageUuid:x,onFork:o,onQuickAsk:a}:void 0;return h.jsx(IQ,{text:RW(e.text),forkTarget:y,...b?{onOpenFilePath:b}:{}},_)}case"assistant-thinking":return h.jsx(RQ,{text:e.text},_);case"permission-inline":return h.jsx(rZ,{tool:e.tool,input:e.input,onRespond:i??(()=>{}),onInterrupt:s},_);case"error":return h.jsx(iZ,{message:e.message},_);case"turn-end":return null;case"merged-tool":return DZ(e,_,{fileSharingScope:f,onShareFile:p,onOpenInTab:m,onPreviewMarkdown:v});case"merged-agent":return h.jsx(SZ,{description:e.description,input:e.input,output:e.output,error:e.error,pending:e.pending,notifications:e.notifications,toolResultExtra:e.toolResultExtra,progress:e.progress},_);case"plan-card":return h.jsx(CZ,{tasks:e.tasks},_);case"todo-checklist":return h.jsx(kZ,{todos:e.todos},_);case"memory-callout":return h.jsx(NZ,{memories:e.memories},_);case"question-card":{const x=d===void 0||d.has(e.toolUseId);return h.jsx(RZ,{toolUseId:e.toolUseId,questions:e.questions,historicalAnswers:e.submittedAnswers,realtimeAnswers:l==null?void 0:l[e.toolUseId],onSubmit:x?c:void 0,...x&&u?{onCancel:u}:{}},_)}default:return null}}function DZ(e,t,n){const r=ml.resolve(e.toolKind,e.tool),i=r?r.render({input:e.input,output:e.output,error:e.error,pending:e.pending,toolUseId:e.toolUseId,...n.fileSharingScope?{fileScope:n.fileSharingScope}:{},...n.onShareFile?{onShareFile:n.onShareFile}:{},...n.onOpenInTab?{onOpenInTab:n.onOpenInTab}:{},...n.onPreviewMarkdown?{onPreviewMarkdown:n.onPreviewMarkdown}:{}}):null;return h.jsx(Ze.Fragment,{children:i??h.jsx(zM,{tool:e.tool,input:e.input,output:e.output,error:e.error,pending:e.pending,...n.fileSharingScope?{fileScope:n.fileSharingScope}:{},...n.onShareFile?{onShareFile:n.onShareFile}:{},...n.onOpenInTab?{onOpenInTab:n.onOpenInTab}:{},...n.onPreviewMarkdown?{onPreviewMarkdown:n.onPreviewMarkdown}:{}})},t)}const OZ={builtin:"Commands",global:"Global",project:"Project",plugin:"Plugin"},Nk={builtin:0,global:1,project:2,plugin:3};function BZ({query:e,skills:t,activeIndex:n,onActiveIndexChange:r,onSelect:i,onEmpty:s}){const o=g.useRef(null),a=g.useMemo(()=>qM(t,e),[t,e]),l=g.useMemo(()=>{const c=new Set;let u=null;for(let d=0;d<a.length;d++)a[d].source!==u&&(c.add(d),u=a[d].source);return c},[a]);return g.useEffect(()=>{a.length===0&&(s==null||s())},[a.length,s]),g.useEffect(()=>{var c;try{(c=o.current)==null||c.scrollIntoView({block:"nearest"})}catch{}},[n]),a.length===0?null:h.jsx("div",{"data-testid":"cc-skill-selector",className:"absolute bottom-full left-0 right-0 z-50 mb-1.5 max-h-[320px] overflow-y-auto rounded-2xl border border-bg-300 bg-bg-50 shadow-lg",children:a.map((c,u)=>{const d=u===n,f=l.has(u);return h.jsxs(Ze.Fragment,{children:[f?h.jsx("div",{className:"sticky top-0 z-10 bg-bg-50/95 backdrop-blur-sm px-4 py-2 text-[10px] font-semibold uppercase tracking-wider text-text-400/70 border-b border-bg-200/60",children:OZ[c.source]}):null,h.jsxs("div",{ref:d?o:void 0,"data-testid":`cc-skill-item-${c.name}`,onMouseEnter:()=>r(u),onClick:()=>i(c),className:fe("flex items-center gap-2.5 px-4 py-2 cursor-pointer transition-colors duration-75",d?"bg-[var(--text-100-dim)]":"hover:bg-bg-100/60"),children:[h.jsxs("code",{className:"text-[12px] font-mono font-semibold text-text-100 shrink-0",children:["/",c.name]}),c.description?h.jsx("span",{className:"text-[11px] text-text-300 truncate ml-auto",children:c.description}):null]})]},`${c.source}/${c.name}`)})})}function qM(e,t){const n=t.trim().toLowerCase(),r=n?e.filter(i=>i.name.toLowerCase().includes(n)||(i.description??"").toLowerCase().includes(n)):e.slice();return r.sort((i,s)=>(Nk[i.source]??9)-(Nk[s.source]??9)),r.slice(0,30)}const zZ=g.createContext(null);function $Z(){return g.useContext(zZ)}const FZ={builtin:"Built-in",global:"Global",project:"Project",policy:"Policy",plugin:"Plugin",persona:"My personas",contact:"People","remote-persona":"Remote personas"},Pk={builtin:0,global:1,project:2,policy:3,plugin:4,persona:5,contact:6,"remote-persona":7};function hf(e){switch(e.kind){case"persona":return"persona";case"contact":return"contact";case"remote-persona":return"remote-persona";case"cc-agent":return e.agent.source}}function HZ(e){switch(e.kind){case"persona":return`persona/${e.persona.personaId}`;case"contact":return`contact/${e.contact.deviceId}`;case"remote-persona":return`remote/${e.deviceId}/${e.persona.personaId}`;case"cc-agent":return`${e.agent.source}/${e.agent.name}`}}function UZ(e){switch(e.kind){case"persona":return`${e.persona.personaId} ${e.persona.label}`.toLowerCase();case"contact":return`${e.contact.displayName} ${e.contact.deviceId}`.toLowerCase();case"remote-persona":return`${e.persona.personaId} ${e.persona.label}`.toLowerCase();case"cc-agent":{const t=e.agent;return`${t.name} ${t.description??""} ${t.whenToUse??""}`.toLowerCase()}}}function WZ(e){switch(e.kind){case"persona":return{displayName:`@persona/${e.persona.personaId}`,description:e.persona.label,testid:`cc-agent-item-persona-${e.persona.personaId}`};case"contact":return{displayName:`@${e.contact.displayName}`,description:e.contact.deviceId,testid:`cc-agent-item-contact-${e.contact.deviceId}`};case"remote-persona":return{displayName:`@persona/${e.persona.personaId}`,description:e.persona.label,testid:`cc-agent-item-remote-${e.deviceId}-${e.persona.personaId}`};case"cc-agent":return{displayName:`@${e.agent.name}`,description:e.agent.description,whenToUse:e.agent.whenToUse,plugin:e.agent.plugin,testid:`cc-agent-item-${e.agent.name}`}}}function KM(e,t){const n=t.trim().toLowerCase(),r=n?e.filter(i=>UZ(i).includes(n)):e.slice();return r.sort((i,s)=>(Pk[hf(i)]??9)-(Pk[hf(s)]??9)),r.slice(0,30)}function Ik({query:e,entries:t,activeIndex:n,onActiveIndexChange:r,onSelect:i,onEmpty:s}){const o=g.useRef(null),a=g.useMemo(()=>KM(t,e),[t,e]),l=g.useMemo(()=>{const c=new Set;let u=null;for(let d=0;d<a.length;d++){const f=hf(a[d]);f!==u&&(c.add(d),u=f)}return c},[a]);return g.useEffect(()=>{a.length===0&&(s==null||s())},[a.length,s]),g.useEffect(()=>{var c;try{(c=o.current)==null||c.scrollIntoView({block:"nearest"})}catch{}},[n]),a.length===0?null:h.jsx("div",{"data-testid":"cc-agent-selector",className:"absolute bottom-full left-0 right-0 z-50 mb-1.5 max-h-[320px] overflow-y-auto rounded-2xl border border-bg-300 bg-bg-50 shadow-lg",children:a.map((c,u)=>{const d=u===n,f=l.has(u),p=hf(c),m=WZ(c);return h.jsxs(Ze.Fragment,{children:[f?h.jsx("div",{"data-testid":`cc-agent-group-header-${p}`,"data-source":p,className:"sticky top-0 z-10 bg-bg-50/95 backdrop-blur-sm px-4 py-2 text-[10px] font-semibold uppercase tracking-wider text-text-400/70 border-b border-bg-200/60",children:FZ[p]}):null,h.jsxs("div",{ref:d?o:void 0,"data-testid":m.testid,onMouseEnter:()=>r(u),onClick:()=>i(c),className:fe("flex items-center gap-2.5 px-4 py-2 cursor-pointer transition-colors duration-75",d?"bg-[var(--text-100-dim)]":"hover:bg-bg-100/60"),children:[h.jsx("code",{className:"text-[12px] font-mono font-semibold text-text-100 shrink-0",children:m.displayName}),m.description?h.jsx("span",{className:"text-[11px] text-text-300 truncate ml-2",children:m.description}):null,m.whenToUse?h.jsx("span",{className:"text-[10px] text-text-400/70 italic truncate ml-auto",children:m.whenToUse}):null,m.plugin?h.jsx("span",{className:"text-[10px] text-text-400/70 ml-2 shrink-0",children:m.plugin}):null]})]},HZ(c))})})}function VZ({attachment:e,onRemove:t,onOpenPreview:n}){const r=e.mimeType.startsWith("image/"),i=e.status==="error",s=e.status==="uploading",o=r&&e.status==="done"&&!!e.previewUrl&&!!n;return h.jsxs("div",{"data-testid":`attachment-pill-${e.id}`,className:fe("group relative flex items-center gap-1.5 rounded-lg border px-2 py-1.5 text-[12px] transition-colors",i?"border-red-400/40 bg-red-500/5":"border-bg-300 bg-bg-100"),children:[r&&e.previewUrl?h.jsxs("div",{className:"relative h-7 w-7 shrink-0",children:[h.jsx("img",{src:e.previewUrl,alt:e.fileName,onClick:o?n:void 0,"data-testid":`attachment-thumb-${e.id}`,className:fe("h-7 w-7 rounded object-cover",o&&"cursor-pointer hover:opacity-80",s&&"opacity-40")}),s?h.jsx(In,{"data-testid":`attachment-spinner-${e.id}`,className:"absolute inset-0 m-auto h-3.5 w-3.5 animate-spin text-text-200"}):null]}):h.jsx("div",{className:"relative flex h-7 w-7 items-center justify-center rounded bg-text-100/5 shrink-0",children:s?h.jsx(In,{"data-testid":`attachment-spinner-${e.id}`,className:"h-3.5 w-3.5 animate-spin text-text-400"}):h.jsx(Ro,{className:"h-3.5 w-3.5 text-text-400"})}),h.jsx("span",{className:fe("max-w-[120px] truncate text-text-200",s&&"text-text-400"),title:e.error??e.fileName,children:e.fileName}),i?h.jsx(Ls,{className:"h-3 w-3 text-red-400 shrink-0"}):null,h.jsx("button",{type:"button",onClick:t,"data-testid":`attachment-remove-${e.id}`,className:"flex h-4 w-4 items-center justify-center rounded-full text-text-400 hover:text-text-100 hover:bg-text-100/10 transition-colors cursor-pointer shrink-0","aria-label":"remove",children:h.jsx(Dr,{className:"h-3 w-3"})})]})}function qZ({attachments:e,onRemove:t,onOpenPreview:n}){return e.length===0?null:h.jsx("div",{"data-testid":"attachment-row",className:"flex flex-wrap gap-1.5 mb-2 px-1",children:e.map(r=>h.jsx(VZ,{attachment:r,onRemove:()=>t(r.id),onOpenPreview:n?()=>n(r):void 0},r.id))})}class Xl extends Error{constructor(t,n,r){super(n),this.code=t,this.status=r,this.name="UploadAttachmentError"}}async function KZ(e){if(!e.httpBaseUrl)throw new Xl("TUNNEL_NOT_READY","daemon httpBaseUrl unavailable");if(!e.httpToken)throw new Xl("NO_AUTH","daemon httpToken unavailable");const t=new URLSearchParams({sessionId:e.sessionId,fileName:e.file.name,mimeType:e.file.type||"application/octet-stream"}),n=`${e.httpBaseUrl.replace(/\/$/,"")}/attachments/upload?${t.toString()}`;let r;try{r=await fetch(n,{method:"POST",headers:{Authorization:`Bearer ${e.httpToken}`,"Content-Type":e.file.type||"application/octet-stream"},body:e.file})}catch(i){throw new Xl("NETWORK_ERROR",i.message)}if(!r.ok){let i="UPLOAD_FAILED",s=`HTTP ${r.status}`;try{const o=await r.json();o.code&&(i=o.code),o.message&&(s=o.message)}catch{}throw new Xl(i,s,r.status)}return await r.json()}const Rk=25*1024*1024,GZ="image/*,.txt,.md,.markdown,.csv,.json,.log,.yaml,.yml,.html,.xml,.pdf",YZ=["image/","text/"],XZ=new Set(["application/json","application/xml","application/x-yaml","application/yaml","application/pdf"]),QZ=new Set(["txt","md","markdown","csv","json","log","yaml","yml","html","xml","pdf"]);function ZZ(e){var r;const t=(e.type||"").toLowerCase();if(t&&YZ.some(i=>t.startsWith(i))||t&&XZ.has(t))return!0;const n=((r=e.name.split(".").pop())==null?void 0:r.toLowerCase())??"";return n.length>0&&QZ.has(n)}let JZ=0;const eJ=()=>`att-${++JZ}-${Date.now()}`;function tJ(e){return new Promise((t,n)=>{const r=new FileReader;r.onload=()=>t(typeof r.result=="string"?r.result:""),r.onerror=()=>n(r.error??new Error("read failed")),r.readAsDataURL(e)})}function nJ(e){const[t,n]=g.useState(e.initial??[]),r=g.useCallback(async o=>{const a=Array.from(o);if(a.length===0)return;const l=[],c=[],u=[];for(const d of a){const f={id:eJ(),fileName:d.name,mimeType:d.type||"application/octet-stream"};if(!ZZ(d)){c.push({...f,url:null,status:"error",error:"不支持的文件类型"});continue}if(d.size>Rk){c.push({...f,url:null,status:"error",error:`超过 ${Math.round(Rk/1024/1024)}MB 上限`});continue}if(e.sessionId==null){u.push({id:f.id,file:d,mimeType:f.mimeType}),c.push({...f,url:null,status:"uploading"});continue}const p=f.mimeType.startsWith("image/")?URL.createObjectURL(d):void 0;c.push({...f,url:null,status:"uploading",...p?{previewUrl:p}:{}}),l.push({id:f.id,file:d})}n(d=>[...d,...c]);for(const d of u)try{const f=await tJ(d.file);n(p=>p.map(m=>m.id===d.id?{...m,url:f,status:"done",...d.mimeType.startsWith("image/")?{previewUrl:f}:{}}:m))}catch(f){n(p=>p.map(m=>m.id===d.id?{...m,status:"error",error:f.message??"read failed"}:m))}l.length!==0&&await Promise.all(l.map(async d=>{try{const f=await KZ({httpBaseUrl:e.httpBaseUrl,httpToken:e.httpToken,sessionId:e.sessionId,file:d.file});n(p=>p.map(m=>m.id===d.id?{...m,url:f.url,status:"done"}:m))}catch(f){const p=f instanceof Xl?f.code:"UPLOAD_FAILED",m=f.message??"upload failed";n(v=>v.map(b=>b.id===d.id?{...b,status:"error",error:`${p}: ${m}`}:b))}}))},[e.sessionId,e.httpBaseUrl,e.httpToken]),i=g.useCallback(o=>{n(a=>a.filter(l=>l.id!==o))},[]),s=g.useCallback(()=>{n([])},[]);return{attachments:t,setAttachments:n,addFiles:r,removeAttachment:i,clearAttachments:s}}const B0=new Map,rJ=[];function Mk(e){if(e)return B0.get(e)}function Ak(e,t){e&&(t.draft.length===0&&t.attachments.length===0?B0.delete(e):B0.set(e,t))}function iJ(e,t){return e.replace(/(^|\s)\/(\S+)/g,(n,r,i)=>{const s=t.find(o=>o.name===i&&o.path);return s!=null&&s.path?`${r}[skill:${i}:${s.path}]`:n})}function sJ({api:e,cwd:t,sessionKey:n,onSend:r,disabled:i,onNewSession:s,onClearSession:o,tool:a,spawnableContacts:l=rJ,ensureRemotePersonas:c,remotePersonasByDeviceId:u}){const d=Mk(n),[f,p]=g.useState((d==null?void 0:d.draft)??""),[m,v]=g.useState(!1),b=g.useRef(null),_=g.useRef(!1),x=g.useCallback(()=>{_.current=!0},[]),y=g.useCallback(()=>{_.current=!1},[]),w=tp(),{attachments:C,setAttachments:k,addFiles:T,removeAttachment:N,clearAttachments:z}=nJ({httpBaseUrl:w.httpBaseUrl,httpToken:w.httpToken,sessionId:n,initial:(d==null?void 0:d.attachments)??[]}),[P,B]=g.useState([]),[R,I]=g.useState(!1),[j,L]=g.useState(0),[$,F]=g.useState(!1),[D,O]=g.useState([]),[E,H]=g.useState(!1),[V,A]=g.useState(0),[ne,ae]=g.useState(!1),[G,ye]=g.useState([]),[Fe,ue]=g.useState(!1),[Ie,Re]=g.useState(null),[Ke,ve]=g.useState(!1),ze=g.useRef(null),fn=g.useMemo(()=>{const se=[];return s&&se.push({name:"new",source:"builtin",description:"在当前目录下新建会话"}),o&&n&&se.push({name:"clear",source:"builtin",description:"清除当前会话"}),se},[s,o,n]),it=g.useMemo(()=>[...fn,...P],[fn,P]),Rt=g.useMemo(()=>{const se=f.match(/^\/(\S*)$/);return se?se[1]:null},[f]),Gt=Rt!==null&&!$,Mt=g.useMemo(()=>Rt!==null?qM(it,Rt):[],[it,Rt]),bt=g.useMemo(()=>{const se=f.match(/^@(\S*)$/);return se?se[1]:null},[f]),Qe=bt!==null&&!ne,st=g.useMemo(()=>Ie?((u==null?void 0:u.get(Ie.deviceId))??[]).map(q=>({kind:"remote-persona",persona:q,deviceId:Ie.deviceId})):[...D.map(se=>({kind:"cc-agent",agent:se})),...G.map(se=>({kind:"persona",persona:se})),...l.map(se=>({kind:"contact",contact:se}))],[Ie,u,D,G,l]),wt=g.useMemo(()=>bt!==null?KM(st,bt):[],[st,bt]),pn=g.useRef(f);g.useEffect(()=>{f!==pn.current&&(F(!1),ae(!1),pn.current=f)},[f]);const on=g.useCallback(()=>{F(!0)},[]),U=g.useCallback(()=>{ae(!0)},[]),Z=g.useRef(f),_e=g.useRef(C);g.useEffect(()=>{Z.current=f},[f]),g.useEffect(()=>{_e.current=C},[C]);const ke=g.useRef(n);g.useEffect(()=>{const se=ke.current;if(se===n)return;Ak(se,{draft:Z.current,attachments:_e.current});const q=Mk(n);p((q==null?void 0:q.draft)??""),k((q==null?void 0:q.attachments)??[]),L(0),A(0),F(!1),ae(!1),Re(null),ze.current=null,ve(!1),queueMicrotask(()=>{q!=null&&q.draft?GM(b.current):Xo(b.current)}),ke.current=n},[n,k]),g.useEffect(()=>()=>{Ak(ke.current,{draft:Z.current,attachments:_e.current})},[]),g.useEffect(()=>{L(0)},[Rt]),g.useEffect(()=>{A(0)},[bt]),g.useEffect(()=>{bt===null&&Ie&&(Re(null),ze.current=null,ve(!1))},[bt,Ie]),g.useEffect(()=>{if(!Gt||R)return;if(!e){I(!0);return}let se=!1;return(async()=>{try{const q=await e.skillsList(t,a);se||(B(q.skills??[]),I(!0))}catch{se||I(!0)}})(),()=>{se=!0}},[Gt,R,e,t,a]),g.useEffect(()=>{if(!Qe||E)return;if(!e){H(!0);return}let se=!1;return(async()=>{try{const q=await e.agentsList(t,a);se||(O(q.agents??[]),H(!0))}catch{se||H(!0)}})(),()=>{se=!0}},[Qe,E,e,t,a]),g.useEffect(()=>{if(!Qe||Fe)return;if(!e){ue(!0);return}let se=!1;return(async()=>{try{const q=await e.personaList();se||(ye((q.personas??[]).map(we=>({personaId:we.personaId,label:we.label}))),ue(!0))}catch{se||ue(!0)}})(),()=>{se=!0}},[Qe,Fe,e]);const He=g.useCallback(se=>{switch(se.kind){case"persona":p(`@persona/${se.persona.personaId} `);break;case"cc-agent":p(`@"${se.agent.name} (agent)" `);break;case"contact":{const q=se.contact.deviceId;Re({deviceId:q,displayName:se.contact.displayName}),ze.current=q,ve(!0),Promise.resolve(c==null?void 0:c(q)).finally(()=>{ze.current===q&&ve(!1)}),p("@"),ae(!1),setTimeout(()=>{var we;return(we=b.current)==null?void 0:we.focus()},0);return}case"remote-persona":p(`@persona/${se.persona.personaId}@${se.deviceId} `),Re(null);break}ae(!1),setTimeout(()=>{var q;return(q=b.current)==null?void 0:q.focus()},0)},[c]),Nt=g.useCallback(()=>{Re(null),ze.current=null,ve(!1),p("@"),setTimeout(()=>{var se;return(se=b.current)==null?void 0:se.focus()},0)},[]),Yt=g.useCallback(se=>{if(se.source==="builtin"&&se.name==="new"&&s){p(""),z(),Xo(b.current),s(t);return}if(se.source==="builtin"&&se.name==="clear"&&o){p(""),z(),Xo(b.current),o();return}p(`/${se.name} `),setTimeout(()=>{var q;return(q=b.current)==null?void 0:q.focus()},0)},[s,t,z,o]),Xt=g.useCallback(async()=>{const se=f.trim(),q=C.filter(we=>we.status==="done");if(!(!se&&q.length===0)&&!(m||i)){if(se==="/new"&&s){v(!0);try{await s(t),p(""),z(),Xo(b.current)}finally{v(!1)}return}if(se==="/clear"&&o){v(!0);try{await o(),p(""),z(),Xo(b.current)}finally{v(!1)}return}v(!0);try{const we=a==="codex"?iJ(se,P):se,ht=oZ(we,C);await r(ht),p(""),z(),Xo(b.current)}finally{v(!1)}}},[f,C,m,i,r,s,t,z,o,a,P]);return{draft:f,setDraft:p,sending:m,textareaRef:b,isComposingRef:_,onCompositionStart:x,onCompositionEnd:y,attachments:C,addFiles:T,removeAttachment:N,skillSelectorVisible:Gt,filteredSkills:Mt,slashQuery:Rt??"",activeSkillIdx:j,setActiveSkillIdx:L,selectSkill:Yt,dismissSkillSelector:on,agentSelectorVisible:Qe,filteredAgents:wt,mentionQuery:bt,activeAgentIdx:V,setActiveAgentIdx:A,selectAgent:He,dismissAgentSelector:U,drilldown:Ie,drilldownLoading:Ke,exitDrilldown:Nt,doSend:Xt}}const oJ=120;function GM(e){e&&(e.style.height="auto",e.style.height=`${Math.min(e.scrollHeight,oJ)}px`)}function Xo(e){e&&(e.style.height="auto")}const aJ={spawnableContacts:[],ensureRemotePersonas:()=>Promise.resolve(),remotePersonasByDeviceId:new Map},lJ=g.createContext(aJ);function cJ(){return g.useContext(lJ)}function uJ({url:e,fileName:t,onClose:n}){const[r,i]=g.useState(!1);g.useEffect(()=>{const o=a=>{a.key==="Escape"&&n()};return document.addEventListener("keydown",o),()=>document.removeEventListener("keydown",o)},[n]);const s=async()=>{try{const a=await(await fetch(e)).blob();await navigator.clipboard.write([new ClipboardItem({[a.type]:a})]),i(!0),setTimeout(()=>i(!1),2e3)}catch{Lk(e,t)}};return h.jsx("div",{"data-testid":"image-lightbox",className:"fixed inset-0 z-[9999] flex items-center justify-center bg-black/60",onClick:n,role:"dialog","aria-modal":"true",children:h.jsxs("div",{className:"relative",onClick:o=>o.stopPropagation(),children:[h.jsx("img",{src:e,alt:t,className:"max-h-[90vh] max-w-[92vw] rounded-lg object-contain shadow-2xl"}),h.jsxs("div",{className:"absolute right-2 top-2 flex items-center gap-1.5",children:[h.jsxs("button",{type:"button",onClick:s,"data-testid":"image-lightbox-copy",className:"flex cursor-pointer items-center gap-1 rounded-full border border-bg-300 bg-bg-50/95 px-2 py-0.5 text-[11px] font-medium text-text-200 shadow transition-colors hover:bg-bg-100",children:[h.jsx(ip,{className:"h-3 w-3"}),r?"Copied":"Copy"]}),h.jsxs("button",{type:"button",onClick:()=>Lk(e,t),"data-testid":"image-lightbox-save",className:"flex cursor-pointer items-center gap-1 rounded-full border border-bg-300 bg-bg-50/95 px-2 py-0.5 text-[11px] font-medium text-text-200 shadow transition-colors hover:bg-bg-100",children:[h.jsx(kz,{className:"h-3.5 w-3.5"}),"Save"]}),h.jsx("button",{type:"button",onClick:n,"data-testid":"image-lightbox-close","aria-label":"close",className:"flex h-6 w-6 cursor-pointer items-center justify-center rounded-full border border-bg-300 bg-bg-50/95 text-text-300 transition-colors hover:bg-bg-100 hover:text-text-100",children:h.jsx(Dr,{className:"h-3 w-3"})})]})]})})}function Lk(e,t){const n=document.createElement("a");n.href=e,n.download=t||"image",n.click()}const jk=1e3,dJ=5e3;function Ed(e){if(!e)return"null";if(e===document.body)return"body";const t=e.getAttribute("data-testid"),n=typeof e.className=="string"&&e.className.trim()?`.${e.className.trim().split(/\s+/).slice(0,3).join(".")}`:"";return`${e.tagName.toLowerCase()}${e.id?`#${e.id}`:""}${t?`[${t}]`:""}${n}`}function hJ({meta:e,api:t,cwd:n,tool:r,onSend:i,sessionKey:s,disabled:o=!1,placeholder:a,className:l,awaitingUser:c=!1,onAbort:u,onNewSession:d,onClearSession:f,configSlot:p,aboveSlot:m}){const v=(e==null?void 0:e.streamInProgress)??!1,b=(e==null?void 0:e.contextPct)??null,_=b==null?"":b>=80?"text-red-400":b>=50?"text-amber-400":"text-text-500",x=g.useRef(null),y=cJ(),w=sJ({...t?{api:t}:{},cwd:n,...r?{tool:r}:{},sessionKey:s,onSend:i,disabled:o,...d?{onNewSession:d}:{},...f?{onClearSession:f}:{},spawnableContacts:y.spawnableContacts,ensureRemotePersonas:y.ensureRemotePersonas,remotePersonasByDeviceId:y.remotePersonasByDeviceId}),{draft:C,setDraft:k,sending:T,textareaRef:N,attachments:z,addFiles:P,removeAttachment:B,skillSelectorVisible:R,filteredSkills:I,slashQuery:j,activeSkillIdx:L,setActiveSkillIdx:$,selectSkill:F,dismissSkillSelector:D,agentSelectorVisible:O,filteredAgents:E,mentionQuery:H,activeAgentIdx:V,setActiveAgentIdx:A,selectAgent:ne,dismissAgentSelector:ae,drilldown:G,drilldownLoading:ye,exitDrilldown:Fe,doSend:ue}=w,Ie=$Z();g.useEffect(()=>{if(!Ie||Ie.signal===0||s===null||Ie.sessionId!==s)return;const{signal:q}=Ie;console.log("[chat-focus] 收到聚焦信号",{sessionKey:s,signal:q,delayMs:jk,activeElement:Ed(document.activeElement)});let we=null,ht=null,an=null;const _l=setTimeout(()=>{if(we=N.current,!we){console.warn("[chat-focus] textarea 已不在,放弃聚焦",{sessionKey:s,signal:q});return}we.focus(),console.log("[chat-focus] focus() 已执行",{sessionKey:s,signal:q,landed:document.activeElement===we,activeElement:Ed(document.activeElement)}),ht=xl=>{const zo=Ed(xl.relatedTarget);setTimeout(()=>{console.warn("[chat-focus] STOLEN 输入框失焦",{sessionKey:s,signal:q,relatedTarget:zo,activeElementAfterTick:Ed(document.activeElement)})},0)},we.addEventListener("blur",ht,{once:!0}),an=setTimeout(()=>{we&&ht&&we.removeEventListener("blur",ht)},dJ)},jk);return()=>{clearTimeout(_l),an&&clearTimeout(an),we&&ht&&we.removeEventListener("blur",ht)}},[Ie==null?void 0:Ie.signal]);const Re=!!t,Ke=T||o||v,ze=(C.trim().length>0||z.some(q=>q.status==="done"))&&!o&&!T&&!c,fn=a??(c?"Answer the question above first...":Ke?"Queue a message...":`Message ${Wx(r)}...`),it=g.useRef(!1),Rt=g.useCallback(()=>{it.current=!0},[]),Gt=g.useCallback(()=>{it.current=!1},[]),Mt=g.useCallback(q=>{if(R&&I.length>0){if(q.key==="ArrowDown")return q.preventDefault(),$(L>=I.length-1?0:L+1),!0;if(q.key==="ArrowUp")return q.preventDefault(),$(L<=0?I.length-1:L-1),!0;if(q.key==="Tab"||q.key==="Enter"&&!q.shiftKey){q.preventDefault();const we=I[L];return we&&F(we),!0}if(q.key==="Escape")return q.preventDefault(),D(),!0}return!1},[R,I,L,$,F,D]),bt=g.useCallback(q=>{if(O&&E.length>0){if(q.key==="ArrowDown")return q.preventDefault(),A(V>=E.length-1?0:V+1),!0;if(q.key==="ArrowUp")return q.preventDefault(),A(V<=0?E.length-1:V-1),!0;if(q.key==="Tab"||q.key==="Enter"&&!q.shiftKey){q.preventDefault();const we=E[V];return we&&ne(we),!0}if(q.key==="Escape")return q.preventDefault(),G?Fe():ae(),!0}return!1},[O,E,V,A,ne,ae,G,Fe]),Qe=g.useCallback(q=>{const we=q.nativeEvent;q.key==="Enter"&&JI({compositionActive:it.current,nativeIsComposing:we.isComposing,keyCode:we.keyCode})||Mt(q)||bt(q)||eR({key:q.key,shiftKey:q.shiftKey,compositionActive:it.current,nativeIsComposing:we.isComposing,keyCode:we.keyCode})&&(q.preventDefault(),ze&&ue())},[Mt,bt,ze,ue]),st=g.useCallback(q=>{k(q.target.value),GM(q.target)},[k]),wt=g.useCallback(q=>{q.target.files&&P(q.target.files),q.target.value=""},[P]),pn=g.useCallback(q=>{if(!Re)return;const we=Array.from(q.clipboardData.items).map(ht=>ht.getAsFile()).filter(ht=>!!(ht&&ht.type.startsWith("image/")));we.length!==0&&(q.preventDefault(),P(we))},[P,Re]),[on,U]=g.useState(null),Z=g.useCallback(q=>{q.previewUrl&&U({url:q.previewUrl,name:q.fileName})},[]),[_e,ke]=g.useState(!1),He=g.useCallback(q=>{Re&&(q.preventDefault(),ke(!0))},[Re]),Nt=g.useCallback(()=>ke(!1),[]),Yt=g.useCallback(q=>{Re&&(q.preventDefault(),ke(!1),q.dataTransfer.files.length>0&&P(q.dataTransfer.files))},[P,Re]),Xt=v&&!c&&typeof u=="function",se=o||c;return h.jsxs("div",{"data-testid":"chat-input",className:fe("shrink-0 border-t border-bg-300/20 px-4 py-3",l),onDragOver:He,onDragLeave:Nt,onDrop:Yt,children:[h.jsxs("div",{className:"max-w-3xl mx-auto relative",children:[Re?h.jsx("input",{ref:x,type:"file",multiple:!0,accept:GZ,hidden:!0,onChange:wt,"data-testid":"chat-input-file"}):null,h.jsxs("div",{"data-testid":"chat-input-bare",className:fe("flex flex-col gap-2"),children:[c||T||v?h.jsxs("div",{"data-testid":"chat-input-status-bar",className:"flex items-center gap-2 text-[12px] text-text-400",children:[h.jsxs("div",{className:"flex gap-1",children:[h.jsx("span",{className:"w-1.5 h-1.5 rounded-full bg-text-400-dim-fg animate-bounce",style:{animationDelay:"0ms"}}),h.jsx("span",{className:"w-1.5 h-1.5 rounded-full bg-text-400-dim-fg animate-bounce",style:{animationDelay:"150ms"}}),h.jsx("span",{className:"w-1.5 h-1.5 rounded-full bg-text-400-dim-fg animate-bounce",style:{animationDelay:"300ms"}})]}),h.jsx("span",{children:c?"Waiting for your answer":`${r==="codex"?"Codex":"Claude"} is working`})]}):null,R?h.jsx(BZ,{query:j,skills:I,activeIndex:L,onActiveIndexChange:$,onSelect:F}):null,O?G?!y.remotePersonasByDeviceId.has(G.deviceId)&&ye?h.jsx("div",{"data-testid":"cc-agent-remote-loading",className:"absolute bottom-full left-0 right-0 z-50 mb-1.5 rounded-2xl border border-bg-300 bg-bg-50 px-4 py-3 text-[12px] text-text-300 shadow-lg",children:`正在加载 @${G.displayName} 的 persona…`}):E.length>0?h.jsx(Ik,{query:H??"",entries:E,activeIndex:V,onActiveIndexChange:A,onSelect:ne}):h.jsx("div",{"data-testid":"cc-agent-remote-empty",className:"absolute bottom-full left-0 right-0 z-50 mb-1.5 rounded-2xl border border-bg-300 bg-bg-50 px-4 py-3 text-[12px] text-text-300 shadow-lg",children:`@${G.displayName} 暂无可派活的 persona(可能离线或未公开)`}):h.jsx(Ik,{query:H??"",entries:E,activeIndex:V,onActiveIndexChange:A,onSelect:ne}):null,z.length>0?h.jsx(qZ,{attachments:z,onRemove:B,onOpenPreview:Z}):null,m?h.jsx("div",{"data-testid":"chat-input-above-slot",className:"mx-2 -mb-3 rounded-t-xl border border-b-0 border-border bg-bg-0 px-3 pt-2 pb-4",children:m}):null,h.jsxs("div",{"data-testid":"bare-chat-input-frame",className:fe("relative flex flex-col gap-1 rounded-xl border border-border bg-bg-0 px-3 py-2 transition-colors duration-200",se?"opacity-60":null,_e?"border-accent/60 bg-accent/5":null),children:[h.jsx("textarea",{ref:N,"data-testid":"chat-input-textarea",value:C,onChange:st,onKeyDown:Qe,onCompositionStart:Rt,onCompositionEnd:Gt,onPaste:pn,placeholder:fn,disabled:se,readOnly:se,rows:1,className:"w-full resize-none bg-transparent border-0 outline-none text-[14px] text-text-100 placeholder:text-text-400 leading-relaxed py-1 min-h-[22px] max-h-[120px] overflow-y-auto disabled:cursor-not-allowed"}),h.jsxs("div",{className:"flex items-center gap-1.5",children:[Re?h.jsx("button",{type:"button",onClick:()=>{var q;return(q=x.current)==null?void 0:q.click()},disabled:Ke,"data-testid":"chat-input-attach","aria-label":"attach files",className:fe("flex h-7 w-7 shrink-0 items-center justify-center rounded-md transition-colors",Ke?"cursor-default text-text-400/50":"cursor-pointer text-text-400 hover:bg-text-100/5 hover:text-text-200"),children:h.jsx(Jz,{className:"h-4 w-4"})}):null,h.jsx("div",{className:"flex-1 min-w-0"}),b!=null?h.jsxs("span",{"data-testid":"chat-input-ctx",className:fe("shrink-0 text-[11px] tabular-nums",_),children:["ctx:",b,"%"]}):null,p,Xt?h.jsx("button",{type:"button",onClick:u,"data-testid":"chat-input-abort","aria-label":"interrupt",title:"中断当前轮次(不杀进程)",className:"h-8 w-8 rounded-full flex items-center justify-center border border-text-400/40 text-text-400 hover:bg-text-100/5 hover:text-text-100 transition-colors cursor-pointer",children:h.jsx(FN,{className:"w-3.5 h-3.5",strokeWidth:2.5})}):null,h.jsx("button",{type:"button",onClick:()=>{ze&&ue()},disabled:!ze,"data-testid":"chat-input-send","aria-label":"send",className:fe("h-8 w-8 rounded-full flex items-center justify-center transition-colors",ze?"bg-accent text-white hover:bg-accent-hover cursor-pointer shadow-sm":"bg-[var(--text-400-dim)] text-[var(--text-400-dim-fg)] cursor-default"),children:h.jsx(tz,{className:"w-4 h-4",strokeWidth:2.5})})]})]})]})]}),on?h.jsx(uJ,{url:on.url,fileName:on.name,onClose:()=>U(null)}):null]})}function fJ(e){const t=e.replace(/\/+$/,""),n=t.lastIndexOf("/");return n>=0?t.slice(n+1):t}function pJ({meta:e,tool:t,connState:n,variant:r="full",onOpenConfig:i,liveWorktreeRoot:s,ephemeral:o=!1,onPromote:a,className:l}){const c=s??e.cwd??"",d=!!e.sessionLabel&&e.sessionLabel!==e.sessionId?e.sessionLabel:fJ(c),f=c;return r==="quickask"?h.jsxs("div",{"data-testid":"chat-header","data-variant":"quickask",className:fe("flex items-center shrink-0 px-3 py-2 gap-2",l),children:[a?h.jsx("button",{type:"button","data-testid":"chat-header-promote","data-promoted":o?"false":"true",disabled:!o,onClick:a,title:o?"保留为正式会话":"已保留为正式会话",className:fe("shrink-0 inline-flex items-center justify-center h-5 w-5 rounded-md transition-colors",o?"text-text-500 hover:text-text-200 hover:bg-text-100/5 cursor-pointer":"text-amber-400"),children:h.jsx(lz,{className:fe("w-3.5 h-3.5",!o&&"fill-current")})}):null,h.jsx("span",{className:"font-semibold text-text-100 truncate text-[13px]","data-testid":"chat-header-worktree",title:f,children:d})]}):h.jsxs("div",{"data-testid":"chat-header","data-variant":"full",className:fe("relative flex items-center shrink-0 px-4 pr-[4.5rem] md:pr-4 py-2.5",l),children:[h.jsx("span",{className:"font-semibold text-text-100 truncate text-[13px]","data-testid":"chat-header-worktree",title:f,children:d}),h.jsx("div",{className:"absolute right-4 top-1/2 -translate-y-1/2 z-10 flex items-center gap-1",children:i?h.jsx("button",{type:"button","aria-label":"Session settings","data-testid":"chat-header-settings-mobile",onClick:i,title:"Session settings",className:"flex md:hidden h-7 w-7 items-center justify-center rounded-md bg-transparent text-text-300 transition-colors duration-150 hover:bg-bg-200 hover:text-text-100 cursor-pointer outline-none",children:h.jsx(zN,{className:"w-4 h-4"})}):null})]})}let mJ=null;function gJ(){return mJ}function Ql({label:e,labelTitle:t,children:n}){return h.jsxs("div",{className:"flex items-start gap-2 px-2 py-1",children:[h.jsx("span",{className:"w-14 shrink-0 truncate text-[11px] text-text-400 pt-0.5",...t?{title:t}:{},children:e}),h.jsx("span",{className:"flex-1 min-w-0 text-[12px] text-text-100",children:n})]})}function Dk({label:e,labelTitle:t,value:n,testid:r}){const[i,s]=g.useState(!1),o=g.useRef(null);g.useEffect(()=>()=>{o.current&&clearTimeout(o.current)},[]);const a=()=>{typeof navigator>"u"||!navigator.clipboard||navigator.clipboard.writeText(n).then(()=>{s(!0),o.current&&clearTimeout(o.current),o.current=setTimeout(()=>s(!1),2e3)},()=>{})};return h.jsx(Ql,{label:e,labelTitle:t,children:h.jsxs("button",{type:"button",onClick:a,"data-testid":r,title:i?"已复制":`复制:${n}`,className:"w-full flex items-center gap-1.5 text-left group cursor-pointer",children:[h.jsx("span",{className:"font-mono text-[11px] text-text-300 truncate flex-1 min-w-0",children:n}),i?h.jsx(ul,{className:"w-3 h-3 shrink-0 text-accent"}):h.jsx(ip,{className:"w-3 h-3 shrink-0 text-text-400 opacity-0 group-hover:opacity-100 transition-opacity"})]})})}function ig({icon:e,label:t,meta:n,onClick:r,testid:i}){return h.jsxs("button",{type:"button","data-testid":i,onClick:r,className:"w-full flex items-center gap-2.5 px-2 py-1.5 rounded-md hover:bg-text-100/5 cursor-pointer text-left",children:[h.jsx("span",{className:"w-4 h-4 shrink-0 text-text-300 inline-flex items-center justify-center",children:e}),h.jsx("span",{className:"flex-1 text-[12.5px] text-text-100",children:t}),n?h.jsx("span",{className:"shrink-0 text-[11px] text-text-400 font-mono",children:n}):null]})}function vJ({session:e,meta:t,liveGitBranch:n,liveWorktreeRoot:r,personaName:i,onOpenPersona:s,onOpenFiles:o,cronActiveCount:a,onCronClick:l,onForceStop:c,viewerRole:u="owner",toolSessionIdLabel:d="tool session id",drill:f=null,onCollapse:p}){const m=n!==void 0?n:t.gitBranch??null,v=t.procAlive??!1,b=cP(e),_=b!=null&&e.originOwnerPrincipalId==null&&u!=="guest",[x,y]=g.useState(null),w=g.useRef(null);g.useEffect(()=>()=>{w.current&&clearTimeout(w.current)},[]);const C=async()=>{if(!_)return;const k=gJ();let T;try{k||(await navigator.clipboard.writeText(b),T="命令已复制")}catch{T="操作失败"}y(T),w.current&&clearTimeout(w.current),w.current=setTimeout(()=>y(null),2500)};return h.jsxs("div",{"data-testid":"session-info-panel",className:"h-full min-w-0 border-l border-border bg-bg-100 flex flex-col",children:[h.jsxs("div",{className:"flex items-center gap-2 px-3 py-2.5 border-b border-border shrink-0",children:[f?h.jsx("button",{type:"button","data-testid":"session-info-back",onClick:f.onBack,"aria-label":"返回会话信息",className:"p-1 -ml-1 rounded text-text-400 hover:text-text-100 hover:bg-text-100/10",children:h.jsx(JB,{className:"w-4 h-4"})}):p?h.jsx("button",{type:"button","data-testid":"session-info-collapse",onClick:p,"aria-label":"collapse session info",title:"收起会话信息",className:"p-1 -ml-1 rounded text-text-400 hover:text-text-100 hover:bg-text-100/10",children:h.jsx(Nm,{className:"w-4 h-4"})}):h.jsx(Nm,{className:"w-4 h-4 text-text-300"}),h.jsx("span",{className:"flex-1 text-[13px] font-medium text-text-100 truncate",children:f?f.title:"会话信息"}),f&&p?h.jsx("button",{type:"button","data-testid":"session-info-collapse",onClick:p,"aria-label":"collapse session info",title:"收起会话信息",className:"p-1 rounded text-text-400 hover:text-text-100 hover:bg-text-100/10",children:h.jsx(Nm,{className:"w-4 h-4"})}):null]}),f?h.jsx("div",{"data-testid":"session-info-drill",className:"flex-1 min-h-0 overflow-y-auto",children:f.content}):h.jsxs("div",{className:"flex-1 overflow-y-auto px-2 py-2",children:[m?h.jsx(Ql,{label:"分支",children:h.jsxs("span",{"data-testid":"session-info-branch",className:"inline-flex items-center gap-1 font-mono text-[11.5px] min-w-0",title:r??void 0,children:[h.jsx(zx,{className:"w-3 h-3 shrink-0 text-text-400"}),h.jsx("span",{className:"truncate",children:m})]})}):null,i&&s?h.jsx(Ql,{label:"persona",children:h.jsxs("button",{type:"button","data-testid":"session-info-persona",onClick:s,className:"inline-flex items-center gap-1 hover:text-accent cursor-pointer",children:[h.jsx(VN,{className:"w-3 h-3"}),h.jsx("span",{className:"truncate",children:i})]})}):null,h.jsx(Ql,{label:"引擎",children:h.jsxs("span",{className:"inline-flex items-center gap-1.5","data-testid":"session-info-engine",children:[h.jsx(sp,{tool:e.tool,className:fe("w-3.5 h-3.5 shrink-0",op(e.tool))}),h.jsxs("span",{className:"truncate",children:[Wx(e.tool),t.model?` · ${t.model}`:""]})]})}),h.jsx(Ql,{label:"cwd",children:h.jsx("span",{"data-testid":"session-info-cwd",className:"font-mono text-[11px] text-text-300 truncate block",title:e.cwd,children:e.cwd})}),h.jsx(Dk,{label:"session id",value:e.sessionId,testid:"session-info-session-id"}),e.toolSessionId?h.jsx(Dk,{label:`${e.tool||"claude"} id`,labelTitle:d,value:e.toolSessionId,testid:"session-info-tool-session-id"}):null,h.jsx("div",{className:"my-2 border-t border-border"}),o?h.jsx(ig,{icon:h.jsx(Rz,{className:"w-3.5 h-3.5"}),label:"Edited Files",onClick:o,testid:"session-info-files"}):null,a&&a>0&&l?h.jsx(ig,{icon:h.jsx(xz,{className:"w-3.5 h-3.5"}),label:"定时任务",meta:String(a),onClick:l,testid:"session-info-cron"}):null,_?h.jsx(ig,{icon:h.jsx(w$,{className:"w-3.5 h-3.5"}),label:"终端",meta:x,onClick:()=>void C(),testid:"session-info-terminal"}):null]}),v&&c?h.jsx("div",{className:"shrink-0 border-t border-border px-3 py-2.5",children:h.jsxs("button",{type:"button","data-testid":"session-info-force-stop",onClick:c,title:e.tool==="codex"?"强制停止 Codex 进程":"强制停止 Claude Code 进程(会丢失 initialize / 预热缓存)",className:"inline-flex items-center gap-1.5 h-6 px-2.5 rounded-md text-text-400 hover:bg-red-500/10 hover:text-red-400 transition-colors text-[12px] cursor-pointer",children:[h.jsx(Xz,{className:"w-3.5 h-3.5"}),h.jsx("span",{children:"强制停止"})]})}):null]})}const _J=g.createContext({container:null});function xJ(){return g.useContext(_J)}function yJ(e){return e==="TodoWrite"}function bJ(e){if(!e||typeof e!="object")return null;const t=e;if(!Array.isArray(t.todos))return null;const n=[];for(const r of t.todos){if(!r||typeof r!="object")continue;const i=r,s=typeof i.content=="string"?i.content:"";if(!s)continue;const o=i.status==="in_progress"||i.status==="completed"?i.status:"pending",a=typeof i.activeForm=="string"?i.activeForm:void 0;n.push({content:s,status:o,activeForm:a})}return n}function wJ(e,t,n){const r=[],i=new Map;for(let s=0;s<e.length;s++){const o=e[s],a=typeof o.seq=="number"?o.seq:s;switch(o.kind){case"session_init":r.push({kind:"session-init",seq:a,toolSessionId:o.toolSessionId});break;case"text":Ok(r,a,"assistant-text",o.text,o.partialId,o.uuid);break;case"thinking":Ok(r,a,"assistant-thinking",o.text,o.partialId);break;case"user_text":{o.meta==="task-notification"?r.push({kind:"agent-notification",seq:a,text:o.text,taskId:o.taskId,parentToolUseId:o.parentToolUseId}):o.meta?r.push({kind:"user-meta",seq:a,metaKind:o.meta,text:o.text}):r.push({kind:"user-text",seq:a,text:o.text,uuid:o.uuid,...o.sender&&o.sender.principal!=="owner"?{senderDisplayName:o.sender.displayName}:{}});break}case"tool_call":YM(r,a,o.toolUseId,o.tool,o.input,o.toolKind);break;case"tool_result":{const l=i.get(o.toolUseId);if(l!==void 0){if(o.askQuestionAnswers){const u=r[l];u.submittedAnswers=o.askQuestionAnswers}i.delete(o.toolUseId);break}const c={kind:"tool-result",seq:a,toolUseId:o.toolUseId,output:o.output,error:o.error};o.toolResultExtra&&(c.toolResultExtra=o.toolResultExtra),r.push(c);break}case"attachment_memories":r.push({kind:"memory-callout",seq:a,memories:o.memories});break;case"permission_request":{if(!t||o.requestId!==t)break;r.push({kind:"permission-inline",seq:a,requestId:o.requestId,tool:o.tool,input:o.input});break}case"ask_user_question":i.set(o.toolUseId,r.length),r.push({kind:"question-card",seq:a,toolUseId:o.toolUseId,questions:o.questions});break;case"turn_end":{const l={kind:"turn-end",seq:a};o.durationMs!==void 0&&(l.durationMs=o.durationMs),o.reason!==void 0&&(l.reason=o.reason),r.push(l);break}case"subagent_progress":{const l={kind:"agent-progress",seq:a,toolUseId:o.toolUseId,agentId:o.agentId,status:o.status};o.description&&(l.description=o.description),o.lastToolName&&(l.lastToolName=o.lastToolName),o.prompt&&(l.prompt=o.prompt),o.stats&&(l.stats=o.stats),r.push(l);break}case"error":r.push({kind:"error",seq:a,message:o.message});break}}return r}function YM(e,t,n,r,i,s){if(yJ(r)){const o=bJ(i);if(o){e.push({kind:"todo-checklist",seq:t,toolUseId:n,todos:o});return}}if(r==="Agent"){const o=i??{},a=typeof o.description=="string"&&o.description?o.description:typeof o.subagent_type=="string"&&o.subagent_type?o.subagent_type:"Subagent";e.push({kind:"agent-call",seq:t,toolUseId:n,description:a,input:i});return}if(lW(r)){e.push({kind:"task-event",seq:t,toolUseId:n,name:r,input:i});return}e.push({kind:"tool-call",seq:t,toolUseId:n,tool:r,toolKind:s,input:i})}function Ok(e,t,n,r,i,s){let o=-1;for(let c=e.length-1;c>=0;c--)if(e[c].kind===n){o=c;break}const a=o>=0?e[o]:null;if(i){if(a&&a.partialId===i){const u=n==="assistant-text"?{kind:n,seq:a.seq,text:a.text+r,partialId:i,...s?{uuid:s}:{}}:{kind:n,seq:a.seq,text:a.text+r,partialId:i};e[o]=u;return}const c=n==="assistant-text"?{kind:n,seq:t,text:r,partialId:i,...s?{uuid:s}:{}}:{kind:n,seq:t,text:r,partialId:i};e.push(c);return}if(a&&a.partialId){const c=n==="assistant-text"?{kind:n,seq:a.seq,text:r,...s?{uuid:s}:{}}:{kind:n,seq:a.seq,text:r};e[o]=c;return}const l=n==="assistant-text"?{kind:n,seq:t,text:r,...s?{uuid:s}:{}}:{kind:n,seq:t,text:r};e.push(l)}const SJ="AskUserQuestion";function XM(e,t=0,n){var o;const r=[],i=new Map;let s=t;for(const a of e){const l=s++,c=a.toolUseId??`hist-${l}`;switch(a.kind){case"user-text":if(a.meta==="task-notification")r.push({kind:"agent-notification",seq:l,text:a.text??"",taskId:a.taskId,parentToolUseId:a.parentToolUseId});else if(a.meta)r.push({kind:"user-meta",seq:l,metaKind:a.meta,text:a.text??""});else{const u=(o=Q6.exec(a.text??""))==null?void 0:o[1];r.push({kind:"user-text",seq:l,text:a.text??"",uuid:a.uuid,...u?{senderDisplayName:u}:{}})}break;case"assistant-text":r.push({kind:"assistant-text",seq:l,text:a.text??"",uuid:a.uuid});break;case"tool_call":{if(a.tool===SJ){const u=a.input??{},d=Array.isArray(u.questions)?u.questions:[];i.set(c,r.length),r.push({kind:"question-card",seq:l,toolUseId:c,questions:d});break}YM(r,l,c,a.tool??"",a.input,n);break}case"tool_result":{const u=i.get(c);if(u!==void 0){if(a.askQuestionAnswers){const f=r[u];f.submittedAnswers=a.askQuestionAnswers}i.delete(c);break}const d={kind:"tool-result",seq:l,toolUseId:c,output:a.output};a.error!==void 0&&(d.error=a.error),a.toolResultExtra&&(d.toolResultExtra=a.toolResultExtra),r.push(d);break}case"attachment_memories":a.memories&&a.memories.length>0&&r.push({kind:"memory-callout",seq:l,memories:a.memories});break;case"summary":break;case"turn-end":{const u={kind:"turn-end",seq:l};typeof a.durationMs=="number"&&(u.durationMs=a.durationMs),r.push(u);break}}}return r}const kJ=5e5;function CJ(e){const t=kJ-e.length;return e.map(n=>({...n,seq:n.seq+t}))}function EJ({api:e,cwd:t,toolSessionId:n,toolKind:r="claude"}){const i=UM(),s=(i==null?void 0:i.state.agentId)??null,o=i==null?void 0:i.state.agentType,[a,l]=g.useState([]),[c,u]=g.useState(!1),[d,f]=g.useState(null);g.useEffect(()=>{if(!s)return;let m=!1;return u(!0),f(null),l([]),e.historySubagentRead({cwd:t,toolSessionId:n,subagentId:s}).then(v=>{m||l(v.messages??[])}).catch(v=>{m||f(v instanceof Error?v.message:String(v))}).finally(()=>{m||u(!1)}),()=>{m=!0}},[s,t,n,e]);const p=g.useMemo(()=>a.length>0?XM(a,0,r):[],[a,r]);return!i||!s?null:h.jsxs("div",{"data-testid":"subagent-drawer","data-agent-id":s,className:fe("fixed inset-y-0 right-0 z-50 w-[min(560px,92vw)]","flex flex-col border-l border-bg-200/60 bg-bg-50 shadow-xl"),style:{paddingTop:"env(safe-area-inset-top)"},children:[h.jsxs("div",{className:"flex flex-col gap-0.5 px-3 py-2 border-b border-bg-200/60",children:[h.jsxs("div",{className:"flex items-center justify-between",children:[h.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[o?h.jsx("span",{className:"inline-flex items-center rounded-sm bg-violet-500/10 px-1.5 py-0.5 text-[11px] text-violet-400 font-medium",children:o}):null,h.jsx("span",{className:"font-mono text-[11px] text-text-400 truncate",title:s,children:s})]}),h.jsx("button",{type:"button","aria-label":"关闭",onClick:()=>i.close(),className:"p-1 rounded hover:bg-bg-200/50 text-text-400 hover:text-text-200",children:h.jsx(Dr,{className:"w-4 h-4"})})]}),!c&&!d&&a.length>0?h.jsxs("div",{className:"text-[11px] text-text-400",children:[a.length," 条消息 · 首条为主会话派发的任务指令"]}):null]}),h.jsx("div",{className:"flex-1 min-h-0 overflow-y-auto overflow-x-hidden px-3 py-2",children:c?h.jsxs("div",{className:"flex items-center gap-2 text-[12px] text-text-400",children:[h.jsx(In,{className:"w-3.5 h-3.5 animate-spin"}),h.jsx("span",{children:"加载中…"})]}):d?h.jsxs("div",{className:"flex items-center gap-2 text-[12px] text-error",children:[h.jsx(Ls,{className:"w-3.5 h-3.5"}),h.jsx("span",{children:d})]}):p.length===0?h.jsx("div",{className:"text-[12px] text-text-400 italic",children:"无消息"}):h.jsx(VM,{lines:p})})]})}function Bk(e,t){let n=0;for(const r of e.lines)r.startsWith(t)&&n++;return n}function TJ(e,t){const n=e.findIndex(c=>c.kind==="user-text"&&c.uuid===t);if(n<0)return{userMessageId:t,files:[],totalInsertions:0,totalDeletions:0,anchorFound:!1};let r=e.length;for(let c=n+1;c<e.length;c++)if(e[c].kind==="user-text"){r=c;break}const i=[],s=new Map;for(let c=n+1;c<r;c++){const u=e[c];if(u.kind!=="tool-result")continue;const d=u.toolResultExtra;if(!(d!=null&&d.filePath)||!d.structuredPatch||d.structuredPatch.length===0)continue;const f=d.filePath;let p=s.get(f);p||(p={filePath:f,hunks:[],insertions:0,deletions:0},s.set(f,p),i.push(f));for(const m of d.structuredPatch)p.hunks.push(m),p.insertions+=Bk(m,"+"),p.deletions+=Bk(m,"-")}const o=i.map(c=>s.get(c)),a=o.reduce((c,u)=>c+u.insertions,0),l=o.reduce((c,u)=>c+u.deletions,0);return{userMessageId:t,files:o,totalInsertions:a,totalDeletions:l,anchorFound:!0}}function NJ({open:e,onOpenChange:t,api:n,sessionId:r,userMessageId:i,lines:s,procAlive:o,onApplied:a,onNoChanges:l}){const c=g.useMemo(()=>TJ(s,i),[s,i]),[u,d]=g.useState(null),[f,p]=g.useState(!1),[m,v]=g.useState(!1),[b,_]=g.useState(null);g.useEffect(()=>{if(!e)return;let k=!1;return p(!0),d(null),(async()=>{try{const T=await n.sessionRewindDiff({sessionId:r,userMessageId:i});k||(d(T),!T.canRewind&&!T.error&&T.files.length===0&&(l==null||l(i)))}catch{k||d(null)}finally{k||p(!1)}})(),()=>{k=!0}},[e,n,r,i]);const x=g.useMemo(()=>{if(u){const k=!u.canRewind&&!u.error&&u.files.length===0;if(u.canRewind||k)return{source:"rpc",anchorFound:!0,files:u.files.map(T=>({filePath:T.filePath,hunks:T.hunks,insertions:T.insertions,deletions:T.deletions})),totalInsertions:u.totalInsertions,totalDeletions:u.totalDeletions}}return{source:"local",anchorFound:c.anchorFound,files:c.files,totalInsertions:c.totalInsertions,totalDeletions:c.totalDeletions,rpcError:u==null?void 0:u.error}},[u,c]),y=g.useCallback(async()=>{v(!0),_(null);try{const k=await n.sessionRewind({sessionId:r,userMessageId:i,dryRun:!1});if(!k.canRewind){_(k.error??"回退失败");return}a==null||a(),t(!1)}catch(k){_(k.message||"回退失败")}finally{v(!1)}},[n,r,i,a,t]);if(!e)return null;const w=x.files.length>0,C=!f&&!m&&x.anchorFound&&w&&!b;return h.jsxs("div",{"data-testid":"rewind-preview-drawer",className:"fixed right-0 top-0 bottom-0 z-40 flex flex-col border-l border-bg-300/40 bg-bg-0 shadow-xl",style:{width:480,minWidth:480},children:[h.jsxs("div",{className:"flex items-center justify-between px-4 py-3 border-b border-bg-300/30 shrink-0",children:[h.jsxs("div",{className:"flex items-center gap-2",children:[h.jsx(WN,{className:"w-4 h-4 text-text-300"}),h.jsx("span",{className:"text-[14px] font-semibold text-text-100",children:"Rewind 预览"})]}),h.jsx("button",{type:"button",onClick:()=>t(!1),"data-testid":"rewind-drawer-close",className:"flex items-center justify-center w-7 h-7 rounded-md text-text-400 hover:bg-text-100/5 hover:text-text-200 cursor-pointer","aria-label":"close",children:h.jsx(Dr,{className:"w-4 h-4"})})]}),b?h.jsxs("div",{"data-testid":"rewind-error-banner",className:"mx-4 mt-3 flex items-start gap-2 rounded-md border border-red-400/40 bg-red-500/10 px-3 py-2 text-[12px] text-red-400",children:[h.jsx(Kc,{className:"w-4 h-4 shrink-0 mt-0.5"}),h.jsx("span",{children:b})]}):null,h.jsx("div",{className:"flex-1 overflow-y-auto px-4 py-3 space-y-3",children:f?h.jsxs("div",{"data-testid":"rewind-loading",className:"flex items-center gap-2 text-[12px] text-text-400",children:[h.jsx(In,{className:"w-3.5 h-3.5 animate-spin"}),h.jsx("span",{children:"正在读取快照…"})]}):x.anchorFound?w?h.jsxs(h.Fragment,{children:[h.jsxs("div",{"data-testid":"rewind-summary",className:"rounded-md border border-bg-300 bg-bg-100/40 px-3 py-2 text-[12px] text-text-200",children:[h.jsxs("div",{children:["将回退 ",h.jsx("span",{className:"font-semibold text-text-100",children:x.files.length})," ","个文件,",h.jsxs("span",{className:"text-green-500 font-mono",children:["+",x.totalInsertions]})," / ",h.jsxs("span",{className:"text-red-400 font-mono",children:["-",x.totalDeletions]})]}),x.source==="local"?h.jsx("div",{"data-testid":"rewind-source-hint",className:"mt-1 text-text-400 text-[11px]",children:"基于对话里 tool_result 估算(未读到 CC 快照,数字可能与实际磁盘略有差异)"}):null]}),x.files.map(k=>h.jsx(IJ,{file:k},k.filePath))]}):h.jsxs("div",{"data-testid":"rewind-no-changes",className:"rounded-md border border-bg-300 bg-bg-100/60 px-3 py-2 text-[12px] text-text-300 space-y-1",children:[h.jsx("div",{children:"磁盘上的文件已经和这个时刻的快照完全一致——没有需要回退的改动。"}),h.jsx("div",{className:"text-text-400 text-[11px]",children:"可能这条消息之后 Claude 没落盘编辑,或之前已经 rewind 过了。"})]}):h.jsx("div",{"data-testid":"rewind-no-anchor",className:"rounded-md border border-bg-300 bg-bg-100/60 px-3 py-2 text-[12px] text-text-300",children:"未能在当前消息流中找到对应的用户消息(可能已被历史裁剪)。"})}),h.jsxs("div",{className:"flex flex-col gap-2 px-4 py-3 border-t border-bg-300/30 shrink-0",children:[w&&x.anchorFound&&!o?h.jsxs("div",{"data-testid":"rewind-needs-cc",className:"flex items-start gap-2 rounded-md border border-bg-300 bg-bg-100/60 px-3 py-2 text-[12px] text-text-300",children:[h.jsx(Kc,{className:"w-4 h-4 shrink-0 mt-0.5 text-warning"}),h.jsx("span",{children:'Claude Code 进程当前未运行。点击"确认回退"时会自动启动它再执行 — 可能需要等一两秒。'})]}):null,h.jsxs("div",{className:"flex items-center justify-end gap-2",children:[h.jsx("button",{type:"button",onClick:()=>t(!1),className:"h-8 px-3 rounded-md text-[12px] text-text-300 hover:bg-text-100/5 cursor-pointer",children:"取消"}),h.jsx("button",{type:"button",disabled:!C,onClick:()=>void y(),"data-testid":"rewind-apply",className:fe("h-8 px-3 rounded-md text-[12px] font-medium transition-colors",C?"bg-accent text-white hover:bg-accent-hover cursor-pointer":"bg-bg-200 text-text-400 cursor-not-allowed"),children:m?"回退中…":"确认回退"})]})]})]})}function PJ(e){return e.replace(/^\/Users\/[^/]+/,"~")}function IJ({file:e}){const[t,n]=g.useState(!0);return h.jsxs("div",{"data-testid":"rewind-file-block","data-file":e.filePath,className:"rounded-md border border-bg-300 overflow-hidden bg-bg-0",children:[h.jsxs("button",{type:"button",onClick:()=>n(r=>!r),className:"w-full flex items-center gap-1.5 px-3 py-2 text-[12px] hover:bg-text-100/5 cursor-pointer",children:[t?h.jsx(ir,{className:"w-3.5 h-3.5 text-text-400 shrink-0"}):h.jsx(Un,{className:"w-3.5 h-3.5 text-text-400 shrink-0"}),h.jsx("span",{className:"font-mono text-text-200 truncate flex-1 text-left",title:e.filePath,children:PJ(e.filePath)}),h.jsxs("span",{className:"font-mono shrink-0 text-text-400",children:[h.jsxs("span",{className:"text-green-500",children:["+",e.insertions]})," ",h.jsxs("span",{className:"text-red-400",children:["-",e.deletions]})]})]}),t?h.jsx("div",{className:"border-t border-bg-300",children:e.hunks.map(r=>h.jsx(RJ,{hunk:r},`${r.oldStart}-${r.oldLines}-${r.newStart}-${r.newLines}`))}):null]})}function RJ({hunk:e}){const t=`@@ -${e.oldStart},${e.oldLines} +${e.newStart},${e.newLines} @@`;return h.jsxs("div",{className:"text-[11px] font-mono leading-relaxed",children:[h.jsx("div",{className:"px-3 py-1 text-text-400 bg-bg-100/40 border-b border-bg-300",children:t}),e.lines.map((n,r)=>{const i=n.charAt(0),s=i==="+"?"bg-green-500/10 text-green-300":i==="-"?"bg-red-500/10 text-red-300":"text-text-300";return h.jsx("div",{className:fe("px-3 whitespace-pre",s),children:n.length>0?n:" "},r)})]})}function MJ({jobs:e}){return e.length===0?h.jsx("div",{"data-testid":"cron-job-list-empty",className:"px-4 py-3 text-sm text-text-500",children:"当前会话暂无活跃 cron 任务"}):h.jsx("ul",{"data-testid":"cron-job-list",className:"flex flex-col gap-2",children:e.map(t=>h.jsxs("li",{"data-testid":`cron-job-${t.id}`,className:"flex flex-col gap-1 rounded-md border border-border px-3 py-2",children:[h.jsxs("div",{className:"flex items-center gap-2 text-xs",children:[h.jsx("span",{className:"font-mono text-text-300",children:t.id}),h.jsx("span",{className:"text-text-500",children:"·"}),h.jsx("span",{className:"text-text-400",children:t.humanSchedule}),t.recurring?h.jsx("span",{"data-testid":`cron-job-${t.id}-recurring-badge`,className:"ml-auto rounded-md bg-accent-dim px-2 py-0.5 text-accent",children:"recurring"}):null]}),h.jsx("div",{className:"text-sm text-text-200 truncate",title:t.prompt,children:t.prompt})]},t.id))})}const AJ={idle:"还没启动","turn-running":"正在 run 中","turn-idle":"进程活着,等输入",exited:"进程已退出",crashed:"启动失败 / 异常退出"};function LJ({sessionStatus:e}){switch(e){case"idle":return"idle";case"running":return"turn-running";case"running-idle":return"turn-idle";case"observing":return"turn-running";case"stopped":return"exited";case"error":return"crashed"}}function jJ(e){return e==="running"||e==="observing"}function QM(e){return e==="running"||e==="running-idle"||e==="observing"}/**
511
+ `):null}if(typeof e=="object"){const t=e;if(typeof t.text=="string")return t.text}return null}function Tk(e){if(!e||!Number.isFinite(e))return null;if(e<1e3)return`${e}ms`;const t=e/1e3;if(t<60)return`${t.toFixed(1)}s`;const n=Math.floor(t/60),r=Math.round(t-n*60);return`${n}m${r.toString().padStart(2,"0")}s`}function yZ(e){return!e||!Number.isFinite(e)?null:e<1e3?`${e} tok`:e<1e4?`${(e/1e3).toFixed(1)}k tok`:`${Math.round(e/1e3)}k tok`}const bZ={readCount:"read",searchCount:"search",bashCount:"bash",editFileCount:"edit",linesAdded:"+lines",linesRemoved:"-lines",otherToolCount:"other"};function wZ(e){if(!e)return[];const t=[];for(const[n,r]of Object.entries(e)){if(!r||r<=0)continue;const i=bZ[n]??n;t.push(`${i}:${r}`)}return t}function SZ({description:e,input:t,output:n,error:r,pending:i,notifications:s,toolResultExtra:o,progress:a}){const[l,c]=g.useState(!1),u=UM(),d=g.useMemo(()=>{if(!t||typeof t!="object")return null;const P=t;return typeof P.prompt=="string"?P.prompt:null},[t]),f=g.useMemo(()=>{if(!t||typeof t!="object")return;const P=t.agentId;return typeof P=="string"&&P.length>0?P:void 0},[t]),p=(o==null?void 0:o.prompt)??d,m=g.useMemo(()=>xZ(n),[n]),v=o==null?void 0:o.stats,b=a==null?void 0:a.stats,_=Tk((v==null?void 0:v.durationMs)??(b==null?void 0:b.durationMs)),x=yZ((v==null?void 0:v.tokens)??(b==null?void 0:b.tokens)),y=wZ(v==null?void 0:v.toolStats),w=i&&(a!=null&&a.lastToolName)?`now:${a.lastToolName}`:null,C=!!(o!=null&&o.agentType||_||x||y.length>0||w),k=(o==null?void 0:o.agentId)??(a==null?void 0:a.agentId)??f,T=!!(r||(a==null?void 0:a.status)==="failed"),N=g.useMemo(()=>s.map(P=>({taskId:P.taskId,text:P.text,parsed:FM(P.text)})),[s]),z=T?h.jsx(Ls,{className:"w-3.5 h-3.5 text-error"}):i?h.jsx(In,{className:"w-3.5 h-3.5 text-blue-400 animate-spin"}):h.jsx(rp,{className:"w-3.5 h-3.5 text-green-500"});return h.jsxs("div",{"data-testid":"msg-line-agent-call","data-pending":i?"true":"false","data-has-error":T?"true":"false","data-notification-count":s.length,"data-has-stats":C?"true":"false","data-agent-id":k??"",className:"my-1 min-w-0 max-w-full rounded-md border border-bg-200/60 bg-bg-100/30",children:[h.jsxs("button",{type:"button","aria-expanded":l,onClick:()=>c(P=>!P),className:fe("flex w-full min-w-0 items-center gap-2 px-2.5 py-1.5 text-left text-[13px]","hover:bg-bg-200/40 rounded-md transition-colors"),children:[h.jsx("span",{className:"w-5 h-5 flex items-center justify-center text-[10px] rounded bg-violet-500/10 text-violet-500 shrink-0","aria-hidden":!0,children:h.jsx(L$,{className:"w-3 h-3"})}),h.jsx("span",{className:"shrink-0",children:z}),h.jsx("span",{className:"flex-1 min-w-0 truncate font-medium text-text-200",children:e}),C?null:s.length>0?h.jsxs("span",{className:"text-[11px] text-text-400 tabular-nums shrink-0",children:[s.length," 次通知"]}):null,k&&(u!=null&&u.open)?h.jsx("span",{role:"button",tabIndex:0,"data-testid":"open-subagent-btn-header","data-agent-id":k,"aria-label":"打开子 agent 对话",onClick:P=>{P.stopPropagation(),u.open(k,o==null?void 0:o.agentType)},onKeyDown:P=>{(P.key==="Enter"||P.key===" ")&&(P.stopPropagation(),P.preventDefault(),u.open(k,o==null?void 0:o.agentType))},className:"shrink-0 inline-flex items-center justify-center w-3.5 h-3.5 text-text-400 hover:text-text-200",children:h.jsx(qc,{className:"w-3.5 h-3.5"})}):null,l?h.jsx(ir,{className:"w-3.5 h-3.5 text-text-400 shrink-0"}):h.jsx(Un,{className:"w-3.5 h-3.5 text-text-400 shrink-0"})]}),i&&(a!=null&&a.description)?h.jsx("div",{"data-testid":"agent-call-progress-desc",className:"px-3 pt-0 pb-1 text-[12px] text-text-300 truncate",children:a.description}):null,C?h.jsxs("div",{"data-testid":"agent-call-stats",className:"flex items-center gap-1.5 flex-wrap px-3 pb-1.5 pt-0 text-[11px] text-text-400",children:[o!=null&&o.agentType?h.jsx("span",{"data-testid":"agent-call-stats-type",className:"inline-flex items-center rounded-sm bg-violet-500/10 px-1.5 py-0.5 text-violet-400 font-medium",children:o.agentType}):null,_?h.jsx("span",{className:"tabular-nums",children:_}):null,x?h.jsx("span",{className:"tabular-nums",children:x}):null,w?h.jsx("span",{"data-testid":"agent-call-stats-now",className:"font-mono tabular-nums text-blue-400",children:w}):null,y.map(P=>h.jsx("span",{className:"font-mono tabular-nums text-text-400/80",children:P},P)),s.length>0?h.jsxs("span",{className:"tabular-nums text-text-400/70",children:["· ",s.length," 次通知"]}):null]}):null,l?h.jsxs("div",{"data-testid":"agent-call-body",className:"min-w-0 border-t border-bg-200/60 px-3 py-2 space-y-3",children:[r?h.jsx("div",{className:"text-[12px] text-error whitespace-pre-wrap",children:r}):null,N.map((P,B)=>{const R=P.parsed,I=Tk(R.durationMs);return h.jsxs("div",{"data-testid":"agent-call-notification","data-task-id":P.taskId??"",className:"min-w-0 rounded-md border border-bg-200/60 bg-bg-0/40 p-2 space-y-1.5",children:[h.jsxs("div",{className:"flex items-center gap-2 text-[11px] text-text-400 flex-wrap",children:[h.jsx("span",{className:"font-mono",children:(P.taskId??R.taskId??"未知").slice(0,12)}),h.jsx("span",{className:"uppercase tracking-wide",children:R.status??"unknown"}),I?h.jsxs("span",{className:"tabular-nums",children:["· ",I]}):null,R.totalTokens?h.jsxs("span",{className:"tabular-nums",children:["· ",R.totalTokens," tok"]}):null,R.toolUses?h.jsxs("span",{className:"tabular-nums",children:["· ",R.toolUses," tools"]}):null,R.worktreeBranch?h.jsxs("span",{className:"font-mono",children:["· ",R.worktreeBranch]}):null]}),R.summary?h.jsx("div",{className:"text-[12px] text-text-300",children:R.summary}):null,R.result?h.jsx("div",{"data-testid":"agent-call-notification-result",className:"assistant-markdown text-[12px] leading-relaxed break-words",children:h.jsx(tu,{remarkPlugins:[ru],components:So,children:R.result})}):null]},`${P.taskId??"n"}-${B}`)}),p?h.jsxs("div",{"data-testid":"agent-call-prompt-block",className:"min-w-0 space-y-1",children:[h.jsx("div",{className:"text-[11px] text-text-400 font-medium",children:"任务指令"}),h.jsx("pre",{"data-testid":"agent-call-prompt",className:"max-w-full whitespace-pre-wrap break-words text-[11px] text-text-300 bg-bg-50/60 rounded p-2 border border-bg-200/60 max-h-64 overflow-auto [overflow-wrap:anywhere]",children:p})]}):null,m?h.jsxs("div",{"data-testid":"agent-call-result-block",className:"min-w-0 space-y-1",children:[h.jsx("div",{className:"text-[11px] text-text-400 font-medium",children:"子 agent 报告"}),h.jsx("div",{"data-testid":"agent-call-result",className:"assistant-markdown text-[12px] leading-relaxed break-words",children:h.jsx(tu,{remarkPlugins:[ru],components:So,children:m})})]}):null,!m&&N.length===0&&!r&&!p?h.jsx("div",{className:"text-[11px] text-text-400 italic",children:"无详细信息"}):null,k&&(u!=null&&u.open)?h.jsx("div",{className:"flex justify-end",children:h.jsxs("button",{type:"button","data-testid":"open-subagent-btn","data-agent-id":k,onClick:()=>u.open(k,o==null?void 0:o.agentType),className:fe("inline-flex items-center gap-1 rounded-md border border-bg-200/60","bg-bg-100/40 hover:bg-bg-200/40 transition-colors","px-2 py-1 text-[11px] text-text-300"),children:[h.jsx(qc,{className:"w-3 h-3"}),h.jsx("span",{children:"打开子 agent 对话"})]})}):null]}):null]})}function WM({title:e,items:t,live:n,progressColor:r="bg-green-500",listKind:i,children:s}){const[o,a]=g.useState(!!n),l=t.length,c=t.filter(d=>d.status==="completed").length,u=l>0?Math.round(c/l*100):0;return h.jsxs("div",{"data-testid":"msg-line-checklist","data-list-kind":i,className:"min-w-0 max-w-full py-1",children:[h.jsxs("button",{type:"button",onClick:()=>a(d=>!d),"aria-expanded":o,className:"flex items-center gap-2.5 w-full text-left rounded-md px-1.5 py-1 hover:bg-text-100/5 cursor-pointer",children:[o?h.jsx(ir,{className:"w-3.5 h-3.5 text-text-400 shrink-0"}):h.jsx(Un,{className:"w-3.5 h-3.5 text-text-400 shrink-0"}),h.jsx("span",{className:"text-[13px] font-medium text-text-200",children:e}),h.jsxs("span",{className:"text-[11px] text-text-400 tabular-nums",children:[c,"/",l]}),h.jsx("div",{className:"flex-1 max-w-[120px] h-1.5 rounded-full bg-text-100/10 overflow-hidden",children:h.jsx("div",{className:fe("h-full rounded-full transition-all duration-300",r),style:{width:`${u}%`}})})]}),o?h.jsxs("div",{"data-testid":"checklist-body",className:"ml-6 mt-0.5",children:[h.jsx("div",{className:"space-y-px",children:t.map((d,f)=>h.jsxs("div",{className:"flex min-w-0 items-start gap-2 py-0.5 px-1",children:[h.jsx("span",{className:"w-4 h-4 mt-0.5 flex items-center justify-center shrink-0",children:d.status==="completed"?h.jsx(ul,{className:"w-3.5 h-3.5 text-green-500"}):d.status==="in_progress"&&n?h.jsx(In,{className:"w-3.5 h-3.5 text-blue-400 animate-spin"}):h.jsx("span",{className:"w-2 h-2 rounded-full border border-text-400/40"})}),h.jsx("span",{className:fe("min-w-0 text-[13px] leading-snug break-words [overflow-wrap:anywhere]",d.status==="completed"?"text-text-400 line-through":"text-text-200"),children:d.status==="in_progress"&&d.activeForm?d.activeForm:d.content})]},`${f}-${d.content}`))}),s]}):null]})}function kZ({todos:e,live:t}){return h.jsx(WM,{title:"Tasks",items:e,live:t,progressColor:"bg-green-500",listKind:"todo"})}function CZ({tasks:e,live:t}){return h.jsx(WM,{title:"Plan",items:e,live:t,progressColor:"bg-blue-500",listKind:"plan"})}function EZ(e){if(!e||!Number.isFinite(e))return null;const t=Date.now()-e;if(t<0)return null;const n=Math.floor(t/1e3);if(n<60)return`${n}s ago`;const r=Math.floor(n/60);if(r<60)return`${r}m ago`;const i=Math.floor(r/60);if(i<24)return`${i}h ago`;const s=Math.floor(i/24);if(s<7)return`${s}d ago`;const o=Math.floor(s/7);return o<5?`${o}w ago`:new Date(e).toISOString().slice(0,10)}function TZ(e){return(e.split("/").pop()??e)||e}function NZ({memories:e}){return!e||e.length===0?null:h.jsxs("div",{"data-testid":"memory-callout",className:"my-1 min-w-0 max-w-full rounded-md border border-bg-200/60 bg-bg-100/30",children:[h.jsxs("div",{className:"flex items-center gap-1.5 px-2.5 py-1.5 text-[12px] text-text-300 border-b border-bg-200/60",children:[h.jsx(oz,{className:"w-3.5 h-3.5 text-amber-500 shrink-0"}),h.jsx("span",{className:"font-medium",children:"项目记忆"}),h.jsxs("span",{className:"text-text-400 tabular-nums",children:["· ",e.length]})]}),h.jsx("ul",{className:"divide-y divide-bg-200/40",children:e.map(t=>h.jsx(PZ,{memory:t},t.path))})]})}function PZ({memory:e}){const[t,n]=g.useState(!1),r=EZ(e.mtimeMs),i=e.content.replace(/\s+/g," ").trim().slice(0,80);return h.jsxs("li",{className:"px-2.5 py-1.5",children:[h.jsxs("button",{type:"button","aria-expanded":t,onClick:()=>n(s=>!s),className:fe("flex w-full items-center gap-1.5 text-left text-[12px]","hover:bg-bg-200/30 rounded-sm py-0.5"),children:[t?h.jsx(ir,{className:"w-3 h-3 text-text-400 shrink-0"}):h.jsx(Un,{className:"w-3 h-3 text-text-400 shrink-0"}),h.jsx("span",{className:"font-mono text-text-300 shrink-0 max-w-[20ch] truncate",title:e.path,children:TZ(e.path)}),h.jsx("span",{className:"flex-1 min-w-0 truncate text-text-400/80",children:i}),r?h.jsx("span",{className:"shrink-0 text-[11px] text-text-400 tabular-nums",children:r}):null]}),t?h.jsx("pre",{"data-testid":"memory-callout-body",className:"mt-1 max-w-full whitespace-pre-wrap break-words text-[12px] text-text-300 bg-bg-50/60 rounded-md p-2 border border-bg-200/60 [overflow-wrap:anywhere]",children:e.content}):null]})}function IZ({toolUseId:e,questions:t,onSubmit:n,onCancel:r,submittedAnswers:i}){const[s,o]=g.useState({}),[a,l]=g.useState({}),[c,u]=g.useState({}),[d,f]=g.useState(!1),[p,m]=g.useState(!1),v=i!==void 0&&Object.keys(i).length>0,b=v||p,_=!n&&!v,x=(k,T)=>{const N={labels:new Set,freeText:""};if(!v||!i)return N;const z=i[k];if(typeof z!="string")return N;const P=z.split(",").map(j=>j.trim()).filter(Boolean),B=new Set(T.map(j=>j.label)),R=new Set,I=[];for(const j of P)B.has(j)?R.add(j):I.push(j);return{labels:R,freeText:I.join(", ")}},y=g.useMemo(()=>t.every(k=>{if((c[k.question]??"").trim().length>0)return!0;if(k.multiSelect){const N=a[k.question];return!!(N&&N.size>0)}return typeof s[k.question]=="string"&&s[k.question].length>0}),[t,s,a,c]),w=async()=>{if(!y||d||b||_||!n)return;const k={};for(const T of t){const N=(c[T.question]??"").trim();if(T.multiSelect){const z=a[T.question],P=z?T.options.filter(B=>z.has(B.label)).map(B=>B.label):[];if(N.length>0&&P.push(N),P.length===0)continue;k[T.question]=P.join(", ")}else if(N.length>0)k[T.question]=N;else{const z=s[T.question];typeof z=="string"&&(k[T.question]=z)}}f(!0);try{await n(k),m(!0)}finally{f(!1)}},C=ku(()=>{w()});return h.jsxs("div",{"data-testid":"msg-line-question","data-tool-use-id":e,className:"min-w-0 max-w-full rounded-md border border-accent/40 bg-accent/5 px-3 py-2.5 text-[13px]",children:[h.jsxs("div",{className:"flex min-w-0 items-center gap-2 mb-2",children:[h.jsx(gz,{className:"w-4 h-4 text-accent shrink-0"}),h.jsx("span",{className:"min-w-0 font-medium text-text-100",children:"需要你的回答 / Need your answer"}),t.length>1?h.jsxs("span",{className:"ml-auto text-[12px] text-text-400","data-testid":"msg-line-question-count",children:[t.length," 个问题"]}):null]}),h.jsx("div",{className:"flex flex-col gap-3 mb-3",children:t.map((k,T)=>{const N=`q-${T}`,z=`${e}-${T}`,P=x(k.question,k.options),B=b||_,R=c[k.question]??"",I=v?P.freeText:p?(c[k.question]??"").trim():"";return h.jsxs("div",{"data-testid":"msg-line-question-item",children:[k.question?h.jsx("div",{className:"text-text-200 mb-1.5",children:k.question}):null,h.jsx("div",{className:"flex flex-col gap-1",children:k.options.map((j,L)=>{var D;const $=`${N}-${L}`,F=v?P.labels.has(j.label):k.multiSelect?!!((D=a[k.question])!=null&&D.has(j.label)):s[k.question]===j.label;return h.jsxs("label",{className:"flex min-w-0 items-start gap-2 cursor-pointer select-none py-1 px-2 rounded hover:bg-bg-100",children:[h.jsx("input",{type:k.multiSelect?"checkbox":"radio",name:z,value:j.label,checked:F,disabled:b||_,onChange:()=>{b||_||(k.multiSelect?l(O=>{const E=new Set(O[k.question]??[]);return E.has(j.label)?E.delete(j.label):E.add(j.label),{...O,[k.question]:E}}):o(O=>({...O,[k.question]:j.label})))},className:"mt-0.5","data-testid":"msg-line-question-option"}),h.jsxs("span",{className:"flex min-w-0 flex-col",children:[h.jsx("span",{className:"text-text-100 [overflow-wrap:anywhere]",children:j.label}),j.description?h.jsx("span",{className:"text-[12px] text-text-400 [overflow-wrap:anywhere]",children:j.description}):null]})]},$)})}),B?I.length>0?h.jsx("div",{className:"mt-2 rounded-lg border border-accent/15 bg-bg-100/60 px-3 py-2 text-[13px] leading-relaxed text-text-200 [overflow-wrap:anywhere]","data-testid":"msg-line-question-freetext-result",children:I}):null:h.jsx("textarea",{rows:3,value:R,placeholder:"或自行输入回答...",onChange:j=>{const L=j.target.value;u($=>({...$,[k.question]:L}))},...C,className:"mt-2 w-full resize-y rounded-lg border border-accent/20 bg-bg-000/60 px-3 py-2 text-[13px] leading-relaxed text-text-100 placeholder:text-text-400 outline-none transition-colors focus:border-accent/60 focus:bg-bg-000","data-testid":"msg-line-question-freetext"})]},N)})}),h.jsxs("div",{className:"flex items-center gap-2",children:[h.jsx(ni,{size:"sm",variant:"default",onClick:()=>void w(),disabled:!y||d||b||_,"data-testid":"msg-line-question-submit",children:b?"已提交 / Submitted":_?"已结束 / Ended":"提交 / Submit"}),r&&!b&&!_?h.jsx(ni,{size:"sm",variant:"ghost",onClick:()=>void r(),disabled:d,"data-testid":"msg-line-question-cancel",children:"跳过 / Skip"}):null]})]})}function RZ({toolUseId:e,questions:t,historicalAnswers:n,realtimeAnswers:r,onSubmit:i,onCancel:s}){const o=r??n,a=g.useCallback(async c=>{i&&await i(e,c)},[i,e]),l=g.useCallback(async()=>{s&&await s(e)},[s,e]);return h.jsx(IZ,{toolUseId:e,questions:t,onSubmit:i?a:void 0,...s?{onCancel:l}:{},submittedAnswers:o})}function MZ(){const e=new Map,t=(n,r)=>`${n}::${r}`;return{register(n,r,i){e.set(t(n,r),i)},resolve(n,r){return n?e.get(t(n,r))??null:null},reset(){e.clear()}}}const ml=MZ();function VM({lines:e,onPermissionRespond:t,onPermissionInterrupt:n,topSlot:r,onRewind:i,rewindableUserMessageIds:s,onFork:o,onQuickAsk:a,realtimeQuestionAnswers:l,onSubmitQuestion:c,onCancelQuestion:u,liveQuestionToolUseIds:d,fileSharingScope:f,onShareFile:p,onOpenInTab:m,onPreviewMarkdown:v,onOpenFilePath:b,turnCollapse:_}){const x=g.useMemo(()=>hW(e),[e]),y=g.useMemo(()=>_?gW(x,_):null,[x,_]),w={onRewind:i,rewindableUserMessageIds:s,onPermissionRespond:t,onPermissionInterrupt:n,onFork:o,onQuickAsk:a,realtimeQuestionAnswers:l,onSubmitQuestion:c,onCancelQuestion:u,liveQuestionToolUseIds:d,fileSharingScope:f,onShareFile:p,onOpenInTab:m,onPreviewMarkdown:v,onOpenFilePath:b};return h.jsxs("div",{"data-testid":"message-list",className:"flex w-full min-w-0 max-w-full flex-col gap-2 px-4 py-3",children:[r,y!==null?y.map(C=>AZ(C,w)):x.map(C=>df(C,w))]})}function AZ(e,t){const n=`turn-${e.seq}`,r=e.query?df(e.query,t):null,i=e.process.map(o=>LZ(o,t)),s=e.tail.map(o=>df(o,t));return e.status==="running"?h.jsxs(Ze.Fragment,{children:[r,i,s]},n):h.jsxs(Ze.Fragment,{children:[r,h.jsx(NW,{status:e.status,...e.durationMs!==void 0?{durationMs:e.durationMs}:{},children:i}),s]},n)}function LZ(e,t){return e.kind==="tool-group"?h.jsx(CW,{items:e.items,renderItemDetail:n=>jZ(n,t)},`tool-group-${e.seq}`):df(e,t)}function jZ(e,t){const n=ml.resolve(e.toolKind,e.tool);return n?n.render({input:e.input,output:e.output,error:e.error,pending:e.pending,toolUseId:e.toolUseId,...t.fileSharingScope?{fileScope:t.fileSharingScope}:{},...t.onShareFile?{onShareFile:t.onShareFile}:{},...t.onOpenInTab?{onOpenInTab:t.onOpenInTab}:{},...t.onPreviewMarkdown?{onPreviewMarkdown:t.onPreviewMarkdown}:{}}):null}function df(e,t){const{onRewind:n,rewindableUserMessageIds:r,onPermissionRespond:i,onPermissionInterrupt:s,onFork:o,onQuickAsk:a,realtimeQuestionAnswers:l,onSubmitQuestion:c,onCancelQuestion:u,liveQuestionToolUseIds:d,fileSharingScope:f,onShareFile:p,onOpenInTab:m,onPreviewMarkdown:v,onOpenFilePath:b}=t,_=`${e.kind}-${e.seq}`;switch(e.kind){case"session-init":return null;case"user-text":{const x=typeof e.uuid=="string"?e.uuid:void 0,y=!!(n&&x&&(!r||r.has(x)));return h.jsx(cZ,{text:e.text,senderDisplayName:e.senderDisplayName,rewindTarget:y&&x&&n?{userMessageId:x,onRewind:n}:void 0},_)}case"user-meta":return h.jsx(pZ,{metaKind:e.metaKind,text:e.text},_);case"meta-text":return h.jsx(mZ,{text:e.text,metaSource:e.metaSource},_);case"agent-notification":return h.jsx(vZ,{text:e.text,taskId:e.taskId,parentToolUseId:e.parentToolUseId},_);case"assistant-text":{const x=typeof e.uuid=="string"?e.uuid:void 0,y=x&&(o||a)?{messageUuid:x,onFork:o,onQuickAsk:a}:void 0;return h.jsx(IQ,{text:RW(e.text),forkTarget:y,...b?{onOpenFilePath:b}:{}},_)}case"assistant-thinking":return h.jsx(RQ,{text:e.text},_);case"permission-inline":return h.jsx(rZ,{tool:e.tool,input:e.input,onRespond:i??(()=>{}),onInterrupt:s},_);case"error":return h.jsx(iZ,{message:e.message},_);case"turn-end":return null;case"merged-tool":return DZ(e,_,{fileSharingScope:f,onShareFile:p,onOpenInTab:m,onPreviewMarkdown:v});case"merged-agent":return h.jsx(SZ,{description:e.description,input:e.input,output:e.output,error:e.error,pending:e.pending,notifications:e.notifications,toolResultExtra:e.toolResultExtra,progress:e.progress},_);case"plan-card":return h.jsx(CZ,{tasks:e.tasks},_);case"todo-checklist":return h.jsx(kZ,{todos:e.todos},_);case"memory-callout":return h.jsx(NZ,{memories:e.memories},_);case"question-card":{const x=d===void 0||d.has(e.toolUseId);return h.jsx(RZ,{toolUseId:e.toolUseId,questions:e.questions,historicalAnswers:e.submittedAnswers,realtimeAnswers:l==null?void 0:l[e.toolUseId],onSubmit:x?c:void 0,...x&&u?{onCancel:u}:{}},_)}default:return null}}function DZ(e,t,n){const r=ml.resolve(e.toolKind,e.tool),i=r?r.render({input:e.input,output:e.output,error:e.error,pending:e.pending,toolUseId:e.toolUseId,...n.fileSharingScope?{fileScope:n.fileSharingScope}:{},...n.onShareFile?{onShareFile:n.onShareFile}:{},...n.onOpenInTab?{onOpenInTab:n.onOpenInTab}:{},...n.onPreviewMarkdown?{onPreviewMarkdown:n.onPreviewMarkdown}:{}}):null;return h.jsx(Ze.Fragment,{children:i??h.jsx(zM,{tool:e.tool,input:e.input,output:e.output,error:e.error,pending:e.pending,...n.fileSharingScope?{fileScope:n.fileSharingScope}:{},...n.onShareFile?{onShareFile:n.onShareFile}:{},...n.onOpenInTab?{onOpenInTab:n.onOpenInTab}:{},...n.onPreviewMarkdown?{onPreviewMarkdown:n.onPreviewMarkdown}:{}})},t)}const OZ={builtin:"Commands",global:"Global",project:"Project",plugin:"Plugin"},Nk={builtin:0,global:1,project:2,plugin:3};function BZ({query:e,skills:t,activeIndex:n,onActiveIndexChange:r,onSelect:i,onEmpty:s}){const o=g.useRef(null),a=g.useMemo(()=>qM(t,e),[t,e]),l=g.useMemo(()=>{const c=new Set;let u=null;for(let d=0;d<a.length;d++)a[d].source!==u&&(c.add(d),u=a[d].source);return c},[a]);return g.useEffect(()=>{a.length===0&&(s==null||s())},[a.length,s]),g.useEffect(()=>{var c;try{(c=o.current)==null||c.scrollIntoView({block:"nearest"})}catch{}},[n]),a.length===0?null:h.jsx("div",{"data-testid":"cc-skill-selector",className:"absolute bottom-full left-0 right-0 z-50 mb-1.5 max-h-[320px] overflow-y-auto rounded-2xl border border-bg-300 bg-bg-50 shadow-lg",children:a.map((c,u)=>{const d=u===n,f=l.has(u);return h.jsxs(Ze.Fragment,{children:[f?h.jsx("div",{className:"sticky top-0 z-10 bg-bg-50/95 backdrop-blur-sm px-4 py-2 text-[10px] font-semibold uppercase tracking-wider text-text-400/70 border-b border-bg-200/60",children:OZ[c.source]}):null,h.jsxs("div",{ref:d?o:void 0,"data-testid":`cc-skill-item-${c.name}`,onMouseEnter:()=>r(u),onClick:()=>i(c),className:fe("flex items-center gap-2.5 px-4 py-2 cursor-pointer transition-colors duration-75",d?"bg-[var(--text-100-dim)]":"hover:bg-bg-100/60"),children:[h.jsxs("code",{className:"text-[12px] font-mono font-semibold text-text-100 shrink-0",children:["/",c.name]}),c.description?h.jsx("span",{className:"text-[11px] text-text-300 truncate ml-auto",children:c.description}):null]})]},`${c.source}/${c.name}`)})})}function qM(e,t){const n=t.trim().toLowerCase(),r=n?e.filter(i=>i.name.toLowerCase().includes(n)||(i.description??"").toLowerCase().includes(n)):e.slice();return r.sort((i,s)=>(Nk[i.source]??9)-(Nk[s.source]??9)),r.slice(0,30)}const zZ=g.createContext(null);function $Z(){return g.useContext(zZ)}const FZ={builtin:"Built-in",global:"Global",project:"Project",policy:"Policy",plugin:"Plugin",persona:"My personas",contact:"People","remote-persona":"Remote personas"},Pk={builtin:0,global:1,project:2,policy:3,plugin:4,persona:5,contact:6,"remote-persona":7};function hf(e){switch(e.kind){case"persona":return"persona";case"contact":return"contact";case"remote-persona":return"remote-persona";case"cc-agent":return e.agent.source}}function HZ(e){switch(e.kind){case"persona":return`persona/${e.persona.personaId}`;case"contact":return`contact/${e.contact.deviceId}`;case"remote-persona":return`remote/${e.deviceId}/${e.persona.personaId}`;case"cc-agent":return`${e.agent.source}/${e.agent.name}`}}function UZ(e){switch(e.kind){case"persona":return`${e.persona.personaId} ${e.persona.label}`.toLowerCase();case"contact":return`${e.contact.displayName} ${e.contact.deviceId}`.toLowerCase();case"remote-persona":return`${e.persona.personaId} ${e.persona.label}`.toLowerCase();case"cc-agent":{const t=e.agent;return`${t.name} ${t.description??""} ${t.whenToUse??""}`.toLowerCase()}}}function WZ(e){switch(e.kind){case"persona":return{displayName:`@persona/${e.persona.personaId}`,description:e.persona.label,testid:`cc-agent-item-persona-${e.persona.personaId}`};case"contact":return{displayName:`@${e.contact.displayName}`,description:e.contact.deviceId,testid:`cc-agent-item-contact-${e.contact.deviceId}`};case"remote-persona":return{displayName:`@persona/${e.persona.personaId}`,description:e.persona.label,testid:`cc-agent-item-remote-${e.deviceId}-${e.persona.personaId}`};case"cc-agent":return{displayName:`@${e.agent.name}`,description:e.agent.description,whenToUse:e.agent.whenToUse,plugin:e.agent.plugin,testid:`cc-agent-item-${e.agent.name}`}}}function KM(e,t){const n=t.trim().toLowerCase(),r=n?e.filter(i=>UZ(i).includes(n)):e.slice();return r.sort((i,s)=>(Pk[hf(i)]??9)-(Pk[hf(s)]??9)),r.slice(0,30)}function Ik({query:e,entries:t,activeIndex:n,onActiveIndexChange:r,onSelect:i,onEmpty:s}){const o=g.useRef(null),a=g.useMemo(()=>KM(t,e),[t,e]),l=g.useMemo(()=>{const c=new Set;let u=null;for(let d=0;d<a.length;d++){const f=hf(a[d]);f!==u&&(c.add(d),u=f)}return c},[a]);return g.useEffect(()=>{a.length===0&&(s==null||s())},[a.length,s]),g.useEffect(()=>{var c;try{(c=o.current)==null||c.scrollIntoView({block:"nearest"})}catch{}},[n]),a.length===0?null:h.jsx("div",{"data-testid":"cc-agent-selector",className:"absolute bottom-full left-0 right-0 z-50 mb-1.5 max-h-[320px] overflow-y-auto rounded-2xl border border-bg-300 bg-bg-50 shadow-lg",children:a.map((c,u)=>{const d=u===n,f=l.has(u),p=hf(c),m=WZ(c);return h.jsxs(Ze.Fragment,{children:[f?h.jsx("div",{"data-testid":`cc-agent-group-header-${p}`,"data-source":p,className:"sticky top-0 z-10 bg-bg-50/95 backdrop-blur-sm px-4 py-2 text-[10px] font-semibold uppercase tracking-wider text-text-400/70 border-b border-bg-200/60",children:FZ[p]}):null,h.jsxs("div",{ref:d?o:void 0,"data-testid":m.testid,onMouseEnter:()=>r(u),onClick:()=>i(c),className:fe("flex items-center gap-2.5 px-4 py-2 cursor-pointer transition-colors duration-75",d?"bg-[var(--text-100-dim)]":"hover:bg-bg-100/60"),children:[h.jsx("code",{className:"text-[12px] font-mono font-semibold text-text-100 shrink-0",children:m.displayName}),m.description?h.jsx("span",{className:"text-[11px] text-text-300 truncate ml-2",children:m.description}):null,m.whenToUse?h.jsx("span",{className:"text-[10px] text-text-400/70 italic truncate ml-auto",children:m.whenToUse}):null,m.plugin?h.jsx("span",{className:"text-[10px] text-text-400/70 ml-2 shrink-0",children:m.plugin}):null]})]},HZ(c))})})}function VZ({attachment:e,onRemove:t,onOpenPreview:n}){const r=e.mimeType.startsWith("image/"),i=e.status==="error",s=e.status==="uploading",o=r&&e.status==="done"&&!!e.previewUrl&&!!n;return h.jsxs("div",{"data-testid":`attachment-pill-${e.id}`,className:fe("group relative flex items-center gap-1.5 rounded-lg border px-2 py-1.5 text-[12px] transition-colors",i?"border-red-400/40 bg-red-500/5":"border-bg-300 bg-bg-100"),children:[r&&e.previewUrl?h.jsxs("div",{className:"relative h-7 w-7 shrink-0",children:[h.jsx("img",{src:e.previewUrl,alt:e.fileName,onClick:o?n:void 0,"data-testid":`attachment-thumb-${e.id}`,className:fe("h-7 w-7 rounded object-cover",o&&"cursor-pointer hover:opacity-80",s&&"opacity-40")}),s?h.jsx(In,{"data-testid":`attachment-spinner-${e.id}`,className:"absolute inset-0 m-auto h-3.5 w-3.5 animate-spin text-text-200"}):null]}):h.jsx("div",{className:"relative flex h-7 w-7 items-center justify-center rounded bg-text-100/5 shrink-0",children:s?h.jsx(In,{"data-testid":`attachment-spinner-${e.id}`,className:"h-3.5 w-3.5 animate-spin text-text-400"}):h.jsx(Ro,{className:"h-3.5 w-3.5 text-text-400"})}),h.jsx("span",{className:fe("max-w-[120px] truncate text-text-200",s&&"text-text-400"),title:e.error??e.fileName,children:e.fileName}),i?h.jsx(Ls,{className:"h-3 w-3 text-red-400 shrink-0"}):null,h.jsx("button",{type:"button",onClick:t,"data-testid":`attachment-remove-${e.id}`,className:"flex h-4 w-4 items-center justify-center rounded-full text-text-400 hover:text-text-100 hover:bg-text-100/10 transition-colors cursor-pointer shrink-0","aria-label":"remove",children:h.jsx(Dr,{className:"h-3 w-3"})})]})}function qZ({attachments:e,onRemove:t,onOpenPreview:n}){return e.length===0?null:h.jsx("div",{"data-testid":"attachment-row",className:"flex flex-wrap gap-1.5 mb-2 px-1",children:e.map(r=>h.jsx(VZ,{attachment:r,onRemove:()=>t(r.id),onOpenPreview:n?()=>n(r):void 0},r.id))})}class Xl extends Error{constructor(t,n,r){super(n),this.code=t,this.status=r,this.name="UploadAttachmentError"}}async function KZ(e){if(!e.httpBaseUrl)throw new Xl("TUNNEL_NOT_READY","daemon httpBaseUrl unavailable");if(!e.httpToken)throw new Xl("NO_AUTH","daemon httpToken unavailable");const t=new URLSearchParams({sessionId:e.sessionId,fileName:e.file.name,mimeType:e.file.type||"application/octet-stream"}),n=`${e.httpBaseUrl.replace(/\/$/,"")}/attachments/upload?${t.toString()}`;let r;try{r=await fetch(n,{method:"POST",headers:{Authorization:`Bearer ${e.httpToken}`,"Content-Type":e.file.type||"application/octet-stream"},body:e.file})}catch(i){throw new Xl("NETWORK_ERROR",i.message)}if(!r.ok){let i="UPLOAD_FAILED",s=`HTTP ${r.status}`;try{const o=await r.json();o.code&&(i=o.code),o.message&&(s=o.message)}catch{}throw new Xl(i,s,r.status)}return await r.json()}const Rk=25*1024*1024,GZ="image/*,.txt,.md,.markdown,.csv,.json,.log,.yaml,.yml,.html,.xml,.pdf",YZ=["image/","text/"],XZ=new Set(["application/json","application/xml","application/x-yaml","application/yaml","application/pdf"]),QZ=new Set(["txt","md","markdown","csv","json","log","yaml","yml","html","xml","pdf"]);function ZZ(e){var r;const t=(e.type||"").toLowerCase();if(t&&YZ.some(i=>t.startsWith(i))||t&&XZ.has(t))return!0;const n=((r=e.name.split(".").pop())==null?void 0:r.toLowerCase())??"";return n.length>0&&QZ.has(n)}let JZ=0;const eJ=()=>`att-${++JZ}-${Date.now()}`;function tJ(e){return new Promise((t,n)=>{const r=new FileReader;r.onload=()=>t(typeof r.result=="string"?r.result:""),r.onerror=()=>n(r.error??new Error("read failed")),r.readAsDataURL(e)})}function nJ(e){const[t,n]=g.useState(e.initial??[]),r=g.useCallback(async o=>{const a=Array.from(o);if(a.length===0)return;const l=[],c=[],u=[];for(const d of a){const f={id:eJ(),fileName:d.name,mimeType:d.type||"application/octet-stream"};if(!ZZ(d)){c.push({...f,url:null,status:"error",error:"不支持的文件类型"});continue}if(d.size>Rk){c.push({...f,url:null,status:"error",error:`超过 ${Math.round(Rk/1024/1024)}MB 上限`});continue}if(e.sessionId==null){u.push({id:f.id,file:d,mimeType:f.mimeType}),c.push({...f,url:null,status:"uploading"});continue}const p=f.mimeType.startsWith("image/")?URL.createObjectURL(d):void 0;c.push({...f,url:null,status:"uploading",...p?{previewUrl:p}:{}}),l.push({id:f.id,file:d})}n(d=>[...d,...c]);for(const d of u)try{const f=await tJ(d.file);n(p=>p.map(m=>m.id===d.id?{...m,url:f,status:"done",...d.mimeType.startsWith("image/")?{previewUrl:f}:{}}:m))}catch(f){n(p=>p.map(m=>m.id===d.id?{...m,status:"error",error:f.message??"read failed"}:m))}l.length!==0&&await Promise.all(l.map(async d=>{try{const f=await KZ({httpBaseUrl:e.httpBaseUrl,httpToken:e.httpToken,sessionId:e.sessionId,file:d.file});n(p=>p.map(m=>m.id===d.id?{...m,url:f.url,status:"done"}:m))}catch(f){const p=f instanceof Xl?f.code:"UPLOAD_FAILED",m=f.message??"upload failed";n(v=>v.map(b=>b.id===d.id?{...b,status:"error",error:`${p}: ${m}`}:b))}}))},[e.sessionId,e.httpBaseUrl,e.httpToken]),i=g.useCallback(o=>{n(a=>a.filter(l=>l.id!==o))},[]),s=g.useCallback(()=>{n([])},[]);return{attachments:t,setAttachments:n,addFiles:r,removeAttachment:i,clearAttachments:s}}const B0=new Map,rJ=[];function Mk(e){if(e)return B0.get(e)}function Ak(e,t){e&&(t.draft.length===0&&t.attachments.length===0?B0.delete(e):B0.set(e,t))}function iJ(e,t){return e.replace(/(^|\s)\/(\S+)/g,(n,r,i)=>{const s=t.find(o=>o.name===i&&o.path);return s!=null&&s.path?`${r}[skill:${i}:${s.path}]`:n})}function sJ({api:e,cwd:t,sessionKey:n,onSend:r,disabled:i,onNewSession:s,onClearSession:o,tool:a,spawnableContacts:l=rJ,ensureRemotePersonas:c,remotePersonasByDeviceId:u}){const d=Mk(n),[f,p]=g.useState((d==null?void 0:d.draft)??""),[m,v]=g.useState(!1),b=g.useRef(null),_=g.useRef(!1),x=g.useCallback(()=>{_.current=!0},[]),y=g.useCallback(()=>{_.current=!1},[]),w=tp(),{attachments:C,setAttachments:k,addFiles:T,removeAttachment:N,clearAttachments:z}=nJ({httpBaseUrl:w.httpBaseUrl,httpToken:w.httpToken,sessionId:n,initial:(d==null?void 0:d.attachments)??[]}),[P,B]=g.useState([]),[R,I]=g.useState(!1),[j,L]=g.useState(0),[$,F]=g.useState(!1),[D,O]=g.useState([]),[E,H]=g.useState(!1),[V,A]=g.useState(0),[ne,ae]=g.useState(!1),[G,ye]=g.useState([]),[Fe,ue]=g.useState(!1),[Ie,Re]=g.useState(null),[Ke,ve]=g.useState(!1),ze=g.useRef(null),fn=g.useMemo(()=>{const se=[];return s&&se.push({name:"new",source:"builtin",description:"在当前目录下新建会话"}),o&&n&&se.push({name:"clear",source:"builtin",description:"清除当前会话"}),se},[s,o,n]),it=g.useMemo(()=>[...fn,...P],[fn,P]),Rt=g.useMemo(()=>{const se=f.match(/^\/(\S*)$/);return se?se[1]:null},[f]),Gt=Rt!==null&&!$,Mt=g.useMemo(()=>Rt!==null?qM(it,Rt):[],[it,Rt]),bt=g.useMemo(()=>{const se=f.match(/^@(\S*)$/);return se?se[1]:null},[f]),Qe=bt!==null&&!ne,st=g.useMemo(()=>Ie?((u==null?void 0:u.get(Ie.deviceId))??[]).map(K=>({kind:"remote-persona",persona:K,deviceId:Ie.deviceId})):[...D.map(se=>({kind:"cc-agent",agent:se})),...G.map(se=>({kind:"persona",persona:se})),...l.map(se=>({kind:"contact",contact:se}))],[Ie,u,D,G,l]),wt=g.useMemo(()=>bt!==null?KM(st,bt):[],[st,bt]),pn=g.useRef(f);g.useEffect(()=>{f!==pn.current&&(F(!1),ae(!1),pn.current=f)},[f]);const on=g.useCallback(()=>{F(!0)},[]),U=g.useCallback(()=>{ae(!0)},[]),Z=g.useRef(f),_e=g.useRef(C);g.useEffect(()=>{Z.current=f},[f]),g.useEffect(()=>{_e.current=C},[C]);const ke=g.useRef(n);g.useEffect(()=>{const se=ke.current;if(se===n)return;Ak(se,{draft:Z.current,attachments:_e.current});const K=Mk(n);p((K==null?void 0:K.draft)??""),k((K==null?void 0:K.attachments)??[]),L(0),A(0),F(!1),ae(!1),Re(null),ze.current=null,ve(!1),queueMicrotask(()=>{K!=null&&K.draft?GM(b.current):Xo(b.current)}),ke.current=n},[n,k]),g.useEffect(()=>()=>{Ak(ke.current,{draft:Z.current,attachments:_e.current})},[]),g.useEffect(()=>{L(0)},[Rt]),g.useEffect(()=>{A(0)},[bt]),g.useEffect(()=>{bt===null&&Ie&&(Re(null),ze.current=null,ve(!1))},[bt,Ie]),g.useEffect(()=>{if(!Gt||R)return;if(!e){I(!0);return}let se=!1;return(async()=>{try{const K=await e.skillsList(t,a);se||(B(K.skills??[]),I(!0))}catch{se||I(!0)}})(),()=>{se=!0}},[Gt,R,e,t,a]),g.useEffect(()=>{if(!Qe||E)return;if(!e){H(!0);return}let se=!1;return(async()=>{try{const K=await e.agentsList(t,a);se||(O(K.agents??[]),H(!0))}catch{se||H(!0)}})(),()=>{se=!0}},[Qe,E,e,t,a]),g.useEffect(()=>{if(!Qe||Fe)return;if(!e){ue(!0);return}let se=!1;return(async()=>{try{const K=await e.personaList();se||(ye((K.personas??[]).map(we=>({personaId:we.personaId,label:we.label}))),ue(!0))}catch{se||ue(!0)}})(),()=>{se=!0}},[Qe,Fe,e]);const He=g.useCallback(se=>{switch(se.kind){case"persona":p(`@persona/${se.persona.personaId} `);break;case"cc-agent":p(`@"${se.agent.name} (agent)" `);break;case"contact":{const K=se.contact.deviceId;Re({deviceId:K,displayName:se.contact.displayName}),ze.current=K,ve(!0),Promise.resolve(c==null?void 0:c(K)).finally(()=>{ze.current===K&&ve(!1)}),p("@"),ae(!1),setTimeout(()=>{var we;return(we=b.current)==null?void 0:we.focus()},0);return}case"remote-persona":p(`@persona/${se.persona.personaId}@${se.deviceId} `),Re(null);break}ae(!1),setTimeout(()=>{var K;return(K=b.current)==null?void 0:K.focus()},0)},[c]),Nt=g.useCallback(()=>{Re(null),ze.current=null,ve(!1),p("@"),setTimeout(()=>{var se;return(se=b.current)==null?void 0:se.focus()},0)},[]),Yt=g.useCallback(se=>{if(se.source==="builtin"&&se.name==="new"&&s){p(""),z(),Xo(b.current),s(t);return}if(se.source==="builtin"&&se.name==="clear"&&o){p(""),z(),Xo(b.current),o();return}p(`/${se.name} `),setTimeout(()=>{var K;return(K=b.current)==null?void 0:K.focus()},0)},[s,t,z,o]),Xt=g.useCallback(async()=>{const se=f.trim(),K=C.filter(we=>we.status==="done");if(!(!se&&K.length===0)&&!(m||i)){if(se==="/new"&&s){v(!0);try{await s(t),p(""),z(),Xo(b.current)}finally{v(!1)}return}if(se==="/clear"&&o){v(!0);try{await o(),p(""),z(),Xo(b.current)}finally{v(!1)}return}v(!0);try{const we=a==="codex"?iJ(se,P):se,ht=oZ(we,C);await r(ht),p(""),z(),Xo(b.current)}finally{v(!1)}}},[f,C,m,i,r,s,t,z,o,a,P]);return{draft:f,setDraft:p,sending:m,textareaRef:b,isComposingRef:_,onCompositionStart:x,onCompositionEnd:y,attachments:C,addFiles:T,removeAttachment:N,skillSelectorVisible:Gt,filteredSkills:Mt,slashQuery:Rt??"",activeSkillIdx:j,setActiveSkillIdx:L,selectSkill:Yt,dismissSkillSelector:on,agentSelectorVisible:Qe,filteredAgents:wt,mentionQuery:bt,activeAgentIdx:V,setActiveAgentIdx:A,selectAgent:He,dismissAgentSelector:U,drilldown:Ie,drilldownLoading:Ke,exitDrilldown:Nt,doSend:Xt}}const oJ=120;function GM(e){e&&(e.style.height="auto",e.style.height=`${Math.min(e.scrollHeight,oJ)}px`)}function Xo(e){e&&(e.style.height="auto")}const aJ={spawnableContacts:[],ensureRemotePersonas:()=>Promise.resolve(),remotePersonasByDeviceId:new Map},lJ=g.createContext(aJ);function cJ(){return g.useContext(lJ)}function uJ({url:e,fileName:t,onClose:n}){const[r,i]=g.useState(!1);g.useEffect(()=>{const o=a=>{a.key==="Escape"&&n()};return document.addEventListener("keydown",o),()=>document.removeEventListener("keydown",o)},[n]);const s=async()=>{try{const a=await(await fetch(e)).blob();await navigator.clipboard.write([new ClipboardItem({[a.type]:a})]),i(!0),setTimeout(()=>i(!1),2e3)}catch{Lk(e,t)}};return h.jsx("div",{"data-testid":"image-lightbox",className:"fixed inset-0 z-[9999] flex items-center justify-center bg-black/60",onClick:n,role:"dialog","aria-modal":"true",children:h.jsxs("div",{className:"relative",onClick:o=>o.stopPropagation(),children:[h.jsx("img",{src:e,alt:t,className:"max-h-[90vh] max-w-[92vw] rounded-lg object-contain shadow-2xl"}),h.jsxs("div",{className:"absolute right-2 top-2 flex items-center gap-1.5",children:[h.jsxs("button",{type:"button",onClick:s,"data-testid":"image-lightbox-copy",className:"flex cursor-pointer items-center gap-1 rounded-full border border-bg-300 bg-bg-50/95 px-2 py-0.5 text-[11px] font-medium text-text-200 shadow transition-colors hover:bg-bg-100",children:[h.jsx(ip,{className:"h-3 w-3"}),r?"Copied":"Copy"]}),h.jsxs("button",{type:"button",onClick:()=>Lk(e,t),"data-testid":"image-lightbox-save",className:"flex cursor-pointer items-center gap-1 rounded-full border border-bg-300 bg-bg-50/95 px-2 py-0.5 text-[11px] font-medium text-text-200 shadow transition-colors hover:bg-bg-100",children:[h.jsx(kz,{className:"h-3.5 w-3.5"}),"Save"]}),h.jsx("button",{type:"button",onClick:n,"data-testid":"image-lightbox-close","aria-label":"close",className:"flex h-6 w-6 cursor-pointer items-center justify-center rounded-full border border-bg-300 bg-bg-50/95 text-text-300 transition-colors hover:bg-bg-100 hover:text-text-100",children:h.jsx(Dr,{className:"h-3 w-3"})})]})]})})}function Lk(e,t){const n=document.createElement("a");n.href=e,n.download=t||"image",n.click()}const jk=1e3,dJ=5e3;function Ed(e){if(!e)return"null";if(e===document.body)return"body";const t=e.getAttribute("data-testid"),n=typeof e.className=="string"&&e.className.trim()?`.${e.className.trim().split(/\s+/).slice(0,3).join(".")}`:"";return`${e.tagName.toLowerCase()}${e.id?`#${e.id}`:""}${t?`[${t}]`:""}${n}`}function hJ({meta:e,api:t,cwd:n,tool:r,onSend:i,sessionKey:s,disabled:o=!1,placeholder:a,className:l,awaitingUser:c=!1,onAbort:u,onNewSession:d,onClearSession:f,configSlot:p,aboveSlot:m}){const v=(e==null?void 0:e.streamInProgress)??!1,b=(e==null?void 0:e.contextPct)??null,_=b==null?"":b>=80?"text-red-400":b>=50?"text-amber-400":"text-text-500",x=g.useRef(null),y=cJ(),w=sJ({...t?{api:t}:{},cwd:n,...r?{tool:r}:{},sessionKey:s,onSend:i,disabled:o,...d?{onNewSession:d}:{},...f?{onClearSession:f}:{},spawnableContacts:y.spawnableContacts,ensureRemotePersonas:y.ensureRemotePersonas,remotePersonasByDeviceId:y.remotePersonasByDeviceId}),{draft:C,setDraft:k,sending:T,textareaRef:N,attachments:z,addFiles:P,removeAttachment:B,skillSelectorVisible:R,filteredSkills:I,slashQuery:j,activeSkillIdx:L,setActiveSkillIdx:$,selectSkill:F,dismissSkillSelector:D,agentSelectorVisible:O,filteredAgents:E,mentionQuery:H,activeAgentIdx:V,setActiveAgentIdx:A,selectAgent:ne,dismissAgentSelector:ae,drilldown:G,drilldownLoading:ye,exitDrilldown:Fe,doSend:ue}=w,Ie=$Z();g.useEffect(()=>{if(!Ie||Ie.signal===0||s===null||Ie.sessionId!==s)return;const{signal:K}=Ie;console.log("[chat-focus] 收到聚焦信号",{sessionKey:s,signal:K,delayMs:jk,activeElement:Ed(document.activeElement)});let we=null,ht=null,an=null;const _l=setTimeout(()=>{if(we=N.current,!we){console.warn("[chat-focus] textarea 已不在,放弃聚焦",{sessionKey:s,signal:K});return}we.focus(),console.log("[chat-focus] focus() 已执行",{sessionKey:s,signal:K,landed:document.activeElement===we,activeElement:Ed(document.activeElement)}),ht=xl=>{const zo=Ed(xl.relatedTarget);setTimeout(()=>{console.warn("[chat-focus] STOLEN 输入框失焦",{sessionKey:s,signal:K,relatedTarget:zo,activeElementAfterTick:Ed(document.activeElement)})},0)},we.addEventListener("blur",ht,{once:!0}),an=setTimeout(()=>{we&&ht&&we.removeEventListener("blur",ht)},dJ)},jk);return()=>{clearTimeout(_l),an&&clearTimeout(an),we&&ht&&we.removeEventListener("blur",ht)}},[Ie==null?void 0:Ie.signal]);const Re=!!t,Ke=T||o||v,ze=(C.trim().length>0||z.some(K=>K.status==="done"))&&!o&&!T&&!c,fn=a??(c?"Answer the question above first...":Ke?"Queue a message...":`Message ${Wx(r)}...`),it=g.useRef(!1),Rt=g.useCallback(()=>{it.current=!0},[]),Gt=g.useCallback(()=>{it.current=!1},[]),Mt=g.useCallback(K=>{if(R&&I.length>0){if(K.key==="ArrowDown")return K.preventDefault(),$(L>=I.length-1?0:L+1),!0;if(K.key==="ArrowUp")return K.preventDefault(),$(L<=0?I.length-1:L-1),!0;if(K.key==="Tab"||K.key==="Enter"&&!K.shiftKey){K.preventDefault();const we=I[L];return we&&F(we),!0}if(K.key==="Escape")return K.preventDefault(),D(),!0}return!1},[R,I,L,$,F,D]),bt=g.useCallback(K=>{if(O&&E.length>0){if(K.key==="ArrowDown")return K.preventDefault(),A(V>=E.length-1?0:V+1),!0;if(K.key==="ArrowUp")return K.preventDefault(),A(V<=0?E.length-1:V-1),!0;if(K.key==="Tab"||K.key==="Enter"&&!K.shiftKey){K.preventDefault();const we=E[V];return we&&ne(we),!0}if(K.key==="Escape")return K.preventDefault(),G?Fe():ae(),!0}return!1},[O,E,V,A,ne,ae,G,Fe]),Qe=g.useCallback(K=>{const we=K.nativeEvent;K.key==="Enter"&&JI({compositionActive:it.current,nativeIsComposing:we.isComposing,keyCode:we.keyCode})||Mt(K)||bt(K)||eR({key:K.key,shiftKey:K.shiftKey,compositionActive:it.current,nativeIsComposing:we.isComposing,keyCode:we.keyCode})&&(K.preventDefault(),ze&&ue())},[Mt,bt,ze,ue]),st=g.useCallback(K=>{k(K.target.value),GM(K.target)},[k]),wt=g.useCallback(K=>{K.target.files&&P(K.target.files),K.target.value=""},[P]),pn=g.useCallback(K=>{if(!Re)return;const we=Array.from(K.clipboardData.items).map(ht=>ht.getAsFile()).filter(ht=>!!(ht&&ht.type.startsWith("image/")));we.length!==0&&(K.preventDefault(),P(we))},[P,Re]),[on,U]=g.useState(null),Z=g.useCallback(K=>{K.previewUrl&&U({url:K.previewUrl,name:K.fileName})},[]),[_e,ke]=g.useState(!1),He=g.useCallback(K=>{Re&&(K.preventDefault(),ke(!0))},[Re]),Nt=g.useCallback(()=>ke(!1),[]),Yt=g.useCallback(K=>{Re&&(K.preventDefault(),ke(!1),K.dataTransfer.files.length>0&&P(K.dataTransfer.files))},[P,Re]),Xt=v&&!c&&typeof u=="function",se=o||c;return h.jsxs("div",{"data-testid":"chat-input",className:fe("shrink-0 border-t border-bg-300/20 px-4 py-3",l),onDragOver:He,onDragLeave:Nt,onDrop:Yt,children:[h.jsxs("div",{className:"max-w-3xl mx-auto relative",children:[Re?h.jsx("input",{ref:x,type:"file",multiple:!0,accept:GZ,hidden:!0,onChange:wt,"data-testid":"chat-input-file"}):null,h.jsxs("div",{"data-testid":"chat-input-bare",className:fe("flex flex-col gap-2"),children:[c||T||v?h.jsxs("div",{"data-testid":"chat-input-status-bar",className:"flex items-center gap-2 text-[12px] text-text-400",children:[h.jsxs("div",{className:"flex gap-1",children:[h.jsx("span",{className:"w-1.5 h-1.5 rounded-full bg-text-400-dim-fg animate-bounce",style:{animationDelay:"0ms"}}),h.jsx("span",{className:"w-1.5 h-1.5 rounded-full bg-text-400-dim-fg animate-bounce",style:{animationDelay:"150ms"}}),h.jsx("span",{className:"w-1.5 h-1.5 rounded-full bg-text-400-dim-fg animate-bounce",style:{animationDelay:"300ms"}})]}),h.jsx("span",{children:c?"Waiting for your answer":`${r==="codex"?"Codex":"Claude"} is working`})]}):null,R?h.jsx(BZ,{query:j,skills:I,activeIndex:L,onActiveIndexChange:$,onSelect:F}):null,O?G?!y.remotePersonasByDeviceId.has(G.deviceId)&&ye?h.jsx("div",{"data-testid":"cc-agent-remote-loading",className:"absolute bottom-full left-0 right-0 z-50 mb-1.5 rounded-2xl border border-bg-300 bg-bg-50 px-4 py-3 text-[12px] text-text-300 shadow-lg",children:`正在加载 @${G.displayName} 的 persona…`}):E.length>0?h.jsx(Ik,{query:H??"",entries:E,activeIndex:V,onActiveIndexChange:A,onSelect:ne}):h.jsx("div",{"data-testid":"cc-agent-remote-empty",className:"absolute bottom-full left-0 right-0 z-50 mb-1.5 rounded-2xl border border-bg-300 bg-bg-50 px-4 py-3 text-[12px] text-text-300 shadow-lg",children:`@${G.displayName} 暂无可派活的 persona(可能离线或未公开)`}):h.jsx(Ik,{query:H??"",entries:E,activeIndex:V,onActiveIndexChange:A,onSelect:ne}):null,z.length>0?h.jsx(qZ,{attachments:z,onRemove:B,onOpenPreview:Z}):null,m?h.jsx("div",{"data-testid":"chat-input-above-slot",className:"mx-2 -mb-3 rounded-t-xl border border-b-0 border-border bg-bg-0 px-3 pt-2 pb-4",children:m}):null,h.jsxs("div",{"data-testid":"bare-chat-input-frame",className:fe("relative flex flex-col gap-1 rounded-xl border border-border bg-bg-0 px-3 py-2 transition-colors duration-200",se?"opacity-60":null,_e?"border-accent/60 bg-accent/5":null),children:[h.jsx("textarea",{ref:N,"data-testid":"chat-input-textarea",value:C,onChange:st,onKeyDown:Qe,onCompositionStart:Rt,onCompositionEnd:Gt,onPaste:pn,placeholder:fn,disabled:se,readOnly:se,rows:1,className:"w-full resize-none bg-transparent border-0 outline-none text-[14px] text-text-100 placeholder:text-text-400 leading-relaxed py-1 min-h-[22px] max-h-[120px] overflow-y-auto disabled:cursor-not-allowed"}),h.jsxs("div",{className:"flex items-center gap-1.5",children:[Re?h.jsx("button",{type:"button",onClick:()=>{var K;return(K=x.current)==null?void 0:K.click()},disabled:Ke,"data-testid":"chat-input-attach","aria-label":"attach files",className:fe("flex h-7 w-7 shrink-0 items-center justify-center rounded-md transition-colors",Ke?"cursor-default text-text-400/50":"cursor-pointer text-text-400 hover:bg-text-100/5 hover:text-text-200"),children:h.jsx(Jz,{className:"h-4 w-4"})}):null,h.jsx("div",{className:"flex-1 min-w-0"}),b!=null?h.jsxs("span",{"data-testid":"chat-input-ctx",className:fe("shrink-0 text-[11px] tabular-nums",_),children:["ctx:",b,"%"]}):null,p,Xt?h.jsx("button",{type:"button",onClick:u,"data-testid":"chat-input-abort","aria-label":"interrupt",title:"中断当前轮次(不杀进程)",className:"h-8 w-8 rounded-full flex items-center justify-center border border-text-400/40 text-text-400 hover:bg-text-100/5 hover:text-text-100 transition-colors cursor-pointer",children:h.jsx(FN,{className:"w-3.5 h-3.5",strokeWidth:2.5})}):null,h.jsx("button",{type:"button",onClick:()=>{ze&&ue()},disabled:!ze,"data-testid":"chat-input-send","aria-label":"send",className:fe("h-8 w-8 rounded-full flex items-center justify-center transition-colors",ze?"bg-accent text-white hover:bg-accent-hover cursor-pointer shadow-sm":"bg-[var(--text-400-dim)] text-[var(--text-400-dim-fg)] cursor-default"),children:h.jsx(tz,{className:"w-4 h-4",strokeWidth:2.5})})]})]})]})]}),on?h.jsx(uJ,{url:on.url,fileName:on.name,onClose:()=>U(null)}):null]})}function fJ(e){const t=e.replace(/\/+$/,""),n=t.lastIndexOf("/");return n>=0?t.slice(n+1):t}function pJ({meta:e,tool:t,connState:n,variant:r="full",onOpenConfig:i,liveWorktreeRoot:s,ephemeral:o=!1,onPromote:a,className:l}){const c=s??e.cwd??"",d=!!e.sessionLabel&&e.sessionLabel!==e.sessionId?e.sessionLabel:fJ(c),f=c;return r==="quickask"?h.jsxs("div",{"data-testid":"chat-header","data-variant":"quickask",className:fe("flex items-center shrink-0 px-3 py-2 gap-2",l),children:[a?h.jsx("button",{type:"button","data-testid":"chat-header-promote","data-promoted":o?"false":"true",disabled:!o,onClick:a,title:o?"保留为正式会话":"已保留为正式会话",className:fe("shrink-0 inline-flex items-center justify-center h-5 w-5 rounded-md transition-colors",o?"text-text-500 hover:text-text-200 hover:bg-text-100/5 cursor-pointer":"text-amber-400"),children:h.jsx(lz,{className:fe("w-3.5 h-3.5",!o&&"fill-current")})}):null,h.jsx("span",{className:"font-semibold text-text-100 truncate text-[13px]","data-testid":"chat-header-worktree",title:f,children:d})]}):h.jsxs("div",{"data-testid":"chat-header","data-variant":"full",className:fe("relative flex items-center shrink-0 px-4 pr-[4.5rem] md:pr-4 py-2.5",l),children:[h.jsx("span",{className:"font-semibold text-text-100 truncate text-[13px]","data-testid":"chat-header-worktree",title:f,children:d}),h.jsx("div",{className:"absolute right-4 top-1/2 -translate-y-1/2 z-10 flex items-center gap-1",children:i?h.jsx("button",{type:"button","aria-label":"Session settings","data-testid":"chat-header-settings-mobile",onClick:i,title:"Session settings",className:"flex md:hidden h-7 w-7 items-center justify-center rounded-md bg-transparent text-text-300 transition-colors duration-150 hover:bg-bg-200 hover:text-text-100 cursor-pointer outline-none",children:h.jsx(zN,{className:"w-4 h-4"})}):null})]})}let mJ=null;function gJ(){return mJ}function Ql({label:e,labelTitle:t,children:n}){return h.jsxs("div",{className:"flex items-start gap-2 px-2 py-1",children:[h.jsx("span",{className:"w-14 shrink-0 truncate text-[11px] text-text-400 pt-0.5",...t?{title:t}:{},children:e}),h.jsx("span",{className:"flex-1 min-w-0 text-[12px] text-text-100",children:n})]})}function Dk({label:e,labelTitle:t,value:n,testid:r}){const[i,s]=g.useState(!1),o=g.useRef(null);g.useEffect(()=>()=>{o.current&&clearTimeout(o.current)},[]);const a=()=>{typeof navigator>"u"||!navigator.clipboard||navigator.clipboard.writeText(n).then(()=>{s(!0),o.current&&clearTimeout(o.current),o.current=setTimeout(()=>s(!1),2e3)},()=>{})};return h.jsx(Ql,{label:e,labelTitle:t,children:h.jsxs("button",{type:"button",onClick:a,"data-testid":r,title:i?"已复制":`复制:${n}`,className:"w-full flex items-center gap-1.5 text-left group cursor-pointer",children:[h.jsx("span",{className:"font-mono text-[11px] text-text-300 truncate flex-1 min-w-0",children:n}),i?h.jsx(ul,{className:"w-3 h-3 shrink-0 text-accent"}):h.jsx(ip,{className:"w-3 h-3 shrink-0 text-text-400 opacity-0 group-hover:opacity-100 transition-opacity"})]})})}function ig({icon:e,label:t,meta:n,onClick:r,testid:i}){return h.jsxs("button",{type:"button","data-testid":i,onClick:r,className:"w-full flex items-center gap-2.5 px-2 py-1.5 rounded-md hover:bg-text-100/5 cursor-pointer text-left",children:[h.jsx("span",{className:"w-4 h-4 shrink-0 text-text-300 inline-flex items-center justify-center",children:e}),h.jsx("span",{className:"flex-1 text-[12.5px] text-text-100",children:t}),n?h.jsx("span",{className:"shrink-0 text-[11px] text-text-400 font-mono",children:n}):null]})}function vJ({session:e,meta:t,liveGitBranch:n,liveWorktreeRoot:r,personaName:i,onOpenPersona:s,onOpenFiles:o,cronActiveCount:a,onCronClick:l,onForceStop:c,viewerRole:u="owner",toolSessionIdLabel:d="tool session id",drill:f=null,onCollapse:p}){const m=n!==void 0?n:t.gitBranch??null,v=t.procAlive??!1,b=cP(e),_=b!=null&&e.originOwnerPrincipalId==null&&u!=="guest",[x,y]=g.useState(null),w=g.useRef(null);g.useEffect(()=>()=>{w.current&&clearTimeout(w.current)},[]);const C=async()=>{if(!_)return;const k=gJ();let T;try{k||(await navigator.clipboard.writeText(b),T="命令已复制")}catch{T="操作失败"}y(T),w.current&&clearTimeout(w.current),w.current=setTimeout(()=>y(null),2500)};return h.jsxs("div",{"data-testid":"session-info-panel",className:"h-full min-w-0 border-l border-border bg-bg-100 flex flex-col",children:[h.jsxs("div",{className:"flex items-center gap-2 px-3 py-2.5 border-b border-border shrink-0",children:[f?h.jsx("button",{type:"button","data-testid":"session-info-back",onClick:f.onBack,"aria-label":"返回会话信息",className:"p-1 -ml-1 rounded text-text-400 hover:text-text-100 hover:bg-text-100/10",children:h.jsx(JB,{className:"w-4 h-4"})}):p?h.jsx("button",{type:"button","data-testid":"session-info-collapse",onClick:p,"aria-label":"collapse session info",title:"收起会话信息",className:"p-1 -ml-1 rounded text-text-400 hover:text-text-100 hover:bg-text-100/10",children:h.jsx(Nm,{className:"w-4 h-4"})}):h.jsx(Nm,{className:"w-4 h-4 text-text-300"}),h.jsx("span",{className:"flex-1 text-[13px] font-medium text-text-100 truncate",children:f?f.title:"会话信息"}),f&&p?h.jsx("button",{type:"button","data-testid":"session-info-collapse",onClick:p,"aria-label":"collapse session info",title:"收起会话信息",className:"p-1 rounded text-text-400 hover:text-text-100 hover:bg-text-100/10",children:h.jsx(Nm,{className:"w-4 h-4"})}):null]}),f?h.jsx("div",{"data-testid":"session-info-drill",className:"flex-1 min-h-0 overflow-y-auto",children:f.content}):h.jsxs("div",{className:"flex-1 overflow-y-auto px-2 py-2",children:[m?h.jsx(Ql,{label:"分支",children:h.jsxs("span",{"data-testid":"session-info-branch",className:"inline-flex items-center gap-1 font-mono text-[11.5px] min-w-0",title:r??void 0,children:[h.jsx(zx,{className:"w-3 h-3 shrink-0 text-text-400"}),h.jsx("span",{className:"truncate",children:m})]})}):null,i&&s?h.jsx(Ql,{label:"persona",children:h.jsxs("button",{type:"button","data-testid":"session-info-persona",onClick:s,className:"inline-flex items-center gap-1 hover:text-accent cursor-pointer",children:[h.jsx(VN,{className:"w-3 h-3"}),h.jsx("span",{className:"truncate",children:i})]})}):null,h.jsx(Ql,{label:"引擎",children:h.jsxs("span",{className:"inline-flex items-center gap-1.5","data-testid":"session-info-engine",children:[h.jsx(sp,{tool:e.tool,className:fe("w-3.5 h-3.5 shrink-0",op(e.tool))}),h.jsxs("span",{className:"truncate",children:[Wx(e.tool),t.model?` · ${t.model}`:""]})]})}),h.jsx(Ql,{label:"cwd",children:h.jsx("span",{"data-testid":"session-info-cwd",className:"font-mono text-[11px] text-text-300 truncate block",title:e.cwd,children:e.cwd})}),h.jsx(Dk,{label:"session id",value:e.sessionId,testid:"session-info-session-id"}),e.toolSessionId?h.jsx(Dk,{label:`${e.tool||"claude"} id`,labelTitle:d,value:e.toolSessionId,testid:"session-info-tool-session-id"}):null,h.jsx("div",{className:"my-2 border-t border-border"}),o?h.jsx(ig,{icon:h.jsx(Rz,{className:"w-3.5 h-3.5"}),label:"Edited Files",onClick:o,testid:"session-info-files"}):null,a&&a>0&&l?h.jsx(ig,{icon:h.jsx(xz,{className:"w-3.5 h-3.5"}),label:"定时任务",meta:String(a),onClick:l,testid:"session-info-cron"}):null,_?h.jsx(ig,{icon:h.jsx(w$,{className:"w-3.5 h-3.5"}),label:"终端",meta:x,onClick:()=>void C(),testid:"session-info-terminal"}):null]}),v&&c?h.jsx("div",{className:"shrink-0 border-t border-border px-3 py-2.5",children:h.jsxs("button",{type:"button","data-testid":"session-info-force-stop",onClick:c,title:e.tool==="codex"?"强制停止 Codex 进程":"强制停止 Claude Code 进程(会丢失 initialize / 预热缓存)",className:"inline-flex items-center gap-1.5 h-6 px-2.5 rounded-md text-text-400 hover:bg-red-500/10 hover:text-red-400 transition-colors text-[12px] cursor-pointer",children:[h.jsx(Xz,{className:"w-3.5 h-3.5"}),h.jsx("span",{children:"强制停止"})]})}):null]})}const _J=g.createContext({container:null});function xJ(){return g.useContext(_J)}function yJ(e){return e==="TodoWrite"}function bJ(e){if(!e||typeof e!="object")return null;const t=e;if(!Array.isArray(t.todos))return null;const n=[];for(const r of t.todos){if(!r||typeof r!="object")continue;const i=r,s=typeof i.content=="string"?i.content:"";if(!s)continue;const o=i.status==="in_progress"||i.status==="completed"?i.status:"pending",a=typeof i.activeForm=="string"?i.activeForm:void 0;n.push({content:s,status:o,activeForm:a})}return n}function wJ(e,t,n){const r=[],i=new Map;for(let s=0;s<e.length;s++){const o=e[s],a=typeof o.seq=="number"?o.seq:s;switch(o.kind){case"session_init":r.push({kind:"session-init",seq:a,toolSessionId:o.toolSessionId});break;case"text":Ok(r,a,"assistant-text",o.text,o.partialId,o.uuid);break;case"thinking":Ok(r,a,"assistant-thinking",o.text,o.partialId);break;case"user_text":{o.meta==="task-notification"?r.push({kind:"agent-notification",seq:a,text:o.text,taskId:o.taskId,parentToolUseId:o.parentToolUseId}):o.meta?r.push({kind:"user-meta",seq:a,metaKind:o.meta,text:o.text}):r.push({kind:"user-text",seq:a,text:o.text,uuid:o.uuid,...o.sender&&o.sender.principal!=="owner"?{senderDisplayName:o.sender.displayName}:{}});break}case"tool_call":YM(r,a,o.toolUseId,o.tool,o.input,o.toolKind);break;case"tool_result":{const l=i.get(o.toolUseId);if(l!==void 0){if(o.askQuestionAnswers){const u=r[l];u.submittedAnswers=o.askQuestionAnswers}i.delete(o.toolUseId);break}const c={kind:"tool-result",seq:a,toolUseId:o.toolUseId,output:o.output,error:o.error};o.toolResultExtra&&(c.toolResultExtra=o.toolResultExtra),r.push(c);break}case"attachment_memories":r.push({kind:"memory-callout",seq:a,memories:o.memories});break;case"permission_request":{if(!t||o.requestId!==t)break;r.push({kind:"permission-inline",seq:a,requestId:o.requestId,tool:o.tool,input:o.input});break}case"ask_user_question":i.set(o.toolUseId,r.length),r.push({kind:"question-card",seq:a,toolUseId:o.toolUseId,questions:o.questions});break;case"turn_end":{const l={kind:"turn-end",seq:a};o.durationMs!==void 0&&(l.durationMs=o.durationMs),o.reason!==void 0&&(l.reason=o.reason),r.push(l);break}case"subagent_progress":{const l={kind:"agent-progress",seq:a,toolUseId:o.toolUseId,agentId:o.agentId,status:o.status};o.description&&(l.description=o.description),o.lastToolName&&(l.lastToolName=o.lastToolName),o.prompt&&(l.prompt=o.prompt),o.stats&&(l.stats=o.stats),r.push(l);break}case"error":r.push({kind:"error",seq:a,message:o.message});break}}return r}function YM(e,t,n,r,i,s){if(yJ(r)){const o=bJ(i);if(o){e.push({kind:"todo-checklist",seq:t,toolUseId:n,todos:o});return}}if(r==="Agent"){const o=i??{},a=typeof o.description=="string"&&o.description?o.description:typeof o.subagent_type=="string"&&o.subagent_type?o.subagent_type:"Subagent";e.push({kind:"agent-call",seq:t,toolUseId:n,description:a,input:i});return}if(lW(r)){e.push({kind:"task-event",seq:t,toolUseId:n,name:r,input:i});return}e.push({kind:"tool-call",seq:t,toolUseId:n,tool:r,toolKind:s,input:i})}function Ok(e,t,n,r,i,s){let o=-1;for(let c=e.length-1;c>=0;c--)if(e[c].kind===n){o=c;break}const a=o>=0?e[o]:null;if(i){if(a&&a.partialId===i){const u=n==="assistant-text"?{kind:n,seq:a.seq,text:a.text+r,partialId:i,...s?{uuid:s}:{}}:{kind:n,seq:a.seq,text:a.text+r,partialId:i};e[o]=u;return}const c=n==="assistant-text"?{kind:n,seq:t,text:r,partialId:i,...s?{uuid:s}:{}}:{kind:n,seq:t,text:r,partialId:i};e.push(c);return}if(a&&a.partialId){const c=n==="assistant-text"?{kind:n,seq:a.seq,text:r,...s?{uuid:s}:{}}:{kind:n,seq:a.seq,text:r};e[o]=c;return}const l=n==="assistant-text"?{kind:n,seq:t,text:r,...s?{uuid:s}:{}}:{kind:n,seq:t,text:r};e.push(l)}const SJ="AskUserQuestion";function XM(e,t=0,n){var o;const r=[],i=new Map;let s=t;for(const a of e){const l=s++,c=a.toolUseId??`hist-${l}`;switch(a.kind){case"user-text":if(a.meta==="task-notification")r.push({kind:"agent-notification",seq:l,text:a.text??"",taskId:a.taskId,parentToolUseId:a.parentToolUseId});else if(a.meta)r.push({kind:"user-meta",seq:l,metaKind:a.meta,text:a.text??""});else{const u=(o=Q6.exec(a.text??""))==null?void 0:o[1];r.push({kind:"user-text",seq:l,text:a.text??"",uuid:a.uuid,...u?{senderDisplayName:u}:{}})}break;case"assistant-text":r.push({kind:"assistant-text",seq:l,text:a.text??"",uuid:a.uuid});break;case"tool_call":{if(a.tool===SJ){const u=a.input??{},d=Array.isArray(u.questions)?u.questions:[];i.set(c,r.length),r.push({kind:"question-card",seq:l,toolUseId:c,questions:d});break}YM(r,l,c,a.tool??"",a.input,n);break}case"tool_result":{const u=i.get(c);if(u!==void 0){if(a.askQuestionAnswers){const f=r[u];f.submittedAnswers=a.askQuestionAnswers}i.delete(c);break}const d={kind:"tool-result",seq:l,toolUseId:c,output:a.output};a.error!==void 0&&(d.error=a.error),a.toolResultExtra&&(d.toolResultExtra=a.toolResultExtra),r.push(d);break}case"attachment_memories":a.memories&&a.memories.length>0&&r.push({kind:"memory-callout",seq:l,memories:a.memories});break;case"summary":break;case"turn-end":{const u={kind:"turn-end",seq:l};typeof a.durationMs=="number"&&(u.durationMs=a.durationMs),r.push(u);break}}}return r}const kJ=5e5;function CJ(e){const t=kJ-e.length;return e.map(n=>({...n,seq:n.seq+t}))}function EJ({api:e,cwd:t,toolSessionId:n,toolKind:r="claude"}){const i=UM(),s=(i==null?void 0:i.state.agentId)??null,o=i==null?void 0:i.state.agentType,[a,l]=g.useState([]),[c,u]=g.useState(!1),[d,f]=g.useState(null);g.useEffect(()=>{if(!s)return;let m=!1;return u(!0),f(null),l([]),e.historySubagentRead({cwd:t,toolSessionId:n,subagentId:s}).then(v=>{m||l(v.messages??[])}).catch(v=>{m||f(v instanceof Error?v.message:String(v))}).finally(()=>{m||u(!1)}),()=>{m=!0}},[s,t,n,e]);const p=g.useMemo(()=>a.length>0?XM(a,0,r):[],[a,r]);return!i||!s?null:h.jsxs("div",{"data-testid":"subagent-drawer","data-agent-id":s,className:fe("fixed inset-y-0 right-0 z-50 w-[min(560px,92vw)]","flex flex-col border-l border-bg-200/60 bg-bg-50 shadow-xl"),style:{paddingTop:"env(safe-area-inset-top)"},children:[h.jsxs("div",{className:"flex flex-col gap-0.5 px-3 py-2 border-b border-bg-200/60",children:[h.jsxs("div",{className:"flex items-center justify-between",children:[h.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[o?h.jsx("span",{className:"inline-flex items-center rounded-sm bg-violet-500/10 px-1.5 py-0.5 text-[11px] text-violet-400 font-medium",children:o}):null,h.jsx("span",{className:"font-mono text-[11px] text-text-400 truncate",title:s,children:s})]}),h.jsx("button",{type:"button","aria-label":"关闭",onClick:()=>i.close(),className:"p-1 rounded hover:bg-bg-200/50 text-text-400 hover:text-text-200",children:h.jsx(Dr,{className:"w-4 h-4"})})]}),!c&&!d&&a.length>0?h.jsxs("div",{className:"text-[11px] text-text-400",children:[a.length," 条消息 · 首条为主会话派发的任务指令"]}):null]}),h.jsx("div",{className:"flex-1 min-h-0 overflow-y-auto overflow-x-hidden px-3 py-2",children:c?h.jsxs("div",{className:"flex items-center gap-2 text-[12px] text-text-400",children:[h.jsx(In,{className:"w-3.5 h-3.5 animate-spin"}),h.jsx("span",{children:"加载中…"})]}):d?h.jsxs("div",{className:"flex items-center gap-2 text-[12px] text-error",children:[h.jsx(Ls,{className:"w-3.5 h-3.5"}),h.jsx("span",{children:d})]}):p.length===0?h.jsx("div",{className:"text-[12px] text-text-400 italic",children:"无消息"}):h.jsx(VM,{lines:p})})]})}function Bk(e,t){let n=0;for(const r of e.lines)r.startsWith(t)&&n++;return n}function TJ(e,t){const n=e.findIndex(c=>c.kind==="user-text"&&c.uuid===t);if(n<0)return{userMessageId:t,files:[],totalInsertions:0,totalDeletions:0,anchorFound:!1};let r=e.length;for(let c=n+1;c<e.length;c++)if(e[c].kind==="user-text"){r=c;break}const i=[],s=new Map;for(let c=n+1;c<r;c++){const u=e[c];if(u.kind!=="tool-result")continue;const d=u.toolResultExtra;if(!(d!=null&&d.filePath)||!d.structuredPatch||d.structuredPatch.length===0)continue;const f=d.filePath;let p=s.get(f);p||(p={filePath:f,hunks:[],insertions:0,deletions:0},s.set(f,p),i.push(f));for(const m of d.structuredPatch)p.hunks.push(m),p.insertions+=Bk(m,"+"),p.deletions+=Bk(m,"-")}const o=i.map(c=>s.get(c)),a=o.reduce((c,u)=>c+u.insertions,0),l=o.reduce((c,u)=>c+u.deletions,0);return{userMessageId:t,files:o,totalInsertions:a,totalDeletions:l,anchorFound:!0}}function NJ({open:e,onOpenChange:t,api:n,sessionId:r,userMessageId:i,lines:s,procAlive:o,onApplied:a,onNoChanges:l}){const c=g.useMemo(()=>TJ(s,i),[s,i]),[u,d]=g.useState(null),[f,p]=g.useState(!1),[m,v]=g.useState(!1),[b,_]=g.useState(null);g.useEffect(()=>{if(!e)return;let k=!1;return p(!0),d(null),(async()=>{try{const T=await n.sessionRewindDiff({sessionId:r,userMessageId:i});k||(d(T),!T.canRewind&&!T.error&&T.files.length===0&&(l==null||l(i)))}catch{k||d(null)}finally{k||p(!1)}})(),()=>{k=!0}},[e,n,r,i]);const x=g.useMemo(()=>{if(u){const k=!u.canRewind&&!u.error&&u.files.length===0;if(u.canRewind||k)return{source:"rpc",anchorFound:!0,files:u.files.map(T=>({filePath:T.filePath,hunks:T.hunks,insertions:T.insertions,deletions:T.deletions})),totalInsertions:u.totalInsertions,totalDeletions:u.totalDeletions}}return{source:"local",anchorFound:c.anchorFound,files:c.files,totalInsertions:c.totalInsertions,totalDeletions:c.totalDeletions,rpcError:u==null?void 0:u.error}},[u,c]),y=g.useCallback(async()=>{v(!0),_(null);try{const k=await n.sessionRewind({sessionId:r,userMessageId:i,dryRun:!1});if(!k.canRewind){_(k.error??"回退失败");return}a==null||a(),t(!1)}catch(k){_(k.message||"回退失败")}finally{v(!1)}},[n,r,i,a,t]);if(!e)return null;const w=x.files.length>0,C=!f&&!m&&x.anchorFound&&w&&!b;return h.jsxs("div",{"data-testid":"rewind-preview-drawer",className:"fixed right-0 top-0 bottom-0 z-40 flex flex-col border-l border-bg-300/40 bg-bg-0 shadow-xl",style:{width:480,minWidth:480},children:[h.jsxs("div",{className:"flex items-center justify-between px-4 py-3 border-b border-bg-300/30 shrink-0",children:[h.jsxs("div",{className:"flex items-center gap-2",children:[h.jsx(WN,{className:"w-4 h-4 text-text-300"}),h.jsx("span",{className:"text-[14px] font-semibold text-text-100",children:"Rewind 预览"})]}),h.jsx("button",{type:"button",onClick:()=>t(!1),"data-testid":"rewind-drawer-close",className:"flex items-center justify-center w-7 h-7 rounded-md text-text-400 hover:bg-text-100/5 hover:text-text-200 cursor-pointer","aria-label":"close",children:h.jsx(Dr,{className:"w-4 h-4"})})]}),b?h.jsxs("div",{"data-testid":"rewind-error-banner",className:"mx-4 mt-3 flex items-start gap-2 rounded-md border border-red-400/40 bg-red-500/10 px-3 py-2 text-[12px] text-red-400",children:[h.jsx(Kc,{className:"w-4 h-4 shrink-0 mt-0.5"}),h.jsx("span",{children:b})]}):null,h.jsx("div",{className:"flex-1 overflow-y-auto px-4 py-3 space-y-3",children:f?h.jsxs("div",{"data-testid":"rewind-loading",className:"flex items-center gap-2 text-[12px] text-text-400",children:[h.jsx(In,{className:"w-3.5 h-3.5 animate-spin"}),h.jsx("span",{children:"正在读取快照…"})]}):x.anchorFound?w?h.jsxs(h.Fragment,{children:[h.jsxs("div",{"data-testid":"rewind-summary",className:"rounded-md border border-bg-300 bg-bg-100/40 px-3 py-2 text-[12px] text-text-200",children:[h.jsxs("div",{children:["将回退 ",h.jsx("span",{className:"font-semibold text-text-100",children:x.files.length})," ","个文件,",h.jsxs("span",{className:"text-green-500 font-mono",children:["+",x.totalInsertions]})," / ",h.jsxs("span",{className:"text-red-400 font-mono",children:["-",x.totalDeletions]})]}),x.source==="local"?h.jsx("div",{"data-testid":"rewind-source-hint",className:"mt-1 text-text-400 text-[11px]",children:"基于对话里 tool_result 估算(未读到 CC 快照,数字可能与实际磁盘略有差异)"}):null]}),x.files.map(k=>h.jsx(IJ,{file:k},k.filePath))]}):h.jsxs("div",{"data-testid":"rewind-no-changes",className:"rounded-md border border-bg-300 bg-bg-100/60 px-3 py-2 text-[12px] text-text-300 space-y-1",children:[h.jsx("div",{children:"磁盘上的文件已经和这个时刻的快照完全一致——没有需要回退的改动。"}),h.jsx("div",{className:"text-text-400 text-[11px]",children:"可能这条消息之后 Claude 没落盘编辑,或之前已经 rewind 过了。"})]}):h.jsx("div",{"data-testid":"rewind-no-anchor",className:"rounded-md border border-bg-300 bg-bg-100/60 px-3 py-2 text-[12px] text-text-300",children:"未能在当前消息流中找到对应的用户消息(可能已被历史裁剪)。"})}),h.jsxs("div",{className:"flex flex-col gap-2 px-4 py-3 border-t border-bg-300/30 shrink-0",children:[w&&x.anchorFound&&!o?h.jsxs("div",{"data-testid":"rewind-needs-cc",className:"flex items-start gap-2 rounded-md border border-bg-300 bg-bg-100/60 px-3 py-2 text-[12px] text-text-300",children:[h.jsx(Kc,{className:"w-4 h-4 shrink-0 mt-0.5 text-warning"}),h.jsx("span",{children:'Claude Code 进程当前未运行。点击"确认回退"时会自动启动它再执行 — 可能需要等一两秒。'})]}):null,h.jsxs("div",{className:"flex items-center justify-end gap-2",children:[h.jsx("button",{type:"button",onClick:()=>t(!1),className:"h-8 px-3 rounded-md text-[12px] text-text-300 hover:bg-text-100/5 cursor-pointer",children:"取消"}),h.jsx("button",{type:"button",disabled:!C,onClick:()=>void y(),"data-testid":"rewind-apply",className:fe("h-8 px-3 rounded-md text-[12px] font-medium transition-colors",C?"bg-accent text-white hover:bg-accent-hover cursor-pointer":"bg-bg-200 text-text-400 cursor-not-allowed"),children:m?"回退中…":"确认回退"})]})]})]})}function PJ(e){return e.replace(/^\/Users\/[^/]+/,"~")}function IJ({file:e}){const[t,n]=g.useState(!0);return h.jsxs("div",{"data-testid":"rewind-file-block","data-file":e.filePath,className:"rounded-md border border-bg-300 overflow-hidden bg-bg-0",children:[h.jsxs("button",{type:"button",onClick:()=>n(r=>!r),className:"w-full flex items-center gap-1.5 px-3 py-2 text-[12px] hover:bg-text-100/5 cursor-pointer",children:[t?h.jsx(ir,{className:"w-3.5 h-3.5 text-text-400 shrink-0"}):h.jsx(Un,{className:"w-3.5 h-3.5 text-text-400 shrink-0"}),h.jsx("span",{className:"font-mono text-text-200 truncate flex-1 text-left",title:e.filePath,children:PJ(e.filePath)}),h.jsxs("span",{className:"font-mono shrink-0 text-text-400",children:[h.jsxs("span",{className:"text-green-500",children:["+",e.insertions]})," ",h.jsxs("span",{className:"text-red-400",children:["-",e.deletions]})]})]}),t?h.jsx("div",{className:"border-t border-bg-300",children:e.hunks.map(r=>h.jsx(RJ,{hunk:r},`${r.oldStart}-${r.oldLines}-${r.newStart}-${r.newLines}`))}):null]})}function RJ({hunk:e}){const t=`@@ -${e.oldStart},${e.oldLines} +${e.newStart},${e.newLines} @@`;return h.jsxs("div",{className:"text-[11px] font-mono leading-relaxed",children:[h.jsx("div",{className:"px-3 py-1 text-text-400 bg-bg-100/40 border-b border-bg-300",children:t}),e.lines.map((n,r)=>{const i=n.charAt(0),s=i==="+"?"bg-green-500/10 text-green-300":i==="-"?"bg-red-500/10 text-red-300":"text-text-300";return h.jsx("div",{className:fe("px-3 whitespace-pre",s),children:n.length>0?n:" "},r)})]})}function MJ({jobs:e}){return e.length===0?h.jsx("div",{"data-testid":"cron-job-list-empty",className:"px-4 py-3 text-sm text-text-500",children:"当前会话暂无活跃 cron 任务"}):h.jsx("ul",{"data-testid":"cron-job-list",className:"flex flex-col gap-2",children:e.map(t=>h.jsxs("li",{"data-testid":`cron-job-${t.id}`,className:"flex flex-col gap-1 rounded-md border border-border px-3 py-2",children:[h.jsxs("div",{className:"flex items-center gap-2 text-xs",children:[h.jsx("span",{className:"font-mono text-text-300",children:t.id}),h.jsx("span",{className:"text-text-500",children:"·"}),h.jsx("span",{className:"text-text-400",children:t.humanSchedule}),t.recurring?h.jsx("span",{"data-testid":`cron-job-${t.id}-recurring-badge`,className:"ml-auto rounded-md bg-accent-dim px-2 py-0.5 text-accent",children:"recurring"}):null]}),h.jsx("div",{className:"text-sm text-text-200 truncate",title:t.prompt,children:t.prompt})]},t.id))})}const AJ={idle:"还没启动","turn-running":"正在 run 中","turn-idle":"进程活着,等输入",exited:"进程已退出",crashed:"启动失败 / 异常退出"};function LJ({sessionStatus:e}){switch(e){case"idle":return"idle";case"running":return"turn-running";case"running-idle":return"turn-idle";case"observing":return"turn-running";case"stopped":return"exited";case"error":return"crashed"}}function jJ(e){return e==="running"||e==="observing"}function QM(e){return e==="running"||e==="running-idle"||e==="observing"}/**
512
512
  * Copyright (c) 2014-2024 The xterm.js authors. All rights reserved.
513
513
  * @license MIT
514
514
  *
@@ -556,4 +556,4 @@ Minimum version required to store current data is: `+s+`.
556
556
 
557
557
  If you want to hide the \`${t.titleName}\`, you can wrap it with our VisuallyHidden component.
558
558
 
559
- For more information, see https://radix-ui.com/primitives/docs/components/${t.docsSlug}`;return g.useEffect(()=>{e&&(document.getElementById(e)||console.error(n))},[n,e]),null},rie="DialogDescriptionWarning",iie=({contentRef:e,descriptionId:t})=>{const r=`Warning: Missing \`Description\` or \`aria-describedby={undefined}\` for {${y5(rie).contentName}}.`;return g.useEffect(()=>{var s;const i=(s=e.current)==null?void 0:s.getAttribute("aria-describedby");t&&i&&(document.getElementById(t)||console.warn(r))},[r,e,t]),null},sie=a5,oie=u5,b5=d5,w5=h5,S5=p5,k5=g5,aie=_5;const c1=sie,lie=oie,C5=g.forwardRef(({className:e,...t},n)=>h.jsx(b5,{ref:n,className:fe("fixed inset-0 z-50 bg-black/50 backdrop-blur-sm",e),...t}));C5.displayName=b5.displayName;const zp=g.forwardRef(({className:e,children:t,...n},r)=>h.jsxs(lie,{children:[h.jsx(C5,{}),h.jsxs(w5,{ref:r,className:fe("fixed left-1/2 top-1/2 z-50 grid w-full max-w-lg -translate-x-1/2 -translate-y-1/2","gap-4 rounded-lg border border-border bg-elevated p-6 shadow-lg",e),...n,children:[t,h.jsxs(aie,{className:"absolute right-4 top-4 rounded-sm opacity-70 transition-opacity hover:opacity-100 focus:outline-none focus:ring-2 focus:ring-accent",children:[h.jsx(Dr,{className:"h-4 w-4"}),h.jsx("span",{className:"sr-only",children:"Close"})]})]})]}));zp.displayName=w5.displayName;const $p=({className:e,...t})=>h.jsx("div",{className:fe("flex flex-col space-y-1.5 text-left",e),...t});$p.displayName="DialogHeader";const u1=({className:e,...t})=>h.jsx("div",{className:fe("flex flex-row justify-end gap-2",e),...t});u1.displayName="DialogFooter";const Fp=g.forwardRef(({className:e,...t},n)=>h.jsx(S5,{ref:n,className:fe("text-lg font-semibold leading-none text-text-100",e),...t}));Fp.displayName=S5.displayName;const E5=g.forwardRef(({className:e,...t},n)=>h.jsx(k5,{ref:n,className:fe("text-sm text-text-300",e),...t}));E5.displayName=k5.displayName;function cie({persona:e,open:t,onClose:n,onDelete:r,embedded:i,onLoadPersonality:s,onSavePersonality:o,onDirtyChange:a,initialPersonality:l,onShareCapability:c,readOnly:u=!1,larkBot:d}){const[f,p]=g.useState(!1),m=b=>{p(b),a==null||a(b)},v=()=>{f&&!window.confirm("修改未保存,确定关闭?")||n()};return t?h.jsxs(h.Fragment,{children:[!i&&h.jsx("div",{className:"absolute inset-0 z-30 bg-black/30",onClick:v,"aria-hidden":"true"}),h.jsxs("aside",{className:i?"flex h-full w-full flex-col bg-bg-0":"absolute right-0 top-0 z-40 flex h-full w-[420px] flex-col bg-bg-0 border-l border-border shadow-xl","data-testid":"persona-settings-drawer",children:[h.jsxs("header",{className:"flex items-center justify-between border-b border-border px-4 py-3 shrink-0",children:[h.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[h.jsx(p$,{className:"h-4 w-4 text-text-300"}),h.jsx("span",{className:"text-[13px] font-medium text-text-100 truncate",children:"Persona 设置"})]}),h.jsx("button",{type:"button",onClick:v,"aria-label":"关闭",className:"rounded-sm p-1.5 text-text-400 hover:bg-bg-200 hover:text-text-100",children:h.jsx(Dr,{className:"h-4 w-4"})})]}),h.jsxs("div",{className:"flex-1 overflow-y-auto p-6 flex flex-col gap-4",children:[h.jsxs("header",{className:"flex items-start justify-between gap-3",children:[h.jsxs("div",{className:"flex flex-col gap-0.5 min-w-0",children:[h.jsxs("div",{className:"flex items-center gap-2",children:[h.jsx("h2",{className:"text-lg font-semibold text-text-100 truncate",children:e.label}),e.public?h.jsxs("span",{className:"inline-flex items-center gap-1 rounded-sm bg-bg-200 px-1.5 py-0.5 text-[10px] text-text-200",children:[h.jsx(Dz,{className:"h-3 w-3"})," 公开"]}):h.jsxs("span",{className:"inline-flex items-center gap-1 rounded-sm bg-error-dim px-1.5 py-0.5 text-[10px] text-error",children:[h.jsx(Lz,{className:"h-3 w-3"})," 已关闭"]})]}),h.jsx("span",{className:"font-mono text-[11px] text-text-400 truncate","data-testid":"persona-id-subtitle",children:e.personaId})]}),h.jsxs("div",{className:"flex items-center gap-1",children:[c?h.jsxs("button",{type:"button",onClick:c,"aria-label":"分享给他人",title:"分享给他人",className:"inline-flex items-center gap-1 rounded-sm px-2 py-1.5 text-xs text-text-200 hover:bg-bg-200 hover:text-text-100",children:[h.jsx($x,{className:"h-3.5 w-3.5"}),"分享"]}):null,r?h.jsx("button",{type:"button",onClick:r,"aria-label":"删除 persona",className:"rounded-sm p-1.5 text-text-400 hover:bg-bg-200 hover:text-error",children:h.jsx(Fx,{className:"h-4 w-4"})}):null]})]}),h.jsx("hr",{className:"border-border"}),d?h.jsxs(h.Fragment,{children:[h.jsx(fie,{...d}),h.jsx("hr",{className:"border-border"})]}):null,s?h.jsxs(h.Fragment,{children:[h.jsx(vie,{onLoad:s,...o?{onSave:o}:{},onDirtyChange:m,initialPersonality:l,readOnly:u}),h.jsx("hr",{className:"border-border"})]}):null,h.jsx(pie,{settings:e.sandboxSettings??null}),h.jsx("hr",{className:"border-border"}),h.jsx(mie,{skills:e.skills??[]}),h.jsx("hr",{className:"border-border"}),h.jsx(gie,{plugins:e.plugins??[]})]})]})]}):null}function uie({qrUrl:e,busy:t,onCancel:n}){const[r,i]=g.useState(null);return g.useEffect(()=>{let s=!1;return Au.toDataURL(e,{width:240,margin:1}).then(o=>{s||i(o)}).catch(()=>{s||i(null)}),()=>{s=!0}},[e]),h.jsx(c1,{open:!0,onOpenChange:s=>s||n==null?void 0:n(),children:h.jsxs(zp,{className:"max-w-xs","data-testid":"lark-bot-qr-dialog",onInteractOutside:s=>s.preventDefault(),onEscapeKeyDown:s=>s.preventDefault(),children:[h.jsx($p,{children:h.jsx(Fp,{children:"扫码关联飞书 Bot"})}),h.jsxs("div",{className:"flex flex-col items-center gap-2",children:[r?h.jsx("img",{src:r,alt:"飞书扫码创建应用二维码",className:"h-60 w-60 rounded bg-white p-2","data-testid":"lark-bot-qr-img"}):h.jsx("div",{className:"flex h-60 w-60 items-center justify-center text-[12px] text-text-400",children:"二维码生成中…"}),h.jsx("span",{className:"text-center text-[12px] text-text-300",children:"用手机飞书扫码,按页面提示创建应用。确认后自动完成关联。"}),n?h.jsx("button",{type:"button",disabled:t,onClick:n,className:"rounded border border-border px-3 py-1.5 text-[12px] text-text-300 hover:bg-bg-200 disabled:opacity-50","data-testid":"lark-bot-provision-cancel",children:"取消"}):null]})]})})}const die={expired:"二维码已过期,请重新扫码。",cancelled:"已取消。",access_denied:"你在飞书上取消了本次授权。",lark_protocol_error:"飞书返回了未预期的响应,请重试。",cloud_unreachable:"云端暂时不可达,请稍后重试。",internal_error:"关联失败。若飞书中已创建应用,可在开发者后台删除后重试,或改用手动绑定填入其凭证。"},hie=new Set(["expired","access_denied","lark_protocol_error","cloud_unreachable","internal_error"]);function fie({status:e,onProvision:t,onCancelProvision:n,onBindManual:r,onUnbind:i}){const[s,o]=g.useState(!1),[a,l]=g.useState(null),[c,u]=g.useState(""),[d,f]=g.useState(""),[p,m]=g.useState(null),v=C=>{C&&(o(!0),l(null),C().catch(k=>l(k instanceof Error?k.message:String(k))).finally(()=>o(!1)))},b=()=>{m(null),v(t)},_=!s&&!!c&&!!d,x=()=>{!_||!r||v(()=>r({appId:c,appSecret:d}))},y=ku(x),w=h.jsxs("div",{className:"flex items-center gap-1.5",children:[h.jsx(np,{className:"h-3.5 w-3.5 text-text-400","aria-hidden":!0}),h.jsx("span",{className:"text-[13px] font-medium text-text-100",children:"飞书 Bot"})]});return e?h.jsxs("section",{className:"flex flex-col gap-1.5","data-testid":"lark-bot-section",children:[w,e.state==="unbound"||e.state==="provisioning"?h.jsxs(h.Fragment,{children:[h.jsx("span",{className:"text-[11px] text-text-400",children:"关联一个飞书 bot 后,这个 persona 就是它:拉进群后群成员 @ 它提问、或直接私聊它, 推理跑在你本机,回复自动发回去。"}),t?h.jsx("button",{type:"button",disabled:s||e.state==="provisioning",onClick:b,className:"self-start rounded border border-border bg-bg-200 px-3 py-1.5 text-[12px] font-medium text-text-100 hover:bg-bg-300 disabled:opacity-50","data-testid":"lark-bot-provision",children:e.state==="provisioning"?"等待扫码…":"扫码关联飞书 Bot"}):null,e.state==="unbound"&&e.errorReason&&!p?h.jsxs("div",{className:"flex flex-col gap-1.5 rounded border border-error bg-error-dim px-2 py-1.5","data-testid":"lark-bot-provision-error",children:[h.jsx("span",{className:"text-[11px] text-error",children:die[e.errorReason]}),h.jsxs("div",{className:"flex gap-1.5",children:[hie.has(e.errorReason)&&t?h.jsx("button",{type:"button",disabled:s,onClick:b,className:"rounded border border-border px-2 py-1 text-[11px] text-text-100 hover:bg-bg-200 disabled:opacity-50","data-testid":"lark-bot-provision-retry",children:"重新扫码"}):null,h.jsx("button",{type:"button",onClick:()=>m(e.errorReason??null),className:"rounded border border-border px-2 py-1 text-[11px] text-text-300 hover:bg-bg-200","data-testid":"lark-bot-provision-error-dismiss",children:"知道了"})]})]}):null,e.state==="provisioning"&&e.qrUrl?h.jsx(uie,{qrUrl:e.qrUrl,busy:s,onCancel:n?()=>v(n):void 0}):null,r&&e.state==="unbound"?h.jsxs("details",{"data-testid":"lark-bot-manual-details",children:[h.jsx("summary",{className:"cursor-pointer text-[11px] text-text-400 hover:text-text-300",children:"已有飞书应用?手动填入凭证"}),h.jsxs("div",{className:"mt-1.5 flex flex-col gap-1.5","data-testid":"lark-bot-manual-form",children:[h.jsx("span",{className:"text-[11px] text-text-400",children:"先在飞书开放平台(open.feishu.cn)创建企业自建应用并启用机器人能力,再填入凭证:"}),h.jsx("input",{value:c,onChange:C=>u(C.target.value),...y,placeholder:"App ID(cli_ 开头)",className:"rounded border border-border bg-bg-100 px-2 py-1 text-[12px] text-text-200","data-testid":"lark-bot-manual-appid"}),h.jsx("input",{value:d,onChange:C=>f(C.target.value),...y,type:"password",placeholder:"App Secret",className:"rounded border border-border bg-bg-100 px-2 py-1 text-[12px] text-text-200","data-testid":"lark-bot-manual-secret"}),h.jsx("button",{type:"button",disabled:!_,onClick:x,className:"self-start rounded border border-border px-3 py-1.5 text-[12px] text-text-100 hover:bg-bg-200 disabled:opacity-50","data-testid":"lark-bot-manual-submit",children:s?"绑定中…":"绑定"})]})]}):null]}):null,e.state==="bound"||e.state==="broken"?h.jsxs("div",{className:"flex flex-col gap-1.5",children:[e.state==="broken"?h.jsxs("div",{className:"rounded border border-error bg-error-dim px-2 py-1.5 text-[11px] text-error","data-testid":"lark-bot-broken",children:["Bot 凭证失效:",e.brokenReason??"未知原因","。请解绑后重新填入有效凭证绑定。"]}):null,h.jsxs("div",{className:"flex items-center gap-2 text-[12px] text-text-200",children:[h.jsx("span",{className:"font-medium text-text-100",children:e.botName??"未命名 bot"}),e.appId?h.jsx("span",{className:"text-[11px] text-text-400",children:e.appId}):null]}),h.jsx("span",{className:"text-[11px] text-text-400",children:"把 bot 拉进任意飞书群,群成员 @ 它即可提问。"}),e.groups.length>0?h.jsx("ul",{className:"flex flex-col gap-0.5","data-testid":"lark-bot-groups",children:e.groups.map(C=>h.jsxs("li",{className:"text-[11px] text-text-300 truncate",children:["· ",C.chatName??C.chatId]},C.chatId))}):h.jsx("span",{className:"text-[11px] text-text-400","data-testid":"lark-bot-groups-empty",children:"还没有服务中的群。"}),i?h.jsx("button",{type:"button",disabled:s,onClick:()=>v(i),className:"self-start rounded border border-border px-3 py-1.5 text-[12px] text-error hover:bg-error-dim disabled:opacity-50","data-testid":"lark-bot-unbind",children:"解绑"}):null]}):null,a?h.jsx("div",{className:"rounded border border-error bg-error-dim px-2 py-1.5 text-[11px] text-error","data-testid":"lark-bot-error",children:a}):null]}):h.jsxs("section",{className:"flex flex-col gap-1.5","data-testid":"lark-bot-section",children:[w,h.jsx("span",{className:"text-[11px] text-text-400",children:"状态加载中…"})]})}function pie({settings:e}){var t,n,r,i,s,o,a,l,c,u,d,f,p;return h.jsxs("section",{className:"flex flex-col gap-2","data-testid":"persona-sandbox-setting-section",children:[h.jsxs("header",{className:"flex flex-col gap-0.5",children:[h.jsx("span",{className:"text-[13px] font-medium text-text-100",children:"Sandbox Setting"}),h.jsx("span",{className:"text-[11px] text-text-400",children:"约束此 persona 的沙箱权限(只读,需通过文件修改)。"})]}),e==null?h.jsx("span",{className:"text-[12px] text-text-300","data-testid":"persona-sandbox-setting-empty",children:"暂无 sandbox 配置"}):h.jsxs("div",{className:"flex flex-col gap-1.5 rounded-md border border-border bg-bg-100 px-3 py-2",children:[h.jsx(jd,{label:"权限默认模式",value:((t=e.permissions)==null?void 0:t.defaultMode)??"—"}),h.jsx(jd,{label:"沙箱启用",value:Tg((n=e.sandbox)==null?void 0:n.enabled)}),h.jsx(jd,{label:"沙箱内自动放行 Bash",value:Tg((r=e.sandbox)==null?void 0:r.autoAllowBashIfSandboxed)}),h.jsx(jd,{label:"允许非沙箱命令",value:Tg((i=e.sandbox)==null?void 0:i.allowUnsandboxedCommands)}),h.jsxs("div",{className:"mt-1 flex flex-col gap-1.5 border-t border-border pt-1.5",children:[h.jsx(Hl,{label:"沙箱外命令",paths:(s=e.sandbox)==null?void 0:s.excludedCommands}),h.jsx(Hl,{label:"允许读取",paths:(a=(o=e.sandbox)==null?void 0:o.filesystem)==null?void 0:a.allowRead}),h.jsx(Hl,{label:"拒绝读取",paths:(c=(l=e.sandbox)==null?void 0:l.filesystem)==null?void 0:c.denyRead}),h.jsx(Hl,{label:"允许写入",paths:(d=(u=e.sandbox)==null?void 0:u.filesystem)==null?void 0:d.allowWrite}),h.jsx(Hl,{label:"拒绝写入",paths:(p=(f=e.sandbox)==null?void 0:f.filesystem)==null?void 0:p.denyWrite})]})]})]})}function Tg(e){return e===!0?"是":e===!1?"否":"—"}function jd({label:e,value:t}){return h.jsxs("div",{className:"flex items-center justify-between gap-3 text-[12px]",children:[h.jsx("span",{className:"text-text-300",children:e}),h.jsx("span",{className:"font-mono text-text-100",children:t})]})}function Hl({label:e,paths:t}){const n=!t||t.length===0;return h.jsxs("div",{className:"flex flex-col gap-1",children:[h.jsx("span",{className:"text-[11px] text-text-300",children:e}),n?h.jsx("span",{className:"text-[11px] text-text-400",children:"—"}):h.jsx("div",{className:"flex flex-wrap gap-1",children:t.map((r,i)=>h.jsx("span",{className:"rounded-sm border border-border bg-bg-0 px-1.5 py-0.5 font-mono text-[11px] text-text-200",children:r},`${e}-${i}-${r}`))})]})}function mie({skills:e}){return h.jsxs("section",{className:"flex flex-col gap-2","data-testid":"persona-skills-section",children:[h.jsxs("header",{className:"flex flex-col gap-0.5",children:[h.jsxs("div",{className:"flex items-center gap-2",children:[h.jsx("span",{className:"text-[13px] font-medium text-text-100",children:"Persona Skills"}),h.jsx("span",{className:"rounded-sm border border-border px-1.5 py-0.5 text-[10px] text-text-300",children:e.length})]}),h.jsxs("span",{className:"text-[11px] text-text-400",children:["此 persona 私有 skills(来自"," ",h.jsx("code",{className:"font-mono",children:"<persona-dir>/.claude/skills/"}),")。"]})]}),e.length===0?h.jsx("span",{className:"text-[12px] text-text-300","data-testid":"persona-skills-empty",children:"暂无 skills"}):h.jsx("ul",{className:"flex flex-col divide-y divide-border rounded-md border border-border bg-bg-100",children:e.map(t=>h.jsxs("li",{className:"flex flex-col gap-0.5 px-3 py-2","data-testid":"persona-skill-row",children:[h.jsx("span",{className:"font-mono text-[13px] text-text-100",children:t.name}),t.description?h.jsx("span",{className:"text-[12px] text-text-300",children:t.description}):h.jsx("span",{className:"text-[11px] text-text-400 italic",children:"无描述"})]},t.name))})]})}function gie({plugins:e}){return h.jsxs("section",{className:"flex flex-col gap-2","data-testid":"persona-plugins-section",children:[h.jsxs("header",{className:"flex flex-col gap-0.5",children:[h.jsxs("div",{className:"flex items-center gap-2",children:[h.jsx("span",{className:"text-[13px] font-medium text-text-100",children:"Enabled Plugins"}),h.jsx("span",{className:"rounded-sm border border-border px-1.5 py-0.5 text-[10px] text-text-300",children:e.length})]}),h.jsxs("span",{className:"text-[11px] text-text-400",children:["此 persona 已启用的插件(来自"," ",h.jsx("code",{className:"font-mono",children:"<persona-dir>/.claude/settings.json"})," ","的 ",h.jsx("code",{className:"font-mono",children:"enabledPlugins"}),")。"]})]}),e.length===0?h.jsx("span",{className:"text-[12px] text-text-300","data-testid":"persona-plugins-empty",children:"暂无启用插件"}):h.jsx("ul",{className:"flex flex-col divide-y divide-border rounded-md border border-border bg-bg-100",children:e.map(t=>h.jsx("li",{className:"flex flex-col gap-0.5 px-3 py-2","data-testid":"persona-plugin-row",children:h.jsx("span",{className:"font-mono text-[13px] text-text-100",children:t.id})},t.id))})]})}function vie({onLoad:e,onSave:t,onDirtyChange:n,initialPersonality:r,readOnly:i=!1}){const s=r!==void 0,[o,a]=g.useState(s),[l,c]=g.useState(s?r:""),[u,d]=g.useState(s?r:""),[f,p]=g.useState(null),[m,v]=g.useState(!1),[b,_]=g.useState(null),x=Ze.useRef(e),y=Ze.useRef(t),w=Ze.useRef(n);Ze.useEffect(()=>{x.current=e,y.current=t,w.current=n});const C=Ze.useCallback(()=>{a(!1),p(null),x.current().then(P=>{c(P),d(P),a(!0)}).catch(P=>{p(P instanceof Error?P.message:String(P))})},[]);Ze.useEffect(()=>{s||C()},[s,C]);const k=!i&&o&&u!==l;Ze.useEffect(()=>{i||w.current(k)},[k,i]);const T=()=>{y.current&&(v(!0),_(null),y.current(u).then(()=>{c(u),v(!1)}).catch(P=>{_(P instanceof Error?P.message:String(P)),v(!1)}))},N=()=>{d(l),_(null)},z=ku(()=>{!k||m||T()},()=>{!k||m||N()});return h.jsxs("section",{className:"flex flex-col gap-2","data-testid":"persona-personality-section",children:[h.jsx("span",{className:"text-[12px] font-medium text-text-200",children:"人格 (Personality)"}),f?h.jsxs("div",{"data-testid":"persona-personality-load-error",className:"rounded-md border border-error bg-error-dim px-3 py-2 text-[12px] text-error flex items-center justify-between gap-2",children:[h.jsxs("span",{children:["加载失败:",f]}),h.jsx("button",{type:"button",onClick:C,className:"rounded-sm border border-error px-2 py-0.5 text-[11px] hover:bg-error/10",children:"重试"})]}):null,b?h.jsxs("div",{"data-testid":"persona-personality-save-error",className:"rounded-md border border-error bg-error-dim px-3 py-2 text-[12px] text-error",children:["保存失败:",b]}):null,h.jsx("textarea",{"data-testid":"persona-personality-textarea",value:u,onChange:P=>d(P.target.value),...z,readOnly:i,disabled:!i&&(!o||m),placeholder:o?"":"加载中…",rows:8,className:"min-h-[8rem] max-h-[18rem] resize-y rounded-md border border-border bg-bg-100 px-2 py-1.5 font-mono text-[11px] text-text-100 disabled:opacity-60"}),!i&&h.jsxs("p",{className:"text-[10px] text-text-400",children:["写入到 ",h.jsx("code",{className:"font-mono",children:"<persona-dir>/CLAUDE.md"}),"。 修改只对新启动的 sub-session 生效。"]}),o&&k?h.jsxs("div",{className:"flex justify-end gap-2",children:[h.jsx("button",{type:"button",onClick:N,disabled:m,className:"rounded-sm border border-border px-2 py-1 text-[12px] text-text-200 hover:bg-bg-200 disabled:opacity-60",children:"放弃"}),h.jsx("button",{type:"button",onClick:T,disabled:m,"data-testid":"persona-personality-save-btn",className:"rounded-sm bg-accent-dim px-2 py-1 text-[12px] text-text-100 hover:opacity-90 disabled:opacity-60",children:m?"保存中…":"保存"})]}):null]})}const _ie={state:"unbound",groups:[]};function xie(e,t){const[n,r]=g.useState(null);g.useEffect(()=>{if(!e)return;let l=!1;r(null);const c=async()=>{try{const f=await e.request("larkBot:status",{personaId:t});l||r(f)}catch{l||r(_ie)}};c();const u=e.on("larkBot:state",f=>{const p=f;if(p.personaId!==t)return;const{personaId:m,...v}=p;r(v)}),d=e.on("daemon:connected",()=>{c()});return()=>{l=!0,u(),d()}},[e,t]);const i=g.useCallback(async()=>{e&&await e.request("larkBot:provision",{personaId:t})},[e,t]),s=g.useCallback(async()=>{e&&await e.request("larkBot:provisionCancel",{personaId:t})},[e,t]),o=g.useCallback(async l=>{e&&await e.request("larkBot:bindManual",{personaId:t,...l})},[e,t]),a=g.useCallback(async()=>{e&&await e.request("larkBot:unbind",{personaId:t})},[e,t]);return{status:n,provision:i,cancelProvision:s,bindManual:o,unbind:a}}function yie(e,t="owner"){const{persona:n}=jN(e),r=OB(e),i=BB(),s=zB(),{httpBaseUrl:o}=tp(),a=ci(),l=xie(t==="guest"?null:a,e),{capabilities:c}=e1((n==null?void 0:n.tool)??"claude"),u=g.useMemo(()=>!(n!=null&&n.public)||!o||/^https?:\/\/(127\.0\.0\.1|localhost|0\.0\.0\.0|\[?::1\]?)([:/]|$)/i.test(o)?null:`${o}/s/${e}`,[n==null?void 0:n.public,o,e]),d=g.useCallback((y,w)=>{i(e,w).catch(C=>{Ae("persona",`${y} failed`,C)})},[i,e]),f=g.useCallback(y=>d("togglePublic",{public:y}),[d]),p=g.useCallback(y=>d("changeTool",{tool:y}),[d]),m=g.useCallback(y=>d("changeModel",{model:y}),[d]),v=g.useCallback(y=>d("changeEffort",{effort:y}),[d]),b=g.useCallback(()=>!n||!confirm(`删除 persona "${n.label}"?`)?!1:(s(e).catch(y=>{Ae("persona","delete failed",y)}),!0),[n,s,e]),_=g.useCallback(async()=>r.loaded?r.personality:(await r.refresh()).personality,[r]),x=g.useCallback(async y=>{await i(e,{personality:y}),await r.refresh()},[i,e,r]);return{persona:n,detail:r,models:(c==null?void 0:c.models)??[],configSchema:(c==null?void 0:c.configSchema)??[],larkBot:l,guestShareUrl:u,changeTool:p,changeModel:m,changeEffort:v,togglePublic:f,remove:b,loadPersonality:_,savePersonality:x}}function bie({personaId:e,open:t,onClose:n,api:r,embedded:i,onDirtyChange:s,onShareCapability:o,viewerRole:a="owner"}){const l=yie(e,a),{persona:c,detail:u}=l,d=g.useCallback(()=>{l.remove()&&n()},[l,n]);if(!c)return null;const f=a==="guest";return h.jsx(cie,{embedded:i,persona:{...c,skills:u.skills,plugins:u.plugins,sandboxSettings:u.sandboxSettings},open:t,onClose:n,onLoadPersonality:l.loadPersonality,onDirtyChange:s,readOnly:f,...f?{}:{onTogglePublic:l.togglePublic,guestShareUrl:l.guestShareUrl,onChangeTool:l.changeTool,onChangeModel:l.changeModel,onChangeEffort:l.changeEffort,models:l.models,configSchema:l.configSchema,onDelete:d,onSavePersonality:l.savePersonality,larkBot:{status:l.larkBot.status,onProvision:l.larkBot.provision,onCancelProvision:l.larkBot.cancelProvision,onBindManual:l.larkBot.bindManual,onUnbind:l.larkBot.unbind},...o?{onShareCapability:o}:{}}})}function wie(e){try{const t=new URL(e);return t.protocol==="ws:"?t.protocol="http:":t.protocol==="wss:"&&(t.protocol="https:"),`${t.protocol}//${t.host}`}catch{return e}}function Sie(e,t){try{const n=new URL(e),r=new URL(t);return n.protocol=r.protocol,n.host=r.host,n.toString()}catch{return e}}async function d1(e,t,n,r,i){const s=await e.attachmentSignUrl({sessionId:n,relPath:r,...i!==void 0?{ttlSeconds:i}:{}});return Sie(s.url,wie(t.url))}async function zC(e,t,n,r,i=60,s){const o=window.open("about:blank","_blank");try{s&&await s();const a=await d1(e,t,n,r,i);o?o.location.href=a:window.open(a,"_blank")}catch(a){throw o&&o.close(),a}}async function kie(e){var t;try{if((t=navigator.clipboard)!=null&&t.writeText)return await navigator.clipboard.writeText(e),!0}catch{}try{const n=document.createElement("textarea");n.value=e,n.style.position="fixed",n.style.left="-9999px",n.style.top="0",n.setAttribute("readonly",""),document.body.appendChild(n),n.select();const r=document.execCommand("copy");return document.body.removeChild(n),r}catch{return!1}}const Cie={...So,h1:({node:e,...t})=>h.jsx("h1",{...t,className:"mt-4 mb-3 text-[18px] font-semibold leading-tight text-text-100"}),h2:({node:e,...t})=>h.jsx("h2",{...t,className:"mt-4 mb-2 text-[16px] font-semibold leading-tight text-text-100"}),h3:({node:e,...t})=>h.jsx("h3",{...t,className:"mt-3 mb-2 text-[14px] font-semibold leading-tight text-text-100"}),h4:({node:e,...t})=>h.jsx("h4",{...t,className:"mt-3 mb-1 text-[13px] font-semibold text-text-100"}),h5:({node:e,...t})=>h.jsx("h5",{...t,className:"mt-2 mb-1 text-[12px] font-semibold text-text-100"}),h6:({node:e,...t})=>h.jsx("h6",{...t,className:"mt-2 mb-1 text-[12px] font-semibold text-text-300"}),p:({node:e,...t})=>h.jsx("p",{...t,className:"my-2 leading-relaxed"}),ul:({node:e,...t})=>h.jsx("ul",{...t,className:"my-2 list-disc space-y-1 pl-5"}),ol:({node:e,...t})=>h.jsx("ol",{...t,className:"my-2 list-decimal space-y-1 pl-5"}),li:({node:e,...t})=>h.jsx("li",{...t,className:"leading-relaxed"}),blockquote:({node:e,...t})=>h.jsx("blockquote",{...t,className:"my-2 border-l-2 border-border pl-3 italic text-text-300"}),code:({node:e,className:t,children:n,...r})=>t?h.jsx("code",{...r,className:`${t} font-mono text-[12px]`,children:n}):h.jsx("code",{...r,className:"rounded bg-bg-50 px-1 py-0.5 font-mono text-[12px] text-text-100",children:n}),pre:({node:e,...t})=>h.jsx("pre",{...t,className:"my-2 overflow-auto rounded border border-border bg-bg-0 p-3 text-[12px] font-mono text-text-100"}),hr:({node:e,...t})=>h.jsx("hr",{...t,className:"my-3 border-border"}),table:({node:e,...t})=>h.jsx("table",{...t,className:"my-2 w-full border-collapse text-[12px]"}),thead:({node:e,...t})=>h.jsx("thead",{...t,className:"bg-bg-50"}),th:({node:e,...t})=>h.jsx("th",{...t,className:"border border-border px-2 py-1 text-left font-semibold"}),td:({node:e,...t})=>h.jsx("td",{...t,className:"border border-border px-2 py-1"}),strong:({node:e,...t})=>h.jsx("strong",{...t,className:"font-semibold text-text-100"}),em:({node:e,...t})=>h.jsx("em",{...t,className:"italic"})};function Eie(e){const t=e.split("/");return t[t.length-1]||e}function T5({relPath:e,loadMarkdown:t,headerRight:n,showTitleBar:r=!1}){const[i,s]=g.useState(null),[o,a]=g.useState(null),[l,c]=g.useState(!1);return g.useEffect(()=>{if(!e)return;let u=!1;return c(!0),a(null),s(null),(async()=>{try{const d=await t(e);if(u)return;s(d)}catch(d){if(u)return;a(d.message||String(d))}finally{u||c(!1)}})(),()=>{u=!0}},[e,t]),h.jsxs("div",{className:"flex flex-col h-full",children:[r&&e?h.jsxs("div",{className:"flex items-center justify-between border-b border-border px-3 py-2",children:[h.jsx("div",{"data-testid":"md-preview-title",className:"truncate text-[13px] font-medium text-text-100",title:e,children:Eie(e)}),h.jsx("div",{className:"flex items-center gap-1",children:n})]}):null,h.jsx("div",{className:"flex-1 overflow-auto px-4 py-3 text-[13px] text-text-100",children:l?h.jsx("div",{"data-testid":"md-preview-loading",className:"text-text-400",children:"Loading…"}):o?h.jsx("div",{"data-testid":"md-preview-error",className:"text-destructive whitespace-pre-wrap",children:o}):i!==null?h.jsx("div",{"data-testid":"md-preview-content",className:"max-w-none",children:h.jsx(tu,{remarkPlugins:[ru],components:Cie,children:i})}):null})]})}function Tie({open:e,onOpenChange:t,relPath:n,loadMarkdown:r,onShare:i}){return e?h.jsx("div",{"data-testid":"md-preview-drawer",className:"fixed inset-y-0 right-0 z-50 flex w-1/2 max-w-[900px] flex-col border-l border-border bg-elevated shadow-2xl",children:h.jsx(T5,{relPath:n,loadMarkdown:r,showTitleBar:!0,headerRight:h.jsxs(h.Fragment,{children:[i?h.jsx("button",{type:"button","data-testid":"md-preview-share","aria-label":"Share rendered preview link",onClick:i,className:"inline-flex h-6 w-6 items-center justify-center rounded text-text-400 hover:bg-bg-50 hover:text-text-200",children:h.jsx(Fz,{className:"h-4 w-4"})}):null,h.jsx("button",{type:"button","aria-label":"Close preview",onClick:()=>t(!1),className:"inline-flex h-6 w-6 items-center justify-center rounded text-text-400 hover:bg-bg-50 hover:text-text-200",children:h.jsx(Dr,{className:"h-4 w-4"})})]})})}):null}function Nie({left:e,right:t,stage:n,onExpand:r,onCollapse:i}){const s=n==="stopped",[o,a]=g.useState(!1);async function l(){if(!o){a(!0);try{await r()}catch{}finally{a(!1)}}}async function c(){if(!o){a(!0);try{await i()}catch{}finally{a(!1)}}}return h.jsxs("div",{className:"flex h-full w-full min-h-0","data-testid":"two-pane-layout",children:[h.jsxs("div",{className:"relative flex min-w-0 flex-1 flex-col","data-testid":"two-pane-left",children:[s&&h.jsx("button",{type:"button",disabled:o,className:"absolute right-14 top-2 z-10 rounded border border-border bg-elevated px-2 py-1 text-[12px] text-text-100 hover:bg-bg-200 disabled:opacity-50 disabled:cursor-not-allowed",onClick:l,children:o?"启动中…":"展开预览"}),e]}),!s&&h.jsxs("div",{className:"flex w-1/2 min-w-[320px] flex-col border-l border-bg-200","data-testid":"two-pane-right",children:[h.jsx("div",{className:"flex items-center justify-end gap-2 border-b border-bg-200 bg-bg-50 px-2 py-1",children:h.jsx("button",{type:"button",disabled:o,className:"rounded px-2 py-1 text-[12px] text-text-300 hover:bg-bg-100 disabled:opacity-50",onClick:c,children:"收起预览"})}),h.jsx("div",{className:"min-h-0 flex-1",children:t})]})]})}const Pie=6173,Iie=6182;function Rie({open:e,onOpenChange:t,projectName:n,currentPort:r,allUsedPorts:i,onUpdate:s}){const o=[];for(let v=Pie;v<=Iie;v++)(v===r||!i.includes(v))&&o.push(v);const[a,l]=g.useState(r),[c,u]=g.useState(!1),[d,f]=g.useState(null),p=a!==r&&!c;async function m(){if(p){u(!0),f(null);try{await s(a),t(!1)}catch(v){f((v==null?void 0:v.message)??String(v))}finally{u(!1)}}}return h.jsx(c1,{open:e,onOpenChange:t,children:h.jsxs(zp,{className:"max-w-md",children:[h.jsxs($p,{children:[h.jsxs(Fp,{children:["改端口 · ",n]}),h.jsxs(E5,{children:["手改通常发生在系统其他进程占了默认分配的端口、dev server 起不来时。 提交后 daemon 会停 dev server → 写 ",h.jsx("code",{className:"mx-1 rounded bg-bg-100 px-1 py-0.5 text-[11px]",children:".clawd-project.json"})," → 用新端口重新起。"]})]}),h.jsxs("div",{className:"flex flex-col gap-2",children:[h.jsx("label",{className:"text-xs text-text-400",children:"新端口(仅显示段内可用 + 当前端口)"}),h.jsx("select",{className:"h-9 rounded-md border border-border bg-elevated px-3 py-1 text-sm text-text-100 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent",value:a,onChange:v=>l(Number(v.target.value)),disabled:c,children:o.map(v=>h.jsxs("option",{value:v,children:[v,v===r?"(当前)":""]},v))}),o.length===1&&h.jsx("div",{className:"text-[11px] text-text-400",children:"端口段已全被其它 project 占用,没有可换的;先删一个 idle project 释放端口。"}),d&&h.jsx("div",{className:"rounded border border-destructive/30 bg-destructive/5 px-3 py-2 text-[12px] text-destructive",children:d})]}),h.jsxs(u1,{children:[h.jsx(ni,{variant:"ghost",onClick:()=>t(!1),disabled:c,children:"取消"}),h.jsx(ni,{onClick:m,disabled:!p,children:c?"应用中…":"应用新端口"})]})]})})}const $C=[{stage:"build",label:"构建"},{stage:"deploy",label:"部署到阿里云"},{stage:"verify",label:"验证可访问性"}];function Mie({currentStage:e,onCancel:t}){const n=$C.findIndex(r=>r.stage===e);return h.jsxs("div",{"data-testid":"publish-progress",className:"flex items-center gap-3 border-b border-bg-200 bg-bg-50 px-3 py-1.5 text-[12px]",children:[$C.map((r,i)=>{const s=i<n,o=i===n,a=s?"text-text-300":o?"text-text-200":"text-text-500/50";return h.jsxs("span",{className:`flex items-center gap-1 ${a}`,children:[s?h.jsx(rp,{className:"size-3.5"}):o?h.jsx(In,{className:"size-3.5 animate-spin"}):h.jsx(BN,{className:"size-3.5"}),h.jsxs("span",{children:[r.label,o?"中…":""]})]},r.stage)}),h.jsx("button",{type:"button",onClick:t,className:"ml-auto rounded px-2 py-0.5 text-[11px] text-text-400 hover:bg-bg-100 hover:text-text-200",children:"取消"})]})}const Aie={build:"构建",deploy:"部署",verify:"验证"};function Lie({stage:e,onRetry:t,onDismiss:n}){return h.jsxs("div",{"data-testid":"publish-interrupted-banner",className:"flex items-center gap-2 border-b border-yellow-400/40 bg-yellow-400/10 px-3 py-1.5 text-[12px]",children:[h.jsx(Kc,{className:"size-3.5 text-yellow-500"}),h.jsxs("span",{className:"text-text-200",children:["上次发布在 ",h.jsxs("strong",{className:"font-medium",children:["[",Aie[e],"]"]})," ","阶段被中断(daemon 重启)"]}),h.jsx("button",{type:"button",onClick:t,className:"ml-auto rounded bg-accent-main-100 px-2 py-0.5 text-[11px] text-oncolor-100 hover:opacity-90",children:"重新发布"}),h.jsx("button",{type:"button",onClick:n,className:"rounded px-2 py-0.5 text-[11px] text-text-400 hover:bg-bg-100 hover:text-text-200",children:"取消"})]})}const jie={build:"构建",deploy:"部署",verify:"验证",unknown:"未知"};function Die({stage:e,onFocusChat:t,onClose:n}){return h.jsxs("div",{"data-testid":"publish-failed-banner",className:"flex items-center gap-2 border-b border-destructive/40 bg-destructive/10 px-3 py-1.5 text-[12px]",children:[h.jsx(Ls,{className:"size-3.5 text-destructive"}),h.jsxs("button",{type:"button",onClick:t,className:"flex-1 text-left text-text-200 hover:underline",children:["发布失败:",h.jsxs("strong",{className:"font-medium",children:["[",jie[e],"]"]})," ","已通知 assistant 接管 →"]}),h.jsx("button",{type:"button",onClick:n,"aria-label":"关闭失败提示",className:"rounded p-0.5 text-text-400 hover:bg-bg-100 hover:text-text-200",children:h.jsx(Dr,{className:"size-3.5"})})]})}const FC={"install-pending":{label:"等装依赖…",step:"1/3"},installing:{label:"安装依赖中…(可能要几十秒到几分钟)",step:"2/3"},"starting-dev-server":{label:"启动 dev server…(等监听端口才挂 iframe)",step:"3/3"}};function Oie({project:e,previewHost:t,previewScheme:n,onUpdatePort:r,allUsedPorts:i,publishSlot:s,publishInFlightStage:o,onDismissPublishJob:a,onRetryPublish:l,publishFailureBanner:c,onPublishFailureBannerClose:u,onPublishFailureBannerFocusChat:d}){var _,x;const[f,p]=g.useState(!1);if(!e)return h.jsx("div",{className:"flex h-full w-full items-center justify-center p-6 text-center text-[13px] text-text-400",children:"未绑定 project"});const m=e.stage??(e.isRunning?"running":"stopped"),v=t?`${n}://${t}/preview/${e.port}/`:null,b=e.prodUrl??null;return h.jsxs("div",{className:"flex h-full w-full flex-col","data-testid":"preview-pane",children:[h.jsxs("header",{className:"flex items-center justify-between gap-2 border-b border-bg-200 bg-bg-50 px-3 py-1.5",children:[h.jsxs("div",{className:"flex items-center gap-2 text-[12px]",children:[h.jsx("span",{className:"font-medium text-text-200",children:e.name}),h.jsx("span",{className:"rounded bg-bg-100 px-1.5 py-0.5 text-[11px] text-text-400",children:e.port}),h.jsx("span",{className:"text-[10px] uppercase tracking-wider text-text-500",children:m==="running"?"dev":m})]}),h.jsxs("div",{className:"flex items-center gap-2",children:[b?h.jsxs("a",{href:b,target:"_blank",rel:"noopener noreferrer",title:`打开线上:${b}`,className:"inline-flex items-center gap-1 rounded border border-bg-200 px-2 py-0.5 text-[11px] text-text-300 hover:bg-bg-100",children:[h.jsx(qc,{className:"size-3"}),"打开线上"]}):null,s,h.jsxs(hy,{children:[h.jsx(fy,{asChild:!0,children:h.jsx("button",{type:"button","aria-label":"Project settings",className:"rounded p-1 text-text-400 hover:bg-bg-100",children:h.jsx(h$,{className:"size-3.5"})})}),h.jsxs(gp,{align:"end",children:[h.jsx(yi,{onSelect:()=>p(!0),children:"Update Port…"}),h.jsxs(yi,{disabled:!0,title:"rename not supported yet",onSelect:y=>y.preventDefault(),children:["Name: ",e.name]})]})]})]})]}),c?h.jsx(Die,{stage:c.stage,onClose:()=>u==null?void 0:u(),onFocusChat:()=>d==null?void 0:d()}):null,((_=e.publishJob)==null?void 0:_.status)==="in-flight"?h.jsx(Mie,{currentStage:o??e.publishJob.stage,onCancel:()=>void(a==null?void 0:a())}):null,((x=e.publishJob)==null?void 0:x.status)==="interrupted"?h.jsx(Lie,{stage:e.publishJob.stage,onRetry:()=>void(l==null?void 0:l()),onDismiss:()=>void(a==null?void 0:a())}):null,h.jsx("div",{className:"min-h-0 flex-1",children:m==="failed"?h.jsx(Bie,{reason:e.stageReason}):m==="stopped"?null:m==="running"?v?h.jsx("iframe",{"data-testid":"preview-iframe",className:"size-full border-0 bg-white",src:v,title:"preview"}):h.jsx(HC,{label:"等 tunnel 起来…",step:"-"}):h.jsx(HC,{label:FC[m].label,step:FC[m].step})}),h.jsx(Rie,{open:f,onOpenChange:p,projectName:e.name,currentPort:e.port,allUsedPorts:i,onUpdate:async y=>{await r(y)}})]})}function HC({label:e,step:t}){return h.jsxs("div",{"data-testid":"preview-spinner",className:"flex h-full w-full flex-col items-center justify-center gap-3 p-6 text-center",children:[h.jsx(In,{className:"size-6 animate-spin text-accent-main-100"}),h.jsx("div",{className:"text-[13px] text-text-200",children:e}),h.jsx("div",{className:"text-[11px] uppercase tracking-wider text-text-500",children:t}),h.jsx("div",{className:"mt-2 max-w-[300px] text-[11px] text-text-500",children:"左侧 chat 可看 assistant 详细进度"})]})}function Bie({reason:e}){return h.jsxs("div",{"data-testid":"preview-failed",className:"flex h-full w-full flex-col items-center justify-center gap-3 p-6 text-center",children:[h.jsx(Ls,{className:"size-6 text-destructive"}),h.jsx("div",{className:"text-[13px] text-text-200",children:"project 启动失败"}),h.jsx("div",{className:"max-w-[400px] text-[12px] text-text-400",children:e??"未知原因 —— 看 ~/.clawd/clawd.log 排查"}),h.jsx("div",{className:"mt-1 max-w-[300px] text-[11px] text-text-500",children:"左侧 chat 可看 assistant 详细进度 / 跟它说怎么修"})]})}function zie({error:e,onClose:t}){const[n,r]=g.useState(!1),i=async()=>{var a;if(!e)return;const s=e.message;let o=!1;try{(a=navigator.clipboard)!=null&&a.writeText&&(await navigator.clipboard.writeText(s),o=!0)}catch{o=!1}if(!o){const l=document.createElement("textarea");l.value=s,l.style.position="fixed",l.style.opacity="0",document.body.appendChild(l),l.select();try{document.execCommand("copy"),o=!0}catch{o=!1}finally{document.body.removeChild(l)}}o&&(r(!0),setTimeout(()=>r(!1),1500))};return h.jsx(c1,{open:!!e,onOpenChange:s=>{s||(r(!1),t())},children:h.jsxs(zp,{className:"max-w-lg",children:[h.jsx($p,{children:h.jsx(Fp,{children:(e==null?void 0:e.title)??"错误"})}),h.jsx("pre",{"data-testid":"rpc-error-message",className:"max-h-72 overflow-auto whitespace-pre-wrap break-words rounded border border-bg-200 bg-bg-50 px-3 py-2 text-[12px] text-text-200",children:(e==null?void 0:e.message)??""}),h.jsxs(u1,{children:[h.jsx(ni,{variant:"ghost",onClick:i,className:"gap-1.5",children:n?h.jsxs(h.Fragment,{children:[h.jsx(ul,{className:"size-3.5"}),"已复制"]}):h.jsxs(h.Fragment,{children:[h.jsx(ip,{className:"size-3.5"}),"复制"]})}),h.jsx(ni,{onClick:t,children:"关闭"})]})]})})}function $ie(e,t){for(const n of[e,t])if(n)try{const r=new URL(n),i=r.protocol==="https:"||r.protocol==="wss:"?"https":"http";return{host:r.host,scheme:i}}catch{}return{host:null,scheme:"https"}}const Fie={codex:"on-request",claude:"bypassPermissions"};function Hie(e){const t={cwd:e.cwd,permissionMode:e.sourcePermissionMode??Fie[e.sourceTool??"claude"]??"bypassPermissions",forkedFromSessionId:e.sourceSessionId};return e.sourceOwnerPersonaId&&(t.ownerPersonaId=e.sourceOwnerPersonaId),e.sourceTool&&(t.tool=e.sourceTool),e.sourceProjectPath&&(t.projectPath=e.sourceProjectPath),t}async function Uie(e,t,n,r={}){if(!t.toolSessionId)return null;const i=await e.sessionCreate({...Hie({cwd:t.cwd,sourceSessionId:t.sessionId,sourcePermissionMode:t.permissionMode,sourceOwnerPersonaId:t.ownerPersonaId,sourceTool:t.tool,sourceProjectPath:t.projectPath}),...r.ephemeral?{ephemeral:!0}:{}});try{const{forkedToolSessionId:s}=await e.sessionFork({cwd:t.cwd,toolSessionId:t.toolSessionId,messageUuid:n,targetCwd:i.cwd});await e.sessionResume(i.sessionId,s)}catch(s){throw e.sessionDelete(i.sessionId).catch(o=>Ae("quick-ask","fork rollback failed",o)),s}return i}async function Wie(e,t,n){return Uie(e,t,n,{ephemeral:!0})}function Dd(e){return e!=null&&e.ephemeral!==!1}async function Vie(e,t){return t.stillEphemeral?(await e.sessionUpdate(t.sessionId,{ephemeral:!1}),!0):!1}const qie=300;function Kie(e){return e&&typeof e=="object"&&"value"in e?e.value:e}function Gie(e,t){const n=bx(),[r,i]=g.useState(null),s=g.useRef(null);g.useEffect(()=>{let a=!1;return(async()=>{try{const l=await n.kv.get(e);if(a)return;const c=Kie(l);typeof c=="number"&&Number.isFinite(c)&&c>0?i(c):i(t)}catch{a||i(t)}})(),()=>{a=!0}},[n,e,t]);const o=g.useCallback(a=>{s.current&&clearTimeout(s.current),s.current=setTimeout(()=>{s.current=null,n.kv.set(e,a).catch(()=>{})},qie)},[n,e]);return g.useEffect(()=>()=>{s.current&&(clearTimeout(s.current),s.current=null)},[]),{initialSize:r??t,setSize:o,loading:r===null}}function Yie(){return{quickAsk:null,mds:[],active:null}}function Xie(e,t){return{...e,quickAsk:{sessionId:t.sessionId,ephemeral:!0},active:"quick-ask"}}function Qie(e,t){const n=e.mds.includes(t);return{...e,mds:n?e.mds:[...e.mds,t],active:{kind:"md",relPath:t}}}function Zie(e){if(!e.quickAsk)return e;const t=e.active==="quick-ask",n=e.mds[0],r=t?n?{kind:"md",relPath:n}:null:e.active;return{...e,quickAsk:null,active:r}}function Jie(e){return e.quickAsk?{...e,quickAsk:{...e.quickAsk,ephemeral:!1}}:e}function ese(e,t){const n=e.mds.indexOf(t);if(n<0)return e;const r=e.mds.filter(l=>l!==t);if(!(e.active!==null&&e.active!=="quick-ask"&&e.active.relPath===t))return{...e,mds:r};const s=r[n],o=n>0?r[n-1]:void 0;let a=null;return s?a={kind:"md",relPath:s}:o?a={kind:"md",relPath:o}:e.quickAsk&&(a="quick-ask"),{...e,mds:r,active:a}}function tse(e,t){return{...e,active:t}}function nse(e,t){return e===null||t===null||e==="quick-ask"||t==="quick-ask"?e===t:e.relPath===t.relPath}function N5(e){return e.quickAsk!==null||e.mds.length>0}function rse(e){return e.split("/").pop()||e}function ise({state:e,api:t,onSwitchTab:n,onCloseQuickAsk:r,onCloseMd:i,loadMarkdown:s,quickAskSession:o,onPromoteQuickAsk:a}){if(!N5(e))return null;const l=[];e.quickAsk&&l.push({id:"quick-ask",label:"问一下",title:"问一下",icon:h.jsx(d0,{className:"w-3.5 h-3.5"})});for(const c of e.mds)l.push({id:{kind:"md",relPath:c},label:rse(c),title:c,icon:h.jsx(Ro,{className:"w-3.5 h-3.5"})});return h.jsxs("div",{className:"flex flex-col h-full bg-bg-50/60 border-l border-border-strong",children:[h.jsx(rf,{delayDuration:200,skipDelayDuration:100,children:h.jsx("div",{className:["flex items-stretch h-9 border-b border-text-100/10 shrink-0 overflow-x-auto","[scrollbar-width:none] [-ms-overflow-style:none]","[&::-webkit-scrollbar]:hidden"].join(" "),role:"tablist",children:l.map(c=>{const u=nse(e.active,c.id),d=c.id==="quick-ask"?"quick-ask":`md:${c.id.relPath}`;return h.jsxs(yp,{children:[h.jsx(bp,{asChild:!0,children:h.jsxs("div",{role:"tab","aria-selected":u,"data-tab-title":c.title,onClick:()=>n(c.id),className:["group relative flex items-center gap-2 px-3 h-full cursor-pointer select-none","text-[12px] max-w-[180px] shrink-0 transition-colors duration-100",u?"text-text-100":"text-text-400 hover:text-text-100 hover:bg-text-100/[0.04]"].join(" "),children:[c.icon,h.jsx("span",{className:"truncate",children:c.label}),h.jsx("button",{type:"button","aria-label":`关闭 ${c.label}`,className:["ml-1 rounded p-0.5 shrink-0 transition-opacity","hover:bg-text-100/10",u?"opacity-70 hover:opacity-100":"opacity-0 group-hover:opacity-70"].join(" "),onClick:f=>{f.stopPropagation(),c.id==="quick-ask"?r():i(c.id.relPath)},children:h.jsx(Dr,{className:"w-3 h-3"})}),u?h.jsx("span",{"aria-hidden":"true",className:"absolute left-2 right-2 -bottom-px h-[2px] rounded-full bg-accent"}):null]})}),h.jsx(Cu,{side:"bottom",align:"start",className:"max-w-sm break-all",children:c.title})]},d)})})}),h.jsxs("div",{className:"flex-1 min-h-0 overflow-hidden relative",children:[e.quickAsk&&o?h.jsx("div",{className:"absolute inset-0",style:{display:e.active==="quick-ask"?"block":"none"},children:h.jsx(cse,{session:o,api:t,...a?{onPromoteQuickAsk:a}:{}})}):null,e.mds.map(c=>{const u=e.active!==null&&e.active!=="quick-ask"&&e.active.relPath===c;return h.jsx("div",{className:"absolute inset-0",style:{display:u?"block":"none"},children:h.jsx(T5,{relPath:c,loadMarkdown:s,showTitleBar:!1})},`md-body:${c}`)})]})]})}function sse({state:e,extras:t}){const{api:n,session:r}=t,i=ci(),[s,o]=g.useState(Yie()),a=g.useRef(s);a.current=s;const l=g.useRef(!1),c=g.useCallback(async C=>{const k=a.current.quickAsk,T=await Wie(n,r,C);if(T){if(l.current){n.sessionDelete(T.sessionId).catch(()=>{});return}Dd(k)&&n.sessionDelete(k.sessionId).catch(()=>{}),o(N=>Xie(N,{sessionId:T.sessionId}))}},[n,r]),u=g.useCallback(async C=>{const k=a.current.quickAsk,T=(k==null?void 0:k.sessionId)===C;try{await Vie(n,{sessionId:C,stillEphemeral:T&&Dd(k)})&&o(z=>Jie(z))}catch(N){Ae("quick-ask","promote failed",N)}},[n]),d=g.useCallback(C=>{o(k=>Qie(k,C))},[]),f=g.useCallback(C=>{o(k=>tse(k,C))},[]),p=g.useCallback(()=>{const C=a.current.quickAsk;Dd(C)&&n.sessionDelete(C.sessionId).catch(()=>{}),o(k=>Zie(k))},[n]),m=g.useCallback(C=>{o(k=>ese(k,C))},[]);g.useEffect(()=>()=>{l.current=!0;const C=a.current.quickAsk;Dd(C)&&n.sessionDelete(C.sessionId).catch(()=>{})},[]);const v=si("sessions")??[],b=s.quickAsk?v.find(C=>C.sessionId===s.quickAsk.sessionId)??{sessionId:s.quickAsk.sessionId,cwd:r.cwd,tool:r.tool}:null,_=g.useCallback(async C=>{const k=await d1(n,i,r.sessionId,C,60),T=await fetch(k);if(!T.ok)throw new Error(`fetch ${T.status} ${T.statusText}`);return T.text()},[n,i,r.sessionId]),x=h.jsx(h1,{state:e,extras:t,onQuickAskInternal:c,onPreviewMdInternal:d}),{initialSize:y,setSize:w}=Gie("chat-panel-right-slot-width",480);return h.jsxs(Sy,{orientation:"horizontal",className:"flex-1 flex min-w-0 min-h-0",children:[h.jsx(sf,{id:"chat",minSize:"400px",children:x}),N5(s)?h.jsxs(h.Fragment,{children:[h.jsx(TR,{className:"w-1 bg-text-100/10 hover:bg-text-100/25 transition-colors cursor-col-resize"}),h.jsx(sf,{id:"right-slot",defaultSize:`${y}px`,minSize:"360px",maxSize:"800px",onResize:C=>w(C.inPixels),children:h.jsx(ise,{state:s,api:n,onSwitchTab:f,onCloseQuickAsk:p,onCloseMd:m,loadMarkdown:_,quickAskSession:b,onPromoteQuickAsk:u})})]}):null]})}const ose={closeTrailing:!1},ase={closeTrailing:!0};function lse(e){return e?ose:ase}function cse({session:e,api:t,onPromoteQuickAsk:n}){const r=UA(e.sessionId);return h.jsx(h1,{state:r,extras:{session:e,api:t,...n?{onPromoteQuickAsk:n}:{}}})}function use({extras:e}){const t=UA(e.session.sessionId);if(e.session.appBuilderProject){const n=h.jsx(h1,{state:t,extras:e});return h.jsx(dse,{state:t,chat:n,extras:e})}return h.jsx(sse,{state:t,extras:e})}function dse({state:e,chat:t,extras:n}){var N;const r=si("daemon-info"),i=ci(),s=n.api,o=n.session,a=o.appBuilderProject,[l,c]=g.useState(null),u=g.useCallback(()=>{s.appBuilderGetProject(o.sessionId).then(z=>c(z.project)).catch(()=>c(null))},[s,o.sessionId]);g.useEffect(()=>{u()},[u]);const[d,f]=g.useState([]),p=g.useCallback(()=>{s.appBuilderListProjects().then(z=>f(z.projects)).catch(()=>f([]))},[s]);g.useEffect(()=>{p()},[p]),g.useEffect(()=>i.on("appBuilder:project-updated",P=>{const B=P;B!=null&&B.project&&(B.project.name===a&&c(B.project),f(R=>{const I=R.findIndex(L=>L.name===B.project.name);if(I<0)return[...R,B.project];const j=R.slice();return j[I]=B.project,j}))}),[i,a]);const{host:m,scheme:v}=$ie(i.url,r==null?void 0:r.tunnelUrl),[b,_]=g.useState(void 0),[x,y]=g.useState(null);g.useEffect(()=>{const z=i.on("appBuilder:publish-progress",B=>{const R=B;!R||R.name!==a||R.status==="started"&&_(R.stage)}),P=i.on("appBuilder:publish-failed",B=>{const R=B;!R||R.name!==a||(_(void 0),y({stage:R.stage}))});return()=>{z(),P()}},[i,a]),g.useEffect(()=>{_(void 0),y(null)},[a]);const[w,C]=g.useState(null),k=h.jsx("button",{type:"button",className:"rounded bg-accent-main-100 px-2.5 py-1 text-[12px] text-oncolor-100 hover:opacity-90 disabled:cursor-not-allowed disabled:opacity-50",disabled:((N=l==null?void 0:l.publishJob)==null?void 0:N.status)==="in-flight",onClick:async()=>{try{await s.appBuilderPublish(a)}catch(z){C({title:"发布请求失败",message:(z==null?void 0:z.message)??String(z)})}},children:"发布上线"}),T=(l==null?void 0:l.stage)??(l!=null&&l.isRunning?"running":"stopped");return h.jsxs(h.Fragment,{children:[h.jsx(Nie,{left:t,stage:T,onExpand:async()=>{await s.appBuilderStartDevServer(o.sessionId)},onCollapse:async()=>{await s.appBuilderStopDevServer(o.sessionId)},right:h.jsx(Oie,{project:l,previewHost:m,previewScheme:v,allUsedPorts:d.map(z=>z.port),onUpdatePort:async z=>{await s.appBuilderUpdateProjectPort(a,z),p()},publishSlot:k,publishInFlightStage:b,onDismissPublishJob:async()=>{try{await s.appBuilderDismissPublishJob(a)}catch(z){C({title:"取消发布失败",message:(z==null?void 0:z.message)??String(z)})}},onRetryPublish:async()=>{try{await s.appBuilderPublish(a)}catch(z){C({title:"重新发布失败",message:(z==null?void 0:z.message)??String(z)})}},publishFailureBanner:x,onPublishFailureBannerClose:()=>y(null),onPublishFailureBannerFocusChat:()=>{}})}),h.jsx(zie,{error:w,onClose:()=>C(null)})]})}function hse({headerMeta:e,connState:t,liveWorktreeRoot:n,onOpenConfig:r,variant:i="full",ephemeral:s,onPromote:o,lines:a,pendingPermissions:l,procAlive:c,rewindableUserMessageIds:u,onPermissionRespond:d,onPermissionInterrupt:f,onRewind:p,onFork:m,onQuickAsk:v,topSlot:b,realtimeQuestionAnswers:_,onSubmitQuestion:x,onCancelQuestion:y,liveQuestionToolUseIds:w,api:C,cwd:k,tool:T,sessionKey:N,onSend:z,awaitingUser:P,onAbort:B,onNewSession:R,onClearSession:I,configSlot:j,chatRootRef:L,chatBodyRef:$,drawers:F,xtermSlot:D,fileSharingScope:O,onShareFile:E,onOpenInTab:H,onPreviewMarkdown:V,onOpenFilePath:A}){return h.jsx(_Z,{children:h.jsxs("div",{ref:L,"data-cc-chat-root":"",className:"flex flex-col h-full bg-bg-100",children:[h.jsx(pJ,{meta:e,...T?{tool:T}:{},connState:t,variant:i,...n!==void 0?{liveWorktreeRoot:n}:{},...i==="full"&&r?{onOpenConfig:r}:{},...i==="quickask"?{ephemeral:s??!1,...o?{onPromote:o}:{}}:{}}),h.jsx("div",{ref:$,"data-testid":"chat-body",className:"flex-1 overflow-y-auto min-h-0",style:{overflowAnchor:"none"},children:h.jsx(VM,{lines:a,...d?{onPermissionRespond:d}:{},...f&&c?{onPermissionInterrupt:f}:{},topSlot:b,...p?{onRewind:p}:{},rewindableUserMessageIds:u,...m?{onFork:m}:{},...v?{onQuickAsk:v}:{},realtimeQuestionAnswers:_,onSubmitQuestion:x,...y?{onCancelQuestion:y}:{},liveQuestionToolUseIds:w,...O?{fileSharingScope:O}:{},...E?{onShareFile:E}:{},...H?{onOpenInTab:H}:{},...V?{onPreviewMarkdown:V}:{},...A?{onOpenFilePath:A}:{},...i==="full"?{turnCollapse:lse(c)}:{}})}),D,e.larkChatName?h.jsx("div",{className:"mx-3 mb-3 rounded-lg border border-border bg-bg-200 px-3 py-2 text-[12px] text-text-400","data-testid":"lark-readonly-notice",children:e.larkChatType==="p2p"?`此会话由与「${e.larkChatName}」的飞书私聊驱动——对方消息触发,这里仅供观察。`:`此会话由飞书群「${e.larkChatName}」驱动——群成员 @ bot 提问触发,这里仅供观察。`}):h.jsx(hJ,{meta:e,...C?{api:C}:{},cwd:k,...T?{tool:T}:{},sessionKey:N,onSend:z,awaitingUser:P,...B?{onAbort:B}:{},...R?{onNewSession:R}:{},...I?{onClearSession:I}:{},...j?{configSlot:j}:{}}),F]})})}function h1({state:e,extras:t,onQuickAskInternal:n,onPreviewMdInternal:r}){const{session:i,api:s,liveGitBranch:o,liveWorktreeRoot:a,onNewSession:l,onTurnEnd:c,onOpenConfig:u,onFork:d,onQuickAsk:f,viewerRole:p,onPromoteQuickAsk:m,configSlot:v}=t,{capabilities:b}=e1(i.tool||"claude"),_=(b==null?void 0:b.features)??IN(i.tool),[x,y]=g.useState(null),[w,C]=g.useState(null),k=tp(),T=!!s&&k.actionsLevel==="owner"&&_.fileSharing,N=jN(i.ownerPersonaId??null).persona,z=(N==null?void 0:N.label)??null,P=!!z&&!!i.ownerPersonaId,B=g.useCallback((te,oe)=>{y({kind:te,text:oe}),setTimeout(()=>{y(de=>(de==null?void 0:de.text)===oe?null:de)},2e3)},[]),R=ci(),I=fB(),j=HA(i.sessionId,i.toolSessionId),{events:L,pendingQuestions:$,clearQuestion:F,markQuestionSubmitted:D,status:O}=j,E=e.historyLoading,H=QM(O);g.useEffect(()=>{Ae("chat-panel","sessionStatus",{sessionId:i.sessionId,sessionStatus:O,procAlive:H})},[O,H,i.sessionId]);const V=e.lines,A=e.pendingPermissions,ne=A[0]??null,ae=g.useMemo(()=>oW(L),[L]),[G,ye]=g.useState(null),[Fe,ue]=g.useState(()=>new Set);rW(s,i.sessionId,i.toolSessionId,_.observe);const Ie=g.useRef(i.sessionId);g.useEffect(()=>{if(Ie.current=i.sessionId,!_.rewind){ye(null);return}let te=!1;return ye(null),(async()=>{try{const oe=await s.sessionRewindableMessageIds(i.sessionId);if(te)return;ye(new Set(oe.userMessageIds))}catch{te||ye(null)}})(),()=>{te=!0}},[s,i.sessionId,_.rewind]);const Re=g.useCallback(()=>{const te=i.sessionId;s.sessionRewindableMessageIds(te).then(oe=>{Ie.current===te&&ye(new Set(oe.userMessageIds))}).catch(()=>{})},[s,i.sessionId]),Ke=g.useMemo(()=>{if(G!==null){const je=new Set(G);for(const $t of Fe)je.delete($t);return je}const te=new Set(["Edit","Write","MultiEdit","NotebookEdit"]),oe=new Set;let de=null;for(const je of V)je.kind==="user-text"?de=je.uuid??null:de&&je.kind==="tool-call"&&te.has(je.tool)&&!Fe.has(de)&&oe.add(de);return oe},[V,Fe,G]),ve=g.useRef(c);ve.current=c,iW(i.sessionId,i.toolSessionId,()=>{Gt(null),ue(new Set)});const ze=LJ({sessionStatus:O}),fn=g.useRef(null);g.useEffect(()=>{var de;const te=fn.current,oe=(te==null?void 0:te.sid)===i.sessionId;oe&&te.phase===ze||(fn.current={sid:i.sessionId,phase:ze},Ae("session-phase",ze,{sid:i.sessionId,phase:ze,prev:oe?te.phase:null,desc:AJ[ze]}),oe&&te.phase==="turn-running"&&ze!=="turn-running"&&((de=ve.current)==null||de.call(ve),Re()))},[ze,i.sessionId,Re]);const it=g.useCallback(()=>{s.sessionInterrupt(i.sessionId).catch(()=>{})},[s,i.sessionId]),[Rt,Gt]=g.useState(null),Mt=g.useCallback(te=>{Gt(te)},[]),[bt,Qe]=g.useState(!1),st=g.useCallback(()=>{s.sessionStop(i.sessionId).catch(()=>{}),Qe(!1)},[s,i.sessionId]);g.useCallback(te=>{s.pinSession(i.sessionId,te).catch(oe=>{Ae("chat-panel","pinSession failed",{err:oe==null?void 0:oe.message})})},[s,i.sessionId]);const wt=m?"quickask":"full",{container:pn,onCollapse:on}=xJ(),U=g.useRef(0),Z=g.useRef(null);g.useEffect(()=>{const te=oe=>{if(oe.key!=="Escape")return;if(!H){U.current=0;return}if(oe.isComposing)return;const je=oe.target;if(je&&je.closest("[data-cc-chat-root]")!==Z.current)return;const $t=Date.now();$t-U.current<2e3?(U.current=0,Qe(!0)):(U.current=$t,it())};return window.addEventListener("keydown",te),()=>window.removeEventListener("keydown",te)},[it,H]);const _e=g.useRef(null),ke=g.useRef(!0),He=g.useRef(void 0),Nt=g.useRef(0),Yt=g.useRef(0),Xt=g.useRef(void 0);g.useEffect(()=>{C(null)},[i.sessionId]),g.useEffect(()=>{const te=_e.current;if(!te)return;const oe=150,de=je=>{Date.now()<Yt.current&&(je.preventDefault(),Yt.current=Date.now()+oe)};return te.addEventListener("wheel",de,{passive:!1}),()=>te.removeEventListener("wheel",de)},[]),g.useEffect(()=>{const te=_e.current;if(!te)return;const oe=32,de=()=>{const je=te.scrollHeight-te.scrollTop-te.clientHeight;ke.current=je<=oe};return te.addEventListener("scroll",de,{passive:!0}),()=>te.removeEventListener("scroll",de)},[]),g.useLayoutEffect(()=>{var $s;const te=_e.current;if(!te)return;const oe=Xt.current!==i.sessionId;oe&&(Xt.current=i.sessionId,ke.current=!0,He.current=void 0,Nt.current=0,Yt.current=0);const de=He.current,je=($s=V[0])==null?void 0:$s.seq;He.current=je,!oe&&de!==void 0&&je!==void 0&&je<de?(te.scrollTop=te.scrollHeight-Nt.current,Yt.current=Date.now()+200):ke.current&&(te.scrollTop=te.scrollHeight),Nt.current=te.scrollHeight-te.scrollTop},[V,ne==null?void 0:ne.requestId,i.sessionId]);const se=g.useMemo(()=>{const te={};for(const[oe,de]of Object.entries($))de.submittedAnswers&&(te[oe]=de.submittedAnswers);return te},[$]),q=g.useMemo(()=>new Set(Object.keys($)),[$]),we=g.useCallback(async(te,oe)=>{try{await s.answerQuestion({sessionId:i.sessionId,toolUseId:te,answers:oe}),D(te,oe)}catch{}},[s,i.sessionId,D]),ht=g.useCallback(async te=>{try{await s.cancelQuestion({sessionId:i.sessionId,toolUseId:te}),F(te)}catch{}},[s,i.sessionId,F]),an=g.useCallback(async(te,oe)=>{var de;if(ne)try{await((de=e.respondPermission)==null?void 0:de.call(e,ne.requestId,te?"allow":"deny"))}catch{}},[e,ne]),_l=g.useCallback(async()=>{const te=i.sessionId;try{await s.sessionStop(te)}catch{}e.clearSession?await e.clearSession():await s.sessionNew(te)},[e,s,i.sessionId]),xl=g.useMemo(()=>e.historyError?h.jsxs("div",{className:"flex justify-center py-2 text-[12px] text-text-400","data-testid":"history-error",children:["历史未加载完(",e.historyError,");切走再切回可重试"]}):E&&V.length===0?h.jsx("div",{className:"flex justify-center py-4","data-testid":"history-loading",children:h.jsx(In,{className:"w-4 h-4 text-text-400 animate-spin"})}):null,[E,V.length,e.historyError]),zo=e.meta,Hp=h.jsxs(h.Fragment,{children:[i.toolSessionId&&_.subagents?h.jsx(EJ,{api:s,cwd:i.cwd,toolSessionId:i.toolSessionId,toolKind:i.tool??"claude"}):null,Rt&&_.rewind?h.jsx(NJ,{open:!0,onOpenChange:te=>{te||Gt(null)},api:s,sessionId:i.sessionId,userMessageId:Rt,lines:V,procAlive:H,onNoChanges:te=>{ue(oe=>{if(oe.has(te))return oe;const de=new Set(oe);return de.add(te),de})}}):null,bt?h.jsx(fse,{onConfirm:st,onCancel:()=>Qe(!1)}):null]}),ju={kind:"session",sessionId:i.sessionId},Du=g.useCallback(async te=>{if(s)try{await zC(s,R,i.sessionId,te)}catch(oe){const de=oe.message;Ae("chat-panel","open-in-tab failed",{err:de}),B("err",`Open in tab 失败:${de}`)}},[s,R,i.sessionId,B]),[Ou,zs]=g.useState(!1),[Wi,yl]=g.useState(null),Vi=g.useCallback(te=>{if(r){r(te);return}yl(te),zs(!0)},[r]),qi=g.useCallback(te=>{if(!s)return;const oe=async()=>{try{await s.attachmentGroupAdd(i.sessionId,te)}catch(je){Ae("chat-panel","file-link groupAdd skipped",{err:je.message})}},de=je=>{const $t=je.message;Ae("chat-panel","file-link open failed",{err:$t}),B("err",`打开文件失败:${$t}`)};if(Pp(te)){oe().then(()=>Vi(te),de);return}zC(s,R,i.sessionId,te,60,oe).catch(de)},[s,R,i.sessionId,Vi,B]),Ki=g.useCallback(async te=>{if(!s)throw new Error("daemon api not ready");const oe=await d1(s,R,i.sessionId,te,60),de=await fetch(oe);if(!de.ok)throw new Error(`fetch ${de.status} ${de.statusText}`);return await de.text()},[s,R,i.sessionId]),$o=g.useCallback(async(te,oe)=>{if(s)try{const{url:de}=await s.attachmentSignUrl({sessionId:i.sessionId,relPath:te,ttlSeconds:86400,...oe?{view:oe}:{}}),je=await kie(de);B(je?"ok":"err",je?"分享链接已复制到剪贴板(24h 有效)":"复制失败:请手动复制")}catch(de){const je=de.message;Ae("chat-panel","share-file failed",{err:je}),B("err",`生成分享链接失败:${je}`)}},[s,i.sessionId,B]),Fo=g.useCallback(()=>C(null),[]),zt=w==="files"&&T&&s?{title:"Edited Files",onBack:Fo,content:h.jsx(rre,{api:s,scope:ju,sessionId:i.sessionId,onShareFile:$o,onOpenInTab:Du,onPreviewMarkdown:Vi})}:w==="cron"?{title:`定时任务${ae.length?` (${ae.length})`:""}`,onBack:Fo,content:h.jsx("div",{className:"p-3",children:h.jsx(MJ,{jobs:ae})})}:w==="persona"&&P&&s&&i.ownerPersonaId?{title:`Persona · ${z??""}`,onBack:Fo,content:h.jsx(bie,{personaId:i.ownerPersonaId,open:!0,onClose:Fo,api:s,embedded:!0,...p?{viewerRole:p}:{}},i.ownerPersonaId)}:null,bl=wt==="full"?h.jsx(vJ,{session:i,meta:zo,...o!==void 0?{liveGitBranch:o}:{},...a!==void 0?{liveWorktreeRoot:a}:{},...P?{personaName:z}:{},...P?{onOpenPersona:()=>C("persona")}:{},...T?{onOpenFiles:()=>C("files")}:{},cronActiveCount:ae.length,onCronClick:()=>C("cron"),onForceStop:()=>Qe(!0),...p?{viewerRole:p}:{},...b!=null&&b.toolSessionIdLabel?{toolSessionIdLabel:b.toolSessionIdLabel}:{},drill:zt,...on?{onCollapse:on}:{}}):null;return h.jsxs(h.Fragment,{children:[pn&&bl?el.createPortal(bl,pn):null,h.jsx(hse,{headerMeta:zo,connState:e.connState,...a!==void 0?{liveWorktreeRoot:a}:{},...u?{onOpenConfig:u}:{},variant:wt,...wt==="quickask"?{ephemeral:i.ephemeral!==!1,onPromote:()=>void(m==null?void 0:m(i.sessionId))}:{},lines:V,pendingPermissions:A,procAlive:H,rewindableUserMessageIds:Ke,onPermissionRespond:an,onPermissionInterrupt:it,onRewind:_.rewind?Mt:void 0,...d&&_.fork?{onFork:d}:{},...n&&_.fork?{onQuickAsk:n}:f&&_.fork?{onQuickAsk:f}:{},topSlot:xl,realtimeQuestionAnswers:se,onSubmitQuestion:we,onCancelQuestion:ht,liveQuestionToolUseIds:q,api:s,cwd:i.cwd,...i.tool?{tool:i.tool}:{},sessionKey:i.sessionId,onSend:e.sendText,awaitingUser:A.length>0||Object.values($).some(te=>!te.submittedAnswers),onAbort:it,...l?{onNewSession:l}:{},onClearSession:_l,...v?{configSlot:v}:{},chatRootRef:Z,chatBodyRef:_e,drawers:Hp,xtermSlot:I==="tui"&&H&&_.tui?h.jsx(Gne,{sessionId:i.sessionId,client:R},i.sessionId):null,fileSharingScope:ju,...s?{onShareFile:$o}:{},...s?{onOpenInTab:Du}:{},...s?{onPreviewMarkdown:Vi}:{},...s?{onOpenFilePath:qi}:{}}),s?h.jsx(Tie,{open:Ou,onOpenChange:zs,relPath:Wi,loadMarkdown:Ki,onShare:Wi?()=>void $o(Wi,"md-rendered"):void 0}):null,x?h.jsx("div",{"data-testid":"share-toast",role:"status","aria-live":"polite",className:x.kind==="ok"?"fixed left-1/2 top-4 z-50 -translate-x-1/2 rounded-md border border-emerald-500/40 bg-emerald-500/10 px-3 py-2 text-[12px] text-emerald-700 shadow-md dark:text-emerald-300":"fixed left-1/2 top-4 z-50 -translate-x-1/2 rounded-md border border-destructive/40 bg-destructive/10 px-3 py-2 text-[12px] text-destructive shadow-md",children:x.text}):null]})}function fse({onConfirm:e,onCancel:t}){return h.jsx("div",{role:"dialog","aria-modal":"true","data-testid":"force-stop-confirm",className:"fixed inset-0 z-50 flex items-center justify-center bg-black/40",onClick:t,children:h.jsxs("div",{className:"max-w-sm w-[92%] rounded-lg border border-red-400/40 bg-bg-0 p-4 shadow-xl",onClick:n=>n.stopPropagation(),children:[h.jsxs("div",{className:"flex items-start gap-2 mb-3",children:[h.jsx(Kc,{className:"w-5 h-5 text-red-500 shrink-0 mt-0.5"}),h.jsx("div",{className:"text-[14px] text-text-100",children:"强制停止会话进程?会丢失 initialize / 预热缓存,下一次发送需要重新 spawn。"})]}),h.jsxs("div",{className:"flex justify-end gap-2",children:[h.jsx("button",{type:"button",onClick:t,className:"h-8 px-3 rounded-md text-[12px] text-text-300 hover:bg-text-100/5 cursor-pointer",children:"取消"}),h.jsx("button",{type:"button","data-testid":"force-stop-confirm-ok",onClick:e,className:"h-8 px-3 rounded-md bg-red-500 text-white text-[12px] font-medium hover:bg-red-600 cursor-pointer",children:"强制停止"})]})]})})}function pse(e,t,n){const r=e?t.find(s=>s.id===e):void 0;if(r!=null&&r.efforts&&r.efforts.length>0)return{options:r.efforts,defaultValue:r.defaultEffort??""};const i=n.find(s=>s.name==="effort");return{options:(i==null?void 0:i.options)??[],defaultValue:typeof(i==null?void 0:i.default)=="string"?i.default:""}}function mse(e,t,n){var l;if(!t)return((l=(e??[]).find(c=>c.id===""))==null?void 0:l.label)??"未指定";const r=t.toLowerCase(),i=[["opus","Opus"],["fable","Fable"],["sonnet","Sonnet"],["haiku","Haiku"]];for(const[c,u]of i){if(!r.includes(c))continue;const d=r.match(new RegExp(`${c}-(\\d+)(?:-(\\d+))?`));return d?d[2]?`${u} ${d[1]}.${d[2]}`:`${u} ${d[1]}`:u}const s=e??[],o=s.find(c=>c.id===t);if(o)return o.label;const a=s.find(c=>c.id&&t.toLowerCase().includes(c.id.toLowerCase()));return a?a.label:t}function gse(e,t){var m,v,b,_;const{models:n,modes:r,configSchema:i}=t,s=e.resolvedModel??e.model,o=pse(s,n,i),a=o.options,l=a.some(x=>x.value===e.effort)?e.effort:o.defaultValue,c=e.effort===""&&e.resolvedEffort?((m=a.find(x=>x.value===e.resolvedEffort))==null?void 0:m.label)??e.resolvedEffort:((v=a.find(x=>x.value===l))==null?void 0:v.label)??null,u=((b=i.find(x=>x.name==="permissionMode"))==null?void 0:b.default)??"",d=r.some(x=>x.id===e.permissionMode)?e.permissionMode:u,p=d===u?null:((_=r.find(x=>x.id===d))==null?void 0:_.label)??null;return{modelLabel:mse(n,s),effortOptions:a,effortValue:l,effortLabel:c,modeValue:d,modeLabel:p,modeTone:p===null?null:d==="bypassPermissions"?"danger":"info"}}function vse({models:e=[],modes:t=[],configSchema:n=[],model:r,resolvedModel:i,resolvedEffort:s,effort:o,permissionMode:a,onPatch:l}){var p;const c=gse({model:r,resolvedModel:i,resolvedEffort:s,effort:o,permissionMode:a},{models:e,modes:t,configSchema:n}),u=i??r,d=e.map(m=>{const v=m.id===""&&i?`${m.description?`${m.description};`:""}当前:${i}`:m.description;return{value:m.id,label:m.label,...v?{description:v}:{}}}),f=t.map(m=>({value:m.id,label:m.label,...m.description?{description:m.description}:{}}));return h.jsxs(hy,{children:[h.jsx(fy,{asChild:!0,children:h.jsxs("button",{type:"button","data-testid":"session-config-chip",title:"Model / reasoning effort / permission mode",className:"inline-flex items-center gap-1 h-7 px-2.5 rounded-full text-[11px] text-text-400 transition-colors outline-none cursor-pointer hover:bg-text-100/5 hover:text-text-200 data-[state=open]:bg-text-100/5",children:[h.jsx("span",{className:"truncate max-w-[120px]","data-testid":"session-config-chip-model",children:u||c.modelLabel}),c.effortLabel?h.jsxs(h.Fragment,{children:[h.jsx("span",{className:"text-text-500",children:"·"}),h.jsx("span",{className:"truncate max-w-[80px]","data-testid":"session-config-chip-effort",children:c.effortLabel})]}):null,c.modeLabel?h.jsxs(h.Fragment,{children:[h.jsx("span",{className:"text-text-500",children:"·"}),h.jsx("span",{"data-testid":"session-config-chip-mode","data-tone":c.modeTone,className:fe("font-semibold",c.modeTone==="danger"?"text-red-400":"text-blue-400"),children:c.modeLabel})]}):null]})}),h.jsxs(gp,{side:"top",align:"end",className:"w-[230px]","data-testid":"session-config-menu",children:[h.jsx(Ng,{testid:"session-config-model",label:"Model",current:r,currentLabel:c.modelLabel,options:d,onSelect:m=>l({model:m})}),h.jsx(Ng,{testid:"session-config-effort",label:"Reasoning effort",current:c.effortValue,currentLabel:c.effortLabel??"—",options:c.effortOptions,onSelect:m=>l({effort:m})}),f.length>0?h.jsx(Ng,{testid:"session-config-mode",label:"Permission mode",current:c.modeValue,currentLabel:((p=t.find(m=>m.id===c.modeValue))==null?void 0:p.label)??"—",currentTone:c.modeTone,options:f,onSelect:m=>l({permissionMode:m})}):null]})]})}function Ng({testid:e,label:t,current:n,currentLabel:r,currentTone:i,options:s,onSelect:o}){const a=s.length===0;return h.jsxs(RH,{children:[h.jsxs(XI,{"data-testid":e,disabled:a,className:"gap-2 text-[12px]",children:[h.jsx("span",{className:"flex-1 text-text-200",children:t}),h.jsx("span",{className:fe("truncate max-w-[100px]",i==="danger"?"text-red-400 font-semibold":i==="info"?"text-blue-400 font-semibold":"text-text-400"),children:r}),h.jsx(Un,{className:"w-3.5 h-3.5 shrink-0 text-text-500"})]}),h.jsx(QI,{className:"w-[220px] max-h-[320px] overflow-y-auto",children:s.map(l=>{const c=l.value===n;return h.jsxs(yi,{"data-testid":`${e}-option-${l.value||"default"}`,onSelect:()=>o(l.value),className:"items-start gap-2",children:[h.jsxs("span",{className:"flex-1 min-w-0",children:[h.jsx("span",{className:fe("block text-[12px]",c?"text-text-100 font-medium":"text-text-300"),children:l.label}),l.description?h.jsx("span",{className:"block text-[11px] text-text-400 mt-0.5",children:l.description}):null]}),c?h.jsx(ul,{className:"w-3.5 h-3.5 shrink-0 text-accent mt-0.5"}):null]},l.value||"default")})})]})}function _se(e,t,n=0){const[r,i]=g.useState(null),[s,o]=g.useState(!1),a=g.useCallback(async()=>{if(!t){i(null);return}o(!0);try{const l=await e.getGitBranch(t);i(l.branch??null)}catch{i(null)}finally{o(!1)}},[e,t]);return g.useEffect(()=>{a()},[a,n]),{branch:r,loading:s,refresh:()=>void a()}}function xse(e,t,n=0){const[r,i]=g.useState(null),[s,o]=g.useState(!1),a=g.useCallback(async()=>{if(!t){i(null);return}o(!0);try{const l=await e.getGitRoot(t);i(l.gitRoot??null)}catch{i(null)}finally{o(!1)}},[e,t]);return g.useEffect(()=>{a()},[a,n]),{worktreeRoot:r,loading:s,refresh:()=>void a()}}function yse({api:e,session:t,focused:n,totalPanes:r,onFocus:i,onClose:s,onNewSession:o,onOpenConfig:a,onFork:l,onQuickAsk:c,className:u,viewerRole:d="owner"}){const{capabilities:f}=e1(t.tool),[p,m]=g.useState(0),{branch:v}=_se(e,t.cwd,p),{worktreeRoot:b}=xse(e,t.cwd,p),_=r>1,x=y=>{e.sessionUpdate(t.sessionId,y).catch(w=>{console.error("[session-config] session:update failed",t.sessionId,w)})};return h.jsxs("div",{className:`group/pane relative flex-1 ${u??"flex"} flex-row min-w-0 min-h-0 overflow-hidden ${_?`rounded-md border transition-colors ${n?"border-accent ring-1 ring-accent":"border-border"}`:""}`,onMouseDown:i,"data-testid":`session-pane-${t.sessionId}`,children:[h.jsx(Sy,{orientation:"horizontal",className:"flex-1 flex min-w-0 min-h-0",children:h.jsx(sf,{id:"chat",minSize:"400px",children:h.jsx("div",{className:"flex flex-col min-w-0 min-h-0 h-full",children:h.jsx(bse,{api:e,session:t,liveGitBranch:v,liveWorktreeRoot:b,onNewSession:o,onTurnEnd:()=>m(y=>y+1),onOpenConfig:a,onFork:l,onQuickAsk:c,viewerRole:d,configSlot:f?h.jsx(vse,{models:f.models,modes:f.permissionModes,configSchema:f.configSchema,model:t.model??"",...t.resolvedModel?{resolvedModel:t.resolvedModel}:{},...t.resolvedEffort?{resolvedEffort:t.resolvedEffort}:{},effort:t.effort??"",permissionMode:t.permissionMode??"",onPatch:x}):null})})})}),_&&h.jsx("button",{type:"button",onClick:y=>{y.stopPropagation(),s()},className:"absolute top-1.5 right-1.5 z-10 p-1 rounded-md bg-bg-100/80 backdrop-blur-sm border border-border opacity-0 group-hover/pane:opacity-100 transition-opacity text-text-400 hover:text-text-100 hover:bg-bg-200","aria-label":"close pane","data-testid":`session-pane-close-${t.sessionId}`,children:h.jsx(Dr,{className:"w-3.5 h-3.5"})})]})}function bse({api:e,session:t,liveGitBranch:n,liveWorktreeRoot:r,onNewSession:i,onTurnEnd:s,onOpenConfig:o,onFork:a,onQuickAsk:l,viewerRole:c,configSlot:u}){return h.jsx(use,{extras:{session:t,api:e,...n!==void 0?{liveGitBranch:n}:{},...r!==void 0?{liveWorktreeRoot:r}:{},onNewSession:i,onTurnEnd:s,onOpenConfig:o,...a?{onFork:d=>{a(d)}}:{},...l?{onQuickAsk:d=>{l(d)}}:{},...c?{viewerRole:c}:{},...u?{configSlot:u}:{}}})}function wse({personas:e,sessions:t,api:n,selfPrincipalId:r,selectedPersonaId:i,selectedSessionId:s,selectedSession:o,onSelectPersona:a,onSelectSession:l,onCreateSession:c,onDeleteSession:u,onEditSession:d,onCloseSession:f}){return h.jsxs("div",{className:"flex h-screen min-h-0 bg-bg-50","data-testid":"guest-share-page",children:[h.jsx("aside",{className:"w-[280px] shrink-0 overflow-y-auto border-r border-border bg-bg-50",children:h.jsx(bU,{personas:e,sessions:t,activePersonaId:i,activeSessionId:s,onSelectPersona:a,onSelectSession:l,onCreateSession:c,onDeleteSession:u,onEditSession:d,showCopyResume:!1,treatSessionsAsRoots:!0,...r?{ownerPrincipalId:r}:{},isPersonaExpanded:()=>!0})}),h.jsx("main",{className:"flex-1 min-w-0 min-h-0 flex",children:o?h.jsx(yse,{api:n,session:o,focused:!0,totalPanes:1,onFocus:()=>{},onClose:f,onNewSession:()=>{},onOpenConfig:()=>{},viewerRole:"guest"}):h.jsx("div",{className:"flex flex-1 items-center justify-center p-6 text-xs text-text-400","data-testid":"guest-share-empty",children:"选择左侧 persona 开始对话"})})]})}function Sse(){const e=ci(),t=g.useMemo(()=>new Ox(e),[e]),n=jB(e),{sessions:r,refresh:i}=DB(n),{personas:s}=LN(),o=HB(),a=g.useMemo(()=>{const w=window.location.pathname.match(/^\/s\/([^/]+)/);return w?decodeURIComponent(w[1]):null},[]),l=g.useMemo(()=>r.filter(w=>!w.ephemeral&&w.larkChatId==null),[r]),c=g.useMemo(()=>a?s.filter(w=>w.personaId===a):s,[s,a]),[u,d]=g.useState(null),[f,p]=g.useState(null),[m,v]=g.useState(null);g.useEffect(()=>{let w=!1;return e.request("whoami",{}).then(C=>{w||d(C.capability.id)}).catch(()=>{}),()=>{w=!0}},[e]),g.useEffect(()=>{a&&p(a)},[a]);const b=g.useCallback(async(w,C)=>{const k=await t.sessionCreate({ownerPersonaId:w,...C.trim()?{label:C.trim()}:{}});await i(),p(w),v(k.sessionId)},[t,i]),_=g.useCallback(async w=>{await t.sessionDelete(w),await i(),v(C=>C===w?null:C)},[t,i]),x=g.useCallback(async(w,C)=>{await t.sessionUpdate(w,{label:C.label}),await i()},[t,i]),y=g.useMemo(()=>l.find(w=>w.sessionId===m)??null,[l,m]);return h.jsx(Bx.Provider,{value:o,children:h.jsx(wse,{personas:c,sessions:l,api:t,selfPrincipalId:u,selectedPersonaId:f,selectedSessionId:m,selectedSession:y,onSelectPersona:p,onSelectSession:v,onCreateSession:(w,C)=>void b(w,C),onDeleteSession:w=>void _(w),onEditSession:(w,C)=>void x(w,C),onCloseSession:()=>v(null)})})}const UC="https://app.ttcadvisory.com";function kse({onAuthed:e}){const[t,n]=g.useState(!1),[r,i]=g.useState(null),s=g.useRef(null);g.useEffect(()=>()=>{s.current&&window.removeEventListener("message",s.current)},[]);const o=g.useCallback(()=>{s.current&&(window.removeEventListener("message",s.current),s.current=null),n(!0),i(null);const a=window.location.origin,l=`${UC}/auth/authorize?callback_url=${encodeURIComponent(a)}&auto=1`,c=async d=>{if(d.origin!==UC)return;const f=d.data;if((f==null?void 0:f.type)==="AUTH_CANCEL"){u(),n(!1);return}if(!((f==null?void 0:f.type)!=="AUTH_SUCCESS"||!f.token)){u();try{const p=await fetch(`${window.location.origin}/share/exchange`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({ttcToken:f.token})});if(!p.ok){const v=await p.json().catch(()=>({}));throw new Error(v.code??`exchange failed (${p.status})`)}const m=await p.json();if(!m.visitorToken)throw new Error("no visitorToken in response");e(m.visitorToken)}catch(p){i(p instanceof Error?p.message:String(p)),n(!1)}}},u=()=>{window.removeEventListener("message",c),s.current=null};s.current=d=>void c(d),window.addEventListener("message",s.current),window.open(l,"ttc-login","width=480,height=640")},[e]);return h.jsx("div",{className:"flex min-h-screen items-center justify-center bg-bg-50 p-6 font-sans text-text-100","data-testid":"guest-login",children:h.jsxs("div",{className:"flex w-full max-w-xs flex-col gap-3 rounded-lg border border-border bg-bg-100 px-5 py-6",children:[h.jsx("h1",{className:"text-base font-semibold",children:"登录后进入分享"}),h.jsx("p",{className:"text-[11px] leading-snug text-text-400",children:"使用飞书账号登录,即可在浏览器里与分享给你的 persona 交互,无需安装。"}),r?h.jsxs("p",{className:"text-[11px] leading-snug text-error","data-testid":"guest-login-error",children:["登录失败:",r]}):null,h.jsx("button",{type:"button",disabled:t,onClick:()=>o(),"data-testid":"guest-login-button",className:"w-full rounded border border-border bg-bg-50 px-2 py-1.5 text-xs text-text-200 transition-colors hover:bg-text-100/5 hover:text-text-100 disabled:opacity-50",children:t?"请在弹窗中完成授权…":"飞书登录"})]})})}const E_="clawd-visitor:token";function Cse(e,t){const r=`${e.protocol==="https:"?"wss:":"ws:"}//${e.host}`;return t!=null&&t.devPath?`${r}${t.devPath}`:r}function Ese(){return{async getUrl(e){const t=localStorage.getItem(E_);if(!t)throw new Error("NO_VISITOR_TOKEN");const n=Cse(window.location,{});return await CN(e).upsert({id:"guest",name:"访客",mode:"remote",url:n,token:t}),{url:n}}}}function Tse(e){const t=n=>{document.documentElement.classList.toggle("dark",n==="dark")};return t(e.theme.mode),e.onThemeChange(n=>t(n.mode))}function Nse(){const e=ci(),t=g.useMemo(()=>LB(e),[e]);return h.jsx(mB,{cache:t.cache,children:h.jsx(_B,{children:h.jsx(Sse,{})})})}function Pse({host:e}){const[t]=g.useState(()=>localStorage.getItem(E_)),[n,r]=g.useState(!1),[i,s]=g.useState(null);return g.useEffect(()=>Tse(e),[e]),g.useEffect(()=>{if(!t)return;let o=!1;return Ese().getUrl(e).then(()=>{o||r(!0)}).catch(a=>{o||s(a instanceof Error?a.message:String(a))}),()=>{o=!0}},[e,t]),t?h.jsx(Pb,{host:e,children:h.jsx(lw,{children:i?h.jsxs("div",{className:"flex min-h-screen items-center justify-center bg-bg-50 p-6 text-center text-xs text-error","data-testid":"guest-share-connect-error",children:["连接失败:",i]}):n?h.jsx(hB,{host:e,children:h.jsx(Nse,{})}):h.jsx("div",{className:"flex min-h-screen items-center justify-center bg-bg-50 p-6 text-xs text-text-400",children:"正在连接…"})})}):h.jsx(Pb,{host:e,children:h.jsx(lw,{children:h.jsx(kse,{onAuthed:o=>{localStorage.setItem(E_,o),window.location.reload()}})})})}function Ise({filePath:e,oldString:t,newString:n,content:r}){const i=g.useMemo(()=>r!=null?r.split(/\r?\n/).map(s=>({type:"add",text:s})):Rse(t??"",n??""),[t,n,r]);return h.jsxs("div",{"data-testid":"inline-diff",className:"min-w-0 max-w-full rounded-lg border border-bg-300/60 bg-bg-50 overflow-hidden text-[12px] font-mono",children:[h.jsx("div",{className:"flex min-w-0 items-center gap-2 px-3 py-1.5 border-b border-bg-300/40 bg-bg-100/30",children:h.jsx("span",{className:"min-w-0 text-text-400 truncate",title:e,children:e})}),h.jsx("div",{className:"max-h-[320px] max-w-full overflow-auto",children:i.map((s,o)=>h.jsxs("div",{"data-testid":`diff-line-${s.type}`,className:fe("flex min-w-max gap-2 px-3 py-0.5 whitespace-pre",s.type==="add"?"bg-success/10 text-success":s.type==="remove"?"bg-error/10 text-error":"text-text-300"),children:[h.jsx("span",{className:"w-3 shrink-0 select-none opacity-60",children:s.type==="add"?"+":s.type==="remove"?"-":" "}),h.jsx("span",{className:"flex-1",children:s.text||" "})]},o))})]})}function Rse(e,t){const n=e.split(/\r?\n/),r=t.split(/\r?\n/),i=n.length,s=r.length,o=Array.from({length:i+1},()=>new Array(s+1).fill(0));for(let u=i-1;u>=0;u--)for(let d=s-1;d>=0;d--)o[u][d]=n[u]===r[d]?o[u+1][d+1]+1:Math.max(o[u+1][d],o[u][d+1]);const a=[];let l=0,c=0;for(;l<i&&c<s;)n[l]===r[c]?(a.push({type:"equal",text:n[l]}),l++,c++):o[l+1][c]>=o[l][c+1]?(a.push({type:"remove",text:n[l]}),l++):(a.push({type:"add",text:r[c]}),c++);for(;l<i;)a.push({type:"remove",text:n[l++]});for(;c<s;)a.push({type:"add",text:r[c++]});return a}function Mse({items:e}){return e.length===0?null:h.jsxs("div",{"data-testid":"todo-checklist",className:"rounded-lg border border-bg-300/60 bg-bg-50 px-3 py-2 text-[13px]",children:[h.jsx("div",{className:"text-[11px] font-semibold uppercase tracking-wider text-text-400/70 mb-1.5",children:"Todos"}),h.jsx("ul",{className:"flex flex-col gap-1",children:e.map((t,n)=>{const r=t.status==="in_progress"&&t.activeForm||t.content;return h.jsxs("li",{"data-testid":`todo-item-${t.status}`,className:"flex items-start gap-2",children:[h.jsx(Ase,{status:t.status}),h.jsx("span",{className:fe("flex-1 leading-snug",t.status==="completed"?"text-text-400 line-through":t.status==="in_progress"?"text-text-100 font-medium":"text-text-200"),children:r})]},n)})})]})}function Ase({status:e}){return e==="completed"?h.jsx(rp,{className:"w-3.5 h-3.5 text-success mt-0.5 shrink-0"}):e==="in_progress"?h.jsx(In,{className:"w-3.5 h-3.5 text-warning mt-0.5 shrink-0 animate-spin"}):h.jsx(BN,{className:"w-3.5 h-3.5 text-text-400 mt-0.5 shrink-0"})}function Lse(e){const t=e??{};return Array.isArray(t.todos)?t.todos.map(n=>{if(!n||typeof n!="object")return null;const r=n,i=typeof r.content=="string"?r.content:"",s=r.status==="pending"||r.status==="in_progress"||r.status==="completed"?r.status:"pending",o=typeof r.activeForm=="string"?r.activeForm:void 0;return{content:i,status:s,activeForm:o}}).filter(n=>n!==null):[]}function jse({description:e,prompt:t,subagentType:n}){return h.jsxs("div",{"data-testid":"task-checklist",className:"rounded-lg border border-bg-300/60 bg-bg-50 px-3 py-2 text-[13px]",children:[h.jsxs("div",{className:"flex items-center gap-2 text-text-200 font-medium",children:[h.jsx(np,{className:"w-3.5 h-3.5 text-accent shrink-0"}),h.jsx("span",{className:"truncate",children:e||"subagent task"}),n?h.jsx("span",{className:"shrink-0 px-1.5 py-0.5 rounded-md text-[10px] font-mono bg-accent/10 text-accent",children:n}):null]}),t?h.jsx("div",{className:"mt-1 text-[12px] text-text-400 leading-snug line-clamp-3",children:t}):null]})}function Dse(e){const t=e??{};return{description:typeof t.description=="string"?t.description:"",prompt:typeof t.prompt=="string"?t.prompt:void 0,subagentType:typeof t.subagent_type=="string"?t.subagent_type:void 0}}const Ose={render:({input:e})=>Ze.createElement(Mse,{items:Lse(e)})},Bse={render:({input:e})=>{const{description:t,prompt:n,subagentType:r}=Dse(e);return Ze.createElement(jse,{description:t,prompt:n,subagentType:r})}},P5={render:({input:e,output:t,error:n,pending:r,fileScope:i,onShareFile:s,onOpenInTab:o,onPreviewMarkdown:a})=>{const l=$se(e),c=l?Ze.createElement(Ise,{filePath:l.filePath,oldString:l.oldString,newString:l.newString,content:l.content}):void 0;return Ze.createElement(zM,{tool:zse(e),input:e,output:t,error:n,pending:r,expandedBody:c,...i?{fileScope:i}:{},...s?{onShareFile:s}:{},...o?{onOpenInTab:o}:{},...a?{onPreviewMarkdown:a}:{}})}};function zse(e){const t=e??{};return"content"in t&&t.content!==void 0?"Write":("old_string"in t&&t.old_string!==void 0,"Edit")}function $se(e){const t=e??{},n=typeof t.file_path=="string"?t.file_path:null;if(!n)return null;const r=typeof t.old_string=="string"?t.old_string:void 0,i=typeof t.new_string=="string"?t.new_string:void 0,s=typeof t.content=="string"?t.content:void 0;return r==null&&i==null&&s==null?null:{filePath:n,oldString:r,newString:i,content:s}}ml.register("claude","TodoWrite",Ose);ml.register("claude","Task",Bse);ml.register("claude","Edit",P5);ml.register("claude","Write",P5);const I5=document.getElementById("root");if(!I5)throw new Error("guest-main: #root not found");const Fse=dL({});Pg.createRoot(I5).render(h.jsx(Ze.StrictMode,{children:h.jsx(Pse,{host:Fse})}));
559
+ For more information, see https://radix-ui.com/primitives/docs/components/${t.docsSlug}`;return g.useEffect(()=>{e&&(document.getElementById(e)||console.error(n))},[n,e]),null},rie="DialogDescriptionWarning",iie=({contentRef:e,descriptionId:t})=>{const r=`Warning: Missing \`Description\` or \`aria-describedby={undefined}\` for {${y5(rie).contentName}}.`;return g.useEffect(()=>{var s;const i=(s=e.current)==null?void 0:s.getAttribute("aria-describedby");t&&i&&(document.getElementById(t)||console.warn(r))},[r,e,t]),null},sie=a5,oie=u5,b5=d5,w5=h5,S5=p5,k5=g5,aie=_5;const c1=sie,lie=oie,C5=g.forwardRef(({className:e,...t},n)=>h.jsx(b5,{ref:n,className:fe("fixed inset-0 z-50 bg-black/50 backdrop-blur-sm",e),...t}));C5.displayName=b5.displayName;const zp=g.forwardRef(({className:e,children:t,...n},r)=>h.jsxs(lie,{children:[h.jsx(C5,{}),h.jsxs(w5,{ref:r,className:fe("fixed left-1/2 top-1/2 z-50 grid w-full max-w-lg -translate-x-1/2 -translate-y-1/2","gap-4 rounded-lg border border-border bg-elevated p-6 shadow-lg",e),...n,children:[t,h.jsxs(aie,{className:"absolute right-4 top-4 rounded-sm opacity-70 transition-opacity hover:opacity-100 focus:outline-none focus:ring-2 focus:ring-accent",children:[h.jsx(Dr,{className:"h-4 w-4"}),h.jsx("span",{className:"sr-only",children:"Close"})]})]})]}));zp.displayName=w5.displayName;const $p=({className:e,...t})=>h.jsx("div",{className:fe("flex flex-col space-y-1.5 text-left",e),...t});$p.displayName="DialogHeader";const u1=({className:e,...t})=>h.jsx("div",{className:fe("flex flex-row justify-end gap-2",e),...t});u1.displayName="DialogFooter";const Fp=g.forwardRef(({className:e,...t},n)=>h.jsx(S5,{ref:n,className:fe("text-lg font-semibold leading-none text-text-100",e),...t}));Fp.displayName=S5.displayName;const E5=g.forwardRef(({className:e,...t},n)=>h.jsx(k5,{ref:n,className:fe("text-sm text-text-300",e),...t}));E5.displayName=k5.displayName;function cie({persona:e,open:t,onClose:n,onDelete:r,embedded:i,onLoadPersonality:s,onSavePersonality:o,onDirtyChange:a,initialPersonality:l,onShareCapability:c,readOnly:u=!1,larkBot:d}){const[f,p]=g.useState(!1),m=b=>{p(b),a==null||a(b)},v=()=>{f&&!window.confirm("修改未保存,确定关闭?")||n()};return t?h.jsxs(h.Fragment,{children:[!i&&h.jsx("div",{className:"absolute inset-0 z-30 bg-black/30",onClick:v,"aria-hidden":"true"}),h.jsxs("aside",{className:i?"flex h-full w-full flex-col bg-bg-0":"absolute right-0 top-0 z-40 flex h-full w-[420px] flex-col bg-bg-0 border-l border-border shadow-xl","data-testid":"persona-settings-drawer",children:[h.jsxs("header",{className:"flex items-center justify-between border-b border-border px-4 py-3 shrink-0",children:[h.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[h.jsx(p$,{className:"h-4 w-4 text-text-300"}),h.jsx("span",{className:"text-[13px] font-medium text-text-100 truncate",children:"Persona 设置"})]}),h.jsx("button",{type:"button",onClick:v,"aria-label":"关闭",className:"rounded-sm p-1.5 text-text-400 hover:bg-bg-200 hover:text-text-100",children:h.jsx(Dr,{className:"h-4 w-4"})})]}),h.jsxs("div",{className:"flex-1 overflow-y-auto p-6 flex flex-col gap-4",children:[h.jsxs("header",{className:"flex items-start justify-between gap-3",children:[h.jsxs("div",{className:"flex flex-col gap-0.5 min-w-0",children:[h.jsxs("div",{className:"flex items-center gap-2",children:[h.jsx("h2",{className:"text-lg font-semibold text-text-100 truncate",children:e.label}),e.public?h.jsxs("span",{className:"inline-flex items-center gap-1 rounded-sm bg-bg-200 px-1.5 py-0.5 text-[10px] text-text-200",children:[h.jsx(Dz,{className:"h-3 w-3"})," 公开"]}):h.jsxs("span",{className:"inline-flex items-center gap-1 rounded-sm bg-error-dim px-1.5 py-0.5 text-[10px] text-error",children:[h.jsx(Lz,{className:"h-3 w-3"})," 已关闭"]})]}),h.jsx("span",{className:"font-mono text-[11px] text-text-400 truncate","data-testid":"persona-id-subtitle",children:e.personaId})]}),h.jsxs("div",{className:"flex items-center gap-1",children:[c?h.jsxs("button",{type:"button",onClick:c,"aria-label":"分享给他人",title:"分享给他人",className:"inline-flex items-center gap-1 rounded-sm px-2 py-1.5 text-xs text-text-200 hover:bg-bg-200 hover:text-text-100",children:[h.jsx($x,{className:"h-3.5 w-3.5"}),"分享"]}):null,r?h.jsx("button",{type:"button",onClick:r,"aria-label":"删除 persona",className:"rounded-sm p-1.5 text-text-400 hover:bg-bg-200 hover:text-error",children:h.jsx(Fx,{className:"h-4 w-4"})}):null]})]}),h.jsx("hr",{className:"border-border"}),d?h.jsxs(h.Fragment,{children:[h.jsx(fie,{...d}),h.jsx("hr",{className:"border-border"})]}):null,s?h.jsxs(h.Fragment,{children:[h.jsx(vie,{onLoad:s,...o?{onSave:o}:{},onDirtyChange:m,initialPersonality:l,readOnly:u}),h.jsx("hr",{className:"border-border"})]}):null,h.jsx(pie,{settings:e.sandboxSettings??null}),h.jsx("hr",{className:"border-border"}),h.jsx(mie,{skills:e.skills??[]}),h.jsx("hr",{className:"border-border"}),h.jsx(gie,{plugins:e.plugins??[]})]})]})]}):null}function uie({qrUrl:e,busy:t,onCancel:n}){const[r,i]=g.useState(null);return g.useEffect(()=>{let s=!1;return Au.toDataURL(e,{width:240,margin:1}).then(o=>{s||i(o)}).catch(()=>{s||i(null)}),()=>{s=!0}},[e]),h.jsx(c1,{open:!0,onOpenChange:s=>s||n==null?void 0:n(),children:h.jsxs(zp,{className:"max-w-xs","data-testid":"lark-bot-qr-dialog",onInteractOutside:s=>s.preventDefault(),onEscapeKeyDown:s=>s.preventDefault(),children:[h.jsx($p,{children:h.jsx(Fp,{children:"扫码关联飞书 Bot"})}),h.jsxs("div",{className:"flex flex-col items-center gap-2",children:[r?h.jsx("img",{src:r,alt:"飞书扫码创建应用二维码",className:"h-60 w-60 rounded bg-white p-2","data-testid":"lark-bot-qr-img"}):h.jsx("div",{className:"flex h-60 w-60 items-center justify-center text-[12px] text-text-400",children:"二维码生成中…"}),h.jsx("span",{className:"text-center text-[12px] text-text-300",children:"用手机飞书扫码,按页面提示创建应用。确认后自动完成关联。"}),n?h.jsx("button",{type:"button",disabled:t,onClick:n,className:"rounded border border-border px-3 py-1.5 text-[12px] text-text-300 hover:bg-bg-200 disabled:opacity-50","data-testid":"lark-bot-provision-cancel",children:"取消"}):null]})]})})}const die={expired:"二维码已过期,请重新扫码。",cancelled:"已取消。",access_denied:"你在飞书上取消了本次授权。",lark_protocol_error:"飞书返回了未预期的响应,请重试。",cloud_unreachable:"云端暂时不可达,请稍后重试。",internal_error:"关联失败。若飞书中已创建应用,可在开发者后台删除后重试,或改用手动绑定填入其凭证。"},hie=new Set(["expired","access_denied","lark_protocol_error","cloud_unreachable","internal_error"]);function fie({status:e,onProvision:t,onCancelProvision:n,onBindManual:r,onUnbind:i}){const[s,o]=g.useState(!1),[a,l]=g.useState(null),[c,u]=g.useState(""),[d,f]=g.useState(""),[p,m]=g.useState(null),v=C=>{C&&(o(!0),l(null),C().catch(k=>l(k instanceof Error?k.message:String(k))).finally(()=>o(!1)))},b=()=>{m(null),v(t)},_=!s&&!!c&&!!d,x=()=>{!_||!r||v(()=>r({appId:c,appSecret:d}))},y=ku(x),w=h.jsxs("div",{className:"flex items-center gap-1.5",children:[h.jsx(np,{className:"h-3.5 w-3.5 text-text-400","aria-hidden":!0}),h.jsx("span",{className:"text-[13px] font-medium text-text-100",children:"飞书 Bot"})]});return e?h.jsxs("section",{className:"flex flex-col gap-1.5","data-testid":"lark-bot-section",children:[w,e.state==="unbound"||e.state==="provisioning"?h.jsxs(h.Fragment,{children:[h.jsx("span",{className:"text-[11px] text-text-400",children:"关联一个飞书 bot 后,这个 persona 就是它:拉进群后群成员 @ 它提问、或直接私聊它, 推理跑在你本机,回复自动发回去。"}),t?h.jsx("button",{type:"button",disabled:s||e.state==="provisioning",onClick:b,className:"self-start rounded border border-border bg-bg-200 px-3 py-1.5 text-[12px] font-medium text-text-100 hover:bg-bg-300 disabled:opacity-50","data-testid":"lark-bot-provision",children:e.state==="provisioning"?"等待扫码…":"扫码关联飞书 Bot"}):null,e.state==="unbound"&&e.errorReason&&!p?h.jsxs("div",{className:"flex flex-col gap-1.5 rounded border border-error bg-error-dim px-2 py-1.5","data-testid":"lark-bot-provision-error",children:[h.jsx("span",{className:"text-[11px] text-error",children:die[e.errorReason]}),h.jsxs("div",{className:"flex gap-1.5",children:[hie.has(e.errorReason)&&t?h.jsx("button",{type:"button",disabled:s,onClick:b,className:"rounded border border-border px-2 py-1 text-[11px] text-text-100 hover:bg-bg-200 disabled:opacity-50","data-testid":"lark-bot-provision-retry",children:"重新扫码"}):null,h.jsx("button",{type:"button",onClick:()=>m(e.errorReason??null),className:"rounded border border-border px-2 py-1 text-[11px] text-text-300 hover:bg-bg-200","data-testid":"lark-bot-provision-error-dismiss",children:"知道了"})]})]}):null,e.state==="provisioning"&&e.qrUrl?h.jsx(uie,{qrUrl:e.qrUrl,busy:s,onCancel:n?()=>v(n):void 0}):null,r&&e.state==="unbound"?h.jsxs("details",{"data-testid":"lark-bot-manual-details",children:[h.jsx("summary",{className:"cursor-pointer text-[11px] text-text-400 hover:text-text-300",children:"已有飞书应用?手动填入凭证"}),h.jsxs("div",{className:"mt-1.5 flex flex-col gap-1.5","data-testid":"lark-bot-manual-form",children:[h.jsx("span",{className:"text-[11px] text-text-400",children:"先在飞书开放平台(open.feishu.cn)创建企业自建应用并启用机器人能力,再填入凭证:"}),h.jsx("input",{value:c,onChange:C=>u(C.target.value),...y,placeholder:"App ID(cli_ 开头)",className:"rounded border border-border bg-bg-100 px-2 py-1 text-[12px] text-text-200","data-testid":"lark-bot-manual-appid"}),h.jsx("input",{value:d,onChange:C=>f(C.target.value),...y,type:"password",placeholder:"App Secret",className:"rounded border border-border bg-bg-100 px-2 py-1 text-[12px] text-text-200","data-testid":"lark-bot-manual-secret"}),h.jsx("button",{type:"button",disabled:!_,onClick:x,className:"self-start rounded border border-border px-3 py-1.5 text-[12px] text-text-100 hover:bg-bg-200 disabled:opacity-50","data-testid":"lark-bot-manual-submit",children:s?"绑定中…":"绑定"})]})]}):null]}):null,e.state==="bound"||e.state==="broken"?h.jsxs("div",{className:"flex flex-col gap-1.5",children:[e.state==="broken"?h.jsxs("div",{className:"rounded border border-error bg-error-dim px-2 py-1.5 text-[11px] text-error","data-testid":"lark-bot-broken",children:["Bot 凭证失效:",e.brokenReason??"未知原因","。请解绑后重新填入有效凭证绑定。"]}):null,h.jsxs("div",{className:"flex items-center gap-2 text-[12px] text-text-200",children:[h.jsx("span",{className:"font-medium text-text-100",children:e.botName??"未命名 bot"}),e.appId?h.jsx("span",{className:"text-[11px] text-text-400",children:e.appId}):null]}),h.jsx("span",{className:"text-[11px] text-text-400",children:"把 bot 拉进任意飞书群,群成员 @ 它即可提问。"}),e.groups.length>0?h.jsx("ul",{className:"flex flex-col gap-0.5","data-testid":"lark-bot-groups",children:e.groups.map(C=>h.jsxs("li",{className:"text-[11px] text-text-300 truncate",children:["· ",C.chatName??C.chatId]},C.chatId))}):h.jsx("span",{className:"text-[11px] text-text-400","data-testid":"lark-bot-groups-empty",children:"还没有服务中的群。"}),i?h.jsx("button",{type:"button",disabled:s,onClick:()=>v(i),className:"self-start rounded border border-border px-3 py-1.5 text-[12px] text-error hover:bg-error-dim disabled:opacity-50","data-testid":"lark-bot-unbind",children:"解绑"}):null]}):null,a?h.jsx("div",{className:"rounded border border-error bg-error-dim px-2 py-1.5 text-[11px] text-error","data-testid":"lark-bot-error",children:a}):null]}):h.jsxs("section",{className:"flex flex-col gap-1.5","data-testid":"lark-bot-section",children:[w,h.jsx("span",{className:"text-[11px] text-text-400",children:"状态加载中…"})]})}function pie({settings:e}){var t,n,r,i,s,o,a,l,c,u,d,f,p;return h.jsxs("section",{className:"flex flex-col gap-2","data-testid":"persona-sandbox-setting-section",children:[h.jsxs("header",{className:"flex flex-col gap-0.5",children:[h.jsx("span",{className:"text-[13px] font-medium text-text-100",children:"Sandbox Setting"}),h.jsx("span",{className:"text-[11px] text-text-400",children:"约束此 persona 的沙箱权限(只读,需通过文件修改)。"})]}),e==null?h.jsx("span",{className:"text-[12px] text-text-300","data-testid":"persona-sandbox-setting-empty",children:"暂无 sandbox 配置"}):h.jsxs("div",{className:"flex flex-col gap-1.5 rounded-md border border-border bg-bg-100 px-3 py-2",children:[h.jsx(jd,{label:"权限默认模式",value:((t=e.permissions)==null?void 0:t.defaultMode)??"—"}),h.jsx(jd,{label:"沙箱启用",value:Tg((n=e.sandbox)==null?void 0:n.enabled)}),h.jsx(jd,{label:"沙箱内自动放行 Bash",value:Tg((r=e.sandbox)==null?void 0:r.autoAllowBashIfSandboxed)}),h.jsx(jd,{label:"允许非沙箱命令",value:Tg((i=e.sandbox)==null?void 0:i.allowUnsandboxedCommands)}),h.jsxs("div",{className:"mt-1 flex flex-col gap-1.5 border-t border-border pt-1.5",children:[h.jsx(Hl,{label:"沙箱外命令",paths:(s=e.sandbox)==null?void 0:s.excludedCommands}),h.jsx(Hl,{label:"允许读取",paths:(a=(o=e.sandbox)==null?void 0:o.filesystem)==null?void 0:a.allowRead}),h.jsx(Hl,{label:"拒绝读取",paths:(c=(l=e.sandbox)==null?void 0:l.filesystem)==null?void 0:c.denyRead}),h.jsx(Hl,{label:"允许写入",paths:(d=(u=e.sandbox)==null?void 0:u.filesystem)==null?void 0:d.allowWrite}),h.jsx(Hl,{label:"拒绝写入",paths:(p=(f=e.sandbox)==null?void 0:f.filesystem)==null?void 0:p.denyWrite})]})]})]})}function Tg(e){return e===!0?"是":e===!1?"否":"—"}function jd({label:e,value:t}){return h.jsxs("div",{className:"flex items-center justify-between gap-3 text-[12px]",children:[h.jsx("span",{className:"text-text-300",children:e}),h.jsx("span",{className:"font-mono text-text-100",children:t})]})}function Hl({label:e,paths:t}){const n=!t||t.length===0;return h.jsxs("div",{className:"flex flex-col gap-1",children:[h.jsx("span",{className:"text-[11px] text-text-300",children:e}),n?h.jsx("span",{className:"text-[11px] text-text-400",children:"—"}):h.jsx("div",{className:"flex flex-wrap gap-1",children:t.map((r,i)=>h.jsx("span",{className:"rounded-sm border border-border bg-bg-0 px-1.5 py-0.5 font-mono text-[11px] text-text-200",children:r},`${e}-${i}-${r}`))})]})}function mie({skills:e}){return h.jsxs("section",{className:"flex flex-col gap-2","data-testid":"persona-skills-section",children:[h.jsxs("header",{className:"flex flex-col gap-0.5",children:[h.jsxs("div",{className:"flex items-center gap-2",children:[h.jsx("span",{className:"text-[13px] font-medium text-text-100",children:"Persona Skills"}),h.jsx("span",{className:"rounded-sm border border-border px-1.5 py-0.5 text-[10px] text-text-300",children:e.length})]}),h.jsxs("span",{className:"text-[11px] text-text-400",children:["此 persona 私有 skills(来自"," ",h.jsx("code",{className:"font-mono",children:"<persona-dir>/.claude/skills/"}),")。"]})]}),e.length===0?h.jsx("span",{className:"text-[12px] text-text-300","data-testid":"persona-skills-empty",children:"暂无 skills"}):h.jsx("ul",{className:"flex flex-col divide-y divide-border rounded-md border border-border bg-bg-100",children:e.map(t=>h.jsxs("li",{className:"flex flex-col gap-0.5 px-3 py-2","data-testid":"persona-skill-row",children:[h.jsx("span",{className:"font-mono text-[13px] text-text-100",children:t.name}),t.description?h.jsx("span",{className:"text-[12px] text-text-300",children:t.description}):h.jsx("span",{className:"text-[11px] text-text-400 italic",children:"无描述"})]},t.name))})]})}function gie({plugins:e}){return h.jsxs("section",{className:"flex flex-col gap-2","data-testid":"persona-plugins-section",children:[h.jsxs("header",{className:"flex flex-col gap-0.5",children:[h.jsxs("div",{className:"flex items-center gap-2",children:[h.jsx("span",{className:"text-[13px] font-medium text-text-100",children:"Enabled Plugins"}),h.jsx("span",{className:"rounded-sm border border-border px-1.5 py-0.5 text-[10px] text-text-300",children:e.length})]}),h.jsxs("span",{className:"text-[11px] text-text-400",children:["此 persona 已启用的插件(来自"," ",h.jsx("code",{className:"font-mono",children:"<persona-dir>/.claude/settings.json"})," ","的 ",h.jsx("code",{className:"font-mono",children:"enabledPlugins"}),")。"]})]}),e.length===0?h.jsx("span",{className:"text-[12px] text-text-300","data-testid":"persona-plugins-empty",children:"暂无启用插件"}):h.jsx("ul",{className:"flex flex-col divide-y divide-border rounded-md border border-border bg-bg-100",children:e.map(t=>h.jsx("li",{className:"flex flex-col gap-0.5 px-3 py-2","data-testid":"persona-plugin-row",children:h.jsx("span",{className:"font-mono text-[13px] text-text-100",children:t.id})},t.id))})]})}function vie({onLoad:e,onSave:t,onDirtyChange:n,initialPersonality:r,readOnly:i=!1}){const s=r!==void 0,[o,a]=g.useState(s),[l,c]=g.useState(s?r:""),[u,d]=g.useState(s?r:""),[f,p]=g.useState(null),[m,v]=g.useState(!1),[b,_]=g.useState(null),x=Ze.useRef(e),y=Ze.useRef(t),w=Ze.useRef(n);Ze.useEffect(()=>{x.current=e,y.current=t,w.current=n});const C=Ze.useCallback(()=>{a(!1),p(null),x.current().then(P=>{c(P),d(P),a(!0)}).catch(P=>{p(P instanceof Error?P.message:String(P))})},[]);Ze.useEffect(()=>{s||C()},[s,C]);const k=!i&&o&&u!==l;Ze.useEffect(()=>{i||w.current(k)},[k,i]);const T=()=>{y.current&&(v(!0),_(null),y.current(u).then(()=>{c(u),v(!1)}).catch(P=>{_(P instanceof Error?P.message:String(P)),v(!1)}))},N=()=>{d(l),_(null)},z=ku(()=>{!k||m||T()},()=>{!k||m||N()});return h.jsxs("section",{className:"flex flex-col gap-2","data-testid":"persona-personality-section",children:[h.jsx("span",{className:"text-[12px] font-medium text-text-200",children:"人格 (Personality)"}),f?h.jsxs("div",{"data-testid":"persona-personality-load-error",className:"rounded-md border border-error bg-error-dim px-3 py-2 text-[12px] text-error flex items-center justify-between gap-2",children:[h.jsxs("span",{children:["加载失败:",f]}),h.jsx("button",{type:"button",onClick:C,className:"rounded-sm border border-error px-2 py-0.5 text-[11px] hover:bg-error/10",children:"重试"})]}):null,b?h.jsxs("div",{"data-testid":"persona-personality-save-error",className:"rounded-md border border-error bg-error-dim px-3 py-2 text-[12px] text-error",children:["保存失败:",b]}):null,h.jsx("textarea",{"data-testid":"persona-personality-textarea",value:u,onChange:P=>d(P.target.value),...z,readOnly:i,disabled:!i&&(!o||m),placeholder:o?"":"加载中…",rows:8,className:"min-h-[8rem] max-h-[18rem] resize-y rounded-md border border-border bg-bg-100 px-2 py-1.5 font-mono text-[11px] text-text-100 disabled:opacity-60"}),!i&&h.jsxs("p",{className:"text-[10px] text-text-400",children:["写入到 ",h.jsx("code",{className:"font-mono",children:"<persona-dir>/CLAUDE.md"}),"。 修改只对新启动的 sub-session 生效。"]}),o&&k?h.jsxs("div",{className:"flex justify-end gap-2",children:[h.jsx("button",{type:"button",onClick:N,disabled:m,className:"rounded-sm border border-border px-2 py-1 text-[12px] text-text-200 hover:bg-bg-200 disabled:opacity-60",children:"放弃"}),h.jsx("button",{type:"button",onClick:T,disabled:m,"data-testid":"persona-personality-save-btn",className:"rounded-sm bg-accent-dim px-2 py-1 text-[12px] text-text-100 hover:opacity-90 disabled:opacity-60",children:m?"保存中…":"保存"})]}):null]})}const _ie={state:"unbound",groups:[]};function xie(e,t){const[n,r]=g.useState(null);g.useEffect(()=>{if(!e)return;let l=!1;r(null);const c=async()=>{try{const f=await e.request("larkBot:status",{personaId:t});l||r(f)}catch{l||r(_ie)}};c();const u=e.on("larkBot:state",f=>{const p=f;if(p.personaId!==t)return;const{personaId:m,...v}=p;r(v)}),d=e.on("daemon:connected",()=>{c()});return()=>{l=!0,u(),d()}},[e,t]);const i=g.useCallback(async()=>{e&&await e.request("larkBot:provision",{personaId:t})},[e,t]),s=g.useCallback(async()=>{e&&await e.request("larkBot:provisionCancel",{personaId:t})},[e,t]),o=g.useCallback(async l=>{e&&await e.request("larkBot:bindManual",{personaId:t,...l})},[e,t]),a=g.useCallback(async()=>{e&&await e.request("larkBot:unbind",{personaId:t})},[e,t]);return{status:n,provision:i,cancelProvision:s,bindManual:o,unbind:a}}function yie(e,t="owner"){const{persona:n}=jN(e),r=OB(e),i=BB(),s=zB(),{httpBaseUrl:o}=tp(),a=ci(),l=xie(t==="guest"?null:a,e),{capabilities:c}=e1((n==null?void 0:n.tool)??"claude"),u=g.useMemo(()=>!(n!=null&&n.public)||!o||/^https?:\/\/(127\.0\.0\.1|localhost|0\.0\.0\.0|\[?::1\]?)([:/]|$)/i.test(o)?null:`${o}/s/${e}`,[n==null?void 0:n.public,o,e]),d=g.useCallback((y,w)=>{i(e,w).catch(C=>{Ae("persona",`${y} failed`,C)})},[i,e]),f=g.useCallback(y=>d("togglePublic",{public:y}),[d]),p=g.useCallback(y=>d("changeTool",{tool:y}),[d]),m=g.useCallback(y=>d("changeModel",{model:y}),[d]),v=g.useCallback(y=>d("changeEffort",{effort:y}),[d]),b=g.useCallback(()=>!n||!confirm(`删除 persona "${n.label}"?`)?!1:(s(e).catch(y=>{Ae("persona","delete failed",y)}),!0),[n,s,e]),_=g.useCallback(async()=>r.loaded?r.personality:(await r.refresh()).personality,[r]),x=g.useCallback(async y=>{await i(e,{personality:y}),await r.refresh()},[i,e,r]);return{persona:n,detail:r,models:(c==null?void 0:c.models)??[],configSchema:(c==null?void 0:c.configSchema)??[],larkBot:l,guestShareUrl:u,changeTool:p,changeModel:m,changeEffort:v,togglePublic:f,remove:b,loadPersonality:_,savePersonality:x}}function bie({personaId:e,open:t,onClose:n,api:r,embedded:i,onDirtyChange:s,onShareCapability:o,viewerRole:a="owner"}){const l=yie(e,a),{persona:c,detail:u}=l,d=g.useCallback(()=>{l.remove()&&n()},[l,n]);if(!c)return null;const f=a==="guest";return h.jsx(cie,{embedded:i,persona:{...c,skills:u.skills,plugins:u.plugins,sandboxSettings:u.sandboxSettings},open:t,onClose:n,onLoadPersonality:l.loadPersonality,onDirtyChange:s,readOnly:f,...f?{}:{onTogglePublic:l.togglePublic,guestShareUrl:l.guestShareUrl,onChangeTool:l.changeTool,onChangeModel:l.changeModel,onChangeEffort:l.changeEffort,models:l.models,configSchema:l.configSchema,onDelete:d,onSavePersonality:l.savePersonality,larkBot:{status:l.larkBot.status,onProvision:l.larkBot.provision,onCancelProvision:l.larkBot.cancelProvision,onBindManual:l.larkBot.bindManual,onUnbind:l.larkBot.unbind},...o?{onShareCapability:o}:{}}})}function wie(e){try{const t=new URL(e);return t.protocol==="ws:"?t.protocol="http:":t.protocol==="wss:"&&(t.protocol="https:"),`${t.protocol}//${t.host}`}catch{return e}}function Sie(e,t){try{const n=new URL(e),r=new URL(t);return n.protocol=r.protocol,n.host=r.host,n.toString()}catch{return e}}async function d1(e,t,n,r,i){const s=await e.attachmentSignUrl({sessionId:n,relPath:r,...i!==void 0?{ttlSeconds:i}:{}});return Sie(s.url,wie(t.url))}async function zC(e,t,n,r,i=60,s){const o=window.open("about:blank","_blank");try{s&&await s();const a=await d1(e,t,n,r,i);o?o.location.href=a:window.open(a,"_blank")}catch(a){throw o&&o.close(),a}}async function kie(e){var t;try{if((t=navigator.clipboard)!=null&&t.writeText)return await navigator.clipboard.writeText(e),!0}catch{}try{const n=document.createElement("textarea");n.value=e,n.style.position="fixed",n.style.left="-9999px",n.style.top="0",n.setAttribute("readonly",""),document.body.appendChild(n),n.select();const r=document.execCommand("copy");return document.body.removeChild(n),r}catch{return!1}}const Cie={...So,h1:({node:e,...t})=>h.jsx("h1",{...t,className:"mt-4 mb-3 text-[18px] font-semibold leading-tight text-text-100"}),h2:({node:e,...t})=>h.jsx("h2",{...t,className:"mt-4 mb-2 text-[16px] font-semibold leading-tight text-text-100"}),h3:({node:e,...t})=>h.jsx("h3",{...t,className:"mt-3 mb-2 text-[14px] font-semibold leading-tight text-text-100"}),h4:({node:e,...t})=>h.jsx("h4",{...t,className:"mt-3 mb-1 text-[13px] font-semibold text-text-100"}),h5:({node:e,...t})=>h.jsx("h5",{...t,className:"mt-2 mb-1 text-[12px] font-semibold text-text-100"}),h6:({node:e,...t})=>h.jsx("h6",{...t,className:"mt-2 mb-1 text-[12px] font-semibold text-text-300"}),p:({node:e,...t})=>h.jsx("p",{...t,className:"my-2 leading-relaxed"}),ul:({node:e,...t})=>h.jsx("ul",{...t,className:"my-2 list-disc space-y-1 pl-5"}),ol:({node:e,...t})=>h.jsx("ol",{...t,className:"my-2 list-decimal space-y-1 pl-5"}),li:({node:e,...t})=>h.jsx("li",{...t,className:"leading-relaxed"}),blockquote:({node:e,...t})=>h.jsx("blockquote",{...t,className:"my-2 border-l-2 border-border pl-3 italic text-text-300"}),code:({node:e,className:t,children:n,...r})=>t?h.jsx("code",{...r,className:`${t} font-mono text-[12px]`,children:n}):h.jsx("code",{...r,className:"rounded bg-bg-50 px-1 py-0.5 font-mono text-[12px] text-text-100",children:n}),pre:({node:e,...t})=>h.jsx("pre",{...t,className:"my-2 overflow-auto rounded border border-border bg-bg-0 p-3 text-[12px] font-mono text-text-100"}),hr:({node:e,...t})=>h.jsx("hr",{...t,className:"my-3 border-border"}),table:({node:e,...t})=>h.jsx("table",{...t,className:"my-2 w-full border-collapse text-[12px]"}),thead:({node:e,...t})=>h.jsx("thead",{...t,className:"bg-bg-50"}),th:({node:e,...t})=>h.jsx("th",{...t,className:"border border-border px-2 py-1 text-left font-semibold"}),td:({node:e,...t})=>h.jsx("td",{...t,className:"border border-border px-2 py-1"}),strong:({node:e,...t})=>h.jsx("strong",{...t,className:"font-semibold text-text-100"}),em:({node:e,...t})=>h.jsx("em",{...t,className:"italic"})};function Eie(e){const t=e.split("/");return t[t.length-1]||e}function T5({relPath:e,loadMarkdown:t,headerRight:n,showTitleBar:r=!1}){const[i,s]=g.useState(null),[o,a]=g.useState(null),[l,c]=g.useState(!1);return g.useEffect(()=>{if(!e)return;let u=!1;return c(!0),a(null),s(null),(async()=>{try{const d=await t(e);if(u)return;s(d)}catch(d){if(u)return;a(d.message||String(d))}finally{u||c(!1)}})(),()=>{u=!0}},[e,t]),h.jsxs("div",{className:"flex flex-col h-full",children:[r&&e?h.jsxs("div",{className:"flex items-center justify-between border-b border-border px-3 py-2",children:[h.jsx("div",{"data-testid":"md-preview-title",className:"truncate text-[13px] font-medium text-text-100",title:e,children:Eie(e)}),h.jsx("div",{className:"flex items-center gap-1",children:n})]}):null,h.jsx("div",{className:"flex-1 overflow-auto px-4 py-3 text-[13px] text-text-100",children:l?h.jsx("div",{"data-testid":"md-preview-loading",className:"text-text-400",children:"Loading…"}):o?h.jsx("div",{"data-testid":"md-preview-error",className:"text-destructive whitespace-pre-wrap",children:o}):i!==null?h.jsx("div",{"data-testid":"md-preview-content",className:"max-w-none",children:h.jsx(tu,{remarkPlugins:[ru],components:Cie,children:i})}):null})]})}function Tie({open:e,onOpenChange:t,relPath:n,loadMarkdown:r,onShare:i}){return e?h.jsx("div",{"data-testid":"md-preview-drawer",className:"fixed inset-y-0 right-0 z-50 flex w-1/2 max-w-[900px] flex-col border-l border-border bg-elevated shadow-2xl",children:h.jsx(T5,{relPath:n,loadMarkdown:r,showTitleBar:!0,headerRight:h.jsxs(h.Fragment,{children:[i?h.jsx("button",{type:"button","data-testid":"md-preview-share","aria-label":"Share rendered preview link",onClick:i,className:"inline-flex h-6 w-6 items-center justify-center rounded text-text-400 hover:bg-bg-50 hover:text-text-200",children:h.jsx(Fz,{className:"h-4 w-4"})}):null,h.jsx("button",{type:"button","aria-label":"Close preview",onClick:()=>t(!1),className:"inline-flex h-6 w-6 items-center justify-center rounded text-text-400 hover:bg-bg-50 hover:text-text-200",children:h.jsx(Dr,{className:"h-4 w-4"})})]})})}):null}function Nie({left:e,right:t,stage:n,onExpand:r,onCollapse:i}){const s=n==="stopped",[o,a]=g.useState(!1);async function l(){if(!o){a(!0);try{await r()}catch{}finally{a(!1)}}}async function c(){if(!o){a(!0);try{await i()}catch{}finally{a(!1)}}}return h.jsxs("div",{className:"flex h-full w-full min-h-0","data-testid":"two-pane-layout",children:[h.jsxs("div",{className:"relative flex min-w-0 flex-1 flex-col","data-testid":"two-pane-left",children:[s&&h.jsx("button",{type:"button",disabled:o,className:"absolute right-14 top-2 z-10 rounded border border-border bg-elevated px-2 py-1 text-[12px] text-text-100 hover:bg-bg-200 disabled:opacity-50 disabled:cursor-not-allowed",onClick:l,children:o?"启动中…":"展开预览"}),e]}),!s&&h.jsxs("div",{className:"flex w-1/2 min-w-[320px] flex-col border-l border-bg-200","data-testid":"two-pane-right",children:[h.jsx("div",{className:"flex items-center justify-end gap-2 border-b border-bg-200 bg-bg-50 px-2 py-1",children:h.jsx("button",{type:"button",disabled:o,className:"rounded px-2 py-1 text-[12px] text-text-300 hover:bg-bg-100 disabled:opacity-50",onClick:c,children:"收起预览"})}),h.jsx("div",{className:"min-h-0 flex-1",children:t})]})]})}const Pie=6173,Iie=6182;function Rie({open:e,onOpenChange:t,projectName:n,currentPort:r,allUsedPorts:i,onUpdate:s}){const o=[];for(let v=Pie;v<=Iie;v++)(v===r||!i.includes(v))&&o.push(v);const[a,l]=g.useState(r),[c,u]=g.useState(!1),[d,f]=g.useState(null),p=a!==r&&!c;async function m(){if(p){u(!0),f(null);try{await s(a),t(!1)}catch(v){f((v==null?void 0:v.message)??String(v))}finally{u(!1)}}}return h.jsx(c1,{open:e,onOpenChange:t,children:h.jsxs(zp,{className:"max-w-md",children:[h.jsxs($p,{children:[h.jsxs(Fp,{children:["改端口 · ",n]}),h.jsxs(E5,{children:["手改通常发生在系统其他进程占了默认分配的端口、dev server 起不来时。 提交后 daemon 会停 dev server → 写 ",h.jsx("code",{className:"mx-1 rounded bg-bg-100 px-1 py-0.5 text-[11px]",children:".clawd-project.json"})," → 用新端口重新起。"]})]}),h.jsxs("div",{className:"flex flex-col gap-2",children:[h.jsx("label",{className:"text-xs text-text-400",children:"新端口(仅显示段内可用 + 当前端口)"}),h.jsx("select",{className:"h-9 rounded-md border border-border bg-elevated px-3 py-1 text-sm text-text-100 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent",value:a,onChange:v=>l(Number(v.target.value)),disabled:c,children:o.map(v=>h.jsxs("option",{value:v,children:[v,v===r?"(当前)":""]},v))}),o.length===1&&h.jsx("div",{className:"text-[11px] text-text-400",children:"端口段已全被其它 project 占用,没有可换的;先删一个 idle project 释放端口。"}),d&&h.jsx("div",{className:"rounded border border-destructive/30 bg-destructive/5 px-3 py-2 text-[12px] text-destructive",children:d})]}),h.jsxs(u1,{children:[h.jsx(ni,{variant:"ghost",onClick:()=>t(!1),disabled:c,children:"取消"}),h.jsx(ni,{onClick:m,disabled:!p,children:c?"应用中…":"应用新端口"})]})]})})}const $C=[{stage:"build",label:"构建"},{stage:"deploy",label:"部署到阿里云"},{stage:"verify",label:"验证可访问性"}];function Mie({currentStage:e,onCancel:t}){const n=$C.findIndex(r=>r.stage===e);return h.jsxs("div",{"data-testid":"publish-progress",className:"flex items-center gap-3 border-b border-bg-200 bg-bg-50 px-3 py-1.5 text-[12px]",children:[$C.map((r,i)=>{const s=i<n,o=i===n,a=s?"text-text-300":o?"text-text-200":"text-text-500/50";return h.jsxs("span",{className:`flex items-center gap-1 ${a}`,children:[s?h.jsx(rp,{className:"size-3.5"}):o?h.jsx(In,{className:"size-3.5 animate-spin"}):h.jsx(BN,{className:"size-3.5"}),h.jsxs("span",{children:[r.label,o?"中…":""]})]},r.stage)}),h.jsx("button",{type:"button",onClick:t,className:"ml-auto rounded px-2 py-0.5 text-[11px] text-text-400 hover:bg-bg-100 hover:text-text-200",children:"取消"})]})}const Aie={build:"构建",deploy:"部署",verify:"验证"};function Lie({stage:e,onRetry:t,onDismiss:n}){return h.jsxs("div",{"data-testid":"publish-interrupted-banner",className:"flex items-center gap-2 border-b border-yellow-400/40 bg-yellow-400/10 px-3 py-1.5 text-[12px]",children:[h.jsx(Kc,{className:"size-3.5 text-yellow-500"}),h.jsxs("span",{className:"text-text-200",children:["上次发布在 ",h.jsxs("strong",{className:"font-medium",children:["[",Aie[e],"]"]})," ","阶段被中断(daemon 重启)"]}),h.jsx("button",{type:"button",onClick:t,className:"ml-auto rounded bg-accent-main-100 px-2 py-0.5 text-[11px] text-oncolor-100 hover:opacity-90",children:"重新发布"}),h.jsx("button",{type:"button",onClick:n,className:"rounded px-2 py-0.5 text-[11px] text-text-400 hover:bg-bg-100 hover:text-text-200",children:"取消"})]})}const jie={build:"构建",deploy:"部署",verify:"验证",unknown:"未知"};function Die({stage:e,onFocusChat:t,onClose:n}){return h.jsxs("div",{"data-testid":"publish-failed-banner",className:"flex items-center gap-2 border-b border-destructive/40 bg-destructive/10 px-3 py-1.5 text-[12px]",children:[h.jsx(Ls,{className:"size-3.5 text-destructive"}),h.jsxs("button",{type:"button",onClick:t,className:"flex-1 text-left text-text-200 hover:underline",children:["发布失败:",h.jsxs("strong",{className:"font-medium",children:["[",jie[e],"]"]})," ","已通知 assistant 接管 →"]}),h.jsx("button",{type:"button",onClick:n,"aria-label":"关闭失败提示",className:"rounded p-0.5 text-text-400 hover:bg-bg-100 hover:text-text-200",children:h.jsx(Dr,{className:"size-3.5"})})]})}const FC={"install-pending":{label:"等装依赖…",step:"1/3"},installing:{label:"安装依赖中…(可能要几十秒到几分钟)",step:"2/3"},"starting-dev-server":{label:"启动 dev server…(等监听端口才挂 iframe)",step:"3/3"}};function Oie({project:e,previewHost:t,previewScheme:n,onUpdatePort:r,allUsedPorts:i,publishSlot:s,publishInFlightStage:o,onDismissPublishJob:a,onRetryPublish:l,publishFailureBanner:c,onPublishFailureBannerClose:u,onPublishFailureBannerFocusChat:d}){var _,x;const[f,p]=g.useState(!1);if(!e)return h.jsx("div",{className:"flex h-full w-full items-center justify-center p-6 text-center text-[13px] text-text-400",children:"未绑定 project"});const m=e.stage??(e.isRunning?"running":"stopped"),v=t?`${n}://${t}/preview/${e.port}/`:null,b=e.prodUrl??null;return h.jsxs("div",{className:"flex h-full w-full flex-col","data-testid":"preview-pane",children:[h.jsxs("header",{className:"flex items-center justify-between gap-2 border-b border-bg-200 bg-bg-50 px-3 py-1.5",children:[h.jsxs("div",{className:"flex items-center gap-2 text-[12px]",children:[h.jsx("span",{className:"font-medium text-text-200",children:e.name}),h.jsx("span",{className:"rounded bg-bg-100 px-1.5 py-0.5 text-[11px] text-text-400",children:e.port}),h.jsx("span",{className:"text-[10px] uppercase tracking-wider text-text-500",children:m==="running"?"dev":m})]}),h.jsxs("div",{className:"flex items-center gap-2",children:[b?h.jsxs("a",{href:b,target:"_blank",rel:"noopener noreferrer",title:`打开线上:${b}`,className:"inline-flex items-center gap-1 rounded border border-bg-200 px-2 py-0.5 text-[11px] text-text-300 hover:bg-bg-100",children:[h.jsx(qc,{className:"size-3"}),"打开线上"]}):null,s,h.jsxs(hy,{children:[h.jsx(fy,{asChild:!0,children:h.jsx("button",{type:"button","aria-label":"Project settings",className:"rounded p-1 text-text-400 hover:bg-bg-100",children:h.jsx(h$,{className:"size-3.5"})})}),h.jsxs(gp,{align:"end",children:[h.jsx(yi,{onSelect:()=>p(!0),children:"Update Port…"}),h.jsxs(yi,{disabled:!0,title:"rename not supported yet",onSelect:y=>y.preventDefault(),children:["Name: ",e.name]})]})]})]})]}),c?h.jsx(Die,{stage:c.stage,onClose:()=>u==null?void 0:u(),onFocusChat:()=>d==null?void 0:d()}):null,((_=e.publishJob)==null?void 0:_.status)==="in-flight"?h.jsx(Mie,{currentStage:o??e.publishJob.stage,onCancel:()=>void(a==null?void 0:a())}):null,((x=e.publishJob)==null?void 0:x.status)==="interrupted"?h.jsx(Lie,{stage:e.publishJob.stage,onRetry:()=>void(l==null?void 0:l()),onDismiss:()=>void(a==null?void 0:a())}):null,h.jsx("div",{className:"min-h-0 flex-1",children:m==="failed"?h.jsx(Bie,{reason:e.stageReason}):m==="stopped"?null:m==="running"?v?h.jsx("iframe",{"data-testid":"preview-iframe",className:"size-full border-0 bg-white",src:v,title:"preview"}):h.jsx(HC,{label:"等 tunnel 起来…",step:"-"}):h.jsx(HC,{label:FC[m].label,step:FC[m].step})}),h.jsx(Rie,{open:f,onOpenChange:p,projectName:e.name,currentPort:e.port,allUsedPorts:i,onUpdate:async y=>{await r(y)}})]})}function HC({label:e,step:t}){return h.jsxs("div",{"data-testid":"preview-spinner",className:"flex h-full w-full flex-col items-center justify-center gap-3 p-6 text-center",children:[h.jsx(In,{className:"size-6 animate-spin text-accent-main-100"}),h.jsx("div",{className:"text-[13px] text-text-200",children:e}),h.jsx("div",{className:"text-[11px] uppercase tracking-wider text-text-500",children:t}),h.jsx("div",{className:"mt-2 max-w-[300px] text-[11px] text-text-500",children:"左侧 chat 可看 assistant 详细进度"})]})}function Bie({reason:e}){return h.jsxs("div",{"data-testid":"preview-failed",className:"flex h-full w-full flex-col items-center justify-center gap-3 p-6 text-center",children:[h.jsx(Ls,{className:"size-6 text-destructive"}),h.jsx("div",{className:"text-[13px] text-text-200",children:"project 启动失败"}),h.jsx("div",{className:"max-w-[400px] text-[12px] text-text-400",children:e??"未知原因 —— 看 ~/.clawd/clawd.log 排查"}),h.jsx("div",{className:"mt-1 max-w-[300px] text-[11px] text-text-500",children:"左侧 chat 可看 assistant 详细进度 / 跟它说怎么修"})]})}function zie({error:e,onClose:t}){const[n,r]=g.useState(!1),i=async()=>{var a;if(!e)return;const s=e.message;let o=!1;try{(a=navigator.clipboard)!=null&&a.writeText&&(await navigator.clipboard.writeText(s),o=!0)}catch{o=!1}if(!o){const l=document.createElement("textarea");l.value=s,l.style.position="fixed",l.style.opacity="0",document.body.appendChild(l),l.select();try{document.execCommand("copy"),o=!0}catch{o=!1}finally{document.body.removeChild(l)}}o&&(r(!0),setTimeout(()=>r(!1),1500))};return h.jsx(c1,{open:!!e,onOpenChange:s=>{s||(r(!1),t())},children:h.jsxs(zp,{className:"max-w-lg",children:[h.jsx($p,{children:h.jsx(Fp,{children:(e==null?void 0:e.title)??"错误"})}),h.jsx("pre",{"data-testid":"rpc-error-message",className:"max-h-72 overflow-auto whitespace-pre-wrap break-words rounded border border-bg-200 bg-bg-50 px-3 py-2 text-[12px] text-text-200",children:(e==null?void 0:e.message)??""}),h.jsxs(u1,{children:[h.jsx(ni,{variant:"ghost",onClick:i,className:"gap-1.5",children:n?h.jsxs(h.Fragment,{children:[h.jsx(ul,{className:"size-3.5"}),"已复制"]}):h.jsxs(h.Fragment,{children:[h.jsx(ip,{className:"size-3.5"}),"复制"]})}),h.jsx(ni,{onClick:t,children:"关闭"})]})]})})}function $ie(e,t){for(const n of[e,t])if(n)try{const r=new URL(n),i=r.protocol==="https:"||r.protocol==="wss:"?"https":"http";return{host:r.host,scheme:i}}catch{}return{host:null,scheme:"https"}}const Fie={codex:"on-request",claude:"bypassPermissions"};function Hie(e){const t={cwd:e.cwd,permissionMode:e.sourcePermissionMode??Fie[e.sourceTool??"claude"]??"bypassPermissions",forkedFromSessionId:e.sourceSessionId};return e.sourceOwnerPersonaId&&(t.ownerPersonaId=e.sourceOwnerPersonaId),e.sourceTool&&(t.tool=e.sourceTool),e.sourceProjectPath&&(t.projectPath=e.sourceProjectPath),t}async function Uie(e,t,n,r={}){if(!t.toolSessionId)return null;const i=await e.sessionCreate({...Hie({cwd:t.cwd,sourceSessionId:t.sessionId,sourcePermissionMode:t.permissionMode,sourceOwnerPersonaId:t.ownerPersonaId,sourceTool:t.tool,sourceProjectPath:t.projectPath}),...r.ephemeral?{ephemeral:!0}:{}});try{const{forkedToolSessionId:s}=await e.sessionFork({cwd:t.cwd,toolSessionId:t.toolSessionId,messageUuid:n,targetCwd:i.cwd});await e.sessionResume(i.sessionId,s)}catch(s){throw e.sessionDelete(i.sessionId).catch(o=>Ae("quick-ask","fork rollback failed",o)),s}return i}async function Wie(e,t,n){return Uie(e,t,n,{ephemeral:!0})}function Dd(e){return e!=null&&e.ephemeral!==!1}async function Vie(e,t){return t.stillEphemeral?(await e.sessionUpdate(t.sessionId,{ephemeral:!1}),!0):!1}const qie=300;function Kie(e){return e&&typeof e=="object"&&"value"in e?e.value:e}function Gie(e,t){const n=bx(),[r,i]=g.useState(null),s=g.useRef(null);g.useEffect(()=>{let a=!1;return(async()=>{try{const l=await n.kv.get(e);if(a)return;const c=Kie(l);typeof c=="number"&&Number.isFinite(c)&&c>0?i(c):i(t)}catch{a||i(t)}})(),()=>{a=!0}},[n,e,t]);const o=g.useCallback(a=>{s.current&&clearTimeout(s.current),s.current=setTimeout(()=>{s.current=null,n.kv.set(e,a).catch(()=>{})},qie)},[n,e]);return g.useEffect(()=>()=>{s.current&&(clearTimeout(s.current),s.current=null)},[]),{initialSize:r??t,setSize:o,loading:r===null}}function Yie(){return{quickAsk:null,mds:[],active:null}}function Xie(e,t){return{...e,quickAsk:{sessionId:t.sessionId,ephemeral:!0},active:"quick-ask"}}function Qie(e,t){const n=e.mds.includes(t);return{...e,mds:n?e.mds:[...e.mds,t],active:{kind:"md",relPath:t}}}function Zie(e){if(!e.quickAsk)return e;const t=e.active==="quick-ask",n=e.mds[0],r=t?n?{kind:"md",relPath:n}:null:e.active;return{...e,quickAsk:null,active:r}}function Jie(e){return e.quickAsk?{...e,quickAsk:{...e.quickAsk,ephemeral:!1}}:e}function ese(e,t){const n=e.mds.indexOf(t);if(n<0)return e;const r=e.mds.filter(l=>l!==t);if(!(e.active!==null&&e.active!=="quick-ask"&&e.active.relPath===t))return{...e,mds:r};const s=r[n],o=n>0?r[n-1]:void 0;let a=null;return s?a={kind:"md",relPath:s}:o?a={kind:"md",relPath:o}:e.quickAsk&&(a="quick-ask"),{...e,mds:r,active:a}}function tse(e,t){return{...e,active:t}}function nse(e,t){return e===null||t===null||e==="quick-ask"||t==="quick-ask"?e===t:e.relPath===t.relPath}function N5(e){return e.quickAsk!==null||e.mds.length>0}function rse(e){return e.split("/").pop()||e}function ise({state:e,api:t,onSwitchTab:n,onCloseQuickAsk:r,onCloseMd:i,loadMarkdown:s,quickAskSession:o,onPromoteQuickAsk:a}){if(!N5(e))return null;const l=[];e.quickAsk&&l.push({id:"quick-ask",label:"问一下",title:"问一下",icon:h.jsx(d0,{className:"w-3.5 h-3.5"})});for(const c of e.mds)l.push({id:{kind:"md",relPath:c},label:rse(c),title:c,icon:h.jsx(Ro,{className:"w-3.5 h-3.5"})});return h.jsxs("div",{className:"flex flex-col h-full bg-bg-50/60 border-l border-border-strong",children:[h.jsx(rf,{delayDuration:200,skipDelayDuration:100,children:h.jsx("div",{className:["flex items-stretch h-9 border-b border-text-100/10 shrink-0 overflow-x-auto","[scrollbar-width:none] [-ms-overflow-style:none]","[&::-webkit-scrollbar]:hidden"].join(" "),role:"tablist",children:l.map(c=>{const u=nse(e.active,c.id),d=c.id==="quick-ask"?"quick-ask":`md:${c.id.relPath}`;return h.jsxs(yp,{children:[h.jsx(bp,{asChild:!0,children:h.jsxs("div",{role:"tab","aria-selected":u,"data-tab-title":c.title,onClick:()=>n(c.id),className:["group relative flex items-center gap-2 px-3 h-full cursor-pointer select-none","text-[12px] max-w-[180px] shrink-0 transition-colors duration-100",u?"text-text-100":"text-text-400 hover:text-text-100 hover:bg-text-100/[0.04]"].join(" "),children:[c.icon,h.jsx("span",{className:"truncate",children:c.label}),h.jsx("button",{type:"button","aria-label":`关闭 ${c.label}`,className:["ml-1 rounded p-0.5 shrink-0 transition-opacity","hover:bg-text-100/10",u?"opacity-70 hover:opacity-100":"opacity-0 group-hover:opacity-70"].join(" "),onClick:f=>{f.stopPropagation(),c.id==="quick-ask"?r():i(c.id.relPath)},children:h.jsx(Dr,{className:"w-3 h-3"})}),u?h.jsx("span",{"aria-hidden":"true",className:"absolute left-2 right-2 -bottom-px h-[2px] rounded-full bg-accent"}):null]})}),h.jsx(Cu,{side:"bottom",align:"start",className:"max-w-sm break-all",children:c.title})]},d)})})}),h.jsxs("div",{className:"flex-1 min-h-0 overflow-hidden relative",children:[e.quickAsk&&o?h.jsx("div",{className:"absolute inset-0",style:{display:e.active==="quick-ask"?"block":"none"},children:h.jsx(cse,{session:o,api:t,...a?{onPromoteQuickAsk:a}:{}})}):null,e.mds.map(c=>{const u=e.active!==null&&e.active!=="quick-ask"&&e.active.relPath===c;return h.jsx("div",{className:"absolute inset-0",style:{display:u?"block":"none"},children:h.jsx(T5,{relPath:c,loadMarkdown:s,showTitleBar:!1})},`md-body:${c}`)})]})]})}function sse({state:e,extras:t}){const{api:n,session:r}=t,i=ci(),[s,o]=g.useState(Yie()),a=g.useRef(s);a.current=s;const l=g.useRef(!1),c=g.useCallback(async C=>{const k=a.current.quickAsk,T=await Wie(n,r,C);if(T){if(l.current){n.sessionDelete(T.sessionId).catch(()=>{});return}Dd(k)&&n.sessionDelete(k.sessionId).catch(()=>{}),o(N=>Xie(N,{sessionId:T.sessionId}))}},[n,r]),u=g.useCallback(async C=>{const k=a.current.quickAsk,T=(k==null?void 0:k.sessionId)===C;try{await Vie(n,{sessionId:C,stillEphemeral:T&&Dd(k)})&&o(z=>Jie(z))}catch(N){Ae("quick-ask","promote failed",N)}},[n]),d=g.useCallback(C=>{o(k=>Qie(k,C))},[]),f=g.useCallback(C=>{o(k=>tse(k,C))},[]),p=g.useCallback(()=>{const C=a.current.quickAsk;Dd(C)&&n.sessionDelete(C.sessionId).catch(()=>{}),o(k=>Zie(k))},[n]),m=g.useCallback(C=>{o(k=>ese(k,C))},[]);g.useEffect(()=>()=>{l.current=!0;const C=a.current.quickAsk;Dd(C)&&n.sessionDelete(C.sessionId).catch(()=>{})},[]);const v=si("sessions")??[],b=s.quickAsk?v.find(C=>C.sessionId===s.quickAsk.sessionId)??{sessionId:s.quickAsk.sessionId,cwd:r.cwd,tool:r.tool}:null,_=g.useCallback(async C=>{const k=await d1(n,i,r.sessionId,C,60),T=await fetch(k);if(!T.ok)throw new Error(`fetch ${T.status} ${T.statusText}`);return T.text()},[n,i,r.sessionId]),x=h.jsx(h1,{state:e,extras:t,onQuickAskInternal:c,onPreviewMdInternal:d}),{initialSize:y,setSize:w}=Gie("chat-panel-right-slot-width",480);return h.jsxs(Sy,{orientation:"horizontal",className:"flex-1 flex min-w-0 min-h-0",children:[h.jsx(sf,{id:"chat",minSize:"400px",children:x}),N5(s)?h.jsxs(h.Fragment,{children:[h.jsx(TR,{className:"w-1 bg-text-100/10 hover:bg-text-100/25 transition-colors cursor-col-resize"}),h.jsx(sf,{id:"right-slot",defaultSize:`${y}px`,minSize:"360px",maxSize:"800px",onResize:C=>w(C.inPixels),children:h.jsx(ise,{state:s,api:n,onSwitchTab:f,onCloseQuickAsk:p,onCloseMd:m,loadMarkdown:_,quickAskSession:b,onPromoteQuickAsk:u})})]}):null]})}const ose={closeTrailing:!1},ase={closeTrailing:!0};function lse(e){return e?ose:ase}function cse({session:e,api:t,onPromoteQuickAsk:n}){const r=UA(e.sessionId);return h.jsx(h1,{state:r,extras:{session:e,api:t,...n?{onPromoteQuickAsk:n}:{}}})}function use({extras:e}){const t=UA(e.session.sessionId);if(e.session.appBuilderProject){const n=h.jsx(h1,{state:t,extras:e});return h.jsx(dse,{state:t,chat:n,extras:e})}return h.jsx(sse,{state:t,extras:e})}function dse({state:e,chat:t,extras:n}){var N;const r=si("daemon-info"),i=ci(),s=n.api,o=n.session,a=o.appBuilderProject,[l,c]=g.useState(null),u=g.useCallback(()=>{s.appBuilderGetProject(o.sessionId).then(z=>c(z.project)).catch(()=>c(null))},[s,o.sessionId]);g.useEffect(()=>{u()},[u]);const[d,f]=g.useState([]),p=g.useCallback(()=>{s.appBuilderListProjects().then(z=>f(z.projects)).catch(()=>f([]))},[s]);g.useEffect(()=>{p()},[p]),g.useEffect(()=>i.on("appBuilder:project-updated",P=>{const B=P;B!=null&&B.project&&(B.project.name===a&&c(B.project),f(R=>{const I=R.findIndex(L=>L.name===B.project.name);if(I<0)return[...R,B.project];const j=R.slice();return j[I]=B.project,j}))}),[i,a]);const{host:m,scheme:v}=$ie(i.url,r==null?void 0:r.tunnelUrl),[b,_]=g.useState(void 0),[x,y]=g.useState(null);g.useEffect(()=>{const z=i.on("appBuilder:publish-progress",B=>{const R=B;!R||R.name!==a||R.status==="started"&&_(R.stage)}),P=i.on("appBuilder:publish-failed",B=>{const R=B;!R||R.name!==a||(_(void 0),y({stage:R.stage}))});return()=>{z(),P()}},[i,a]),g.useEffect(()=>{_(void 0),y(null)},[a]);const[w,C]=g.useState(null),k=h.jsx("button",{type:"button",className:"rounded bg-accent-main-100 px-2.5 py-1 text-[12px] text-oncolor-100 hover:opacity-90 disabled:cursor-not-allowed disabled:opacity-50",disabled:((N=l==null?void 0:l.publishJob)==null?void 0:N.status)==="in-flight",onClick:async()=>{try{await s.appBuilderPublish(a)}catch(z){C({title:"发布请求失败",message:(z==null?void 0:z.message)??String(z)})}},children:"发布上线"}),T=(l==null?void 0:l.stage)??(l!=null&&l.isRunning?"running":"stopped");return h.jsxs(h.Fragment,{children:[h.jsx(Nie,{left:t,stage:T,onExpand:async()=>{await s.appBuilderStartDevServer(o.sessionId)},onCollapse:async()=>{await s.appBuilderStopDevServer(o.sessionId)},right:h.jsx(Oie,{project:l,previewHost:m,previewScheme:v,allUsedPorts:d.map(z=>z.port),onUpdatePort:async z=>{await s.appBuilderUpdateProjectPort(a,z),p()},publishSlot:k,publishInFlightStage:b,onDismissPublishJob:async()=>{try{await s.appBuilderDismissPublishJob(a)}catch(z){C({title:"取消发布失败",message:(z==null?void 0:z.message)??String(z)})}},onRetryPublish:async()=>{try{await s.appBuilderPublish(a)}catch(z){C({title:"重新发布失败",message:(z==null?void 0:z.message)??String(z)})}},publishFailureBanner:x,onPublishFailureBannerClose:()=>y(null),onPublishFailureBannerFocusChat:()=>{}})}),h.jsx(zie,{error:w,onClose:()=>C(null)})]})}function hse({headerMeta:e,connState:t,liveWorktreeRoot:n,onOpenConfig:r,variant:i="full",ephemeral:s,onPromote:o,lines:a,pendingPermissions:l,procAlive:c,rewindableUserMessageIds:u,onPermissionRespond:d,onPermissionInterrupt:f,onRewind:p,onFork:m,onQuickAsk:v,topSlot:b,realtimeQuestionAnswers:_,onSubmitQuestion:x,onCancelQuestion:y,liveQuestionToolUseIds:w,api:C,cwd:k,tool:T,sessionKey:N,onSend:z,awaitingUser:P,onAbort:B,onNewSession:R,onClearSession:I,configSlot:j,chatRootRef:L,chatBodyRef:$,drawers:F,xtermSlot:D,fileSharingScope:O,onShareFile:E,onOpenInTab:H,onPreviewMarkdown:V,onOpenFilePath:A}){return h.jsx(_Z,{children:h.jsxs("div",{ref:L,"data-cc-chat-root":"",className:"flex flex-col h-full bg-bg-100",children:[h.jsx(pJ,{meta:e,...T?{tool:T}:{},connState:t,variant:i,...n!==void 0?{liveWorktreeRoot:n}:{},...i==="full"&&r?{onOpenConfig:r}:{},...i==="quickask"?{ephemeral:s??!1,...o?{onPromote:o}:{}}:{}}),h.jsx("div",{ref:$,"data-testid":"chat-body",className:"flex-1 overflow-y-auto min-h-0",style:{overflowAnchor:"none"},children:h.jsx(VM,{lines:a,...d?{onPermissionRespond:d}:{},...f&&c?{onPermissionInterrupt:f}:{},topSlot:b,...p?{onRewind:p}:{},rewindableUserMessageIds:u,...m?{onFork:m}:{},...v?{onQuickAsk:v}:{},realtimeQuestionAnswers:_,onSubmitQuestion:x,...y?{onCancelQuestion:y}:{},liveQuestionToolUseIds:w,...O?{fileSharingScope:O}:{},...E?{onShareFile:E}:{},...H?{onOpenInTab:H}:{},...V?{onPreviewMarkdown:V}:{},...A?{onOpenFilePath:A}:{},...i==="full"?{turnCollapse:lse(c)}:{}})}),D,e.larkChatName?h.jsx("div",{className:"mx-3 mb-3 rounded-lg border border-border bg-bg-200 px-3 py-2 text-[12px] text-text-400","data-testid":"lark-readonly-notice",children:e.larkChatType==="p2p"?`此会话由与「${e.larkChatName}」的飞书私聊驱动——对方消息触发,这里仅供观察。`:`此会话由飞书群「${e.larkChatName}」驱动——群成员 @ bot 提问触发,这里仅供观察。`}):h.jsx(hJ,{meta:e,...C?{api:C}:{},cwd:k,...T?{tool:T}:{},sessionKey:N,onSend:z,awaitingUser:P,...B?{onAbort:B}:{},...R?{onNewSession:R}:{},...I?{onClearSession:I}:{},...j?{configSlot:j}:{}}),F]})})}function h1({state:e,extras:t,onQuickAskInternal:n,onPreviewMdInternal:r}){const{session:i,api:s,liveGitBranch:o,liveWorktreeRoot:a,onNewSession:l,onTurnEnd:c,onOpenConfig:u,onFork:d,onQuickAsk:f,viewerRole:p,onPromoteQuickAsk:m,configSlot:v}=t,{capabilities:b}=e1(i.tool||"claude"),_=(b==null?void 0:b.features)??IN(i.tool),[x,y]=g.useState(null),[w,C]=g.useState(null),k=tp(),T=!!s&&k.actionsLevel==="owner"&&_.fileSharing,N=jN(i.ownerPersonaId??null).persona,z=(N==null?void 0:N.label)??null,P=!!z&&!!i.ownerPersonaId,B=g.useCallback((te,oe)=>{y({kind:te,text:oe}),setTimeout(()=>{y(de=>(de==null?void 0:de.text)===oe?null:de)},2e3)},[]),R=ci(),I=fB(),j=HA(i.sessionId,i.toolSessionId),{events:L,pendingQuestions:$,clearQuestion:F,markQuestionSubmitted:D,status:O}=j,E=e.historyLoading,H=QM(O);g.useEffect(()=>{Ae("chat-panel","sessionStatus",{sessionId:i.sessionId,sessionStatus:O,procAlive:H})},[O,H,i.sessionId]);const V=e.lines,A=e.pendingPermissions,ne=A[0]??null,ae=g.useMemo(()=>oW(L),[L]),[G,ye]=g.useState(null),[Fe,ue]=g.useState(()=>new Set);rW(s,i.sessionId,i.toolSessionId,_.observe);const Ie=g.useRef(i.sessionId);g.useEffect(()=>{if(Ie.current=i.sessionId,!_.rewind){ye(null);return}let te=!1;return ye(null),(async()=>{try{const oe=await s.sessionRewindableMessageIds(i.sessionId);if(te)return;ye(new Set(oe.userMessageIds))}catch{te||ye(null)}})(),()=>{te=!0}},[s,i.sessionId,_.rewind]);const Re=g.useCallback(()=>{const te=i.sessionId;s.sessionRewindableMessageIds(te).then(oe=>{Ie.current===te&&ye(new Set(oe.userMessageIds))}).catch(()=>{})},[s,i.sessionId]),Ke=g.useMemo(()=>{if(G!==null){const je=new Set(G);for(const $t of Fe)je.delete($t);return je}const te=new Set(["Edit","Write","MultiEdit","NotebookEdit"]),oe=new Set;let de=null;for(const je of V)je.kind==="user-text"?de=je.uuid??null:de&&je.kind==="tool-call"&&te.has(je.tool)&&!Fe.has(de)&&oe.add(de);return oe},[V,Fe,G]),ve=g.useRef(c);ve.current=c,iW(i.sessionId,i.toolSessionId,()=>{Gt(null),ue(new Set)});const ze=LJ({sessionStatus:O}),fn=g.useRef(null);g.useEffect(()=>{var de;const te=fn.current,oe=(te==null?void 0:te.sid)===i.sessionId;oe&&te.phase===ze||(fn.current={sid:i.sessionId,phase:ze},Ae("session-phase",ze,{sid:i.sessionId,phase:ze,prev:oe?te.phase:null,desc:AJ[ze]}),oe&&te.phase==="turn-running"&&ze!=="turn-running"&&((de=ve.current)==null||de.call(ve),Re()))},[ze,i.sessionId,Re]);const it=g.useCallback(()=>{s.sessionInterrupt(i.sessionId).catch(()=>{})},[s,i.sessionId]),[Rt,Gt]=g.useState(null),Mt=g.useCallback(te=>{Gt(te)},[]),[bt,Qe]=g.useState(!1),st=g.useCallback(()=>{s.sessionStop(i.sessionId).catch(()=>{}),Qe(!1)},[s,i.sessionId]);g.useCallback(te=>{s.pinSession(i.sessionId,te).catch(oe=>{Ae("chat-panel","pinSession failed",{err:oe==null?void 0:oe.message})})},[s,i.sessionId]);const wt=m?"quickask":"full",{container:pn,onCollapse:on}=xJ(),U=g.useRef(0),Z=g.useRef(null);g.useEffect(()=>{const te=oe=>{if(oe.key!=="Escape")return;if(!H){U.current=0;return}if(oe.isComposing)return;const je=oe.target;if(je&&je.closest("[data-cc-chat-root]")!==Z.current)return;const $t=Date.now();$t-U.current<2e3?(U.current=0,Qe(!0)):(U.current=$t,it())};return window.addEventListener("keydown",te),()=>window.removeEventListener("keydown",te)},[it,H]);const _e=g.useRef(null),ke=g.useRef(!0),He=g.useRef(void 0),Nt=g.useRef(0),Yt=g.useRef(0),Xt=g.useRef(void 0);g.useEffect(()=>{C(null)},[i.sessionId]),g.useEffect(()=>{const te=_e.current;if(!te)return;const oe=150,de=je=>{Date.now()<Yt.current&&(je.preventDefault(),Yt.current=Date.now()+oe)};return te.addEventListener("wheel",de,{passive:!1}),()=>te.removeEventListener("wheel",de)},[]),g.useEffect(()=>{const te=_e.current;if(!te)return;const oe=32,de=()=>{const je=te.scrollHeight-te.scrollTop-te.clientHeight;ke.current=je<=oe};return te.addEventListener("scroll",de,{passive:!0}),()=>te.removeEventListener("scroll",de)},[]),g.useLayoutEffect(()=>{var $s;const te=_e.current;if(!te)return;const oe=Xt.current!==i.sessionId;oe&&(Xt.current=i.sessionId,ke.current=!0,He.current=void 0,Nt.current=0,Yt.current=0);const de=He.current,je=($s=V[0])==null?void 0:$s.seq;He.current=je,!oe&&de!==void 0&&je!==void 0&&je<de?(te.scrollTop=te.scrollHeight-Nt.current,Yt.current=Date.now()+200):ke.current&&(te.scrollTop=te.scrollHeight),Nt.current=te.scrollHeight-te.scrollTop},[V,ne==null?void 0:ne.requestId,i.sessionId]);const se=g.useMemo(()=>{const te={};for(const[oe,de]of Object.entries($))de.submittedAnswers&&(te[oe]=de.submittedAnswers);return te},[$]),K=g.useMemo(()=>new Set(Object.keys($)),[$]),we=g.useCallback(async(te,oe)=>{try{await s.answerQuestion({sessionId:i.sessionId,toolUseId:te,answers:oe}),D(te,oe)}catch{}},[s,i.sessionId,D]),ht=g.useCallback(async te=>{try{await s.cancelQuestion({sessionId:i.sessionId,toolUseId:te}),F(te)}catch{}},[s,i.sessionId,F]),an=g.useCallback(async(te,oe)=>{var de;if(ne)try{await((de=e.respondPermission)==null?void 0:de.call(e,ne.requestId,te?"allow":"deny"))}catch{}},[e,ne]),_l=g.useCallback(async()=>{const te=i.sessionId;try{await s.sessionStop(te)}catch{}e.clearSession?await e.clearSession():await s.sessionNew(te)},[e,s,i.sessionId]),xl=g.useMemo(()=>e.historyError?h.jsxs("div",{className:"flex justify-center py-2 text-[12px] text-text-400","data-testid":"history-error",children:["历史未加载完(",e.historyError,");切走再切回可重试"]}):E&&V.length===0?h.jsx("div",{className:"flex justify-center py-4","data-testid":"history-loading",children:h.jsx(In,{className:"w-4 h-4 text-text-400 animate-spin"})}):null,[E,V.length,e.historyError]),zo=e.meta,Hp=h.jsxs(h.Fragment,{children:[i.toolSessionId&&_.subagents?h.jsx(EJ,{api:s,cwd:i.cwd,toolSessionId:i.toolSessionId,toolKind:i.tool??"claude"}):null,Rt&&_.rewind?h.jsx(NJ,{open:!0,onOpenChange:te=>{te||Gt(null)},api:s,sessionId:i.sessionId,userMessageId:Rt,lines:V,procAlive:H,onNoChanges:te=>{ue(oe=>{if(oe.has(te))return oe;const de=new Set(oe);return de.add(te),de})}}):null,bt?h.jsx(fse,{onConfirm:st,onCancel:()=>Qe(!1)}):null]}),ju={kind:"session",sessionId:i.sessionId},Du=g.useCallback(async te=>{if(s)try{await zC(s,R,i.sessionId,te)}catch(oe){const de=oe.message;Ae("chat-panel","open-in-tab failed",{err:de}),B("err",`Open in tab 失败:${de}`)}},[s,R,i.sessionId,B]),[Ou,zs]=g.useState(!1),[Wi,yl]=g.useState(null),Vi=g.useCallback(te=>{if(r){r(te);return}yl(te),zs(!0)},[r]),qi=g.useCallback(te=>{if(!s)return;const oe=async()=>{try{await s.attachmentGroupAdd(i.sessionId,te)}catch(je){Ae("chat-panel","file-link groupAdd skipped",{err:je.message})}},de=je=>{const $t=je.message;Ae("chat-panel","file-link open failed",{err:$t}),B("err",`打开文件失败:${$t}`)};if(Pp(te)){oe().then(()=>Vi(te),de);return}zC(s,R,i.sessionId,te,60,oe).catch(de)},[s,R,i.sessionId,Vi,B]),Ki=g.useCallback(async te=>{if(!s)throw new Error("daemon api not ready");const oe=await d1(s,R,i.sessionId,te,60),de=await fetch(oe);if(!de.ok)throw new Error(`fetch ${de.status} ${de.statusText}`);return await de.text()},[s,R,i.sessionId]),$o=g.useCallback(async(te,oe)=>{if(s)try{const{url:de}=await s.attachmentSignUrl({sessionId:i.sessionId,relPath:te,ttlSeconds:86400,...oe?{view:oe}:{}}),je=await kie(de);B(je?"ok":"err",je?"分享链接已复制到剪贴板(24h 有效)":"复制失败:请手动复制")}catch(de){const je=de.message;Ae("chat-panel","share-file failed",{err:je}),B("err",`生成分享链接失败:${je}`)}},[s,i.sessionId,B]),Fo=g.useCallback(()=>C(null),[]),zt=w==="files"&&T&&s?{title:"Edited Files",onBack:Fo,content:h.jsx(rre,{api:s,scope:ju,sessionId:i.sessionId,onShareFile:$o,onOpenInTab:Du,onPreviewMarkdown:Vi})}:w==="cron"?{title:`定时任务${ae.length?` (${ae.length})`:""}`,onBack:Fo,content:h.jsx("div",{className:"p-3",children:h.jsx(MJ,{jobs:ae})})}:w==="persona"&&P&&s&&i.ownerPersonaId?{title:`Persona · ${z??""}`,onBack:Fo,content:h.jsx(bie,{personaId:i.ownerPersonaId,open:!0,onClose:Fo,api:s,embedded:!0,...p?{viewerRole:p}:{}},i.ownerPersonaId)}:null,bl=wt==="full"?h.jsx(vJ,{session:i,meta:zo,...o!==void 0?{liveGitBranch:o}:{},...a!==void 0?{liveWorktreeRoot:a}:{},...P?{personaName:z}:{},...P?{onOpenPersona:()=>C("persona")}:{},...T?{onOpenFiles:()=>C("files")}:{},cronActiveCount:ae.length,onCronClick:()=>C("cron"),onForceStop:()=>Qe(!0),...p?{viewerRole:p}:{},...b!=null&&b.toolSessionIdLabel?{toolSessionIdLabel:b.toolSessionIdLabel}:{},drill:zt,...on?{onCollapse:on}:{}}):null;return h.jsxs(h.Fragment,{children:[pn&&bl?el.createPortal(bl,pn):null,h.jsx(hse,{headerMeta:zo,connState:e.connState,...a!==void 0?{liveWorktreeRoot:a}:{},...u?{onOpenConfig:u}:{},variant:wt,...wt==="quickask"?{ephemeral:i.ephemeral!==!1,onPromote:()=>void(m==null?void 0:m(i.sessionId))}:{},lines:V,pendingPermissions:A,procAlive:H,rewindableUserMessageIds:Ke,onPermissionRespond:an,onPermissionInterrupt:it,onRewind:_.rewind?Mt:void 0,...d&&_.fork?{onFork:d}:{},...n&&_.fork?{onQuickAsk:n}:f&&_.fork?{onQuickAsk:f}:{},topSlot:xl,realtimeQuestionAnswers:se,onSubmitQuestion:we,onCancelQuestion:ht,liveQuestionToolUseIds:K,api:s,cwd:i.cwd,...i.tool?{tool:i.tool}:{},sessionKey:i.sessionId,onSend:e.sendText,awaitingUser:A.length>0||Object.values($).some(te=>!te.submittedAnswers),onAbort:it,...l?{onNewSession:l}:{},onClearSession:_l,...v?{configSlot:v}:{},chatRootRef:Z,chatBodyRef:_e,drawers:Hp,xtermSlot:I==="tui"&&H&&_.tui?h.jsx(Gne,{sessionId:i.sessionId,client:R},i.sessionId):null,fileSharingScope:ju,...s?{onShareFile:$o}:{},...s?{onOpenInTab:Du}:{},...s?{onPreviewMarkdown:Vi}:{},...s?{onOpenFilePath:qi}:{}}),s?h.jsx(Tie,{open:Ou,onOpenChange:zs,relPath:Wi,loadMarkdown:Ki,onShare:Wi?()=>void $o(Wi,"md-rendered"):void 0}):null,x?h.jsx("div",{"data-testid":"share-toast",role:"status","aria-live":"polite",className:x.kind==="ok"?"fixed left-1/2 top-4 z-50 -translate-x-1/2 rounded-md border border-emerald-500/40 bg-emerald-500/10 px-3 py-2 text-[12px] text-emerald-700 shadow-md dark:text-emerald-300":"fixed left-1/2 top-4 z-50 -translate-x-1/2 rounded-md border border-destructive/40 bg-destructive/10 px-3 py-2 text-[12px] text-destructive shadow-md",children:x.text}):null]})}function fse({onConfirm:e,onCancel:t}){return h.jsx("div",{role:"dialog","aria-modal":"true","data-testid":"force-stop-confirm",className:"fixed inset-0 z-50 flex items-center justify-center bg-black/40",onClick:t,children:h.jsxs("div",{className:"max-w-sm w-[92%] rounded-lg border border-red-400/40 bg-bg-0 p-4 shadow-xl",onClick:n=>n.stopPropagation(),children:[h.jsxs("div",{className:"flex items-start gap-2 mb-3",children:[h.jsx(Kc,{className:"w-5 h-5 text-red-500 shrink-0 mt-0.5"}),h.jsx("div",{className:"text-[14px] text-text-100",children:"强制停止会话进程?会丢失 initialize / 预热缓存,下一次发送需要重新 spawn。"})]}),h.jsxs("div",{className:"flex justify-end gap-2",children:[h.jsx("button",{type:"button",onClick:t,className:"h-8 px-3 rounded-md text-[12px] text-text-300 hover:bg-text-100/5 cursor-pointer",children:"取消"}),h.jsx("button",{type:"button","data-testid":"force-stop-confirm-ok",onClick:e,className:"h-8 px-3 rounded-md bg-red-500 text-white text-[12px] font-medium hover:bg-red-600 cursor-pointer",children:"强制停止"})]})]})})}function pse(e,t,n){const r=e?t.find(s=>s.id===e):void 0;if(r!=null&&r.efforts&&r.efforts.length>0)return{options:r.efforts,defaultValue:r.defaultEffort??""};const i=n.find(s=>s.name==="effort");return{options:(i==null?void 0:i.options)??[],defaultValue:typeof(i==null?void 0:i.default)=="string"?i.default:""}}function mse(e,t,n){var l;if(!t)return((l=(e??[]).find(c=>c.id===""))==null?void 0:l.label)??"未指定";const r=t.toLowerCase(),i=[["opus","Opus"],["fable","Fable"],["sonnet","Sonnet"],["haiku","Haiku"]];for(const[c,u]of i){if(!r.includes(c))continue;const d=r.match(new RegExp(`${c}-(\\d+)(?:-(\\d+))?`));return d?d[2]?`${u} ${d[1]}.${d[2]}`:`${u} ${d[1]}`:u}const s=e??[],o=s.find(c=>c.id===t);if(o)return o.label;const a=s.find(c=>c.id&&t.toLowerCase().includes(c.id.toLowerCase()));return a?a.label:t}function gse(e,t){var m,v,b,_;const{models:n,modes:r,configSchema:i}=t,s=e.resolvedModel??e.model,o=pse(s,n,i),a=o.options,l=a.some(x=>x.value===e.effort)?e.effort:o.defaultValue,c=e.effort===""&&e.resolvedEffort?((m=a.find(x=>x.value===e.resolvedEffort))==null?void 0:m.label)??e.resolvedEffort:((v=a.find(x=>x.value===l))==null?void 0:v.label)??null,u=((b=i.find(x=>x.name==="permissionMode"))==null?void 0:b.default)??"",d=r.some(x=>x.id===e.permissionMode)?e.permissionMode:u,p=d===u?null:((_=r.find(x=>x.id===d))==null?void 0:_.label)??null;return{modelLabel:mse(n,s),effortOptions:a,effortValue:l,effortLabel:c,modeValue:d,modeLabel:p,modeTone:p===null?null:d==="bypassPermissions"?"danger":"info"}}function vse({models:e=[],modes:t=[],configSchema:n=[],model:r,resolvedModel:i,resolvedEffort:s,effort:o,permissionMode:a,onPatch:l}){var p;const c=gse({model:r,resolvedModel:i,resolvedEffort:s,effort:o,permissionMode:a},{models:e,modes:t,configSchema:n}),u=i??r,d=e.map(m=>{const v=m.id===""&&i?`${m.description?`${m.description};`:""}当前:${i}`:m.description;return{value:m.id,label:m.label,...v?{description:v}:{}}}),f=t.map(m=>({value:m.id,label:m.label,...m.description?{description:m.description}:{}}));return h.jsxs(hy,{children:[h.jsx(fy,{asChild:!0,children:h.jsxs("button",{type:"button","data-testid":"session-config-chip",title:"Model / reasoning effort / permission mode",className:"inline-flex items-center gap-1 h-7 px-2.5 rounded-full text-[11px] text-text-400 transition-colors outline-none cursor-pointer hover:bg-text-100/5 hover:text-text-200 data-[state=open]:bg-text-100/5",children:[h.jsx("span",{className:"truncate max-w-[120px]","data-testid":"session-config-chip-model",children:u||c.modelLabel}),c.effortLabel?h.jsxs(h.Fragment,{children:[h.jsx("span",{className:"text-text-500",children:"·"}),h.jsx("span",{className:"truncate max-w-[80px]","data-testid":"session-config-chip-effort",children:c.effortLabel})]}):null,c.modeLabel?h.jsxs(h.Fragment,{children:[h.jsx("span",{className:"text-text-500",children:"·"}),h.jsx("span",{"data-testid":"session-config-chip-mode","data-tone":c.modeTone,className:fe("font-semibold",c.modeTone==="danger"?"text-red-400":"text-blue-400"),children:c.modeLabel})]}):null]})}),h.jsxs(gp,{side:"top",align:"end",className:"w-[230px]","data-testid":"session-config-menu",children:[h.jsx(Ng,{testid:"session-config-model",label:"Model",current:r,currentLabel:c.modelLabel,options:d,onSelect:m=>l({model:m})}),h.jsx(Ng,{testid:"session-config-effort",label:"Reasoning effort",current:c.effortValue,currentLabel:c.effortLabel??"—",options:c.effortOptions,onSelect:m=>l({effort:m})}),f.length>0?h.jsx(Ng,{testid:"session-config-mode",label:"Permission mode",current:c.modeValue,currentLabel:((p=t.find(m=>m.id===c.modeValue))==null?void 0:p.label)??"—",currentTone:c.modeTone,options:f,onSelect:m=>l({permissionMode:m})}):null]})]})}function Ng({testid:e,label:t,current:n,currentLabel:r,currentTone:i,options:s,onSelect:o}){const a=s.length===0;return h.jsxs(RH,{children:[h.jsxs(XI,{"data-testid":e,disabled:a,className:"gap-2 text-[12px]",children:[h.jsx("span",{className:"flex-1 text-text-200",children:t}),h.jsx("span",{className:fe("truncate max-w-[100px]",i==="danger"?"text-red-400 font-semibold":i==="info"?"text-blue-400 font-semibold":"text-text-400"),children:r}),h.jsx(Un,{className:"w-3.5 h-3.5 shrink-0 text-text-500"})]}),h.jsx(QI,{className:"w-[220px] max-h-[320px] overflow-y-auto",children:s.map(l=>{const c=l.value===n;return h.jsxs(yi,{"data-testid":`${e}-option-${l.value||"default"}`,onSelect:()=>o(l.value),className:"items-start gap-2",children:[h.jsxs("span",{className:"flex-1 min-w-0",children:[h.jsx("span",{className:fe("block text-[12px]",c?"text-text-100 font-medium":"text-text-300"),children:l.label}),l.description?h.jsx("span",{className:"block text-[11px] text-text-400 mt-0.5",children:l.description}):null]}),c?h.jsx(ul,{className:"w-3.5 h-3.5 shrink-0 text-accent mt-0.5"}):null]},l.value||"default")})})]})}function _se(e,t,n=0){const[r,i]=g.useState(null),[s,o]=g.useState(!1),a=g.useCallback(async()=>{if(!t){i(null);return}o(!0);try{const l=await e.getGitBranch(t);i(l.branch??null)}catch{i(null)}finally{o(!1)}},[e,t]);return g.useEffect(()=>{a()},[a,n]),{branch:r,loading:s,refresh:()=>void a()}}function xse(e,t,n=0){const[r,i]=g.useState(null),[s,o]=g.useState(!1),a=g.useCallback(async()=>{if(!t){i(null);return}o(!0);try{const l=await e.getGitRoot(t);i(l.gitRoot??null)}catch{i(null)}finally{o(!1)}},[e,t]);return g.useEffect(()=>{a()},[a,n]),{worktreeRoot:r,loading:s,refresh:()=>void a()}}function yse({api:e,session:t,focused:n,totalPanes:r,onFocus:i,onClose:s,onNewSession:o,onOpenConfig:a,onFork:l,onQuickAsk:c,className:u,viewerRole:d="owner"}){const{capabilities:f}=e1(t.tool),[p,m]=g.useState(0),{branch:v}=_se(e,t.cwd,p),{worktreeRoot:b}=xse(e,t.cwd,p),_=r>1,x=y=>{e.sessionUpdate(t.sessionId,y).catch(w=>{console.error("[session-config] session:update failed",t.sessionId,w)})};return h.jsxs("div",{className:`group/pane relative flex-1 ${u??"flex"} flex-row min-w-0 min-h-0 overflow-hidden ${_?`rounded-md border transition-colors ${n?"border-accent ring-1 ring-accent":"border-border"}`:""}`,onMouseDown:i,"data-testid":`session-pane-${t.sessionId}`,children:[h.jsx(Sy,{orientation:"horizontal",className:"flex-1 flex min-w-0 min-h-0",children:h.jsx(sf,{id:"chat",minSize:"400px",children:h.jsx("div",{className:"flex flex-col min-w-0 min-h-0 h-full",children:h.jsx(bse,{api:e,session:t,liveGitBranch:v,liveWorktreeRoot:b,onNewSession:o,onTurnEnd:()=>m(y=>y+1),onOpenConfig:a,onFork:l,onQuickAsk:c,viewerRole:d,configSlot:f?h.jsx(vse,{models:f.models,modes:f.permissionModes,configSchema:f.configSchema,model:t.model??"",...t.resolvedModel?{resolvedModel:t.resolvedModel}:{},...t.resolvedEffort?{resolvedEffort:t.resolvedEffort}:{},effort:t.effort??"",permissionMode:t.permissionMode??"",onPatch:x}):null})})})}),_&&h.jsx("button",{type:"button",onClick:y=>{y.stopPropagation(),s()},className:"absolute top-1.5 right-1.5 z-10 p-1 rounded-md bg-bg-100/80 backdrop-blur-sm border border-border opacity-0 group-hover/pane:opacity-100 transition-opacity text-text-400 hover:text-text-100 hover:bg-bg-200","aria-label":"close pane","data-testid":`session-pane-close-${t.sessionId}`,children:h.jsx(Dr,{className:"w-3.5 h-3.5"})})]})}function bse({api:e,session:t,liveGitBranch:n,liveWorktreeRoot:r,onNewSession:i,onTurnEnd:s,onOpenConfig:o,onFork:a,onQuickAsk:l,viewerRole:c,configSlot:u}){return h.jsx(use,{extras:{session:t,api:e,...n!==void 0?{liveGitBranch:n}:{},...r!==void 0?{liveWorktreeRoot:r}:{},onNewSession:i,onTurnEnd:s,onOpenConfig:o,...a?{onFork:d=>{a(d)}}:{},...l?{onQuickAsk:d=>{l(d)}}:{},...c?{viewerRole:c}:{},...u?{configSlot:u}:{}}})}function wse({personas:e,sessions:t,api:n,selfPrincipalId:r,selectedPersonaId:i,selectedSessionId:s,selectedSession:o,onSelectPersona:a,onSelectSession:l,onCreateSession:c,onDeleteSession:u,onEditSession:d,onCloseSession:f}){return h.jsxs("div",{className:"flex h-screen min-h-0 bg-bg-50","data-testid":"guest-share-page",children:[h.jsx("aside",{className:"w-[280px] shrink-0 overflow-y-auto border-r border-border bg-bg-50",children:h.jsx(bU,{personas:e,sessions:t,activePersonaId:i,activeSessionId:s,onSelectPersona:a,onSelectSession:l,onCreateSession:c,onDeleteSession:u,onEditSession:d,showCopyResume:!1,treatSessionsAsRoots:!0,...r?{ownerPrincipalId:r}:{},isPersonaExpanded:()=>!0})}),h.jsx("main",{className:"flex-1 min-w-0 min-h-0 flex",children:o?h.jsx(yse,{api:n,session:o,focused:!0,totalPanes:1,onFocus:()=>{},onClose:f,onNewSession:()=>{},onOpenConfig:()=>{},viewerRole:"guest"}):h.jsx("div",{className:"flex flex-1 items-center justify-center p-6 text-xs text-text-400","data-testid":"guest-share-empty",children:"选择左侧 persona 开始对话"})})]})}function Sse(){const e=ci(),t=g.useMemo(()=>new Ox(e),[e]),n=jB(e),{sessions:r,refresh:i}=DB(n),{personas:s}=LN(),o=HB(),a=g.useMemo(()=>{const w=window.location.pathname.match(/^\/s\/([^/]+)/);return w?decodeURIComponent(w[1]):null},[]),l=g.useMemo(()=>r.filter(w=>!w.ephemeral&&w.larkChatId==null),[r]),c=g.useMemo(()=>a?s.filter(w=>w.personaId===a):s,[s,a]),[u,d]=g.useState(null),[f,p]=g.useState(null),[m,v]=g.useState(null);g.useEffect(()=>{let w=!1;return e.request("whoami",{}).then(C=>{w||d(C.capability.id)}).catch(()=>{}),()=>{w=!0}},[e]),g.useEffect(()=>{a&&p(a)},[a]);const b=g.useCallback(async(w,C)=>{const k=await t.sessionCreate({ownerPersonaId:w,...C.trim()?{label:C.trim()}:{}});await i(),p(w),v(k.sessionId)},[t,i]),_=g.useCallback(async w=>{await t.sessionDelete(w),await i(),v(C=>C===w?null:C)},[t,i]),x=g.useCallback(async(w,C)=>{await t.sessionUpdate(w,{label:C.label}),await i()},[t,i]),y=g.useMemo(()=>l.find(w=>w.sessionId===m)??null,[l,m]);return h.jsx(Bx.Provider,{value:o,children:h.jsx(wse,{personas:c,sessions:l,api:t,selfPrincipalId:u,selectedPersonaId:f,selectedSessionId:m,selectedSession:y,onSelectPersona:p,onSelectSession:v,onCreateSession:(w,C)=>void b(w,C),onDeleteSession:w=>void _(w),onEditSession:(w,C)=>void x(w,C),onCloseSession:()=>v(null)})})}const UC="https://app.ttcadvisory.com";function kse({onAuthed:e}){const[t,n]=g.useState(!1),[r,i]=g.useState(null),s=g.useRef(null);g.useEffect(()=>()=>{s.current&&window.removeEventListener("message",s.current)},[]);const o=g.useCallback(()=>{s.current&&(window.removeEventListener("message",s.current),s.current=null),n(!0),i(null);const a=window.location.origin,l=`${UC}/auth/authorize?callback_url=${encodeURIComponent(a)}&auto=1`,c=async d=>{if(d.origin!==UC)return;const f=d.data;if((f==null?void 0:f.type)==="AUTH_CANCEL"){u(),n(!1);return}if(!((f==null?void 0:f.type)!=="AUTH_SUCCESS"||!f.token)){u();try{const p=await fetch(`${window.location.origin}/share/exchange`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({ttcToken:f.token})});if(!p.ok){const v=await p.json().catch(()=>({}));throw new Error(v.code??`exchange failed (${p.status})`)}const m=await p.json();if(!m.visitorToken)throw new Error("no visitorToken in response");e(m.visitorToken)}catch(p){i(p instanceof Error?p.message:String(p)),n(!1)}}},u=()=>{window.removeEventListener("message",c),s.current=null};s.current=d=>void c(d),window.addEventListener("message",s.current),window.open(l,"ttc-login","width=480,height=640")},[e]);return h.jsx("div",{className:"flex min-h-screen items-center justify-center bg-bg-50 p-6 font-sans text-text-100","data-testid":"guest-login",children:h.jsxs("div",{className:"flex w-full max-w-xs flex-col gap-3 rounded-lg border border-border bg-bg-100 px-5 py-6",children:[h.jsx("h1",{className:"text-base font-semibold",children:"登录后进入分享"}),h.jsx("p",{className:"text-[11px] leading-snug text-text-400",children:"使用飞书账号登录,即可在浏览器里与分享给你的 persona 交互,无需安装。"}),r?h.jsxs("p",{className:"text-[11px] leading-snug text-error","data-testid":"guest-login-error",children:["登录失败:",r]}):null,h.jsx("button",{type:"button",disabled:t,onClick:()=>o(),"data-testid":"guest-login-button",className:"w-full rounded border border-border bg-bg-50 px-2 py-1.5 text-xs text-text-200 transition-colors hover:bg-text-100/5 hover:text-text-100 disabled:opacity-50",children:t?"请在弹窗中完成授权…":"飞书登录"})]})})}const E_="clawd-visitor:token";function Cse(e,t){const r=`${e.protocol==="https:"?"wss:":"ws:"}//${e.host}`;return t!=null&&t.devPath?`${r}${t.devPath}`:r}function Ese(){return{async getUrl(e){const t=localStorage.getItem(E_);if(!t)throw new Error("NO_VISITOR_TOKEN");const n=Cse(window.location,{});return await CN(e).upsert({id:"guest",name:"访客",mode:"remote",url:n,token:t}),{url:n}}}}function Tse(e){const t=n=>{document.documentElement.classList.toggle("dark",n==="dark")};return t(e.theme.mode),e.onThemeChange(n=>t(n.mode))}function Nse(){const e=ci(),t=g.useMemo(()=>LB(e),[e]);return h.jsx(mB,{cache:t.cache,children:h.jsx(_B,{children:h.jsx(Sse,{})})})}function Pse({host:e}){const[t]=g.useState(()=>localStorage.getItem(E_)),[n,r]=g.useState(!1),[i,s]=g.useState(null);return g.useEffect(()=>Tse(e),[e]),g.useEffect(()=>{if(!t)return;let o=!1;return Ese().getUrl(e).then(()=>{o||r(!0)}).catch(a=>{o||s(a instanceof Error?a.message:String(a))}),()=>{o=!0}},[e,t]),t?h.jsx(Pb,{host:e,children:h.jsx(lw,{children:i?h.jsxs("div",{className:"flex min-h-screen items-center justify-center bg-bg-50 p-6 text-center text-xs text-error","data-testid":"guest-share-connect-error",children:["连接失败:",i]}):n?h.jsx(hB,{host:e,children:h.jsx(Nse,{})}):h.jsx("div",{className:"flex min-h-screen items-center justify-center bg-bg-50 p-6 text-xs text-text-400",children:"正在连接…"})})}):h.jsx(Pb,{host:e,children:h.jsx(lw,{children:h.jsx(kse,{onAuthed:o=>{localStorage.setItem(E_,o),window.location.reload()}})})})}function Ise({filePath:e,oldString:t,newString:n,content:r}){const i=g.useMemo(()=>r!=null?r.split(/\r?\n/).map(s=>({type:"add",text:s})):Rse(t??"",n??""),[t,n,r]);return h.jsxs("div",{"data-testid":"inline-diff",className:"min-w-0 max-w-full rounded-lg border border-bg-300/60 bg-bg-50 overflow-hidden text-[12px] font-mono",children:[h.jsx("div",{className:"flex min-w-0 items-center gap-2 px-3 py-1.5 border-b border-bg-300/40 bg-bg-100/30",children:h.jsx("span",{className:"min-w-0 text-text-400 truncate",title:e,children:e})}),h.jsx("div",{className:"max-h-[320px] max-w-full overflow-auto",children:i.map((s,o)=>h.jsxs("div",{"data-testid":`diff-line-${s.type}`,className:fe("flex min-w-max gap-2 px-3 py-0.5 whitespace-pre",s.type==="add"?"bg-success/10 text-success":s.type==="remove"?"bg-error/10 text-error":"text-text-300"),children:[h.jsx("span",{className:"w-3 shrink-0 select-none opacity-60",children:s.type==="add"?"+":s.type==="remove"?"-":" "}),h.jsx("span",{className:"flex-1",children:s.text||" "})]},o))})]})}function Rse(e,t){const n=e.split(/\r?\n/),r=t.split(/\r?\n/),i=n.length,s=r.length,o=Array.from({length:i+1},()=>new Array(s+1).fill(0));for(let u=i-1;u>=0;u--)for(let d=s-1;d>=0;d--)o[u][d]=n[u]===r[d]?o[u+1][d+1]+1:Math.max(o[u+1][d],o[u][d+1]);const a=[];let l=0,c=0;for(;l<i&&c<s;)n[l]===r[c]?(a.push({type:"equal",text:n[l]}),l++,c++):o[l+1][c]>=o[l][c+1]?(a.push({type:"remove",text:n[l]}),l++):(a.push({type:"add",text:r[c]}),c++);for(;l<i;)a.push({type:"remove",text:n[l++]});for(;c<s;)a.push({type:"add",text:r[c++]});return a}function Mse({items:e}){return e.length===0?null:h.jsxs("div",{"data-testid":"todo-checklist",className:"rounded-lg border border-bg-300/60 bg-bg-50 px-3 py-2 text-[13px]",children:[h.jsx("div",{className:"text-[11px] font-semibold uppercase tracking-wider text-text-400/70 mb-1.5",children:"Todos"}),h.jsx("ul",{className:"flex flex-col gap-1",children:e.map((t,n)=>{const r=t.status==="in_progress"&&t.activeForm||t.content;return h.jsxs("li",{"data-testid":`todo-item-${t.status}`,className:"flex items-start gap-2",children:[h.jsx(Ase,{status:t.status}),h.jsx("span",{className:fe("flex-1 leading-snug",t.status==="completed"?"text-text-400 line-through":t.status==="in_progress"?"text-text-100 font-medium":"text-text-200"),children:r})]},n)})})]})}function Ase({status:e}){return e==="completed"?h.jsx(rp,{className:"w-3.5 h-3.5 text-success mt-0.5 shrink-0"}):e==="in_progress"?h.jsx(In,{className:"w-3.5 h-3.5 text-warning mt-0.5 shrink-0 animate-spin"}):h.jsx(BN,{className:"w-3.5 h-3.5 text-text-400 mt-0.5 shrink-0"})}function Lse(e){const t=e??{};return Array.isArray(t.todos)?t.todos.map(n=>{if(!n||typeof n!="object")return null;const r=n,i=typeof r.content=="string"?r.content:"",s=r.status==="pending"||r.status==="in_progress"||r.status==="completed"?r.status:"pending",o=typeof r.activeForm=="string"?r.activeForm:void 0;return{content:i,status:s,activeForm:o}}).filter(n=>n!==null):[]}function jse({description:e,prompt:t,subagentType:n}){return h.jsxs("div",{"data-testid":"task-checklist",className:"rounded-lg border border-bg-300/60 bg-bg-50 px-3 py-2 text-[13px]",children:[h.jsxs("div",{className:"flex items-center gap-2 text-text-200 font-medium",children:[h.jsx(np,{className:"w-3.5 h-3.5 text-accent shrink-0"}),h.jsx("span",{className:"truncate",children:e||"subagent task"}),n?h.jsx("span",{className:"shrink-0 px-1.5 py-0.5 rounded-md text-[10px] font-mono bg-accent/10 text-accent",children:n}):null]}),t?h.jsx("div",{className:"mt-1 text-[12px] text-text-400 leading-snug line-clamp-3",children:t}):null]})}function Dse(e){const t=e??{};return{description:typeof t.description=="string"?t.description:"",prompt:typeof t.prompt=="string"?t.prompt:void 0,subagentType:typeof t.subagent_type=="string"?t.subagent_type:void 0}}const Ose={render:({input:e})=>Ze.createElement(Mse,{items:Lse(e)})},Bse={render:({input:e})=>{const{description:t,prompt:n,subagentType:r}=Dse(e);return Ze.createElement(jse,{description:t,prompt:n,subagentType:r})}},P5={render:({input:e,output:t,error:n,pending:r,fileScope:i,onShareFile:s,onOpenInTab:o,onPreviewMarkdown:a})=>{const l=$se(e),c=l?Ze.createElement(Ise,{filePath:l.filePath,oldString:l.oldString,newString:l.newString,content:l.content}):void 0;return Ze.createElement(zM,{tool:zse(e),input:e,output:t,error:n,pending:r,expandedBody:c,...i?{fileScope:i}:{},...s?{onShareFile:s}:{},...o?{onOpenInTab:o}:{},...a?{onPreviewMarkdown:a}:{}})}};function zse(e){const t=e??{};return"content"in t&&t.content!==void 0?"Write":("old_string"in t&&t.old_string!==void 0,"Edit")}function $se(e){const t=e??{},n=typeof t.file_path=="string"?t.file_path:null;if(!n)return null;const r=typeof t.old_string=="string"?t.old_string:void 0,i=typeof t.new_string=="string"?t.new_string:void 0,s=typeof t.content=="string"?t.content:void 0;return r==null&&i==null&&s==null?null:{filePath:n,oldString:r,newString:i,content:s}}ml.register("claude","TodoWrite",Ose);ml.register("claude","Task",Bse);ml.register("claude","Edit",P5);ml.register("claude","Write",P5);const I5=document.getElementById("root");if(!I5)throw new Error("guest-main: #root not found");const Fse=dL({});Pg.createRoot(I5).render(h.jsx(Ze.StrictMode,{children:h.jsx(Pse,{host:Fse})}));