@clawos-dev/clawd 0.2.396 → 0.2.397
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.
|
@@ -93,7 +93,7 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
|
|
|
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
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 lw=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 UD={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},WD={motionBase:!0,motionUnit:!0},VD={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},oT=(e,t,n)=>{const r=n.getDerivativeToken(e),{override:i}=t,s=lw(t,["override"]);let o=Object.assign(Object.assign({},r),{override:i});return o=sT(o),s&&Object.entries(s).forEach(([a,l])=>{const{theme:c}=l,u=lw(l,["theme"]);let d=u;c&&(d=oT(Object.assign(Object.assign({},o),u),{override:u},c)),o[a]=d}),o};function aT(){const{token:e,hashed:t,theme:n,override:r,cssVar:i}=Qe.useContext(rT),s=`${FD}-${t||""}`,o=n||nT,[a,l,c]=RL(o,[qc,e],{salt:s,override:r,getComputedToken:oT,formatToken:sT,cssVar:i&&{prefix:i.prefix,key:i.key,unitless:UD,ignore:WD,preserve:VD}});return[o,c,t?l:"",a,i]}const qD=()=>({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"}}),KD=e=>({[`.${e}`]:Object.assign(Object.assign({},qD()),{[`.${e} .${e}-icon`]:{display:"block"}})}),GD=(e,t)=>{const[n,r]=aT();return sD({token:r,hashId:"",path:["ant-design-icons",e],nonce:()=>t==null?void 0:t.nonce,layer:{name:"antd"}},()=>KD(e))},YD=Object.assign({},rl),{useId:cw}=YD,XD=()=>"",ZD=typeof cw>"u"?XD:cw;function QD(e,t,n){var r;const i=e||{},s=i.inherit===!1||!t?Object.assign(Object.assign({},Wh),{hashed:(r=t==null?void 0:t.hashed)!==null&&r!==void 0?r:Wh.hashed,cssVar:t==null?void 0:t.cssVar}):t,o=ZD();return CN(()=>{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!sL(c,d,!0)}))}var JD=["children"],lT=g.createContext({});function eO(e){var t=e.children,n=jv(e,JD);return g.createElement(lT.Provider,{value:n},t)}var tO=function(e){NN(n,e);var t=IN(n);function n(){return al(this,n),t.apply(this,arguments)}return ll(n,[{key:"render",value:function(){return this.props.children}}]),n}(g.Component);function nO(e){var t=g.useReducer(function(a){return a+1},0),n=Je(t,2),r=n[1],i=g.useRef(e),s=n0(function(){return i.current}),o=n0(function(a){i.current=typeof a=="function"?a(i.current):a,r()});return[s,o]}var is="none",cd="appear",ud="enter",dd="leave",uw="none",Pr="prepare",va="start",xa="active",B_="end",cT="prepared";function dw(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 rO(e,t){var n={animationend:dw("Animation","AnimationEnd"),transitionend:dw("Transition","TransitionEnd")};return e&&("AnimationEvent"in t||delete n.animationend.animation,"TransitionEvent"in t||delete n.transitionend.transition),n}var iO=rO(Ui(),typeof window<"u"?window:{}),uT={};if(Ui()){var sO=document.createElement("div");uT=sO.style}var hd={};function dT(e){if(hd[e])return hd[e];var t=iO[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 uT)return hd[e]=t[s],hd[e]}return""}var hT=dT("animationend"),fT=dT("transitionend"),pT=!!(hT&&fT),hw=hT||"animationend",fw=fT||"transitionend";function pw(e,t){if(!e)return null;if(Nt(e)==="object"){var n=t.replace(/-\w/g,function(r){return r[1].toUpperCase()});return e[n]}return"".concat(e,"-").concat(t)}const oO=function(e){var t=g.useRef();function n(i){i&&(i.removeEventListener(fw,e),i.removeEventListener(hw,e))}function r(i){t.current&&t.current!==i&&n(t.current),i&&i!==t.current&&(i.addEventListener(fw,e),i.addEventListener(hw,e),t.current=i)}return g.useEffect(function(){return function(){n(t.current)}},[]),[r,n]};var mT=Ui()?g.useLayoutEffect:g.useEffect;const aO=function(){var e=g.useRef(null);function t(){Mv.cancel(e.current)}function n(r){var i=arguments.length>1&&arguments[1]!==void 0?arguments[1]:2;t();var s=Mv(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 lO=[Pr,va,xa,B_],cO=[Pr,cT],gT=!1,uO=!0;function vT(e){return e===xa||e===B_}const dO=function(e,t,n){var r=r0(uw),i=Je(r,2),s=i[0],o=i[1],a=aO(),l=Je(a,2),c=l[0],u=l[1];function d(){o(Pr,!0)}var f=t?cO:lO;return mT(function(){if(s!==uw&&s!==B_){var p=f.indexOf(s),m=f[p+1],v=n(s);v===gT?o(m,!0):m&&c(function(b){function x(){b.isCanceled()||o(m,!0)}v===!0?x():Promise.resolve(v).then(x)})}},[e,s]),g.useEffect(function(){return function(){u()}},[]),[d,s]};function hO(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,x=r.onLeaveStart,_=r.onAppearActive,y=r.onEnterActive,S=r.onLeaveActive,C=r.onAppearEnd,k=r.onEnterEnd,N=r.onLeaveEnd,T=r.onVisibleChanged,z=r0(),I=Je(z,2),M=I[0],L=I[1],R=nO(is),A=Je(R,2),D=A[0],$=A[1],F=r0(null),O=Je(F,2),B=O[0],E=O[1],H=D(),q=g.useRef(!1),j=g.useRef(null);function ne(){return n()}var re=g.useRef(!1);function G(){$(is),E(null,!0)}var ve=n0(function(Xe){var st=D();if(st!==is){var At=ne();if(!(Xe&&!Xe.deadline&&Xe.target!==At)){var Xt=re.current,pn;st===cd&&Xt?pn=C==null?void 0:C(At,Xe):st===ud&&Xt?pn=k==null?void 0:k(At,Xe):st===dd&&Xt&&(pn=N==null?void 0:N(At,Xe)),Xt&&pn!==!1&&G()}}}),ze=oO(ve),he=Je(ze,1),Ie=he[0],Re=function(st){switch(st){case cd:return Ce(Ce(Ce({},Pr,f),va,v),xa,_);case ud:return Ce(Ce(Ce({},Pr,p),va,b),xa,y);case dd:return Ce(Ce(Ce({},Pr,m),va,x),xa,S);default:return{}}},Ve=g.useMemo(function(){return Re(H)},[H]),xe=dO(H,!e,function(Xe){if(Xe===Pr){var st=Ve[Pr];return st?st(ne()):gT}if(it in Ve){var At;E(((At=Ve[it])===null||At===void 0?void 0:At.call(Ve,ne(),null))||null)}return it===xa&&H!==is&&(Ie(ne()),u>0&&(clearTimeout(j.current),j.current=setTimeout(function(){ve({deadline:!0})},u))),it===cT&&G(),uO}),Ke=Je(xe,2),Cn=Ke[0],it=Ke[1],ct=vT(it);re.current=ct;var on=g.useRef(null);mT(function(){if(!(q.current&&on.current===t)){L(t);var Xe=q.current;q.current=!0;var st;!Xe&&t&&a&&(st=cd),Xe&&t&&s&&(st=ud),(Xe&&!t&&c||!Xe&&d&&!t&&c)&&(st=dd);var At=Re(st);st&&(e||At[Pr])?($(st),Cn()):$(is),on.current=t}},[t]),g.useEffect(function(){(H===cd&&!a||H===ud&&!s||H===dd&&!c)&&$(is)},[a,s,c]),g.useEffect(function(){return function(){q.current=!1,clearTimeout(j.current)}},[]);var gt=g.useRef(!1);g.useEffect(function(){M&&(gt.current=!0),M!==void 0&&H===is&&((gt.current||M)&&(T==null||T(M)),gt.current=!0)},[M,H]);var vt=B;return Ve[Pr]&&it===va&&(vt=$e({transition:"none"},vt)),[H,it,vt,M??t]}function fO(e){var t=e;Nt(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(lT),b=v.motion,x=n(i,b),_=g.useRef(),y=g.useRef();function S(){try{return _.current instanceof HTMLElement?_.current:Hj(y.current)}catch{return null}}var C=hO(x,a,S,i),k=Je(C,4),N=k[0],T=k[1],z=k[2],I=k[3],M=g.useRef(I);I&&(M.current=!0);var L=g.useCallback(function(O){_.current=O,qj(s,O)},[s]),R,A=$e($e({},m),{},{visible:a});if(!d)R=null;else if(N===is)I?R=d($e({},A),L):!c&&M.current&&p?R=d($e($e({},A),{},{className:p}),L):u||!c&&!p?R=d($e($e({},A),{},{style:{display:"none"}}),L):R=null;else{var D;T===Pr?D="prepare":vT(T)?D="active":T===va&&(D="start");var $=pw(f,"".concat(N,"-").concat(D));R=d($e($e({},A),{},{className:Pj(pw(f,N),Ce(Ce({},$,$&&D),f,typeof f=="string")),style:z}),L)}if(g.isValidElement(R)&&Kj(R)){var F=Gj(R);F||(R=g.cloneElement(R,{ref:L}))}return g.createElement(tO,{ref:y},R)});return r.displayName="CSSMotion",r}const pO=fO(pT);var i0="add",s0="keep",o0="remove",Im="removed";function mO(e){var t;return e&&Nt(e)==="object"&&"key"in e?t=e:t={key:e},$e($e({},t),{},{key:String(t.key)})}function a0(){var e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:[];return e.map(mO)}function gO(){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=a0(e),o=a0(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:i0})})),r=d),n.push($e($e({},f),{},{status:s0})),r+=1,u=!0;break}}u||n.push($e($e({},c),{},{status:o0}))}),r<i&&(n=n.concat(o.slice(r).map(function(c){return $e($e({},c),{},{status:i0})})));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!==o0}),n.forEach(function(u){u.key===c&&(u.status=s0)})}),n}var vO=["component","children","onVisibleChanged","onAllRemoved"],xO=["status"],_O=["eventProps","visible","children","motionName","motionAppear","motionEnter","motionLeave","motionLeaveImmediately","motionDeadline","removeOnLeave","leavedClassName","onAppearPrepare","onAppearStart","onAppearActive","onAppearEnd","onEnterStart","onEnterActive","onEnterEnd","onLeaveStart","onLeaveActive","onLeaveEnd"];function yO(e){var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:pO,n=function(r){NN(s,r);var i=IN(s);function s(){var o;al(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(Pv(o),"state",{keyEntities:[]}),Ce(Pv(o),"removeKey",function(u){o.setState(function(d){var f=d.keyEntities.map(function(p){return p.key!==u?p:$e($e({},p),{},{status:Im})});return{keyEntities:f}},function(){var d=o.state.keyEntities,f=d.filter(function(p){var m=p.status;return m!==Im}).length;f===0&&o.props.onAllRemoved&&o.props.onAllRemoved()})}),o}return ll(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=jv(c,vO),m=u||g.Fragment,v={};return _O.forEach(function(b){v[b]=p[b],delete p[b]}),delete p.keys,g.createElement(m,p,l.map(function(b,x){var _=b.status,y=jv(b,xO),S=_===i0||_===s0;return g.createElement(t,Fh({},v,{key:y.key,visible:S,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:x}),k)})}))}}],[{key:"getDerivedStateFromProps",value:function(a,l){var c=a.keys,u=l.keyEntities,d=a0(c),f=gO(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===Im&&p.status===o0)})}}}]),s}(g.Component);return Ce(n,"defaultProps",{component:"div"}),n}yO(pT);const mw=g.createContext(!0);function bO(e){const t=g.useContext(mw),{children:n}=e,[,r]=aT(),{motion:i}=r,s=g.useRef(!1);return s.current||(s.current=t!==i),s.current?g.createElement(mw.Provider,{value:i},g.createElement(eO,{motion:i},n)):n}const wO=()=>null;var SO=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 kO=["getTargetContainer","getPopupContainer","renderEmpty","input","pagination","form","select","button"];let xT;function CO(){return xT||e0}function EO(e){return Object.keys(e).some(t=>t.endsWith("Color"))}const NO=e=>{const{prefixCls:t,iconPrefixCls:n,theme:r,holderRender:i}=e;t!==void 0&&(xT=t),r&&EO(r)&&LD(CO(),r)},TO=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:x,iconPrefixCls:_,theme:y,componentDisabled:S,segmented:C,statistic:k,spin:N,calendar:T,carousel:z,cascader:I,collapse:M,typography:L,checkbox:R,descriptions:A,divider:D,drawer:$,skeleton:F,steps:O,image:B,layout:E,list:H,mentions:q,modal:j,progress:ne,result:re,slider:G,breadcrumb:ve,menu:ze,pagination:he,input:Ie,textArea:Re,empty:Ve,badge:xe,radio:Ke,rate:Cn,switch:it,transfer:ct,avatar:on,message:gt,tag:vt,table:Xe,card:st,tabs:At,timeline:Xt,timePicker:pn,upload:U,notification:J,tree:ye,colorPicker:ke,datePicker:Ue,rangePicker:kt,flex:an,wave:Ft,dropdown:le,warning:K,tour:we,tooltip:ft,popover:ln,popconfirm:Sl,floatButton:kl,floatButtonGroup:Cl,variant:Vp,inputNumber:qp,treeSelect:Fu}=e,Hu=g.useCallback((Pt,jt)=>{const{prefixCls:Z}=e;if(jt)return jt;const fe=Z||x.getPrefixCls("");return Pt?`${fe}-${Pt}`:fe},[x.getPrefixCls,e.prefixCls]),Ws=_||x.iconPrefixCls||iT,Vs=n||x.csp;GD(Ws,Vs);const El=QD(y,x.theme,{prefixCls:Hu("")}),Ho={csp:Vs,autoInsertSpaceInButton:r,alert:i,anchor:s,locale:a||b,direction:c,space:u,splitter:d,virtual:f,popupMatchSelectWidth:m??p,popupOverflow:v,getPrefixCls:Hu,iconPrefixCls:Ws,theme:El,segmented:C,statistic:k,spin:N,calendar:T,carousel:z,cascader:I,collapse:M,typography:L,checkbox:R,descriptions:A,divider:D,drawer:$,skeleton:F,steps:O,image:B,input:Ie,textArea:Re,layout:E,list:H,mentions:q,modal:j,progress:ne,result:re,slider:G,breadcrumb:ve,menu:ze,pagination:he,empty:Ve,badge:xe,radio:Ke,rate:Cn,switch:it,transfer:ct,avatar:on,message:gt,tag:vt,table:Xe,card:st,tabs:At,timeline:Xt,timePicker:pn,upload:U,notification:J,tree:ye,colorPicker:ke,datePicker:Ue,rangePicker:kt,flex:an,wave:Ft,dropdown:le,warning:K,tour:we,tooltip:ft,popover:ln,popconfirm:Sl,floatButton:kl,floatButtonGroup:Cl,variant:Vp,inputNumber:qp,treeSelect:Fu},Fr=Object.assign({},x);Object.keys(Ho).forEach(Pt=>{Ho[Pt]!==void 0&&(Fr[Pt]=Ho[Pt])}),kO.forEach(Pt=>{const jt=e[Pt];jt&&(Fr[Pt]=jt)}),typeof r<"u"&&(Fr.button=Object.assign({autoInsertSpace:r},Fr.button));const Xi=CN(()=>Fr,Fr,(Pt,jt)=>{const Z=Object.keys(Pt),fe=Object.keys(jt);return Z.length!==fe.length||Z.some(be=>Pt[be]!==jt[be])}),{layer:qs}=g.useContext(tp),Kp=g.useMemo(()=>({prefixCls:Ws,csp:Vs,layer:qs?"antd":void 0}),[Ws,Vs,qs]);let Ht=g.createElement(g.Fragment,null,g.createElement(wO,{dropdownMatchSelectWidth:p}),t);const Uo=g.useMemo(()=>{var Pt,jt,Z,fe;return fD(((Pt=ip.Form)===null||Pt===void 0?void 0:Pt.defaultValidateMessages)||{},((Z=(jt=Xi.locale)===null||jt===void 0?void 0:jt.Form)===null||Z===void 0?void 0:Z.defaultValidateMessages)||{},((fe=Xi.form)===null||fe===void 0?void 0:fe.validateMessages)||{},(o==null?void 0:o.validateMessages)||{})},[Xi,o==null?void 0:o.validateMessages]);Object.keys(Uo).length>0&&(Ht=g.createElement(mD.Provider,{value:Uo},Ht)),a&&(Ht=g.createElement(xD,{locale:a,_ANT_MARK__:vD},Ht)),Ht=g.createElement(cD.Provider,{value:Kp},Ht),l&&(Ht=g.createElement(OD,{size:l},Ht)),Ht=g.createElement(bO,null,Ht);const Wo=g.useMemo(()=>{const Pt=El||{},{algorithm:jt,token:Z,components:fe,cssVar:be}=Pt,Ze=SO(Pt,["algorithm","token","components","cssVar"]),Cr=jt&&(!Array.isArray(jt)||jt.length>0)?Dv(jt):nT,Vo={};Object.entries(fe||{}).forEach(([YA,XA])=>{const xi=Object.assign({},XA);"algorithm"in xi&&(xi.algorithm===!0?xi.theme=Cr:(Array.isArray(xi.algorithm)||typeof xi.algorithm=="function")&&(xi.theme=Dv(xi.algorithm)),delete xi.algorithm),Vo[YA]=xi});const S1=Object.assign(Object.assign({},qc),Z);return Object.assign(Object.assign({},Ze),{theme:Cr,token:S1,components:Vo,override:Object.assign({override:S1},Vo),cssVar:be})},[El]);return y&&(Ht=g.createElement(rT.Provider,{value:Wo},Ht)),Xi.warning&&(Ht=g.createElement(pD.Provider,{value:Xi.warning},Ht)),S!==void 0&&(Ht=g.createElement(DD,{disabled:S},Ht)),g.createElement(sp.Provider,{value:Xi},Ht)},ul=e=>{const t=g.useContext(sp),n=g.useContext(QN);return g.createElement(TO,Object.assign({parentContext:t,legacyLocale:n},e))};ul.ConfigContext=sp;ul.SizeContext=Kc;ul.config=NO;ul.useConfig=BD;Object.defineProperty(ul,"SizeContext",{get:()=>Kc});const cr=(e,t)=>new bt(e).setA(t).toRgbString(),Go=(e,t)=>new bt(e).lighten(t).toHexString(),IO=e=>{const t=Ha(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]}},PO=(e,t)=>{const n=e||"#000",r=t||"#fff";return{colorBgBase:n,colorTextBase:r,colorText:cr(r,.85),colorTextSecondary:cr(r,.65),colorTextTertiary:cr(r,.45),colorTextQuaternary:cr(r,.25),colorFill:cr(r,.18),colorFillSecondary:cr(r,.12),colorFillTertiary:cr(r,.08),colorFillQuaternary:cr(r,.04),colorBgSolid:cr(r,.95),colorBgSolidHover:cr(r,1),colorBgSolidActive:cr(r,.9),colorBgElevated:Go(n,12),colorBgContainer:Go(n,8),colorBgLayout:Go(n,0),colorBgSpotlight:Go(n,26),colorBgBlur:cr(r,.04),colorBorder:Go(n,26),colorBorderSecondary:Go(n,19)}},RO=(e,t)=>{const n=Object.keys(D_).map(s=>{const o=Ha(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??O_(e),i=tT(e,{generateColorPalettes:IO,generateNeutralColorPalettes:PO});return Object.assign(Object.assign(Object.assign(Object.assign({},r),n),i),{colorPrimaryBg:i.colorPrimaryBorder,colorPrimaryBgHover:i.colorPrimaryBorderHover})},gw={defaultSeed:Wh.token,defaultAlgorithm:O_,darkAlgorithm:RO};function vw({children:e}){const t=T_(),[n,r]=g.useState(t.theme);return g.useEffect(()=>t.onThemeChange(r),[t]),h.jsx(ul,{theme:{algorithm:n.mode==="dark"?gw.darkAlgorithm:gw.defaultAlgorithm,token:{colorPrimary:n.colorPrimary,colorBgContainer:n.colorBgContainer,colorText:n.colorText,colorBorder:n.colorBorder}},children:e})}var Ge;(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})(Ge||(Ge={}));var xw;(function(e){e.mergeShapes=(t,n)=>({...t,...n})})(xw||(xw={}));const ue=Ge.arrayToEnum(["string","nan","number","integer","float","boolean","date","bigint","symbol","function","undefined","null","array","object","unknown","promise","void","never","map","set"]),ls=e=>{switch(typeof e){case"undefined":return ue.undefined;case"string":return ue.string;case"number":return Number.isNaN(e)?ue.nan:ue.number;case"boolean":return ue.boolean;case"function":return ue.function;case"bigint":return ue.bigint;case"symbol":return ue.symbol;case"object":return Array.isArray(e)?ue.array:e===null?ue.null:e.then&&typeof e.then=="function"&&e.catch&&typeof e.catch=="function"?ue.promise:typeof Map<"u"&&e instanceof Map?ue.map:typeof Set<"u"&&e instanceof Set?ue.set:typeof Date<"u"&&e instanceof Date?ue.date:ue.object;default:return ue.unknown}},Y=Ge.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 Bi 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 Bi))throw new Error(`Not a ZodError: ${t}`)}toString(){return this.message}get message(){return JSON.stringify(this.issues,Ge.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()}}Bi.create=e=>new Bi(e);const l0=(e,t)=>{let n;switch(e.code){case Y.invalid_type:e.received===ue.undefined?n="Required":n=`Expected ${e.expected}, received ${e.received}`;break;case Y.invalid_literal:n=`Invalid literal value, expected ${JSON.stringify(e.expected,Ge.jsonStringifyReplacer)}`;break;case Y.unrecognized_keys:n=`Unrecognized key(s) in object: ${Ge.joinValues(e.keys,", ")}`;break;case Y.invalid_union:n="Invalid input";break;case Y.invalid_union_discriminator:n=`Invalid discriminator value. Expected ${Ge.joinValues(e.options)}`;break;case Y.invalid_enum_value:n=`Invalid enum value. Expected ${Ge.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}"`:Ge.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,Ge.assertNever(e)}return{message:n}};let MO=l0;function AO(){return MO}const jO=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 ie(e,t){const n=AO(),r=jO({issueData:t,data:e.data,path:e.path,errorMaps:[e.common.contextualErrorMap,e.schemaErrorMap,n,n===l0?void 0:l0].filter(i=>!!i)});e.common.issues.push(r)}class Rn{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 Ne;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 Rn.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 Ne;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 Ne=Object.freeze({status:"aborted"}),Ql=e=>({status:"dirty",value:e}),kr=e=>({status:"valid",value:e}),_w=e=>e.status==="aborted",yw=e=>e.status==="dirty",Ua=e=>e.status==="valid",Vh=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 li{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 bw=(e,t)=>{if(Ua(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 Bi(e.common.issues);return this._error=n,this._error}}};function je(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 We{get description(){return this._def.description}_getType(t){return ls(t.data)}_getOrReturnCtx(t,n){return n||{common:t.parent.common,data:t.data,parsedType:ls(t.data),schemaErrorMap:this._def.errorMap,path:t.path,parent:t.parent}}_processInputParams(t){return{status:new Rn,ctx:{common:t.parent.common,data:t.data,parsedType:ls(t.data),schemaErrorMap:this._def.errorMap,path:t.path,parent:t.parent}}}_parseSync(t){const n=this._parse(t);if(Vh(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:ls(t)},i=this._parseSync({data:t,path:r.path,parent:r});return bw(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:ls(t)};if(!this["~standard"].async)try{const s=this._parseSync({data:t,path:[],parent:n});return Ua(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=>Ua(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:ls(t)},i=this._parse({data:t,path:r.path,parent:r}),s=await(Vh(i)?i:Promise.resolve(i));return bw(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 bo({schema:this,typeName:Te.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 Mi.create(this,this._def)}nullable(){return wo.create(this,this._def)}nullish(){return this.nullable().optional()}array(){return ii.create(this)}promise(){return Zh.create(this,this._def)}or(t){return Kh.create([this,t],this._def)}and(t){return Gh.create(this,t,this._def)}transform(t){return new bo({...je(this._def),schema:this,typeName:Te.ZodEffects,effect:{type:"transform",transform:t}})}default(t){const n=typeof t=="function"?t:()=>t;return new Qh({...je(this._def),innerType:this,defaultValue:n,typeName:Te.ZodDefault})}brand(){return new wT({typeName:Te.ZodBranded,type:this,...je(this._def)})}catch(t){const n=typeof t=="function"?t:()=>t;return new Jh({...je(this._def),innerType:this,catchValue:n,typeName:Te.ZodCatch})}describe(t){const n=this.constructor;return new n({...this._def,description:t})}pipe(t){return $_.create(this,t)}readonly(){return ef.create(this)}isOptional(){return this.safeParse(void 0).success}isNullable(){return this.safeParse(null).success}}const LO=/^c[^\s-]{8,}$/i,DO=/^[0-9a-z]+$/,OO=/^[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,zO=/^[a-z0-9_-]{21}$/i,$O=/^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$/,FO=/^[-+]?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)?)??$/,HO=/^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i,UO="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$";let Pm;const WO=/^(?:(?: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])$/,VO=/^(?:(?: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])$/,qO=/^(([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]))$/,KO=/^(([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])$/,GO=/^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,YO=/^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$/,_T="((\\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])))",XO=new RegExp(`^${_T}$`);function yT(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 ZO(e){return new RegExp(`^${yT(e)}$`)}function QO(e){let t=`${_T}T${yT(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 JO(e,t){return!!((t==="v4"||!t)&&WO.test(e)||(t==="v6"||!t)&&qO.test(e))}function e6(e,t){if(!$O.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 t6(e,t){return!!((t==="v4"||!t)&&VO.test(e)||(t==="v6"||!t)&&KO.test(e))}class Ti extends We{_parse(t){if(this._def.coerce&&(t.data=String(t.data)),this._getType(t)!==ue.string){const s=this._getOrReturnCtx(t);return ie(s,{code:Y.invalid_type,expected:ue.string,received:s.parsedType}),Ne}const r=new Rn;let i;for(const s of this._def.checks)if(s.kind==="min")t.data.length<s.value&&(i=this._getOrReturnCtx(t,i),ie(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),ie(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?ie(i,{code:Y.too_big,maximum:s.value,type:"string",inclusive:!0,exact:!0,message:s.message}):a&&ie(i,{code:Y.too_small,minimum:s.value,type:"string",inclusive:!0,exact:!0,message:s.message}),r.dirty())}else if(s.kind==="email")HO.test(t.data)||(i=this._getOrReturnCtx(t,i),ie(i,{validation:"email",code:Y.invalid_string,message:s.message}),r.dirty());else if(s.kind==="emoji")Pm||(Pm=new RegExp(UO,"u")),Pm.test(t.data)||(i=this._getOrReturnCtx(t,i),ie(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),ie(i,{validation:"uuid",code:Y.invalid_string,message:s.message}),r.dirty());else if(s.kind==="nanoid")zO.test(t.data)||(i=this._getOrReturnCtx(t,i),ie(i,{validation:"nanoid",code:Y.invalid_string,message:s.message}),r.dirty());else if(s.kind==="cuid")LO.test(t.data)||(i=this._getOrReturnCtx(t,i),ie(i,{validation:"cuid",code:Y.invalid_string,message:s.message}),r.dirty());else if(s.kind==="cuid2")DO.test(t.data)||(i=this._getOrReturnCtx(t,i),ie(i,{validation:"cuid2",code:Y.invalid_string,message:s.message}),r.dirty());else if(s.kind==="ulid")OO.test(t.data)||(i=this._getOrReturnCtx(t,i),ie(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),ie(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),ie(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),ie(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),ie(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),ie(i,{code:Y.invalid_string,validation:{endsWith:s.value},message:s.message}),r.dirty()):s.kind==="datetime"?QO(s).test(t.data)||(i=this._getOrReturnCtx(t,i),ie(i,{code:Y.invalid_string,validation:"datetime",message:s.message}),r.dirty()):s.kind==="date"?XO.test(t.data)||(i=this._getOrReturnCtx(t,i),ie(i,{code:Y.invalid_string,validation:"date",message:s.message}),r.dirty()):s.kind==="time"?ZO(s).test(t.data)||(i=this._getOrReturnCtx(t,i),ie(i,{code:Y.invalid_string,validation:"time",message:s.message}),r.dirty()):s.kind==="duration"?FO.test(t.data)||(i=this._getOrReturnCtx(t,i),ie(i,{validation:"duration",code:Y.invalid_string,message:s.message}),r.dirty()):s.kind==="ip"?JO(t.data,s.version)||(i=this._getOrReturnCtx(t,i),ie(i,{validation:"ip",code:Y.invalid_string,message:s.message}),r.dirty()):s.kind==="jwt"?e6(t.data,s.alg)||(i=this._getOrReturnCtx(t,i),ie(i,{validation:"jwt",code:Y.invalid_string,message:s.message}),r.dirty()):s.kind==="cidr"?t6(t.data,s.version)||(i=this._getOrReturnCtx(t,i),ie(i,{validation:"cidr",code:Y.invalid_string,message:s.message}),r.dirty()):s.kind==="base64"?GO.test(t.data)||(i=this._getOrReturnCtx(t,i),ie(i,{validation:"base64",code:Y.invalid_string,message:s.message}),r.dirty()):s.kind==="base64url"?YO.test(t.data)||(i=this._getOrReturnCtx(t,i),ie(i,{validation:"base64url",code:Y.invalid_string,message:s.message}),r.dirty()):Ge.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 Ti({...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 Ti({...this._def,checks:[...this._def.checks,{kind:"trim"}]})}toLowerCase(){return new Ti({...this._def,checks:[...this._def.checks,{kind:"toLowerCase"}]})}toUpperCase(){return new Ti({...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}}Ti.create=e=>new Ti({checks:[],typeName:Te.ZodString,coerce:(e==null?void 0:e.coerce)??!1,...je(e)});function n6(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 Wa extends We{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)!==ue.number){const s=this._getOrReturnCtx(t);return ie(s,{code:Y.invalid_type,expected:ue.number,received:s.parsedType}),Ne}let r;const i=new Rn;for(const s of this._def.checks)s.kind==="int"?Ge.isInteger(t.data)||(r=this._getOrReturnCtx(t,r),ie(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),ie(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),ie(r,{code:Y.too_big,maximum:s.value,type:"number",inclusive:s.inclusive,exact:!1,message:s.message}),i.dirty()):s.kind==="multipleOf"?n6(t.data,s.value)!==0&&(r=this._getOrReturnCtx(t,r),ie(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),ie(r,{code:Y.not_finite,message:s.message}),i.dirty()):Ge.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 Wa({...this._def,checks:[...this._def.checks,{kind:t,value:n,inclusive:r,message:ge.toString(i)}]})}_addCheck(t){return new Wa({...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"&&Ge.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)}}Wa.create=e=>new Wa({checks:[],typeName:Te.ZodNumber,coerce:(e==null?void 0:e.coerce)||!1,...je(e)});class Gc extends We{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)!==ue.bigint)return this._getInvalidInput(t);let r;const i=new Rn;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),ie(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),ie(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),ie(r,{code:Y.not_multiple_of,multipleOf:s.value,message:s.message}),i.dirty()):Ge.assertNever(s);return{status:i.value,value:t.data}}_getInvalidInput(t){const n=this._getOrReturnCtx(t);return ie(n,{code:Y.invalid_type,expected:ue.bigint,received:n.parsedType}),Ne}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 Gc({...this._def,checks:[...this._def.checks,{kind:t,value:n,inclusive:r,message:ge.toString(i)}]})}_addCheck(t){return new Gc({...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}}Gc.create=e=>new Gc({checks:[],typeName:Te.ZodBigInt,coerce:(e==null?void 0:e.coerce)??!1,...je(e)});class c0 extends We{_parse(t){if(this._def.coerce&&(t.data=!!t.data),this._getType(t)!==ue.boolean){const r=this._getOrReturnCtx(t);return ie(r,{code:Y.invalid_type,expected:ue.boolean,received:r.parsedType}),Ne}return kr(t.data)}}c0.create=e=>new c0({typeName:Te.ZodBoolean,coerce:(e==null?void 0:e.coerce)||!1,...je(e)});class qh extends We{_parse(t){if(this._def.coerce&&(t.data=new Date(t.data)),this._getType(t)!==ue.date){const s=this._getOrReturnCtx(t);return ie(s,{code:Y.invalid_type,expected:ue.date,received:s.parsedType}),Ne}if(Number.isNaN(t.data.getTime())){const s=this._getOrReturnCtx(t);return ie(s,{code:Y.invalid_date}),Ne}const r=new Rn;let i;for(const s of this._def.checks)s.kind==="min"?t.data.getTime()<s.value&&(i=this._getOrReturnCtx(t,i),ie(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),ie(i,{code:Y.too_big,message:s.message,inclusive:!0,exact:!1,maximum:s.value,type:"date"}),r.dirty()):Ge.assertNever(s);return{status:r.value,value:new Date(t.data.getTime())}}_addCheck(t){return new qh({...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}}qh.create=e=>new qh({checks:[],coerce:(e==null?void 0:e.coerce)||!1,typeName:Te.ZodDate,...je(e)});class ww extends We{_parse(t){if(this._getType(t)!==ue.symbol){const r=this._getOrReturnCtx(t);return ie(r,{code:Y.invalid_type,expected:ue.symbol,received:r.parsedType}),Ne}return kr(t.data)}}ww.create=e=>new ww({typeName:Te.ZodSymbol,...je(e)});class u0 extends We{_parse(t){if(this._getType(t)!==ue.undefined){const r=this._getOrReturnCtx(t);return ie(r,{code:Y.invalid_type,expected:ue.undefined,received:r.parsedType}),Ne}return kr(t.data)}}u0.create=e=>new u0({typeName:Te.ZodUndefined,...je(e)});class d0 extends We{_parse(t){if(this._getType(t)!==ue.null){const r=this._getOrReturnCtx(t);return ie(r,{code:Y.invalid_type,expected:ue.null,received:r.parsedType}),Ne}return kr(t.data)}}d0.create=e=>new d0({typeName:Te.ZodNull,...je(e)});class Sw extends We{constructor(){super(...arguments),this._any=!0}_parse(t){return kr(t.data)}}Sw.create=e=>new Sw({typeName:Te.ZodAny,...je(e)});class h0 extends We{constructor(){super(...arguments),this._unknown=!0}_parse(t){return kr(t.data)}}h0.create=e=>new h0({typeName:Te.ZodUnknown,...je(e)});class Rs extends We{_parse(t){const n=this._getOrReturnCtx(t);return ie(n,{code:Y.invalid_type,expected:ue.never,received:n.parsedType}),Ne}}Rs.create=e=>new Rs({typeName:Te.ZodNever,...je(e)});class kw extends We{_parse(t){if(this._getType(t)!==ue.undefined){const r=this._getOrReturnCtx(t);return ie(r,{code:Y.invalid_type,expected:ue.void,received:r.parsedType}),Ne}return kr(t.data)}}kw.create=e=>new kw({typeName:Te.ZodVoid,...je(e)});class ii extends We{_parse(t){const{ctx:n,status:r}=this._processInputParams(t),i=this._def;if(n.parsedType!==ue.array)return ie(n,{code:Y.invalid_type,expected:ue.array,received:n.parsedType}),Ne;if(i.exactLength!==null){const o=n.data.length>i.exactLength.value,a=n.data.length<i.exactLength.value;(o||a)&&(ie(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&&(ie(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&&(ie(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 li(n,o,n.path,a)))).then(o=>Rn.mergeArray(r,o));const s=[...n.data].map((o,a)=>i.type._parseSync(new li(n,o,n.path,a)));return Rn.mergeArray(r,s)}get element(){return this._def.type}min(t,n){return new ii({...this._def,minLength:{value:t,message:ge.toString(n)}})}max(t,n){return new ii({...this._def,maxLength:{value:t,message:ge.toString(n)}})}length(t,n){return new ii({...this._def,exactLength:{value:t,message:ge.toString(n)}})}nonempty(t){return this.min(1,t)}}ii.create=(e,t)=>new ii({type:e,minLength:null,maxLength:null,exactLength:null,typeName:Te.ZodArray,...je(t)});function ra(e){if(e instanceof Ot){const t={};for(const n in e.shape){const r=e.shape[n];t[n]=Mi.create(ra(r))}return new Ot({...e._def,shape:()=>t})}else return e instanceof ii?new ii({...e._def,type:ra(e.element)}):e instanceof Mi?Mi.create(ra(e.unwrap())):e instanceof wo?wo.create(ra(e.unwrap())):e instanceof _o?_o.create(e.items.map(t=>ra(t))):e}class Ot extends We{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=Ge.objectKeys(t);return this._cached={shape:t,keys:n},this._cached}_parse(t){if(this._getType(t)!==ue.object){const c=this._getOrReturnCtx(t);return ie(c,{code:Y.invalid_type,expected:ue.object,received:c.parsedType}),Ne}const{status:r,ctx:i}=this._processInputParams(t),{shape:s,keys:o}=this._getCached(),a=[];if(!(this._def.catchall instanceof Rs&&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 li(i,d,i.path,c)),alwaysSet:c in i.data})}if(this._def.catchall instanceof Rs){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&&(ie(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 li(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=>Rn.mergeObjectSync(r,c)):Rn.mergeObjectSync(r,l)}get shape(){return this._def.shape()}strict(t){return ge.errToObj,new Ot({...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 Ot({...this._def,unknownKeys:"strip"})}passthrough(){return new Ot({...this._def,unknownKeys:"passthrough"})}extend(t){return new Ot({...this._def,shape:()=>({...this._def.shape(),...t})})}merge(t){return new Ot({unknownKeys:t._def.unknownKeys,catchall:t._def.catchall,shape:()=>({...this._def.shape(),...t._def.shape()}),typeName:Te.ZodObject})}setKey(t,n){return this.augment({[t]:n})}catchall(t){return new Ot({...this._def,catchall:t})}pick(t){const n={};for(const r of Ge.objectKeys(t))t[r]&&this.shape[r]&&(n[r]=this.shape[r]);return new Ot({...this._def,shape:()=>n})}omit(t){const n={};for(const r of Ge.objectKeys(this.shape))t[r]||(n[r]=this.shape[r]);return new Ot({...this._def,shape:()=>n})}deepPartial(){return ra(this)}partial(t){const n={};for(const r of Ge.objectKeys(this.shape)){const i=this.shape[r];t&&!t[r]?n[r]=i:n[r]=i.optional()}return new Ot({...this._def,shape:()=>n})}required(t){const n={};for(const r of Ge.objectKeys(this.shape))if(t&&!t[r])n[r]=this.shape[r];else{let s=this.shape[r];for(;s instanceof Mi;)s=s._def.innerType;n[r]=s}return new Ot({...this._def,shape:()=>n})}keyof(){return bT(Ge.objectKeys(this.shape))}}Ot.create=(e,t)=>new Ot({shape:()=>e,unknownKeys:"strip",catchall:Rs.create(),typeName:Te.ZodObject,...je(t)});Ot.strictCreate=(e,t)=>new Ot({shape:()=>e,unknownKeys:"strict",catchall:Rs.create(),typeName:Te.ZodObject,...je(t)});Ot.lazycreate=(e,t)=>new Ot({shape:e,unknownKeys:"strip",catchall:Rs.create(),typeName:Te.ZodObject,...je(t)});class Kh extends We{_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 Bi(a.ctx.common.issues));return ie(n,{code:Y.invalid_union,unionErrors:o}),Ne}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 Bi(l));return ie(n,{code:Y.invalid_union,unionErrors:a}),Ne}}get options(){return this._def.options}}Kh.create=(e,t)=>new Kh({options:e,typeName:Te.ZodUnion,...je(t)});const wi=e=>e instanceof p0?wi(e.schema):e instanceof bo?wi(e.innerType()):e instanceof Xh?[e.value]:e instanceof yo?e.options:e instanceof m0?Ge.objectValues(e.enum):e instanceof Qh?wi(e._def.innerType):e instanceof u0?[void 0]:e instanceof d0?[null]:e instanceof Mi?[void 0,...wi(e.unwrap())]:e instanceof wo?[null,...wi(e.unwrap())]:e instanceof wT||e instanceof ef?wi(e.unwrap()):e instanceof Jh?wi(e._def.innerType):[];class z_ extends We{_parse(t){const{ctx:n}=this._processInputParams(t);if(n.parsedType!==ue.object)return ie(n,{code:Y.invalid_type,expected:ue.object,received:n.parsedType}),Ne;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}):(ie(n,{code:Y.invalid_union_discriminator,options:Array.from(this.optionsMap.keys()),path:[r]}),Ne)}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=wi(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 z_({typeName:Te.ZodDiscriminatedUnion,discriminator:t,options:n,optionsMap:i,...je(r)})}}function f0(e,t){const n=ls(e),r=ls(t);if(e===t)return{valid:!0,data:e};if(n===ue.object&&r===ue.object){const i=Ge.objectKeys(t),s=Ge.objectKeys(e).filter(a=>i.indexOf(a)!==-1),o={...e,...t};for(const a of s){const l=f0(e[a],t[a]);if(!l.valid)return{valid:!1};o[a]=l.data}return{valid:!0,data:o}}else if(n===ue.array&&r===ue.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=f0(o,a);if(!l.valid)return{valid:!1};i.push(l.data)}return{valid:!0,data:i}}else return n===ue.date&&r===ue.date&&+e==+t?{valid:!0,data:e}:{valid:!1}}class Gh extends We{_parse(t){const{status:n,ctx:r}=this._processInputParams(t),i=(s,o)=>{if(_w(s)||_w(o))return Ne;const a=f0(s.value,o.value);return a.valid?((yw(s)||yw(o))&&n.dirty(),{status:n.value,value:a.data}):(ie(r,{code:Y.invalid_intersection_types}),Ne)};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}))}}Gh.create=(e,t,n)=>new Gh({left:e,right:t,typeName:Te.ZodIntersection,...je(n)});class _o extends We{_parse(t){const{status:n,ctx:r}=this._processInputParams(t);if(r.parsedType!==ue.array)return ie(r,{code:Y.invalid_type,expected:ue.array,received:r.parsedType}),Ne;if(r.data.length<this._def.items.length)return ie(r,{code:Y.too_small,minimum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),Ne;!this._def.rest&&r.data.length>this._def.items.length&&(ie(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 li(r,o,r.path,a)):null}).filter(o=>!!o);return r.common.async?Promise.all(s).then(o=>Rn.mergeArray(n,o)):Rn.mergeArray(n,s)}get items(){return this._def.items}rest(t){return new _o({...this._def,rest:t})}}_o.create=(e,t)=>{if(!Array.isArray(e))throw new Error("You must pass an array of schemas to z.tuple([ ... ])");return new _o({items:e,typeName:Te.ZodTuple,rest:null,...je(t)})};class Yh extends We{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!==ue.object)return ie(r,{code:Y.invalid_type,expected:ue.object,received:r.parsedType}),Ne;const i=[],s=this._def.keyType,o=this._def.valueType;for(const a in r.data)i.push({key:s._parse(new li(r,a,r.path,a)),value:o._parse(new li(r,r.data[a],r.path,a)),alwaysSet:a in r.data});return r.common.async?Rn.mergeObjectAsync(n,i):Rn.mergeObjectSync(n,i)}get element(){return this._def.valueType}static create(t,n,r){return n instanceof We?new Yh({keyType:t,valueType:n,typeName:Te.ZodRecord,...je(r)}):new Yh({keyType:Ti.create(),valueType:t,typeName:Te.ZodRecord,...je(n)})}}class Cw extends We{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!==ue.map)return ie(r,{code:Y.invalid_type,expected:ue.map,received:r.parsedType}),Ne;const i=this._def.keyType,s=this._def.valueType,o=[...r.data.entries()].map(([a,l],c)=>({key:i._parse(new li(r,a,r.path,[c,"key"])),value:s._parse(new li(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 Ne;(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 Ne;(c.status==="dirty"||u.status==="dirty")&&n.dirty(),a.set(c.value,u.value)}return{status:n.value,value:a}}}}Cw.create=(e,t,n)=>new Cw({valueType:t,keyType:e,typeName:Te.ZodMap,...je(n)});class Yc extends We{_parse(t){const{status:n,ctx:r}=this._processInputParams(t);if(r.parsedType!==ue.set)return ie(r,{code:Y.invalid_type,expected:ue.set,received:r.parsedType}),Ne;const i=this._def;i.minSize!==null&&r.data.size<i.minSize.value&&(ie(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&&(ie(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 Ne;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 li(r,l,r.path,c)));return r.common.async?Promise.all(a).then(l=>o(l)):o(a)}min(t,n){return new Yc({...this._def,minSize:{value:t,message:ge.toString(n)}})}max(t,n){return new Yc({...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)}}Yc.create=(e,t)=>new Yc({valueType:e,minSize:null,maxSize:null,typeName:Te.ZodSet,...je(t)});class p0 extends We{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})}}p0.create=(e,t)=>new p0({getter:e,typeName:Te.ZodLazy,...je(t)});class Xh extends We{_parse(t){if(t.data!==this._def.value){const n=this._getOrReturnCtx(t);return ie(n,{received:n.data,code:Y.invalid_literal,expected:this._def.value}),Ne}return{status:"valid",value:t.data}}get value(){return this._def.value}}Xh.create=(e,t)=>new Xh({value:e,typeName:Te.ZodLiteral,...je(t)});function bT(e,t){return new yo({values:e,typeName:Te.ZodEnum,...je(t)})}class yo extends We{_parse(t){if(typeof t.data!="string"){const n=this._getOrReturnCtx(t),r=this._def.values;return ie(n,{expected:Ge.joinValues(r),received:n.parsedType,code:Y.invalid_type}),Ne}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 ie(n,{received:n.data,code:Y.invalid_enum_value,options:r}),Ne}return kr(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 yo.create(t,{...this._def,...n})}exclude(t,n=this._def){return yo.create(this.options.filter(r=>!t.includes(r)),{...this._def,...n})}}yo.create=bT;class m0 extends We{_parse(t){const n=Ge.getValidEnumValues(this._def.values),r=this._getOrReturnCtx(t);if(r.parsedType!==ue.string&&r.parsedType!==ue.number){const i=Ge.objectValues(n);return ie(r,{expected:Ge.joinValues(i),received:r.parsedType,code:Y.invalid_type}),Ne}if(this._cache||(this._cache=new Set(Ge.getValidEnumValues(this._def.values))),!this._cache.has(t.data)){const i=Ge.objectValues(n);return ie(r,{received:r.data,code:Y.invalid_enum_value,options:i}),Ne}return kr(t.data)}get enum(){return this._def.values}}m0.create=(e,t)=>new m0({values:e,typeName:Te.ZodNativeEnum,...je(t)});class Zh extends We{unwrap(){return this._def.type}_parse(t){const{ctx:n}=this._processInputParams(t);if(n.parsedType!==ue.promise&&n.common.async===!1)return ie(n,{code:Y.invalid_type,expected:ue.promise,received:n.parsedType}),Ne;const r=n.parsedType===ue.promise?n.data:Promise.resolve(n.data);return kr(r.then(i=>this._def.type.parseAsync(i,{path:n.path,errorMap:n.common.contextualErrorMap})))}}Zh.create=(e,t)=>new Zh({type:e,typeName:Te.ZodPromise,...je(t)});class bo extends We{innerType(){return this._def.schema}sourceType(){return this._def.schema._def.typeName===Te.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=>{ie(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 Ne;const l=await this._def.schema._parseAsync({data:a,path:r.path,parent:r});return l.status==="aborted"?Ne:l.status==="dirty"||n.value==="dirty"?Ql(l.value):l});{if(n.value==="aborted")return Ne;const a=this._def.schema._parseSync({data:o,path:r.path,parent:r});return a.status==="aborted"?Ne:a.status==="dirty"||n.value==="dirty"?Ql(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"?Ne:(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"?Ne:(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(!Ua(o))return Ne;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=>Ua(o)?Promise.resolve(i.transform(o.value,s)).then(a=>({status:n.value,value:a})):Ne);Ge.assertNever(i)}}bo.create=(e,t,n)=>new bo({schema:e,typeName:Te.ZodEffects,effect:t,...je(n)});bo.createWithPreprocess=(e,t,n)=>new bo({schema:t,effect:{type:"preprocess",transform:e},typeName:Te.ZodEffects,...je(n)});class Mi extends We{_parse(t){return this._getType(t)===ue.undefined?kr(void 0):this._def.innerType._parse(t)}unwrap(){return this._def.innerType}}Mi.create=(e,t)=>new Mi({innerType:e,typeName:Te.ZodOptional,...je(t)});class wo extends We{_parse(t){return this._getType(t)===ue.null?kr(null):this._def.innerType._parse(t)}unwrap(){return this._def.innerType}}wo.create=(e,t)=>new wo({innerType:e,typeName:Te.ZodNullable,...je(t)});class Qh extends We{_parse(t){const{ctx:n}=this._processInputParams(t);let r=n.data;return n.parsedType===ue.undefined&&(r=this._def.defaultValue()),this._def.innerType._parse({data:r,path:n.path,parent:n})}removeDefault(){return this._def.innerType}}Qh.create=(e,t)=>new Qh({innerType:e,typeName:Te.ZodDefault,defaultValue:typeof t.default=="function"?t.default:()=>t.default,...je(t)});class Jh extends We{_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 Vh(i)?i.then(s=>({status:"valid",value:s.status==="valid"?s.value:this._def.catchValue({get error(){return new Bi(r.common.issues)},input:r.data})})):{status:"valid",value:i.status==="valid"?i.value:this._def.catchValue({get error(){return new Bi(r.common.issues)},input:r.data})}}removeCatch(){return this._def.innerType}}Jh.create=(e,t)=>new Jh({innerType:e,typeName:Te.ZodCatch,catchValue:typeof t.catch=="function"?t.catch:()=>t.catch,...je(t)});class Ew extends We{_parse(t){if(this._getType(t)!==ue.nan){const r=this._getOrReturnCtx(t);return ie(r,{code:Y.invalid_type,expected:ue.nan,received:r.parsedType}),Ne}return{status:"valid",value:t.data}}}Ew.create=e=>new Ew({typeName:Te.ZodNaN,...je(e)});class wT extends We{_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 $_ extends We{_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"?Ne:s.status==="dirty"?(n.dirty(),Ql(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"?Ne: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 $_({in:t,out:n,typeName:Te.ZodPipeline})}}class ef extends We{_parse(t){const n=this._def.innerType._parse(t),r=i=>(Ua(i)&&(i.value=Object.freeze(i.value)),i);return Vh(n)?n.then(i=>r(i)):r(n)}unwrap(){return this._def.innerType}}ef.create=(e,t)=>new ef({innerType:e,typeName:Te.ZodReadonly,...je(t)});var Te;(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"})(Te||(Te={}));const w=Ti.create,V=Wa.create,_e=c0.create,Es=h0.create;Rs.create;const se=ii.create,P=Ot.create;Kh.create;const fi=z_.create;Gh.create;_o.create;const zs=Yh.create,ee=Xh.create,Le=yo.create;Zh.create;Mi.create;wo.create;new Set("ABCDEFGHIJKLMNOPQRSTUVXYZabcdefghijklmnopqrstuvxyz0123456789");const r6=["owner"],i6=["agent","owner","user-upload"],ST=P({id:w().min(1),relPath:w().min(1),from:Le(i6),label:w().optional(),size:V().int().nonnegative(),mime:w().min(1),addedAt:V().int().nonnegative(),lastEditedAt:V().int().nonnegative().optional(),stale:_e().optional()});P({sessionId:w().min(1),relPath:w().min(1),ttlSeconds:V().int().positive().nullable().optional(),view:Le(["raw","md-rendered"]).optional()});P({url:w().min(1),expiresAt:V().int().nonnegative().nullable()});P({sessionId:w().min(1),relPath:w().min(1),label:w().optional(),origin:ee("agent").optional()});P({entry:ST});P({sessionId:w().min(1),relPath:w().min(1)});P({removed:ee(!0)});P({sessionId:w().min(1)});P({entries:se(ST)});P({attachmentId:w().min(1),url:w().min(1),relPath:w().min(1),sizeBytes:V().int().nonnegative(),mimeType:w().min(1)});const s6=fi("type",[P({type:ee("persona"),id:w().min(1)}).strict(),P({type:ee("chat"),id:w().min(1)}).strict(),P({type:ee("*")}).strict()]),o6=Le(["read","send","admin"]),F_=P({resource:s6,actions:se(o6).min(1)}).strict(),a6=P({id:w().min(1),secretHash:w().regex(/^[a-f0-9]{64}$/),displayName:w(),grants:se(F_),issuedAt:V().int().nonnegative(),expiresAt:V().int().positive().optional(),maxUses:V().int().positive().optional(),usedCount:V().int().nonnegative(),peerOwnerId:w().min(1).optional(),firstUsedByPeerAt:V().int().positive().optional(),peerDisplayName:w().optional()}).strict(),l6=a6.omit({secretHash:!0});P({type:ee("whoami:ok"),owner:P({id:w(),kind:Le(["owner","guest"]),displayName:w(),ownerId:w(),provider:w()}).strict(),capability:l6,grantedPersonas:se(P({id:w().min(1),displayName:w()}).strict())}).strict();P({selfUrl:w().min(1)});P({type:ee("contact:handshake:ok"),owner:P({id:w(),ownerId:w(),provider:w(),displayName:w()}),grants:se(F_)});P({deviceId:w().min(1),remoteAccessAllowed:_e()}).strict();P({type:ee("contact:setRemoteAccess:ok"),deviceId:w().min(1),remoteAccessAllowed:_e()}).strict();P({type:ee("contact:remote-access-updated"),deviceId:w().min(1),remoteAccessAllowed:_e()}).strict();const c6=P({deviceId:w().min(1),ownerId:w().min(1),provider:w().min(1),displayName:w(),remoteUrl:w().min(1),connectToken:w(),grants:se(F_),addedAt:V().int().nonnegative(),pinnedAt:V().int().nullable().default(null),remoteAccessAllowed:_e().default(!1)}).strict(),kT=c6;P({deviceId:w().min(1)}).strict();P({type:ee("contact:remove:ok"),deviceId:w().min(1)}).strict();P({type:ee("contact:list:ok"),contacts:se(kT)}).strict();P({type:ee("contact:added"),contact:kT}).strict();P({type:ee("contact:removed"),deviceId:w().min(1)}).strict();P({deviceId:w().min(1),pinned:_e()}).strict();P({type:ee("contact:pin:ok"),deviceId:w().min(1),pinnedAt:V().int().nullable()}).strict();P({type:ee("contact:pinned"),deviceId:w().min(1),pinnedAt:V().int().nullable()}).strict();const u6=P({deviceId:w().min(1),name:w().min(1),url:w().min(1)});P({type:ee("device:list:ok"),devices:se(u6)});P({deviceId:w().min(1),url:w().min(1).optional(),name:w().optional()});P({type:ee("device:connect:ok"),deviceId:w(),name:w(),url:w()});const CT=P({ownerId:w().min(1),provider:w().min(1),displayName:w().min(1),avatarUrl:w().optional(),unionId:w().optional()});P({type:ee("auth:login:start:ok"),authUrl:w().min(1),state:w().min(1)});P({type:ee("auth:getIdentity:ok"),identity:CT.nullable(),deviceId:w().min(1),ttcTokenExpiresAt:V().nullable().optional()});P({type:ee("auth:logout:ok")});P({type:ee("auth:login:done"),identity:CT});P({type:ee("auth:login:failed"),reason:w()});const H_=fi("kind",[P({kind:ee("success"),text:w(),brief:w().optional(),filePaths:se(w()).optional()}),P({kind:ee("failure"),reason:w(),brief:w().optional()})]);P({targetPersona:w().min(1).optional(),dispatchId:w().min(1).optional(),prompt:w(),brief:w().optional(),targetDeviceId:w().min(1).optional(),model:w().min(1).optional(),tool:w().min(1).optional(),sessionLabel:w().min(1).max(60).optional(),meta:zs(Es()).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)"}).refine(e=>!(e.tool!==void 0&&e.targetDeviceId!==void 0),{message:"engine override is not supported for cross-device dispatch (tool + targetDeviceId are mutually exclusive)"}).refine(e=>!(e.dispatchId!==void 0&&(e.tool!==void 0||e.model!==void 0)),{message:"a follow-up dispatch cannot change engine or model (dispatchId excludes tool / model); start a new dispatch instead"});P({dispatchId:w().min(1),outcome:H_});const d6=["running","completed","failed"],U_=Le(d6),h6=P({dispatchId:w().min(1),sourceSessionId:w().min(1),sourcePersonaId:w().min(1).optional(),targetPersonaId:w().min(1),workerSessionId:w().min(1).optional(),taskText:w(),taskBrief:w().optional(),round:V().int().positive().optional(),status:U_,outcome:H_.optional(),meta:zs(Es()).optional(),createdAt:w().min(1),completedAt:w().min(1).optional(),deliveredAt:w().min(1).optional()});P({sourceSessionId:w().min(1).optional()});P({records:se(h6)});P({dispatchId:w().min(1)});P({type:ee("personaDispatch:get:ok"),status:U_,outcome:H_.optional()});const f6=/^[a-z0-9][a-z0-9-]*$/;Le(["stopped","starting","running","crashed","invalid"]);const p6=new Set(["localhost","127.0.0.1"]);function m6(e){let t;try{t=new URL(e)}catch{return!1}return!!(t.protocol==="https:"||t.protocol==="http:"&&p6.has(t.hostname))}const fd=P({id:w().regex(f6),name:w().min(1),version:w().min(1),apiVersion:ee("1"),runtime:P({startCommand:w().min(1)}).passthrough().optional(),entry:P({url:w().url().refine(m6,{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"})}),g6=fi("kind",[P({kind:ee("local"),port:V().int().min(1).max(65535)}),P({kind:ee("hosted"),url:w().url()})]);fi("state",[P({extId:w(),manifest:fd,state:ee("stopped")}),P({extId:w(),manifest:fd,state:ee("starting")}),P({extId:w(),manifest:fd,state:ee("running"),target:g6}),P({extId:w(),manifest:fd,state:ee("crashed")}),P({extId:w(),manifest:Es().nullable(),state:ee("invalid"),invalidReason:w().min(1)})]);P({snapshotHash:w().min(1),version:w().min(1),publishedAt:V()});const v6=fi("kind",[P({kind:ee("p2p-tunnel"),ownerPrincipalId:w().min(1),extId:w().min(1)})]);fi("kind",[P({kind:ee("p2p-tunnel"),ownerPrincipalId:w().min(1),extId:w().min(1),snapshotHash:w().min(1)})]);P({extId:w().min(1),name:w().min(1),version:w().min(1),contentHash:w().min(1),publishedAt:V()});const x6=fi("kind",[P({kind:ee("clean")}),P({kind:ee("ready-new-version"),fromVersion:w().min(1),toVersion:w().min(1)}),P({kind:ee("error-same-hash"),version:w().min(1)}),P({kind:ee("error-version-not-bumped"),localVersion:w().min(1),publishedVersion:w().min(1)}),P({kind:ee("error-version-regression"),localVersion:w().min(1),publishedVersion:w().min(1)})]);P({localManifest:P({name:w().min(1),version:w().min(1),contentHash:w().min(1)}),publishState:fi("kind",[P({kind:ee("unpublished")}),P({kind:ee("published"),version:w().min(1),contentHash:w().min(1),publishedAt:V()})]),check:x6});P({extId:w().min(1),newVersion:w().min(1).nullish()});P({extId:w().min(1)});P({extId:w().min(1),snapshotHash:w().min(1)});P({channelRef:v6,snapshotHash:w().min(1),zipBase64:w().min(1)});P({id:w().min(1),peerDeviceId:w().min(1),senderDeviceId:w().min(1),text:w().min(1),createdAt:V().int().nonnegative(),readBy:zs(w().min(1),V().int().positive()).default({}),origin:P({kind:ee("persona"),personaId:w().min(1)}).optional()}).strict();P({peerDeviceId:w().min(1).optional(),id:w().min(1),text:w().min(1),createdAt:V().int().nonnegative(),origin:P({kind:ee("persona"),personaId:w().min(1)}).optional()}).strict();P({peerDeviceId:w().min(1),sinceCreatedAt:V().int().nonnegative().optional()}).strict();P({peerDeviceId:w().min(1),upToCreatedAt:V().int().nonnegative()}).strict();P({peerDeviceId:w().min(1).optional(),text:w().min(1)});P({peerDeviceId:w().min(1).optional(),command:w().min(1),timeoutMs:V().int().positive().optional()}).strict();P({type:ee("peerExec:run:ok"),stdout:w(),stderr:w(),exitCode:V().int().nullable(),timedOut:_e(),stdoutTruncated:_e(),stderrTruncated:_e()}).strict();const ET=fi("kind",[P({kind:ee("at"),at:w().min(1)}),P({kind:ee("every"),everyMs:V().int().positive(),anchorMs:V().int().nonnegative().optional()}),P({kind:ee("cron"),expr:w().min(1),tz:w().min(1).optional()})]),vu=w().trim().min(1);P({personaId:vu,name:w().min(1),schedule:ET,prompt:w().min(1),targetPersona:w().min(1).optional(),timeoutMs:V().int().positive().optional()});P({personaId:vu,onlyMine:_e().optional()});P({personaId:vu,shiftId:w().min(1)});const _6=P({name:w().min(1).optional(),schedule:ET.optional(),prompt:w().min(1).optional(),targetPersona:w().min(1).optional(),timeoutMs:V().int().positive().optional(),enabled:_e().optional()});P({personaId:vu,shiftId:w().min(1),patch:_6});P({personaId:vu,shiftId:w().min(1),limit:V().int().positive().optional()});const NT=P({id:w().min(1),name:w().min(1),memberPersonaIds:se(w().min(1)),memberContactDeviceIds:se(w().min(1)),createdAt:w().min(1),updatedAt:w().min(1)}),TT=w().trim().min(1);P({name:TT,memberPersonaIds:se(w().min(1)).default([]),memberContactDeviceIds:se(w().min(1)).default([])});P({channelId:w().min(1),name:TT.optional(),memberPersonaIds:se(w().min(1)).optional(),memberContactDeviceIds:se(w().min(1)).optional()});P({channelId:w().min(1)});P({channels:se(NT)});P({channel:NT});P({ok:ee(!0),removedTopics:V().int().min(0)});const yn=w().trim().min(1),y6=["planning","running","done","archived"],b6=Le(y6),w6=P({at:w().min(1),actor:w().min(1),action:w().min(1),target:w().optional(),reason:w().min(1),artifacts:se(yn).optional()}),S6=P({rejectCount:V().int().min(0),accepted:_e().default(!1),overrideCount:V().int().min(0).optional()}),W_=P({id:w().min(1),channelId:w().min(1),title:w(),masterSessionId:w().min(1),goal:w(),boundaries:w(),acceptanceCriteria:se(w()),activity:se(w6),lineMeta:zs(S6),state:b6,createdAt:w().min(1),updatedAt:w().min(1)}),k6=P({lineId:w().min(1),dispatchId:w().min(1),workerSessionId:w().optional(),assignee:w().min(1),focus:w(),status:U_,acceptance:se(w()),rejectCount:V().int().min(0),accepted:_e()});P({channelId:w().min(1)});P({topicId:w().min(1).optional(),sessionId:w().min(1).optional()}).refine(e=>e.topicId!==void 0||e.sessionId!==void 0,{message:"either topicId or sessionId is required"});P({channelId:w().min(1),title:yn.optional()});P({topicId:w().min(1),title:yn.optional(),goal:yn,boundaries:w(),acceptanceCriteria:se(yn).min(1)});P({topicId:w().min(1),action:yn,target:yn.optional(),reason:yn,artifacts:se(yn).optional()});P({topicId:w().min(1),lineId:yn,reason:yn});P({topicId:w().min(1),lineId:yn,reason:yn,artifacts:se(yn).optional(),watcherVerdict:Le(["pass","fail"]),overrideReason:yn.optional()}).refine(e=>e.watcherVerdict!=="fail"||!!e.overrideReason,{message:"watcherVerdict=fail 时必须给 overrideReason(推翻 watcher 的理由)",path:["overrideReason"]});P({topicId:w().min(1),state:Le(["done","archived"])});P({topicId:w().min(1),title:yn});P({topicId:w().min(1)});const C6=W_.extend({lineCount:V().int().min(0)});P({topics:se(C6)});P({topic:W_,lines:se(k6)});P({topicId:w().min(1),masterSessionId:w().min(1)});P({rejectCount:V().int().min(1),needsOwnerAttention:_e()});P({acceptedLines:V().int().min(1),totalLines:V().int().min(1),allAccepted:_e(),overrides:V().int().min(0),needsOwnerAttention:_e()});P({topic:W_});P({ok:ee(!0),removedMasterSessionId:w().min(1).nullable()});const E6=["ask","allow","deny"],IT=Le(E6),N6=P({id:w().min(1),desc:w().min(1),action:IT});P({rules:se(N6)});P({ruleId:w().min(1)});P({action:IT,desc:w(),source:w().min(1)});const T6=["created","review-requested"],PT=/^[A-Za-z0-9._-]+$/,dl=w().min(1).regex(PT),hl=w().min(1).regex(PT),xu=V().int().positive();P({role:Le(T6)});P({owner:dl,repo:hl,number:xu});P({owner:dl,repo:hl,number:xu,expectedHeadSha:w().min(1)});P({owner:dl,repo:hl,number:xu,body:w().min(1)});P({owner:dl,repo:hl,number:xu,ready:_e()});P({owner:dl,repo:hl});P({owner:dl,repo:hl,number:xu,reviewers:se(w().min(1)).min(1)});P({personaId:w().min(1)});const I6=["expired","cancelled","access_denied","lark_protocol_error","cloud_unreachable","internal_error"],P6=Le(I6);P({personaId:w().min(1),appId:w().min(1),appSecret:w().min(1),botName:w().min(1).optional()});const R6=P({chatId:w().min(1),chatName:w().optional(),lastActiveAt:V().int().optional()}),M6=P({state:Le(["unbound","provisioning","bound","broken"]),appId:w().optional(),botName:w().optional(),brokenReason:w().optional(),qrUrl:w().optional(),errorReason:P6.optional(),groups:se(R6)});M6.extend({personaId:w().min(1)});P({});P({onboardingCompletedAt:V()});P({});P({tools:se(P({id:Le(["claude","codex"]),available:_e(),version:w().optional(),path:w().optional()}))});P({});const A6=P({tool:Le(["claude","codex"]),cwd:w(),toolSessionId:w(),label:w().optional(),createdAt:w(),updatedAt:w(),turns:V()});P({candidates:se(A6)});P({});P({registered:_e()});const j6=P({personaId:w(),label:w(),model:w().optional(),effort:w().optional(),public:_e(),iconKey:w().optional(),tool:w().optional(),createdAt:V(),updatedAt:V()}).strict(),L6=P({name:w().min(1),description:w().optional()}),D6=P({id:w().min(1)}),O6=P({permissions:P({defaultMode:w().optional(),allow:se(w()).optional(),deny:se(w()).optional()}).optional(),sandbox:P({enabled:_e().optional(),autoAllowBashIfSandboxed:_e().optional(),allowUnsandboxedCommands:_e().optional(),excludedCommands:se(w()).optional(),filesystem:P({denyRead:se(w()).optional(),allowRead:se(w()).optional(),denyWrite:se(w()).optional(),allowWrite:se(w()).optional()}).optional(),network:P({allowedDomains:se(w()).optional(),allowLocalBinding:_e().optional()}).optional()}).optional()});j6.extend({personality:w().optional(),skills:se(L6).optional(),plugins:se(D6).optional(),sandboxSettings:O6.nullable().optional()});P({slug:w().regex(/^[a-z0-9]+(-[a-z0-9]+)*$/).max(32),label:w().min(1),personality:w(),model:w().optional(),effort:w().optional(),tool:w().optional(),public:_e().optional(),iconKey:w().optional()}).strict();P({personaId:w().min(1)});P({personaId:w().min(1),patch:P({label:w().min(1).optional(),model:w().optional(),effort:w().optional(),tool:w().optional(),personality:w().optional(),public:_e().optional(),iconKey:w().nullable().optional()}).strict()}).strict();P({writableRoots:se(w()).optional(),denyRead:se(w()).optional(),network:_e().optional()}).strict();const RT=["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"],MT=["idle","running","running-idle","stopped","error","observing"],B6=["task-notification","slash-command","local-command","system-reminder","skill-hint","meta-text","attachment-skills","attachment-deferred-tools","dispatch-task","dispatch-result"];function op(e){return e==="dispatch-task"||e==="dispatch-result"}const z6=["builtin","global","project","plugin"],$6=["builtin","global","project","policy","plugin"],AT=Le(["owner","guest"]);P({id:w().min(1),kind:AT,displayName:w(),feishuUnionId:w().optional()}).strict();const F6=P({did:w().min(1),displayName:w(),feishuUnionId:w().optional(),principal:AT}).strict(),H6=Le(MT),U6=P({input_tokens:V().int().nonnegative().optional(),cache_read_input_tokens:V().int().nonnegative().optional(),cache_creation_input_tokens:V().int().nonnegative().optional(),output_tokens:V().int().nonnegative().optional()}),W6=P({inputTokens:V().int().nonnegative(),outputTokens:V().int().nonnegative(),cacheReadTokens:V().int().nonnegative().optional(),cacheCreateTokens:V().int().nonnegative().optional()}),jT={gitBranch:w().optional(),resolvedModel:w().optional(),resolvedEffort:w().optional(),contextUsage:W6.optional(),contextWindowSize:V().int().positive().optional(),aiLabel:w().optional()},V6=P(jT),LT=P({value:w(),label:w(),description:w().optional()}),q6=P({id:w().min(1),label:w().min(1),description:w().optional(),contextWindowSize:V().int().positive(),default:_e().optional(),efforts:se(LT).optional(),defaultEffort:w().optional()}),K6=P({id:w().min(1),label:w().min(1),description:w().optional()}),G6=P({name:w().min(1),type:Le(["string","select","toggle"]),label:w().min(1),description:w().optional(),options:se(LT).optional(),default:Es().optional(),scope:Le(["core","tool-specific"])});P({tool:w().min(1)});const Y6=P({rewind:_e(),subagents:_e(),tui:_e(),observe:_e(),fileSharing:_e(),fork:_e()});P({tool:w().min(1),toolSessionIdLabel:w().optional(),models:se(q6),permissionModes:se(K6),configSchema:se(G6),features:Y6});const X6=P({tool:w().min(1),pattern:w().min(1),createdAt:w().min(1).optional()});P({sessionId:w().min(1),cwd:w().min(1),tool:ee("claude").or(w().min(1)).default("claude"),toolSessionId:w().optional(),label:w().optional(),model:w().optional(),permissionMode:w().optional(),effort:w().optional(),...jT,aiLabelGeneratedAt:w().optional(),permissionRules:se(X6).optional(),pinnedAt:V().int().nonnegative().nullable().optional(),archivedAt:V().int().nonnegative().nullable().optional(),pinSortOrder:V().int().nullable().optional(),unreadAt:w().min(1).nullable().optional(),iconKey:w().optional(),forkedFromSessionId:w().min(1).optional(),ephemeral:_e().optional(),ownerPersonaId:w().min(1).optional(),projectPath:w().min(1).optional(),appBuilderProject:w().regex(/^[a-z][a-z0-9-]{0,39}$/).optional(),chatId:w().min(1).optional(),creatorPrincipalId:w().min(1).optional(),creatorDisplayName:w().min(1).optional(),creatorFeishuUnionId:w().min(1).optional(),originOwnerPrincipalId:w().min(1).optional(),originOwnerPersonaId:w().min(1).optional(),dispatchedFromSessionId:w().min(1).optional(),shiftFiredFromSessionId:w().min(1).optional(),larkChatId:w().min(1).optional(),larkChatName:w().min(1).optional(),larkChatType:Le(["p2p","group"]).optional(),createdAt:w().min(1),updatedAt:w().min(1)});const Bn={seq:V().int().nonnegative().optional(),ts:w().optional(),uuid:w().optional()},Z6=Le(B6),Q6=P({readCount:V().int().nonnegative().optional(),searchCount:V().int().nonnegative().optional(),bashCount:V().int().nonnegative().optional(),editFileCount:V().int().nonnegative().optional(),linesAdded:V().int().nonnegative().optional(),linesRemoved:V().int().nonnegative().optional(),otherToolCount:V().int().nonnegative().optional()}),J6=P({oldStart:V().int().nonnegative(),oldLines:V().int().nonnegative(),newStart:V().int().nonnegative(),newLines:V().int().nonnegative(),lines:se(w())}),eB=P({agentId:w().optional(),agentType:w().optional(),status:w().optional(),prompt:w().optional(),filePath:w().optional(),structuredPatch:se(J6).optional(),stats:P({durationMs:V().int().nonnegative().optional(),tokens:V().int().nonnegative().optional(),toolUseCount:V().int().nonnegative().optional(),toolStats:Q6.optional(),usage:U6.optional()}).optional()}),tB=P({path:w(),content:w(),mtimeMs:V().optional()}),nB=P({label:w().min(1),description:w().optional()}),DT=P({question:w().min(1),multiSelect:_e(),options:se(nB).min(1)}),rB=["completed","interrupted"];fi("kind",[P({...Bn,kind:ee("session_init"),toolSessionId:w().optional()}),P({...Bn,kind:ee("thinking"),text:w(),partialId:w().optional()}),P({...Bn,kind:ee("text"),text:w(),partialId:w().optional()}),P({...Bn,kind:ee("user_text"),text:w(),meta:Z6.optional(),taskId:w().optional(),parentToolUseId:w().optional(),sender:F6.optional()}),P({...Bn,kind:ee("tool_call"),toolUseId:w(),tool:w(),toolKind:w().optional(),input:Es()}),P({...Bn,kind:ee("tool_result"),toolUseId:w(),output:Es().optional(),error:w().optional(),toolResultExtra:eB.optional(),sourceToolAssistantUUID:w().optional(),askQuestionAnswers:zs(w(),w()).optional()}),P({...Bn,kind:ee("attachment_memories"),memories:se(tB)}),P({...Bn,kind:ee("permission_request"),requestId:w(),tool:w(),input:Es(),toolUseId:w().optional()}),P({...Bn,kind:ee("ask_user_question"),toolUseId:w(),questions:se(DT)}),P({...Bn,kind:ee("turn_end"),durationMs:V().int().nonnegative().optional(),reason:Le(rB).optional()}),P({...Bn,kind:ee("subagent_progress"),toolUseId:w(),agentId:w(),status:Le(["started","running","completed","failed"]),description:w().optional(),lastToolName:w().optional(),prompt:w().optional(),stats:P({durationMs:V().int().nonnegative().optional(),tokens:V().int().nonnegative().optional(),toolUseCount:V().int().nonnegative().optional()}).optional()}),P({...Bn,kind:ee("error"),message:w()}),P({...Bn,kind:ee("meta_update"),patch:V6}),P({...Bn,kind:ee("meta-text"),text:w(),metaSource:Le(["cc","owner"]).optional()})]);P({cwd:w().min(1).optional(),tool:w().optional(),label:w().optional(),aiLabel:w().optional(),model:w().optional(),permissionMode:w().optional(),effort:w().optional(),iconKey:w().optional(),forkedFromSessionId:w().min(1).optional(),ephemeral:_e().optional(),ownerPersonaId:w().min(1).optional(),projectPath:w().min(1).optional()}).refine(e=>e.cwd!=null||e.ownerPersonaId!=null||e.projectPath!=null,{message:"cwd / ownerPersonaId / projectPath 至少传一个"});P({path:w().min(1),name:w().min(1),createdAt:w().datetime(),pinnedAt:V().optional()});P({path:w().min(1),pinnedAt:V().nullable()});P({path:w().min(1)});P({path:w().min(1).optional(),name:w().min(1).optional()}).refine(e=>e.path!=null||e.name!=null,{message:"path 与 name 至少给一个"});P({cwd:w().min(1),tool:w().min(1),toolSessionId:w().min(1),label:w().optional(),aiLabel:w().optional(),iconKey:w().optional(),createdAt:w().datetime(),updatedAt:w().datetime(),ownerPersonaId:w().min(1).optional()});P({originOnly:_e().optional(),ownerPersonaId:w().min(1).optional(),limit:V().int().positive().optional(),offset:V().int().nonnegative().optional()});P({sessionId:w().min(1)});P({sessionId:w().min(1),patch:P({label:w().optional(),model:w().optional(),permissionMode:w().optional(),effort:w().optional(),cwd:w().optional(),iconKey:w().optional(),ephemeral:ee(!1).optional()})});P({sessionId:w().min(1),text:w()});P({sessionId:w().min(1),userMessageId:w().min(1),dryRun:_e().optional()});P({canRewind:_e(),error:w().optional(),filesChanged:se(w()).optional(),insertions:V().int().nonnegative().optional(),deletions:V().int().nonnegative().optional()});P({sessionId:w().min(1),userMessageId:w().min(1)});const iB=P({oldStart:V().int().nonnegative(),oldLines:V().int().nonnegative(),newStart:V().int().nonnegative(),newLines:V().int().nonnegative(),lines:se(w())}),sB=P({filePath:w().min(1),hunks:se(iB),insertions:V().int().nonnegative(),deletions:V().int().nonnegative(),status:Le(["modified","added","deleted"]).optional()});P({canRewind:_e(),error:w().optional(),files:se(sB),totalInsertions:V().int().nonnegative(),totalDeletions:V().int().nonnegative()});P({userMessageIds:se(w())});P({sessionId:w().min(1),toolSessionId:w().min(1)});P({cwd:w().min(1),toolSessionId:w().min(1),messageUuid:w().min(1),targetCwd:w().min(1).optional()});P({forkedToolSessionId:w().min(1),forkedFilePath:w().min(1)});P({sessionId:w().min(1),toolSessionId:w().min(1),jsonlPath:w().optional()});P({sessionId:w().min(1),afterSeq:V().int().min(-1)});P({sessionId:w().min(1),permissionRequestId:w().min(1),allow:_e(),permanent:_e().optional(),pattern:w().optional()});P({projectPath:w().min(1)});P({sessionId:w().min(1),limit:V().int().positive().max(5e3).optional(),offset:V().int().nonnegative().optional(),slim:_e().optional()});P({cwd:w().min(1),toolSessionId:w().min(1)});P({cwd:w().min(1),toolSessionId:w().min(1),subagentId:w().min(1)});P({cwd:w().min(1).optional(),path:w().optional(),showHidden:_e().optional()});P({cwd:w().min(1),path:w().min(1)});P({cwd:w().min(1),tool:w().optional()});P({name:w().min(1),source:Le(z6),path:w().optional(),description:w().optional(),plugin:w().optional()});const oB=P({name:w().min(1),source:Le($6),path:w().optional(),description:w().optional(),whenToUse:w().optional(),plugin:w().optional()});P({cwd:w().min(1),tool:w().optional()});P({agents:se(oB)});P({sessionId:w().optional()});P({sessionId:w().min(1).optional()});P({sessionId:w().min(1),pinned:_e()});P({sessionId:w().min(1),archived:_e()});P({type:ee("peerSession:upsert:ok")});P({sessionId:w().min(1)});P({type:ee("peerSession:remove:ok")});P({orderedIds:se(w().min(1)).min(1)});P({cwd:w().min(1)});P({isGitRoot:_e(),gitRoot:w().nullable()});P({cwd:w().min(1)});P({branch:w().nullable()});P({cwd:w().min(1)});P({branches:se(w()),head:w().nullable()});P({}).optional();const aB=P({cwd:w().min(1),updatedAt:w().min(1)});P({dirs:se(aB)});P({type:ee("session:question"),sessionId:w().min(1),toolUseId:w().min(1),requestId:w().min(1),questions:se(DT).min(1)});P({type:ee("session:question:cleared"),sessionId:w().min(1),toolUseId:w().min(1),answers:zs(w(),w()).optional()});P({sessionId:w().min(1),toolUseId:w().min(1),answers:zs(w(),w())});P({ok:ee(!0)});P({sessionId:w().min(1),toolUseId:w().min(1)});P({ok:ee(!0)});const OT=P({name:w().min(1),version:w().min(1),instanceId:w().min(1),deviceLabel:w().transform(e=>e.trim().slice(0,64)).optional()});P({type:ee("auth"),token:w().min(1),scheme:ee("bearer").optional(),clientInfo:OT.optional()});P({type:ee("auth:ok"),version:w().min(1).optional(),protocolVersion:V().int().nonnegative().optional()});const lB=P({clientId:w().min(1),connectedAt:V().int().nonnegative(),self:_e(),clientInfo:OT.optional()});P({type:ee("device:connections:ok"),connections:se(lB)});P({type:ee("tunnel:ready"),url:w().min(1),subdomain:w().min(1)});P({type:ee("tunnel:exited"),code:V().int().nullable(),subdomain:w().nullable(),url:w().nullable()});P({type:ee("tunnel:unavailable"),reason:w().min(1),failedAt:w().min(1)});const cB=P({sessionId:w().min(1),status:H6,freshSpawn:_e(),pendingPermissionRequestIds:se(w().min(1)),pendingQuestionToolUseIds:se(w().min(1))});P({type:ee("info"),version:w(),protocolVersion:V(),hostname:w(),os:w(),tools:se(P({id:w(),available:_e()})),runningSessions:se(cB),tokenRole:Le(r6).optional(),isLoopback:_e().optional(),httpBaseUrl:w().optional(),httpToken:w().optional(),daemonSource:Le(["ota","packaged"]).optional(),globalCliVersion:w().nullable().optional()});const uB=6173,dB=6272,fl=/^[a-z][a-z0-9-]{0,39}$/,_u=P({name:w().regex(fl,{message:"kebab-case, 小写字母开头,只允许小写字母 / 数字 / -,最长 40 字符"}),port:V().int().min(uB).max(dB),createdAt:w().datetime(),devCommand:w().min(1),prodUrl:w().url().optional(),readyPattern:w().optional(),publishJob:P({jobId:w().min(1),stage:Le(["build","deploy","verify"]),startedAt:V().int().nonnegative()}).optional()}),hB=["install-pending","installing","starting-dev-server","running","stopped","failed"],BT=Le(hB),V_=_u.extend({isRunning:_e(),boundSessionId:w().nullable(),stage:BT.optional(),stageReason:w().optional(),publishJob:P({jobId:w().min(1),stage:Le(["build","deploy","verify"]),startedAt:V().int().nonnegative(),status:Le(["in-flight","interrupted"])}).optional()});P({}).strict();P({projects:se(V_)}).strict();P({sessionId:w().min(1)}).strict();P({project:V_.nullable()}).strict();P({sessionId:w().min(1),name:w().min(1)}).strict();P({project:_u}).strict();P({name:w()}).strict();P({}).strict();P({name:w(),newPort:V().int()}).strict();P({project:_u}).strict();P({name:w().regex(fl),url:w().url()}).strict();P({project:_u}).strict();P({sessionId:w().min(1),force:_e().optional()}).strict();P({project:_u}).strict();const fB=["installing","failed"];P({sessionId:w().min(1),stage:Le(fB),reason:w().optional()}).strict();P({ok:ee(!0)}).strict();P({sessionId:w().min(1)}).strict();P({ok:ee(!0)}).strict();P({type:ee("appBuilder:project-updated"),project:V_,stage:BT,stageReason:w().optional()}).strict();P({name:w().regex(fl)});P({jobId:w().min(1),status:Le(["started","already-publishing"])}).strict();P({name:w().regex(fl)});P({ok:ee(!0)}).strict();P({type:ee("appBuilder:publish-progress"),name:w().regex(fl),jobId:w().min(1),stage:Le(["build","deploy","verify"]),status:Le(["started","completed"])}).strict();P({type:ee("appBuilder:publish-failed"),name:w().regex(fl),jobId:w().min(1),stage:Le(["build","deploy","verify","unknown"]),errorSummary:w()}).strict();P({});P({method:w().min(1).optional()});const pB=["allowed","conditional","denied"],mB=Le(pB),gB=P({name:w().min(1),status:mB,description:w().min(1),args:se(P({name:w(),required:_e()})).nullable(),argsSchema:zs(Es()).optional(),reason:w().optional()});P({type:ee("meta:methods"),methods:se(gB)});const Nw=1,vB=["daemon","main","renderer"],xB=Le(vB),_B=["debug","info","warn","error"],yB=Le(_B);P({ts:V().int(),source:xB,level:yB,msg:w(),ownerPrincipalId:w(),deviceId:w(),appVersion:w(),daemonVersion:w().optional(),os:w(),meta_json:w().optional(),sessionId:w().optional()});P({v:ee(1),visitorId:w().min(1),displayName:w(),provider:w(),iat:V(),exp:V()});const bB=P({visitorId:w(),displayName:w(),avatarUrl:w().optional(),provider:w(),firstSeen:V(),lastSeen:V()});P({visitors:se(bB)});const wB=/<system-reminder>此消息来自飞书群成员 (.+?)<\/system-reminder>\s*$/,SB=/<system-reminder>此消息来自 (owner|guest):(.+?)<\/system-reminder>\s*$/,kB="clawd-dispatch-task",CB="clawd-dispatch-result",Tw=120;function EB(e){if(!e)return[];const t=[];for(const n of["task","result"]){const r=n==="task"?kB:CB,i=new RegExp(`<${r}\\b([^>]*)>([\\s\\S]*?)</${r}>`,"gi");for(let s=i.exec(e);s!==null;s=i.exec(e))t.push({at:s.index,block:NB(n,s[1]??"",s[2]??"")})}return t.sort((n,r)=>n.at-r.at).map(n=>n.block)}function NB(e,t,n){var c;const r=jB(t),i=g0(AB(Rm(n,"detail")??n)),s=(c=Rm(n,"brief"))==null?void 0:c.trim(),o=s&&s.length>0?g0(s):TB(i),a=r.round!==void 0?Number.parseInt(r.round,10):void 0,l=r.status;return{kind:e,dispatchId:r["dispatch-id"]??"",...r.from?{from:r.from}:{},...e==="task"&&a!==void 0&&Number.isFinite(a)?{round:a}:{},...e==="result"&&(l==="success"||l==="failure")?{status:l}:{},brief:o,briefIsDerived:!(s&&s.length>0),detail:i,filePaths:MB(Rm(n,"files"))}}function TB(e){const t=e.split(/\n\s*\n/).map(r=>r.trim()).find(r=>r.length>0);if(!t)return"";const n=t.replace(/\s+/g," ");return n.length>Tw?`${n.slice(0,Tw)}…`:n}const IB="clawd-dispatch-task|clawd-dispatch-result|brief|detail|files",PB=new RegExp(`<\\\\(\\\\*)(/?)(${IB})\\b`,"g");function RB(e){return g0(e)}function g0(e){return e.replace(PB,"<$1$2$3")}function Rm(e,t){const n=new RegExp(`<${t}>([\\s\\S]*?)</${t}>`,"i").exec(e);return n?n[1]??"":null}function MB(e){return e?e.split(`
|
|
96
|
-
`).map(t=>t.trim()).filter(t=>t.startsWith("- ")).map(t=>t.slice(2).trim()).filter(t=>t.length>0):[]}function AB(e){return e.replace(/^\n/,"").replace(/\n$/,"")}function jB(e){const t={},n=/([a-z-]+)="([^"]*)"/gi;for(let r=n.exec(e);r!==null;r=n.exec(e))t[r[1]]=LB(r[2]??"");return t}function LB(e){return e.replace(/"/g,'"').replace(/</g,"<").replace(/>/g,">").replace(/&/g,"&")}const DB=new Set(["localhost","127.0.0.1","0.0.0.0","::1"]);let _i=null;function OB(){if(_i!==null)return _i;if(typeof window>"u")return _i=!1,!1;if(DB.has(window.location.hostname)||window.location.protocol==="file:")return _i=!0,!0;if(new URLSearchParams(window.location.search).get("debug")==="1"){_i=!0;try{sessionStorage.setItem("debug","1")}catch{}}else try{_i=sessionStorage.getItem("debug")==="1"}catch{_i=!1}return _i}function Ae(e,...t){OB()&&console.log(`[${e}][${new Date().toISOString()}]`,...t)}function pd(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 BB=e=>{const t=[1e3,2e3,4e3,8e3,16e3,3e4];return t[Math.min(e,t.length-1)]},zB=new Set(["auth:ok","pong","error"]),Iw=new Set(RT.filter(e=>!zB.has(e)));let $B=0;const Pw=()=>`r${++$B}`;function FB(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??BB;let u=null,d=!1,f=0,p=null,m=null,v=null,b=null,x=!1,_="disconnected";const y=new Map,S=new Map;let C=null;const k=(B,E)=>{var H;B==="ready"&&(C=E),(H=S.get(B))==null||H.forEach(q=>{try{q(E)}catch{}})},N=B=>{_!==B&&(_=B,k("status",B))},T=(B,E)=>{const H=S.get(B)??new Set;if(H.add(E),S.set(B,H),B==="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)},I=()=>{v&&clearTimeout(v),v=setTimeout(()=>{try{u==null||u.close(4e3,"pong watchdog")}catch{}},a)},M=()=>{m&&clearInterval(m),m=setInterval(()=>{(u==null?void 0:u.readyState)===1&&u.send(JSON.stringify({type:"ping",requestId:Pw()}))},o),I()},L=B=>{for(const[,E]of y)clearTimeout(E.timer),E.reject(new Error(B));y.clear()},R=[],A=()=>{if(R.length===0)return;const B=R.splice(0);for(const E of B)(u==null?void 0:u.readyState)===1&&!x?E.doSend():(clearTimeout(E.timer),E.reject(new Error("NOT_CONNECTED")))},D=B=>{if(R.length===0)return;const E=R.splice(0);for(const H of E)clearTimeout(H.timer),H.reject(new Error(B))},$=()=>{if(d)return;const B=c(f);B<0||(k("daemon:reconnecting",{attempt:f+1,nextDelayMs:B,scheduledAt:Date.now()}),p&&clearTimeout(p),p=setTimeout(()=>{f+=1,O()},B))},F=B=>{I();const E=String(B.type??"");if(E==="auth:ok"){Ae("daemon-client","auth:ok received → connected",{url:t}),b&&(clearTimeout(b),b=null),x=!1,f=0,N("connected"),k("daemon:connected",{url:t}),M(),A();return}if(E==="pong")return;if(E==="ready"){const q=Number(B.protocolVersion??-1);q!==Nw&&k("daemon:version-mismatch",{daemonProtocol:q,supportedProtocol:Nw}),k("ready",B);return}const H=B.requestId;if(typeof H=="string"&&y.has(H)){const q=y.get(H);if(y.delete(H),clearTimeout(q.timer),E==="error"){const j=String(B.code??"ERR"),ne=String(B.message??"unknown");q.reject(new Error(`${j}: ${ne}`))}else Iw.has(E)&&k(E,B),q.resolve(B);return}Iw.has(E)&&k(E,B)},O=()=>{p&&(clearTimeout(p),p=null),Ae("daemon-client","connect →",{url:t,token:pd(n),attempt:f}),N("connecting");let B;try{B=new WebSocket(t)}catch(E){N("disconnected"),k("daemon:disconnected",{reason:(E==null?void 0:E.message)??"ws constructor failed"}),$();return}u=B,x=!!n,B.onopen=()=>{if(B!==u){Ae("daemon-client","onopen → stale (replaced before opened), ignore");return}if(n){Ae("daemon-client","onopen → send auth frame",{token:pd(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),B.send(JSON.stringify(E)),b=setTimeout(()=>{try{B.close(4001,"auth handshake timeout")}catch{}},l)}else Ae("daemon-client","onopen → no token, treat as connected (daemon authMode=none)"),f=0,N("connected"),k("daemon:connected",{url:t}),M(),A()},B.onclose=E=>{if(B!==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:x,manualStop:d}),z(),L(`connection closed: ${H}`),u=null,E.code===4401?N("revoked"):N("disconnected"),k("daemon:disconnected",{reason:H}),E.code===1008||E.code===4401){D(`connection closed: ${H}`);return}d?D(`connection closed: ${H}`):$()},B.onerror=()=>{},B.onmessage=E=>{if(B!==u)return;let H;try{H=JSON.parse(String(E.data))}catch{return}F(H)}};return{start(){d=!1,f=0,O()},stop(){d=!0,p&&(clearTimeout(p),p=null),z();try{u==null||u.close(1e3,"shutdown")}catch{}u=null,L("shutdown"),D("shutdown"),N("disconnected")},switchProfile(B){Ae("daemon-client","switchProfile →",{url:B.url,token:pd(B.authToken)},"prev:",{url:t,token:pd(n)}),t=B.url,n=B.authToken,B.selfIdentity!==void 0&&(r=B.selfIdentity),f=0,d=!0,p&&(clearTimeout(p),p=null),z(),L("switch profile"),D("switch profile");try{u==null||u.close(1e3,"switch profile")}catch{}u=null,d=!1,O()},request(B,E){return new Promise((H,q)=>{const j=Pw(),ne=setTimeout(()=>{y.delete(j);const G=R.findIndex(ve=>ve.timer===ne);G>=0&&R.splice(G,1),q(new Error(`request timeout: ${B}`))},s),re=()=>{y.set(j,{resolve:G=>H(G),reject:q,timer:ne}),u.send(JSON.stringify({...E,type:B,requestId:j}))};(u==null?void 0:u.readyState)===1&&!x?re():d||u==null&&p==null?(clearTimeout(ne),q(new Error("NOT_CONNECTED"))):R.push({doSend:re,reject:q,timer:ne})})},on:T,get isOpen(){return(u==null?void 0:u.readyState)===1&&!x},get url(){return t},getStatus(){return _}}}function HB(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 UB(e){return e?{id:e.id,mode:e.mode,url:e.url,token:HB(e.token),name:e.name}:null}function md(e){return e?Array.isArray(e)?e.map(UB):{_notArray:typeof e,_value:e}:null}function Rw(e){return e==null?null:typeof e=="object"&&"value"in e?e.value:e}const WB="ws://127.0.0.1:18790",Mw="daemon:profiles",Aw="daemon:active-profile-id";function VB(){return Math.random().toString(36).slice(2,10)}function qB(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 KB(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 zT(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 →",md(t.profiles),"active:",t.activeId),await e.kv.set(Mw,t.profiles),await e.kv.set(Aw,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(Mw);c=Rw(d)}catch{c=null}let u=null;try{const d=await e.kv.get(Aw);u=Rw(d)??null}catch{u=null}if(Ae("profile-store","ensureLoaded read kv →","profiles:",md(c),"activeId:",u),Array.isArray(c)&&c.length>0){const d=c.filter(KB),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",md(d),"active:",f);return}t={profiles:[{id:"default",name:"本机",mode:"localhost",url:WB}],activeId:"default"},Ae("profile-store","ensureLoaded → fallback synthesized default (NO token)",md(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 x=qB(c);c=x.url,!u&&x.token&&(u=x.token)}const d=l.id?t.profiles.find(x=>x.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??VB(),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(x=>x.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 jw="clawd.client-instance-id";let GB={name:"clawd-web",version:"unknown"};function YB(){let e=null;try{e=localStorage.getItem(jw),e||(e=crypto.randomUUID(),localStorage.setItem(jw,e))}catch{e=e??crypto.randomUUID()}return{...GB,instanceId:e}}function Lw(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 $T=g.createContext(null);function XB({host:e,children:t}){const[n,r]=g.useState(null),i=g.useMemo(()=>async()=>{const s=zT(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:Lw(a.token)}),{client:FB({url:a.url,authToken:a.token,clientInfo:YB()}),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:Lw(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($T.Provider,{value:n,children:t}):null}function pi(){const e=g.useContext($T);if(!e)throw new Error("useDaemonClient must be used inside <DaemonProvider>");return e.client}function ZB(){const e=pi(),[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 QB(){const e=pi(),[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 FT=g.createContext(null);function JB({cache:e,children:t}){return g.createElement(FT.Provider,{value:e},t)}function jo(){const e=g.useContext(FT);if(!e)throw new Error("useCache must be used inside <CacheProvider>");return e}function ci(e){const t=jo(),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 HT={actionsLevel:"none",httpBaseUrl:null,httpToken:null},UT=g.createContext(HT);function ap(){return g.useContext(UT)}function ez(e){return e!=null&&e.httpBaseUrl?{actionsLevel:e.tokenRole==="owner"?"owner":"none",httpBaseUrl:e.httpBaseUrl,httpToken:e.httpToken??null}:HT}function tz(){const e=ci("daemon-info");return g.useMemo(()=>ez(e),[e])}function nz({children:e}){const t=tz();return Qe.createElement(UT.Provider,{value:t},e)}function rz(e,t,n){if(!e.httpBaseUrl)return null;const r=encodeURIComponent(n);return`${e.httpBaseUrl}/session/${encodeURIComponent(t.sessionId)}/files?path=${r}`}function iz(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 sz(){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 oz(e){return{request:(t,n)=>e.request(t,n),onFrame(t){const n=[];for(const r of RT)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 WT(e){const t=(e??"claude")==="claude";return{rewind:t,subagents:t,tui:t,observe:t,fileSharing:t,fork:t}}const az=e=>({tool:e,models:[{id:"",label:"未指定",contextWindowSize:2e5,default:!0}],permissionModes:[{id:"",label:"未指定"}],configSchema:[],features:WT(e)});function lz(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,()=>az(r))}},o=e.onConnect(()=>{s()});return s(),()=>{i=!0,o()}}}}function cz(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 Xc={sessionId:null,events:[],lastSeq:-1,pendingPermissions:[],status:"idle",pendingQuestions:{}};function Mm(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 VT(e,t,n){const r=n===void 0?e.sessionId:n;switch(t.type){case"session:change":return{...Xc,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=Mm(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)=>Mm(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)=>Mm(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{...Xc,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 uz="session/";function dz(e){return{sid:e.slice(uz.length)}}const hz=new Set(MT);function qT(e){return hz.has(e)}function Dw(e){return qT(e)?e:"idle"}function fz(e,t){return{start(n){const{sid:r}=dz(n);let i=!1,s=-1;const o=f=>{t(n,p=>VT(p??Xc,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 x=m.bufferStartSeq??0,_=b<p||x>p+1;o({type:_?"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:Dw(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(!qT(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:Dw(v.status)}))})}),d=e.onConnect(()=>{c()});return e.isConnected&&c(),()=>{i=!0,u(),d(),e.request("session:unsubscribe",{sessionId:r}).catch(()=>{})}}}}const pz=new Set(["tunnel:ready","tunnel:exited","tunnel:unavailable"]);function mz(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=>{pz.has(a)&&i()});return i(),()=>{r=!0,s(),o()}}}}function gz(){return{start(){return()=>{}}}}function vz(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 xz(e){const t=oz(e),n=sz();let r=null;const i=(o,a)=>{r==null||r.setData(o,a)};n.register(/^capabilities\//,lz(t,i)),n.register(/^sessions$/,cz(t,i)),n.register(/^session\//,fz(t,i)),n.register(/^personas$/,vz(t,i)),n.register(/^persona-detail\//,gz()),n.register(/^daemon-info$/,mz(t,i));const s=iz({onFirstObserver:o=>{o&&n.activate(o)},onLastObserver:o=>{o&&n.deactivate(o)}});return r=s,{cache:s,channel:t}}class q_{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")}channelList(){return this.client.request("channel:list")}channelCreate(t){return this.client.request("channel:create",t)}channelUpdate(t){return this.client.request("channel:update",t)}channelDelete(t){return this.client.request("channel:delete",t)}topicList(t){return this.client.request("topic:list",t)}topicGet(t){return this.client.request("topic:get",t)}topicCreate(t){return this.client.request("topic:create",t)}topicClose(t){return this.client.request("topic:close",t)}topicRename(t){return this.client.request("topic:rename",t)}topicDelete(t){return this.client.request("topic:delete",t)}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 _z(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 yz(e){const t=jo(),n=ci(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 pl(){const e=pi();return g.useMemo(()=>new q_(e),[e])}function KT(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 K_(){const e=jo(),t=pl(),n=ci("personas")??[],r=g.useMemo(()=>n.map(s=>KT(s)),[n]),i=g.useCallback(async()=>{const s=await t.personaList();e.setData("personas",()=>s.personas??[])},[t,e]);return{personas:r,raw:n,loaded:ci("personas")!==void 0,refresh:i}}function GT(e){const{raw:t}=K_(),n=jo(),r=pl(),i=e?t.find(a=>a.personaId===e)??null:null,s=i?KT(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 bz(e){const t=pl(),n=jo(),r=e?`persona-detail/${e}`:"",i=ci(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 YT(){const e=jo(),t=pl();return g.useCallback(async()=>{const n=await t.personaList();e.setData("personas",()=>n.personas??[])},[e,t])}function wz(){const e=pl(),t=YT();return g.useCallback(async(n,r)=>{const i=await e.personaUpdate(n,r);return await t(),i},[e,t])}function Sz(){const e=pl(),t=YT();return g.useCallback(async n=>{await e.personaDelete(n),await t()},[e,t])}const Ow="clawd:sidebar:tree-collapsed";function kz(e){return e&&typeof e=="object"&&"value"in e?e.value:e}function Cz(e){const t=kz(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 Ez(){const e=T_(),[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(Ow);if(l)return;n(Cz(c))}catch{}})(),()=>{l=!0}},[e]);const i=g.useCallback(l=>{e.kv.set(Ow,[...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 G_=g.createContext(null);function Nz(){const e=g.useContext(G_);if(!e)throw new Error("SessionTreeCollapsedContext.Provider missing — wrap SessionTreeNode tree with <SessionTreeCollapsedContext.Provider value={useSessionTreeCollapsed()}>");return e}/**
|
|
96
|
+
`).map(t=>t.trim()).filter(t=>t.startsWith("- ")).map(t=>t.slice(2).trim()).filter(t=>t.length>0):[]}function AB(e){return e.replace(/^\n/,"").replace(/\n$/,"")}function jB(e){const t={},n=/([a-z-]+)="([^"]*)"/gi;for(let r=n.exec(e);r!==null;r=n.exec(e))t[r[1]]=LB(r[2]??"");return t}function LB(e){return e.replace(/"/g,'"').replace(/</g,"<").replace(/>/g,">").replace(/&/g,"&")}const DB=new Set(["localhost","127.0.0.1","0.0.0.0","::1"]);let _i=null;function OB(){if(_i!==null)return _i;if(typeof window>"u")return _i=!1,!1;if(DB.has(window.location.hostname)||window.location.protocol==="file:")return _i=!0,!0;if(new URLSearchParams(window.location.search).get("debug")==="1"){_i=!0;try{sessionStorage.setItem("debug","1")}catch{}}else try{_i=sessionStorage.getItem("debug")==="1"}catch{_i=!1}return _i}function Me(e,...t){OB()&&console.log(`[${e}][${new Date().toISOString()}]`,...t)}function pd(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 BB=e=>{const t=[1e3,2e3,4e3,8e3,16e3,3e4];return t[Math.min(e,t.length-1)]},zB=new Set(["auth:ok","pong","error"]),Iw=new Set(RT.filter(e=>!zB.has(e)));let $B=0;const Pw=()=>`r${++$B}`;function FB(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??BB;let u=null,d=!1,f=0,p=null,m=null,v=null,b=null,x=!1,_="disconnected";const y=new Map,S=new Map;let C=null;const k=(B,E)=>{var H;B==="ready"&&(C=E),(H=S.get(B))==null||H.forEach(q=>{try{q(E)}catch{}})},N=B=>{_!==B&&(_=B,k("status",B))},T=(B,E)=>{const H=S.get(B)??new Set;if(H.add(E),S.set(B,H),B==="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)},I=()=>{v&&clearTimeout(v),v=setTimeout(()=>{try{u==null||u.close(4e3,"pong watchdog")}catch{}},a)},M=()=>{m&&clearInterval(m),m=setInterval(()=>{(u==null?void 0:u.readyState)===1&&u.send(JSON.stringify({type:"ping",requestId:Pw()}))},o),I()},L=B=>{for(const[,E]of y)clearTimeout(E.timer),E.reject(new Error(B));y.clear()},R=[],A=()=>{if(R.length===0)return;const B=R.splice(0);for(const E of B)(u==null?void 0:u.readyState)===1&&!x?E.doSend():(clearTimeout(E.timer),E.reject(new Error("NOT_CONNECTED")))},D=B=>{if(R.length===0)return;const E=R.splice(0);for(const H of E)clearTimeout(H.timer),H.reject(new Error(B))},$=()=>{if(d)return;const B=c(f);B<0||(k("daemon:reconnecting",{attempt:f+1,nextDelayMs:B,scheduledAt:Date.now()}),p&&clearTimeout(p),p=setTimeout(()=>{f+=1,O()},B))},F=B=>{I();const E=String(B.type??"");if(E==="auth:ok"){Me("daemon-client","auth:ok received → connected",{url:t}),b&&(clearTimeout(b),b=null),x=!1,f=0,N("connected"),k("daemon:connected",{url:t}),M(),A();return}if(E==="pong")return;if(E==="ready"){const q=Number(B.protocolVersion??-1);q!==Nw&&k("daemon:version-mismatch",{daemonProtocol:q,supportedProtocol:Nw}),k("ready",B);return}const H=B.requestId;if(typeof H=="string"&&y.has(H)){const q=y.get(H);if(y.delete(H),clearTimeout(q.timer),E==="error"){const j=String(B.code??"ERR"),ne=String(B.message??"unknown");q.reject(new Error(`${j}: ${ne}`))}else Iw.has(E)&&k(E,B),q.resolve(B);return}Iw.has(E)&&k(E,B)},O=()=>{p&&(clearTimeout(p),p=null),Me("daemon-client","connect →",{url:t,token:pd(n),attempt:f}),N("connecting");let B;try{B=new WebSocket(t)}catch(E){N("disconnected"),k("daemon:disconnected",{reason:(E==null?void 0:E.message)??"ws constructor failed"}),$();return}u=B,x=!!n,B.onopen=()=>{if(B!==u){Me("daemon-client","onopen → stale (replaced before opened), ignore");return}if(n){Me("daemon-client","onopen → send auth frame",{token:pd(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),B.send(JSON.stringify(E)),b=setTimeout(()=>{try{B.close(4001,"auth handshake timeout")}catch{}},l)}else Me("daemon-client","onopen → no token, treat as connected (daemon authMode=none)"),f=0,N("connected"),k("daemon:connected",{url:t}),M(),A()},B.onclose=E=>{if(B!==u){Me("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(Me("daemon-client","onclose →",{code:E.code,reason:H,awaitingAuth:x,manualStop:d}),z(),L(`connection closed: ${H}`),u=null,E.code===4401?N("revoked"):N("disconnected"),k("daemon:disconnected",{reason:H}),E.code===1008||E.code===4401){D(`connection closed: ${H}`);return}d?D(`connection closed: ${H}`):$()},B.onerror=()=>{},B.onmessage=E=>{if(B!==u)return;let H;try{H=JSON.parse(String(E.data))}catch{return}F(H)}};return{start(){d=!1,f=0,O()},stop(){d=!0,p&&(clearTimeout(p),p=null),z();try{u==null||u.close(1e3,"shutdown")}catch{}u=null,L("shutdown"),D("shutdown"),N("disconnected")},switchProfile(B){Me("daemon-client","switchProfile →",{url:B.url,token:pd(B.authToken)},"prev:",{url:t,token:pd(n)}),t=B.url,n=B.authToken,B.selfIdentity!==void 0&&(r=B.selfIdentity),f=0,d=!0,p&&(clearTimeout(p),p=null),z(),L("switch profile"),D("switch profile");try{u==null||u.close(1e3,"switch profile")}catch{}u=null,d=!1,O()},request(B,E){return new Promise((H,q)=>{const j=Pw(),ne=setTimeout(()=>{y.delete(j);const G=R.findIndex(ve=>ve.timer===ne);G>=0&&R.splice(G,1),q(new Error(`request timeout: ${B}`))},s),re=()=>{y.set(j,{resolve:G=>H(G),reject:q,timer:ne}),u.send(JSON.stringify({...E,type:B,requestId:j}))};(u==null?void 0:u.readyState)===1&&!x?re():d||u==null&&p==null?(clearTimeout(ne),q(new Error("NOT_CONNECTED"))):R.push({doSend:re,reject:q,timer:ne})})},on:T,get isOpen(){return(u==null?void 0:u.readyState)===1&&!x},get url(){return t},getStatus(){return _}}}function HB(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 UB(e){return e?{id:e.id,mode:e.mode,url:e.url,token:HB(e.token),name:e.name}:null}function md(e){return e?Array.isArray(e)?e.map(UB):{_notArray:typeof e,_value:e}:null}function Rw(e){return e==null?null:typeof e=="object"&&"value"in e?e.value:e}const WB="ws://127.0.0.1:18790",Mw="daemon:profiles",Aw="daemon:active-profile-id";function VB(){return Math.random().toString(36).slice(2,10)}function qB(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 KB(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 zT(e){let t={profiles:[],activeId:null},n=!1,r=null;const i=new Set,s=()=>{for(const l of i)l(t)},o=async()=>{Me("profile-store","persist →",md(t.profiles),"active:",t.activeId),await e.kv.set(Mw,t.profiles),await e.kv.set(Aw,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(Mw);c=Rw(d)}catch{c=null}let u=null;try{const d=await e.kv.get(Aw);u=Rw(d)??null}catch{u=null}if(Me("profile-store","ensureLoaded read kv →","profiles:",md(c),"activeId:",u),Array.isArray(c)&&c.length>0){const d=c.filter(KB),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,Me("profile-store","ensureLoaded → use kv profiles",md(d),"active:",f);return}t={profiles:[{id:"default",name:"本机",mode:"localhost",url:WB}],activeId:"default"},Me("profile-store","ensureLoaded → fallback synthesized default (NO token)",md(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 x=qB(c);c=x.url,!u&&x.token&&(u=x.token)}const d=l.id?t.profiles.find(x=>x.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??VB(),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(x=>x.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 jw="clawd.client-instance-id";let GB={name:"clawd-web",version:"unknown"};function YB(){let e=null;try{e=localStorage.getItem(jw),e||(e=crypto.randomUUID(),localStorage.setItem(jw,e))}catch{e=e??crypto.randomUUID()}return{...GB,instanceId:e}}function Lw(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 $T=g.createContext(null);function XB({host:e,children:t}){const[n,r]=g.useState(null),i=g.useMemo(()=>async()=>{const s=zT(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 Me("daemon-context","bootstrap → createDaemonClient",{id:a.id,url:a.url,token:Lw(a.token)}),{client:FB({url:a.url,authToken:a.token,clientInfo:YB()}),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){Me("daemon-context","subscribe → no active profile, skip switchProfile");return}Me("daemon-context","subscribe → switchProfile",{id:c.id,url:c.url,token:Lw(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($T.Provider,{value:n,children:t}):null}function pi(){const e=g.useContext($T);if(!e)throw new Error("useDaemonClient must be used inside <DaemonProvider>");return e.client}function ZB(){const e=pi(),[t,n]=g.useState(void 0);return g.useEffect(()=>e.on("ready",i=>{const s=i.mode,o=s==="tui"?"tui":"sdk";Me("daemon-context","useDaemonMode ready.mode =",{rawMode:s,resolved:o}),n(o)}),[e]),t}function QB(){const e=pi(),[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 FT=g.createContext(null);function JB({cache:e,children:t}){return g.createElement(FT.Provider,{value:e},t)}function jo(){const e=g.useContext(FT);if(!e)throw new Error("useCache must be used inside <CacheProvider>");return e}function ci(e){const t=jo(),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 HT={actionsLevel:"none",httpBaseUrl:null,httpToken:null},UT=g.createContext(HT);function ap(){return g.useContext(UT)}function ez(e){return e!=null&&e.httpBaseUrl?{actionsLevel:e.tokenRole==="owner"?"owner":"none",httpBaseUrl:e.httpBaseUrl,httpToken:e.httpToken??null}:HT}function tz(){const e=ci("daemon-info");return g.useMemo(()=>ez(e),[e])}function nz({children:e}){const t=tz();return Qe.createElement(UT.Provider,{value:t},e)}function rz(e,t,n){if(!e.httpBaseUrl)return null;const r=encodeURIComponent(n);return`${e.httpBaseUrl}/session/${encodeURIComponent(t.sessionId)}/files?path=${r}`}function iz(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 sz(){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 oz(e){return{request:(t,n)=>e.request(t,n),onFrame(t){const n=[];for(const r of RT)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 WT(e){const t=(e??"claude")==="claude";return{rewind:t,subagents:t,tui:t,observe:t,fileSharing:t,fork:t}}const az=e=>({tool:e,models:[{id:"",label:"未指定",contextWindowSize:2e5,default:!0}],permissionModes:[{id:"",label:"未指定"}],configSchema:[],features:WT(e)});function lz(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,()=>az(r))}},o=e.onConnect(()=>{s()});return s(),()=>{i=!0,o()}}}}function cz(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 Xc={sessionId:null,events:[],lastSeq:-1,pendingPermissions:[],status:"idle",pendingQuestions:{}};function Mm(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 VT(e,t,n){const r=n===void 0?e.sessionId:n;switch(t.type){case"session:change":return{...Xc,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=Mm(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)=>Mm(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)=>Mm(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{...Xc,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 uz="session/";function dz(e){return{sid:e.slice(uz.length)}}const hz=new Set(MT);function qT(e){return hz.has(e)}function Dw(e){return qT(e)?e:"idle"}function fz(e,t){return{start(n){const{sid:r}=dz(n);let i=!1,s=-1;const o=f=>{t(n,p=>VT(p??Xc,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 x=m.bufferStartSeq??0,_=b<p||x>p+1;o({type:_?"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:Dw(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;Me("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(!qT(m.status)){Me("session-events","push session:status drop",{sid:r,status:m.status});return}Me("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;Me("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:Dw(v.status)}))})}),d=e.onConnect(()=>{c()});return e.isConnected&&c(),()=>{i=!0,u(),d(),e.request("session:unsubscribe",{sessionId:r}).catch(()=>{})}}}}const pz=new Set(["tunnel:ready","tunnel:exited","tunnel:unavailable"]);function mz(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=>{pz.has(a)&&i()});return i(),()=>{r=!0,s(),o()}}}}function gz(){return{start(){return()=>{}}}}function vz(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 xz(e){const t=oz(e),n=sz();let r=null;const i=(o,a)=>{r==null||r.setData(o,a)};n.register(/^capabilities\//,lz(t,i)),n.register(/^sessions$/,cz(t,i)),n.register(/^session\//,fz(t,i)),n.register(/^personas$/,vz(t,i)),n.register(/^persona-detail\//,gz()),n.register(/^daemon-info$/,mz(t,i));const s=iz({onFirstObserver:o=>{o&&n.activate(o)},onLastObserver:o=>{o&&n.deactivate(o)}});return r=s,{cache:s,channel:t}}class q_{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")}channelList(){return this.client.request("channel:list")}channelCreate(t){return this.client.request("channel:create",t)}channelUpdate(t){return this.client.request("channel:update",t)}channelDelete(t){return this.client.request("channel:delete",t)}topicList(t){return this.client.request("topic:list",t)}topicGet(t){return this.client.request("topic:get",t)}topicCreate(t){return this.client.request("topic:create",t)}topicClose(t){return this.client.request("topic:close",t)}topicRename(t){return this.client.request("topic:rename",t)}topicDelete(t){return this.client.request("topic:delete",t)}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 _z(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 yz(e){const t=jo(),n=ci(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 pl(){const e=pi();return g.useMemo(()=>new q_(e),[e])}function KT(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 K_(){const e=jo(),t=pl(),n=ci("personas")??[],r=g.useMemo(()=>n.map(s=>KT(s)),[n]),i=g.useCallback(async()=>{const s=await t.personaList();e.setData("personas",()=>s.personas??[])},[t,e]);return{personas:r,raw:n,loaded:ci("personas")!==void 0,refresh:i}}function GT(e){const{raw:t}=K_(),n=jo(),r=pl(),i=e?t.find(a=>a.personaId===e)??null:null,s=i?KT(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 bz(e){const t=pl(),n=jo(),r=e?`persona-detail/${e}`:"",i=ci(r),s=g.useCallback(async()=>{const o={personality:"",skills:[],plugins:[],sandboxSettings:null};if(!e)return o;let a=null;try{a=await t.personaGet(e)}catch(c){Me("personas","personaGet failed → empty detail",{personaId:e,err:c}),a=null}const l=a?{personality:a.personality??"",skills:a.skills??[],plugins:a.plugins??[],sandboxSettings:a.sandboxSettings??null}:o;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 YT(){const e=jo(),t=pl();return g.useCallback(async()=>{const n=await t.personaList();e.setData("personas",()=>n.personas??[])},[e,t])}function wz(){const e=pl(),t=YT();return g.useCallback(async(n,r)=>{const i=await e.personaUpdate(n,r);return await t(),i},[e,t])}function Sz(){const e=pl(),t=YT();return g.useCallback(async n=>{await e.personaDelete(n),await t()},[e,t])}const Ow="clawd:sidebar:tree-collapsed";function kz(e){return e&&typeof e=="object"&&"value"in e?e.value:e}function Cz(e){const t=kz(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 Ez(){const e=T_(),[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(Ow);if(l)return;n(Cz(c))}catch{}})(),()=>{l=!0}},[e]);const i=g.useCallback(l=>{e.kv.set(Ow,[...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 G_=g.createContext(null);function Nz(){const e=g.useContext(G_);if(!e)throw new Error("SessionTreeCollapsedContext.Provider missing — wrap SessionTreeNode tree with <SessionTreeCollapsedContext.Provider value={useSessionTreeCollapsed()}>");return e}/**
|
|
97
97
|
* @license lucide-react v0.577.0 - ISC
|
|
98
98
|
*
|
|
99
99
|
* This source code is licensed under the ISC license.
|
|
@@ -503,7 +503,7 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
|
|
|
503
503
|
`)},gS=function(){var e=parseInt(document.body.getAttribute(Ia)||"0",10);return isFinite(e)?e:0},G7=function(){g.useEffect(function(){return document.body.setAttribute(Ia,(gS()+1).toString()),function(){var e=gS()-1;e<=0?document.body.removeAttribute(Ia):document.body.setAttribute(Ia,e.toString())}},[])},Y7=function(e){var t=e.noRelative,n=e.noImportant,r=e.gapMode,i=r===void 0?"margin":r;G7();var s=g.useMemo(function(){return V7(i)},[i]);return g.createElement(q7,{styles:K7(s,!t,i,n?"":"!important")})},C0=!1;if(typeof window<"u")try{var wd=Object.defineProperty({},"passive",{get:function(){return C0=!0,!0}});window.addEventListener("test",wd,wd),window.removeEventListener("test",wd,wd)}catch{C0=!1}var Xo=C0?{passive:!1}:!1,X7=function(e){return e.tagName==="TEXTAREA"},pP=function(e,t){if(!(e instanceof Element))return!1;var n=window.getComputedStyle(e);return n[t]!=="hidden"&&!(n.overflowY===n.overflowX&&!X7(e)&&n[t]==="visible")},Z7=function(e){return pP(e,"overflowY")},Q7=function(e){return pP(e,"overflowX")},vS=function(e,t){var n=t.ownerDocument,r=t;do{typeof ShadowRoot<"u"&&r instanceof ShadowRoot&&(r=r.host);var i=mP(e,r);if(i){var s=gP(e,r),o=s[1],a=s[2];if(o>a)return!0}r=r.parentNode}while(r&&r!==n.body);return!1},J7=function(e){var t=e.scrollTop,n=e.scrollHeight,r=e.clientHeight;return[t,n,r]},eH=function(e){var t=e.scrollLeft,n=e.scrollWidth,r=e.clientWidth;return[t,n,r]},mP=function(e,t){return e==="v"?Z7(t):Q7(t)},gP=function(e,t){return e==="v"?J7(t):eH(t)},tH=function(e,t){return e==="h"&&t==="rtl"?-1:1},nH=function(e,t,n,r,i){var s=tH(e,window.getComputedStyle(t).direction),o=s*r,a=n.target,l=t.contains(a),c=!1,u=o>0,d=0,f=0;do{if(!a)break;var p=gP(e,a),m=p[0],v=p[1],b=p[2],x=v-b-s*m;(m||x)&&mP(e,a)&&(d+=x,f+=m);var _=a.parentNode;a=_&&_.nodeType===Node.DOCUMENT_FRAGMENT_NODE?_.host:_}while(!l&&a!==document.body||l&&(t.contains(a)||t===a));return(u&&Math.abs(d)<1||!u&&Math.abs(f)<1)&&(c=!0),c},Sd=function(e){return"changedTouches"in e?[e.changedTouches[0].clientX,e.changedTouches[0].clientY]:[0,0]},xS=function(e){return[e.deltaX,e.deltaY]},_S=function(e){return e&&"current"in e?e.current:e},rH=function(e,t){return e[0]===t[0]&&e[1]===t[1]},iH=function(e){return`
|
|
504
504
|
.block-interactivity-`.concat(e,` {pointer-events: none;}
|
|
505
505
|
.allow-interactivity-`).concat(e,` {pointer-events: all;}
|
|
506
|
-
`)},sH=0,Zo=[];function oH(e){var t=g.useRef([]),n=g.useRef([0,0]),r=g.useRef(),i=g.useState(sH++)[0],s=g.useState(fP)[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=N7([e.lockRef.current],(e.shards||[]).map(_S),!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 x=Sd(v),_=n.current,y="deltaX"in v?v.deltaX:_[0]-x[0],S="deltaY"in v?v.deltaY:_[1]-x[1],C,k=v.target,N=Math.abs(y)>Math.abs(S)?"h":"v";if("touches"in v&&N==="h"&&k.type==="range")return!1;var T=window.getSelection(),z=T&&T.anchorNode,I=z?z===k||z.contains(k):!1;if(I)return!1;var M=vS(N,k);if(!M)return!0;if(M?C=N:(C=N==="v"?"h":"v",M=vS(N,k)),!M)return!1;if(!r.current&&"changedTouches"in v&&(y||S)&&(r.current=C),!C)return!0;var L=r.current||C;return nH(L,b,v,L==="h"?y:S)},[]),l=g.useCallback(function(v){var b=v;if(!(!Zo.length||Zo[Zo.length-1]!==s)){var x="deltaY"in b?xS(b):Sd(b),_=t.current.filter(function(C){return C.name===b.type&&(C.target===b.target||b.target===C.shadowParent)&&rH(C.delta,x)})[0];if(_&&_.should){b.cancelable&&b.preventDefault();return}if(!_){var y=(o.current.shards||[]).map(_S).filter(Boolean).filter(function(C){return C.contains(b.target)}),S=y.length>0?a(b,y[0]):!o.current.noIsolation;S&&b.cancelable&&b.preventDefault()}}},[]),c=g.useCallback(function(v,b,x,_){var y={name:v,delta:b,target:x,should:_,shadowParent:aH(x)};t.current.push(y),setTimeout(function(){t.current=t.current.filter(function(S){return S!==y})},1)},[]),u=g.useCallback(function(v){n.current=Sd(v),r.current=void 0},[]),d=g.useCallback(function(v){c(v.type,xS(v),v.target,a(v,e.lockRef.current))},[]),f=g.useCallback(function(v){c(v.type,Sd(v),v.target,a(v,e.lockRef.current))},[]);g.useEffect(function(){return Zo.push(s),e.setCallbacks({onScrollCapture:d,onWheelCapture:d,onTouchMoveCapture:f}),document.addEventListener("wheel",l,Xo),document.addEventListener("touchmove",l,Xo),document.addEventListener("touchstart",u,Xo),function(){Zo=Zo.filter(function(v){return v!==s}),document.removeEventListener("wheel",l,Xo),document.removeEventListener("touchmove",l,Xo),document.removeEventListener("touchstart",u,Xo)}},[]);var p=e.removeScrollBar,m=e.inert;return g.createElement(g.Fragment,null,m?g.createElement(s,{styles:iH(i)}):null,p?g.createElement(Y7,{noRelative:e.noRelative,gapMode:e.gapMode}):null)}function aH(e){for(var t=null;e!==null;)e instanceof ShadowRoot&&(t=e.host,e=e.host),e=e.parentNode;return t}const lH=D7(hP,oH);var fy=g.forwardRef(function(e,t){return g.createElement(gp,Qr({},e,{ref:t,sideCar:lH}))});fy.classNames=gp.classNames;var E0=["Enter"," "],cH=["ArrowDown","PageUp","Home"],vP=["ArrowUp","PageDown","End"],uH=[...cH,...vP],dH={ltr:[...E0,"ArrowRight"],rtl:[...E0,"ArrowLeft"]},hH={ltr:["ArrowLeft"],rtl:["ArrowRight"]},Nu="Menu",[tu,fH,pH]=EI(Nu),[Oo,xP]=Do(Nu,[pH,mp,rP]),Tu=mp(),_P=rP(),[yP,Fs]=Oo(Nu),[mH,Iu]=Oo(Nu),bP=e=>{const{__scopeMenu:t,open:n=!1,children:r,dir:i,onOpenChange:s,modal:o=!0}=e,a=Tu(t),[l,c]=g.useState(null),u=g.useRef(!1),d=di(s),f=NI(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(dy,{...a,children:h.jsx(yP,{scope:t,open:n,onOpenChange:d,content:l,onContentChange:c,children:h.jsx(mH,{scope:t,onClose:g.useCallback(()=>d(!1),[d]),isUsingKeyboardRef:u,dir:f,modal:o,children:r})})})};bP.displayName=Nu;var gH="MenuAnchor",py=g.forwardRef((e,t)=>{const{__scopeMenu:n,...r}=e,i=Tu(n);return h.jsx(JI,{...i,...r,ref:t})});py.displayName=gH;var my="MenuPortal",[vH,wP]=Oo(my,{forceMount:void 0}),SP=e=>{const{__scopeMenu:t,forceMount:n,children:r,container:i}=e,s=Fs(my,t);return h.jsx(vH,{scope:t,forceMount:n,children:h.jsx(qi,{present:n||s.open,children:h.jsx(hy,{asChild:!0,container:i,children:r})})})};SP.displayName=my;var xr="MenuContent",[xH,gy]=Oo(xr),kP=g.forwardRef((e,t)=>{const n=wP(xr,e.__scopeMenu),{forceMount:r=n.forceMount,...i}=e,s=Fs(xr,e.__scopeMenu),o=Iu(xr,e.__scopeMenu);return h.jsx(tu.Provider,{scope:e.__scopeMenu,children:h.jsx(qi,{present:r||s.open,children:h.jsx(tu.Slot,{scope:e.__scopeMenu,children:o.modal?h.jsx(_H,{...i,ref:t}):h.jsx(yH,{...i,ref:t})})})})}),_H=g.forwardRef((e,t)=>{const n=Fs(xr,e.__scopeMenu),r=g.useRef(null),i=Gt(t,r);return g.useEffect(()=>{const s=r.current;if(s)return cP(s)},[]),h.jsx(vy,{...e,ref:i,trapFocus:n.open,disableOutsidePointerEvents:n.open,disableOutsideScroll:!0,onFocusOutside:Pe(e.onFocusOutside,s=>s.preventDefault(),{checkForDefaultPrevented:!1}),onDismiss:()=>n.onOpenChange(!1)})}),yH=g.forwardRef((e,t)=>{const n=Fs(xr,e.__scopeMenu);return h.jsx(vy,{...e,ref:t,trapFocus:!1,disableOutsidePointerEvents:!1,disableOutsideScroll:!1,onDismiss:()=>n.onOpenChange(!1)})}),bH=Jc("MenuContent.ScrollLock"),vy=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=Fs(xr,n),x=Iu(xr,n),_=Tu(n),y=_P(n),S=fH(n),[C,k]=g.useState(null),N=g.useRef(null),T=Gt(t,N,b.onContentChange),z=g.useRef(0),I=g.useRef(""),M=g.useRef(0),L=g.useRef(null),R=g.useRef("right"),A=g.useRef(0),D=m?fy:g.Fragment,$=m?{as:bH,allowPinchZoom:!0}:void 0,F=B=>{var ve,ze;const E=I.current+B,H=S().filter(he=>!he.disabled),q=document.activeElement,j=(ve=H.find(he=>he.ref.current===q))==null?void 0:ve.textValue,ne=H.map(he=>he.textValue),re=AH(ne,E,j),G=(ze=H.find(he=>he.textValue===re))==null?void 0:ze.ref.current;(function he(Ie){I.current=Ie,window.clearTimeout(z.current),Ie!==""&&(z.current=window.setTimeout(()=>he(""),1e3))})(E),G&&setTimeout(()=>G.focus())};g.useEffect(()=>()=>window.clearTimeout(z.current),[]),PI();const O=g.useCallback(B=>{var H,q;return R.current===((H=L.current)==null?void 0:H.side)&&LH(B,(q=L.current)==null?void 0:q.area)},[]);return h.jsx(xH,{scope:n,searchRef:I,onItemEnter:g.useCallback(B=>{O(B)&&B.preventDefault()},[O]),onItemLeave:g.useCallback(B=>{var E;O(B)||((E=N.current)==null||E.focus(),k(null))},[O]),onTriggerLeave:g.useCallback(B=>{O(B)&&B.preventDefault()},[O]),pointerGraceTimerRef:M,onPointerGraceIntentChange:g.useCallback(B=>{L.current=B},[]),children:h.jsx(D,{...$,children:h.jsx(ny,{asChild:!0,trapped:i,onMountAutoFocus:Pe(s,B=>{var E;B.preventDefault(),(E=N.current)==null||E.focus({preventScroll:!0})}),onUnmountAutoFocus:o,children:h.jsx(up,{asChild:!0,disableOutsidePointerEvents:a,onEscapeKeyDown:c,onPointerDownOutside:u,onFocusOutside:d,onInteractOutside:f,onDismiss:p,children:h.jsx(w7,{asChild:!0,...y,dir:x.dir,orientation:"vertical",loop:r,currentTabStopId:C,onCurrentTabStopIdChange:k,onEntryFocus:Pe(l,B=>{x.isUsingKeyboardRef.current||B.preventDefault()}),preventScrollOnEntryFocus:!0,children:h.jsx(eP,{role:"menu","aria-orientation":"vertical","data-state":FP(b.open),"data-radix-menu-content":"",dir:x.dir,..._,...v,ref:T,style:{outline:"none",...v.style},onKeyDown:Pe(v.onKeyDown,B=>{const H=B.target.closest("[data-radix-menu-content]")===B.currentTarget,q=B.ctrlKey||B.altKey||B.metaKey,j=B.key.length===1;H&&(B.key==="Tab"&&B.preventDefault(),!q&&j&&F(B.key));const ne=N.current;if(B.target!==ne||!uH.includes(B.key))return;B.preventDefault();const G=S().filter(ve=>!ve.disabled).map(ve=>ve.ref.current);vP.includes(B.key)&&G.reverse(),RH(G)}),onBlur:Pe(e.onBlur,B=>{B.currentTarget.contains(B.target)||(window.clearTimeout(z.current),I.current="")}),onPointerMove:Pe(e.onPointerMove,nu(B=>{const E=B.target,H=A.current!==B.clientX;if(B.currentTarget.contains(E)&&H){const q=B.clientX>A.current?"right":"left";R.current=q,A.current=B.clientX}}))})})})})})})});kP.displayName=xr;var wH="MenuGroup",xy=g.forwardRef((e,t)=>{const{__scopeMenu:n,...r}=e;return h.jsx(Tt.div,{role:"group",...r,ref:t})});xy.displayName=wH;var SH="MenuLabel",CP=g.forwardRef((e,t)=>{const{__scopeMenu:n,...r}=e;return h.jsx(Tt.div,{...r,ref:t})});CP.displayName=SH;var af="MenuItem",yS="menu.itemSelect",vp=g.forwardRef((e,t)=>{const{disabled:n=!1,onSelect:r,...i}=e,s=g.useRef(null),o=Iu(af,e.__scopeMenu),a=gy(af,e.__scopeMenu),l=Gt(t,s),c=g.useRef(!1),u=()=>{const d=s.current;if(!n&&d){const f=new CustomEvent(yS,{bubbles:!0,cancelable:!0});d.addEventListener(yS,p=>r==null?void 0:r(p),{once:!0}),CI(d,f),f.defaultPrevented?c.current=!1:o.onClose()}};return h.jsx(EP,{...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===" "||E0.includes(d.key)&&(d.currentTarget.click(),d.preventDefault())})})});vp.displayName=af;var EP=g.forwardRef((e,t)=>{const{__scopeMenu:n,disabled:r=!1,textValue:i,...s}=e,o=gy(af,n),a=_P(n),l=g.useRef(null),c=Gt(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(tu.ItemSlot,{scope:n,disabled:r,textValue:i??f,children:h.jsx(S7,{asChild:!0,...a,focusable:!r,children:h.jsx(Tt.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,nu(m=>{r?o.onItemLeave(m):(o.onItemEnter(m),m.defaultPrevented||m.currentTarget.focus({preventScroll:!0}))})),onPointerLeave:Pe(e.onPointerLeave,nu(m=>o.onItemLeave(m))),onFocus:Pe(e.onFocus,()=>d(!0)),onBlur:Pe(e.onBlur,()=>d(!1))})})})}),kH="MenuCheckboxItem",NP=g.forwardRef((e,t)=>{const{checked:n=!1,onCheckedChange:r,...i}=e;return h.jsx(MP,{scope:e.__scopeMenu,checked:n,children:h.jsx(vp,{role:"menuitemcheckbox","aria-checked":lf(n)?"mixed":n,...i,ref:t,"data-state":by(n),onSelect:Pe(i.onSelect,()=>r==null?void 0:r(lf(n)?!0:!n),{checkForDefaultPrevented:!1})})})});NP.displayName=kH;var TP="MenuRadioGroup",[CH,EH]=Oo(TP,{value:void 0,onValueChange:()=>{}}),IP=g.forwardRef((e,t)=>{const{value:n,onValueChange:r,...i}=e,s=di(r);return h.jsx(CH,{scope:e.__scopeMenu,value:n,onValueChange:s,children:h.jsx(xy,{...i,ref:t})})});IP.displayName=TP;var PP="MenuRadioItem",RP=g.forwardRef((e,t)=>{const{value:n,...r}=e,i=EH(PP,e.__scopeMenu),s=n===i.value;return h.jsx(MP,{scope:e.__scopeMenu,checked:s,children:h.jsx(vp,{role:"menuitemradio","aria-checked":s,...r,ref:t,"data-state":by(s),onSelect:Pe(r.onSelect,()=>{var o;return(o=i.onValueChange)==null?void 0:o.call(i,n)},{checkForDefaultPrevented:!1})})})});RP.displayName=PP;var _y="MenuItemIndicator",[MP,NH]=Oo(_y,{checked:!1}),AP=g.forwardRef((e,t)=>{const{__scopeMenu:n,forceMount:r,...i}=e,s=NH(_y,n);return h.jsx(qi,{present:r||lf(s.checked)||s.checked===!0,children:h.jsx(Tt.span,{...i,ref:t,"data-state":by(s.checked)})})});AP.displayName=_y;var TH="MenuSeparator",jP=g.forwardRef((e,t)=>{const{__scopeMenu:n,...r}=e;return h.jsx(Tt.div,{role:"separator","aria-orientation":"horizontal",...r,ref:t})});jP.displayName=TH;var IH="MenuArrow",LP=g.forwardRef((e,t)=>{const{__scopeMenu:n,...r}=e,i=Tu(n);return h.jsx(tP,{...i,...r,ref:t})});LP.displayName=IH;var yy="MenuSub",[PH,DP]=Oo(yy),OP=e=>{const{__scopeMenu:t,children:n,open:r=!1,onOpenChange:i}=e,s=Fs(yy,t),o=Tu(t),[a,l]=g.useState(null),[c,u]=g.useState(null),d=di(i);return g.useEffect(()=>(s.open===!1&&d(!1),()=>d(!1)),[s.open,d]),h.jsx(dy,{...o,children:h.jsx(yP,{scope:t,open:r,onOpenChange:d,content:c,onContentChange:u,children:h.jsx(PH,{scope:t,contentId:Ai(),triggerId:Ai(),trigger:a,onTriggerChange:l,children:n})})})};OP.displayName=yy;var Jl="MenuSubTrigger",BP=g.forwardRef((e,t)=>{const n=Fs(Jl,e.__scopeMenu),r=Iu(Jl,e.__scopeMenu),i=DP(Jl,e.__scopeMenu),s=gy(Jl,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(py,{asChild:!0,...c,children:h.jsx(EP,{id:i.triggerId,"aria-haspopup":"menu","aria-expanded":n.open,"aria-controls":i.contentId,"data-state":FP(n.open),...e,ref:Su(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,nu(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,nu(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",x=b?-5:5,_=f[b?"left":"right"],y=f[b?"right":"left"];s.onPointerGraceIntentChange({area:[{x:d.clientX+x,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===" "||dH[r.dir].includes(d.key)&&(n.onOpenChange(!0),(p=n.content)==null||p.focus(),d.preventDefault())})})})});BP.displayName=Jl;var zP="MenuSubContent",$P=g.forwardRef((e,t)=>{const n=wP(xr,e.__scopeMenu),{forceMount:r=n.forceMount,...i}=e,s=Fs(xr,e.__scopeMenu),o=Iu(xr,e.__scopeMenu),a=DP(zP,e.__scopeMenu),l=g.useRef(null),c=Gt(t,l);return h.jsx(tu.Provider,{scope:e.__scopeMenu,children:h.jsx(qi,{present:r||s.open,children:h.jsx(tu.Slot,{scope:e.__scopeMenu,children:h.jsx(vy,{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=hH[o.dir].includes(u.key);d&&f&&(s.onOpenChange(!1),(p=a.trigger)==null||p.focus(),u.preventDefault())})})})})})});$P.displayName=zP;function FP(e){return e?"open":"closed"}function lf(e){return e==="indeterminate"}function by(e){return lf(e)?"indeterminate":e?"checked":"unchecked"}function RH(e){const t=document.activeElement;for(const n of e)if(n===t||(n.focus(),document.activeElement!==t))return}function MH(e,t){return e.map((n,r)=>e[(t+r)%e.length])}function AH(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=MH(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 jH(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 LH(e,t){if(!t)return!1;const n={x:e.clientX,y:e.clientY};return jH(n,t)}function nu(e){return t=>t.pointerType==="mouse"?e(t):void 0}var DH=bP,OH=py,BH=SP,zH=kP,$H=xy,FH=CP,HH=vp,UH=NP,WH=IP,VH=RP,qH=AP,KH=jP,GH=LP,YH=OP,XH=BP,ZH=$P,xp="DropdownMenu",[QH]=Do(xp,[xP]),Sn=xP(),[JH,HP]=QH(xp),UP=e=>{const{__scopeDropdownMenu:t,children:n,dir:r,open:i,defaultOpen:s,onOpenChange:o,modal:a=!0}=e,l=Sn(t),c=g.useRef(null),[u,d]=ku({prop:i,defaultProp:s??!1,onChange:o,caller:xp});return h.jsx(JH,{scope:t,triggerId:Ai(),triggerRef:c,contentId:Ai(),open:u,onOpenChange:d,onOpenToggle:g.useCallback(()=>d(f=>!f),[d]),modal:a,children:h.jsx(DH,{...l,open:u,onOpenChange:d,dir:r,modal:a,children:n})})};UP.displayName=xp;var WP="DropdownMenuTrigger",VP=g.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,disabled:r=!1,...i}=e,s=HP(WP,n),o=Sn(n);return h.jsx(OH,{asChild:!0,...o,children:h.jsx(Tt.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:Su(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())})})})});VP.displayName=WP;var eU="DropdownMenuPortal",qP=e=>{const{__scopeDropdownMenu:t,...n}=e,r=Sn(t);return h.jsx(BH,{...r,...n})};qP.displayName=eU;var KP="DropdownMenuContent",GP=g.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,i=HP(KP,n),s=Sn(n),o=g.useRef(!1);return h.jsx(zH,{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)"}})});GP.displayName=KP;var tU="DropdownMenuGroup",nU=g.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,i=Sn(n);return h.jsx($H,{...i,...r,ref:t})});nU.displayName=tU;var rU="DropdownMenuLabel",YP=g.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,i=Sn(n);return h.jsx(FH,{...i,...r,ref:t})});YP.displayName=rU;var iU="DropdownMenuItem",XP=g.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,i=Sn(n);return h.jsx(HH,{...i,...r,ref:t})});XP.displayName=iU;var sU="DropdownMenuCheckboxItem",ZP=g.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,i=Sn(n);return h.jsx(UH,{...i,...r,ref:t})});ZP.displayName=sU;var oU="DropdownMenuRadioGroup",aU=g.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,i=Sn(n);return h.jsx(WH,{...i,...r,ref:t})});aU.displayName=oU;var lU="DropdownMenuRadioItem",cU=g.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,i=Sn(n);return h.jsx(VH,{...i,...r,ref:t})});cU.displayName=lU;var uU="DropdownMenuItemIndicator",QP=g.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,i=Sn(n);return h.jsx(qH,{...i,...r,ref:t})});QP.displayName=uU;var dU="DropdownMenuSeparator",JP=g.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,i=Sn(n);return h.jsx(KH,{...i,...r,ref:t})});JP.displayName=dU;var hU="DropdownMenuArrow",fU=g.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,i=Sn(n);return h.jsx(GH,{...i,...r,ref:t})});fU.displayName=hU;var pU=e=>{const{__scopeDropdownMenu:t,children:n,open:r,onOpenChange:i,defaultOpen:s}=e,o=Sn(t),[a,l]=ku({prop:r,defaultProp:s??!1,onChange:i,caller:"DropdownMenuSub"});return h.jsx(YH,{...o,open:a,onOpenChange:l,children:n})},mU="DropdownMenuSubTrigger",eR=g.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,i=Sn(n);return h.jsx(XH,{...i,...r,ref:t})});eR.displayName=mU;var gU="DropdownMenuSubContent",tR=g.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,i=Sn(n);return h.jsx(ZH,{...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)"}})});tR.displayName=gU;var vU=UP,xU=VP,nR=qP,rR=GP,iR=YP,sR=XP,oR=ZP,_U=QP,aR=JP,yU=pU,lR=eR,cR=tR;const wy=vU,Sy=xU,_p=g.forwardRef(({className:e,sideOffset:t=4,...n},r)=>h.jsx(nR,{children:h.jsx(rR,{ref:r,sideOffset:t,className:oe("z-50 min-w-[8rem] overflow-hidden rounded-md border border-border bg-elevated p-1","text-text-100 shadow-md",e),...n})}));_p.displayName=rR.displayName;const bU=yU,uR=g.forwardRef(({className:e,...t},n)=>h.jsx(lR,{ref:n,className:oe("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}));uR.displayName=lR.displayName;const dR=g.forwardRef(({className:e,...t},n)=>h.jsx(nR,{children:h.jsx(cR,{ref:n,className:oe("z-50 min-w-[6rem] overflow-hidden rounded-md border border-border bg-elevated p-1","text-text-100 shadow-md",e),...t})}));dR.displayName=cR.displayName;const Ci=g.forwardRef(({className:e,inset:t,...n},r)=>h.jsx(sR,{ref:r,className:oe("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}));Ci.displayName=sR.displayName;const wU=g.forwardRef(({className:e,children:t,checked:n,...r},i)=>h.jsxs(oR,{ref:i,checked:n,className:oe("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(_U,{children:h.jsx(ml,{className:"h-3.5 w-3.5"})})}),t]}));wU.displayName=oR.displayName;const hR=g.forwardRef(({className:e,...t},n)=>h.jsx(aR,{ref:n,className:oe("-mx-1 my-1 h-px bg-border",e),...t}));hR.displayName=aR.displayName;const SU=g.forwardRef(({className:e,...t},n)=>h.jsx(iR,{ref:n,className:oe("px-2 py-1.5 text-xs font-semibold text-text-400",e),...t}));SU.displayName=iR.displayName;function kU({tool:e,className:t}){const n=gF(e);return h.jsx("span",{"data-testid":n?`session-icon-${e}`:"session-icon-default","aria-label":n?ey(e):"未知引擎",className:oe("w-3.5 h-3.5 shrink-0 inline-flex items-center justify-center",wu(e),t),children:h.jsx(bu,{tool:e,className:"w-full h-full"})})}function CU({sessionId:e,hasUnread:t,running:n=!1,awaitingUser:r=!1,style:i}){return r?h.jsx(Fz,{"data-testid":`awaiting-dot-${e}`,style:i,className:"w-3 h-3 text-warning shrink-0 animate-pulse",strokeWidth:2.25,"aria-label":"awaiting user"}):t?h.jsx("span",{"data-testid":`unread-dot-${e}`,style:i,className:"w-2 h-2 rounded-full bg-error shrink-0","aria-label":"unread"}):n?h.jsx("span",{"data-testid":`running-dot-${e}`,style:i,className:"w-2 h-2 rounded-full bg-success shrink-0 animate-pulse","aria-label":"running"}):null}function fR(e){return e.compositionActive||!!e.nativeIsComposing||e.keyCode===229}function pR(e){return e.key==="Enter"&&!e.shiftKey&&!fR(e)}function Pu(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(pR({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 EU({open:e,initialLabel:t,placeholder:n,onSubmit:r,onCancel:i,title:s="Edit session",fieldLabel:o="Label",testId:a="session-edit-dialog",requireNonEmpty:l=!1}){const[c,u]=g.useState(t);g.useEffect(()=>{e&&u(t)},[e,t]);const d=c.trim(),f=l&&d==="",p=()=>{f||r({label:d})},m=Pu(p,i);return e?ol.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":`${a}-overlay`,children:h.jsxs("div",{"data-testid":a,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:v=>v.stopPropagation(),children:[h.jsx("div",{className:"text-[15px] font-semibold text-text-100",children:s}),h.jsxs("div",{children:[h.jsx("label",{className:"block text-[12px] font-semibold text-text-200 mb-1",children:o}),h.jsx("input",{autoFocus:!0,type:"text",value:c,onChange:v=>u(v.target.value),...m,placeholder:n,"data-testid":`${a}-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:p,disabled:f,"data-testid":`${a}-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 disabled:cursor-not-allowed disabled:opacity-40",children:"Save"})]})]})}),document.body):null}var NU=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"}),TU="VisuallyHidden",mR=g.forwardRef((e,t)=>h.jsx(Tt.span,{...e,ref:t,style:{...NU,...e.style}}));mR.displayName=TU;var IU=mR,[yp]=Do("Tooltip",[mp]),bp=mp(),gR="TooltipProvider",PU=700,N0="tooltip.open",[RU,ky]=yp(gR),vR=e=>{const{__scopeTooltip:t,delayDuration:n=PU,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(RU,{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})};vR.displayName=gR;var ru="Tooltip",[MU,wp]=yp(ru),xR=e=>{const{__scopeTooltip:t,children:n,open:r,defaultOpen:i,onOpenChange:s,disableHoverableContent:o,delayDuration:a}=e,l=ky(ru,e.__scopeTooltip),c=bp(t),[u,d]=g.useState(null),f=Ai(),p=g.useRef(0),m=o??l.disableHoverableContent,v=a??l.delayDuration,b=g.useRef(!1),[x,_]=ku({prop:r,defaultProp:i??!1,onChange:N=>{N?(l.onOpen(),document.dispatchEvent(new CustomEvent(N0))):l.onClose(),s==null||s(N)},caller:ru}),y=g.useMemo(()=>x?b.current?"delayed-open":"instant-open":"closed",[x]),S=g.useCallback(()=>{window.clearTimeout(p.current),p.current=0,b.current=!1,_(!0)},[_]),C=g.useCallback(()=>{window.clearTimeout(p.current),p.current=0,_(!1)},[_]),k=g.useCallback(()=>{window.clearTimeout(p.current),p.current=window.setTimeout(()=>{b.current=!0,_(!0),p.current=0},v)},[v,_]);return g.useEffect(()=>()=>{p.current&&(window.clearTimeout(p.current),p.current=0)},[]),h.jsx(dy,{...c,children:h.jsx(MU,{scope:t,contentId:f,open:x,stateAttribute:y,trigger:u,onTriggerChange:d,onTriggerEnter:g.useCallback(()=>{l.isOpenDelayedRef.current?k():S()},[l.isOpenDelayedRef,k,S]),onTriggerLeave:g.useCallback(()=>{m?C():(window.clearTimeout(p.current),p.current=0)},[C,m]),onOpen:S,onClose:C,disableHoverableContent:m,children:n})})};xR.displayName=ru;var T0="TooltipTrigger",_R=g.forwardRef((e,t)=>{const{__scopeTooltip:n,...r}=e,i=wp(T0,n),s=ky(T0,n),o=bp(n),a=g.useRef(null),l=Gt(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(JI,{asChild:!0,...o,children:h.jsx(Tt.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)})})});_R.displayName=T0;var AU="TooltipPortal",[Boe,jU]=yp(AU,{forceMount:void 0}),qa="TooltipContent",yR=g.forwardRef((e,t)=>{const n=jU(qa,e.__scopeTooltip),{forceMount:r=n.forceMount,side:i="top",...s}=e,o=wp(qa,e.__scopeTooltip);return h.jsx(qi,{present:r||o.open,children:o.disableHoverableContent?h.jsx(bR,{side:i,...s,ref:t}):h.jsx(LU,{side:i,...s,ref:t})})}),LU=g.forwardRef((e,t)=>{const n=wp(qa,e.__scopeTooltip),r=ky(qa,e.__scopeTooltip),i=g.useRef(null),s=Gt(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={x:m.clientX,y:m.clientY},_=$U(x,b.getBoundingClientRect()),y=FU(x,_),S=HU(v.getBoundingClientRect()),C=WU([...y,...S]);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={x:v.clientX,y:v.clientY},_=(l==null?void 0:l.contains(b))||(u==null?void 0:u.contains(b)),y=!UU(x,o);_?f():y&&(f(),c())};return document.addEventListener("pointermove",m),()=>document.removeEventListener("pointermove",m)}},[l,u,o,c,f]),h.jsx(bR,{...e,ref:s})}),[DU,OU]=yp(ru,{isInside:!1}),BU=EF("TooltipContent"),bR=g.forwardRef((e,t)=>{const{__scopeTooltip:n,children:r,"aria-label":i,onEscapeKeyDown:s,onPointerDownOutside:o,...a}=e,l=wp(qa,n),c=bp(n),{onClose:u}=l;return g.useEffect(()=>(document.addEventListener(N0,u),()=>document.removeEventListener(N0,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(up,{asChild:!0,disableOutsidePointerEvents:!1,onEscapeKeyDown:s,onPointerDownOutside:o,onFocusOutside:d=>d.preventDefault(),onDismiss:u,children:h.jsxs(eP,{"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(BU,{children:r}),h.jsx(DU,{scope:n,isInside:!0,children:h.jsx(IU,{id:l.contentId,role:"tooltip",children:i||r})})]})})});yR.displayName=qa;var wR="TooltipArrow",zU=g.forwardRef((e,t)=>{const{__scopeTooltip:n,...r}=e,i=bp(n);return OU(wR,n).isInside?null:h.jsx(tP,{...i,...r,ref:t})});zU.displayName=wR;function $U(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 FU(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 HU(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 UU(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 WU(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),VU(t)}function VU(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 qU=vR,KU=xR,GU=_R,SR=yR;const cf=qU,Sp=KU,kp=GU,Ru=g.forwardRef(({className:e,sideOffset:t=4,...n},r)=>h.jsx(SR,{ref:r,sideOffset:t,className:oe("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}));Ru.displayName=SR.displayName;const YU={held:!1,indexBySessionId:new Map},XU=g.createContext(YU);function ZU(){return g.useContext(XU)}const QU=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})),JU=[{id:"new-session",combo:{key:"n",mod:!0},label:"新建任务",description:"打开快捷新建弹窗",group:"通用",desktopOnly:!0},...QU,{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}];JU.filter(e=>!e.displayOnly);function eW(){return/Mac|iP(hone|od|ad)/.test(navigator.platform)}const tW=10,nW=20,rW=16,iW=20,sW=60,oW=4;function kd({testId:e,label:t,children:n}){return h.jsxs(Sp,{children:[h.jsx(kp,{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(Ru,{side:"bottom",children:t})]})}function aW({session:e,active:t,hasUnread:n,running:r=!1,awaitingUser:i=!1,onSelect:s,onEdit:o,onDelete:a,onPin:l,onArchive:c,quickAction:u,depth:d=0,chevron:f,showCopyResume:p=!0,contactDisplayName:m,ownerPrincipalId:v,creatorDisplayName:b,dispatchedFromSessionTitle:x}){const[_,y]=g.useState(!1),S=ZU(),C=S.held?S.indexBySessionId.get(e.sessionId):void 0,k=!!e.pinnedAt,N=d===0,T=d===0&&!!c,z=tW+d*nW;let I=null;u==="pin"&&N&&l?I={icon:k?h.jsx(Fw,{className:"w-4 h-4"}):h.jsx(Hw,{className:"w-4 h-4"}),label:k?"取消置顶":"置顶",run:()=>l(e.sessionId,!k)}:u==="archive"&&T&&c?I={icon:h.jsx(zw,{className:"w-4 h-4"}),label:"归档",run:()=>c(e.sessionId,!0)}:u==="rename"&&o&&(I={icon:h.jsx(v0,{className:"w-4 h-4"}),label:"重命名",run:()=>y(!0)});const M=g.useCallback(async()=>{const $=SI(e);if($)try{await navigator.clipboard.writeText($)}catch{}},[e]),L=ty(e),R=e.originOwnerPrincipalId,A=R?`@${m??`…${R.slice(-8)}`}`:null,D=!!(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:`${rW}px ${iW}px 1fr auto ${sW}px`,gridTemplateAreas:'"chev icon name dot time"',columnGap:`${oW}px`,alignItems:"center"},className:oe("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(kU,{tool:e.tool})}),h.jsxs("div",{style:{gridArea:"name"},className:"flex items-center gap-1 min-w-0",children:[h.jsxs(cf,{delayDuration:200,skipDelayDuration:100,children:[e.dispatchedFromSessionId?h.jsx(kd,{testId:`dispatched-icon-${e.sessionId}`,label:`来自【${x??"另一会话"}】dispatch`,children:h.jsx(l$,{"aria-hidden":"true",className:"w-3 h-3 text-accent",strokeWidth:2.25})}):null,e.shiftFiredFromSessionId?h.jsx(kd,{testId:`shift-fired-icon-${e.sessionId}`,label:"定时任务",children:h.jsx(jz,{"aria-hidden":"true",className:"w-3 h-3 text-accent",strokeWidth:2.25})}):null,e.larkChatId?h.jsx(kd,{testId:`lark-chat-icon-${e.sessionId}`,label:e.larkChatType==="p2p"?"来自飞书DM":"来自飞书群",children:h.jsx(L$,{"aria-hidden":"true",className:"w-3 h-3 text-accent",strokeWidth:2.25})}):null,D?h.jsx(kd,{testId:`guest-created-icon-${e.sessionId}`,label:b?`${b}创建`:"其他人创建",children:h.jsx(x8,{"aria-hidden":"true",className:"w-3 h-3 text-accent",strokeWidth:2.25})}):null]}),h.jsx("span",{"data-testid":`session-title-${e.sessionId}`,className:oe("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:L}),A?h.jsx("span",{"data-testid":`session-mirror-chip-${e.sessionId}`,title:`在 ${A.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:A}):null]}),h.jsx(CU,{sessionId:e.sessionId,hasUnread:n,running:r,awaitingUser:i,style:{gridArea:"dot"}}),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:eW()?`⌘${C}`:`Ctrl+${C}`})}):h.jsx("span",{style:{gridArea:"time"},className:oe("text-[11px] text-text-400/70 text-right shrink-0","transition-opacity duration-150 group-hover:opacity-0"),children:e.updatedAt?vF(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:[I?h.jsx(cf,{delayDuration:200,skipDelayDuration:100,children:h.jsxs(Sp,{children:[h.jsx(kp,{asChild:!0,children:h.jsx("button",{type:"button",onClick:$=>{$.stopPropagation(),I.run()},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":I.label,"data-testid":`quick-action-${u}-${e.sessionId}`,children:I.icon})}),h.jsx(Ru,{side:"bottom",children:I.label})]})}):null,h.jsxs(wy,{modal:!1,children:[h.jsx(Sy,{asChild:!0,children:h.jsx("button",{type:"button",onClick:$=>$.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(QT,{className:"w-4 h-4"})})}),h.jsxs(_p,{align:"end",onClick:$=>$.stopPropagation(),children:[l&&N&&h.jsxs(Ci,{onSelect:()=>l(e.sessionId,!k),"data-testid":`session-${k?"unpin":"pin"}-${e.sessionId}`,children:[k?h.jsx(Fw,{className:"w-3 h-3 mr-2 text-text-400"}):h.jsx(Hw,{className:"w-3 h-3 mr-2 text-text-400"}),k?"Unpin":"Pin"]}),T&&c&&h.jsxs(Ci,{onSelect:()=>c(e.sessionId,!0),"data-testid":`session-archive-${e.sessionId}`,children:[h.jsx(zw,{className:"w-3 h-3 mr-2 text-text-400"}),"Archive"]}),o&&h.jsxs(Ci,{onSelect:()=>y(!0),"data-testid":`session-rename-${e.sessionId}`,children:[h.jsx(v0,{className:"w-3 h-3 mr-2 text-text-400"}),"Rename"]}),p&&e.toolSessionId?h.jsxs(Ci,{onSelect:()=>void M(),"data-testid":`session-copy-resume-${e.sessionId}`,children:[h.jsx(cp,{className:"w-3 h-3 mr-2 text-text-400"}),"Copy Resume Command"]}):null,(l||o||p&&e.toolSessionId)&&a&&h.jsx(hR,{}),a&&h.jsxs(Ci,{onSelect:()=>void a(e.sessionId),className:"text-destructive focus:text-destructive focus:bg-destructive/10","data-testid":`session-delete-${e.sessionId}`,children:[h.jsx(Z_,{className:"w-3 h-3 mr-2"}),"Delete"]})]})]})]}):null]}),o?h.jsx(EU,{open:_,initialLabel:e.label??"",placeholder:e.cwd.split("/").pop()||"",onSubmit:$=>{o(e.sessionId,$),y(!1)},onCancel:()=>y(!1)}):null]})}function Cy({node:e,depth:t=0,activeId:n,unreadIds:r,runningIds:i,awaitingIds:s,onSelect:o,onEdit:a,onDelete:l,onPin:c,onArchive:u,quickAction:d,getContactDisplayName:f,showCopyResume:p,ownerPrincipalId:m,getCreatorDisplayName:v,getSessionDisplayName:b,parentSession:x}){const _=e.children.length>0,{isCollapsed:y,toggle:S}=Nz(),C=!y(e.session.sessionId),k=g.useCallback(T=>{T.stopPropagation(),S(e.session.sessionId)},[S,e.session.sessionId]),N=_?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(qn,{className:"w-3 h-3"}):h.jsx(Ln,{className:"w-3 h-3"})}):null;return h.jsxs("div",{"data-testid":`session-tree-node-${e.session.sessionId}`,children:[h.jsx(aW,{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,quickAction: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))??((x==null?void 0:x.sessionId)===e.session.dispatchedFromSessionId?ty(x):void 0):void 0,depth:t,chevron:N,contactDisplayName:e.session.originOwnerPrincipalId?f==null?void 0:f(e.session.originOwnerPrincipalId):void 0}),_&&C?h.jsx("div",{"data-testid":`session-tree-children-${e.session.sessionId}`,children:e.children.map(T=>h.jsx(Cy,{node:T,depth:t+1,activeId:n,unreadIds:r,runningIds:i,awaitingIds:s,onSelect:o,onEdit:a,onDelete:l,onPin:c,onArchive:u,quickAction:d,getContactDisplayName:f,showCopyResume:p,ownerPrincipalId:m,getCreatorDisplayName:v,getSessionDisplayName:b,parentSession:e.session},T.session.sessionId))}):null]})}function lW(e){return e.forkedFromSessionId??e.dispatchedFromSessionId??e.shiftFiredFromSessionId}function kR(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=lW(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(cW).map(i)}function CR(e){return[...e].sort((t,n)=>t.session.updatedAt<n.session.updatedAt?1:t.session.updatedAt>n.session.updatedAt?-1:0)}function cW(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 uW(e){return e.appBuilderProject?`[app] ${e.appBuilderProject}`:e.label?e.label:e.aiLabel?e.aiLabel:e.cwd.split("/").filter(Boolean).pop()??""}function bS(e,t){const n=t.trim().toLowerCase();return n===""?!0:e.toLowerCase().includes(n)}const dW={isCollapsed:()=>!1,toggle:()=>{},prune:()=>{}};function hW({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:x,treatSessionsAsRoots:_,searchQuery:y}){const[S,C]=g.useState(null),[k,N]=g.useState(()=>new Set),T=p??(D=>k.has(D)),z=g.useCallback(D=>{if(m){m(D);return}N($=>{const F=new Set($);return F.has(D)?F.delete(D):F.add(D),F})},[m]),I=g.useMemo(()=>i==null?void 0:i.filter(D=>!D.ephemeral),[i]),M=g.useMemo(()=>new Map((I??[]).map(D=>[D.sessionId,ty(D)])),[I]),L=g.useCallback(D=>f==null?void 0:f.get(D),[f]),R=g.useCallback(D=>M.get(D),[M]);if(e.length===0)return h.jsx(fW,{});const A=(y??"").trim();return A?h.jsx(G_.Provider,{value:dW,children:h.jsx("div",{"data-testid":"my-personas-list",className:"flex flex-col gap-0.5",children:e.map(D=>{const $=I?I.filter(E=>E.ownerPersonaId===D.personaId).sort((E,H)=>H.updatedAt>E.updatedAt?1:-1):[],F=bS(D.label,A),O=$.filter(E=>bS(uW(E),A));if(!F&&O.length===0)return null;const B=F?$:O;return h.jsx(wS,{persona:D,active:D.personaId===t,editing:!1,onSelectPersona:n,onSubmitCreateSession:()=>{},onCancelCreateSession:()=>{},personaSessions:B,collapsed:!1,onToggleCollapsed:()=>{},activeSessionId:s??null,awaitingIds:o,runningIds:a,unreadIds:l,onSelectSession:c,onDeleteSession:u,onEditSession:v,onPinSession:b,showCopyResume:x,treatSessionsAsRoots:_,ownerPrincipalId:d,creatorDisplayNameByOwnerId:f,getCreatorDisplayName:L,getSessionDisplayName:R},D.personaId)})})}):h.jsx("div",{"data-testid":"my-personas-list",className:"flex flex-col gap-0.5",children:e.map(D=>{const $=I?I.filter(F=>F.ownerPersonaId===D.personaId).sort((F,O)=>O.updatedAt>F.updatedAt?1:-1):[];return h.jsx(wS,{persona:D,active:D.personaId===t,editing:D.personaId===S,onSelectPersona:n,onStartCreateSession:r?()=>C(D.personaId):void 0,onSubmitCreateSession:F=>{C(null),r==null||r(D.personaId,F)},onCancelCreateSession:()=>C(null),personaSessions:$,collapsed:!T(D.personaId),onToggleCollapsed:()=>z(D.personaId),activeSessionId:s??null,awaitingIds:o,runningIds:a,unreadIds:l,onSelectSession:c,onDeleteSession:u,onEditSession:v,onPinSession:b,showCopyResume:x,treatSessionsAsRoots:_,ownerPrincipalId:d,creatorDisplayNameByOwnerId:f,getCreatorDisplayName:L,getSessionDisplayName:R},D.personaId)})})}function fW(){return h.jsx("div",{className:"px-3 py-3 text-[11px] leading-relaxed text-text-400",children:"还没有 persona。点上方 Personas 标题右侧 + 创建第一个。"})}function wS({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:x,showCopyResume:_,treatSessionsAsRoots:y,ownerPrincipalId:S,creatorDisplayNameByOwnerId:C,getCreatorDisplayName:k,getSessionDisplayName:N}){const T=a.length>0,z=!l,I=g.useMemo(()=>{const R=[],A=new Map;for(const D of a){const $=D.creatorPrincipalId;if(D.larkChatId!=null||!$||S&&$===S){R.push(D);continue}const F=$,O=(C==null?void 0:C.get(F))??`…${F.slice(-8)}`,B=A.get(F);B?B.sessions.push(D):A.set(F,{groupKey:F,displayName:O,sessions:[D]})}return{self:R,byPeer:[...A.values()]}},[a,S,C]),M=I.byPeer.length>0,L=g.useMemo(()=>z&&!M?CR(kR(a)):[],[z,M,a]);return h.jsxs("div",{"data-testid":`persona-node-${e.personaId}`,children:[h.jsxs("div",{className:oe("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:[T?h.jsx("button",{type:"button",onClick:R=>{R.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(qn,{className:"h-3 w-3"}):h.jsx(Ln,{className:"h-3 w-3"})}):h.jsx("span",{className:"h-4 w-4 shrink-0","aria-hidden":"true"}),h.jsx(bu,{tool:e.tool,className:oe("h-3.5 w-3.5 shrink-0",wu(e.tool))}),h.jsx("span",{className:"flex-1 truncate text-[13px]",children:e.label}),T?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:R=>{R.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(G$,{className:"h-3.5 w-3.5"})}):null]}),n?h.jsx(pW,{personaId:e.personaId,tool:e.tool,onSubmit:s,onCancel:o}):null,T&&z?h.jsx("div",{"data-testid":`persona-sessions-${e.personaId}`,children:M?h.jsxs(h.Fragment,{children:[I.self.length>0&&h.jsx(SS,{groupKey:`${e.personaId}-self`,label:"我自己",testId:`persona-sessions-${e.personaId}-self`,sessions:I.self,activeSessionId:u,awaitingIds:d,runningIds:f,unreadIds:p,onSelectSession:m,onDeleteSession:v,onEditSession:b,onPinSession:x,showCopyResume:_,ownerPrincipalId:S,getCreatorDisplayName:k,getSessionDisplayName:N}),I.byPeer.map(R=>h.jsx(SS,{groupKey:`${e.personaId}-peer-${R.groupKey}`,label:R.displayName,testId:`persona-sessions-${e.personaId}-peer-${R.groupKey}`,sessions:R.sessions,activeSessionId:u,awaitingIds:d,runningIds:f,unreadIds:p,onSelectSession:m,onDeleteSession:v,onEditSession:b,onPinSession:x,showCopyResume:_,ownerPrincipalId:S,getCreatorDisplayName:k,getSessionDisplayName:N},`${e.personaId}-peer-${R.groupKey}`))]}):L.map(R=>h.jsx(Cy,{node:R,depth:y?0:1,activeId:u,unreadIds:p,runningIds:f,awaitingIds:d,onSelect:A=>m==null?void 0:m(A),onDelete:v,onEdit:b,onPin:x,showCopyResume:_,ownerPrincipalId:S,getCreatorDisplayName:k,getSessionDisplayName:N},R.session.sessionId))}):null]})}function SS({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),x=!v,_=g.useMemo(()=>x?CR(kR(n)):[],[x,n]);return h.jsxs("div",{"data-testid":t,children:[h.jsxs("button",{type:"button",onClick:()=>b(y=>!y),"aria-label":x?"collapse":"expand","aria-expanded":x,"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:[x?h.jsx(qn,{className:"h-3 w-3"}):h.jsx(Ln,{className:"h-3 w-3"}),h.jsx(sI,{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})]}),x&&h.jsx("div",{children:_.map(y=>h.jsx(Cy,{node:y,depth:2,activeId:r,unreadIds:o,runningIds:s,awaitingIds:i,onSelect:S=>a==null?void 0:a(S),onDelete:l,onEdit:c,onPin:u,showCopyResume:d,ownerPrincipalId:f,getCreatorDisplayName:p,getSessionDisplayName:m},y.session.sessionId))})]})}function pW({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=Pu(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(bu,{tool:t,className:oe("h-3 w-3 shrink-0",wu(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(ml,{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(zr,{className:"h-3 w-3"})})]})}function mW(e,t){const n=getComputedStyle(e),r=parseFloat(n.fontSize);return t*r}function gW(e,t){const n=getComputedStyle(e.ownerDocument.documentElement),r=parseFloat(n.fontSize);return t*r}function vW(e){return e/100*window.innerHeight}function xW(e){return e/100*window.innerWidth}function _W(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 ec({groupSize:e,panelElement:t,styleProp:n}){let r;const[i,s]=_W(n);switch(s){case"%":{r=i/100*e;break}case"px":{r=i;break}case"rem":{r=gW(t,i);break}case"em":{r=mW(t,i);break}case"vh":{r=vW(i);break}case"vw":{r=xW(i);break}}return r}function In(e){return parseFloat(e.toFixed(3))}function Ka({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 I0(e){const{panels:t}=e,n=Ka({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=ec({groupSize:n,panelElement:i,styleProp:s.collapsedSize});o=In(u/n*100)}let a;if(s.defaultSize!==void 0){const u=ec({groupSize:n,panelElement:i,styleProp:s.defaultSize});a=In(u/n*100)}let l=0;if(s.minSize!==void 0){const u=ec({groupSize:n,panelElement:i,styleProp:s.minSize});l=In(u/n*100)}let c=100;if(s.maxSize!==void 0){const u=ec({groupSize:n,panelElement:i,styleProp:s.maxSize});c=In(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 P0(e,t){return Array.from(t).sort(e==="horizontal"?yW:bW)}function yW(e,t){const n=e.element.offsetLeft-t.element.offsetLeft;return n!==0?n:e.element.offsetWidth-t.element.offsetWidth}function bW(e,t){const n=e.element.offsetTop-t.element.offsetTop;return n!==0?n:e.element.offsetHeight-t.element.offsetHeight}function ER(e){return e!==null&&typeof e=="object"&&"nodeType"in e&&e.nodeType===Node.ELEMENT_NODE}function NR(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 wW({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}=NR(r,o),c=e==="horizontal"?a:l;c<s&&(s=c,i=o)}return rt(i,"No rect found"),i}let Cd;function SW(){return Cd===void 0&&(typeof matchMedia=="function"?Cd=!!matchMedia("(pointer:coarse)").matches:Cd=!1),Cd}function TR(e){const{element:t,orientation:n,panels:r,separators:i}=e,s=P0(n,Array.from(t.children).filter(ER).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(x=>x.element===v);if(b){if(f){const x=f.element.getBoundingClientRect(),_=v.getBoundingClientRect();let y;if(l){const S=n==="horizontal"?new DOMRect(x.right,x.top,0,x.height):new DOMRect(x.left,x.bottom,x.width,0),C=n==="horizontal"?new DOMRect(_.left,_.top,0,_.height):new DOMRect(_.left,_.top,_.width,0);switch(p.length){case 0:{y=[S,C];break}case 1:{const k=p[0],N=wW({orientation:n,rects:[x,_],targetRect:k.element.getBoundingClientRect()});y=[k,N===x?C:S];break}default:{y=p;break}}}else p.length?y=p:y=[n==="horizontal"?new DOMRect(x.right,_.top,_.left-x.right,_.height):new DOMRect(_.left,x.bottom,_.width,_.top-x.bottom)];for(const S of y){let C="width"in S?S:S.element.getBoundingClientRect();const k=SW()?e.resizeTargetMinimumSize.coarse:e.resizeTargetMinimumSize.fine;if(C.width<k){const T=k-C.width;C=new DOMRect(C.x-T/2,C.y,C.width+T,C.height)}if(C.height<k){const T=k-C.height;C=new DOMRect(C.x,C.y-T/2,C.width,C.height+T)}const N=m<=c||m>u;!a&&!N&&o.push({group:e,groupSize:Ka({group:e}),panels:[f,b],separator:"width"in S?void 0:S,rect:C}),a=!1}}l=!1,f=b,p=[]}}else if(v.hasAttribute("data-separator")){v.ariaDisabled!==null&&(a=!0);const b=i.find(x=>x.element===v);b?p.push(b):(f=void 0,p=[])}else l=!0}return o}var hs;class IR{constructor(){E1(this,hs,{})}addListener(t,n){const r=Nl(this,hs)[t];return r===void 0?Nl(this,hs)[t]=[n]:r.includes(n)||r.push(n),()=>{this.removeListener(t,n)}}emit(t,n){const r=Nl(this,hs)[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(){N1(this,hs,{})}removeListener(t,n){const r=Nl(this,hs)[t];if(r!==void 0){const i=r.indexOf(n);i>=0&&r.splice(i,1)}}}hs=new WeakMap;let Pa={cursorFlags:0,state:"inactive"};const Ey=new IR;function ko(){return Pa}function kW(e){return Ey.addListener("change",e)}function CW(e){const t=Pa,n={...Pa};n.cursorFlags=e,Pa=n,Ey.emit("change",{prev:t,next:n})}function Ra(e){const t=Pa;Pa=e,Ey.emit("change",{prev:t,next:e})}const EW=e=>e,qm=()=>{},PR=1,RR=2,MR=4,AR=8,kS=3,CS=12;let Ed;function ES(){return Ed===void 0&&(Ed=!1,typeof window<"u"&&(window.navigator.userAgent.includes("Chrome")||window.navigator.userAgent.includes("Firefox"))&&(Ed=!0)),Ed}function NW({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&&ES()){const s=(e&PR)!==0,o=(e&RR)!==0,a=(e&MR)!==0,l=(e&AR)!==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 ES()?r>0&&i>0?"move":r>0?"ew-resize":"ns-resize":r>0&&i>0?"grab":r>0?"col-resize":"row-resize"}}const NS=new WeakMap;function Ny(e){if(e.defaultView===null||e.defaultView===void 0)return;let{prevStyle:t,styleSheet:n}=NS.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=ko();switch(r.state){case"active":case"hover":{const i=NW({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}}NS.set(e,{prevStyle:t,styleSheet:n})}let ei=new Map;const jR=new IR;function TW(e){ei=new Map(ei),ei.delete(e)}function TS(e,t){for(const[n]of ei)if(n.id===e)return n}function Ns(e,t){for(const[n,r]of ei)if(n.id===e)return r;if(t)throw Error(`Could not find data for Group with id ${e}`)}function Bo(){return ei}function Ty(e,t){return jR.addListener("groupChange",n=>{n.group.id===e&&t(n)})}function Fi(e,t,n){const r=ei.get(e);ei=new Map(ei),ei.set(e,t),jR.emit("groupChange",{group:e,isUserInteraction:(n==null?void 0:n.isUserInteraction)===!0,prev:r,next:t})}function LR(e){const t=ko();let n=!1;switch(t.state){case"active":Ra({cursorFlags:0,state:"inactive"}),t.hitRegions.length>0&&(Ny(e),n=!0,t.hitRegions.forEach(r=>{const i=Ns(r.group.id,!0);Fi(r.group,i,{isUserInteraction:!0})}))}return n}function IS(e){e.defaultPrevented||LR(e.currentTarget)}function IW(e,t,n){let r,i={x:1/0,y:1/0};for(const s of t){const o=NR(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 PW(e){return e!==null&&typeof e=="object"&&"nodeType"in e&&e.nodeType===Node.DOCUMENT_FRAGMENT_NODE}function RW(e,t){if(e===t)throw new Error("Cannot compare node with itself");const n={a:MS(e),b:MS(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:RS(PS(n.a)),b:RS(PS(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 MW=/\b(?:position|zIndex|opacity|transform|webkitTransform|mixBlendMode|filter|webkitFilter|isolation)\b/;function AW(e){const t=getComputedStyle(DR(e)??e).display;return t==="flex"||t==="inline-flex"}function jW(e){const t=getComputedStyle(e);return!!(t.position==="fixed"||t.zIndex!=="auto"&&(t.position!=="static"||AW(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"||MW.test(t.willChange)||t.webkitOverflowScrolling==="touch")}function PS(e){let t=e.length;for(;t--;){const n=e[t];if(rt(n,"Missing node"),jW(n))return n}return null}function RS(e){return e&&Number(getComputedStyle(e).zIndex)||0}function MS(e){const t=[];for(;e;)t.push(e),e=DR(e);return t}function DR(e){const{parentNode:t}=e;return PW(t)?t.host:t}function LW(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 DW({groupElement:e,hitRegion:t,pointerEventTarget:n}){if(!ER(n)||n.contains(e)||e.contains(n))return!0;if(RW(n,e)>0){let r=n;for(;r;){if(r.contains(e))return!0;if(LW(r.getBoundingClientRect(),t))return!1;r=r.parentElement}}return!0}function Iy(e,t){const n=[];return t.forEach((r,i)=>{if(i.disabled)return;const s=TR(i),o=IW(i.orientation,s,{x:e.clientX,y:e.clientY});o&&o.distance.x<=0&&o.distance.y<=0&&DW({groupElement:i.element,hitRegion:o.hitRegion.rect,pointerEventTarget:e.target})&&n.push(o.hitRegion)}),n}function OW(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 xn(e,t,n=0){return Math.abs(In(e)-In(t))<=n}function Xr(e,t){return xn(e,t)?0:e>t?1:-1}function _a({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(Xr(r,l)<0)if(s){const c=(i+l)/2;Xr(r,c)<0?r=i:r=l}else r=l;return r=Math.min(a,r),r=In(r),r}function iu({delta:e,initialLayout:t,panelConstraints:n,pivotIndices:r,prevLayout:i,trigger:s}){if(xn(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:x=0,collapsible:_,minSize:y=0}=b;if(_){const S=a[v];if(rt(S!=null,`Previous layout not found for panel index ${v}`),xn(S,x)){const C=y-S;Xr(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:x=0,collapsible:_,minSize:y=0}=b;if(_){const S=a[v];if(rt(S!=null,`Previous layout not found for panel index ${v}`),xn(S,y)){const C=S-x;Xr(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 x=a[v],{collapsible:_,collapsedSize:y,minSize:S}=b;if(_&&Xr(x,S)<0)if(e>0){const C=S-y,k=C/2,N=x+e;Xr(N,S)<0&&(e=Xr(e,k)<=0?0:C)}else{const C=S-y,k=100-C/2,N=x-e;Xr(N,S)<0&&(e=Xr(100+e,k)>0?0:-C)}break}}{const v=e<0?1:-1;let b=e<0?d:u,x=0;for(;;){const y=a[b];rt(y!=null,`Previous layout not found for panel index ${b}`);const S=_a({overrideDisabledPanels:o,panelConstraints:n[b],prevSize:y,size:100})-y;if(x+=S,b+=v,b<0||b>=n.length)break}const _=Math.min(Math.abs(e),Math.abs(x));e=e<0?0-_:_}{let v=e<0?u:d;for(;v>=0&&v<n.length;){const b=Math.abs(e)-Math.abs(f),x=a[v];rt(x!=null,`Previous layout not found for panel index ${v}`);const _=x-b,y=_a({overrideDisabledPanels:o,panelConstraints:n[v],prevSize:x,size:_});if(!xn(x,y)&&(f+=x-y,c[v]=y,f.toFixed(3).localeCompare(Math.abs(e).toFixed(3),void 0,{numeric:!0})>=0))break;e<0?v--:v++}}if(OW(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 x=b+f,_=_a({overrideDisabledPanels:o,panelConstraints:n[v],prevSize:b,size:x});if(c[v]=_,!xn(_,x)){let y=x-_,S=e<0?d:u;for(;S>=0&&S<n.length;){const C=c[S];rt(C!=null,`Previous layout not found for panel index ${S}`);const k=C+y,N=_a({overrideDisabledPanels:o,panelConstraints:n[S],prevSize:C,size:k});if(xn(C,N)||(y-=N-C,c[S]=N),xn(y,0))break;e>0?S--:S++}}}const p=Object.values(c).reduce((v,b)=>b+v,0);if(!xn(p,100,.1))return i;const m=Object.keys(i);return c.reduce((v,b,x)=>(v[m[x]]=b,v),{})}function Co(e,t){if(Object.keys(e).length!==Object.keys(t).length)return!1;for(const n in e)if(t[n]===void 0||Xr(e[n],t[n])!==0)return!1;return!0}function Eo({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(!xn(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=_a({overrideDisabledPanels:!0,panelConstraints:t[a],prevSize:l,size:c});c!=u&&(s+=c-u,r[a]=u)}if(!xn(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=_a({overrideDisabledPanels:!0,panelConstraints:t[a],prevSize:l,size:c});if(l!==u&&(s-=u-l,r[a]=u,xn(s,0)))break}const o=Object.keys(e);return r.reduce((a,l,c)=>(a[o[c]]=l,a),{})}function OR({groupId:e,panelId:t}){const n=()=>{const l=Bo();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,x)=>{const _=d[x];return(_==null?void 0:_.collapsible)&&xn(_.collapsedSize,u[_.panelId])}))){const b=c.slice(0,p).reduce((x,_)=>x+u[_.id],0);return{...u,[t]:In(100-b)}}return iu({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}),x=Eo({layout:b,panelConstraints:d});Co(m,x)||Fi(f,{defaultLayoutDeferred:u,derivedPanelConstraints:d,groupSize:p,layout:x,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&&xn(c,u)},resize:l=>{const{group:c}=n(),{element:u}=i(),d=Ka({group:c}),f=ec({groupSize:d,panelElement:u,styleProp:l}),p=In(f/d*100);a(p)}}}function AS(e){if(e.defaultPrevented)return;const t=Bo();Iy(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=OR({groupId:n.group.id,panelId:r.id});s&&i!==void 0&&(s.resize(i),e.preventDefault())}}})}function ah(e){const t=Bo();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 BR({groupId:e}){const t=()=>{const n=Bo();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=Eo({layout:n,panelConstraints:i});return r?a:(Co(a,c)||Fi(s,{defaultLayoutDeferred:r,derivedPanelConstraints:i,groupSize:o,layout:c,separatorToPanels:l}),c)}}}function Ys(e,t){const n=ah(e),r=Ns(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=BR({groupId:n.id}).getLayout(),l=iu({delta:t,initialLayout:a,panelConstraints:r.derivedPanelConstraints,pivotIndices:o,prevLayout:a,trigger:"keyboard"}),c=Eo({layout:l,panelConstraints:r.derivedPanelConstraints});Co(a,c)||Fi(n,{defaultLayoutDeferred:r.defaultLayoutDeferred,derivedPanelConstraints:r.derivedPanelConstraints,groupSize:r.groupSize,layout:c,separatorToPanels:r.separatorToPanels},{isUserInteraction:!0})}function jS(e){if(e.defaultPrevented)return;const t=e.currentTarget,n=ah(t);if(!n.disabled)switch(e.key){case"ArrowDown":{e.preventDefault(),n.orientation==="vertical"&&Ys(t,5);break}case"ArrowLeft":{e.preventDefault(),n.orientation==="horizontal"&&Ys(t,-5);break}case"ArrowRight":{e.preventDefault(),n.orientation==="horizontal"&&Ys(t,5);break}case"ArrowUp":{e.preventDefault(),n.orientation==="vertical"&&Ys(t,-5);break}case"End":{e.preventDefault(),Ys(t,100);break}case"Enter":{e.preventDefault();const r=ah(t),i=Ns(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;Ys(t,p-f)}break}case"F6":{e.preventDefault();const r=ah(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(),Ys(t,-100);break}}}function LS(e){if(e.defaultPrevented||e.pointerType==="mouse"&&e.button>0)return;const t=Bo(),n=Iy(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)}),Ra({cursorFlags:0,hitRegions:n,initialLayoutMap:r,pointerDownAtPoint:{x:e.clientX,y:e.clientY},state:"active"}),n.length&&e.preventDefault()}function zR({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),x=i.get(u);if(!b||!x)return;const{defaultLayoutDeferred:_,derivedPanelConstraints:y,groupSize:S,layout:C,separatorToPanels:k}=x;if(y&&C&&k){const N=iu({delta:v,initialLayout:b,panelConstraints:y,pivotIndices:c.panels.map(T=>p.indexOf(T)),prevLayout:C,trigger:"mouse-or-touch"});if(Co(N,C)){if(v!==0&&!m)switch(f){case"horizontal":{a|=v<0?PR:RR;break}case"vertical":{a|=v<0?MR:AR;break}}}else Fi(c.group,{defaultLayoutDeferred:_,derivedPanelConstraints:y,groupSize:S,layout:N,separatorToPanels:k})}});let l=0;t.movementX===0?l|=o&kS:l|=a&kS,t.movementY===0?l|=o&CS:l|=a&CS,CW(l),Ny(e)}function DS(e){const t=Bo(),n=ko();switch(n.state){case"active":zR({document:e.currentTarget,event:e,hitRegions:n.hitRegions,initialLayoutMap:n.initialLayoutMap,mountedGroups:t,prevCursorFlags:n.cursorFlags})}}function OS(e){var r,i;if(e.defaultPrevented)return;const t=ko(),n=Bo();switch(t.state){case"active":{if(e.buttons===0){Ra({cursorFlags:0,state:"inactive"}),t.hitRegions.forEach(s=>{const o=Ns(s.group.id,!0);Fi(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))}zR({document:e.currentTarget,event:e,hitRegions:t.hitRegions,initialLayoutMap:t.initialLayoutMap,mountedGroups:n,pointerDownAtPoint:t.pointerDownAtPoint,prevCursorFlags:t.cursorFlags});break}default:{const s=Iy(e,n);s.length===0?t.state!=="inactive"&&Ra({cursorFlags:0,state:"inactive"}):Ra({cursorFlags:0,hitRegions:s,state:"hover"}),Ny(e.currentTarget);break}}}function BS(e){if(e.relatedTarget instanceof HTMLIFrameElement)switch(ko().state){case"hover":Ra({cursorFlags:0,state:"inactive"})}}function zS(e){e.defaultPrevented||e.pointerType==="mouse"&&e.button>0||LR(e.currentTarget)&&e.preventDefault()}function $S(e){let t=0,n=0;const r={};for(const s of e)if(s.defaultSize!==void 0){t++;const o=In(s.defaultSize);n+=o,r[s.panelId]=o}else r[s.panelId]=void 0;const i=e.length-t;if(i!==0){const s=In((100-n)/i);for(const o of e)o.defaultSize===void 0&&(r[o.panelId]=s)}return r}function BW(e,t,n){if(!n[0])return;const r=e.panels.find(l=>l.element===t);if(!r||!r.onResize)return;const i=Ka({group:e}),s=e.orientation==="horizontal"?r.element.offsetWidth:r.element.offsetHeight,o=r.mutableValues.prevSize,a={asPercentage:In(s/i*100),inPixels:s};r.mutableValues.prevSize=a,r.onResize(a,r.id,o)}function zW(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 $W({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=In(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]=In(f/s*c)}else{const d=In(c/l.length);for(const f of l)u[f]=d}return u}function FW(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 Qo=new Map;function HW(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:x}=v;if(x===e.element){if(t){const _=Ka({group:e});if(_===0)return;const y=Ns(e.id);if(!y)return;const S=I0(e),C=y.defaultLayoutDeferred?$S(S):y.layout,k=$W({group:e,nextGroupSize:_,prevGroupSize:y.groupSize,prevLayout:C}),N=Eo({layout:k,panelConstraints:S});if(!y.defaultLayoutDeferred&&Co(y.layout,N)&&zW(y.derivedPanelConstraints,S)&&y.groupSize===_)return;Fi(e,{defaultLayoutDeferred:!1,derivedPanelConstraints:S,groupSize:_,layout:N,separatorToPanels:y.separatorToPanels})}}else BW(e,x,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=Ka({group:e}),a=I0(e),l=e.panels.map(({id:m})=>m).join(",");let c=e.mutableState.defaultLayout;c&&(FW(e.panels,c)||(c=void 0));const u=e.mutableState.layouts[l]??c??$S(a),d=Eo({layout:u,panelConstraints:a}),f=e.element.ownerDocument;Qo.set(f,(Qo.get(f)??0)+1);const p=new Map;return TR(e).forEach(m=>{m.separator&&p.set(m.separator,m.panels)}),Fi(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",jS)}),Qo.get(f)===1&&(f.addEventListener("contextmenu",IS,!0),f.addEventListener("dblclick",AS,!0),f.addEventListener("pointerdown",LS,!0),f.addEventListener("pointerleave",DS),f.addEventListener("pointermove",OS),f.addEventListener("pointerout",BS),f.addEventListener("pointerup",zS,!0)),function(){t=!1,Qo.set(f,Math.max(0,(Qo.get(f)??0)-1)),TW(e),e.separators.forEach(m=>{m.element.removeEventListener("keydown",jS)}),Qo.get(f)||(f.removeEventListener("contextmenu",IS,!0),f.removeEventListener("dblclick",AS,!0),f.removeEventListener("pointerdown",LS,!0),f.removeEventListener("pointerleave",DS),f.removeEventListener("pointermove",OS),f.removeEventListener("pointerout",BS),f.removeEventListener("pointerup",zS,!0)),s.disconnect()}}function UW(){const[e,t]=g.useState({}),n=g.useCallback(()=>t({}),[]);return[e,n]}function Py(e){const t=g.useId();return`${e??t}`}const zo=typeof window<"u"?g.useLayoutEffect:g.useEffect;function yc(e){const t=g.useRef(e);return zo(()=>{t.current=e},[e]),g.useCallback((...n)=>{var r;return(r=t.current)==null?void 0:r.call(t,...n)},[t])}function Ry(...e){return yc(t=>{e.forEach(n=>{if(n)switch(typeof n){case"function":{n(t);break}case"object":{n.current=t;break}}})})}function My(e){const t=g.useRef({...e});return zo(()=>{for(const n in e)t.current[n]=e[n]},[e]),t.current}const $R=g.createContext(null);function WW(e,t){const n=g.useRef({getLayout:()=>({}),setLayout:EW});g.useImperativeHandle(t,()=>n.current,[]),zo(()=>{Object.assign(n.current,BR({groupId:e}))})}function Ay({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=yc(M=>{Co(m.current.onLayoutChange,M)||(m.current.onLayoutChange=M,l==null||l(M))}),b=yc((M,L)=>{Co(m.current.onLayoutChanged,M)||(m.current.onLayoutChanged=M,c==null||c(M,{isUserInteraction:L}))}),x=Py(a),_=g.useRef(null),[y,S]=UW(),C=g.useRef({lastExpandedPanelSizes:{},layouts:{},panels:[],resizeTargetMinimumSize:d,separators:[]}),k=Ry(_,s);WW(x,o);const N=yc((M,L)=>{const R=ko(),A=TS(M),D=Ns(M);if(D){let $=!1;switch(R.state){case"active":{$=R.hitRegions.some(F=>F.group===A);break}}return{flexGrow:D.layout[L]??1,pointerEvents:$?"none":void 0}}if(n!=null&&n[L])return{flexGrow:n==null?void 0:n[L]}}),T=My({defaultLayout:n,disableCursor:r}),z=g.useMemo(()=>({get disableCursor(){return!!T.disableCursor},getPanelStyles:N,id:x,orientation:u,registerPanel:M=>{const L=C.current;return L.panels=P0(u,[...L.panels,M]),S(),()=>{L.panels=L.panels.filter(R=>R!==M),S()}},registerSeparator:M=>{const L=C.current;return L.separators=P0(u,[...L.separators,M]),S(),()=>{L.separators=L.separators.filter(R=>R!==M),S()}},updatePanelProps:(M,{disabled:L})=>{const R=C.current.panels.find($=>$.id===M);R&&(R.panelConstraints.disabled=L);const A=TS(x),D=Ns(x);A&&D&&Fi(A,{...D,derivedPanelConstraints:I0(A)})},updateSeparatorProps:(M,{disabled:L,disableDoubleClick:R})=>{const A=C.current.separators.find(D=>D.id===M);A&&(A.disabled=L,A.disableDoubleClick=R)}}),[N,x,S,u,T]),I=g.useRef(null);return zo(()=>{const M=_.current;if(M===null)return;const L=C.current;let R;if(T.defaultLayout!==void 0&&Object.keys(T.defaultLayout).length===L.panels.length){R={};for(const E of L.panels){const H=T.defaultLayout[E.id];H!==void 0&&(R[E.id]=H)}}const A={disabled:!!i,element:M,id:x,mutableState:{defaultLayout:R,disableCursor:!!T.disableCursor,expandedPanelSizes:C.current.lastExpandedPanelSizes,layouts:C.current.layouts},orientation:u,panels:L.panels,resizeTargetMinimumSize:L.resizeTargetMinimumSize,separators:L.separators};I.current=A;const D=HW(A),{defaultLayoutDeferred:$,derivedPanelConstraints:F,layout:O}=Ns(A.id,!0);!$&&F.length>0&&(v(O),b(O,!1));const B=Ty(x,E=>{const{defaultLayoutDeferred:H,derivedPanelConstraints:q,layout:j}=E.next;if(H||q.length===0)return;const ne=A.panels.map(({id:G})=>G).join(",");A.mutableState.layouts[ne]=j,q.forEach(G=>{if(G.collapsible){const{layout:ve}=E.prev??{};if(ve){const ze=xn(G.collapsedSize,j[G.panelId]),he=xn(G.collapsedSize,ve[G.panelId]);ze&&!he&&(A.mutableState.expandedPanelSizes[G.panelId]=ve[G.panelId])}}});const re=ko().state!=="active";v(j),re&&b(j,E.isUserInteraction)});return()=>{I.current=null,D(),B()}},[i,x,b,v,u,y,T]),g.useEffect(()=>{const M=I.current;M&&(M.mutableState.defaultLayout=n,M.mutableState.disableCursor=!!r)}),h.jsx($R.Provider,{value:z,children:h.jsx("div",{...p,className:t,"data-group":!0,"data-testid":x,id:x,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})})}Ay.displayName="Group";function jy(){const e=g.useContext($R);return rt(e,"Group Context not found; did you render a Panel or Separator outside of a Group?"),e}function VW(e,t){const{id:n}=jy(),r=g.useRef({collapse:qm,expand:qm,getSize:()=>({asPercentage:0,inPixels:0}),isCollapsed:()=>!1,resize:qm});g.useImperativeHandle(t,()=>r.current,[]),zo(()=>{Object.assign(r.current,OR({groupId:n,panelId:e}))})}function uf({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=Py(l),x=My({disabled:s}),_=g.useRef(null),y=Ry(_,o),{getPanelStyles:S,id:C,orientation:k,registerPanel:N,updatePanelProps:T}=jy(),z=d!==null,I=yc((A,D,$)=>{d==null||d(A,l,$)});zo(()=>{const A=_.current;if(A!==null){const D={element:A,id:b,idIsStable:v,mutableValues:{expandToSize:void 0,prevSize:void 0},onResize:z?I:void 0,panelConstraints:{groupResizeBehavior:a,collapsedSize:n,collapsible:r,defaultSize:i,disabled:x.disabled,maxSize:c,minSize:u}};return N(D)}},[a,n,r,i,z,b,v,c,u,I,N,x]),g.useEffect(()=>{T(b,{disabled:s})},[s,b,T]),VW(b,f);const M=()=>{const A=S(C,b);if(A)return JSON.stringify(A)},L=g.useSyncExternalStore(A=>Ty(C,A),M,M);let R;return L?R=JSON.parse(L):i!==void 0?R={flexGrow:void 0,flexShrink:void 0,flexBasis:i}:R={flexGrow:1},h.jsx("div",{...m,"data-disabled":s||void 0,"data-panel":!0,"data-testid":b,id:b,ref:y,style:{...qW,display:"flex",flexBasis:0,flexShrink:1,overflow:"visible",...R},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})})}uf.displayName="Panel";const qW={minHeight:0,maxHeight:"100%",height:"auto",minWidth:0,maxWidth:"100%",width:"auto",border:"none",borderWidth:0,padding:0,margin:0};function KW({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=Eo({layout:iu({delta:c-o,initialLayout:e,panelConstraints:t,pivotIndices:u,prevLayout:e}),panelConstraints:t})[n],i=Eo({layout:iu({delta:l-o,initialLayout:e,panelConstraints:t,pivotIndices:u,prevLayout:e}),panelConstraints:t})[n]}return{valueControls:n,valueMax:i,valueMin:s,valueNow:o}}function FR({children:e,className:t,disabled:n,disableDoubleClick:r,elementRef:i,id:s,style:o,...a}){const l=Py(s),c=My({disabled:n,disableDoubleClick:r}),[u,d]=g.useState({}),[f,p]=g.useState("inactive"),[m,v]=g.useState(!1),b=g.useRef(null),x=Ry(b,i),{disableCursor:_,id:y,orientation:S,registerSeparator:C,updateSeparatorProps:k}=jy(),N=S==="horizontal"?"vertical":"horizontal";zo(()=>{const I=b.current;if(I!==null){const M={disabled:c.disabled,disableDoubleClick:c.disableDoubleClick,element:I,id:l},L=C(M),R=kW(D=>{p(D.next.state!=="inactive"&&D.next.hitRegions.some($=>$.separator===M)?D.next.state:"inactive")}),A=Ty(y,D=>{const{derivedPanelConstraints:$,layout:F,separatorToPanels:O}=D.next,B=O.get(M);if(B){const E=B[0],H=B.indexOf(E);d(KW({layout:F,panelConstraints:$,panelId:E.id,panelIndex:H}))}});return()=>{R(),A(),L()}}},[y,l,C,c]),g.useEffect(()=>{k(l,{disabled:n,disableDoubleClick:r})},[n,r,l,k]);let T;n&&!_&&(T="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":N,"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:x,role:"separator",style:{flexBasis:"auto",cursor:T,...o,flexGrow:0,flexShrink:0,touchAction:"none"},tabIndex:n?void 0:0})}FR.displayName="Separator";function GW(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 YW(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 XW=/^Scheduled (?:recurring job|one-shot task) ([0-9a-f]{8}) \(([^)]+)\)/;function ZW(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(XW);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 QW=["TaskCreate","TaskUpdate","TaskList","TaskGet"];function JW(e){return QW.includes(e)}function HR(e){return e==="in_progress"||e==="completed"?e:"pending"}function eV(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:HR(n.status),activeForm:i,description:s}]}function tV(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=HR(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 nV(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=eV(t,i.input);break;case"TaskUpdate":t=tV(t,i.input);break}}return{tasks:t,lastEventIndex:n}}function UR(e){var n;if(e.error)return!1;if(e.pending)return!0;if(e.notifications.length>0)return!1;const t=(n=e.progress)==null?void 0:n.status;return t==="running"?!0:t==="started"?rV(e.input):!1}function rV(e){return!e||typeof e!="object"?!1:e.run_in_background===!0}function iV(e){const{tasks:t,lastEventIndex:n}=nV(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 sV=new Set(["permission-inline","question-card"]);function oV(e){return e.kind==="user-text"?!0:e.kind!=="user-meta"?!1:e.metaKind==="slash-command"||op(e.metaKind)}function aV(e){return e.kind==="user-text"&&e.continuesTurn===!0}function lV(e,t={}){const n=[];let r=null;const i=(s,o)=>{r&&(n.push(cV(r,s,o)),r=null)};for(const s of e){if(s.kind==="turn-end"){i(s,!0);continue}if(oV(s)&&(r===null||!aV(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 cV(e,t,n){const{query:r,body:i}=e,s=uV(i,t,n),o=dV(i,s),a=fV(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 uV(e,t,n){if(!n)return"running";if((t==null?void 0:t.reason)==="interrupted")return"interrupted";const r=R0(e,i=>i.kind==="error");return r>=0&&!e.slice(r+1).some(s=>s.kind==="assistant-text")?"error":"done"}function dV(e,t){if(t==="running"){const i=[];for(let s=e.length-1;s>=0&&sV.has(e[s].kind);s--)i.unshift(e[s]);return i}const n=[];e.forEach((i,s)=>{i.kind==="merged-agent"&&UR(i)&&n.push(s)});const r=t==="error"?R0(e,i=>i.kind==="error"):R0(e,i=>i.kind==="assistant-text");return r>=0&&n.push(r),n.sort((i,s)=>i-s).map(i=>e[i])}const hV=new Set(["assistant-thinking","user-meta"]);function fV(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(hV.has(o.kind)){r.push(o);continue}s(),r.push(o)}return s(),r}function R0(e,t){for(let n=e.length-1;n>=0;n--)if(t(e[n]))return n;return-1}const pV={Read:["正在读取","已读取"],Bash:["正在运行","已运行"],Grep:["正在搜索","已搜索"],Glob:["正在搜索","已搜索"],Edit:["正在编辑","已编辑"],Write:["正在写入","已写入"],WebFetch:["正在抓取","已抓取"],WebSearch:["正在搜索","已搜索"],Skill:["正在读取","已读取"]};function mV(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 WR(e){const t=pV[e.tool],n=t?e.pending?t[0]:t[1]:e.pending?`正在执行 ${e.tool}`:`已执行 ${e.tool}`,r=mV(e.input);return r?`${n} ${r}`:n}function gV({item:e,renderItemDetail:t}){const[n,r]=g.useState(!1),i=n?qn:Ln,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:oe("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(Mn,{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:WR(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 vV({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?qn:Ln;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(Mn,{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:oe("truncate min-w-0",s&&"text-text-300"),children:[WR(o),a]})]}),r?h.jsx("div",{className:"mt-0.5 flex flex-col pl-5",children:e.map(c=>h.jsx(gV,{item:c,renderItemDetail:n},c.toolUseId))}):null]})}function xV(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 _V(e,t){const n=t!==void 0?`耗时 ${xV(t)}`:"";switch(e){case"interrupted":return n?`已中断 · ${n}`:"已中断";case"error":return n?`出错 · ${n}`:"出错";default:return n||"已完成"}}function yV({status:e="done",durationMs:t,defaultExpanded:n=!1,children:r}){const[i,s]=g.useState(n),o=i?qn:Ln;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:oe("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:_V(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 bV=/<(system-reminder|related-dir|clawd-shift-fire)\b[^>]*>[\s\S]*?<\/\1>/gi,wV=/<builder-preview\b[^>]*\/>/gi,SV=/<(clawd-dispatch-task|clawd-dispatch-result)\b[^>]*>([\s\S]*?)<\/\1>/gi,kV=/<\/?(brief|detail|files)>/gi;function VR(e){return e?e.replace(SV,(t,n,r)=>RB(r.replace(kV,"")).trim()).replace(bV,"").replace(wV,"").trim():""}const CV=VR;function EV(e,t){const n={};return(e[e.length-1]===""?[...e,""]:e).join((n.padRight?" ":"")+","+(n.padLeft===!1?"":" ")).trim()}const NV=/^[$_\p{ID_Start}][$_\u{200C}\u{200D}\p{ID_Continue}]*$/u,TV=/^[$_\p{ID_Start}][-$_\u{200C}\u{200D}\p{ID_Continue}]*$/u,IV={};function FS(e,t){return(IV.jsx?TV:NV).test(e)}const PV=/[ \t\n\f\r]/g;function RV(e){return typeof e=="object"?e.type==="text"?HS(e.value):!1:HS(e)}function HS(e){return e.replace(PV,"")===""}class Mu{constructor(t,n,r){this.normal=n,this.property=t,r&&(this.space=r)}}Mu.prototype.normal={};Mu.prototype.property={};Mu.prototype.space=void 0;function qR(e,t){const n={},r={};for(const i of e)Object.assign(n,i.property),Object.assign(r,i.normal);return new Mu(n,r,t)}function M0(e){return e.toLowerCase()}class Kn{constructor(t,n){this.attribute=n,this.property=t}}Kn.prototype.attribute="";Kn.prototype.booleanish=!1;Kn.prototype.boolean=!1;Kn.prototype.commaOrSpaceSeparated=!1;Kn.prototype.commaSeparated=!1;Kn.prototype.defined=!1;Kn.prototype.mustUseProperty=!1;Kn.prototype.number=!1;Kn.prototype.overloadedBoolean=!1;Kn.prototype.property="";Kn.prototype.spaceSeparated=!1;Kn.prototype.space=void 0;let MV=0;const Me=$o(),Lt=$o(),A0=$o(),Q=$o(),at=$o(),Ma=$o(),Zn=$o();function $o(){return 2**++MV}const j0=Object.freeze(Object.defineProperty({__proto__:null,boolean:Me,booleanish:Lt,commaOrSpaceSeparated:Zn,commaSeparated:Ma,number:Q,overloadedBoolean:A0,spaceSeparated:at},Symbol.toStringTag,{value:"Module"})),Km=Object.keys(j0);class Ly extends Kn{constructor(t,n,r,i){let s=-1;if(super(t,n),US(this,"space",i),typeof r=="number")for(;++s<Km.length;){const o=Km[s];US(this,Km[s],(r&j0[o])===j0[o])}}}Ly.prototype.defined=!0;function US(e,t,n){n&&(e[t]=n)}function xl(e){const t={},n={};for(const[r,i]of Object.entries(e.properties)){const s=new Ly(r,e.transform(e.attributes||{},r),i,e.space);e.mustUseProperty&&e.mustUseProperty.includes(r)&&(s.mustUseProperty=!0),t[r]=s,n[M0(r)]=r,n[M0(s.attribute)]=r}return new Mu(t,n,e.space)}const KR=xl({properties:{ariaActiveDescendant:null,ariaAtomic:Lt,ariaAutoComplete:null,ariaBusy:Lt,ariaChecked:Lt,ariaColCount:Q,ariaColIndex:Q,ariaColSpan:Q,ariaControls:at,ariaCurrent:null,ariaDescribedBy:at,ariaDetails:null,ariaDisabled:Lt,ariaDropEffect:at,ariaErrorMessage:null,ariaExpanded:Lt,ariaFlowTo:at,ariaGrabbed:Lt,ariaHasPopup:null,ariaHidden:Lt,ariaInvalid:null,ariaKeyShortcuts:null,ariaLabel:null,ariaLabelledBy:at,ariaLevel:Q,ariaLive:null,ariaModal:Lt,ariaMultiLine:Lt,ariaMultiSelectable:Lt,ariaOrientation:null,ariaOwns:at,ariaPlaceholder:null,ariaPosInSet:Q,ariaPressed:Lt,ariaReadOnly:Lt,ariaRelevant:null,ariaRequired:Lt,ariaRoleDescription:at,ariaRowCount:Q,ariaRowIndex:Q,ariaRowSpan:Q,ariaSelected:Lt,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 GR(e,t){return t in e?e[t]:t}function YR(e,t){return GR(e,t.toLowerCase())}const AV=xl({attributes:{acceptcharset:"accept-charset",classname:"class",htmlfor:"for",httpequiv:"http-equiv"},mustUseProperty:["checked","multiple","muted","selected"],properties:{abbr:null,accept:Ma,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:Lt,controls:Me,controlsList:at,coords:Q|Ma,crossOrigin:null,data:null,dateTime:null,decoding:null,default:Me,defer:Me,dir:null,dirName:null,disabled:Me,download:A0,draggable:Lt,encType:null,enterKeyHint:null,fetchPriority:null,form:null,formAction:null,formEncType:null,formMethod:null,formNoValidate:Me,formTarget:null,headers:at,height:Q,hidden:A0,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:Lt,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:Lt,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:Lt,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:YR}),jV=xl({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:Zn,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:Ma,g2:Ma,glyphName:Ma,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:Zn,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:Zn,r:null,radius:null,referrerPolicy:null,refX:null,refY:null,rel:Zn,rev:Zn,renderingIntent:null,repeatCount:null,repeatDur:null,requiredExtensions:Zn,requiredFeatures:Zn,requiredFonts:Zn,requiredFormats:Zn,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:Zn,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:Zn,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:Zn,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:GR}),XR=xl({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()}}),ZR=xl({attributes:{xmlnsxlink:"xmlns:xlink"},properties:{xmlnsXLink:null,xmlns:null},space:"xmlns",transform:YR}),QR=xl({properties:{xmlBase:null,xmlLang:null,xmlSpace:null},space:"xml",transform(e,t){return"xml:"+t.slice(3).toLowerCase()}}),LV={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"},DV=/[A-Z]/g,WS=/-[a-z]/g,OV=/^data[-\w.:]+$/i;function BV(e,t){const n=M0(t);let r=t,i=Kn;if(n in e.normal)return e.property[e.normal[n]];if(n.length>4&&n.slice(0,4)==="data"&&OV.test(t)){if(t.charAt(4)==="-"){const s=t.slice(5).replace(WS,$V);r="data"+s.charAt(0).toUpperCase()+s.slice(1)}else{const s=t.slice(4);if(!WS.test(s)){let o=s.replace(DV,zV);o.charAt(0)!=="-"&&(o="-"+o),t="data"+o}}i=Ly}return new i(r,t)}function zV(e){return"-"+e.toLowerCase()}function $V(e){return e.charAt(1).toUpperCase()}const FV=qR([KR,AV,XR,ZR,QR],"html"),Dy=qR([KR,jV,XR,ZR,QR],"svg");function HV(e){return e.join(" ").trim()}var Oy={},VS=/\/\*[^*]*\*+([^/*][^*]*\*+)*\//g,UV=/\n/g,WV=/^\s*/,VV=/^(\*?[-#/*\\\w]+(\[[0-9a-z_-]+\])?)\s*/,qV=/^:\s*/,KV=/^((?:'(?:\\'|.)*?'|"(?:\\"|.)*?"|\([^)]*?\)|[^};])+)/,GV=/^[;\s]*/,YV=/^\s+|\s+$/g,XV=`
|
|
506
|
+
`)},sH=0,Zo=[];function oH(e){var t=g.useRef([]),n=g.useRef([0,0]),r=g.useRef(),i=g.useState(sH++)[0],s=g.useState(fP)[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=N7([e.lockRef.current],(e.shards||[]).map(_S),!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 x=Sd(v),_=n.current,y="deltaX"in v?v.deltaX:_[0]-x[0],S="deltaY"in v?v.deltaY:_[1]-x[1],C,k=v.target,N=Math.abs(y)>Math.abs(S)?"h":"v";if("touches"in v&&N==="h"&&k.type==="range")return!1;var T=window.getSelection(),z=T&&T.anchorNode,I=z?z===k||z.contains(k):!1;if(I)return!1;var M=vS(N,k);if(!M)return!0;if(M?C=N:(C=N==="v"?"h":"v",M=vS(N,k)),!M)return!1;if(!r.current&&"changedTouches"in v&&(y||S)&&(r.current=C),!C)return!0;var L=r.current||C;return nH(L,b,v,L==="h"?y:S)},[]),l=g.useCallback(function(v){var b=v;if(!(!Zo.length||Zo[Zo.length-1]!==s)){var x="deltaY"in b?xS(b):Sd(b),_=t.current.filter(function(C){return C.name===b.type&&(C.target===b.target||b.target===C.shadowParent)&&rH(C.delta,x)})[0];if(_&&_.should){b.cancelable&&b.preventDefault();return}if(!_){var y=(o.current.shards||[]).map(_S).filter(Boolean).filter(function(C){return C.contains(b.target)}),S=y.length>0?a(b,y[0]):!o.current.noIsolation;S&&b.cancelable&&b.preventDefault()}}},[]),c=g.useCallback(function(v,b,x,_){var y={name:v,delta:b,target:x,should:_,shadowParent:aH(x)};t.current.push(y),setTimeout(function(){t.current=t.current.filter(function(S){return S!==y})},1)},[]),u=g.useCallback(function(v){n.current=Sd(v),r.current=void 0},[]),d=g.useCallback(function(v){c(v.type,xS(v),v.target,a(v,e.lockRef.current))},[]),f=g.useCallback(function(v){c(v.type,Sd(v),v.target,a(v,e.lockRef.current))},[]);g.useEffect(function(){return Zo.push(s),e.setCallbacks({onScrollCapture:d,onWheelCapture:d,onTouchMoveCapture:f}),document.addEventListener("wheel",l,Xo),document.addEventListener("touchmove",l,Xo),document.addEventListener("touchstart",u,Xo),function(){Zo=Zo.filter(function(v){return v!==s}),document.removeEventListener("wheel",l,Xo),document.removeEventListener("touchmove",l,Xo),document.removeEventListener("touchstart",u,Xo)}},[]);var p=e.removeScrollBar,m=e.inert;return g.createElement(g.Fragment,null,m?g.createElement(s,{styles:iH(i)}):null,p?g.createElement(Y7,{noRelative:e.noRelative,gapMode:e.gapMode}):null)}function aH(e){for(var t=null;e!==null;)e instanceof ShadowRoot&&(t=e.host,e=e.host),e=e.parentNode;return t}const lH=D7(hP,oH);var fy=g.forwardRef(function(e,t){return g.createElement(gp,Qr({},e,{ref:t,sideCar:lH}))});fy.classNames=gp.classNames;var E0=["Enter"," "],cH=["ArrowDown","PageUp","Home"],vP=["ArrowUp","PageDown","End"],uH=[...cH,...vP],dH={ltr:[...E0,"ArrowRight"],rtl:[...E0,"ArrowLeft"]},hH={ltr:["ArrowLeft"],rtl:["ArrowRight"]},Nu="Menu",[tu,fH,pH]=EI(Nu),[Oo,xP]=Do(Nu,[pH,mp,rP]),Tu=mp(),_P=rP(),[yP,Fs]=Oo(Nu),[mH,Iu]=Oo(Nu),bP=e=>{const{__scopeMenu:t,open:n=!1,children:r,dir:i,onOpenChange:s,modal:o=!0}=e,a=Tu(t),[l,c]=g.useState(null),u=g.useRef(!1),d=di(s),f=NI(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(dy,{...a,children:h.jsx(yP,{scope:t,open:n,onOpenChange:d,content:l,onContentChange:c,children:h.jsx(mH,{scope:t,onClose:g.useCallback(()=>d(!1),[d]),isUsingKeyboardRef:u,dir:f,modal:o,children:r})})})};bP.displayName=Nu;var gH="MenuAnchor",py=g.forwardRef((e,t)=>{const{__scopeMenu:n,...r}=e,i=Tu(n);return h.jsx(JI,{...i,...r,ref:t})});py.displayName=gH;var my="MenuPortal",[vH,wP]=Oo(my,{forceMount:void 0}),SP=e=>{const{__scopeMenu:t,forceMount:n,children:r,container:i}=e,s=Fs(my,t);return h.jsx(vH,{scope:t,forceMount:n,children:h.jsx(qi,{present:n||s.open,children:h.jsx(hy,{asChild:!0,container:i,children:r})})})};SP.displayName=my;var xr="MenuContent",[xH,gy]=Oo(xr),kP=g.forwardRef((e,t)=>{const n=wP(xr,e.__scopeMenu),{forceMount:r=n.forceMount,...i}=e,s=Fs(xr,e.__scopeMenu),o=Iu(xr,e.__scopeMenu);return h.jsx(tu.Provider,{scope:e.__scopeMenu,children:h.jsx(qi,{present:r||s.open,children:h.jsx(tu.Slot,{scope:e.__scopeMenu,children:o.modal?h.jsx(_H,{...i,ref:t}):h.jsx(yH,{...i,ref:t})})})})}),_H=g.forwardRef((e,t)=>{const n=Fs(xr,e.__scopeMenu),r=g.useRef(null),i=Gt(t,r);return g.useEffect(()=>{const s=r.current;if(s)return cP(s)},[]),h.jsx(vy,{...e,ref:i,trapFocus:n.open,disableOutsidePointerEvents:n.open,disableOutsideScroll:!0,onFocusOutside:Pe(e.onFocusOutside,s=>s.preventDefault(),{checkForDefaultPrevented:!1}),onDismiss:()=>n.onOpenChange(!1)})}),yH=g.forwardRef((e,t)=>{const n=Fs(xr,e.__scopeMenu);return h.jsx(vy,{...e,ref:t,trapFocus:!1,disableOutsidePointerEvents:!1,disableOutsideScroll:!1,onDismiss:()=>n.onOpenChange(!1)})}),bH=Jc("MenuContent.ScrollLock"),vy=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=Fs(xr,n),x=Iu(xr,n),_=Tu(n),y=_P(n),S=fH(n),[C,k]=g.useState(null),N=g.useRef(null),T=Gt(t,N,b.onContentChange),z=g.useRef(0),I=g.useRef(""),M=g.useRef(0),L=g.useRef(null),R=g.useRef("right"),A=g.useRef(0),D=m?fy:g.Fragment,$=m?{as:bH,allowPinchZoom:!0}:void 0,F=B=>{var ve,ze;const E=I.current+B,H=S().filter(he=>!he.disabled),q=document.activeElement,j=(ve=H.find(he=>he.ref.current===q))==null?void 0:ve.textValue,ne=H.map(he=>he.textValue),re=AH(ne,E,j),G=(ze=H.find(he=>he.textValue===re))==null?void 0:ze.ref.current;(function he(Ie){I.current=Ie,window.clearTimeout(z.current),Ie!==""&&(z.current=window.setTimeout(()=>he(""),1e3))})(E),G&&setTimeout(()=>G.focus())};g.useEffect(()=>()=>window.clearTimeout(z.current),[]),PI();const O=g.useCallback(B=>{var H,q;return R.current===((H=L.current)==null?void 0:H.side)&&LH(B,(q=L.current)==null?void 0:q.area)},[]);return h.jsx(xH,{scope:n,searchRef:I,onItemEnter:g.useCallback(B=>{O(B)&&B.preventDefault()},[O]),onItemLeave:g.useCallback(B=>{var E;O(B)||((E=N.current)==null||E.focus(),k(null))},[O]),onTriggerLeave:g.useCallback(B=>{O(B)&&B.preventDefault()},[O]),pointerGraceTimerRef:M,onPointerGraceIntentChange:g.useCallback(B=>{L.current=B},[]),children:h.jsx(D,{...$,children:h.jsx(ny,{asChild:!0,trapped:i,onMountAutoFocus:Pe(s,B=>{var E;B.preventDefault(),(E=N.current)==null||E.focus({preventScroll:!0})}),onUnmountAutoFocus:o,children:h.jsx(up,{asChild:!0,disableOutsidePointerEvents:a,onEscapeKeyDown:c,onPointerDownOutside:u,onFocusOutside:d,onInteractOutside:f,onDismiss:p,children:h.jsx(w7,{asChild:!0,...y,dir:x.dir,orientation:"vertical",loop:r,currentTabStopId:C,onCurrentTabStopIdChange:k,onEntryFocus:Pe(l,B=>{x.isUsingKeyboardRef.current||B.preventDefault()}),preventScrollOnEntryFocus:!0,children:h.jsx(eP,{role:"menu","aria-orientation":"vertical","data-state":FP(b.open),"data-radix-menu-content":"",dir:x.dir,..._,...v,ref:T,style:{outline:"none",...v.style},onKeyDown:Pe(v.onKeyDown,B=>{const H=B.target.closest("[data-radix-menu-content]")===B.currentTarget,q=B.ctrlKey||B.altKey||B.metaKey,j=B.key.length===1;H&&(B.key==="Tab"&&B.preventDefault(),!q&&j&&F(B.key));const ne=N.current;if(B.target!==ne||!uH.includes(B.key))return;B.preventDefault();const G=S().filter(ve=>!ve.disabled).map(ve=>ve.ref.current);vP.includes(B.key)&&G.reverse(),RH(G)}),onBlur:Pe(e.onBlur,B=>{B.currentTarget.contains(B.target)||(window.clearTimeout(z.current),I.current="")}),onPointerMove:Pe(e.onPointerMove,nu(B=>{const E=B.target,H=A.current!==B.clientX;if(B.currentTarget.contains(E)&&H){const q=B.clientX>A.current?"right":"left";R.current=q,A.current=B.clientX}}))})})})})})})});kP.displayName=xr;var wH="MenuGroup",xy=g.forwardRef((e,t)=>{const{__scopeMenu:n,...r}=e;return h.jsx(Tt.div,{role:"group",...r,ref:t})});xy.displayName=wH;var SH="MenuLabel",CP=g.forwardRef((e,t)=>{const{__scopeMenu:n,...r}=e;return h.jsx(Tt.div,{...r,ref:t})});CP.displayName=SH;var af="MenuItem",yS="menu.itemSelect",vp=g.forwardRef((e,t)=>{const{disabled:n=!1,onSelect:r,...i}=e,s=g.useRef(null),o=Iu(af,e.__scopeMenu),a=gy(af,e.__scopeMenu),l=Gt(t,s),c=g.useRef(!1),u=()=>{const d=s.current;if(!n&&d){const f=new CustomEvent(yS,{bubbles:!0,cancelable:!0});d.addEventListener(yS,p=>r==null?void 0:r(p),{once:!0}),CI(d,f),f.defaultPrevented?c.current=!1:o.onClose()}};return h.jsx(EP,{...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===" "||E0.includes(d.key)&&(d.currentTarget.click(),d.preventDefault())})})});vp.displayName=af;var EP=g.forwardRef((e,t)=>{const{__scopeMenu:n,disabled:r=!1,textValue:i,...s}=e,o=gy(af,n),a=_P(n),l=g.useRef(null),c=Gt(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(tu.ItemSlot,{scope:n,disabled:r,textValue:i??f,children:h.jsx(S7,{asChild:!0,...a,focusable:!r,children:h.jsx(Tt.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,nu(m=>{r?o.onItemLeave(m):(o.onItemEnter(m),m.defaultPrevented||m.currentTarget.focus({preventScroll:!0}))})),onPointerLeave:Pe(e.onPointerLeave,nu(m=>o.onItemLeave(m))),onFocus:Pe(e.onFocus,()=>d(!0)),onBlur:Pe(e.onBlur,()=>d(!1))})})})}),kH="MenuCheckboxItem",NP=g.forwardRef((e,t)=>{const{checked:n=!1,onCheckedChange:r,...i}=e;return h.jsx(MP,{scope:e.__scopeMenu,checked:n,children:h.jsx(vp,{role:"menuitemcheckbox","aria-checked":lf(n)?"mixed":n,...i,ref:t,"data-state":by(n),onSelect:Pe(i.onSelect,()=>r==null?void 0:r(lf(n)?!0:!n),{checkForDefaultPrevented:!1})})})});NP.displayName=kH;var TP="MenuRadioGroup",[CH,EH]=Oo(TP,{value:void 0,onValueChange:()=>{}}),IP=g.forwardRef((e,t)=>{const{value:n,onValueChange:r,...i}=e,s=di(r);return h.jsx(CH,{scope:e.__scopeMenu,value:n,onValueChange:s,children:h.jsx(xy,{...i,ref:t})})});IP.displayName=TP;var PP="MenuRadioItem",RP=g.forwardRef((e,t)=>{const{value:n,...r}=e,i=EH(PP,e.__scopeMenu),s=n===i.value;return h.jsx(MP,{scope:e.__scopeMenu,checked:s,children:h.jsx(vp,{role:"menuitemradio","aria-checked":s,...r,ref:t,"data-state":by(s),onSelect:Pe(r.onSelect,()=>{var o;return(o=i.onValueChange)==null?void 0:o.call(i,n)},{checkForDefaultPrevented:!1})})})});RP.displayName=PP;var _y="MenuItemIndicator",[MP,NH]=Oo(_y,{checked:!1}),AP=g.forwardRef((e,t)=>{const{__scopeMenu:n,forceMount:r,...i}=e,s=NH(_y,n);return h.jsx(qi,{present:r||lf(s.checked)||s.checked===!0,children:h.jsx(Tt.span,{...i,ref:t,"data-state":by(s.checked)})})});AP.displayName=_y;var TH="MenuSeparator",jP=g.forwardRef((e,t)=>{const{__scopeMenu:n,...r}=e;return h.jsx(Tt.div,{role:"separator","aria-orientation":"horizontal",...r,ref:t})});jP.displayName=TH;var IH="MenuArrow",LP=g.forwardRef((e,t)=>{const{__scopeMenu:n,...r}=e,i=Tu(n);return h.jsx(tP,{...i,...r,ref:t})});LP.displayName=IH;var yy="MenuSub",[PH,DP]=Oo(yy),OP=e=>{const{__scopeMenu:t,children:n,open:r=!1,onOpenChange:i}=e,s=Fs(yy,t),o=Tu(t),[a,l]=g.useState(null),[c,u]=g.useState(null),d=di(i);return g.useEffect(()=>(s.open===!1&&d(!1),()=>d(!1)),[s.open,d]),h.jsx(dy,{...o,children:h.jsx(yP,{scope:t,open:r,onOpenChange:d,content:c,onContentChange:u,children:h.jsx(PH,{scope:t,contentId:Ai(),triggerId:Ai(),trigger:a,onTriggerChange:l,children:n})})})};OP.displayName=yy;var Jl="MenuSubTrigger",BP=g.forwardRef((e,t)=>{const n=Fs(Jl,e.__scopeMenu),r=Iu(Jl,e.__scopeMenu),i=DP(Jl,e.__scopeMenu),s=gy(Jl,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(py,{asChild:!0,...c,children:h.jsx(EP,{id:i.triggerId,"aria-haspopup":"menu","aria-expanded":n.open,"aria-controls":i.contentId,"data-state":FP(n.open),...e,ref:Su(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,nu(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,nu(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",x=b?-5:5,_=f[b?"left":"right"],y=f[b?"right":"left"];s.onPointerGraceIntentChange({area:[{x:d.clientX+x,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===" "||dH[r.dir].includes(d.key)&&(n.onOpenChange(!0),(p=n.content)==null||p.focus(),d.preventDefault())})})})});BP.displayName=Jl;var zP="MenuSubContent",$P=g.forwardRef((e,t)=>{const n=wP(xr,e.__scopeMenu),{forceMount:r=n.forceMount,...i}=e,s=Fs(xr,e.__scopeMenu),o=Iu(xr,e.__scopeMenu),a=DP(zP,e.__scopeMenu),l=g.useRef(null),c=Gt(t,l);return h.jsx(tu.Provider,{scope:e.__scopeMenu,children:h.jsx(qi,{present:r||s.open,children:h.jsx(tu.Slot,{scope:e.__scopeMenu,children:h.jsx(vy,{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=hH[o.dir].includes(u.key);d&&f&&(s.onOpenChange(!1),(p=a.trigger)==null||p.focus(),u.preventDefault())})})})})})});$P.displayName=zP;function FP(e){return e?"open":"closed"}function lf(e){return e==="indeterminate"}function by(e){return lf(e)?"indeterminate":e?"checked":"unchecked"}function RH(e){const t=document.activeElement;for(const n of e)if(n===t||(n.focus(),document.activeElement!==t))return}function MH(e,t){return e.map((n,r)=>e[(t+r)%e.length])}function AH(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=MH(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 jH(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 LH(e,t){if(!t)return!1;const n={x:e.clientX,y:e.clientY};return jH(n,t)}function nu(e){return t=>t.pointerType==="mouse"?e(t):void 0}var DH=bP,OH=py,BH=SP,zH=kP,$H=xy,FH=CP,HH=vp,UH=NP,WH=IP,VH=RP,qH=AP,KH=jP,GH=LP,YH=OP,XH=BP,ZH=$P,xp="DropdownMenu",[QH]=Do(xp,[xP]),Sn=xP(),[JH,HP]=QH(xp),UP=e=>{const{__scopeDropdownMenu:t,children:n,dir:r,open:i,defaultOpen:s,onOpenChange:o,modal:a=!0}=e,l=Sn(t),c=g.useRef(null),[u,d]=ku({prop:i,defaultProp:s??!1,onChange:o,caller:xp});return h.jsx(JH,{scope:t,triggerId:Ai(),triggerRef:c,contentId:Ai(),open:u,onOpenChange:d,onOpenToggle:g.useCallback(()=>d(f=>!f),[d]),modal:a,children:h.jsx(DH,{...l,open:u,onOpenChange:d,dir:r,modal:a,children:n})})};UP.displayName=xp;var WP="DropdownMenuTrigger",VP=g.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,disabled:r=!1,...i}=e,s=HP(WP,n),o=Sn(n);return h.jsx(OH,{asChild:!0,...o,children:h.jsx(Tt.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:Su(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())})})})});VP.displayName=WP;var eU="DropdownMenuPortal",qP=e=>{const{__scopeDropdownMenu:t,...n}=e,r=Sn(t);return h.jsx(BH,{...r,...n})};qP.displayName=eU;var KP="DropdownMenuContent",GP=g.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,i=HP(KP,n),s=Sn(n),o=g.useRef(!1);return h.jsx(zH,{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)"}})});GP.displayName=KP;var tU="DropdownMenuGroup",nU=g.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,i=Sn(n);return h.jsx($H,{...i,...r,ref:t})});nU.displayName=tU;var rU="DropdownMenuLabel",YP=g.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,i=Sn(n);return h.jsx(FH,{...i,...r,ref:t})});YP.displayName=rU;var iU="DropdownMenuItem",XP=g.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,i=Sn(n);return h.jsx(HH,{...i,...r,ref:t})});XP.displayName=iU;var sU="DropdownMenuCheckboxItem",ZP=g.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,i=Sn(n);return h.jsx(UH,{...i,...r,ref:t})});ZP.displayName=sU;var oU="DropdownMenuRadioGroup",aU=g.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,i=Sn(n);return h.jsx(WH,{...i,...r,ref:t})});aU.displayName=oU;var lU="DropdownMenuRadioItem",cU=g.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,i=Sn(n);return h.jsx(VH,{...i,...r,ref:t})});cU.displayName=lU;var uU="DropdownMenuItemIndicator",QP=g.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,i=Sn(n);return h.jsx(qH,{...i,...r,ref:t})});QP.displayName=uU;var dU="DropdownMenuSeparator",JP=g.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,i=Sn(n);return h.jsx(KH,{...i,...r,ref:t})});JP.displayName=dU;var hU="DropdownMenuArrow",fU=g.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,i=Sn(n);return h.jsx(GH,{...i,...r,ref:t})});fU.displayName=hU;var pU=e=>{const{__scopeDropdownMenu:t,children:n,open:r,onOpenChange:i,defaultOpen:s}=e,o=Sn(t),[a,l]=ku({prop:r,defaultProp:s??!1,onChange:i,caller:"DropdownMenuSub"});return h.jsx(YH,{...o,open:a,onOpenChange:l,children:n})},mU="DropdownMenuSubTrigger",eR=g.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,i=Sn(n);return h.jsx(XH,{...i,...r,ref:t})});eR.displayName=mU;var gU="DropdownMenuSubContent",tR=g.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,i=Sn(n);return h.jsx(ZH,{...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)"}})});tR.displayName=gU;var vU=UP,xU=VP,nR=qP,rR=GP,iR=YP,sR=XP,oR=ZP,_U=QP,aR=JP,yU=pU,lR=eR,cR=tR;const wy=vU,Sy=xU,_p=g.forwardRef(({className:e,sideOffset:t=4,...n},r)=>h.jsx(nR,{children:h.jsx(rR,{ref:r,sideOffset:t,className:oe("z-50 min-w-[8rem] overflow-hidden rounded-md border border-border bg-elevated p-1","text-text-100 shadow-md",e),...n})}));_p.displayName=rR.displayName;const bU=yU,uR=g.forwardRef(({className:e,...t},n)=>h.jsx(lR,{ref:n,className:oe("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}));uR.displayName=lR.displayName;const dR=g.forwardRef(({className:e,...t},n)=>h.jsx(nR,{children:h.jsx(cR,{ref:n,className:oe("z-50 min-w-[6rem] overflow-hidden rounded-md border border-border bg-elevated p-1","text-text-100 shadow-md",e),...t})}));dR.displayName=cR.displayName;const Ci=g.forwardRef(({className:e,inset:t,...n},r)=>h.jsx(sR,{ref:r,className:oe("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}));Ci.displayName=sR.displayName;const wU=g.forwardRef(({className:e,children:t,checked:n,...r},i)=>h.jsxs(oR,{ref:i,checked:n,className:oe("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(_U,{children:h.jsx(ml,{className:"h-3.5 w-3.5"})})}),t]}));wU.displayName=oR.displayName;const hR=g.forwardRef(({className:e,...t},n)=>h.jsx(aR,{ref:n,className:oe("-mx-1 my-1 h-px bg-border",e),...t}));hR.displayName=aR.displayName;const SU=g.forwardRef(({className:e,...t},n)=>h.jsx(iR,{ref:n,className:oe("px-2 py-1.5 text-xs font-semibold text-text-400",e),...t}));SU.displayName=iR.displayName;function kU({tool:e,className:t}){const n=gF(e);return h.jsx("span",{"data-testid":n?`session-icon-${e}`:"session-icon-default","aria-label":n?ey(e):"未知引擎",className:oe("w-3.5 h-3.5 shrink-0 inline-flex items-center justify-center",wu(e),t),children:h.jsx(bu,{tool:e,className:"w-full h-full"})})}function CU({sessionId:e,hasUnread:t,running:n=!1,awaitingUser:r=!1,style:i}){return r?h.jsx(Fz,{"data-testid":`awaiting-dot-${e}`,style:i,className:"w-3 h-3 text-warning shrink-0 animate-pulse",strokeWidth:2.25,"aria-label":"awaiting user"}):t?h.jsx("span",{"data-testid":`unread-dot-${e}`,style:i,className:"w-2 h-2 rounded-full bg-error shrink-0","aria-label":"unread"}):n?h.jsx("span",{"data-testid":`running-dot-${e}`,style:i,className:"w-2 h-2 rounded-full bg-success shrink-0 animate-pulse","aria-label":"running"}):null}function fR(e){return e.compositionActive||!!e.nativeIsComposing||e.keyCode===229}function pR(e){return e.key==="Enter"&&!e.shiftKey&&!fR(e)}function Pu(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(pR({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 EU({open:e,initialLabel:t,placeholder:n,onSubmit:r,onCancel:i,title:s="Edit session",fieldLabel:o="Label",testId:a="session-edit-dialog",requireNonEmpty:l=!1}){const[c,u]=g.useState(t);g.useEffect(()=>{e&&u(t)},[e,t]);const d=c.trim(),f=l&&d==="",p=()=>{f||r({label:d})},m=Pu(p,i);return e?ol.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":`${a}-overlay`,children:h.jsxs("div",{"data-testid":a,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:v=>v.stopPropagation(),children:[h.jsx("div",{className:"text-[15px] font-semibold text-text-100",children:s}),h.jsxs("div",{children:[h.jsx("label",{className:"block text-[12px] font-semibold text-text-200 mb-1",children:o}),h.jsx("input",{autoFocus:!0,type:"text",value:c,onChange:v=>u(v.target.value),...m,placeholder:n,"data-testid":`${a}-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:p,disabled:f,"data-testid":`${a}-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 disabled:cursor-not-allowed disabled:opacity-40",children:"Save"})]})]})}),document.body):null}var NU=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"}),TU="VisuallyHidden",mR=g.forwardRef((e,t)=>h.jsx(Tt.span,{...e,ref:t,style:{...NU,...e.style}}));mR.displayName=TU;var IU=mR,[yp]=Do("Tooltip",[mp]),bp=mp(),gR="TooltipProvider",PU=700,N0="tooltip.open",[RU,ky]=yp(gR),vR=e=>{const{__scopeTooltip:t,delayDuration:n=PU,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(RU,{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})};vR.displayName=gR;var ru="Tooltip",[MU,wp]=yp(ru),xR=e=>{const{__scopeTooltip:t,children:n,open:r,defaultOpen:i,onOpenChange:s,disableHoverableContent:o,delayDuration:a}=e,l=ky(ru,e.__scopeTooltip),c=bp(t),[u,d]=g.useState(null),f=Ai(),p=g.useRef(0),m=o??l.disableHoverableContent,v=a??l.delayDuration,b=g.useRef(!1),[x,_]=ku({prop:r,defaultProp:i??!1,onChange:N=>{N?(l.onOpen(),document.dispatchEvent(new CustomEvent(N0))):l.onClose(),s==null||s(N)},caller:ru}),y=g.useMemo(()=>x?b.current?"delayed-open":"instant-open":"closed",[x]),S=g.useCallback(()=>{window.clearTimeout(p.current),p.current=0,b.current=!1,_(!0)},[_]),C=g.useCallback(()=>{window.clearTimeout(p.current),p.current=0,_(!1)},[_]),k=g.useCallback(()=>{window.clearTimeout(p.current),p.current=window.setTimeout(()=>{b.current=!0,_(!0),p.current=0},v)},[v,_]);return g.useEffect(()=>()=>{p.current&&(window.clearTimeout(p.current),p.current=0)},[]),h.jsx(dy,{...c,children:h.jsx(MU,{scope:t,contentId:f,open:x,stateAttribute:y,trigger:u,onTriggerChange:d,onTriggerEnter:g.useCallback(()=>{l.isOpenDelayedRef.current?k():S()},[l.isOpenDelayedRef,k,S]),onTriggerLeave:g.useCallback(()=>{m?C():(window.clearTimeout(p.current),p.current=0)},[C,m]),onOpen:S,onClose:C,disableHoverableContent:m,children:n})})};xR.displayName=ru;var T0="TooltipTrigger",_R=g.forwardRef((e,t)=>{const{__scopeTooltip:n,...r}=e,i=wp(T0,n),s=ky(T0,n),o=bp(n),a=g.useRef(null),l=Gt(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(JI,{asChild:!0,...o,children:h.jsx(Tt.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)})})});_R.displayName=T0;var AU="TooltipPortal",[Boe,jU]=yp(AU,{forceMount:void 0}),qa="TooltipContent",yR=g.forwardRef((e,t)=>{const n=jU(qa,e.__scopeTooltip),{forceMount:r=n.forceMount,side:i="top",...s}=e,o=wp(qa,e.__scopeTooltip);return h.jsx(qi,{present:r||o.open,children:o.disableHoverableContent?h.jsx(bR,{side:i,...s,ref:t}):h.jsx(LU,{side:i,...s,ref:t})})}),LU=g.forwardRef((e,t)=>{const n=wp(qa,e.__scopeTooltip),r=ky(qa,e.__scopeTooltip),i=g.useRef(null),s=Gt(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={x:m.clientX,y:m.clientY},_=$U(x,b.getBoundingClientRect()),y=FU(x,_),S=HU(v.getBoundingClientRect()),C=WU([...y,...S]);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={x:v.clientX,y:v.clientY},_=(l==null?void 0:l.contains(b))||(u==null?void 0:u.contains(b)),y=!UU(x,o);_?f():y&&(f(),c())};return document.addEventListener("pointermove",m),()=>document.removeEventListener("pointermove",m)}},[l,u,o,c,f]),h.jsx(bR,{...e,ref:s})}),[DU,OU]=yp(ru,{isInside:!1}),BU=EF("TooltipContent"),bR=g.forwardRef((e,t)=>{const{__scopeTooltip:n,children:r,"aria-label":i,onEscapeKeyDown:s,onPointerDownOutside:o,...a}=e,l=wp(qa,n),c=bp(n),{onClose:u}=l;return g.useEffect(()=>(document.addEventListener(N0,u),()=>document.removeEventListener(N0,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(up,{asChild:!0,disableOutsidePointerEvents:!1,onEscapeKeyDown:s,onPointerDownOutside:o,onFocusOutside:d=>d.preventDefault(),onDismiss:u,children:h.jsxs(eP,{"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(BU,{children:r}),h.jsx(DU,{scope:n,isInside:!0,children:h.jsx(IU,{id:l.contentId,role:"tooltip",children:i||r})})]})})});yR.displayName=qa;var wR="TooltipArrow",zU=g.forwardRef((e,t)=>{const{__scopeTooltip:n,...r}=e,i=bp(n);return OU(wR,n).isInside?null:h.jsx(tP,{...i,...r,ref:t})});zU.displayName=wR;function $U(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 FU(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 HU(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 UU(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 WU(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),VU(t)}function VU(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 qU=vR,KU=xR,GU=_R,SR=yR;const cf=qU,Sp=KU,kp=GU,Ru=g.forwardRef(({className:e,sideOffset:t=4,...n},r)=>h.jsx(SR,{ref:r,sideOffset:t,className:oe("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}));Ru.displayName=SR.displayName;const YU={held:!1,indexBySessionId:new Map},XU=g.createContext(YU);function ZU(){return g.useContext(XU)}const QU=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})),JU=[{id:"new-session",combo:{key:"n",mod:!0},label:"新建任务",description:"打开快捷新建弹窗",group:"通用",desktopOnly:!0},...QU,{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}];JU.filter(e=>!e.displayOnly);function eW(){return/Mac|iP(hone|od|ad)/.test(navigator.platform)}const tW=10,nW=20,rW=16,iW=20,sW=60,oW=4;function kd({testId:e,label:t,children:n}){return h.jsxs(Sp,{children:[h.jsx(kp,{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(Ru,{side:"bottom",children:t})]})}function aW({session:e,active:t,hasUnread:n,running:r=!1,awaitingUser:i=!1,onSelect:s,onEdit:o,onDelete:a,onPin:l,onArchive:c,quickAction:u,depth:d=0,chevron:f,showCopyResume:p=!0,contactDisplayName:m,ownerPrincipalId:v,creatorDisplayName:b,dispatchedFromSessionTitle:x}){const[_,y]=g.useState(!1),S=ZU(),C=S.held?S.indexBySessionId.get(e.sessionId):void 0,k=!!e.pinnedAt,N=d===0,T=d===0&&!!c,z=tW+d*nW;let I=null;u==="pin"&&N&&l?I={icon:k?h.jsx(Fw,{className:"w-4 h-4"}):h.jsx(Hw,{className:"w-4 h-4"}),label:k?"取消置顶":"置顶",run:()=>l(e.sessionId,!k)}:u==="archive"&&T&&c?I={icon:h.jsx(zw,{className:"w-4 h-4"}),label:"归档",run:()=>c(e.sessionId,!0)}:u==="rename"&&o&&(I={icon:h.jsx(v0,{className:"w-4 h-4"}),label:"重命名",run:()=>y(!0)});const M=g.useCallback(async()=>{const $=SI(e);if($)try{await navigator.clipboard.writeText($)}catch{}},[e]),L=ty(e),R=e.originOwnerPrincipalId,A=R?`@${m??`…${R.slice(-8)}`}`:null,D=!!(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:`${rW}px ${iW}px 1fr auto ${sW}px`,gridTemplateAreas:'"chev icon name dot time"',columnGap:`${oW}px`,alignItems:"center"},className:oe("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(kU,{tool:e.tool})}),h.jsxs("div",{style:{gridArea:"name"},className:"flex items-center gap-1 min-w-0",children:[h.jsxs(cf,{delayDuration:200,skipDelayDuration:100,children:[e.dispatchedFromSessionId?h.jsx(kd,{testId:`dispatched-icon-${e.sessionId}`,label:`来自【${x??"另一会话"}】dispatch`,children:h.jsx(l$,{"aria-hidden":"true",className:"w-3 h-3 text-accent",strokeWidth:2.25})}):null,e.shiftFiredFromSessionId?h.jsx(kd,{testId:`shift-fired-icon-${e.sessionId}`,label:"定时任务",children:h.jsx(jz,{"aria-hidden":"true",className:"w-3 h-3 text-accent",strokeWidth:2.25})}):null,e.larkChatId?h.jsx(kd,{testId:`lark-chat-icon-${e.sessionId}`,label:e.larkChatType==="p2p"?"来自飞书DM":"来自飞书群",children:h.jsx(L$,{"aria-hidden":"true",className:"w-3 h-3 text-accent",strokeWidth:2.25})}):null,D?h.jsx(kd,{testId:`guest-created-icon-${e.sessionId}`,label:b?`${b}创建`:"其他人创建",children:h.jsx(x8,{"aria-hidden":"true",className:"w-3 h-3 text-accent",strokeWidth:2.25})}):null]}),h.jsx("span",{"data-testid":`session-title-${e.sessionId}`,className:oe("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:L}),A?h.jsx("span",{"data-testid":`session-mirror-chip-${e.sessionId}`,title:`在 ${A.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:A}):null]}),h.jsx(CU,{sessionId:e.sessionId,hasUnread:n,running:r,awaitingUser:i,style:{gridArea:"dot"}}),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:eW()?`⌘${C}`:`Ctrl+${C}`})}):h.jsx("span",{style:{gridArea:"time"},className:oe("text-[11px] text-text-400/70 text-right shrink-0","transition-opacity duration-150 group-hover:opacity-0"),children:e.updatedAt?vF(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:[I?h.jsx(cf,{delayDuration:200,skipDelayDuration:100,children:h.jsxs(Sp,{children:[h.jsx(kp,{asChild:!0,children:h.jsx("button",{type:"button",onClick:$=>{$.stopPropagation(),I.run()},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":I.label,"data-testid":`quick-action-${u}-${e.sessionId}`,children:I.icon})}),h.jsx(Ru,{side:"bottom",children:I.label})]})}):null,h.jsxs(wy,{modal:!1,children:[h.jsx(Sy,{asChild:!0,children:h.jsx("button",{type:"button",onClick:$=>$.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(QT,{className:"w-4 h-4"})})}),h.jsxs(_p,{align:"end",onClick:$=>$.stopPropagation(),children:[l&&N&&h.jsxs(Ci,{onSelect:()=>l(e.sessionId,!k),"data-testid":`session-${k?"unpin":"pin"}-${e.sessionId}`,children:[k?h.jsx(Fw,{className:"w-3 h-3 mr-2 text-text-400"}):h.jsx(Hw,{className:"w-3 h-3 mr-2 text-text-400"}),k?"Unpin":"Pin"]}),T&&c&&h.jsxs(Ci,{onSelect:()=>c(e.sessionId,!0),"data-testid":`session-archive-${e.sessionId}`,children:[h.jsx(zw,{className:"w-3 h-3 mr-2 text-text-400"}),"Archive"]}),o&&h.jsxs(Ci,{onSelect:()=>y(!0),"data-testid":`session-rename-${e.sessionId}`,children:[h.jsx(v0,{className:"w-3 h-3 mr-2 text-text-400"}),"Rename"]}),p&&e.toolSessionId?h.jsxs(Ci,{onSelect:()=>void M(),"data-testid":`session-copy-resume-${e.sessionId}`,children:[h.jsx(cp,{className:"w-3 h-3 mr-2 text-text-400"}),"Copy Resume Command"]}):null,(l||o||p&&e.toolSessionId)&&a&&h.jsx(hR,{}),a&&h.jsxs(Ci,{onSelect:()=>void a(e.sessionId),className:"text-destructive focus:text-destructive focus:bg-destructive/10","data-testid":`session-delete-${e.sessionId}`,children:[h.jsx(Z_,{className:"w-3 h-3 mr-2"}),"Delete"]})]})]})]}):null]}),o?h.jsx(EU,{open:_,initialLabel:e.label??"",placeholder:e.cwd.split("/").pop()||"",onSubmit:$=>{o(e.sessionId,$),y(!1)},onCancel:()=>y(!1)}):null]})}function Cy({node:e,depth:t=0,activeId:n,unreadIds:r,runningIds:i,awaitingIds:s,onSelect:o,onEdit:a,onDelete:l,onPin:c,onArchive:u,quickAction:d,getContactDisplayName:f,showCopyResume:p,ownerPrincipalId:m,getCreatorDisplayName:v,getSessionDisplayName:b,parentSession:x}){const _=e.children.length>0,{isCollapsed:y,toggle:S}=Nz(),C=!y(e.session.sessionId),k=g.useCallback(T=>{T.stopPropagation(),S(e.session.sessionId)},[S,e.session.sessionId]),N=_?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(qn,{className:"w-3 h-3"}):h.jsx(Ln,{className:"w-3 h-3"})}):null;return h.jsxs("div",{"data-testid":`session-tree-node-${e.session.sessionId}`,children:[h.jsx(aW,{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,quickAction: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))??((x==null?void 0:x.sessionId)===e.session.dispatchedFromSessionId?ty(x):void 0):void 0,depth:t,chevron:N,contactDisplayName:e.session.originOwnerPrincipalId?f==null?void 0:f(e.session.originOwnerPrincipalId):void 0}),_&&C?h.jsx("div",{"data-testid":`session-tree-children-${e.session.sessionId}`,children:e.children.map(T=>h.jsx(Cy,{node:T,depth:t+1,activeId:n,unreadIds:r,runningIds:i,awaitingIds:s,onSelect:o,onEdit:a,onDelete:l,onPin:c,onArchive:u,quickAction:d,getContactDisplayName:f,showCopyResume:p,ownerPrincipalId:m,getCreatorDisplayName:v,getSessionDisplayName:b,parentSession:e.session},T.session.sessionId))}):null]})}function lW(e){return e.forkedFromSessionId??e.dispatchedFromSessionId??e.shiftFiredFromSessionId}function kR(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=lW(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(cW).map(i)}function CR(e){return[...e].sort((t,n)=>t.session.updatedAt<n.session.updatedAt?1:t.session.updatedAt>n.session.updatedAt?-1:0)}function cW(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 uW(e){return e.appBuilderProject?`[app] ${e.appBuilderProject}`:e.label?e.label:e.aiLabel?e.aiLabel:e.cwd.split("/").filter(Boolean).pop()??""}function bS(e,t){const n=t.trim().toLowerCase();return n===""?!0:e.toLowerCase().includes(n)}const dW={isCollapsed:()=>!1,toggle:()=>{},prune:()=>{}};function hW({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:x,treatSessionsAsRoots:_,searchQuery:y}){const[S,C]=g.useState(null),[k,N]=g.useState(()=>new Set),T=p??(D=>k.has(D)),z=g.useCallback(D=>{if(m){m(D);return}N($=>{const F=new Set($);return F.has(D)?F.delete(D):F.add(D),F})},[m]),I=g.useMemo(()=>i==null?void 0:i.filter(D=>!D.ephemeral),[i]),M=g.useMemo(()=>new Map((I??[]).map(D=>[D.sessionId,ty(D)])),[I]),L=g.useCallback(D=>f==null?void 0:f.get(D),[f]),R=g.useCallback(D=>M.get(D),[M]);if(e.length===0)return h.jsx(fW,{});const A=(y??"").trim();return A?h.jsx(G_.Provider,{value:dW,children:h.jsx("div",{"data-testid":"my-personas-list",className:"flex flex-col gap-0.5",children:e.map(D=>{const $=I?I.filter(E=>E.ownerPersonaId===D.personaId).sort((E,H)=>H.updatedAt>E.updatedAt?1:-1):[],F=bS(D.label,A),O=$.filter(E=>bS(uW(E),A));if(!F&&O.length===0)return null;const B=F?$:O;return h.jsx(wS,{persona:D,active:D.personaId===t,editing:!1,onSelectPersona:n,onSubmitCreateSession:()=>{},onCancelCreateSession:()=>{},personaSessions:B,collapsed:!1,onToggleCollapsed:()=>{},activeSessionId:s??null,awaitingIds:o,runningIds:a,unreadIds:l,onSelectSession:c,onDeleteSession:u,onEditSession:v,onPinSession:b,showCopyResume:x,treatSessionsAsRoots:_,ownerPrincipalId:d,creatorDisplayNameByOwnerId:f,getCreatorDisplayName:L,getSessionDisplayName:R},D.personaId)})})}):h.jsx("div",{"data-testid":"my-personas-list",className:"flex flex-col gap-0.5",children:e.map(D=>{const $=I?I.filter(F=>F.ownerPersonaId===D.personaId).sort((F,O)=>O.updatedAt>F.updatedAt?1:-1):[];return h.jsx(wS,{persona:D,active:D.personaId===t,editing:D.personaId===S,onSelectPersona:n,onStartCreateSession:r?()=>C(D.personaId):void 0,onSubmitCreateSession:F=>{C(null),r==null||r(D.personaId,F)},onCancelCreateSession:()=>C(null),personaSessions:$,collapsed:!T(D.personaId),onToggleCollapsed:()=>z(D.personaId),activeSessionId:s??null,awaitingIds:o,runningIds:a,unreadIds:l,onSelectSession:c,onDeleteSession:u,onEditSession:v,onPinSession:b,showCopyResume:x,treatSessionsAsRoots:_,ownerPrincipalId:d,creatorDisplayNameByOwnerId:f,getCreatorDisplayName:L,getSessionDisplayName:R},D.personaId)})})}function fW(){return h.jsx("div",{className:"px-3 py-3 text-[11px] leading-relaxed text-text-400",children:"还没有 persona。点上方 Personas 标题右侧 + 创建第一个。"})}function wS({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:x,showCopyResume:_,treatSessionsAsRoots:y,ownerPrincipalId:S,creatorDisplayNameByOwnerId:C,getCreatorDisplayName:k,getSessionDisplayName:N}){const T=a.length>0,z=!l,I=g.useMemo(()=>{const R=[],A=new Map;for(const D of a){const $=D.creatorPrincipalId;if(D.larkChatId!=null||!$||S&&$===S){R.push(D);continue}const F=$,O=(C==null?void 0:C.get(F))??`…${F.slice(-8)}`,B=A.get(F);B?B.sessions.push(D):A.set(F,{groupKey:F,displayName:O,sessions:[D]})}return{self:R,byPeer:[...A.values()]}},[a,S,C]),M=I.byPeer.length>0,L=g.useMemo(()=>z&&!M?CR(kR(a)):[],[z,M,a]);return h.jsxs("div",{"data-testid":`persona-node-${e.personaId}`,children:[h.jsxs("div",{className:oe("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:[T?h.jsx("button",{type:"button",onClick:R=>{R.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(qn,{className:"h-3 w-3"}):h.jsx(Ln,{className:"h-3 w-3"})}):h.jsx("span",{className:"h-4 w-4 shrink-0","aria-hidden":"true"}),h.jsx(bu,{tool:e.tool,className:oe("h-3.5 w-3.5 shrink-0",wu(e.tool))}),h.jsx("span",{className:"flex-1 truncate text-[13px]",children:e.label}),T?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:R=>{R.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(G$,{className:"h-3.5 w-3.5"})}):null]}),n?h.jsx(pW,{personaId:e.personaId,tool:e.tool,onSubmit:s,onCancel:o}):null,T&&z?h.jsx("div",{"data-testid":`persona-sessions-${e.personaId}`,children:M?h.jsxs(h.Fragment,{children:[I.self.length>0&&h.jsx(SS,{groupKey:`${e.personaId}-self`,label:"我自己",testId:`persona-sessions-${e.personaId}-self`,sessions:I.self,activeSessionId:u,awaitingIds:d,runningIds:f,unreadIds:p,onSelectSession:m,onDeleteSession:v,onEditSession:b,onPinSession:x,showCopyResume:_,ownerPrincipalId:S,getCreatorDisplayName:k,getSessionDisplayName:N}),I.byPeer.map(R=>h.jsx(SS,{groupKey:`${e.personaId}-peer-${R.groupKey}`,label:R.displayName,testId:`persona-sessions-${e.personaId}-peer-${R.groupKey}`,sessions:R.sessions,activeSessionId:u,awaitingIds:d,runningIds:f,unreadIds:p,onSelectSession:m,onDeleteSession:v,onEditSession:b,onPinSession:x,showCopyResume:_,ownerPrincipalId:S,getCreatorDisplayName:k,getSessionDisplayName:N},`${e.personaId}-peer-${R.groupKey}`))]}):L.map(R=>h.jsx(Cy,{node:R,depth:y?0:1,activeId:u,unreadIds:p,runningIds:f,awaitingIds:d,onSelect:A=>m==null?void 0:m(A),onDelete:v,onEdit:b,onPin:x,showCopyResume:_,ownerPrincipalId:S,getCreatorDisplayName:k,getSessionDisplayName:N},R.session.sessionId))}):null]})}function SS({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),x=!v,_=g.useMemo(()=>x?CR(kR(n)):[],[x,n]);return h.jsxs("div",{"data-testid":t,children:[h.jsxs("button",{type:"button",onClick:()=>b(y=>!y),"aria-label":x?"collapse":"expand","aria-expanded":x,"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:[x?h.jsx(qn,{className:"h-3 w-3"}):h.jsx(Ln,{className:"h-3 w-3"}),h.jsx(sI,{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})]}),x&&h.jsx("div",{children:_.map(y=>h.jsx(Cy,{node:y,depth:2,activeId:r,unreadIds:o,runningIds:s,awaitingIds:i,onSelect:S=>a==null?void 0:a(S),onDelete:l,onEdit:c,onPin:u,showCopyResume:d,ownerPrincipalId:f,getCreatorDisplayName:p,getSessionDisplayName:m},y.session.sessionId))})]})}function pW({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=Pu(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(bu,{tool:t,className:oe("h-3 w-3 shrink-0",wu(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(ml,{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(zr,{className:"h-3 w-3"})})]})}function mW(e,t){const n=getComputedStyle(e),r=parseFloat(n.fontSize);return t*r}function gW(e,t){const n=getComputedStyle(e.ownerDocument.documentElement),r=parseFloat(n.fontSize);return t*r}function vW(e){return e/100*window.innerHeight}function xW(e){return e/100*window.innerWidth}function _W(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 ec({groupSize:e,panelElement:t,styleProp:n}){let r;const[i,s]=_W(n);switch(s){case"%":{r=i/100*e;break}case"px":{r=i;break}case"rem":{r=gW(t,i);break}case"em":{r=mW(t,i);break}case"vh":{r=vW(i);break}case"vw":{r=xW(i);break}}return r}function In(e){return parseFloat(e.toFixed(3))}function Ka({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 I0(e){const{panels:t}=e,n=Ka({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=ec({groupSize:n,panelElement:i,styleProp:s.collapsedSize});o=In(u/n*100)}let a;if(s.defaultSize!==void 0){const u=ec({groupSize:n,panelElement:i,styleProp:s.defaultSize});a=In(u/n*100)}let l=0;if(s.minSize!==void 0){const u=ec({groupSize:n,panelElement:i,styleProp:s.minSize});l=In(u/n*100)}let c=100;if(s.maxSize!==void 0){const u=ec({groupSize:n,panelElement:i,styleProp:s.maxSize});c=In(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 P0(e,t){return Array.from(t).sort(e==="horizontal"?yW:bW)}function yW(e,t){const n=e.element.offsetLeft-t.element.offsetLeft;return n!==0?n:e.element.offsetWidth-t.element.offsetWidth}function bW(e,t){const n=e.element.offsetTop-t.element.offsetTop;return n!==0?n:e.element.offsetHeight-t.element.offsetHeight}function ER(e){return e!==null&&typeof e=="object"&&"nodeType"in e&&e.nodeType===Node.ELEMENT_NODE}function NR(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 wW({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}=NR(r,o),c=e==="horizontal"?a:l;c<s&&(s=c,i=o)}return rt(i,"No rect found"),i}let Cd;function SW(){return Cd===void 0&&(typeof matchMedia=="function"?Cd=!!matchMedia("(pointer:coarse)").matches:Cd=!1),Cd}function TR(e){const{element:t,orientation:n,panels:r,separators:i}=e,s=P0(n,Array.from(t.children).filter(ER).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(x=>x.element===v);if(b){if(f){const x=f.element.getBoundingClientRect(),_=v.getBoundingClientRect();let y;if(l){const S=n==="horizontal"?new DOMRect(x.right,x.top,0,x.height):new DOMRect(x.left,x.bottom,x.width,0),C=n==="horizontal"?new DOMRect(_.left,_.top,0,_.height):new DOMRect(_.left,_.top,_.width,0);switch(p.length){case 0:{y=[S,C];break}case 1:{const k=p[0],N=wW({orientation:n,rects:[x,_],targetRect:k.element.getBoundingClientRect()});y=[k,N===x?C:S];break}default:{y=p;break}}}else p.length?y=p:y=[n==="horizontal"?new DOMRect(x.right,_.top,_.left-x.right,_.height):new DOMRect(_.left,x.bottom,_.width,_.top-x.bottom)];for(const S of y){let C="width"in S?S:S.element.getBoundingClientRect();const k=SW()?e.resizeTargetMinimumSize.coarse:e.resizeTargetMinimumSize.fine;if(C.width<k){const T=k-C.width;C=new DOMRect(C.x-T/2,C.y,C.width+T,C.height)}if(C.height<k){const T=k-C.height;C=new DOMRect(C.x,C.y-T/2,C.width,C.height+T)}const N=m<=c||m>u;!a&&!N&&o.push({group:e,groupSize:Ka({group:e}),panels:[f,b],separator:"width"in S?void 0:S,rect:C}),a=!1}}l=!1,f=b,p=[]}}else if(v.hasAttribute("data-separator")){v.ariaDisabled!==null&&(a=!0);const b=i.find(x=>x.element===v);b?p.push(b):(f=void 0,p=[])}else l=!0}return o}var hs;class IR{constructor(){E1(this,hs,{})}addListener(t,n){const r=Nl(this,hs)[t];return r===void 0?Nl(this,hs)[t]=[n]:r.includes(n)||r.push(n),()=>{this.removeListener(t,n)}}emit(t,n){const r=Nl(this,hs)[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(){N1(this,hs,{})}removeListener(t,n){const r=Nl(this,hs)[t];if(r!==void 0){const i=r.indexOf(n);i>=0&&r.splice(i,1)}}}hs=new WeakMap;let Pa={cursorFlags:0,state:"inactive"};const Ey=new IR;function ko(){return Pa}function kW(e){return Ey.addListener("change",e)}function CW(e){const t=Pa,n={...Pa};n.cursorFlags=e,Pa=n,Ey.emit("change",{prev:t,next:n})}function Ra(e){const t=Pa;Pa=e,Ey.emit("change",{prev:t,next:e})}const EW=e=>e,qm=()=>{},PR=1,RR=2,MR=4,AR=8,kS=3,CS=12;let Ed;function ES(){return Ed===void 0&&(Ed=!1,typeof window<"u"&&(window.navigator.userAgent.includes("Chrome")||window.navigator.userAgent.includes("Firefox"))&&(Ed=!0)),Ed}function NW({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&&ES()){const s=(e&PR)!==0,o=(e&RR)!==0,a=(e&MR)!==0,l=(e&AR)!==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 ES()?r>0&&i>0?"move":r>0?"ew-resize":"ns-resize":r>0&&i>0?"grab":r>0?"col-resize":"row-resize"}}const NS=new WeakMap;function Ny(e){if(e.defaultView===null||e.defaultView===void 0)return;let{prevStyle:t,styleSheet:n}=NS.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=ko();switch(r.state){case"active":case"hover":{const i=NW({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}}NS.set(e,{prevStyle:t,styleSheet:n})}let ei=new Map;const jR=new IR;function TW(e){ei=new Map(ei),ei.delete(e)}function TS(e,t){for(const[n]of ei)if(n.id===e)return n}function Ns(e,t){for(const[n,r]of ei)if(n.id===e)return r;if(t)throw Error(`Could not find data for Group with id ${e}`)}function Bo(){return ei}function Ty(e,t){return jR.addListener("groupChange",n=>{n.group.id===e&&t(n)})}function Fi(e,t,n){const r=ei.get(e);ei=new Map(ei),ei.set(e,t),jR.emit("groupChange",{group:e,isUserInteraction:(n==null?void 0:n.isUserInteraction)===!0,prev:r,next:t})}function LR(e){const t=ko();let n=!1;switch(t.state){case"active":Ra({cursorFlags:0,state:"inactive"}),t.hitRegions.length>0&&(Ny(e),n=!0,t.hitRegions.forEach(r=>{const i=Ns(r.group.id,!0);Fi(r.group,i,{isUserInteraction:!0})}))}return n}function IS(e){e.defaultPrevented||LR(e.currentTarget)}function IW(e,t,n){let r,i={x:1/0,y:1/0};for(const s of t){const o=NR(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 PW(e){return e!==null&&typeof e=="object"&&"nodeType"in e&&e.nodeType===Node.DOCUMENT_FRAGMENT_NODE}function RW(e,t){if(e===t)throw new Error("Cannot compare node with itself");const n={a:MS(e),b:MS(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:RS(PS(n.a)),b:RS(PS(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 MW=/\b(?:position|zIndex|opacity|transform|webkitTransform|mixBlendMode|filter|webkitFilter|isolation)\b/;function AW(e){const t=getComputedStyle(DR(e)??e).display;return t==="flex"||t==="inline-flex"}function jW(e){const t=getComputedStyle(e);return!!(t.position==="fixed"||t.zIndex!=="auto"&&(t.position!=="static"||AW(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"||MW.test(t.willChange)||t.webkitOverflowScrolling==="touch")}function PS(e){let t=e.length;for(;t--;){const n=e[t];if(rt(n,"Missing node"),jW(n))return n}return null}function RS(e){return e&&Number(getComputedStyle(e).zIndex)||0}function MS(e){const t=[];for(;e;)t.push(e),e=DR(e);return t}function DR(e){const{parentNode:t}=e;return PW(t)?t.host:t}function LW(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 DW({groupElement:e,hitRegion:t,pointerEventTarget:n}){if(!ER(n)||n.contains(e)||e.contains(n))return!0;if(RW(n,e)>0){let r=n;for(;r;){if(r.contains(e))return!0;if(LW(r.getBoundingClientRect(),t))return!1;r=r.parentElement}}return!0}function Iy(e,t){const n=[];return t.forEach((r,i)=>{if(i.disabled)return;const s=TR(i),o=IW(i.orientation,s,{x:e.clientX,y:e.clientY});o&&o.distance.x<=0&&o.distance.y<=0&&DW({groupElement:i.element,hitRegion:o.hitRegion.rect,pointerEventTarget:e.target})&&n.push(o.hitRegion)}),n}function OW(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 xn(e,t,n=0){return Math.abs(In(e)-In(t))<=n}function Xr(e,t){return xn(e,t)?0:e>t?1:-1}function _a({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(Xr(r,l)<0)if(s){const c=(i+l)/2;Xr(r,c)<0?r=i:r=l}else r=l;return r=Math.min(a,r),r=In(r),r}function iu({delta:e,initialLayout:t,panelConstraints:n,pivotIndices:r,prevLayout:i,trigger:s}){if(xn(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:x=0,collapsible:_,minSize:y=0}=b;if(_){const S=a[v];if(rt(S!=null,`Previous layout not found for panel index ${v}`),xn(S,x)){const C=y-S;Xr(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:x=0,collapsible:_,minSize:y=0}=b;if(_){const S=a[v];if(rt(S!=null,`Previous layout not found for panel index ${v}`),xn(S,y)){const C=S-x;Xr(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 x=a[v],{collapsible:_,collapsedSize:y,minSize:S}=b;if(_&&Xr(x,S)<0)if(e>0){const C=S-y,k=C/2,N=x+e;Xr(N,S)<0&&(e=Xr(e,k)<=0?0:C)}else{const C=S-y,k=100-C/2,N=x-e;Xr(N,S)<0&&(e=Xr(100+e,k)>0?0:-C)}break}}{const v=e<0?1:-1;let b=e<0?d:u,x=0;for(;;){const y=a[b];rt(y!=null,`Previous layout not found for panel index ${b}`);const S=_a({overrideDisabledPanels:o,panelConstraints:n[b],prevSize:y,size:100})-y;if(x+=S,b+=v,b<0||b>=n.length)break}const _=Math.min(Math.abs(e),Math.abs(x));e=e<0?0-_:_}{let v=e<0?u:d;for(;v>=0&&v<n.length;){const b=Math.abs(e)-Math.abs(f),x=a[v];rt(x!=null,`Previous layout not found for panel index ${v}`);const _=x-b,y=_a({overrideDisabledPanels:o,panelConstraints:n[v],prevSize:x,size:_});if(!xn(x,y)&&(f+=x-y,c[v]=y,f.toFixed(3).localeCompare(Math.abs(e).toFixed(3),void 0,{numeric:!0})>=0))break;e<0?v--:v++}}if(OW(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 x=b+f,_=_a({overrideDisabledPanels:o,panelConstraints:n[v],prevSize:b,size:x});if(c[v]=_,!xn(_,x)){let y=x-_,S=e<0?d:u;for(;S>=0&&S<n.length;){const C=c[S];rt(C!=null,`Previous layout not found for panel index ${S}`);const k=C+y,N=_a({overrideDisabledPanels:o,panelConstraints:n[S],prevSize:C,size:k});if(xn(C,N)||(y-=N-C,c[S]=N),xn(y,0))break;e>0?S--:S++}}}const p=Object.values(c).reduce((v,b)=>b+v,0);if(!xn(p,100,.1))return i;const m=Object.keys(i);return c.reduce((v,b,x)=>(v[m[x]]=b,v),{})}function Co(e,t){if(Object.keys(e).length!==Object.keys(t).length)return!1;for(const n in e)if(t[n]===void 0||Xr(e[n],t[n])!==0)return!1;return!0}function Eo({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(!xn(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=_a({overrideDisabledPanels:!0,panelConstraints:t[a],prevSize:l,size:c});c!=u&&(s+=c-u,r[a]=u)}if(!xn(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=_a({overrideDisabledPanels:!0,panelConstraints:t[a],prevSize:l,size:c});if(l!==u&&(s-=u-l,r[a]=u,xn(s,0)))break}const o=Object.keys(e);return r.reduce((a,l,c)=>(a[o[c]]=l,a),{})}function OR({groupId:e,panelId:t}){const n=()=>{const l=Bo();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,x)=>{const _=d[x];return(_==null?void 0:_.collapsible)&&xn(_.collapsedSize,u[_.panelId])}))){const b=c.slice(0,p).reduce((x,_)=>x+u[_.id],0);return{...u,[t]:In(100-b)}}return iu({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}),x=Eo({layout:b,panelConstraints:d});Co(m,x)||Fi(f,{defaultLayoutDeferred:u,derivedPanelConstraints:d,groupSize:p,layout:x,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&&xn(c,u)},resize:l=>{const{group:c}=n(),{element:u}=i(),d=Ka({group:c}),f=ec({groupSize:d,panelElement:u,styleProp:l}),p=In(f/d*100);a(p)}}}function AS(e){if(e.defaultPrevented)return;const t=Bo();Iy(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=OR({groupId:n.group.id,panelId:r.id});s&&i!==void 0&&(s.resize(i),e.preventDefault())}}})}function ah(e){const t=Bo();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 BR({groupId:e}){const t=()=>{const n=Bo();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=Eo({layout:n,panelConstraints:i});return r?a:(Co(a,c)||Fi(s,{defaultLayoutDeferred:r,derivedPanelConstraints:i,groupSize:o,layout:c,separatorToPanels:l}),c)}}}function Ys(e,t){const n=ah(e),r=Ns(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=BR({groupId:n.id}).getLayout(),l=iu({delta:t,initialLayout:a,panelConstraints:r.derivedPanelConstraints,pivotIndices:o,prevLayout:a,trigger:"keyboard"}),c=Eo({layout:l,panelConstraints:r.derivedPanelConstraints});Co(a,c)||Fi(n,{defaultLayoutDeferred:r.defaultLayoutDeferred,derivedPanelConstraints:r.derivedPanelConstraints,groupSize:r.groupSize,layout:c,separatorToPanels:r.separatorToPanels},{isUserInteraction:!0})}function jS(e){if(e.defaultPrevented)return;const t=e.currentTarget,n=ah(t);if(!n.disabled)switch(e.key){case"ArrowDown":{e.preventDefault(),n.orientation==="vertical"&&Ys(t,5);break}case"ArrowLeft":{e.preventDefault(),n.orientation==="horizontal"&&Ys(t,-5);break}case"ArrowRight":{e.preventDefault(),n.orientation==="horizontal"&&Ys(t,5);break}case"ArrowUp":{e.preventDefault(),n.orientation==="vertical"&&Ys(t,-5);break}case"End":{e.preventDefault(),Ys(t,100);break}case"Enter":{e.preventDefault();const r=ah(t),i=Ns(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;Ys(t,p-f)}break}case"F6":{e.preventDefault();const r=ah(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(),Ys(t,-100);break}}}function LS(e){if(e.defaultPrevented||e.pointerType==="mouse"&&e.button>0)return;const t=Bo(),n=Iy(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)}),Ra({cursorFlags:0,hitRegions:n,initialLayoutMap:r,pointerDownAtPoint:{x:e.clientX,y:e.clientY},state:"active"}),n.length&&e.preventDefault()}function zR({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),x=i.get(u);if(!b||!x)return;const{defaultLayoutDeferred:_,derivedPanelConstraints:y,groupSize:S,layout:C,separatorToPanels:k}=x;if(y&&C&&k){const N=iu({delta:v,initialLayout:b,panelConstraints:y,pivotIndices:c.panels.map(T=>p.indexOf(T)),prevLayout:C,trigger:"mouse-or-touch"});if(Co(N,C)){if(v!==0&&!m)switch(f){case"horizontal":{a|=v<0?PR:RR;break}case"vertical":{a|=v<0?MR:AR;break}}}else Fi(c.group,{defaultLayoutDeferred:_,derivedPanelConstraints:y,groupSize:S,layout:N,separatorToPanels:k})}});let l=0;t.movementX===0?l|=o&kS:l|=a&kS,t.movementY===0?l|=o&CS:l|=a&CS,CW(l),Ny(e)}function DS(e){const t=Bo(),n=ko();switch(n.state){case"active":zR({document:e.currentTarget,event:e,hitRegions:n.hitRegions,initialLayoutMap:n.initialLayoutMap,mountedGroups:t,prevCursorFlags:n.cursorFlags})}}function OS(e){var r,i;if(e.defaultPrevented)return;const t=ko(),n=Bo();switch(t.state){case"active":{if(e.buttons===0){Ra({cursorFlags:0,state:"inactive"}),t.hitRegions.forEach(s=>{const o=Ns(s.group.id,!0);Fi(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))}zR({document:e.currentTarget,event:e,hitRegions:t.hitRegions,initialLayoutMap:t.initialLayoutMap,mountedGroups:n,pointerDownAtPoint:t.pointerDownAtPoint,prevCursorFlags:t.cursorFlags});break}default:{const s=Iy(e,n);s.length===0?t.state!=="inactive"&&Ra({cursorFlags:0,state:"inactive"}):Ra({cursorFlags:0,hitRegions:s,state:"hover"}),Ny(e.currentTarget);break}}}function BS(e){if(e.relatedTarget instanceof HTMLIFrameElement)switch(ko().state){case"hover":Ra({cursorFlags:0,state:"inactive"})}}function zS(e){e.defaultPrevented||e.pointerType==="mouse"&&e.button>0||LR(e.currentTarget)&&e.preventDefault()}function $S(e){let t=0,n=0;const r={};for(const s of e)if(s.defaultSize!==void 0){t++;const o=In(s.defaultSize);n+=o,r[s.panelId]=o}else r[s.panelId]=void 0;const i=e.length-t;if(i!==0){const s=In((100-n)/i);for(const o of e)o.defaultSize===void 0&&(r[o.panelId]=s)}return r}function BW(e,t,n){if(!n[0])return;const r=e.panels.find(l=>l.element===t);if(!r||!r.onResize)return;const i=Ka({group:e}),s=e.orientation==="horizontal"?r.element.offsetWidth:r.element.offsetHeight,o=r.mutableValues.prevSize,a={asPercentage:In(s/i*100),inPixels:s};r.mutableValues.prevSize=a,r.onResize(a,r.id,o)}function zW(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 $W({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=In(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]=In(f/s*c)}else{const d=In(c/l.length);for(const f of l)u[f]=d}return u}function FW(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 Qo=new Map;function HW(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:x}=v;if(x===e.element){if(t){const _=Ka({group:e});if(_===0)return;const y=Ns(e.id);if(!y)return;const S=I0(e),C=y.defaultLayoutDeferred?$S(S):y.layout,k=$W({group:e,nextGroupSize:_,prevGroupSize:y.groupSize,prevLayout:C}),N=Eo({layout:k,panelConstraints:S});if(!y.defaultLayoutDeferred&&Co(y.layout,N)&&zW(y.derivedPanelConstraints,S)&&y.groupSize===_)return;Fi(e,{defaultLayoutDeferred:!1,derivedPanelConstraints:S,groupSize:_,layout:N,separatorToPanels:y.separatorToPanels})}}else BW(e,x,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=Ka({group:e}),a=I0(e),l=e.panels.map(({id:m})=>m).join(",");let c=e.mutableState.defaultLayout;c&&(FW(e.panels,c)||(c=void 0));const u=e.mutableState.layouts[l]??c??$S(a),d=Eo({layout:u,panelConstraints:a}),f=e.element.ownerDocument;Qo.set(f,(Qo.get(f)??0)+1);const p=new Map;return TR(e).forEach(m=>{m.separator&&p.set(m.separator,m.panels)}),Fi(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",jS)}),Qo.get(f)===1&&(f.addEventListener("contextmenu",IS,!0),f.addEventListener("dblclick",AS,!0),f.addEventListener("pointerdown",LS,!0),f.addEventListener("pointerleave",DS),f.addEventListener("pointermove",OS),f.addEventListener("pointerout",BS),f.addEventListener("pointerup",zS,!0)),function(){t=!1,Qo.set(f,Math.max(0,(Qo.get(f)??0)-1)),TW(e),e.separators.forEach(m=>{m.element.removeEventListener("keydown",jS)}),Qo.get(f)||(f.removeEventListener("contextmenu",IS,!0),f.removeEventListener("dblclick",AS,!0),f.removeEventListener("pointerdown",LS,!0),f.removeEventListener("pointerleave",DS),f.removeEventListener("pointermove",OS),f.removeEventListener("pointerout",BS),f.removeEventListener("pointerup",zS,!0)),s.disconnect()}}function UW(){const[e,t]=g.useState({}),n=g.useCallback(()=>t({}),[]);return[e,n]}function Py(e){const t=g.useId();return`${e??t}`}const zo=typeof window<"u"?g.useLayoutEffect:g.useEffect;function yc(e){const t=g.useRef(e);return zo(()=>{t.current=e},[e]),g.useCallback((...n)=>{var r;return(r=t.current)==null?void 0:r.call(t,...n)},[t])}function Ry(...e){return yc(t=>{e.forEach(n=>{if(n)switch(typeof n){case"function":{n(t);break}case"object":{n.current=t;break}}})})}function My(e){const t=g.useRef({...e});return zo(()=>{for(const n in e)t.current[n]=e[n]},[e]),t.current}const $R=g.createContext(null);function WW(e,t){const n=g.useRef({getLayout:()=>({}),setLayout:EW});g.useImperativeHandle(t,()=>n.current,[]),zo(()=>{Object.assign(n.current,BR({groupId:e}))})}function Ay({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=yc(M=>{Co(m.current.onLayoutChange,M)||(m.current.onLayoutChange=M,l==null||l(M))}),b=yc((M,L)=>{Co(m.current.onLayoutChanged,M)||(m.current.onLayoutChanged=M,c==null||c(M,{isUserInteraction:L}))}),x=Py(a),_=g.useRef(null),[y,S]=UW(),C=g.useRef({lastExpandedPanelSizes:{},layouts:{},panels:[],resizeTargetMinimumSize:d,separators:[]}),k=Ry(_,s);WW(x,o);const N=yc((M,L)=>{const R=ko(),A=TS(M),D=Ns(M);if(D){let $=!1;switch(R.state){case"active":{$=R.hitRegions.some(F=>F.group===A);break}}return{flexGrow:D.layout[L]??1,pointerEvents:$?"none":void 0}}if(n!=null&&n[L])return{flexGrow:n==null?void 0:n[L]}}),T=My({defaultLayout:n,disableCursor:r}),z=g.useMemo(()=>({get disableCursor(){return!!T.disableCursor},getPanelStyles:N,id:x,orientation:u,registerPanel:M=>{const L=C.current;return L.panels=P0(u,[...L.panels,M]),S(),()=>{L.panels=L.panels.filter(R=>R!==M),S()}},registerSeparator:M=>{const L=C.current;return L.separators=P0(u,[...L.separators,M]),S(),()=>{L.separators=L.separators.filter(R=>R!==M),S()}},updatePanelProps:(M,{disabled:L})=>{const R=C.current.panels.find($=>$.id===M);R&&(R.panelConstraints.disabled=L);const A=TS(x),D=Ns(x);A&&D&&Fi(A,{...D,derivedPanelConstraints:I0(A)})},updateSeparatorProps:(M,{disabled:L,disableDoubleClick:R})=>{const A=C.current.separators.find(D=>D.id===M);A&&(A.disabled=L,A.disableDoubleClick=R)}}),[N,x,S,u,T]),I=g.useRef(null);return zo(()=>{const M=_.current;if(M===null)return;const L=C.current;let R;if(T.defaultLayout!==void 0&&Object.keys(T.defaultLayout).length===L.panels.length){R={};for(const E of L.panels){const H=T.defaultLayout[E.id];H!==void 0&&(R[E.id]=H)}}const A={disabled:!!i,element:M,id:x,mutableState:{defaultLayout:R,disableCursor:!!T.disableCursor,expandedPanelSizes:C.current.lastExpandedPanelSizes,layouts:C.current.layouts},orientation:u,panels:L.panels,resizeTargetMinimumSize:L.resizeTargetMinimumSize,separators:L.separators};I.current=A;const D=HW(A),{defaultLayoutDeferred:$,derivedPanelConstraints:F,layout:O}=Ns(A.id,!0);!$&&F.length>0&&(v(O),b(O,!1));const B=Ty(x,E=>{const{defaultLayoutDeferred:H,derivedPanelConstraints:q,layout:j}=E.next;if(H||q.length===0)return;const ne=A.panels.map(({id:G})=>G).join(",");A.mutableState.layouts[ne]=j,q.forEach(G=>{if(G.collapsible){const{layout:ve}=E.prev??{};if(ve){const ze=xn(G.collapsedSize,j[G.panelId]),he=xn(G.collapsedSize,ve[G.panelId]);ze&&!he&&(A.mutableState.expandedPanelSizes[G.panelId]=ve[G.panelId])}}});const re=ko().state!=="active";v(j),re&&b(j,E.isUserInteraction)});return()=>{I.current=null,D(),B()}},[i,x,b,v,u,y,T]),g.useEffect(()=>{const M=I.current;M&&(M.mutableState.defaultLayout=n,M.mutableState.disableCursor=!!r)}),h.jsx($R.Provider,{value:z,children:h.jsx("div",{...p,className:t,"data-group":!0,"data-testid":x,id:x,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})})}Ay.displayName="Group";function jy(){const e=g.useContext($R);return rt(e,"Group Context not found; did you render a Panel or Separator outside of a Group?"),e}function VW(e,t){const{id:n}=jy(),r=g.useRef({collapse:qm,expand:qm,getSize:()=>({asPercentage:0,inPixels:0}),isCollapsed:()=>!1,resize:qm});g.useImperativeHandle(t,()=>r.current,[]),zo(()=>{Object.assign(r.current,OR({groupId:n,panelId:e}))})}function uf({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=Py(l),x=My({disabled:s}),_=g.useRef(null),y=Ry(_,o),{getPanelStyles:S,id:C,orientation:k,registerPanel:N,updatePanelProps:T}=jy(),z=d!==null,I=yc((A,D,$)=>{d==null||d(A,l,$)});zo(()=>{const A=_.current;if(A!==null){const D={element:A,id:b,idIsStable:v,mutableValues:{expandToSize:void 0,prevSize:void 0},onResize:z?I:void 0,panelConstraints:{groupResizeBehavior:a,collapsedSize:n,collapsible:r,defaultSize:i,disabled:x.disabled,maxSize:c,minSize:u}};return N(D)}},[a,n,r,i,z,b,v,c,u,I,N,x]),g.useEffect(()=>{T(b,{disabled:s})},[s,b,T]),VW(b,f);const M=()=>{const A=S(C,b);if(A)return JSON.stringify(A)},L=g.useSyncExternalStore(A=>Ty(C,A),M,M);let R;return L?R=JSON.parse(L):i!==void 0?R={flexGrow:void 0,flexShrink:void 0,flexBasis:i}:R={flexGrow:1},h.jsx("div",{...m,"data-disabled":s||void 0,"data-panel":!0,"data-testid":b,id:b,ref:y,style:{...qW,display:"flex",flexBasis:0,flexShrink:1,overflow:"visible",...R},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})})}uf.displayName="Panel";const qW={minHeight:0,maxHeight:"100%",height:"auto",minWidth:0,maxWidth:"100%",width:"auto",border:"none",borderWidth:0,padding:0,margin:0};function KW({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=Eo({layout:iu({delta:c-o,initialLayout:e,panelConstraints:t,pivotIndices:u,prevLayout:e}),panelConstraints:t})[n],i=Eo({layout:iu({delta:l-o,initialLayout:e,panelConstraints:t,pivotIndices:u,prevLayout:e}),panelConstraints:t})[n]}return{valueControls:n,valueMax:i,valueMin:s,valueNow:o}}function FR({children:e,className:t,disabled:n,disableDoubleClick:r,elementRef:i,id:s,style:o,...a}){const l=Py(s),c=My({disabled:n,disableDoubleClick:r}),[u,d]=g.useState({}),[f,p]=g.useState("inactive"),[m,v]=g.useState(!1),b=g.useRef(null),x=Ry(b,i),{disableCursor:_,id:y,orientation:S,registerSeparator:C,updateSeparatorProps:k}=jy(),N=S==="horizontal"?"vertical":"horizontal";zo(()=>{const I=b.current;if(I!==null){const M={disabled:c.disabled,disableDoubleClick:c.disableDoubleClick,element:I,id:l},L=C(M),R=kW(D=>{p(D.next.state!=="inactive"&&D.next.hitRegions.some($=>$.separator===M)?D.next.state:"inactive")}),A=Ty(y,D=>{const{derivedPanelConstraints:$,layout:F,separatorToPanels:O}=D.next,B=O.get(M);if(B){const E=B[0],H=B.indexOf(E);d(KW({layout:F,panelConstraints:$,panelId:E.id,panelIndex:H}))}});return()=>{R(),A(),L()}}},[y,l,C,c]),g.useEffect(()=>{k(l,{disabled:n,disableDoubleClick:r})},[n,r,l,k]);let T;n&&!_&&(T="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":N,"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:x,role:"separator",style:{flexBasis:"auto",cursor:T,...o,flexGrow:0,flexShrink:0,touchAction:"none"},tabIndex:n?void 0:0})}FR.displayName="Separator";function GW(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 YW(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 XW=/^Scheduled (?:recurring job|one-shot task) ([0-9a-f]{8}) \(([^)]+)\)/;function ZW(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(XW);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 QW=["TaskCreate","TaskUpdate","TaskList","TaskGet"];function JW(e){return QW.includes(e)}function HR(e){return e==="in_progress"||e==="completed"?e:"pending"}function eV(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:HR(n.status),activeForm:i,description:s}]}function tV(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=HR(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 nV(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=eV(t,i.input);break;case"TaskUpdate":t=tV(t,i.input);break}}return{tasks:t,lastEventIndex:n}}function UR(e){var n;if(e.error)return!1;if(e.pending)return!0;if(e.notifications.length>0)return!1;const t=(n=e.progress)==null?void 0:n.status;return t==="running"?!0:t==="started"?rV(e.input):!1}function rV(e){return!e||typeof e!="object"?!1:e.run_in_background===!0}function iV(e){const{tasks:t,lastEventIndex:n}=nV(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 sV=new Set(["permission-inline","question-card"]);function oV(e){return e.kind==="user-text"?!0:e.kind!=="user-meta"?!1:e.metaKind==="slash-command"||op(e.metaKind)}function aV(e){return e.kind==="user-text"&&e.continuesTurn===!0}function lV(e,t={}){const n=[];let r=null;const i=(s,o)=>{r&&(n.push(cV(r,s,o)),r=null)};for(const s of e){if(s.kind==="turn-end"){i(s,!0);continue}if(oV(s)&&(r===null||!aV(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 cV(e,t,n){const{query:r,body:i}=e,s=uV(i,t,n),o=dV(i,s),a=fV(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 uV(e,t,n){if(!n)return"running";if((t==null?void 0:t.reason)==="interrupted")return"interrupted";const r=R0(e,i=>i.kind==="error");return r>=0&&!e.slice(r+1).some(s=>s.kind==="assistant-text")?"error":"done"}function dV(e,t){if(t==="running"){const i=[];for(let s=e.length-1;s>=0&&sV.has(e[s].kind);s--)i.unshift(e[s]);return i}const n=[];e.forEach((i,s)=>{i.kind==="merged-agent"&&UR(i)&&n.push(s)});const r=t==="error"?R0(e,i=>i.kind==="error"):R0(e,i=>i.kind==="assistant-text");return r>=0&&n.push(r),n.sort((i,s)=>i-s).map(i=>e[i])}const hV=new Set(["assistant-thinking","user-meta"]);function fV(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(hV.has(o.kind)){r.push(o);continue}s(),r.push(o)}return s(),r}function R0(e,t){for(let n=e.length-1;n>=0;n--)if(t(e[n]))return n;return-1}const pV={Read:["正在读取","已读取"],Bash:["正在运行","已运行"],Grep:["正在搜索","已搜索"],Glob:["正在搜索","已搜索"],Edit:["正在编辑","已编辑"],Write:["正在写入","已写入"],WebFetch:["正在抓取","已抓取"],WebSearch:["正在搜索","已搜索"],Skill:["正在读取","已读取"]};function mV(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 WR(e){const t=pV[e.tool],n=t?e.pending?t[0]:t[1]:e.pending?`正在执行 ${e.tool}`:`已执行 ${e.tool}`,r=mV(e.input);return r?`${n} ${r}`:n}function gV({item:e,renderItemDetail:t}){const[n,r]=g.useState(!1),i=n?qn:Ln,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:oe("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(Mn,{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:WR(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 vV({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?qn:Ln;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(Mn,{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:oe("truncate min-w-0",s&&"text-text-300"),children:[WR(o),a]})]}),r?h.jsx("div",{className:"mt-0.5 flex flex-col pl-5",children:e.map(c=>h.jsx(gV,{item:c,renderItemDetail:n},c.toolUseId))}):null]})}function xV(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 _V(e,t){const n=t!==void 0?`耗时 ${xV(t)}`:"";switch(e){case"interrupted":return n?`已中断 · ${n}`:"已中断";case"error":return n?`出错 · ${n}`:"出错";default:return n||"已完成"}}function yV({status:e="done",durationMs:t,defaultExpanded:n=!1,children:r}){const[i,s]=g.useState(n),o=i?qn:Ln;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:oe("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:_V(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 bV=/<(system-reminder|related-dir|clawd-shift-fire)\b[^>]*>[\s\S]*?<\/\1>/gi,wV=/<builder-preview\b[^>]*\/>/gi,SV=/<(clawd-dispatch-task|clawd-dispatch-result)\b[^>]*>([\s\S]*?)<\/\1>/gi,kV=/<\/?(brief|detail|files)>/gi;function VR(e){return e?e.replace(SV,(t,n,r)=>RB(r.replace(kV,"")).trim()).replace(bV,"").replace(wV,"").trim():""}const CV=VR;function EV(e,t){const n={};return(e[e.length-1]===""?[...e,""]:e).join((n.padRight?" ":"")+","+(n.padLeft===!1?"":" ")).trim()}const NV=/^[$_\p{ID_Start}][$_\u{200C}\u{200D}\p{ID_Continue}]*$/u,TV=/^[$_\p{ID_Start}][-$_\u{200C}\u{200D}\p{ID_Continue}]*$/u,IV={};function FS(e,t){return(IV.jsx?TV:NV).test(e)}const PV=/[ \t\n\f\r]/g;function RV(e){return typeof e=="object"?e.type==="text"?HS(e.value):!1:HS(e)}function HS(e){return e.replace(PV,"")===""}class Mu{constructor(t,n,r){this.normal=n,this.property=t,r&&(this.space=r)}}Mu.prototype.normal={};Mu.prototype.property={};Mu.prototype.space=void 0;function qR(e,t){const n={},r={};for(const i of e)Object.assign(n,i.property),Object.assign(r,i.normal);return new Mu(n,r,t)}function M0(e){return e.toLowerCase()}class Kn{constructor(t,n){this.attribute=n,this.property=t}}Kn.prototype.attribute="";Kn.prototype.booleanish=!1;Kn.prototype.boolean=!1;Kn.prototype.commaOrSpaceSeparated=!1;Kn.prototype.commaSeparated=!1;Kn.prototype.defined=!1;Kn.prototype.mustUseProperty=!1;Kn.prototype.number=!1;Kn.prototype.overloadedBoolean=!1;Kn.prototype.property="";Kn.prototype.spaceSeparated=!1;Kn.prototype.space=void 0;let MV=0;const Ae=$o(),Lt=$o(),A0=$o(),Q=$o(),at=$o(),Ma=$o(),Zn=$o();function $o(){return 2**++MV}const j0=Object.freeze(Object.defineProperty({__proto__:null,boolean:Ae,booleanish:Lt,commaOrSpaceSeparated:Zn,commaSeparated:Ma,number:Q,overloadedBoolean:A0,spaceSeparated:at},Symbol.toStringTag,{value:"Module"})),Km=Object.keys(j0);class Ly extends Kn{constructor(t,n,r,i){let s=-1;if(super(t,n),US(this,"space",i),typeof r=="number")for(;++s<Km.length;){const o=Km[s];US(this,Km[s],(r&j0[o])===j0[o])}}}Ly.prototype.defined=!0;function US(e,t,n){n&&(e[t]=n)}function xl(e){const t={},n={};for(const[r,i]of Object.entries(e.properties)){const s=new Ly(r,e.transform(e.attributes||{},r),i,e.space);e.mustUseProperty&&e.mustUseProperty.includes(r)&&(s.mustUseProperty=!0),t[r]=s,n[M0(r)]=r,n[M0(s.attribute)]=r}return new Mu(t,n,e.space)}const KR=xl({properties:{ariaActiveDescendant:null,ariaAtomic:Lt,ariaAutoComplete:null,ariaBusy:Lt,ariaChecked:Lt,ariaColCount:Q,ariaColIndex:Q,ariaColSpan:Q,ariaControls:at,ariaCurrent:null,ariaDescribedBy:at,ariaDetails:null,ariaDisabled:Lt,ariaDropEffect:at,ariaErrorMessage:null,ariaExpanded:Lt,ariaFlowTo:at,ariaGrabbed:Lt,ariaHasPopup:null,ariaHidden:Lt,ariaInvalid:null,ariaKeyShortcuts:null,ariaLabel:null,ariaLabelledBy:at,ariaLevel:Q,ariaLive:null,ariaModal:Lt,ariaMultiLine:Lt,ariaMultiSelectable:Lt,ariaOrientation:null,ariaOwns:at,ariaPlaceholder:null,ariaPosInSet:Q,ariaPressed:Lt,ariaReadOnly:Lt,ariaRelevant:null,ariaRequired:Lt,ariaRoleDescription:at,ariaRowCount:Q,ariaRowIndex:Q,ariaRowSpan:Q,ariaSelected:Lt,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 GR(e,t){return t in e?e[t]:t}function YR(e,t){return GR(e,t.toLowerCase())}const AV=xl({attributes:{acceptcharset:"accept-charset",classname:"class",htmlfor:"for",httpequiv:"http-equiv"},mustUseProperty:["checked","multiple","muted","selected"],properties:{abbr:null,accept:Ma,acceptCharset:at,accessKey:at,action:null,allow:null,allowFullScreen:Ae,allowPaymentRequest:Ae,allowUserMedia:Ae,alt:null,as:null,async:Ae,autoCapitalize:null,autoComplete:at,autoFocus:Ae,autoPlay:Ae,blocking:at,capture:null,charSet:null,checked:Ae,cite:null,className:at,cols:Q,colSpan:null,content:null,contentEditable:Lt,controls:Ae,controlsList:at,coords:Q|Ma,crossOrigin:null,data:null,dateTime:null,decoding:null,default:Ae,defer:Ae,dir:null,dirName:null,disabled:Ae,download:A0,draggable:Lt,encType:null,enterKeyHint:null,fetchPriority:null,form:null,formAction:null,formEncType:null,formMethod:null,formNoValidate:Ae,formTarget:null,headers:at,height:Q,hidden:A0,high:Q,href:null,hrefLang:null,htmlFor:at,httpEquiv:at,id:null,imageSizes:null,imageSrcSet:null,inert:Ae,inputMode:null,integrity:null,is:null,isMap:Ae,itemId:null,itemProp:at,itemRef:at,itemScope:Ae,itemType:at,kind:null,label:null,lang:null,language:null,list:null,loading:null,loop:Ae,low:Q,manifest:null,max:null,maxLength:Q,media:null,method:null,min:null,minLength:Q,multiple:Ae,muted:Ae,name:null,nonce:null,noModule:Ae,noValidate:Ae,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:Ae,optimum:Q,pattern:null,ping:at,placeholder:null,playsInline:Ae,popover:null,popoverTarget:null,popoverTargetAction:null,poster:null,preload:null,readOnly:Ae,referrerPolicy:null,rel:at,required:Ae,reversed:Ae,rows:Q,rowSpan:Q,sandbox:at,scope:null,scoped:Ae,seamless:Ae,selected:Ae,shadowRootClonable:Ae,shadowRootDelegatesFocus:Ae,shadowRootMode:null,shape:null,size:Q,sizes:null,slot:null,span:Q,spellCheck:Lt,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:Ae,useMap:null,value:Lt,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:Ae,declare:Ae,event:null,face:null,frame:null,frameBorder:null,hSpace:Q,leftMargin:Q,link:null,longDesc:null,lowSrc:null,marginHeight:Q,marginWidth:Q,noResize:Ae,noHref:Ae,noShade:Ae,noWrap:Ae,object:null,profile:null,prompt:null,rev:null,rightMargin:Q,rules:null,scheme:null,scrolling:Lt,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:Ae,disableRemotePlayback:Ae,prefix:null,property:null,results:Q,security:null,unselectable:null},space:"html",transform:YR}),jV=xl({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:Zn,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:Ae,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:Ma,g2:Ma,glyphName:Ma,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:Zn,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:Zn,r:null,radius:null,referrerPolicy:null,refX:null,refY:null,rel:Zn,rev:Zn,renderingIntent:null,repeatCount:null,repeatDur:null,requiredExtensions:Zn,requiredFeatures:Zn,requiredFonts:Zn,requiredFormats:Zn,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:Zn,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:Zn,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:Zn,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:GR}),XR=xl({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()}}),ZR=xl({attributes:{xmlnsxlink:"xmlns:xlink"},properties:{xmlnsXLink:null,xmlns:null},space:"xmlns",transform:YR}),QR=xl({properties:{xmlBase:null,xmlLang:null,xmlSpace:null},space:"xml",transform(e,t){return"xml:"+t.slice(3).toLowerCase()}}),LV={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"},DV=/[A-Z]/g,WS=/-[a-z]/g,OV=/^data[-\w.:]+$/i;function BV(e,t){const n=M0(t);let r=t,i=Kn;if(n in e.normal)return e.property[e.normal[n]];if(n.length>4&&n.slice(0,4)==="data"&&OV.test(t)){if(t.charAt(4)==="-"){const s=t.slice(5).replace(WS,$V);r="data"+s.charAt(0).toUpperCase()+s.slice(1)}else{const s=t.slice(4);if(!WS.test(s)){let o=s.replace(DV,zV);o.charAt(0)!=="-"&&(o="-"+o),t="data"+o}}i=Ly}return new i(r,t)}function zV(e){return"-"+e.toLowerCase()}function $V(e){return e.charAt(1).toUpperCase()}const FV=qR([KR,AV,XR,ZR,QR],"html"),Dy=qR([KR,jV,XR,ZR,QR],"svg");function HV(e){return e.join(" ").trim()}var Oy={},VS=/\/\*[^*]*\*+([^/*][^*]*\*+)*\//g,UV=/\n/g,WV=/^\s*/,VV=/^(\*?[-#/*\\\w]+(\[[0-9a-z_-]+\])?)\s*/,qV=/^:\s*/,KV=/^((?:'(?:\\'|.)*?'|"(?:\\"|.)*?"|\([^)]*?\)|[^};])+)/,GV=/^[;\s]*/,YV=/^\s+|\s+$/g,XV=`
|
|
507
507
|
`,qS="/",KS="*",ro="",ZV="comment",QV="declaration";function JV(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(UV);v&&(n+=v.length);var b=m.lastIndexOf(XV);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(WV)}function u(m){var v;for(m=m||[];v=d();)v!==!1&&m.push(v);return m}function d(){var m=s();if(!(qS!=e.charAt(0)||KS!=e.charAt(1))){for(var v=2;ro!=e.charAt(v)&&(KS!=e.charAt(v)||qS!=e.charAt(v+1));)++v;if(v+=2,ro===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:ZV,comment:b})}}function f(){var m=s(),v=l(VV);if(v){if(d(),!l(qV))return a("property missing ':'");var b=l(KV),x=m({type:QV,property:GS(v[0].replace(VS,ro)),value:b?GS(b[0].replace(VS,ro)):ro});return l(GV),x}}function p(){var m=[];u(m);for(var v;v=f();)v!==!1&&(m.push(v),u(m));return m}return c(),p()}function GS(e){return e?e.replace(YV,ro):ro}var eq=JV,tq=gh&&gh.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(Oy,"__esModule",{value:!0});Oy.default=rq;const nq=tq(eq);function rq(e,t){let n=null;if(!e||typeof e!="string")return n;const r=(0,nq.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 Cp={};Object.defineProperty(Cp,"__esModule",{value:!0});Cp.camelCase=void 0;var iq=/^--[a-zA-Z0-9_-]+$/,sq=/-([a-z])/g,oq=/^[^-]+$/,aq=/^-(webkit|moz|ms|o|khtml)-/,lq=/^-(ms)-/,cq=function(e){return!e||oq.test(e)||iq.test(e)},uq=function(e,t){return t.toUpperCase()},YS=function(e,t){return"".concat(t,"-")},dq=function(e,t){return t===void 0&&(t={}),cq(e)?e:(e=e.toLowerCase(),t.reactCompat?e=e.replace(lq,YS):e=e.replace(aq,YS),e.replace(sq,uq))};Cp.camelCase=dq;var hq=gh&&gh.__importDefault||function(e){return e&&e.__esModule?e:{default:e}},fq=hq(Oy),pq=Cp;function L0(e,t){var n={};return!e||typeof e!="string"||(0,fq.default)(e,function(r,i){r&&i&&(n[(0,pq.camelCase)(r,t)]=i)}),n}L0.default=L0;var mq=L0;const gq=du(mq),JR=e5("end"),By=e5("start");function e5(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 vq(e){const t=By(e),n=JR(e);if(t&&n)return{start:t,end:n}}function bc(e){return!e||typeof e!="object"?"":"position"in e||"type"in e?XS(e.position):"start"in e||"end"in e?XS(e):"line"in e||"column"in e?D0(e):""}function D0(e){return ZS(e&&e.line)+":"+ZS(e&&e.column)}function XS(e){return D0(e&&e.start)+"-"+D0(e&&e.end)}function ZS(e){return e&&typeof e=="number"?e:1}class kn 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=bc(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}}kn.prototype.file="";kn.prototype.name="";kn.prototype.reason="";kn.prototype.message="";kn.prototype.stack="";kn.prototype.column=void 0;kn.prototype.line=void 0;kn.prototype.ancestors=void 0;kn.prototype.cause=void 0;kn.prototype.fatal=void 0;kn.prototype.place=void 0;kn.prototype.ruleId=void 0;kn.prototype.source=void 0;const zy={}.hasOwnProperty,xq=new Map,_q=/[A-Z]/g,yq=new Set(["table","tbody","thead","tfoot","tr"]),bq=new Set(["td","th"]),t5="https://github.com/syntax-tree/hast-util-to-jsx-runtime";function wq(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=Pq(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=Iq(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"?Dy:FV,stylePropertyNameCase:t.stylePropertyNameCase||"dom",tableCellAlignToStyle:t.tableCellAlignToStyle!==!1},s=n5(i,e,void 0);return s&&typeof s!="string"?s:i.create(e,i.Fragment,{children:s||void 0},void 0)}function n5(e,t,n){if(t.type==="element")return Sq(e,t,n);if(t.type==="mdxFlowExpression"||t.type==="mdxTextExpression")return kq(e,t);if(t.type==="mdxJsxFlowElement"||t.type==="mdxJsxTextElement")return Eq(e,t,n);if(t.type==="mdxjsEsm")return Cq(e,t);if(t.type==="root")return Nq(e,t,n);if(t.type==="text")return Tq(e,t)}function Sq(e,t,n){const r=e.schema;let i=r;t.tagName.toLowerCase()==="svg"&&r.space==="html"&&(i=Dy,e.schema=i),e.ancestors.push(t);const s=i5(e,t.tagName,!1),o=Rq(e,t);let a=Fy(e,t);return yq.has(t.tagName)&&(a=a.filter(function(l){return typeof l=="string"?!RV(l):!0})),r5(e,o,s,t),$y(o,a),e.ancestors.pop(),e.schema=r,e.create(t,s,o,n)}function kq(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)}su(e,t.position)}function Cq(e,t){if(t.data&&t.data.estree&&e.evaluater)return e.evaluater.evaluateProgram(t.data.estree);su(e,t.position)}function Eq(e,t,n){const r=e.schema;let i=r;t.name==="svg"&&r.space==="html"&&(i=Dy,e.schema=i),e.ancestors.push(t);const s=t.name===null?e.Fragment:i5(e,t.name,!0),o=Mq(e,t),a=Fy(e,t);return r5(e,o,s,t),$y(o,a),e.ancestors.pop(),e.schema=r,e.create(t,s,o,n)}function Nq(e,t,n){const r={};return $y(r,Fy(e,t)),e.create(t,e.Fragment,r,n)}function Tq(e,t){return t.value}function r5(e,t,n,r){typeof n!="string"&&n!==e.Fragment&&e.passNode&&(t.node=r)}function $y(e,t){if(t.length>0){const n=t.length>1?t:t[0];n&&(e.children=n)}}function Iq(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 Pq(e,t){return n;function n(r,i,s,o){const a=Array.isArray(s.children),l=By(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 Rq(e,t){const n={};let r,i;for(i in t.properties)if(i!=="children"&&zy.call(t.properties,i)){const s=Aq(e,i,t.properties[i]);if(s){const[o,a]=s;e.tableCellAlignToStyle&&o==="align"&&typeof a=="string"&&bq.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 Mq(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 su(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 su(e,t.position);else s=r.value===null?!0:r.value;n[i]=s}return n}function Fy(e,t){const n=[];let r=-1;const i=e.passKeys?new Map:xq;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=n5(e,s,o);a!==void 0&&n.push(a)}return n}function Aq(e,t,n){const r=BV(e.schema,t);if(!(n==null||typeof n=="number"&&Number.isNaN(n))){if(Array.isArray(n)&&(n=r.commaSeparated?EV(n):HV(n)),r.property==="style"){let i=typeof n=="object"?n:jq(e,String(n));return e.stylePropertyNameCase==="css"&&(i=Lq(i)),["style",i]}return[e.elementAttributeNameCase==="react"&&r.space?LV[r.property]||r.property:r.attribute,n]}}function jq(e,t){try{return gq(t,{reactCompat:!0})}catch(n){if(e.ignoreInvalidStyle)return{};const r=n,i=new kn("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=t5+"#cannot-parse-style-attribute",i}}function i5(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=FS(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=FS(t)&&!/^[a-z]/.test(t)?{type:"Identifier",name:t}:{type:"Literal",value:t};if(r.type==="Literal"){const i=r.value;return zy.call(e.components,i)?e.components[i]:i}if(e.evaluater)return e.evaluater.evaluateExpression(r);su(e)}function su(e,t){const n=new kn("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=t5+"#cannot-handle-mdx-estrees-without-createevaluater",n}function Lq(e){const t={};let n;for(n in e)zy.call(e,n)&&(t[Dq(n)]=e[n]);return t}function Dq(e){let t=e.replace(_q,Oq);return t.slice(0,3)==="ms-"&&(t="-"+t),t}function Oq(e){return"-"+e.toLowerCase()}const Gm={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"]},Bq={};function Hy(e,t){const n=Bq,r=typeof n.includeImageAlt=="boolean"?n.includeImageAlt:!0,i=typeof n.includeHtml=="boolean"?n.includeHtml:!0;return s5(e,r,i)}function s5(e,t,n){if(zq(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 QS(e.children,t,n)}return Array.isArray(e)?QS(e,t,n):""}function QS(e,t,n){const r=[];let i=-1;for(;++i<e.length;)r[i]=s5(e[i],t,n);return r.join("")}function zq(e){return!!(e&&typeof e=="object")}const JS=document.createElement("i");function Uy(e){const t="&"+e+";";JS.innerHTML=t;const n=JS.textContent;return n.charCodeAt(n.length-1)===59&&e!=="semi"||n===t?!1:n}function rr(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 mr(e,t){return e.length>0?(rr(e,e.length,0,t),e):t}const ek={}.hasOwnProperty;function o5(e){const t={};let n=-1;for(;++n<e.length;)$q(t,e[n]);return t}function $q(e,t){let n;for(n in t){const i=(ek.call(e,n)?e[n]:void 0)||(e[n]={}),s=t[n];let o;if(s)for(o in s){ek.call(i,o)||(i[o]=[]);const a=s[o];Fq(i[o],Array.isArray(a)?a:a?[a]:[])}}}function Fq(e,t){let n=-1;const r=[];for(;++n<t.length;)(t[n].add==="after"?e:r).push(t[n]);rr(e,0,0,r)}function a5(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 Lr(e){return e.replace(/[\t\n\r ]+/g," ").replace(/^ | $/g,"").toLowerCase().toUpperCase()}const Tn=Hs(/[A-Za-z]/),bn=Hs(/[\dA-Za-z]/),Hq=Hs(/[#-'*+\--9=?A-Z^-~]/);function df(e){return e!==null&&(e<32||e===127)}const O0=Hs(/\d/),Uq=Hs(/[\dA-Fa-f]/),Wq=Hs(/[!-/:-@[-`{-~]/);function Se(e){return e!==null&&e<-2}function ot(e){return e!==null&&(e<0||e===32)}function Fe(e){return e===-2||e===-1||e===32}const Ep=Hs(new RegExp("\\p{P}|\\p{S}","u")),No=Hs(/\s/);function Hs(e){return t;function t(n){return n!==null&&n>-1&&e.test(String.fromCharCode(n))}}function _l(e){const t=[];let n=-1,r=0,i=0;for(;++n<e.length;){const s=e.charCodeAt(n);let o="";if(s===37&&bn(e.charCodeAt(n+1))&&bn(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 qe(e,t,n,r){const i=r?r-1:Number.POSITIVE_INFINITY;let s=0;return o;function o(l){return Fe(l)?(e.enter(n),a(l)):t(l)}function a(l){return Fe(l)&&s++<i?(e.consume(l),a):(e.exit(n),t(l))}}const Vq={tokenize:qq};function qq(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"),qe(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 Se(a)?(e.consume(a),e.exit("chunkText"),s):(e.consume(a),o)}}const Kq={tokenize:Gq},tk={tokenize:Yq};function Gq(e){const t=this,n=[];let r=0,i,s,o;return a;function a(y){if(r<n.length){const S=n[r];return t.containerState=S[1],e.attempt(S[0].continuation,l,c)(y)}return c(y)}function l(y){if(r++,t.containerState._closeFlow){t.containerState._closeFlow=void 0,i&&_();const S=t.events.length;let C=S,k;for(;C--;)if(t.events[C][0]==="exit"&&t.events[C][1].type==="chunkFlow"){k=t.events[C][1].end;break}x(r);let N=S;for(;N<t.events.length;)t.events[N][1].end={...k},N++;return rr(t.events,C+1,0,t.events.slice(S)),t.events.length=N,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(tk,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(tk,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),x(0),e.consume(y);return}return Se(y)?(e.consume(y),b(e.exit("chunkFlow")),r=0,t.interrupt=void 0,a):(e.consume(y),v)}function b(y,S){const C=t.sliceStream(y);if(S&&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 N=t.events.length;let T=N,z,I;for(;T--;)if(t.events[T][0]==="exit"&&t.events[T][1].type==="chunkFlow"){if(z){I=t.events[T][1].end;break}z=!0}for(x(r),k=N;k<t.events.length;)t.events[k][1].end={...I},k++;rr(t.events,T+1,0,t.events.slice(N)),t.events.length=k}}function x(y){let S=n.length;for(;S-- >y;){const C=n[S];t.containerState=C[1],C[0].exit.call(t,e)}n.length=y}function _(){i.write([null]),s=void 0,i=void 0,t.containerState._closeFlow=void 0}}function Yq(e,t,n){return qe(e,e.attempt(this.parser.constructs.document,t,n),"linePrefix",this.parser.constructs.disable.null.includes("codeIndented")?void 0:4)}function Ga(e){if(e===null||ot(e)||No(e))return 1;if(Ep(e))return 2}function Np(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 B0={name:"attention",resolveAll:Xq,tokenize:Zq};function Xq(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};nk(d,-l),nk(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=mr(c,[["enter",e[r][1],t],["exit",e[r][1],t]])),c=mr(c,[["enter",i,t],["enter",o,t],["exit",o,t],["enter",s,t]]),c=mr(c,Np(t.parser.constructs.insideSpan.null,e.slice(r+1,n),t)),c=mr(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=mr(c,[["enter",e[n][1],t],["exit",e[n][1],t]])):u=0,rr(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 Zq(e,t){const n=this.parser.constructs.attentionMarkers.null,r=this.previous,i=Ga(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=Ga(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 nk(e,t){e.column+=t,e.offset+=t,e._bufferIndex+=t}const Qq={name:"autolink",tokenize:Jq};function Jq(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 Tn(p)?(e.consume(p),o):p===64?n(p):c(p)}function o(p){return p===43||p===45||p===46||bn(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||bn(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||df(p)?n(p):(e.consume(p),l)}function c(p){return p===64?(e.consume(p),u):Hq(p)?(e.consume(p),c):n(p)}function u(p){return bn(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||bn(p))&&r++<63){const m=p===45?f:d;return e.consume(p),m}return n(p)}}const Au={partial:!0,tokenize:eK};function eK(e,t,n){return r;function r(s){return Fe(s)?qe(e,i,"linePrefix")(s):i(s)}function i(s){return s===null||Se(s)?t(s):n(s)}}const l5={continuation:{tokenize:nK},exit:rK,name:"blockQuote",tokenize:tK};function tK(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 Fe(o)?(e.enter("blockQuotePrefixWhitespace"),e.consume(o),e.exit("blockQuotePrefixWhitespace"),e.exit("blockQuotePrefix"),t):(e.exit("blockQuotePrefix"),t(o))}}function nK(e,t,n){const r=this;return i;function i(o){return Fe(o)?qe(e,s,"linePrefix",r.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(o):s(o)}function s(o){return e.attempt(l5,t,n)(o)}}function rK(e){e.exit("blockQuote")}const c5={name:"characterEscape",tokenize:iK};function iK(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 Wq(s)?(e.enter("characterEscapeValue"),e.consume(s),e.exit("characterEscapeValue"),e.exit("characterEscape"),t):n(s)}}const u5={name:"characterReference",tokenize:sK};function sK(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=bn,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=Uq,u):(e.enter("characterReferenceValue"),s=7,o=O0,u(d))}function u(d){if(d===59&&i){const f=e.exit("characterReferenceValue");return o===bn&&!Uy(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 rk={partial:!0,tokenize:aK},ik={concrete:!0,name:"codeFenced",tokenize:oK};function oK(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 N=r.events[r.events.length-1];return s=N&&N[1].type==="linePrefix"?N[2].sliceSerialize(N[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"),Fe(k)?qe(e,d,"whitespace")(k):d(k))}function d(k){return k===null||Se(k)?(e.exit("codeFencedFence"),r.interrupt?t(k):e.check(rk,v,S)(k)):(e.enter("codeFencedFenceInfo"),e.enter("chunkString",{contentType:"string"}),f(k))}function f(k){return k===null||Se(k)?(e.exit("chunkString"),e.exit("codeFencedFenceInfo"),d(k)):Fe(k)?(e.exit("chunkString"),e.exit("codeFencedFenceInfo"),qe(e,p,"whitespace")(k)):k===96&&k===a?n(k):(e.consume(k),f)}function p(k){return k===null||Se(k)?d(k):(e.enter("codeFencedFenceMeta"),e.enter("chunkString",{contentType:"string"}),m(k))}function m(k){return k===null||Se(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,S,b)(k)}function b(k){return e.enter("lineEnding"),e.consume(k),e.exit("lineEnding"),x}function x(k){return s>0&&Fe(k)?qe(e,_,"linePrefix",s+1)(k):_(k)}function _(k){return k===null||Se(k)?e.check(rk,v,S)(k):(e.enter("codeFlowValue"),y(k))}function y(k){return k===null||Se(k)?(e.exit("codeFlowValue"),_(k)):(e.consume(k),y)}function S(k){return e.exit("codeFenced"),t(k)}function C(k,N,T){let z=0;return I;function I(D){return k.enter("lineEnding"),k.consume(D),k.exit("lineEnding"),M}function M(D){return k.enter("codeFencedFence"),Fe(D)?qe(k,L,"linePrefix",r.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(D):L(D)}function L(D){return D===a?(k.enter("codeFencedFenceSequence"),R(D)):T(D)}function R(D){return D===a?(z++,k.consume(D),R):z>=o?(k.exit("codeFencedFenceSequence"),Fe(D)?qe(k,A,"whitespace")(D):A(D)):T(D)}function A(D){return D===null||Se(D)?(k.exit("codeFencedFence"),N(D)):T(D)}}}function aK(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 Ym={name:"codeIndented",tokenize:cK},lK={partial:!0,tokenize:uK};function cK(e,t,n){const r=this;return i;function i(c){return e.enter("codeIndented"),qe(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):Se(c)?e.attempt(lK,o,l)(c):(e.enter("codeFlowValue"),a(c))}function a(c){return c===null||Se(c)?(e.exit("codeFlowValue"),o(c)):(e.consume(c),a)}function l(c){return e.exit("codeIndented"),t(c)}}function uK(e,t,n){const r=this;return i;function i(o){return r.parser.lazy[r.now().line]?n(o):Se(o)?(e.enter("lineEnding"),e.consume(o),e.exit("lineEnding"),i):qe(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):Se(o)?i(o):n(o)}}const dK={name:"codeText",previous:fK,resolve:hK,tokenize:pK};function hK(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 fK(e){return e!==96||this.events[this.events.length-1][1].type==="characterEscape"}function pK(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)):Se(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||Se(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 mK{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&&zl(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),zl(this.left,t)}unshift(t){this.setCursor(0),this.right.push(t)}unshiftMany(t){this.setCursor(0),zl(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);zl(this.right,n.reverse())}else{const n=this.right.splice(this.left.length+this.right.length-t,Number.POSITIVE_INFINITY);zl(this.left,n.reverse())}}}function zl(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 d5(e){const t={};let n=-1,r,i,s,o,a,l,c;const u=new mK(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,gK(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 rr(e,0,Number.POSITIVE_INFINITY,u.slice(0)),!c}function gK(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 x=a.slice(b[f],b[f+1]),_=s.pop();l.push([_,_+x.length-1]),e.splice(_,2,x)}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 vK={resolve:_K,tokenize:yK},xK={partial:!0,tokenize:bK};function _K(e){return d5(e),e}function yK(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):Se(a)?e.check(xK,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 bK(e,t,n){const r=this;return i;function i(o){return e.exit("chunkContent"),e.enter("lineEnding"),e.consume(o),e.exit("lineEnding"),qe(e,s,"linePrefix")}function s(o){if(o===null||Se(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 h5(e,t,n,r,i,s,o,a,l){const c=l||Number.POSITIVE_INFINITY;let u=0;return d;function d(x){return x===60?(e.enter(r),e.enter(i),e.enter(s),e.consume(x),e.exit(s),f):x===null||x===32||x===41||df(x)?n(x):(e.enter(r),e.enter(o),e.enter(a),e.enter("chunkString",{contentType:"string"}),v(x))}function f(x){return x===62?(e.enter(s),e.consume(x),e.exit(s),e.exit(i),e.exit(r),t):(e.enter(a),e.enter("chunkString",{contentType:"string"}),p(x))}function p(x){return x===62?(e.exit("chunkString"),e.exit(a),f(x)):x===null||x===60||Se(x)?n(x):(e.consume(x),x===92?m:p)}function m(x){return x===60||x===62||x===92?(e.consume(x),p):p(x)}function v(x){return!u&&(x===null||x===41||ot(x))?(e.exit("chunkString"),e.exit(a),e.exit(o),e.exit(r),t(x)):u<c&&x===40?(e.consume(x),u++,v):x===41?(e.consume(x),u--,v):x===null||x===32||x===40||df(x)?n(x):(e.consume(x),x===92?b:v)}function b(x){return x===40||x===41||x===92?(e.consume(x),v):v(x)}}function f5(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):Se(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||Se(p)||a++>999?(e.exit("chunkString"),u(p)):(e.consume(p),l||(l=!Fe(p)),p===92?f:d)}function f(p){return p===91||p===92||p===93?(e.consume(p),a++,d):d(p)}}function p5(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):Se(f)?(e.enter("lineEnding"),e.consume(f),e.exit("lineEnding"),qe(e,c,"linePrefix")):(e.enter("chunkString",{contentType:"string"}),u(f))}function u(f){return f===o||f===null||Se(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 wc(e,t){let n;return r;function r(i){return Se(i)?(e.enter("lineEnding"),e.consume(i),e.exit("lineEnding"),n=!0,r):Fe(i)?qe(e,r,n?"linePrefix":"lineSuffix")(i):t(i)}}const wK={name:"definition",tokenize:kK},SK={partial:!0,tokenize:CK};function kK(e,t,n){const r=this;let i;return s;function s(p){return e.enter("definition"),o(p)}function o(p){return f5.call(r,e,a,n,"definitionLabel","definitionLabelMarker","definitionLabelString")(p)}function a(p){return i=Lr(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)?wc(e,c)(p):c(p)}function c(p){return h5(e,u,n,"definitionDestination","definitionDestinationLiteral","definitionDestinationLiteralMarker","definitionDestinationRaw","definitionDestinationString")(p)}function u(p){return e.attempt(SK,d,d)(p)}function d(p){return Fe(p)?qe(e,f,"whitespace")(p):f(p)}function f(p){return p===null||Se(p)?(e.exit("definition"),r.parser.defined.push(i),t(p)):n(p)}}function CK(e,t,n){return r;function r(a){return ot(a)?wc(e,i)(a):n(a)}function i(a){return p5(e,s,n,"definitionTitle","definitionTitleMarker","definitionTitleString")(a)}function s(a){return Fe(a)?qe(e,o,"whitespace")(a):o(a)}function o(a){return a===null||Se(a)?t(a):n(a)}}const EK={name:"hardBreakEscape",tokenize:NK};function NK(e,t,n){return r;function r(s){return e.enter("hardBreakEscape"),e.consume(s),i}function i(s){return Se(s)?(e.exit("hardBreakEscape"),t(s)):n(s)}}const TK={name:"headingAtx",resolve:IK,tokenize:PK};function IK(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"},rr(e,r,n-r+1,[["enter",i,t],["enter",s,t],["exit",s,t],["exit",i,t]])),e}function PK(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||Se(u)?(e.exit("atxHeading"),t(u)):Fe(u)?qe(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 RK=["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"],sk=["pre","script","style","textarea"],MK={concrete:!0,name:"htmlFlow",resolveTo:LK,tokenize:DK},AK={partial:!0,tokenize:BK},jK={partial:!0,tokenize:OK};function LK(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 DK(e,t,n){const r=this;let i,s,o,a,l;return c;function c(j){return u(j)}function u(j){return e.enter("htmlFlow"),e.enter("htmlFlowData"),e.consume(j),d}function d(j){return j===33?(e.consume(j),f):j===47?(e.consume(j),s=!0,v):j===63?(e.consume(j),i=3,r.interrupt?t:E):Tn(j)?(e.consume(j),o=String.fromCharCode(j),b):n(j)}function f(j){return j===45?(e.consume(j),i=2,p):j===91?(e.consume(j),i=5,a=0,m):Tn(j)?(e.consume(j),i=4,r.interrupt?t:E):n(j)}function p(j){return j===45?(e.consume(j),r.interrupt?t:E):n(j)}function m(j){const ne="CDATA[";return j===ne.charCodeAt(a++)?(e.consume(j),a===ne.length?r.interrupt?t:L:m):n(j)}function v(j){return Tn(j)?(e.consume(j),o=String.fromCharCode(j),b):n(j)}function b(j){if(j===null||j===47||j===62||ot(j)){const ne=j===47,re=o.toLowerCase();return!ne&&!s&&sk.includes(re)?(i=1,r.interrupt?t(j):L(j)):RK.includes(o.toLowerCase())?(i=6,ne?(e.consume(j),x):r.interrupt?t(j):L(j)):(i=7,r.interrupt&&!r.parser.lazy[r.now().line]?n(j):s?_(j):y(j))}return j===45||bn(j)?(e.consume(j),o+=String.fromCharCode(j),b):n(j)}function x(j){return j===62?(e.consume(j),r.interrupt?t:L):n(j)}function _(j){return Fe(j)?(e.consume(j),_):I(j)}function y(j){return j===47?(e.consume(j),I):j===58||j===95||Tn(j)?(e.consume(j),S):Fe(j)?(e.consume(j),y):I(j)}function S(j){return j===45||j===46||j===58||j===95||bn(j)?(e.consume(j),S):C(j)}function C(j){return j===61?(e.consume(j),k):Fe(j)?(e.consume(j),C):y(j)}function k(j){return j===null||j===60||j===61||j===62||j===96?n(j):j===34||j===39?(e.consume(j),l=j,N):Fe(j)?(e.consume(j),k):T(j)}function N(j){return j===l?(e.consume(j),l=null,z):j===null||Se(j)?n(j):(e.consume(j),N)}function T(j){return j===null||j===34||j===39||j===47||j===60||j===61||j===62||j===96||ot(j)?C(j):(e.consume(j),T)}function z(j){return j===47||j===62||Fe(j)?y(j):n(j)}function I(j){return j===62?(e.consume(j),M):n(j)}function M(j){return j===null||Se(j)?L(j):Fe(j)?(e.consume(j),M):n(j)}function L(j){return j===45&&i===2?(e.consume(j),$):j===60&&i===1?(e.consume(j),F):j===62&&i===4?(e.consume(j),H):j===63&&i===3?(e.consume(j),E):j===93&&i===5?(e.consume(j),B):Se(j)&&(i===6||i===7)?(e.exit("htmlFlowData"),e.check(AK,q,R)(j)):j===null||Se(j)?(e.exit("htmlFlowData"),R(j)):(e.consume(j),L)}function R(j){return e.check(jK,A,q)(j)}function A(j){return e.enter("lineEnding"),e.consume(j),e.exit("lineEnding"),D}function D(j){return j===null||Se(j)?R(j):(e.enter("htmlFlowData"),L(j))}function $(j){return j===45?(e.consume(j),E):L(j)}function F(j){return j===47?(e.consume(j),o="",O):L(j)}function O(j){if(j===62){const ne=o.toLowerCase();return sk.includes(ne)?(e.consume(j),H):L(j)}return Tn(j)&&o.length<8?(e.consume(j),o+=String.fromCharCode(j),O):L(j)}function B(j){return j===93?(e.consume(j),E):L(j)}function E(j){return j===62?(e.consume(j),H):j===45&&i===2?(e.consume(j),E):L(j)}function H(j){return j===null||Se(j)?(e.exit("htmlFlowData"),q(j)):(e.consume(j),H)}function q(j){return e.exit("htmlFlow"),t(j)}}function OK(e,t,n){const r=this;return i;function i(o){return Se(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 BK(e,t,n){return r;function r(i){return e.enter("lineEnding"),e.consume(i),e.exit("lineEnding"),e.attempt(Au,t,n)}}const zK={name:"htmlText",tokenize:$K};function $K(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):Tn(E)?(e.consume(E),T):n(E)}function c(E){return E===45?(e.consume(E),u):E===91?(e.consume(E),s=0,m):Tn(E)?(e.consume(E),_):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):Se(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):Se(E)?(o=v,F(E)):(e.consume(E),v)}function b(E){return E===93?(e.consume(E),x):v(E)}function x(E){return E===62?$(E):E===93?(e.consume(E),x):v(E)}function _(E){return E===null||E===62?$(E):Se(E)?(o=_,F(E)):(e.consume(E),_)}function y(E){return E===null?n(E):E===63?(e.consume(E),S):Se(E)?(o=y,F(E)):(e.consume(E),y)}function S(E){return E===62?$(E):y(E)}function C(E){return Tn(E)?(e.consume(E),k):n(E)}function k(E){return E===45||bn(E)?(e.consume(E),k):N(E)}function N(E){return Se(E)?(o=N,F(E)):Fe(E)?(e.consume(E),N):$(E)}function T(E){return E===45||bn(E)?(e.consume(E),T):E===47||E===62||ot(E)?z(E):n(E)}function z(E){return E===47?(e.consume(E),$):E===58||E===95||Tn(E)?(e.consume(E),I):Se(E)?(o=z,F(E)):Fe(E)?(e.consume(E),z):$(E)}function I(E){return E===45||E===46||E===58||E===95||bn(E)?(e.consume(E),I):M(E)}function M(E){return E===61?(e.consume(E),L):Se(E)?(o=M,F(E)):Fe(E)?(e.consume(E),M):z(E)}function L(E){return E===null||E===60||E===61||E===62||E===96?n(E):E===34||E===39?(e.consume(E),i=E,R):Se(E)?(o=L,F(E)):Fe(E)?(e.consume(E),L):(e.consume(E),A)}function R(E){return E===i?(e.consume(E),i=void 0,D):E===null?n(E):Se(E)?(o=R,F(E)):(e.consume(E),R)}function A(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),A)}function D(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"),O}function O(E){return Fe(E)?qe(e,B,"linePrefix",r.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(E):B(E)}function B(E){return e.enter("htmlTextData"),o(E)}}const Wy={name:"labelEnd",resolveAll:WK,resolveTo:VK,tokenize:qK},FK={tokenize:KK},HK={tokenize:GK},UK={tokenize:YK};function WK(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&&rr(e,0,e.length,n),e}function VK(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=mr(a,e.slice(s+1,s+r+3)),a=mr(a,[["enter",u,t]]),a=mr(a,Np(t.parser.constructs.insideSpan.null,e.slice(s+r+4,o-3),t)),a=mr(a,[["exit",u,t],e[o-2],e[o-1],["exit",c,t]]),a=mr(a,e.slice(o+1)),a=mr(a,[["exit",l,t]]),rr(e,s,e.length,a),e}function qK(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(Lr(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(FK,u,o?u:d)(f):f===91?e.attempt(HK,u,o?c:d)(f):o?u(f):d(f)}function c(f){return e.attempt(UK,u,d)(f)}function u(f){return t(f)}function d(f){return s._balanced=!0,n(f)}}function KK(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)?wc(e,s)(d):s(d)}function s(d){return d===41?u(d):h5(e,o,a,"resourceDestination","resourceDestinationLiteral","resourceDestinationLiteralMarker","resourceDestinationRaw","resourceDestinationString",32)(d)}function o(d){return ot(d)?wc(e,l)(d):u(d)}function a(d){return n(d)}function l(d){return d===34||d===39||d===40?p5(e,c,n,"resourceTitle","resourceTitleMarker","resourceTitleString")(d):u(d)}function c(d){return ot(d)?wc(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 GK(e,t,n){const r=this;return i;function i(a){return f5.call(r,e,s,o,"reference","referenceMarker","referenceString")(a)}function s(a){return r.parser.defined.includes(Lr(r.sliceSerialize(r.events[r.events.length-1][1]).slice(1,-1)))?t(a):n(a)}function o(a){return n(a)}}function YK(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 XK={name:"labelStartImage",resolveAll:Wy.resolveAll,tokenize:ZK};function ZK(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 QK={name:"labelStartLink",resolveAll:Wy.resolveAll,tokenize:JK};function JK(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 Xm={name:"lineEnding",tokenize:eG};function eG(e,t){return n;function n(r){return e.enter("lineEnding"),e.consume(r),e.exit("lineEnding"),qe(e,t,"linePrefix")}}const lh={name:"thematicBreak",tokenize:tG};function tG(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||Se(c))?(e.exit("thematicBreak"),t(c)):n(c)}function l(c){return c===i?(e.consume(c),r++,l):(e.exit("thematicBreakSequence"),Fe(c)?qe(e,a,"whitespace")(c):a(c))}}const $n={continuation:{tokenize:sG},exit:aG,name:"list",tokenize:iG},nG={partial:!0,tokenize:lG},rG={partial:!0,tokenize:oG};function iG(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:O0(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(lh,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 O0(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(Au,r.interrupt?n:u,e.attempt(nG,f,d))}function u(p){return r.containerState.initialBlankLine=!0,s++,f(p)}function d(p){return Fe(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 sG(e,t,n){const r=this;return r.containerState._closeFlow=void 0,e.check(Au,i,s);function i(a){return r.containerState.furtherBlankLines=r.containerState.furtherBlankLines||r.containerState.initialBlankLine,qe(e,t,"listItemIndent",r.containerState.size+1)(a)}function s(a){return r.containerState.furtherBlankLines||!Fe(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(rG,t,o)(a))}function o(a){return r.containerState._closeFlow=!0,r.interrupt=void 0,qe(e,e.attempt($n,t,n),"linePrefix",r.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(a)}}function oG(e,t,n){const r=this;return qe(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 aG(e){e.exit(this.containerState.type)}function lG(e,t,n){const r=this;return qe(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!Fe(s)&&o&&o[1].type==="listItemPrefixWhitespace"?t(s):n(s)}}const ok={name:"setextUnderline",resolveTo:cG,tokenize:uG};function cG(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 uG(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"),Fe(c)?qe(e,l,"lineSuffix")(c):l(c))}function l(c){return c===null||Se(c)?(e.exit("setextHeadingLine"),t(c)):n(c)}}const dG={tokenize:hG};function hG(e){const t=this,n=e.attempt(Au,r,e.attempt(this.parser.constructs.flowInitial,i,qe(e,e.attempt(this.parser.constructs.flow,i,e.attempt(vK,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 fG={resolveAll:g5()},pG=m5("string"),mG=m5("text");function m5(e){return{resolveAll:g5(e==="text"?gG: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 g5(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 gG(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 vG={42:$n,43:$n,45:$n,48:$n,49:$n,50:$n,51:$n,52:$n,53:$n,54:$n,55:$n,56:$n,57:$n,62:l5},xG={91:wK},_G={[-2]:Ym,[-1]:Ym,32:Ym},yG={35:TK,42:lh,45:[ok,lh],60:MK,61:ok,95:lh,96:ik,126:ik},bG={38:u5,92:c5},wG={[-5]:Xm,[-4]:Xm,[-3]:Xm,33:XK,38:u5,42:B0,60:[Qq,zK],91:QK,92:[EK,c5],93:Wy,95:B0,96:dK},SG={null:[B0,fG]},kG={null:[42,95]},CG={null:[]},EG=Object.freeze(Object.defineProperty({__proto__:null,attentionMarkers:kG,contentInitial:xG,disable:CG,document:vG,flow:yG,flowInitial:_G,insideSpan:SG,string:bG,text:wG},Symbol.toStringTag,{value:"Module"}));function NG(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:N(C),check:N(k),consume:_,enter:y,exit:S,interrupt:N(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(M){return o=mr(o,M),b(),o[o.length-1]!==null?[]:(T(t,0),c.events=Np(s,c.events,c),c.events)}function f(M,L){return IG(p(M),L)}function p(M){return TG(o,M)}function m(){const{_bufferIndex:M,_index:L,line:R,column:A,offset:D}=r;return{_bufferIndex:M,_index:L,line:R,column:A,offset:D}}function v(M){i[M.line]=M.column,I()}function b(){let M;for(;r._index<o.length;){const L=o[r._index];if(typeof L=="string")for(M=r._index,r._bufferIndex<0&&(r._bufferIndex=0);r._index===M&&r._bufferIndex<L.length;)x(L.charCodeAt(r._bufferIndex));else x(L)}}function x(M){u=u(M)}function _(M){Se(M)?(r.line++,r.column=1,r.offset+=M===-3?2:1,I()):M!==-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=M}function y(M,L){const R=L||{};return R.type=M,R.start=m(),c.events.push(["enter",R,c]),a.push(R),R}function S(M){const L=a.pop();return L.end=m(),c.events.push(["exit",L,c]),L}function C(M,L){T(M,L.from)}function k(M,L){L.restore()}function N(M,L){return R;function R(A,D,$){let F,O,B,E;return Array.isArray(A)?q(A):"tokenize"in A?q([A]):H(A);function H(G){return ve;function ve(ze){const he=ze!==null&&G[ze],Ie=ze!==null&&G.null,Re=[...Array.isArray(he)?he:he?[he]:[],...Array.isArray(Ie)?Ie:Ie?[Ie]:[]];return q(Re)(ze)}}function q(G){return F=G,O=0,G.length===0?$:j(G[O])}function j(G){return ve;function ve(ze){return E=z(),B=G,G.partial||(c.currentConstruct=G),G.name&&c.parser.constructs.disable.null.includes(G.name)?re():G.tokenize.call(L?Object.assign(Object.create(c),L):c,l,ne,re)(ze)}}function ne(G){return M(B,E),D}function re(G){return E.restore(),++O<F.length?j(F[O]):$}}}function T(M,L){M.resolveAll&&!s.includes(M)&&s.push(M),M.resolve&&rr(c.events,L,c.events.length-L,M.resolve(c.events.slice(L),c)),M.resolveTo&&(c.events=M.resolveTo(c.events,c))}function z(){const M=m(),L=c.previous,R=c.currentConstruct,A=c.events.length,D=Array.from(a);return{from:A,restore:$};function $(){r=M,c.previous=L,c.currentConstruct=R,c.events.length=A,a=D,I()}}function I(){r.line in i&&r.column<2&&(r.column=i[r.line],r.offset+=i[r.line]-1)}}function TG(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 IG(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=`
|
|
508
508
|
`;break}case-3:{o=`\r
|
|
509
509
|
`;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 PG(e){const r={constructs:o5([EG,...(e||{}).extensions||[]]),content:i(Vq),defined:[],document:i(Kq),flow:i(dG),lazy:{},string:i(pG),text:i(mG)};return r;function i(s){return o;function o(a){return NG(r,s,a)}}}function RG(e){for(;!d5(e););return e}const ak=/[\0\t\n\r]/g;function MG(){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(ak.lastIndex=d,c=ak.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 AG=/\\([!-/:-@[-`{-~])|&(#(?:\d{1,7}|x[\da-f]{1,6})|[\da-z]{1,31});/gi;function jG(e){return e.replace(AG,LG)}function LG(e,t,n){if(t)return t;if(n.charCodeAt(0)===35){const i=n.charCodeAt(1),s=i===120||i===88;return a5(n.slice(s?2:1),s?16:10)}return Uy(n)||e}const v5={}.hasOwnProperty;function DG(e,t,n){return t&&typeof t=="object"&&(n=t,t=void 0),OG(n)(RG(PG(n).document().write(MG()(e,t,!0))))}function OG(e){const t={transforms:[],canContainEols:["emphasis","fragment","heading","paragraph","strong"],enter:{autolink:s(gt),autolinkProtocol:z,autolinkEmail:z,atxHeading:s(Cn),blockQuote:s(Ie),characterEscape:z,characterReference:z,codeFenced:s(Re),codeFencedFenceInfo:o,codeFencedFenceMeta:o,codeIndented:s(Re,o),codeText:s(Ve,o),codeTextData:z,data:z,codeFlowValue:z,definition:s(xe),definitionDestinationString:o,definitionLabelString:o,definitionTitleString:o,emphasis:s(Ke),hardBreakEscape:s(it),hardBreakTrailing:s(it),htmlFlow:s(ct,o),htmlFlowData:z,htmlText:s(ct,o),htmlTextData:z,image:s(on),label:o,link:s(gt),listItem:s(Xe),listItemValue:f,listOrdered:s(vt,d),listUnordered:s(vt),paragraph:s(st),reference:j,referenceString:o,resourceDestinationString:o,resourceTitleString:o,setextHeading:s(Cn),strong:s(At),thematicBreak:s(pn)},exit:{atxHeading:l(),atxHeadingSequence:C,autolink:l(),autolinkEmail:he,autolinkProtocol:ze,blockQuote:l(),characterEscapeValue:I,characterReferenceMarkerHexadecimal:re,characterReferenceMarkerNumeric:re,characterReferenceValue:G,characterReference:ve,codeFenced:l(b),codeFencedFence:v,codeFencedFenceInfo:p,codeFencedFenceMeta:m,codeFlowValue:I,codeIndented:l(x),codeText:l(D),codeTextData:I,data:I,definition:l(),definitionDestinationString:S,definitionLabelString:_,definitionTitleString:y,emphasis:l(),hardBreakEscape:l(L),hardBreakTrailing:l(L),htmlFlow:l(R),htmlFlowData:I,htmlText:l(A),htmlTextData:I,image:l(F),label:B,labelText:O,lineEnding:M,link:l($),listItem:l(),listOrdered:l(),listUnordered:l(),paragraph:l(),referenceString:ne,resourceDestinationString:E,resourceTitleString:H,resource:q,setextHeading:l(T),setextHeadingLineSequence:N,setextHeadingText:k,strong:l(),thematicBreak:l()}};x5(t,(e||{}).mdastExtensions||[]);const n={};return r;function r(U){let J={type:"root",children:[]};const ye={stack:[J],tokenStack:[],config:t,enter:a,exit:c,buffer:o,resume:u,data:n},ke=[];let Ue=-1;for(;++Ue<U.length;)if(U[Ue][1].type==="listOrdered"||U[Ue][1].type==="listUnordered")if(U[Ue][0]==="enter")ke.push(Ue);else{const kt=ke.pop();Ue=i(U,kt,Ue)}for(Ue=-1;++Ue<U.length;){const kt=t[U[Ue][0]];v5.call(kt,U[Ue][1].type)&&kt[U[Ue][1].type].call(Object.assign({sliceSerialize:U[Ue][2].sliceSerialize},ye),U[Ue][1])}if(ye.tokenStack.length>0){const kt=ye.tokenStack[ye.tokenStack.length-1];(kt[1]||lk).call(ye,void 0,kt[0])}for(J.position={start:es(U.length>0?U[0][1].start:{line:1,column:1,offset:0}),end:es(U.length>0?U[U.length-2][1].end:{line:1,column:1,offset:0})},Ue=-1;++Ue<t.transforms.length;)J=t.transforms[Ue](J)||J;return J}function i(U,J,ye){let ke=J-1,Ue=-1,kt=!1,an,Ft,le,K;for(;++ke<=ye;){const we=U[ke];switch(we[1].type){case"listUnordered":case"listOrdered":case"blockQuote":{we[0]==="enter"?Ue++:Ue--,K=void 0;break}case"lineEndingBlank":{we[0]==="enter"&&(an&&!K&&!Ue&&!le&&(le=ke),K=void 0);break}case"linePrefix":case"listItemValue":case"listItemMarker":case"listItemPrefix":case"listItemPrefixWhitespace":break;default:K=void 0}if(!Ue&&we[0]==="enter"&&we[1].type==="listItemPrefix"||Ue===-1&&we[0]==="exit"&&(we[1].type==="listUnordered"||we[1].type==="listOrdered")){if(an){let ft=ke;for(Ft=void 0;ft--;){const ln=U[ft];if(ln[1].type==="lineEnding"||ln[1].type==="lineEndingBlank"){if(ln[0]==="exit")continue;Ft&&(U[Ft][1].type="lineEndingBlank",kt=!0),ln[1].type="lineEnding",Ft=ft}else if(!(ln[1].type==="linePrefix"||ln[1].type==="blockQuotePrefix"||ln[1].type==="blockQuotePrefixWhitespace"||ln[1].type==="blockQuoteMarker"||ln[1].type==="listItemIndent"))break}le&&(!Ft||le<Ft)&&(an._spread=!0),an.end=Object.assign({},Ft?U[Ft][1].start:we[1].end),U.splice(Ft||ke,0,["exit",an,we[2]]),ke++,ye++}if(we[1].type==="listItemPrefix"){const ft={type:"listItem",_spread:!1,start:Object.assign({},we[1].start),end:void 0};an=ft,U.splice(ke,0,["enter",ft,we[2]]),ke++,ye++,le=void 0,K=!0}}}return U[J][1]._spread=kt,ye}function s(U,J){return ye;function ye(ke){a.call(this,U(ke),ke),J&&J.call(this,ke)}}function o(){this.stack.push({type:"fragment",children:[]})}function a(U,J,ye){this.stack[this.stack.length-1].children.push(U),this.stack.push(U),this.tokenStack.push([J,ye||void 0]),U.position={start:es(J.start),end:void 0}}function l(U){return J;function J(ye){U&&U.call(this,ye),c.call(this,ye)}}function c(U,J){const ye=this.stack.pop(),ke=this.tokenStack.pop();if(ke)ke[0].type!==U.type&&(J?J.call(this,U,ke[0]):(ke[1]||lk).call(this,U,ke[0]));else throw new Error("Cannot close `"+U.type+"` ("+bc({start:U.start,end:U.end})+"): it’s not open");ye.position.end=es(U.end)}function u(){return Hy(this.stack.pop())}function d(){this.data.expectingFirstListItemValue=!0}function f(U){if(this.data.expectingFirstListItemValue){const J=this.stack[this.stack.length-2];J.start=Number.parseInt(this.sliceSerialize(U),10),this.data.expectingFirstListItemValue=void 0}}function p(){const U=this.resume(),J=this.stack[this.stack.length-1];J.lang=U}function m(){const U=this.resume(),J=this.stack[this.stack.length-1];J.meta=U}function v(){this.data.flowCodeInside||(this.buffer(),this.data.flowCodeInside=!0)}function b(){const U=this.resume(),J=this.stack[this.stack.length-1];J.value=U.replace(/^(\r?\n|\r)|(\r?\n|\r)$/g,""),this.data.flowCodeInside=void 0}function x(){const U=this.resume(),J=this.stack[this.stack.length-1];J.value=U.replace(/(\r?\n|\r)$/g,"")}function _(U){const J=this.resume(),ye=this.stack[this.stack.length-1];ye.label=J,ye.identifier=Lr(this.sliceSerialize(U)).toLowerCase()}function y(){const U=this.resume(),J=this.stack[this.stack.length-1];J.title=U}function S(){const U=this.resume(),J=this.stack[this.stack.length-1];J.url=U}function C(U){const J=this.stack[this.stack.length-1];if(!J.depth){const ye=this.sliceSerialize(U).length;J.depth=ye}}function k(){this.data.setextHeadingSlurpLineEnding=!0}function N(U){const J=this.stack[this.stack.length-1];J.depth=this.sliceSerialize(U).codePointAt(0)===61?1:2}function T(){this.data.setextHeadingSlurpLineEnding=void 0}function z(U){const ye=this.stack[this.stack.length-1].children;let ke=ye[ye.length-1];(!ke||ke.type!=="text")&&(ke=Xt(),ke.position={start:es(U.start),end:void 0},ye.push(ke)),this.stack.push(ke)}function I(U){const J=this.stack.pop();J.value+=this.sliceSerialize(U),J.position.end=es(U.end)}function M(U){const J=this.stack[this.stack.length-1];if(this.data.atHardBreak){const ye=J.children[J.children.length-1];ye.position.end=es(U.end),this.data.atHardBreak=void 0;return}!this.data.setextHeadingSlurpLineEnding&&t.canContainEols.includes(J.type)&&(z.call(this,U),I.call(this,U))}function L(){this.data.atHardBreak=!0}function R(){const U=this.resume(),J=this.stack[this.stack.length-1];J.value=U}function A(){const U=this.resume(),J=this.stack[this.stack.length-1];J.value=U}function D(){const U=this.resume(),J=this.stack[this.stack.length-1];J.value=U}function $(){const U=this.stack[this.stack.length-1];if(this.data.inReference){const J=this.data.referenceType||"shortcut";U.type+="Reference",U.referenceType=J,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 J=this.data.referenceType||"shortcut";U.type+="Reference",U.referenceType=J,delete U.url,delete U.title}else delete U.identifier,delete U.label;this.data.referenceType=void 0}function O(U){const J=this.sliceSerialize(U),ye=this.stack[this.stack.length-2];ye.label=jG(J),ye.identifier=Lr(J).toLowerCase()}function B(){const U=this.stack[this.stack.length-1],J=this.resume(),ye=this.stack[this.stack.length-1];if(this.data.inReference=!0,ye.type==="link"){const ke=U.children;ye.children=ke}else ye.alt=J}function E(){const U=this.resume(),J=this.stack[this.stack.length-1];J.url=U}function H(){const U=this.resume(),J=this.stack[this.stack.length-1];J.title=U}function q(){this.data.inReference=void 0}function j(){this.data.referenceType="collapsed"}function ne(U){const J=this.resume(),ye=this.stack[this.stack.length-1];ye.label=J,ye.identifier=Lr(this.sliceSerialize(U)).toLowerCase(),this.data.referenceType="full"}function re(U){this.data.characterReferenceType=U.type}function G(U){const J=this.sliceSerialize(U),ye=this.data.characterReferenceType;let ke;ye?(ke=a5(J,ye==="characterReferenceMarkerNumeric"?10:16),this.data.characterReferenceType=void 0):ke=Uy(J);const Ue=this.stack[this.stack.length-1];Ue.value+=ke}function ve(U){const J=this.stack.pop();J.position.end=es(U.end)}function ze(U){I.call(this,U);const J=this.stack[this.stack.length-1];J.url=this.sliceSerialize(U)}function he(U){I.call(this,U);const J=this.stack[this.stack.length-1];J.url="mailto:"+this.sliceSerialize(U)}function Ie(){return{type:"blockquote",children:[]}}function Re(){return{type:"code",lang:null,meta:null,value:""}}function Ve(){return{type:"inlineCode",value:""}}function xe(){return{type:"definition",identifier:"",label:null,title:null,url:""}}function Ke(){return{type:"emphasis",children:[]}}function Cn(){return{type:"heading",depth:0,children:[]}}function it(){return{type:"break"}}function ct(){return{type:"html",value:""}}function on(){return{type:"image",title:null,url:"",alt:null}}function gt(){return{type:"link",title:null,url:"",children:[]}}function vt(U){return{type:"list",ordered:U.type==="listOrdered",start:null,spread:U._spread,children:[]}}function Xe(U){return{type:"listItem",spread:U._spread,checked:null,children:[]}}function st(){return{type:"paragraph",children:[]}}function At(){return{type:"strong",children:[]}}function Xt(){return{type:"text",value:""}}function pn(){return{type:"thematicBreak"}}}function es(e){return{line:e.line,column:e.column,offset:e.offset}}function x5(e,t){let n=-1;for(;++n<t.length;){const r=t[n];Array.isArray(r)?x5(e,r):BG(e,r)}}function BG(e,t){let n;for(n in t)if(v5.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 lk(e,t){throw e?new Error("Cannot close `"+e.type+"` ("+bc({start:e.start,end:e.end})+"): a different token (`"+t.type+"`, "+bc({start:t.start,end:t.end})+") is open"):new Error("Cannot close document, a token (`"+t.type+"`, "+bc({start:t.start,end:t.end})+") is still open")}function zG(e){const t=this;t.parser=n;function n(r){return DG(r,{...t.data("settings"),...e,extensions:t.data("micromarkExtensions")||[],mdastExtensions:t.data("fromMarkdownExtensions")||[]})}}function $G(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 FG(e,t){const n={type:"element",tagName:"br",properties:{},children:[]};return e.patch(t,n),[e.applyData(t,n),{type:"text",value:`
|
|
@@ -571,7 +571,7 @@ WARNING: This link could potentially be dangerous`)){let n=window.open();if(n){t
|
|
|
571
571
|
* Fabrice Bellard's javascript vt100 for jslinux:
|
|
572
572
|
* http://bellard.org/jslinux/
|
|
573
573
|
* Copyright (c) 2011 Fabrice Bellard
|
|
574
|
-
*/var zre=2,$re=1,Fre=class{activate(e){this._terminal=e}dispose(){}fit(){let e=this.proposeDimensions();if(!e||!this._terminal||isNaN(e.cols)||isNaN(e.rows))return;let t=this._terminal._core;(this._terminal.rows!==e.rows||this._terminal.cols!==e.cols)&&(t._renderService.clear(),this._terminal.resize(e.cols,e.rows))}proposeDimensions(){var d;if(!this._terminal||!this._terminal.element||!this._terminal.element.parentElement)return;let e=this._terminal._core._renderService.dimensions;if(e.css.cell.width===0||e.css.cell.height===0)return;let t=this._terminal.options.scrollback===0?0:((d=this._terminal.options.overviewRuler)==null?void 0:d.width)||14,n=window.getComputedStyle(this._terminal.element.parentElement),r=parseInt(n.getPropertyValue("height")),i=Math.max(0,parseInt(n.getPropertyValue("width"))),s=window.getComputedStyle(this._terminal.element),o={top:parseInt(s.getPropertyValue("padding-top")),bottom:parseInt(s.getPropertyValue("padding-bottom")),right:parseInt(s.getPropertyValue("padding-right")),left:parseInt(s.getPropertyValue("padding-left"))},a=o.top+o.bottom,l=o.right+o.left,c=r-a,u=i-l-t;return{cols:Math.max(zre,Math.floor(u/e.css.cell.width)),rows:Math.max($re,Math.floor(c/e.css.cell.height))}}};let Sg;function kg(){return{count:0,byteSum:0,firstT:null,lastT:null}}const Cg=32,VC=320;function Hre({sessionId:e,client:t}){const n=g.useRef(null),r=g.useRef(null),i=g.useRef(null),s=g.useRef([]),o=g.useRef(kg()),a=g.useRef(!1),[l,c]=g.useState("collapsed"),[u,d]=g.useState(null);g.useEffect(()=>{const v=n.current;if(!v)return;let b=!1;const x=(N,T)=>getComputedStyle(document.documentElement).getPropertyValue(N).trim()||T,_=x("--bg-0","#1B1B1B"),y=x("--text-100","#ECECEC"),S=new Bre({fontFamily:"ui-monospace, SF Mono, Menlo, monospace",fontSize:12,lineHeight:1.2,theme:{background:_,foreground:y},minimumContrastRatio:4.5,cursorBlink:!0,convertEol:!1,scrollback:5e3,allowProposedApi:!0,cols:120,rows:40}),C=new Fre;S.loadAddon(C),Ae("xterm-mount",{sessionId:e,hostChildCount:v.childNodes.length}),Sg!==e&&(Ae("xterm-trace",`===== SWITCH ${Sg??"(initial)"} → ${e} =====`),Sg=e),Ae("xterm-trace","effect-setup-start",{sessionId:e,t:performance.now()}),o.current=kg(),S.open(v);const k=S.onData(N=>{const T=btoa(unescape(encodeURIComponent(N)));t.request("session:pty:input",{sessionId:e,data:T}).catch(()=>{})});return(async()=>{var R;let N=0,T=null,z=null;try{Ae("xterm-trace","snapshot-rpc-start",{sessionId:e,t:performance.now()});const A=await t.request("session:pty:snapshot",{sessionId:e});if(Ae("xterm-trace","snapshot-rpc-resolved",{sessionId:e,cancelled:b,byteLen:((R=A==null?void 0:A.data)==null?void 0:R.length)??0,atSeq:A==null?void 0:A.atSeq,t:performance.now()}),b)return;if(A!=null&&A.ok&&typeof A.data=="string"&&A.data.length>0){const D=atob(A.data),$=new Uint8Array(D.length);for(let F=0;F<D.length;F++)$[F]=D.charCodeAt(F);T=$}A!=null&&A.ok&&typeof A.atSeq=="number"&&(N=A.atSeq),A!=null&&A.ok&&A.popupKind!=null&&(z=A.popupKind)}catch{}if(b)return;r.current=S,i.current=C;let I=!1,M;const L=S.onRender(()=>{if(!I){I=!0;try{C.fit(),T&&S.write(T),Ae("xterm-trace","snapshot-flush",{sessionId:e,atSeq:N,pendingFrameCount:s.current.length,frameStatsBeforeFlush:{...o.current},t:performance.now()}),o.current=kg();const A=s.current;s.current=[];let D=0;for(const $ of A){if($.seq!==void 0&&$.seq<=N){D++;continue}S.write($.bytes)}D>0&&Ae("xterm-trace","snapshot-flush-dropped",{sessionId:e,dropped:D,atSeq:N}),a.current=!0,z!=null&&(d(z),c("expanded"),requestAnimationFrame(()=>S.focus())),t.request("session:pty:resize",{sessionId:e,cols:S.cols,rows:S.rows}).catch(()=>{})}catch{}S.scrollToBottom(),M?M():setTimeout(()=>M==null?void 0:M(),0)}});M=()=>L.dispose()})(),()=>{Ae("xterm-trace","cleanup-start",{sessionId:e,pendingFrameCount:s.current.length,termReady:a.current,frameStatsThisMount:{...o.current},t:performance.now()}),b=!0,k.dispose(),S.dispose(),r.current=null,i.current=null,a.current=!1,s.current=[],Ae("xterm-trace","cleanup-cleared-pending",{sessionId:e,t:performance.now()})}},[e,t]),g.useEffect(()=>{const v=t.on("session:pty",x=>{const _=x;if(_.sessionId!==e||typeof _.data!="string")return;const y=o.current;y.count++,y.byteSum+=_.data.length;const S=performance.now();y.firstT===null&&(y.firstT=S),y.lastT=S;try{const C=atob(_.data),k=new Uint8Array(C.length);for(let N=0;N<C.length;N++)k[N]=C.charCodeAt(N);a.current&&r.current?r.current.write(k):s.current.push({seq:_.seq,bytes:k})}catch{}}),b=t.on("session:control",x=>{const _=x;if(_.sessionId===e)switch(_.kind){case"popup_open":(_.popupKind==="permission"||_.popupKind==="question")&&(d(_.popupKind),c("expanded"),requestAnimationFrame(()=>{var y;return(y=r.current)==null?void 0:y.focus()}));break;case"popup_close":d(null),c("collapsed");break}});return()=>{v(),b(),Ae("xterm-trace","cleanup-off-listener",{sessionId:e,t:performance.now()})}},[e,t]),g.useEffect(()=>{const v=n.current;if(!v)return;let b=0,x=0;const _=()=>{const S=i.current,C=r.current;if(!(!S||!C)){try{S.fit()}catch{return}try{C.refresh(0,C.rows-1)}catch{}C.cols===b&&C.rows===x||(b=C.cols,x=C.rows,t.request("session:pty:resize",{sessionId:e,cols:C.cols,rows:C.rows}).catch(()=>{}))}},y=new ResizeObserver(()=>_());return y.observe(v),()=>y.disconnect()},[e,t]);const f=()=>{c(v=>{const b=v==="collapsed"?"expanded":"collapsed";return b==="expanded"&&requestAnimationFrame(()=>{var x;return(x=r.current)==null?void 0:x.focus()}),b})},p=l==="expanded"?VC:Cg,m=VC-Cg;return h.jsxs("div",{className:"border-t border-border bg-bg-0 overflow-hidden",style:{height:p},"data-testid":"xterm-panel","data-state":l,"data-mode":"tui","data-popup-kind":u??"",children:[h.jsxs("button",{type:"button",onClick:f,className:"flex items-center justify-between w-full px-3 py-1 text-xs text-text-200 bg-bg-200 hover:bg-bg-300 cursor-pointer border-b border-border",style:{height:Cg,flexShrink:0},"data-testid":"xterm-panel-toggle",children:[h.jsxs("span",{className:"font-mono",children:[u==="permission"&&"⚠️ CC 需要权限确认 — 在下方终端按数字键 / Enter 选择",u==="question"&&"❓ CC 在问问题 — 在下方终端用 ↑/↓ + Enter 选择",u===null&&(l==="collapsed"?"▴ 展开原生 TUI 终端":"▾ 收起 TUI 终端")]}),h.jsx("span",{className:"text-text-200 text-[10px] opacity-60",children:l==="expanded"?"点击收起":"点击展开"})]}),h.jsx("div",{ref:n,className:"p-1",style:{height:m},"data-testid":"xterm-panel-host"})]})}function oA(e,t){const n=jo(),r=e?`session/${e}`:"",i=ci(r)??Xc,s=g.useCallback(d=>{!e||!r||n.setData(r,f=>VT(f??Xc,d,e))},[n,r,e]),o=g.useCallback(()=>{e&&s({type:"session:change",sessionId:e})},[s,e]),a=g.useCallback(d=>{e&&s({type:"permission:clear",sessionId:e,requestId:d})},[s,e]),l=g.useCallback(d=>{e&&s({type:"permission:request",sessionId:e,requestId:d.requestId,tool:d.tool,input:d.input,...d.toolUseId?{toolUseId:d.toolUseId}:{}})},[s,e]),c=g.useCallback(d=>{e&&s({type:"session:question:clear",sessionId:e,toolUseId:d})},[s,e]),u=g.useCallback((d,f)=>{e&&s({type:"session:question:submitted",sessionId:e,toolUseId:d,answers:f})},[s,e]);return{...i,reset:o,clearPermission:a,restorePermission:l,clearQuestion:c,markQuestionSubmitted:u}}function u1(e){const t=ci(e?`capabilities/${e}`:"");return e?{capabilities:t??null,loading:!t}:{capabilities:null,loading:!1}}function Ure(e){return e.kind!=="user-text"?!1:e.meta===void 0||e.meta==="slash-command"||op(e.meta)}function Wre(e,t={}){let n=0;if(t.implicitCloseOnUserText){for(const r of e)Ure(r)&&n++;return n}for(const r of e)r.kind==="turn-end"&&n++;return n}const Vre=50;function qre({api:e,sessionId:t,toolSessionId:n,initialTurns:r,implicitCloseOnUserText:i,pageSize:s=Vre}){const[o,a]=g.useState({messages:[],total:0,loading:!1,error:null}),l=g.useRef(n),c=g.useRef(null),u=g.useRef(0),d=g.useRef(!0);return g.useEffect(()=>(d.current=!0,()=>{d.current=!1}),[]),g.useEffect(()=>{const f=l.current;if(l.current=n,!(c.current!==t)&&!(typeof f=="string"&&f!==n))return;if(a({messages:[],total:0,loading:!1,error:null}),!t){c.current=null;return}c.current=t;const v=++u.current;a(b=>({...b,loading:!0,error:null})),(async()=>{let b=[],x=!1,_=r===void 0?{}:{limit:s},y=Number.POSITIVE_INFINITY;for(;;){let S;try{S=await e.historyRead({sessionId:t,..._})}catch(M){if(v!==u.current||!d.current)return;const L=M.message??"history load failed";a(x?R=>({...R,error:L}):{messages:[],total:0,loading:!1,error:L});return}if(v!==u.current||!d.current)return;b=[...S.messages??[],...b];const C=S.total??0,k=typeof S.offset=="number"?S.offset:0,N=k>=y,T=k<=0||N;y=k;const z=r!==void 0&&Wre(b,{implicitCloseOnUserText:i})>=r;if(x?a({messages:b,total:C,loading:!1,error:null}):(T||z)&&(x=!0,a({messages:b,total:C,loading:!1,error:null})),T)return;const I=Math.max(0,k-s);_={offset:I,limit:k-I}}})()},[e,t,n,s,r]),o}function qC(e){const t=Rp(e);return t.commandName?t.commandArgs?`${t.commandName} ${t.commandArgs}`:t.commandName:e}function KC(e){return e.kind==="user-text"?!0:e.kind!=="user-meta"?!1:e.metaKind==="slash-command"||op(e.metaKind)}function Kre(e,t){const n=t.find(KC);if(!n)return e;const r=qC(n.text);for(let s=e.length-1;s>=0;s--){const o=e[s];if(KC(o)&&qC(o.text)===r)return e.slice(0,s)}const i=e[e.length-1];return i!==void 0&&i.kind!=="turn-end"?[...e,{kind:"turn-end",seq:i.seq+1}]:e}const Gre=1e6,Yre=5;function Xre(e){if(!e)return;const t=e.contextUsage,n=e.contextWindowSize;if(!t||!n||n<=0)return;const r=t.inputTokens+(t.cacheReadTokens??0)+(t.cacheCreateTokens??0);if(!(r<=0))return Math.round(r/n*100)}function aA(e){const t=pi(),n=g.useMemo(()=>new q_(t),[t]),r=ci("sessions"),i=g.useMemo(()=>r==null?void 0:r.find(F=>F.sessionId===e),[r,e]),s=i==null?void 0:i.toolSessionId,o=i==null?void 0:i.tool,a=oA(e),{events:l,pendingPermissions:c,status:u,clearPermission:d,restorePermission:f}=a,p=QB(),m=qre({api:n,sessionId:e,toolSessionId:s,initialTurns:p==="owner"?void 0:Yre,implicitCloseOnUserText:o==="codex"}),v=g.useMemo(()=>m.messages.filter(F=>!F.isSidechain),[m.messages]),b=g.useMemo(()=>_ee(pM(v,0,o)),[v,o]),x=c[0]??null,_=g.useMemo(()=>gee(l,(x==null?void 0:x.requestId)??null),[l,x==null?void 0:x.requestId]),y=g.useMemo(()=>Kre(b,_),[b,_]),S=g.useMemo(()=>_.map((F,O)=>({...F,seq:Gre+O})),[_]),C=g.useMemo(()=>[...y,...S],[y,S]),k=mM(u),N=Iee(u),T=(i==null?void 0:i.resolvedModel)??(i==null?void 0:i.model),z=g.useMemo(()=>({sessionLabel:(i==null?void 0:i.label)||(i==null?void 0:i.aiLabel)||(i==null?void 0:i.larkChatName)||(i==null?void 0:i.larkChatId)||e,sessionId:e,...i!=null&&i.larkChatId?{larkChatName:i.larkChatName??i.larkChatId,larkChatType:i.larkChatType??"group"}:{},...T?{model:T}:{},...(()=>{const F=i==null?void 0:i.gitBranch;return F?{gitBranch:F}:{}})(),...(()=>{const F=Xre(i);return F!==void 0?{contextPct:F}:{}})(),...i!=null&&i.cwd?{cwd:i.cwd}:{},...(()=>{const F=i==null?void 0:i.permissionMode;return F?{permissionMode:F}:{}})(),procAlive:k,streamInProgress:N,pinnedAt:(i==null?void 0:i.pinnedAt)??null}),[i,e,T,k,N]),I=g.useMemo(()=>t.isOpen?u==="error"?{kind:"error",message:"session error"}:{kind:"ready"}:{kind:"closed"},[t.isOpen,u]),M=g.useCallback(async F=>{await n.sessionSend(e,F)},[n,e]),L=g.useCallback(async F=>{if(!(i!=null&&i.cwd)||!s)throw new Error("fork requires sessionFile with cwd + toolSessionId");await n.sessionFork({cwd:i.cwd,toolSessionId:s,messageUuid:F})},[n,i==null?void 0:i.cwd,s]),R=g.useCallback(async F=>{await n.sessionRewind({sessionId:e,userMessageId:F,dryRun:!1})},[n,e]),A=g.useCallback(async F=>{await n.sessionUpdate(e,{model:F})},[n,e]),D=g.useCallback(async()=>{await n.sessionNew(e)},[n,e]),$=g.useCallback(async(F,O)=>{const B=c.find(E=>E.requestId===F);B&&d(F);try{await n.permissionRespond({sessionId:e,permissionRequestId:F,allow:O==="allow"})}catch(E){throw!((E==null?void 0:E.message)??"").startsWith("PERMISSION_REQUEST_STALE")&&B&&f(B),E}},[n,e,c,d,f]);return g.useMemo(()=>({lines:C,connState:I,meta:z,historyLoading:m.loading,historyError:m.error,pendingPermissions:c,sendText:M,fork:L,rewind:R,switchModel:A,clearSession:D,respondPermission:$}),[C,I,z,m.loading,m.error,c,M,L,R,A,D,$])}function Zre({api:e,scope:t,sessionId:n,onShareFile:r,onOpenInTab:i,onPreviewMarkdown:s}){const[o,a]=g.useState([]),[l,c]=g.useState(null);g.useEffect(()=>{let d=!1;return(async()=>{try{const f=await e.attachmentGroupList(n);if(d)return;a(f.entries)}catch(f){d||c(f.message)}})(),()=>{d=!0}},[e,n]);async function u(d){try{await e.attachmentGroupRemove(n,d.relPath),a(f=>d.from==="owner"?f.filter(p=>p.relPath!==d.relPath):f.map(p=>p.relPath===d.relPath?{...p,stale:!0}:p))}catch(f){c(f.message)}}return h.jsx(cf,{delayDuration:120,children:h.jsx("div",{"data-testid":"files-panel-body",className:"flex h-full flex-col",children:h.jsxs("div",{className:"flex-1 overflow-y-auto",children:[h.jsx(Qre,{title:`Session files (${o.length})`,subtitle:"agent Write/Edit 自动入清单",children:o.length===0?h.jsx(eie,{text:"还没有文件。agent Write/Edit 会自动加入清单。"}):o.map(d=>h.jsx(Jre,{entry:d,onShareLink:()=>r(d.relPath),...i?{onOpenInTab:()=>i(d.relPath)}:{},...s&&!d.stale&&Mp(d.relPath)?{onPreview:()=>s(d.relPath)}:{},onRemove:()=>u(d)},d.id))}),l?h.jsx("div",{className:"border-t border-border bg-destructive/5 px-4 py-2 text-[11px] text-destructive",children:l}):null]})})})}function Qre({title:e,subtitle:t,children:n}){return h.jsxs("div",{className:"border-b border-border last:border-b-0",children:[h.jsx("div",{className:"sticky top-0 z-10 flex items-start justify-between bg-bg-100 px-4 py-2",children:h.jsxs("div",{className:"flex-1",children:[h.jsx("div",{className:"text-[11px] font-semibold uppercase tracking-wide text-text-300",children:e}),t?h.jsx("div",{className:"mt-0.5 text-[11px] text-text-400",children:t}):null]})}),h.jsx("div",{className:"flex flex-col",children:n})]})}function Jre({entry:e,onShareLink:t,onOpenInTab:n,onPreview:r,onRemove:i}){var c;const s=(c=e.mime)!=null&&c.startsWith("image/")?k$:ui,o=e.relPath.lastIndexOf("/"),a=o>=0?e.relPath.slice(0,o+1):"",l=o>=0?e.relPath.slice(o+1):e.relPath;return h.jsxs("div",{"data-testid":"files-panel-row",className:oe("group flex items-center gap-2 px-4 py-2 hover:bg-bg-200",e.stale&&"opacity-50"),children:[h.jsx(s,{className:"h-4 w-4 shrink-0 text-text-400"}),h.jsxs("div",{className:"min-w-0 flex-1",children:[h.jsxs("div",{className:"flex items-center gap-1.5",children:[h.jsxs(Sp,{children:[h.jsx(kp,{asChild:!0,children:r?h.jsxs("button",{type:"button","data-testid":"files-panel-preview",onClick:r,className:"flex min-w-0 items-baseline text-left text-[13px] text-text-100 hover:text-accent hover:underline underline-offset-2 cursor-pointer",children:[a?h.jsx("span",{className:"truncate text-text-400",children:a}):null,h.jsx("span",{className:"shrink-0",children:l})]}):h.jsxs("span",{className:"flex min-w-0 items-baseline text-[13px] text-text-100",children:[a?h.jsx("span",{className:"truncate text-text-400",children:a}):null,h.jsx("span",{className:"shrink-0",children:l})]})}),h.jsx(Ru,{side:"top",align:"start",className:"max-w-[380px] break-all",children:e.relPath})]}),e.stale&&h.jsx("span",{className:"rounded bg-text-100/10 px-1 py-0 text-[10px] uppercase text-text-400",children:"stale"})]}),h.jsxs("div",{className:"flex items-center gap-1.5 truncate text-[11px] text-text-400",children:[h.jsx("span",{children:e.from}),h.jsx("span",{children:"·"}),h.jsx("span",{children:tie(e.addedAt)})]})]}),!e.stale&&h.jsxs("div",{className:"flex items-center gap-0.5 opacity-0 transition-opacity group-hover:opacity-100",children:[n?h.jsx(Eg,{icon:h.jsx(Zc,{className:"h-3.5 w-3.5"}),title:"Open in tab",onClick:n}):null,h.jsx(Eg,{icon:h.jsx(X_,{className:"h-3.5 w-3.5"}),title:"Share link",onClick:t}),e.from==="owner"&&h.jsx(Eg,{icon:h.jsx(Z_,{className:"h-3.5 w-3.5"}),title:"Remove",onClick:i})]})]})}function Eg({icon:e,title:t,onClick:n}){return h.jsx("button",{type:"button",onClick:n,title:t,"aria-label":t,className:"flex h-7 w-7 items-center justify-center rounded text-text-400 hover:bg-text-100/10 hover:text-text-100",children:e})}function eie({text:e}){return h.jsx("div",{className:"px-4 py-3 text-[12px] italic text-text-400",children:e})}function tie(e){const t=Date.now()-e;return t<6e4?`${Math.max(1,Math.floor(t/1e3))}s ago`:t<36e5?`${Math.floor(t/6e4)}m ago`:t<864e5?`${Math.floor(t/36e5)}h ago`:`${Math.floor(t/864e5)}d ago`}var zu={},nie=function(){return typeof Promise=="function"&&Promise.prototype&&Promise.prototype.then},lA={},ar={};let d1;const rie=[0,26,44,70,100,134,172,196,242,292,346,404,466,532,581,655,733,815,901,991,1085,1156,1258,1364,1474,1588,1706,1828,1921,2051,2185,2323,2465,2611,2761,2876,3034,3196,3362,3532,3706];ar.getSymbolSize=function(t){if(!t)throw new Error('"version" cannot be null or undefined');if(t<1||t>40)throw new Error('"version" should be in range from 1 to 40');return t*4+17};ar.getSymbolTotalCodewords=function(t){return rie[t]};ar.getBCHDigit=function(e){let t=0;for(;e!==0;)t++,e>>>=1;return t};ar.setToSJISFunction=function(t){if(typeof t!="function")throw new Error('"toSJISFunc" is not a valid function.');d1=t};ar.isKanjiModeEnabled=function(){return typeof d1<"u"};ar.toSJIS=function(t){return d1(t)};var Op={};(function(e){e.L={bit:1},e.M={bit:0},e.Q={bit:3},e.H={bit:2};function t(n){if(typeof n!="string")throw new Error("Param is not a string");switch(n.toLowerCase()){case"l":case"low":return e.L;case"m":case"medium":return e.M;case"q":case"quartile":return e.Q;case"h":case"high":return e.H;default:throw new Error("Unknown EC Level: "+n)}}e.isValid=function(r){return r&&typeof r.bit<"u"&&r.bit>=0&&r.bit<4},e.from=function(r,i){if(e.isValid(r))return r;try{return t(r)}catch{return i}}})(Op);function cA(){this.buffer=[],this.length=0}cA.prototype={get:function(e){const t=Math.floor(e/8);return(this.buffer[t]>>>7-e%8&1)===1},put:function(e,t){for(let n=0;n<t;n++)this.putBit((e>>>t-n-1&1)===1)},getLengthInBits:function(){return this.length},putBit:function(e){const t=Math.floor(this.length/8);this.buffer.length<=t&&this.buffer.push(0),e&&(this.buffer[t]|=128>>>this.length%8),this.length++}};var iie=cA;function $u(e){if(!e||e<1)throw new Error("BitMatrix size must be defined and greater than 0");this.size=e,this.data=new Uint8Array(e*e),this.reservedBit=new Uint8Array(e*e)}$u.prototype.set=function(e,t,n,r){const i=e*this.size+t;this.data[i]=n,r&&(this.reservedBit[i]=!0)};$u.prototype.get=function(e,t){return this.data[e*this.size+t]};$u.prototype.xor=function(e,t,n){this.data[e*this.size+t]^=n};$u.prototype.isReserved=function(e,t){return this.reservedBit[e*this.size+t]};var sie=$u,uA={};(function(e){const t=ar.getSymbolSize;e.getRowColCoords=function(r){if(r===1)return[];const i=Math.floor(r/7)+2,s=t(r),o=s===145?26:Math.ceil((s-13)/(2*i-2))*2,a=[s-7];for(let l=1;l<i-1;l++)a[l]=a[l-1]-o;return a.push(6),a.reverse()},e.getPositions=function(r){const i=[],s=e.getRowColCoords(r),o=s.length;for(let a=0;a<o;a++)for(let l=0;l<o;l++)a===0&&l===0||a===0&&l===o-1||a===o-1&&l===0||i.push([s[a],s[l]]);return i}})(uA);var dA={};const oie=ar.getSymbolSize,GC=7;dA.getPositions=function(t){const n=oie(t);return[[0,0],[n-GC,0],[0,n-GC]]};var hA={};(function(e){e.Patterns={PATTERN000:0,PATTERN001:1,PATTERN010:2,PATTERN011:3,PATTERN100:4,PATTERN101:5,PATTERN110:6,PATTERN111:7};const t={N1:3,N2:3,N3:40,N4:10};e.isValid=function(i){return i!=null&&i!==""&&!isNaN(i)&&i>=0&&i<=7},e.from=function(i){return e.isValid(i)?parseInt(i,10):void 0},e.getPenaltyN1=function(i){const s=i.size;let o=0,a=0,l=0,c=null,u=null;for(let d=0;d<s;d++){a=l=0,c=u=null;for(let f=0;f<s;f++){let p=i.get(d,f);p===c?a++:(a>=5&&(o+=t.N1+(a-5)),c=p,a=1),p=i.get(f,d),p===u?l++:(l>=5&&(o+=t.N1+(l-5)),u=p,l=1)}a>=5&&(o+=t.N1+(a-5)),l>=5&&(o+=t.N1+(l-5))}return o},e.getPenaltyN2=function(i){const s=i.size;let o=0;for(let a=0;a<s-1;a++)for(let l=0;l<s-1;l++){const c=i.get(a,l)+i.get(a,l+1)+i.get(a+1,l)+i.get(a+1,l+1);(c===4||c===0)&&o++}return o*t.N2},e.getPenaltyN3=function(i){const s=i.size;let o=0,a=0,l=0;for(let c=0;c<s;c++){a=l=0;for(let u=0;u<s;u++)a=a<<1&2047|i.get(c,u),u>=10&&(a===1488||a===93)&&o++,l=l<<1&2047|i.get(u,c),u>=10&&(l===1488||l===93)&&o++}return o*t.N3},e.getPenaltyN4=function(i){let s=0;const o=i.data.length;for(let l=0;l<o;l++)s+=i.data[l];return Math.abs(Math.ceil(s*100/o/5)-10)*t.N4};function n(r,i,s){switch(r){case e.Patterns.PATTERN000:return(i+s)%2===0;case e.Patterns.PATTERN001:return i%2===0;case e.Patterns.PATTERN010:return s%3===0;case e.Patterns.PATTERN011:return(i+s)%3===0;case e.Patterns.PATTERN100:return(Math.floor(i/2)+Math.floor(s/3))%2===0;case e.Patterns.PATTERN101:return i*s%2+i*s%3===0;case e.Patterns.PATTERN110:return(i*s%2+i*s%3)%2===0;case e.Patterns.PATTERN111:return(i*s%3+(i+s)%2)%2===0;default:throw new Error("bad maskPattern:"+r)}}e.applyMask=function(i,s){const o=s.size;for(let a=0;a<o;a++)for(let l=0;l<o;l++)s.isReserved(l,a)||s.xor(l,a,n(i,l,a))},e.getBestMask=function(i,s){const o=Object.keys(e.Patterns).length;let a=0,l=1/0;for(let c=0;c<o;c++){s(c),e.applyMask(c,i);const u=e.getPenaltyN1(i)+e.getPenaltyN2(i)+e.getPenaltyN3(i)+e.getPenaltyN4(i);e.applyMask(c,i),u<l&&(l=u,a=c)}return a}})(hA);var Bp={};const vs=Op,Bd=[1,1,1,1,1,1,1,1,1,1,2,2,1,2,2,4,1,2,4,4,2,4,4,4,2,4,6,5,2,4,6,6,2,5,8,8,4,5,8,8,4,5,8,11,4,8,10,11,4,9,12,16,4,9,16,16,6,10,12,18,6,10,17,16,6,11,16,19,6,13,18,21,7,14,21,25,8,16,20,25,8,17,23,25,9,17,23,34,9,18,25,30,10,20,27,32,12,21,29,35,12,23,34,37,12,25,34,40,13,26,35,42,14,28,38,45,15,29,40,48,16,31,43,51,17,33,45,54,18,35,48,57,19,37,51,60,19,38,53,63,20,40,56,66,21,43,59,70,22,45,62,74,24,47,65,77,25,49,68,81],zd=[7,10,13,17,10,16,22,28,15,26,36,44,20,36,52,64,26,48,72,88,36,64,96,112,40,72,108,130,48,88,132,156,60,110,160,192,72,130,192,224,80,150,224,264,96,176,260,308,104,198,288,352,120,216,320,384,132,240,360,432,144,280,408,480,168,308,448,532,180,338,504,588,196,364,546,650,224,416,600,700,224,442,644,750,252,476,690,816,270,504,750,900,300,560,810,960,312,588,870,1050,336,644,952,1110,360,700,1020,1200,390,728,1050,1260,420,784,1140,1350,450,812,1200,1440,480,868,1290,1530,510,924,1350,1620,540,980,1440,1710,570,1036,1530,1800,570,1064,1590,1890,600,1120,1680,1980,630,1204,1770,2100,660,1260,1860,2220,720,1316,1950,2310,750,1372,2040,2430];Bp.getBlocksCount=function(t,n){switch(n){case vs.L:return Bd[(t-1)*4+0];case vs.M:return Bd[(t-1)*4+1];case vs.Q:return Bd[(t-1)*4+2];case vs.H:return Bd[(t-1)*4+3];default:return}};Bp.getTotalCodewordsCount=function(t,n){switch(n){case vs.L:return zd[(t-1)*4+0];case vs.M:return zd[(t-1)*4+1];case vs.Q:return zd[(t-1)*4+2];case vs.H:return zd[(t-1)*4+3];default:return}};var fA={},zp={};const Cc=new Uint8Array(512),kf=new Uint8Array(256);(function(){let t=1;for(let n=0;n<255;n++)Cc[n]=t,kf[t]=n,t<<=1,t&256&&(t^=285);for(let n=255;n<512;n++)Cc[n]=Cc[n-255]})();zp.log=function(t){if(t<1)throw new Error("log("+t+")");return kf[t]};zp.exp=function(t){return Cc[t]};zp.mul=function(t,n){return t===0||n===0?0:Cc[kf[t]+kf[n]]};(function(e){const t=zp;e.mul=function(r,i){const s=new Uint8Array(r.length+i.length-1);for(let o=0;o<r.length;o++)for(let a=0;a<i.length;a++)s[o+a]^=t.mul(r[o],i[a]);return s},e.mod=function(r,i){let s=new Uint8Array(r);for(;s.length-i.length>=0;){const o=s[0];for(let l=0;l<i.length;l++)s[l]^=t.mul(i[l],o);let a=0;for(;a<s.length&&s[a]===0;)a++;s=s.slice(a)}return s},e.generateECPolynomial=function(r){let i=new Uint8Array([1]);for(let s=0;s<r;s++)i=e.mul(i,new Uint8Array([1,t.exp(s)]));return i}})(fA);const pA=fA;function h1(e){this.genPoly=void 0,this.degree=e,this.degree&&this.initialize(this.degree)}h1.prototype.initialize=function(t){this.degree=t,this.genPoly=pA.generateECPolynomial(this.degree)};h1.prototype.encode=function(t){if(!this.genPoly)throw new Error("Encoder not initialized");const n=new Uint8Array(t.length+this.degree);n.set(t);const r=pA.mod(n,this.genPoly),i=this.degree-r.length;if(i>0){const s=new Uint8Array(this.degree);return s.set(r,i),s}return r};var aie=h1,mA={},Us={},f1={};f1.isValid=function(t){return!isNaN(t)&&t>=1&&t<=40};var vi={};const gA="[0-9]+",lie="[A-Z $%*+\\-./:]+";let uu="(?:[u3000-u303F]|[u3040-u309F]|[u30A0-u30FF]|[uFF00-uFFEF]|[u4E00-u9FAF]|[u2605-u2606]|[u2190-u2195]|u203B|[u2010u2015u2018u2019u2025u2026u201Cu201Du2225u2260]|[u0391-u0451]|[u00A7u00A8u00B1u00B4u00D7u00F7])+";uu=uu.replace(/u/g,"\\u");const cie="(?:(?![A-Z0-9 $%*+\\-./:]|"+uu+`)(?:.|[\r
|
|
574
|
+
*/var zre=2,$re=1,Fre=class{activate(e){this._terminal=e}dispose(){}fit(){let e=this.proposeDimensions();if(!e||!this._terminal||isNaN(e.cols)||isNaN(e.rows))return;let t=this._terminal._core;(this._terminal.rows!==e.rows||this._terminal.cols!==e.cols)&&(t._renderService.clear(),this._terminal.resize(e.cols,e.rows))}proposeDimensions(){var d;if(!this._terminal||!this._terminal.element||!this._terminal.element.parentElement)return;let e=this._terminal._core._renderService.dimensions;if(e.css.cell.width===0||e.css.cell.height===0)return;let t=this._terminal.options.scrollback===0?0:((d=this._terminal.options.overviewRuler)==null?void 0:d.width)||14,n=window.getComputedStyle(this._terminal.element.parentElement),r=parseInt(n.getPropertyValue("height")),i=Math.max(0,parseInt(n.getPropertyValue("width"))),s=window.getComputedStyle(this._terminal.element),o={top:parseInt(s.getPropertyValue("padding-top")),bottom:parseInt(s.getPropertyValue("padding-bottom")),right:parseInt(s.getPropertyValue("padding-right")),left:parseInt(s.getPropertyValue("padding-left"))},a=o.top+o.bottom,l=o.right+o.left,c=r-a,u=i-l-t;return{cols:Math.max(zre,Math.floor(u/e.css.cell.width)),rows:Math.max($re,Math.floor(c/e.css.cell.height))}}};let Sg;function kg(){return{count:0,byteSum:0,firstT:null,lastT:null}}const Cg=32,VC=320;function Hre({sessionId:e,client:t}){const n=g.useRef(null),r=g.useRef(null),i=g.useRef(null),s=g.useRef([]),o=g.useRef(kg()),a=g.useRef(!1),[l,c]=g.useState("collapsed"),[u,d]=g.useState(null);g.useEffect(()=>{const v=n.current;if(!v)return;let b=!1;const x=(N,T)=>getComputedStyle(document.documentElement).getPropertyValue(N).trim()||T,_=x("--bg-0","#1B1B1B"),y=x("--text-100","#ECECEC"),S=new Bre({fontFamily:"ui-monospace, SF Mono, Menlo, monospace",fontSize:12,lineHeight:1.2,theme:{background:_,foreground:y},minimumContrastRatio:4.5,cursorBlink:!0,convertEol:!1,scrollback:5e3,allowProposedApi:!0,cols:120,rows:40}),C=new Fre;S.loadAddon(C),Me("xterm-mount",{sessionId:e,hostChildCount:v.childNodes.length}),Sg!==e&&(Me("xterm-trace",`===== SWITCH ${Sg??"(initial)"} → ${e} =====`),Sg=e),Me("xterm-trace","effect-setup-start",{sessionId:e,t:performance.now()}),o.current=kg(),S.open(v);const k=S.onData(N=>{const T=btoa(unescape(encodeURIComponent(N)));t.request("session:pty:input",{sessionId:e,data:T}).catch(()=>{})});return(async()=>{var R;let N=0,T=null,z=null;try{Me("xterm-trace","snapshot-rpc-start",{sessionId:e,t:performance.now()});const A=await t.request("session:pty:snapshot",{sessionId:e});if(Me("xterm-trace","snapshot-rpc-resolved",{sessionId:e,cancelled:b,byteLen:((R=A==null?void 0:A.data)==null?void 0:R.length)??0,atSeq:A==null?void 0:A.atSeq,t:performance.now()}),b)return;if(A!=null&&A.ok&&typeof A.data=="string"&&A.data.length>0){const D=atob(A.data),$=new Uint8Array(D.length);for(let F=0;F<D.length;F++)$[F]=D.charCodeAt(F);T=$}A!=null&&A.ok&&typeof A.atSeq=="number"&&(N=A.atSeq),A!=null&&A.ok&&A.popupKind!=null&&(z=A.popupKind)}catch{}if(b)return;r.current=S,i.current=C;let I=!1,M;const L=S.onRender(()=>{if(!I){I=!0;try{C.fit(),T&&S.write(T),Me("xterm-trace","snapshot-flush",{sessionId:e,atSeq:N,pendingFrameCount:s.current.length,frameStatsBeforeFlush:{...o.current},t:performance.now()}),o.current=kg();const A=s.current;s.current=[];let D=0;for(const $ of A){if($.seq!==void 0&&$.seq<=N){D++;continue}S.write($.bytes)}D>0&&Me("xterm-trace","snapshot-flush-dropped",{sessionId:e,dropped:D,atSeq:N}),a.current=!0,z!=null&&(d(z),c("expanded"),requestAnimationFrame(()=>S.focus())),t.request("session:pty:resize",{sessionId:e,cols:S.cols,rows:S.rows}).catch(()=>{})}catch{}S.scrollToBottom(),M?M():setTimeout(()=>M==null?void 0:M(),0)}});M=()=>L.dispose()})(),()=>{Me("xterm-trace","cleanup-start",{sessionId:e,pendingFrameCount:s.current.length,termReady:a.current,frameStatsThisMount:{...o.current},t:performance.now()}),b=!0,k.dispose(),S.dispose(),r.current=null,i.current=null,a.current=!1,s.current=[],Me("xterm-trace","cleanup-cleared-pending",{sessionId:e,t:performance.now()})}},[e,t]),g.useEffect(()=>{const v=t.on("session:pty",x=>{const _=x;if(_.sessionId!==e||typeof _.data!="string")return;const y=o.current;y.count++,y.byteSum+=_.data.length;const S=performance.now();y.firstT===null&&(y.firstT=S),y.lastT=S;try{const C=atob(_.data),k=new Uint8Array(C.length);for(let N=0;N<C.length;N++)k[N]=C.charCodeAt(N);a.current&&r.current?r.current.write(k):s.current.push({seq:_.seq,bytes:k})}catch{}}),b=t.on("session:control",x=>{const _=x;if(_.sessionId===e)switch(_.kind){case"popup_open":(_.popupKind==="permission"||_.popupKind==="question")&&(d(_.popupKind),c("expanded"),requestAnimationFrame(()=>{var y;return(y=r.current)==null?void 0:y.focus()}));break;case"popup_close":d(null),c("collapsed");break}});return()=>{v(),b(),Me("xterm-trace","cleanup-off-listener",{sessionId:e,t:performance.now()})}},[e,t]),g.useEffect(()=>{const v=n.current;if(!v)return;let b=0,x=0;const _=()=>{const S=i.current,C=r.current;if(!(!S||!C)){try{S.fit()}catch{return}try{C.refresh(0,C.rows-1)}catch{}C.cols===b&&C.rows===x||(b=C.cols,x=C.rows,t.request("session:pty:resize",{sessionId:e,cols:C.cols,rows:C.rows}).catch(()=>{}))}},y=new ResizeObserver(()=>_());return y.observe(v),()=>y.disconnect()},[e,t]);const f=()=>{c(v=>{const b=v==="collapsed"?"expanded":"collapsed";return b==="expanded"&&requestAnimationFrame(()=>{var x;return(x=r.current)==null?void 0:x.focus()}),b})},p=l==="expanded"?VC:Cg,m=VC-Cg;return h.jsxs("div",{className:"border-t border-border bg-bg-0 overflow-hidden",style:{height:p},"data-testid":"xterm-panel","data-state":l,"data-mode":"tui","data-popup-kind":u??"",children:[h.jsxs("button",{type:"button",onClick:f,className:"flex items-center justify-between w-full px-3 py-1 text-xs text-text-200 bg-bg-200 hover:bg-bg-300 cursor-pointer border-b border-border",style:{height:Cg,flexShrink:0},"data-testid":"xterm-panel-toggle",children:[h.jsxs("span",{className:"font-mono",children:[u==="permission"&&"⚠️ CC 需要权限确认 — 在下方终端按数字键 / Enter 选择",u==="question"&&"❓ CC 在问问题 — 在下方终端用 ↑/↓ + Enter 选择",u===null&&(l==="collapsed"?"▴ 展开原生 TUI 终端":"▾ 收起 TUI 终端")]}),h.jsx("span",{className:"text-text-200 text-[10px] opacity-60",children:l==="expanded"?"点击收起":"点击展开"})]}),h.jsx("div",{ref:n,className:"p-1",style:{height:m},"data-testid":"xterm-panel-host"})]})}function oA(e,t){const n=jo(),r=e?`session/${e}`:"",i=ci(r)??Xc,s=g.useCallback(d=>{!e||!r||n.setData(r,f=>VT(f??Xc,d,e))},[n,r,e]),o=g.useCallback(()=>{e&&s({type:"session:change",sessionId:e})},[s,e]),a=g.useCallback(d=>{e&&s({type:"permission:clear",sessionId:e,requestId:d})},[s,e]),l=g.useCallback(d=>{e&&s({type:"permission:request",sessionId:e,requestId:d.requestId,tool:d.tool,input:d.input,...d.toolUseId?{toolUseId:d.toolUseId}:{}})},[s,e]),c=g.useCallback(d=>{e&&s({type:"session:question:clear",sessionId:e,toolUseId:d})},[s,e]),u=g.useCallback((d,f)=>{e&&s({type:"session:question:submitted",sessionId:e,toolUseId:d,answers:f})},[s,e]);return{...i,reset:o,clearPermission:a,restorePermission:l,clearQuestion:c,markQuestionSubmitted:u}}function u1(e){const t=ci(e?`capabilities/${e}`:"");return e?{capabilities:t??null,loading:!t}:{capabilities:null,loading:!1}}function Ure(e){return e.kind!=="user-text"?!1:e.meta===void 0||e.meta==="slash-command"||op(e.meta)}function Wre(e,t={}){let n=0;if(t.implicitCloseOnUserText){for(const r of e)Ure(r)&&n++;return n}for(const r of e)r.kind==="turn-end"&&n++;return n}const Vre=50;function qre({api:e,sessionId:t,toolSessionId:n,initialTurns:r,implicitCloseOnUserText:i,pageSize:s=Vre}){const[o,a]=g.useState({messages:[],total:0,loading:!1,error:null}),l=g.useRef(n),c=g.useRef(null),u=g.useRef(0),d=g.useRef(!0);return g.useEffect(()=>(d.current=!0,()=>{d.current=!1}),[]),g.useEffect(()=>{const f=l.current;if(l.current=n,!(c.current!==t)&&!(typeof f=="string"&&f!==n))return;if(a({messages:[],total:0,loading:!1,error:null}),!t){c.current=null;return}c.current=t;const v=++u.current;a(b=>({...b,loading:!0,error:null})),(async()=>{let b=[],x=!1,_=r===void 0?{}:{limit:s},y=Number.POSITIVE_INFINITY;for(;;){let S;try{S=await e.historyRead({sessionId:t,..._})}catch(M){if(v!==u.current||!d.current)return;const L=M.message??"history load failed";a(x?R=>({...R,error:L}):{messages:[],total:0,loading:!1,error:L});return}if(v!==u.current||!d.current)return;b=[...S.messages??[],...b];const C=S.total??0,k=typeof S.offset=="number"?S.offset:0,N=k>=y,T=k<=0||N;y=k;const z=r!==void 0&&Wre(b,{implicitCloseOnUserText:i})>=r;if(x?a({messages:b,total:C,loading:!1,error:null}):(T||z)&&(x=!0,a({messages:b,total:C,loading:!1,error:null})),T)return;const I=Math.max(0,k-s);_={offset:I,limit:k-I}}})()},[e,t,n,s,r]),o}function qC(e){const t=Rp(e);return t.commandName?t.commandArgs?`${t.commandName} ${t.commandArgs}`:t.commandName:e}function KC(e){return e.kind==="user-text"?!0:e.kind!=="user-meta"?!1:e.metaKind==="slash-command"||op(e.metaKind)}function Kre(e,t){const n=t.find(KC);if(!n)return e;const r=qC(n.text);for(let s=e.length-1;s>=0;s--){const o=e[s];if(KC(o)&&qC(o.text)===r)return e.slice(0,s)}const i=e[e.length-1];return i!==void 0&&i.kind!=="turn-end"?[...e,{kind:"turn-end",seq:i.seq+1}]:e}const Gre=1e6,Yre=5;function Xre(e){if(!e)return;const t=e.contextUsage,n=e.contextWindowSize;if(!t||!n||n<=0)return;const r=t.inputTokens+(t.cacheReadTokens??0)+(t.cacheCreateTokens??0);if(!(r<=0))return Math.round(r/n*100)}function aA(e){const t=pi(),n=g.useMemo(()=>new q_(t),[t]),r=ci("sessions"),i=g.useMemo(()=>r==null?void 0:r.find(F=>F.sessionId===e),[r,e]),s=i==null?void 0:i.toolSessionId,o=i==null?void 0:i.tool,a=oA(e),{events:l,pendingPermissions:c,status:u,clearPermission:d,restorePermission:f}=a,p=QB(),m=qre({api:n,sessionId:e,toolSessionId:s,initialTurns:p==="owner"?void 0:Yre,implicitCloseOnUserText:o==="codex"}),v=g.useMemo(()=>m.messages.filter(F=>!F.isSidechain),[m.messages]),b=g.useMemo(()=>_ee(pM(v,0,o)),[v,o]),x=c[0]??null,_=g.useMemo(()=>gee(l,(x==null?void 0:x.requestId)??null),[l,x==null?void 0:x.requestId]),y=g.useMemo(()=>Kre(b,_),[b,_]),S=g.useMemo(()=>_.map((F,O)=>({...F,seq:Gre+O})),[_]),C=g.useMemo(()=>[...y,...S],[y,S]),k=mM(u),N=Iee(u),T=(i==null?void 0:i.resolvedModel)??(i==null?void 0:i.model),z=g.useMemo(()=>({sessionLabel:(i==null?void 0:i.label)||(i==null?void 0:i.aiLabel)||(i==null?void 0:i.larkChatName)||(i==null?void 0:i.larkChatId)||e,sessionId:e,...i!=null&&i.larkChatId?{larkChatName:i.larkChatName??i.larkChatId,larkChatType:i.larkChatType??"group"}:{},...T?{model:T}:{},...(()=>{const F=i==null?void 0:i.gitBranch;return F?{gitBranch:F}:{}})(),...(()=>{const F=Xre(i);return F!==void 0?{contextPct:F}:{}})(),...i!=null&&i.cwd?{cwd:i.cwd}:{},...(()=>{const F=i==null?void 0:i.permissionMode;return F?{permissionMode:F}:{}})(),procAlive:k,streamInProgress:N,pinnedAt:(i==null?void 0:i.pinnedAt)??null}),[i,e,T,k,N]),I=g.useMemo(()=>t.isOpen?u==="error"?{kind:"error",message:"session error"}:{kind:"ready"}:{kind:"closed"},[t.isOpen,u]),M=g.useCallback(async F=>{await n.sessionSend(e,F)},[n,e]),L=g.useCallback(async F=>{if(!(i!=null&&i.cwd)||!s)throw new Error("fork requires sessionFile with cwd + toolSessionId");await n.sessionFork({cwd:i.cwd,toolSessionId:s,messageUuid:F})},[n,i==null?void 0:i.cwd,s]),R=g.useCallback(async F=>{await n.sessionRewind({sessionId:e,userMessageId:F,dryRun:!1})},[n,e]),A=g.useCallback(async F=>{await n.sessionUpdate(e,{model:F})},[n,e]),D=g.useCallback(async()=>{await n.sessionNew(e)},[n,e]),$=g.useCallback(async(F,O)=>{const B=c.find(E=>E.requestId===F);B&&d(F);try{await n.permissionRespond({sessionId:e,permissionRequestId:F,allow:O==="allow"})}catch(E){throw!((E==null?void 0:E.message)??"").startsWith("PERMISSION_REQUEST_STALE")&&B&&f(B),E}},[n,e,c,d,f]);return g.useMemo(()=>({lines:C,connState:I,meta:z,historyLoading:m.loading,historyError:m.error,pendingPermissions:c,sendText:M,fork:L,rewind:R,switchModel:A,clearSession:D,respondPermission:$}),[C,I,z,m.loading,m.error,c,M,L,R,A,D,$])}function Zre({api:e,scope:t,sessionId:n,onShareFile:r,onOpenInTab:i,onPreviewMarkdown:s}){const[o,a]=g.useState([]),[l,c]=g.useState(null);g.useEffect(()=>{let d=!1;return(async()=>{try{const f=await e.attachmentGroupList(n);if(d)return;a(f.entries)}catch(f){d||c(f.message)}})(),()=>{d=!0}},[e,n]);async function u(d){try{await e.attachmentGroupRemove(n,d.relPath),a(f=>d.from==="owner"?f.filter(p=>p.relPath!==d.relPath):f.map(p=>p.relPath===d.relPath?{...p,stale:!0}:p))}catch(f){c(f.message)}}return h.jsx(cf,{delayDuration:120,children:h.jsx("div",{"data-testid":"files-panel-body",className:"flex h-full flex-col",children:h.jsxs("div",{className:"flex-1 overflow-y-auto",children:[h.jsx(Qre,{title:`Session files (${o.length})`,subtitle:"agent Write/Edit 自动入清单",children:o.length===0?h.jsx(eie,{text:"还没有文件。agent Write/Edit 会自动加入清单。"}):o.map(d=>h.jsx(Jre,{entry:d,onShareLink:()=>r(d.relPath),...i?{onOpenInTab:()=>i(d.relPath)}:{},...s&&!d.stale&&Mp(d.relPath)?{onPreview:()=>s(d.relPath)}:{},onRemove:()=>u(d)},d.id))}),l?h.jsx("div",{className:"border-t border-border bg-destructive/5 px-4 py-2 text-[11px] text-destructive",children:l}):null]})})})}function Qre({title:e,subtitle:t,children:n}){return h.jsxs("div",{className:"border-b border-border last:border-b-0",children:[h.jsx("div",{className:"sticky top-0 z-10 flex items-start justify-between bg-bg-100 px-4 py-2",children:h.jsxs("div",{className:"flex-1",children:[h.jsx("div",{className:"text-[11px] font-semibold uppercase tracking-wide text-text-300",children:e}),t?h.jsx("div",{className:"mt-0.5 text-[11px] text-text-400",children:t}):null]})}),h.jsx("div",{className:"flex flex-col",children:n})]})}function Jre({entry:e,onShareLink:t,onOpenInTab:n,onPreview:r,onRemove:i}){var c;const s=(c=e.mime)!=null&&c.startsWith("image/")?k$:ui,o=e.relPath.lastIndexOf("/"),a=o>=0?e.relPath.slice(0,o+1):"",l=o>=0?e.relPath.slice(o+1):e.relPath;return h.jsxs("div",{"data-testid":"files-panel-row",className:oe("group flex items-center gap-2 px-4 py-2 hover:bg-bg-200",e.stale&&"opacity-50"),children:[h.jsx(s,{className:"h-4 w-4 shrink-0 text-text-400"}),h.jsxs("div",{className:"min-w-0 flex-1",children:[h.jsxs("div",{className:"flex items-center gap-1.5",children:[h.jsxs(Sp,{children:[h.jsx(kp,{asChild:!0,children:r?h.jsxs("button",{type:"button","data-testid":"files-panel-preview",onClick:r,className:"flex min-w-0 items-baseline text-left text-[13px] text-text-100 hover:text-accent hover:underline underline-offset-2 cursor-pointer",children:[a?h.jsx("span",{className:"truncate text-text-400",children:a}):null,h.jsx("span",{className:"shrink-0",children:l})]}):h.jsxs("span",{className:"flex min-w-0 items-baseline text-[13px] text-text-100",children:[a?h.jsx("span",{className:"truncate text-text-400",children:a}):null,h.jsx("span",{className:"shrink-0",children:l})]})}),h.jsx(Ru,{side:"top",align:"start",className:"max-w-[380px] break-all",children:e.relPath})]}),e.stale&&h.jsx("span",{className:"rounded bg-text-100/10 px-1 py-0 text-[10px] uppercase text-text-400",children:"stale"})]}),h.jsxs("div",{className:"flex items-center gap-1.5 truncate text-[11px] text-text-400",children:[h.jsx("span",{children:e.from}),h.jsx("span",{children:"·"}),h.jsx("span",{children:tie(e.addedAt)})]})]}),!e.stale&&h.jsxs("div",{className:"flex items-center gap-0.5 opacity-0 transition-opacity group-hover:opacity-100",children:[n?h.jsx(Eg,{icon:h.jsx(Zc,{className:"h-3.5 w-3.5"}),title:"Open in tab",onClick:n}):null,h.jsx(Eg,{icon:h.jsx(X_,{className:"h-3.5 w-3.5"}),title:"Share link",onClick:t}),e.from==="owner"&&h.jsx(Eg,{icon:h.jsx(Z_,{className:"h-3.5 w-3.5"}),title:"Remove",onClick:i})]})]})}function Eg({icon:e,title:t,onClick:n}){return h.jsx("button",{type:"button",onClick:n,title:t,"aria-label":t,className:"flex h-7 w-7 items-center justify-center rounded text-text-400 hover:bg-text-100/10 hover:text-text-100",children:e})}function eie({text:e}){return h.jsx("div",{className:"px-4 py-3 text-[12px] italic text-text-400",children:e})}function tie(e){const t=Date.now()-e;return t<6e4?`${Math.max(1,Math.floor(t/1e3))}s ago`:t<36e5?`${Math.floor(t/6e4)}m ago`:t<864e5?`${Math.floor(t/36e5)}h ago`:`${Math.floor(t/864e5)}d ago`}var zu={},nie=function(){return typeof Promise=="function"&&Promise.prototype&&Promise.prototype.then},lA={},ar={};let d1;const rie=[0,26,44,70,100,134,172,196,242,292,346,404,466,532,581,655,733,815,901,991,1085,1156,1258,1364,1474,1588,1706,1828,1921,2051,2185,2323,2465,2611,2761,2876,3034,3196,3362,3532,3706];ar.getSymbolSize=function(t){if(!t)throw new Error('"version" cannot be null or undefined');if(t<1||t>40)throw new Error('"version" should be in range from 1 to 40');return t*4+17};ar.getSymbolTotalCodewords=function(t){return rie[t]};ar.getBCHDigit=function(e){let t=0;for(;e!==0;)t++,e>>>=1;return t};ar.setToSJISFunction=function(t){if(typeof t!="function")throw new Error('"toSJISFunc" is not a valid function.');d1=t};ar.isKanjiModeEnabled=function(){return typeof d1<"u"};ar.toSJIS=function(t){return d1(t)};var Op={};(function(e){e.L={bit:1},e.M={bit:0},e.Q={bit:3},e.H={bit:2};function t(n){if(typeof n!="string")throw new Error("Param is not a string");switch(n.toLowerCase()){case"l":case"low":return e.L;case"m":case"medium":return e.M;case"q":case"quartile":return e.Q;case"h":case"high":return e.H;default:throw new Error("Unknown EC Level: "+n)}}e.isValid=function(r){return r&&typeof r.bit<"u"&&r.bit>=0&&r.bit<4},e.from=function(r,i){if(e.isValid(r))return r;try{return t(r)}catch{return i}}})(Op);function cA(){this.buffer=[],this.length=0}cA.prototype={get:function(e){const t=Math.floor(e/8);return(this.buffer[t]>>>7-e%8&1)===1},put:function(e,t){for(let n=0;n<t;n++)this.putBit((e>>>t-n-1&1)===1)},getLengthInBits:function(){return this.length},putBit:function(e){const t=Math.floor(this.length/8);this.buffer.length<=t&&this.buffer.push(0),e&&(this.buffer[t]|=128>>>this.length%8),this.length++}};var iie=cA;function $u(e){if(!e||e<1)throw new Error("BitMatrix size must be defined and greater than 0");this.size=e,this.data=new Uint8Array(e*e),this.reservedBit=new Uint8Array(e*e)}$u.prototype.set=function(e,t,n,r){const i=e*this.size+t;this.data[i]=n,r&&(this.reservedBit[i]=!0)};$u.prototype.get=function(e,t){return this.data[e*this.size+t]};$u.prototype.xor=function(e,t,n){this.data[e*this.size+t]^=n};$u.prototype.isReserved=function(e,t){return this.reservedBit[e*this.size+t]};var sie=$u,uA={};(function(e){const t=ar.getSymbolSize;e.getRowColCoords=function(r){if(r===1)return[];const i=Math.floor(r/7)+2,s=t(r),o=s===145?26:Math.ceil((s-13)/(2*i-2))*2,a=[s-7];for(let l=1;l<i-1;l++)a[l]=a[l-1]-o;return a.push(6),a.reverse()},e.getPositions=function(r){const i=[],s=e.getRowColCoords(r),o=s.length;for(let a=0;a<o;a++)for(let l=0;l<o;l++)a===0&&l===0||a===0&&l===o-1||a===o-1&&l===0||i.push([s[a],s[l]]);return i}})(uA);var dA={};const oie=ar.getSymbolSize,GC=7;dA.getPositions=function(t){const n=oie(t);return[[0,0],[n-GC,0],[0,n-GC]]};var hA={};(function(e){e.Patterns={PATTERN000:0,PATTERN001:1,PATTERN010:2,PATTERN011:3,PATTERN100:4,PATTERN101:5,PATTERN110:6,PATTERN111:7};const t={N1:3,N2:3,N3:40,N4:10};e.isValid=function(i){return i!=null&&i!==""&&!isNaN(i)&&i>=0&&i<=7},e.from=function(i){return e.isValid(i)?parseInt(i,10):void 0},e.getPenaltyN1=function(i){const s=i.size;let o=0,a=0,l=0,c=null,u=null;for(let d=0;d<s;d++){a=l=0,c=u=null;for(let f=0;f<s;f++){let p=i.get(d,f);p===c?a++:(a>=5&&(o+=t.N1+(a-5)),c=p,a=1),p=i.get(f,d),p===u?l++:(l>=5&&(o+=t.N1+(l-5)),u=p,l=1)}a>=5&&(o+=t.N1+(a-5)),l>=5&&(o+=t.N1+(l-5))}return o},e.getPenaltyN2=function(i){const s=i.size;let o=0;for(let a=0;a<s-1;a++)for(let l=0;l<s-1;l++){const c=i.get(a,l)+i.get(a,l+1)+i.get(a+1,l)+i.get(a+1,l+1);(c===4||c===0)&&o++}return o*t.N2},e.getPenaltyN3=function(i){const s=i.size;let o=0,a=0,l=0;for(let c=0;c<s;c++){a=l=0;for(let u=0;u<s;u++)a=a<<1&2047|i.get(c,u),u>=10&&(a===1488||a===93)&&o++,l=l<<1&2047|i.get(u,c),u>=10&&(l===1488||l===93)&&o++}return o*t.N3},e.getPenaltyN4=function(i){let s=0;const o=i.data.length;for(let l=0;l<o;l++)s+=i.data[l];return Math.abs(Math.ceil(s*100/o/5)-10)*t.N4};function n(r,i,s){switch(r){case e.Patterns.PATTERN000:return(i+s)%2===0;case e.Patterns.PATTERN001:return i%2===0;case e.Patterns.PATTERN010:return s%3===0;case e.Patterns.PATTERN011:return(i+s)%3===0;case e.Patterns.PATTERN100:return(Math.floor(i/2)+Math.floor(s/3))%2===0;case e.Patterns.PATTERN101:return i*s%2+i*s%3===0;case e.Patterns.PATTERN110:return(i*s%2+i*s%3)%2===0;case e.Patterns.PATTERN111:return(i*s%3+(i+s)%2)%2===0;default:throw new Error("bad maskPattern:"+r)}}e.applyMask=function(i,s){const o=s.size;for(let a=0;a<o;a++)for(let l=0;l<o;l++)s.isReserved(l,a)||s.xor(l,a,n(i,l,a))},e.getBestMask=function(i,s){const o=Object.keys(e.Patterns).length;let a=0,l=1/0;for(let c=0;c<o;c++){s(c),e.applyMask(c,i);const u=e.getPenaltyN1(i)+e.getPenaltyN2(i)+e.getPenaltyN3(i)+e.getPenaltyN4(i);e.applyMask(c,i),u<l&&(l=u,a=c)}return a}})(hA);var Bp={};const vs=Op,Bd=[1,1,1,1,1,1,1,1,1,1,2,2,1,2,2,4,1,2,4,4,2,4,4,4,2,4,6,5,2,4,6,6,2,5,8,8,4,5,8,8,4,5,8,11,4,8,10,11,4,9,12,16,4,9,16,16,6,10,12,18,6,10,17,16,6,11,16,19,6,13,18,21,7,14,21,25,8,16,20,25,8,17,23,25,9,17,23,34,9,18,25,30,10,20,27,32,12,21,29,35,12,23,34,37,12,25,34,40,13,26,35,42,14,28,38,45,15,29,40,48,16,31,43,51,17,33,45,54,18,35,48,57,19,37,51,60,19,38,53,63,20,40,56,66,21,43,59,70,22,45,62,74,24,47,65,77,25,49,68,81],zd=[7,10,13,17,10,16,22,28,15,26,36,44,20,36,52,64,26,48,72,88,36,64,96,112,40,72,108,130,48,88,132,156,60,110,160,192,72,130,192,224,80,150,224,264,96,176,260,308,104,198,288,352,120,216,320,384,132,240,360,432,144,280,408,480,168,308,448,532,180,338,504,588,196,364,546,650,224,416,600,700,224,442,644,750,252,476,690,816,270,504,750,900,300,560,810,960,312,588,870,1050,336,644,952,1110,360,700,1020,1200,390,728,1050,1260,420,784,1140,1350,450,812,1200,1440,480,868,1290,1530,510,924,1350,1620,540,980,1440,1710,570,1036,1530,1800,570,1064,1590,1890,600,1120,1680,1980,630,1204,1770,2100,660,1260,1860,2220,720,1316,1950,2310,750,1372,2040,2430];Bp.getBlocksCount=function(t,n){switch(n){case vs.L:return Bd[(t-1)*4+0];case vs.M:return Bd[(t-1)*4+1];case vs.Q:return Bd[(t-1)*4+2];case vs.H:return Bd[(t-1)*4+3];default:return}};Bp.getTotalCodewordsCount=function(t,n){switch(n){case vs.L:return zd[(t-1)*4+0];case vs.M:return zd[(t-1)*4+1];case vs.Q:return zd[(t-1)*4+2];case vs.H:return zd[(t-1)*4+3];default:return}};var fA={},zp={};const Cc=new Uint8Array(512),kf=new Uint8Array(256);(function(){let t=1;for(let n=0;n<255;n++)Cc[n]=t,kf[t]=n,t<<=1,t&256&&(t^=285);for(let n=255;n<512;n++)Cc[n]=Cc[n-255]})();zp.log=function(t){if(t<1)throw new Error("log("+t+")");return kf[t]};zp.exp=function(t){return Cc[t]};zp.mul=function(t,n){return t===0||n===0?0:Cc[kf[t]+kf[n]]};(function(e){const t=zp;e.mul=function(r,i){const s=new Uint8Array(r.length+i.length-1);for(let o=0;o<r.length;o++)for(let a=0;a<i.length;a++)s[o+a]^=t.mul(r[o],i[a]);return s},e.mod=function(r,i){let s=new Uint8Array(r);for(;s.length-i.length>=0;){const o=s[0];for(let l=0;l<i.length;l++)s[l]^=t.mul(i[l],o);let a=0;for(;a<s.length&&s[a]===0;)a++;s=s.slice(a)}return s},e.generateECPolynomial=function(r){let i=new Uint8Array([1]);for(let s=0;s<r;s++)i=e.mul(i,new Uint8Array([1,t.exp(s)]));return i}})(fA);const pA=fA;function h1(e){this.genPoly=void 0,this.degree=e,this.degree&&this.initialize(this.degree)}h1.prototype.initialize=function(t){this.degree=t,this.genPoly=pA.generateECPolynomial(this.degree)};h1.prototype.encode=function(t){if(!this.genPoly)throw new Error("Encoder not initialized");const n=new Uint8Array(t.length+this.degree);n.set(t);const r=pA.mod(n,this.genPoly),i=this.degree-r.length;if(i>0){const s=new Uint8Array(this.degree);return s.set(r,i),s}return r};var aie=h1,mA={},Us={},f1={};f1.isValid=function(t){return!isNaN(t)&&t>=1&&t<=40};var vi={};const gA="[0-9]+",lie="[A-Z $%*+\\-./:]+";let uu="(?:[u3000-u303F]|[u3040-u309F]|[u30A0-u30FF]|[uFF00-uFFEF]|[u4E00-u9FAF]|[u2605-u2606]|[u2190-u2195]|u203B|[u2010u2015u2018u2019u2025u2026u201Cu201Du2225u2260]|[u0391-u0451]|[u00A7u00A8u00B1u00B4u00D7u00F7])+";uu=uu.replace(/u/g,"\\u");const cie="(?:(?![A-Z0-9 $%*+\\-./:]|"+uu+`)(?:.|[\r
|
|
575
575
|
]))+`;vi.KANJI=new RegExp(uu,"g");vi.BYTE_KANJI=new RegExp("[^A-Z0-9 $%*+\\-./:]+","g");vi.BYTE=new RegExp(cie,"g");vi.NUMERIC=new RegExp(gA,"g");vi.ALPHANUMERIC=new RegExp(lie,"g");const uie=new RegExp("^"+uu+"$"),die=new RegExp("^"+gA+"$"),hie=new RegExp("^[A-Z0-9 $%*+\\-./:]+$");vi.testKanji=function(t){return uie.test(t)};vi.testNumeric=function(t){return die.test(t)};vi.testAlphanumeric=function(t){return hie.test(t)};(function(e){const t=f1,n=vi;e.NUMERIC={id:"Numeric",bit:1,ccBits:[10,12,14]},e.ALPHANUMERIC={id:"Alphanumeric",bit:2,ccBits:[9,11,13]},e.BYTE={id:"Byte",bit:4,ccBits:[8,16,16]},e.KANJI={id:"Kanji",bit:8,ccBits:[8,10,12]},e.MIXED={bit:-1},e.getCharCountIndicator=function(s,o){if(!s.ccBits)throw new Error("Invalid mode: "+s);if(!t.isValid(o))throw new Error("Invalid version: "+o);return o>=1&&o<10?s.ccBits[0]:o<27?s.ccBits[1]:s.ccBits[2]},e.getBestModeForData=function(s){return n.testNumeric(s)?e.NUMERIC:n.testAlphanumeric(s)?e.ALPHANUMERIC:n.testKanji(s)?e.KANJI:e.BYTE},e.toString=function(s){if(s&&s.id)return s.id;throw new Error("Invalid mode")},e.isValid=function(s){return s&&s.bit&&s.ccBits};function r(i){if(typeof i!="string")throw new Error("Param is not a string");switch(i.toLowerCase()){case"numeric":return e.NUMERIC;case"alphanumeric":return e.ALPHANUMERIC;case"kanji":return e.KANJI;case"byte":return e.BYTE;default:throw new Error("Unknown mode: "+i)}}e.from=function(s,o){if(e.isValid(s))return s;try{return r(s)}catch{return o}}})(Us);(function(e){const t=ar,n=Bp,r=Op,i=Us,s=f1,o=7973,a=t.getBCHDigit(o);function l(f,p,m){for(let v=1;v<=40;v++)if(p<=e.getCapacity(v,m,f))return v}function c(f,p){return i.getCharCountIndicator(f,p)+4}function u(f,p){let m=0;return f.forEach(function(v){const b=c(v.mode,p);m+=b+v.getBitsLength()}),m}function d(f,p){for(let m=1;m<=40;m++)if(u(f,m)<=e.getCapacity(m,p,i.MIXED))return m}e.from=function(p,m){return s.isValid(p)?parseInt(p,10):m},e.getCapacity=function(p,m,v){if(!s.isValid(p))throw new Error("Invalid QR Code version");typeof v>"u"&&(v=i.BYTE);const b=t.getSymbolTotalCodewords(p),x=n.getTotalCodewordsCount(p,m),_=(b-x)*8;if(v===i.MIXED)return _;const y=_-c(v,p);switch(v){case i.NUMERIC:return Math.floor(y/10*3);case i.ALPHANUMERIC:return Math.floor(y/11*2);case i.KANJI:return Math.floor(y/13);case i.BYTE:default:return Math.floor(y/8)}},e.getBestVersionForData=function(p,m){let v;const b=r.from(m,r.M);if(Array.isArray(p)){if(p.length>1)return d(p,b);if(p.length===0)return 1;v=p[0]}else v=p;return l(v.mode,v.getLength(),b)},e.getEncodedBits=function(p){if(!s.isValid(p)||p<7)throw new Error("Invalid QR Code version");let m=p<<12;for(;t.getBCHDigit(m)-a>=0;)m^=o<<t.getBCHDigit(m)-a;return p<<12|m}})(mA);var vA={};const Ix=ar,xA=1335,fie=21522,YC=Ix.getBCHDigit(xA);vA.getEncodedBits=function(t,n){const r=t.bit<<3|n;let i=r<<10;for(;Ix.getBCHDigit(i)-YC>=0;)i^=xA<<Ix.getBCHDigit(i)-YC;return(r<<10|i)^fie};var _A={};const pie=Us;function Qa(e){this.mode=pie.NUMERIC,this.data=e.toString()}Qa.getBitsLength=function(t){return 10*Math.floor(t/3)+(t%3?t%3*3+1:0)};Qa.prototype.getLength=function(){return this.data.length};Qa.prototype.getBitsLength=function(){return Qa.getBitsLength(this.data.length)};Qa.prototype.write=function(t){let n,r,i;for(n=0;n+3<=this.data.length;n+=3)r=this.data.substr(n,3),i=parseInt(r,10),t.put(i,10);const s=this.data.length-n;s>0&&(r=this.data.substr(n),i=parseInt(r,10),t.put(i,s*3+1))};var mie=Qa;const gie=Us,Ng=["0","1","2","3","4","5","6","7","8","9","A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z"," ","$","%","*","+","-",".","/",":"];function Ja(e){this.mode=gie.ALPHANUMERIC,this.data=e}Ja.getBitsLength=function(t){return 11*Math.floor(t/2)+6*(t%2)};Ja.prototype.getLength=function(){return this.data.length};Ja.prototype.getBitsLength=function(){return Ja.getBitsLength(this.data.length)};Ja.prototype.write=function(t){let n;for(n=0;n+2<=this.data.length;n+=2){let r=Ng.indexOf(this.data[n])*45;r+=Ng.indexOf(this.data[n+1]),t.put(r,11)}this.data.length%2&&t.put(Ng.indexOf(this.data[n]),6)};var vie=Ja;const xie=Us;function el(e){this.mode=xie.BYTE,typeof e=="string"?this.data=new TextEncoder().encode(e):this.data=new Uint8Array(e)}el.getBitsLength=function(t){return t*8};el.prototype.getLength=function(){return this.data.length};el.prototype.getBitsLength=function(){return el.getBitsLength(this.data.length)};el.prototype.write=function(e){for(let t=0,n=this.data.length;t<n;t++)e.put(this.data[t],8)};var _ie=el;const yie=Us,bie=ar;function tl(e){this.mode=yie.KANJI,this.data=e}tl.getBitsLength=function(t){return t*13};tl.prototype.getLength=function(){return this.data.length};tl.prototype.getBitsLength=function(){return tl.getBitsLength(this.data.length)};tl.prototype.write=function(e){let t;for(t=0;t<this.data.length;t++){let n=bie.toSJIS(this.data[t]);if(n>=33088&&n<=40956)n-=33088;else if(n>=57408&&n<=60351)n-=49472;else throw new Error("Invalid SJIS character: "+this.data[t]+`
|
|
576
576
|
Make sure your charset is UTF-8`);n=(n>>>8&255)*192+(n&255),e.put(n,13)}};var wie=tl,yA={exports:{}};(function(e){var t={single_source_shortest_paths:function(n,r,i){var s={},o={};o[r]=0;var a=t.PriorityQueue.make();a.push(r,0);for(var l,c,u,d,f,p,m,v,b;!a.empty();){l=a.pop(),c=l.value,d=l.cost,f=n[c]||{};for(u in f)f.hasOwnProperty(u)&&(p=f[u],m=d+p,v=o[u],b=typeof o[u]>"u",(b||v>m)&&(o[u]=m,a.push(u,m),s[u]=c))}if(typeof i<"u"&&typeof o[i]>"u"){var x=["Could not find a path from ",r," to ",i,"."].join("");throw new Error(x)}return s},extract_shortest_path_from_predecessor_list:function(n,r){for(var i=[],s=r;s;)i.push(s),n[s],s=n[s];return i.reverse(),i},find_path:function(n,r,i){var s=t.single_source_shortest_paths(n,r,i);return t.extract_shortest_path_from_predecessor_list(s,i)},PriorityQueue:{make:function(n){var r=t.PriorityQueue,i={},s;n=n||{};for(s in r)r.hasOwnProperty(s)&&(i[s]=r[s]);return i.queue=[],i.sorter=n.sorter||r.default_sorter,i},default_sorter:function(n,r){return n.cost-r.cost},push:function(n,r){var i={value:n,cost:r};this.queue.push(i),this.queue.sort(this.sorter)},pop:function(){return this.queue.shift()},empty:function(){return this.queue.length===0}}};e.exports=t})(yA);var Sie=yA.exports;(function(e){const t=Us,n=mie,r=vie,i=_ie,s=wie,o=vi,a=ar,l=Sie;function c(x){return unescape(encodeURIComponent(x)).length}function u(x,_,y){const S=[];let C;for(;(C=x.exec(y))!==null;)S.push({data:C[0],index:C.index,mode:_,length:C[0].length});return S}function d(x){const _=u(o.NUMERIC,t.NUMERIC,x),y=u(o.ALPHANUMERIC,t.ALPHANUMERIC,x);let S,C;return a.isKanjiModeEnabled()?(S=u(o.BYTE,t.BYTE,x),C=u(o.KANJI,t.KANJI,x)):(S=u(o.BYTE_KANJI,t.BYTE,x),C=[]),_.concat(y,S,C).sort(function(N,T){return N.index-T.index}).map(function(N){return{data:N.data,mode:N.mode,length:N.length}})}function f(x,_){switch(_){case t.NUMERIC:return n.getBitsLength(x);case t.ALPHANUMERIC:return r.getBitsLength(x);case t.KANJI:return s.getBitsLength(x);case t.BYTE:return i.getBitsLength(x)}}function p(x){return x.reduce(function(_,y){const S=_.length-1>=0?_[_.length-1]:null;return S&&S.mode===y.mode?(_[_.length-1].data+=y.data,_):(_.push(y),_)},[])}function m(x){const _=[];for(let y=0;y<x.length;y++){const S=x[y];switch(S.mode){case t.NUMERIC:_.push([S,{data:S.data,mode:t.ALPHANUMERIC,length:S.length},{data:S.data,mode:t.BYTE,length:S.length}]);break;case t.ALPHANUMERIC:_.push([S,{data:S.data,mode:t.BYTE,length:S.length}]);break;case t.KANJI:_.push([S,{data:S.data,mode:t.BYTE,length:c(S.data)}]);break;case t.BYTE:_.push([{data:S.data,mode:t.BYTE,length:c(S.data)}])}}return _}function v(x,_){const y={},S={start:{}};let C=["start"];for(let k=0;k<x.length;k++){const N=x[k],T=[];for(let z=0;z<N.length;z++){const I=N[z],M=""+k+z;T.push(M),y[M]={node:I,lastCount:0},S[M]={};for(let L=0;L<C.length;L++){const R=C[L];y[R]&&y[R].node.mode===I.mode?(S[R][M]=f(y[R].lastCount+I.length,I.mode)-f(y[R].lastCount,I.mode),y[R].lastCount+=I.length):(y[R]&&(y[R].lastCount=I.length),S[R][M]=f(I.length,I.mode)+4+t.getCharCountIndicator(I.mode,_))}}C=T}for(let k=0;k<C.length;k++)S[C[k]].end=0;return{map:S,table:y}}function b(x,_){let y;const S=t.getBestModeForData(x);if(y=t.from(_,S),y!==t.BYTE&&y.bit<S.bit)throw new Error('"'+x+'" cannot be encoded with mode '+t.toString(y)+`.
|
|
577
577
|
Suggested mode is: `+t.toString(S));switch(y===t.KANJI&&!a.isKanjiModeEnabled()&&(y=t.BYTE),y){case t.NUMERIC:return new n(x);case t.ALPHANUMERIC:return new r(x);case t.KANJI:return new s(x);case t.BYTE:return new i(x)}}e.fromArray=function(_){return _.reduce(function(y,S){return typeof S=="string"?y.push(b(S,null)):S.data&&y.push(b(S.data,S.mode)),y},[])},e.fromString=function(_,y){const S=d(_,a.isKanjiModeEnabled()),C=m(S),k=v(C,y),N=l.find_path(k.map,"start","end"),T=[];for(let z=1;z<N.length-1;z++)T.push(k.table[N[z]].node);return e.fromArray(p(T))},e.rawSplit=function(_){return e.fromArray(d(_,a.isKanjiModeEnabled()))}})(_A);const $p=ar,Tg=Op,kie=iie,Cie=sie,Eie=uA,Nie=dA,Px=hA,Rx=Bp,Tie=aie,Cf=mA,Iie=vA,Pie=Us,Ig=_A;function Rie(e,t){const n=e.size,r=Nie.getPositions(t);for(let i=0;i<r.length;i++){const s=r[i][0],o=r[i][1];for(let a=-1;a<=7;a++)if(!(s+a<=-1||n<=s+a))for(let l=-1;l<=7;l++)o+l<=-1||n<=o+l||(a>=0&&a<=6&&(l===0||l===6)||l>=0&&l<=6&&(a===0||a===6)||a>=2&&a<=4&&l>=2&&l<=4?e.set(s+a,o+l,!0,!0):e.set(s+a,o+l,!1,!0))}}function Mie(e){const t=e.size;for(let n=8;n<t-8;n++){const r=n%2===0;e.set(n,6,r,!0),e.set(6,n,r,!0)}}function Aie(e,t){const n=Eie.getPositions(t);for(let r=0;r<n.length;r++){const i=n[r][0],s=n[r][1];for(let o=-2;o<=2;o++)for(let a=-2;a<=2;a++)o===-2||o===2||a===-2||a===2||o===0&&a===0?e.set(i+o,s+a,!0,!0):e.set(i+o,s+a,!1,!0)}}function jie(e,t){const n=e.size,r=Cf.getEncodedBits(t);let i,s,o;for(let a=0;a<18;a++)i=Math.floor(a/3),s=a%3+n-8-3,o=(r>>a&1)===1,e.set(i,s,o,!0),e.set(s,i,o,!0)}function Pg(e,t,n){const r=e.size,i=Iie.getEncodedBits(t,n);let s,o;for(s=0;s<15;s++)o=(i>>s&1)===1,s<6?e.set(s,8,o,!0):s<8?e.set(s+1,8,o,!0):e.set(r-15+s,8,o,!0),s<8?e.set(8,r-s-1,o,!0):s<9?e.set(8,15-s-1+1,o,!0):e.set(8,15-s-1,o,!0);e.set(r-8,8,1,!0)}function Lie(e,t){const n=e.size;let r=-1,i=n-1,s=7,o=0;for(let a=n-1;a>0;a-=2)for(a===6&&a--;;){for(let l=0;l<2;l++)if(!e.isReserved(i,a-l)){let c=!1;o<t.length&&(c=(t[o]>>>s&1)===1),e.set(i,a-l,c),s--,s===-1&&(o++,s=7)}if(i+=r,i<0||n<=i){i-=r,r=-r;break}}}function Die(e,t,n){const r=new kie;n.forEach(function(l){r.put(l.mode.bit,4),r.put(l.getLength(),Pie.getCharCountIndicator(l.mode,e)),l.write(r)});const i=$p.getSymbolTotalCodewords(e),s=Rx.getTotalCodewordsCount(e,t),o=(i-s)*8;for(r.getLengthInBits()+4<=o&&r.put(0,4);r.getLengthInBits()%8!==0;)r.putBit(0);const a=(o-r.getLengthInBits())/8;for(let l=0;l<a;l++)r.put(l%2?17:236,8);return Oie(r,e,t)}function Oie(e,t,n){const r=$p.getSymbolTotalCodewords(t),i=Rx.getTotalCodewordsCount(t,n),s=r-i,o=Rx.getBlocksCount(t,n),a=r%o,l=o-a,c=Math.floor(r/o),u=Math.floor(s/o),d=u+1,f=c-u,p=new Tie(f);let m=0;const v=new Array(o),b=new Array(o);let x=0;const _=new Uint8Array(e.buffer);for(let N=0;N<o;N++){const T=N<l?u:d;v[N]=_.slice(m,m+T),b[N]=p.encode(v[N]),m+=T,x=Math.max(x,T)}const y=new Uint8Array(r);let S=0,C,k;for(C=0;C<x;C++)for(k=0;k<o;k++)C<v[k].length&&(y[S++]=v[k][C]);for(C=0;C<f;C++)for(k=0;k<o;k++)y[S++]=b[k][C];return y}function Bie(e,t,n,r){let i;if(Array.isArray(e))i=Ig.fromArray(e);else if(typeof e=="string"){let c=t;if(!c){const u=Ig.rawSplit(e);c=Cf.getBestVersionForData(u,n)}i=Ig.fromString(e,c||40)}else throw new Error("Invalid data");const s=Cf.getBestVersionForData(i,n);if(!s)throw new Error("The amount of data is too big to be stored in a QR Code");if(!t)t=s;else if(t<s)throw new Error(`
|
|
@@ -582,4 +582,4 @@ Minimum version required to store current data is: `+s+`.
|
|
|
582
582
|
|
|
583
583
|
If you want to hide the \`${t.titleName}\`, you can wrap it with our VisuallyHidden component.
|
|
584
584
|
|
|
585
|
-
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},Zie="DialogDescriptionWarning",Qie=({contentRef:e,descriptionId:t})=>{const r=`Warning: Missing \`Description\` or \`aria-describedby={undefined}\` for {${BA(Zie).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},Jie=CA,ese=TA,zA=IA,$A=PA,FA=MA,HA=jA,tse=DA;const _1=Jie,nse=ese,UA=g.forwardRef(({className:e,...t},n)=>h.jsx(zA,{ref:n,className:oe("fixed inset-0 z-50 bg-black/50 backdrop-blur-sm",e),...t}));UA.displayName=zA.displayName;const Hp=g.forwardRef(({className:e,children:t,...n},r)=>h.jsxs(nse,{children:[h.jsx(UA,{}),h.jsxs($A,{ref:r,className:oe("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(tse,{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(zr,{className:"h-4 w-4"}),h.jsx("span",{className:"sr-only",children:"Close"})]})]})]}));Hp.displayName=$A.displayName;const Up=({className:e,...t})=>h.jsx("div",{className:oe("flex flex-col space-y-1.5 text-left",e),...t});Up.displayName="DialogHeader";const y1=({className:e,...t})=>h.jsx("div",{className:oe("flex flex-row justify-end gap-2",e),...t});y1.displayName="DialogFooter";const Wp=g.forwardRef(({className:e,...t},n)=>h.jsx(FA,{ref:n,className:oe("text-lg font-semibold leading-none text-text-100",e),...t}));Wp.displayName=FA.displayName;const WA=g.forwardRef(({className:e,...t},n)=>h.jsx(HA,{ref:n,className:oe("text-sm text-text-300",e),...t}));WA.displayName=HA.displayName;function rse({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(n8,{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(zr,{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(w$,{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(y$,{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(Z_,{className:"h-4 w-4"})}):null]})]}),h.jsx("hr",{className:"border-border"}),d?h.jsxs(h.Fragment,{children:[h.jsx(ase,{...d}),h.jsx("hr",{className:"border-border"})]}):null,s?h.jsxs(h.Fragment,{children:[h.jsx(dse,{onLoad:s,...o?{onSave:o}:{},onDirtyChange:m,initialPersonality:l,readOnly:u}),h.jsx("hr",{className:"border-border"})]}):null,h.jsx(lse,{settings:e.sandboxSettings??null}),h.jsx("hr",{className:"border-border"}),h.jsx(cse,{skills:e.skills??[]}),h.jsx("hr",{className:"border-border"}),h.jsx(use,{plugins:e.plugins??[]})]})]})]}):null}function ise({qrUrl:e,busy:t,onCancel:n}){const[r,i]=g.useState(null);return g.useEffect(()=>{let s=!1;return zu.toDataURL(e,{width:240,margin:1}).then(o=>{s||i(o)}).catch(()=>{s||i(null)}),()=>{s=!0}},[e]),h.jsx(_1,{open:!0,onOpenChange:s=>s||n==null?void 0:n(),children:h.jsxs(Hp,{className:"max-w-xs","data-testid":"lark-bot-qr-dialog",onInteractOutside:s=>s.preventDefault(),onEscapeKeyDown:s=>s.preventDefault(),children:[h.jsx(Up,{children:h.jsx(Wp,{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 sse={expired:"二维码已过期,请重新扫码。",cancelled:"已取消。",access_denied:"你在飞书上取消了本次授权。",lark_protocol_error:"飞书返回了未预期的响应,请重试。",cloud_unreachable:"云端暂时不可达,请稍后重试。",internal_error:"关联失败。若飞书中已创建应用,可在开发者后台删除后重试,或改用手动绑定填入其凭证。"},ose=new Set(["expired","access_denied","lark_protocol_error","cloud_unreachable","internal_error"]);function ase({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)},x=!s&&!!c&&!!d,_=()=>{!x||!r||v(()=>r({appId:c,appSecret:d}))},y=Pu(_),S=h.jsxs("div",{className:"flex items-center gap-1.5",children:[h.jsx(lp,{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:[S,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:sse[e.errorReason]}),h.jsxs("div",{className:"flex gap-1.5",children:[ose.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(ise,{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:!x,onClick:_,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:[S,h.jsx("span",{className:"text-[11px] text-text-400",children:"状态加载中…"})]})}function lse({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($d,{label:"权限默认模式",value:((t=e.permissions)==null?void 0:t.defaultMode)??"—"}),h.jsx($d,{label:"沙箱启用",value:Mg((n=e.sandbox)==null?void 0:n.enabled)}),h.jsx($d,{label:"沙箱内自动放行 Bash",value:Mg((r=e.sandbox)==null?void 0:r.autoAllowBashIfSandboxed)}),h.jsx($d,{label:"允许非沙箱命令",value:Mg((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(Kl,{label:"沙箱外命令",paths:(s=e.sandbox)==null?void 0:s.excludedCommands}),h.jsx(Kl,{label:"允许读取",paths:(a=(o=e.sandbox)==null?void 0:o.filesystem)==null?void 0:a.allowRead}),h.jsx(Kl,{label:"拒绝读取",paths:(c=(l=e.sandbox)==null?void 0:l.filesystem)==null?void 0:c.denyRead}),h.jsx(Kl,{label:"允许写入",paths:(d=(u=e.sandbox)==null?void 0:u.filesystem)==null?void 0:d.allowWrite}),h.jsx(Kl,{label:"拒绝写入",paths:(p=(f=e.sandbox)==null?void 0:f.filesystem)==null?void 0:p.denyWrite})]})]})]})}function Mg(e){return e===!0?"是":e===!1?"否":"—"}function $d({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 Kl({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 cse({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 use({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 dse({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,x]=g.useState(null),_=Qe.useRef(e),y=Qe.useRef(t),S=Qe.useRef(n);Qe.useEffect(()=>{_.current=e,y.current=t,S.current=n});const C=Qe.useCallback(()=>{a(!1),p(null),_.current().then(I=>{c(I),d(I),a(!0)}).catch(I=>{p(I instanceof Error?I.message:String(I))})},[]);Qe.useEffect(()=>{s||C()},[s,C]);const k=!i&&o&&u!==l;Qe.useEffect(()=>{i||S.current(k)},[k,i]);const N=()=>{y.current&&(v(!0),x(null),y.current(u).then(()=>{c(u),v(!1)}).catch(I=>{x(I instanceof Error?I.message:String(I)),v(!1)}))},T=()=>{d(l),x(null)},z=Pu(()=>{!k||m||N()},()=>{!k||m||T()});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:I=>d(I.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:T,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:N,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 hse={state:"unbound",groups:[]};function fse(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(hse)}};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 pse(e,t="owner"){const{persona:n}=GT(e),r=bz(e),i=wz(),s=Sz(),{httpBaseUrl:o}=ap(),a=pi(),l=fse(t==="guest"?null:a,e),{capabilities:c}=u1((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,S)=>{i(e,S).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]),x=g.useCallback(async()=>r.loaded?r.personality:(await r.refresh()).personality,[r]),_=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:x,savePersonality:_}}function mse({personaId:e,open:t,onClose:n,api:r,embedded:i,onDirtyChange:s,onShareCapability:o,viewerRole:a="owner"}){const l=pse(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(rse,{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 gse(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 vse(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 b1(e,t,n,r,i){const s=await e.attachmentSignUrl({sessionId:n,relPath:r,...i!==void 0?{ttlSeconds:i}:{}});return vse(s.url,gse(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 b1(e,t,n,r,i);o?o.location.href=a:window.open(a,"_blank")}catch(a){throw o&&o.close(),a}}async function xse(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 _se={...Ls,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 yse(e){const t=e.split("/");return t[t.length-1]||e}function VA({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:yse(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(Ya,{remarkPlugins:[Xa],components:_se,children:i})}):null})]})}function bse({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(VA,{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(T$,{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(zr,{className:"h-4 w-4"})})]})})}):null}function wse({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 Sse=6173,kse=6182;function Cse({open:e,onOpenChange:t,projectName:n,currentPort:r,allUsedPorts:i,onUpdate:s}){const o=[];for(let v=Sse;v<=kse;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(_1,{open:e,onOpenChange:t,children:h.jsxs(Hp,{className:"max-w-md",children:[h.jsxs(Up,{children:[h.jsxs(Wp,{children:["改端口 · ",n]}),h.jsxs(WA,{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(y1,{children:[h.jsx(oi,{variant:"ghost",onClick:()=>t(!1),disabled:c,children:"取消"}),h.jsx(oi,{onClick:m,disabled:!p,children:c?"应用中…":"应用新端口"})]})]})})}const QC=[{stage:"build",label:"构建"},{stage:"deploy",label:"部署到阿里云"},{stage:"verify",label:"验证可访问性"}];function Ese({currentStage:e,onCancel:t}){const n=QC.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:[QC.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(yu,{className:"size-3.5"}):o?h.jsx(Mn,{className:"size-3.5 animate-spin"}):h.jsx(ZT,{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 Nse={build:"构建",deploy:"部署",verify:"验证"};function Tse({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(Qc,{className:"size-3.5 text-yellow-500"}),h.jsxs("span",{className:"text-text-200",children:["上次发布在 ",h.jsxs("strong",{className:"font-medium",children:["[",Nse[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 Ise={build:"构建",deploy:"部署",verify:"验证",unknown:"未知"};function Pse({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(Wi,{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:["[",Ise[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(zr,{className:"size-3.5"})})]})}const JC={"install-pending":{label:"等装依赖…",step:"1/3"},installing:{label:"安装依赖中…(可能要几十秒到几分钟)",step:"2/3"},"starting-dev-server":{label:"启动 dev server…(等监听端口才挂 iframe)",step:"3/3"}};function Rse({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(Zc,{className:"size-3"}),"打开线上"]}):null,s,h.jsxs(wy,{children:[h.jsx(Sy,{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(e8,{className:"size-3.5"})})}),h.jsxs(_p,{align:"end",children:[h.jsx(Ci,{onSelect:()=>p(!0),children:"Update Port…"}),h.jsxs(Ci,{disabled:!0,title:"rename not supported yet",onSelect:y=>y.preventDefault(),children:["Name: ",e.name]})]})]})]})]}),c?h.jsx(Pse,{stage:c.stage,onClose:()=>u==null?void 0:u(),onFocusChat:()=>d==null?void 0:d()}):null,((x=e.publishJob)==null?void 0:x.status)==="in-flight"?h.jsx(Ese,{currentStage:o??e.publishJob.stage,onCancel:()=>void(a==null?void 0:a())}):null,((_=e.publishJob)==null?void 0:_.status)==="interrupted"?h.jsx(Tse,{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(Mse,{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(e2,{label:"等 tunnel 起来…",step:"-"}):h.jsx(e2,{label:JC[m].label,step:JC[m].step})}),h.jsx(Cse,{open:f,onOpenChange:p,projectName:e.name,currentPort:e.port,allUsedPorts:i,onUpdate:async y=>{await r(y)}})]})}function e2({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(Mn,{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 Mse({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(Wi,{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 Ase({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(_1,{open:!!e,onOpenChange:s=>{s||(r(!1),t())},children:h.jsxs(Hp,{className:"max-w-lg",children:[h.jsx(Up,{children:h.jsx(Wp,{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(y1,{children:[h.jsx(oi,{variant:"ghost",onClick:i,className:"gap-1.5",children:n?h.jsxs(h.Fragment,{children:[h.jsx(ml,{className:"size-3.5"}),"已复制"]}):h.jsxs(h.Fragment,{children:[h.jsx(cp,{className:"size-3.5"}),"复制"]})}),h.jsx(oi,{onClick:t,children:"关闭"})]})]})})}function jse(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 Lse={codex:"on-request",claude:"bypassPermissions"};function Dse(e){const t={cwd:e.cwd,permissionMode:e.sourcePermissionMode??Lse[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 Ose(e,t,n,r={}){if(!t.toolSessionId)return null;const i=await e.sessionCreate({...Dse({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 Bse(e,t,n){return Ose(e,t,n,{ephemeral:!0})}function Fd(e){return e!=null&&e.ephemeral!==!1}async function zse(e,t){return t.stillEphemeral?(await e.sessionUpdate(t.sessionId,{ephemeral:!1}),!0):!1}const $se=300;function Fse(e){return e&&typeof e=="object"&&"value"in e?e.value:e}function Hse(e,t){const n=T_(),[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=Fse(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(()=>{})},$se)},[n,e]);return g.useEffect(()=>()=>{s.current&&(clearTimeout(s.current),s.current=null)},[]),{initialSize:r??t,setSize:o,loading:r===null}}function Use(){return{quickAsk:null,mds:[],active:null}}function Wse(e,t){return{...e,quickAsk:{sessionId:t.sessionId,ephemeral:!0},active:"quick-ask"}}function Vse(e,t){const n=e.mds.includes(t);return{...e,mds:n?e.mds:[...e.mds,t],active:{kind:"md",relPath:t}}}function qse(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 Kse(e){return e.quickAsk?{...e,quickAsk:{...e.quickAsk,ephemeral:!1}}:e}function Gse(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 Yse(e,t){return{...e,active:t}}function Xse(e,t){return e===null||t===null||e==="quick-ask"||t==="quick-ask"?e===t:e.relPath===t.relPath}function qA(e){return e.quickAsk!==null||e.mds.length>0}function Zse(e){return e.split("/").pop()||e}function Qse({state:e,api:t,onSwitchTab:n,onCloseQuickAsk:r,onCloseMd:i,loadMarkdown:s,quickAskSession:o,onPromoteQuickAsk:a}){if(!qA(e))return null;const l=[];e.quickAsk&&l.push({id:"quick-ask",label:"问一下",title:"问一下",icon:h.jsx(x0,{className:"w-3.5 h-3.5"})});for(const c of e.mds)l.push({id:{kind:"md",relPath:c},label:Zse(c),title:c,icon:h.jsx(ui,{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(cf,{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=Xse(e.active,c.id),d=c.id==="quick-ask"?"quick-ask":`md:${c.id.relPath}`;return h.jsxs(Sp,{children:[h.jsx(kp,{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(zr,{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(Ru,{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(roe,{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(VA,{relPath:c,loadMarkdown:s,showTitleBar:!1})},`md-body:${c}`)})]})]})}function Jse({state:e,extras:t}){const{api:n,session:r}=t,i=pi(),[s,o]=g.useState(Use()),a=g.useRef(s);a.current=s;const l=g.useRef(!1),c=g.useCallback(async C=>{const k=a.current.quickAsk,N=await Bse(n,r,C);if(N){if(l.current){n.sessionDelete(N.sessionId).catch(()=>{});return}Fd(k)&&n.sessionDelete(k.sessionId).catch(()=>{}),o(T=>Wse(T,{sessionId:N.sessionId}))}},[n,r]),u=g.useCallback(async C=>{const k=a.current.quickAsk,N=(k==null?void 0:k.sessionId)===C;try{await zse(n,{sessionId:C,stillEphemeral:N&&Fd(k)})&&o(z=>Kse(z))}catch(T){Ae("quick-ask","promote failed",T)}},[n]),d=g.useCallback(C=>{o(k=>Vse(k,C))},[]),f=g.useCallback(C=>{o(k=>Yse(k,C))},[]),p=g.useCallback(()=>{const C=a.current.quickAsk;Fd(C)&&n.sessionDelete(C.sessionId).catch(()=>{}),o(k=>qse(k))},[n]),m=g.useCallback(C=>{o(k=>Gse(k,C))},[]);g.useEffect(()=>()=>{l.current=!0;const C=a.current.quickAsk;Fd(C)&&n.sessionDelete(C.sessionId).catch(()=>{})},[]);const v=ci("sessions")??[],b=s.quickAsk?v.find(C=>C.sessionId===s.quickAsk.sessionId)??{sessionId:s.quickAsk.sessionId,cwd:r.cwd,tool:r.tool}:null,x=g.useCallback(async C=>{const k=await b1(n,i,r.sessionId,C,60),N=await fetch(k);if(!N.ok)throw new Error(`fetch ${N.status} ${N.statusText}`);return N.text()},[n,i,r.sessionId]),_=h.jsx(w1,{state:e,extras:t,onQuickAskInternal:c,onPreviewMdInternal:d}),{initialSize:y,setSize:S}=Hse("chat-panel-right-slot-width",480);return h.jsxs(Ay,{orientation:"horizontal",className:"flex-1 flex min-w-0 min-h-0",children:[h.jsx(uf,{id:"chat",minSize:"400px",children:_}),qA(s)?h.jsxs(h.Fragment,{children:[h.jsx(FR,{className:"w-1 bg-text-100/10 hover:bg-text-100/25 transition-colors cursor-col-resize"}),h.jsx(uf,{id:"right-slot",defaultSize:`${y}px`,minSize:"360px",maxSize:"800px",onResize:C=>S(C.inPixels),children:h.jsx(Qse,{state:s,api:n,onSwitchTab:f,onCloseQuickAsk:p,onCloseMd:m,loadMarkdown:x,quickAskSession:b,onPromoteQuickAsk:u})})]}):null]})}const eoe={closeTrailing:!1},toe={closeTrailing:!0};function noe(e){return e?eoe:toe}function roe({session:e,api:t,onPromoteQuickAsk:n}){const r=aA(e.sessionId);return h.jsx(w1,{state:r,extras:{session:e,api:t,...n?{onPromoteQuickAsk:n}:{}}})}function ioe({extras:e}){const t=aA(e.session.sessionId);if(e.session.appBuilderProject){const n=h.jsx(w1,{state:t,extras:e});return h.jsx(soe,{state:t,chat:n,extras:e})}return h.jsx(Jse,{state:t,extras:e})}function soe({state:e,chat:t,extras:n}){var T;const r=ci("daemon-info"),i=pi(),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",I=>{const M=I;M!=null&&M.project&&(M.project.name===a&&c(M.project),f(L=>{const R=L.findIndex(D=>D.name===M.project.name);if(R<0)return[...L,M.project];const A=L.slice();return A[R]=M.project,A}))}),[i,a]);const{host:m,scheme:v}=jse(i.url,r==null?void 0:r.tunnelUrl),[b,x]=g.useState(void 0),[_,y]=g.useState(null);g.useEffect(()=>{const z=i.on("appBuilder:publish-progress",M=>{const L=M;!L||L.name!==a||L.status==="started"&&x(L.stage)}),I=i.on("appBuilder:publish-failed",M=>{const L=M;!L||L.name!==a||(x(void 0),y({stage:L.stage}))});return()=>{z(),I()}},[i,a]),g.useEffect(()=>{x(void 0),y(null)},[a]);const[S,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:((T=l==null?void 0:l.publishJob)==null?void 0:T.status)==="in-flight",onClick:async()=>{try{await s.appBuilderPublish(a)}catch(z){C({title:"发布请求失败",message:(z==null?void 0:z.message)??String(z)})}},children:"发布上线"}),N=(l==null?void 0:l.stage)??(l!=null&&l.isRunning?"running":"stopped");return h.jsxs(h.Fragment,{children:[h.jsx(wse,{left:t,stage:N,onExpand:async()=>{await s.appBuilderStartDevServer(o.sessionId)},onCollapse:async()=>{await s.appBuilderStopDevServer(o.sessionId)},right:h.jsx(Rse,{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:_,onPublishFailureBannerClose:()=>y(null),onPublishFailureBannerFocusChat:()=>{}})}),h.jsx(Ase,{error:S,onClose:()=>C(null)})]})}function ooe({headerMeta:e,connState:t,liveWorktreeRoot:n,onOpenConfig:r,variant:i="full",ephemeral:s,onPromote:o,hideHeader:a=!1,lines:l,pendingPermissions:c,procAlive:u,rewindableUserMessageIds:d,onPermissionRespond:f,onPermissionInterrupt:p,onRewind:m,onFork:v,onQuickAsk:b,topSlot:x,realtimeQuestionAnswers:_,onSubmitQuestion:y,onCancelQuestion:S,liveQuestionToolUseIds:C,api:k,cwd:N,tool:T,sessionKey:z,onSend:I,awaitingUser:M,onAbort:L,onNewSession:R,onClearSession:A,configSlot:D,chatRootRef:$,chatBodyRef:F,drawers:O,xtermSlot:B,fileSharingScope:E,onShareFile:H,onOpenInTab:q,onPreviewMarkdown:j,onOpenFilePath:ne,resolvePersona:re}){return h.jsx(hJ,{children:h.jsxs("div",{ref:$,"data-cc-chat-root":"",className:"flex flex-col h-full bg-bg-100",children:[a?null:h.jsx(lee,{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:F,"data-testid":"chat-body",className:"flex-1 overflow-y-auto min-h-0",style:{overflowAnchor:"none"},children:h.jsx(cM,{lines:l,...f?{onPermissionRespond:f}:{},...p&&u?{onPermissionInterrupt:p}:{},topSlot:x,...m?{onRewind:m}:{},rewindableUserMessageIds:d,...v?{onFork:v}:{},...b?{onQuickAsk:b}:{},realtimeQuestionAnswers:_,onSubmitQuestion:y,...S?{onCancelQuestion:S}:{},liveQuestionToolUseIds:C,...E?{fileSharingScope:E}:{},...H?{onShareFile:H}:{},...q?{onOpenInTab:q}:{},...j?{onPreviewMarkdown:j}:{},...ne?{onOpenFilePath:ne}:{},...re?{resolvePersona:re}:{},...i==="full"?{turnCollapse:noe(u)}:{}})}),B,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(oee,{meta:e,...k?{api:k}:{},cwd:N,...T?{tool:T}:{},sessionKey:z,onSend:I,awaitingUser:M,...L?{onAbort:L}:{},...R?{onNewSession:R}:{},...A?{onClearSession:A}:{},...D?{configSlot:D}:{}}),O]})})}function w1({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,hideHeader:b}=t,{capabilities:x}=u1(i.tool||"claude"),_=(x==null?void 0:x.features)??WT(i.tool),[y,S]=g.useState(null),[C,k]=g.useState(null),N=ap(),T=!!s&&N.actionsLevel==="owner"&&_.fileSharing,z=GT(i.ownerPersonaId??null).persona,I=(z==null?void 0:z.label)??null,M=!!I&&!!i.ownerPersonaId,{raw:L}=K_(),R=g.useCallback(Z=>{const fe=L.find(be=>be.personaId===Z);return fe?{label:fe.label,...fe.tool?{tool:fe.tool}:{}}:void 0},[L]),A=g.useCallback((Z,fe)=>{S({kind:Z,text:fe}),setTimeout(()=>{S(be=>(be==null?void 0:be.text)===fe?null:be)},2e3)},[]),D=pi(),$=ZB(),F=oA(i.sessionId,i.toolSessionId),{events:O,pendingQuestions:B,clearQuestion:E,markQuestionSubmitted:H,status:q}=F,j=e.historyLoading,ne=mM(q);g.useEffect(()=>{Ae("chat-panel","sessionStatus",{sessionId:i.sessionId,sessionStatus:q,procAlive:ne})},[q,ne,i.sessionId]);const re=e.lines,G=e.pendingPermissions,ve=G[0]??null,ze=g.useMemo(()=>ZW(O),[O]),[he,Ie]=g.useState(null),[Re,Ve]=g.useState(()=>new Set);GW(s,i.sessionId,i.toolSessionId,_.observe);const xe=g.useRef(i.sessionId);g.useEffect(()=>{if(xe.current=i.sessionId,!_.rewind){Ie(null);return}let Z=!1;return Ie(null),(async()=>{try{const fe=await s.sessionRewindableMessageIds(i.sessionId);if(Z)return;Ie(new Set(fe.userMessageIds))}catch{Z||Ie(null)}})(),()=>{Z=!0}},[s,i.sessionId,_.rewind]);const Ke=g.useCallback(()=>{const Z=i.sessionId;s.sessionRewindableMessageIds(Z).then(fe=>{xe.current===Z&&Ie(new Set(fe.userMessageIds))}).catch(()=>{})},[s,i.sessionId]),Cn=g.useMemo(()=>{if(he!==null){const Ze=new Set(he);for(const Cr of Re)Ze.delete(Cr);return Ze}const Z=new Set(["Edit","Write","MultiEdit","NotebookEdit"]),fe=new Set;let be=null;for(const Ze of re)Ze.kind==="user-text"?be=Ze.uuid??null:be&&Ze.kind==="tool-call"&&Z.has(Ze.tool)&&!Re.has(be)&&fe.add(be);return fe},[re,Re,he]),it=g.useRef(c);it.current=c,YW(i.sessionId,i.toolSessionId,()=>{Xe(null),Ve(new Set)});const ct=Tee({sessionStatus:q}),on=g.useRef(null);g.useEffect(()=>{var be;const Z=on.current,fe=(Z==null?void 0:Z.sid)===i.sessionId;fe&&Z.phase===ct||(on.current={sid:i.sessionId,phase:ct},Ae("session-phase",ct,{sid:i.sessionId,phase:ct,prev:fe?Z.phase:null,desc:Nee[ct]}),fe&&Z.phase==="turn-running"&&ct!=="turn-running"&&((be=it.current)==null||be.call(it),Ke()))},[ct,i.sessionId,Ke]);const gt=g.useCallback(()=>{s.sessionInterrupt(i.sessionId).catch(()=>{})},[s,i.sessionId]),[vt,Xe]=g.useState(null),st=g.useCallback(Z=>{Xe(Z)},[]),[At,Xt]=g.useState(!1),pn=g.useCallback(()=>{s.sessionStop(i.sessionId).catch(()=>{}),Xt(!1)},[s,i.sessionId]);g.useCallback(Z=>{s.pinSession(i.sessionId,Z).catch(fe=>{Ae("chat-panel","pinSession failed",{err:fe==null?void 0:fe.message})})},[s,i.sessionId]);const U=m?"quickask":"full",{container:J,onCollapse:ye}=fee(),ke=g.useRef(0),Ue=g.useRef(null);g.useEffect(()=>{const Z=fe=>{if(fe.key!=="Escape")return;if(!ne){ke.current=0;return}if(fe.isComposing)return;const Ze=fe.target;if(Ze&&Ze.closest("[data-cc-chat-root]")!==Ue.current)return;const Cr=Date.now();Cr-ke.current<2e3?(ke.current=0,Xt(!0)):(ke.current=Cr,gt())};return window.addEventListener("keydown",Z),()=>window.removeEventListener("keydown",Z)},[gt,ne]);const kt=g.useRef(null),an=g.useRef(!0),Ft=g.useRef(void 0),le=g.useRef(0),K=g.useRef(0),we=g.useRef(void 0);g.useEffect(()=>{k(null)},[i.sessionId]),g.useEffect(()=>{const Z=kt.current;if(!Z)return;const fe=150,be=Ze=>{Date.now()<K.current&&(Ze.preventDefault(),K.current=Date.now()+fe)};return Z.addEventListener("wheel",be,{passive:!1}),()=>Z.removeEventListener("wheel",be)},[]),g.useEffect(()=>{const Z=kt.current;if(!Z)return;const fe=32,be=()=>{const Ze=Z.scrollHeight-Z.scrollTop-Z.clientHeight;an.current=Ze<=fe};return Z.addEventListener("scroll",be,{passive:!0}),()=>Z.removeEventListener("scroll",be)},[]),g.useLayoutEffect(()=>{var Vo;const Z=kt.current;if(!Z)return;const fe=we.current!==i.sessionId;fe&&(we.current=i.sessionId,an.current=!0,Ft.current=void 0,le.current=0,K.current=0);const be=Ft.current,Ze=(Vo=re[0])==null?void 0:Vo.seq;Ft.current=Ze,!fe&&be!==void 0&&Ze!==void 0&&Ze<be?(Z.scrollTop=Z.scrollHeight-le.current,K.current=Date.now()+200):an.current&&(Z.scrollTop=Z.scrollHeight),le.current=Z.scrollHeight-Z.scrollTop},[re,ve==null?void 0:ve.requestId,i.sessionId]);const ft=g.useMemo(()=>{const Z={};for(const[fe,be]of Object.entries(B))be.submittedAnswers&&(Z[fe]=be.submittedAnswers);return Z},[B]),ln=g.useMemo(()=>new Set(Object.keys(B)),[B]),Sl=g.useCallback(async(Z,fe)=>{try{await s.answerQuestion({sessionId:i.sessionId,toolUseId:Z,answers:fe}),H(Z,fe)}catch{}},[s,i.sessionId,H]),kl=g.useCallback(async Z=>{try{await s.cancelQuestion({sessionId:i.sessionId,toolUseId:Z}),E(Z)}catch{}},[s,i.sessionId,E]),Cl=g.useCallback(async(Z,fe)=>{var be;if(ve)try{await((be=e.respondPermission)==null?void 0:be.call(e,ve.requestId,Z?"allow":"deny"))}catch{}},[e,ve]),Vp=g.useCallback(async()=>{const Z=i.sessionId;try{await s.sessionStop(Z)}catch{}e.clearSession?await e.clearSession():await s.sessionNew(Z)},[e,s,i.sessionId]),qp=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,");切走再切回可重试"]}):j&&re.length===0?h.jsx("div",{className:"flex justify-center py-4","data-testid":"history-loading",children:h.jsx(Mn,{className:"w-4 h-4 text-text-400 animate-spin"})}):null,[j,re.length,e.historyError]),Fu=e.meta,Hu=h.jsxs(h.Fragment,{children:[i.toolSessionId&&_.subagents?h.jsx(yee,{api:s,cwd:i.cwd,toolSessionId:i.toolSessionId,toolKind:i.tool??"claude"}):null,vt&&_.rewind?h.jsx(wee,{open:!0,onOpenChange:Z=>{Z||Xe(null)},api:s,sessionId:i.sessionId,userMessageId:vt,lines:re,procAlive:ne,onNoChanges:Z=>{Ve(fe=>{if(fe.has(Z))return fe;const be=new Set(fe);return be.add(Z),be})}}):null,At?h.jsx(aoe,{onConfirm:pn,onCancel:()=>Xt(!1)}):null]}),Ws={kind:"session",sessionId:i.sessionId},Vs=g.useCallback(async Z=>{if(s)try{await ZC(s,D,i.sessionId,Z)}catch(fe){const be=fe.message;Ae("chat-panel","open-in-tab failed",{err:be}),A("err",`Open in tab 失败:${be}`)}},[s,D,i.sessionId,A]),[El,Ho]=g.useState(!1),[Fr,Xi]=g.useState(null),qs=g.useCallback(Z=>{if(r){r(Z);return}Xi(Z),Ho(!0)},[r]),Kp=g.useCallback(Z=>{if(!s)return;const fe=async()=>{try{await s.attachmentGroupAdd(i.sessionId,Z)}catch(Ze){Ae("chat-panel","file-link groupAdd skipped",{err:Ze.message})}},be=Ze=>{const Cr=Ze.message;Ae("chat-panel","file-link open failed",{err:Cr}),A("err",`打开文件失败:${Cr}`)};if(Mp(Z)){fe().then(()=>qs(Z),be);return}ZC(s,D,i.sessionId,Z,60,fe).catch(be)},[s,D,i.sessionId,qs,A]),Ht=g.useCallback(async Z=>{if(!s)throw new Error("daemon api not ready");const fe=await b1(s,D,i.sessionId,Z,60),be=await fetch(fe);if(!be.ok)throw new Error(`fetch ${be.status} ${be.statusText}`);return await be.text()},[s,D,i.sessionId]),Uo=g.useCallback(async(Z,fe)=>{if(s)try{const{url:be}=await s.attachmentSignUrl({sessionId:i.sessionId,relPath:Z,ttlSeconds:86400,...fe?{view:fe}:{}}),Ze=await xse(be);A(Ze?"ok":"err",Ze?"分享链接已复制到剪贴板(24h 有效)":"复制失败:请手动复制")}catch(be){const Ze=be.message;Ae("chat-panel","share-file failed",{err:Ze}),A("err",`生成分享链接失败:${Ze}`)}},[s,i.sessionId,A]),Wo=g.useCallback(()=>k(null),[]),Pt=C==="files"&&T&&s?{title:"Edited Files",onBack:Wo,content:h.jsx(Zre,{api:s,scope:Ws,sessionId:i.sessionId,onShareFile:Uo,onOpenInTab:Vs,onPreviewMarkdown:qs})}:C==="cron"?{title:`定时任务${ze.length?` (${ze.length})`:""}`,onBack:Wo,content:h.jsx("div",{className:"p-3",children:h.jsx(Eee,{jobs:ze})})}:C==="persona"&&M&&s&&i.ownerPersonaId?{title:`Persona · ${I??""}`,onBack:Wo,content:h.jsx(mse,{personaId:i.ownerPersonaId,open:!0,onClose:Wo,api:s,embedded:!0,...p?{viewerRole:p}:{}},i.ownerPersonaId)}:null,jt=U==="full"?h.jsx(dee,{session:i,meta:Fu,...o!==void 0?{liveGitBranch:o}:{},...a!==void 0?{liveWorktreeRoot:a}:{},...M?{personaName:I}:{},...M?{onOpenPersona:()=>k("persona")}:{},...T?{onOpenFiles:()=>k("files")}:{},cronActiveCount:ze.length,onCronClick:()=>k("cron"),onForceStop:()=>Xt(!0),...p?{viewerRole:p}:{},...x!=null&&x.toolSessionIdLabel?{toolSessionIdLabel:x.toolSessionIdLabel}:{},drill:Pt,...ye?{onCollapse:ye}:{}}):null;return h.jsxs(h.Fragment,{children:[J&&jt?ol.createPortal(jt,J):null,h.jsx(ooe,{headerMeta:Fu,connState:e.connState,...a!==void 0?{liveWorktreeRoot:a}:{},...u?{onOpenConfig:u}:{},variant:U,...b?{hideHeader:b}:{},...U==="quickask"?{ephemeral:i.ephemeral!==!1,onPromote:()=>void(m==null?void 0:m(i.sessionId))}:{},lines:re,pendingPermissions:G,procAlive:ne,rewindableUserMessageIds:Cn,onPermissionRespond:Cl,onPermissionInterrupt:gt,onRewind:_.rewind?st:void 0,...d&&_.fork?{onFork:d}:{},...n&&_.fork?{onQuickAsk:n}:f&&_.fork?{onQuickAsk:f}:{},topSlot:qp,realtimeQuestionAnswers:ft,onSubmitQuestion:Sl,onCancelQuestion:kl,liveQuestionToolUseIds:ln,api:s,cwd:i.cwd,...i.tool?{tool:i.tool}:{},sessionKey:i.sessionId,onSend:e.sendText,awaitingUser:G.length>0||Object.values(B).some(Z=>!Z.submittedAnswers),onAbort:gt,...l?{onNewSession:l}:{},onClearSession:Vp,...v?{configSlot:v}:{},chatRootRef:Ue,chatBodyRef:kt,drawers:Hu,xtermSlot:$==="tui"&&ne&&_.tui?h.jsx(Hre,{sessionId:i.sessionId,client:D},i.sessionId):null,fileSharingScope:Ws,...s?{onShareFile:Uo}:{},...s?{onOpenInTab:Vs}:{},...s?{onPreviewMarkdown:qs}:{},...s?{onOpenFilePath:Kp}:{},resolvePersona:R}),s?h.jsx(bse,{open:El,onOpenChange:Ho,relPath:Fr,loadMarkdown:Ht,onShare:Fr?()=>void Uo(Fr,"md-rendered"):void 0}):null,y?h.jsx("div",{"data-testid":"share-toast",role:"status","aria-live":"polite",className:y.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:y.text}):null]})}function aoe({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(Qc,{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 loe(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 coe(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 uoe(e,t){var m,v,b,x;const{models:n,modes:r,configSchema:i}=t,s=e.resolvedModel??e.model,o=loe(s,n,i),a=o.options,l=a.some(_=>_.value===e.effort)?e.effort:o.defaultValue,c=e.effort===""&&e.resolvedEffort?((m=a.find(_=>_.value===e.resolvedEffort))==null?void 0:m.label)??e.resolvedEffort:((v=a.find(_=>_.value===l))==null?void 0:v.label)??null,u=((b=i.find(_=>_.name==="permissionMode"))==null?void 0:b.default)??"",d=r.some(_=>_.id===e.permissionMode)?e.permissionMode:u,p=d===u?null:((x=r.find(_=>_.id===d))==null?void 0:x.label)??null;return{modelLabel:coe(n,s),effortOptions:a,effortValue:l,effortLabel:c,modeValue:d,modeLabel:p,modeTone:p===null?null:d==="bypassPermissions"?"danger":"info"}}function doe({models:e=[],modes:t=[],configSchema:n=[],model:r,resolvedModel:i,resolvedEffort:s,effort:o,permissionMode:a,onPatch:l}){var p;const c=uoe({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(wy,{children:[h.jsx(Sy,{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:oe("font-semibold",c.modeTone==="danger"?"text-red-400":"text-blue-400"),children:c.modeLabel})]}):null]})}),h.jsxs(_p,{side:"top",align:"end",className:"w-[230px]","data-testid":"session-config-menu",children:[h.jsx(Ag,{testid:"session-config-model",label:"Model",current:r,currentLabel:c.modelLabel,options:d,onSelect:m=>l({model:m})}),h.jsx(Ag,{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(Ag,{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 Ag({testid:e,label:t,current:n,currentLabel:r,currentTone:i,options:s,onSelect:o}){const a=s.length===0;return h.jsxs(bU,{children:[h.jsxs(uR,{"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:oe("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(Ln,{className:"w-3.5 h-3.5 shrink-0 text-text-500"})]}),h.jsx(dR,{className:"w-[220px] max-h-[320px] overflow-y-auto",children:s.map(l=>{const c=l.value===n;return h.jsxs(Ci,{"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:oe("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(ml,{className:"w-3.5 h-3.5 shrink-0 text-accent mt-0.5"}):null]},l.value||"default")})})]})}function hoe(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 foe(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 poe({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",hideHeader:f}){const{capabilities:p}=u1(t.tool),[m,v]=g.useState(0),{branch:b}=hoe(e,t.cwd,m),{worktreeRoot:x}=foe(e,t.cwd,m),_=r>1,y=S=>{e.sessionUpdate(t.sessionId,S).catch(C=>{console.error("[session-config] session:update failed",t.sessionId,C)})};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(Ay,{orientation:"horizontal",className:"flex-1 flex min-w-0 min-h-0",children:h.jsx(uf,{id:"chat",minSize:"400px",children:h.jsx("div",{className:"flex flex-col min-w-0 min-h-0 h-full",children:h.jsx(moe,{api:e,session:t,liveGitBranch:b,liveWorktreeRoot:x,onNewSession:o,onTurnEnd:()=>v(S=>S+1),onOpenConfig:a,onFork:l,onQuickAsk:c,viewerRole:d,hideHeader:f,configSlot:p?h.jsx(doe,{models:p.models,modes:p.permissionModes,configSchema:p.configSchema,model:t.model??"",...t.resolvedModel?{resolvedModel:t.resolvedModel}:{},...t.resolvedEffort?{resolvedEffort:t.resolvedEffort}:{},effort:t.effort??"",permissionMode:t.permissionMode??"",onPatch:y}):null})})})}),_&&h.jsx("button",{type:"button",onClick:S=>{S.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(zr,{className:"w-3.5 h-3.5"})})]})}function moe({api:e,session:t,liveGitBranch:n,liveWorktreeRoot:r,onNewSession:i,onTurnEnd:s,onOpenConfig:o,onFork:a,onQuickAsk:l,viewerRole:c,configSlot:u,hideHeader:d}){return h.jsx(ioe,{extras:{session:t,api:e,...n!==void 0?{liveGitBranch:n}:{},...r!==void 0?{liveWorktreeRoot:r}:{},onNewSession:i,onTurnEnd:s,onOpenConfig:o,...a?{onFork:f=>{a(f)}}:{},...l?{onQuickAsk:f=>{l(f)}}:{},...c?{viewerRole:c}:{},...u?{configSlot:u}:{},...d?{hideHeader:d}:{}}})}function goe({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(hW,{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(poe,{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 voe(){const e=pi(),t=g.useMemo(()=>new q_(e),[e]),n=_z(e),{sessions:r,refresh:i}=yz(n),{personas:s}=K_(),o=Ez(),a=g.useMemo(()=>{const S=window.location.pathname.match(/^\/s\/([^/]+)/);return S?decodeURIComponent(S[1]):null},[]),l=g.useMemo(()=>r.filter(S=>!S.ephemeral&&S.larkChatId==null),[r]),c=g.useMemo(()=>a?s.filter(S=>S.personaId===a):s,[s,a]),[u,d]=g.useState(null),[f,p]=g.useState(null),[m,v]=g.useState(null);g.useEffect(()=>{let S=!1;return e.request("whoami",{}).then(C=>{S||d(C.capability.id)}).catch(()=>{}),()=>{S=!0}},[e]),g.useEffect(()=>{a&&p(a)},[a]);const b=g.useCallback(async(S,C)=>{const k=await t.sessionCreate({ownerPersonaId:S,...C.trim()?{label:C.trim()}:{}});await i(),p(S),v(k.sessionId)},[t,i]),x=g.useCallback(async S=>{await t.sessionDelete(S),await i(),v(C=>C===S?null:C)},[t,i]),_=g.useCallback(async(S,C)=>{await t.sessionUpdate(S,{label:C.label}),await i()},[t,i]),y=g.useMemo(()=>l.find(S=>S.sessionId===m)??null,[l,m]);return h.jsx(G_.Provider,{value:o,children:h.jsx(goe,{personas:c,sessions:l,api:t,selfPrincipalId:u,selectedPersonaId:f,selectedSessionId:m,selectedSession:y,onSelectPersona:p,onSelectSession:v,onCreateSession:(S,C)=>void b(S,C),onDeleteSession:S=>void x(S),onEditSession:(S,C)=>void _(S,C),onCloseSession:()=>v(null)})})}const t2="https://app.ttcadvisory.com";function xoe({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=`${t2}/auth/authorize?callback_url=${encodeURIComponent(a)}&auto=1`,c=async d=>{if(d.origin!==t2)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 Ax="clawd-visitor:token";function _oe(e,t){const r=`${e.protocol==="https:"?"wss:":"ws:"}//${e.host}`;return t!=null&&t.devPath?`${r}${t.devPath}`:r}function yoe(){return{async getUrl(e){const t=localStorage.getItem(Ax);if(!t)throw new Error("NO_VISITOR_TOKEN");const n=_oe(window.location,{});return await zT(e).upsert({id:"guest",name:"访客",mode:"remote",url:n,token:t}),{url:n}}}}function boe(e){const t=n=>{document.documentElement.classList.toggle("dark",n==="dark")};return t(e.theme.mode),e.onThemeChange(n=>t(n.mode))}function woe(){const e=pi(),t=g.useMemo(()=>xz(e),[e]);return h.jsx(JB,{cache:t.cache,children:h.jsx(nz,{children:h.jsx(voe,{})})})}function Soe({host:e}){const[t]=g.useState(()=>localStorage.getItem(Ax)),[n,r]=g.useState(!1),[i,s]=g.useState(null);return g.useEffect(()=>boe(e),[e]),g.useEffect(()=>{if(!t)return;let o=!1;return yoe().getUrl(e).then(()=>{o||r(!0)}).catch(a=>{o||s(a instanceof Error?a.message:String(a))}),()=>{o=!0}},[e,t]),t?h.jsx(Bb,{host:e,children:h.jsx(vw,{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(XB,{host:e,children:h.jsx(woe,{})}):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(Bb,{host:e,children:h.jsx(vw,{children:h.jsx(xoe,{onAuthed:o=>{localStorage.setItem(Ax,o),window.location.reload()}})})})}function koe({filePath:e,oldString:t,newString:n,content:r}){const i=g.useMemo(()=>r!=null?r.split(/\r?\n/).map(s=>({type:"add",text:s})):Coe(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:oe("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 Coe(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 Eoe({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(Noe,{status:t.status}),h.jsx("span",{className:oe("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 Noe({status:e}){return e==="completed"?h.jsx(yu,{className:"w-3.5 h-3.5 text-success mt-0.5 shrink-0"}):e==="in_progress"?h.jsx(Mn,{className:"w-3.5 h-3.5 text-warning mt-0.5 shrink-0 animate-spin"}):h.jsx(ZT,{className:"w-3.5 h-3.5 text-text-400 mt-0.5 shrink-0"})}function Toe(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 Ioe({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(lp,{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 Poe(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 Roe={render:({input:e})=>Qe.createElement(Eoe,{items:Toe(e)})},Moe={render:({input:e})=>{const{description:t,prompt:n,subagentType:r}=Poe(e);return Qe.createElement(Ioe,{description:t,prompt:n,subagentType:r})}},KA={render:({input:e,output:t,error:n,pending:r,fileScope:i,onShareFile:s,onOpenInTab:o,onPreviewMarkdown:a})=>{const l=joe(e),c=l?Qe.createElement(koe,{filePath:l.filePath,oldString:l.oldString,newString:l.newString,content:l.content}):void 0;return Qe.createElement(nM,{tool:Aoe(e),input:e,output:t,error:n,pending:r,expandedBody:c,...i?{fileScope:i}:{},...s?{onShareFile:s}:{},...o?{onOpenInTab:o}:{},...a?{onPreviewMarkdown:a}:{}})}};function Aoe(e){const t=e??{};return"content"in t&&t.content!==void 0?"Write":("old_string"in t&&t.old_string!==void 0,"Edit")}function joe(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}}yl.register("claude","TodoWrite",Roe);yl.register("claude","Task",Moe);yl.register("claude","Edit",KA);yl.register("claude","Write",KA);const GA=document.getElementById("root");if(!GA)throw new Error("guest-main: #root not found");const Loe=Tj({});jg.createRoot(GA).render(h.jsx(Qe.StrictMode,{children:h.jsx(Soe,{host:Loe})}));
|
|
585
|
+
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},Zie="DialogDescriptionWarning",Qie=({contentRef:e,descriptionId:t})=>{const r=`Warning: Missing \`Description\` or \`aria-describedby={undefined}\` for {${BA(Zie).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},Jie=CA,ese=TA,zA=IA,$A=PA,FA=MA,HA=jA,tse=DA;const _1=Jie,nse=ese,UA=g.forwardRef(({className:e,...t},n)=>h.jsx(zA,{ref:n,className:oe("fixed inset-0 z-50 bg-black/50 backdrop-blur-sm",e),...t}));UA.displayName=zA.displayName;const Hp=g.forwardRef(({className:e,children:t,...n},r)=>h.jsxs(nse,{children:[h.jsx(UA,{}),h.jsxs($A,{ref:r,className:oe("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(tse,{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(zr,{className:"h-4 w-4"}),h.jsx("span",{className:"sr-only",children:"Close"})]})]})]}));Hp.displayName=$A.displayName;const Up=({className:e,...t})=>h.jsx("div",{className:oe("flex flex-col space-y-1.5 text-left",e),...t});Up.displayName="DialogHeader";const y1=({className:e,...t})=>h.jsx("div",{className:oe("flex flex-row justify-end gap-2",e),...t});y1.displayName="DialogFooter";const Wp=g.forwardRef(({className:e,...t},n)=>h.jsx(FA,{ref:n,className:oe("text-lg font-semibold leading-none text-text-100",e),...t}));Wp.displayName=FA.displayName;const WA=g.forwardRef(({className:e,...t},n)=>h.jsx(HA,{ref:n,className:oe("text-sm text-text-300",e),...t}));WA.displayName=HA.displayName;function rse({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(n8,{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(zr,{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(w$,{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(y$,{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(Z_,{className:"h-4 w-4"})}):null]})]}),h.jsx("hr",{className:"border-border"}),d?h.jsxs(h.Fragment,{children:[h.jsx(ase,{...d}),h.jsx("hr",{className:"border-border"})]}):null,s?h.jsxs(h.Fragment,{children:[h.jsx(dse,{onLoad:s,...o?{onSave:o}:{},onDirtyChange:m,initialPersonality:l,readOnly:u}),h.jsx("hr",{className:"border-border"})]}):null,h.jsx(lse,{settings:e.sandboxSettings??null}),h.jsx("hr",{className:"border-border"}),h.jsx(cse,{skills:e.skills??[]}),h.jsx("hr",{className:"border-border"}),h.jsx(use,{plugins:e.plugins??[]})]})]})]}):null}function ise({qrUrl:e,busy:t,onCancel:n}){const[r,i]=g.useState(null);return g.useEffect(()=>{let s=!1;return zu.toDataURL(e,{width:240,margin:1}).then(o=>{s||i(o)}).catch(()=>{s||i(null)}),()=>{s=!0}},[e]),h.jsx(_1,{open:!0,onOpenChange:s=>s||n==null?void 0:n(),children:h.jsxs(Hp,{className:"max-w-xs","data-testid":"lark-bot-qr-dialog",onInteractOutside:s=>s.preventDefault(),onEscapeKeyDown:s=>s.preventDefault(),children:[h.jsx(Up,{children:h.jsx(Wp,{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 sse={expired:"二维码已过期,请重新扫码。",cancelled:"已取消。",access_denied:"你在飞书上取消了本次授权。",lark_protocol_error:"飞书返回了未预期的响应,请重试。",cloud_unreachable:"云端暂时不可达,请稍后重试。",internal_error:"关联失败。若飞书中已创建应用,可在开发者后台删除后重试,或改用手动绑定填入其凭证。"},ose=new Set(["expired","access_denied","lark_protocol_error","cloud_unreachable","internal_error"]);function ase({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)},x=!s&&!!c&&!!d,_=()=>{!x||!r||v(()=>r({appId:c,appSecret:d}))},y=Pu(_),S=h.jsxs("div",{className:"flex items-center gap-1.5",children:[h.jsx(lp,{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:[S,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:sse[e.errorReason]}),h.jsxs("div",{className:"flex gap-1.5",children:[ose.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(ise,{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:!x,onClick:_,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:[S,h.jsx("span",{className:"text-[11px] text-text-400",children:"状态加载中…"})]})}function lse({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($d,{label:"权限默认模式",value:((t=e.permissions)==null?void 0:t.defaultMode)??"—"}),h.jsx($d,{label:"沙箱启用",value:Mg((n=e.sandbox)==null?void 0:n.enabled)}),h.jsx($d,{label:"沙箱内自动放行 Bash",value:Mg((r=e.sandbox)==null?void 0:r.autoAllowBashIfSandboxed)}),h.jsx($d,{label:"允许非沙箱命令",value:Mg((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(Kl,{label:"沙箱外命令",paths:(s=e.sandbox)==null?void 0:s.excludedCommands}),h.jsx(Kl,{label:"允许读取",paths:(a=(o=e.sandbox)==null?void 0:o.filesystem)==null?void 0:a.allowRead}),h.jsx(Kl,{label:"拒绝读取",paths:(c=(l=e.sandbox)==null?void 0:l.filesystem)==null?void 0:c.denyRead}),h.jsx(Kl,{label:"允许写入",paths:(d=(u=e.sandbox)==null?void 0:u.filesystem)==null?void 0:d.allowWrite}),h.jsx(Kl,{label:"拒绝写入",paths:(p=(f=e.sandbox)==null?void 0:f.filesystem)==null?void 0:p.denyWrite})]})]})]})}function Mg(e){return e===!0?"是":e===!1?"否":"—"}function $d({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 Kl({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 cse({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 use({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 dse({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,x]=g.useState(null),_=Qe.useRef(e),y=Qe.useRef(t),S=Qe.useRef(n);Qe.useEffect(()=>{_.current=e,y.current=t,S.current=n});const C=Qe.useCallback(()=>{a(!1),p(null),_.current().then(I=>{c(I),d(I),a(!0)}).catch(I=>{p(I instanceof Error?I.message:String(I))})},[]);Qe.useEffect(()=>{s||C()},[s,C]);const k=!i&&o&&u!==l;Qe.useEffect(()=>{i||S.current(k)},[k,i]);const N=()=>{y.current&&(v(!0),x(null),y.current(u).then(()=>{c(u),v(!1)}).catch(I=>{x(I instanceof Error?I.message:String(I)),v(!1)}))},T=()=>{d(l),x(null)},z=Pu(()=>{!k||m||N()},()=>{!k||m||T()});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:I=>d(I.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:T,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:N,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 hse={state:"unbound",groups:[]};function fse(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(hse)}};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 pse(e,t="owner"){const{persona:n}=GT(e),r=bz(e),i=wz(),s=Sz(),{httpBaseUrl:o}=ap(),a=pi(),l=fse(t==="guest"?null:a,e),{capabilities:c}=u1((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,S)=>{i(e,S).catch(C=>{Me("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=>{Me("persona","delete failed",y)}),!0),[n,s,e]),x=g.useCallback(async()=>r.loaded?r.personality:(await r.refresh()).personality,[r]),_=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:x,savePersonality:_}}function mse({personaId:e,open:t,onClose:n,api:r,embedded:i,onDirtyChange:s,onShareCapability:o,viewerRole:a="owner"}){const l=pse(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(rse,{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 gse(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 vse(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 b1(e,t,n,r,i){const s=await e.attachmentSignUrl({sessionId:n,relPath:r,...i!==void 0?{ttlSeconds:i}:{}});return vse(s.url,gse(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 b1(e,t,n,r,i);o?o.location.href=a:window.open(a,"_blank")}catch(a){throw o&&o.close(),a}}async function xse(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 _se={...Ls,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 yse(e){const t=e.split("/");return t[t.length-1]||e}function VA({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:yse(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(Ya,{remarkPlugins:[Xa],components:_se,children:i})}):null})]})}function bse({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(VA,{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(T$,{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(zr,{className:"h-4 w-4"})})]})})}):null}function wse({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 Sse=6173,kse=6182;function Cse({open:e,onOpenChange:t,projectName:n,currentPort:r,allUsedPorts:i,onUpdate:s}){const o=[];for(let v=Sse;v<=kse;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(_1,{open:e,onOpenChange:t,children:h.jsxs(Hp,{className:"max-w-md",children:[h.jsxs(Up,{children:[h.jsxs(Wp,{children:["改端口 · ",n]}),h.jsxs(WA,{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(y1,{children:[h.jsx(oi,{variant:"ghost",onClick:()=>t(!1),disabled:c,children:"取消"}),h.jsx(oi,{onClick:m,disabled:!p,children:c?"应用中…":"应用新端口"})]})]})})}const QC=[{stage:"build",label:"构建"},{stage:"deploy",label:"部署到阿里云"},{stage:"verify",label:"验证可访问性"}];function Ese({currentStage:e,onCancel:t}){const n=QC.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:[QC.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(yu,{className:"size-3.5"}):o?h.jsx(Mn,{className:"size-3.5 animate-spin"}):h.jsx(ZT,{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 Nse={build:"构建",deploy:"部署",verify:"验证"};function Tse({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(Qc,{className:"size-3.5 text-yellow-500"}),h.jsxs("span",{className:"text-text-200",children:["上次发布在 ",h.jsxs("strong",{className:"font-medium",children:["[",Nse[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 Ise={build:"构建",deploy:"部署",verify:"验证",unknown:"未知"};function Pse({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(Wi,{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:["[",Ise[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(zr,{className:"size-3.5"})})]})}const JC={"install-pending":{label:"等装依赖…",step:"1/3"},installing:{label:"安装依赖中…(可能要几十秒到几分钟)",step:"2/3"},"starting-dev-server":{label:"启动 dev server…(等监听端口才挂 iframe)",step:"3/3"}};function Rse({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(Zc,{className:"size-3"}),"打开线上"]}):null,s,h.jsxs(wy,{children:[h.jsx(Sy,{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(e8,{className:"size-3.5"})})}),h.jsxs(_p,{align:"end",children:[h.jsx(Ci,{onSelect:()=>p(!0),children:"Update Port…"}),h.jsxs(Ci,{disabled:!0,title:"rename not supported yet",onSelect:y=>y.preventDefault(),children:["Name: ",e.name]})]})]})]})]}),c?h.jsx(Pse,{stage:c.stage,onClose:()=>u==null?void 0:u(),onFocusChat:()=>d==null?void 0:d()}):null,((x=e.publishJob)==null?void 0:x.status)==="in-flight"?h.jsx(Ese,{currentStage:o??e.publishJob.stage,onCancel:()=>void(a==null?void 0:a())}):null,((_=e.publishJob)==null?void 0:_.status)==="interrupted"?h.jsx(Tse,{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(Mse,{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(e2,{label:"等 tunnel 起来…",step:"-"}):h.jsx(e2,{label:JC[m].label,step:JC[m].step})}),h.jsx(Cse,{open:f,onOpenChange:p,projectName:e.name,currentPort:e.port,allUsedPorts:i,onUpdate:async y=>{await r(y)}})]})}function e2({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(Mn,{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 Mse({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(Wi,{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 Ase({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(_1,{open:!!e,onOpenChange:s=>{s||(r(!1),t())},children:h.jsxs(Hp,{className:"max-w-lg",children:[h.jsx(Up,{children:h.jsx(Wp,{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(y1,{children:[h.jsx(oi,{variant:"ghost",onClick:i,className:"gap-1.5",children:n?h.jsxs(h.Fragment,{children:[h.jsx(ml,{className:"size-3.5"}),"已复制"]}):h.jsxs(h.Fragment,{children:[h.jsx(cp,{className:"size-3.5"}),"复制"]})}),h.jsx(oi,{onClick:t,children:"关闭"})]})]})})}function jse(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 Lse={codex:"on-request",claude:"bypassPermissions"};function Dse(e){const t={cwd:e.cwd,permissionMode:e.sourcePermissionMode??Lse[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 Ose(e,t,n,r={}){if(!t.toolSessionId)return null;const i=await e.sessionCreate({...Dse({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=>Me("quick-ask","fork rollback failed",o)),s}return i}async function Bse(e,t,n){return Ose(e,t,n,{ephemeral:!0})}function Fd(e){return e!=null&&e.ephemeral!==!1}async function zse(e,t){return t.stillEphemeral?(await e.sessionUpdate(t.sessionId,{ephemeral:!1}),!0):!1}const $se=300;function Fse(e){return e&&typeof e=="object"&&"value"in e?e.value:e}function Hse(e,t){const n=T_(),[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=Fse(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(()=>{})},$se)},[n,e]);return g.useEffect(()=>()=>{s.current&&(clearTimeout(s.current),s.current=null)},[]),{initialSize:r??t,setSize:o,loading:r===null}}function Use(){return{quickAsk:null,mds:[],active:null}}function Wse(e,t){return{...e,quickAsk:{sessionId:t.sessionId,ephemeral:!0},active:"quick-ask"}}function Vse(e,t){const n=e.mds.includes(t);return{...e,mds:n?e.mds:[...e.mds,t],active:{kind:"md",relPath:t}}}function qse(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 Kse(e){return e.quickAsk?{...e,quickAsk:{...e.quickAsk,ephemeral:!1}}:e}function Gse(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 Yse(e,t){return{...e,active:t}}function Xse(e,t){return e===null||t===null||e==="quick-ask"||t==="quick-ask"?e===t:e.relPath===t.relPath}function qA(e){return e.quickAsk!==null||e.mds.length>0}function Zse(e){return e.split("/").pop()||e}function Qse({state:e,api:t,onSwitchTab:n,onCloseQuickAsk:r,onCloseMd:i,loadMarkdown:s,quickAskSession:o,onPromoteQuickAsk:a}){if(!qA(e))return null;const l=[];e.quickAsk&&l.push({id:"quick-ask",label:"问一下",title:"问一下",icon:h.jsx(x0,{className:"w-3.5 h-3.5"})});for(const c of e.mds)l.push({id:{kind:"md",relPath:c},label:Zse(c),title:c,icon:h.jsx(ui,{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(cf,{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=Xse(e.active,c.id),d=c.id==="quick-ask"?"quick-ask":`md:${c.id.relPath}`;return h.jsxs(Sp,{children:[h.jsx(kp,{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(zr,{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(Ru,{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(roe,{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(VA,{relPath:c,loadMarkdown:s,showTitleBar:!1})},`md-body:${c}`)})]})]})}function Jse({state:e,extras:t}){const{api:n,session:r}=t,i=pi(),[s,o]=g.useState(Use()),a=g.useRef(s);a.current=s;const l=g.useRef(!1),c=g.useCallback(async C=>{const k=a.current.quickAsk,N=await Bse(n,r,C);if(N){if(l.current){n.sessionDelete(N.sessionId).catch(()=>{});return}Fd(k)&&n.sessionDelete(k.sessionId).catch(()=>{}),o(T=>Wse(T,{sessionId:N.sessionId}))}},[n,r]),u=g.useCallback(async C=>{const k=a.current.quickAsk,N=(k==null?void 0:k.sessionId)===C;try{await zse(n,{sessionId:C,stillEphemeral:N&&Fd(k)})&&o(z=>Kse(z))}catch(T){Me("quick-ask","promote failed",T)}},[n]),d=g.useCallback(C=>{o(k=>Vse(k,C))},[]),f=g.useCallback(C=>{o(k=>Yse(k,C))},[]),p=g.useCallback(()=>{const C=a.current.quickAsk;Fd(C)&&n.sessionDelete(C.sessionId).catch(()=>{}),o(k=>qse(k))},[n]),m=g.useCallback(C=>{o(k=>Gse(k,C))},[]);g.useEffect(()=>()=>{l.current=!0;const C=a.current.quickAsk;Fd(C)&&n.sessionDelete(C.sessionId).catch(()=>{})},[]);const v=ci("sessions")??[],b=s.quickAsk?v.find(C=>C.sessionId===s.quickAsk.sessionId)??{sessionId:s.quickAsk.sessionId,cwd:r.cwd,tool:r.tool}:null,x=g.useCallback(async C=>{const k=await b1(n,i,r.sessionId,C,60),N=await fetch(k);if(!N.ok)throw new Error(`fetch ${N.status} ${N.statusText}`);return N.text()},[n,i,r.sessionId]),_=h.jsx(w1,{state:e,extras:t,onQuickAskInternal:c,onPreviewMdInternal:d}),{initialSize:y,setSize:S}=Hse("chat-panel-right-slot-width",480);return h.jsxs(Ay,{orientation:"horizontal",className:"flex-1 flex min-w-0 min-h-0",children:[h.jsx(uf,{id:"chat",minSize:"400px",children:_}),qA(s)?h.jsxs(h.Fragment,{children:[h.jsx(FR,{className:"w-1 bg-text-100/10 hover:bg-text-100/25 transition-colors cursor-col-resize"}),h.jsx(uf,{id:"right-slot",defaultSize:`${y}px`,minSize:"360px",maxSize:"800px",onResize:C=>S(C.inPixels),children:h.jsx(Qse,{state:s,api:n,onSwitchTab:f,onCloseQuickAsk:p,onCloseMd:m,loadMarkdown:x,quickAskSession:b,onPromoteQuickAsk:u})})]}):null]})}const eoe={closeTrailing:!1},toe={closeTrailing:!0};function noe(e){return e?eoe:toe}function roe({session:e,api:t,onPromoteQuickAsk:n}){const r=aA(e.sessionId);return h.jsx(w1,{state:r,extras:{session:e,api:t,...n?{onPromoteQuickAsk:n}:{}}})}function ioe({extras:e}){const t=aA(e.session.sessionId);if(e.session.appBuilderProject){const n=h.jsx(w1,{state:t,extras:e});return h.jsx(soe,{state:t,chat:n,extras:e})}return h.jsx(Jse,{state:t,extras:e})}function soe({state:e,chat:t,extras:n}){var T;const r=ci("daemon-info"),i=pi(),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",I=>{const M=I;M!=null&&M.project&&(M.project.name===a&&c(M.project),f(L=>{const R=L.findIndex(D=>D.name===M.project.name);if(R<0)return[...L,M.project];const A=L.slice();return A[R]=M.project,A}))}),[i,a]);const{host:m,scheme:v}=jse(i.url,r==null?void 0:r.tunnelUrl),[b,x]=g.useState(void 0),[_,y]=g.useState(null);g.useEffect(()=>{const z=i.on("appBuilder:publish-progress",M=>{const L=M;!L||L.name!==a||L.status==="started"&&x(L.stage)}),I=i.on("appBuilder:publish-failed",M=>{const L=M;!L||L.name!==a||(x(void 0),y({stage:L.stage}))});return()=>{z(),I()}},[i,a]),g.useEffect(()=>{x(void 0),y(null)},[a]);const[S,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:((T=l==null?void 0:l.publishJob)==null?void 0:T.status)==="in-flight",onClick:async()=>{try{await s.appBuilderPublish(a)}catch(z){C({title:"发布请求失败",message:(z==null?void 0:z.message)??String(z)})}},children:"发布上线"}),N=(l==null?void 0:l.stage)??(l!=null&&l.isRunning?"running":"stopped");return h.jsxs(h.Fragment,{children:[h.jsx(wse,{left:t,stage:N,onExpand:async()=>{await s.appBuilderStartDevServer(o.sessionId)},onCollapse:async()=>{await s.appBuilderStopDevServer(o.sessionId)},right:h.jsx(Rse,{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:_,onPublishFailureBannerClose:()=>y(null),onPublishFailureBannerFocusChat:()=>{}})}),h.jsx(Ase,{error:S,onClose:()=>C(null)})]})}function ooe({headerMeta:e,connState:t,liveWorktreeRoot:n,onOpenConfig:r,variant:i="full",ephemeral:s,onPromote:o,hideHeader:a=!1,lines:l,pendingPermissions:c,procAlive:u,rewindableUserMessageIds:d,onPermissionRespond:f,onPermissionInterrupt:p,onRewind:m,onFork:v,onQuickAsk:b,topSlot:x,realtimeQuestionAnswers:_,onSubmitQuestion:y,onCancelQuestion:S,liveQuestionToolUseIds:C,api:k,cwd:N,tool:T,sessionKey:z,onSend:I,awaitingUser:M,onAbort:L,onNewSession:R,onClearSession:A,configSlot:D,chatRootRef:$,chatBodyRef:F,drawers:O,xtermSlot:B,fileSharingScope:E,onShareFile:H,onOpenInTab:q,onPreviewMarkdown:j,onOpenFilePath:ne,resolvePersona:re}){return h.jsx(hJ,{children:h.jsxs("div",{ref:$,"data-cc-chat-root":"",className:"flex flex-col h-full bg-bg-100",children:[a?null:h.jsx(lee,{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:F,"data-testid":"chat-body",className:"flex-1 overflow-y-auto min-h-0",style:{overflowAnchor:"none"},children:h.jsx(cM,{lines:l,...f?{onPermissionRespond:f}:{},...p&&u?{onPermissionInterrupt:p}:{},topSlot:x,...m?{onRewind:m}:{},rewindableUserMessageIds:d,...v?{onFork:v}:{},...b?{onQuickAsk:b}:{},realtimeQuestionAnswers:_,onSubmitQuestion:y,...S?{onCancelQuestion:S}:{},liveQuestionToolUseIds:C,...E?{fileSharingScope:E}:{},...H?{onShareFile:H}:{},...q?{onOpenInTab:q}:{},...j?{onPreviewMarkdown:j}:{},...ne?{onOpenFilePath:ne}:{},...re?{resolvePersona:re}:{},...i==="full"?{turnCollapse:noe(u)}:{}})}),B,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(oee,{meta:e,...k?{api:k}:{},cwd:N,...T?{tool:T}:{},sessionKey:z,onSend:I,awaitingUser:M,...L?{onAbort:L}:{},...R?{onNewSession:R}:{},...A?{onClearSession:A}:{},...D?{configSlot:D}:{}}),O]})})}function w1({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,hideHeader:b}=t,{capabilities:x}=u1(i.tool||"claude"),_=(x==null?void 0:x.features)??WT(i.tool),[y,S]=g.useState(null),[C,k]=g.useState(null),N=ap(),T=!!s&&N.actionsLevel==="owner"&&_.fileSharing,z=GT(i.ownerPersonaId??null).persona,I=(z==null?void 0:z.label)??null,M=!!I&&!!i.ownerPersonaId,{raw:L}=K_(),R=g.useCallback(Z=>{const fe=L.find(be=>be.personaId===Z);return fe?{label:fe.label,...fe.tool?{tool:fe.tool}:{}}:void 0},[L]),A=g.useCallback((Z,fe)=>{S({kind:Z,text:fe}),setTimeout(()=>{S(be=>(be==null?void 0:be.text)===fe?null:be)},2e3)},[]),D=pi(),$=ZB(),F=oA(i.sessionId,i.toolSessionId),{events:O,pendingQuestions:B,clearQuestion:E,markQuestionSubmitted:H,status:q}=F,j=e.historyLoading,ne=mM(q);g.useEffect(()=>{Me("chat-panel","sessionStatus",{sessionId:i.sessionId,sessionStatus:q,procAlive:ne})},[q,ne,i.sessionId]);const re=e.lines,G=e.pendingPermissions,ve=G[0]??null,ze=g.useMemo(()=>ZW(O),[O]),[he,Ie]=g.useState(null),[Re,Ve]=g.useState(()=>new Set);GW(s,i.sessionId,i.toolSessionId,_.observe);const xe=g.useRef(i.sessionId);g.useEffect(()=>{if(xe.current=i.sessionId,!_.rewind){Ie(null);return}let Z=!1;return Ie(null),(async()=>{try{const fe=await s.sessionRewindableMessageIds(i.sessionId);if(Z)return;Ie(new Set(fe.userMessageIds))}catch{Z||Ie(null)}})(),()=>{Z=!0}},[s,i.sessionId,_.rewind]);const Ke=g.useCallback(()=>{const Z=i.sessionId;s.sessionRewindableMessageIds(Z).then(fe=>{xe.current===Z&&Ie(new Set(fe.userMessageIds))}).catch(()=>{})},[s,i.sessionId]),Cn=g.useMemo(()=>{if(he!==null){const Ze=new Set(he);for(const Cr of Re)Ze.delete(Cr);return Ze}const Z=new Set(["Edit","Write","MultiEdit","NotebookEdit"]),fe=new Set;let be=null;for(const Ze of re)Ze.kind==="user-text"?be=Ze.uuid??null:be&&Ze.kind==="tool-call"&&Z.has(Ze.tool)&&!Re.has(be)&&fe.add(be);return fe},[re,Re,he]),it=g.useRef(c);it.current=c,YW(i.sessionId,i.toolSessionId,()=>{Xe(null),Ve(new Set)});const ct=Tee({sessionStatus:q}),on=g.useRef(null);g.useEffect(()=>{var be;const Z=on.current,fe=(Z==null?void 0:Z.sid)===i.sessionId;fe&&Z.phase===ct||(on.current={sid:i.sessionId,phase:ct},Me("session-phase",ct,{sid:i.sessionId,phase:ct,prev:fe?Z.phase:null,desc:Nee[ct]}),fe&&Z.phase==="turn-running"&&ct!=="turn-running"&&((be=it.current)==null||be.call(it),Ke()))},[ct,i.sessionId,Ke]);const gt=g.useCallback(()=>{s.sessionInterrupt(i.sessionId).catch(()=>{})},[s,i.sessionId]),[vt,Xe]=g.useState(null),st=g.useCallback(Z=>{Xe(Z)},[]),[At,Xt]=g.useState(!1),pn=g.useCallback(()=>{s.sessionStop(i.sessionId).catch(()=>{}),Xt(!1)},[s,i.sessionId]);g.useCallback(Z=>{s.pinSession(i.sessionId,Z).catch(fe=>{Me("chat-panel","pinSession failed",{err:fe==null?void 0:fe.message})})},[s,i.sessionId]);const U=m?"quickask":"full",{container:J,onCollapse:ye}=fee(),ke=g.useRef(0),Ue=g.useRef(null);g.useEffect(()=>{const Z=fe=>{if(fe.key!=="Escape")return;if(!ne){ke.current=0;return}if(fe.isComposing)return;const Ze=fe.target;if(Ze&&Ze.closest("[data-cc-chat-root]")!==Ue.current)return;const Cr=Date.now();Cr-ke.current<2e3?(ke.current=0,Xt(!0)):(ke.current=Cr,gt())};return window.addEventListener("keydown",Z),()=>window.removeEventListener("keydown",Z)},[gt,ne]);const kt=g.useRef(null),an=g.useRef(!0),Ft=g.useRef(void 0),le=g.useRef(0),K=g.useRef(0),we=g.useRef(void 0);g.useEffect(()=>{k(null)},[i.sessionId]),g.useEffect(()=>{const Z=kt.current;if(!Z)return;const fe=150,be=Ze=>{Date.now()<K.current&&(Ze.preventDefault(),K.current=Date.now()+fe)};return Z.addEventListener("wheel",be,{passive:!1}),()=>Z.removeEventListener("wheel",be)},[]),g.useEffect(()=>{const Z=kt.current;if(!Z)return;const fe=32,be=()=>{const Ze=Z.scrollHeight-Z.scrollTop-Z.clientHeight;an.current=Ze<=fe};return Z.addEventListener("scroll",be,{passive:!0}),()=>Z.removeEventListener("scroll",be)},[]),g.useLayoutEffect(()=>{var Vo;const Z=kt.current;if(!Z)return;const fe=we.current!==i.sessionId;fe&&(we.current=i.sessionId,an.current=!0,Ft.current=void 0,le.current=0,K.current=0);const be=Ft.current,Ze=(Vo=re[0])==null?void 0:Vo.seq;Ft.current=Ze,!fe&&be!==void 0&&Ze!==void 0&&Ze<be?(Z.scrollTop=Z.scrollHeight-le.current,K.current=Date.now()+200):an.current&&(Z.scrollTop=Z.scrollHeight),le.current=Z.scrollHeight-Z.scrollTop},[re,ve==null?void 0:ve.requestId,i.sessionId]);const ft=g.useMemo(()=>{const Z={};for(const[fe,be]of Object.entries(B))be.submittedAnswers&&(Z[fe]=be.submittedAnswers);return Z},[B]),ln=g.useMemo(()=>new Set(Object.keys(B)),[B]),Sl=g.useCallback(async(Z,fe)=>{try{await s.answerQuestion({sessionId:i.sessionId,toolUseId:Z,answers:fe}),H(Z,fe)}catch{}},[s,i.sessionId,H]),kl=g.useCallback(async Z=>{try{await s.cancelQuestion({sessionId:i.sessionId,toolUseId:Z}),E(Z)}catch{}},[s,i.sessionId,E]),Cl=g.useCallback(async(Z,fe)=>{var be;if(ve)try{await((be=e.respondPermission)==null?void 0:be.call(e,ve.requestId,Z?"allow":"deny"))}catch{}},[e,ve]),Vp=g.useCallback(async()=>{const Z=i.sessionId;try{await s.sessionStop(Z)}catch{}e.clearSession?await e.clearSession():await s.sessionNew(Z)},[e,s,i.sessionId]),qp=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,");切走再切回可重试"]}):j&&re.length===0?h.jsx("div",{className:"flex justify-center py-4","data-testid":"history-loading",children:h.jsx(Mn,{className:"w-4 h-4 text-text-400 animate-spin"})}):null,[j,re.length,e.historyError]),Fu=e.meta,Hu=h.jsxs(h.Fragment,{children:[i.toolSessionId&&_.subagents?h.jsx(yee,{api:s,cwd:i.cwd,toolSessionId:i.toolSessionId,toolKind:i.tool??"claude"}):null,vt&&_.rewind?h.jsx(wee,{open:!0,onOpenChange:Z=>{Z||Xe(null)},api:s,sessionId:i.sessionId,userMessageId:vt,lines:re,procAlive:ne,onNoChanges:Z=>{Ve(fe=>{if(fe.has(Z))return fe;const be=new Set(fe);return be.add(Z),be})}}):null,At?h.jsx(aoe,{onConfirm:pn,onCancel:()=>Xt(!1)}):null]}),Ws={kind:"session",sessionId:i.sessionId},Vs=g.useCallback(async Z=>{if(s)try{await ZC(s,D,i.sessionId,Z)}catch(fe){const be=fe.message;Me("chat-panel","open-in-tab failed",{err:be}),A("err",`Open in tab 失败:${be}`)}},[s,D,i.sessionId,A]),[El,Ho]=g.useState(!1),[Fr,Xi]=g.useState(null),qs=g.useCallback(Z=>{if(r){r(Z);return}Xi(Z),Ho(!0)},[r]),Kp=g.useCallback(Z=>{if(!s)return;const fe=async()=>{try{await s.attachmentGroupAdd(i.sessionId,Z)}catch(Ze){Me("chat-panel","file-link groupAdd skipped",{err:Ze.message})}},be=Ze=>{const Cr=Ze.message;Me("chat-panel","file-link open failed",{err:Cr}),A("err",`打开文件失败:${Cr}`)};if(Mp(Z)){fe().then(()=>qs(Z),be);return}ZC(s,D,i.sessionId,Z,60,fe).catch(be)},[s,D,i.sessionId,qs,A]),Ht=g.useCallback(async Z=>{if(!s)throw new Error("daemon api not ready");const fe=await b1(s,D,i.sessionId,Z,60),be=await fetch(fe);if(!be.ok)throw new Error(`fetch ${be.status} ${be.statusText}`);return await be.text()},[s,D,i.sessionId]),Uo=g.useCallback(async(Z,fe)=>{if(s)try{const{url:be}=await s.attachmentSignUrl({sessionId:i.sessionId,relPath:Z,ttlSeconds:86400,...fe?{view:fe}:{}}),Ze=await xse(be);A(Ze?"ok":"err",Ze?"分享链接已复制到剪贴板(24h 有效)":"复制失败:请手动复制")}catch(be){const Ze=be.message;Me("chat-panel","share-file failed",{err:Ze}),A("err",`生成分享链接失败:${Ze}`)}},[s,i.sessionId,A]),Wo=g.useCallback(()=>k(null),[]),Pt=C==="files"&&T&&s?{title:"Edited Files",onBack:Wo,content:h.jsx(Zre,{api:s,scope:Ws,sessionId:i.sessionId,onShareFile:Uo,onOpenInTab:Vs,onPreviewMarkdown:qs})}:C==="cron"?{title:`定时任务${ze.length?` (${ze.length})`:""}`,onBack:Wo,content:h.jsx("div",{className:"p-3",children:h.jsx(Eee,{jobs:ze})})}:C==="persona"&&M&&s&&i.ownerPersonaId?{title:`Persona · ${I??""}`,onBack:Wo,content:h.jsx(mse,{personaId:i.ownerPersonaId,open:!0,onClose:Wo,api:s,embedded:!0,...p?{viewerRole:p}:{}},i.ownerPersonaId)}:null,jt=U==="full"?h.jsx(dee,{session:i,meta:Fu,...o!==void 0?{liveGitBranch:o}:{},...a!==void 0?{liveWorktreeRoot:a}:{},...M?{personaName:I}:{},...M?{onOpenPersona:()=>k("persona")}:{},...T?{onOpenFiles:()=>k("files")}:{},cronActiveCount:ze.length,onCronClick:()=>k("cron"),onForceStop:()=>Xt(!0),...p?{viewerRole:p}:{},...x!=null&&x.toolSessionIdLabel?{toolSessionIdLabel:x.toolSessionIdLabel}:{},drill:Pt,...ye?{onCollapse:ye}:{}}):null;return h.jsxs(h.Fragment,{children:[J&&jt?ol.createPortal(jt,J):null,h.jsx(ooe,{headerMeta:Fu,connState:e.connState,...a!==void 0?{liveWorktreeRoot:a}:{},...u?{onOpenConfig:u}:{},variant:U,...b?{hideHeader:b}:{},...U==="quickask"?{ephemeral:i.ephemeral!==!1,onPromote:()=>void(m==null?void 0:m(i.sessionId))}:{},lines:re,pendingPermissions:G,procAlive:ne,rewindableUserMessageIds:Cn,onPermissionRespond:Cl,onPermissionInterrupt:gt,onRewind:_.rewind?st:void 0,...d&&_.fork?{onFork:d}:{},...n&&_.fork?{onQuickAsk:n}:f&&_.fork?{onQuickAsk:f}:{},topSlot:qp,realtimeQuestionAnswers:ft,onSubmitQuestion:Sl,onCancelQuestion:kl,liveQuestionToolUseIds:ln,api:s,cwd:i.cwd,...i.tool?{tool:i.tool}:{},sessionKey:i.sessionId,onSend:e.sendText,awaitingUser:G.length>0||Object.values(B).some(Z=>!Z.submittedAnswers),onAbort:gt,...l?{onNewSession:l}:{},onClearSession:Vp,...v?{configSlot:v}:{},chatRootRef:Ue,chatBodyRef:kt,drawers:Hu,xtermSlot:$==="tui"&&ne&&_.tui?h.jsx(Hre,{sessionId:i.sessionId,client:D},i.sessionId):null,fileSharingScope:Ws,...s?{onShareFile:Uo}:{},...s?{onOpenInTab:Vs}:{},...s?{onPreviewMarkdown:qs}:{},...s?{onOpenFilePath:Kp}:{},resolvePersona:R}),s?h.jsx(bse,{open:El,onOpenChange:Ho,relPath:Fr,loadMarkdown:Ht,onShare:Fr?()=>void Uo(Fr,"md-rendered"):void 0}):null,y?h.jsx("div",{"data-testid":"share-toast",role:"status","aria-live":"polite",className:y.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:y.text}):null]})}function aoe({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(Qc,{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 loe(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 coe(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 uoe(e,t){var m,v,b,x;const{models:n,modes:r,configSchema:i}=t,s=e.resolvedModel??e.model,o=loe(s,n,i),a=o.options,l=a.some(_=>_.value===e.effort)?e.effort:o.defaultValue,c=e.effort===""&&e.resolvedEffort?((m=a.find(_=>_.value===e.resolvedEffort))==null?void 0:m.label)??e.resolvedEffort:((v=a.find(_=>_.value===l))==null?void 0:v.label)??null,u=((b=i.find(_=>_.name==="permissionMode"))==null?void 0:b.default)??"",d=r.some(_=>_.id===e.permissionMode)?e.permissionMode:u,p=d===u?null:((x=r.find(_=>_.id===d))==null?void 0:x.label)??null;return{modelLabel:coe(n,s),effortOptions:a,effortValue:l,effortLabel:c,modeValue:d,modeLabel:p,modeTone:p===null?null:d==="bypassPermissions"?"danger":"info"}}function doe({models:e=[],modes:t=[],configSchema:n=[],model:r,resolvedModel:i,resolvedEffort:s,effort:o,permissionMode:a,onPatch:l}){var p;const c=uoe({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(wy,{children:[h.jsx(Sy,{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:oe("font-semibold",c.modeTone==="danger"?"text-red-400":"text-blue-400"),children:c.modeLabel})]}):null]})}),h.jsxs(_p,{side:"top",align:"end",className:"w-[230px]","data-testid":"session-config-menu",children:[h.jsx(Ag,{testid:"session-config-model",label:"Model",current:r,currentLabel:c.modelLabel,options:d,onSelect:m=>l({model:m})}),h.jsx(Ag,{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(Ag,{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 Ag({testid:e,label:t,current:n,currentLabel:r,currentTone:i,options:s,onSelect:o}){const a=s.length===0;return h.jsxs(bU,{children:[h.jsxs(uR,{"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:oe("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(Ln,{className:"w-3.5 h-3.5 shrink-0 text-text-500"})]}),h.jsx(dR,{className:"w-[220px] max-h-[320px] overflow-y-auto",children:s.map(l=>{const c=l.value===n;return h.jsxs(Ci,{"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:oe("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(ml,{className:"w-3.5 h-3.5 shrink-0 text-accent mt-0.5"}):null]},l.value||"default")})})]})}function hoe(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 foe(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 poe({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",hideHeader:f}){const{capabilities:p}=u1(t.tool),[m,v]=g.useState(0),{branch:b}=hoe(e,t.cwd,m),{worktreeRoot:x}=foe(e,t.cwd,m),_=r>1,y=S=>{e.sessionUpdate(t.sessionId,S).catch(C=>{console.error("[session-config] session:update failed",t.sessionId,C)})};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(Ay,{orientation:"horizontal",className:"flex-1 flex min-w-0 min-h-0",children:h.jsx(uf,{id:"chat",minSize:"400px",children:h.jsx("div",{className:"flex flex-col min-w-0 min-h-0 h-full",children:h.jsx(moe,{api:e,session:t,liveGitBranch:b,liveWorktreeRoot:x,onNewSession:o,onTurnEnd:()=>v(S=>S+1),onOpenConfig:a,onFork:l,onQuickAsk:c,viewerRole:d,hideHeader:f,configSlot:p?h.jsx(doe,{models:p.models,modes:p.permissionModes,configSchema:p.configSchema,model:t.model??"",...t.resolvedModel?{resolvedModel:t.resolvedModel}:{},...t.resolvedEffort?{resolvedEffort:t.resolvedEffort}:{},effort:t.effort??"",permissionMode:t.permissionMode??"",onPatch:y}):null})})})}),_&&h.jsx("button",{type:"button",onClick:S=>{S.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(zr,{className:"w-3.5 h-3.5"})})]})}function moe({api:e,session:t,liveGitBranch:n,liveWorktreeRoot:r,onNewSession:i,onTurnEnd:s,onOpenConfig:o,onFork:a,onQuickAsk:l,viewerRole:c,configSlot:u,hideHeader:d}){return h.jsx(ioe,{extras:{session:t,api:e,...n!==void 0?{liveGitBranch:n}:{},...r!==void 0?{liveWorktreeRoot:r}:{},onNewSession:i,onTurnEnd:s,onOpenConfig:o,...a?{onFork:f=>{a(f)}}:{},...l?{onQuickAsk:f=>{l(f)}}:{},...c?{viewerRole:c}:{},...u?{configSlot:u}:{},...d?{hideHeader:d}:{}}})}function goe({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(hW,{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(poe,{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 voe(){const e=pi(),t=g.useMemo(()=>new q_(e),[e]),n=_z(e),{sessions:r,refresh:i}=yz(n),{personas:s}=K_(),o=Ez(),a=g.useMemo(()=>{const S=window.location.pathname.match(/^\/s\/([^/]+)/);return S?decodeURIComponent(S[1]):null},[]),l=g.useMemo(()=>r.filter(S=>!S.ephemeral&&S.larkChatId==null),[r]),c=g.useMemo(()=>a?s.filter(S=>S.personaId===a):s,[s,a]),[u,d]=g.useState(null),[f,p]=g.useState(null),[m,v]=g.useState(null);g.useEffect(()=>{let S=!1;return e.request("whoami",{}).then(C=>{S||d(C.capability.id)}).catch(()=>{}),()=>{S=!0}},[e]),g.useEffect(()=>{a&&p(a)},[a]);const b=g.useCallback(async(S,C)=>{const k=await t.sessionCreate({ownerPersonaId:S,...C.trim()?{label:C.trim()}:{}});await i(),p(S),v(k.sessionId)},[t,i]),x=g.useCallback(async S=>{await t.sessionDelete(S),await i(),v(C=>C===S?null:C)},[t,i]),_=g.useCallback(async(S,C)=>{await t.sessionUpdate(S,{label:C.label}),await i()},[t,i]),y=g.useMemo(()=>l.find(S=>S.sessionId===m)??null,[l,m]);return h.jsx(G_.Provider,{value:o,children:h.jsx(goe,{personas:c,sessions:l,api:t,selfPrincipalId:u,selectedPersonaId:f,selectedSessionId:m,selectedSession:y,onSelectPersona:p,onSelectSession:v,onCreateSession:(S,C)=>void b(S,C),onDeleteSession:S=>void x(S),onEditSession:(S,C)=>void _(S,C),onCloseSession:()=>v(null)})})}const t2="https://app.ttcadvisory.com";function xoe({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=`${t2}/auth/authorize?callback_url=${encodeURIComponent(a)}&auto=1`,c=async d=>{if(d.origin!==t2)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 Ax="clawd-visitor:token";function _oe(e,t){const r=`${e.protocol==="https:"?"wss:":"ws:"}//${e.host}`;return t!=null&&t.devPath?`${r}${t.devPath}`:r}function yoe(){return{async getUrl(e){const t=localStorage.getItem(Ax);if(!t)throw new Error("NO_VISITOR_TOKEN");const n=_oe(window.location,{});return await zT(e).upsert({id:"guest",name:"访客",mode:"remote",url:n,token:t}),{url:n}}}}function boe(e){const t=n=>{document.documentElement.classList.toggle("dark",n==="dark")};return t(e.theme.mode),e.onThemeChange(n=>t(n.mode))}function woe(){const e=pi(),t=g.useMemo(()=>xz(e),[e]);return h.jsx(JB,{cache:t.cache,children:h.jsx(nz,{children:h.jsx(voe,{})})})}function Soe({host:e}){const[t]=g.useState(()=>localStorage.getItem(Ax)),[n,r]=g.useState(!1),[i,s]=g.useState(null);return g.useEffect(()=>boe(e),[e]),g.useEffect(()=>{if(!t)return;let o=!1;return yoe().getUrl(e).then(()=>{o||r(!0)}).catch(a=>{o||s(a instanceof Error?a.message:String(a))}),()=>{o=!0}},[e,t]),t?h.jsx(Bb,{host:e,children:h.jsx(vw,{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(XB,{host:e,children:h.jsx(woe,{})}):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(Bb,{host:e,children:h.jsx(vw,{children:h.jsx(xoe,{onAuthed:o=>{localStorage.setItem(Ax,o),window.location.reload()}})})})}function koe({filePath:e,oldString:t,newString:n,content:r}){const i=g.useMemo(()=>r!=null?r.split(/\r?\n/).map(s=>({type:"add",text:s})):Coe(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:oe("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 Coe(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 Eoe({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(Noe,{status:t.status}),h.jsx("span",{className:oe("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 Noe({status:e}){return e==="completed"?h.jsx(yu,{className:"w-3.5 h-3.5 text-success mt-0.5 shrink-0"}):e==="in_progress"?h.jsx(Mn,{className:"w-3.5 h-3.5 text-warning mt-0.5 shrink-0 animate-spin"}):h.jsx(ZT,{className:"w-3.5 h-3.5 text-text-400 mt-0.5 shrink-0"})}function Toe(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 Ioe({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(lp,{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 Poe(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 Roe={render:({input:e})=>Qe.createElement(Eoe,{items:Toe(e)})},Moe={render:({input:e})=>{const{description:t,prompt:n,subagentType:r}=Poe(e);return Qe.createElement(Ioe,{description:t,prompt:n,subagentType:r})}},KA={render:({input:e,output:t,error:n,pending:r,fileScope:i,onShareFile:s,onOpenInTab:o,onPreviewMarkdown:a})=>{const l=joe(e),c=l?Qe.createElement(koe,{filePath:l.filePath,oldString:l.oldString,newString:l.newString,content:l.content}):void 0;return Qe.createElement(nM,{tool:Aoe(e),input:e,output:t,error:n,pending:r,expandedBody:c,...i?{fileScope:i}:{},...s?{onShareFile:s}:{},...o?{onOpenInTab:o}:{},...a?{onPreviewMarkdown:a}:{}})}};function Aoe(e){const t=e??{};return"content"in t&&t.content!==void 0?"Write":("old_string"in t&&t.old_string!==void 0,"Edit")}function joe(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}}yl.register("claude","TodoWrite",Roe);yl.register("claude","Task",Moe);yl.register("claude","Edit",KA);yl.register("claude","Write",KA);const GA=document.getElementById("root");if(!GA)throw new Error("guest-main: #root not found");const Loe=Tj({});jg.createRoot(GA).render(h.jsx(Qe.StrictMode,{children:h.jsx(Soe,{host:Loe})}));
|