@clawos-dev/clawd 0.2.340 → 0.2.342
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.
|
@@ -55,7 +55,7 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
|
|
|
55
55
|
`);else if(x._keyframe)m(x);else{var y=d.reduce(function(w,k){var C;return(k==null||(C=k.visit)===null||C===void 0?void 0:C.call(k,w))||w},x);Object.keys(y).forEach(function(w){var k=y[w];if(Nt(k)==="object"&&k&&(w!=="animationName"||!k._keyframe)&&!Dj(k)){var C=!1,N=w.trim(),T=!1;(i||s)&&a?N.startsWith("@")?C=!0:N==="&"?N=Fb("",a,c):N=Fb(w,a,c):i&&!a&&(N==="&"||N==="")&&(N="",T=!0);var B=e(k,n,{root:T,injectHash:C,parentSelectors:[].concat(Po(o),[N])}),P=Je(B,2),j=P[0],I=P[1];p=ze(ze({},p),I),f+="".concat(N).concat(j)}else{let z=function($,F){var D=$.replace(/[A-Z]/g,function(E){return"-".concat(E.toLowerCase())}),O=F;!pj[$]&&typeof O=="number"&&O!==0&&(O="".concat(O,"px")),$==="animationName"&&F!==null&&F!==void 0&&F._keyframe&&(m(F),O=F.getName(a)),f+="".concat(D,":").concat(O,";")};var R,L=(R=k==null?void 0:k.value)!==null&&R!==void 0?R:k;Nt(k)==="object"&&k!==null&&k!==void 0&&k[AN]&&Array.isArray(L)?L.forEach(function($){z(w,$)}):z(w,L)}})}}),i?l&&(f&&(f="@layer ".concat(l.name," {").concat(f,"}")),l.dependencies&&(p["@layer ".concat(l.name)]=l.dependencies.map(function(_){return"@layer ".concat(_,", ").concat(l.name,";")}).join(`
|
|
56
56
|
`))):f="{".concat(f,"}"),[f,p]};function Bj(e,t){return Oc("".concat(e.join("%")).concat(t))}function zj(){return null}var LN="style";function $j(e,t){var n=e.token,r=e.path,i=e.hashId,s=e.layer,o=e.nonce,a=e.clientOnly,l=e.order,c=l===void 0?0:l,u=g.useContext(Vf),d=u.autoClear;u.mock;var f=u.defaultCache,p=u.hashPriority,m=u.container,v=u.ssrInline,b=u.transformers,_=u.linters,x=u.cache,y=u.layer,w=n._tokenKey,k=[w];y&&k.push("layer"),k.push.apply(k,Po(r));var C=jb,N=kN(LN,k,function(){var I=k.join("|");if(Aj(I)){var R=Lj(I),L=Je(R,2),z=L[0],$=L[1];if(z)return[z,w,$,{},a,c]}var F=t(),D=Oj(F,{hashId:i,hashPriority:p,layer:y?s:void 0,path:r.join("-"),transformers:b,linters:_}),O=Je(D,2),E=O[0],H=O[1],V=Kd(E),A=Bj(k,V);return[V,w,A,H,a,c]},function(I,R){var L=Je(I,3),z=L[2];(R||d)&&jb&&OL(z,{mark:Ni,attachTo:m})},function(I){var R=Je(I,4),L=R[0];R[1];var z=R[2],$=R[3];if(C&&L!==RN){var F={mark:Ni,prepend:y?!1:"queue",attachTo:m,priority:c},D=typeof o=="function"?o():o;D&&(F.csp={nonce:D});var O=[],E=[];Object.keys($).forEach(function(V){V.startsWith("@layer")?O.push(V):E.push(V)}),O.forEach(function(V){dc(Kd($[V]),"_layer-".concat(V),ze(ze({},F),{},{prepend:!0}))});var H=dc(L,z,F);H[to]=x.instanceId,H.setAttribute(Bc,w),E.forEach(function(V){dc(Kd($[V]),"_effect-".concat(V),F)})}}),T=Je(N,3),B=T[0],P=T[1],j=T[2];return function(I){var R;return!v||C||!f?R=g.createElement(zj,null):R=g.createElement("style",Mh({},ke(ke({},Bc,P),Ni,j),{dangerouslySetInnerHTML:{__html:B}})),g.createElement(g.Fragment,null,R,I)}}var Fj=function(t,n,r){var i=Je(t,6),s=i[0],o=i[1],a=i[2],l=i[3],c=i[4],u=i[5],d=r||{},f=d.plain;if(c)return null;var p=s,m={"data-rc-order":"prependQueue","data-rc-priority":"".concat(u)};return p=Lh(s,o,a,m,f),l&&Object.keys(l).forEach(function(v){if(!n[v]){n[v]=!0;var b=Kd(l[v]),_=Lh(b,o,"_effect-".concat(v),m,f);v.startsWith("@layer")?p=_+p:p+=_}}),[u,a,p]},Hj="cssVar",Uj=function(t,n,r){var i=Je(t,4),s=i[1],o=i[2],a=i[3],l=r||{},c=l.plain;if(!s)return null;var u=-999,d={"data-rc-order":"prependQueue","data-rc-priority":"".concat(u)},f=Lh(s,a,o,d,c);return[u,o,f]};ke(ke(ke({},LN,Fj),CN,fj),Hj,Uj);function Ho(e){return e.notSplit=!0,e}Ho(["borderTop","borderBottom"]),Ho(["borderTop"]),Ho(["borderBottom"]),Ho(["borderLeft","borderRight"]),Ho(["borderLeft"]),Ho(["borderRight"]);var Wj=g.createContext({});function Vj(e){return _N(e)||pN(e)||yx(e)||xN()}function Rv(e,t){for(var n=e,r=0;r<t.length;r+=1){if(n==null)return;n=n[t[r]]}return n}function jN(e,t,n,r){if(!t.length)return n;var i=Vj(t),s=i[0],o=i.slice(1),a;return!e&&typeof s=="number"?a=[]:Array.isArray(e)?a=Po(e):a=ze({},e),r&&n===void 0&&o.length===1?delete a[s][o[0]]:a[s]=jN(a[s],o,n,r),a}function gm(e,t,n){var r=arguments.length>3&&arguments[3]!==void 0?arguments[3]:!1;return t.length&&r&&n===void 0&&!Rv(e,t.slice(0,-1))?e:jN(e,t,n,r)}function qj(e){return Nt(e)==="object"&&e!==null&&Object.getPrototypeOf(e)===Object.prototype}function Hb(e){return Array.isArray(e)?[]:{}}var Kj=typeof Reflect>"u"?Object.keys:Reflect.ownKeys;function Gj(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];var r=Hb(t[0]);return t.forEach(function(i){function s(o,a){var l=new Set(a),c=Rv(i,o),u=Array.isArray(c);if(u||qj(c)){if(!l.has(c)){l.add(c);var d=Rv(r,o);u?r=gm(r,o,[]):(!d||Nt(d)!=="object")&&(r=gm(r,o,Hb(c))),Kj(c).forEach(function(f){s([].concat(Po(o),[f]),l)})}}else r=gm(r,o,c)}s([])}),r}const Xj=g.createContext({}),Yj=g.createContext(void 0),Vn="${label} is not a valid ${type}",Gf={Modal:{okText:"OK",cancelText:"Cancel",justOkText:"OK"},Form:{optional:"(optional)",defaultValidateMessages:{default:"Field validation error for ${label}",required:"Please enter ${label}",enum:"${label} must be one of [${enum}]",whitespace:"${label} cannot be a blank character",date:{format:"${label} date format is invalid",parse:"${label} cannot be converted to a date",invalid:"${label} is an invalid date"},types:{string:Vn,method:Vn,array:Vn,object:Vn,number:Vn,date:Vn,boolean:Vn,integer:Vn,float:Vn,regexp:Vn,email:Vn,url:Vn,hex:Vn},string:{len:"${label} must be ${len} characters",min:"${label} must be at least ${min} characters",max:"${label} must be up to ${max} characters",range:"${label} must be between ${min}-${max} characters"},number:{len:"${label} must be equal to ${len}",min:"${label} must be minimum ${min}",max:"${label} must be maximum ${max}",range:"${label} must be between ${min}-${max}"},array:{len:"Must be ${len} ${label}",min:"At least ${min} ${label}",max:"At most ${max} ${label}",range:"The amount of ${label} must be between ${min}-${max}"},pattern:{mismatch:"${label} does not match the pattern ${pattern}"}}}};Object.assign({},Gf.Modal);let Gd=[];const Ub=()=>Gd.reduce((e,t)=>Object.assign(Object.assign({},e),t),Gf.Modal);function Zj(e){if(e){const t=Object.assign({},e);return Gd.push(t),Ub(),()=>{Gd=Gd.filter(n=>n!==t),Ub()}}Object.assign({},Gf.Modal)}const DN=g.createContext(void 0),Qj="internalMark",Jj=e=>{const{locale:t={},children:n,_ANT_MARK__:r}=e;g.useEffect(()=>Zj(t==null?void 0:t.Modal),[t]);const i=g.useMemo(()=>Object.assign(Object.assign({},t),{exist:!0}),[t]);return g.createElement(DN.Provider,{value:i},n)},Cx={blue:"#1677FF",purple:"#722ED1",cyan:"#13C2C2",green:"#52C41A",magenta:"#EB2F96",pink:"#EB2F96",red:"#F5222D",orange:"#FA8C16",yellow:"#FADB14",volcano:"#FA541C",geekblue:"#2F54EB",gold:"#FAAD14",lime:"#A0D911"},$c=Object.assign(Object.assign({},Cx),{colorPrimary:"#1677ff",colorSuccess:"#52c41a",colorWarning:"#faad14",colorError:"#ff4d4f",colorInfo:"#1677ff",colorLink:"",colorTextBase:"",colorBgBase:"",fontFamily:`-apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial,
|
|
57
57
|
'Noto Sans', sans-serif, 'Apple Color Emoji', 'Segoe UI Emoji', 'Segoe UI Symbol',
|
|
58
|
-
'Noto Color Emoji'`,fontFamilyCode:"'SFMono-Regular', Consolas, 'Liberation Mono', Menlo, Courier, monospace",fontSize:14,lineWidth:1,lineType:"solid",motionUnit:.1,motionBase:0,motionEaseOutCirc:"cubic-bezier(0.08, 0.82, 0.17, 1)",motionEaseInOutCirc:"cubic-bezier(0.78, 0.14, 0.15, 0.86)",motionEaseOut:"cubic-bezier(0.215, 0.61, 0.355, 1)",motionEaseInOut:"cubic-bezier(0.645, 0.045, 0.355, 1)",motionEaseOutBack:"cubic-bezier(0.12, 0.4, 0.29, 1.46)",motionEaseInBack:"cubic-bezier(0.71, -0.46, 0.88, 0.6)",motionEaseInQuint:"cubic-bezier(0.755, 0.05, 0.855, 0.06)",motionEaseOutQuint:"cubic-bezier(0.23, 1, 0.32, 1)",borderRadius:6,sizeUnit:4,sizeStep:4,sizePopupArrow:16,controlHeight:32,zIndexBase:0,zIndexPopupBase:1e3,opacityImage:1,wireframe:!1,motion:!0}),Yt=Math.round;function vm(e,t){const n=e.replace(/^[^(]*\((.*)/,"$1").replace(/\).*/,"").match(/\d*\.?\d+%?/g)||[],r=n.map(i=>parseFloat(i));for(let i=0;i<3;i+=1)r[i]=t(r[i]||0,n[i]||"",i);return n[3]?r[3]=n[3].includes("%")?r[3]/100:r[3]:r[3]=1,r}const Wb=(e,t,n)=>n===0?e:e/100;function Il(e,t){const n=t||255;return e>n?n:e<0?0:e}class xt{constructor(t){ke(this,"isValid",!0),ke(this,"r",0),ke(this,"g",0),ke(this,"b",0),ke(this,"a",1),ke(this,"_h",void 0),ke(this,"_s",void 0),ke(this,"_l",void 0),ke(this,"_v",void 0),ke(this,"_max",void 0),ke(this,"_min",void 0),ke(this,"_brightness",void 0);function n(i){return i[0]in t&&i[1]in t&&i[2]in t}if(t)if(typeof t=="string"){let s=function(o){return i.startsWith(o)};var r=s;const i=t.trim();/^#?[A-F\d]{3,8}$/i.test(i)?this.fromHexString(i):s("rgb")?this.fromRgbString(i):s("hsl")?this.fromHslString(i):(s("hsv")||s("hsb"))&&this.fromHsvString(i)}else if(t instanceof xt)this.r=t.r,this.g=t.g,this.b=t.b,this.a=t.a,this._h=t._h,this._s=t._s,this._l=t._l,this._v=t._v;else if(n("rgb"))this.r=Il(t.r),this.g=Il(t.g),this.b=Il(t.b),this.a=typeof t.a=="number"?Il(t.a,1):1;else if(n("hsl"))this.fromHsl(t);else if(n("hsv"))this.fromHsv(t);else throw new Error("@ant-design/fast-color: unsupported input "+JSON.stringify(t))}setR(t){return this._sc("r",t)}setG(t){return this._sc("g",t)}setB(t){return this._sc("b",t)}setA(t){return this._sc("a",t,1)}setHue(t){const n=this.toHsv();return n.h=t,this._c(n)}getLuminance(){function t(s){const o=s/255;return o<=.03928?o/12.92:Math.pow((o+.055)/1.055,2.4)}const n=t(this.r),r=t(this.g),i=t(this.b);return .2126*n+.7152*r+.0722*i}getHue(){if(typeof this._h>"u"){const t=this.getMax()-this.getMin();t===0?this._h=0:this._h=Yt(60*(this.r===this.getMax()?(this.g-this.b)/t+(this.g<this.b?6:0):this.g===this.getMax()?(this.b-this.r)/t+2:(this.r-this.g)/t+4))}return this._h}getSaturation(){if(typeof this._s>"u"){const t=this.getMax()-this.getMin();t===0?this._s=0:this._s=t/this.getMax()}return this._s}getLightness(){return typeof this._l>"u"&&(this._l=(this.getMax()+this.getMin())/510),this._l}getValue(){return typeof this._v>"u"&&(this._v=this.getMax()/255),this._v}getBrightness(){return typeof this._brightness>"u"&&(this._brightness=(this.r*299+this.g*587+this.b*114)/1e3),this._brightness}darken(t=10){const n=this.getHue(),r=this.getSaturation();let i=this.getLightness()-t/100;return i<0&&(i=0),this._c({h:n,s:r,l:i,a:this.a})}lighten(t=10){const n=this.getHue(),r=this.getSaturation();let i=this.getLightness()+t/100;return i>1&&(i=1),this._c({h:n,s:r,l:i,a:this.a})}mix(t,n=50){const r=this._c(t),i=n/100,s=a=>(r[a]-this[a])*i+this[a],o={r:Yt(s("r")),g:Yt(s("g")),b:Yt(s("b")),a:Yt(s("a")*100)/100};return this._c(o)}tint(t=10){return this.mix({r:255,g:255,b:255,a:1},t)}shade(t=10){return this.mix({r:0,g:0,b:0,a:1},t)}onBackground(t){const n=this._c(t),r=this.a+n.a*(1-this.a),i=s=>Yt((this[s]*this.a+n[s]*n.a*(1-this.a))/r);return this._c({r:i("r"),g:i("g"),b:i("b"),a:r})}isDark(){return this.getBrightness()<128}isLight(){return this.getBrightness()>=128}equals(t){return this.r===t.r&&this.g===t.g&&this.b===t.b&&this.a===t.a}clone(){return this._c(this)}toHexString(){let t="#";const n=(this.r||0).toString(16);t+=n.length===2?n:"0"+n;const r=(this.g||0).toString(16);t+=r.length===2?r:"0"+r;const i=(this.b||0).toString(16);if(t+=i.length===2?i:"0"+i,typeof this.a=="number"&&this.a>=0&&this.a<1){const s=Yt(this.a*255).toString(16);t+=s.length===2?s:"0"+s}return t}toHsl(){return{h:this.getHue(),s:this.getSaturation(),l:this.getLightness(),a:this.a}}toHslString(){const t=this.getHue(),n=Yt(this.getSaturation()*100),r=Yt(this.getLightness()*100);return this.a!==1?`hsla(${t},${n}%,${r}%,${this.a})`:`hsl(${t},${n}%,${r}%)`}toHsv(){return{h:this.getHue(),s:this.getSaturation(),v:this.getValue(),a:this.a}}toRgb(){return{r:this.r,g:this.g,b:this.b,a:this.a}}toRgbString(){return this.a!==1?`rgba(${this.r},${this.g},${this.b},${this.a})`:`rgb(${this.r},${this.g},${this.b})`}toString(){return this.toRgbString()}_sc(t,n,r){const i=this.clone();return i[t]=Il(n,r),i}_c(t){return new this.constructor(t)}getMax(){return typeof this._max>"u"&&(this._max=Math.max(this.r,this.g,this.b)),this._max}getMin(){return typeof this._min>"u"&&(this._min=Math.min(this.r,this.g,this.b)),this._min}fromHexString(t){const n=t.replace("#","");function r(i,s){return parseInt(n[i]+n[s||i],16)}n.length<6?(this.r=r(0),this.g=r(1),this.b=r(2),this.a=n[3]?r(3)/255:1):(this.r=r(0,1),this.g=r(2,3),this.b=r(4,5),this.a=n[6]?r(6,7)/255:1)}fromHsl({h:t,s:n,l:r,a:i}){if(this._h=t%360,this._s=n,this._l=r,this.a=typeof i=="number"?i:1,n<=0){const f=Yt(r*255);this.r=f,this.g=f,this.b=f}let s=0,o=0,a=0;const l=t/60,c=(1-Math.abs(2*r-1))*n,u=c*(1-Math.abs(l%2-1));l>=0&&l<1?(s=c,o=u):l>=1&&l<2?(s=u,o=c):l>=2&&l<3?(o=c,a=u):l>=3&&l<4?(o=u,a=c):l>=4&&l<5?(s=u,a=c):l>=5&&l<6&&(s=c,a=u);const d=r-c/2;this.r=Yt((s+d)*255),this.g=Yt((o+d)*255),this.b=Yt((a+d)*255)}fromHsv({h:t,s:n,v:r,a:i}){this._h=t%360,this._s=n,this._v=r,this.a=typeof i=="number"?i:1;const s=Yt(r*255);if(this.r=s,this.g=s,this.b=s,n<=0)return;const o=t/60,a=Math.floor(o),l=o-a,c=Yt(r*(1-n)*255),u=Yt(r*(1-n*l)*255),d=Yt(r*(1-n*(1-l))*255);switch(a){case 0:this.g=d,this.b=c;break;case 1:this.r=u,this.b=c;break;case 2:this.r=c,this.b=d;break;case 3:this.r=c,this.g=u;break;case 4:this.r=d,this.g=c;break;case 5:default:this.g=c,this.b=u;break}}fromHsvString(t){const n=vm(t,Wb);this.fromHsv({h:n[0],s:n[1],v:n[2],a:n[3]})}fromHslString(t){const n=vm(t,Wb);this.fromHsl({h:n[0],s:n[1],l:n[2],a:n[3]})}fromRgbString(t){const n=vm(t,(r,i)=>i.includes("%")?Yt(r/100*255):r);this.r=n[0],this.g=n[1],this.b=n[2],this.a=n[3]}}var Ju=2,Vb=.16,eD=.05,tD=.05,nD=.15,ON=5,BN=4,rD=[{index:7,amount:15},{index:6,amount:25},{index:5,amount:30},{index:5,amount:45},{index:5,amount:65},{index:5,amount:85},{index:4,amount:90},{index:3,amount:95},{index:2,amount:97},{index:1,amount:98}];function qb(e,t,n){var r;return Math.round(e.h)>=60&&Math.round(e.h)<=240?r=n?Math.round(e.h)-Ju*t:Math.round(e.h)+Ju*t:r=n?Math.round(e.h)+Ju*t:Math.round(e.h)-Ju*t,r<0?r+=360:r>=360&&(r-=360),r}function Kb(e,t,n){if(e.h===0&&e.s===0)return e.s;var r;return n?r=e.s-Vb*t:t===BN?r=e.s+Vb:r=e.s+eD*t,r>1&&(r=1),n&&t===ON&&r>.1&&(r=.1),r<.06&&(r=.06),Math.round(r*100)/100}function Gb(e,t,n){var r;return n?r=e.v+tD*t:r=e.v-nD*t,r=Math.max(0,Math.min(1,r)),Math.round(r*100)/100}function Oa(e){for(var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},n=[],r=new xt(e),i=r.toHsv(),s=ON;s>0;s-=1){var o=new xt({h:qb(i,s,!0),s:Kb(i,s,!0),v:Gb(i,s,!0)});n.push(o)}n.push(r);for(var a=1;a<=BN;a+=1){var l=new xt({h:qb(i,a),s:Kb(i,a),v:Gb(i,a)});n.push(l)}return t.theme==="dark"?rD.map(function(c){var u=c.index,d=c.amount;return new xt(t.backgroundColor||"#141414").mix(n[u],d).toHexString()}):n.map(function(c){return c.toHexString()})}var _m={red:"#F5222D",volcano:"#FA541C",orange:"#FA8C16",gold:"#FAAD14",yellow:"#FADB14",lime:"#A0D911",green:"#52C41A",cyan:"#13C2C2",blue:"#1677FF",geekblue:"#2F54EB",purple:"#722ED1",magenta:"#EB2F96",grey:"#666666"},Mv=["#fff1f0","#ffccc7","#ffa39e","#ff7875","#ff4d4f","#f5222d","#cf1322","#a8071a","#820014","#5c0011"];Mv.primary=Mv[5];var Av=["#fff2e8","#ffd8bf","#ffbb96","#ff9c6e","#ff7a45","#fa541c","#d4380d","#ad2102","#871400","#610b00"];Av.primary=Av[5];var Lv=["#fff7e6","#ffe7ba","#ffd591","#ffc069","#ffa940","#fa8c16","#d46b08","#ad4e00","#873800","#612500"];Lv.primary=Lv[5];var jv=["#fffbe6","#fff1b8","#ffe58f","#ffd666","#ffc53d","#faad14","#d48806","#ad6800","#874d00","#613400"];jv.primary=jv[5];var Dv=["#feffe6","#ffffb8","#fffb8f","#fff566","#ffec3d","#fadb14","#d4b106","#ad8b00","#876800","#614700"];Dv.primary=Dv[5];var Ov=["#fcffe6","#f4ffb8","#eaff8f","#d3f261","#bae637","#a0d911","#7cb305","#5b8c00","#3f6600","#254000"];Ov.primary=Ov[5];var Bv=["#f6ffed","#d9f7be","#b7eb8f","#95de64","#73d13d","#52c41a","#389e0d","#237804","#135200","#092b00"];Bv.primary=Bv[5];var zv=["#e6fffb","#b5f5ec","#87e8de","#5cdbd3","#36cfc9","#13c2c2","#08979c","#006d75","#00474f","#002329"];zv.primary=zv[5];var $v=["#e6f4ff","#bae0ff","#91caff","#69b1ff","#4096ff","#1677ff","#0958d9","#003eb3","#002c8c","#001d66"];$v.primary=$v[5];var Fv=["#f0f5ff","#d6e4ff","#adc6ff","#85a5ff","#597ef7","#2f54eb","#1d39c4","#10239e","#061178","#030852"];Fv.primary=Fv[5];var Hv=["#f9f0ff","#efdbff","#d3adf7","#b37feb","#9254de","#722ed1","#531dab","#391085","#22075e","#120338"];Hv.primary=Hv[5];var Uv=["#fff0f6","#ffd6e7","#ffadd2","#ff85c0","#f759ab","#eb2f96","#c41d7f","#9e1068","#780650","#520339"];Uv.primary=Uv[5];var Wv=["#a6a6a6","#999999","#8c8c8c","#808080","#737373","#666666","#404040","#1a1a1a","#000000","#000000"];Wv.primary=Wv[5];var xm={red:Mv,volcano:Av,orange:Lv,gold:jv,yellow:Dv,lime:Ov,green:Bv,cyan:zv,blue:$v,geekblue:Fv,purple:Hv,magenta:Uv,grey:Wv};function zN(e,{generateColorPalettes:t,generateNeutralColorPalettes:n}){const{colorSuccess:r,colorWarning:i,colorError:s,colorInfo:o,colorPrimary:a,colorBgBase:l,colorTextBase:c}=e,u=t(a),d=t(r),f=t(i),p=t(s),m=t(o),v=n(l,c),b=e.colorLink||e.colorInfo,_=t(b),x=new xt(p[1]).mix(new xt(p[3]),50).toHexString();return Object.assign(Object.assign({},v),{colorPrimaryBg:u[1],colorPrimaryBgHover:u[2],colorPrimaryBorder:u[3],colorPrimaryBorderHover:u[4],colorPrimaryHover:u[5],colorPrimary:u[6],colorPrimaryActive:u[7],colorPrimaryTextHover:u[8],colorPrimaryText:u[9],colorPrimaryTextActive:u[10],colorSuccessBg:d[1],colorSuccessBgHover:d[2],colorSuccessBorder:d[3],colorSuccessBorderHover:d[4],colorSuccessHover:d[4],colorSuccess:d[6],colorSuccessActive:d[7],colorSuccessTextHover:d[8],colorSuccessText:d[9],colorSuccessTextActive:d[10],colorErrorBg:p[1],colorErrorBgHover:p[2],colorErrorBgFilledHover:x,colorErrorBgActive:p[3],colorErrorBorder:p[3],colorErrorBorderHover:p[4],colorErrorHover:p[5],colorError:p[6],colorErrorActive:p[7],colorErrorTextHover:p[8],colorErrorText:p[9],colorErrorTextActive:p[10],colorWarningBg:f[1],colorWarningBgHover:f[2],colorWarningBorder:f[3],colorWarningBorderHover:f[4],colorWarningHover:f[4],colorWarning:f[6],colorWarningActive:f[7],colorWarningTextHover:f[8],colorWarningText:f[9],colorWarningTextActive:f[10],colorInfoBg:m[1],colorInfoBgHover:m[2],colorInfoBorder:m[3],colorInfoBorderHover:m[4],colorInfoHover:m[4],colorInfo:m[6],colorInfoActive:m[7],colorInfoTextHover:m[8],colorInfoText:m[9],colorInfoTextActive:m[10],colorLinkHover:_[4],colorLink:_[6],colorLinkActive:_[7],colorBgMask:new xt("#000").setA(.45).toRgbString(),colorWhite:"#fff"})}const iD=e=>{let t=e,n=e,r=e,i=e;return e<6&&e>=5?t=e+1:e<16&&e>=6?t=e+2:e>=16&&(t=16),e<7&&e>=5?n=4:e<8&&e>=7?n=5:e<14&&e>=8?n=6:e<16&&e>=14?n=7:e>=16&&(n=8),e<6&&e>=2?r=1:e>=6&&(r=2),e>4&&e<8?i=4:e>=8&&(i=6),{borderRadius:e,borderRadiusXS:r,borderRadiusSM:n,borderRadiusLG:t,borderRadiusOuter:i}};function sD(e){const{motionUnit:t,motionBase:n,borderRadius:r,lineWidth:i}=e;return Object.assign({motionDurationFast:`${(n+t).toFixed(1)}s`,motionDurationMid:`${(n+t*2).toFixed(1)}s`,motionDurationSlow:`${(n+t*3).toFixed(1)}s`,lineWidthBold:i+1},iD(r))}const oD=e=>{const{controlHeight:t}=e;return{controlHeightSM:t*.75,controlHeightXS:t*.5,controlHeightLG:t*1.25}};function aD(e){return(e+8)/e}function lD(e){const t=Array.from({length:10}).map((n,r)=>{const i=r-1,s=e*Math.pow(Math.E,i/5),o=r>1?Math.floor(s):Math.ceil(s);return Math.floor(o/2)*2});return t[1]=e,t.map(n=>({size:n,lineHeight:aD(n)}))}const cD=e=>{const t=lD(e),n=t.map(u=>u.size),r=t.map(u=>u.lineHeight),i=n[1],s=n[0],o=n[2],a=r[1],l=r[0],c=r[2];return{fontSizeSM:s,fontSize:i,fontSizeLG:o,fontSizeXL:n[3],fontSizeHeading1:n[6],fontSizeHeading2:n[5],fontSizeHeading3:n[4],fontSizeHeading4:n[3],fontSizeHeading5:n[2],lineHeight:a,lineHeightLG:c,lineHeightSM:l,fontHeight:Math.round(a*i),fontHeightLG:Math.round(c*o),fontHeightSM:Math.round(l*s),lineHeightHeading1:r[6],lineHeightHeading2:r[5],lineHeightHeading3:r[4],lineHeightHeading4:r[3],lineHeightHeading5:r[2]}};function uD(e){const{sizeUnit:t,sizeStep:n}=e;return{sizeXXL:t*(n+8),sizeXL:t*(n+4),sizeLG:t*(n+2),sizeMD:t*(n+1),sizeMS:t*n,size:t*n,sizeSM:t*(n-1),sizeXS:t*(n-2),sizeXXS:t*(n-3)}}const or=(e,t)=>new xt(e).setA(t).toRgbString(),Rl=(e,t)=>new xt(e).darken(t).toHexString(),dD=e=>{const t=Oa(e);return{1:t[0],2:t[1],3:t[2],4:t[3],5:t[4],6:t[5],7:t[6],8:t[4],9:t[5],10:t[6]}},hD=(e,t)=>{const n=e||"#fff",r=t||"#000";return{colorBgBase:n,colorTextBase:r,colorText:or(r,.88),colorTextSecondary:or(r,.65),colorTextTertiary:or(r,.45),colorTextQuaternary:or(r,.25),colorFill:or(r,.15),colorFillSecondary:or(r,.06),colorFillTertiary:or(r,.04),colorFillQuaternary:or(r,.02),colorBgSolid:or(r,1),colorBgSolidHover:or(r,.75),colorBgSolidActive:or(r,.95),colorBgLayout:Rl(n,4),colorBgContainer:Rl(n,0),colorBgElevated:Rl(n,0),colorBgSpotlight:or(r,.85),colorBgBlur:"transparent",colorBorder:Rl(n,15),colorBorderSecondary:Rl(n,6)}};function Ex(e){_m.pink=_m.magenta,xm.pink=xm.magenta;const t=Object.keys(Cx).map(n=>{const r=e[n]===_m[n]?xm[n]:Oa(e[n]);return Array.from({length:10},()=>1).reduce((i,s,o)=>(i[`${n}-${o+1}`]=r[o],i[`${n}${o+1}`]=r[o],i),{})}).reduce((n,r)=>(n=Object.assign(Object.assign({},n),r),n),{});return Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({},e),t),zN(e,{generateColorPalettes:dD,generateNeutralColorPalettes:hD})),cD(e.fontSize)),uD(e)),oD(e)),sD(e))}const $N=Nv(Ex),jh={token:$c,override:{override:$c},hashed:!0},FN=Qe.createContext(jh),Vv="ant",HN="anticon",fD=(e,t)=>t||(e?`${Vv}-${e}`:Vv),Xf=g.createContext({getPrefixCls:fD,iconPrefixCls:HN}),{Consumer:Cse}=Xf,pD=`-ant-${Date.now()}-${Math.random()}`;function mD(e,t){const n={},r=(o,a)=>{let l=o.clone();return l=(a==null?void 0:a(l))||l,l.toRgbString()},i=(o,a)=>{const l=new xt(o),c=Oa(l.toRgbString());n[`${a}-color`]=r(l),n[`${a}-color-disabled`]=c[1],n[`${a}-color-hover`]=c[4],n[`${a}-color-active`]=c[6],n[`${a}-color-outline`]=l.clone().setA(.2).toRgbString(),n[`${a}-color-deprecated-bg`]=c[0],n[`${a}-color-deprecated-border`]=c[2]};if(t.primaryColor){i(t.primaryColor,"primary");const o=new xt(t.primaryColor),a=Oa(o.toRgbString());a.forEach((c,u)=>{n[`primary-${u+1}`]=c}),n["primary-color-deprecated-l-35"]=r(o,c=>c.lighten(35)),n["primary-color-deprecated-l-20"]=r(o,c=>c.lighten(20)),n["primary-color-deprecated-t-20"]=r(o,c=>c.tint(20)),n["primary-color-deprecated-t-50"]=r(o,c=>c.tint(50)),n["primary-color-deprecated-f-12"]=r(o,c=>c.setA(c.a*.12));const l=new xt(a[0]);n["primary-color-active-deprecated-f-30"]=r(l,c=>c.setA(c.a*.3)),n["primary-color-active-deprecated-d-02"]=r(l,c=>c.darken(2))}return t.successColor&&i(t.successColor,"success"),t.warningColor&&i(t.warningColor,"warning"),t.errorColor&&i(t.errorColor,"error"),t.infoColor&&i(t.infoColor,"info"),`
|
|
58
|
+
'Noto Color Emoji'`,fontFamilyCode:"'SFMono-Regular', Consolas, 'Liberation Mono', Menlo, Courier, monospace",fontSize:14,lineWidth:1,lineType:"solid",motionUnit:.1,motionBase:0,motionEaseOutCirc:"cubic-bezier(0.08, 0.82, 0.17, 1)",motionEaseInOutCirc:"cubic-bezier(0.78, 0.14, 0.15, 0.86)",motionEaseOut:"cubic-bezier(0.215, 0.61, 0.355, 1)",motionEaseInOut:"cubic-bezier(0.645, 0.045, 0.355, 1)",motionEaseOutBack:"cubic-bezier(0.12, 0.4, 0.29, 1.46)",motionEaseInBack:"cubic-bezier(0.71, -0.46, 0.88, 0.6)",motionEaseInQuint:"cubic-bezier(0.755, 0.05, 0.855, 0.06)",motionEaseOutQuint:"cubic-bezier(0.23, 1, 0.32, 1)",borderRadius:6,sizeUnit:4,sizeStep:4,sizePopupArrow:16,controlHeight:32,zIndexBase:0,zIndexPopupBase:1e3,opacityImage:1,wireframe:!1,motion:!0}),Yt=Math.round;function vm(e,t){const n=e.replace(/^[^(]*\((.*)/,"$1").replace(/\).*/,"").match(/\d*\.?\d+%?/g)||[],r=n.map(i=>parseFloat(i));for(let i=0;i<3;i+=1)r[i]=t(r[i]||0,n[i]||"",i);return n[3]?r[3]=n[3].includes("%")?r[3]/100:r[3]:r[3]=1,r}const Wb=(e,t,n)=>n===0?e:e/100;function Il(e,t){const n=t||255;return e>n?n:e<0?0:e}class xt{constructor(t){ke(this,"isValid",!0),ke(this,"r",0),ke(this,"g",0),ke(this,"b",0),ke(this,"a",1),ke(this,"_h",void 0),ke(this,"_s",void 0),ke(this,"_l",void 0),ke(this,"_v",void 0),ke(this,"_max",void 0),ke(this,"_min",void 0),ke(this,"_brightness",void 0);function n(i){return i[0]in t&&i[1]in t&&i[2]in t}if(t)if(typeof t=="string"){let s=function(o){return i.startsWith(o)};var r=s;const i=t.trim();/^#?[A-F\d]{3,8}$/i.test(i)?this.fromHexString(i):s("rgb")?this.fromRgbString(i):s("hsl")?this.fromHslString(i):(s("hsv")||s("hsb"))&&this.fromHsvString(i)}else if(t instanceof xt)this.r=t.r,this.g=t.g,this.b=t.b,this.a=t.a,this._h=t._h,this._s=t._s,this._l=t._l,this._v=t._v;else if(n("rgb"))this.r=Il(t.r),this.g=Il(t.g),this.b=Il(t.b),this.a=typeof t.a=="number"?Il(t.a,1):1;else if(n("hsl"))this.fromHsl(t);else if(n("hsv"))this.fromHsv(t);else throw new Error("@ant-design/fast-color: unsupported input "+JSON.stringify(t))}setR(t){return this._sc("r",t)}setG(t){return this._sc("g",t)}setB(t){return this._sc("b",t)}setA(t){return this._sc("a",t,1)}setHue(t){const n=this.toHsv();return n.h=t,this._c(n)}getLuminance(){function t(s){const o=s/255;return o<=.03928?o/12.92:Math.pow((o+.055)/1.055,2.4)}const n=t(this.r),r=t(this.g),i=t(this.b);return .2126*n+.7152*r+.0722*i}getHue(){if(typeof this._h>"u"){const t=this.getMax()-this.getMin();t===0?this._h=0:this._h=Yt(60*(this.r===this.getMax()?(this.g-this.b)/t+(this.g<this.b?6:0):this.g===this.getMax()?(this.b-this.r)/t+2:(this.r-this.g)/t+4))}return this._h}getSaturation(){if(typeof this._s>"u"){const t=this.getMax()-this.getMin();t===0?this._s=0:this._s=t/this.getMax()}return this._s}getLightness(){return typeof this._l>"u"&&(this._l=(this.getMax()+this.getMin())/510),this._l}getValue(){return typeof this._v>"u"&&(this._v=this.getMax()/255),this._v}getBrightness(){return typeof this._brightness>"u"&&(this._brightness=(this.r*299+this.g*587+this.b*114)/1e3),this._brightness}darken(t=10){const n=this.getHue(),r=this.getSaturation();let i=this.getLightness()-t/100;return i<0&&(i=0),this._c({h:n,s:r,l:i,a:this.a})}lighten(t=10){const n=this.getHue(),r=this.getSaturation();let i=this.getLightness()+t/100;return i>1&&(i=1),this._c({h:n,s:r,l:i,a:this.a})}mix(t,n=50){const r=this._c(t),i=n/100,s=a=>(r[a]-this[a])*i+this[a],o={r:Yt(s("r")),g:Yt(s("g")),b:Yt(s("b")),a:Yt(s("a")*100)/100};return this._c(o)}tint(t=10){return this.mix({r:255,g:255,b:255,a:1},t)}shade(t=10){return this.mix({r:0,g:0,b:0,a:1},t)}onBackground(t){const n=this._c(t),r=this.a+n.a*(1-this.a),i=s=>Yt((this[s]*this.a+n[s]*n.a*(1-this.a))/r);return this._c({r:i("r"),g:i("g"),b:i("b"),a:r})}isDark(){return this.getBrightness()<128}isLight(){return this.getBrightness()>=128}equals(t){return this.r===t.r&&this.g===t.g&&this.b===t.b&&this.a===t.a}clone(){return this._c(this)}toHexString(){let t="#";const n=(this.r||0).toString(16);t+=n.length===2?n:"0"+n;const r=(this.g||0).toString(16);t+=r.length===2?r:"0"+r;const i=(this.b||0).toString(16);if(t+=i.length===2?i:"0"+i,typeof this.a=="number"&&this.a>=0&&this.a<1){const s=Yt(this.a*255).toString(16);t+=s.length===2?s:"0"+s}return t}toHsl(){return{h:this.getHue(),s:this.getSaturation(),l:this.getLightness(),a:this.a}}toHslString(){const t=this.getHue(),n=Yt(this.getSaturation()*100),r=Yt(this.getLightness()*100);return this.a!==1?`hsla(${t},${n}%,${r}%,${this.a})`:`hsl(${t},${n}%,${r}%)`}toHsv(){return{h:this.getHue(),s:this.getSaturation(),v:this.getValue(),a:this.a}}toRgb(){return{r:this.r,g:this.g,b:this.b,a:this.a}}toRgbString(){return this.a!==1?`rgba(${this.r},${this.g},${this.b},${this.a})`:`rgb(${this.r},${this.g},${this.b})`}toString(){return this.toRgbString()}_sc(t,n,r){const i=this.clone();return i[t]=Il(n,r),i}_c(t){return new this.constructor(t)}getMax(){return typeof this._max>"u"&&(this._max=Math.max(this.r,this.g,this.b)),this._max}getMin(){return typeof this._min>"u"&&(this._min=Math.min(this.r,this.g,this.b)),this._min}fromHexString(t){const n=t.replace("#","");function r(i,s){return parseInt(n[i]+n[s||i],16)}n.length<6?(this.r=r(0),this.g=r(1),this.b=r(2),this.a=n[3]?r(3)/255:1):(this.r=r(0,1),this.g=r(2,3),this.b=r(4,5),this.a=n[6]?r(6,7)/255:1)}fromHsl({h:t,s:n,l:r,a:i}){if(this._h=t%360,this._s=n,this._l=r,this.a=typeof i=="number"?i:1,n<=0){const f=Yt(r*255);this.r=f,this.g=f,this.b=f}let s=0,o=0,a=0;const l=t/60,c=(1-Math.abs(2*r-1))*n,u=c*(1-Math.abs(l%2-1));l>=0&&l<1?(s=c,o=u):l>=1&&l<2?(s=u,o=c):l>=2&&l<3?(o=c,a=u):l>=3&&l<4?(o=u,a=c):l>=4&&l<5?(s=u,a=c):l>=5&&l<6&&(s=c,a=u);const d=r-c/2;this.r=Yt((s+d)*255),this.g=Yt((o+d)*255),this.b=Yt((a+d)*255)}fromHsv({h:t,s:n,v:r,a:i}){this._h=t%360,this._s=n,this._v=r,this.a=typeof i=="number"?i:1;const s=Yt(r*255);if(this.r=s,this.g=s,this.b=s,n<=0)return;const o=t/60,a=Math.floor(o),l=o-a,c=Yt(r*(1-n)*255),u=Yt(r*(1-n*l)*255),d=Yt(r*(1-n*(1-l))*255);switch(a){case 0:this.g=d,this.b=c;break;case 1:this.r=u,this.b=c;break;case 2:this.r=c,this.b=d;break;case 3:this.r=c,this.g=u;break;case 4:this.r=d,this.g=c;break;case 5:default:this.g=c,this.b=u;break}}fromHsvString(t){const n=vm(t,Wb);this.fromHsv({h:n[0],s:n[1],v:n[2],a:n[3]})}fromHslString(t){const n=vm(t,Wb);this.fromHsl({h:n[0],s:n[1],l:n[2],a:n[3]})}fromRgbString(t){const n=vm(t,(r,i)=>i.includes("%")?Yt(r/100*255):r);this.r=n[0],this.g=n[1],this.b=n[2],this.a=n[3]}}var Ju=2,Vb=.16,eD=.05,tD=.05,nD=.15,ON=5,BN=4,rD=[{index:7,amount:15},{index:6,amount:25},{index:5,amount:30},{index:5,amount:45},{index:5,amount:65},{index:5,amount:85},{index:4,amount:90},{index:3,amount:95},{index:2,amount:97},{index:1,amount:98}];function qb(e,t,n){var r;return Math.round(e.h)>=60&&Math.round(e.h)<=240?r=n?Math.round(e.h)-Ju*t:Math.round(e.h)+Ju*t:r=n?Math.round(e.h)+Ju*t:Math.round(e.h)-Ju*t,r<0?r+=360:r>=360&&(r-=360),r}function Kb(e,t,n){if(e.h===0&&e.s===0)return e.s;var r;return n?r=e.s-Vb*t:t===BN?r=e.s+Vb:r=e.s+eD*t,r>1&&(r=1),n&&t===ON&&r>.1&&(r=.1),r<.06&&(r=.06),Math.round(r*100)/100}function Gb(e,t,n){var r;return n?r=e.v+tD*t:r=e.v-nD*t,r=Math.max(0,Math.min(1,r)),Math.round(r*100)/100}function Oa(e){for(var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},n=[],r=new xt(e),i=r.toHsv(),s=ON;s>0;s-=1){var o=new xt({h:qb(i,s,!0),s:Kb(i,s,!0),v:Gb(i,s,!0)});n.push(o)}n.push(r);for(var a=1;a<=BN;a+=1){var l=new xt({h:qb(i,a),s:Kb(i,a),v:Gb(i,a)});n.push(l)}return t.theme==="dark"?rD.map(function(c){var u=c.index,d=c.amount;return new xt(t.backgroundColor||"#141414").mix(n[u],d).toHexString()}):n.map(function(c){return c.toHexString()})}var _m={red:"#F5222D",volcano:"#FA541C",orange:"#FA8C16",gold:"#FAAD14",yellow:"#FADB14",lime:"#A0D911",green:"#52C41A",cyan:"#13C2C2",blue:"#1677FF",geekblue:"#2F54EB",purple:"#722ED1",magenta:"#EB2F96",grey:"#666666"},Mv=["#fff1f0","#ffccc7","#ffa39e","#ff7875","#ff4d4f","#f5222d","#cf1322","#a8071a","#820014","#5c0011"];Mv.primary=Mv[5];var Av=["#fff2e8","#ffd8bf","#ffbb96","#ff9c6e","#ff7a45","#fa541c","#d4380d","#ad2102","#871400","#610b00"];Av.primary=Av[5];var Lv=["#fff7e6","#ffe7ba","#ffd591","#ffc069","#ffa940","#fa8c16","#d46b08","#ad4e00","#873800","#612500"];Lv.primary=Lv[5];var jv=["#fffbe6","#fff1b8","#ffe58f","#ffd666","#ffc53d","#faad14","#d48806","#ad6800","#874d00","#613400"];jv.primary=jv[5];var Dv=["#feffe6","#ffffb8","#fffb8f","#fff566","#ffec3d","#fadb14","#d4b106","#ad8b00","#876800","#614700"];Dv.primary=Dv[5];var Ov=["#fcffe6","#f4ffb8","#eaff8f","#d3f261","#bae637","#a0d911","#7cb305","#5b8c00","#3f6600","#254000"];Ov.primary=Ov[5];var Bv=["#f6ffed","#d9f7be","#b7eb8f","#95de64","#73d13d","#52c41a","#389e0d","#237804","#135200","#092b00"];Bv.primary=Bv[5];var zv=["#e6fffb","#b5f5ec","#87e8de","#5cdbd3","#36cfc9","#13c2c2","#08979c","#006d75","#00474f","#002329"];zv.primary=zv[5];var $v=["#e6f4ff","#bae0ff","#91caff","#69b1ff","#4096ff","#1677ff","#0958d9","#003eb3","#002c8c","#001d66"];$v.primary=$v[5];var Fv=["#f0f5ff","#d6e4ff","#adc6ff","#85a5ff","#597ef7","#2f54eb","#1d39c4","#10239e","#061178","#030852"];Fv.primary=Fv[5];var Hv=["#f9f0ff","#efdbff","#d3adf7","#b37feb","#9254de","#722ed1","#531dab","#391085","#22075e","#120338"];Hv.primary=Hv[5];var Uv=["#fff0f6","#ffd6e7","#ffadd2","#ff85c0","#f759ab","#eb2f96","#c41d7f","#9e1068","#780650","#520339"];Uv.primary=Uv[5];var Wv=["#a6a6a6","#999999","#8c8c8c","#808080","#737373","#666666","#404040","#1a1a1a","#000000","#000000"];Wv.primary=Wv[5];var xm={red:Mv,volcano:Av,orange:Lv,gold:jv,yellow:Dv,lime:Ov,green:Bv,cyan:zv,blue:$v,geekblue:Fv,purple:Hv,magenta:Uv,grey:Wv};function zN(e,{generateColorPalettes:t,generateNeutralColorPalettes:n}){const{colorSuccess:r,colorWarning:i,colorError:s,colorInfo:o,colorPrimary:a,colorBgBase:l,colorTextBase:c}=e,u=t(a),d=t(r),f=t(i),p=t(s),m=t(o),v=n(l,c),b=e.colorLink||e.colorInfo,_=t(b),x=new xt(p[1]).mix(new xt(p[3]),50).toHexString();return Object.assign(Object.assign({},v),{colorPrimaryBg:u[1],colorPrimaryBgHover:u[2],colorPrimaryBorder:u[3],colorPrimaryBorderHover:u[4],colorPrimaryHover:u[5],colorPrimary:u[6],colorPrimaryActive:u[7],colorPrimaryTextHover:u[8],colorPrimaryText:u[9],colorPrimaryTextActive:u[10],colorSuccessBg:d[1],colorSuccessBgHover:d[2],colorSuccessBorder:d[3],colorSuccessBorderHover:d[4],colorSuccessHover:d[4],colorSuccess:d[6],colorSuccessActive:d[7],colorSuccessTextHover:d[8],colorSuccessText:d[9],colorSuccessTextActive:d[10],colorErrorBg:p[1],colorErrorBgHover:p[2],colorErrorBgFilledHover:x,colorErrorBgActive:p[3],colorErrorBorder:p[3],colorErrorBorderHover:p[4],colorErrorHover:p[5],colorError:p[6],colorErrorActive:p[7],colorErrorTextHover:p[8],colorErrorText:p[9],colorErrorTextActive:p[10],colorWarningBg:f[1],colorWarningBgHover:f[2],colorWarningBorder:f[3],colorWarningBorderHover:f[4],colorWarningHover:f[4],colorWarning:f[6],colorWarningActive:f[7],colorWarningTextHover:f[8],colorWarningText:f[9],colorWarningTextActive:f[10],colorInfoBg:m[1],colorInfoBgHover:m[2],colorInfoBorder:m[3],colorInfoBorderHover:m[4],colorInfoHover:m[4],colorInfo:m[6],colorInfoActive:m[7],colorInfoTextHover:m[8],colorInfoText:m[9],colorInfoTextActive:m[10],colorLinkHover:_[4],colorLink:_[6],colorLinkActive:_[7],colorBgMask:new xt("#000").setA(.45).toRgbString(),colorWhite:"#fff"})}const iD=e=>{let t=e,n=e,r=e,i=e;return e<6&&e>=5?t=e+1:e<16&&e>=6?t=e+2:e>=16&&(t=16),e<7&&e>=5?n=4:e<8&&e>=7?n=5:e<14&&e>=8?n=6:e<16&&e>=14?n=7:e>=16&&(n=8),e<6&&e>=2?r=1:e>=6&&(r=2),e>4&&e<8?i=4:e>=8&&(i=6),{borderRadius:e,borderRadiusXS:r,borderRadiusSM:n,borderRadiusLG:t,borderRadiusOuter:i}};function sD(e){const{motionUnit:t,motionBase:n,borderRadius:r,lineWidth:i}=e;return Object.assign({motionDurationFast:`${(n+t).toFixed(1)}s`,motionDurationMid:`${(n+t*2).toFixed(1)}s`,motionDurationSlow:`${(n+t*3).toFixed(1)}s`,lineWidthBold:i+1},iD(r))}const oD=e=>{const{controlHeight:t}=e;return{controlHeightSM:t*.75,controlHeightXS:t*.5,controlHeightLG:t*1.25}};function aD(e){return(e+8)/e}function lD(e){const t=Array.from({length:10}).map((n,r)=>{const i=r-1,s=e*Math.pow(Math.E,i/5),o=r>1?Math.floor(s):Math.ceil(s);return Math.floor(o/2)*2});return t[1]=e,t.map(n=>({size:n,lineHeight:aD(n)}))}const cD=e=>{const t=lD(e),n=t.map(u=>u.size),r=t.map(u=>u.lineHeight),i=n[1],s=n[0],o=n[2],a=r[1],l=r[0],c=r[2];return{fontSizeSM:s,fontSize:i,fontSizeLG:o,fontSizeXL:n[3],fontSizeHeading1:n[6],fontSizeHeading2:n[5],fontSizeHeading3:n[4],fontSizeHeading4:n[3],fontSizeHeading5:n[2],lineHeight:a,lineHeightLG:c,lineHeightSM:l,fontHeight:Math.round(a*i),fontHeightLG:Math.round(c*o),fontHeightSM:Math.round(l*s),lineHeightHeading1:r[6],lineHeightHeading2:r[5],lineHeightHeading3:r[4],lineHeightHeading4:r[3],lineHeightHeading5:r[2]}};function uD(e){const{sizeUnit:t,sizeStep:n}=e;return{sizeXXL:t*(n+8),sizeXL:t*(n+4),sizeLG:t*(n+2),sizeMD:t*(n+1),sizeMS:t*n,size:t*n,sizeSM:t*(n-1),sizeXS:t*(n-2),sizeXXS:t*(n-3)}}const or=(e,t)=>new xt(e).setA(t).toRgbString(),Rl=(e,t)=>new xt(e).darken(t).toHexString(),dD=e=>{const t=Oa(e);return{1:t[0],2:t[1],3:t[2],4:t[3],5:t[4],6:t[5],7:t[6],8:t[4],9:t[5],10:t[6]}},hD=(e,t)=>{const n=e||"#fff",r=t||"#000";return{colorBgBase:n,colorTextBase:r,colorText:or(r,.88),colorTextSecondary:or(r,.65),colorTextTertiary:or(r,.45),colorTextQuaternary:or(r,.25),colorFill:or(r,.15),colorFillSecondary:or(r,.06),colorFillTertiary:or(r,.04),colorFillQuaternary:or(r,.02),colorBgSolid:or(r,1),colorBgSolidHover:or(r,.75),colorBgSolidActive:or(r,.95),colorBgLayout:Rl(n,4),colorBgContainer:Rl(n,0),colorBgElevated:Rl(n,0),colorBgSpotlight:or(r,.85),colorBgBlur:"transparent",colorBorder:Rl(n,15),colorBorderSecondary:Rl(n,6)}};function Ex(e){_m.pink=_m.magenta,xm.pink=xm.magenta;const t=Object.keys(Cx).map(n=>{const r=e[n]===_m[n]?xm[n]:Oa(e[n]);return Array.from({length:10},()=>1).reduce((i,s,o)=>(i[`${n}-${o+1}`]=r[o],i[`${n}${o+1}`]=r[o],i),{})}).reduce((n,r)=>(n=Object.assign(Object.assign({},n),r),n),{});return Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({},e),t),zN(e,{generateColorPalettes:dD,generateNeutralColorPalettes:hD})),cD(e.fontSize)),uD(e)),oD(e)),sD(e))}const $N=Nv(Ex),jh={token:$c,override:{override:$c},hashed:!0},FN=Qe.createContext(jh),Vv="ant",HN="anticon",fD=(e,t)=>t||(e?`${Vv}-${e}`:Vv),Xf=g.createContext({getPrefixCls:fD,iconPrefixCls:HN}),{Consumer:Tse}=Xf,pD=`-ant-${Date.now()}-${Math.random()}`;function mD(e,t){const n={},r=(o,a)=>{let l=o.clone();return l=(a==null?void 0:a(l))||l,l.toRgbString()},i=(o,a)=>{const l=new xt(o),c=Oa(l.toRgbString());n[`${a}-color`]=r(l),n[`${a}-color-disabled`]=c[1],n[`${a}-color-hover`]=c[4],n[`${a}-color-active`]=c[6],n[`${a}-color-outline`]=l.clone().setA(.2).toRgbString(),n[`${a}-color-deprecated-bg`]=c[0],n[`${a}-color-deprecated-border`]=c[2]};if(t.primaryColor){i(t.primaryColor,"primary");const o=new xt(t.primaryColor),a=Oa(o.toRgbString());a.forEach((c,u)=>{n[`primary-${u+1}`]=c}),n["primary-color-deprecated-l-35"]=r(o,c=>c.lighten(35)),n["primary-color-deprecated-l-20"]=r(o,c=>c.lighten(20)),n["primary-color-deprecated-t-20"]=r(o,c=>c.tint(20)),n["primary-color-deprecated-t-50"]=r(o,c=>c.tint(50)),n["primary-color-deprecated-f-12"]=r(o,c=>c.setA(c.a*.12));const l=new xt(a[0]);n["primary-color-active-deprecated-f-30"]=r(l,c=>c.setA(c.a*.3)),n["primary-color-active-deprecated-d-02"]=r(l,c=>c.darken(2))}return t.successColor&&i(t.successColor,"success"),t.warningColor&&i(t.warningColor,"warning"),t.errorColor&&i(t.errorColor,"error"),t.infoColor&&i(t.infoColor,"info"),`
|
|
59
59
|
:root {
|
|
60
60
|
${Object.keys(n).map(o=>`--${e}-${o}: ${n[o]};`).join(`
|
|
61
61
|
`)}
|
|
@@ -472,7 +472,7 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
|
|
|
472
472
|
`)},eS=function(){var e=parseInt(document.body.getAttribute(ka)||"0",10);return isFinite(e)?e:0},J9=function(){g.useEffect(function(){return document.body.setAttribute(ka,(eS()+1).toString()),function(){var e=eS()-1;e<=0?document.body.removeAttribute(ka):document.body.setAttribute(ka,e.toString())}},[])},e7=function(e){var t=e.noRelative,n=e.noImportant,r=e.gapMode,i=r===void 0?"margin":r;J9();var s=g.useMemo(function(){return Y9(i)},[i]);return g.createElement(Z9,{styles:Q9(s,!t,i,n?"":"!important")})},p0=!1;if(typeof window<"u")try{var pd=Object.defineProperty({},"passive",{get:function(){return p0=!0,!0}});window.addEventListener("test",pd,pd),window.removeEventListener("test",pd,pd)}catch{p0=!1}var Vo=p0?{passive:!1}:!1,t7=function(e){return e.tagName==="TEXTAREA"},YP=function(e,t){if(!(e instanceof Element))return!1;var n=window.getComputedStyle(e);return n[t]!=="hidden"&&!(n.overflowY===n.overflowX&&!t7(e)&&n[t]==="visible")},n7=function(e){return YP(e,"overflowY")},r7=function(e){return YP(e,"overflowX")},tS=function(e,t){var n=t.ownerDocument,r=t;do{typeof ShadowRoot<"u"&&r instanceof ShadowRoot&&(r=r.host);var i=ZP(e,r);if(i){var s=QP(e,r),o=s[1],a=s[2];if(o>a)return!0}r=r.parentNode}while(r&&r!==n.body);return!1},i7=function(e){var t=e.scrollTop,n=e.scrollHeight,r=e.clientHeight;return[t,n,r]},s7=function(e){var t=e.scrollLeft,n=e.scrollWidth,r=e.clientWidth;return[t,n,r]},ZP=function(e,t){return e==="v"?n7(t):r7(t)},QP=function(e,t){return e==="v"?i7(t):s7(t)},o7=function(e,t){return e==="h"&&t==="rtl"?-1:1},a7=function(e,t,n,r,i){var s=o7(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=QP(e,a),m=p[0],v=p[1],b=p[2],_=v-b-s*m;(m||_)&&ZP(e,a)&&(d+=_,f+=m);var x=a.parentNode;a=x&&x.nodeType===Node.DOCUMENT_FRAGMENT_NODE?x.host:x}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},md=function(e){return"changedTouches"in e?[e.changedTouches[0].clientX,e.changedTouches[0].clientY]:[0,0]},nS=function(e){return[e.deltaX,e.deltaY]},rS=function(e){return e&&"current"in e?e.current:e},l7=function(e,t){return e[0]===t[0]&&e[1]===t[1]},c7=function(e){return`
|
|
473
473
|
.block-interactivity-`.concat(e,` {pointer-events: none;}
|
|
474
474
|
.allow-interactivity-`).concat(e,` {pointer-events: all;}
|
|
475
|
-
`)},u7=0,qo=[];function d7(e){var t=g.useRef([]),n=g.useRef([0,0]),r=g.useRef(),i=g.useState(u7++)[0],s=g.useState(XP)[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=M9([e.lockRef.current],(e.shards||[]).map(rS),!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 _=md(v),x=n.current,y="deltaX"in v?v.deltaX:x[0]-_[0],w="deltaY"in v?v.deltaY:x[1]-_[1],k,C=v.target,N=Math.abs(y)>Math.abs(w)?"h":"v";if("touches"in v&&N==="h"&&C.type==="range")return!1;var T=window.getSelection(),B=T&&T.anchorNode,P=B?B===C||B.contains(C):!1;if(P)return!1;var j=tS(N,C);if(!j)return!0;if(j?k=N:(k=N==="v"?"h":"v",j=tS(N,C)),!j)return!1;if(!r.current&&"changedTouches"in v&&(y||w)&&(r.current=k),!k)return!0;var I=r.current||k;return a7(I,b,v,I==="h"?y:w)},[]),l=g.useCallback(function(v){var b=v;if(!(!qo.length||qo[qo.length-1]!==s)){var _="deltaY"in b?nS(b):md(b),x=t.current.filter(function(k){return k.name===b.type&&(k.target===b.target||b.target===k.shadowParent)&&l7(k.delta,_)})[0];if(x&&x.should){b.cancelable&&b.preventDefault();return}if(!x){var y=(o.current.shards||[]).map(rS).filter(Boolean).filter(function(k){return k.contains(b.target)}),w=y.length>0?a(b,y[0]):!o.current.noIsolation;w&&b.cancelable&&b.preventDefault()}}},[]),c=g.useCallback(function(v,b,_,x){var y={name:v,delta:b,target:_,should:x,shadowParent:h7(_)};t.current.push(y),setTimeout(function(){t.current=t.current.filter(function(w){return w!==y})},1)},[]),u=g.useCallback(function(v){n.current=md(v),r.current=void 0},[]),d=g.useCallback(function(v){c(v.type,nS(v),v.target,a(v,e.lockRef.current))},[]),f=g.useCallback(function(v){c(v.type,md(v),v.target,a(v,e.lockRef.current))},[]);g.useEffect(function(){return qo.push(s),e.setCallbacks({onScrollCapture:d,onWheelCapture:d,onTouchMoveCapture:f}),document.addEventListener("wheel",l,Vo),document.addEventListener("touchmove",l,Vo),document.addEventListener("touchstart",u,Vo),function(){qo=qo.filter(function(v){return v!==s}),document.removeEventListener("wheel",l,Vo),document.removeEventListener("touchmove",l,Vo),document.removeEventListener("touchstart",u,Vo)}},[]);var p=e.removeScrollBar,m=e.inert;return g.createElement(g.Fragment,null,m?g.createElement(s,{styles:c7(i)}):null,p?g.createElement(e7,{noRelative:e.noRelative,gapMode:e.gapMode}):null)}function h7(e){for(var t=null;e!==null;)e instanceof ShadowRoot&&(t=e.host,e=e.host),e=e.parentNode;return t}const f7=F9(GP,d7);var Qx=g.forwardRef(function(e,t){return g.createElement(lp,Yr({},e,{ref:t,sideCar:f7}))});Qx.classNames=lp.classNames;var m0=["Enter"," "],p7=["ArrowDown","PageUp","Home"],JP=["ArrowUp","PageDown","End"],m7=[...p7,...JP],g7={ltr:[...m0,"ArrowRight"],rtl:[...m0,"ArrowLeft"]},v7={ltr:["ArrowLeft"],rtl:["ArrowRight"]},yu="Menu",[Xc,_7,x7]=lP(yu),[Lo,eI]=Ao(yu,[x7,ap,zP]),bu=ap(),tI=zP(),[nI,js]=Lo(yu),[y7,wu]=Lo(yu),rI=e=>{const{__scopeMenu:t,open:n=!1,children:r,dir:i,onOpenChange:s,modal:o=!0}=e,a=bu(t),[l,c]=g.useState(null),u=g.useRef(!1),d=li(s),f=cP(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(Yx,{...a,children:h.jsx(nI,{scope:t,open:n,onOpenChange:d,content:l,onContentChange:c,children:h.jsx(y7,{scope:t,onClose:g.useCallback(()=>d(!1),[d]),isUsingKeyboardRef:u,dir:f,modal:o,children:r})})})};rI.displayName=yu;var b7="MenuAnchor",Jx=g.forwardRef((e,t)=>{const{__scopeMenu:n,...r}=e,i=bu(n);return h.jsx(jP,{...i,...r,ref:t})});Jx.displayName=b7;var ey="MenuPortal",[w7,iI]=Lo(ey,{forceMount:void 0}),sI=e=>{const{__scopeMenu:t,forceMount:n,children:r,container:i}=e,s=js(ey,t);return h.jsx(w7,{scope:t,forceMount:n,children:h.jsx(Hi,{present:n||s.open,children:h.jsx(Zx,{asChild:!0,container:i,children:r})})})};sI.displayName=ey;var gr="MenuContent",[S7,ty]=Lo(gr),oI=g.forwardRef((e,t)=>{const n=iI(gr,e.__scopeMenu),{forceMount:r=n.forceMount,...i}=e,s=js(gr,e.__scopeMenu),o=wu(gr,e.__scopeMenu);return h.jsx(Xc.Provider,{scope:e.__scopeMenu,children:h.jsx(Hi,{present:r||s.open,children:h.jsx(Xc.Slot,{scope:e.__scopeMenu,children:o.modal?h.jsx(k7,{...i,ref:t}):h.jsx(C7,{...i,ref:t})})})})}),k7=g.forwardRef((e,t)=>{const n=js(gr,e.__scopeMenu),r=g.useRef(null),i=Kt(t,r);return g.useEffect(()=>{const s=r.current;if(s)return VP(s)},[]),h.jsx(ny,{...e,ref:i,trapFocus:n.open,disableOutsidePointerEvents:n.open,disableOutsideScroll:!0,onFocusOutside:Pe(e.onFocusOutside,s=>s.preventDefault(),{checkForDefaultPrevented:!1}),onDismiss:()=>n.onOpenChange(!1)})}),C7=g.forwardRef((e,t)=>{const n=js(gr,e.__scopeMenu);return h.jsx(ny,{...e,ref:t,trapFocus:!1,disableOutsidePointerEvents:!1,disableOutsideScroll:!1,onDismiss:()=>n.onOpenChange(!1)})}),E7=Kc("MenuContent.ScrollLock"),ny=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=js(gr,n),_=wu(gr,n),x=bu(n),y=tI(n),w=_7(n),[k,C]=g.useState(null),N=g.useRef(null),T=Kt(t,N,b.onContentChange),B=g.useRef(0),P=g.useRef(""),j=g.useRef(0),I=g.useRef(null),R=g.useRef("right"),L=g.useRef(0),z=m?Qx:g.Fragment,$=m?{as:E7,allowPinchZoom:!0}:void 0,F=O=>{var ye,$e;const E=P.current+O,H=w().filter(ue=>!ue.disabled),V=document.activeElement,A=(ye=H.find(ue=>ue.ref.current===V))==null?void 0:ye.textValue,ne=H.map(ue=>ue.textValue),oe=B7(ne,E,A),X=($e=H.find(ue=>ue.textValue===oe))==null?void 0:$e.ref.current;(function ue(Ie){P.current=Ie,window.clearTimeout(B.current),Ie!==""&&(B.current=window.setTimeout(()=>ue(""),1e3))})(E),X&&setTimeout(()=>X.focus())};g.useEffect(()=>()=>window.clearTimeout(B.current),[]),hP();const D=g.useCallback(O=>{var H,V;return R.current===((H=I.current)==null?void 0:H.side)&&$7(O,(V=I.current)==null?void 0:V.area)},[]);return h.jsx(S7,{scope:n,searchRef:P,onItemEnter:g.useCallback(O=>{D(O)&&O.preventDefault()},[D]),onItemLeave:g.useCallback(O=>{var E;D(O)||((E=N.current)==null||E.focus(),C(null))},[D]),onTriggerLeave:g.useCallback(O=>{D(O)&&O.preventDefault()},[D]),pointerGraceTimerRef:j,onPointerGraceIntentChange:g.useCallback(O=>{I.current=O},[]),children:h.jsx(z,{...$,children:h.jsx(Fx,{asChild:!0,trapped:i,onMountAutoFocus:Pe(s,O=>{var E;O.preventDefault(),(E=N.current)==null||E.focus({preventScroll:!0})}),onUnmountAutoFocus:o,children:h.jsx(np,{asChild:!0,disableOutsidePointerEvents:a,onEscapeKeyDown:c,onPointerDownOutside:u,onFocusOutside:d,onInteractOutside:f,onDismiss:p,children:h.jsx(N9,{asChild:!0,...y,dir:_.dir,orientation:"vertical",loop:r,currentTabStopId:k,onCurrentTabStopIdChange:C,onEntryFocus:Pe(l,O=>{_.isUsingKeyboardRef.current||O.preventDefault()}),preventScrollOnEntryFocus:!0,children:h.jsx(DP,{role:"menu","aria-orientation":"vertical","data-state":SI(b.open),"data-radix-menu-content":"",dir:_.dir,...x,...v,ref:T,style:{outline:"none",...v.style},onKeyDown:Pe(v.onKeyDown,O=>{const H=O.target.closest("[data-radix-menu-content]")===O.currentTarget,V=O.ctrlKey||O.altKey||O.metaKey,A=O.key.length===1;H&&(O.key==="Tab"&&O.preventDefault(),!V&&A&&F(O.key));const ne=N.current;if(O.target!==ne||!m7.includes(O.key))return;O.preventDefault();const X=w().filter(ye=>!ye.disabled).map(ye=>ye.ref.current);JP.includes(O.key)&&X.reverse(),D7(X)}),onBlur:Pe(e.onBlur,O=>{O.currentTarget.contains(O.target)||(window.clearTimeout(B.current),P.current="")}),onPointerMove:Pe(e.onPointerMove,Yc(O=>{const E=O.target,H=L.current!==O.clientX;if(O.currentTarget.contains(E)&&H){const V=O.clientX>L.current?"right":"left";R.current=V,L.current=O.clientX}}))})})})})})})});oI.displayName=gr;var N7="MenuGroup",ry=g.forwardRef((e,t)=>{const{__scopeMenu:n,...r}=e;return h.jsx(Tt.div,{role:"group",...r,ref:t})});ry.displayName=N7;var T7="MenuLabel",aI=g.forwardRef((e,t)=>{const{__scopeMenu:n,...r}=e;return h.jsx(Tt.div,{...r,ref:t})});aI.displayName=T7;var Zh="MenuItem",iS="menu.itemSelect",cp=g.forwardRef((e,t)=>{const{disabled:n=!1,onSelect:r,...i}=e,s=g.useRef(null),o=wu(Zh,e.__scopeMenu),a=ty(Zh,e.__scopeMenu),l=Kt(t,s),c=g.useRef(!1),u=()=>{const d=s.current;if(!n&&d){const f=new CustomEvent(iS,{bubbles:!0,cancelable:!0});d.addEventListener(iS,p=>r==null?void 0:r(p),{once:!0}),aP(d,f),f.defaultPrevented?c.current=!1:o.onClose()}};return h.jsx(lI,{...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===" "||m0.includes(d.key)&&(d.currentTarget.click(),d.preventDefault())})})});cp.displayName=Zh;var lI=g.forwardRef((e,t)=>{const{__scopeMenu:n,disabled:r=!1,textValue:i,...s}=e,o=ty(Zh,n),a=tI(n),l=g.useRef(null),c=Kt(t,l),[u,d]=g.useState(!1),[f,p]=g.useState("");return g.useEffect(()=>{const m=l.current;m&&p((m.textContent??"").trim())},[s.children]),h.jsx(Xc.ItemSlot,{scope:n,disabled:r,textValue:i??f,children:h.jsx(T9,{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,Yc(m=>{r?o.onItemLeave(m):(o.onItemEnter(m),m.defaultPrevented||m.currentTarget.focus({preventScroll:!0}))})),onPointerLeave:Pe(e.onPointerLeave,Yc(m=>o.onItemLeave(m))),onFocus:Pe(e.onFocus,()=>d(!0)),onBlur:Pe(e.onBlur,()=>d(!1))})})})}),P7="MenuCheckboxItem",cI=g.forwardRef((e,t)=>{const{checked:n=!1,onCheckedChange:r,...i}=e;return h.jsx(pI,{scope:e.__scopeMenu,checked:n,children:h.jsx(cp,{role:"menuitemcheckbox","aria-checked":Qh(n)?"mixed":n,...i,ref:t,"data-state":oy(n),onSelect:Pe(i.onSelect,()=>r==null?void 0:r(Qh(n)?!0:!n),{checkForDefaultPrevented:!1})})})});cI.displayName=P7;var uI="MenuRadioGroup",[I7,R7]=Lo(uI,{value:void 0,onValueChange:()=>{}}),dI=g.forwardRef((e,t)=>{const{value:n,onValueChange:r,...i}=e,s=li(r);return h.jsx(I7,{scope:e.__scopeMenu,value:n,onValueChange:s,children:h.jsx(ry,{...i,ref:t})})});dI.displayName=uI;var hI="MenuRadioItem",fI=g.forwardRef((e,t)=>{const{value:n,...r}=e,i=R7(hI,e.__scopeMenu),s=n===i.value;return h.jsx(pI,{scope:e.__scopeMenu,checked:s,children:h.jsx(cp,{role:"menuitemradio","aria-checked":s,...r,ref:t,"data-state":oy(s),onSelect:Pe(r.onSelect,()=>{var o;return(o=i.onValueChange)==null?void 0:o.call(i,n)},{checkForDefaultPrevented:!1})})})});fI.displayName=hI;var iy="MenuItemIndicator",[pI,M7]=Lo(iy,{checked:!1}),mI=g.forwardRef((e,t)=>{const{__scopeMenu:n,forceMount:r,...i}=e,s=M7(iy,n);return h.jsx(Hi,{present:r||Qh(s.checked)||s.checked===!0,children:h.jsx(Tt.span,{...i,ref:t,"data-state":oy(s.checked)})})});mI.displayName=iy;var A7="MenuSeparator",gI=g.forwardRef((e,t)=>{const{__scopeMenu:n,...r}=e;return h.jsx(Tt.div,{role:"separator","aria-orientation":"horizontal",...r,ref:t})});gI.displayName=A7;var L7="MenuArrow",vI=g.forwardRef((e,t)=>{const{__scopeMenu:n,...r}=e,i=bu(n);return h.jsx(OP,{...i,...r,ref:t})});vI.displayName=L7;var sy="MenuSub",[j7,_I]=Lo(sy),xI=e=>{const{__scopeMenu:t,children:n,open:r=!1,onOpenChange:i}=e,s=js(sy,t),o=bu(t),[a,l]=g.useState(null),[c,u]=g.useState(null),d=li(i);return g.useEffect(()=>(s.open===!1&&d(!1),()=>d(!1)),[s.open,d]),h.jsx(Yx,{...o,children:h.jsx(nI,{scope:t,open:r,onOpenChange:d,content:c,onContentChange:u,children:h.jsx(j7,{scope:t,contentId:Pi(),triggerId:Pi(),trigger:a,onTriggerChange:l,children:n})})})};xI.displayName=sy;var Kl="MenuSubTrigger",yI=g.forwardRef((e,t)=>{const n=js(Kl,e.__scopeMenu),r=wu(Kl,e.__scopeMenu),i=_I(Kl,e.__scopeMenu),s=ty(Kl,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(Jx,{asChild:!0,...c,children:h.jsx(lI,{id:i.triggerId,"aria-haspopup":"menu","aria-expanded":n.open,"aria-controls":i.contentId,"data-state":SI(n.open),...e,ref:gu(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,Yc(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,Yc(d=>{var p,m;u();const f=(p=n.content)==null?void 0:p.getBoundingClientRect();if(f){const v=(m=n.content)==null?void 0:m.dataset.side,b=v==="right",_=b?-5:5,x=f[b?"left":"right"],y=f[b?"right":"left"];s.onPointerGraceIntentChange({area:[{x:d.clientX+_,y:d.clientY},{x,y:f.top},{x:y,y:f.top},{x:y,y:f.bottom},{x,y:f.bottom}],side:v}),window.clearTimeout(a.current),a.current=window.setTimeout(()=>s.onPointerGraceIntentChange(null),300)}else{if(s.onTriggerLeave(d),d.defaultPrevented)return;s.onPointerGraceIntentChange(null)}})),onKeyDown:Pe(e.onKeyDown,d=>{var p;const f=s.searchRef.current!=="";e.disabled||f&&d.key===" "||g7[r.dir].includes(d.key)&&(n.onOpenChange(!0),(p=n.content)==null||p.focus(),d.preventDefault())})})})});yI.displayName=Kl;var bI="MenuSubContent",wI=g.forwardRef((e,t)=>{const n=iI(gr,e.__scopeMenu),{forceMount:r=n.forceMount,...i}=e,s=js(gr,e.__scopeMenu),o=wu(gr,e.__scopeMenu),a=_I(bI,e.__scopeMenu),l=g.useRef(null),c=Kt(t,l);return h.jsx(Xc.Provider,{scope:e.__scopeMenu,children:h.jsx(Hi,{present:r||s.open,children:h.jsx(Xc.Slot,{scope:e.__scopeMenu,children:h.jsx(ny,{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=v7[o.dir].includes(u.key);d&&f&&(s.onOpenChange(!1),(p=a.trigger)==null||p.focus(),u.preventDefault())})})})})})});wI.displayName=bI;function SI(e){return e?"open":"closed"}function Qh(e){return e==="indeterminate"}function oy(e){return Qh(e)?"indeterminate":e?"checked":"unchecked"}function D7(e){const t=document.activeElement;for(const n of e)if(n===t||(n.focus(),document.activeElement!==t))return}function O7(e,t){return e.map((n,r)=>e[(t+r)%e.length])}function B7(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=O7(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 z7(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 $7(e,t){if(!t)return!1;const n={x:e.clientX,y:e.clientY};return z7(n,t)}function Yc(e){return t=>t.pointerType==="mouse"?e(t):void 0}var F7=rI,H7=Jx,U7=sI,W7=oI,V7=ry,q7=aI,K7=cp,G7=cI,X7=dI,Y7=fI,Z7=mI,Q7=gI,J7=vI,eH=xI,tH=yI,nH=wI,up="DropdownMenu",[rH]=Ao(up,[eI]),wn=eI(),[iH,kI]=rH(up),CI=e=>{const{__scopeDropdownMenu:t,children:n,dir:r,open:i,defaultOpen:s,onOpenChange:o,modal:a=!0}=e,l=wn(t),c=g.useRef(null),[u,d]=vu({prop:i,defaultProp:s??!1,onChange:o,caller:up});return h.jsx(iH,{scope:t,triggerId:Pi(),triggerRef:c,contentId:Pi(),open:u,onOpenChange:d,onOpenToggle:g.useCallback(()=>d(f=>!f),[d]),modal:a,children:h.jsx(F7,{...l,open:u,onOpenChange:d,dir:r,modal:a,children:n})})};CI.displayName=up;var EI="DropdownMenuTrigger",NI=g.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,disabled:r=!1,...i}=e,s=kI(EI,n),o=wn(n);return h.jsx(H7,{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:gu(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())})})})});NI.displayName=EI;var sH="DropdownMenuPortal",TI=e=>{const{__scopeDropdownMenu:t,...n}=e,r=wn(t);return h.jsx(U7,{...r,...n})};TI.displayName=sH;var PI="DropdownMenuContent",II=g.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,i=kI(PI,n),s=wn(n),o=g.useRef(!1);return h.jsx(W7,{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)"}})});II.displayName=PI;var oH="DropdownMenuGroup",aH=g.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,i=wn(n);return h.jsx(V7,{...i,...r,ref:t})});aH.displayName=oH;var lH="DropdownMenuLabel",RI=g.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,i=wn(n);return h.jsx(q7,{...i,...r,ref:t})});RI.displayName=lH;var cH="DropdownMenuItem",MI=g.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,i=wn(n);return h.jsx(K7,{...i,...r,ref:t})});MI.displayName=cH;var uH="DropdownMenuCheckboxItem",AI=g.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,i=wn(n);return h.jsx(G7,{...i,...r,ref:t})});AI.displayName=uH;var dH="DropdownMenuRadioGroup",hH=g.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,i=wn(n);return h.jsx(X7,{...i,...r,ref:t})});hH.displayName=dH;var fH="DropdownMenuRadioItem",pH=g.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,i=wn(n);return h.jsx(Y7,{...i,...r,ref:t})});pH.displayName=fH;var mH="DropdownMenuItemIndicator",LI=g.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,i=wn(n);return h.jsx(Z7,{...i,...r,ref:t})});LI.displayName=mH;var gH="DropdownMenuSeparator",jI=g.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,i=wn(n);return h.jsx(Q7,{...i,...r,ref:t})});jI.displayName=gH;var vH="DropdownMenuArrow",_H=g.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,i=wn(n);return h.jsx(J7,{...i,...r,ref:t})});_H.displayName=vH;var xH=e=>{const{__scopeDropdownMenu:t,children:n,open:r,onOpenChange:i,defaultOpen:s}=e,o=wn(t),[a,l]=vu({prop:r,defaultProp:s??!1,onChange:i,caller:"DropdownMenuSub"});return h.jsx(eH,{...o,open:a,onOpenChange:l,children:n})},yH="DropdownMenuSubTrigger",DI=g.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,i=wn(n);return h.jsx(tH,{...i,...r,ref:t})});DI.displayName=yH;var bH="DropdownMenuSubContent",OI=g.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,i=wn(n);return h.jsx(nH,{...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)"}})});OI.displayName=bH;var wH=CI,SH=NI,BI=TI,zI=II,$I=RI,FI=MI,HI=AI,kH=LI,UI=jI,CH=xH,WI=DI,VI=OI;const ay=wH,ly=SH,dp=g.forwardRef(({className:e,sideOffset:t=4,...n},r)=>h.jsx(BI,{children:h.jsx(zI,{ref:r,sideOffset:t,className:he("z-50 min-w-[8rem] overflow-hidden rounded-md border border-border bg-elevated p-1","text-text-100 shadow-md",e),...n})}));dp.displayName=zI.displayName;const EH=CH,qI=g.forwardRef(({className:e,...t},n)=>h.jsx(WI,{ref:n,className:he("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}));qI.displayName=WI.displayName;const KI=g.forwardRef(({className:e,...t},n)=>h.jsx(BI,{children:h.jsx(VI,{ref:n,className:he("z-50 min-w-[6rem] overflow-hidden rounded-md border border-border bg-elevated p-1","text-text-100 shadow-md",e),...t})}));KI.displayName=VI.displayName;const bi=g.forwardRef(({className:e,inset:t,...n},r)=>h.jsx(FI,{ref:r,className:he("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}));bi.displayName=FI.displayName;const NH=g.forwardRef(({className:e,children:t,checked:n,...r},i)=>h.jsxs(HI,{ref:i,checked:n,className:he("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(kH,{children:h.jsx(cl,{className:"h-3.5 w-3.5"})})}),t]}));NH.displayName=HI.displayName;const GI=g.forwardRef(({className:e,...t},n)=>h.jsx(UI,{ref:n,className:he("-mx-1 my-1 h-px bg-border",e),...t}));GI.displayName=UI.displayName;const TH=g.forwardRef(({className:e,...t},n)=>h.jsx($I,{ref:n,className:he("px-2 py-1.5 text-xs font-semibold text-text-400",e),...t}));TH.displayName=$I.displayName;function PH({tool:e,className:t}){const n=b8(e);return h.jsx("span",{"data-testid":n?`session-icon-${e}`:"session-icon-default","aria-label":n?$x(e):"未知引擎",className:he("w-3.5 h-3.5 shrink-0 inline-flex items-center justify-center",tp(e),t),children:h.jsx(ep,{tool:e,className:"w-full h-full"})})}function XI(e){return e.compositionActive||!!e.nativeIsComposing||e.keyCode===229}function YI(e){return e.key==="Enter"&&!e.shiftKey&&!XI(e)}function Su(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(YI({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 IH({open:e,initialLabel:t,placeholder:n,onSubmit:r,onCancel:i}){const[s,o]=g.useState(t);g.useEffect(()=>{e&&o(t)},[e,t]);const a=Su(()=>r({label:s.trim()}),i);return e?Ja.createPortal(h.jsx("div",{className:"fixed inset-0 z-[10000] flex items-center justify-center bg-bg-0/40 backdrop-blur-[2px]",onClick:i,"data-testid":"session-edit-dialog-overlay",children:h.jsxs("div",{"data-testid":"session-edit-dialog",className:"w-[420px] max-w-[calc(100vw-32px)] rounded-2xl border border-text-100/[0.12] flex flex-col gap-4 p-5",style:{backgroundColor:"var(--bg-0)",boxShadow:"0 12px 40px rgba(0,0,0,0.04)"},onClick:l=>l.stopPropagation(),children:[h.jsx("div",{className:"text-[15px] font-semibold text-text-100",children:"Edit session"}),h.jsxs("div",{children:[h.jsx("label",{className:"block text-[12px] font-semibold text-text-200 mb-1",children:"Label"}),h.jsx("input",{autoFocus:!0,type:"text",value:s,onChange:l=>o(l.target.value),...a,placeholder:n,"data-testid":"session-edit-dialog-label",className:"w-full px-3 py-2 text-[13px] bg-bg-50 border border-bg-300 rounded-lg focus:outline-none focus:border-text-300 transition-colors"})]}),h.jsxs("div",{className:"flex justify-end gap-2 pt-1",children:[h.jsx("button",{type:"button",onClick:i,className:"px-4 py-1.5 text-[12px] text-text-300 rounded-lg hover:bg-text-100/5 transition-colors cursor-pointer",children:"Cancel"}),h.jsx("button",{type:"button",onClick:()=>r({label:s.trim()}),"data-testid":"session-edit-dialog-save",className:"px-4 py-1.5 text-[12px] font-medium text-bg-0 rounded-lg bg-text-100 hover:bg-text-200 transition-colors cursor-pointer",children:"Save"})]})]})}),document.body):null}const RH=10,MH=20,AH=16,LH=20,jH=60,DH=4;function OH({session:e,active:t,hasUnread:n,running:r=!1,awaitingUser:i=!1,onSelect:s,onEdit:o,onDelete:a,onPin:l,onArchive:c,archiveShortcut:u=!1,depth:d=0,chevron:f,showCopyResume:p=!0,contactDisplayName:m}){const[v,b]=g.useState(!1),_=!!e.pinnedAt,x=d===0,y=d===0&&!!c,w=RH+d*MH,k=g.useCallback(async()=>{const B=sP(e);if(B)try{await navigator.clipboard.writeText(B)}catch{}},[e]),C=e.appBuilderProject?`[app] ${e.appBuilderProject}`:e.label||e.larkChatName||e.larkChatId||e.cwd.split("/").filter(Boolean).pop()||e.sessionId.slice(0,8),N=e.originOwnerPrincipalId,T=N?`@${m??`…${N.slice(-8)}`}`:null;return h.jsxs(h.Fragment,{children:[h.jsxs("div",{"data-testid":`session-item-${e.sessionId}`,onClick:s,style:{paddingLeft:w,display:"grid",gridTemplateColumns:`${AH}px ${LH}px 1fr auto ${jH}px`,gridTemplateAreas:'"chev icon name dot time"',columnGap:`${DH}px`,alignItems:"center"},className:he("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(PH,{tool:e.tool})}),h.jsxs("div",{style:{gridArea:"name"},className:"flex items-center gap-1 min-w-0",children:[e.dispatchedFromSessionId?h.jsx(xz,{"data-testid":`dispatched-icon-${e.sessionId}`,className:"w-3 h-3 text-accent shrink-0",strokeWidth:2.25,"aria-label":"dispatched from another session",children:h.jsx("title",{children:"由另一个 session dispatch 派生"})}):null,e.shiftFiredFromSessionId?h.jsx(KB,{"data-testid":`shift-fired-icon-${e.sessionId}`,className:"w-3 h-3 text-accent shrink-0",strokeWidth:2.25,"aria-label":"fired by clawd-shift scheduler",children:h.jsx("title",{children:"由 shift 排班到点 fire 派生"})}):null,e.larkChatId?h.jsx(Vz,{"data-testid":`lark-chat-icon-${e.sessionId}`,className:"w-3 h-3 text-accent shrink-0",strokeWidth:2.25,"aria-label":"driven by feishu chat",children:h.jsx("title",{children:e.larkChatType==="p2p"?"飞书私聊会话(对方消息驱动)":"飞书群会话(群成员 @ bot 驱动)"})}):null,h.jsx("span",{"data-testid":`session-title-${e.sessionId}`,className:he("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:C}),T?h.jsx("span",{"data-testid":`session-mirror-chip-${e.sessionId}`,title:`在 ${T.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:T}):null]}),i?h.jsx(ez,{"data-testid":`awaiting-dot-${e.sessionId}`,style:{gridArea:"dot"},className:"w-3 h-3 text-warning shrink-0 animate-pulse",strokeWidth:2.25,"aria-label":"awaiting user"}):n?h.jsx("span",{"data-testid":`unread-dot-${e.sessionId}`,style:{gridArea:"dot"},className:"w-2 h-2 rounded-full bg-error shrink-0","aria-label":"unread"}):r?h.jsx("span",{"data-testid":`running-dot-${e.sessionId}`,style:{gridArea:"dot"},className:"w-2 h-2 rounded-full bg-success shrink-0 animate-pulse","aria-label":"running"}):null,h.jsx("span",{style:{gridArea:"time"},className:he("text-[11px] text-text-400/70 text-right shrink-0","transition-opacity duration-150 group-hover:opacity-0"),children:e.updatedAt?w8(e.updatedAt):""}),o||a||l||c?h.jsxs("div",{className:"absolute right-2 top-[3px] flex items-center opacity-0 group-hover:opacity-100 data-[state=open]:opacity-100 transition-opacity",children:[u&&y&&c?h.jsx("button",{type:"button",title:"归档",onClick:B=>{B.stopPropagation(),c(e.sessionId,!0)},className:"flex items-center justify-center w-7 h-7 rounded-md text-text-400 hover:text-text-100 hover:bg-text-100/5 transition-colors cursor-pointer","aria-label":"archive session","data-testid":`archive-shortcut-${e.sessionId}`,children:h.jsx(Cw,{className:"w-4 h-4"})}):null,h.jsxs(ay,{modal:!1,children:[h.jsx(ly,{asChild:!0,children:h.jsx("button",{type:"button",onClick:B=>B.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(jT,{className:"w-4 h-4"})})}),h.jsxs(dp,{align:"end",onClick:B=>B.stopPropagation(),children:[l&&x&&h.jsxs(bi,{onSelect:()=>l(e.sessionId,!_),"data-testid":`session-${_?"unpin":"pin"}-${e.sessionId}`,children:[_?h.jsx(e$,{className:"w-3 h-3 mr-2 text-text-400"}):h.jsx(n$,{className:"w-3 h-3 mr-2 text-text-400"}),_?"Unpin":"Pin"]}),y&&c&&h.jsxs(bi,{onSelect:()=>c(e.sessionId,!0),"data-testid":`session-archive-${e.sessionId}`,children:[h.jsx(Cw,{className:"w-3 h-3 mr-2 text-text-400"}),"Archive"]}),o&&h.jsxs(bi,{onSelect:()=>b(!0),"data-testid":`session-rename-${e.sessionId}`,children:[h.jsx(BT,{className:"w-3 h-3 mr-2 text-text-400"}),"Rename"]}),p&&e.toolSessionId?h.jsxs(bi,{onSelect:()=>void k(),"data-testid":`session-copy-resume-${e.sessionId}`,children:[h.jsx(Jf,{className:"w-3 h-3 mr-2 text-text-400"}),"Copy Resume Command"]}):null,(l||o||p&&e.toolSessionId)&&a&&h.jsx(GI,{}),a&&h.jsxs(bi,{onSelect:()=>void a(e.sessionId),className:"text-destructive focus:text-destructive focus:bg-destructive/10","data-testid":`session-delete-${e.sessionId}`,children:[h.jsx(Ox,{className:"w-3 h-3 mr-2"}),"Delete"]})]})]})]}):null]}),o?h.jsx(IH,{open:v,initialLabel:e.label??"",placeholder:e.cwd.split("/").pop()||"",onSubmit:B=>{o(e.sessionId,B),b(!1)},onCancel:()=>b(!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,archiveShortcut:d,getContactDisplayName:f,showCopyResume:p}){const m=e.children.length>0,{isCollapsed:v,toggle:b}=$B(),_=!v(e.session.sessionId),x=g.useCallback(w=>{w.stopPropagation(),b(e.session.sessionId)},[b,e.session.sessionId]),y=m?h.jsx("button",{type:"button",onClick:x,"data-testid":`session-chevron-${e.session.sessionId}`,"aria-label":_?"collapse":"expand","aria-expanded":_,className:"shrink-0 flex items-center justify-center w-4 h-4 text-text-400 hover:text-text-100 cursor-pointer",children:_?h.jsx(ir,{className:"w-3 h-3"}):h.jsx(Un,{className:"w-3 h-3"})}):null;return h.jsxs("div",{"data-testid":`session-tree-node-${e.session.sessionId}`,children:[h.jsx(OH,{session:e.session,active:n===e.session.sessionId,hasUnread:(r==null?void 0:r.has(e.session.sessionId))??!1,running:(i==null?void 0:i.has(e.session.sessionId))??!1,awaitingUser:(s==null?void 0:s.has(e.session.sessionId))??!1,onSelect:()=>o(e.session.sessionId),onEdit:a,onDelete:l,onPin:c,onArchive:u,archiveShortcut:d,showCopyResume:p,depth:t,chevron:y,contactDisplayName:e.session.originOwnerPrincipalId?f==null?void 0:f(e.session.originOwnerPrincipalId):void 0}),m&&_?h.jsx("div",{"data-testid":`session-tree-children-${e.session.sessionId}`,children:e.children.map(w=>h.jsx(cy,{node:w,depth:t+1,activeId:n,unreadIds:r,runningIds:i,awaitingIds:s,onSelect:o,onEdit:a,onDelete:l,onPin:c,onArchive:u,archiveShortcut:d,getContactDisplayName:f,showCopyResume:p},w.session.sessionId))}):null]})}function BH(e){return e.forkedFromSessionId??e.dispatchedFromSessionId??e.shiftFiredFromSessionId}function ZI(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=BH(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(zH).map(i)}function QI(e){return[...e].sort((t,n)=>t.session.updatedAt<n.session.updatedAt?1:t.session.updatedAt>n.session.updatedAt?-1:0)}function zH(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 $H(e){return e.appBuilderProject?`[app] ${e.appBuilderProject}`:e.label?e.label:e.cwd.split("/").filter(Boolean).pop()??""}function sS(e,t){const n=t.trim().toLowerCase();return n===""?!0:e.toLowerCase().includes(n)}const FH={isCollapsed:()=>!1,toggle:()=>{},prune:()=>{}};function HH({personas:e,activePersonaId:t,onSelectPersona:n,onCreateSession:r,sessions:i,activeSessionId:s,awaitingIds:o,runningIds:a,unreadIds:l,onSelectSession:c,onDeleteSession:u,ownerPrincipalId:d,creatorDisplayNameByOwnerId:f,isPersonaExpanded:p,onTogglePersonaExpanded:m,onEditSession:v,onPinSession:b,showCopyResume:_,treatSessionsAsRoots:x,searchQuery:y}){const[w,k]=g.useState(null),[C,N]=g.useState(()=>new Set),T=p??(I=>C.has(I)),B=g.useCallback(I=>{if(m){m(I);return}N(R=>{const L=new Set(R);return L.has(I)?L.delete(I):L.add(I),L})},[m]),P=g.useMemo(()=>i==null?void 0:i.filter(I=>!I.ephemeral),[i]);if(e.length===0)return h.jsx(UH,{});const j=(y??"").trim();return j?h.jsx(Lx.Provider,{value:FH,children:h.jsx("div",{"data-testid":"my-personas-list",className:"flex flex-col gap-0.5",children:e.map(I=>{const R=P?P.filter(F=>F.ownerPersonaId===I.personaId).sort((F,D)=>D.updatedAt>F.updatedAt?1:-1):[],L=sS(I.label,j),z=R.filter(F=>sS($H(F),j));if(!L&&z.length===0)return null;const $=L?R:z;return h.jsx(oS,{persona:I,active:I.personaId===t,editing:!1,onSelectPersona:n,onSubmitCreateSession:()=>{},onCancelCreateSession:()=>{},personaSessions:$,collapsed:!1,onToggleCollapsed:()=>{},activeSessionId:s??null,awaitingIds:o,runningIds:a,unreadIds:l,onSelectSession:c,onDeleteSession:u,onEditSession:v,onPinSession:b,showCopyResume:_,treatSessionsAsRoots:x,ownerPrincipalId:d,creatorDisplayNameByOwnerId:f},I.personaId)})})}):h.jsx("div",{"data-testid":"my-personas-list",className:"flex flex-col gap-0.5",children:e.map(I=>{const R=P?P.filter(L=>L.ownerPersonaId===I.personaId).sort((L,z)=>z.updatedAt>L.updatedAt?1:-1):[];return h.jsx(oS,{persona:I,active:I.personaId===t,editing:I.personaId===w,onSelectPersona:n,onStartCreateSession:r?()=>k(I.personaId):void 0,onSubmitCreateSession:L=>{k(null),r==null||r(I.personaId,L)},onCancelCreateSession:()=>k(null),personaSessions:R,collapsed:!T(I.personaId),onToggleCollapsed:()=>B(I.personaId),activeSessionId:s??null,awaitingIds:o,runningIds:a,unreadIds:l,onSelectSession:c,onDeleteSession:u,onEditSession:v,onPinSession:b,showCopyResume:_,treatSessionsAsRoots:x,ownerPrincipalId:d,creatorDisplayNameByOwnerId:f},I.personaId)})})}function UH(){return h.jsx("div",{className:"px-3 py-3 text-[11px] leading-relaxed text-text-400",children:"还没有 persona。点上方 Personas 标题右侧 + 创建第一个。"})}function oS({persona:e,active:t,editing:n,onSelectPersona:r,onStartCreateSession:i,onSubmitCreateSession:s,onCancelCreateSession:o,personaSessions:a,collapsed:l,onToggleCollapsed:c,activeSessionId:u,awaitingIds:d,runningIds:f,unreadIds:p,onSelectSession:m,onDeleteSession:v,onEditSession:b,onPinSession:_,showCopyResume:x,treatSessionsAsRoots:y,ownerPrincipalId:w,creatorDisplayNameByOwnerId:k}){const C=a.length>0,N=!l,T=g.useMemo(()=>{const j=[],I=new Map;for(const R of a){const L=R.creatorPrincipalId;if(R.larkChatId!=null||!L||w&&L===w){j.push(R);continue}const z=L,$=(k==null?void 0:k.get(z))??`…${z.slice(-8)}`,F=I.get(z);F?F.sessions.push(R):I.set(z,{groupKey:z,displayName:$,sessions:[R]})}return{self:j,byPeer:[...I.values()]}},[a,w,k]),B=T.byPeer.length>0,P=g.useMemo(()=>N&&!B?QI(ZI(a)):[],[N,B,a]);return h.jsxs("div",{"data-testid":`persona-node-${e.personaId}`,children:[h.jsxs("div",{className:he("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:[C?h.jsx("button",{type:"button",onClick:j=>{j.stopPropagation(),c()},"aria-label":N?"collapse":"expand","aria-expanded":N,"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:N?h.jsx(ir,{className:"h-3 w-3"}):h.jsx(Un,{className:"h-3 w-3"})}):h.jsx("span",{className:"h-4 w-4 shrink-0","aria-hidden":"true"}),h.jsx(ep,{tool:e.tool,className:he("h-3.5 w-3.5 shrink-0",tp(e.tool))}),h.jsx("span",{className:"flex-1 truncate text-[13px]",children:e.label}),C?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:j=>{j.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(o$,{className:"h-3.5 w-3.5"})}):null]}),n?h.jsx(WH,{personaId:e.personaId,tool:e.tool,onSubmit:s,onCancel:o}):null,C&&N?h.jsx("div",{"data-testid":`persona-sessions-${e.personaId}`,children:B?h.jsxs(h.Fragment,{children:[T.self.length>0&&h.jsx(aS,{groupKey:`${e.personaId}-self`,label:"我自己",testId:`persona-sessions-${e.personaId}-self`,sessions:T.self,activeSessionId:u,awaitingIds:d,runningIds:f,unreadIds:p,onSelectSession:m,onDeleteSession:v,onEditSession:b,onPinSession:_,showCopyResume:x}),T.byPeer.map(j=>h.jsx(aS,{groupKey:`${e.personaId}-peer-${j.groupKey}`,label:j.displayName,testId:`persona-sessions-${e.personaId}-peer-${j.groupKey}`,sessions:j.sessions,activeSessionId:u,awaitingIds:d,runningIds:f,unreadIds:p,onSelectSession:m,onDeleteSession:v,onEditSession:b,onPinSession:_,showCopyResume:x},`${e.personaId}-peer-${j.groupKey}`))]}):P.map(j=>h.jsx(cy,{node:j,depth:y?0:1,activeId:u,unreadIds:p,runningIds:f,awaitingIds:d,onSelect:I=>m==null?void 0:m(I),onDelete:v,onEdit:b,onPin:_,showCopyResume:x},j.session.sessionId))}):null]})}function aS({label:e,testId:t,sessions:n,activeSessionId:r,awaitingIds:i,runningIds:s,unreadIds:o,onSelectSession:a,onDeleteSession:l,onEditSession:c,onPinSession:u,showCopyResume:d}){const[f,p]=g.useState(!1),m=!f,v=g.useMemo(()=>m?QI(ZI(n)):[],[m,n]);return h.jsxs("div",{"data-testid":t,children:[h.jsxs("button",{type:"button",onClick:()=>p(b=>!b),"aria-label":m?"collapse":"expand","aria-expanded":m,"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:[m?h.jsx(ir,{className:"h-3 w-3"}):h.jsx(Un,{className:"h-3 w-3"}),h.jsx(FT,{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})]}),m&&h.jsx("div",{children:v.map(b=>h.jsx(cy,{node:b,depth:2,activeId:r,unreadIds:o,runningIds:s,awaitingIds:i,onSelect:_=>a==null?void 0:a(_),onDelete:l,onEdit:c,onPin:u,showCopyResume:d},b.session.sessionId))})]})}function WH({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=Su(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(ep,{tool:t,className:he("h-3 w-3 shrink-0",tp(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(cl,{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(Br,{className:"h-3 w-3"})})]})}function VH(e,t){const n=getComputedStyle(e),r=parseFloat(n.fontSize);return t*r}function qH(e,t){const n=getComputedStyle(e.ownerDocument.documentElement),r=parseFloat(n.fontSize);return t*r}function KH(e){return e/100*window.innerHeight}function GH(e){return e/100*window.innerWidth}function XH(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 Gl({groupSize:e,panelElement:t,styleProp:n}){let r;const[i,s]=XH(n);switch(s){case"%":{r=i/100*e;break}case"px":{r=i;break}case"rem":{r=qH(t,i);break}case"em":{r=VH(t,i);break}case"vh":{r=KH(i);break}case"vw":{r=GH(i);break}}return r}function Nn(e){return parseFloat(e.toFixed(3))}function Fa({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 g0(e){const{panels:t}=e,n=Fa({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=Gl({groupSize:n,panelElement:i,styleProp:s.collapsedSize});o=Nn(u/n*100)}let a;if(s.defaultSize!==void 0){const u=Gl({groupSize:n,panelElement:i,styleProp:s.defaultSize});a=Nn(u/n*100)}let l=0;if(s.minSize!==void 0){const u=Gl({groupSize:n,panelElement:i,styleProp:s.minSize});l=Nn(u/n*100)}let c=100;if(s.maxSize!==void 0){const u=Gl({groupSize:n,panelElement:i,styleProp:s.maxSize});c=Nn(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 v0(e,t){return Array.from(t).sort(e==="horizontal"?YH:ZH)}function YH(e,t){const n=e.element.offsetLeft-t.element.offsetLeft;return n!==0?n:e.element.offsetWidth-t.element.offsetWidth}function ZH(e,t){const n=e.element.offsetTop-t.element.offsetTop;return n!==0?n:e.element.offsetHeight-t.element.offsetHeight}function JI(e){return e!==null&&typeof e=="object"&&"nodeType"in e&&e.nodeType===Node.ELEMENT_NODE}function eR(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 QH({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}=eR(r,o),c=e==="horizontal"?a:l;c<s&&(s=c,i=o)}return rt(i,"No rect found"),i}let gd;function JH(){return gd===void 0&&(typeof matchMedia=="function"?gd=!!matchMedia("(pointer:coarse)").matches:gd=!1),gd}function tR(e){const{element:t,orientation:n,panels:r,separators:i}=e,s=v0(n,Array.from(t.children).filter(JI).map(m=>({element:m}))).map(({element:m})=>m),o=[];let a=!1,l=!1,c=-1,u=-1,d=0,f,p=[];{let m=-1;for(const v of s)v.hasAttribute("data-panel")&&(m++,v.hasAttribute("data-disabled")||(d++,c===-1&&(c=m),u=m))}if(d>1){let m=-1;for(const v of s)if(v.hasAttribute("data-panel")){m++;const b=r.find(_=>_.element===v);if(b){if(f){const _=f.element.getBoundingClientRect(),x=v.getBoundingClientRect();let y;if(l){const w=n==="horizontal"?new DOMRect(_.right,_.top,0,_.height):new DOMRect(_.left,_.bottom,_.width,0),k=n==="horizontal"?new DOMRect(x.left,x.top,0,x.height):new DOMRect(x.left,x.top,x.width,0);switch(p.length){case 0:{y=[w,k];break}case 1:{const C=p[0],N=QH({orientation:n,rects:[_,x],targetRect:C.element.getBoundingClientRect()});y=[C,N===_?k:w];break}default:{y=p;break}}}else p.length?y=p:y=[n==="horizontal"?new DOMRect(_.right,x.top,x.left-_.right,x.height):new DOMRect(x.left,_.bottom,x.width,x.top-_.bottom)];for(const w of y){let k="width"in w?w:w.element.getBoundingClientRect();const C=JH()?e.resizeTargetMinimumSize.coarse:e.resizeTargetMinimumSize.fine;if(k.width<C){const T=C-k.width;k=new DOMRect(k.x-T/2,k.y,k.width+T,k.height)}if(k.height<C){const T=C-k.height;k=new DOMRect(k.x,k.y-T/2,k.width,k.height+T)}const N=m<=c||m>u;!a&&!N&&o.push({group:e,groupSize:Fa({group:e}),panels:[f,b],separator:"width"in w?void 0:w,rect:k}),a=!1}}l=!1,f=b,p=[]}}else if(v.hasAttribute("data-separator")){v.ariaDisabled!==null&&(a=!0);const b=i.find(_=>_.element===v);b?p.push(b):(f=void 0,p=[])}else l=!0}return o}var ls;class nR{constructor(){f1(this,ls,{})}addListener(t,n){const r=bl(this,ls)[t];return r===void 0?bl(this,ls)[t]=[n]:r.includes(n)||r.push(n),()=>{this.removeListener(t,n)}}emit(t,n){const r=bl(this,ls)[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(){p1(this,ls,{})}removeListener(t,n){const r=bl(this,ls)[t];if(r!==void 0){const i=r.indexOf(n);i>=0&&r.splice(i,1)}}}ls=new WeakMap;let Ca={cursorFlags:0,state:"inactive"};const uy=new nR;function xo(){return Ca}function eU(e){return uy.addListener("change",e)}function tU(e){const t=Ca,n={...Ca};n.cursorFlags=e,Ca=n,uy.emit("change",{prev:t,next:n})}function Ea(e){const t=Ca;Ca=e,uy.emit("change",{prev:t,next:e})}const nU=e=>e,Om=()=>{},rR=1,iR=2,sR=4,oR=8,lS=3,cS=12;let vd;function uS(){return vd===void 0&&(vd=!1,typeof window<"u"&&(window.navigator.userAgent.includes("Chrome")||window.navigator.userAgent.includes("Firefox"))&&(vd=!0)),vd}function rU({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&&uS()){const s=(e&rR)!==0,o=(e&iR)!==0,a=(e&sR)!==0,l=(e&oR)!==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 uS()?r>0&&i>0?"move":r>0?"ew-resize":"ns-resize":r>0&&i>0?"grab":r>0?"col-resize":"row-resize"}}const dS=new WeakMap;function dy(e){if(e.defaultView===null||e.defaultView===void 0)return;let{prevStyle:t,styleSheet:n}=dS.get(e)??{};n===void 0&&(n=new e.defaultView.CSSStyleSheet,e.adoptedStyleSheets&&(Object.isExtensible(e.adoptedStyleSheets)?e.adoptedStyleSheets.push(n):e.adoptedStyleSheets=[...e.adoptedStyleSheets,n]));const r=xo();switch(r.state){case"active":case"hover":{const i=rU({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}}dS.set(e,{prevStyle:t,styleSheet:n})}let Qr=new Map;const aR=new nR;function iU(e){Qr=new Map(Qr),Qr.delete(e)}function hS(e,t){for(const[n]of Qr)if(n.id===e)return n}function ws(e,t){for(const[n,r]of Qr)if(n.id===e)return r;if(t)throw Error(`Could not find data for Group with id ${e}`)}function jo(){return Qr}function hy(e,t){return aR.addListener("groupChange",n=>{n.group.id===e&&t(n)})}function Oi(e,t,n){const r=Qr.get(e);Qr=new Map(Qr),Qr.set(e,t),aR.emit("groupChange",{group:e,isUserInteraction:(n==null?void 0:n.isUserInteraction)===!0,prev:r,next:t})}function lR(e){const t=xo();let n=!1;switch(t.state){case"active":Ea({cursorFlags:0,state:"inactive"}),t.hitRegions.length>0&&(dy(e),n=!0,t.hitRegions.forEach(r=>{const i=ws(r.group.id,!0);Oi(r.group,i,{isUserInteraction:!0})}))}return n}function fS(e){e.defaultPrevented||lR(e.currentTarget)}function sU(e,t,n){let r,i={x:1/0,y:1/0};for(const s of t){const o=eR(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 oU(e){return e!==null&&typeof e=="object"&&"nodeType"in e&&e.nodeType===Node.DOCUMENT_FRAGMENT_NODE}function aU(e,t){if(e===t)throw new Error("Cannot compare node with itself");const n={a:gS(e),b:gS(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:mS(pS(n.a)),b:mS(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 lU=/\b(?:position|zIndex|opacity|transform|webkitTransform|mixBlendMode|filter|webkitFilter|isolation)\b/;function cU(e){const t=getComputedStyle(cR(e)??e).display;return t==="flex"||t==="inline-flex"}function uU(e){const t=getComputedStyle(e);return!!(t.position==="fixed"||t.zIndex!=="auto"&&(t.position!=="static"||cU(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"||lU.test(t.willChange)||t.webkitOverflowScrolling==="touch")}function pS(e){let t=e.length;for(;t--;){const n=e[t];if(rt(n,"Missing node"),uU(n))return n}return null}function mS(e){return e&&Number(getComputedStyle(e).zIndex)||0}function gS(e){const t=[];for(;e;)t.push(e),e=cR(e);return t}function cR(e){const{parentNode:t}=e;return oU(t)?t.host:t}function dU(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 hU({groupElement:e,hitRegion:t,pointerEventTarget:n}){if(!JI(n)||n.contains(e)||e.contains(n))return!0;if(aU(n,e)>0){let r=n;for(;r;){if(r.contains(e))return!0;if(dU(r.getBoundingClientRect(),t))return!1;r=r.parentElement}}return!0}function fy(e,t){const n=[];return t.forEach((r,i)=>{if(i.disabled)return;const s=tR(i),o=sU(i.orientation,s,{x:e.clientX,y:e.clientY});o&&o.distance.x<=0&&o.distance.y<=0&&hU({groupElement:i.element,hitRegion:o.hitRegion.rect,pointerEventTarget:e.target})&&n.push(o.hitRegion)}),n}function fU(e,t){if(e.length!==t.length)return!1;for(let n=0;n<e.length;n++)if(e[n]!=t[n])return!1;return!0}function _n(e,t,n=0){return Math.abs(Nn(e)-Nn(t))<=n}function Gr(e,t){return _n(e,t)?0:e>t?1:-1}function pa({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(Gr(r,l)<0)if(s){const c=(i+l)/2;Gr(r,c)<0?r=i:r=l}else r=l;return r=Math.min(a,r),r=Nn(r),r}function Zc({delta:e,initialLayout:t,panelConstraints:n,pivotIndices:r,prevLayout:i,trigger:s}){if(_n(e,0))return t;const o=s==="imperative-api",a=Object.values(t),l=Object.values(i),c=[...a],[u,d]=r;rt(u!=null,"Invalid first pivot index"),rt(d!=null,"Invalid second pivot index");let f=0;switch(s){case"keyboard":{{const v=e<0?d:u,b=n[v];rt(b,`Panel constraints not found for index ${v}`);const{collapsedSize:_=0,collapsible:x,minSize:y=0}=b;if(x){const w=a[v];if(rt(w!=null,`Previous layout not found for panel index ${v}`),_n(w,_)){const k=y-w;Gr(k,Math.abs(e))>0&&(e=e<0?0-k:k)}}}{const v=e<0?u:d,b=n[v];rt(b,`No panel constraints found for index ${v}`);const{collapsedSize:_=0,collapsible:x,minSize:y=0}=b;if(x){const w=a[v];if(rt(w!=null,`Previous layout not found for panel index ${v}`),_n(w,y)){const k=w-_;Gr(k,Math.abs(e))>0&&(e=e<0?0-k:k)}}}break}default:{const v=e<0?d:u,b=n[v];rt(b,`Panel constraints not found for index ${v}`);const _=a[v],{collapsible:x,collapsedSize:y,minSize:w}=b;if(x&&Gr(_,w)<0)if(e>0){const k=w-y,C=k/2,N=_+e;Gr(N,w)<0&&(e=Gr(e,C)<=0?0:k)}else{const k=w-y,C=100-k/2,N=_-e;Gr(N,w)<0&&(e=Gr(100+e,C)>0?0:-k)}break}}{const v=e<0?1:-1;let b=e<0?d:u,_=0;for(;;){const y=a[b];rt(y!=null,`Previous layout not found for panel index ${b}`);const w=pa({overrideDisabledPanels:o,panelConstraints:n[b],prevSize:y,size:100})-y;if(_+=w,b+=v,b<0||b>=n.length)break}const x=Math.min(Math.abs(e),Math.abs(_));e=e<0?0-x:x}{let v=e<0?u:d;for(;v>=0&&v<n.length;){const b=Math.abs(e)-Math.abs(f),_=a[v];rt(_!=null,`Previous layout not found for panel index ${v}`);const x=_-b,y=pa({overrideDisabledPanels:o,panelConstraints:n[v],prevSize:_,size:x});if(!_n(_,y)&&(f+=_-y,c[v]=y,f.toFixed(3).localeCompare(Math.abs(e).toFixed(3),void 0,{numeric:!0})>=0))break;e<0?v--:v++}}if(fU(l,c))return i;{const v=e<0?d:u,b=a[v];rt(b!=null,`Previous layout not found for panel index ${v}`);const _=b+f,x=pa({overrideDisabledPanels:o,panelConstraints:n[v],prevSize:b,size:_});if(c[v]=x,!_n(x,_)){let y=_-x,w=e<0?d:u;for(;w>=0&&w<n.length;){const k=c[w];rt(k!=null,`Previous layout not found for panel index ${w}`);const C=k+y,N=pa({overrideDisabledPanels:o,panelConstraints:n[w],prevSize:k,size:C});if(_n(k,N)||(y-=N-k,c[w]=N),_n(y,0))break;e>0?w--:w++}}}const p=Object.values(c).reduce((v,b)=>b+v,0);if(!_n(p,100,.1))return i;const m=Object.keys(i);return c.reduce((v,b,_)=>(v[m[_]]=b,v),{})}function yo(e,t){if(Object.keys(e).length!==Object.keys(t).length)return!1;for(const n in e)if(t[n]===void 0||Gr(e[n],t[n])!==0)return!1;return!0}function bo({layout:e,panelConstraints:t}){const n=Object.values(e),r=[...n],i=r.reduce((a,l)=>a+l,0);if(r.length!==t.length)throw Error(`Invalid ${t.length} panel layout: ${r.map(a=>`${a}%`).join(", ")}`);if(!_n(i,100)&&r.length>0)for(let a=0;a<t.length;a++){const l=r[a];rt(l!=null,`No layout data found for index ${a}`);const c=100/i*l;r[a]=c}let s=0;for(let a=0;a<t.length;a++){const l=n[a];rt(l!=null,`No layout data found for index ${a}`);const c=r[a];rt(c!=null,`No layout data found for index ${a}`);const u=pa({overrideDisabledPanels:!0,panelConstraints:t[a],prevSize:l,size:c});c!=u&&(s+=c-u,r[a]=u)}if(!_n(s,0))for(let a=0;a<t.length;a++){const l=r[a];rt(l!=null,`No layout data found for index ${a}`);const c=l+s,u=pa({overrideDisabledPanels:!0,panelConstraints:t[a],prevSize:l,size:c});if(l!==u&&(s-=u-l,r[a]=u,_n(s,0)))break}const o=Object.keys(e);return r.reduce((a,l,c)=>(a[o[c]]=l,a),{})}function uR({groupId:e,panelId:t}){const n=()=>{const l=jo();for(const[c,{defaultLayoutDeferred:u,derivedPanelConstraints:d,layout:f,groupSize:p,separatorToPanels:m}]of l)if(c.id===e)return{defaultLayoutDeferred:u,derivedPanelConstraints:d,group:c,groupSize:p,layout:f,separatorToPanels:m};throw Error(`Group ${e} not found`)},r=()=>{const l=n().derivedPanelConstraints.find(c=>c.panelId===t);if(l!==void 0)return l;throw Error(`Panel constraints not found for Panel ${t}`)},i=()=>{const l=n().group.panels.find(c=>c.id===t);if(l!==void 0)return l;throw Error(`Layout not found for Panel ${t}`)},s=()=>{const l=n().layout[t];if(l!==void 0)return l;throw Error(`Layout not found for Panel ${t}`)},o=({nextSize:l,panels:c,prevLayout:u,derivedPanelConstraints:d})=>{const f=s(),p=c.findIndex(b=>b.id===t),m=p===0,v=p===c.length-1;if(v&&l<f&&(m||c.slice(0,p).every((b,_)=>{const x=d[_];return(x==null?void 0:x.collapsible)&&_n(x.collapsedSize,u[x.panelId])}))){const b=c.slice(0,p).reduce((_,x)=>_+u[x.id],0);return{...u,[t]:Nn(100-b)}}return Zc({delta:v?f-l:l-f,initialLayout:u,panelConstraints:d,pivotIndices:v?[p-1,p]:[p,p+1],prevLayout:u,trigger:"imperative-api"})},a=l=>{const c=s();if(l===c)return;const{defaultLayoutDeferred:u,derivedPanelConstraints:d,group:f,groupSize:p,layout:m,separatorToPanels:v}=n(),b=o({nextSize:l,panels:f.panels,prevLayout:m,derivedPanelConstraints:d}),_=bo({layout:b,panelConstraints:d});yo(m,_)||Oi(f,{defaultLayoutDeferred:u,derivedPanelConstraints:d,groupSize:p,layout:_,separatorToPanels:v})};return{collapse:()=>{const{collapsible:l,collapsedSize:c}=r(),{mutableValues:u}=i(),d=s();l&&d!==c&&(u.expandToSize=d,a(c))},expand:()=>{const{collapsible:l,collapsedSize:c,minSize:u}=r(),{mutableValues:d}=i(),f=s();if(l&&f===c){let p=d.expandToSize??u;p===0&&(p=1),a(p)}},getSize:()=>{const{group:l}=n(),c=s(),{element:u}=i(),d=l.orientation==="horizontal"?u.offsetWidth:u.offsetHeight;return{asPercentage:c,inPixels:d}},isCollapsed:()=>{const{collapsible:l,collapsedSize:c}=r(),u=s();return l&&_n(c,u)},resize:l=>{const{group:c}=n(),{element:u}=i(),d=Fa({group:c}),f=Gl({groupSize:d,panelElement:u,styleProp:l}),p=Nn(f/d*100);a(p)}}}function vS(e){if(e.defaultPrevented)return;const t=jo();fy(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=uR({groupId:n.group.id,panelId:r.id});s&&i!==void 0&&(s.resize(i),e.preventDefault())}}})}function Qd(e){const t=jo();for(const[n]of t)if(n.separators.some(r=>r.element===e))return n;throw Error("Could not find parent Group for separator element")}function dR({groupId:e}){const t=()=>{const n=jo();for(const[r,i]of n)if(r.id===e)return{group:r,...i};throw Error(`Could not find Group with id "${e}"`)};return{getLayout(){const{defaultLayoutDeferred:n,layout:r}=t();return n?{}:r},setLayout(n){const{defaultLayoutDeferred:r,derivedPanelConstraints:i,group:s,groupSize:o,layout:a,separatorToPanels:l}=t(),c=bo({layout:n,panelConstraints:i});return r?a:(yo(a,c)||Oi(s,{defaultLayoutDeferred:r,derivedPanelConstraints:i,groupSize:o,layout:c,separatorToPanels:l}),c)}}}function Us(e,t){const n=Qd(e),r=ws(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=dR({groupId:n.id}).getLayout(),l=Zc({delta:t,initialLayout:a,panelConstraints:r.derivedPanelConstraints,pivotIndices:o,prevLayout:a,trigger:"keyboard"}),c=bo({layout:l,panelConstraints:r.derivedPanelConstraints});yo(a,c)||Oi(n,{defaultLayoutDeferred:r.defaultLayoutDeferred,derivedPanelConstraints:r.derivedPanelConstraints,groupSize:r.groupSize,layout:c,separatorToPanels:r.separatorToPanels},{isUserInteraction:!0})}function _S(e){if(e.defaultPrevented)return;const t=e.currentTarget,n=Qd(t);if(!n.disabled)switch(e.key){case"ArrowDown":{e.preventDefault(),n.orientation==="vertical"&&Us(t,5);break}case"ArrowLeft":{e.preventDefault(),n.orientation==="horizontal"&&Us(t,-5);break}case"ArrowRight":{e.preventDefault(),n.orientation==="horizontal"&&Us(t,5);break}case"ArrowUp":{e.preventDefault(),n.orientation==="vertical"&&Us(t,-5);break}case"End":{e.preventDefault(),Us(t,100);break}case"Enter":{e.preventDefault();const r=Qd(t),i=ws(r.id,!0),{derivedPanelConstraints:s,layout:o,separatorToPanels:a}=i,l=r.separators.find(f=>f.element===t);rt(l,"Matching separator not found");const c=a.get(l);rt(c,"Matching panels not found");const u=c[0],d=s.find(f=>f.panelId===u.id);if(rt(d,"Panel metadata not found"),d.collapsible){const f=o[u.id],p=d.collapsedSize===f?r.mutableState.expandedPanelSizes[u.id]??d.minSize:d.collapsedSize;Us(t,p-f)}break}case"F6":{e.preventDefault();const r=Qd(t).separators.map(o=>o.element),i=Array.from(r).findIndex(o=>o===e.currentTarget);rt(i!==null,"Index not found");const s=e.shiftKey?i>0?i-1:r.length-1:i+1<r.length?i+1:0;r[s].focus({preventScroll:!0});break}case"Home":{e.preventDefault(),Us(t,-100);break}}}function xS(e){if(e.defaultPrevented||e.pointerType==="mouse"&&e.button>0)return;const t=jo(),n=fy(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)}),Ea({cursorFlags:0,hitRegions:n,initialLayoutMap:r,pointerDownAtPoint:{x:e.clientX,y:e.clientY},state:"active"}),n.length&&e.preventDefault()}function hR({document:e,event:t,hitRegions:n,initialLayoutMap:r,mountedGroups:i,pointerDownAtPoint:s,prevCursorFlags:o}){let a=0;n.forEach(c=>{const{group:u,groupSize:d}=c,{orientation:f,panels:p}=u,{disableCursor:m}=u.mutableState;let v=0;s?f==="horizontal"?v=(t.clientX-s.x)/d*100:v=(t.clientY-s.y)/d*100:f==="horizontal"?v=t.clientX<0?-100:100:v=t.clientY<0?-100:100;const b=r.get(u),_=i.get(u);if(!b||!_)return;const{defaultLayoutDeferred:x,derivedPanelConstraints:y,groupSize:w,layout:k,separatorToPanels:C}=_;if(y&&k&&C){const N=Zc({delta:v,initialLayout:b,panelConstraints:y,pivotIndices:c.panels.map(T=>p.indexOf(T)),prevLayout:k,trigger:"mouse-or-touch"});if(yo(N,k)){if(v!==0&&!m)switch(f){case"horizontal":{a|=v<0?rR:iR;break}case"vertical":{a|=v<0?sR:oR;break}}}else Oi(c.group,{defaultLayoutDeferred:x,derivedPanelConstraints:y,groupSize:w,layout:N,separatorToPanels:C})}});let l=0;t.movementX===0?l|=o&lS:l|=a&lS,t.movementY===0?l|=o&cS:l|=a&cS,tU(l),dy(e)}function yS(e){const t=jo(),n=xo();switch(n.state){case"active":hR({document:e.currentTarget,event:e,hitRegions:n.hitRegions,initialLayoutMap:n.initialLayoutMap,mountedGroups:t,prevCursorFlags:n.cursorFlags})}}function bS(e){var r,i;if(e.defaultPrevented)return;const t=xo(),n=jo();switch(t.state){case"active":{if(e.buttons===0){Ea({cursorFlags:0,state:"inactive"}),t.hitRegions.forEach(s=>{const o=ws(s.group.id,!0);Oi(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))}hR({document:e.currentTarget,event:e,hitRegions:t.hitRegions,initialLayoutMap:t.initialLayoutMap,mountedGroups:n,pointerDownAtPoint:t.pointerDownAtPoint,prevCursorFlags:t.cursorFlags});break}default:{const s=fy(e,n);s.length===0?t.state!=="inactive"&&Ea({cursorFlags:0,state:"inactive"}):Ea({cursorFlags:0,hitRegions:s,state:"hover"}),dy(e.currentTarget);break}}}function wS(e){if(e.relatedTarget instanceof HTMLIFrameElement)switch(xo().state){case"hover":Ea({cursorFlags:0,state:"inactive"})}}function SS(e){e.defaultPrevented||e.pointerType==="mouse"&&e.button>0||lR(e.currentTarget)&&e.preventDefault()}function kS(e){let t=0,n=0;const r={};for(const s of e)if(s.defaultSize!==void 0){t++;const o=Nn(s.defaultSize);n+=o,r[s.panelId]=o}else r[s.panelId]=void 0;const i=e.length-t;if(i!==0){const s=Nn((100-n)/i);for(const o of e)o.defaultSize===void 0&&(r[o.panelId]=s)}return r}function pU(e,t,n){if(!n[0])return;const r=e.panels.find(l=>l.element===t);if(!r||!r.onResize)return;const i=Fa({group:e}),s=e.orientation==="horizontal"?r.element.offsetWidth:r.element.offsetHeight,o=r.mutableValues.prevSize,a={asPercentage:Nn(s/i*100),inPixels:s};r.mutableValues.prevSize=a,r.onResize(a,r.id,o)}function mU(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 gU({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=Nn(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]=Nn(f/s*c)}else{const d=Nn(c/l.length);for(const f of l)u[f]=d}return u}function vU(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 Ko=new Map;function _U(e){let t=!0;rt(e.element.ownerDocument.defaultView,"Cannot register an unmounted Group");const n=e.element.ownerDocument.defaultView.ResizeObserver,r=new Set,i=new Set,s=new n(m=>{for(const v of m){const{borderBoxSize:b,target:_}=v;if(_===e.element){if(t){const x=Fa({group:e});if(x===0)return;const y=ws(e.id);if(!y)return;const w=g0(e),k=y.defaultLayoutDeferred?kS(w):y.layout,C=gU({group:e,nextGroupSize:x,prevGroupSize:y.groupSize,prevLayout:k}),N=bo({layout:C,panelConstraints:w});if(!y.defaultLayoutDeferred&&yo(y.layout,N)&&mU(y.derivedPanelConstraints,w)&&y.groupSize===x)return;Oi(e,{defaultLayoutDeferred:!1,derivedPanelConstraints:w,groupSize:x,layout:N,separatorToPanels:y.separatorToPanels})}}else pU(e,_,b)}});s.observe(e.element),e.panels.forEach(m=>{rt(!r.has(m.id),`Panel ids must be unique; id "${m.id}" was used more than once`),r.add(m.id),m.onResize&&s.observe(m.element)});const o=Fa({group:e}),a=g0(e),l=e.panels.map(({id:m})=>m).join(",");let c=e.mutableState.defaultLayout;c&&(vU(e.panels,c)||(c=void 0));const u=e.mutableState.layouts[l]??c??kS(a),d=bo({layout:u,panelConstraints:a}),f=e.element.ownerDocument;Ko.set(f,(Ko.get(f)??0)+1);const p=new Map;return tR(e).forEach(m=>{m.separator&&p.set(m.separator,m.panels)}),Oi(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",_S)}),Ko.get(f)===1&&(f.addEventListener("contextmenu",fS,!0),f.addEventListener("dblclick",vS,!0),f.addEventListener("pointerdown",xS,!0),f.addEventListener("pointerleave",yS),f.addEventListener("pointermove",bS),f.addEventListener("pointerout",wS),f.addEventListener("pointerup",SS,!0)),function(){t=!1,Ko.set(f,Math.max(0,(Ko.get(f)??0)-1)),iU(e),e.separators.forEach(m=>{m.element.removeEventListener("keydown",_S)}),Ko.get(f)||(f.removeEventListener("contextmenu",fS,!0),f.removeEventListener("dblclick",vS,!0),f.removeEventListener("pointerdown",xS,!0),f.removeEventListener("pointerleave",yS),f.removeEventListener("pointermove",bS),f.removeEventListener("pointerout",wS),f.removeEventListener("pointerup",SS,!0)),s.disconnect()}}function xU(){const[e,t]=g.useState({}),n=g.useCallback(()=>t({}),[]);return[e,n]}function py(e){const t=g.useId();return`${e??t}`}const Do=typeof window<"u"?g.useLayoutEffect:g.useEffect;function pc(e){const t=g.useRef(e);return Do(()=>{t.current=e},[e]),g.useCallback((...n)=>{var r;return(r=t.current)==null?void 0:r.call(t,...n)},[t])}function my(...e){return pc(t=>{e.forEach(n=>{if(n)switch(typeof n){case"function":{n(t);break}case"object":{n.current=t;break}}})})}function gy(e){const t=g.useRef({...e});return Do(()=>{for(const n in e)t.current[n]=e[n]},[e]),t.current}const fR=g.createContext(null);function yU(e,t){const n=g.useRef({getLayout:()=>({}),setLayout:nU});g.useImperativeHandle(t,()=>n.current,[]),Do(()=>{Object.assign(n.current,dR({groupId:e}))})}function vy({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=pc(j=>{yo(m.current.onLayoutChange,j)||(m.current.onLayoutChange=j,l==null||l(j))}),b=pc((j,I)=>{yo(m.current.onLayoutChanged,j)||(m.current.onLayoutChanged=j,c==null||c(j,{isUserInteraction:I}))}),_=py(a),x=g.useRef(null),[y,w]=xU(),k=g.useRef({lastExpandedPanelSizes:{},layouts:{},panels:[],resizeTargetMinimumSize:d,separators:[]}),C=my(x,s);yU(_,o);const N=pc((j,I)=>{const R=xo(),L=hS(j),z=ws(j);if(z){let $=!1;switch(R.state){case"active":{$=R.hitRegions.some(F=>F.group===L);break}}return{flexGrow:z.layout[I]??1,pointerEvents:$?"none":void 0}}if(n!=null&&n[I])return{flexGrow:n==null?void 0:n[I]}}),T=gy({defaultLayout:n,disableCursor:r}),B=g.useMemo(()=>({get disableCursor(){return!!T.disableCursor},getPanelStyles:N,id:_,orientation:u,registerPanel:j=>{const I=k.current;return I.panels=v0(u,[...I.panels,j]),w(),()=>{I.panels=I.panels.filter(R=>R!==j),w()}},registerSeparator:j=>{const I=k.current;return I.separators=v0(u,[...I.separators,j]),w(),()=>{I.separators=I.separators.filter(R=>R!==j),w()}},updatePanelProps:(j,{disabled:I})=>{const R=k.current.panels.find($=>$.id===j);R&&(R.panelConstraints.disabled=I);const L=hS(_),z=ws(_);L&&z&&Oi(L,{...z,derivedPanelConstraints:g0(L)})},updateSeparatorProps:(j,{disabled:I,disableDoubleClick:R})=>{const L=k.current.separators.find(z=>z.id===j);L&&(L.disabled=I,L.disableDoubleClick=R)}}),[N,_,w,u,T]),P=g.useRef(null);return Do(()=>{const j=x.current;if(j===null)return;const I=k.current;let R;if(T.defaultLayout!==void 0&&Object.keys(T.defaultLayout).length===I.panels.length){R={};for(const E of I.panels){const H=T.defaultLayout[E.id];H!==void 0&&(R[E.id]=H)}}const L={disabled:!!i,element:j,id:_,mutableState:{defaultLayout:R,disableCursor:!!T.disableCursor,expandedPanelSizes:k.current.lastExpandedPanelSizes,layouts:k.current.layouts},orientation:u,panels:I.panels,resizeTargetMinimumSize:I.resizeTargetMinimumSize,separators:I.separators};P.current=L;const z=_U(L),{defaultLayoutDeferred:$,derivedPanelConstraints:F,layout:D}=ws(L.id,!0);!$&&F.length>0&&(v(D),b(D,!1));const O=hy(_,E=>{const{defaultLayoutDeferred:H,derivedPanelConstraints:V,layout:A}=E.next;if(H||V.length===0)return;const ne=L.panels.map(({id:X})=>X).join(",");L.mutableState.layouts[ne]=A,V.forEach(X=>{if(X.collapsible){const{layout:ye}=E.prev??{};if(ye){const $e=_n(X.collapsedSize,A[X.panelId]),ue=_n(X.collapsedSize,ye[X.panelId]);$e&&!ue&&(L.mutableState.expandedPanelSizes[X.panelId]=ye[X.panelId])}}});const oe=xo().state!=="active";v(A),oe&&b(A,E.isUserInteraction)});return()=>{P.current=null,z(),O()}},[i,_,b,v,u,y,T]),g.useEffect(()=>{const j=P.current;j&&(j.mutableState.defaultLayout=n,j.mutableState.disableCursor=!!r)}),h.jsx(fR.Provider,{value:B,children:h.jsx("div",{...p,className:t,"data-group":!0,"data-testid":_,id:_,ref:C,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})})}vy.displayName="Group";function _y(){const e=g.useContext(fR);return rt(e,"Group Context not found; did you render a Panel or Separator outside of a Group?"),e}function bU(e,t){const{id:n}=_y(),r=g.useRef({collapse:Om,expand:Om,getSize:()=>({asPercentage:0,inPixels:0}),isCollapsed:()=>!1,resize:Om});g.useImperativeHandle(t,()=>r.current,[]),Do(()=>{Object.assign(r.current,uR({groupId:n,panelId:e}))})}function Jh({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),_=gy({disabled:s}),x=g.useRef(null),y=my(x,o),{getPanelStyles:w,id:k,orientation:C,registerPanel:N,updatePanelProps:T}=_y(),B=d!==null,P=pc((L,z,$)=>{d==null||d(L,l,$)});Do(()=>{const L=x.current;if(L!==null){const z={element:L,id:b,idIsStable:v,mutableValues:{expandToSize:void 0,prevSize:void 0},onResize:B?P:void 0,panelConstraints:{groupResizeBehavior:a,collapsedSize:n,collapsible:r,defaultSize:i,disabled:_.disabled,maxSize:c,minSize:u}};return N(z)}},[a,n,r,i,B,b,v,c,u,P,N,_]),g.useEffect(()=>{T(b,{disabled:s})},[s,b,T]),bU(b,f);const j=()=>{const L=w(k,b);if(L)return JSON.stringify(L)},I=g.useSyncExternalStore(L=>hy(k,L),j,j);let R;return I?R=JSON.parse(I):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:{...wU,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:C==="horizontal"?"pan-y":"pan-x"},children:e})})}Jh.displayName="Panel";const wU={minHeight:0,maxHeight:"100%",height:"auto",minWidth:0,maxWidth:"100%",width:"auto",border:"none",borderWidth:0,padding:0,margin:0};function SU({layout:e,panelConstraints:t,panelId:n,panelIndex:r}){let i,s;const o=e[n],a=t.find(l=>l.panelId===n);if(a){const l=a.maxSize,c=a.collapsible?a.collapsedSize:a.minSize,u=[r,r+1];s=bo({layout:Zc({delta:c-o,initialLayout:e,panelConstraints:t,pivotIndices:u,prevLayout:e}),panelConstraints:t})[n],i=bo({layout:Zc({delta:l-o,initialLayout:e,panelConstraints:t,pivotIndices:u,prevLayout:e}),panelConstraints:t})[n]}return{valueControls:n,valueMax:i,valueMin:s,valueNow:o}}function pR({children:e,className:t,disabled:n,disableDoubleClick:r,elementRef:i,id:s,style:o,...a}){const l=py(s),c=gy({disabled:n,disableDoubleClick:r}),[u,d]=g.useState({}),[f,p]=g.useState("inactive"),[m,v]=g.useState(!1),b=g.useRef(null),_=my(b,i),{disableCursor:x,id:y,orientation:w,registerSeparator:k,updateSeparatorProps:C}=_y(),N=w==="horizontal"?"vertical":"horizontal";Do(()=>{const P=b.current;if(P!==null){const j={disabled:c.disabled,disableDoubleClick:c.disableDoubleClick,element:P,id:l},I=k(j),R=eU(z=>{p(z.next.state!=="inactive"&&z.next.hitRegions.some($=>$.separator===j)?z.next.state:"inactive")}),L=hy(y,z=>{const{derivedPanelConstraints:$,layout:F,separatorToPanels:D}=z.next,O=D.get(j);if(O){const E=O[0],H=O.indexOf(E);d(SU({layout:F,panelConstraints:$,panelId:E.id,panelIndex:H}))}});return()=>{R(),L(),I()}}},[y,l,k,c]),g.useEffect(()=>{C(l,{disabled:n,disableDoubleClick:r})},[n,r,l,C]);let T;n&&!x&&(T="not-allowed");let B;if(n)B="disabled";else switch(f){case"active":{B="active";break}default:m?B="focus":B=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":B,"data-testid":l,id:l,onBlur:()=>v(!1),onFocus:()=>v(!0),ref:_,role:"separator",style:{flexBasis:"auto",cursor:T,...o,flexGrow:0,flexShrink:0,touchAction:"none"},tabIndex:n?void 0:0})}pR.displayName="Separator";function kU(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 CU(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 EU=/^Scheduled (?:recurring job|one-shot task) ([0-9a-f]{8}) \(([^)]+)\)/;function NU(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(EU);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 TU=["TaskCreate","TaskUpdate","TaskList","TaskGet"];function PU(e){return TU.includes(e)}function mR(e){return e==="in_progress"||e==="completed"?e:"pending"}function IU(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:mR(n.status),activeForm:i,description:s}]}function RU(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=mR(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 MU(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=IU(t,i.input);break;case"TaskUpdate":t=RU(t,i.input);break}}return{tasks:t,lastEventIndex:n}}function AU(e){const{tasks:t,lastEventIndex:n}=MU(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;const d={agentId:u.agentId,status:u.status};u.description?d.description=u.description:(f=c.progress)!=null&&f.description&&(d.description=c.progress.description),u.lastToolName?d.lastToolName=u.lastToolName:(p=c.progress)!=null&&p.lastToolName&&(d.lastToolName=c.progress.lastToolName),u.stats?d.stats=u.stats:(m=c.progress)!=null&&m.stats&&(d.stats=c.progress.stats),c.progress=d};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}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 LU=new Set(["permission-inline","question-card"]);function jU(e){return e.kind==="user-text"?!0:e.kind==="user-meta"&&e.metaKind==="slash-command"}function DU(e,t={}){const n=[];let r=null;const i=(s,o)=>{r&&(n.push(OU(r,s,o)),r=null)};for(const s of e){if(s.kind==="turn-end"){i(s,!0);continue}if(jU(s)&&(r===null||t.implicitCloseOnUserText)){i(void 0,!0),r={query:s,body:[]};continue}r===null?r={body:[s]}:r.body.push(s)}return i(void 0,!1),n}function OU(e,t,n){const{query:r,body:i}=e,s=BU(i,t,n),o=zU(i,s),a=FU(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 BU(e,t,n){if(!n)return"running";if((t==null?void 0:t.reason)==="interrupted")return"interrupted";const r=_0(e,i=>i.kind==="error");return r>=0&&!e.slice(r+1).some(s=>s.kind==="assistant-text")?"error":"done"}function zU(e,t){if(t==="running"){const i=[];for(let s=e.length-1;s>=0&&LU.has(e[s].kind);s--)i.unshift(e[s]);return i}const n=[];e.forEach((i,s)=>{i.kind==="merged-agent"&&i.pending&&n.push(s)});const r=t==="error"?_0(e,i=>i.kind==="error"):_0(e,i=>i.kind==="assistant-text");return r>=0&&n.push(r),n.sort((i,s)=>i-s).map(i=>e[i])}const $U=new Set(["assistant-thinking","user-meta"]);function FU(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($U.has(o.kind)){r.push(o);continue}s(),r.push(o)}return s(),r}function _0(e,t){for(let n=e.length-1;n>=0;n--)if(t(e[n]))return n;return-1}const HU={Read:["正在读取","已读取"],Bash:["正在运行","已运行"],Grep:["正在搜索","已搜索"],Glob:["正在搜索","已搜索"],Edit:["正在编辑","已编辑"],Write:["正在写入","已写入"],WebFetch:["正在抓取","已抓取"],WebSearch:["正在搜索","已搜索"],Skill:["正在读取","已读取"]};function UU(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 gR(e){const t=HU[e.tool],n=t?e.pending?t[0]:t[1]:e.pending?`正在执行 ${e.tool}`:`已执行 ${e.tool}`,r=UU(e.input);return r?`${n} ${r}`:n}function WU({item:e,renderItemDetail:t}){const[n,r]=g.useState(!1),i=n?ir:Un,s=n?(t==null?void 0:t(e))??null:null;return h.jsxs("div",{className:"min-w-0 max-w-full",children:[h.jsxs("button",{type:"button",onClick:()=>r(o=>!o),"aria-expanded":n,"data-testid":"tool-call-group-row",className:he("flex w-full items-center gap-1.5 text-left cursor-pointer min-w-0 py-0.5 text-[13px] hover:text-text-200",e.error?"text-destructive/80":"text-text-400"),children:[e.pending?h.jsx(In,{className:"w-3.5 h-3.5 animate-spin shrink-0"}):h.jsx(i,{className:"w-3.5 h-3.5 shrink-0 opacity-60"}),h.jsx("span",{className:"truncate min-w-0",children:gR(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 VU({items:e,defaultExpanded:t=!1,renderItemDetail:n}){const[r,i]=g.useState(t);if(e.length===0)return null;const s=e.some(c=>c.pending),o=s?[...e].reverse().find(c=>c.pending):e[e.length-1],a=!s&&e.length>1?` 等 ${e.length} 项`:"",l=r?ir:Un;return h.jsxs("div",{"data-testid":"tool-call-group",className:"min-w-0 max-w-full",children:[h.jsxs("button",{type:"button",onClick:()=>i(c=>!c),"aria-expanded":r,"data-testid":"tool-call-group-header",className:"flex w-full items-center gap-1.5 text-left cursor-pointer min-w-0 py-0.5 text-[13px] text-text-400 hover:text-text-200",children:[s&&!r?h.jsx(In,{className:"w-3.5 h-3.5 animate-spin shrink-0"}):h.jsx(l,{className:"w-3.5 h-3.5 shrink-0"}),r?h.jsx("span",{className:"min-w-0 truncate opacity-70",children:s?"正在执行":`${e.length} 项`}):h.jsxs("span",{className:he("truncate min-w-0",s&&"text-text-300"),children:[gR(o),a]})]}),r?h.jsx("div",{className:"mt-0.5 flex flex-col pl-5",children:e.map(c=>h.jsx(WU,{item:c,renderItemDetail:n},c.toolUseId))}):null]})}function qU(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 KU(e,t){const n=t!==void 0?`耗时 ${qU(t)}`:"";switch(e){case"interrupted":return n?`已中断 · ${n}`:"已中断";case"error":return n?`出错 · ${n}`:"出错";default:return n||"已完成"}}function GU({status:e="done",durationMs:t,defaultExpanded:n=!1,children:r}){const[i,s]=g.useState(n),o=i?ir:Un;return h.jsxs("div",{"data-testid":"turn-process-block",className:"min-w-0 max-w-full border-t border-border pt-2",children:[h.jsxs("button",{type:"button",onClick:()=>s(a=>!a),"aria-expanded":i,"data-testid":"turn-process-block-header",className:he("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:KU(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 XU=/<(system-reminder|related-dir|clawd-shift-fire)\b[^>]*>[\s\S]*?<\/\1>/gi,YU=/<builder-preview\b[^>]*\/>/gi;function vR(e){return e?e.replace(XU,"").replace(YU,"").trim():""}const ZU=vR;function QU(e,t){const n={};return(e[e.length-1]===""?[...e,""]:e).join((n.padRight?" ":"")+","+(n.padLeft===!1?"":" ")).trim()}const JU=/^[$_\p{ID_Start}][$_\u{200C}\u{200D}\p{ID_Continue}]*$/u,eW=/^[$_\p{ID_Start}][-$_\u{200C}\u{200D}\p{ID_Continue}]*$/u,tW={};function CS(e,t){return(tW.jsx?eW:JU).test(e)}const nW=/[ \t\n\f\r]/g;function rW(e){return typeof e=="object"?e.type==="text"?ES(e.value):!1:ES(e)}function ES(e){return e.replace(nW,"")===""}class ku{constructor(t,n,r){this.normal=n,this.property=t,r&&(this.space=r)}}ku.prototype.normal={};ku.prototype.property={};ku.prototype.space=void 0;function _R(e,t){const n={},r={};for(const i of e)Object.assign(n,i.property),Object.assign(r,i.normal);return new ku(n,r,t)}function x0(e){return e.toLowerCase()}class Wn{constructor(t,n){this.attribute=n,this.property=t}}Wn.prototype.attribute="";Wn.prototype.booleanish=!1;Wn.prototype.boolean=!1;Wn.prototype.commaOrSpaceSeparated=!1;Wn.prototype.commaSeparated=!1;Wn.prototype.defined=!1;Wn.prototype.mustUseProperty=!1;Wn.prototype.number=!1;Wn.prototype.overloadedBoolean=!1;Wn.prototype.property="";Wn.prototype.spaceSeparated=!1;Wn.prototype.space=void 0;let iW=0;const Me=Oo(),Dt=Oo(),y0=Oo(),Q=Oo(),at=Oo(),Na=Oo(),Gn=Oo();function Oo(){return 2**++iW}const b0=Object.freeze(Object.defineProperty({__proto__:null,boolean:Me,booleanish:Dt,commaOrSpaceSeparated:Gn,commaSeparated:Na,number:Q,overloadedBoolean:y0,spaceSeparated:at},Symbol.toStringTag,{value:"Module"})),Bm=Object.keys(b0);class xy extends Wn{constructor(t,n,r,i){let s=-1;if(super(t,n),NS(this,"space",i),typeof r=="number")for(;++s<Bm.length;){const o=Bm[s];NS(this,Bm[s],(r&b0[o])===b0[o])}}}xy.prototype.defined=!0;function NS(e,t,n){n&&(e[t]=n)}function hl(e){const t={},n={};for(const[r,i]of Object.entries(e.properties)){const s=new xy(r,e.transform(e.attributes||{},r),i,e.space);e.mustUseProperty&&e.mustUseProperty.includes(r)&&(s.mustUseProperty=!0),t[r]=s,n[x0(r)]=r,n[x0(s.attribute)]=r}return new ku(t,n,e.space)}const xR=hl({properties:{ariaActiveDescendant:null,ariaAtomic:Dt,ariaAutoComplete:null,ariaBusy:Dt,ariaChecked:Dt,ariaColCount:Q,ariaColIndex:Q,ariaColSpan:Q,ariaControls:at,ariaCurrent:null,ariaDescribedBy:at,ariaDetails:null,ariaDisabled:Dt,ariaDropEffect:at,ariaErrorMessage:null,ariaExpanded:Dt,ariaFlowTo:at,ariaGrabbed:Dt,ariaHasPopup:null,ariaHidden:Dt,ariaInvalid:null,ariaKeyShortcuts:null,ariaLabel:null,ariaLabelledBy:at,ariaLevel:Q,ariaLive:null,ariaModal:Dt,ariaMultiLine:Dt,ariaMultiSelectable:Dt,ariaOrientation:null,ariaOwns:at,ariaPlaceholder:null,ariaPosInSet:Q,ariaPressed:Dt,ariaReadOnly:Dt,ariaRelevant:null,ariaRequired:Dt,ariaRoleDescription:at,ariaRowCount:Q,ariaRowIndex:Q,ariaRowSpan:Q,ariaSelected:Dt,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 yR(e,t){return t in e?e[t]:t}function bR(e,t){return yR(e,t.toLowerCase())}const sW=hl({attributes:{acceptcharset:"accept-charset",classname:"class",htmlfor:"for",httpequiv:"http-equiv"},mustUseProperty:["checked","multiple","muted","selected"],properties:{abbr:null,accept:Na,acceptCharset:at,accessKey:at,action:null,allow:null,allowFullScreen:Me,allowPaymentRequest:Me,allowUserMedia:Me,alt:null,as:null,async:Me,autoCapitalize:null,autoComplete:at,autoFocus:Me,autoPlay:Me,blocking:at,capture:null,charSet:null,checked:Me,cite:null,className:at,cols:Q,colSpan:null,content:null,contentEditable:Dt,controls:Me,controlsList:at,coords:Q|Na,crossOrigin:null,data:null,dateTime:null,decoding:null,default:Me,defer:Me,dir:null,dirName:null,disabled:Me,download:y0,draggable:Dt,encType:null,enterKeyHint:null,fetchPriority:null,form:null,formAction:null,formEncType:null,formMethod:null,formNoValidate:Me,formTarget:null,headers:at,height:Q,hidden:y0,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:Dt,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:Dt,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:Dt,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:bR}),oW=hl({attributes:{accentHeight:"accent-height",alignmentBaseline:"alignment-baseline",arabicForm:"arabic-form",baselineShift:"baseline-shift",capHeight:"cap-height",className:"class",clipPath:"clip-path",clipRule:"clip-rule",colorInterpolation:"color-interpolation",colorInterpolationFilters:"color-interpolation-filters",colorProfile:"color-profile",colorRendering:"color-rendering",crossOrigin:"crossorigin",dataType:"datatype",dominantBaseline:"dominant-baseline",enableBackground:"enable-background",fillOpacity:"fill-opacity",fillRule:"fill-rule",floodColor:"flood-color",floodOpacity:"flood-opacity",fontFamily:"font-family",fontSize:"font-size",fontSizeAdjust:"font-size-adjust",fontStretch:"font-stretch",fontStyle:"font-style",fontVariant:"font-variant",fontWeight:"font-weight",glyphName:"glyph-name",glyphOrientationHorizontal:"glyph-orientation-horizontal",glyphOrientationVertical:"glyph-orientation-vertical",hrefLang:"hreflang",horizAdvX:"horiz-adv-x",horizOriginX:"horiz-origin-x",horizOriginY:"horiz-origin-y",imageRendering:"image-rendering",letterSpacing:"letter-spacing",lightingColor:"lighting-color",markerEnd:"marker-end",markerMid:"marker-mid",markerStart:"marker-start",navDown:"nav-down",navDownLeft:"nav-down-left",navDownRight:"nav-down-right",navLeft:"nav-left",navNext:"nav-next",navPrev:"nav-prev",navRight:"nav-right",navUp:"nav-up",navUpLeft:"nav-up-left",navUpRight:"nav-up-right",onAbort:"onabort",onActivate:"onactivate",onAfterPrint:"onafterprint",onBeforePrint:"onbeforeprint",onBegin:"onbegin",onCancel:"oncancel",onCanPlay:"oncanplay",onCanPlayThrough:"oncanplaythrough",onChange:"onchange",onClick:"onclick",onClose:"onclose",onCopy:"oncopy",onCueChange:"oncuechange",onCut:"oncut",onDblClick:"ondblclick",onDrag:"ondrag",onDragEnd:"ondragend",onDragEnter:"ondragenter",onDragExit:"ondragexit",onDragLeave:"ondragleave",onDragOver:"ondragover",onDragStart:"ondragstart",onDrop:"ondrop",onDurationChange:"ondurationchange",onEmptied:"onemptied",onEnd:"onend",onEnded:"onended",onError:"onerror",onFocus:"onfocus",onFocusIn:"onfocusin",onFocusOut:"onfocusout",onHashChange:"onhashchange",onInput:"oninput",onInvalid:"oninvalid",onKeyDown:"onkeydown",onKeyPress:"onkeypress",onKeyUp:"onkeyup",onLoad:"onload",onLoadedData:"onloadeddata",onLoadedMetadata:"onloadedmetadata",onLoadStart:"onloadstart",onMessage:"onmessage",onMouseDown:"onmousedown",onMouseEnter:"onmouseenter",onMouseLeave:"onmouseleave",onMouseMove:"onmousemove",onMouseOut:"onmouseout",onMouseOver:"onmouseover",onMouseUp:"onmouseup",onMouseWheel:"onmousewheel",onOffline:"onoffline",onOnline:"ononline",onPageHide:"onpagehide",onPageShow:"onpageshow",onPaste:"onpaste",onPause:"onpause",onPlay:"onplay",onPlaying:"onplaying",onPopState:"onpopstate",onProgress:"onprogress",onRateChange:"onratechange",onRepeat:"onrepeat",onReset:"onreset",onResize:"onresize",onScroll:"onscroll",onSeeked:"onseeked",onSeeking:"onseeking",onSelect:"onselect",onShow:"onshow",onStalled:"onstalled",onStorage:"onstorage",onSubmit:"onsubmit",onSuspend:"onsuspend",onTimeUpdate:"ontimeupdate",onToggle:"ontoggle",onUnload:"onunload",onVolumeChange:"onvolumechange",onWaiting:"onwaiting",onZoom:"onzoom",overlinePosition:"overline-position",overlineThickness:"overline-thickness",paintOrder:"paint-order",panose1:"panose-1",pointerEvents:"pointer-events",referrerPolicy:"referrerpolicy",renderingIntent:"rendering-intent",shapeRendering:"shape-rendering",stopColor:"stop-color",stopOpacity:"stop-opacity",strikethroughPosition:"strikethrough-position",strikethroughThickness:"strikethrough-thickness",strokeDashArray:"stroke-dasharray",strokeDashOffset:"stroke-dashoffset",strokeLineCap:"stroke-linecap",strokeLineJoin:"stroke-linejoin",strokeMiterLimit:"stroke-miterlimit",strokeOpacity:"stroke-opacity",strokeWidth:"stroke-width",tabIndex:"tabindex",textAnchor:"text-anchor",textDecoration:"text-decoration",textRendering:"text-rendering",transformOrigin:"transform-origin",typeOf:"typeof",underlinePosition:"underline-position",underlineThickness:"underline-thickness",unicodeBidi:"unicode-bidi",unicodeRange:"unicode-range",unitsPerEm:"units-per-em",vAlphabetic:"v-alphabetic",vHanging:"v-hanging",vIdeographic:"v-ideographic",vMathematical:"v-mathematical",vectorEffect:"vector-effect",vertAdvY:"vert-adv-y",vertOriginX:"vert-origin-x",vertOriginY:"vert-origin-y",wordSpacing:"word-spacing",writingMode:"writing-mode",xHeight:"x-height",playbackOrder:"playbackorder",timelineBegin:"timelinebegin"},properties:{about:Gn,accentHeight:Q,accumulate:null,additive:null,alignmentBaseline:null,alphabetic:Q,amplitude:Q,arabicForm:null,ascent:Q,attributeName:null,attributeType:null,azimuth:Q,bandwidth:null,baselineShift:null,baseFrequency:null,baseProfile:null,bbox:null,begin:null,bias:Q,by:null,calcMode:null,capHeight:Q,className:at,clip:null,clipPath:null,clipPathUnits:null,clipRule:null,color:null,colorInterpolation:null,colorInterpolationFilters:null,colorProfile:null,colorRendering:null,content:null,contentScriptType:null,contentStyleType:null,crossOrigin:null,cursor:null,cx:null,cy:null,d:null,dataType:null,defaultAction:null,descent:Q,diffuseConstant:Q,direction:null,display:null,dur:null,divisor:Q,dominantBaseline:null,download:Me,dx:null,dy:null,edgeMode:null,editable:null,elevation:Q,enableBackground:null,end:null,event:null,exponent:Q,externalResourcesRequired:null,fill:null,fillOpacity:Q,fillRule:null,filter:null,filterRes:null,filterUnits:null,floodColor:null,floodOpacity:null,focusable:null,focusHighlight:null,fontFamily:null,fontSize:null,fontSizeAdjust:null,fontStretch:null,fontStyle:null,fontVariant:null,fontWeight:null,format:null,fr:null,from:null,fx:null,fy:null,g1:Na,g2:Na,glyphName:Na,glyphOrientationHorizontal:null,glyphOrientationVertical:null,glyphRef:null,gradientTransform:null,gradientUnits:null,handler:null,hanging:Q,hatchContentUnits:null,hatchUnits:null,height:null,href:null,hrefLang:null,horizAdvX:Q,horizOriginX:Q,horizOriginY:Q,id:null,ideographic:Q,imageRendering:null,initialVisibility:null,in:null,in2:null,intercept:Q,k:Q,k1:Q,k2:Q,k3:Q,k4:Q,kernelMatrix:Gn,kernelUnitLength:null,keyPoints:null,keySplines:null,keyTimes:null,kerning:null,lang:null,lengthAdjust:null,letterSpacing:null,lightingColor:null,limitingConeAngle:Q,local:null,markerEnd:null,markerMid:null,markerStart:null,markerHeight:null,markerUnits:null,markerWidth:null,mask:null,maskContentUnits:null,maskUnits:null,mathematical:null,max:null,media:null,mediaCharacterEncoding:null,mediaContentEncodings:null,mediaSize:Q,mediaTime:null,method:null,min:null,mode:null,name:null,navDown:null,navDownLeft:null,navDownRight:null,navLeft:null,navNext:null,navPrev:null,navRight:null,navUp:null,navUpLeft:null,navUpRight:null,numOctaves:null,observer:null,offset:null,onAbort:null,onActivate:null,onAfterPrint:null,onBeforePrint:null,onBegin:null,onCancel:null,onCanPlay:null,onCanPlayThrough:null,onChange:null,onClick:null,onClose:null,onCopy:null,onCueChange:null,onCut:null,onDblClick:null,onDrag:null,onDragEnd:null,onDragEnter:null,onDragExit:null,onDragLeave:null,onDragOver:null,onDragStart:null,onDrop:null,onDurationChange:null,onEmptied:null,onEnd:null,onEnded:null,onError:null,onFocus:null,onFocusIn:null,onFocusOut:null,onHashChange:null,onInput:null,onInvalid:null,onKeyDown:null,onKeyPress:null,onKeyUp:null,onLoad:null,onLoadedData:null,onLoadedMetadata:null,onLoadStart:null,onMessage:null,onMouseDown:null,onMouseEnter:null,onMouseLeave:null,onMouseMove:null,onMouseOut:null,onMouseOver:null,onMouseUp:null,onMouseWheel:null,onOffline:null,onOnline:null,onPageHide:null,onPageShow:null,onPaste:null,onPause:null,onPlay:null,onPlaying:null,onPopState:null,onProgress:null,onRateChange:null,onRepeat:null,onReset:null,onResize:null,onScroll:null,onSeeked:null,onSeeking:null,onSelect:null,onShow:null,onStalled:null,onStorage:null,onSubmit:null,onSuspend:null,onTimeUpdate:null,onToggle:null,onUnload:null,onVolumeChange:null,onWaiting:null,onZoom:null,opacity:null,operator:null,order:null,orient:null,orientation:null,origin:null,overflow:null,overlay:null,overlinePosition:Q,overlineThickness:Q,paintOrder:null,panose1:null,path:null,pathLength:Q,patternContentUnits:null,patternTransform:null,patternUnits:null,phase:null,ping:at,pitch:null,playbackOrder:null,pointerEvents:null,points:null,pointsAtX:Q,pointsAtY:Q,pointsAtZ:Q,preserveAlpha:null,preserveAspectRatio:null,primitiveUnits:null,propagate:null,property:Gn,r:null,radius:null,referrerPolicy:null,refX:null,refY:null,rel:Gn,rev:Gn,renderingIntent:null,repeatCount:null,repeatDur:null,requiredExtensions:Gn,requiredFeatures:Gn,requiredFonts:Gn,requiredFormats:Gn,resource:null,restart:null,result:null,rotate:null,rx:null,ry:null,scale:null,seed:null,shapeRendering:null,side:null,slope:null,snapshotTime:null,specularConstant:Q,specularExponent:Q,spreadMethod:null,spacing:null,startOffset:null,stdDeviation:null,stemh:null,stemv:null,stitchTiles:null,stopColor:null,stopOpacity:null,strikethroughPosition:Q,strikethroughThickness:Q,string:null,stroke:null,strokeDashArray:Gn,strokeDashOffset:null,strokeLineCap:null,strokeLineJoin:null,strokeMiterLimit:Q,strokeOpacity:Q,strokeWidth:null,style:null,surfaceScale:Q,syncBehavior:null,syncBehaviorDefault:null,syncMaster:null,syncTolerance:null,syncToleranceDefault:null,systemLanguage:Gn,tabIndex:Q,tableValues:null,target:null,targetX:Q,targetY:Q,textAnchor:null,textDecoration:null,textRendering:null,textLength:null,timelineBegin:null,title:null,transformBehavior:null,type:null,typeOf:Gn,to:null,transform:null,transformOrigin:null,u1:null,u2:null,underlinePosition:Q,underlineThickness:Q,unicode:null,unicodeBidi:null,unicodeRange:null,unitsPerEm:Q,values:null,vAlphabetic:Q,vMathematical:Q,vectorEffect:null,vHanging:Q,vIdeographic:Q,version:null,vertAdvY:Q,vertOriginX:Q,vertOriginY:Q,viewBox:null,viewTarget:null,visibility:null,width:null,widths:null,wordSpacing:null,writingMode:null,x:null,x1:null,x2:null,xChannelSelector:null,xHeight:Q,y:null,y1:null,y2:null,yChannelSelector:null,z:null,zoomAndPan:null},space:"svg",transform:yR}),wR=hl({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()}}),SR=hl({attributes:{xmlnsxlink:"xmlns:xlink"},properties:{xmlnsXLink:null,xmlns:null},space:"xmlns",transform:bR}),kR=hl({properties:{xmlBase:null,xmlLang:null,xmlSpace:null},space:"xml",transform(e,t){return"xml:"+t.slice(3).toLowerCase()}}),aW={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"},lW=/[A-Z]/g,TS=/-[a-z]/g,cW=/^data[-\w.:]+$/i;function uW(e,t){const n=x0(t);let r=t,i=Wn;if(n in e.normal)return e.property[e.normal[n]];if(n.length>4&&n.slice(0,4)==="data"&&cW.test(t)){if(t.charAt(4)==="-"){const s=t.slice(5).replace(TS,hW);r="data"+s.charAt(0).toUpperCase()+s.slice(1)}else{const s=t.slice(4);if(!TS.test(s)){let o=s.replace(lW,dW);o.charAt(0)!=="-"&&(o="-"+o),t="data"+o}}i=xy}return new i(r,t)}function dW(e){return"-"+e.toLowerCase()}function hW(e){return e.charAt(1).toUpperCase()}const fW=_R([xR,sW,wR,SR,kR],"html"),yy=_R([xR,oW,wR,SR,kR],"svg");function pW(e){return e.join(" ").trim()}var by={},PS=/\/\*[^*]*\*+([^/*][^*]*\*+)*\//g,mW=/\n/g,gW=/^\s*/,vW=/^(\*?[-#/*\\\w]+(\[[0-9a-z_-]+\])?)\s*/,_W=/^:\s*/,xW=/^((?:'(?:\\'|.)*?'|"(?:\\"|.)*?"|\([^)]*?\)|[^};])+)/,yW=/^[;\s]*/,bW=/^\s+|\s+$/g,wW=`
|
|
475
|
+
`)},u7=0,qo=[];function d7(e){var t=g.useRef([]),n=g.useRef([0,0]),r=g.useRef(),i=g.useState(u7++)[0],s=g.useState(XP)[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=M9([e.lockRef.current],(e.shards||[]).map(rS),!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 _=md(v),x=n.current,y="deltaX"in v?v.deltaX:x[0]-_[0],w="deltaY"in v?v.deltaY:x[1]-_[1],k,C=v.target,N=Math.abs(y)>Math.abs(w)?"h":"v";if("touches"in v&&N==="h"&&C.type==="range")return!1;var T=window.getSelection(),B=T&&T.anchorNode,P=B?B===C||B.contains(C):!1;if(P)return!1;var j=tS(N,C);if(!j)return!0;if(j?k=N:(k=N==="v"?"h":"v",j=tS(N,C)),!j)return!1;if(!r.current&&"changedTouches"in v&&(y||w)&&(r.current=k),!k)return!0;var I=r.current||k;return a7(I,b,v,I==="h"?y:w)},[]),l=g.useCallback(function(v){var b=v;if(!(!qo.length||qo[qo.length-1]!==s)){var _="deltaY"in b?nS(b):md(b),x=t.current.filter(function(k){return k.name===b.type&&(k.target===b.target||b.target===k.shadowParent)&&l7(k.delta,_)})[0];if(x&&x.should){b.cancelable&&b.preventDefault();return}if(!x){var y=(o.current.shards||[]).map(rS).filter(Boolean).filter(function(k){return k.contains(b.target)}),w=y.length>0?a(b,y[0]):!o.current.noIsolation;w&&b.cancelable&&b.preventDefault()}}},[]),c=g.useCallback(function(v,b,_,x){var y={name:v,delta:b,target:_,should:x,shadowParent:h7(_)};t.current.push(y),setTimeout(function(){t.current=t.current.filter(function(w){return w!==y})},1)},[]),u=g.useCallback(function(v){n.current=md(v),r.current=void 0},[]),d=g.useCallback(function(v){c(v.type,nS(v),v.target,a(v,e.lockRef.current))},[]),f=g.useCallback(function(v){c(v.type,md(v),v.target,a(v,e.lockRef.current))},[]);g.useEffect(function(){return qo.push(s),e.setCallbacks({onScrollCapture:d,onWheelCapture:d,onTouchMoveCapture:f}),document.addEventListener("wheel",l,Vo),document.addEventListener("touchmove",l,Vo),document.addEventListener("touchstart",u,Vo),function(){qo=qo.filter(function(v){return v!==s}),document.removeEventListener("wheel",l,Vo),document.removeEventListener("touchmove",l,Vo),document.removeEventListener("touchstart",u,Vo)}},[]);var p=e.removeScrollBar,m=e.inert;return g.createElement(g.Fragment,null,m?g.createElement(s,{styles:c7(i)}):null,p?g.createElement(e7,{noRelative:e.noRelative,gapMode:e.gapMode}):null)}function h7(e){for(var t=null;e!==null;)e instanceof ShadowRoot&&(t=e.host,e=e.host),e=e.parentNode;return t}const f7=F9(GP,d7);var Qx=g.forwardRef(function(e,t){return g.createElement(lp,Yr({},e,{ref:t,sideCar:f7}))});Qx.classNames=lp.classNames;var m0=["Enter"," "],p7=["ArrowDown","PageUp","Home"],JP=["ArrowUp","PageDown","End"],m7=[...p7,...JP],g7={ltr:[...m0,"ArrowRight"],rtl:[...m0,"ArrowLeft"]},v7={ltr:["ArrowLeft"],rtl:["ArrowRight"]},yu="Menu",[Xc,_7,x7]=lP(yu),[Lo,eI]=Ao(yu,[x7,ap,zP]),bu=ap(),tI=zP(),[nI,js]=Lo(yu),[y7,wu]=Lo(yu),rI=e=>{const{__scopeMenu:t,open:n=!1,children:r,dir:i,onOpenChange:s,modal:o=!0}=e,a=bu(t),[l,c]=g.useState(null),u=g.useRef(!1),d=li(s),f=cP(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(Yx,{...a,children:h.jsx(nI,{scope:t,open:n,onOpenChange:d,content:l,onContentChange:c,children:h.jsx(y7,{scope:t,onClose:g.useCallback(()=>d(!1),[d]),isUsingKeyboardRef:u,dir:f,modal:o,children:r})})})};rI.displayName=yu;var b7="MenuAnchor",Jx=g.forwardRef((e,t)=>{const{__scopeMenu:n,...r}=e,i=bu(n);return h.jsx(jP,{...i,...r,ref:t})});Jx.displayName=b7;var ey="MenuPortal",[w7,iI]=Lo(ey,{forceMount:void 0}),sI=e=>{const{__scopeMenu:t,forceMount:n,children:r,container:i}=e,s=js(ey,t);return h.jsx(w7,{scope:t,forceMount:n,children:h.jsx(Hi,{present:n||s.open,children:h.jsx(Zx,{asChild:!0,container:i,children:r})})})};sI.displayName=ey;var gr="MenuContent",[S7,ty]=Lo(gr),oI=g.forwardRef((e,t)=>{const n=iI(gr,e.__scopeMenu),{forceMount:r=n.forceMount,...i}=e,s=js(gr,e.__scopeMenu),o=wu(gr,e.__scopeMenu);return h.jsx(Xc.Provider,{scope:e.__scopeMenu,children:h.jsx(Hi,{present:r||s.open,children:h.jsx(Xc.Slot,{scope:e.__scopeMenu,children:o.modal?h.jsx(k7,{...i,ref:t}):h.jsx(C7,{...i,ref:t})})})})}),k7=g.forwardRef((e,t)=>{const n=js(gr,e.__scopeMenu),r=g.useRef(null),i=Kt(t,r);return g.useEffect(()=>{const s=r.current;if(s)return VP(s)},[]),h.jsx(ny,{...e,ref:i,trapFocus:n.open,disableOutsidePointerEvents:n.open,disableOutsideScroll:!0,onFocusOutside:Pe(e.onFocusOutside,s=>s.preventDefault(),{checkForDefaultPrevented:!1}),onDismiss:()=>n.onOpenChange(!1)})}),C7=g.forwardRef((e,t)=>{const n=js(gr,e.__scopeMenu);return h.jsx(ny,{...e,ref:t,trapFocus:!1,disableOutsidePointerEvents:!1,disableOutsideScroll:!1,onDismiss:()=>n.onOpenChange(!1)})}),E7=Kc("MenuContent.ScrollLock"),ny=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=js(gr,n),_=wu(gr,n),x=bu(n),y=tI(n),w=_7(n),[k,C]=g.useState(null),N=g.useRef(null),T=Kt(t,N,b.onContentChange),B=g.useRef(0),P=g.useRef(""),j=g.useRef(0),I=g.useRef(null),R=g.useRef("right"),L=g.useRef(0),z=m?Qx:g.Fragment,$=m?{as:E7,allowPinchZoom:!0}:void 0,F=O=>{var ye,$e;const E=P.current+O,H=w().filter(ue=>!ue.disabled),V=document.activeElement,A=(ye=H.find(ue=>ue.ref.current===V))==null?void 0:ye.textValue,ne=H.map(ue=>ue.textValue),oe=B7(ne,E,A),X=($e=H.find(ue=>ue.textValue===oe))==null?void 0:$e.ref.current;(function ue(Ie){P.current=Ie,window.clearTimeout(B.current),Ie!==""&&(B.current=window.setTimeout(()=>ue(""),1e3))})(E),X&&setTimeout(()=>X.focus())};g.useEffect(()=>()=>window.clearTimeout(B.current),[]),hP();const D=g.useCallback(O=>{var H,V;return R.current===((H=I.current)==null?void 0:H.side)&&$7(O,(V=I.current)==null?void 0:V.area)},[]);return h.jsx(S7,{scope:n,searchRef:P,onItemEnter:g.useCallback(O=>{D(O)&&O.preventDefault()},[D]),onItemLeave:g.useCallback(O=>{var E;D(O)||((E=N.current)==null||E.focus(),C(null))},[D]),onTriggerLeave:g.useCallback(O=>{D(O)&&O.preventDefault()},[D]),pointerGraceTimerRef:j,onPointerGraceIntentChange:g.useCallback(O=>{I.current=O},[]),children:h.jsx(z,{...$,children:h.jsx(Fx,{asChild:!0,trapped:i,onMountAutoFocus:Pe(s,O=>{var E;O.preventDefault(),(E=N.current)==null||E.focus({preventScroll:!0})}),onUnmountAutoFocus:o,children:h.jsx(np,{asChild:!0,disableOutsidePointerEvents:a,onEscapeKeyDown:c,onPointerDownOutside:u,onFocusOutside:d,onInteractOutside:f,onDismiss:p,children:h.jsx(N9,{asChild:!0,...y,dir:_.dir,orientation:"vertical",loop:r,currentTabStopId:k,onCurrentTabStopIdChange:C,onEntryFocus:Pe(l,O=>{_.isUsingKeyboardRef.current||O.preventDefault()}),preventScrollOnEntryFocus:!0,children:h.jsx(DP,{role:"menu","aria-orientation":"vertical","data-state":SI(b.open),"data-radix-menu-content":"",dir:_.dir,...x,...v,ref:T,style:{outline:"none",...v.style},onKeyDown:Pe(v.onKeyDown,O=>{const H=O.target.closest("[data-radix-menu-content]")===O.currentTarget,V=O.ctrlKey||O.altKey||O.metaKey,A=O.key.length===1;H&&(O.key==="Tab"&&O.preventDefault(),!V&&A&&F(O.key));const ne=N.current;if(O.target!==ne||!m7.includes(O.key))return;O.preventDefault();const X=w().filter(ye=>!ye.disabled).map(ye=>ye.ref.current);JP.includes(O.key)&&X.reverse(),D7(X)}),onBlur:Pe(e.onBlur,O=>{O.currentTarget.contains(O.target)||(window.clearTimeout(B.current),P.current="")}),onPointerMove:Pe(e.onPointerMove,Yc(O=>{const E=O.target,H=L.current!==O.clientX;if(O.currentTarget.contains(E)&&H){const V=O.clientX>L.current?"right":"left";R.current=V,L.current=O.clientX}}))})})})})})})});oI.displayName=gr;var N7="MenuGroup",ry=g.forwardRef((e,t)=>{const{__scopeMenu:n,...r}=e;return h.jsx(Tt.div,{role:"group",...r,ref:t})});ry.displayName=N7;var T7="MenuLabel",aI=g.forwardRef((e,t)=>{const{__scopeMenu:n,...r}=e;return h.jsx(Tt.div,{...r,ref:t})});aI.displayName=T7;var Zh="MenuItem",iS="menu.itemSelect",cp=g.forwardRef((e,t)=>{const{disabled:n=!1,onSelect:r,...i}=e,s=g.useRef(null),o=wu(Zh,e.__scopeMenu),a=ty(Zh,e.__scopeMenu),l=Kt(t,s),c=g.useRef(!1),u=()=>{const d=s.current;if(!n&&d){const f=new CustomEvent(iS,{bubbles:!0,cancelable:!0});d.addEventListener(iS,p=>r==null?void 0:r(p),{once:!0}),aP(d,f),f.defaultPrevented?c.current=!1:o.onClose()}};return h.jsx(lI,{...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===" "||m0.includes(d.key)&&(d.currentTarget.click(),d.preventDefault())})})});cp.displayName=Zh;var lI=g.forwardRef((e,t)=>{const{__scopeMenu:n,disabled:r=!1,textValue:i,...s}=e,o=ty(Zh,n),a=tI(n),l=g.useRef(null),c=Kt(t,l),[u,d]=g.useState(!1),[f,p]=g.useState("");return g.useEffect(()=>{const m=l.current;m&&p((m.textContent??"").trim())},[s.children]),h.jsx(Xc.ItemSlot,{scope:n,disabled:r,textValue:i??f,children:h.jsx(T9,{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,Yc(m=>{r?o.onItemLeave(m):(o.onItemEnter(m),m.defaultPrevented||m.currentTarget.focus({preventScroll:!0}))})),onPointerLeave:Pe(e.onPointerLeave,Yc(m=>o.onItemLeave(m))),onFocus:Pe(e.onFocus,()=>d(!0)),onBlur:Pe(e.onBlur,()=>d(!1))})})})}),P7="MenuCheckboxItem",cI=g.forwardRef((e,t)=>{const{checked:n=!1,onCheckedChange:r,...i}=e;return h.jsx(pI,{scope:e.__scopeMenu,checked:n,children:h.jsx(cp,{role:"menuitemcheckbox","aria-checked":Qh(n)?"mixed":n,...i,ref:t,"data-state":oy(n),onSelect:Pe(i.onSelect,()=>r==null?void 0:r(Qh(n)?!0:!n),{checkForDefaultPrevented:!1})})})});cI.displayName=P7;var uI="MenuRadioGroup",[I7,R7]=Lo(uI,{value:void 0,onValueChange:()=>{}}),dI=g.forwardRef((e,t)=>{const{value:n,onValueChange:r,...i}=e,s=li(r);return h.jsx(I7,{scope:e.__scopeMenu,value:n,onValueChange:s,children:h.jsx(ry,{...i,ref:t})})});dI.displayName=uI;var hI="MenuRadioItem",fI=g.forwardRef((e,t)=>{const{value:n,...r}=e,i=R7(hI,e.__scopeMenu),s=n===i.value;return h.jsx(pI,{scope:e.__scopeMenu,checked:s,children:h.jsx(cp,{role:"menuitemradio","aria-checked":s,...r,ref:t,"data-state":oy(s),onSelect:Pe(r.onSelect,()=>{var o;return(o=i.onValueChange)==null?void 0:o.call(i,n)},{checkForDefaultPrevented:!1})})})});fI.displayName=hI;var iy="MenuItemIndicator",[pI,M7]=Lo(iy,{checked:!1}),mI=g.forwardRef((e,t)=>{const{__scopeMenu:n,forceMount:r,...i}=e,s=M7(iy,n);return h.jsx(Hi,{present:r||Qh(s.checked)||s.checked===!0,children:h.jsx(Tt.span,{...i,ref:t,"data-state":oy(s.checked)})})});mI.displayName=iy;var A7="MenuSeparator",gI=g.forwardRef((e,t)=>{const{__scopeMenu:n,...r}=e;return h.jsx(Tt.div,{role:"separator","aria-orientation":"horizontal",...r,ref:t})});gI.displayName=A7;var L7="MenuArrow",vI=g.forwardRef((e,t)=>{const{__scopeMenu:n,...r}=e,i=bu(n);return h.jsx(OP,{...i,...r,ref:t})});vI.displayName=L7;var sy="MenuSub",[j7,_I]=Lo(sy),xI=e=>{const{__scopeMenu:t,children:n,open:r=!1,onOpenChange:i}=e,s=js(sy,t),o=bu(t),[a,l]=g.useState(null),[c,u]=g.useState(null),d=li(i);return g.useEffect(()=>(s.open===!1&&d(!1),()=>d(!1)),[s.open,d]),h.jsx(Yx,{...o,children:h.jsx(nI,{scope:t,open:r,onOpenChange:d,content:c,onContentChange:u,children:h.jsx(j7,{scope:t,contentId:Pi(),triggerId:Pi(),trigger:a,onTriggerChange:l,children:n})})})};xI.displayName=sy;var Kl="MenuSubTrigger",yI=g.forwardRef((e,t)=>{const n=js(Kl,e.__scopeMenu),r=wu(Kl,e.__scopeMenu),i=_I(Kl,e.__scopeMenu),s=ty(Kl,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(Jx,{asChild:!0,...c,children:h.jsx(lI,{id:i.triggerId,"aria-haspopup":"menu","aria-expanded":n.open,"aria-controls":i.contentId,"data-state":SI(n.open),...e,ref:gu(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,Yc(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,Yc(d=>{var p,m;u();const f=(p=n.content)==null?void 0:p.getBoundingClientRect();if(f){const v=(m=n.content)==null?void 0:m.dataset.side,b=v==="right",_=b?-5:5,x=f[b?"left":"right"],y=f[b?"right":"left"];s.onPointerGraceIntentChange({area:[{x:d.clientX+_,y:d.clientY},{x,y:f.top},{x:y,y:f.top},{x:y,y:f.bottom},{x,y:f.bottom}],side:v}),window.clearTimeout(a.current),a.current=window.setTimeout(()=>s.onPointerGraceIntentChange(null),300)}else{if(s.onTriggerLeave(d),d.defaultPrevented)return;s.onPointerGraceIntentChange(null)}})),onKeyDown:Pe(e.onKeyDown,d=>{var p;const f=s.searchRef.current!=="";e.disabled||f&&d.key===" "||g7[r.dir].includes(d.key)&&(n.onOpenChange(!0),(p=n.content)==null||p.focus(),d.preventDefault())})})})});yI.displayName=Kl;var bI="MenuSubContent",wI=g.forwardRef((e,t)=>{const n=iI(gr,e.__scopeMenu),{forceMount:r=n.forceMount,...i}=e,s=js(gr,e.__scopeMenu),o=wu(gr,e.__scopeMenu),a=_I(bI,e.__scopeMenu),l=g.useRef(null),c=Kt(t,l);return h.jsx(Xc.Provider,{scope:e.__scopeMenu,children:h.jsx(Hi,{present:r||s.open,children:h.jsx(Xc.Slot,{scope:e.__scopeMenu,children:h.jsx(ny,{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=v7[o.dir].includes(u.key);d&&f&&(s.onOpenChange(!1),(p=a.trigger)==null||p.focus(),u.preventDefault())})})})})})});wI.displayName=bI;function SI(e){return e?"open":"closed"}function Qh(e){return e==="indeterminate"}function oy(e){return Qh(e)?"indeterminate":e?"checked":"unchecked"}function D7(e){const t=document.activeElement;for(const n of e)if(n===t||(n.focus(),document.activeElement!==t))return}function O7(e,t){return e.map((n,r)=>e[(t+r)%e.length])}function B7(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=O7(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 z7(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 $7(e,t){if(!t)return!1;const n={x:e.clientX,y:e.clientY};return z7(n,t)}function Yc(e){return t=>t.pointerType==="mouse"?e(t):void 0}var F7=rI,H7=Jx,U7=sI,W7=oI,V7=ry,q7=aI,K7=cp,G7=cI,X7=dI,Y7=fI,Z7=mI,Q7=gI,J7=vI,eH=xI,tH=yI,nH=wI,up="DropdownMenu",[rH]=Ao(up,[eI]),wn=eI(),[iH,kI]=rH(up),CI=e=>{const{__scopeDropdownMenu:t,children:n,dir:r,open:i,defaultOpen:s,onOpenChange:o,modal:a=!0}=e,l=wn(t),c=g.useRef(null),[u,d]=vu({prop:i,defaultProp:s??!1,onChange:o,caller:up});return h.jsx(iH,{scope:t,triggerId:Pi(),triggerRef:c,contentId:Pi(),open:u,onOpenChange:d,onOpenToggle:g.useCallback(()=>d(f=>!f),[d]),modal:a,children:h.jsx(F7,{...l,open:u,onOpenChange:d,dir:r,modal:a,children:n})})};CI.displayName=up;var EI="DropdownMenuTrigger",NI=g.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,disabled:r=!1,...i}=e,s=kI(EI,n),o=wn(n);return h.jsx(H7,{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:gu(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())})})})});NI.displayName=EI;var sH="DropdownMenuPortal",TI=e=>{const{__scopeDropdownMenu:t,...n}=e,r=wn(t);return h.jsx(U7,{...r,...n})};TI.displayName=sH;var PI="DropdownMenuContent",II=g.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,i=kI(PI,n),s=wn(n),o=g.useRef(!1);return h.jsx(W7,{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)"}})});II.displayName=PI;var oH="DropdownMenuGroup",aH=g.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,i=wn(n);return h.jsx(V7,{...i,...r,ref:t})});aH.displayName=oH;var lH="DropdownMenuLabel",RI=g.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,i=wn(n);return h.jsx(q7,{...i,...r,ref:t})});RI.displayName=lH;var cH="DropdownMenuItem",MI=g.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,i=wn(n);return h.jsx(K7,{...i,...r,ref:t})});MI.displayName=cH;var uH="DropdownMenuCheckboxItem",AI=g.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,i=wn(n);return h.jsx(G7,{...i,...r,ref:t})});AI.displayName=uH;var dH="DropdownMenuRadioGroup",hH=g.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,i=wn(n);return h.jsx(X7,{...i,...r,ref:t})});hH.displayName=dH;var fH="DropdownMenuRadioItem",pH=g.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,i=wn(n);return h.jsx(Y7,{...i,...r,ref:t})});pH.displayName=fH;var mH="DropdownMenuItemIndicator",LI=g.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,i=wn(n);return h.jsx(Z7,{...i,...r,ref:t})});LI.displayName=mH;var gH="DropdownMenuSeparator",jI=g.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,i=wn(n);return h.jsx(Q7,{...i,...r,ref:t})});jI.displayName=gH;var vH="DropdownMenuArrow",_H=g.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,i=wn(n);return h.jsx(J7,{...i,...r,ref:t})});_H.displayName=vH;var xH=e=>{const{__scopeDropdownMenu:t,children:n,open:r,onOpenChange:i,defaultOpen:s}=e,o=wn(t),[a,l]=vu({prop:r,defaultProp:s??!1,onChange:i,caller:"DropdownMenuSub"});return h.jsx(eH,{...o,open:a,onOpenChange:l,children:n})},yH="DropdownMenuSubTrigger",DI=g.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,i=wn(n);return h.jsx(tH,{...i,...r,ref:t})});DI.displayName=yH;var bH="DropdownMenuSubContent",OI=g.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,i=wn(n);return h.jsx(nH,{...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)"}})});OI.displayName=bH;var wH=CI,SH=NI,BI=TI,zI=II,$I=RI,FI=MI,HI=AI,kH=LI,UI=jI,CH=xH,WI=DI,VI=OI;const ay=wH,ly=SH,dp=g.forwardRef(({className:e,sideOffset:t=4,...n},r)=>h.jsx(BI,{children:h.jsx(zI,{ref:r,sideOffset:t,className:he("z-50 min-w-[8rem] overflow-hidden rounded-md border border-border bg-elevated p-1","text-text-100 shadow-md",e),...n})}));dp.displayName=zI.displayName;const EH=CH,qI=g.forwardRef(({className:e,...t},n)=>h.jsx(WI,{ref:n,className:he("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}));qI.displayName=WI.displayName;const KI=g.forwardRef(({className:e,...t},n)=>h.jsx(BI,{children:h.jsx(VI,{ref:n,className:he("z-50 min-w-[6rem] overflow-hidden rounded-md border border-border bg-elevated p-1","text-text-100 shadow-md",e),...t})}));KI.displayName=VI.displayName;const bi=g.forwardRef(({className:e,inset:t,...n},r)=>h.jsx(FI,{ref:r,className:he("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}));bi.displayName=FI.displayName;const NH=g.forwardRef(({className:e,children:t,checked:n,...r},i)=>h.jsxs(HI,{ref:i,checked:n,className:he("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(kH,{children:h.jsx(cl,{className:"h-3.5 w-3.5"})})}),t]}));NH.displayName=HI.displayName;const GI=g.forwardRef(({className:e,...t},n)=>h.jsx(UI,{ref:n,className:he("-mx-1 my-1 h-px bg-border",e),...t}));GI.displayName=UI.displayName;const TH=g.forwardRef(({className:e,...t},n)=>h.jsx($I,{ref:n,className:he("px-2 py-1.5 text-xs font-semibold text-text-400",e),...t}));TH.displayName=$I.displayName;function PH({tool:e,className:t}){const n=b8(e);return h.jsx("span",{"data-testid":n?`session-icon-${e}`:"session-icon-default","aria-label":n?$x(e):"未知引擎",className:he("w-3.5 h-3.5 shrink-0 inline-flex items-center justify-center",tp(e),t),children:h.jsx(ep,{tool:e,className:"w-full h-full"})})}function XI(e){return e.compositionActive||!!e.nativeIsComposing||e.keyCode===229}function YI(e){return e.key==="Enter"&&!e.shiftKey&&!XI(e)}function Su(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(YI({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 IH({open:e,initialLabel:t,placeholder:n,onSubmit:r,onCancel:i}){const[s,o]=g.useState(t);g.useEffect(()=>{e&&o(t)},[e,t]);const a=Su(()=>r({label:s.trim()}),i);return e?Ja.createPortal(h.jsx("div",{className:"fixed inset-0 z-[10000] flex items-center justify-center bg-bg-0/40 backdrop-blur-[2px]",onClick:i,"data-testid":"session-edit-dialog-overlay",children:h.jsxs("div",{"data-testid":"session-edit-dialog",className:"w-[420px] max-w-[calc(100vw-32px)] rounded-2xl border border-text-100/[0.12] flex flex-col gap-4 p-5",style:{backgroundColor:"var(--bg-0)",boxShadow:"0 12px 40px rgba(0,0,0,0.04)"},onClick:l=>l.stopPropagation(),children:[h.jsx("div",{className:"text-[15px] font-semibold text-text-100",children:"Edit session"}),h.jsxs("div",{children:[h.jsx("label",{className:"block text-[12px] font-semibold text-text-200 mb-1",children:"Label"}),h.jsx("input",{autoFocus:!0,type:"text",value:s,onChange:l=>o(l.target.value),...a,placeholder:n,"data-testid":"session-edit-dialog-label",className:"w-full px-3 py-2 text-[13px] bg-bg-50 border border-bg-300 rounded-lg focus:outline-none focus:border-text-300 transition-colors"})]}),h.jsxs("div",{className:"flex justify-end gap-2 pt-1",children:[h.jsx("button",{type:"button",onClick:i,className:"px-4 py-1.5 text-[12px] text-text-300 rounded-lg hover:bg-text-100/5 transition-colors cursor-pointer",children:"Cancel"}),h.jsx("button",{type:"button",onClick:()=>r({label:s.trim()}),"data-testid":"session-edit-dialog-save",className:"px-4 py-1.5 text-[12px] font-medium text-bg-0 rounded-lg bg-text-100 hover:bg-text-200 transition-colors cursor-pointer",children:"Save"})]})]})}),document.body):null}const RH=10,MH=20,AH=16,LH=20,jH=60,DH=4;function OH({session:e,active:t,hasUnread:n,running:r=!1,awaitingUser:i=!1,onSelect:s,onEdit:o,onDelete:a,onPin:l,onArchive:c,archiveShortcut:u=!1,depth:d=0,chevron:f,showCopyResume:p=!0,contactDisplayName:m}){const[v,b]=g.useState(!1),_=!!e.pinnedAt,x=d===0,y=d===0&&!!c,w=RH+d*MH,k=g.useCallback(async()=>{const B=sP(e);if(B)try{await navigator.clipboard.writeText(B)}catch{}},[e]),C=e.appBuilderProject?`[app] ${e.appBuilderProject}`:e.label||e.larkChatName||e.larkChatId||e.cwd.split("/").filter(Boolean).pop()||e.sessionId.slice(0,8),N=e.originOwnerPrincipalId,T=N?`@${m??`…${N.slice(-8)}`}`:null;return h.jsxs(h.Fragment,{children:[h.jsxs("div",{"data-testid":`session-item-${e.sessionId}`,onClick:s,style:{paddingLeft:w,display:"grid",gridTemplateColumns:`${AH}px ${LH}px 1fr auto ${jH}px`,gridTemplateAreas:'"chev icon name dot time"',columnGap:`${DH}px`,alignItems:"center"},className:he("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(PH,{tool:e.tool})}),h.jsxs("div",{style:{gridArea:"name"},className:"flex items-center gap-1 min-w-0",children:[e.dispatchedFromSessionId?h.jsx(xz,{"data-testid":`dispatched-icon-${e.sessionId}`,className:"w-3 h-3 text-accent shrink-0",strokeWidth:2.25,"aria-label":"dispatched from another session",children:h.jsx("title",{children:"由另一个 session dispatch 派生"})}):null,e.shiftFiredFromSessionId?h.jsx(KB,{"data-testid":`shift-fired-icon-${e.sessionId}`,className:"w-3 h-3 text-accent shrink-0",strokeWidth:2.25,"aria-label":"fired by clawd-shift scheduler",children:h.jsx("title",{children:"由 shift 排班到点 fire 派生"})}):null,e.larkChatId?h.jsx(Vz,{"data-testid":`lark-chat-icon-${e.sessionId}`,className:"w-3 h-3 text-accent shrink-0",strokeWidth:2.25,"aria-label":"driven by feishu chat",children:h.jsx("title",{children:e.larkChatType==="p2p"?"飞书私聊会话(对方消息驱动)":"飞书群会话(群成员 @ bot 驱动)"})}):null,h.jsx("span",{"data-testid":`session-title-${e.sessionId}`,className:he("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:C}),T?h.jsx("span",{"data-testid":`session-mirror-chip-${e.sessionId}`,title:`在 ${T.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:T}):null]}),i?h.jsx(ez,{"data-testid":`awaiting-dot-${e.sessionId}`,style:{gridArea:"dot"},className:"w-3 h-3 text-warning shrink-0 animate-pulse",strokeWidth:2.25,"aria-label":"awaiting user"}):n?h.jsx("span",{"data-testid":`unread-dot-${e.sessionId}`,style:{gridArea:"dot"},className:"w-2 h-2 rounded-full bg-error shrink-0","aria-label":"unread"}):r?h.jsx("span",{"data-testid":`running-dot-${e.sessionId}`,style:{gridArea:"dot"},className:"w-2 h-2 rounded-full bg-success shrink-0 animate-pulse","aria-label":"running"}):null,h.jsx("span",{style:{gridArea:"time"},className:he("text-[11px] text-text-400/70 text-right shrink-0","transition-opacity duration-150 group-hover:opacity-0"),children:e.updatedAt?w8(e.updatedAt):""}),o||a||l||c?h.jsxs("div",{className:"absolute right-2 top-[3px] flex items-center opacity-0 group-hover:opacity-100 data-[state=open]:opacity-100 transition-opacity",children:[u&&y&&c?h.jsx("button",{type:"button",title:"归档",onClick:B=>{B.stopPropagation(),c(e.sessionId,!0)},className:"flex items-center justify-center w-7 h-7 rounded-md text-text-400 hover:text-text-100 hover:bg-text-100/5 transition-colors cursor-pointer","aria-label":"archive session","data-testid":`archive-shortcut-${e.sessionId}`,children:h.jsx(Cw,{className:"w-4 h-4"})}):null,h.jsxs(ay,{modal:!1,children:[h.jsx(ly,{asChild:!0,children:h.jsx("button",{type:"button",onClick:B=>B.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(jT,{className:"w-4 h-4"})})}),h.jsxs(dp,{align:"end",onClick:B=>B.stopPropagation(),children:[l&&x&&h.jsxs(bi,{onSelect:()=>l(e.sessionId,!_),"data-testid":`session-${_?"unpin":"pin"}-${e.sessionId}`,children:[_?h.jsx(e$,{className:"w-3 h-3 mr-2 text-text-400"}):h.jsx(n$,{className:"w-3 h-3 mr-2 text-text-400"}),_?"Unpin":"Pin"]}),y&&c&&h.jsxs(bi,{onSelect:()=>c(e.sessionId,!0),"data-testid":`session-archive-${e.sessionId}`,children:[h.jsx(Cw,{className:"w-3 h-3 mr-2 text-text-400"}),"Archive"]}),o&&h.jsxs(bi,{onSelect:()=>b(!0),"data-testid":`session-rename-${e.sessionId}`,children:[h.jsx(BT,{className:"w-3 h-3 mr-2 text-text-400"}),"Rename"]}),p&&e.toolSessionId?h.jsxs(bi,{onSelect:()=>void k(),"data-testid":`session-copy-resume-${e.sessionId}`,children:[h.jsx(Jf,{className:"w-3 h-3 mr-2 text-text-400"}),"Copy Resume Command"]}):null,(l||o||p&&e.toolSessionId)&&a&&h.jsx(GI,{}),a&&h.jsxs(bi,{onSelect:()=>void a(e.sessionId),className:"text-destructive focus:text-destructive focus:bg-destructive/10","data-testid":`session-delete-${e.sessionId}`,children:[h.jsx(Ox,{className:"w-3 h-3 mr-2"}),"Delete"]})]})]})]}):null]}),o?h.jsx(IH,{open:v,initialLabel:e.label??"",placeholder:e.cwd.split("/").pop()||"",onSubmit:B=>{o(e.sessionId,B),b(!1)},onCancel:()=>b(!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,archiveShortcut:d,getContactDisplayName:f,showCopyResume:p}){const m=e.children.length>0,{isCollapsed:v,toggle:b}=$B(),_=!v(e.session.sessionId),x=g.useCallback(w=>{w.stopPropagation(),b(e.session.sessionId)},[b,e.session.sessionId]),y=m?h.jsx("button",{type:"button",onClick:x,"data-testid":`session-chevron-${e.session.sessionId}`,"aria-label":_?"collapse":"expand","aria-expanded":_,className:"shrink-0 flex items-center justify-center w-4 h-4 text-text-400 hover:text-text-100 cursor-pointer",children:_?h.jsx(ir,{className:"w-3 h-3"}):h.jsx(Un,{className:"w-3 h-3"})}):null;return h.jsxs("div",{"data-testid":`session-tree-node-${e.session.sessionId}`,children:[h.jsx(OH,{session:e.session,active:n===e.session.sessionId,hasUnread:(r==null?void 0:r.has(e.session.sessionId))??!1,running:(i==null?void 0:i.has(e.session.sessionId))??!1,awaitingUser:(s==null?void 0:s.has(e.session.sessionId))??!1,onSelect:()=>o(e.session.sessionId),onEdit:a,onDelete:l,onPin:c,onArchive:u,archiveShortcut:d,showCopyResume:p,depth:t,chevron:y,contactDisplayName:e.session.originOwnerPrincipalId?f==null?void 0:f(e.session.originOwnerPrincipalId):void 0}),m&&_?h.jsx("div",{"data-testid":`session-tree-children-${e.session.sessionId}`,children:e.children.map(w=>h.jsx(cy,{node:w,depth:t+1,activeId:n,unreadIds:r,runningIds:i,awaitingIds:s,onSelect:o,onEdit:a,onDelete:l,onPin:c,onArchive:u,archiveShortcut:d,getContactDisplayName:f,showCopyResume:p},w.session.sessionId))}):null]})}function BH(e){return e.forkedFromSessionId??e.dispatchedFromSessionId??e.shiftFiredFromSessionId}function ZI(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=BH(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(zH).map(i)}function QI(e){return[...e].sort((t,n)=>t.session.updatedAt<n.session.updatedAt?1:t.session.updatedAt>n.session.updatedAt?-1:0)}function zH(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 $H(e){return e.appBuilderProject?`[app] ${e.appBuilderProject}`:e.label?e.label:e.cwd.split("/").filter(Boolean).pop()??""}function sS(e,t){const n=t.trim().toLowerCase();return n===""?!0:e.toLowerCase().includes(n)}const FH={isCollapsed:()=>!1,toggle:()=>{},prune:()=>{}};function HH({personas:e,activePersonaId:t,onSelectPersona:n,onCreateSession:r,sessions:i,activeSessionId:s,awaitingIds:o,runningIds:a,unreadIds:l,onSelectSession:c,onDeleteSession:u,ownerPrincipalId:d,creatorDisplayNameByOwnerId:f,isPersonaExpanded:p,onTogglePersonaExpanded:m,onEditSession:v,onPinSession:b,showCopyResume:_,treatSessionsAsRoots:x,searchQuery:y}){const[w,k]=g.useState(null),[C,N]=g.useState(()=>new Set),T=p??(I=>C.has(I)),B=g.useCallback(I=>{if(m){m(I);return}N(R=>{const L=new Set(R);return L.has(I)?L.delete(I):L.add(I),L})},[m]),P=g.useMemo(()=>i==null?void 0:i.filter(I=>!I.ephemeral),[i]);if(e.length===0)return h.jsx(UH,{});const j=(y??"").trim();return j?h.jsx(Lx.Provider,{value:FH,children:h.jsx("div",{"data-testid":"my-personas-list",className:"flex flex-col gap-0.5",children:e.map(I=>{const R=P?P.filter(F=>F.ownerPersonaId===I.personaId).sort((F,D)=>D.updatedAt>F.updatedAt?1:-1):[],L=sS(I.label,j),z=R.filter(F=>sS($H(F),j));if(!L&&z.length===0)return null;const $=L?R:z;return h.jsx(oS,{persona:I,active:I.personaId===t,editing:!1,onSelectPersona:n,onSubmitCreateSession:()=>{},onCancelCreateSession:()=>{},personaSessions:$,collapsed:!1,onToggleCollapsed:()=>{},activeSessionId:s??null,awaitingIds:o,runningIds:a,unreadIds:l,onSelectSession:c,onDeleteSession:u,onEditSession:v,onPinSession:b,showCopyResume:_,treatSessionsAsRoots:x,ownerPrincipalId:d,creatorDisplayNameByOwnerId:f},I.personaId)})})}):h.jsx("div",{"data-testid":"my-personas-list",className:"flex flex-col gap-0.5",children:e.map(I=>{const R=P?P.filter(L=>L.ownerPersonaId===I.personaId).sort((L,z)=>z.updatedAt>L.updatedAt?1:-1):[];return h.jsx(oS,{persona:I,active:I.personaId===t,editing:I.personaId===w,onSelectPersona:n,onStartCreateSession:r?()=>k(I.personaId):void 0,onSubmitCreateSession:L=>{k(null),r==null||r(I.personaId,L)},onCancelCreateSession:()=>k(null),personaSessions:R,collapsed:!T(I.personaId),onToggleCollapsed:()=>B(I.personaId),activeSessionId:s??null,awaitingIds:o,runningIds:a,unreadIds:l,onSelectSession:c,onDeleteSession:u,onEditSession:v,onPinSession:b,showCopyResume:_,treatSessionsAsRoots:x,ownerPrincipalId:d,creatorDisplayNameByOwnerId:f},I.personaId)})})}function UH(){return h.jsx("div",{className:"px-3 py-3 text-[11px] leading-relaxed text-text-400",children:"还没有 persona。点上方 Personas 标题右侧 + 创建第一个。"})}function oS({persona:e,active:t,editing:n,onSelectPersona:r,onStartCreateSession:i,onSubmitCreateSession:s,onCancelCreateSession:o,personaSessions:a,collapsed:l,onToggleCollapsed:c,activeSessionId:u,awaitingIds:d,runningIds:f,unreadIds:p,onSelectSession:m,onDeleteSession:v,onEditSession:b,onPinSession:_,showCopyResume:x,treatSessionsAsRoots:y,ownerPrincipalId:w,creatorDisplayNameByOwnerId:k}){const C=a.length>0,N=!l,T=g.useMemo(()=>{const j=[],I=new Map;for(const R of a){const L=R.creatorPrincipalId;if(R.larkChatId!=null||!L||w&&L===w){j.push(R);continue}const z=L,$=(k==null?void 0:k.get(z))??`…${z.slice(-8)}`,F=I.get(z);F?F.sessions.push(R):I.set(z,{groupKey:z,displayName:$,sessions:[R]})}return{self:j,byPeer:[...I.values()]}},[a,w,k]),B=T.byPeer.length>0,P=g.useMemo(()=>N&&!B?QI(ZI(a)):[],[N,B,a]);return h.jsxs("div",{"data-testid":`persona-node-${e.personaId}`,children:[h.jsxs("div",{className:he("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:[C?h.jsx("button",{type:"button",onClick:j=>{j.stopPropagation(),c()},"aria-label":N?"collapse":"expand","aria-expanded":N,"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:N?h.jsx(ir,{className:"h-3 w-3"}):h.jsx(Un,{className:"h-3 w-3"})}):h.jsx("span",{className:"h-4 w-4 shrink-0","aria-hidden":"true"}),h.jsx(ep,{tool:e.tool,className:he("h-3.5 w-3.5 shrink-0",tp(e.tool))}),h.jsx("span",{className:"flex-1 truncate text-[13px]",children:e.label}),C?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:j=>{j.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(o$,{className:"h-3.5 w-3.5"})}):null]}),n?h.jsx(WH,{personaId:e.personaId,tool:e.tool,onSubmit:s,onCancel:o}):null,C&&N?h.jsx("div",{"data-testid":`persona-sessions-${e.personaId}`,children:B?h.jsxs(h.Fragment,{children:[T.self.length>0&&h.jsx(aS,{groupKey:`${e.personaId}-self`,label:"我自己",testId:`persona-sessions-${e.personaId}-self`,sessions:T.self,activeSessionId:u,awaitingIds:d,runningIds:f,unreadIds:p,onSelectSession:m,onDeleteSession:v,onEditSession:b,onPinSession:_,showCopyResume:x}),T.byPeer.map(j=>h.jsx(aS,{groupKey:`${e.personaId}-peer-${j.groupKey}`,label:j.displayName,testId:`persona-sessions-${e.personaId}-peer-${j.groupKey}`,sessions:j.sessions,activeSessionId:u,awaitingIds:d,runningIds:f,unreadIds:p,onSelectSession:m,onDeleteSession:v,onEditSession:b,onPinSession:_,showCopyResume:x},`${e.personaId}-peer-${j.groupKey}`))]}):P.map(j=>h.jsx(cy,{node:j,depth:y?0:1,activeId:u,unreadIds:p,runningIds:f,awaitingIds:d,onSelect:I=>m==null?void 0:m(I),onDelete:v,onEdit:b,onPin:_,showCopyResume:x},j.session.sessionId))}):null]})}function aS({label:e,testId:t,sessions:n,activeSessionId:r,awaitingIds:i,runningIds:s,unreadIds:o,onSelectSession:a,onDeleteSession:l,onEditSession:c,onPinSession:u,showCopyResume:d}){const[f,p]=g.useState(!1),m=!f,v=g.useMemo(()=>m?QI(ZI(n)):[],[m,n]);return h.jsxs("div",{"data-testid":t,children:[h.jsxs("button",{type:"button",onClick:()=>p(b=>!b),"aria-label":m?"collapse":"expand","aria-expanded":m,"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:[m?h.jsx(ir,{className:"h-3 w-3"}):h.jsx(Un,{className:"h-3 w-3"}),h.jsx(FT,{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})]}),m&&h.jsx("div",{children:v.map(b=>h.jsx(cy,{node:b,depth:2,activeId:r,unreadIds:o,runningIds:s,awaitingIds:i,onSelect:_=>a==null?void 0:a(_),onDelete:l,onEdit:c,onPin:u,showCopyResume:d},b.session.sessionId))})]})}function WH({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=Su(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(ep,{tool:t,className:he("h-3 w-3 shrink-0",tp(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(cl,{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(Br,{className:"h-3 w-3"})})]})}function VH(e,t){const n=getComputedStyle(e),r=parseFloat(n.fontSize);return t*r}function qH(e,t){const n=getComputedStyle(e.ownerDocument.documentElement),r=parseFloat(n.fontSize);return t*r}function KH(e){return e/100*window.innerHeight}function GH(e){return e/100*window.innerWidth}function XH(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 Gl({groupSize:e,panelElement:t,styleProp:n}){let r;const[i,s]=XH(n);switch(s){case"%":{r=i/100*e;break}case"px":{r=i;break}case"rem":{r=qH(t,i);break}case"em":{r=VH(t,i);break}case"vh":{r=KH(i);break}case"vw":{r=GH(i);break}}return r}function Nn(e){return parseFloat(e.toFixed(3))}function Fa({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 g0(e){const{panels:t}=e,n=Fa({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=Gl({groupSize:n,panelElement:i,styleProp:s.collapsedSize});o=Nn(u/n*100)}let a;if(s.defaultSize!==void 0){const u=Gl({groupSize:n,panelElement:i,styleProp:s.defaultSize});a=Nn(u/n*100)}let l=0;if(s.minSize!==void 0){const u=Gl({groupSize:n,panelElement:i,styleProp:s.minSize});l=Nn(u/n*100)}let c=100;if(s.maxSize!==void 0){const u=Gl({groupSize:n,panelElement:i,styleProp:s.maxSize});c=Nn(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 v0(e,t){return Array.from(t).sort(e==="horizontal"?YH:ZH)}function YH(e,t){const n=e.element.offsetLeft-t.element.offsetLeft;return n!==0?n:e.element.offsetWidth-t.element.offsetWidth}function ZH(e,t){const n=e.element.offsetTop-t.element.offsetTop;return n!==0?n:e.element.offsetHeight-t.element.offsetHeight}function JI(e){return e!==null&&typeof e=="object"&&"nodeType"in e&&e.nodeType===Node.ELEMENT_NODE}function eR(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 QH({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}=eR(r,o),c=e==="horizontal"?a:l;c<s&&(s=c,i=o)}return rt(i,"No rect found"),i}let gd;function JH(){return gd===void 0&&(typeof matchMedia=="function"?gd=!!matchMedia("(pointer:coarse)").matches:gd=!1),gd}function tR(e){const{element:t,orientation:n,panels:r,separators:i}=e,s=v0(n,Array.from(t.children).filter(JI).map(m=>({element:m}))).map(({element:m})=>m),o=[];let a=!1,l=!1,c=-1,u=-1,d=0,f,p=[];{let m=-1;for(const v of s)v.hasAttribute("data-panel")&&(m++,v.hasAttribute("data-disabled")||(d++,c===-1&&(c=m),u=m))}if(d>1){let m=-1;for(const v of s)if(v.hasAttribute("data-panel")){m++;const b=r.find(_=>_.element===v);if(b){if(f){const _=f.element.getBoundingClientRect(),x=v.getBoundingClientRect();let y;if(l){const w=n==="horizontal"?new DOMRect(_.right,_.top,0,_.height):new DOMRect(_.left,_.bottom,_.width,0),k=n==="horizontal"?new DOMRect(x.left,x.top,0,x.height):new DOMRect(x.left,x.top,x.width,0);switch(p.length){case 0:{y=[w,k];break}case 1:{const C=p[0],N=QH({orientation:n,rects:[_,x],targetRect:C.element.getBoundingClientRect()});y=[C,N===_?k:w];break}default:{y=p;break}}}else p.length?y=p:y=[n==="horizontal"?new DOMRect(_.right,x.top,x.left-_.right,x.height):new DOMRect(x.left,_.bottom,x.width,x.top-_.bottom)];for(const w of y){let k="width"in w?w:w.element.getBoundingClientRect();const C=JH()?e.resizeTargetMinimumSize.coarse:e.resizeTargetMinimumSize.fine;if(k.width<C){const T=C-k.width;k=new DOMRect(k.x-T/2,k.y,k.width+T,k.height)}if(k.height<C){const T=C-k.height;k=new DOMRect(k.x,k.y-T/2,k.width,k.height+T)}const N=m<=c||m>u;!a&&!N&&o.push({group:e,groupSize:Fa({group:e}),panels:[f,b],separator:"width"in w?void 0:w,rect:k}),a=!1}}l=!1,f=b,p=[]}}else if(v.hasAttribute("data-separator")){v.ariaDisabled!==null&&(a=!0);const b=i.find(_=>_.element===v);b?p.push(b):(f=void 0,p=[])}else l=!0}return o}var ls;class nR{constructor(){f1(this,ls,{})}addListener(t,n){const r=bl(this,ls)[t];return r===void 0?bl(this,ls)[t]=[n]:r.includes(n)||r.push(n),()=>{this.removeListener(t,n)}}emit(t,n){const r=bl(this,ls)[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(){p1(this,ls,{})}removeListener(t,n){const r=bl(this,ls)[t];if(r!==void 0){const i=r.indexOf(n);i>=0&&r.splice(i,1)}}}ls=new WeakMap;let Ca={cursorFlags:0,state:"inactive"};const uy=new nR;function xo(){return Ca}function eU(e){return uy.addListener("change",e)}function tU(e){const t=Ca,n={...Ca};n.cursorFlags=e,Ca=n,uy.emit("change",{prev:t,next:n})}function Ea(e){const t=Ca;Ca=e,uy.emit("change",{prev:t,next:e})}const nU=e=>e,Om=()=>{},rR=1,iR=2,sR=4,oR=8,lS=3,cS=12;let vd;function uS(){return vd===void 0&&(vd=!1,typeof window<"u"&&(window.navigator.userAgent.includes("Chrome")||window.navigator.userAgent.includes("Firefox"))&&(vd=!0)),vd}function rU({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&&uS()){const s=(e&rR)!==0,o=(e&iR)!==0,a=(e&sR)!==0,l=(e&oR)!==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 uS()?r>0&&i>0?"move":r>0?"ew-resize":"ns-resize":r>0&&i>0?"grab":r>0?"col-resize":"row-resize"}}const dS=new WeakMap;function dy(e){if(e.defaultView===null||e.defaultView===void 0)return;let{prevStyle:t,styleSheet:n}=dS.get(e)??{};n===void 0&&(n=new e.defaultView.CSSStyleSheet,e.adoptedStyleSheets&&(Object.isExtensible(e.adoptedStyleSheets)?e.adoptedStyleSheets.push(n):e.adoptedStyleSheets=[...e.adoptedStyleSheets,n]));const r=xo();switch(r.state){case"active":case"hover":{const i=rU({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}}dS.set(e,{prevStyle:t,styleSheet:n})}let Qr=new Map;const aR=new nR;function iU(e){Qr=new Map(Qr),Qr.delete(e)}function hS(e,t){for(const[n]of Qr)if(n.id===e)return n}function ws(e,t){for(const[n,r]of Qr)if(n.id===e)return r;if(t)throw Error(`Could not find data for Group with id ${e}`)}function jo(){return Qr}function hy(e,t){return aR.addListener("groupChange",n=>{n.group.id===e&&t(n)})}function Oi(e,t,n){const r=Qr.get(e);Qr=new Map(Qr),Qr.set(e,t),aR.emit("groupChange",{group:e,isUserInteraction:(n==null?void 0:n.isUserInteraction)===!0,prev:r,next:t})}function lR(e){const t=xo();let n=!1;switch(t.state){case"active":Ea({cursorFlags:0,state:"inactive"}),t.hitRegions.length>0&&(dy(e),n=!0,t.hitRegions.forEach(r=>{const i=ws(r.group.id,!0);Oi(r.group,i,{isUserInteraction:!0})}))}return n}function fS(e){e.defaultPrevented||lR(e.currentTarget)}function sU(e,t,n){let r,i={x:1/0,y:1/0};for(const s of t){const o=eR(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 oU(e){return e!==null&&typeof e=="object"&&"nodeType"in e&&e.nodeType===Node.DOCUMENT_FRAGMENT_NODE}function aU(e,t){if(e===t)throw new Error("Cannot compare node with itself");const n={a:gS(e),b:gS(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:mS(pS(n.a)),b:mS(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 lU=/\b(?:position|zIndex|opacity|transform|webkitTransform|mixBlendMode|filter|webkitFilter|isolation)\b/;function cU(e){const t=getComputedStyle(cR(e)??e).display;return t==="flex"||t==="inline-flex"}function uU(e){const t=getComputedStyle(e);return!!(t.position==="fixed"||t.zIndex!=="auto"&&(t.position!=="static"||cU(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"||lU.test(t.willChange)||t.webkitOverflowScrolling==="touch")}function pS(e){let t=e.length;for(;t--;){const n=e[t];if(rt(n,"Missing node"),uU(n))return n}return null}function mS(e){return e&&Number(getComputedStyle(e).zIndex)||0}function gS(e){const t=[];for(;e;)t.push(e),e=cR(e);return t}function cR(e){const{parentNode:t}=e;return oU(t)?t.host:t}function dU(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 hU({groupElement:e,hitRegion:t,pointerEventTarget:n}){if(!JI(n)||n.contains(e)||e.contains(n))return!0;if(aU(n,e)>0){let r=n;for(;r;){if(r.contains(e))return!0;if(dU(r.getBoundingClientRect(),t))return!1;r=r.parentElement}}return!0}function fy(e,t){const n=[];return t.forEach((r,i)=>{if(i.disabled)return;const s=tR(i),o=sU(i.orientation,s,{x:e.clientX,y:e.clientY});o&&o.distance.x<=0&&o.distance.y<=0&&hU({groupElement:i.element,hitRegion:o.hitRegion.rect,pointerEventTarget:e.target})&&n.push(o.hitRegion)}),n}function fU(e,t){if(e.length!==t.length)return!1;for(let n=0;n<e.length;n++)if(e[n]!=t[n])return!1;return!0}function _n(e,t,n=0){return Math.abs(Nn(e)-Nn(t))<=n}function Gr(e,t){return _n(e,t)?0:e>t?1:-1}function pa({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(Gr(r,l)<0)if(s){const c=(i+l)/2;Gr(r,c)<0?r=i:r=l}else r=l;return r=Math.min(a,r),r=Nn(r),r}function Zc({delta:e,initialLayout:t,panelConstraints:n,pivotIndices:r,prevLayout:i,trigger:s}){if(_n(e,0))return t;const o=s==="imperative-api",a=Object.values(t),l=Object.values(i),c=[...a],[u,d]=r;rt(u!=null,"Invalid first pivot index"),rt(d!=null,"Invalid second pivot index");let f=0;switch(s){case"keyboard":{{const v=e<0?d:u,b=n[v];rt(b,`Panel constraints not found for index ${v}`);const{collapsedSize:_=0,collapsible:x,minSize:y=0}=b;if(x){const w=a[v];if(rt(w!=null,`Previous layout not found for panel index ${v}`),_n(w,_)){const k=y-w;Gr(k,Math.abs(e))>0&&(e=e<0?0-k:k)}}}{const v=e<0?u:d,b=n[v];rt(b,`No panel constraints found for index ${v}`);const{collapsedSize:_=0,collapsible:x,minSize:y=0}=b;if(x){const w=a[v];if(rt(w!=null,`Previous layout not found for panel index ${v}`),_n(w,y)){const k=w-_;Gr(k,Math.abs(e))>0&&(e=e<0?0-k:k)}}}break}default:{const v=e<0?d:u,b=n[v];rt(b,`Panel constraints not found for index ${v}`);const _=a[v],{collapsible:x,collapsedSize:y,minSize:w}=b;if(x&&Gr(_,w)<0)if(e>0){const k=w-y,C=k/2,N=_+e;Gr(N,w)<0&&(e=Gr(e,C)<=0?0:k)}else{const k=w-y,C=100-k/2,N=_-e;Gr(N,w)<0&&(e=Gr(100+e,C)>0?0:-k)}break}}{const v=e<0?1:-1;let b=e<0?d:u,_=0;for(;;){const y=a[b];rt(y!=null,`Previous layout not found for panel index ${b}`);const w=pa({overrideDisabledPanels:o,panelConstraints:n[b],prevSize:y,size:100})-y;if(_+=w,b+=v,b<0||b>=n.length)break}const x=Math.min(Math.abs(e),Math.abs(_));e=e<0?0-x:x}{let v=e<0?u:d;for(;v>=0&&v<n.length;){const b=Math.abs(e)-Math.abs(f),_=a[v];rt(_!=null,`Previous layout not found for panel index ${v}`);const x=_-b,y=pa({overrideDisabledPanels:o,panelConstraints:n[v],prevSize:_,size:x});if(!_n(_,y)&&(f+=_-y,c[v]=y,f.toFixed(3).localeCompare(Math.abs(e).toFixed(3),void 0,{numeric:!0})>=0))break;e<0?v--:v++}}if(fU(l,c))return i;{const v=e<0?d:u,b=a[v];rt(b!=null,`Previous layout not found for panel index ${v}`);const _=b+f,x=pa({overrideDisabledPanels:o,panelConstraints:n[v],prevSize:b,size:_});if(c[v]=x,!_n(x,_)){let y=_-x,w=e<0?d:u;for(;w>=0&&w<n.length;){const k=c[w];rt(k!=null,`Previous layout not found for panel index ${w}`);const C=k+y,N=pa({overrideDisabledPanels:o,panelConstraints:n[w],prevSize:k,size:C});if(_n(k,N)||(y-=N-k,c[w]=N),_n(y,0))break;e>0?w--:w++}}}const p=Object.values(c).reduce((v,b)=>b+v,0);if(!_n(p,100,.1))return i;const m=Object.keys(i);return c.reduce((v,b,_)=>(v[m[_]]=b,v),{})}function yo(e,t){if(Object.keys(e).length!==Object.keys(t).length)return!1;for(const n in e)if(t[n]===void 0||Gr(e[n],t[n])!==0)return!1;return!0}function bo({layout:e,panelConstraints:t}){const n=Object.values(e),r=[...n],i=r.reduce((a,l)=>a+l,0);if(r.length!==t.length)throw Error(`Invalid ${t.length} panel layout: ${r.map(a=>`${a}%`).join(", ")}`);if(!_n(i,100)&&r.length>0)for(let a=0;a<t.length;a++){const l=r[a];rt(l!=null,`No layout data found for index ${a}`);const c=100/i*l;r[a]=c}let s=0;for(let a=0;a<t.length;a++){const l=n[a];rt(l!=null,`No layout data found for index ${a}`);const c=r[a];rt(c!=null,`No layout data found for index ${a}`);const u=pa({overrideDisabledPanels:!0,panelConstraints:t[a],prevSize:l,size:c});c!=u&&(s+=c-u,r[a]=u)}if(!_n(s,0))for(let a=0;a<t.length;a++){const l=r[a];rt(l!=null,`No layout data found for index ${a}`);const c=l+s,u=pa({overrideDisabledPanels:!0,panelConstraints:t[a],prevSize:l,size:c});if(l!==u&&(s-=u-l,r[a]=u,_n(s,0)))break}const o=Object.keys(e);return r.reduce((a,l,c)=>(a[o[c]]=l,a),{})}function uR({groupId:e,panelId:t}){const n=()=>{const l=jo();for(const[c,{defaultLayoutDeferred:u,derivedPanelConstraints:d,layout:f,groupSize:p,separatorToPanels:m}]of l)if(c.id===e)return{defaultLayoutDeferred:u,derivedPanelConstraints:d,group:c,groupSize:p,layout:f,separatorToPanels:m};throw Error(`Group ${e} not found`)},r=()=>{const l=n().derivedPanelConstraints.find(c=>c.panelId===t);if(l!==void 0)return l;throw Error(`Panel constraints not found for Panel ${t}`)},i=()=>{const l=n().group.panels.find(c=>c.id===t);if(l!==void 0)return l;throw Error(`Layout not found for Panel ${t}`)},s=()=>{const l=n().layout[t];if(l!==void 0)return l;throw Error(`Layout not found for Panel ${t}`)},o=({nextSize:l,panels:c,prevLayout:u,derivedPanelConstraints:d})=>{const f=s(),p=c.findIndex(b=>b.id===t),m=p===0,v=p===c.length-1;if(v&&l<f&&(m||c.slice(0,p).every((b,_)=>{const x=d[_];return(x==null?void 0:x.collapsible)&&_n(x.collapsedSize,u[x.panelId])}))){const b=c.slice(0,p).reduce((_,x)=>_+u[x.id],0);return{...u,[t]:Nn(100-b)}}return Zc({delta:v?f-l:l-f,initialLayout:u,panelConstraints:d,pivotIndices:v?[p-1,p]:[p,p+1],prevLayout:u,trigger:"imperative-api"})},a=l=>{const c=s();if(l===c)return;const{defaultLayoutDeferred:u,derivedPanelConstraints:d,group:f,groupSize:p,layout:m,separatorToPanels:v}=n(),b=o({nextSize:l,panels:f.panels,prevLayout:m,derivedPanelConstraints:d}),_=bo({layout:b,panelConstraints:d});yo(m,_)||Oi(f,{defaultLayoutDeferred:u,derivedPanelConstraints:d,groupSize:p,layout:_,separatorToPanels:v})};return{collapse:()=>{const{collapsible:l,collapsedSize:c}=r(),{mutableValues:u}=i(),d=s();l&&d!==c&&(u.expandToSize=d,a(c))},expand:()=>{const{collapsible:l,collapsedSize:c,minSize:u}=r(),{mutableValues:d}=i(),f=s();if(l&&f===c){let p=d.expandToSize??u;p===0&&(p=1),a(p)}},getSize:()=>{const{group:l}=n(),c=s(),{element:u}=i(),d=l.orientation==="horizontal"?u.offsetWidth:u.offsetHeight;return{asPercentage:c,inPixels:d}},isCollapsed:()=>{const{collapsible:l,collapsedSize:c}=r(),u=s();return l&&_n(c,u)},resize:l=>{const{group:c}=n(),{element:u}=i(),d=Fa({group:c}),f=Gl({groupSize:d,panelElement:u,styleProp:l}),p=Nn(f/d*100);a(p)}}}function vS(e){if(e.defaultPrevented)return;const t=jo();fy(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=uR({groupId:n.group.id,panelId:r.id});s&&i!==void 0&&(s.resize(i),e.preventDefault())}}})}function Qd(e){const t=jo();for(const[n]of t)if(n.separators.some(r=>r.element===e))return n;throw Error("Could not find parent Group for separator element")}function dR({groupId:e}){const t=()=>{const n=jo();for(const[r,i]of n)if(r.id===e)return{group:r,...i};throw Error(`Could not find Group with id "${e}"`)};return{getLayout(){const{defaultLayoutDeferred:n,layout:r}=t();return n?{}:r},setLayout(n){const{defaultLayoutDeferred:r,derivedPanelConstraints:i,group:s,groupSize:o,layout:a,separatorToPanels:l}=t(),c=bo({layout:n,panelConstraints:i});return r?a:(yo(a,c)||Oi(s,{defaultLayoutDeferred:r,derivedPanelConstraints:i,groupSize:o,layout:c,separatorToPanels:l}),c)}}}function Us(e,t){const n=Qd(e),r=ws(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=dR({groupId:n.id}).getLayout(),l=Zc({delta:t,initialLayout:a,panelConstraints:r.derivedPanelConstraints,pivotIndices:o,prevLayout:a,trigger:"keyboard"}),c=bo({layout:l,panelConstraints:r.derivedPanelConstraints});yo(a,c)||Oi(n,{defaultLayoutDeferred:r.defaultLayoutDeferred,derivedPanelConstraints:r.derivedPanelConstraints,groupSize:r.groupSize,layout:c,separatorToPanels:r.separatorToPanels},{isUserInteraction:!0})}function _S(e){if(e.defaultPrevented)return;const t=e.currentTarget,n=Qd(t);if(!n.disabled)switch(e.key){case"ArrowDown":{e.preventDefault(),n.orientation==="vertical"&&Us(t,5);break}case"ArrowLeft":{e.preventDefault(),n.orientation==="horizontal"&&Us(t,-5);break}case"ArrowRight":{e.preventDefault(),n.orientation==="horizontal"&&Us(t,5);break}case"ArrowUp":{e.preventDefault(),n.orientation==="vertical"&&Us(t,-5);break}case"End":{e.preventDefault(),Us(t,100);break}case"Enter":{e.preventDefault();const r=Qd(t),i=ws(r.id,!0),{derivedPanelConstraints:s,layout:o,separatorToPanels:a}=i,l=r.separators.find(f=>f.element===t);rt(l,"Matching separator not found");const c=a.get(l);rt(c,"Matching panels not found");const u=c[0],d=s.find(f=>f.panelId===u.id);if(rt(d,"Panel metadata not found"),d.collapsible){const f=o[u.id],p=d.collapsedSize===f?r.mutableState.expandedPanelSizes[u.id]??d.minSize:d.collapsedSize;Us(t,p-f)}break}case"F6":{e.preventDefault();const r=Qd(t).separators.map(o=>o.element),i=Array.from(r).findIndex(o=>o===e.currentTarget);rt(i!==null,"Index not found");const s=e.shiftKey?i>0?i-1:r.length-1:i+1<r.length?i+1:0;r[s].focus({preventScroll:!0});break}case"Home":{e.preventDefault(),Us(t,-100);break}}}function xS(e){if(e.defaultPrevented||e.pointerType==="mouse"&&e.button>0)return;const t=jo(),n=fy(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)}),Ea({cursorFlags:0,hitRegions:n,initialLayoutMap:r,pointerDownAtPoint:{x:e.clientX,y:e.clientY},state:"active"}),n.length&&e.preventDefault()}function hR({document:e,event:t,hitRegions:n,initialLayoutMap:r,mountedGroups:i,pointerDownAtPoint:s,prevCursorFlags:o}){let a=0;n.forEach(c=>{const{group:u,groupSize:d}=c,{orientation:f,panels:p}=u,{disableCursor:m}=u.mutableState;let v=0;s?f==="horizontal"?v=(t.clientX-s.x)/d*100:v=(t.clientY-s.y)/d*100:f==="horizontal"?v=t.clientX<0?-100:100:v=t.clientY<0?-100:100;const b=r.get(u),_=i.get(u);if(!b||!_)return;const{defaultLayoutDeferred:x,derivedPanelConstraints:y,groupSize:w,layout:k,separatorToPanels:C}=_;if(y&&k&&C){const N=Zc({delta:v,initialLayout:b,panelConstraints:y,pivotIndices:c.panels.map(T=>p.indexOf(T)),prevLayout:k,trigger:"mouse-or-touch"});if(yo(N,k)){if(v!==0&&!m)switch(f){case"horizontal":{a|=v<0?rR:iR;break}case"vertical":{a|=v<0?sR:oR;break}}}else Oi(c.group,{defaultLayoutDeferred:x,derivedPanelConstraints:y,groupSize:w,layout:N,separatorToPanels:C})}});let l=0;t.movementX===0?l|=o&lS:l|=a&lS,t.movementY===0?l|=o&cS:l|=a&cS,tU(l),dy(e)}function yS(e){const t=jo(),n=xo();switch(n.state){case"active":hR({document:e.currentTarget,event:e,hitRegions:n.hitRegions,initialLayoutMap:n.initialLayoutMap,mountedGroups:t,prevCursorFlags:n.cursorFlags})}}function bS(e){var r,i;if(e.defaultPrevented)return;const t=xo(),n=jo();switch(t.state){case"active":{if(e.buttons===0){Ea({cursorFlags:0,state:"inactive"}),t.hitRegions.forEach(s=>{const o=ws(s.group.id,!0);Oi(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))}hR({document:e.currentTarget,event:e,hitRegions:t.hitRegions,initialLayoutMap:t.initialLayoutMap,mountedGroups:n,pointerDownAtPoint:t.pointerDownAtPoint,prevCursorFlags:t.cursorFlags});break}default:{const s=fy(e,n);s.length===0?t.state!=="inactive"&&Ea({cursorFlags:0,state:"inactive"}):Ea({cursorFlags:0,hitRegions:s,state:"hover"}),dy(e.currentTarget);break}}}function wS(e){if(e.relatedTarget instanceof HTMLIFrameElement)switch(xo().state){case"hover":Ea({cursorFlags:0,state:"inactive"})}}function SS(e){e.defaultPrevented||e.pointerType==="mouse"&&e.button>0||lR(e.currentTarget)&&e.preventDefault()}function kS(e){let t=0,n=0;const r={};for(const s of e)if(s.defaultSize!==void 0){t++;const o=Nn(s.defaultSize);n+=o,r[s.panelId]=o}else r[s.panelId]=void 0;const i=e.length-t;if(i!==0){const s=Nn((100-n)/i);for(const o of e)o.defaultSize===void 0&&(r[o.panelId]=s)}return r}function pU(e,t,n){if(!n[0])return;const r=e.panels.find(l=>l.element===t);if(!r||!r.onResize)return;const i=Fa({group:e}),s=e.orientation==="horizontal"?r.element.offsetWidth:r.element.offsetHeight,o=r.mutableValues.prevSize,a={asPercentage:Nn(s/i*100),inPixels:s};r.mutableValues.prevSize=a,r.onResize(a,r.id,o)}function mU(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 gU({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=Nn(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]=Nn(f/s*c)}else{const d=Nn(c/l.length);for(const f of l)u[f]=d}return u}function vU(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 Ko=new Map;function _U(e){let t=!0;rt(e.element.ownerDocument.defaultView,"Cannot register an unmounted Group");const n=e.element.ownerDocument.defaultView.ResizeObserver,r=new Set,i=new Set,s=new n(m=>{for(const v of m){const{borderBoxSize:b,target:_}=v;if(_===e.element){if(t){const x=Fa({group:e});if(x===0)return;const y=ws(e.id);if(!y)return;const w=g0(e),k=y.defaultLayoutDeferred?kS(w):y.layout,C=gU({group:e,nextGroupSize:x,prevGroupSize:y.groupSize,prevLayout:k}),N=bo({layout:C,panelConstraints:w});if(!y.defaultLayoutDeferred&&yo(y.layout,N)&&mU(y.derivedPanelConstraints,w)&&y.groupSize===x)return;Oi(e,{defaultLayoutDeferred:!1,derivedPanelConstraints:w,groupSize:x,layout:N,separatorToPanels:y.separatorToPanels})}}else pU(e,_,b)}});s.observe(e.element),e.panels.forEach(m=>{rt(!r.has(m.id),`Panel ids must be unique; id "${m.id}" was used more than once`),r.add(m.id),m.onResize&&s.observe(m.element)});const o=Fa({group:e}),a=g0(e),l=e.panels.map(({id:m})=>m).join(",");let c=e.mutableState.defaultLayout;c&&(vU(e.panels,c)||(c=void 0));const u=e.mutableState.layouts[l]??c??kS(a),d=bo({layout:u,panelConstraints:a}),f=e.element.ownerDocument;Ko.set(f,(Ko.get(f)??0)+1);const p=new Map;return tR(e).forEach(m=>{m.separator&&p.set(m.separator,m.panels)}),Oi(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",_S)}),Ko.get(f)===1&&(f.addEventListener("contextmenu",fS,!0),f.addEventListener("dblclick",vS,!0),f.addEventListener("pointerdown",xS,!0),f.addEventListener("pointerleave",yS),f.addEventListener("pointermove",bS),f.addEventListener("pointerout",wS),f.addEventListener("pointerup",SS,!0)),function(){t=!1,Ko.set(f,Math.max(0,(Ko.get(f)??0)-1)),iU(e),e.separators.forEach(m=>{m.element.removeEventListener("keydown",_S)}),Ko.get(f)||(f.removeEventListener("contextmenu",fS,!0),f.removeEventListener("dblclick",vS,!0),f.removeEventListener("pointerdown",xS,!0),f.removeEventListener("pointerleave",yS),f.removeEventListener("pointermove",bS),f.removeEventListener("pointerout",wS),f.removeEventListener("pointerup",SS,!0)),s.disconnect()}}function xU(){const[e,t]=g.useState({}),n=g.useCallback(()=>t({}),[]);return[e,n]}function py(e){const t=g.useId();return`${e??t}`}const Do=typeof window<"u"?g.useLayoutEffect:g.useEffect;function pc(e){const t=g.useRef(e);return Do(()=>{t.current=e},[e]),g.useCallback((...n)=>{var r;return(r=t.current)==null?void 0:r.call(t,...n)},[t])}function my(...e){return pc(t=>{e.forEach(n=>{if(n)switch(typeof n){case"function":{n(t);break}case"object":{n.current=t;break}}})})}function gy(e){const t=g.useRef({...e});return Do(()=>{for(const n in e)t.current[n]=e[n]},[e]),t.current}const fR=g.createContext(null);function yU(e,t){const n=g.useRef({getLayout:()=>({}),setLayout:nU});g.useImperativeHandle(t,()=>n.current,[]),Do(()=>{Object.assign(n.current,dR({groupId:e}))})}function vy({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=pc(j=>{yo(m.current.onLayoutChange,j)||(m.current.onLayoutChange=j,l==null||l(j))}),b=pc((j,I)=>{yo(m.current.onLayoutChanged,j)||(m.current.onLayoutChanged=j,c==null||c(j,{isUserInteraction:I}))}),_=py(a),x=g.useRef(null),[y,w]=xU(),k=g.useRef({lastExpandedPanelSizes:{},layouts:{},panels:[],resizeTargetMinimumSize:d,separators:[]}),C=my(x,s);yU(_,o);const N=pc((j,I)=>{const R=xo(),L=hS(j),z=ws(j);if(z){let $=!1;switch(R.state){case"active":{$=R.hitRegions.some(F=>F.group===L);break}}return{flexGrow:z.layout[I]??1,pointerEvents:$?"none":void 0}}if(n!=null&&n[I])return{flexGrow:n==null?void 0:n[I]}}),T=gy({defaultLayout:n,disableCursor:r}),B=g.useMemo(()=>({get disableCursor(){return!!T.disableCursor},getPanelStyles:N,id:_,orientation:u,registerPanel:j=>{const I=k.current;return I.panels=v0(u,[...I.panels,j]),w(),()=>{I.panels=I.panels.filter(R=>R!==j),w()}},registerSeparator:j=>{const I=k.current;return I.separators=v0(u,[...I.separators,j]),w(),()=>{I.separators=I.separators.filter(R=>R!==j),w()}},updatePanelProps:(j,{disabled:I})=>{const R=k.current.panels.find($=>$.id===j);R&&(R.panelConstraints.disabled=I);const L=hS(_),z=ws(_);L&&z&&Oi(L,{...z,derivedPanelConstraints:g0(L)})},updateSeparatorProps:(j,{disabled:I,disableDoubleClick:R})=>{const L=k.current.separators.find(z=>z.id===j);L&&(L.disabled=I,L.disableDoubleClick=R)}}),[N,_,w,u,T]),P=g.useRef(null);return Do(()=>{const j=x.current;if(j===null)return;const I=k.current;let R;if(T.defaultLayout!==void 0&&Object.keys(T.defaultLayout).length===I.panels.length){R={};for(const E of I.panels){const H=T.defaultLayout[E.id];H!==void 0&&(R[E.id]=H)}}const L={disabled:!!i,element:j,id:_,mutableState:{defaultLayout:R,disableCursor:!!T.disableCursor,expandedPanelSizes:k.current.lastExpandedPanelSizes,layouts:k.current.layouts},orientation:u,panels:I.panels,resizeTargetMinimumSize:I.resizeTargetMinimumSize,separators:I.separators};P.current=L;const z=_U(L),{defaultLayoutDeferred:$,derivedPanelConstraints:F,layout:D}=ws(L.id,!0);!$&&F.length>0&&(v(D),b(D,!1));const O=hy(_,E=>{const{defaultLayoutDeferred:H,derivedPanelConstraints:V,layout:A}=E.next;if(H||V.length===0)return;const ne=L.panels.map(({id:X})=>X).join(",");L.mutableState.layouts[ne]=A,V.forEach(X=>{if(X.collapsible){const{layout:ye}=E.prev??{};if(ye){const $e=_n(X.collapsedSize,A[X.panelId]),ue=_n(X.collapsedSize,ye[X.panelId]);$e&&!ue&&(L.mutableState.expandedPanelSizes[X.panelId]=ye[X.panelId])}}});const oe=xo().state!=="active";v(A),oe&&b(A,E.isUserInteraction)});return()=>{P.current=null,z(),O()}},[i,_,b,v,u,y,T]),g.useEffect(()=>{const j=P.current;j&&(j.mutableState.defaultLayout=n,j.mutableState.disableCursor=!!r)}),h.jsx(fR.Provider,{value:B,children:h.jsx("div",{...p,className:t,"data-group":!0,"data-testid":_,id:_,ref:C,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})})}vy.displayName="Group";function _y(){const e=g.useContext(fR);return rt(e,"Group Context not found; did you render a Panel or Separator outside of a Group?"),e}function bU(e,t){const{id:n}=_y(),r=g.useRef({collapse:Om,expand:Om,getSize:()=>({asPercentage:0,inPixels:0}),isCollapsed:()=>!1,resize:Om});g.useImperativeHandle(t,()=>r.current,[]),Do(()=>{Object.assign(r.current,uR({groupId:n,panelId:e}))})}function Jh({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),_=gy({disabled:s}),x=g.useRef(null),y=my(x,o),{getPanelStyles:w,id:k,orientation:C,registerPanel:N,updatePanelProps:T}=_y(),B=d!==null,P=pc((L,z,$)=>{d==null||d(L,l,$)});Do(()=>{const L=x.current;if(L!==null){const z={element:L,id:b,idIsStable:v,mutableValues:{expandToSize:void 0,prevSize:void 0},onResize:B?P:void 0,panelConstraints:{groupResizeBehavior:a,collapsedSize:n,collapsible:r,defaultSize:i,disabled:_.disabled,maxSize:c,minSize:u}};return N(z)}},[a,n,r,i,B,b,v,c,u,P,N,_]),g.useEffect(()=>{T(b,{disabled:s})},[s,b,T]),bU(b,f);const j=()=>{const L=w(k,b);if(L)return JSON.stringify(L)},I=g.useSyncExternalStore(L=>hy(k,L),j,j);let R;return I?R=JSON.parse(I):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:{...wU,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:C==="horizontal"?"pan-y":"pan-x"},children:e})})}Jh.displayName="Panel";const wU={minHeight:0,maxHeight:"100%",height:"auto",minWidth:0,maxWidth:"100%",width:"auto",border:"none",borderWidth:0,padding:0,margin:0};function SU({layout:e,panelConstraints:t,panelId:n,panelIndex:r}){let i,s;const o=e[n],a=t.find(l=>l.panelId===n);if(a){const l=a.maxSize,c=a.collapsible?a.collapsedSize:a.minSize,u=[r,r+1];s=bo({layout:Zc({delta:c-o,initialLayout:e,panelConstraints:t,pivotIndices:u,prevLayout:e}),panelConstraints:t})[n],i=bo({layout:Zc({delta:l-o,initialLayout:e,panelConstraints:t,pivotIndices:u,prevLayout:e}),panelConstraints:t})[n]}return{valueControls:n,valueMax:i,valueMin:s,valueNow:o}}function pR({children:e,className:t,disabled:n,disableDoubleClick:r,elementRef:i,id:s,style:o,...a}){const l=py(s),c=gy({disabled:n,disableDoubleClick:r}),[u,d]=g.useState({}),[f,p]=g.useState("inactive"),[m,v]=g.useState(!1),b=g.useRef(null),_=my(b,i),{disableCursor:x,id:y,orientation:w,registerSeparator:k,updateSeparatorProps:C}=_y(),N=w==="horizontal"?"vertical":"horizontal";Do(()=>{const P=b.current;if(P!==null){const j={disabled:c.disabled,disableDoubleClick:c.disableDoubleClick,element:P,id:l},I=k(j),R=eU(z=>{p(z.next.state!=="inactive"&&z.next.hitRegions.some($=>$.separator===j)?z.next.state:"inactive")}),L=hy(y,z=>{const{derivedPanelConstraints:$,layout:F,separatorToPanels:D}=z.next,O=D.get(j);if(O){const E=O[0],H=O.indexOf(E);d(SU({layout:F,panelConstraints:$,panelId:E.id,panelIndex:H}))}});return()=>{R(),L(),I()}}},[y,l,k,c]),g.useEffect(()=>{C(l,{disabled:n,disableDoubleClick:r})},[n,r,l,C]);let T;n&&!x&&(T="not-allowed");let B;if(n)B="disabled";else switch(f){case"active":{B="active";break}default:m?B="focus":B=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":B,"data-testid":l,id:l,onBlur:()=>v(!1),onFocus:()=>v(!0),ref:_,role:"separator",style:{flexBasis:"auto",cursor:T,...o,flexGrow:0,flexShrink:0,touchAction:"none"},tabIndex:n?void 0:0})}pR.displayName="Separator";function kU(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 CU(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 EU=/^Scheduled (?:recurring job|one-shot task) ([0-9a-f]{8}) \(([^)]+)\)/;function NU(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(EU);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 TU=["TaskCreate","TaskUpdate","TaskList","TaskGet"];function PU(e){return TU.includes(e)}function mR(e){return e==="in_progress"||e==="completed"?e:"pending"}function IU(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:mR(n.status),activeForm:i,description:s}]}function RU(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=mR(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 MU(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=IU(t,i.input);break;case"TaskUpdate":t=RU(t,i.input);break}}return{tasks:t,lastEventIndex:n}}function AU(e){const{tasks:t,lastEventIndex:n}=MU(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;const d={agentId:u.agentId,status:u.status};u.description?d.description=u.description:(f=c.progress)!=null&&f.description&&(d.description=c.progress.description),u.lastToolName?d.lastToolName=u.lastToolName:(p=c.progress)!=null&&p.lastToolName&&(d.lastToolName=c.progress.lastToolName),u.stats?d.stats=u.stats:(m=c.progress)!=null&&m.stats&&(d.stats=c.progress.stats),c.progress=d};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}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 LU=new Set(["permission-inline","question-card"]);function jU(e){return e.kind==="user-text"?!0:e.kind==="user-meta"&&e.metaKind==="slash-command"}function DU(e,t={}){const n=[];let r=null;const i=(s,o)=>{r&&(n.push(OU(r,s,o)),r=null)};for(const s of e){if(s.kind==="turn-end"){i(s,!0);continue}if(jU(s)&&(r===null||t.implicitCloseOnUserText)){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 OU(e,t,n){const{query:r,body:i}=e,s=BU(i,t,n),o=zU(i,s),a=FU(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 BU(e,t,n){if(!n)return"running";if((t==null?void 0:t.reason)==="interrupted")return"interrupted";const r=_0(e,i=>i.kind==="error");return r>=0&&!e.slice(r+1).some(s=>s.kind==="assistant-text")?"error":"done"}function zU(e,t){if(t==="running"){const i=[];for(let s=e.length-1;s>=0&&LU.has(e[s].kind);s--)i.unshift(e[s]);return i}const n=[];e.forEach((i,s)=>{i.kind==="merged-agent"&&i.pending&&n.push(s)});const r=t==="error"?_0(e,i=>i.kind==="error"):_0(e,i=>i.kind==="assistant-text");return r>=0&&n.push(r),n.sort((i,s)=>i-s).map(i=>e[i])}const $U=new Set(["assistant-thinking","user-meta"]);function FU(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($U.has(o.kind)){r.push(o);continue}s(),r.push(o)}return s(),r}function _0(e,t){for(let n=e.length-1;n>=0;n--)if(t(e[n]))return n;return-1}const HU={Read:["正在读取","已读取"],Bash:["正在运行","已运行"],Grep:["正在搜索","已搜索"],Glob:["正在搜索","已搜索"],Edit:["正在编辑","已编辑"],Write:["正在写入","已写入"],WebFetch:["正在抓取","已抓取"],WebSearch:["正在搜索","已搜索"],Skill:["正在读取","已读取"]};function UU(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 gR(e){const t=HU[e.tool],n=t?e.pending?t[0]:t[1]:e.pending?`正在执行 ${e.tool}`:`已执行 ${e.tool}`,r=UU(e.input);return r?`${n} ${r}`:n}function WU({item:e,renderItemDetail:t}){const[n,r]=g.useState(!1),i=n?ir:Un,s=n?(t==null?void 0:t(e))??null:null;return h.jsxs("div",{className:"min-w-0 max-w-full",children:[h.jsxs("button",{type:"button",onClick:()=>r(o=>!o),"aria-expanded":n,"data-testid":"tool-call-group-row",className:he("flex w-full items-center gap-1.5 text-left cursor-pointer min-w-0 py-0.5 text-[13px] hover:text-text-200",e.error?"text-destructive/80":"text-text-400"),children:[e.pending?h.jsx(In,{className:"w-3.5 h-3.5 animate-spin shrink-0"}):h.jsx(i,{className:"w-3.5 h-3.5 shrink-0 opacity-60"}),h.jsx("span",{className:"truncate min-w-0",children:gR(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 VU({items:e,defaultExpanded:t=!1,renderItemDetail:n}){const[r,i]=g.useState(t);if(e.length===0)return null;const s=e.some(c=>c.pending),o=s?[...e].reverse().find(c=>c.pending):e[e.length-1],a=!s&&e.length>1?` 等 ${e.length} 项`:"",l=r?ir:Un;return h.jsxs("div",{"data-testid":"tool-call-group",className:"min-w-0 max-w-full",children:[h.jsxs("button",{type:"button",onClick:()=>i(c=>!c),"aria-expanded":r,"data-testid":"tool-call-group-header",className:"flex w-full items-center gap-1.5 text-left cursor-pointer min-w-0 py-0.5 text-[13px] text-text-400 hover:text-text-200",children:[s&&!r?h.jsx(In,{className:"w-3.5 h-3.5 animate-spin shrink-0"}):h.jsx(l,{className:"w-3.5 h-3.5 shrink-0"}),r?h.jsx("span",{className:"min-w-0 truncate opacity-70",children:s?"正在执行":`${e.length} 项`}):h.jsxs("span",{className:he("truncate min-w-0",s&&"text-text-300"),children:[gR(o),a]})]}),r?h.jsx("div",{className:"mt-0.5 flex flex-col pl-5",children:e.map(c=>h.jsx(WU,{item:c,renderItemDetail:n},c.toolUseId))}):null]})}function qU(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 KU(e,t){const n=t!==void 0?`耗时 ${qU(t)}`:"";switch(e){case"interrupted":return n?`已中断 · ${n}`:"已中断";case"error":return n?`出错 · ${n}`:"出错";default:return n||"已完成"}}function GU({status:e="done",durationMs:t,defaultExpanded:n=!1,children:r}){const[i,s]=g.useState(n),o=i?ir:Un;return h.jsxs("div",{"data-testid":"turn-process-block",className:"min-w-0 max-w-full border-t border-border pt-2",children:[h.jsxs("button",{type:"button",onClick:()=>s(a=>!a),"aria-expanded":i,"data-testid":"turn-process-block-header",className:he("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:KU(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 XU=/<(system-reminder|related-dir|clawd-shift-fire)\b[^>]*>[\s\S]*?<\/\1>/gi,YU=/<builder-preview\b[^>]*\/>/gi;function vR(e){return e?e.replace(XU,"").replace(YU,"").trim():""}const ZU=vR;function QU(e,t){const n={};return(e[e.length-1]===""?[...e,""]:e).join((n.padRight?" ":"")+","+(n.padLeft===!1?"":" ")).trim()}const JU=/^[$_\p{ID_Start}][$_\u{200C}\u{200D}\p{ID_Continue}]*$/u,eW=/^[$_\p{ID_Start}][-$_\u{200C}\u{200D}\p{ID_Continue}]*$/u,tW={};function CS(e,t){return(tW.jsx?eW:JU).test(e)}const nW=/[ \t\n\f\r]/g;function rW(e){return typeof e=="object"?e.type==="text"?ES(e.value):!1:ES(e)}function ES(e){return e.replace(nW,"")===""}class ku{constructor(t,n,r){this.normal=n,this.property=t,r&&(this.space=r)}}ku.prototype.normal={};ku.prototype.property={};ku.prototype.space=void 0;function _R(e,t){const n={},r={};for(const i of e)Object.assign(n,i.property),Object.assign(r,i.normal);return new ku(n,r,t)}function x0(e){return e.toLowerCase()}class Wn{constructor(t,n){this.attribute=n,this.property=t}}Wn.prototype.attribute="";Wn.prototype.booleanish=!1;Wn.prototype.boolean=!1;Wn.prototype.commaOrSpaceSeparated=!1;Wn.prototype.commaSeparated=!1;Wn.prototype.defined=!1;Wn.prototype.mustUseProperty=!1;Wn.prototype.number=!1;Wn.prototype.overloadedBoolean=!1;Wn.prototype.property="";Wn.prototype.spaceSeparated=!1;Wn.prototype.space=void 0;let iW=0;const Me=Oo(),Dt=Oo(),y0=Oo(),Q=Oo(),at=Oo(),Na=Oo(),Gn=Oo();function Oo(){return 2**++iW}const b0=Object.freeze(Object.defineProperty({__proto__:null,boolean:Me,booleanish:Dt,commaOrSpaceSeparated:Gn,commaSeparated:Na,number:Q,overloadedBoolean:y0,spaceSeparated:at},Symbol.toStringTag,{value:"Module"})),Bm=Object.keys(b0);class xy extends Wn{constructor(t,n,r,i){let s=-1;if(super(t,n),NS(this,"space",i),typeof r=="number")for(;++s<Bm.length;){const o=Bm[s];NS(this,Bm[s],(r&b0[o])===b0[o])}}}xy.prototype.defined=!0;function NS(e,t,n){n&&(e[t]=n)}function hl(e){const t={},n={};for(const[r,i]of Object.entries(e.properties)){const s=new xy(r,e.transform(e.attributes||{},r),i,e.space);e.mustUseProperty&&e.mustUseProperty.includes(r)&&(s.mustUseProperty=!0),t[r]=s,n[x0(r)]=r,n[x0(s.attribute)]=r}return new ku(t,n,e.space)}const xR=hl({properties:{ariaActiveDescendant:null,ariaAtomic:Dt,ariaAutoComplete:null,ariaBusy:Dt,ariaChecked:Dt,ariaColCount:Q,ariaColIndex:Q,ariaColSpan:Q,ariaControls:at,ariaCurrent:null,ariaDescribedBy:at,ariaDetails:null,ariaDisabled:Dt,ariaDropEffect:at,ariaErrorMessage:null,ariaExpanded:Dt,ariaFlowTo:at,ariaGrabbed:Dt,ariaHasPopup:null,ariaHidden:Dt,ariaInvalid:null,ariaKeyShortcuts:null,ariaLabel:null,ariaLabelledBy:at,ariaLevel:Q,ariaLive:null,ariaModal:Dt,ariaMultiLine:Dt,ariaMultiSelectable:Dt,ariaOrientation:null,ariaOwns:at,ariaPlaceholder:null,ariaPosInSet:Q,ariaPressed:Dt,ariaReadOnly:Dt,ariaRelevant:null,ariaRequired:Dt,ariaRoleDescription:at,ariaRowCount:Q,ariaRowIndex:Q,ariaRowSpan:Q,ariaSelected:Dt,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 yR(e,t){return t in e?e[t]:t}function bR(e,t){return yR(e,t.toLowerCase())}const sW=hl({attributes:{acceptcharset:"accept-charset",classname:"class",htmlfor:"for",httpequiv:"http-equiv"},mustUseProperty:["checked","multiple","muted","selected"],properties:{abbr:null,accept:Na,acceptCharset:at,accessKey:at,action:null,allow:null,allowFullScreen:Me,allowPaymentRequest:Me,allowUserMedia:Me,alt:null,as:null,async:Me,autoCapitalize:null,autoComplete:at,autoFocus:Me,autoPlay:Me,blocking:at,capture:null,charSet:null,checked:Me,cite:null,className:at,cols:Q,colSpan:null,content:null,contentEditable:Dt,controls:Me,controlsList:at,coords:Q|Na,crossOrigin:null,data:null,dateTime:null,decoding:null,default:Me,defer:Me,dir:null,dirName:null,disabled:Me,download:y0,draggable:Dt,encType:null,enterKeyHint:null,fetchPriority:null,form:null,formAction:null,formEncType:null,formMethod:null,formNoValidate:Me,formTarget:null,headers:at,height:Q,hidden:y0,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:Dt,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:Dt,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:Dt,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:bR}),oW=hl({attributes:{accentHeight:"accent-height",alignmentBaseline:"alignment-baseline",arabicForm:"arabic-form",baselineShift:"baseline-shift",capHeight:"cap-height",className:"class",clipPath:"clip-path",clipRule:"clip-rule",colorInterpolation:"color-interpolation",colorInterpolationFilters:"color-interpolation-filters",colorProfile:"color-profile",colorRendering:"color-rendering",crossOrigin:"crossorigin",dataType:"datatype",dominantBaseline:"dominant-baseline",enableBackground:"enable-background",fillOpacity:"fill-opacity",fillRule:"fill-rule",floodColor:"flood-color",floodOpacity:"flood-opacity",fontFamily:"font-family",fontSize:"font-size",fontSizeAdjust:"font-size-adjust",fontStretch:"font-stretch",fontStyle:"font-style",fontVariant:"font-variant",fontWeight:"font-weight",glyphName:"glyph-name",glyphOrientationHorizontal:"glyph-orientation-horizontal",glyphOrientationVertical:"glyph-orientation-vertical",hrefLang:"hreflang",horizAdvX:"horiz-adv-x",horizOriginX:"horiz-origin-x",horizOriginY:"horiz-origin-y",imageRendering:"image-rendering",letterSpacing:"letter-spacing",lightingColor:"lighting-color",markerEnd:"marker-end",markerMid:"marker-mid",markerStart:"marker-start",navDown:"nav-down",navDownLeft:"nav-down-left",navDownRight:"nav-down-right",navLeft:"nav-left",navNext:"nav-next",navPrev:"nav-prev",navRight:"nav-right",navUp:"nav-up",navUpLeft:"nav-up-left",navUpRight:"nav-up-right",onAbort:"onabort",onActivate:"onactivate",onAfterPrint:"onafterprint",onBeforePrint:"onbeforeprint",onBegin:"onbegin",onCancel:"oncancel",onCanPlay:"oncanplay",onCanPlayThrough:"oncanplaythrough",onChange:"onchange",onClick:"onclick",onClose:"onclose",onCopy:"oncopy",onCueChange:"oncuechange",onCut:"oncut",onDblClick:"ondblclick",onDrag:"ondrag",onDragEnd:"ondragend",onDragEnter:"ondragenter",onDragExit:"ondragexit",onDragLeave:"ondragleave",onDragOver:"ondragover",onDragStart:"ondragstart",onDrop:"ondrop",onDurationChange:"ondurationchange",onEmptied:"onemptied",onEnd:"onend",onEnded:"onended",onError:"onerror",onFocus:"onfocus",onFocusIn:"onfocusin",onFocusOut:"onfocusout",onHashChange:"onhashchange",onInput:"oninput",onInvalid:"oninvalid",onKeyDown:"onkeydown",onKeyPress:"onkeypress",onKeyUp:"onkeyup",onLoad:"onload",onLoadedData:"onloadeddata",onLoadedMetadata:"onloadedmetadata",onLoadStart:"onloadstart",onMessage:"onmessage",onMouseDown:"onmousedown",onMouseEnter:"onmouseenter",onMouseLeave:"onmouseleave",onMouseMove:"onmousemove",onMouseOut:"onmouseout",onMouseOver:"onmouseover",onMouseUp:"onmouseup",onMouseWheel:"onmousewheel",onOffline:"onoffline",onOnline:"ononline",onPageHide:"onpagehide",onPageShow:"onpageshow",onPaste:"onpaste",onPause:"onpause",onPlay:"onplay",onPlaying:"onplaying",onPopState:"onpopstate",onProgress:"onprogress",onRateChange:"onratechange",onRepeat:"onrepeat",onReset:"onreset",onResize:"onresize",onScroll:"onscroll",onSeeked:"onseeked",onSeeking:"onseeking",onSelect:"onselect",onShow:"onshow",onStalled:"onstalled",onStorage:"onstorage",onSubmit:"onsubmit",onSuspend:"onsuspend",onTimeUpdate:"ontimeupdate",onToggle:"ontoggle",onUnload:"onunload",onVolumeChange:"onvolumechange",onWaiting:"onwaiting",onZoom:"onzoom",overlinePosition:"overline-position",overlineThickness:"overline-thickness",paintOrder:"paint-order",panose1:"panose-1",pointerEvents:"pointer-events",referrerPolicy:"referrerpolicy",renderingIntent:"rendering-intent",shapeRendering:"shape-rendering",stopColor:"stop-color",stopOpacity:"stop-opacity",strikethroughPosition:"strikethrough-position",strikethroughThickness:"strikethrough-thickness",strokeDashArray:"stroke-dasharray",strokeDashOffset:"stroke-dashoffset",strokeLineCap:"stroke-linecap",strokeLineJoin:"stroke-linejoin",strokeMiterLimit:"stroke-miterlimit",strokeOpacity:"stroke-opacity",strokeWidth:"stroke-width",tabIndex:"tabindex",textAnchor:"text-anchor",textDecoration:"text-decoration",textRendering:"text-rendering",transformOrigin:"transform-origin",typeOf:"typeof",underlinePosition:"underline-position",underlineThickness:"underline-thickness",unicodeBidi:"unicode-bidi",unicodeRange:"unicode-range",unitsPerEm:"units-per-em",vAlphabetic:"v-alphabetic",vHanging:"v-hanging",vIdeographic:"v-ideographic",vMathematical:"v-mathematical",vectorEffect:"vector-effect",vertAdvY:"vert-adv-y",vertOriginX:"vert-origin-x",vertOriginY:"vert-origin-y",wordSpacing:"word-spacing",writingMode:"writing-mode",xHeight:"x-height",playbackOrder:"playbackorder",timelineBegin:"timelinebegin"},properties:{about:Gn,accentHeight:Q,accumulate:null,additive:null,alignmentBaseline:null,alphabetic:Q,amplitude:Q,arabicForm:null,ascent:Q,attributeName:null,attributeType:null,azimuth:Q,bandwidth:null,baselineShift:null,baseFrequency:null,baseProfile:null,bbox:null,begin:null,bias:Q,by:null,calcMode:null,capHeight:Q,className:at,clip:null,clipPath:null,clipPathUnits:null,clipRule:null,color:null,colorInterpolation:null,colorInterpolationFilters:null,colorProfile:null,colorRendering:null,content:null,contentScriptType:null,contentStyleType:null,crossOrigin:null,cursor:null,cx:null,cy:null,d:null,dataType:null,defaultAction:null,descent:Q,diffuseConstant:Q,direction:null,display:null,dur:null,divisor:Q,dominantBaseline:null,download:Me,dx:null,dy:null,edgeMode:null,editable:null,elevation:Q,enableBackground:null,end:null,event:null,exponent:Q,externalResourcesRequired:null,fill:null,fillOpacity:Q,fillRule:null,filter:null,filterRes:null,filterUnits:null,floodColor:null,floodOpacity:null,focusable:null,focusHighlight:null,fontFamily:null,fontSize:null,fontSizeAdjust:null,fontStretch:null,fontStyle:null,fontVariant:null,fontWeight:null,format:null,fr:null,from:null,fx:null,fy:null,g1:Na,g2:Na,glyphName:Na,glyphOrientationHorizontal:null,glyphOrientationVertical:null,glyphRef:null,gradientTransform:null,gradientUnits:null,handler:null,hanging:Q,hatchContentUnits:null,hatchUnits:null,height:null,href:null,hrefLang:null,horizAdvX:Q,horizOriginX:Q,horizOriginY:Q,id:null,ideographic:Q,imageRendering:null,initialVisibility:null,in:null,in2:null,intercept:Q,k:Q,k1:Q,k2:Q,k3:Q,k4:Q,kernelMatrix:Gn,kernelUnitLength:null,keyPoints:null,keySplines:null,keyTimes:null,kerning:null,lang:null,lengthAdjust:null,letterSpacing:null,lightingColor:null,limitingConeAngle:Q,local:null,markerEnd:null,markerMid:null,markerStart:null,markerHeight:null,markerUnits:null,markerWidth:null,mask:null,maskContentUnits:null,maskUnits:null,mathematical:null,max:null,media:null,mediaCharacterEncoding:null,mediaContentEncodings:null,mediaSize:Q,mediaTime:null,method:null,min:null,mode:null,name:null,navDown:null,navDownLeft:null,navDownRight:null,navLeft:null,navNext:null,navPrev:null,navRight:null,navUp:null,navUpLeft:null,navUpRight:null,numOctaves:null,observer:null,offset:null,onAbort:null,onActivate:null,onAfterPrint:null,onBeforePrint:null,onBegin:null,onCancel:null,onCanPlay:null,onCanPlayThrough:null,onChange:null,onClick:null,onClose:null,onCopy:null,onCueChange:null,onCut:null,onDblClick:null,onDrag:null,onDragEnd:null,onDragEnter:null,onDragExit:null,onDragLeave:null,onDragOver:null,onDragStart:null,onDrop:null,onDurationChange:null,onEmptied:null,onEnd:null,onEnded:null,onError:null,onFocus:null,onFocusIn:null,onFocusOut:null,onHashChange:null,onInput:null,onInvalid:null,onKeyDown:null,onKeyPress:null,onKeyUp:null,onLoad:null,onLoadedData:null,onLoadedMetadata:null,onLoadStart:null,onMessage:null,onMouseDown:null,onMouseEnter:null,onMouseLeave:null,onMouseMove:null,onMouseOut:null,onMouseOver:null,onMouseUp:null,onMouseWheel:null,onOffline:null,onOnline:null,onPageHide:null,onPageShow:null,onPaste:null,onPause:null,onPlay:null,onPlaying:null,onPopState:null,onProgress:null,onRateChange:null,onRepeat:null,onReset:null,onResize:null,onScroll:null,onSeeked:null,onSeeking:null,onSelect:null,onShow:null,onStalled:null,onStorage:null,onSubmit:null,onSuspend:null,onTimeUpdate:null,onToggle:null,onUnload:null,onVolumeChange:null,onWaiting:null,onZoom:null,opacity:null,operator:null,order:null,orient:null,orientation:null,origin:null,overflow:null,overlay:null,overlinePosition:Q,overlineThickness:Q,paintOrder:null,panose1:null,path:null,pathLength:Q,patternContentUnits:null,patternTransform:null,patternUnits:null,phase:null,ping:at,pitch:null,playbackOrder:null,pointerEvents:null,points:null,pointsAtX:Q,pointsAtY:Q,pointsAtZ:Q,preserveAlpha:null,preserveAspectRatio:null,primitiveUnits:null,propagate:null,property:Gn,r:null,radius:null,referrerPolicy:null,refX:null,refY:null,rel:Gn,rev:Gn,renderingIntent:null,repeatCount:null,repeatDur:null,requiredExtensions:Gn,requiredFeatures:Gn,requiredFonts:Gn,requiredFormats:Gn,resource:null,restart:null,result:null,rotate:null,rx:null,ry:null,scale:null,seed:null,shapeRendering:null,side:null,slope:null,snapshotTime:null,specularConstant:Q,specularExponent:Q,spreadMethod:null,spacing:null,startOffset:null,stdDeviation:null,stemh:null,stemv:null,stitchTiles:null,stopColor:null,stopOpacity:null,strikethroughPosition:Q,strikethroughThickness:Q,string:null,stroke:null,strokeDashArray:Gn,strokeDashOffset:null,strokeLineCap:null,strokeLineJoin:null,strokeMiterLimit:Q,strokeOpacity:Q,strokeWidth:null,style:null,surfaceScale:Q,syncBehavior:null,syncBehaviorDefault:null,syncMaster:null,syncTolerance:null,syncToleranceDefault:null,systemLanguage:Gn,tabIndex:Q,tableValues:null,target:null,targetX:Q,targetY:Q,textAnchor:null,textDecoration:null,textRendering:null,textLength:null,timelineBegin:null,title:null,transformBehavior:null,type:null,typeOf:Gn,to:null,transform:null,transformOrigin:null,u1:null,u2:null,underlinePosition:Q,underlineThickness:Q,unicode:null,unicodeBidi:null,unicodeRange:null,unitsPerEm:Q,values:null,vAlphabetic:Q,vMathematical:Q,vectorEffect:null,vHanging:Q,vIdeographic:Q,version:null,vertAdvY:Q,vertOriginX:Q,vertOriginY:Q,viewBox:null,viewTarget:null,visibility:null,width:null,widths:null,wordSpacing:null,writingMode:null,x:null,x1:null,x2:null,xChannelSelector:null,xHeight:Q,y:null,y1:null,y2:null,yChannelSelector:null,z:null,zoomAndPan:null},space:"svg",transform:yR}),wR=hl({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()}}),SR=hl({attributes:{xmlnsxlink:"xmlns:xlink"},properties:{xmlnsXLink:null,xmlns:null},space:"xmlns",transform:bR}),kR=hl({properties:{xmlBase:null,xmlLang:null,xmlSpace:null},space:"xml",transform(e,t){return"xml:"+t.slice(3).toLowerCase()}}),aW={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"},lW=/[A-Z]/g,TS=/-[a-z]/g,cW=/^data[-\w.:]+$/i;function uW(e,t){const n=x0(t);let r=t,i=Wn;if(n in e.normal)return e.property[e.normal[n]];if(n.length>4&&n.slice(0,4)==="data"&&cW.test(t)){if(t.charAt(4)==="-"){const s=t.slice(5).replace(TS,hW);r="data"+s.charAt(0).toUpperCase()+s.slice(1)}else{const s=t.slice(4);if(!TS.test(s)){let o=s.replace(lW,dW);o.charAt(0)!=="-"&&(o="-"+o),t="data"+o}}i=xy}return new i(r,t)}function dW(e){return"-"+e.toLowerCase()}function hW(e){return e.charAt(1).toUpperCase()}const fW=_R([xR,sW,wR,SR,kR],"html"),yy=_R([xR,oW,wR,SR,kR],"svg");function pW(e){return e.join(" ").trim()}var by={},PS=/\/\*[^*]*\*+([^/*][^*]*\*+)*\//g,mW=/\n/g,gW=/^\s*/,vW=/^(\*?[-#/*\\\w]+(\[[0-9a-z_-]+\])?)\s*/,_W=/^:\s*/,xW=/^((?:'(?:\\'|.)*?'|"(?:\\"|.)*?"|\([^)]*?\)|[^};])+)/,yW=/^[;\s]*/,bW=/^\s+|\s+$/g,wW=`
|
|
476
476
|
`,IS="/",RS="*",Zs="",SW="comment",kW="declaration";function CW(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(mW);v&&(n+=v.length);var b=m.lastIndexOf(wW);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(gW)}function u(m){var v;for(m=m||[];v=d();)v!==!1&&m.push(v);return m}function d(){var m=s();if(!(IS!=e.charAt(0)||RS!=e.charAt(1))){for(var v=2;Zs!=e.charAt(v)&&(RS!=e.charAt(v)||IS!=e.charAt(v+1));)++v;if(v+=2,Zs===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:SW,comment:b})}}function f(){var m=s(),v=l(vW);if(v){if(d(),!l(_W))return a("property missing ':'");var b=l(xW),_=m({type:kW,property:MS(v[0].replace(PS,Zs)),value:b?MS(b[0].replace(PS,Zs)):Zs});return l(yW),_}}function p(){var m=[];u(m);for(var v;v=f();)v!==!1&&(m.push(v),u(m));return m}return c(),p()}function MS(e){return e?e.replace(bW,Zs):Zs}var EW=CW,NW=ah&&ah.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(by,"__esModule",{value:!0});by.default=PW;const TW=NW(EW);function PW(e,t){let n=null;if(!e||typeof e!="string")return n;const r=(0,TW.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 hp={};Object.defineProperty(hp,"__esModule",{value:!0});hp.camelCase=void 0;var IW=/^--[a-zA-Z0-9_-]+$/,RW=/-([a-z])/g,MW=/^[^-]+$/,AW=/^-(webkit|moz|ms|o|khtml)-/,LW=/^-(ms)-/,jW=function(e){return!e||MW.test(e)||IW.test(e)},DW=function(e,t){return t.toUpperCase()},AS=function(e,t){return"".concat(t,"-")},OW=function(e,t){return t===void 0&&(t={}),jW(e)?e:(e=e.toLowerCase(),t.reactCompat?e=e.replace(LW,AS):e=e.replace(AW,AS),e.replace(RW,DW))};hp.camelCase=OW;var BW=ah&&ah.__importDefault||function(e){return e&&e.__esModule?e:{default:e}},zW=BW(by),$W=hp;function w0(e,t){var n={};return!e||typeof e!="string"||(0,zW.default)(e,function(r,i){r&&i&&(n[(0,$W.camelCase)(r,t)]=i)}),n}w0.default=w0;var FW=w0;const HW=au(FW),CR=ER("end"),wy=ER("start");function ER(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 UW(e){const t=wy(e),n=CR(e);if(t&&n)return{start:t,end:n}}function mc(e){return!e||typeof e!="object"?"":"position"in e||"type"in e?LS(e.position):"start"in e||"end"in e?LS(e):"line"in e||"column"in e?S0(e):""}function S0(e){return jS(e&&e.line)+":"+jS(e&&e.column)}function LS(e){return S0(e&&e.start)+"-"+S0(e&&e.end)}function jS(e){return e&&typeof e=="number"?e:1}class Sn extends Error{constructor(t,n,r){super(),typeof n=="string"&&(r=n,n=void 0);let i="",s={},o=!1;if(n&&("line"in n&&"column"in n?s={place:n}:"start"in n&&"end"in n?s={place:n}:"type"in n?s={ancestors:[n],place:n.position}:s={...n}),typeof t=="string"?i=t:!s.cause&&t&&(o=!0,i=t.message,s.cause=t),!s.ruleId&&!s.source&&typeof r=="string"){const l=r.indexOf(":");l===-1?s.ruleId=r:(s.source=r.slice(0,l),s.ruleId=r.slice(l+1))}if(!s.place&&s.ancestors&&s.ancestors){const l=s.ancestors[s.ancestors.length-1];l&&(s.place=l.position)}const a=s.place&&"start"in s.place?s.place.start:s.place;this.ancestors=s.ancestors||void 0,this.cause=s.cause||void 0,this.column=a?a.column:void 0,this.fatal=void 0,this.file="",this.message=i,this.line=a?a.line:void 0,this.name=mc(s.place)||"1:1",this.place=s.place||void 0,this.reason=this.message,this.ruleId=s.ruleId||void 0,this.source=s.source||void 0,this.stack=o&&s.cause&&typeof s.cause.stack=="string"?s.cause.stack:"",this.actual=void 0,this.expected=void 0,this.note=void 0,this.url=void 0}}Sn.prototype.file="";Sn.prototype.name="";Sn.prototype.reason="";Sn.prototype.message="";Sn.prototype.stack="";Sn.prototype.column=void 0;Sn.prototype.line=void 0;Sn.prototype.ancestors=void 0;Sn.prototype.cause=void 0;Sn.prototype.fatal=void 0;Sn.prototype.place=void 0;Sn.prototype.ruleId=void 0;Sn.prototype.source=void 0;const Sy={}.hasOwnProperty,WW=new Map,VW=/[A-Z]/g,qW=new Set(["table","tbody","thead","tfoot","tr"]),KW=new Set(["td","th"]),NR="https://github.com/syntax-tree/hast-util-to-jsx-runtime";function GW(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=nV(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=tV(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"?yy:fW,stylePropertyNameCase:t.stylePropertyNameCase||"dom",tableCellAlignToStyle:t.tableCellAlignToStyle!==!1},s=TR(i,e,void 0);return s&&typeof s!="string"?s:i.create(e,i.Fragment,{children:s||void 0},void 0)}function TR(e,t,n){if(t.type==="element")return XW(e,t,n);if(t.type==="mdxFlowExpression"||t.type==="mdxTextExpression")return YW(e,t);if(t.type==="mdxJsxFlowElement"||t.type==="mdxJsxTextElement")return QW(e,t,n);if(t.type==="mdxjsEsm")return ZW(e,t);if(t.type==="root")return JW(e,t,n);if(t.type==="text")return eV(e,t)}function XW(e,t,n){const r=e.schema;let i=r;t.tagName.toLowerCase()==="svg"&&r.space==="html"&&(i=yy,e.schema=i),e.ancestors.push(t);const s=IR(e,t.tagName,!1),o=rV(e,t);let a=Cy(e,t);return qW.has(t.tagName)&&(a=a.filter(function(l){return typeof l=="string"?!rW(l):!0})),PR(e,o,s,t),ky(o,a),e.ancestors.pop(),e.schema=r,e.create(t,s,o,n)}function YW(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)}Qc(e,t.position)}function ZW(e,t){if(t.data&&t.data.estree&&e.evaluater)return e.evaluater.evaluateProgram(t.data.estree);Qc(e,t.position)}function QW(e,t,n){const r=e.schema;let i=r;t.name==="svg"&&r.space==="html"&&(i=yy,e.schema=i),e.ancestors.push(t);const s=t.name===null?e.Fragment:IR(e,t.name,!0),o=iV(e,t),a=Cy(e,t);return PR(e,o,s,t),ky(o,a),e.ancestors.pop(),e.schema=r,e.create(t,s,o,n)}function JW(e,t,n){const r={};return ky(r,Cy(e,t)),e.create(t,e.Fragment,r,n)}function eV(e,t){return t.value}function PR(e,t,n,r){typeof n!="string"&&n!==e.Fragment&&e.passNode&&(t.node=r)}function ky(e,t){if(t.length>0){const n=t.length>1?t:t[0];n&&(e.children=n)}}function tV(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 nV(e,t){return n;function n(r,i,s,o){const a=Array.isArray(s.children),l=wy(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 rV(e,t){const n={};let r,i;for(i in t.properties)if(i!=="children"&&Sy.call(t.properties,i)){const s=sV(e,i,t.properties[i]);if(s){const[o,a]=s;e.tableCellAlignToStyle&&o==="align"&&typeof a=="string"&&KW.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 iV(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 Qc(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 Qc(e,t.position);else s=r.value===null?!0:r.value;n[i]=s}return n}function Cy(e,t){const n=[];let r=-1;const i=e.passKeys?new Map:WW;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=TR(e,s,o);a!==void 0&&n.push(a)}return n}function sV(e,t,n){const r=uW(e.schema,t);if(!(n==null||typeof n=="number"&&Number.isNaN(n))){if(Array.isArray(n)&&(n=r.commaSeparated?QU(n):pW(n)),r.property==="style"){let i=typeof n=="object"?n:oV(e,String(n));return e.stylePropertyNameCase==="css"&&(i=aV(i)),["style",i]}return[e.elementAttributeNameCase==="react"&&r.space?aW[r.property]||r.property:r.attribute,n]}}function oV(e,t){try{return HW(t,{reactCompat:!0})}catch(n){if(e.ignoreInvalidStyle)return{};const r=n,i=new Sn("Cannot parse `style` attribute",{ancestors:e.ancestors,cause:r,ruleId:"style",source:"hast-util-to-jsx-runtime"});throw i.file=e.filePath||void 0,i.url=NR+"#cannot-parse-style-attribute",i}}function IR(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=CS(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=CS(t)&&!/^[a-z]/.test(t)?{type:"Identifier",name:t}:{type:"Literal",value:t};if(r.type==="Literal"){const i=r.value;return Sy.call(e.components,i)?e.components[i]:i}if(e.evaluater)return e.evaluater.evaluateExpression(r);Qc(e)}function Qc(e,t){const n=new Sn("Cannot handle MDX estrees without `createEvaluater`",{ancestors:e.ancestors,place:t,ruleId:"mdx-estree",source:"hast-util-to-jsx-runtime"});throw n.file=e.filePath||void 0,n.url=NR+"#cannot-handle-mdx-estrees-without-createevaluater",n}function aV(e){const t={};let n;for(n in e)Sy.call(e,n)&&(t[lV(n)]=e[n]);return t}function lV(e){let t=e.replace(VW,cV);return t.slice(0,3)==="ms-"&&(t="-"+t),t}function cV(e){return"-"+e.toLowerCase()}const zm={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"]},uV={};function Ey(e,t){const n=uV,r=typeof n.includeImageAlt=="boolean"?n.includeImageAlt:!0,i=typeof n.includeHtml=="boolean"?n.includeHtml:!0;return RR(e,r,i)}function RR(e,t,n){if(dV(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 DS(e.children,t,n)}return Array.isArray(e)?DS(e,t,n):""}function DS(e,t,n){const r=[];let i=-1;for(;++i<e.length;)r[i]=RR(e[i],t,n);return r.join("")}function dV(e){return!!(e&&typeof e=="object")}const OS=document.createElement("i");function Ny(e){const t="&"+e+";";OS.innerHTML=t;const n=OS.textContent;return n.charCodeAt(n.length-1)===59&&e!=="semi"||n===t?!1:n}function er(e,t,n,r){const i=e.length;let s=0,o;if(t<0?t=-t>i?0:i+t:t=t>i?i:t,n=n>0?n:0,r.length<1e4)o=Array.from(r),o.unshift(t,n),e.splice(...o);else for(n&&e.splice(t,n);s<r.length;)o=r.slice(s,s+1e4),o.unshift(t,0),e.splice(...o),s+=1e4,t+=1e4}function fr(e,t){return e.length>0?(er(e,e.length,0,t),e):t}const BS={}.hasOwnProperty;function MR(e){const t={};let n=-1;for(;++n<e.length;)hV(t,e[n]);return t}function hV(e,t){let n;for(n in t){const i=(BS.call(e,n)?e[n]:void 0)||(e[n]={}),s=t[n];let o;if(s)for(o in s){BS.call(i,o)||(i[o]=[]);const a=s[o];fV(i[o],Array.isArray(a)?a:a?[a]:[])}}}function fV(e,t){let n=-1;const r=[];for(;++n<t.length;)(t[n].add==="after"?e:r).push(t[n]);er(e,0,0,r)}function AR(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 En=Ds(/[A-Za-z]/),yn=Ds(/[\dA-Za-z]/),pV=Ds(/[#-'*+\--9=?A-Z^-~]/);function ef(e){return e!==null&&(e<32||e===127)}const k0=Ds(/\d/),mV=Ds(/[\dA-Fa-f]/),gV=Ds(/[!-/:-@[-`{-~]/);function be(e){return e!==null&&e<-2}function ot(e){return e!==null&&(e<0||e===32)}function He(e){return e===-2||e===-1||e===32}const fp=Ds(new RegExp("\\p{P}|\\p{S}","u")),wo=Ds(/\s/);function Ds(e){return t;function t(n){return n!==null&&n>-1&&e.test(String.fromCharCode(n))}}function fl(e){const t=[];let n=-1,r=0,i=0;for(;++n<e.length;){const s=e.charCodeAt(n);let o="";if(s===37&&yn(e.charCodeAt(n+1))&&yn(e.charCodeAt(n+2)))i=2;else if(s<128)/[!#$&-;=?-Z_a-z~]/.test(String.fromCharCode(s))||(o=String.fromCharCode(s));else if(s>55295&&s<57344){const a=e.charCodeAt(n+1);s<56320&&a>56319&&a<57344?(o=String.fromCharCode(s,a),i=1):o="�"}else o=String.fromCharCode(s);o&&(t.push(e.slice(r,n),encodeURIComponent(o)),r=n+i+1,o=""),i&&(n+=i,i=0)}return t.join("")+e.slice(r)}function Ge(e,t,n,r){const i=r?r-1:Number.POSITIVE_INFINITY;let s=0;return o;function o(l){return He(l)?(e.enter(n),a(l)):t(l)}function a(l){return He(l)&&s++<i?(e.consume(l),a):(e.exit(n),t(l))}}const vV={tokenize:_V};function _V(e){const t=e.attempt(this.parser.constructs.contentInitial,r,i);let n;return t;function r(a){if(a===null){e.consume(a);return}return e.enter("lineEnding"),e.consume(a),e.exit("lineEnding"),Ge(e,t,"linePrefix")}function i(a){return e.enter("paragraph"),s(a)}function s(a){const l=e.enter("chunkText",{contentType:"text",previous:n});return n&&(n.next=l),n=l,o(a)}function o(a){if(a===null){e.exit("chunkText"),e.exit("paragraph"),e.consume(a);return}return be(a)?(e.consume(a),e.exit("chunkText"),s):(e.consume(a),o)}}const xV={tokenize:yV},zS={tokenize:bV};function yV(e){const t=this,n=[];let r=0,i,s,o;return a;function a(y){if(r<n.length){const w=n[r];return t.containerState=w[1],e.attempt(w[0].continuation,l,c)(y)}return c(y)}function l(y){if(r++,t.containerState._closeFlow){t.containerState._closeFlow=void 0,i&&x();const w=t.events.length;let k=w,C;for(;k--;)if(t.events[k][0]==="exit"&&t.events[k][1].type==="chunkFlow"){C=t.events[k][1].end;break}_(r);let N=w;for(;N<t.events.length;)t.events[N][1].end={...C},N++;return er(t.events,k+1,0,t.events.slice(w)),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(zS,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(zS,p,m)(y)}function p(y){return r++,n.push([t.currentConstruct,t.containerState]),f(y)}function m(y){if(y===null){i&&x(),_(0),e.consume(y);return}return i=i||t.parser.flow(t.now()),e.enter("chunkFlow",{_tokenizer:i,contentType:"flow",previous:s}),v(y)}function v(y){if(y===null){b(e.exit("chunkFlow"),!0),_(0),e.consume(y);return}return be(y)?(e.consume(y),b(e.exit("chunkFlow")),r=0,t.interrupt=void 0,a):(e.consume(y),v)}function b(y,w){const k=t.sliceStream(y);if(w&&k.push(null),y.previous=s,s&&(s.next=y),s=y,i.defineSkip(y.start),i.write(k),t.parser.lazy[y.start.line]){let C=i.events.length;for(;C--;)if(i.events[C][1].start.offset<o&&(!i.events[C][1].end||i.events[C][1].end.offset>o))return;const N=t.events.length;let T=N,B,P;for(;T--;)if(t.events[T][0]==="exit"&&t.events[T][1].type==="chunkFlow"){if(B){P=t.events[T][1].end;break}B=!0}for(_(r),C=N;C<t.events.length;)t.events[C][1].end={...P},C++;er(t.events,T+1,0,t.events.slice(N)),t.events.length=C}}function _(y){let w=n.length;for(;w-- >y;){const k=n[w];t.containerState=k[1],k[0].exit.call(t,e)}n.length=y}function x(){i.write([null]),s=void 0,i=void 0,t.containerState._closeFlow=void 0}}function bV(e,t,n){return Ge(e,e.attempt(this.parser.constructs.document,t,n),"linePrefix",this.parser.constructs.disable.null.includes("codeIndented")?void 0:4)}function Ha(e){if(e===null||ot(e)||wo(e))return 1;if(fp(e))return 2}function pp(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 C0={name:"attention",resolveAll:wV,tokenize:SV};function wV(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};$S(d,-l),$S(f,l),o={type:l>1?"strongSequence":"emphasisSequence",start:d,end:{...e[r][1].end}},a={type:l>1?"strongSequence":"emphasisSequence",start:{...e[n][1].start},end:f},s={type:l>1?"strongText":"emphasisText",start:{...e[r][1].end},end:{...e[n][1].start}},i={type:l>1?"strong":"emphasis",start:{...o.start},end:{...a.end}},e[r][1].end={...o.start},e[n][1].start={...a.end},c=[],e[r][1].end.offset-e[r][1].start.offset&&(c=fr(c,[["enter",e[r][1],t],["exit",e[r][1],t]])),c=fr(c,[["enter",i,t],["enter",o,t],["exit",o,t],["enter",s,t]]),c=fr(c,pp(t.parser.constructs.insideSpan.null,e.slice(r+1,n),t)),c=fr(c,[["exit",s,t],["enter",a,t],["exit",a,t],["exit",i,t]]),e[n][1].end.offset-e[n][1].start.offset?(u=2,c=fr(c,[["enter",e[n][1],t],["exit",e[n][1],t]])):u=0,er(e,r-1,n-r+3,c),n=r+c.length-u-2;break}}for(n=-1;++n<e.length;)e[n][1].type==="attentionSequence"&&(e[n][1].type="data");return e}function SV(e,t){const n=this.parser.constructs.attentionMarkers.null,r=this.previous,i=Ha(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=Ha(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 $S(e,t){e.column+=t,e.offset+=t,e._bufferIndex+=t}const kV={name:"autolink",tokenize:CV};function CV(e,t,n){let r=0;return i;function i(p){return e.enter("autolink"),e.enter("autolinkMarker"),e.consume(p),e.exit("autolinkMarker"),e.enter("autolinkProtocol"),s}function s(p){return En(p)?(e.consume(p),o):p===64?n(p):c(p)}function o(p){return p===43||p===45||p===46||yn(p)?(r=1,a(p)):c(p)}function a(p){return p===58?(e.consume(p),r=0,l):(p===43||p===45||p===46||yn(p))&&r++<32?(e.consume(p),a):(r=0,c(p))}function l(p){return p===62?(e.exit("autolinkProtocol"),e.enter("autolinkMarker"),e.consume(p),e.exit("autolinkMarker"),e.exit("autolink"),t):p===null||p===32||p===60||ef(p)?n(p):(e.consume(p),l)}function c(p){return p===64?(e.consume(p),u):pV(p)?(e.consume(p),c):n(p)}function u(p){return yn(p)?d(p):n(p)}function d(p){return p===46?(e.consume(p),r=0,u):p===62?(e.exit("autolinkProtocol").type="autolinkEmail",e.enter("autolinkMarker"),e.consume(p),e.exit("autolinkMarker"),e.exit("autolink"),t):f(p)}function f(p){if((p===45||yn(p))&&r++<63){const m=p===45?f:d;return e.consume(p),m}return n(p)}}const Cu={partial:!0,tokenize:EV};function EV(e,t,n){return r;function r(s){return He(s)?Ge(e,i,"linePrefix")(s):i(s)}function i(s){return s===null||be(s)?t(s):n(s)}}const LR={continuation:{tokenize:TV},exit:PV,name:"blockQuote",tokenize:NV};function NV(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 He(o)?(e.enter("blockQuotePrefixWhitespace"),e.consume(o),e.exit("blockQuotePrefixWhitespace"),e.exit("blockQuotePrefix"),t):(e.exit("blockQuotePrefix"),t(o))}}function TV(e,t,n){const r=this;return i;function i(o){return He(o)?Ge(e,s,"linePrefix",r.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(o):s(o)}function s(o){return e.attempt(LR,t,n)(o)}}function PV(e){e.exit("blockQuote")}const jR={name:"characterEscape",tokenize:IV};function IV(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 gV(s)?(e.enter("characterEscapeValue"),e.consume(s),e.exit("characterEscapeValue"),e.exit("characterEscape"),t):n(s)}}const DR={name:"characterReference",tokenize:RV};function RV(e,t,n){const r=this;let i=0,s,o;return a;function a(d){return e.enter("characterReference"),e.enter("characterReferenceMarker"),e.consume(d),e.exit("characterReferenceMarker"),l}function l(d){return d===35?(e.enter("characterReferenceMarkerNumeric"),e.consume(d),e.exit("characterReferenceMarkerNumeric"),c):(e.enter("characterReferenceValue"),s=31,o=yn,u(d))}function c(d){return d===88||d===120?(e.enter("characterReferenceMarkerHexadecimal"),e.consume(d),e.exit("characterReferenceMarkerHexadecimal"),e.enter("characterReferenceValue"),s=6,o=mV,u):(e.enter("characterReferenceValue"),s=7,o=k0,u(d))}function u(d){if(d===59&&i){const f=e.exit("characterReferenceValue");return o===yn&&!Ny(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 FS={partial:!0,tokenize:AV},HS={concrete:!0,name:"codeFenced",tokenize:MV};function MV(e,t,n){const r=this,i={partial:!0,tokenize:k};let s=0,o=0,a;return l;function l(C){return c(C)}function c(C){const N=r.events[r.events.length-1];return s=N&&N[1].type==="linePrefix"?N[2].sliceSerialize(N[1],!0).length:0,a=C,e.enter("codeFenced"),e.enter("codeFencedFence"),e.enter("codeFencedFenceSequence"),u(C)}function u(C){return C===a?(o++,e.consume(C),u):o<3?n(C):(e.exit("codeFencedFenceSequence"),He(C)?Ge(e,d,"whitespace")(C):d(C))}function d(C){return C===null||be(C)?(e.exit("codeFencedFence"),r.interrupt?t(C):e.check(FS,v,w)(C)):(e.enter("codeFencedFenceInfo"),e.enter("chunkString",{contentType:"string"}),f(C))}function f(C){return C===null||be(C)?(e.exit("chunkString"),e.exit("codeFencedFenceInfo"),d(C)):He(C)?(e.exit("chunkString"),e.exit("codeFencedFenceInfo"),Ge(e,p,"whitespace")(C)):C===96&&C===a?n(C):(e.consume(C),f)}function p(C){return C===null||be(C)?d(C):(e.enter("codeFencedFenceMeta"),e.enter("chunkString",{contentType:"string"}),m(C))}function m(C){return C===null||be(C)?(e.exit("chunkString"),e.exit("codeFencedFenceMeta"),d(C)):C===96&&C===a?n(C):(e.consume(C),m)}function v(C){return e.attempt(i,w,b)(C)}function b(C){return e.enter("lineEnding"),e.consume(C),e.exit("lineEnding"),_}function _(C){return s>0&&He(C)?Ge(e,x,"linePrefix",s+1)(C):x(C)}function x(C){return C===null||be(C)?e.check(FS,v,w)(C):(e.enter("codeFlowValue"),y(C))}function y(C){return C===null||be(C)?(e.exit("codeFlowValue"),x(C)):(e.consume(C),y)}function w(C){return e.exit("codeFenced"),t(C)}function k(C,N,T){let B=0;return P;function P(z){return C.enter("lineEnding"),C.consume(z),C.exit("lineEnding"),j}function j(z){return C.enter("codeFencedFence"),He(z)?Ge(C,I,"linePrefix",r.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(z):I(z)}function I(z){return z===a?(C.enter("codeFencedFenceSequence"),R(z)):T(z)}function R(z){return z===a?(B++,C.consume(z),R):B>=o?(C.exit("codeFencedFenceSequence"),He(z)?Ge(C,L,"whitespace")(z):L(z)):T(z)}function L(z){return z===null||be(z)?(C.exit("codeFencedFence"),N(z)):T(z)}}}function AV(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 $m={name:"codeIndented",tokenize:jV},LV={partial:!0,tokenize:DV};function jV(e,t,n){const r=this;return i;function i(c){return e.enter("codeIndented"),Ge(e,s,"linePrefix",5)(c)}function s(c){const u=r.events[r.events.length-1];return u&&u[1].type==="linePrefix"&&u[2].sliceSerialize(u[1],!0).length>=4?o(c):n(c)}function o(c){return c===null?l(c):be(c)?e.attempt(LV,o,l)(c):(e.enter("codeFlowValue"),a(c))}function a(c){return c===null||be(c)?(e.exit("codeFlowValue"),o(c)):(e.consume(c),a)}function l(c){return e.exit("codeIndented"),t(c)}}function DV(e,t,n){const r=this;return i;function i(o){return r.parser.lazy[r.now().line]?n(o):be(o)?(e.enter("lineEnding"),e.consume(o),e.exit("lineEnding"),i):Ge(e,s,"linePrefix",5)(o)}function s(o){const a=r.events[r.events.length-1];return a&&a[1].type==="linePrefix"&&a[2].sliceSerialize(a[1],!0).length>=4?t(o):be(o)?i(o):n(o)}}const OV={name:"codeText",previous:zV,resolve:BV,tokenize:$V};function BV(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 zV(e){return e!==96||this.events[this.events.length-1][1].type==="characterEscape"}function $V(e,t,n){let r=0,i,s;return o;function o(d){return e.enter("codeText"),e.enter("codeTextSequence"),a(d)}function a(d){return d===96?(e.consume(d),r++,a):(e.exit("codeTextSequence"),l(d))}function l(d){return d===null?n(d):d===32?(e.enter("space"),e.consume(d),e.exit("space"),l):d===96?(s=e.enter("codeTextSequence"),i=0,u(d)):be(d)?(e.enter("lineEnding"),e.consume(d),e.exit("lineEnding"),l):(e.enter("codeTextData"),c(d))}function c(d){return d===null||d===32||d===96||be(d)?(e.exit("codeTextData"),l(d)):(e.consume(d),c)}function u(d){return d===96?(e.consume(d),i++,u):i===r?(e.exit("codeTextSequence"),e.exit("codeText"),t(d)):(s.type="codeTextData",c(d))}}class FV{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&&Al(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),Al(this.left,t)}unshift(t){this.setCursor(0),this.right.push(t)}unshiftMany(t){this.setCursor(0),Al(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);Al(this.right,n.reverse())}else{const n=this.right.splice(this.left.length+this.right.length-t,Number.POSITIVE_INFINITY);Al(this.left,n.reverse())}}}function Al(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 OR(e){const t={};let n=-1,r,i,s,o,a,l,c;const u=new FV(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,HV(u,n)),n=t[n],c=!0);else if(r[1]._container){for(s=n,i=void 0;s--;)if(o=u.get(s),o[1].type==="lineEnding"||o[1].type==="lineEndingBlank")o[0]==="enter"&&(i&&(u.get(i)[1].type="lineEndingBlank"),o[1].type="lineEnding",i=s);else if(!(o[1].type==="linePrefix"||o[1].type==="listItemIndent"))break;i&&(r[1].end={...u.get(i)[1].start},a=u.slice(i,n),a.unshift(r),u.splice(i,n-i+1,a))}}return er(e,0,Number.POSITIVE_INFINITY,u.slice(0)),!c}function HV(e,t){const n=e.get(t)[1],r=e.get(t)[2];let i=t-1;const s=[];let o=n._tokenizer;o||(o=r.parser[n.contentType](n.start),n._contentTypeTextTrailing&&(o._contentTypeTextTrailing=!0));const a=o.events,l=[],c={};let u,d,f=-1,p=n,m=0,v=0;const b=[v];for(;p;){for(;e.get(++i)[1]!==p;);s.push(i),p._tokenizer||(u=r.sliceStream(p),p.next||u.push(null),d&&o.defineSkip(p.start),p._isInFirstContentOfListItem&&(o._gfmTasklistFirstContentOfListItem=!0),o.write(u),p._isInFirstContentOfListItem&&(o._gfmTasklistFirstContentOfListItem=void 0)),d=p,p=p.next}for(p=n;++f<a.length;)a[f][0]==="exit"&&a[f-1][0]==="enter"&&a[f][1].type===a[f-1][1].type&&a[f][1].start.line!==a[f][1].end.line&&(v=f+1,b.push(v),p._tokenizer=void 0,p.previous=void 0,p=p.next);for(o.events=[],p?(p._tokenizer=void 0,p.previous=void 0):b.pop(),f=b.length;f--;){const _=a.slice(b[f],b[f+1]),x=s.pop();l.push([x,x+_.length-1]),e.splice(x,2,_)}for(l.reverse(),f=-1;++f<l.length;)c[m+l[f][0]]=m+l[f][1],m+=l[f][1]-l[f][0]-1;return c}const UV={resolve:VV,tokenize:qV},WV={partial:!0,tokenize:KV};function VV(e){return OR(e),e}function qV(e,t){let n;return r;function r(a){return e.enter("content"),n=e.enter("chunkContent",{contentType:"content"}),i(a)}function i(a){return a===null?s(a):be(a)?e.check(WV,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 KV(e,t,n){const r=this;return i;function i(o){return e.exit("chunkContent"),e.enter("lineEnding"),e.consume(o),e.exit("lineEnding"),Ge(e,s,"linePrefix")}function s(o){if(o===null||be(o))return n(o);const a=r.events[r.events.length-1];return!r.parser.constructs.disable.null.includes("codeIndented")&&a&&a[1].type==="linePrefix"&&a[2].sliceSerialize(a[1],!0).length>=4?t(o):e.interrupt(r.parser.constructs.flow,n,t)(o)}}function BR(e,t,n,r,i,s,o,a,l){const c=l||Number.POSITIVE_INFINITY;let u=0;return d;function d(_){return _===60?(e.enter(r),e.enter(i),e.enter(s),e.consume(_),e.exit(s),f):_===null||_===32||_===41||ef(_)?n(_):(e.enter(r),e.enter(o),e.enter(a),e.enter("chunkString",{contentType:"string"}),v(_))}function f(_){return _===62?(e.enter(s),e.consume(_),e.exit(s),e.exit(i),e.exit(r),t):(e.enter(a),e.enter("chunkString",{contentType:"string"}),p(_))}function p(_){return _===62?(e.exit("chunkString"),e.exit(a),f(_)):_===null||_===60||be(_)?n(_):(e.consume(_),_===92?m:p)}function m(_){return _===60||_===62||_===92?(e.consume(_),p):p(_)}function v(_){return!u&&(_===null||_===41||ot(_))?(e.exit("chunkString"),e.exit(a),e.exit(o),e.exit(r),t(_)):u<c&&_===40?(e.consume(_),u++,v):_===41?(e.consume(_),u--,v):_===null||_===32||_===40||ef(_)?n(_):(e.consume(_),_===92?b:v)}function b(_){return _===40||_===41||_===92?(e.consume(_),v):v(_)}}function zR(e,t,n,r,i,s){const o=this;let a=0,l;return c;function c(p){return e.enter(r),e.enter(i),e.consume(p),e.exit(i),e.enter(s),u}function u(p){return a>999||p===null||p===91||p===93&&!l||p===94&&!a&&"_hiddenFootnoteSupport"in o.parser.constructs?n(p):p===93?(e.exit(s),e.enter(i),e.consume(p),e.exit(i),e.exit(r),t):be(p)?(e.enter("lineEnding"),e.consume(p),e.exit("lineEnding"),u):(e.enter("chunkString",{contentType:"string"}),d(p))}function d(p){return p===null||p===91||p===93||be(p)||a++>999?(e.exit("chunkString"),u(p)):(e.consume(p),l||(l=!He(p)),p===92?f:d)}function f(p){return p===91||p===92||p===93?(e.consume(p),a++,d):d(p)}}function $R(e,t,n,r,i,s){let o;return a;function a(f){return f===34||f===39||f===40?(e.enter(r),e.enter(i),e.consume(f),e.exit(i),o=f===40?41:f,l):n(f)}function l(f){return f===o?(e.enter(i),e.consume(f),e.exit(i),e.exit(r),t):(e.enter(s),c(f))}function c(f){return f===o?(e.exit(s),l(o)):f===null?n(f):be(f)?(e.enter("lineEnding"),e.consume(f),e.exit("lineEnding"),Ge(e,c,"linePrefix")):(e.enter("chunkString",{contentType:"string"}),u(f))}function u(f){return f===o||f===null||be(f)?(e.exit("chunkString"),c(f)):(e.consume(f),f===92?d:u)}function d(f){return f===o||f===92?(e.consume(f),u):u(f)}}function gc(e,t){let n;return r;function r(i){return be(i)?(e.enter("lineEnding"),e.consume(i),e.exit("lineEnding"),n=!0,r):He(i)?Ge(e,r,n?"linePrefix":"lineSuffix")(i):t(i)}}const GV={name:"definition",tokenize:YV},XV={partial:!0,tokenize:ZV};function YV(e,t,n){const r=this;let i;return s;function s(p){return e.enter("definition"),o(p)}function o(p){return zR.call(r,e,a,n,"definitionLabel","definitionLabelMarker","definitionLabelString")(p)}function a(p){return i=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)?gc(e,c)(p):c(p)}function c(p){return BR(e,u,n,"definitionDestination","definitionDestinationLiteral","definitionDestinationLiteralMarker","definitionDestinationRaw","definitionDestinationString")(p)}function u(p){return e.attempt(XV,d,d)(p)}function d(p){return He(p)?Ge(e,f,"whitespace")(p):f(p)}function f(p){return p===null||be(p)?(e.exit("definition"),r.parser.defined.push(i),t(p)):n(p)}}function ZV(e,t,n){return r;function r(a){return ot(a)?gc(e,i)(a):n(a)}function i(a){return $R(e,s,n,"definitionTitle","definitionTitleMarker","definitionTitleString")(a)}function s(a){return He(a)?Ge(e,o,"whitespace")(a):o(a)}function o(a){return a===null||be(a)?t(a):n(a)}}const QV={name:"hardBreakEscape",tokenize:JV};function JV(e,t,n){return r;function r(s){return e.enter("hardBreakEscape"),e.consume(s),i}function i(s){return be(s)?(e.exit("hardBreakEscape"),t(s)):n(s)}}const eq={name:"headingAtx",resolve:tq,tokenize:nq};function tq(e,t){let n=e.length-2,r=3,i,s;return e[r][1].type==="whitespace"&&(r+=2),n-2>r&&e[n][1].type==="whitespace"&&(n-=2),e[n][1].type==="atxHeadingSequence"&&(r===n-1||n-4>r&&e[n-2][1].type==="whitespace")&&(n-=r+1===n?2:4),n>r&&(i={type:"atxHeadingText",start:e[r][1].start,end:e[n][1].end},s={type:"chunkText",start:e[r][1].start,end:e[n][1].end,contentType:"text"},er(e,r,n-r+1,[["enter",i,t],["enter",s,t],["exit",s,t],["exit",i,t]])),e}function nq(e,t,n){let r=0;return i;function i(u){return e.enter("atxHeading"),s(u)}function s(u){return e.enter("atxHeadingSequence"),o(u)}function o(u){return u===35&&r++<6?(e.consume(u),o):u===null||ot(u)?(e.exit("atxHeadingSequence"),a(u)):n(u)}function a(u){return u===35?(e.enter("atxHeadingSequence"),l(u)):u===null||be(u)?(e.exit("atxHeading"),t(u)):He(u)?Ge(e,a,"whitespace")(u):(e.enter("atxHeadingText"),c(u))}function l(u){return u===35?(e.consume(u),l):(e.exit("atxHeadingSequence"),a(u))}function c(u){return u===null||u===35||ot(u)?(e.exit("atxHeadingText"),a(u)):(e.consume(u),c)}}const rq=["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"],US=["pre","script","style","textarea"],iq={concrete:!0,name:"htmlFlow",resolveTo:aq,tokenize:lq},sq={partial:!0,tokenize:uq},oq={partial:!0,tokenize:cq};function aq(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 lq(e,t,n){const r=this;let i,s,o,a,l;return c;function c(A){return u(A)}function u(A){return e.enter("htmlFlow"),e.enter("htmlFlowData"),e.consume(A),d}function d(A){return A===33?(e.consume(A),f):A===47?(e.consume(A),s=!0,v):A===63?(e.consume(A),i=3,r.interrupt?t:E):En(A)?(e.consume(A),o=String.fromCharCode(A),b):n(A)}function f(A){return A===45?(e.consume(A),i=2,p):A===91?(e.consume(A),i=5,a=0,m):En(A)?(e.consume(A),i=4,r.interrupt?t:E):n(A)}function p(A){return A===45?(e.consume(A),r.interrupt?t:E):n(A)}function m(A){const ne="CDATA[";return A===ne.charCodeAt(a++)?(e.consume(A),a===ne.length?r.interrupt?t:I:m):n(A)}function v(A){return En(A)?(e.consume(A),o=String.fromCharCode(A),b):n(A)}function b(A){if(A===null||A===47||A===62||ot(A)){const ne=A===47,oe=o.toLowerCase();return!ne&&!s&&US.includes(oe)?(i=1,r.interrupt?t(A):I(A)):rq.includes(o.toLowerCase())?(i=6,ne?(e.consume(A),_):r.interrupt?t(A):I(A)):(i=7,r.interrupt&&!r.parser.lazy[r.now().line]?n(A):s?x(A):y(A))}return A===45||yn(A)?(e.consume(A),o+=String.fromCharCode(A),b):n(A)}function _(A){return A===62?(e.consume(A),r.interrupt?t:I):n(A)}function x(A){return He(A)?(e.consume(A),x):P(A)}function y(A){return A===47?(e.consume(A),P):A===58||A===95||En(A)?(e.consume(A),w):He(A)?(e.consume(A),y):P(A)}function w(A){return A===45||A===46||A===58||A===95||yn(A)?(e.consume(A),w):k(A)}function k(A){return A===61?(e.consume(A),C):He(A)?(e.consume(A),k):y(A)}function C(A){return A===null||A===60||A===61||A===62||A===96?n(A):A===34||A===39?(e.consume(A),l=A,N):He(A)?(e.consume(A),C):T(A)}function N(A){return A===l?(e.consume(A),l=null,B):A===null||be(A)?n(A):(e.consume(A),N)}function T(A){return A===null||A===34||A===39||A===47||A===60||A===61||A===62||A===96||ot(A)?k(A):(e.consume(A),T)}function B(A){return A===47||A===62||He(A)?y(A):n(A)}function P(A){return A===62?(e.consume(A),j):n(A)}function j(A){return A===null||be(A)?I(A):He(A)?(e.consume(A),j):n(A)}function I(A){return A===45&&i===2?(e.consume(A),$):A===60&&i===1?(e.consume(A),F):A===62&&i===4?(e.consume(A),H):A===63&&i===3?(e.consume(A),E):A===93&&i===5?(e.consume(A),O):be(A)&&(i===6||i===7)?(e.exit("htmlFlowData"),e.check(sq,V,R)(A)):A===null||be(A)?(e.exit("htmlFlowData"),R(A)):(e.consume(A),I)}function R(A){return e.check(oq,L,V)(A)}function L(A){return e.enter("lineEnding"),e.consume(A),e.exit("lineEnding"),z}function z(A){return A===null||be(A)?R(A):(e.enter("htmlFlowData"),I(A))}function $(A){return A===45?(e.consume(A),E):I(A)}function F(A){return A===47?(e.consume(A),o="",D):I(A)}function D(A){if(A===62){const ne=o.toLowerCase();return US.includes(ne)?(e.consume(A),H):I(A)}return En(A)&&o.length<8?(e.consume(A),o+=String.fromCharCode(A),D):I(A)}function O(A){return A===93?(e.consume(A),E):I(A)}function E(A){return A===62?(e.consume(A),H):A===45&&i===2?(e.consume(A),E):I(A)}function H(A){return A===null||be(A)?(e.exit("htmlFlowData"),V(A)):(e.consume(A),H)}function V(A){return e.exit("htmlFlow"),t(A)}}function cq(e,t,n){const r=this;return i;function i(o){return be(o)?(e.enter("lineEnding"),e.consume(o),e.exit("lineEnding"),s):n(o)}function s(o){return r.parser.lazy[r.now().line]?n(o):t(o)}}function uq(e,t,n){return r;function r(i){return e.enter("lineEnding"),e.consume(i),e.exit("lineEnding"),e.attempt(Cu,t,n)}}const dq={name:"htmlText",tokenize:hq};function hq(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),k):E===63?(e.consume(E),y):En(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):En(E)?(e.consume(E),x):n(E)}function u(E){return E===45?(e.consume(E),p):n(E)}function d(E){return E===null?n(E):E===45?(e.consume(E),f):be(E)?(o=d,F(E)):(e.consume(E),d)}function f(E){return E===45?(e.consume(E),p):d(E)}function p(E){return E===62?$(E):E===45?f(E):d(E)}function m(E){const H="CDATA[";return E===H.charCodeAt(s++)?(e.consume(E),s===H.length?v:m):n(E)}function v(E){return E===null?n(E):E===93?(e.consume(E),b):be(E)?(o=v,F(E)):(e.consume(E),v)}function b(E){return E===93?(e.consume(E),_):v(E)}function _(E){return E===62?$(E):E===93?(e.consume(E),_):v(E)}function x(E){return E===null||E===62?$(E):be(E)?(o=x,F(E)):(e.consume(E),x)}function y(E){return E===null?n(E):E===63?(e.consume(E),w):be(E)?(o=y,F(E)):(e.consume(E),y)}function w(E){return E===62?$(E):y(E)}function k(E){return En(E)?(e.consume(E),C):n(E)}function C(E){return E===45||yn(E)?(e.consume(E),C):N(E)}function N(E){return be(E)?(o=N,F(E)):He(E)?(e.consume(E),N):$(E)}function T(E){return E===45||yn(E)?(e.consume(E),T):E===47||E===62||ot(E)?B(E):n(E)}function B(E){return E===47?(e.consume(E),$):E===58||E===95||En(E)?(e.consume(E),P):be(E)?(o=B,F(E)):He(E)?(e.consume(E),B):$(E)}function P(E){return E===45||E===46||E===58||E===95||yn(E)?(e.consume(E),P):j(E)}function j(E){return E===61?(e.consume(E),I):be(E)?(o=j,F(E)):He(E)?(e.consume(E),j):B(E)}function I(E){return E===null||E===60||E===61||E===62||E===96?n(E):E===34||E===39?(e.consume(E),i=E,R):be(E)?(o=I,F(E)):He(E)?(e.consume(E),I):(e.consume(E),L)}function R(E){return E===i?(e.consume(E),i=void 0,z):E===null?n(E):be(E)?(o=R,F(E)):(e.consume(E),R)}function L(E){return E===null||E===34||E===39||E===60||E===61||E===96?n(E):E===47||E===62||ot(E)?B(E):(e.consume(E),L)}function z(E){return E===47||E===62||ot(E)?B(E):n(E)}function $(E){return E===62?(e.consume(E),e.exit("htmlTextData"),e.exit("htmlText"),t):n(E)}function F(E){return e.exit("htmlTextData"),e.enter("lineEnding"),e.consume(E),e.exit("lineEnding"),D}function D(E){return He(E)?Ge(e,O,"linePrefix",r.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(E):O(E)}function O(E){return e.enter("htmlTextData"),o(E)}}const Ty={name:"labelEnd",resolveAll:gq,resolveTo:vq,tokenize:_q},fq={tokenize:xq},pq={tokenize:yq},mq={tokenize:bq};function gq(e){let t=-1;const n=[];for(;++t<e.length;){const r=e[t][1];if(n.push(e[t]),r.type==="labelImage"||r.type==="labelLink"||r.type==="labelEnd"){const i=r.type==="labelImage"?4:2;r.type="data",t+=i}}return e.length!==n.length&&er(e,0,e.length,n),e}function vq(e,t){let n=e.length,r=0,i,s,o,a;for(;n--;)if(i=e[n][1],s){if(i.type==="link"||i.type==="labelLink"&&i._inactive)break;e[n][0]==="enter"&&i.type==="labelLink"&&(i._inactive=!0)}else if(o){if(e[n][0]==="enter"&&(i.type==="labelImage"||i.type==="labelLink")&&!i._balanced&&(s=n,i.type!=="labelLink")){r=2;break}}else i.type==="labelEnd"&&(o=n);const l={type:e[s][1].type==="labelLink"?"link":"image",start:{...e[s][1].start},end:{...e[e.length-1][1].end}},c={type:"label",start:{...e[s][1].start},end:{...e[o][1].end}},u={type:"labelText",start:{...e[s+r+2][1].end},end:{...e[o-2][1].start}};return a=[["enter",l,t],["enter",c,t]],a=fr(a,e.slice(s+1,s+r+3)),a=fr(a,[["enter",u,t]]),a=fr(a,pp(t.parser.constructs.insideSpan.null,e.slice(s+r+4,o-3),t)),a=fr(a,[["exit",u,t],e[o-2],e[o-1],["exit",c,t]]),a=fr(a,e.slice(o+1)),a=fr(a,[["exit",l,t]]),er(e,s,e.length,a),e}function _q(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(fq,u,o?u:d)(f):f===91?e.attempt(pq,u,o?c:d)(f):o?u(f):d(f)}function c(f){return e.attempt(mq,u,d)(f)}function u(f){return t(f)}function d(f){return s._balanced=!0,n(f)}}function xq(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)?gc(e,s)(d):s(d)}function s(d){return d===41?u(d):BR(e,o,a,"resourceDestination","resourceDestinationLiteral","resourceDestinationLiteralMarker","resourceDestinationRaw","resourceDestinationString",32)(d)}function o(d){return ot(d)?gc(e,l)(d):u(d)}function a(d){return n(d)}function l(d){return d===34||d===39||d===40?$R(e,c,n,"resourceTitle","resourceTitleMarker","resourceTitleString")(d):u(d)}function c(d){return ot(d)?gc(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 yq(e,t,n){const r=this;return i;function i(a){return zR.call(r,e,s,o,"reference","referenceMarker","referenceString")(a)}function s(a){return r.parser.defined.includes(Lr(r.sliceSerialize(r.events[r.events.length-1][1]).slice(1,-1)))?t(a):n(a)}function o(a){return n(a)}}function bq(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 wq={name:"labelStartImage",resolveAll:Ty.resolveAll,tokenize:Sq};function Sq(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 kq={name:"labelStartLink",resolveAll:Ty.resolveAll,tokenize:Cq};function Cq(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 Fm={name:"lineEnding",tokenize:Eq};function Eq(e,t){return n;function n(r){return e.enter("lineEnding"),e.consume(r),e.exit("lineEnding"),Ge(e,t,"linePrefix")}}const Jd={name:"thematicBreak",tokenize:Nq};function Nq(e,t,n){let r=0,i;return s;function s(c){return e.enter("thematicBreak"),o(c)}function o(c){return i=c,a(c)}function a(c){return c===i?(e.enter("thematicBreakSequence"),l(c)):r>=3&&(c===null||be(c))?(e.exit("thematicBreak"),t(c)):n(c)}function l(c){return c===i?(e.consume(c),r++,l):(e.exit("thematicBreakSequence"),He(c)?Ge(e,a,"whitespace")(c):a(c))}}const On={continuation:{tokenize:Rq},exit:Aq,name:"list",tokenize:Iq},Tq={partial:!0,tokenize:Lq},Pq={partial:!0,tokenize:Mq};function Iq(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:k0(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(Jd,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 k0(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(Cu,r.interrupt?n:u,e.attempt(Tq,f,d))}function u(p){return r.containerState.initialBlankLine=!0,s++,f(p)}function d(p){return He(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 Rq(e,t,n){const r=this;return r.containerState._closeFlow=void 0,e.check(Cu,i,s);function i(a){return r.containerState.furtherBlankLines=r.containerState.furtherBlankLines||r.containerState.initialBlankLine,Ge(e,t,"listItemIndent",r.containerState.size+1)(a)}function s(a){return r.containerState.furtherBlankLines||!He(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(Pq,t,o)(a))}function o(a){return r.containerState._closeFlow=!0,r.interrupt=void 0,Ge(e,e.attempt(On,t,n),"linePrefix",r.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(a)}}function Mq(e,t,n){const r=this;return Ge(e,i,"listItemIndent",r.containerState.size+1);function i(s){const o=r.events[r.events.length-1];return o&&o[1].type==="listItemIndent"&&o[2].sliceSerialize(o[1],!0).length===r.containerState.size?t(s):n(s)}}function Aq(e){e.exit(this.containerState.type)}function Lq(e,t,n){const r=this;return Ge(e,i,"listItemPrefixWhitespace",r.parser.constructs.disable.null.includes("codeIndented")?void 0:5);function i(s){const o=r.events[r.events.length-1];return!He(s)&&o&&o[1].type==="listItemPrefixWhitespace"?t(s):n(s)}}const WS={name:"setextUnderline",resolveTo:jq,tokenize:Dq};function jq(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 Dq(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"),He(c)?Ge(e,l,"lineSuffix")(c):l(c))}function l(c){return c===null||be(c)?(e.exit("setextHeadingLine"),t(c)):n(c)}}const Oq={tokenize:Bq};function Bq(e){const t=this,n=e.attempt(Cu,r,e.attempt(this.parser.constructs.flowInitial,i,Ge(e,e.attempt(this.parser.constructs.flow,i,e.attempt(UV,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 zq={resolveAll:HR()},$q=FR("string"),Fq=FR("text");function FR(e){return{resolveAll:HR(e==="text"?Hq: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 HR(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 Hq(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 Uq={42:On,43:On,45:On,48:On,49:On,50:On,51:On,52:On,53:On,54:On,55:On,56:On,57:On,62:LR},Wq={91:GV},Vq={[-2]:$m,[-1]:$m,32:$m},qq={35:eq,42:Jd,45:[WS,Jd],60:iq,61:WS,95:Jd,96:HS,126:HS},Kq={38:DR,92:jR},Gq={[-5]:Fm,[-4]:Fm,[-3]:Fm,33:wq,38:DR,42:C0,60:[kV,dq],91:kq,92:[QV,jR],93:Ty,95:C0,96:OV},Xq={null:[C0,zq]},Yq={null:[42,95]},Zq={null:[]},Qq=Object.freeze(Object.defineProperty({__proto__:null,attentionMarkers:Yq,contentInitial:Wq,disable:Zq,document:Uq,flow:qq,flowInitial:Vq,insideSpan:Xq,string:Kq,text:Gq},Symbol.toStringTag,{value:"Module"}));function Jq(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(k),check:N(C),consume:x,enter:y,exit:w,interrupt:N(C,{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(j){return o=fr(o,j),b(),o[o.length-1]!==null?[]:(T(t,0),c.events=pp(s,c.events,c),c.events)}function f(j,I){return tK(p(j),I)}function p(j){return eK(o,j)}function m(){const{_bufferIndex:j,_index:I,line:R,column:L,offset:z}=r;return{_bufferIndex:j,_index:I,line:R,column:L,offset:z}}function v(j){i[j.line]=j.column,P()}function b(){let j;for(;r._index<o.length;){const I=o[r._index];if(typeof I=="string")for(j=r._index,r._bufferIndex<0&&(r._bufferIndex=0);r._index===j&&r._bufferIndex<I.length;)_(I.charCodeAt(r._bufferIndex));else _(I)}}function _(j){u=u(j)}function x(j){be(j)?(r.line++,r.column=1,r.offset+=j===-3?2:1,P()):j!==-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=j}function y(j,I){const R=I||{};return R.type=j,R.start=m(),c.events.push(["enter",R,c]),a.push(R),R}function w(j){const I=a.pop();return I.end=m(),c.events.push(["exit",I,c]),I}function k(j,I){T(j,I.from)}function C(j,I){I.restore()}function N(j,I){return R;function R(L,z,$){let F,D,O,E;return Array.isArray(L)?V(L):"tokenize"in L?V([L]):H(L);function H(X){return ye;function ye($e){const ue=$e!==null&&X[$e],Ie=$e!==null&&X.null,Re=[...Array.isArray(ue)?ue:ue?[ue]:[],...Array.isArray(Ie)?Ie:Ie?[Ie]:[]];return V(Re)($e)}}function V(X){return F=X,D=0,X.length===0?$:A(X[D])}function A(X){return ye;function ye($e){return E=B(),O=X,X.partial||(c.currentConstruct=X),X.name&&c.parser.constructs.disable.null.includes(X.name)?oe():X.tokenize.call(I?Object.assign(Object.create(c),I):c,l,ne,oe)($e)}}function ne(X){return j(O,E),z}function oe(X){return E.restore(),++D<F.length?A(F[D]):$}}}function T(j,I){j.resolveAll&&!s.includes(j)&&s.push(j),j.resolve&&er(c.events,I,c.events.length-I,j.resolve(c.events.slice(I),c)),j.resolveTo&&(c.events=j.resolveTo(c.events,c))}function B(){const j=m(),I=c.previous,R=c.currentConstruct,L=c.events.length,z=Array.from(a);return{from:L,restore:$};function $(){r=j,c.previous=I,c.currentConstruct=R,c.events.length=L,a=z,P()}}function P(){r.line in i&&r.column<2&&(r.column=i[r.line],r.offset+=i[r.line]-1)}}function eK(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 tK(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=`
|
|
477
477
|
`;break}case-3:{o=`\r
|
|
478
478
|
`;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 nK(e){const r={constructs:MR([Qq,...(e||{}).extensions||[]]),content:i(vV),defined:[],document:i(xV),flow:i(Oq),lazy:{},string:i($q),text:i(Fq)};return r;function i(s){return o;function o(a){return Jq(r,s,a)}}}function rK(e){for(;!OR(e););return e}const VS=/[\0\t\n\r]/g;function iK(){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(VS.lastIndex=d,c=VS.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 sK=/\\([!-/:-@[-`{-~])|&(#(?:\d{1,7}|x[\da-f]{1,6})|[\da-z]{1,31});/gi;function oK(e){return e.replace(sK,aK)}function aK(e,t,n){if(t)return t;if(n.charCodeAt(0)===35){const i=n.charCodeAt(1),s=i===120||i===88;return AR(n.slice(s?2:1),s?16:10)}return Ny(n)||e}const UR={}.hasOwnProperty;function lK(e,t,n){return t&&typeof t=="object"&&(n=t,t=void 0),cK(n)(rK(nK(n).document().write(iK()(e,t,!0))))}function cK(e){const t={transforms:[],canContainEols:["emphasis","fragment","heading","paragraph","strong"],enter:{autolink:s(Lt),autolinkProtocol:B,autolinkEmail:B,atxHeading:s(fn),blockQuote:s(Ie),characterEscape:B,characterReference:B,codeFenced:s(Re),codeFencedFenceInfo:o,codeFencedFenceMeta:o,codeIndented:s(Re,o),codeText:s(Ke,o),codeTextData:B,data:B,codeFlowValue:B,definition:s(_e),definitionDestinationString:o,definitionLabelString:o,definitionTitleString:o,emphasis:s(Be),hardBreakEscape:s(it),hardBreakTrailing:s(it),htmlFlow:s(At,o),htmlFlowData:B,htmlText:s(At,o),htmlTextData:B,image:s(Xt),label:o,link:s(Lt),listItem:s(Ze),listItemValue:f,listOrdered:s(wt,d),listUnordered:s(wt),paragraph:s(st),reference:A,referenceString:o,resourceDestinationString:o,resourceTitleString:o,setextHeading:s(fn),strong:s(St),thematicBreak:s(sn)},exit:{atxHeading:l(),atxHeadingSequence:k,autolink:l(),autolinkEmail:ue,autolinkProtocol:$e,blockQuote:l(),characterEscapeValue:P,characterReferenceMarkerHexadecimal:oe,characterReferenceMarkerNumeric:oe,characterReferenceValue:X,characterReference:ye,codeFenced:l(b),codeFencedFence:v,codeFencedFenceInfo:p,codeFencedFenceMeta:m,codeFlowValue:P,codeIndented:l(_),codeText:l(z),codeTextData:P,data:P,definition:l(),definitionDestinationString:w,definitionLabelString:x,definitionTitleString:y,emphasis:l(),hardBreakEscape:l(I),hardBreakTrailing:l(I),htmlFlow:l(R),htmlFlowData:P,htmlText:l(L),htmlTextData:P,image:l(F),label:O,labelText:D,lineEnding:j,link:l($),listItem:l(),listOrdered:l(),listUnordered:l(),paragraph:l(),referenceString:ne,resourceDestinationString:E,resourceTitleString:H,resource:V,setextHeading:l(T),setextHeadingLineSequence:N,setextHeadingText:C,strong:l(),thematicBreak:l()}};WR(t,(e||{}).mdastExtensions||[]);const n={};return r;function r(U){let J={type:"root",children:[]};const ve={stack:[J],tokenStack:[],config:t,enter:a,exit:c,buffer:o,resume:u,data:n},Ce=[];let Fe=-1;for(;++Fe<U.length;)if(U[Fe][1].type==="listOrdered"||U[Fe][1].type==="listUnordered")if(U[Fe][0]==="enter")Ce.push(Fe);else{const ht=Ce.pop();Fe=i(U,ht,Fe)}for(Fe=-1;++Fe<U.length;){const ht=t[U[Fe][0]];UR.call(ht,U[Fe][1].type)&&ht[U[Fe][1].type].call(Object.assign({sliceSerialize:U[Fe][2].sliceSerialize},ve),U[Fe][1])}if(ve.tokenStack.length>0){const ht=ve.tokenStack[ve.tokenStack.length-1];(ht[1]||qS).call(ve,void 0,ht[0])}for(J.position={start:Yi(U.length>0?U[0][1].start:{line:1,column:1,offset:0}),end:Yi(U.length>0?U[U.length-2][1].end:{line:1,column:1,offset:0})},Fe=-1;++Fe<t.transforms.length;)J=t.transforms[Fe](J)||J;return J}function i(U,J,ve){let Ce=J-1,Fe=-1,ht=!1,on,jt,se,K;for(;++Ce<=ve;){const we=U[Ce];switch(we[1].type){case"listUnordered":case"listOrdered":case"blockQuote":{we[0]==="enter"?Fe++:Fe--,K=void 0;break}case"lineEndingBlank":{we[0]==="enter"&&(on&&!K&&!Fe&&!se&&(se=Ce),K=void 0);break}case"linePrefix":case"listItemValue":case"listItemMarker":case"listItemPrefix":case"listItemPrefixWhitespace":break;default:K=void 0}if(!Fe&&we[0]==="enter"&&we[1].type==="listItemPrefix"||Fe===-1&&we[0]==="exit"&&(we[1].type==="listUnordered"||we[1].type==="listOrdered")){if(on){let ft=Ce;for(jt=void 0;ft--;){const an=U[ft];if(an[1].type==="lineEnding"||an[1].type==="lineEndingBlank"){if(an[0]==="exit")continue;jt&&(U[jt][1].type="lineEndingBlank",ht=!0),an[1].type="lineEnding",jt=ft}else if(!(an[1].type==="linePrefix"||an[1].type==="blockQuotePrefix"||an[1].type==="blockQuotePrefixWhitespace"||an[1].type==="blockQuoteMarker"||an[1].type==="listItemIndent"))break}se&&(!jt||se<jt)&&(on._spread=!0),on.end=Object.assign({},jt?U[jt][1].start:we[1].end),U.splice(jt||Ce,0,["exit",on,we[2]]),Ce++,ve++}if(we[1].type==="listItemPrefix"){const ft={type:"listItem",_spread:!1,start:Object.assign({},we[1].start),end:void 0};on=ft,U.splice(Ce,0,["enter",ft,we[2]]),Ce++,ve++,se=void 0,K=!0}}}return U[J][1]._spread=ht,ve}function s(U,J){return ve;function ve(Ce){a.call(this,U(Ce),Ce),J&&J.call(this,Ce)}}function o(){this.stack.push({type:"fragment",children:[]})}function a(U,J,ve){this.stack[this.stack.length-1].children.push(U),this.stack.push(U),this.tokenStack.push([J,ve||void 0]),U.position={start:Yi(J.start),end:void 0}}function l(U){return J;function J(ve){U&&U.call(this,ve),c.call(this,ve)}}function c(U,J){const ve=this.stack.pop(),Ce=this.tokenStack.pop();if(Ce)Ce[0].type!==U.type&&(J?J.call(this,U,Ce[0]):(Ce[1]||qS).call(this,U,Ce[0]));else throw new Error("Cannot close `"+U.type+"` ("+mc({start:U.start,end:U.end})+"): it’s not open");ve.position.end=Yi(U.end)}function u(){return Ey(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 _(){const U=this.resume(),J=this.stack[this.stack.length-1];J.value=U.replace(/(\r?\n|\r)$/g,"")}function x(U){const J=this.resume(),ve=this.stack[this.stack.length-1];ve.label=J,ve.identifier=Lr(this.sliceSerialize(U)).toLowerCase()}function y(){const U=this.resume(),J=this.stack[this.stack.length-1];J.title=U}function w(){const U=this.resume(),J=this.stack[this.stack.length-1];J.url=U}function k(U){const J=this.stack[this.stack.length-1];if(!J.depth){const ve=this.sliceSerialize(U).length;J.depth=ve}}function C(){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 B(U){const ve=this.stack[this.stack.length-1].children;let Ce=ve[ve.length-1];(!Ce||Ce.type!=="text")&&(Ce=pn(),Ce.position={start:Yi(U.start),end:void 0},ve.push(Ce)),this.stack.push(Ce)}function P(U){const J=this.stack.pop();J.value+=this.sliceSerialize(U),J.position.end=Yi(U.end)}function j(U){const J=this.stack[this.stack.length-1];if(this.data.atHardBreak){const ve=J.children[J.children.length-1];ve.position.end=Yi(U.end),this.data.atHardBreak=void 0;return}!this.data.setextHeadingSlurpLineEnding&&t.canContainEols.includes(J.type)&&(B.call(this,U),P.call(this,U))}function I(){this.data.atHardBreak=!0}function R(){const U=this.resume(),J=this.stack[this.stack.length-1];J.value=U}function L(){const U=this.resume(),J=this.stack[this.stack.length-1];J.value=U}function z(){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 D(U){const J=this.sliceSerialize(U),ve=this.stack[this.stack.length-2];ve.label=oK(J),ve.identifier=Lr(J).toLowerCase()}function O(){const U=this.stack[this.stack.length-1],J=this.resume(),ve=this.stack[this.stack.length-1];if(this.data.inReference=!0,ve.type==="link"){const Ce=U.children;ve.children=Ce}else ve.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 V(){this.data.inReference=void 0}function A(){this.data.referenceType="collapsed"}function ne(U){const J=this.resume(),ve=this.stack[this.stack.length-1];ve.label=J,ve.identifier=Lr(this.sliceSerialize(U)).toLowerCase(),this.data.referenceType="full"}function oe(U){this.data.characterReferenceType=U.type}function X(U){const J=this.sliceSerialize(U),ve=this.data.characterReferenceType;let Ce;ve?(Ce=AR(J,ve==="characterReferenceMarkerNumeric"?10:16),this.data.characterReferenceType=void 0):Ce=Ny(J);const Fe=this.stack[this.stack.length-1];Fe.value+=Ce}function ye(U){const J=this.stack.pop();J.position.end=Yi(U.end)}function $e(U){P.call(this,U);const J=this.stack[this.stack.length-1];J.url=this.sliceSerialize(U)}function ue(U){P.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 Ke(){return{type:"inlineCode",value:""}}function _e(){return{type:"definition",identifier:"",label:null,title:null,url:""}}function Be(){return{type:"emphasis",children:[]}}function fn(){return{type:"heading",depth:0,children:[]}}function it(){return{type:"break"}}function At(){return{type:"html",value:""}}function Xt(){return{type:"image",title:null,url:"",alt:null}}function Lt(){return{type:"link",title:null,url:"",children:[]}}function wt(U){return{type:"list",ordered:U.type==="listOrdered",start:null,spread:U._spread,children:[]}}function Ze(U){return{type:"listItem",spread:U._spread,checked:null,children:[]}}function st(){return{type:"paragraph",children:[]}}function St(){return{type:"strong",children:[]}}function pn(){return{type:"text",value:""}}function sn(){return{type:"thematicBreak"}}}function Yi(e){return{line:e.line,column:e.column,offset:e.offset}}function WR(e,t){let n=-1;for(;++n<t.length;){const r=t[n];Array.isArray(r)?WR(e,r):uK(e,r)}}function uK(e,t){let n;for(n in t)if(UR.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 qS(e,t){throw e?new Error("Cannot close `"+e.type+"` ("+mc({start:e.start,end:e.end})+"): a different token (`"+t.type+"`, "+mc({start:t.start,end:t.end})+") is open"):new Error("Cannot close document, a token (`"+t.type+"`, "+mc({start:t.start,end:t.end})+") is still open")}function dK(e){const t=this;t.parser=n;function n(r){return lK(r,{...t.data("settings"),...e,extensions:t.data("micromarkExtensions")||[],mdastExtensions:t.data("fromMarkdownExtensions")||[]})}}function hK(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 fK(e,t){const n={type:"element",tagName:"br",properties:{},children:[]};return e.patch(t,n),[e.applyData(t,n),{type:"text",value:`
|
|
@@ -540,15 +540,15 @@ WARNING: This link could potentially be dangerous`)){let n=window.open();if(n){t
|
|
|
540
540
|
* Fabrice Bellard's javascript vt100 for jslinux:
|
|
541
541
|
* http://bellard.org/jslinux/
|
|
542
542
|
* Copyright (c) 2011 Fabrice Bellard
|
|
543
|
-
*/var cne=2,une=1,dne=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(cne,Math.floor(u/e.css.cell.width)),rows:Math.max(une,Math.floor(c/e.css.cell.height))}}};let pg;function mg(){return{count:0,byteSum:0,firstT:null,lastT:null}}const gg=32,PC=320;function hne({sessionId:e,client:t}){const n=g.useRef(null),r=g.useRef(null),i=g.useRef(null),s=g.useRef([]),o=g.useRef(mg()),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 _=(N,T)=>getComputedStyle(document.documentElement).getPropertyValue(N).trim()||T,x=_("--bg-0","#1B1B1B"),y=_("--text-100","#ECECEC"),w=new lne({fontFamily:"ui-monospace, SF Mono, Menlo, monospace",fontSize:12,lineHeight:1.2,theme:{background:x,foreground:y},minimumContrastRatio:4.5,cursorBlink:!0,convertEol:!1,scrollback:5e3,allowProposedApi:!0,cols:120,rows:40}),k=new dne;w.loadAddon(k),Ae("xterm-mount",{sessionId:e,hostChildCount:v.childNodes.length}),pg!==e&&(Ae("xterm-trace",`===== SWITCH ${pg??"(initial)"} → ${e} =====`),pg=e),Ae("xterm-trace","effect-setup-start",{sessionId:e,t:performance.now()}),o.current=mg(),w.open(v);const C=w.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,B=null;try{Ae("xterm-trace","snapshot-rpc-start",{sessionId:e,t:performance.now()});const L=await t.request("session:pty:snapshot",{sessionId:e});if(Ae("xterm-trace","snapshot-rpc-resolved",{sessionId:e,cancelled:b,byteLen:((R=L==null?void 0:L.data)==null?void 0:R.length)??0,atSeq:L==null?void 0:L.atSeq,t:performance.now()}),b)return;if(L!=null&&L.ok&&typeof L.data=="string"&&L.data.length>0){const z=atob(L.data),$=new Uint8Array(z.length);for(let F=0;F<z.length;F++)$[F]=z.charCodeAt(F);T=$}L!=null&&L.ok&&typeof L.atSeq=="number"&&(N=L.atSeq),L!=null&&L.ok&&L.popupKind!=null&&(B=L.popupKind)}catch{}if(b)return;r.current=w,i.current=k;let P=!1,j;const I=w.onRender(()=>{if(!P){P=!0;try{k.fit(),T&&w.write(T),Ae("xterm-trace","snapshot-flush",{sessionId:e,atSeq:N,pendingFrameCount:s.current.length,frameStatsBeforeFlush:{...o.current},t:performance.now()}),o.current=mg();const L=s.current;s.current=[];let z=0;for(const $ of L){if($.seq!==void 0&&$.seq<=N){z++;continue}w.write($.bytes)}z>0&&Ae("xterm-trace","snapshot-flush-dropped",{sessionId:e,dropped:z,atSeq:N}),a.current=!0,B!=null&&(d(B),c("expanded"),requestAnimationFrame(()=>w.focus())),t.request("session:pty:resize",{sessionId:e,cols:w.cols,rows:w.rows}).catch(()=>{})}catch{}w.scrollToBottom(),j?j():setTimeout(()=>j==null?void 0:j(),0)}});j=()=>I.dispose()})(),()=>{Ae("xterm-trace","cleanup-start",{sessionId:e,pendingFrameCount:s.current.length,termReady:a.current,frameStatsThisMount:{...o.current},t:performance.now()}),b=!0,C.dispose(),w.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",_=>{const x=_;if(x.sessionId!==e||typeof x.data!="string")return;const y=o.current;y.count++,y.byteSum+=x.data.length;const w=performance.now();y.firstT===null&&(y.firstT=w),y.lastT=w;try{const k=atob(x.data),C=new Uint8Array(k.length);for(let N=0;N<k.length;N++)C[N]=k.charCodeAt(N);a.current&&r.current?r.current.write(C):s.current.push({seq:x.seq,bytes:C})}catch{}}),b=t.on("session:control",_=>{const x=_;if(x.sessionId===e)switch(x.kind){case"popup_open":(x.popupKind==="permission"||x.popupKind==="question")&&(d(x.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,_=0;const x=()=>{const w=i.current,k=r.current;if(!(!w||!k)){try{w.fit()}catch{return}try{k.refresh(0,k.rows-1)}catch{}k.cols===b&&k.rows===_||(b=k.cols,_=k.rows,t.request("session:pty:resize",{sessionId:e,cols:k.cols,rows:k.rows}).catch(()=>{}))}},y=new ResizeObserver(()=>x());return y.observe(v),()=>y.disconnect()},[e,t]);const f=()=>{c(v=>{const b=v==="collapsed"?"expanded":"collapsed";return b==="expanded"&&requestAnimationFrame(()=>{var _;return(_=r.current)==null?void 0:_.focus()}),b})},p=l==="expanded"?PC:gg,m=PC-gg;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:gg,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 PA(e,t){const n=Io(),r=e?`session/${e}`:"",i=ai(r)??Wc,s=g.useCallback(d=>{!e||!r||n.setData(r,f=>NT(f??Wc,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 Gy(e){const t=ai(e?`capabilities/${e}`:"");return e?{capabilities:t??null,loading:!t}:{capabilities:null,loading:!1}}const fne=50;function pne({api:e,sessionId:t,toolSessionId:n,pageSize:r=fne}){const[i,s]=g.useState({messages:[],total:0,loading:!1,hasMore:!1,error:null}),o=g.useRef(0),a=g.useRef(n),l=g.useRef(null),c=g.useRef(0);g.useEffect(()=>{const d=a.current;if(a.current=n,!(l.current!==t)&&!(typeof d=="string"&&d!==n))return;if(s({messages:[],total:0,loading:!1,hasMore:!1,error:null}),o.current=0,!t){l.current=null;return}l.current=t;const m=++c.current;s(v=>({...v,loading:!0,error:null})),(async()=>{try{const v=await e.historyRead({sessionId:t,limit:r});if(m!==c.current)return;o.current=v.offset,s({messages:v.messages??[],total:v.total??0,loading:!1,hasMore:v.offset>0,error:null})}catch(v){if(m!==c.current)return;s({messages:[],total:0,loading:!1,hasMore:!1,error:v.message??"history load failed"})}})()},[e,t,n,r]);const u=g.useCallback(async()=>{if(!t)return;const d=o.current;if(d<=0)return;const f=Math.max(0,d-r),p=d-f;s(m=>({...m,loading:!0,error:null}));try{const m=await e.historyRead({sessionId:t,limit:p,offset:f});o.current=m.offset,s(v=>({...v,messages:[...m.messages??[],...v.messages],loading:!1,hasMore:m.offset>0}))}catch(m){s(v=>({...v,loading:!1,error:m.message??"load more failed"}))}},[e,t,r]);return{...i,loadMore:u}}function IC(e){const t=_p(e);return t.commandName?t.commandArgs?`${t.commandName} ${t.commandArgs}`:t.commandName:e}function RC(e){return e.kind==="user-text"||e.kind==="user-meta"&&e.metaKind==="slash-command"}function mne(e,t){const n=t.find(RC);if(!n)return e;const r=IC(n.text);for(let i=e.length-1;i>=0;i--){const s=e[i];if(RC(s)&&IC(s.text)===r)return e.slice(0,i)}return e}const gne=1e6;function vne(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 IA(e){const t=$i(),n=g.useMemo(()=>new Ax(t),[t]),r=ai("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=PA(e),{events:l,pendingPermissions:c,status:u,clearPermission:d,restorePermission:f}=a,p=pne({api:n,sessionId:e,toolSessionId:s}),m=g.useMemo(()=>p.messages.filter(F=>!F.isSidechain),[p.messages]),v=g.useMemo(()=>OM(m,0,o),[m,o]),b=c[0]??null,_=g.useMemo(()=>HQ(l,(b==null?void 0:b.requestId)??null),[l,b==null?void 0:b.requestId]),x=g.useMemo(()=>mne(v,_),[v,_]),y=g.useMemo(()=>_.map((F,D)=>({...F,seq:gne+D})),[_]),w=g.useMemo(()=>[...x,...y],[x,y]),k=BM(u),C=JQ(u),N=(i==null?void 0:i.resolvedModel)??(i==null?void 0:i.model),T=g.useMemo(()=>({sessionLabel:(i==null?void 0:i.label)||(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"}:{},...N?{model:N}:{},...(()=>{const F=i==null?void 0:i.gitBranch;return F?{gitBranch:F}:{}})(),...(()=>{const F=vne(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:C,pinnedAt:(i==null?void 0:i.pinnedAt)??null}),[i,e,N,k,C]),B=g.useMemo(()=>t.isOpen?u==="error"?{kind:"error",message:"session error"}:{kind:"ready"}:{kind:"closed"},[t.isOpen,u]),P=g.useCallback(async F=>{await n.sessionSend(e,F)},[n,e]),j=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]),I=g.useCallback(async F=>{await n.sessionRewind({sessionId:e,userMessageId:F,dryRun:!1})},[n,e]),R=g.useCallback(async F=>{await n.sessionUpdate(e,{model:F})},[n,e]),L=g.useCallback(async()=>{await n.sessionNew(e)},[n,e]),z=g.useCallback(async(F,D)=>{const O=c.find(E=>E.requestId===F);O&&d(F);try{await n.permissionRespond({sessionId:e,permissionRequestId:F,allow:D==="allow"})}catch(E){throw!((E==null?void 0:E.message)??"").startsWith("PERMISSION_REQUEST_STALE")&&O&&f(O),E}},[n,e,c,d,f]),$=g.useCallback(async()=>{await p.loadMore()},[p]);return g.useMemo(()=>({lines:w,connState:B,meta:T,historyDone:!p.hasMore,historyLoading:p.loading,pendingPermissions:c,sendText:P,fork:j,rewind:I,switchModel:R,clearSession:L,respondPermission:z,loadMoreHistory:$}),[w,B,T,p.hasMore,p.loading,c,P,j,I,R,L,z,$])}var _ne=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"}),xne="VisuallyHidden",RA=g.forwardRef((e,t)=>h.jsx(Tt.span,{...e,ref:t,style:{..._ne,...e.style}}));RA.displayName=xne;var yne=RA,[kp]=Ao("Tooltip",[ap]),Cp=ap(),MA="TooltipProvider",bne=700,g_="tooltip.open",[wne,Xy]=kp(MA),AA=e=>{const{__scopeTooltip:t,delayDuration:n=bne,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(wne,{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})};AA.displayName=MA;var su="Tooltip",[Sne,Ep]=kp(su),LA=e=>{const{__scopeTooltip:t,children:n,open:r,defaultOpen:i,onOpenChange:s,disableHoverableContent:o,delayDuration:a}=e,l=Xy(su,e.__scopeTooltip),c=Cp(t),[u,d]=g.useState(null),f=Pi(),p=g.useRef(0),m=o??l.disableHoverableContent,v=a??l.delayDuration,b=g.useRef(!1),[_,x]=vu({prop:r,defaultProp:i??!1,onChange:N=>{N?(l.onOpen(),document.dispatchEvent(new CustomEvent(g_))):l.onClose(),s==null||s(N)},caller:su}),y=g.useMemo(()=>_?b.current?"delayed-open":"instant-open":"closed",[_]),w=g.useCallback(()=>{window.clearTimeout(p.current),p.current=0,b.current=!1,x(!0)},[x]),k=g.useCallback(()=>{window.clearTimeout(p.current),p.current=0,x(!1)},[x]),C=g.useCallback(()=>{window.clearTimeout(p.current),p.current=window.setTimeout(()=>{b.current=!0,x(!0),p.current=0},v)},[v,x]);return g.useEffect(()=>()=>{p.current&&(window.clearTimeout(p.current),p.current=0)},[]),h.jsx(Yx,{...c,children:h.jsx(Sne,{scope:t,contentId:f,open:_,stateAttribute:y,trigger:u,onTriggerChange:d,onTriggerEnter:g.useCallback(()=>{l.isOpenDelayedRef.current?C():w()},[l.isOpenDelayedRef,C,w]),onTriggerLeave:g.useCallback(()=>{m?k():(window.clearTimeout(p.current),p.current=0)},[k,m]),onOpen:w,onClose:k,disableHoverableContent:m,children:n})})};LA.displayName=su;var v_="TooltipTrigger",jA=g.forwardRef((e,t)=>{const{__scopeTooltip:n,...r}=e,i=Ep(v_,n),s=Xy(v_,n),o=Cp(n),a=g.useRef(null),l=Kt(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(jP,{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)})})});jA.displayName=v_;var kne="TooltipPortal",[Tse,Cne]=kp(kne,{forceMount:void 0}),Wa="TooltipContent",DA=g.forwardRef((e,t)=>{const n=Cne(Wa,e.__scopeTooltip),{forceMount:r=n.forceMount,side:i="top",...s}=e,o=Ep(Wa,e.__scopeTooltip);return h.jsx(Hi,{present:r||o.open,children:o.disableHoverableContent?h.jsx(OA,{side:i,...s,ref:t}):h.jsx(Ene,{side:i,...s,ref:t})})}),Ene=g.forwardRef((e,t)=>{const n=Ep(Wa,e.__scopeTooltip),r=Xy(Wa,e.__scopeTooltip),i=g.useRef(null),s=Kt(t,i),[o,a]=g.useState(null),{trigger:l,onClose:c}=n,u=i.current,{onPointerInTransitChange:d}=r,f=g.useCallback(()=>{a(null),d(!1)},[d]),p=g.useCallback((m,v)=>{const b=m.currentTarget,_={x:m.clientX,y:m.clientY},x=Rne(_,b.getBoundingClientRect()),y=Mne(_,x),w=Ane(v.getBoundingClientRect()),k=jne([...y,...w]);a(k),d(!0)},[d]);return g.useEffect(()=>()=>f(),[f]),g.useEffect(()=>{if(l&&u){const m=b=>p(b,u),v=b=>p(b,l);return l.addEventListener("pointerleave",m),u.addEventListener("pointerleave",v),()=>{l.removeEventListener("pointerleave",m),u.removeEventListener("pointerleave",v)}}},[l,u,p,f]),g.useEffect(()=>{if(o){const m=v=>{const b=v.target,_={x:v.clientX,y:v.clientY},x=(l==null?void 0:l.contains(b))||(u==null?void 0:u.contains(b)),y=!Lne(_,o);x?f():y&&(f(),c())};return document.addEventListener("pointermove",m),()=>document.removeEventListener("pointermove",m)}},[l,u,o,c,f]),h.jsx(OA,{...e,ref:s})}),[Nne,Tne]=kp(su,{isInside:!1}),Pne=R8("TooltipContent"),OA=g.forwardRef((e,t)=>{const{__scopeTooltip:n,children:r,"aria-label":i,onEscapeKeyDown:s,onPointerDownOutside:o,...a}=e,l=Ep(Wa,n),c=Cp(n),{onClose:u}=l;return g.useEffect(()=>(document.addEventListener(g_,u),()=>document.removeEventListener(g_,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(np,{asChild:!0,disableOutsidePointerEvents:!1,onEscapeKeyDown:s,onPointerDownOutside:o,onFocusOutside:d=>d.preventDefault(),onDismiss:u,children:h.jsxs(DP,{"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(Pne,{children:r}),h.jsx(Nne,{scope:n,isInside:!0,children:h.jsx(yne,{id:l.contentId,role:"tooltip",children:i||r})})]})})});DA.displayName=Wa;var BA="TooltipArrow",Ine=g.forwardRef((e,t)=>{const{__scopeTooltip:n,...r}=e,i=Cp(n);return Tne(BA,n).isInside?null:h.jsx(OP,{...i,...r,ref:t})});Ine.displayName=BA;function Rne(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 Mne(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 Ane(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 Lne(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 jne(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),Dne(t)}function Dne(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 One=AA,Bne=LA,zne=jA,zA=DA;const $A=One,FA=Bne,HA=zne,Yy=g.forwardRef(({className:e,sideOffset:t=4,...n},r)=>h.jsx(zA,{ref:r,sideOffset:t,className:he("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}));Yy.displayName=zA.displayName;function $ne({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($A,{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(Fne,{title:`Session files (${o.length})`,subtitle:"agent Write/Edit 自动入清单",children:o.length===0?h.jsx(Une,{text:"还没有文件。agent Write/Edit 会自动加入清单。"}):o.map(d=>h.jsx(Hne,{entry:d,onShareLink:()=>r(d.relPath),...i?{onOpenInTab:()=>i(d.relPath)}:{},...s&&!d.stale&&xp(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 Fne({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 Hne({entry:e,onShareLink:t,onOpenInTab:n,onPreview:r,onRemove:i}){var c;const s=(c=e.mime)!=null&&c.startsWith("image/")?jz:Ro,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:he("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(FA,{children:[h.jsx(HA,{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(Yy,{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:Wne(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(vg,{icon:h.jsx(Vc,{className:"h-3.5 w-3.5"}),title:"Open in tab",onClick:n}):null,h.jsx(vg,{icon:h.jsx(Dx,{className:"h-3.5 w-3.5"}),title:"Share link",onClick:t}),e.from==="owner"&&h.jsx(vg,{icon:h.jsx(Ox,{className:"h-3.5 w-3.5"}),title:"Remove",onClick:i})]})]})}function vg({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 Une({text:e}){return h.jsx("div",{className:"px-4 py-3 text-[12px] italic text-text-400",children:e})}function Wne(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 Ru={},Vne=function(){return typeof Promise=="function"&&Promise.prototype&&Promise.prototype.then},UA={},sr={};let Zy;const qne=[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];sr.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};sr.getSymbolTotalCodewords=function(t){return qne[t]};sr.getBCHDigit=function(e){let t=0;for(;e!==0;)t++,e>>>=1;return t};sr.setToSJISFunction=function(t){if(typeof t!="function")throw new Error('"toSJISFunc" is not a valid function.');Zy=t};sr.isKanjiModeEnabled=function(){return typeof Zy<"u"};sr.toSJIS=function(t){return Zy(t)};var Np={};(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}}})(Np);function WA(){this.buffer=[],this.length=0}WA.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 Kne=WA;function Mu(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)}Mu.prototype.set=function(e,t,n,r){const i=e*this.size+t;this.data[i]=n,r&&(this.reservedBit[i]=!0)};Mu.prototype.get=function(e,t){return this.data[e*this.size+t]};Mu.prototype.xor=function(e,t,n){this.data[e*this.size+t]^=n};Mu.prototype.isReserved=function(e,t){return this.reservedBit[e*this.size+t]};var Gne=Mu,VA={};(function(e){const t=sr.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}})(VA);var qA={};const Xne=sr.getSymbolSize,MC=7;qA.getPositions=function(t){const n=Xne(t);return[[0,0],[n-MC,0],[0,n-MC]]};var KA={};(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}})(KA);var Tp={};const fs=Np,Pd=[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],Id=[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];Tp.getBlocksCount=function(t,n){switch(n){case fs.L:return Pd[(t-1)*4+0];case fs.M:return Pd[(t-1)*4+1];case fs.Q:return Pd[(t-1)*4+2];case fs.H:return Pd[(t-1)*4+3];default:return}};Tp.getTotalCodewordsCount=function(t,n){switch(n){case fs.L:return Id[(t-1)*4+0];case fs.M:return Id[(t-1)*4+1];case fs.Q:return Id[(t-1)*4+2];case fs.H:return Id[(t-1)*4+3];default:return}};var GA={},Pp={};const xc=new Uint8Array(512),pf=new Uint8Array(256);(function(){let t=1;for(let n=0;n<255;n++)xc[n]=t,pf[t]=n,t<<=1,t&256&&(t^=285);for(let n=255;n<512;n++)xc[n]=xc[n-255]})();Pp.log=function(t){if(t<1)throw new Error("log("+t+")");return pf[t]};Pp.exp=function(t){return xc[t]};Pp.mul=function(t,n){return t===0||n===0?0:xc[pf[t]+pf[n]]};(function(e){const t=Pp;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}})(GA);const XA=GA;function Qy(e){this.genPoly=void 0,this.degree=e,this.degree&&this.initialize(this.degree)}Qy.prototype.initialize=function(t){this.degree=t,this.genPoly=XA.generateECPolynomial(this.degree)};Qy.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=XA.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 Yne=Qy,YA={},Os={},Jy={};Jy.isValid=function(t){return!isNaN(t)&&t>=1&&t<=40};var fi={};const ZA="[0-9]+",Zne="[A-Z $%*+\\-./:]+";let ou="(?:[u3000-u303F]|[u3040-u309F]|[u30A0-u30FF]|[uFF00-uFFEF]|[u4E00-u9FAF]|[u2605-u2606]|[u2190-u2195]|u203B|[u2010u2015u2018u2019u2025u2026u201Cu201Du2225u2260]|[u0391-u0451]|[u00A7u00A8u00B1u00B4u00D7u00F7])+";ou=ou.replace(/u/g,"\\u");const Qne="(?:(?![A-Z0-9 $%*+\\-./:]|"+ou+`)(?:.|[\r
|
|
543
|
+
*/var cne=2,une=1,dne=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(cne,Math.floor(u/e.css.cell.width)),rows:Math.max(une,Math.floor(c/e.css.cell.height))}}};let pg;function mg(){return{count:0,byteSum:0,firstT:null,lastT:null}}const gg=32,PC=320;function hne({sessionId:e,client:t}){const n=g.useRef(null),r=g.useRef(null),i=g.useRef(null),s=g.useRef([]),o=g.useRef(mg()),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 _=(N,T)=>getComputedStyle(document.documentElement).getPropertyValue(N).trim()||T,x=_("--bg-0","#1B1B1B"),y=_("--text-100","#ECECEC"),w=new lne({fontFamily:"ui-monospace, SF Mono, Menlo, monospace",fontSize:12,lineHeight:1.2,theme:{background:x,foreground:y},minimumContrastRatio:4.5,cursorBlink:!0,convertEol:!1,scrollback:5e3,allowProposedApi:!0,cols:120,rows:40}),k=new dne;w.loadAddon(k),Ae("xterm-mount",{sessionId:e,hostChildCount:v.childNodes.length}),pg!==e&&(Ae("xterm-trace",`===== SWITCH ${pg??"(initial)"} → ${e} =====`),pg=e),Ae("xterm-trace","effect-setup-start",{sessionId:e,t:performance.now()}),o.current=mg(),w.open(v);const C=w.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,B=null;try{Ae("xterm-trace","snapshot-rpc-start",{sessionId:e,t:performance.now()});const L=await t.request("session:pty:snapshot",{sessionId:e});if(Ae("xterm-trace","snapshot-rpc-resolved",{sessionId:e,cancelled:b,byteLen:((R=L==null?void 0:L.data)==null?void 0:R.length)??0,atSeq:L==null?void 0:L.atSeq,t:performance.now()}),b)return;if(L!=null&&L.ok&&typeof L.data=="string"&&L.data.length>0){const z=atob(L.data),$=new Uint8Array(z.length);for(let F=0;F<z.length;F++)$[F]=z.charCodeAt(F);T=$}L!=null&&L.ok&&typeof L.atSeq=="number"&&(N=L.atSeq),L!=null&&L.ok&&L.popupKind!=null&&(B=L.popupKind)}catch{}if(b)return;r.current=w,i.current=k;let P=!1,j;const I=w.onRender(()=>{if(!P){P=!0;try{k.fit(),T&&w.write(T),Ae("xterm-trace","snapshot-flush",{sessionId:e,atSeq:N,pendingFrameCount:s.current.length,frameStatsBeforeFlush:{...o.current},t:performance.now()}),o.current=mg();const L=s.current;s.current=[];let z=0;for(const $ of L){if($.seq!==void 0&&$.seq<=N){z++;continue}w.write($.bytes)}z>0&&Ae("xterm-trace","snapshot-flush-dropped",{sessionId:e,dropped:z,atSeq:N}),a.current=!0,B!=null&&(d(B),c("expanded"),requestAnimationFrame(()=>w.focus())),t.request("session:pty:resize",{sessionId:e,cols:w.cols,rows:w.rows}).catch(()=>{})}catch{}w.scrollToBottom(),j?j():setTimeout(()=>j==null?void 0:j(),0)}});j=()=>I.dispose()})(),()=>{Ae("xterm-trace","cleanup-start",{sessionId:e,pendingFrameCount:s.current.length,termReady:a.current,frameStatsThisMount:{...o.current},t:performance.now()}),b=!0,C.dispose(),w.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",_=>{const x=_;if(x.sessionId!==e||typeof x.data!="string")return;const y=o.current;y.count++,y.byteSum+=x.data.length;const w=performance.now();y.firstT===null&&(y.firstT=w),y.lastT=w;try{const k=atob(x.data),C=new Uint8Array(k.length);for(let N=0;N<k.length;N++)C[N]=k.charCodeAt(N);a.current&&r.current?r.current.write(C):s.current.push({seq:x.seq,bytes:C})}catch{}}),b=t.on("session:control",_=>{const x=_;if(x.sessionId===e)switch(x.kind){case"popup_open":(x.popupKind==="permission"||x.popupKind==="question")&&(d(x.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,_=0;const x=()=>{const w=i.current,k=r.current;if(!(!w||!k)){try{w.fit()}catch{return}try{k.refresh(0,k.rows-1)}catch{}k.cols===b&&k.rows===_||(b=k.cols,_=k.rows,t.request("session:pty:resize",{sessionId:e,cols:k.cols,rows:k.rows}).catch(()=>{}))}},y=new ResizeObserver(()=>x());return y.observe(v),()=>y.disconnect()},[e,t]);const f=()=>{c(v=>{const b=v==="collapsed"?"expanded":"collapsed";return b==="expanded"&&requestAnimationFrame(()=>{var _;return(_=r.current)==null?void 0:_.focus()}),b})},p=l==="expanded"?PC:gg,m=PC-gg;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:gg,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 PA(e,t){const n=Io(),r=e?`session/${e}`:"",i=ai(r)??Wc,s=g.useCallback(d=>{!e||!r||n.setData(r,f=>NT(f??Wc,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 Gy(e){const t=ai(e?`capabilities/${e}`:"");return e?{capabilities:t??null,loading:!t}:{capabilities:null,loading:!1}}const fne=50;function pne({api:e,sessionId:t,toolSessionId:n,pageSize:r=fne}){const[i,s]=g.useState({messages:[],total:0,loading:!1,hasMore:!1,error:null}),o=g.useRef(0),a=g.useRef(n),l=g.useRef(null),c=g.useRef(0);g.useEffect(()=>{const d=a.current;if(a.current=n,!(l.current!==t)&&!(typeof d=="string"&&d!==n))return;if(s({messages:[],total:0,loading:!1,hasMore:!1,error:null}),o.current=0,!t){l.current=null;return}l.current=t;const m=++c.current;s(v=>({...v,loading:!0,error:null})),(async()=>{try{const v=await e.historyRead({sessionId:t,limit:r});if(m!==c.current)return;o.current=v.offset,s({messages:v.messages??[],total:v.total??0,loading:!1,hasMore:v.offset>0,error:null})}catch(v){if(m!==c.current)return;s({messages:[],total:0,loading:!1,hasMore:!1,error:v.message??"history load failed"})}})()},[e,t,n,r]);const u=g.useCallback(async()=>{if(!t)return;const d=o.current;if(d<=0)return;const f=Math.max(0,d-r),p=d-f;s(m=>({...m,loading:!0,error:null}));try{const m=await e.historyRead({sessionId:t,limit:p,offset:f});o.current=m.offset,s(v=>({...v,messages:[...m.messages??[],...v.messages],loading:!1,hasMore:m.offset>0}))}catch(m){s(v=>({...v,loading:!1,error:m.message??"load more failed"}))}},[e,t,r]);return{...i,loadMore:u}}function IC(e){const t=_p(e);return t.commandName?t.commandArgs?`${t.commandName} ${t.commandArgs}`:t.commandName:e}function RC(e){return e.kind==="user-text"||e.kind==="user-meta"&&e.metaKind==="slash-command"}function mne(e,t){const n=t.find(RC);if(!n)return e;const r=IC(n.text);for(let s=e.length-1;s>=0;s--){const o=e[s];if(RC(o)&&IC(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 gne=1e6;function vne(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 IA(e){const t=$i(),n=g.useMemo(()=>new Ax(t),[t]),r=ai("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=PA(e),{events:l,pendingPermissions:c,status:u,clearPermission:d,restorePermission:f}=a,p=pne({api:n,sessionId:e,toolSessionId:s}),m=g.useMemo(()=>p.messages.filter(F=>!F.isSidechain),[p.messages]),v=g.useMemo(()=>OM(m,0,o),[m,o]),b=c[0]??null,_=g.useMemo(()=>HQ(l,(b==null?void 0:b.requestId)??null),[l,b==null?void 0:b.requestId]),x=g.useMemo(()=>mne(v,_),[v,_]),y=g.useMemo(()=>_.map((F,D)=>({...F,seq:gne+D})),[_]),w=g.useMemo(()=>[...x,...y],[x,y]),k=BM(u),C=JQ(u),N=(i==null?void 0:i.resolvedModel)??(i==null?void 0:i.model),T=g.useMemo(()=>({sessionLabel:(i==null?void 0:i.label)||(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"}:{},...N?{model:N}:{},...(()=>{const F=i==null?void 0:i.gitBranch;return F?{gitBranch:F}:{}})(),...(()=>{const F=vne(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:C,pinnedAt:(i==null?void 0:i.pinnedAt)??null}),[i,e,N,k,C]),B=g.useMemo(()=>t.isOpen?u==="error"?{kind:"error",message:"session error"}:{kind:"ready"}:{kind:"closed"},[t.isOpen,u]),P=g.useCallback(async F=>{await n.sessionSend(e,F)},[n,e]),j=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]),I=g.useCallback(async F=>{await n.sessionRewind({sessionId:e,userMessageId:F,dryRun:!1})},[n,e]),R=g.useCallback(async F=>{await n.sessionUpdate(e,{model:F})},[n,e]),L=g.useCallback(async()=>{await n.sessionNew(e)},[n,e]),z=g.useCallback(async(F,D)=>{const O=c.find(E=>E.requestId===F);O&&d(F);try{await n.permissionRespond({sessionId:e,permissionRequestId:F,allow:D==="allow"})}catch(E){throw!((E==null?void 0:E.message)??"").startsWith("PERMISSION_REQUEST_STALE")&&O&&f(O),E}},[n,e,c,d,f]),$=g.useCallback(async()=>{await p.loadMore()},[p]);return g.useMemo(()=>({lines:w,connState:B,meta:T,historyDone:!p.hasMore,historyLoading:p.loading,pendingPermissions:c,sendText:P,fork:j,rewind:I,switchModel:R,clearSession:L,respondPermission:z,loadMoreHistory:$}),[w,B,T,p.hasMore,p.loading,c,P,j,I,R,L,z,$])}var _ne=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"}),xne="VisuallyHidden",RA=g.forwardRef((e,t)=>h.jsx(Tt.span,{...e,ref:t,style:{..._ne,...e.style}}));RA.displayName=xne;var yne=RA,[kp]=Ao("Tooltip",[ap]),Cp=ap(),MA="TooltipProvider",bne=700,g_="tooltip.open",[wne,Xy]=kp(MA),AA=e=>{const{__scopeTooltip:t,delayDuration:n=bne,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(wne,{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})};AA.displayName=MA;var su="Tooltip",[Sne,Ep]=kp(su),LA=e=>{const{__scopeTooltip:t,children:n,open:r,defaultOpen:i,onOpenChange:s,disableHoverableContent:o,delayDuration:a}=e,l=Xy(su,e.__scopeTooltip),c=Cp(t),[u,d]=g.useState(null),f=Pi(),p=g.useRef(0),m=o??l.disableHoverableContent,v=a??l.delayDuration,b=g.useRef(!1),[_,x]=vu({prop:r,defaultProp:i??!1,onChange:N=>{N?(l.onOpen(),document.dispatchEvent(new CustomEvent(g_))):l.onClose(),s==null||s(N)},caller:su}),y=g.useMemo(()=>_?b.current?"delayed-open":"instant-open":"closed",[_]),w=g.useCallback(()=>{window.clearTimeout(p.current),p.current=0,b.current=!1,x(!0)},[x]),k=g.useCallback(()=>{window.clearTimeout(p.current),p.current=0,x(!1)},[x]),C=g.useCallback(()=>{window.clearTimeout(p.current),p.current=window.setTimeout(()=>{b.current=!0,x(!0),p.current=0},v)},[v,x]);return g.useEffect(()=>()=>{p.current&&(window.clearTimeout(p.current),p.current=0)},[]),h.jsx(Yx,{...c,children:h.jsx(Sne,{scope:t,contentId:f,open:_,stateAttribute:y,trigger:u,onTriggerChange:d,onTriggerEnter:g.useCallback(()=>{l.isOpenDelayedRef.current?C():w()},[l.isOpenDelayedRef,C,w]),onTriggerLeave:g.useCallback(()=>{m?k():(window.clearTimeout(p.current),p.current=0)},[k,m]),onOpen:w,onClose:k,disableHoverableContent:m,children:n})})};LA.displayName=su;var v_="TooltipTrigger",jA=g.forwardRef((e,t)=>{const{__scopeTooltip:n,...r}=e,i=Ep(v_,n),s=Xy(v_,n),o=Cp(n),a=g.useRef(null),l=Kt(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(jP,{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)})})});jA.displayName=v_;var kne="TooltipPortal",[Rse,Cne]=kp(kne,{forceMount:void 0}),Wa="TooltipContent",DA=g.forwardRef((e,t)=>{const n=Cne(Wa,e.__scopeTooltip),{forceMount:r=n.forceMount,side:i="top",...s}=e,o=Ep(Wa,e.__scopeTooltip);return h.jsx(Hi,{present:r||o.open,children:o.disableHoverableContent?h.jsx(OA,{side:i,...s,ref:t}):h.jsx(Ene,{side:i,...s,ref:t})})}),Ene=g.forwardRef((e,t)=>{const n=Ep(Wa,e.__scopeTooltip),r=Xy(Wa,e.__scopeTooltip),i=g.useRef(null),s=Kt(t,i),[o,a]=g.useState(null),{trigger:l,onClose:c}=n,u=i.current,{onPointerInTransitChange:d}=r,f=g.useCallback(()=>{a(null),d(!1)},[d]),p=g.useCallback((m,v)=>{const b=m.currentTarget,_={x:m.clientX,y:m.clientY},x=Rne(_,b.getBoundingClientRect()),y=Mne(_,x),w=Ane(v.getBoundingClientRect()),k=jne([...y,...w]);a(k),d(!0)},[d]);return g.useEffect(()=>()=>f(),[f]),g.useEffect(()=>{if(l&&u){const m=b=>p(b,u),v=b=>p(b,l);return l.addEventListener("pointerleave",m),u.addEventListener("pointerleave",v),()=>{l.removeEventListener("pointerleave",m),u.removeEventListener("pointerleave",v)}}},[l,u,p,f]),g.useEffect(()=>{if(o){const m=v=>{const b=v.target,_={x:v.clientX,y:v.clientY},x=(l==null?void 0:l.contains(b))||(u==null?void 0:u.contains(b)),y=!Lne(_,o);x?f():y&&(f(),c())};return document.addEventListener("pointermove",m),()=>document.removeEventListener("pointermove",m)}},[l,u,o,c,f]),h.jsx(OA,{...e,ref:s})}),[Nne,Tne]=kp(su,{isInside:!1}),Pne=R8("TooltipContent"),OA=g.forwardRef((e,t)=>{const{__scopeTooltip:n,children:r,"aria-label":i,onEscapeKeyDown:s,onPointerDownOutside:o,...a}=e,l=Ep(Wa,n),c=Cp(n),{onClose:u}=l;return g.useEffect(()=>(document.addEventListener(g_,u),()=>document.removeEventListener(g_,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(np,{asChild:!0,disableOutsidePointerEvents:!1,onEscapeKeyDown:s,onPointerDownOutside:o,onFocusOutside:d=>d.preventDefault(),onDismiss:u,children:h.jsxs(DP,{"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(Pne,{children:r}),h.jsx(Nne,{scope:n,isInside:!0,children:h.jsx(yne,{id:l.contentId,role:"tooltip",children:i||r})})]})})});DA.displayName=Wa;var BA="TooltipArrow",Ine=g.forwardRef((e,t)=>{const{__scopeTooltip:n,...r}=e,i=Cp(n);return Tne(BA,n).isInside?null:h.jsx(OP,{...i,...r,ref:t})});Ine.displayName=BA;function Rne(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 Mne(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 Ane(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 Lne(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 jne(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),Dne(t)}function Dne(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 One=AA,Bne=LA,zne=jA,zA=DA;const $A=One,FA=Bne,HA=zne,Yy=g.forwardRef(({className:e,sideOffset:t=4,...n},r)=>h.jsx(zA,{ref:r,sideOffset:t,className:he("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}));Yy.displayName=zA.displayName;function $ne({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($A,{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(Fne,{title:`Session files (${o.length})`,subtitle:"agent Write/Edit 自动入清单",children:o.length===0?h.jsx(Une,{text:"还没有文件。agent Write/Edit 会自动加入清单。"}):o.map(d=>h.jsx(Hne,{entry:d,onShareLink:()=>r(d.relPath),...i?{onOpenInTab:()=>i(d.relPath)}:{},...s&&!d.stale&&xp(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 Fne({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 Hne({entry:e,onShareLink:t,onOpenInTab:n,onPreview:r,onRemove:i}){var c;const s=(c=e.mime)!=null&&c.startsWith("image/")?jz:Ro,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:he("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(FA,{children:[h.jsx(HA,{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(Yy,{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:Wne(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(vg,{icon:h.jsx(Vc,{className:"h-3.5 w-3.5"}),title:"Open in tab",onClick:n}):null,h.jsx(vg,{icon:h.jsx(Dx,{className:"h-3.5 w-3.5"}),title:"Share link",onClick:t}),e.from==="owner"&&h.jsx(vg,{icon:h.jsx(Ox,{className:"h-3.5 w-3.5"}),title:"Remove",onClick:i})]})]})}function vg({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 Une({text:e}){return h.jsx("div",{className:"px-4 py-3 text-[12px] italic text-text-400",children:e})}function Wne(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 Ru={},Vne=function(){return typeof Promise=="function"&&Promise.prototype&&Promise.prototype.then},UA={},sr={};let Zy;const qne=[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];sr.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};sr.getSymbolTotalCodewords=function(t){return qne[t]};sr.getBCHDigit=function(e){let t=0;for(;e!==0;)t++,e>>>=1;return t};sr.setToSJISFunction=function(t){if(typeof t!="function")throw new Error('"toSJISFunc" is not a valid function.');Zy=t};sr.isKanjiModeEnabled=function(){return typeof Zy<"u"};sr.toSJIS=function(t){return Zy(t)};var Np={};(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}}})(Np);function WA(){this.buffer=[],this.length=0}WA.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 Kne=WA;function Mu(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)}Mu.prototype.set=function(e,t,n,r){const i=e*this.size+t;this.data[i]=n,r&&(this.reservedBit[i]=!0)};Mu.prototype.get=function(e,t){return this.data[e*this.size+t]};Mu.prototype.xor=function(e,t,n){this.data[e*this.size+t]^=n};Mu.prototype.isReserved=function(e,t){return this.reservedBit[e*this.size+t]};var Gne=Mu,VA={};(function(e){const t=sr.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}})(VA);var qA={};const Xne=sr.getSymbolSize,MC=7;qA.getPositions=function(t){const n=Xne(t);return[[0,0],[n-MC,0],[0,n-MC]]};var KA={};(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}})(KA);var Tp={};const fs=Np,Pd=[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],Id=[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];Tp.getBlocksCount=function(t,n){switch(n){case fs.L:return Pd[(t-1)*4+0];case fs.M:return Pd[(t-1)*4+1];case fs.Q:return Pd[(t-1)*4+2];case fs.H:return Pd[(t-1)*4+3];default:return}};Tp.getTotalCodewordsCount=function(t,n){switch(n){case fs.L:return Id[(t-1)*4+0];case fs.M:return Id[(t-1)*4+1];case fs.Q:return Id[(t-1)*4+2];case fs.H:return Id[(t-1)*4+3];default:return}};var GA={},Pp={};const xc=new Uint8Array(512),pf=new Uint8Array(256);(function(){let t=1;for(let n=0;n<255;n++)xc[n]=t,pf[t]=n,t<<=1,t&256&&(t^=285);for(let n=255;n<512;n++)xc[n]=xc[n-255]})();Pp.log=function(t){if(t<1)throw new Error("log("+t+")");return pf[t]};Pp.exp=function(t){return xc[t]};Pp.mul=function(t,n){return t===0||n===0?0:xc[pf[t]+pf[n]]};(function(e){const t=Pp;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}})(GA);const XA=GA;function Qy(e){this.genPoly=void 0,this.degree=e,this.degree&&this.initialize(this.degree)}Qy.prototype.initialize=function(t){this.degree=t,this.genPoly=XA.generateECPolynomial(this.degree)};Qy.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=XA.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 Yne=Qy,YA={},Os={},Jy={};Jy.isValid=function(t){return!isNaN(t)&&t>=1&&t<=40};var fi={};const ZA="[0-9]+",Zne="[A-Z $%*+\\-./:]+";let ou="(?:[u3000-u303F]|[u3040-u309F]|[u30A0-u30FF]|[uFF00-uFFEF]|[u4E00-u9FAF]|[u2605-u2606]|[u2190-u2195]|u203B|[u2010u2015u2018u2019u2025u2026u201Cu201Du2225u2260]|[u0391-u0451]|[u00A7u00A8u00B1u00B4u00D7u00F7])+";ou=ou.replace(/u/g,"\\u");const Qne="(?:(?![A-Z0-9 $%*+\\-./:]|"+ou+`)(?:.|[\r
|
|
544
544
|
]))+`;fi.KANJI=new RegExp(ou,"g");fi.BYTE_KANJI=new RegExp("[^A-Z0-9 $%*+\\-./:]+","g");fi.BYTE=new RegExp(Qne,"g");fi.NUMERIC=new RegExp(ZA,"g");fi.ALPHANUMERIC=new RegExp(Zne,"g");const Jne=new RegExp("^"+ou+"$"),ere=new RegExp("^"+ZA+"$"),tre=new RegExp("^[A-Z0-9 $%*+\\-./:]+$");fi.testKanji=function(t){return Jne.test(t)};fi.testNumeric=function(t){return ere.test(t)};fi.testAlphanumeric=function(t){return tre.test(t)};(function(e){const t=Jy,n=fi;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}}})(Os);(function(e){const t=sr,n=Tp,r=Np,i=Os,s=Jy,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),_=n.getTotalCodewordsCount(p,m),x=(b-_)*8;if(v===i.MIXED)return x;const y=x-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}})(YA);var QA={};const __=sr,JA=1335,nre=21522,AC=__.getBCHDigit(JA);QA.getEncodedBits=function(t,n){const r=t.bit<<3|n;let i=r<<10;for(;__.getBCHDigit(i)-AC>=0;)i^=JA<<__.getBCHDigit(i)-AC;return(r<<10|i)^nre};var e5={};const rre=Os;function Va(e){this.mode=rre.NUMERIC,this.data=e.toString()}Va.getBitsLength=function(t){return 10*Math.floor(t/3)+(t%3?t%3*3+1:0)};Va.prototype.getLength=function(){return this.data.length};Va.prototype.getBitsLength=function(){return Va.getBitsLength(this.data.length)};Va.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 ire=Va;const sre=Os,_g=["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 qa(e){this.mode=sre.ALPHANUMERIC,this.data=e}qa.getBitsLength=function(t){return 11*Math.floor(t/2)+6*(t%2)};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;for(n=0;n+2<=this.data.length;n+=2){let r=_g.indexOf(this.data[n])*45;r+=_g.indexOf(this.data[n+1]),t.put(r,11)}this.data.length%2&&t.put(_g.indexOf(this.data[n]),6)};var ore=qa;const are=Os;function Ka(e){this.mode=are.BYTE,typeof e=="string"?this.data=new TextEncoder().encode(e):this.data=new Uint8Array(e)}Ka.getBitsLength=function(t){return t*8};Ka.prototype.getLength=function(){return this.data.length};Ka.prototype.getBitsLength=function(){return Ka.getBitsLength(this.data.length)};Ka.prototype.write=function(e){for(let t=0,n=this.data.length;t<n;t++)e.put(this.data[t],8)};var lre=Ka;const cre=Os,ure=sr;function Ga(e){this.mode=cre.KANJI,this.data=e}Ga.getBitsLength=function(t){return t*13};Ga.prototype.getLength=function(){return this.data.length};Ga.prototype.getBitsLength=function(){return Ga.getBitsLength(this.data.length)};Ga.prototype.write=function(e){let t;for(t=0;t<this.data.length;t++){let n=ure.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]+`
|
|
545
545
|
Make sure your charset is UTF-8`);n=(n>>>8&255)*192+(n&255),e.put(n,13)}};var dre=Ga,t5={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 _=["Could not find a path from ",r," to ",i,"."].join("");throw new Error(_)}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})(t5);var hre=t5.exports;(function(e){const t=Os,n=ire,r=ore,i=lre,s=dre,o=fi,a=sr,l=hre;function c(_){return unescape(encodeURIComponent(_)).length}function u(_,x,y){const w=[];let k;for(;(k=_.exec(y))!==null;)w.push({data:k[0],index:k.index,mode:x,length:k[0].length});return w}function d(_){const x=u(o.NUMERIC,t.NUMERIC,_),y=u(o.ALPHANUMERIC,t.ALPHANUMERIC,_);let w,k;return a.isKanjiModeEnabled()?(w=u(o.BYTE,t.BYTE,_),k=u(o.KANJI,t.KANJI,_)):(w=u(o.BYTE_KANJI,t.BYTE,_),k=[]),x.concat(y,w,k).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(x){case t.NUMERIC:return n.getBitsLength(_);case t.ALPHANUMERIC:return r.getBitsLength(_);case t.KANJI:return s.getBitsLength(_);case t.BYTE:return i.getBitsLength(_)}}function p(_){return _.reduce(function(x,y){const w=x.length-1>=0?x[x.length-1]:null;return w&&w.mode===y.mode?(x[x.length-1].data+=y.data,x):(x.push(y),x)},[])}function m(_){const x=[];for(let y=0;y<_.length;y++){const w=_[y];switch(w.mode){case t.NUMERIC:x.push([w,{data:w.data,mode:t.ALPHANUMERIC,length:w.length},{data:w.data,mode:t.BYTE,length:w.length}]);break;case t.ALPHANUMERIC:x.push([w,{data:w.data,mode:t.BYTE,length:w.length}]);break;case t.KANJI:x.push([w,{data:w.data,mode:t.BYTE,length:c(w.data)}]);break;case t.BYTE:x.push([{data:w.data,mode:t.BYTE,length:c(w.data)}])}}return x}function v(_,x){const y={},w={start:{}};let k=["start"];for(let C=0;C<_.length;C++){const N=_[C],T=[];for(let B=0;B<N.length;B++){const P=N[B],j=""+C+B;T.push(j),y[j]={node:P,lastCount:0},w[j]={};for(let I=0;I<k.length;I++){const R=k[I];y[R]&&y[R].node.mode===P.mode?(w[R][j]=f(y[R].lastCount+P.length,P.mode)-f(y[R].lastCount,P.mode),y[R].lastCount+=P.length):(y[R]&&(y[R].lastCount=P.length),w[R][j]=f(P.length,P.mode)+4+t.getCharCountIndicator(P.mode,x))}}k=T}for(let C=0;C<k.length;C++)w[k[C]].end=0;return{map:w,table:y}}function b(_,x){let y;const w=t.getBestModeForData(_);if(y=t.from(x,w),y!==t.BYTE&&y.bit<w.bit)throw new Error('"'+_+'" cannot be encoded with mode '+t.toString(y)+`.
|
|
546
546
|
Suggested mode is: `+t.toString(w));switch(y===t.KANJI&&!a.isKanjiModeEnabled()&&(y=t.BYTE),y){case t.NUMERIC:return new n(_);case t.ALPHANUMERIC:return new r(_);case t.KANJI:return new s(_);case t.BYTE:return new i(_)}}e.fromArray=function(x){return x.reduce(function(y,w){return typeof w=="string"?y.push(b(w,null)):w.data&&y.push(b(w.data,w.mode)),y},[])},e.fromString=function(x,y){const w=d(x,a.isKanjiModeEnabled()),k=m(w),C=v(k,y),N=l.find_path(C.map,"start","end"),T=[];for(let B=1;B<N.length-1;B++)T.push(C.table[N[B]].node);return e.fromArray(p(T))},e.rawSplit=function(x){return e.fromArray(d(x,a.isKanjiModeEnabled()))}})(e5);const Ip=sr,xg=Np,fre=Kne,pre=Gne,mre=VA,gre=qA,x_=KA,y_=Tp,vre=Yne,mf=YA,_re=QA,xre=Os,yg=e5;function yre(e,t){const n=e.size,r=gre.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 bre(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 wre(e,t){const n=mre.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 Sre(e,t){const n=e.size,r=mf.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 bg(e,t,n){const r=e.size,i=_re.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 kre(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 Cre(e,t,n){const r=new fre;n.forEach(function(l){r.put(l.mode.bit,4),r.put(l.getLength(),xre.getCharCountIndicator(l.mode,e)),l.write(r)});const i=Ip.getSymbolTotalCodewords(e),s=y_.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 Ere(r,e,t)}function Ere(e,t,n){const r=Ip.getSymbolTotalCodewords(t),i=y_.getTotalCodewordsCount(t,n),s=r-i,o=y_.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 vre(f);let m=0;const v=new Array(o),b=new Array(o);let _=0;const x=new Uint8Array(e.buffer);for(let N=0;N<o;N++){const T=N<l?u:d;v[N]=x.slice(m,m+T),b[N]=p.encode(v[N]),m+=T,_=Math.max(_,T)}const y=new Uint8Array(r);let w=0,k,C;for(k=0;k<_;k++)for(C=0;C<o;C++)k<v[C].length&&(y[w++]=v[C][k]);for(k=0;k<f;k++)for(C=0;C<o;C++)y[w++]=b[C][k];return y}function Nre(e,t,n,r){let i;if(Array.isArray(e))i=yg.fromArray(e);else if(typeof e=="string"){let c=t;if(!c){const u=yg.rawSplit(e);c=mf.getBestVersionForData(u,n)}i=yg.fromString(e,c||40)}else throw new Error("Invalid data");const s=mf.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(`
|
|
547
547
|
The chosen QR Code version cannot contain this amount of data.
|
|
548
548
|
Minimum version required to store current data is: `+s+`.
|
|
549
549
|
`);const o=Cre(t,n,i),a=Ip.getSymbolSize(t),l=new pre(a);return yre(l,t),bre(l),wre(l,t),bg(l,n,0),t>=7&&Sre(l,t),kre(l,o),isNaN(r)&&(r=x_.getBestMask(l,bg.bind(null,l,n))),x_.applyMask(r,l),bg(l,n,r),{modules:l,version:t,errorCorrectionLevel:n,maskPattern:r,segments:i}}UA.create=function(t,n){if(typeof t>"u"||t==="")throw new Error("No input text");let r=xg.M,i,s;return typeof n<"u"&&(r=xg.from(n.errorCorrectionLevel,xg.M),i=mf.from(n.version),s=x_.from(n.maskPattern),n.toSJISFunc&&Ip.setToSJISFunction(n.toSJISFunc)),Nre(t,i,r,s)};var n5={},e1={};(function(e){function t(n){if(typeof n=="number"&&(n=n.toString()),typeof n!="string")throw new Error("Color should be defined as hex string");let r=n.slice().replace("#","").split("");if(r.length<3||r.length===5||r.length>8)throw new Error("Invalid hex color: "+n);(r.length===3||r.length===4)&&(r=Array.prototype.concat.apply([],r.map(function(s){return[s,s]}))),r.length===6&&r.push("F","F");const i=parseInt(r.join(""),16);return{r:i>>24&255,g:i>>16&255,b:i>>8&255,a:i&255,hex:"#"+r.slice(0,6).join("")}}e.getOptions=function(r){r||(r={}),r.color||(r.color={});const i=typeof r.margin>"u"||r.margin===null||r.margin<0?4:r.margin,s=r.width&&r.width>=21?r.width:void 0,o=r.scale||4;return{width:s,scale:s?4:o,margin:i,color:{dark:t(r.color.dark||"#000000ff"),light:t(r.color.light||"#ffffffff")},type:r.type,rendererOpts:r.rendererOpts||{}}},e.getScale=function(r,i){return i.width&&i.width>=r+i.margin*2?i.width/(r+i.margin*2):i.scale},e.getImageWidth=function(r,i){const s=e.getScale(r,i);return Math.floor((r+i.margin*2)*s)},e.qrToImageData=function(r,i,s){const o=i.modules.size,a=i.modules.data,l=e.getScale(o,s),c=Math.floor((o+s.margin*2)*l),u=s.margin*l,d=[s.color.light,s.color.dark];for(let f=0;f<c;f++)for(let p=0;p<c;p++){let m=(f*c+p)*4,v=s.color.light;if(f>=u&&p>=u&&f<c-u&&p<c-u){const b=Math.floor((f-u)/l),_=Math.floor((p-u)/l);v=d[a[b*o+_]?1:0]}r[m++]=v.r,r[m++]=v.g,r[m++]=v.b,r[m]=v.a}}})(e1);(function(e){const t=e1;function n(i,s,o){i.clearRect(0,0,s.width,s.height),s.style||(s.style={}),s.height=o,s.width=o,s.style.height=o+"px",s.style.width=o+"px"}function r(){try{return document.createElement("canvas")}catch{throw new Error("You need to specify a canvas element")}}e.render=function(s,o,a){let l=a,c=o;typeof l>"u"&&(!o||!o.getContext)&&(l=o,o=void 0),o||(c=r()),l=t.getOptions(l);const u=t.getImageWidth(s.modules.size,l),d=c.getContext("2d"),f=d.createImageData(u,u);return t.qrToImageData(f.data,s,l),n(d,c,u),d.putImageData(f,0,0),c},e.renderToDataURL=function(s,o,a){let l=a;typeof l>"u"&&(!o||!o.getContext)&&(l=o,o=void 0),l||(l={});const c=e.render(s,o,l),u=l.type||"image/png",d=l.rendererOpts||{};return c.toDataURL(u,d.quality)}})(n5);var r5={};const Tre=e1;function LC(e,t){const n=e.a/255,r=t+'="'+e.hex+'"';return n<1?r+" "+t+'-opacity="'+n.toFixed(2).slice(1)+'"':r}function wg(e,t,n){let r=e+t;return typeof n<"u"&&(r+=" "+n),r}function Pre(e,t,n){let r="",i=0,s=!1,o=0;for(let a=0;a<e.length;a++){const l=Math.floor(a%t),c=Math.floor(a/t);!l&&!s&&(s=!0),e[a]?(o++,a>0&&l>0&&e[a-1]||(r+=s?wg("M",l+n,.5+c+n):wg("m",i,0),i=0,s=!1),l+1<t&&e[a+1]||(r+=wg("h",o),o=0)):i++}return r}r5.render=function(t,n,r){const i=Tre.getOptions(n),s=t.modules.size,o=t.modules.data,a=s+i.margin*2,l=i.color.light.a?"<path "+LC(i.color.light,"fill")+' d="M0 0h'+a+"v"+a+'H0z"/>':"",c="<path "+LC(i.color.dark,"stroke")+' d="'+Pre(o,s,i.margin)+'"/>',u='viewBox="0 0 '+a+" "+a+'"',f='<svg xmlns="http://www.w3.org/2000/svg" '+(i.width?'width="'+i.width+'" height="'+i.width+'" ':"")+u+' shape-rendering="crispEdges">'+l+c+`</svg>
|
|
550
|
-
`;return typeof r=="function"&&r(null,f),f};const Ire=Vne,b_=UA,i5=n5,Rre=r5;function t1(e,t,n,r,i){const s=[].slice.call(arguments,1),o=s.length,a=typeof s[o-1]=="function";if(!a&&!Ire())throw new Error("Callback required as last argument");if(a){if(o<2)throw new Error("Too few arguments provided");o===2?(i=n,n=t,t=r=void 0):o===3&&(t.getContext&&typeof i>"u"?(i=r,r=void 0):(i=r,r=n,n=t,t=void 0))}else{if(o<1)throw new Error("Too few arguments provided");return o===1?(n=t,t=r=void 0):o===2&&!t.getContext&&(r=n,n=t,t=void 0),new Promise(function(l,c){try{const u=b_.create(n,r);l(e(u,t,r))}catch(u){c(u)}})}try{const l=b_.create(n,r);i(null,e(l,t,r))}catch(l){i(l)}}Ru.create=b_.create;Ru.toCanvas=t1.bind(null,i5.render);Ru.toDataURL=t1.bind(null,i5.renderToDataURL);Ru.toString=t1.bind(null,function(e,t,n){return Rre.render(e,n)});var Rp="Dialog",[s5]=Ao(Rp),[Mre,zr]=s5(Rp),o5=e=>{const{__scopeDialog:t,children:n,open:r,defaultOpen:i,onOpenChange:s,modal:o=!0}=e,a=g.useRef(null),l=g.useRef(null),[c,u]=vu({prop:r,defaultProp:i??!1,onChange:s,caller:Rp});return h.jsx(Mre,{scope:t,triggerRef:a,contentRef:l,contentId:Pi(),titleId:Pi(),descriptionId:Pi(),open:c,onOpenChange:u,onOpenToggle:g.useCallback(()=>u(d=>!d),[u]),modal:o,children:n})};o5.displayName=Rp;var a5="DialogTrigger",Are=g.forwardRef((e,t)=>{const{__scopeDialog:n,...r}=e,i=zr(a5,n),s=Kt(t,i.triggerRef);return h.jsx(Tt.button,{type:"button","aria-haspopup":"dialog","aria-expanded":i.open,"aria-controls":i.contentId,"data-state":i1(i.open),...r,ref:s,onClick:Pe(e.onClick,i.onOpenToggle)})});Are.displayName=a5;var n1="DialogPortal",[Lre,l5]=s5(n1,{forceMount:void 0}),c5=e=>{const{__scopeDialog:t,forceMount:n,children:r,container:i}=e,s=zr(n1,t);return h.jsx(Lre,{scope:t,forceMount:n,children:g.Children.map(r,o=>h.jsx(Hi,{present:n||s.open,children:h.jsx(Zx,{asChild:!0,container:i,children:o})}))})};c5.displayName=n1;var gf="DialogOverlay",u5=g.forwardRef((e,t)=>{const n=l5(gf,e.__scopeDialog),{forceMount:r=n.forceMount,...i}=e,s=zr(gf,e.__scopeDialog);return s.modal?h.jsx(Hi,{present:r||s.open,children:h.jsx(Dre,{...i,ref:t})}):null});u5.displayName=gf;var jre=Kc("DialogOverlay.RemoveScroll"),Dre=g.forwardRef((e,t)=>{const{__scopeDialog:n,...r}=e,i=zr(gf,n);return h.jsx(Qx,{as:jre,allowPinchZoom:!0,shards:[i.contentRef],children:h.jsx(Tt.div,{"data-state":i1(i.open),...r,ref:t,style:{pointerEvents:"auto",...r.style}})})}),Eo="DialogContent",d5=g.forwardRef((e,t)=>{const n=l5(Eo,e.__scopeDialog),{forceMount:r=n.forceMount,...i}=e,s=zr(Eo,e.__scopeDialog);return h.jsx(Hi,{present:r||s.open,children:s.modal?h.jsx(Ore,{...i,ref:t}):h.jsx(Bre,{...i,ref:t})})});d5.displayName=Eo;var Ore=g.forwardRef((e,t)=>{const n=zr(Eo,e.__scopeDialog),r=g.useRef(null),i=Kt(t,n.contentRef,r);return g.useEffect(()=>{const s=r.current;if(s)return VP(s)},[]),h.jsx(h5,{...e,ref:i,trapFocus:n.open,disableOutsidePointerEvents:!0,onCloseAutoFocus:Pe(e.onCloseAutoFocus,s=>{var o;s.preventDefault(),(o=n.triggerRef.current)==null||o.focus()}),onPointerDownOutside:Pe(e.onPointerDownOutside,s=>{const o=s.detail.originalEvent,a=o.button===0&&o.ctrlKey===!0;(o.button===2||a)&&s.preventDefault()}),onFocusOutside:Pe(e.onFocusOutside,s=>s.preventDefault())})}),Bre=g.forwardRef((e,t)=>{const n=zr(Eo,e.__scopeDialog),r=g.useRef(!1),i=g.useRef(!1);return h.jsx(h5,{...e,ref:t,trapFocus:!1,disableOutsidePointerEvents:!1,onCloseAutoFocus:s=>{var o,a;(o=e.onCloseAutoFocus)==null||o.call(e,s),s.defaultPrevented||(r.current||(a=n.triggerRef.current)==null||a.focus(),s.preventDefault()),r.current=!1,i.current=!1},onInteractOutside:s=>{var l,c;(l=e.onInteractOutside)==null||l.call(e,s),s.defaultPrevented||(r.current=!0,s.detail.originalEvent.type==="pointerdown"&&(i.current=!0));const o=s.target;((c=n.triggerRef.current)==null?void 0:c.contains(o))&&s.preventDefault(),s.detail.originalEvent.type==="focusin"&&i.current&&s.preventDefault()}})}),h5=g.forwardRef((e,t)=>{const{__scopeDialog:n,trapFocus:r,onOpenAutoFocus:i,onCloseAutoFocus:s,...o}=e,a=zr(Eo,n),l=g.useRef(null),c=Kt(t,l);return hP(),h.jsxs(h.Fragment,{children:[h.jsx(Fx,{asChild:!0,loop:!0,trapped:r,onMountAutoFocus:i,onUnmountAutoFocus:s,children:h.jsx(np,{role:"dialog",id:a.contentId,"aria-describedby":a.descriptionId,"aria-labelledby":a.titleId,"data-state":i1(a.open),...o,ref:c,onDismiss:()=>a.onOpenChange(!1)})}),h.jsxs(h.Fragment,{children:[h.jsx(zre,{titleId:a.titleId}),h.jsx(Fre,{contentRef:l,descriptionId:a.descriptionId})]})]})}),r1="DialogTitle",f5=g.forwardRef((e,t)=>{const{__scopeDialog:n,...r}=e,i=zr(r1,n);return h.jsx(Tt.h2,{id:i.titleId,...r,ref:t})});f5.displayName=r1;var p5="DialogDescription",m5=g.forwardRef((e,t)=>{const{__scopeDialog:n,...r}=e,i=zr(p5,n);return h.jsx(Tt.p,{id:i.descriptionId,...r,ref:t})});m5.displayName=p5;var g5="DialogClose",v5=g.forwardRef((e,t)=>{const{__scopeDialog:n,...r}=e,i=zr(g5,n);return h.jsx(Tt.button,{type:"button",...r,ref:t,onClick:Pe(e.onClick,()=>i.onOpenChange(!1))})});v5.displayName=g5;function i1(e){return e?"open":"closed"}var _5="DialogTitleWarning",[
|
|
550
|
+
`;return typeof r=="function"&&r(null,f),f};const Ire=Vne,b_=UA,i5=n5,Rre=r5;function t1(e,t,n,r,i){const s=[].slice.call(arguments,1),o=s.length,a=typeof s[o-1]=="function";if(!a&&!Ire())throw new Error("Callback required as last argument");if(a){if(o<2)throw new Error("Too few arguments provided");o===2?(i=n,n=t,t=r=void 0):o===3&&(t.getContext&&typeof i>"u"?(i=r,r=void 0):(i=r,r=n,n=t,t=void 0))}else{if(o<1)throw new Error("Too few arguments provided");return o===1?(n=t,t=r=void 0):o===2&&!t.getContext&&(r=n,n=t,t=void 0),new Promise(function(l,c){try{const u=b_.create(n,r);l(e(u,t,r))}catch(u){c(u)}})}try{const l=b_.create(n,r);i(null,e(l,t,r))}catch(l){i(l)}}Ru.create=b_.create;Ru.toCanvas=t1.bind(null,i5.render);Ru.toDataURL=t1.bind(null,i5.renderToDataURL);Ru.toString=t1.bind(null,function(e,t,n){return Rre.render(e,n)});var Rp="Dialog",[s5]=Ao(Rp),[Mre,zr]=s5(Rp),o5=e=>{const{__scopeDialog:t,children:n,open:r,defaultOpen:i,onOpenChange:s,modal:o=!0}=e,a=g.useRef(null),l=g.useRef(null),[c,u]=vu({prop:r,defaultProp:i??!1,onChange:s,caller:Rp});return h.jsx(Mre,{scope:t,triggerRef:a,contentRef:l,contentId:Pi(),titleId:Pi(),descriptionId:Pi(),open:c,onOpenChange:u,onOpenToggle:g.useCallback(()=>u(d=>!d),[u]),modal:o,children:n})};o5.displayName=Rp;var a5="DialogTrigger",Are=g.forwardRef((e,t)=>{const{__scopeDialog:n,...r}=e,i=zr(a5,n),s=Kt(t,i.triggerRef);return h.jsx(Tt.button,{type:"button","aria-haspopup":"dialog","aria-expanded":i.open,"aria-controls":i.contentId,"data-state":i1(i.open),...r,ref:s,onClick:Pe(e.onClick,i.onOpenToggle)})});Are.displayName=a5;var n1="DialogPortal",[Lre,l5]=s5(n1,{forceMount:void 0}),c5=e=>{const{__scopeDialog:t,forceMount:n,children:r,container:i}=e,s=zr(n1,t);return h.jsx(Lre,{scope:t,forceMount:n,children:g.Children.map(r,o=>h.jsx(Hi,{present:n||s.open,children:h.jsx(Zx,{asChild:!0,container:i,children:o})}))})};c5.displayName=n1;var gf="DialogOverlay",u5=g.forwardRef((e,t)=>{const n=l5(gf,e.__scopeDialog),{forceMount:r=n.forceMount,...i}=e,s=zr(gf,e.__scopeDialog);return s.modal?h.jsx(Hi,{present:r||s.open,children:h.jsx(Dre,{...i,ref:t})}):null});u5.displayName=gf;var jre=Kc("DialogOverlay.RemoveScroll"),Dre=g.forwardRef((e,t)=>{const{__scopeDialog:n,...r}=e,i=zr(gf,n);return h.jsx(Qx,{as:jre,allowPinchZoom:!0,shards:[i.contentRef],children:h.jsx(Tt.div,{"data-state":i1(i.open),...r,ref:t,style:{pointerEvents:"auto",...r.style}})})}),Eo="DialogContent",d5=g.forwardRef((e,t)=>{const n=l5(Eo,e.__scopeDialog),{forceMount:r=n.forceMount,...i}=e,s=zr(Eo,e.__scopeDialog);return h.jsx(Hi,{present:r||s.open,children:s.modal?h.jsx(Ore,{...i,ref:t}):h.jsx(Bre,{...i,ref:t})})});d5.displayName=Eo;var Ore=g.forwardRef((e,t)=>{const n=zr(Eo,e.__scopeDialog),r=g.useRef(null),i=Kt(t,n.contentRef,r);return g.useEffect(()=>{const s=r.current;if(s)return VP(s)},[]),h.jsx(h5,{...e,ref:i,trapFocus:n.open,disableOutsidePointerEvents:!0,onCloseAutoFocus:Pe(e.onCloseAutoFocus,s=>{var o;s.preventDefault(),(o=n.triggerRef.current)==null||o.focus()}),onPointerDownOutside:Pe(e.onPointerDownOutside,s=>{const o=s.detail.originalEvent,a=o.button===0&&o.ctrlKey===!0;(o.button===2||a)&&s.preventDefault()}),onFocusOutside:Pe(e.onFocusOutside,s=>s.preventDefault())})}),Bre=g.forwardRef((e,t)=>{const n=zr(Eo,e.__scopeDialog),r=g.useRef(!1),i=g.useRef(!1);return h.jsx(h5,{...e,ref:t,trapFocus:!1,disableOutsidePointerEvents:!1,onCloseAutoFocus:s=>{var o,a;(o=e.onCloseAutoFocus)==null||o.call(e,s),s.defaultPrevented||(r.current||(a=n.triggerRef.current)==null||a.focus(),s.preventDefault()),r.current=!1,i.current=!1},onInteractOutside:s=>{var l,c;(l=e.onInteractOutside)==null||l.call(e,s),s.defaultPrevented||(r.current=!0,s.detail.originalEvent.type==="pointerdown"&&(i.current=!0));const o=s.target;((c=n.triggerRef.current)==null?void 0:c.contains(o))&&s.preventDefault(),s.detail.originalEvent.type==="focusin"&&i.current&&s.preventDefault()}})}),h5=g.forwardRef((e,t)=>{const{__scopeDialog:n,trapFocus:r,onOpenAutoFocus:i,onCloseAutoFocus:s,...o}=e,a=zr(Eo,n),l=g.useRef(null),c=Kt(t,l);return hP(),h.jsxs(h.Fragment,{children:[h.jsx(Fx,{asChild:!0,loop:!0,trapped:r,onMountAutoFocus:i,onUnmountAutoFocus:s,children:h.jsx(np,{role:"dialog",id:a.contentId,"aria-describedby":a.descriptionId,"aria-labelledby":a.titleId,"data-state":i1(a.open),...o,ref:c,onDismiss:()=>a.onOpenChange(!1)})}),h.jsxs(h.Fragment,{children:[h.jsx(zre,{titleId:a.titleId}),h.jsx(Fre,{contentRef:l,descriptionId:a.descriptionId})]})]})}),r1="DialogTitle",f5=g.forwardRef((e,t)=>{const{__scopeDialog:n,...r}=e,i=zr(r1,n);return h.jsx(Tt.h2,{id:i.titleId,...r,ref:t})});f5.displayName=r1;var p5="DialogDescription",m5=g.forwardRef((e,t)=>{const{__scopeDialog:n,...r}=e,i=zr(p5,n);return h.jsx(Tt.p,{id:i.descriptionId,...r,ref:t})});m5.displayName=p5;var g5="DialogClose",v5=g.forwardRef((e,t)=>{const{__scopeDialog:n,...r}=e,i=zr(g5,n);return h.jsx(Tt.button,{type:"button",...r,ref:t,onClick:Pe(e.onClick,()=>i.onOpenChange(!1))})});v5.displayName=g5;function i1(e){return e?"open":"closed"}var _5="DialogTitleWarning",[Mse,x5]=C8(_5,{contentName:Eo,titleName:r1,docsSlug:"dialog"}),zre=({titleId:e})=>{const t=x5(_5),n=`\`${t.contentName}\` requires a \`${t.titleName}\` for the component to be accessible for screen reader users.
|
|
551
551
|
|
|
552
552
|
If you want to hide the \`${t.titleName}\`, you can wrap it with our VisuallyHidden component.
|
|
553
553
|
|
|
554
|
-
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},$re="DialogDescriptionWarning",Fre=({contentRef:e,descriptionId:t})=>{const r=`Warning: Missing \`Description\` or \`aria-describedby={undefined}\` for {${x5($re).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},Hre=o5,Ure=c5,y5=u5,b5=d5,w5=f5,S5=m5,Wre=v5;const s1=Hre,Vre=Ure,k5=g.forwardRef(({className:e,...t},n)=>h.jsx(y5,{ref:n,className:he("fixed inset-0 z-50 bg-black/50 backdrop-blur-sm",e),...t}));k5.displayName=y5.displayName;const Mp=g.forwardRef(({className:e,children:t,...n},r)=>h.jsxs(Vre,{children:[h.jsx(k5,{}),h.jsxs(b5,{ref:r,className:he("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(Wre,{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(Br,{className:"h-4 w-4"}),h.jsx("span",{className:"sr-only",children:"Close"})]})]})]}));Mp.displayName=b5.displayName;const Ap=({className:e,...t})=>h.jsx("div",{className:he("flex flex-col space-y-1.5 text-left",e),...t});Ap.displayName="DialogHeader";const o1=({className:e,...t})=>h.jsx("div",{className:he("flex flex-row justify-end gap-2",e),...t});o1.displayName="DialogFooter";const Lp=g.forwardRef(({className:e,...t},n)=>h.jsx(w5,{ref:n,className:he("text-lg font-semibold leading-none text-text-100",e),...t}));Lp.displayName=w5.displayName;const C5=g.forwardRef(({className:e,...t},n)=>h.jsx(S5,{ref:n,className:he("text-sm text-text-300",e),...t}));C5.displayName=S5.displayName;function qre({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(d$,{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(Br,{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(Az,{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(Rz,{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(Dx,{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(Ox,{className:"h-4 w-4"})}):null]})]}),h.jsx("hr",{className:"border-border"}),d?h.jsxs(h.Fragment,{children:[h.jsx(Yre,{...d}),h.jsx("hr",{className:"border-border"})]}):null,s?h.jsxs(h.Fragment,{children:[h.jsx(eie,{onLoad:s,...o?{onSave:o}:{},onDirtyChange:m,initialPersonality:l,readOnly:u}),h.jsx("hr",{className:"border-border"})]}):null,h.jsx(Zre,{settings:e.sandboxSettings??null}),h.jsx("hr",{className:"border-border"}),h.jsx(Qre,{skills:e.skills??[]}),h.jsx("hr",{className:"border-border"}),h.jsx(Jre,{plugins:e.plugins??[]})]})]})]}):null}function Kre({qrUrl:e,busy:t,onCancel:n}){const[r,i]=g.useState(null);return g.useEffect(()=>{let s=!1;return Ru.toDataURL(e,{width:240,margin:1}).then(o=>{s||i(o)}).catch(()=>{s||i(null)}),()=>{s=!0}},[e]),h.jsx(s1,{open:!0,onOpenChange:s=>s||n==null?void 0:n(),children:h.jsxs(Mp,{className:"max-w-xs","data-testid":"lark-bot-qr-dialog",onInteractOutside:s=>s.preventDefault(),onEscapeKeyDown:s=>s.preventDefault(),children:[h.jsx(Ap,{children:h.jsx(Lp,{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 Gre={expired:"二维码已过期,请重新扫码。",cancelled:"已取消。",access_denied:"你在飞书上取消了本次授权。",lark_protocol_error:"飞书返回了未预期的响应,请重试。",cloud_unreachable:"云端暂时不可达,请稍后重试。",internal_error:"关联失败。若飞书中已创建应用,可在开发者后台删除后重试,或改用手动绑定填入其凭证。"},Xre=new Set(["expired","access_denied","lark_protocol_error","cloud_unreachable","internal_error"]);function Yre({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=k=>{k&&(o(!0),l(null),k().catch(C=>l(C instanceof Error?C.message:String(C))).finally(()=>o(!1)))},b=()=>{m(null),v(t)},_=!s&&!!c&&!!d,x=()=>{!_||!r||v(()=>r({appId:c,appSecret:d}))},y=Su(x),w=h.jsxs("div",{className:"flex items-center gap-1.5",children:[h.jsx(Zf,{className:"h-3.5 w-3.5 text-text-400","aria-hidden":!0}),h.jsx("span",{className:"text-[13px] font-medium text-text-100",children:"飞书 Bot"})]});return e?h.jsxs("section",{className:"flex flex-col gap-1.5","data-testid":"lark-bot-section",children:[w,e.state==="unbound"||e.state==="provisioning"?h.jsxs(h.Fragment,{children:[h.jsx("span",{className:"text-[11px] text-text-400",children:"关联一个飞书 bot 后,这个 persona 就是它:拉进群后群成员 @ 它提问、或直接私聊它, 推理跑在你本机,回复自动发回去。"}),t?h.jsx("button",{type:"button",disabled:s||e.state==="provisioning",onClick:b,className:"self-start rounded border border-border bg-bg-200 px-3 py-1.5 text-[12px] font-medium text-text-100 hover:bg-bg-300 disabled:opacity-50","data-testid":"lark-bot-provision",children:e.state==="provisioning"?"等待扫码…":"扫码关联飞书 Bot"}):null,e.state==="unbound"&&e.errorReason&&!p?h.jsxs("div",{className:"flex flex-col gap-1.5 rounded border border-error bg-error-dim px-2 py-1.5","data-testid":"lark-bot-provision-error",children:[h.jsx("span",{className:"text-[11px] text-error",children:Gre[e.errorReason]}),h.jsxs("div",{className:"flex gap-1.5",children:[Xre.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(Kre,{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:k=>u(k.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:k=>f(k.target.value),...y,type:"password",placeholder:"App Secret",className:"rounded border border-border bg-bg-100 px-2 py-1 text-[12px] text-text-200","data-testid":"lark-bot-manual-secret"}),h.jsx("button",{type:"button",disabled:!_,onClick:x,className:"self-start rounded border border-border px-3 py-1.5 text-[12px] text-text-100 hover:bg-bg-200 disabled:opacity-50","data-testid":"lark-bot-manual-submit",children:s?"绑定中…":"绑定"})]})]}):null]}):null,e.state==="bound"||e.state==="broken"?h.jsxs("div",{className:"flex flex-col gap-1.5",children:[e.state==="broken"?h.jsxs("div",{className:"rounded border border-error bg-error-dim px-2 py-1.5 text-[11px] text-error","data-testid":"lark-bot-broken",children:["Bot 凭证失效:",e.brokenReason??"未知原因","。请解绑后重新填入有效凭证绑定。"]}):null,h.jsxs("div",{className:"flex items-center gap-2 text-[12px] text-text-200",children:[h.jsx("span",{className:"font-medium text-text-100",children:e.botName??"未命名 bot"}),e.appId?h.jsx("span",{className:"text-[11px] text-text-400",children:e.appId}):null]}),h.jsx("span",{className:"text-[11px] text-text-400",children:"把 bot 拉进任意飞书群,群成员 @ 它即可提问。"}),e.groups.length>0?h.jsx("ul",{className:"flex flex-col gap-0.5","data-testid":"lark-bot-groups",children:e.groups.map(k=>h.jsxs("li",{className:"text-[11px] text-text-300 truncate",children:["· ",k.chatName??k.chatId]},k.chatId))}):h.jsx("span",{className:"text-[11px] text-text-400","data-testid":"lark-bot-groups-empty",children:"还没有服务中的群。"}),i?h.jsx("button",{type:"button",disabled:s,onClick:()=>v(i),className:"self-start rounded border border-border px-3 py-1.5 text-[12px] text-error hover:bg-error-dim disabled:opacity-50","data-testid":"lark-bot-unbind",children:"解绑"}):null]}):null,a?h.jsx("div",{className:"rounded border border-error bg-error-dim px-2 py-1.5 text-[11px] text-error","data-testid":"lark-bot-error",children:a}):null]}):h.jsxs("section",{className:"flex flex-col gap-1.5","data-testid":"lark-bot-section",children:[w,h.jsx("span",{className:"text-[11px] text-text-400",children:"状态加载中…"})]})}function Zre({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(Rd,{label:"权限默认模式",value:((t=e.permissions)==null?void 0:t.defaultMode)??"—"}),h.jsx(Rd,{label:"沙箱启用",value:Sg((n=e.sandbox)==null?void 0:n.enabled)}),h.jsx(Rd,{label:"沙箱内自动放行 Bash",value:Sg((r=e.sandbox)==null?void 0:r.autoAllowBashIfSandboxed)}),h.jsx(Rd,{label:"允许非沙箱命令",value:Sg((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(Fl,{label:"沙箱外命令",paths:(s=e.sandbox)==null?void 0:s.excludedCommands}),h.jsx(Fl,{label:"允许读取",paths:(a=(o=e.sandbox)==null?void 0:o.filesystem)==null?void 0:a.allowRead}),h.jsx(Fl,{label:"拒绝读取",paths:(c=(l=e.sandbox)==null?void 0:l.filesystem)==null?void 0:c.denyRead}),h.jsx(Fl,{label:"允许写入",paths:(d=(u=e.sandbox)==null?void 0:u.filesystem)==null?void 0:d.allowWrite}),h.jsx(Fl,{label:"拒绝写入",paths:(p=(f=e.sandbox)==null?void 0:f.filesystem)==null?void 0:p.denyWrite})]})]})]})}function Sg(e){return e===!0?"是":e===!1?"否":"—"}function Rd({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 Fl({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 Qre({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 Jre({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 eie({onLoad:e,onSave:t,onDirtyChange:n,initialPersonality:r,readOnly:i=!1}){const s=r!==void 0,[o,a]=g.useState(s),[l,c]=g.useState(s?r:""),[u,d]=g.useState(s?r:""),[f,p]=g.useState(null),[m,v]=g.useState(!1),[b,_]=g.useState(null),x=Qe.useRef(e),y=Qe.useRef(t),w=Qe.useRef(n);Qe.useEffect(()=>{x.current=e,y.current=t,w.current=n});const k=Qe.useCallback(()=>{a(!1),p(null),x.current().then(P=>{c(P),d(P),a(!0)}).catch(P=>{p(P instanceof Error?P.message:String(P))})},[]);Qe.useEffect(()=>{s||k()},[s,k]);const C=!i&&o&&u!==l;Qe.useEffect(()=>{i||w.current(C)},[C,i]);const N=()=>{y.current&&(v(!0),_(null),y.current(u).then(()=>{c(u),v(!1)}).catch(P=>{_(P instanceof Error?P.message:String(P)),v(!1)}))},T=()=>{d(l),_(null)},B=Su(()=>{!C||m||N()},()=>{!C||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:k,className:"rounded-sm border border-error px-2 py-0.5 text-[11px] hover:bg-error/10",children:"重试"})]}):null,b?h.jsxs("div",{"data-testid":"persona-personality-save-error",className:"rounded-md border border-error bg-error-dim px-3 py-2 text-[12px] text-error",children:["保存失败:",b]}):null,h.jsx("textarea",{"data-testid":"persona-personality-textarea",value:u,onChange:P=>d(P.target.value),...B,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&&C?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 tie={state:"unbound",groups:[]};function nie(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(tie)}};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 rie(e,t="owner"){const{persona:n}=RT(e),r=LB(e),i=jB(),s=DB(),{httpBaseUrl:o}=Yf(),a=$i(),l=nie(t==="guest"?null:a,e),{capabilities:c}=Gy((n==null?void 0:n.tool)??"claude"),u=g.useMemo(()=>!(n!=null&&n.public)||!o||/^https?:\/\/(127\.0\.0\.1|localhost|0\.0\.0\.0|\[?::1\]?)([:/]|$)/i.test(o)?null:`${o}/s/${e}`,[n==null?void 0:n.public,o,e]),d=g.useCallback((y,w)=>{i(e,w).catch(k=>{Ae("persona",`${y} failed`,k)})},[i,e]),f=g.useCallback(y=>d("togglePublic",{public:y}),[d]),p=g.useCallback(y=>d("changeTool",{tool:y}),[d]),m=g.useCallback(y=>d("changeModel",{model:y}),[d]),v=g.useCallback(y=>d("changeEffort",{effort:y}),[d]),b=g.useCallback(()=>!n||!confirm(`删除 persona "${n.label}"?`)?!1:(s(e).catch(y=>{Ae("persona","delete failed",y)}),!0),[n,s,e]),_=g.useCallback(async()=>r.loaded?r.personality:(await r.refresh()).personality,[r]),x=g.useCallback(async y=>{await i(e,{personality:y}),await r.refresh()},[i,e,r]);return{persona:n,detail:r,models:(c==null?void 0:c.models)??[],configSchema:(c==null?void 0:c.configSchema)??[],larkBot:l,guestShareUrl:u,changeTool:p,changeModel:m,changeEffort:v,togglePublic:f,remove:b,loadPersonality:_,savePersonality:x}}function iie({personaId:e,open:t,onClose:n,api:r,embedded:i,onDirtyChange:s,onShareCapability:o,viewerRole:a="owner"}){const l=rie(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(qre,{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 sie(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 oie(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 a1(e,t,n,r,i){const s=await e.attachmentSignUrl({sessionId:n,relPath:r,...i!==void 0?{ttlSeconds:i}:{}});return oie(s.url,sie(t.url))}async function jC(e,t,n,r,i=60,s){const o=window.open("about:blank","_blank");try{s&&await s();const a=await a1(e,t,n,r,i);o?o.location.href=a:window.open(a,"_blank")}catch(a){throw o&&o.close(),a}}async function aie(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 lie={...So,h1:({node:e,...t})=>h.jsx("h1",{...t,className:"mt-4 mb-3 text-[18px] font-semibold leading-tight text-text-100"}),h2:({node:e,...t})=>h.jsx("h2",{...t,className:"mt-4 mb-2 text-[16px] font-semibold leading-tight text-text-100"}),h3:({node:e,...t})=>h.jsx("h3",{...t,className:"mt-3 mb-2 text-[14px] font-semibold leading-tight text-text-100"}),h4:({node:e,...t})=>h.jsx("h4",{...t,className:"mt-3 mb-1 text-[13px] font-semibold text-text-100"}),h5:({node:e,...t})=>h.jsx("h5",{...t,className:"mt-2 mb-1 text-[12px] font-semibold text-text-100"}),h6:({node:e,...t})=>h.jsx("h6",{...t,className:"mt-2 mb-1 text-[12px] font-semibold text-text-300"}),p:({node:e,...t})=>h.jsx("p",{...t,className:"my-2 leading-relaxed"}),ul:({node:e,...t})=>h.jsx("ul",{...t,className:"my-2 list-disc space-y-1 pl-5"}),ol:({node:e,...t})=>h.jsx("ol",{...t,className:"my-2 list-decimal space-y-1 pl-5"}),li:({node:e,...t})=>h.jsx("li",{...t,className:"leading-relaxed"}),blockquote:({node:e,...t})=>h.jsx("blockquote",{...t,className:"my-2 border-l-2 border-border pl-3 italic text-text-300"}),code:({node:e,className:t,children:n,...r})=>t?h.jsx("code",{...r,className:`${t} font-mono text-[12px]`,children:n}):h.jsx("code",{...r,className:"rounded bg-bg-50 px-1 py-0.5 font-mono text-[12px] text-text-100",children:n}),pre:({node:e,...t})=>h.jsx("pre",{...t,className:"my-2 overflow-auto rounded border border-border bg-bg-0 p-3 text-[12px] font-mono text-text-100"}),hr:({node:e,...t})=>h.jsx("hr",{...t,className:"my-3 border-border"}),table:({node:e,...t})=>h.jsx("table",{...t,className:"my-2 w-full border-collapse text-[12px]"}),thead:({node:e,...t})=>h.jsx("thead",{...t,className:"bg-bg-50"}),th:({node:e,...t})=>h.jsx("th",{...t,className:"border border-border px-2 py-1 text-left font-semibold"}),td:({node:e,...t})=>h.jsx("td",{...t,className:"border border-border px-2 py-1"}),strong:({node:e,...t})=>h.jsx("strong",{...t,className:"font-semibold text-text-100"}),em:({node:e,...t})=>h.jsx("em",{...t,className:"italic"})};function cie(e){const t=e.split("/");return t[t.length-1]||e}function E5({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:cie(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(Jc,{remarkPlugins:[tu],components:lie,children:i})}):null})]})}function uie({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(E5,{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(Bz,{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(Br,{className:"h-4 w-4"})})]})})}):null}function die({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 hie=6173,fie=6182;function pie({open:e,onOpenChange:t,projectName:n,currentPort:r,allUsedPorts:i,onUpdate:s}){const o=[];for(let v=hie;v<=fie;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(s1,{open:e,onOpenChange:t,children:h.jsxs(Mp,{className:"max-w-md",children:[h.jsxs(Ap,{children:[h.jsxs(Lp,{children:["改端口 · ",n]}),h.jsxs(C5,{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(o1,{children:[h.jsx(ii,{variant:"ghost",onClick:()=>t(!1),disabled:c,children:"取消"}),h.jsx(ii,{onClick:m,disabled:!p,children:c?"应用中…":"应用新端口"})]})]})})}const DC=[{stage:"build",label:"构建"},{stage:"deploy",label:"部署到阿里云"},{stage:"verify",label:"验证可访问性"}];function mie({currentStage:e,onCancel:t}){const n=DC.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:[DC.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(Qf,{className:"size-3.5"}):o?h.jsx(In,{className:"size-3.5 animate-spin"}):h.jsx(LT,{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 gie={build:"构建",deploy:"部署",verify:"验证"};function vie({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:["[",gie[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 _ie={build:"构建",deploy:"部署",verify:"验证",unknown:"未知"};function xie({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(As,{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:["[",_ie[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(Br,{className:"size-3.5"})})]})}const OC={"install-pending":{label:"等装依赖…",step:"1/3"},installing:{label:"安装依赖中…(可能要几十秒到几分钟)",step:"2/3"},"starting-dev-server":{label:"启动 dev server…(等监听端口才挂 iframe)",step:"3/3"}};function yie({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(Vc,{className:"size-3"}),"打开线上"]}):null,s,h.jsxs(ay,{children:[h.jsx(ly,{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(c$,{className:"size-3.5"})})}),h.jsxs(dp,{align:"end",children:[h.jsx(bi,{onSelect:()=>p(!0),children:"Update Port…"}),h.jsxs(bi,{disabled:!0,title:"rename not supported yet",onSelect:y=>y.preventDefault(),children:["Name: ",e.name]})]})]})]})]}),c?h.jsx(xie,{stage:c.stage,onClose:()=>u==null?void 0:u(),onFocusChat:()=>d==null?void 0:d()}):null,((_=e.publishJob)==null?void 0:_.status)==="in-flight"?h.jsx(mie,{currentStage:o??e.publishJob.stage,onCancel:()=>void(a==null?void 0:a())}):null,((x=e.publishJob)==null?void 0:x.status)==="interrupted"?h.jsx(vie,{stage:e.publishJob.stage,onRetry:()=>void(l==null?void 0:l()),onDismiss:()=>void(a==null?void 0:a())}):null,h.jsx("div",{className:"min-h-0 flex-1",children:m==="failed"?h.jsx(bie,{reason:e.stageReason}):m==="stopped"?null:m==="running"?v?h.jsx("iframe",{"data-testid":"preview-iframe",className:"size-full border-0 bg-white",src:v,title:"preview"}):h.jsx(BC,{label:"等 tunnel 起来…",step:"-"}):h.jsx(BC,{label:OC[m].label,step:OC[m].step})}),h.jsx(pie,{open:f,onOpenChange:p,projectName:e.name,currentPort:e.port,allUsedPorts:i,onUpdate:async y=>{await r(y)}})]})}function BC({label:e,step:t}){return h.jsxs("div",{"data-testid":"preview-spinner",className:"flex h-full w-full flex-col items-center justify-center gap-3 p-6 text-center",children:[h.jsx(In,{className:"size-6 animate-spin text-accent-main-100"}),h.jsx("div",{className:"text-[13px] text-text-200",children:e}),h.jsx("div",{className:"text-[11px] uppercase tracking-wider text-text-500",children:t}),h.jsx("div",{className:"mt-2 max-w-[300px] text-[11px] text-text-500",children:"左侧 chat 可看 assistant 详细进度"})]})}function bie({reason:e}){return h.jsxs("div",{"data-testid":"preview-failed",className:"flex h-full w-full flex-col items-center justify-center gap-3 p-6 text-center",children:[h.jsx(As,{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 wie({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(s1,{open:!!e,onOpenChange:s=>{s||(r(!1),t())},children:h.jsxs(Mp,{className:"max-w-lg",children:[h.jsx(Ap,{children:h.jsx(Lp,{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(o1,{children:[h.jsx(ii,{variant:"ghost",onClick:i,className:"gap-1.5",children:n?h.jsxs(h.Fragment,{children:[h.jsx(cl,{className:"size-3.5"}),"已复制"]}):h.jsxs(h.Fragment,{children:[h.jsx(Jf,{className:"size-3.5"}),"复制"]})}),h.jsx(ii,{onClick:t,children:"关闭"})]})]})})}function Sie(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 kie={codex:"on-request",claude:"bypassPermissions"};function Cie(e){const t={cwd:e.cwd,permissionMode:e.sourcePermissionMode??kie[e.sourceTool??"claude"]??"bypassPermissions",forkedFromSessionId:e.sourceSessionId};return e.sourceOwnerPersonaId&&(t.ownerPersonaId=e.sourceOwnerPersonaId),e.sourceTool&&(t.tool=e.sourceTool),t}async function Eie(e,t,n,r={}){if(!t.toolSessionId)return null;const i=await e.sessionCreate({...Cie({cwd:t.cwd,sourceSessionId:t.sessionId,sourcePermissionMode:t.permissionMode,sourceOwnerPersonaId:t.ownerPersonaId,sourceTool:t.tool}),...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 Nie(e,t,n){return Eie(e,t,n,{ephemeral:!0})}function Md(e){return e!=null&&e.ephemeral!==!1}async function Tie(e,t){return t.stillEphemeral?(await e.sessionUpdate(t.sessionId,{ephemeral:!1}),!0):!1}const Pie=300;function Iie(e){return e&&typeof e=="object"&&"value"in e?e.value:e}function Rie(e,t){const n=vx(),[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=Iie(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(()=>{})},Pie)},[n,e]);return g.useEffect(()=>()=>{s.current&&(clearTimeout(s.current),s.current=null)},[]),{initialSize:r??t,setSize:o,loading:r===null}}function Mie(){return{quickAsk:null,mds:[],active:null}}function Aie(e,t){return{...e,quickAsk:{sessionId:t.sessionId,ephemeral:!0},active:"quick-ask"}}function Lie(e,t){const n=e.mds.includes(t);return{...e,mds:n?e.mds:[...e.mds,t],active:{kind:"md",relPath:t}}}function jie(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 Die(e){return e.quickAsk?{...e,quickAsk:{...e.quickAsk,ephemeral:!1}}:e}function Oie(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 Bie(e,t){return{...e,active:t}}function zie(e,t){return e===null||t===null||e==="quick-ask"||t==="quick-ask"?e===t:e.relPath===t.relPath}function N5(e){return e.quickAsk!==null||e.mds.length>0}function $ie(e){return e.split("/").pop()||e}function Fie({state:e,api:t,onSwitchTab:n,onCloseQuickAsk:r,onCloseMd:i,loadMarkdown:s,quickAskSession:o,onPromoteQuickAsk:a}){if(!N5(e))return null;const l=[];e.quickAsk&&l.push({id:"quick-ask",label:"问一下",title:"问一下",icon:h.jsx(a0,{className:"w-3.5 h-3.5"})});for(const c of e.mds)l.push({id:{kind:"md",relPath:c},label:$ie(c),title:c,icon:h.jsx(Ro,{className:"w-3.5 h-3.5"})});return h.jsxs("div",{className:"flex flex-col h-full bg-bg-50/60 border-l border-border-strong",children:[h.jsx($A,{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=zie(e.active,c.id),d=c.id==="quick-ask"?"quick-ask":`md:${c.id.relPath}`;return h.jsxs(FA,{children:[h.jsx(HA,{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(Br,{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(Yy,{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(Vie,{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(E5,{relPath:c,loadMarkdown:s,showTitleBar:!1})},`md-body:${c}`)})]})]})}function Hie({state:e,extras:t}){const{api:n,session:r}=t,i=$i(),[s,o]=g.useState(Mie()),a=g.useRef(s);a.current=s;const l=g.useRef(!1),c=g.useCallback(async k=>{const C=a.current.quickAsk,N=await Nie(n,r,k);if(N){if(l.current){n.sessionDelete(N.sessionId).catch(()=>{});return}Md(C)&&n.sessionDelete(C.sessionId).catch(()=>{}),o(T=>Aie(T,{sessionId:N.sessionId}))}},[n,r]),u=g.useCallback(async k=>{const C=a.current.quickAsk,N=(C==null?void 0:C.sessionId)===k;try{await Tie(n,{sessionId:k,stillEphemeral:N&&Md(C)})&&o(B=>Die(B))}catch(T){Ae("quick-ask","promote failed",T)}},[n]),d=g.useCallback(k=>{o(C=>Lie(C,k))},[]),f=g.useCallback(k=>{o(C=>Bie(C,k))},[]),p=g.useCallback(()=>{const k=a.current.quickAsk;Md(k)&&n.sessionDelete(k.sessionId).catch(()=>{}),o(C=>jie(C))},[n]),m=g.useCallback(k=>{o(C=>Oie(C,k))},[]);g.useEffect(()=>()=>{l.current=!0;const k=a.current.quickAsk;Md(k)&&n.sessionDelete(k.sessionId).catch(()=>{})},[]);const v=ai("sessions")??[],b=s.quickAsk?v.find(k=>k.sessionId===s.quickAsk.sessionId)??{sessionId:s.quickAsk.sessionId,cwd:r.cwd,tool:r.tool}:null,_=g.useCallback(async k=>{const C=await a1(n,i,r.sessionId,k,60),N=await fetch(C);if(!N.ok)throw new Error(`fetch ${N.status} ${N.statusText}`);return N.text()},[n,i,r.sessionId]),x=h.jsx(l1,{state:e,extras:t,onQuickAskInternal:c,onPreviewMdInternal:d}),{initialSize:y,setSize:w}=Rie("chat-panel-right-slot-width",480);return h.jsxs(vy,{orientation:"horizontal",className:"flex-1 flex min-w-0 min-h-0",children:[h.jsx(Jh,{id:"chat",minSize:"400px",children:x}),N5(s)?h.jsxs(h.Fragment,{children:[h.jsx(pR,{className:"w-1 bg-text-100/10 hover:bg-text-100/25 transition-colors cursor-col-resize"}),h.jsx(Jh,{id:"right-slot",defaultSize:`${y}px`,minSize:"360px",maxSize:"800px",onResize:k=>w(k.inPixels),children:h.jsx(Fie,{state:s,api:n,onSwitchTab:f,onCloseQuickAsk:p,onCloseMd:m,loadMarkdown:_,quickAskSession:b,onPromoteQuickAsk:u})})]}):null]})}const Uie={implicitCloseOnUserText:!1},Wie={implicitCloseOnUserText:!0};function Vie({session:e,api:t,onPromoteQuickAsk:n}){const r=IA(e.sessionId);return h.jsx(l1,{state:r,extras:{session:e,api:t,...n?{onPromoteQuickAsk:n}:{}}})}function qie({extras:e}){const t=IA(e.session.sessionId);if(e.session.appBuilderProject){const n=h.jsx(l1,{state:t,extras:e});return h.jsx(Kie,{state:t,chat:n,extras:e})}return h.jsx(Hie,{state:t,extras:e})}function Kie({state:e,chat:t,extras:n}){var T;const r=ai("daemon-info"),i=$i(),s=n.api,o=n.session,a=o.appBuilderProject,[l,c]=g.useState(null),u=g.useCallback(()=>{s.appBuilderGetProject(o.sessionId).then(B=>c(B.project)).catch(()=>c(null))},[s,o.sessionId]);g.useEffect(()=>{u()},[u]);const[d,f]=g.useState([]),p=g.useCallback(()=>{s.appBuilderListProjects().then(B=>f(B.projects)).catch(()=>f([]))},[s]);g.useEffect(()=>{p()},[p]),g.useEffect(()=>i.on("appBuilder:project-updated",P=>{const j=P;j!=null&&j.project&&(j.project.name===a&&c(j.project),f(I=>{const R=I.findIndex(z=>z.name===j.project.name);if(R<0)return[...I,j.project];const L=I.slice();return L[R]=j.project,L}))}),[i,a]);const{host:m,scheme:v}=Sie(i.url,r==null?void 0:r.tunnelUrl),[b,_]=g.useState(void 0),[x,y]=g.useState(null);g.useEffect(()=>{const B=i.on("appBuilder:publish-progress",j=>{const I=j;!I||I.name!==a||I.status==="started"&&_(I.stage)}),P=i.on("appBuilder:publish-failed",j=>{const I=j;!I||I.name!==a||(_(void 0),y({stage:I.stage}))});return()=>{B(),P()}},[i,a]),g.useEffect(()=>{_(void 0),y(null)},[a]);const[w,k]=g.useState(null),C=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(B){k({title:"发布请求失败",message:(B==null?void 0:B.message)??String(B)})}},children:"发布上线"}),N=(l==null?void 0:l.stage)??(l!=null&&l.isRunning?"running":"stopped");return h.jsxs(h.Fragment,{children:[h.jsx(die,{left:t,stage:N,onExpand:async()=>{await s.appBuilderStartDevServer(o.sessionId)},onCollapse:async()=>{await s.appBuilderStopDevServer(o.sessionId)},right:h.jsx(yie,{project:l,previewHost:m,previewScheme:v,allUsedPorts:d.map(B=>B.port),onUpdatePort:async B=>{await s.appBuilderUpdateProjectPort(a,B),p()},publishSlot:C,publishInFlightStage:b,onDismissPublishJob:async()=>{try{await s.appBuilderDismissPublishJob(a)}catch(B){k({title:"取消发布失败",message:(B==null?void 0:B.message)??String(B)})}},onRetryPublish:async()=>{try{await s.appBuilderPublish(a)}catch(B){k({title:"重新发布失败",message:(B==null?void 0:B.message)??String(B)})}},publishFailureBanner:x,onPublishFailureBannerClose:()=>y(null),onPublishFailureBannerFocusChat:()=>{}})}),h.jsx(wie,{error:w,onClose:()=>k(null)})]})}function Gie({headerMeta:e,connState:t,liveWorktreeRoot:n,onOpenConfig:r,variant:i="full",ephemeral:s,onPromote:o,lines:a,pendingPermissions:l,procAlive:c,rewindableUserMessageIds:u,onPermissionRespond:d,onPermissionInterrupt:f,onRewind:p,onFork:m,onQuickAsk:v,topSlot:b,realtimeQuestionAnswers:_,onSubmitQuestion:x,onCancelQuestion:y,liveQuestionToolUseIds:w,api:k,cwd:C,tool:N,sessionKey:T,onSend:B,awaitingUser:P,onAbort:j,onNewSession:I,onClearSession:R,configSlot:L,chatRootRef:z,chatBodyRef:$,topSentinelRef:F,drawers:D,xtermSlot:O,fileSharingScope:E,onShareFile:H,onOpenInTab:V,onPreviewMarkdown:A,onOpenFilePath:ne}){return h.jsx(BZ,{children:h.jsxs("div",{ref:z,"data-cc-chat-root":"",className:"flex flex-col h-full bg-bg-100",children:[h.jsx(LQ,{meta:e,...N?{tool:N}:{},connState:t,variant:i,...n!==void 0?{liveWorktreeRoot:n}:{},...i==="full"&&r?{onOpenConfig:r}:{},...i==="quickask"?{ephemeral:s??!1,...o?{onPromote:o}:{}}:{}}),h.jsxs("div",{ref:$,"data-testid":"chat-body",className:"flex-1 overflow-y-auto min-h-0",style:{overflowAnchor:"none"},children:[F?h.jsx("div",{ref:F,"data-testid":"top-sentinel","aria-hidden":"true",style:{height:1}}):null,h.jsx(MM,{lines:a,...d?{onPermissionRespond:d}:{},...f&&c?{onPermissionInterrupt:f}:{},topSlot:b,...p?{onRewind:p}:{},rewindableUserMessageIds:u,...m?{onFork:m}:{},...v?{onQuickAsk:v}:{},realtimeQuestionAnswers:_,onSubmitQuestion:x,...y?{onCancelQuestion:y}:{},liveQuestionToolUseIds:w,...E?{fileSharingScope:E}:{},...H?{onShareFile:H}:{},...V?{onOpenInTab:V}:{},...A?{onPreviewMarkdown:A}:{},...ne?{onOpenFilePath:ne}:{},...i==="full"?{turnCollapse:N==="codex"?Wie:Uie}:{}})]}),O,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(MQ,{meta:e,...k?{api:k}:{},cwd:C,...N?{tool:N}:{},sessionKey:T,onSend:B,awaitingUser:P,...j?{onAbort:j}:{},...I?{onNewSession:I}:{},...R?{onClearSession:R}:{},...L?{configSlot:L}:{}}),D]})})}function l1({state:e,extras:t,onQuickAskInternal:n,onPreviewMdInternal:r}){const{session:i,api:s,liveGitBranch:o,liveWorktreeRoot:a,onNewSession:l,onTurnEnd:c,onOpenConfig:u,onFork:d,onQuickAsk:f,viewerRole:p,onPromoteQuickAsk:m,configSlot:v}=t,{capabilities:b}=Gy(i.tool||"claude"),_=(b==null?void 0:b.features)??ET(i.tool),[x,y]=g.useState(null),[w,k]=g.useState(null),C=Yf(),N=!!s&&C.actionsLevel==="owner"&&_.fileSharing,T=RT(i.ownerPersonaId??null).persona,B=(T==null?void 0:T.label)??null,P=!!B&&!!i.ownerPersonaId,j=g.useCallback((q,ae)=>{y({kind:q,text:ae}),setTimeout(()=>{y(fe=>(fe==null?void 0:fe.text)===ae?null:fe)},2e3)},[]),I=$i(),R=dB(),L=PA(i.sessionId,i.toolSessionId),{events:z,pendingQuestions:$,clearQuestion:F,markQuestionSubmitted:D,status:O}=L,E=e.historyLoading,H=BM(O);g.useEffect(()=>{Ae("chat-panel","sessionStatus",{sessionId:i.sessionId,sessionStatus:O,procAlive:H})},[O,H,i.sessionId]);const V=e.lines,A=e.pendingPermissions,ne=A[0]??null,oe=g.useMemo(()=>NU(z),[z]),[X,ye]=g.useState(null),[$e,ue]=g.useState(()=>new Set);kU(s,i.sessionId,i.toolSessionId,_.observe);const Ie=g.useRef(i.sessionId);g.useEffect(()=>{if(Ie.current=i.sessionId,!_.rewind){ye(null);return}let q=!1;return ye(null),(async()=>{try{const ae=await s.sessionRewindableMessageIds(i.sessionId);if(q)return;ye(new Set(ae.userMessageIds))}catch{q||ye(null)}})(),()=>{q=!0}},[s,i.sessionId,_.rewind]);const Re=g.useCallback(()=>{const q=i.sessionId;s.sessionRewindableMessageIds(q).then(ae=>{Ie.current===q&&ye(new Set(ae.userMessageIds))}).catch(()=>{})},[s,i.sessionId]),Ke=g.useMemo(()=>{if(X!==null){const qe=new Set(X);for(const kr of $e)qe.delete(kr);return qe}const q=new Set(["Edit","Write","MultiEdit","NotebookEdit"]),ae=new Set;let fe=null;for(const qe of V)qe.kind==="user-text"?fe=qe.uuid??null:fe&&qe.kind==="tool-call"&&q.has(qe.tool)&&!$e.has(fe)&&ae.add(fe);return ae},[V,$e,X]),_e=g.useRef(c);_e.current=c,CU(i.sessionId,i.toolSessionId,()=>{Xt(null),ue(new Set)});const Be=QQ({sessionStatus:O}),fn=g.useRef(null);g.useEffect(()=>{var fe;const q=fn.current,ae=(q==null?void 0:q.sid)===i.sessionId;ae&&q.phase===Be||(fn.current={sid:i.sessionId,phase:Be},Ae("session-phase",Be,{sid:i.sessionId,phase:Be,prev:ae?q.phase:null,desc:ZQ[Be]}),ae&&q.phase==="turn-running"&&Be!=="turn-running"&&((fe=_e.current)==null||fe.call(_e),Re()))},[Be,i.sessionId,Re]);const it=g.useCallback(()=>{s.sessionInterrupt(i.sessionId).catch(()=>{})},[s,i.sessionId]),[At,Xt]=g.useState(null),Lt=g.useCallback(q=>{Xt(q)},[]),[wt,Ze]=g.useState(!1),st=g.useCallback(()=>{s.sessionStop(i.sessionId).catch(()=>{}),Ze(!1)},[s,i.sessionId]);g.useCallback(q=>{s.pinSession(i.sessionId,q).catch(ae=>{Ae("chat-panel","pinSession failed",{err:ae==null?void 0:ae.message})})},[s,i.sessionId]);const St=m?"quickask":"full",{container:pn,onCollapse:sn}=zQ(),U=g.useRef(0),J=g.useRef(null);g.useEffect(()=>{const q=ae=>{if(ae.key!=="Escape")return;if(!H){U.current=0;return}if(ae.isComposing)return;const qe=ae.target;if(qe&&qe.closest("[data-cc-chat-root]")!==J.current)return;const kr=Date.now();kr-U.current<2e3?(U.current=0,Ze(!0)):(U.current=kr,it())};return window.addEventListener("keydown",q),()=>window.removeEventListener("keydown",q)},[it,H]);const ve=g.useRef(null),Ce=g.useRef(null),Fe=g.useRef(!0),ht=g.useRef(null),on=g.useRef(0),jt=g.useRef(0);g.useEffect(()=>{Fe.current=!0,ht.current=null,on.current=0,jt.current=0},[i.sessionId]),g.useEffect(()=>{k(null)},[i.sessionId]);const se=g.useRef(e);se.current=e;const K=g.useCallback(()=>{var fe;const q=ve.current;if(!q||ht.current!==null)return;const ae=se.current;ae.historyDone||ae.historyLoading||(ht.current={distFromBottom:q.scrollHeight-q.scrollTop},(fe=ae.loadMoreHistory)==null||fe.call(ae))},[]);g.useEffect(()=>{const q=ve.current,ae=Ce.current;if(!q||!ae)return;const fe=new IntersectionObserver(qe=>{for(const kr of qe)kr.isIntersecting&&K()},{root:q,threshold:0});return fe.observe(ae),()=>fe.disconnect()},[K]),g.useEffect(()=>{const q=ve.current;if(!q)return;const ae=150,fe=qe=>{Date.now()<jt.current&&(qe.preventDefault(),jt.current=Date.now()+ae)};return q.addEventListener("wheel",fe,{passive:!1}),()=>q.removeEventListener("wheel",fe)},[]),g.useEffect(()=>{const q=ve.current;if(!q)return;const ae=32,fe=()=>{const qe=q.scrollHeight-q.scrollTop-q.clientHeight;Fe.current=qe<=ae};return q.addEventListener("scroll",fe,{passive:!0}),()=>q.removeEventListener("scroll",fe)},[]),g.useLayoutEffect(()=>{const q=ve.current;if(!q)return;const ae=on.current,fe=V.length;on.current=fe;const qe=ht.current;if(qe!==null&&fe>ae){ht.current=null,q.scrollTop=q.scrollHeight-qe.distFromBottom,jt.current=Date.now()+200;return}qe!==null&&(ht.current={distFromBottom:q.scrollHeight-q.scrollTop}),Fe.current&&(q.scrollTop=q.scrollHeight)},[V,ne==null?void 0:ne.requestId]);const we=g.useMemo(()=>{const q={};for(const[ae,fe]of Object.entries($))fe.submittedAnswers&&(q[ae]=fe.submittedAnswers);return q},[$]),ft=g.useMemo(()=>new Set(Object.keys($)),[$]),an=g.useCallback(async(q,ae)=>{try{await s.answerQuestion({sessionId:i.sessionId,toolUseId:q,answers:ae}),D(q,ae)}catch{}},[s,i.sessionId,D]),vl=g.useCallback(async q=>{try{await s.cancelQuestion({sessionId:i.sessionId,toolUseId:q}),F(q)}catch{}},[s,i.sessionId,F]),_l=g.useCallback(async(q,ae)=>{var fe;if(ne)try{await((fe=e.respondPermission)==null?void 0:fe.call(e,ne.requestId,q?"allow":"deny"))}catch{}},[e,ne]),xl=g.useCallback(async()=>{const q=i.sessionId;try{await s.sessionStop(q)}catch{}e.clearSession?await e.clearSession():await s.sessionNew(q)},[e,s,i.sessionId]),jp=g.useMemo(()=>E&&V.length===0?h.jsx("div",{className:"flex justify-center py-4","data-testid":"history-loading",children:h.jsx(In,{className:"w-4 h-4 text-text-400 animate-spin"})}):e.historyDone?null:h.jsx("div",{className:"flex justify-center py-2",children:h.jsx("button",{type:"button",onClick:()=>{var q;return void((q=e.loadMoreHistory)==null?void 0:q.call(e))},disabled:E,"data-testid":"history-load-more",className:"text-[12px] text-text-400 hover:text-text-200 cursor-pointer px-3 py-1 rounded-md border border-bg-300 hover:bg-bg-100 transition-colors disabled:opacity-60",children:E?"加载中…":"Load earlier messages"})}),[E,V.length,e.historyDone,e.loadMoreHistory]),Au=e.meta,Dp=h.jsxs(h.Fragment,{children:[i.toolSessionId&&_.subagents?h.jsx(WQ,{api:s,cwd:i.cwd,toolSessionId:i.toolSessionId}):null,At&&_.rewind?h.jsx(qQ,{open:!0,onOpenChange:q=>{q||Xt(null)},api:s,sessionId:i.sessionId,userMessageId:At,lines:V,procAlive:H,onNoChanges:q=>{ue(ae=>{if(ae.has(q))return ae;const fe=new Set(ae);return fe.add(q),fe})}}):null,wt?h.jsx(Xie,{onConfirm:st,onCancel:()=>Ze(!1)}):null]}),yl={kind:"session",sessionId:i.sessionId},Bs=g.useCallback(async q=>{if(s)try{await jC(s,I,i.sessionId,q)}catch(ae){const fe=ae.message;Ae("chat-panel","open-in-tab failed",{err:fe}),j("err",`Open in tab 失败:${fe}`)}},[s,I,i.sessionId,j]),[zo,$o]=g.useState(!1),[zs,qi]=g.useState(null),Sr=g.useCallback(q=>{if(r){r(q);return}qi(q),$o(!0)},[r]),Lu=g.useCallback(q=>{if(!s)return;const ae=async()=>{try{await s.attachmentGroupAdd(i.sessionId,q)}catch(qe){Ae("chat-panel","file-link groupAdd skipped",{err:qe.message})}},fe=qe=>{const kr=qe.message;Ae("chat-panel","file-link open failed",{err:kr}),j("err",`打开文件失败:${kr}`)};if(xp(q)){ae().then(()=>Sr(q),fe);return}jC(s,I,i.sessionId,q,60,ae).catch(fe)},[s,I,i.sessionId,Sr,j]),Op=g.useCallback(async q=>{if(!s)throw new Error("daemon api not ready");const ae=await a1(s,I,i.sessionId,q,60),fe=await fetch(ae);if(!fe.ok)throw new Error(`fetch ${fe.status} ${fe.statusText}`);return await fe.text()},[s,I,i.sessionId]),It=g.useCallback(async(q,ae)=>{if(s)try{const{url:fe}=await s.attachmentSignUrl({sessionId:i.sessionId,relPath:q,ttlSeconds:86400,...ae?{view:ae}:{}}),qe=await aie(fe);j(qe?"ok":"err",qe?"分享链接已复制到剪贴板(24h 有效)":"复制失败:请手动复制")}catch(fe){const qe=fe.message;Ae("chat-panel","share-file failed",{err:qe}),j("err",`生成分享链接失败:${qe}`)}},[s,i.sessionId,j]),$s=g.useCallback(()=>k(null),[]),Bp=w==="files"&&N&&s?{title:"Edited Files",onBack:$s,content:h.jsx($ne,{api:s,scope:yl,sessionId:i.sessionId,onShareFile:It,onOpenInTab:Bs,onPreviewMarkdown:Sr})}:w==="cron"?{title:`定时任务${oe.length?` (${oe.length})`:""}`,onBack:$s,content:h.jsx("div",{className:"p-3",children:h.jsx(YQ,{jobs:oe})})}:w==="persona"&&P&&s&&i.ownerPersonaId?{title:`Persona · ${B??""}`,onBack:$s,content:h.jsx(iie,{personaId:i.ownerPersonaId,open:!0,onClose:$s,api:s,embedded:!0,...p?{viewerRole:p}:{}},i.ownerPersonaId)}:null,kt=St==="full"?h.jsx(OQ,{session:i,meta:Au,...o!==void 0?{liveGitBranch:o}:{},...a!==void 0?{liveWorktreeRoot:a}:{},...P?{personaName:B}:{},...P?{onOpenPersona:()=>k("persona")}:{},...N?{onOpenFiles:()=>k("files")}:{},cronActiveCount:oe.length,onCronClick:()=>k("cron"),onForceStop:()=>Ze(!0),...p?{viewerRole:p}:{},...b!=null&&b.toolSessionIdLabel?{toolSessionIdLabel:b.toolSessionIdLabel}:{},drill:Bp,...sn?{onCollapse:sn}:{}}):null;return h.jsxs(h.Fragment,{children:[pn&&kt?Ja.createPortal(kt,pn):null,h.jsx(Gie,{headerMeta:Au,connState:e.connState,...a!==void 0?{liveWorktreeRoot:a}:{},...u?{onOpenConfig:u}:{},variant:St,...St==="quickask"?{ephemeral:i.ephemeral!==!1,onPromote:()=>void(m==null?void 0:m(i.sessionId))}:{},lines:V,pendingPermissions:A,procAlive:H,rewindableUserMessageIds:Ke,onPermissionRespond:_l,onPermissionInterrupt:it,onRewind:_.rewind?Lt:void 0,...d&&_.fork?{onFork:d}:{},...n&&_.fork?{onQuickAsk:n}:f&&_.fork?{onQuickAsk:f}:{},topSlot:jp,realtimeQuestionAnswers:we,onSubmitQuestion:an,onCancelQuestion:vl,liveQuestionToolUseIds:ft,api:s,cwd:i.cwd,...i.tool?{tool:i.tool}:{},sessionKey:i.sessionId,onSend:e.sendText,awaitingUser:A.length>0||Object.values($).some(q=>!q.submittedAnswers),onAbort:it,...l?{onNewSession:l}:{},onClearSession:xl,...v?{configSlot:v}:{},chatRootRef:J,chatBodyRef:ve,topSentinelRef:Ce,drawers:Dp,xtermSlot:R==="tui"&&H&&_.tui?h.jsx(hne,{sessionId:i.sessionId,client:I},i.sessionId):null,fileSharingScope:yl,...s?{onShareFile:It}:{},...s?{onOpenInTab:Bs}:{},...s?{onPreviewMarkdown:Sr}:{},...s?{onOpenFilePath:Lu}:{}}),s?h.jsx(uie,{open:zo,onOpenChange:$o,relPath:zs,loadMarkdown:Op,onShare:zs?()=>void It(zs,"md-rendered"):void 0}):null,x?h.jsx("div",{"data-testid":"share-toast",role:"status","aria-live":"polite",className:x.kind==="ok"?"fixed left-1/2 top-4 z-50 -translate-x-1/2 rounded-md border border-emerald-500/40 bg-emerald-500/10 px-3 py-2 text-[12px] text-emerald-700 shadow-md dark:text-emerald-300":"fixed left-1/2 top-4 z-50 -translate-x-1/2 rounded-md border border-destructive/40 bg-destructive/10 px-3 py-2 text-[12px] text-destructive shadow-md",children:x.text}):null]})}function Xie({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 Yie(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 Zie(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 Qie(e,t){var m,v,b,_;const{models:n,modes:r,configSchema:i}=t,s=e.resolvedModel??e.model,o=Yie(s,n,i),a=o.options,l=a.some(x=>x.value===e.effort)?e.effort:o.defaultValue,c=e.effort===""&&e.resolvedEffort?((m=a.find(x=>x.value===e.resolvedEffort))==null?void 0:m.label)??e.resolvedEffort:((v=a.find(x=>x.value===l))==null?void 0:v.label)??null,u=((b=i.find(x=>x.name==="permissionMode"))==null?void 0:b.default)??"",d=r.some(x=>x.id===e.permissionMode)?e.permissionMode:u,p=d===u?null:((_=r.find(x=>x.id===d))==null?void 0:_.label)??null;return{modelLabel:Zie(n,s),effortOptions:a,effortValue:l,effortLabel:c,modeValue:d,modeLabel:p,modeTone:p===null?null:d==="bypassPermissions"?"danger":"info"}}function Jie({models:e=[],modes:t=[],configSchema:n=[],model:r,resolvedModel:i,resolvedEffort:s,effort:o,permissionMode:a,onPatch:l}){var p;const c=Qie({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(ay,{children:[h.jsx(ly,{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:he("font-semibold",c.modeTone==="danger"?"text-red-400":"text-blue-400"),children:c.modeLabel})]}):null]})}),h.jsxs(dp,{side:"top",align:"end",className:"w-[230px]","data-testid":"session-config-menu",children:[h.jsx(kg,{testid:"session-config-model",label:"Model",current:r,currentLabel:c.modelLabel,options:d,onSelect:m=>l({model:m})}),h.jsx(kg,{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(kg,{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 kg({testid:e,label:t,current:n,currentLabel:r,currentTone:i,options:s,onSelect:o}){const a=s.length===0;return h.jsxs(EH,{children:[h.jsxs(qI,{"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:he("truncate max-w-[100px]",i==="danger"?"text-red-400 font-semibold":i==="info"?"text-blue-400 font-semibold":"text-text-400"),children:r}),h.jsx(Un,{className:"w-3.5 h-3.5 shrink-0 text-text-500"})]}),h.jsx(KI,{className:"w-[220px] max-h-[320px] overflow-y-auto",children:s.map(l=>{const c=l.value===n;return h.jsxs(bi,{"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:he("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(cl,{className:"w-3.5 h-3.5 shrink-0 text-accent mt-0.5"}):null]},l.value||"default")})})]})}function ese(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 tse(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 nse({api:e,session:t,focused:n,totalPanes:r,onFocus:i,onClose:s,onNewSession:o,onOpenConfig:a,onFork:l,onQuickAsk:c,className:u,viewerRole:d="owner"}){const{capabilities:f}=Gy(t.tool),[p,m]=g.useState(0),{branch:v}=ese(e,t.cwd,p),{worktreeRoot:b}=tse(e,t.cwd,p),_=r>1,x=y=>{e.sessionUpdate(t.sessionId,y).catch(w=>{console.error("[session-config] session:update failed",t.sessionId,w)})};return h.jsxs("div",{className:`group/pane relative flex-1 ${u??"flex"} flex-row min-w-0 min-h-0 overflow-hidden ${_?`rounded-md border transition-colors ${n?"border-accent ring-1 ring-accent":"border-border"}`:""}`,onMouseDown:i,"data-testid":`session-pane-${t.sessionId}`,children:[h.jsx(vy,{orientation:"horizontal",className:"flex-1 flex min-w-0 min-h-0",children:h.jsx(Jh,{id:"chat",minSize:"400px",children:h.jsx("div",{className:"flex flex-col min-w-0 min-h-0 h-full",children:h.jsx(rse,{api:e,session:t,liveGitBranch:v,liveWorktreeRoot:b,onNewSession:o,onTurnEnd:()=>m(y=>y+1),onOpenConfig:a,onFork:l,onQuickAsk:c,viewerRole:d,configSlot:f?h.jsx(Jie,{models:f.models,modes:f.permissionModes,configSchema:f.configSchema,model:t.model??"",...t.resolvedModel?{resolvedModel:t.resolvedModel}:{},...t.resolvedEffort?{resolvedEffort:t.resolvedEffort}:{},effort:t.effort??"",permissionMode:t.permissionMode??"",onPatch:x}):null})})})}),_&&h.jsx("button",{type:"button",onClick:y=>{y.stopPropagation(),s()},className:"absolute top-1.5 right-1.5 z-10 p-1 rounded-md bg-bg-100/80 backdrop-blur-sm border border-border opacity-0 group-hover/pane:opacity-100 transition-opacity text-text-400 hover:text-text-100 hover:bg-bg-200","aria-label":"close pane","data-testid":`session-pane-close-${t.sessionId}`,children:h.jsx(Br,{className:"w-3.5 h-3.5"})})]})}function rse({api:e,session:t,liveGitBranch:n,liveWorktreeRoot:r,onNewSession:i,onTurnEnd:s,onOpenConfig:o,onFork:a,onQuickAsk:l,viewerRole:c,configSlot:u}){return h.jsx(qie,{extras:{session:t,api:e,...n!==void 0?{liveGitBranch:n}:{},...r!==void 0?{liveWorktreeRoot:r}:{},onNewSession:i,onTurnEnd:s,onOpenConfig:o,...a?{onFork:d=>{a(d)}}:{},...l?{onQuickAsk:d=>{l(d)}}:{},...c?{viewerRole:c}:{},...u?{configSlot:u}:{}}})}function ise({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(HH,{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(nse,{api:n,session:o,focused:!0,totalPanes:1,onFocus:()=>{},onClose:f,onNewSession:()=>{},onOpenConfig:()=>{},viewerRole:"guest"}):h.jsx("div",{className:"flex flex-1 items-center justify-center p-6 text-xs text-text-400","data-testid":"guest-share-empty",children:"选择左侧 persona 开始对话"})})]})}function sse(){const e=$i(),t=g.useMemo(()=>new Ax(e),[e]),n=MB(e),{sessions:r,refresh:i}=AB(n),{personas:s}=IT(),o=zB(),a=g.useMemo(()=>{const w=window.location.pathname.match(/^\/s\/([^/]+)/);return w?decodeURIComponent(w[1]):null},[]),l=g.useMemo(()=>r.filter(w=>!w.ephemeral&&w.larkChatId==null),[r]),c=g.useMemo(()=>a?s.filter(w=>w.personaId===a):s,[s,a]),[u,d]=g.useState(null),[f,p]=g.useState(null),[m,v]=g.useState(null);g.useEffect(()=>{let w=!1;return e.request("whoami",{}).then(k=>{w||d(k.capability.id)}).catch(()=>{}),()=>{w=!0}},[e]),g.useEffect(()=>{a&&p(a)},[a]);const b=g.useCallback(async(w,k)=>{const C=await t.sessionCreate({ownerPersonaId:w,...k.trim()?{label:k.trim()}:{}});await i(),p(w),v(C.sessionId)},[t,i]),_=g.useCallback(async w=>{await t.sessionDelete(w),await i(),v(k=>k===w?null:k)},[t,i]),x=g.useCallback(async(w,k)=>{await t.sessionUpdate(w,{label:k.label}),await i()},[t,i]),y=g.useMemo(()=>l.find(w=>w.sessionId===m)??null,[l,m]);return h.jsx(Lx.Provider,{value:o,children:h.jsx(ise,{personas:c,sessions:l,api:t,selfPrincipalId:u,selectedPersonaId:f,selectedSessionId:m,selectedSession:y,onSelectPersona:p,onSelectSession:v,onCreateSession:(w,k)=>void b(w,k),onDeleteSession:w=>void _(w),onEditSession:(w,k)=>void x(w,k),onCloseSession:()=>v(null)})})}const zC="https://app.ttcadvisory.com";function ose({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=`${zC}/auth/authorize?callback_url=${encodeURIComponent(a)}&auto=1`,c=async d=>{if(d.origin!==zC)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 w_="clawd-visitor:token";function ase(e,t){const r=`${e.protocol==="https:"?"wss:":"ws:"}//${e.host}`;return t!=null&&t.devPath?`${r}${t.devPath}`:r}function lse(){return{async getUrl(e){const t=localStorage.getItem(w_);if(!t)throw new Error("NO_VISITOR_TOKEN");const n=ase(window.location,{});return await bT(e).upsert({id:"guest",name:"访客",mode:"remote",url:n,token:t}),{url:n}}}}function cse(e){const t=n=>{document.documentElement.classList.toggle("dark",n==="dark")};return t(e.theme.mode),e.onThemeChange(n=>t(n.mode))}function use(){const e=$i(),t=g.useMemo(()=>RB(e),[e]);return h.jsx(hB,{cache:t.cache,children:h.jsx(mB,{children:h.jsx(sse,{})})})}function dse({host:e}){const[t]=g.useState(()=>localStorage.getItem(w_)),[n,r]=g.useState(!1),[i,s]=g.useState(null);return g.useEffect(()=>cse(e),[e]),g.useEffect(()=>{if(!t)return;let o=!1;return lse().getUrl(e).then(()=>{o||r(!0)}).catch(a=>{o||s(a instanceof Error?a.message:String(a))}),()=>{o=!0}},[e,t]),t?h.jsx(Cb,{host:e,children:h.jsx(iw,{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(uB,{host:e,children:h.jsx(use,{})}):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(Cb,{host:e,children:h.jsx(iw,{children:h.jsx(ose,{onAuthed:o=>{localStorage.setItem(w_,o),window.location.reload()}})})})}function hse({filePath:e,oldString:t,newString:n,content:r}){const i=g.useMemo(()=>r!=null?r.split(/\r?\n/).map(s=>({type:"add",text:s})):fse(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:he("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 fse(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 pse({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(mse,{status:t.status}),h.jsx("span",{className:he("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 mse({status:e}){return e==="completed"?h.jsx(Qf,{className:"w-3.5 h-3.5 text-success mt-0.5 shrink-0"}):e==="in_progress"?h.jsx(In,{className:"w-3.5 h-3.5 text-warning mt-0.5 shrink-0 animate-spin"}):h.jsx(LT,{className:"w-3.5 h-3.5 text-text-400 mt-0.5 shrink-0"})}function gse(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 vse({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(Zf,{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 _se(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 xse={render:({input:e})=>Qe.createElement(pse,{items:gse(e)})},yse={render:({input:e})=>{const{description:t,prompt:n,subagentType:r}=_se(e);return Qe.createElement(vse,{description:t,prompt:n,subagentType:r})}},T5={render:({input:e,output:t,error:n,pending:r,fileScope:i,onShareFile:s,onOpenInTab:o,onPreviewMarkdown:a})=>{const l=wse(e),c=l?Qe.createElement(hse,{filePath:l.filePath,oldString:l.oldString,newString:l.newString,content:l.content}):void 0;return Qe.createElement(EM,{tool:bse(e),input:e,output:t,error:n,pending:r,expandedBody:c,...i?{fileScope:i}:{},...s?{onShareFile:s}:{},...o?{onOpenInTab:o}:{},...a?{onPreviewMarkdown:a}:{}})}};function bse(e){const t=e??{};return"content"in t&&t.content!==void 0?"Write":("old_string"in t&&t.old_string!==void 0,"Edit")}function wse(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}}pl.register("claude","TodoWrite",xse);pl.register("claude","Task",yse);pl.register("claude","Edit",T5);pl.register("claude","Write",T5);const P5=document.getElementById("root");if(!P5)throw new Error("guest-main: #root not found");const Sse=cL({});Cg.createRoot(P5).render(h.jsx(Qe.StrictMode,{children:h.jsx(dse,{host:Sse})}));
|
|
554
|
+
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},$re="DialogDescriptionWarning",Fre=({contentRef:e,descriptionId:t})=>{const r=`Warning: Missing \`Description\` or \`aria-describedby={undefined}\` for {${x5($re).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},Hre=o5,Ure=c5,y5=u5,b5=d5,w5=f5,S5=m5,Wre=v5;const s1=Hre,Vre=Ure,k5=g.forwardRef(({className:e,...t},n)=>h.jsx(y5,{ref:n,className:he("fixed inset-0 z-50 bg-black/50 backdrop-blur-sm",e),...t}));k5.displayName=y5.displayName;const Mp=g.forwardRef(({className:e,children:t,...n},r)=>h.jsxs(Vre,{children:[h.jsx(k5,{}),h.jsxs(b5,{ref:r,className:he("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(Wre,{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(Br,{className:"h-4 w-4"}),h.jsx("span",{className:"sr-only",children:"Close"})]})]})]}));Mp.displayName=b5.displayName;const Ap=({className:e,...t})=>h.jsx("div",{className:he("flex flex-col space-y-1.5 text-left",e),...t});Ap.displayName="DialogHeader";const o1=({className:e,...t})=>h.jsx("div",{className:he("flex flex-row justify-end gap-2",e),...t});o1.displayName="DialogFooter";const Lp=g.forwardRef(({className:e,...t},n)=>h.jsx(w5,{ref:n,className:he("text-lg font-semibold leading-none text-text-100",e),...t}));Lp.displayName=w5.displayName;const C5=g.forwardRef(({className:e,...t},n)=>h.jsx(S5,{ref:n,className:he("text-sm text-text-300",e),...t}));C5.displayName=S5.displayName;function qre({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(d$,{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(Br,{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(Az,{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(Rz,{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(Dx,{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(Ox,{className:"h-4 w-4"})}):null]})]}),h.jsx("hr",{className:"border-border"}),d?h.jsxs(h.Fragment,{children:[h.jsx(Yre,{...d}),h.jsx("hr",{className:"border-border"})]}):null,s?h.jsxs(h.Fragment,{children:[h.jsx(eie,{onLoad:s,...o?{onSave:o}:{},onDirtyChange:m,initialPersonality:l,readOnly:u}),h.jsx("hr",{className:"border-border"})]}):null,h.jsx(Zre,{settings:e.sandboxSettings??null}),h.jsx("hr",{className:"border-border"}),h.jsx(Qre,{skills:e.skills??[]}),h.jsx("hr",{className:"border-border"}),h.jsx(Jre,{plugins:e.plugins??[]})]})]})]}):null}function Kre({qrUrl:e,busy:t,onCancel:n}){const[r,i]=g.useState(null);return g.useEffect(()=>{let s=!1;return Ru.toDataURL(e,{width:240,margin:1}).then(o=>{s||i(o)}).catch(()=>{s||i(null)}),()=>{s=!0}},[e]),h.jsx(s1,{open:!0,onOpenChange:s=>s||n==null?void 0:n(),children:h.jsxs(Mp,{className:"max-w-xs","data-testid":"lark-bot-qr-dialog",onInteractOutside:s=>s.preventDefault(),onEscapeKeyDown:s=>s.preventDefault(),children:[h.jsx(Ap,{children:h.jsx(Lp,{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 Gre={expired:"二维码已过期,请重新扫码。",cancelled:"已取消。",access_denied:"你在飞书上取消了本次授权。",lark_protocol_error:"飞书返回了未预期的响应,请重试。",cloud_unreachable:"云端暂时不可达,请稍后重试。",internal_error:"关联失败。若飞书中已创建应用,可在开发者后台删除后重试,或改用手动绑定填入其凭证。"},Xre=new Set(["expired","access_denied","lark_protocol_error","cloud_unreachable","internal_error"]);function Yre({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=k=>{k&&(o(!0),l(null),k().catch(C=>l(C instanceof Error?C.message:String(C))).finally(()=>o(!1)))},b=()=>{m(null),v(t)},_=!s&&!!c&&!!d,x=()=>{!_||!r||v(()=>r({appId:c,appSecret:d}))},y=Su(x),w=h.jsxs("div",{className:"flex items-center gap-1.5",children:[h.jsx(Zf,{className:"h-3.5 w-3.5 text-text-400","aria-hidden":!0}),h.jsx("span",{className:"text-[13px] font-medium text-text-100",children:"飞书 Bot"})]});return e?h.jsxs("section",{className:"flex flex-col gap-1.5","data-testid":"lark-bot-section",children:[w,e.state==="unbound"||e.state==="provisioning"?h.jsxs(h.Fragment,{children:[h.jsx("span",{className:"text-[11px] text-text-400",children:"关联一个飞书 bot 后,这个 persona 就是它:拉进群后群成员 @ 它提问、或直接私聊它, 推理跑在你本机,回复自动发回去。"}),t?h.jsx("button",{type:"button",disabled:s||e.state==="provisioning",onClick:b,className:"self-start rounded border border-border bg-bg-200 px-3 py-1.5 text-[12px] font-medium text-text-100 hover:bg-bg-300 disabled:opacity-50","data-testid":"lark-bot-provision",children:e.state==="provisioning"?"等待扫码…":"扫码关联飞书 Bot"}):null,e.state==="unbound"&&e.errorReason&&!p?h.jsxs("div",{className:"flex flex-col gap-1.5 rounded border border-error bg-error-dim px-2 py-1.5","data-testid":"lark-bot-provision-error",children:[h.jsx("span",{className:"text-[11px] text-error",children:Gre[e.errorReason]}),h.jsxs("div",{className:"flex gap-1.5",children:[Xre.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(Kre,{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:k=>u(k.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:k=>f(k.target.value),...y,type:"password",placeholder:"App Secret",className:"rounded border border-border bg-bg-100 px-2 py-1 text-[12px] text-text-200","data-testid":"lark-bot-manual-secret"}),h.jsx("button",{type:"button",disabled:!_,onClick:x,className:"self-start rounded border border-border px-3 py-1.5 text-[12px] text-text-100 hover:bg-bg-200 disabled:opacity-50","data-testid":"lark-bot-manual-submit",children:s?"绑定中…":"绑定"})]})]}):null]}):null,e.state==="bound"||e.state==="broken"?h.jsxs("div",{className:"flex flex-col gap-1.5",children:[e.state==="broken"?h.jsxs("div",{className:"rounded border border-error bg-error-dim px-2 py-1.5 text-[11px] text-error","data-testid":"lark-bot-broken",children:["Bot 凭证失效:",e.brokenReason??"未知原因","。请解绑后重新填入有效凭证绑定。"]}):null,h.jsxs("div",{className:"flex items-center gap-2 text-[12px] text-text-200",children:[h.jsx("span",{className:"font-medium text-text-100",children:e.botName??"未命名 bot"}),e.appId?h.jsx("span",{className:"text-[11px] text-text-400",children:e.appId}):null]}),h.jsx("span",{className:"text-[11px] text-text-400",children:"把 bot 拉进任意飞书群,群成员 @ 它即可提问。"}),e.groups.length>0?h.jsx("ul",{className:"flex flex-col gap-0.5","data-testid":"lark-bot-groups",children:e.groups.map(k=>h.jsxs("li",{className:"text-[11px] text-text-300 truncate",children:["· ",k.chatName??k.chatId]},k.chatId))}):h.jsx("span",{className:"text-[11px] text-text-400","data-testid":"lark-bot-groups-empty",children:"还没有服务中的群。"}),i?h.jsx("button",{type:"button",disabled:s,onClick:()=>v(i),className:"self-start rounded border border-border px-3 py-1.5 text-[12px] text-error hover:bg-error-dim disabled:opacity-50","data-testid":"lark-bot-unbind",children:"解绑"}):null]}):null,a?h.jsx("div",{className:"rounded border border-error bg-error-dim px-2 py-1.5 text-[11px] text-error","data-testid":"lark-bot-error",children:a}):null]}):h.jsxs("section",{className:"flex flex-col gap-1.5","data-testid":"lark-bot-section",children:[w,h.jsx("span",{className:"text-[11px] text-text-400",children:"状态加载中…"})]})}function Zre({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(Rd,{label:"权限默认模式",value:((t=e.permissions)==null?void 0:t.defaultMode)??"—"}),h.jsx(Rd,{label:"沙箱启用",value:Sg((n=e.sandbox)==null?void 0:n.enabled)}),h.jsx(Rd,{label:"沙箱内自动放行 Bash",value:Sg((r=e.sandbox)==null?void 0:r.autoAllowBashIfSandboxed)}),h.jsx(Rd,{label:"允许非沙箱命令",value:Sg((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(Fl,{label:"沙箱外命令",paths:(s=e.sandbox)==null?void 0:s.excludedCommands}),h.jsx(Fl,{label:"允许读取",paths:(a=(o=e.sandbox)==null?void 0:o.filesystem)==null?void 0:a.allowRead}),h.jsx(Fl,{label:"拒绝读取",paths:(c=(l=e.sandbox)==null?void 0:l.filesystem)==null?void 0:c.denyRead}),h.jsx(Fl,{label:"允许写入",paths:(d=(u=e.sandbox)==null?void 0:u.filesystem)==null?void 0:d.allowWrite}),h.jsx(Fl,{label:"拒绝写入",paths:(p=(f=e.sandbox)==null?void 0:f.filesystem)==null?void 0:p.denyWrite})]})]})]})}function Sg(e){return e===!0?"是":e===!1?"否":"—"}function Rd({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 Fl({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 Qre({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 Jre({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 eie({onLoad:e,onSave:t,onDirtyChange:n,initialPersonality:r,readOnly:i=!1}){const s=r!==void 0,[o,a]=g.useState(s),[l,c]=g.useState(s?r:""),[u,d]=g.useState(s?r:""),[f,p]=g.useState(null),[m,v]=g.useState(!1),[b,_]=g.useState(null),x=Qe.useRef(e),y=Qe.useRef(t),w=Qe.useRef(n);Qe.useEffect(()=>{x.current=e,y.current=t,w.current=n});const k=Qe.useCallback(()=>{a(!1),p(null),x.current().then(P=>{c(P),d(P),a(!0)}).catch(P=>{p(P instanceof Error?P.message:String(P))})},[]);Qe.useEffect(()=>{s||k()},[s,k]);const C=!i&&o&&u!==l;Qe.useEffect(()=>{i||w.current(C)},[C,i]);const N=()=>{y.current&&(v(!0),_(null),y.current(u).then(()=>{c(u),v(!1)}).catch(P=>{_(P instanceof Error?P.message:String(P)),v(!1)}))},T=()=>{d(l),_(null)},B=Su(()=>{!C||m||N()},()=>{!C||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:k,className:"rounded-sm border border-error px-2 py-0.5 text-[11px] hover:bg-error/10",children:"重试"})]}):null,b?h.jsxs("div",{"data-testid":"persona-personality-save-error",className:"rounded-md border border-error bg-error-dim px-3 py-2 text-[12px] text-error",children:["保存失败:",b]}):null,h.jsx("textarea",{"data-testid":"persona-personality-textarea",value:u,onChange:P=>d(P.target.value),...B,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&&C?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 tie={state:"unbound",groups:[]};function nie(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(tie)}};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 rie(e,t="owner"){const{persona:n}=RT(e),r=LB(e),i=jB(),s=DB(),{httpBaseUrl:o}=Yf(),a=$i(),l=nie(t==="guest"?null:a,e),{capabilities:c}=Gy((n==null?void 0:n.tool)??"claude"),u=g.useMemo(()=>!(n!=null&&n.public)||!o||/^https?:\/\/(127\.0\.0\.1|localhost|0\.0\.0\.0|\[?::1\]?)([:/]|$)/i.test(o)?null:`${o}/s/${e}`,[n==null?void 0:n.public,o,e]),d=g.useCallback((y,w)=>{i(e,w).catch(k=>{Ae("persona",`${y} failed`,k)})},[i,e]),f=g.useCallback(y=>d("togglePublic",{public:y}),[d]),p=g.useCallback(y=>d("changeTool",{tool:y}),[d]),m=g.useCallback(y=>d("changeModel",{model:y}),[d]),v=g.useCallback(y=>d("changeEffort",{effort:y}),[d]),b=g.useCallback(()=>!n||!confirm(`删除 persona "${n.label}"?`)?!1:(s(e).catch(y=>{Ae("persona","delete failed",y)}),!0),[n,s,e]),_=g.useCallback(async()=>r.loaded?r.personality:(await r.refresh()).personality,[r]),x=g.useCallback(async y=>{await i(e,{personality:y}),await r.refresh()},[i,e,r]);return{persona:n,detail:r,models:(c==null?void 0:c.models)??[],configSchema:(c==null?void 0:c.configSchema)??[],larkBot:l,guestShareUrl:u,changeTool:p,changeModel:m,changeEffort:v,togglePublic:f,remove:b,loadPersonality:_,savePersonality:x}}function iie({personaId:e,open:t,onClose:n,api:r,embedded:i,onDirtyChange:s,onShareCapability:o,viewerRole:a="owner"}){const l=rie(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(qre,{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 sie(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 oie(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 a1(e,t,n,r,i){const s=await e.attachmentSignUrl({sessionId:n,relPath:r,...i!==void 0?{ttlSeconds:i}:{}});return oie(s.url,sie(t.url))}async function jC(e,t,n,r,i=60,s){const o=window.open("about:blank","_blank");try{s&&await s();const a=await a1(e,t,n,r,i);o?o.location.href=a:window.open(a,"_blank")}catch(a){throw o&&o.close(),a}}async function aie(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 lie={...So,h1:({node:e,...t})=>h.jsx("h1",{...t,className:"mt-4 mb-3 text-[18px] font-semibold leading-tight text-text-100"}),h2:({node:e,...t})=>h.jsx("h2",{...t,className:"mt-4 mb-2 text-[16px] font-semibold leading-tight text-text-100"}),h3:({node:e,...t})=>h.jsx("h3",{...t,className:"mt-3 mb-2 text-[14px] font-semibold leading-tight text-text-100"}),h4:({node:e,...t})=>h.jsx("h4",{...t,className:"mt-3 mb-1 text-[13px] font-semibold text-text-100"}),h5:({node:e,...t})=>h.jsx("h5",{...t,className:"mt-2 mb-1 text-[12px] font-semibold text-text-100"}),h6:({node:e,...t})=>h.jsx("h6",{...t,className:"mt-2 mb-1 text-[12px] font-semibold text-text-300"}),p:({node:e,...t})=>h.jsx("p",{...t,className:"my-2 leading-relaxed"}),ul:({node:e,...t})=>h.jsx("ul",{...t,className:"my-2 list-disc space-y-1 pl-5"}),ol:({node:e,...t})=>h.jsx("ol",{...t,className:"my-2 list-decimal space-y-1 pl-5"}),li:({node:e,...t})=>h.jsx("li",{...t,className:"leading-relaxed"}),blockquote:({node:e,...t})=>h.jsx("blockquote",{...t,className:"my-2 border-l-2 border-border pl-3 italic text-text-300"}),code:({node:e,className:t,children:n,...r})=>t?h.jsx("code",{...r,className:`${t} font-mono text-[12px]`,children:n}):h.jsx("code",{...r,className:"rounded bg-bg-50 px-1 py-0.5 font-mono text-[12px] text-text-100",children:n}),pre:({node:e,...t})=>h.jsx("pre",{...t,className:"my-2 overflow-auto rounded border border-border bg-bg-0 p-3 text-[12px] font-mono text-text-100"}),hr:({node:e,...t})=>h.jsx("hr",{...t,className:"my-3 border-border"}),table:({node:e,...t})=>h.jsx("table",{...t,className:"my-2 w-full border-collapse text-[12px]"}),thead:({node:e,...t})=>h.jsx("thead",{...t,className:"bg-bg-50"}),th:({node:e,...t})=>h.jsx("th",{...t,className:"border border-border px-2 py-1 text-left font-semibold"}),td:({node:e,...t})=>h.jsx("td",{...t,className:"border border-border px-2 py-1"}),strong:({node:e,...t})=>h.jsx("strong",{...t,className:"font-semibold text-text-100"}),em:({node:e,...t})=>h.jsx("em",{...t,className:"italic"})};function cie(e){const t=e.split("/");return t[t.length-1]||e}function E5({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:cie(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(Jc,{remarkPlugins:[tu],components:lie,children:i})}):null})]})}function uie({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(E5,{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(Bz,{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(Br,{className:"h-4 w-4"})})]})})}):null}function die({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 hie=6173,fie=6182;function pie({open:e,onOpenChange:t,projectName:n,currentPort:r,allUsedPorts:i,onUpdate:s}){const o=[];for(let v=hie;v<=fie;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(s1,{open:e,onOpenChange:t,children:h.jsxs(Mp,{className:"max-w-md",children:[h.jsxs(Ap,{children:[h.jsxs(Lp,{children:["改端口 · ",n]}),h.jsxs(C5,{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(o1,{children:[h.jsx(ii,{variant:"ghost",onClick:()=>t(!1),disabled:c,children:"取消"}),h.jsx(ii,{onClick:m,disabled:!p,children:c?"应用中…":"应用新端口"})]})]})})}const DC=[{stage:"build",label:"构建"},{stage:"deploy",label:"部署到阿里云"},{stage:"verify",label:"验证可访问性"}];function mie({currentStage:e,onCancel:t}){const n=DC.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:[DC.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(Qf,{className:"size-3.5"}):o?h.jsx(In,{className:"size-3.5 animate-spin"}):h.jsx(LT,{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 gie={build:"构建",deploy:"部署",verify:"验证"};function vie({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:["[",gie[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 _ie={build:"构建",deploy:"部署",verify:"验证",unknown:"未知"};function xie({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(As,{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:["[",_ie[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(Br,{className:"size-3.5"})})]})}const OC={"install-pending":{label:"等装依赖…",step:"1/3"},installing:{label:"安装依赖中…(可能要几十秒到几分钟)",step:"2/3"},"starting-dev-server":{label:"启动 dev server…(等监听端口才挂 iframe)",step:"3/3"}};function yie({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(Vc,{className:"size-3"}),"打开线上"]}):null,s,h.jsxs(ay,{children:[h.jsx(ly,{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(c$,{className:"size-3.5"})})}),h.jsxs(dp,{align:"end",children:[h.jsx(bi,{onSelect:()=>p(!0),children:"Update Port…"}),h.jsxs(bi,{disabled:!0,title:"rename not supported yet",onSelect:y=>y.preventDefault(),children:["Name: ",e.name]})]})]})]})]}),c?h.jsx(xie,{stage:c.stage,onClose:()=>u==null?void 0:u(),onFocusChat:()=>d==null?void 0:d()}):null,((_=e.publishJob)==null?void 0:_.status)==="in-flight"?h.jsx(mie,{currentStage:o??e.publishJob.stage,onCancel:()=>void(a==null?void 0:a())}):null,((x=e.publishJob)==null?void 0:x.status)==="interrupted"?h.jsx(vie,{stage:e.publishJob.stage,onRetry:()=>void(l==null?void 0:l()),onDismiss:()=>void(a==null?void 0:a())}):null,h.jsx("div",{className:"min-h-0 flex-1",children:m==="failed"?h.jsx(bie,{reason:e.stageReason}):m==="stopped"?null:m==="running"?v?h.jsx("iframe",{"data-testid":"preview-iframe",className:"size-full border-0 bg-white",src:v,title:"preview"}):h.jsx(BC,{label:"等 tunnel 起来…",step:"-"}):h.jsx(BC,{label:OC[m].label,step:OC[m].step})}),h.jsx(pie,{open:f,onOpenChange:p,projectName:e.name,currentPort:e.port,allUsedPorts:i,onUpdate:async y=>{await r(y)}})]})}function BC({label:e,step:t}){return h.jsxs("div",{"data-testid":"preview-spinner",className:"flex h-full w-full flex-col items-center justify-center gap-3 p-6 text-center",children:[h.jsx(In,{className:"size-6 animate-spin text-accent-main-100"}),h.jsx("div",{className:"text-[13px] text-text-200",children:e}),h.jsx("div",{className:"text-[11px] uppercase tracking-wider text-text-500",children:t}),h.jsx("div",{className:"mt-2 max-w-[300px] text-[11px] text-text-500",children:"左侧 chat 可看 assistant 详细进度"})]})}function bie({reason:e}){return h.jsxs("div",{"data-testid":"preview-failed",className:"flex h-full w-full flex-col items-center justify-center gap-3 p-6 text-center",children:[h.jsx(As,{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 wie({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(s1,{open:!!e,onOpenChange:s=>{s||(r(!1),t())},children:h.jsxs(Mp,{className:"max-w-lg",children:[h.jsx(Ap,{children:h.jsx(Lp,{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(o1,{children:[h.jsx(ii,{variant:"ghost",onClick:i,className:"gap-1.5",children:n?h.jsxs(h.Fragment,{children:[h.jsx(cl,{className:"size-3.5"}),"已复制"]}):h.jsxs(h.Fragment,{children:[h.jsx(Jf,{className:"size-3.5"}),"复制"]})}),h.jsx(ii,{onClick:t,children:"关闭"})]})]})})}function Sie(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 kie={codex:"on-request",claude:"bypassPermissions"};function Cie(e){const t={cwd:e.cwd,permissionMode:e.sourcePermissionMode??kie[e.sourceTool??"claude"]??"bypassPermissions",forkedFromSessionId:e.sourceSessionId};return e.sourceOwnerPersonaId&&(t.ownerPersonaId=e.sourceOwnerPersonaId),e.sourceTool&&(t.tool=e.sourceTool),t}async function Eie(e,t,n,r={}){if(!t.toolSessionId)return null;const i=await e.sessionCreate({...Cie({cwd:t.cwd,sourceSessionId:t.sessionId,sourcePermissionMode:t.permissionMode,sourceOwnerPersonaId:t.ownerPersonaId,sourceTool:t.tool}),...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 Nie(e,t,n){return Eie(e,t,n,{ephemeral:!0})}function Md(e){return e!=null&&e.ephemeral!==!1}async function Tie(e,t){return t.stillEphemeral?(await e.sessionUpdate(t.sessionId,{ephemeral:!1}),!0):!1}const Pie=300;function Iie(e){return e&&typeof e=="object"&&"value"in e?e.value:e}function Rie(e,t){const n=vx(),[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=Iie(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(()=>{})},Pie)},[n,e]);return g.useEffect(()=>()=>{s.current&&(clearTimeout(s.current),s.current=null)},[]),{initialSize:r??t,setSize:o,loading:r===null}}function Mie(){return{quickAsk:null,mds:[],active:null}}function Aie(e,t){return{...e,quickAsk:{sessionId:t.sessionId,ephemeral:!0},active:"quick-ask"}}function Lie(e,t){const n=e.mds.includes(t);return{...e,mds:n?e.mds:[...e.mds,t],active:{kind:"md",relPath:t}}}function jie(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 Die(e){return e.quickAsk?{...e,quickAsk:{...e.quickAsk,ephemeral:!1}}:e}function Oie(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 Bie(e,t){return{...e,active:t}}function zie(e,t){return e===null||t===null||e==="quick-ask"||t==="quick-ask"?e===t:e.relPath===t.relPath}function N5(e){return e.quickAsk!==null||e.mds.length>0}function $ie(e){return e.split("/").pop()||e}function Fie({state:e,api:t,onSwitchTab:n,onCloseQuickAsk:r,onCloseMd:i,loadMarkdown:s,quickAskSession:o,onPromoteQuickAsk:a}){if(!N5(e))return null;const l=[];e.quickAsk&&l.push({id:"quick-ask",label:"问一下",title:"问一下",icon:h.jsx(a0,{className:"w-3.5 h-3.5"})});for(const c of e.mds)l.push({id:{kind:"md",relPath:c},label:$ie(c),title:c,icon:h.jsx(Ro,{className:"w-3.5 h-3.5"})});return h.jsxs("div",{className:"flex flex-col h-full bg-bg-50/60 border-l border-border-strong",children:[h.jsx($A,{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=zie(e.active,c.id),d=c.id==="quick-ask"?"quick-ask":`md:${c.id.relPath}`;return h.jsxs(FA,{children:[h.jsx(HA,{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(Br,{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(Yy,{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(Gie,{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(E5,{relPath:c,loadMarkdown:s,showTitleBar:!1})},`md-body:${c}`)})]})]})}function Hie({state:e,extras:t}){const{api:n,session:r}=t,i=$i(),[s,o]=g.useState(Mie()),a=g.useRef(s);a.current=s;const l=g.useRef(!1),c=g.useCallback(async k=>{const C=a.current.quickAsk,N=await Nie(n,r,k);if(N){if(l.current){n.sessionDelete(N.sessionId).catch(()=>{});return}Md(C)&&n.sessionDelete(C.sessionId).catch(()=>{}),o(T=>Aie(T,{sessionId:N.sessionId}))}},[n,r]),u=g.useCallback(async k=>{const C=a.current.quickAsk,N=(C==null?void 0:C.sessionId)===k;try{await Tie(n,{sessionId:k,stillEphemeral:N&&Md(C)})&&o(B=>Die(B))}catch(T){Ae("quick-ask","promote failed",T)}},[n]),d=g.useCallback(k=>{o(C=>Lie(C,k))},[]),f=g.useCallback(k=>{o(C=>Bie(C,k))},[]),p=g.useCallback(()=>{const k=a.current.quickAsk;Md(k)&&n.sessionDelete(k.sessionId).catch(()=>{}),o(C=>jie(C))},[n]),m=g.useCallback(k=>{o(C=>Oie(C,k))},[]);g.useEffect(()=>()=>{l.current=!0;const k=a.current.quickAsk;Md(k)&&n.sessionDelete(k.sessionId).catch(()=>{})},[]);const v=ai("sessions")??[],b=s.quickAsk?v.find(k=>k.sessionId===s.quickAsk.sessionId)??{sessionId:s.quickAsk.sessionId,cwd:r.cwd,tool:r.tool}:null,_=g.useCallback(async k=>{const C=await a1(n,i,r.sessionId,k,60),N=await fetch(C);if(!N.ok)throw new Error(`fetch ${N.status} ${N.statusText}`);return N.text()},[n,i,r.sessionId]),x=h.jsx(l1,{state:e,extras:t,onQuickAskInternal:c,onPreviewMdInternal:d}),{initialSize:y,setSize:w}=Rie("chat-panel-right-slot-width",480);return h.jsxs(vy,{orientation:"horizontal",className:"flex-1 flex min-w-0 min-h-0",children:[h.jsx(Jh,{id:"chat",minSize:"400px",children:x}),N5(s)?h.jsxs(h.Fragment,{children:[h.jsx(pR,{className:"w-1 bg-text-100/10 hover:bg-text-100/25 transition-colors cursor-col-resize"}),h.jsx(Jh,{id:"right-slot",defaultSize:`${y}px`,minSize:"360px",maxSize:"800px",onResize:k=>w(k.inPixels),children:h.jsx(Fie,{state:s,api:n,onSwitchTab:f,onCloseQuickAsk:p,onCloseMd:m,loadMarkdown:_,quickAskSession:b,onPromoteQuickAsk:u})})]}):null]})}const Uie={implicitCloseOnUserText:!1,closeTrailing:!1},Wie={implicitCloseOnUserText:!1,closeTrailing:!0},Vie={implicitCloseOnUserText:!0,closeTrailing:!1},qie={implicitCloseOnUserText:!0,closeTrailing:!0};function Kie(e,t){return e==="codex"?t?Vie:qie:t?Uie:Wie}function Gie({session:e,api:t,onPromoteQuickAsk:n}){const r=IA(e.sessionId);return h.jsx(l1,{state:r,extras:{session:e,api:t,...n?{onPromoteQuickAsk:n}:{}}})}function Xie({extras:e}){const t=IA(e.session.sessionId);if(e.session.appBuilderProject){const n=h.jsx(l1,{state:t,extras:e});return h.jsx(Yie,{state:t,chat:n,extras:e})}return h.jsx(Hie,{state:t,extras:e})}function Yie({state:e,chat:t,extras:n}){var T;const r=ai("daemon-info"),i=$i(),s=n.api,o=n.session,a=o.appBuilderProject,[l,c]=g.useState(null),u=g.useCallback(()=>{s.appBuilderGetProject(o.sessionId).then(B=>c(B.project)).catch(()=>c(null))},[s,o.sessionId]);g.useEffect(()=>{u()},[u]);const[d,f]=g.useState([]),p=g.useCallback(()=>{s.appBuilderListProjects().then(B=>f(B.projects)).catch(()=>f([]))},[s]);g.useEffect(()=>{p()},[p]),g.useEffect(()=>i.on("appBuilder:project-updated",P=>{const j=P;j!=null&&j.project&&(j.project.name===a&&c(j.project),f(I=>{const R=I.findIndex(z=>z.name===j.project.name);if(R<0)return[...I,j.project];const L=I.slice();return L[R]=j.project,L}))}),[i,a]);const{host:m,scheme:v}=Sie(i.url,r==null?void 0:r.tunnelUrl),[b,_]=g.useState(void 0),[x,y]=g.useState(null);g.useEffect(()=>{const B=i.on("appBuilder:publish-progress",j=>{const I=j;!I||I.name!==a||I.status==="started"&&_(I.stage)}),P=i.on("appBuilder:publish-failed",j=>{const I=j;!I||I.name!==a||(_(void 0),y({stage:I.stage}))});return()=>{B(),P()}},[i,a]),g.useEffect(()=>{_(void 0),y(null)},[a]);const[w,k]=g.useState(null),C=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(B){k({title:"发布请求失败",message:(B==null?void 0:B.message)??String(B)})}},children:"发布上线"}),N=(l==null?void 0:l.stage)??(l!=null&&l.isRunning?"running":"stopped");return h.jsxs(h.Fragment,{children:[h.jsx(die,{left:t,stage:N,onExpand:async()=>{await s.appBuilderStartDevServer(o.sessionId)},onCollapse:async()=>{await s.appBuilderStopDevServer(o.sessionId)},right:h.jsx(yie,{project:l,previewHost:m,previewScheme:v,allUsedPorts:d.map(B=>B.port),onUpdatePort:async B=>{await s.appBuilderUpdateProjectPort(a,B),p()},publishSlot:C,publishInFlightStage:b,onDismissPublishJob:async()=>{try{await s.appBuilderDismissPublishJob(a)}catch(B){k({title:"取消发布失败",message:(B==null?void 0:B.message)??String(B)})}},onRetryPublish:async()=>{try{await s.appBuilderPublish(a)}catch(B){k({title:"重新发布失败",message:(B==null?void 0:B.message)??String(B)})}},publishFailureBanner:x,onPublishFailureBannerClose:()=>y(null),onPublishFailureBannerFocusChat:()=>{}})}),h.jsx(wie,{error:w,onClose:()=>k(null)})]})}function Zie({headerMeta:e,connState:t,liveWorktreeRoot:n,onOpenConfig:r,variant:i="full",ephemeral:s,onPromote:o,lines:a,pendingPermissions:l,procAlive:c,rewindableUserMessageIds:u,onPermissionRespond:d,onPermissionInterrupt:f,onRewind:p,onFork:m,onQuickAsk:v,topSlot:b,realtimeQuestionAnswers:_,onSubmitQuestion:x,onCancelQuestion:y,liveQuestionToolUseIds:w,api:k,cwd:C,tool:N,sessionKey:T,onSend:B,awaitingUser:P,onAbort:j,onNewSession:I,onClearSession:R,configSlot:L,chatRootRef:z,chatBodyRef:$,topSentinelRef:F,drawers:D,xtermSlot:O,fileSharingScope:E,onShareFile:H,onOpenInTab:V,onPreviewMarkdown:A,onOpenFilePath:ne}){return h.jsx(BZ,{children:h.jsxs("div",{ref:z,"data-cc-chat-root":"",className:"flex flex-col h-full bg-bg-100",children:[h.jsx(LQ,{meta:e,...N?{tool:N}:{},connState:t,variant:i,...n!==void 0?{liveWorktreeRoot:n}:{},...i==="full"&&r?{onOpenConfig:r}:{},...i==="quickask"?{ephemeral:s??!1,...o?{onPromote:o}:{}}:{}}),h.jsxs("div",{ref:$,"data-testid":"chat-body",className:"flex-1 overflow-y-auto min-h-0",style:{overflowAnchor:"none"},children:[F?h.jsx("div",{ref:F,"data-testid":"top-sentinel","aria-hidden":"true",style:{height:1}}):null,h.jsx(MM,{lines:a,...d?{onPermissionRespond:d}:{},...f&&c?{onPermissionInterrupt:f}:{},topSlot:b,...p?{onRewind:p}:{},rewindableUserMessageIds:u,...m?{onFork:m}:{},...v?{onQuickAsk:v}:{},realtimeQuestionAnswers:_,onSubmitQuestion:x,...y?{onCancelQuestion:y}:{},liveQuestionToolUseIds:w,...E?{fileSharingScope:E}:{},...H?{onShareFile:H}:{},...V?{onOpenInTab:V}:{},...A?{onPreviewMarkdown:A}:{},...ne?{onOpenFilePath:ne}:{},...i==="full"?{turnCollapse:Kie(N,c)}:{}})]}),O,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(MQ,{meta:e,...k?{api:k}:{},cwd:C,...N?{tool:N}:{},sessionKey:T,onSend:B,awaitingUser:P,...j?{onAbort:j}:{},...I?{onNewSession:I}:{},...R?{onClearSession:R}:{},...L?{configSlot:L}:{}}),D]})})}function l1({state:e,extras:t,onQuickAskInternal:n,onPreviewMdInternal:r}){const{session:i,api:s,liveGitBranch:o,liveWorktreeRoot:a,onNewSession:l,onTurnEnd:c,onOpenConfig:u,onFork:d,onQuickAsk:f,viewerRole:p,onPromoteQuickAsk:m,configSlot:v}=t,{capabilities:b}=Gy(i.tool||"claude"),_=(b==null?void 0:b.features)??ET(i.tool),[x,y]=g.useState(null),[w,k]=g.useState(null),C=Yf(),N=!!s&&C.actionsLevel==="owner"&&_.fileSharing,T=RT(i.ownerPersonaId??null).persona,B=(T==null?void 0:T.label)??null,P=!!B&&!!i.ownerPersonaId,j=g.useCallback((q,ae)=>{y({kind:q,text:ae}),setTimeout(()=>{y(fe=>(fe==null?void 0:fe.text)===ae?null:fe)},2e3)},[]),I=$i(),R=dB(),L=PA(i.sessionId,i.toolSessionId),{events:z,pendingQuestions:$,clearQuestion:F,markQuestionSubmitted:D,status:O}=L,E=e.historyLoading,H=BM(O);g.useEffect(()=>{Ae("chat-panel","sessionStatus",{sessionId:i.sessionId,sessionStatus:O,procAlive:H})},[O,H,i.sessionId]);const V=e.lines,A=e.pendingPermissions,ne=A[0]??null,oe=g.useMemo(()=>NU(z),[z]),[X,ye]=g.useState(null),[$e,ue]=g.useState(()=>new Set);kU(s,i.sessionId,i.toolSessionId,_.observe);const Ie=g.useRef(i.sessionId);g.useEffect(()=>{if(Ie.current=i.sessionId,!_.rewind){ye(null);return}let q=!1;return ye(null),(async()=>{try{const ae=await s.sessionRewindableMessageIds(i.sessionId);if(q)return;ye(new Set(ae.userMessageIds))}catch{q||ye(null)}})(),()=>{q=!0}},[s,i.sessionId,_.rewind]);const Re=g.useCallback(()=>{const q=i.sessionId;s.sessionRewindableMessageIds(q).then(ae=>{Ie.current===q&&ye(new Set(ae.userMessageIds))}).catch(()=>{})},[s,i.sessionId]),Ke=g.useMemo(()=>{if(X!==null){const qe=new Set(X);for(const kr of $e)qe.delete(kr);return qe}const q=new Set(["Edit","Write","MultiEdit","NotebookEdit"]),ae=new Set;let fe=null;for(const qe of V)qe.kind==="user-text"?fe=qe.uuid??null:fe&&qe.kind==="tool-call"&&q.has(qe.tool)&&!$e.has(fe)&&ae.add(fe);return ae},[V,$e,X]),_e=g.useRef(c);_e.current=c,CU(i.sessionId,i.toolSessionId,()=>{Xt(null),ue(new Set)});const Be=QQ({sessionStatus:O}),fn=g.useRef(null);g.useEffect(()=>{var fe;const q=fn.current,ae=(q==null?void 0:q.sid)===i.sessionId;ae&&q.phase===Be||(fn.current={sid:i.sessionId,phase:Be},Ae("session-phase",Be,{sid:i.sessionId,phase:Be,prev:ae?q.phase:null,desc:ZQ[Be]}),ae&&q.phase==="turn-running"&&Be!=="turn-running"&&((fe=_e.current)==null||fe.call(_e),Re()))},[Be,i.sessionId,Re]);const it=g.useCallback(()=>{s.sessionInterrupt(i.sessionId).catch(()=>{})},[s,i.sessionId]),[At,Xt]=g.useState(null),Lt=g.useCallback(q=>{Xt(q)},[]),[wt,Ze]=g.useState(!1),st=g.useCallback(()=>{s.sessionStop(i.sessionId).catch(()=>{}),Ze(!1)},[s,i.sessionId]);g.useCallback(q=>{s.pinSession(i.sessionId,q).catch(ae=>{Ae("chat-panel","pinSession failed",{err:ae==null?void 0:ae.message})})},[s,i.sessionId]);const St=m?"quickask":"full",{container:pn,onCollapse:sn}=zQ(),U=g.useRef(0),J=g.useRef(null);g.useEffect(()=>{const q=ae=>{if(ae.key!=="Escape")return;if(!H){U.current=0;return}if(ae.isComposing)return;const qe=ae.target;if(qe&&qe.closest("[data-cc-chat-root]")!==J.current)return;const kr=Date.now();kr-U.current<2e3?(U.current=0,Ze(!0)):(U.current=kr,it())};return window.addEventListener("keydown",q),()=>window.removeEventListener("keydown",q)},[it,H]);const ve=g.useRef(null),Ce=g.useRef(null),Fe=g.useRef(!0),ht=g.useRef(null),on=g.useRef(0),jt=g.useRef(0);g.useEffect(()=>{Fe.current=!0,ht.current=null,on.current=0,jt.current=0},[i.sessionId]),g.useEffect(()=>{k(null)},[i.sessionId]);const se=g.useRef(e);se.current=e;const K=g.useCallback(()=>{var fe;const q=ve.current;if(!q||ht.current!==null)return;const ae=se.current;ae.historyDone||ae.historyLoading||(ht.current={distFromBottom:q.scrollHeight-q.scrollTop},(fe=ae.loadMoreHistory)==null||fe.call(ae))},[]);g.useEffect(()=>{const q=ve.current,ae=Ce.current;if(!q||!ae)return;const fe=new IntersectionObserver(qe=>{for(const kr of qe)kr.isIntersecting&&K()},{root:q,threshold:0});return fe.observe(ae),()=>fe.disconnect()},[K]),g.useEffect(()=>{const q=ve.current;if(!q)return;const ae=150,fe=qe=>{Date.now()<jt.current&&(qe.preventDefault(),jt.current=Date.now()+ae)};return q.addEventListener("wheel",fe,{passive:!1}),()=>q.removeEventListener("wheel",fe)},[]),g.useEffect(()=>{const q=ve.current;if(!q)return;const ae=32,fe=()=>{const qe=q.scrollHeight-q.scrollTop-q.clientHeight;Fe.current=qe<=ae};return q.addEventListener("scroll",fe,{passive:!0}),()=>q.removeEventListener("scroll",fe)},[]),g.useLayoutEffect(()=>{const q=ve.current;if(!q)return;const ae=on.current,fe=V.length;on.current=fe;const qe=ht.current;if(qe!==null&&fe>ae){ht.current=null,q.scrollTop=q.scrollHeight-qe.distFromBottom,jt.current=Date.now()+200;return}qe!==null&&(ht.current={distFromBottom:q.scrollHeight-q.scrollTop}),Fe.current&&(q.scrollTop=q.scrollHeight)},[V,ne==null?void 0:ne.requestId]);const we=g.useMemo(()=>{const q={};for(const[ae,fe]of Object.entries($))fe.submittedAnswers&&(q[ae]=fe.submittedAnswers);return q},[$]),ft=g.useMemo(()=>new Set(Object.keys($)),[$]),an=g.useCallback(async(q,ae)=>{try{await s.answerQuestion({sessionId:i.sessionId,toolUseId:q,answers:ae}),D(q,ae)}catch{}},[s,i.sessionId,D]),vl=g.useCallback(async q=>{try{await s.cancelQuestion({sessionId:i.sessionId,toolUseId:q}),F(q)}catch{}},[s,i.sessionId,F]),_l=g.useCallback(async(q,ae)=>{var fe;if(ne)try{await((fe=e.respondPermission)==null?void 0:fe.call(e,ne.requestId,q?"allow":"deny"))}catch{}},[e,ne]),xl=g.useCallback(async()=>{const q=i.sessionId;try{await s.sessionStop(q)}catch{}e.clearSession?await e.clearSession():await s.sessionNew(q)},[e,s,i.sessionId]),jp=g.useMemo(()=>E&&V.length===0?h.jsx("div",{className:"flex justify-center py-4","data-testid":"history-loading",children:h.jsx(In,{className:"w-4 h-4 text-text-400 animate-spin"})}):e.historyDone?null:h.jsx("div",{className:"flex justify-center py-2",children:h.jsx("button",{type:"button",onClick:()=>{var q;return void((q=e.loadMoreHistory)==null?void 0:q.call(e))},disabled:E,"data-testid":"history-load-more",className:"text-[12px] text-text-400 hover:text-text-200 cursor-pointer px-3 py-1 rounded-md border border-bg-300 hover:bg-bg-100 transition-colors disabled:opacity-60",children:E?"加载中…":"Load earlier messages"})}),[E,V.length,e.historyDone,e.loadMoreHistory]),Au=e.meta,Dp=h.jsxs(h.Fragment,{children:[i.toolSessionId&&_.subagents?h.jsx(WQ,{api:s,cwd:i.cwd,toolSessionId:i.toolSessionId}):null,At&&_.rewind?h.jsx(qQ,{open:!0,onOpenChange:q=>{q||Xt(null)},api:s,sessionId:i.sessionId,userMessageId:At,lines:V,procAlive:H,onNoChanges:q=>{ue(ae=>{if(ae.has(q))return ae;const fe=new Set(ae);return fe.add(q),fe})}}):null,wt?h.jsx(Qie,{onConfirm:st,onCancel:()=>Ze(!1)}):null]}),yl={kind:"session",sessionId:i.sessionId},Bs=g.useCallback(async q=>{if(s)try{await jC(s,I,i.sessionId,q)}catch(ae){const fe=ae.message;Ae("chat-panel","open-in-tab failed",{err:fe}),j("err",`Open in tab 失败:${fe}`)}},[s,I,i.sessionId,j]),[zo,$o]=g.useState(!1),[zs,qi]=g.useState(null),Sr=g.useCallback(q=>{if(r){r(q);return}qi(q),$o(!0)},[r]),Lu=g.useCallback(q=>{if(!s)return;const ae=async()=>{try{await s.attachmentGroupAdd(i.sessionId,q)}catch(qe){Ae("chat-panel","file-link groupAdd skipped",{err:qe.message})}},fe=qe=>{const kr=qe.message;Ae("chat-panel","file-link open failed",{err:kr}),j("err",`打开文件失败:${kr}`)};if(xp(q)){ae().then(()=>Sr(q),fe);return}jC(s,I,i.sessionId,q,60,ae).catch(fe)},[s,I,i.sessionId,Sr,j]),Op=g.useCallback(async q=>{if(!s)throw new Error("daemon api not ready");const ae=await a1(s,I,i.sessionId,q,60),fe=await fetch(ae);if(!fe.ok)throw new Error(`fetch ${fe.status} ${fe.statusText}`);return await fe.text()},[s,I,i.sessionId]),It=g.useCallback(async(q,ae)=>{if(s)try{const{url:fe}=await s.attachmentSignUrl({sessionId:i.sessionId,relPath:q,ttlSeconds:86400,...ae?{view:ae}:{}}),qe=await aie(fe);j(qe?"ok":"err",qe?"分享链接已复制到剪贴板(24h 有效)":"复制失败:请手动复制")}catch(fe){const qe=fe.message;Ae("chat-panel","share-file failed",{err:qe}),j("err",`生成分享链接失败:${qe}`)}},[s,i.sessionId,j]),$s=g.useCallback(()=>k(null),[]),Bp=w==="files"&&N&&s?{title:"Edited Files",onBack:$s,content:h.jsx($ne,{api:s,scope:yl,sessionId:i.sessionId,onShareFile:It,onOpenInTab:Bs,onPreviewMarkdown:Sr})}:w==="cron"?{title:`定时任务${oe.length?` (${oe.length})`:""}`,onBack:$s,content:h.jsx("div",{className:"p-3",children:h.jsx(YQ,{jobs:oe})})}:w==="persona"&&P&&s&&i.ownerPersonaId?{title:`Persona · ${B??""}`,onBack:$s,content:h.jsx(iie,{personaId:i.ownerPersonaId,open:!0,onClose:$s,api:s,embedded:!0,...p?{viewerRole:p}:{}},i.ownerPersonaId)}:null,kt=St==="full"?h.jsx(OQ,{session:i,meta:Au,...o!==void 0?{liveGitBranch:o}:{},...a!==void 0?{liveWorktreeRoot:a}:{},...P?{personaName:B}:{},...P?{onOpenPersona:()=>k("persona")}:{},...N?{onOpenFiles:()=>k("files")}:{},cronActiveCount:oe.length,onCronClick:()=>k("cron"),onForceStop:()=>Ze(!0),...p?{viewerRole:p}:{},...b!=null&&b.toolSessionIdLabel?{toolSessionIdLabel:b.toolSessionIdLabel}:{},drill:Bp,...sn?{onCollapse:sn}:{}}):null;return h.jsxs(h.Fragment,{children:[pn&&kt?Ja.createPortal(kt,pn):null,h.jsx(Zie,{headerMeta:Au,connState:e.connState,...a!==void 0?{liveWorktreeRoot:a}:{},...u?{onOpenConfig:u}:{},variant:St,...St==="quickask"?{ephemeral:i.ephemeral!==!1,onPromote:()=>void(m==null?void 0:m(i.sessionId))}:{},lines:V,pendingPermissions:A,procAlive:H,rewindableUserMessageIds:Ke,onPermissionRespond:_l,onPermissionInterrupt:it,onRewind:_.rewind?Lt:void 0,...d&&_.fork?{onFork:d}:{},...n&&_.fork?{onQuickAsk:n}:f&&_.fork?{onQuickAsk:f}:{},topSlot:jp,realtimeQuestionAnswers:we,onSubmitQuestion:an,onCancelQuestion:vl,liveQuestionToolUseIds:ft,api:s,cwd:i.cwd,...i.tool?{tool:i.tool}:{},sessionKey:i.sessionId,onSend:e.sendText,awaitingUser:A.length>0||Object.values($).some(q=>!q.submittedAnswers),onAbort:it,...l?{onNewSession:l}:{},onClearSession:xl,...v?{configSlot:v}:{},chatRootRef:J,chatBodyRef:ve,topSentinelRef:Ce,drawers:Dp,xtermSlot:R==="tui"&&H&&_.tui?h.jsx(hne,{sessionId:i.sessionId,client:I},i.sessionId):null,fileSharingScope:yl,...s?{onShareFile:It}:{},...s?{onOpenInTab:Bs}:{},...s?{onPreviewMarkdown:Sr}:{},...s?{onOpenFilePath:Lu}:{}}),s?h.jsx(uie,{open:zo,onOpenChange:$o,relPath:zs,loadMarkdown:Op,onShare:zs?()=>void It(zs,"md-rendered"):void 0}):null,x?h.jsx("div",{"data-testid":"share-toast",role:"status","aria-live":"polite",className:x.kind==="ok"?"fixed left-1/2 top-4 z-50 -translate-x-1/2 rounded-md border border-emerald-500/40 bg-emerald-500/10 px-3 py-2 text-[12px] text-emerald-700 shadow-md dark:text-emerald-300":"fixed left-1/2 top-4 z-50 -translate-x-1/2 rounded-md border border-destructive/40 bg-destructive/10 px-3 py-2 text-[12px] text-destructive shadow-md",children:x.text}):null]})}function Qie({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 Jie(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 ese(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 tse(e,t){var m,v,b,_;const{models:n,modes:r,configSchema:i}=t,s=e.resolvedModel??e.model,o=Jie(s,n,i),a=o.options,l=a.some(x=>x.value===e.effort)?e.effort:o.defaultValue,c=e.effort===""&&e.resolvedEffort?((m=a.find(x=>x.value===e.resolvedEffort))==null?void 0:m.label)??e.resolvedEffort:((v=a.find(x=>x.value===l))==null?void 0:v.label)??null,u=((b=i.find(x=>x.name==="permissionMode"))==null?void 0:b.default)??"",d=r.some(x=>x.id===e.permissionMode)?e.permissionMode:u,p=d===u?null:((_=r.find(x=>x.id===d))==null?void 0:_.label)??null;return{modelLabel:ese(n,s),effortOptions:a,effortValue:l,effortLabel:c,modeValue:d,modeLabel:p,modeTone:p===null?null:d==="bypassPermissions"?"danger":"info"}}function nse({models:e=[],modes:t=[],configSchema:n=[],model:r,resolvedModel:i,resolvedEffort:s,effort:o,permissionMode:a,onPatch:l}){var p;const c=tse({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(ay,{children:[h.jsx(ly,{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:he("font-semibold",c.modeTone==="danger"?"text-red-400":"text-blue-400"),children:c.modeLabel})]}):null]})}),h.jsxs(dp,{side:"top",align:"end",className:"w-[230px]","data-testid":"session-config-menu",children:[h.jsx(kg,{testid:"session-config-model",label:"Model",current:r,currentLabel:c.modelLabel,options:d,onSelect:m=>l({model:m})}),h.jsx(kg,{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(kg,{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 kg({testid:e,label:t,current:n,currentLabel:r,currentTone:i,options:s,onSelect:o}){const a=s.length===0;return h.jsxs(EH,{children:[h.jsxs(qI,{"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:he("truncate max-w-[100px]",i==="danger"?"text-red-400 font-semibold":i==="info"?"text-blue-400 font-semibold":"text-text-400"),children:r}),h.jsx(Un,{className:"w-3.5 h-3.5 shrink-0 text-text-500"})]}),h.jsx(KI,{className:"w-[220px] max-h-[320px] overflow-y-auto",children:s.map(l=>{const c=l.value===n;return h.jsxs(bi,{"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:he("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(cl,{className:"w-3.5 h-3.5 shrink-0 text-accent mt-0.5"}):null]},l.value||"default")})})]})}function rse(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 ise(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 sse({api:e,session:t,focused:n,totalPanes:r,onFocus:i,onClose:s,onNewSession:o,onOpenConfig:a,onFork:l,onQuickAsk:c,className:u,viewerRole:d="owner"}){const{capabilities:f}=Gy(t.tool),[p,m]=g.useState(0),{branch:v}=rse(e,t.cwd,p),{worktreeRoot:b}=ise(e,t.cwd,p),_=r>1,x=y=>{e.sessionUpdate(t.sessionId,y).catch(w=>{console.error("[session-config] session:update failed",t.sessionId,w)})};return h.jsxs("div",{className:`group/pane relative flex-1 ${u??"flex"} flex-row min-w-0 min-h-0 overflow-hidden ${_?`rounded-md border transition-colors ${n?"border-accent ring-1 ring-accent":"border-border"}`:""}`,onMouseDown:i,"data-testid":`session-pane-${t.sessionId}`,children:[h.jsx(vy,{orientation:"horizontal",className:"flex-1 flex min-w-0 min-h-0",children:h.jsx(Jh,{id:"chat",minSize:"400px",children:h.jsx("div",{className:"flex flex-col min-w-0 min-h-0 h-full",children:h.jsx(ose,{api:e,session:t,liveGitBranch:v,liveWorktreeRoot:b,onNewSession:o,onTurnEnd:()=>m(y=>y+1),onOpenConfig:a,onFork:l,onQuickAsk:c,viewerRole:d,configSlot:f?h.jsx(nse,{models:f.models,modes:f.permissionModes,configSchema:f.configSchema,model:t.model??"",...t.resolvedModel?{resolvedModel:t.resolvedModel}:{},...t.resolvedEffort?{resolvedEffort:t.resolvedEffort}:{},effort:t.effort??"",permissionMode:t.permissionMode??"",onPatch:x}):null})})})}),_&&h.jsx("button",{type:"button",onClick:y=>{y.stopPropagation(),s()},className:"absolute top-1.5 right-1.5 z-10 p-1 rounded-md bg-bg-100/80 backdrop-blur-sm border border-border opacity-0 group-hover/pane:opacity-100 transition-opacity text-text-400 hover:text-text-100 hover:bg-bg-200","aria-label":"close pane","data-testid":`session-pane-close-${t.sessionId}`,children:h.jsx(Br,{className:"w-3.5 h-3.5"})})]})}function ose({api:e,session:t,liveGitBranch:n,liveWorktreeRoot:r,onNewSession:i,onTurnEnd:s,onOpenConfig:o,onFork:a,onQuickAsk:l,viewerRole:c,configSlot:u}){return h.jsx(Xie,{extras:{session:t,api:e,...n!==void 0?{liveGitBranch:n}:{},...r!==void 0?{liveWorktreeRoot:r}:{},onNewSession:i,onTurnEnd:s,onOpenConfig:o,...a?{onFork:d=>{a(d)}}:{},...l?{onQuickAsk:d=>{l(d)}}:{},...c?{viewerRole:c}:{},...u?{configSlot:u}:{}}})}function ase({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(HH,{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(sse,{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 lse(){const e=$i(),t=g.useMemo(()=>new Ax(e),[e]),n=MB(e),{sessions:r,refresh:i}=AB(n),{personas:s}=IT(),o=zB(),a=g.useMemo(()=>{const w=window.location.pathname.match(/^\/s\/([^/]+)/);return w?decodeURIComponent(w[1]):null},[]),l=g.useMemo(()=>r.filter(w=>!w.ephemeral&&w.larkChatId==null),[r]),c=g.useMemo(()=>a?s.filter(w=>w.personaId===a):s,[s,a]),[u,d]=g.useState(null),[f,p]=g.useState(null),[m,v]=g.useState(null);g.useEffect(()=>{let w=!1;return e.request("whoami",{}).then(k=>{w||d(k.capability.id)}).catch(()=>{}),()=>{w=!0}},[e]),g.useEffect(()=>{a&&p(a)},[a]);const b=g.useCallback(async(w,k)=>{const C=await t.sessionCreate({ownerPersonaId:w,...k.trim()?{label:k.trim()}:{}});await i(),p(w),v(C.sessionId)},[t,i]),_=g.useCallback(async w=>{await t.sessionDelete(w),await i(),v(k=>k===w?null:k)},[t,i]),x=g.useCallback(async(w,k)=>{await t.sessionUpdate(w,{label:k.label}),await i()},[t,i]),y=g.useMemo(()=>l.find(w=>w.sessionId===m)??null,[l,m]);return h.jsx(Lx.Provider,{value:o,children:h.jsx(ase,{personas:c,sessions:l,api:t,selfPrincipalId:u,selectedPersonaId:f,selectedSessionId:m,selectedSession:y,onSelectPersona:p,onSelectSession:v,onCreateSession:(w,k)=>void b(w,k),onDeleteSession:w=>void _(w),onEditSession:(w,k)=>void x(w,k),onCloseSession:()=>v(null)})})}const zC="https://app.ttcadvisory.com";function cse({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=`${zC}/auth/authorize?callback_url=${encodeURIComponent(a)}&auto=1`,c=async d=>{if(d.origin!==zC)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 w_="clawd-visitor:token";function use(e,t){const r=`${e.protocol==="https:"?"wss:":"ws:"}//${e.host}`;return t!=null&&t.devPath?`${r}${t.devPath}`:r}function dse(){return{async getUrl(e){const t=localStorage.getItem(w_);if(!t)throw new Error("NO_VISITOR_TOKEN");const n=use(window.location,{});return await bT(e).upsert({id:"guest",name:"访客",mode:"remote",url:n,token:t}),{url:n}}}}function hse(e){const t=n=>{document.documentElement.classList.toggle("dark",n==="dark")};return t(e.theme.mode),e.onThemeChange(n=>t(n.mode))}function fse(){const e=$i(),t=g.useMemo(()=>RB(e),[e]);return h.jsx(hB,{cache:t.cache,children:h.jsx(mB,{children:h.jsx(lse,{})})})}function pse({host:e}){const[t]=g.useState(()=>localStorage.getItem(w_)),[n,r]=g.useState(!1),[i,s]=g.useState(null);return g.useEffect(()=>hse(e),[e]),g.useEffect(()=>{if(!t)return;let o=!1;return dse().getUrl(e).then(()=>{o||r(!0)}).catch(a=>{o||s(a instanceof Error?a.message:String(a))}),()=>{o=!0}},[e,t]),t?h.jsx(Cb,{host:e,children:h.jsx(iw,{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(uB,{host:e,children:h.jsx(fse,{})}):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(Cb,{host:e,children:h.jsx(iw,{children:h.jsx(cse,{onAuthed:o=>{localStorage.setItem(w_,o),window.location.reload()}})})})}function mse({filePath:e,oldString:t,newString:n,content:r}){const i=g.useMemo(()=>r!=null?r.split(/\r?\n/).map(s=>({type:"add",text:s})):gse(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:he("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 gse(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 vse({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(_se,{status:t.status}),h.jsx("span",{className:he("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 _se({status:e}){return e==="completed"?h.jsx(Qf,{className:"w-3.5 h-3.5 text-success mt-0.5 shrink-0"}):e==="in_progress"?h.jsx(In,{className:"w-3.5 h-3.5 text-warning mt-0.5 shrink-0 animate-spin"}):h.jsx(LT,{className:"w-3.5 h-3.5 text-text-400 mt-0.5 shrink-0"})}function xse(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 yse({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(Zf,{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 bse(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 wse={render:({input:e})=>Qe.createElement(vse,{items:xse(e)})},Sse={render:({input:e})=>{const{description:t,prompt:n,subagentType:r}=bse(e);return Qe.createElement(yse,{description:t,prompt:n,subagentType:r})}},T5={render:({input:e,output:t,error:n,pending:r,fileScope:i,onShareFile:s,onOpenInTab:o,onPreviewMarkdown:a})=>{const l=Cse(e),c=l?Qe.createElement(mse,{filePath:l.filePath,oldString:l.oldString,newString:l.newString,content:l.content}):void 0;return Qe.createElement(EM,{tool:kse(e),input:e,output:t,error:n,pending:r,expandedBody:c,...i?{fileScope:i}:{},...s?{onShareFile:s}:{},...o?{onOpenInTab:o}:{},...a?{onPreviewMarkdown:a}:{}})}};function kse(e){const t=e??{};return"content"in t&&t.content!==void 0?"Write":("old_string"in t&&t.old_string!==void 0,"Edit")}function Cse(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}}pl.register("claude","TodoWrite",wse);pl.register("claude","Task",Sse);pl.register("claude","Edit",T5);pl.register("claude","Write",T5);const P5=document.getElementById("root");if(!P5)throw new Error("guest-main: #root not found");const Ese=cL({});Cg.createRoot(P5).render(h.jsx(Qe.StrictMode,{children:h.jsx(pse,{host:Ese})}));
|