@gencode/console 0.0.9 → 0.0.10

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.
@@ -138,4 +138,4 @@ Error generating stack: `+o.message+`
138
138
  * This source code is licensed under the ISC license.
139
139
  * See the LICENSE file in the root directory of this source tree.
140
140
  */const ei=Qe("Zap",[["path",{d:"M4 14a1 1 0 0 1-.78-1.63l9.9-10.2a.5.5 0 0 1 .86.46l-1.92 6.02A1 1 0 0 0 13 10h7a1 1 0 0 1 .78 1.63l-9.9 10.2a.5.5 0 0 1-.86-.46l1.92-6.02A1 1 0 0 0 11 14z",key:"1xq2db"}]]);function ip(s,u={}){const[i,c]=q.useState(!1),[p,d]=q.useState(null),w=q.useRef(null),C=q.useRef(),E=q.useRef(u);q.useEffect(()=>{E.current=u},[u]);const I=q.useCallback(()=>{var Q;if(((Q=w.current)==null?void 0:Q.readyState)!==WebSocket.OPEN)try{console.log("WebSocket connecting to:",s);const K=new WebSocket(s);w.current=K,K.onopen=()=>{var B,O;console.log("WebSocket connected"),c(!0),d(null),(O=(B=E.current).onOpen)==null||O.call(B)},K.onmessage=B=>{var O,F;try{const re=JSON.parse(B.data);(F=(O=E.current).onMessage)==null||F.call(O,re)}catch(re){console.error("Failed to parse WebSocket message:",re)}},K.onerror=B=>{var O,F;console.error("WebSocket error:",B),d(B),(F=(O=E.current).onError)==null||F.call(O,B)},K.onclose=B=>{var O,F;console.log("WebSocket closed:",B.code,B.reason),c(!1),w.current=null,(F=(O=E.current).onClose)==null||F.call(O),C.current=setTimeout(()=>{console.log("WebSocket attempting to reconnect..."),I()},3e3)}}catch(K){console.error("Failed to create WebSocket:",K),d(K)}},[s]),z=q.useCallback(()=>{C.current&&clearTimeout(C.current),w.current&&(w.current.close(),w.current=null),c(!1)},[]),A=q.useCallback(Q=>{var K;((K=w.current)==null?void 0:K.readyState)===WebSocket.OPEN?(console.log("WebSocket sending:",Q),w.current.send(JSON.stringify(Q))):console.warn("WebSocket is not connected, cannot send message:",Q)},[]);return q.useEffect(()=>(I(),()=>{z()}),[I,z]),{isConnected:i,error:p,send:A,connect:I,disconnect:z}}const zc=6048e5,up=864e5,xc=Symbol.for("constructDateFrom");function ln(s,u){return typeof s=="function"?s(u):s&&typeof s=="object"&&xc in s?s[xc](u):s instanceof Date?new s.constructor(u):new Date(u)}function wt(s,u){return ln(u||s,s)}let ap={};function Zl(){return ap}function br(s,u){var C,E,I,z;const i=Zl(),c=(u==null?void 0:u.weekStartsOn)??((E=(C=u==null?void 0:u.locale)==null?void 0:C.options)==null?void 0:E.weekStartsOn)??i.weekStartsOn??((z=(I=i.locale)==null?void 0:I.options)==null?void 0:z.weekStartsOn)??0,p=wt(s,u==null?void 0:u.in),d=p.getDay(),w=(d<c?7:0)+d-c;return p.setDate(p.getDate()-w),p.setHours(0,0,0,0),p}function Jl(s,u){return br(s,{...u,weekStartsOn:1})}function Rc(s,u){const i=wt(s,u==null?void 0:u.in),c=i.getFullYear(),p=ln(i,0);p.setFullYear(c+1,0,4),p.setHours(0,0,0,0);const d=Jl(p),w=ln(i,0);w.setFullYear(c,0,4),w.setHours(0,0,0,0);const C=Jl(w);return i.getTime()>=d.getTime()?c+1:i.getTime()>=C.getTime()?c:c-1}function wc(s){const u=wt(s),i=new Date(Date.UTC(u.getFullYear(),u.getMonth(),u.getDate(),u.getHours(),u.getMinutes(),u.getSeconds(),u.getMilliseconds()));return i.setUTCFullYear(u.getFullYear()),+s-+i}function cp(s,...u){const i=ln.bind(null,u.find(c=>typeof c=="object"));return u.map(i)}function kc(s,u){const i=wt(s,u==null?void 0:u.in);return i.setHours(0,0,0,0),i}function dp(s,u,i){const[c,p]=cp(i==null?void 0:i.in,s,u),d=kc(c),w=kc(p),C=+d-wc(d),E=+w-wc(w);return Math.round((C-E)/up)}function fp(s,u){const i=Rc(s,u),c=ln(s,0);return c.setFullYear(i,0,4),c.setHours(0,0,0,0),Jl(c)}function pp(s){return s instanceof Date||typeof s=="object"&&Object.prototype.toString.call(s)==="[object Date]"}function mp(s){return!(!pp(s)&&typeof s!="number"||isNaN(+wt(s)))}function hp(s,u){const i=wt(s,u==null?void 0:u.in);return i.setFullYear(i.getFullYear(),0,1),i.setHours(0,0,0,0),i}const gp={lessThanXSeconds:{one:"less than a second",other:"less than {{count}} seconds"},xSeconds:{one:"1 second",other:"{{count}} seconds"},halfAMinute:"half a minute",lessThanXMinutes:{one:"less than a minute",other:"less than {{count}} minutes"},xMinutes:{one:"1 minute",other:"{{count}} minutes"},aboutXHours:{one:"about 1 hour",other:"about {{count}} hours"},xHours:{one:"1 hour",other:"{{count}} hours"},xDays:{one:"1 day",other:"{{count}} days"},aboutXWeeks:{one:"about 1 week",other:"about {{count}} weeks"},xWeeks:{one:"1 week",other:"{{count}} weeks"},aboutXMonths:{one:"about 1 month",other:"about {{count}} months"},xMonths:{one:"1 month",other:"{{count}} months"},aboutXYears:{one:"about 1 year",other:"about {{count}} years"},xYears:{one:"1 year",other:"{{count}} years"},overXYears:{one:"over 1 year",other:"over {{count}} years"},almostXYears:{one:"almost 1 year",other:"almost {{count}} years"}},yp=(s,u,i)=>{let c;const p=gp[s];return typeof p=="string"?c=p:u===1?c=p.one:c=p.other.replace("{{count}}",u.toString()),i!=null&&i.addSuffix?i.comparison&&i.comparison>0?"in "+c:c+" ago":c};function ti(s){return(u={})=>{const i=u.width?String(u.width):s.defaultWidth;return s.formats[i]||s.formats[s.defaultWidth]}}const vp={full:"EEEE, MMMM do, y",long:"MMMM do, y",medium:"MMM d, y",short:"MM/dd/yyyy"},xp={full:"h:mm:ss a zzzz",long:"h:mm:ss a z",medium:"h:mm:ss a",short:"h:mm a"},wp={full:"{{date}} 'at' {{time}}",long:"{{date}} 'at' {{time}}",medium:"{{date}}, {{time}}",short:"{{date}}, {{time}}"},kp={date:ti({formats:vp,defaultWidth:"full"}),time:ti({formats:xp,defaultWidth:"full"}),dateTime:ti({formats:wp,defaultWidth:"full"})},Sp={lastWeek:"'last' eeee 'at' p",yesterday:"'yesterday at' p",today:"'today at' p",tomorrow:"'tomorrow at' p",nextWeek:"eeee 'at' p",other:"P"},Cp=(s,u,i,c)=>Sp[s];function Lr(s){return(u,i)=>{const c=i!=null&&i.context?String(i.context):"standalone";let p;if(c==="formatting"&&s.formattingValues){const w=s.defaultFormattingWidth||s.defaultWidth,C=i!=null&&i.width?String(i.width):w;p=s.formattingValues[C]||s.formattingValues[w]}else{const w=s.defaultWidth,C=i!=null&&i.width?String(i.width):s.defaultWidth;p=s.values[C]||s.values[w]}const d=s.argumentCallback?s.argumentCallback(u):u;return p[d]}}const Np={narrow:["B","A"],abbreviated:["BC","AD"],wide:["Before Christ","Anno Domini"]},Ep={narrow:["1","2","3","4"],abbreviated:["Q1","Q2","Q3","Q4"],wide:["1st quarter","2nd quarter","3rd quarter","4th quarter"]},_p={narrow:["J","F","M","A","M","J","J","A","S","O","N","D"],abbreviated:["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],wide:["January","February","March","April","May","June","July","August","September","October","November","December"]},jp={narrow:["S","M","T","W","T","F","S"],short:["Su","Mo","Tu","We","Th","Fr","Sa"],abbreviated:["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],wide:["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"]},Pp={narrow:{am:"a",pm:"p",midnight:"mi",noon:"n",morning:"morning",afternoon:"afternoon",evening:"evening",night:"night"},abbreviated:{am:"AM",pm:"PM",midnight:"midnight",noon:"noon",morning:"morning",afternoon:"afternoon",evening:"evening",night:"night"},wide:{am:"a.m.",pm:"p.m.",midnight:"midnight",noon:"noon",morning:"morning",afternoon:"afternoon",evening:"evening",night:"night"}},Ip={narrow:{am:"a",pm:"p",midnight:"mi",noon:"n",morning:"in the morning",afternoon:"in the afternoon",evening:"in the evening",night:"at night"},abbreviated:{am:"AM",pm:"PM",midnight:"midnight",noon:"noon",morning:"in the morning",afternoon:"in the afternoon",evening:"in the evening",night:"at night"},wide:{am:"a.m.",pm:"p.m.",midnight:"midnight",noon:"noon",morning:"in the morning",afternoon:"in the afternoon",evening:"in the evening",night:"at night"}},Tp=(s,u)=>{const i=Number(s),c=i%100;if(c>20||c<10)switch(c%10){case 1:return i+"st";case 2:return i+"nd";case 3:return i+"rd"}return i+"th"},Mp={ordinalNumber:Tp,era:Lr({values:Np,defaultWidth:"wide"}),quarter:Lr({values:Ep,defaultWidth:"wide",argumentCallback:s=>s-1}),month:Lr({values:_p,defaultWidth:"wide"}),day:Lr({values:jp,defaultWidth:"wide"}),dayPeriod:Lr({values:Pp,defaultWidth:"wide",formattingValues:Ip,defaultFormattingWidth:"wide"})};function Dr(s){return(u,i={})=>{const c=i.width,p=c&&s.matchPatterns[c]||s.matchPatterns[s.defaultMatchWidth],d=u.match(p);if(!d)return null;const w=d[0],C=c&&s.parsePatterns[c]||s.parsePatterns[s.defaultParseWidth],E=Array.isArray(C)?Rp(C,A=>A.test(w)):zp(C,A=>A.test(w));let I;I=s.valueCallback?s.valueCallback(E):E,I=i.valueCallback?i.valueCallback(I):I;const z=u.slice(w.length);return{value:I,rest:z}}}function zp(s,u){for(const i in s)if(Object.prototype.hasOwnProperty.call(s,i)&&u(s[i]))return i}function Rp(s,u){for(let i=0;i<s.length;i++)if(u(s[i]))return i}function Op(s){return(u,i={})=>{const c=u.match(s.matchPattern);if(!c)return null;const p=c[0],d=u.match(s.parsePattern);if(!d)return null;let w=s.valueCallback?s.valueCallback(d[0]):d[0];w=i.valueCallback?i.valueCallback(w):w;const C=u.slice(p.length);return{value:w,rest:C}}}const Lp=/^(\d+)(th|st|nd|rd)?/i,Dp=/\d+/i,Fp={narrow:/^(b|a)/i,abbreviated:/^(b\.?\s?c\.?|b\.?\s?c\.?\s?e\.?|a\.?\s?d\.?|c\.?\s?e\.?)/i,wide:/^(before christ|before common era|anno domini|common era)/i},Wp={any:[/^b/i,/^(a|c)/i]},Ap={narrow:/^[1234]/i,abbreviated:/^q[1234]/i,wide:/^[1234](th|st|nd|rd)? quarter/i},bp={any:[/1/i,/2/i,/3/i,/4/i]},Up={narrow:/^[jfmasond]/i,abbreviated:/^(jan|feb|mar|apr|may|jun|jul|aug|sep|oct|nov|dec)/i,wide:/^(january|february|march|april|may|june|july|august|september|october|november|december)/i},Vp={narrow:[/^j/i,/^f/i,/^m/i,/^a/i,/^m/i,/^j/i,/^j/i,/^a/i,/^s/i,/^o/i,/^n/i,/^d/i],any:[/^ja/i,/^f/i,/^mar/i,/^ap/i,/^may/i,/^jun/i,/^jul/i,/^au/i,/^s/i,/^o/i,/^n/i,/^d/i]},Hp={narrow:/^[smtwf]/i,short:/^(su|mo|tu|we|th|fr|sa)/i,abbreviated:/^(sun|mon|tue|wed|thu|fri|sat)/i,wide:/^(sunday|monday|tuesday|wednesday|thursday|friday|saturday)/i},Bp={narrow:[/^s/i,/^m/i,/^t/i,/^w/i,/^t/i,/^f/i,/^s/i],any:[/^su/i,/^m/i,/^tu/i,/^w/i,/^th/i,/^f/i,/^sa/i]},qp={narrow:/^(a|p|mi|n|(in the|at) (morning|afternoon|evening|night))/i,any:/^([ap]\.?\s?m\.?|midnight|noon|(in the|at) (morning|afternoon|evening|night))/i},Qp={any:{am:/^a/i,pm:/^p/i,midnight:/^mi/i,noon:/^no/i,morning:/morning/i,afternoon:/afternoon/i,evening:/evening/i,night:/night/i}},$p={ordinalNumber:Op({matchPattern:Lp,parsePattern:Dp,valueCallback:s=>parseInt(s,10)}),era:Dr({matchPatterns:Fp,defaultMatchWidth:"wide",parsePatterns:Wp,defaultParseWidth:"any"}),quarter:Dr({matchPatterns:Ap,defaultMatchWidth:"wide",parsePatterns:bp,defaultParseWidth:"any",valueCallback:s=>s+1}),month:Dr({matchPatterns:Up,defaultMatchWidth:"wide",parsePatterns:Vp,defaultParseWidth:"any"}),day:Dr({matchPatterns:Hp,defaultMatchWidth:"wide",parsePatterns:Bp,defaultParseWidth:"any"}),dayPeriod:Dr({matchPatterns:qp,defaultMatchWidth:"any",parsePatterns:Qp,defaultParseWidth:"any"})},Yp={code:"en-US",formatDistance:yp,formatLong:kp,formatRelative:Cp,localize:Mp,match:$p,options:{weekStartsOn:0,firstWeekContainsDate:1}};function Gp(s,u){const i=wt(s,u==null?void 0:u.in);return dp(i,hp(i))+1}function Xp(s,u){const i=wt(s,u==null?void 0:u.in),c=+Jl(i)-+fp(i);return Math.round(c/zc)+1}function Oc(s,u){var z,A,Q,K;const i=wt(s,u==null?void 0:u.in),c=i.getFullYear(),p=Zl(),d=(u==null?void 0:u.firstWeekContainsDate)??((A=(z=u==null?void 0:u.locale)==null?void 0:z.options)==null?void 0:A.firstWeekContainsDate)??p.firstWeekContainsDate??((K=(Q=p.locale)==null?void 0:Q.options)==null?void 0:K.firstWeekContainsDate)??1,w=ln((u==null?void 0:u.in)||s,0);w.setFullYear(c+1,0,d),w.setHours(0,0,0,0);const C=br(w,u),E=ln((u==null?void 0:u.in)||s,0);E.setFullYear(c,0,d),E.setHours(0,0,0,0);const I=br(E,u);return+i>=+C?c+1:+i>=+I?c:c-1}function Kp(s,u){var C,E,I,z;const i=Zl(),c=(u==null?void 0:u.firstWeekContainsDate)??((E=(C=u==null?void 0:u.locale)==null?void 0:C.options)==null?void 0:E.firstWeekContainsDate)??i.firstWeekContainsDate??((z=(I=i.locale)==null?void 0:I.options)==null?void 0:z.firstWeekContainsDate)??1,p=Oc(s,u),d=ln((u==null?void 0:u.in)||s,0);return d.setFullYear(p,0,c),d.setHours(0,0,0,0),br(d,u)}function Jp(s,u){const i=wt(s,u==null?void 0:u.in),c=+br(i,u)-+Kp(i,u);return Math.round(c/zc)+1}function ie(s,u){const i=s<0?"-":"",c=Math.abs(s).toString().padStart(u,"0");return i+c}const tn={y(s,u){const i=s.getFullYear(),c=i>0?i:1-i;return ie(u==="yy"?c%100:c,u.length)},M(s,u){const i=s.getMonth();return u==="M"?String(i+1):ie(i+1,2)},d(s,u){return ie(s.getDate(),u.length)},a(s,u){const i=s.getHours()/12>=1?"pm":"am";switch(u){case"a":case"aa":return i.toUpperCase();case"aaa":return i;case"aaaaa":return i[0];case"aaaa":default:return i==="am"?"a.m.":"p.m."}},h(s,u){return ie(s.getHours()%12||12,u.length)},H(s,u){return ie(s.getHours(),u.length)},m(s,u){return ie(s.getMinutes(),u.length)},s(s,u){return ie(s.getSeconds(),u.length)},S(s,u){const i=u.length,c=s.getMilliseconds(),p=Math.trunc(c*Math.pow(10,i-3));return ie(p,u.length)}},Qn={midnight:"midnight",noon:"noon",morning:"morning",afternoon:"afternoon",evening:"evening",night:"night"},Sc={G:function(s,u,i){const c=s.getFullYear()>0?1:0;switch(u){case"G":case"GG":case"GGG":return i.era(c,{width:"abbreviated"});case"GGGGG":return i.era(c,{width:"narrow"});case"GGGG":default:return i.era(c,{width:"wide"})}},y:function(s,u,i){if(u==="yo"){const c=s.getFullYear(),p=c>0?c:1-c;return i.ordinalNumber(p,{unit:"year"})}return tn.y(s,u)},Y:function(s,u,i,c){const p=Oc(s,c),d=p>0?p:1-p;if(u==="YY"){const w=d%100;return ie(w,2)}return u==="Yo"?i.ordinalNumber(d,{unit:"year"}):ie(d,u.length)},R:function(s,u){const i=Rc(s);return ie(i,u.length)},u:function(s,u){const i=s.getFullYear();return ie(i,u.length)},Q:function(s,u,i){const c=Math.ceil((s.getMonth()+1)/3);switch(u){case"Q":return String(c);case"QQ":return ie(c,2);case"Qo":return i.ordinalNumber(c,{unit:"quarter"});case"QQQ":return i.quarter(c,{width:"abbreviated",context:"formatting"});case"QQQQQ":return i.quarter(c,{width:"narrow",context:"formatting"});case"QQQQ":default:return i.quarter(c,{width:"wide",context:"formatting"})}},q:function(s,u,i){const c=Math.ceil((s.getMonth()+1)/3);switch(u){case"q":return String(c);case"qq":return ie(c,2);case"qo":return i.ordinalNumber(c,{unit:"quarter"});case"qqq":return i.quarter(c,{width:"abbreviated",context:"standalone"});case"qqqqq":return i.quarter(c,{width:"narrow",context:"standalone"});case"qqqq":default:return i.quarter(c,{width:"wide",context:"standalone"})}},M:function(s,u,i){const c=s.getMonth();switch(u){case"M":case"MM":return tn.M(s,u);case"Mo":return i.ordinalNumber(c+1,{unit:"month"});case"MMM":return i.month(c,{width:"abbreviated",context:"formatting"});case"MMMMM":return i.month(c,{width:"narrow",context:"formatting"});case"MMMM":default:return i.month(c,{width:"wide",context:"formatting"})}},L:function(s,u,i){const c=s.getMonth();switch(u){case"L":return String(c+1);case"LL":return ie(c+1,2);case"Lo":return i.ordinalNumber(c+1,{unit:"month"});case"LLL":return i.month(c,{width:"abbreviated",context:"standalone"});case"LLLLL":return i.month(c,{width:"narrow",context:"standalone"});case"LLLL":default:return i.month(c,{width:"wide",context:"standalone"})}},w:function(s,u,i,c){const p=Jp(s,c);return u==="wo"?i.ordinalNumber(p,{unit:"week"}):ie(p,u.length)},I:function(s,u,i){const c=Xp(s);return u==="Io"?i.ordinalNumber(c,{unit:"week"}):ie(c,u.length)},d:function(s,u,i){return u==="do"?i.ordinalNumber(s.getDate(),{unit:"date"}):tn.d(s,u)},D:function(s,u,i){const c=Gp(s);return u==="Do"?i.ordinalNumber(c,{unit:"dayOfYear"}):ie(c,u.length)},E:function(s,u,i){const c=s.getDay();switch(u){case"E":case"EE":case"EEE":return i.day(c,{width:"abbreviated",context:"formatting"});case"EEEEE":return i.day(c,{width:"narrow",context:"formatting"});case"EEEEEE":return i.day(c,{width:"short",context:"formatting"});case"EEEE":default:return i.day(c,{width:"wide",context:"formatting"})}},e:function(s,u,i,c){const p=s.getDay(),d=(p-c.weekStartsOn+8)%7||7;switch(u){case"e":return String(d);case"ee":return ie(d,2);case"eo":return i.ordinalNumber(d,{unit:"day"});case"eee":return i.day(p,{width:"abbreviated",context:"formatting"});case"eeeee":return i.day(p,{width:"narrow",context:"formatting"});case"eeeeee":return i.day(p,{width:"short",context:"formatting"});case"eeee":default:return i.day(p,{width:"wide",context:"formatting"})}},c:function(s,u,i,c){const p=s.getDay(),d=(p-c.weekStartsOn+8)%7||7;switch(u){case"c":return String(d);case"cc":return ie(d,u.length);case"co":return i.ordinalNumber(d,{unit:"day"});case"ccc":return i.day(p,{width:"abbreviated",context:"standalone"});case"ccccc":return i.day(p,{width:"narrow",context:"standalone"});case"cccccc":return i.day(p,{width:"short",context:"standalone"});case"cccc":default:return i.day(p,{width:"wide",context:"standalone"})}},i:function(s,u,i){const c=s.getDay(),p=c===0?7:c;switch(u){case"i":return String(p);case"ii":return ie(p,u.length);case"io":return i.ordinalNumber(p,{unit:"day"});case"iii":return i.day(c,{width:"abbreviated",context:"formatting"});case"iiiii":return i.day(c,{width:"narrow",context:"formatting"});case"iiiiii":return i.day(c,{width:"short",context:"formatting"});case"iiii":default:return i.day(c,{width:"wide",context:"formatting"})}},a:function(s,u,i){const p=s.getHours()/12>=1?"pm":"am";switch(u){case"a":case"aa":return i.dayPeriod(p,{width:"abbreviated",context:"formatting"});case"aaa":return i.dayPeriod(p,{width:"abbreviated",context:"formatting"}).toLowerCase();case"aaaaa":return i.dayPeriod(p,{width:"narrow",context:"formatting"});case"aaaa":default:return i.dayPeriod(p,{width:"wide",context:"formatting"})}},b:function(s,u,i){const c=s.getHours();let p;switch(c===12?p=Qn.noon:c===0?p=Qn.midnight:p=c/12>=1?"pm":"am",u){case"b":case"bb":return i.dayPeriod(p,{width:"abbreviated",context:"formatting"});case"bbb":return i.dayPeriod(p,{width:"abbreviated",context:"formatting"}).toLowerCase();case"bbbbb":return i.dayPeriod(p,{width:"narrow",context:"formatting"});case"bbbb":default:return i.dayPeriod(p,{width:"wide",context:"formatting"})}},B:function(s,u,i){const c=s.getHours();let p;switch(c>=17?p=Qn.evening:c>=12?p=Qn.afternoon:c>=4?p=Qn.morning:p=Qn.night,u){case"B":case"BB":case"BBB":return i.dayPeriod(p,{width:"abbreviated",context:"formatting"});case"BBBBB":return i.dayPeriod(p,{width:"narrow",context:"formatting"});case"BBBB":default:return i.dayPeriod(p,{width:"wide",context:"formatting"})}},h:function(s,u,i){if(u==="ho"){let c=s.getHours()%12;return c===0&&(c=12),i.ordinalNumber(c,{unit:"hour"})}return tn.h(s,u)},H:function(s,u,i){return u==="Ho"?i.ordinalNumber(s.getHours(),{unit:"hour"}):tn.H(s,u)},K:function(s,u,i){const c=s.getHours()%12;return u==="Ko"?i.ordinalNumber(c,{unit:"hour"}):ie(c,u.length)},k:function(s,u,i){let c=s.getHours();return c===0&&(c=24),u==="ko"?i.ordinalNumber(c,{unit:"hour"}):ie(c,u.length)},m:function(s,u,i){return u==="mo"?i.ordinalNumber(s.getMinutes(),{unit:"minute"}):tn.m(s,u)},s:function(s,u,i){return u==="so"?i.ordinalNumber(s.getSeconds(),{unit:"second"}):tn.s(s,u)},S:function(s,u){return tn.S(s,u)},X:function(s,u,i){const c=s.getTimezoneOffset();if(c===0)return"Z";switch(u){case"X":return Nc(c);case"XXXX":case"XX":return wn(c);case"XXXXX":case"XXX":default:return wn(c,":")}},x:function(s,u,i){const c=s.getTimezoneOffset();switch(u){case"x":return Nc(c);case"xxxx":case"xx":return wn(c);case"xxxxx":case"xxx":default:return wn(c,":")}},O:function(s,u,i){const c=s.getTimezoneOffset();switch(u){case"O":case"OO":case"OOO":return"GMT"+Cc(c,":");case"OOOO":default:return"GMT"+wn(c,":")}},z:function(s,u,i){const c=s.getTimezoneOffset();switch(u){case"z":case"zz":case"zzz":return"GMT"+Cc(c,":");case"zzzz":default:return"GMT"+wn(c,":")}},t:function(s,u,i){const c=Math.trunc(+s/1e3);return ie(c,u.length)},T:function(s,u,i){return ie(+s,u.length)}};function Cc(s,u=""){const i=s>0?"-":"+",c=Math.abs(s),p=Math.trunc(c/60),d=c%60;return d===0?i+String(p):i+String(p)+u+ie(d,2)}function Nc(s,u){return s%60===0?(s>0?"-":"+")+ie(Math.abs(s)/60,2):wn(s,u)}function wn(s,u=""){const i=s>0?"-":"+",c=Math.abs(s),p=ie(Math.trunc(c/60),2),d=ie(c%60,2);return i+p+u+d}const Ec=(s,u)=>{switch(s){case"P":return u.date({width:"short"});case"PP":return u.date({width:"medium"});case"PPP":return u.date({width:"long"});case"PPPP":default:return u.date({width:"full"})}},Lc=(s,u)=>{switch(s){case"p":return u.time({width:"short"});case"pp":return u.time({width:"medium"});case"ppp":return u.time({width:"long"});case"pppp":default:return u.time({width:"full"})}},Zp=(s,u)=>{const i=s.match(/(P+)(p+)?/)||[],c=i[1],p=i[2];if(!p)return Ec(s,u);let d;switch(c){case"P":d=u.dateTime({width:"short"});break;case"PP":d=u.dateTime({width:"medium"});break;case"PPP":d=u.dateTime({width:"long"});break;case"PPPP":default:d=u.dateTime({width:"full"});break}return d.replace("{{date}}",Ec(c,u)).replace("{{time}}",Lc(p,u))},em={p:Lc,P:Zp},tm=/^D+$/,nm=/^Y+$/,rm=["D","DD","YY","YYYY"];function lm(s){return tm.test(s)}function om(s){return nm.test(s)}function sm(s,u,i){const c=im(s,u,i);if(console.warn(c),rm.includes(s))throw new RangeError(c)}function im(s,u,i){const c=s[0]==="Y"?"years":"days of the month";return`Use \`${s.toLowerCase()}\` instead of \`${s}\` (in \`${u}\`) for formatting ${c} to the input \`${i}\`; see: https://github.com/date-fns/date-fns/blob/master/docs/unicodeTokens.md`}const um=/[yYQqMLwIdDecihHKkms]o|(\w)\1*|''|'(''|[^'])+('|$)|./g,am=/P+p+|P+|p+|''|'(''|[^'])+('|$)|./g,cm=/^'([^]*?)'?$/,dm=/''/g,fm=/[a-zA-Z]/;function Dc(s,u,i){var z,A,Q,K;const c=Zl(),p=c.locale??Yp,d=c.firstWeekContainsDate??((A=(z=c.locale)==null?void 0:z.options)==null?void 0:A.firstWeekContainsDate)??1,w=c.weekStartsOn??((K=(Q=c.locale)==null?void 0:Q.options)==null?void 0:K.weekStartsOn)??0,C=wt(s,i==null?void 0:i.in);if(!mp(C))throw new RangeError("Invalid time value");let E=u.match(am).map(B=>{const O=B[0];if(O==="p"||O==="P"){const F=em[O];return F(B,p.formatLong)}return B}).join("").match(um).map(B=>{if(B==="''")return{isToken:!1,value:"'"};const O=B[0];if(O==="'")return{isToken:!1,value:pm(B)};if(Sc[O])return{isToken:!0,value:B};if(O.match(fm))throw new RangeError("Format string contains an unescaped latin alphabet character `"+O+"`");return{isToken:!1,value:B}});p.localize.preprocessor&&(E=p.localize.preprocessor(C,E));const I={firstWeekContainsDate:d,weekStartsOn:w,locale:p};return E.map(B=>{if(!B.isToken)return B.value;const O=B.value;(om(O)||lm(O))&&sm(O,u,String(s));const F=Sc[O[0]];return F(C,O,p.localize,I)}).join("")}function pm(s){const u=s.match(cm);return u?u[1].replace(dm,"'"):s}function Fc(s){var u,i,c="";if(typeof s=="string"||typeof s=="number")c+=s;else if(typeof s=="object")if(Array.isArray(s)){var p=s.length;for(u=0;u<p;u++)s[u]&&(i=Fc(s[u]))&&(c&&(c+=" "),c+=i)}else for(i in s)s[i]&&(c&&(c+=" "),c+=i);return c}function mm(){for(var s,u,i=0,c="",p=arguments.length;i<p;i++)(s=arguments[i])&&(u=Fc(s))&&(c&&(c+=" "),c+=u);return c}const ui="-",hm=s=>{const u=ym(s),{conflictingClassGroups:i,conflictingClassGroupModifiers:c}=s;return{getClassGroupId:w=>{const C=w.split(ui);return C[0]===""&&C.length!==1&&C.shift(),Wc(C,u)||gm(w)},getConflictingClassGroupIds:(w,C)=>{const E=i[w]||[];return C&&c[w]?[...E,...c[w]]:E}}},Wc=(s,u)=>{var w;if(s.length===0)return u.classGroupId;const i=s[0],c=u.nextPart.get(i),p=c?Wc(s.slice(1),c):void 0;if(p)return p;if(u.validators.length===0)return;const d=s.join(ui);return(w=u.validators.find(({validator:C})=>C(d)))==null?void 0:w.classGroupId},_c=/^\[(.+)\]$/,gm=s=>{if(_c.test(s)){const u=_c.exec(s)[1],i=u==null?void 0:u.substring(0,u.indexOf(":"));if(i)return"arbitrary.."+i}},ym=s=>{const{theme:u,prefix:i}=s,c={nextPart:new Map,validators:[]};return xm(Object.entries(s.classGroups),i).forEach(([d,w])=>{oi(w,c,d,u)}),c},oi=(s,u,i,c)=>{s.forEach(p=>{if(typeof p=="string"){const d=p===""?u:jc(u,p);d.classGroupId=i;return}if(typeof p=="function"){if(vm(p)){oi(p(c),u,i,c);return}u.validators.push({validator:p,classGroupId:i});return}Object.entries(p).forEach(([d,w])=>{oi(w,jc(u,d),i,c)})})},jc=(s,u)=>{let i=s;return u.split(ui).forEach(c=>{i.nextPart.has(c)||i.nextPart.set(c,{nextPart:new Map,validators:[]}),i=i.nextPart.get(c)}),i},vm=s=>s.isThemeGetter,xm=(s,u)=>u?s.map(([i,c])=>{const p=c.map(d=>typeof d=="string"?u+d:typeof d=="object"?Object.fromEntries(Object.entries(d).map(([w,C])=>[u+w,C])):d);return[i,p]}):s,wm=s=>{if(s<1)return{get:()=>{},set:()=>{}};let u=0,i=new Map,c=new Map;const p=(d,w)=>{i.set(d,w),u++,u>s&&(u=0,c=i,i=new Map)};return{get(d){let w=i.get(d);if(w!==void 0)return w;if((w=c.get(d))!==void 0)return p(d,w),w},set(d,w){i.has(d)?i.set(d,w):p(d,w)}}},Ac="!",km=s=>{const{separator:u,experimentalParseClassName:i}=s,c=u.length===1,p=u[0],d=u.length,w=C=>{const E=[];let I=0,z=0,A;for(let F=0;F<C.length;F++){let re=C[F];if(I===0){if(re===p&&(c||C.slice(F,F+d)===u)){E.push(C.slice(z,F)),z=F+d;continue}if(re==="/"){A=F;continue}}re==="["?I++:re==="]"&&I--}const Q=E.length===0?C:C.substring(z),K=Q.startsWith(Ac),B=K?Q.substring(1):Q,O=A&&A>z?A-z:void 0;return{modifiers:E,hasImportantModifier:K,baseClassName:B,maybePostfixModifierPosition:O}};return i?C=>i({className:C,parseClassName:w}):w},Sm=s=>{if(s.length<=1)return s;const u=[];let i=[];return s.forEach(c=>{c[0]==="["?(u.push(...i.sort(),c),i=[]):i.push(c)}),u.push(...i.sort()),u},Cm=s=>({cache:wm(s.cacheSize),parseClassName:km(s),...hm(s)}),Nm=/\s+/,Em=(s,u)=>{const{parseClassName:i,getClassGroupId:c,getConflictingClassGroupIds:p}=u,d=[],w=s.trim().split(Nm);let C="";for(let E=w.length-1;E>=0;E-=1){const I=w[E],{modifiers:z,hasImportantModifier:A,baseClassName:Q,maybePostfixModifierPosition:K}=i(I);let B=!!K,O=c(B?Q.substring(0,K):Q);if(!O){if(!B){C=I+(C.length>0?" "+C:C);continue}if(O=c(Q),!O){C=I+(C.length>0?" "+C:C);continue}B=!1}const F=Sm(z).join(":"),re=A?F+Ac:F,ue=re+O;if(d.includes(ue))continue;d.push(ue);const je=p(O,B);for(let fe=0;fe<je.length;++fe){const we=je[fe];d.push(re+we)}C=I+(C.length>0?" "+C:C)}return C};function _m(){let s=0,u,i,c="";for(;s<arguments.length;)(u=arguments[s++])&&(i=bc(u))&&(c&&(c+=" "),c+=i);return c}const bc=s=>{if(typeof s=="string")return s;let u,i="";for(let c=0;c<s.length;c++)s[c]&&(u=bc(s[c]))&&(i&&(i+=" "),i+=u);return i};function jm(s,...u){let i,c,p,d=w;function w(E){const I=u.reduce((z,A)=>A(z),s());return i=Cm(I),c=i.cache.get,p=i.cache.set,d=C,C(E)}function C(E){const I=c(E);if(I)return I;const z=Em(E,i);return p(E,z),z}return function(){return d(_m.apply(null,arguments))}}const ge=s=>{const u=i=>i[s]||[];return u.isThemeGetter=!0,u},Uc=/^\[(?:([a-z-]+):)?(.+)\]$/i,Pm=/^\d+\/\d+$/,Im=new Set(["px","full","screen"]),Tm=/^(\d+(\.\d+)?)?(xs|sm|md|lg|xl)$/,Mm=/\d+(%|px|r?em|[sdl]?v([hwib]|min|max)|pt|pc|in|cm|mm|cap|ch|ex|r?lh|cq(w|h|i|b|min|max))|\b(calc|min|max|clamp)\(.+\)|^0$/,zm=/^(rgba?|hsla?|hwb|(ok)?(lab|lch)|color-mix)\(.+\)$/,Rm=/^(inset_)?-?((\d+)?\.?(\d+)[a-z]+|0)_-?((\d+)?\.?(\d+)[a-z]+|0)/,Om=/^(url|image|image-set|cross-fade|element|(repeating-)?(linear|radial|conic)-gradient)\(.+\)$/,Ot=s=>$n(s)||Im.has(s)||Pm.test(s),nn=s=>Yn(s,"length",Vm),$n=s=>!!s&&!Number.isNaN(Number(s)),ni=s=>Yn(s,"number",$n),Fr=s=>!!s&&Number.isInteger(Number(s)),Lm=s=>s.endsWith("%")&&$n(s.slice(0,-1)),J=s=>Uc.test(s),rn=s=>Tm.test(s),Dm=new Set(["length","size","percentage"]),Fm=s=>Yn(s,Dm,Vc),Wm=s=>Yn(s,"position",Vc),Am=new Set(["image","url"]),bm=s=>Yn(s,Am,Bm),Um=s=>Yn(s,"",Hm),Wr=()=>!0,Yn=(s,u,i)=>{const c=Uc.exec(s);return c?c[1]?typeof u=="string"?c[1]===u:u.has(c[1]):i(c[2]):!1},Vm=s=>Mm.test(s)&&!zm.test(s),Vc=()=>!1,Hm=s=>Rm.test(s),Bm=s=>Om.test(s),qm=()=>{const s=ge("colors"),u=ge("spacing"),i=ge("blur"),c=ge("brightness"),p=ge("borderColor"),d=ge("borderRadius"),w=ge("borderSpacing"),C=ge("borderWidth"),E=ge("contrast"),I=ge("grayscale"),z=ge("hueRotate"),A=ge("invert"),Q=ge("gap"),K=ge("gradientColorStops"),B=ge("gradientColorStopPositions"),O=ge("inset"),F=ge("margin"),re=ge("opacity"),ue=ge("padding"),je=ge("saturate"),fe=ge("scale"),we=ge("sepia"),Pe=ge("skew"),ye=ge("space"),Ie=ge("translate"),Ae=()=>["auto","contain","none"],ve=()=>["auto","hidden","clip","visible","scroll"],$e=()=>["auto",J,u],Z=()=>[J,u],Re=()=>["",Ot,nn],Oe=()=>["auto",$n,J],Le=()=>["bottom","center","left","left-bottom","left-top","right","right-bottom","right-top","top"],Ne=()=>["solid","dashed","dotted","double","none"],de=()=>["normal","multiply","screen","overlay","darken","lighten","color-dodge","color-burn","hard-light","soft-light","difference","exclusion","hue","saturation","color","luminosity"],M=()=>["start","end","center","between","around","evenly","stretch"],H=()=>["","0",J],L=()=>["auto","avoid","all","avoid-page","page","left","right","column"],v=()=>[$n,J];return{cacheSize:500,separator:":",theme:{colors:[Wr],spacing:[Ot,nn],blur:["none","",rn,J],brightness:v(),borderColor:[s],borderRadius:["none","","full",rn,J],borderSpacing:Z(),borderWidth:Re(),contrast:v(),grayscale:H(),hueRotate:v(),invert:H(),gap:Z(),gradientColorStops:[s],gradientColorStopPositions:[Lm,nn],inset:$e(),margin:$e(),opacity:v(),padding:Z(),saturate:v(),scale:v(),sepia:H(),skew:v(),space:Z(),translate:Z()},classGroups:{aspect:[{aspect:["auto","square","video",J]}],container:["container"],columns:[{columns:[rn]}],"break-after":[{"break-after":L()}],"break-before":[{"break-before":L()}],"break-inside":[{"break-inside":["auto","avoid","avoid-page","avoid-column"]}],"box-decoration":[{"box-decoration":["slice","clone"]}],box:[{box:["border","content"]}],display:["block","inline-block","inline","flex","inline-flex","table","inline-table","table-caption","table-cell","table-column","table-column-group","table-footer-group","table-header-group","table-row-group","table-row","flow-root","grid","inline-grid","contents","list-item","hidden"],float:[{float:["right","left","none","start","end"]}],clear:[{clear:["left","right","both","none","start","end"]}],isolation:["isolate","isolation-auto"],"object-fit":[{object:["contain","cover","fill","none","scale-down"]}],"object-position":[{object:[...Le(),J]}],overflow:[{overflow:ve()}],"overflow-x":[{"overflow-x":ve()}],"overflow-y":[{"overflow-y":ve()}],overscroll:[{overscroll:Ae()}],"overscroll-x":[{"overscroll-x":Ae()}],"overscroll-y":[{"overscroll-y":Ae()}],position:["static","fixed","absolute","relative","sticky"],inset:[{inset:[O]}],"inset-x":[{"inset-x":[O]}],"inset-y":[{"inset-y":[O]}],start:[{start:[O]}],end:[{end:[O]}],top:[{top:[O]}],right:[{right:[O]}],bottom:[{bottom:[O]}],left:[{left:[O]}],visibility:["visible","invisible","collapse"],z:[{z:["auto",Fr,J]}],basis:[{basis:$e()}],"flex-direction":[{flex:["row","row-reverse","col","col-reverse"]}],"flex-wrap":[{flex:["wrap","wrap-reverse","nowrap"]}],flex:[{flex:["1","auto","initial","none",J]}],grow:[{grow:H()}],shrink:[{shrink:H()}],order:[{order:["first","last","none",Fr,J]}],"grid-cols":[{"grid-cols":[Wr]}],"col-start-end":[{col:["auto",{span:["full",Fr,J]},J]}],"col-start":[{"col-start":Oe()}],"col-end":[{"col-end":Oe()}],"grid-rows":[{"grid-rows":[Wr]}],"row-start-end":[{row:["auto",{span:[Fr,J]},J]}],"row-start":[{"row-start":Oe()}],"row-end":[{"row-end":Oe()}],"grid-flow":[{"grid-flow":["row","col","dense","row-dense","col-dense"]}],"auto-cols":[{"auto-cols":["auto","min","max","fr",J]}],"auto-rows":[{"auto-rows":["auto","min","max","fr",J]}],gap:[{gap:[Q]}],"gap-x":[{"gap-x":[Q]}],"gap-y":[{"gap-y":[Q]}],"justify-content":[{justify:["normal",...M()]}],"justify-items":[{"justify-items":["start","end","center","stretch"]}],"justify-self":[{"justify-self":["auto","start","end","center","stretch"]}],"align-content":[{content:["normal",...M(),"baseline"]}],"align-items":[{items:["start","end","center","baseline","stretch"]}],"align-self":[{self:["auto","start","end","center","stretch","baseline"]}],"place-content":[{"place-content":[...M(),"baseline"]}],"place-items":[{"place-items":["start","end","center","baseline","stretch"]}],"place-self":[{"place-self":["auto","start","end","center","stretch"]}],p:[{p:[ue]}],px:[{px:[ue]}],py:[{py:[ue]}],ps:[{ps:[ue]}],pe:[{pe:[ue]}],pt:[{pt:[ue]}],pr:[{pr:[ue]}],pb:[{pb:[ue]}],pl:[{pl:[ue]}],m:[{m:[F]}],mx:[{mx:[F]}],my:[{my:[F]}],ms:[{ms:[F]}],me:[{me:[F]}],mt:[{mt:[F]}],mr:[{mr:[F]}],mb:[{mb:[F]}],ml:[{ml:[F]}],"space-x":[{"space-x":[ye]}],"space-x-reverse":["space-x-reverse"],"space-y":[{"space-y":[ye]}],"space-y-reverse":["space-y-reverse"],w:[{w:["auto","min","max","fit","svw","lvw","dvw",J,u]}],"min-w":[{"min-w":[J,u,"min","max","fit"]}],"max-w":[{"max-w":[J,u,"none","full","min","max","fit","prose",{screen:[rn]},rn]}],h:[{h:[J,u,"auto","min","max","fit","svh","lvh","dvh"]}],"min-h":[{"min-h":[J,u,"min","max","fit","svh","lvh","dvh"]}],"max-h":[{"max-h":[J,u,"min","max","fit","svh","lvh","dvh"]}],size:[{size:[J,u,"auto","min","max","fit"]}],"font-size":[{text:["base",rn,nn]}],"font-smoothing":["antialiased","subpixel-antialiased"],"font-style":["italic","not-italic"],"font-weight":[{font:["thin","extralight","light","normal","medium","semibold","bold","extrabold","black",ni]}],"font-family":[{font:[Wr]}],"fvn-normal":["normal-nums"],"fvn-ordinal":["ordinal"],"fvn-slashed-zero":["slashed-zero"],"fvn-figure":["lining-nums","oldstyle-nums"],"fvn-spacing":["proportional-nums","tabular-nums"],"fvn-fraction":["diagonal-fractions","stacked-fractions"],tracking:[{tracking:["tighter","tight","normal","wide","wider","widest",J]}],"line-clamp":[{"line-clamp":["none",$n,ni]}],leading:[{leading:["none","tight","snug","normal","relaxed","loose",Ot,J]}],"list-image":[{"list-image":["none",J]}],"list-style-type":[{list:["none","disc","decimal",J]}],"list-style-position":[{list:["inside","outside"]}],"placeholder-color":[{placeholder:[s]}],"placeholder-opacity":[{"placeholder-opacity":[re]}],"text-alignment":[{text:["left","center","right","justify","start","end"]}],"text-color":[{text:[s]}],"text-opacity":[{"text-opacity":[re]}],"text-decoration":["underline","overline","line-through","no-underline"],"text-decoration-style":[{decoration:[...Ne(),"wavy"]}],"text-decoration-thickness":[{decoration:["auto","from-font",Ot,nn]}],"underline-offset":[{"underline-offset":["auto",Ot,J]}],"text-decoration-color":[{decoration:[s]}],"text-transform":["uppercase","lowercase","capitalize","normal-case"],"text-overflow":["truncate","text-ellipsis","text-clip"],"text-wrap":[{text:["wrap","nowrap","balance","pretty"]}],indent:[{indent:Z()}],"vertical-align":[{align:["baseline","top","middle","bottom","text-top","text-bottom","sub","super",J]}],whitespace:[{whitespace:["normal","nowrap","pre","pre-line","pre-wrap","break-spaces"]}],break:[{break:["normal","words","all","keep"]}],hyphens:[{hyphens:["none","manual","auto"]}],content:[{content:["none",J]}],"bg-attachment":[{bg:["fixed","local","scroll"]}],"bg-clip":[{"bg-clip":["border","padding","content","text"]}],"bg-opacity":[{"bg-opacity":[re]}],"bg-origin":[{"bg-origin":["border","padding","content"]}],"bg-position":[{bg:[...Le(),Wm]}],"bg-repeat":[{bg:["no-repeat",{repeat:["","x","y","round","space"]}]}],"bg-size":[{bg:["auto","cover","contain",Fm]}],"bg-image":[{bg:["none",{"gradient-to":["t","tr","r","br","b","bl","l","tl"]},bm]}],"bg-color":[{bg:[s]}],"gradient-from-pos":[{from:[B]}],"gradient-via-pos":[{via:[B]}],"gradient-to-pos":[{to:[B]}],"gradient-from":[{from:[K]}],"gradient-via":[{via:[K]}],"gradient-to":[{to:[K]}],rounded:[{rounded:[d]}],"rounded-s":[{"rounded-s":[d]}],"rounded-e":[{"rounded-e":[d]}],"rounded-t":[{"rounded-t":[d]}],"rounded-r":[{"rounded-r":[d]}],"rounded-b":[{"rounded-b":[d]}],"rounded-l":[{"rounded-l":[d]}],"rounded-ss":[{"rounded-ss":[d]}],"rounded-se":[{"rounded-se":[d]}],"rounded-ee":[{"rounded-ee":[d]}],"rounded-es":[{"rounded-es":[d]}],"rounded-tl":[{"rounded-tl":[d]}],"rounded-tr":[{"rounded-tr":[d]}],"rounded-br":[{"rounded-br":[d]}],"rounded-bl":[{"rounded-bl":[d]}],"border-w":[{border:[C]}],"border-w-x":[{"border-x":[C]}],"border-w-y":[{"border-y":[C]}],"border-w-s":[{"border-s":[C]}],"border-w-e":[{"border-e":[C]}],"border-w-t":[{"border-t":[C]}],"border-w-r":[{"border-r":[C]}],"border-w-b":[{"border-b":[C]}],"border-w-l":[{"border-l":[C]}],"border-opacity":[{"border-opacity":[re]}],"border-style":[{border:[...Ne(),"hidden"]}],"divide-x":[{"divide-x":[C]}],"divide-x-reverse":["divide-x-reverse"],"divide-y":[{"divide-y":[C]}],"divide-y-reverse":["divide-y-reverse"],"divide-opacity":[{"divide-opacity":[re]}],"divide-style":[{divide:Ne()}],"border-color":[{border:[p]}],"border-color-x":[{"border-x":[p]}],"border-color-y":[{"border-y":[p]}],"border-color-s":[{"border-s":[p]}],"border-color-e":[{"border-e":[p]}],"border-color-t":[{"border-t":[p]}],"border-color-r":[{"border-r":[p]}],"border-color-b":[{"border-b":[p]}],"border-color-l":[{"border-l":[p]}],"divide-color":[{divide:[p]}],"outline-style":[{outline:["",...Ne()]}],"outline-offset":[{"outline-offset":[Ot,J]}],"outline-w":[{outline:[Ot,nn]}],"outline-color":[{outline:[s]}],"ring-w":[{ring:Re()}],"ring-w-inset":["ring-inset"],"ring-color":[{ring:[s]}],"ring-opacity":[{"ring-opacity":[re]}],"ring-offset-w":[{"ring-offset":[Ot,nn]}],"ring-offset-color":[{"ring-offset":[s]}],shadow:[{shadow:["","inner","none",rn,Um]}],"shadow-color":[{shadow:[Wr]}],opacity:[{opacity:[re]}],"mix-blend":[{"mix-blend":[...de(),"plus-lighter","plus-darker"]}],"bg-blend":[{"bg-blend":de()}],filter:[{filter:["","none"]}],blur:[{blur:[i]}],brightness:[{brightness:[c]}],contrast:[{contrast:[E]}],"drop-shadow":[{"drop-shadow":["","none",rn,J]}],grayscale:[{grayscale:[I]}],"hue-rotate":[{"hue-rotate":[z]}],invert:[{invert:[A]}],saturate:[{saturate:[je]}],sepia:[{sepia:[we]}],"backdrop-filter":[{"backdrop-filter":["","none"]}],"backdrop-blur":[{"backdrop-blur":[i]}],"backdrop-brightness":[{"backdrop-brightness":[c]}],"backdrop-contrast":[{"backdrop-contrast":[E]}],"backdrop-grayscale":[{"backdrop-grayscale":[I]}],"backdrop-hue-rotate":[{"backdrop-hue-rotate":[z]}],"backdrop-invert":[{"backdrop-invert":[A]}],"backdrop-opacity":[{"backdrop-opacity":[re]}],"backdrop-saturate":[{"backdrop-saturate":[je]}],"backdrop-sepia":[{"backdrop-sepia":[we]}],"border-collapse":[{border:["collapse","separate"]}],"border-spacing":[{"border-spacing":[w]}],"border-spacing-x":[{"border-spacing-x":[w]}],"border-spacing-y":[{"border-spacing-y":[w]}],"table-layout":[{table:["auto","fixed"]}],caption:[{caption:["top","bottom"]}],transition:[{transition:["none","all","","colors","opacity","shadow","transform",J]}],duration:[{duration:v()}],ease:[{ease:["linear","in","out","in-out",J]}],delay:[{delay:v()}],animate:[{animate:["none","spin","ping","pulse","bounce",J]}],transform:[{transform:["","gpu","none"]}],scale:[{scale:[fe]}],"scale-x":[{"scale-x":[fe]}],"scale-y":[{"scale-y":[fe]}],rotate:[{rotate:[Fr,J]}],"translate-x":[{"translate-x":[Ie]}],"translate-y":[{"translate-y":[Ie]}],"skew-x":[{"skew-x":[Pe]}],"skew-y":[{"skew-y":[Pe]}],"transform-origin":[{origin:["center","top","top-right","right","bottom-right","bottom","bottom-left","left","top-left",J]}],accent:[{accent:["auto",s]}],appearance:[{appearance:["none","auto"]}],cursor:[{cursor:["auto","default","pointer","wait","text","move","help","not-allowed","none","context-menu","progress","cell","crosshair","vertical-text","alias","copy","no-drop","grab","grabbing","all-scroll","col-resize","row-resize","n-resize","e-resize","s-resize","w-resize","ne-resize","nw-resize","se-resize","sw-resize","ew-resize","ns-resize","nesw-resize","nwse-resize","zoom-in","zoom-out",J]}],"caret-color":[{caret:[s]}],"pointer-events":[{"pointer-events":["none","auto"]}],resize:[{resize:["none","y","x",""]}],"scroll-behavior":[{scroll:["auto","smooth"]}],"scroll-m":[{"scroll-m":Z()}],"scroll-mx":[{"scroll-mx":Z()}],"scroll-my":[{"scroll-my":Z()}],"scroll-ms":[{"scroll-ms":Z()}],"scroll-me":[{"scroll-me":Z()}],"scroll-mt":[{"scroll-mt":Z()}],"scroll-mr":[{"scroll-mr":Z()}],"scroll-mb":[{"scroll-mb":Z()}],"scroll-ml":[{"scroll-ml":Z()}],"scroll-p":[{"scroll-p":Z()}],"scroll-px":[{"scroll-px":Z()}],"scroll-py":[{"scroll-py":Z()}],"scroll-ps":[{"scroll-ps":Z()}],"scroll-pe":[{"scroll-pe":Z()}],"scroll-pt":[{"scroll-pt":Z()}],"scroll-pr":[{"scroll-pr":Z()}],"scroll-pb":[{"scroll-pb":Z()}],"scroll-pl":[{"scroll-pl":Z()}],"snap-align":[{snap:["start","end","center","align-none"]}],"snap-stop":[{snap:["normal","always"]}],"snap-type":[{snap:["none","x","y","both"]}],"snap-strictness":[{snap:["mandatory","proximity"]}],touch:[{touch:["auto","none","manipulation"]}],"touch-x":[{"touch-pan":["x","left","right"]}],"touch-y":[{"touch-pan":["y","up","down"]}],"touch-pz":["touch-pinch-zoom"],select:[{select:["none","text","all","auto"]}],"will-change":[{"will-change":["auto","scroll","contents","transform",J]}],fill:[{fill:[s,"none"]}],"stroke-w":[{stroke:[Ot,nn,ni]}],stroke:[{stroke:[s,"none"]}],sr:["sr-only","not-sr-only"],"forced-color-adjust":[{"forced-color-adjust":["auto","none"]}]},conflictingClassGroups:{overflow:["overflow-x","overflow-y"],overscroll:["overscroll-x","overscroll-y"],inset:["inset-x","inset-y","start","end","top","right","bottom","left"],"inset-x":["right","left"],"inset-y":["top","bottom"],flex:["basis","grow","shrink"],gap:["gap-x","gap-y"],p:["px","py","ps","pe","pt","pr","pb","pl"],px:["pr","pl"],py:["pt","pb"],m:["mx","my","ms","me","mt","mr","mb","ml"],mx:["mr","ml"],my:["mt","mb"],size:["w","h"],"font-size":["leading"],"fvn-normal":["fvn-ordinal","fvn-slashed-zero","fvn-figure","fvn-spacing","fvn-fraction"],"fvn-ordinal":["fvn-normal"],"fvn-slashed-zero":["fvn-normal"],"fvn-figure":["fvn-normal"],"fvn-spacing":["fvn-normal"],"fvn-fraction":["fvn-normal"],"line-clamp":["display","overflow"],rounded:["rounded-s","rounded-e","rounded-t","rounded-r","rounded-b","rounded-l","rounded-ss","rounded-se","rounded-ee","rounded-es","rounded-tl","rounded-tr","rounded-br","rounded-bl"],"rounded-s":["rounded-ss","rounded-es"],"rounded-e":["rounded-se","rounded-ee"],"rounded-t":["rounded-tl","rounded-tr"],"rounded-r":["rounded-tr","rounded-br"],"rounded-b":["rounded-br","rounded-bl"],"rounded-l":["rounded-tl","rounded-bl"],"border-spacing":["border-spacing-x","border-spacing-y"],"border-w":["border-w-s","border-w-e","border-w-t","border-w-r","border-w-b","border-w-l"],"border-w-x":["border-w-r","border-w-l"],"border-w-y":["border-w-t","border-w-b"],"border-color":["border-color-s","border-color-e","border-color-t","border-color-r","border-color-b","border-color-l"],"border-color-x":["border-color-r","border-color-l"],"border-color-y":["border-color-t","border-color-b"],"scroll-m":["scroll-mx","scroll-my","scroll-ms","scroll-me","scroll-mt","scroll-mr","scroll-mb","scroll-ml"],"scroll-mx":["scroll-mr","scroll-ml"],"scroll-my":["scroll-mt","scroll-mb"],"scroll-p":["scroll-px","scroll-py","scroll-ps","scroll-pe","scroll-pt","scroll-pr","scroll-pb","scroll-pl"],"scroll-px":["scroll-pr","scroll-pl"],"scroll-py":["scroll-pt","scroll-pb"],touch:["touch-x","touch-y","touch-pz"],"touch-x":["touch"],"touch-y":["touch"],"touch-pz":["touch"]},conflictingClassGroupModifiers:{"font-size":["leading"]}}},Qm=jm(qm);function on(...s){return Qm(mm(s))}const ai=q.forwardRef(({className:s,children:u,...i},c)=>h.jsx("div",{ref:c,className:on("relative overflow-auto",s),...i,children:u}));ai.displayName="ScrollArea";const ci=q.forwardRef(({className:s,...u},i)=>h.jsx("div",{ref:i,className:on("rounded-lg border bg-card text-card-foreground shadow-sm",s),...u}));ci.displayName="Card";const $m=q.forwardRef(({className:s,...u},i)=>h.jsx("div",{ref:i,className:on("flex flex-col space-y-1.5 p-6",s),...u}));$m.displayName="CardHeader";const Ym=q.forwardRef(({className:s,...u},i)=>h.jsx("h3",{ref:i,className:on("text-2xl font-semibold leading-none tracking-tight",s),...u}));Ym.displayName="CardTitle";const Gm=q.forwardRef(({className:s,...u},i)=>h.jsx("p",{ref:i,className:on("text-sm text-muted-foreground",s),...u}));Gm.displayName="CardDescription";const Xm=q.forwardRef(({className:s,...u},i)=>h.jsx("div",{ref:i,className:on("p-6 pt-0",s),...u}));Xm.displayName="CardContent";const Km=q.forwardRef(({className:s,...u},i)=>h.jsx("div",{ref:i,className:on("flex items-center p-6 pt-0",s),...u}));Km.displayName="CardFooter";const Lt=q.forwardRef(({className:s,variant:u="default",size:i="default",...c},p)=>{const d={default:"bg-primary text-primary-foreground hover:bg-primary/90",destructive:"bg-destructive text-destructive-foreground hover:bg-destructive/90",outline:"border border-input bg-background hover:bg-accent hover:text-accent-foreground",secondary:"bg-secondary text-secondary-foreground hover:bg-secondary/80",ghost:"hover:bg-accent hover:text-accent-foreground"},w={default:"h-10 px-4 py-2",sm:"h-9 rounded-md px-3",lg:"h-11 rounded-md px-8",icon:"h-10 w-10"};return h.jsx("button",{className:on("inline-flex items-center justify-center whitespace-nowrap rounded-md text-sm font-medium ring-offset-background transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50",d[u],w[i],s),ref:p,...c})});Lt.displayName="Button";const Jm={"agent.start":vc,"agent.text":ii,"agent.bootstrap":ei,"agent.tool_start":sp,"agent.tool_end":Zs,"agent.compaction":ei,"agent.memory_changed":Zf,"agent.skill_used":ei,"agent.subagent_spawn":ep,"agent.subagent_complete":Zs,"agent.hitl_requested":hc,"agent.hitl_resumed":gc,"agent.hitl_expired":mc,"agent.hitl_cancelled":yc,"agent.ui_tool_request":hc,"agent.ui_tool_result":gc,"agent.turn_end":vc,"agent.done":Zs,"agent.error":mc,"server.info":tp,"server.error":yc},Zm={"agent.start":"text-blue-500","agent.text":"text-gray-700 dark:text-gray-300","agent.bootstrap":"text-indigo-500","agent.tool_start":"text-orange-500","agent.tool_end":"text-green-500","agent.compaction":"text-yellow-500","agent.memory_changed":"text-cyan-500","agent.skill_used":"text-amber-500","agent.subagent_spawn":"text-purple-500","agent.subagent_complete":"text-green-500","agent.hitl_requested":"text-amber-500","agent.hitl_resumed":"text-emerald-500","agent.hitl_expired":"text-orange-600","agent.hitl_cancelled":"text-red-500","agent.ui_tool_request":"text-violet-500","agent.ui_tool_result":"text-emerald-500","agent.turn_end":"text-blue-500","agent.done":"text-green-500","agent.error":"text-red-500","server.info":"text-blue-500","server.error":"text-red-500"},eh={callback:"bg-amber-100 text-amber-800",websocket:"bg-sky-100 text-sky-800"};function th({events:s,pendingRequestIds:u=[],onSubmitHitl:i,onSubmitUiTool:c,onCancelHitl:p}){const d=new Set(u);return h.jsx(ai,{className:"h-[calc(100vh-12rem)]",children:h.jsx("div",{className:"space-y-2 p-4",children:s.length===0?h.jsx("div",{className:"flex items-center justify-center h-64 text-muted-foreground",children:h.jsx("p",{children:"暂无事件,请发送消息开始会话"})}):s.map((w,C)=>{const E=Jm[w.message.type]||ii,I=Zm[w.message.type]||"text-gray-500";return h.jsx(ci,{className:"p-3 hover:shadow-md transition-shadow",children:h.jsxs("div",{className:"flex items-start gap-3",children:[h.jsx(nh,{data:w.message,children:h.jsx(E,{className:`mt-0.5 h-4 w-4 flex-shrink-0 cursor-pointer ${I}`})}),h.jsxs("div",{className:"flex-1 min-w-0",children:[h.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[h.jsx("span",{className:"text-xs text-muted-foreground",children:Dc(w.timestamp,"HH:mm:ss.SSS")}),h.jsx("span",{className:"text-xs font-mono px-2 py-0.5 rounded-full bg-secondary text-secondary-foreground",children:w.message.type}),w.message.transport?h.jsx("span",{className:`text-[10px] font-medium uppercase tracking-wide px-2 py-0.5 rounded-full ${eh[w.message.transport]}`,children:w.message.transport}):null]}),h.jsx("div",{className:"text-sm text-foreground",children:rh(w,d,i,c,p)})]})]})},C)})})})}function nh({data:s,children:u}){const[i,c]=q.useState(!1),p=JSON.stringify(s,null,2);return h.jsxs(h.Fragment,{children:[h.jsx("div",{className:"relative flex-shrink-0",onClick:()=>c(d=>!d),children:u}),i&&h.jsxs(h.Fragment,{children:[h.jsx("div",{className:"fixed inset-0 z-40",onClick:()=>c(!1)}),h.jsx("div",{className:"fixed z-50 w-[500px] rounded-md border bg-popover p-3 shadow-lg",style:{top:0,left:0},ref:d=>{var E;if(!d)return;const w=(E=d.previousElementSibling)==null?void 0:E.previousElementSibling;if(!w)return;const C=w.getBoundingClientRect();d.style.top=`${C.bottom+4}px`,d.style.left=`${C.left}px`},onClick:d=>d.stopPropagation(),children:h.jsx("pre",{className:"max-h-80 overflow-auto whitespace-pre-wrap break-all text-xs text-popover-foreground font-mono",children:p})})]})]})}function rh(s,u,i,c,p){var w,C;const{message:d}=s;switch(d.type){case"agent.start":return h.jsxs("div",{className:"space-y-1",children:[h.jsxs("div",{className:"text-xs text-muted-foreground",children:["Session: ",d.sessionId,d.messageId&&h.jsxs("span",{className:"ml-2",children:["Message: ",d.messageId]}),h.jsxs("span",{className:"ml-2",children:["启动时间: ",ri(s.startLatencyMs)]})]}),h.jsxs("div",{className:"font-medium",children:["任务: ",d.message]})]});case"agent.text":return h.jsxs("div",{className:"space-y-1",children:[d.messageId&&h.jsxs("div",{className:"text-xs text-muted-foreground",children:["Message: ",d.messageId]}),h.jsx("span",{className:"whitespace-pre-wrap break-words",children:d.delta})]});case"agent.bootstrap":return h.jsxs("div",{className:"space-y-1",children:[d.messageId&&h.jsxs("div",{className:"text-xs text-muted-foreground",children:["Message: ",d.messageId]}),h.jsxs("div",{className:"font-medium",children:["Phase: ",d.phase]}),h.jsx("div",{className:"text-xs text-muted-foreground",children:d.dataDir})]});case"agent.tool_start":return h.jsxs("div",{className:"space-y-1",children:[h.jsx("div",{className:"font-medium",children:d.name}),d.messageId&&h.jsxs("div",{className:"text-xs text-muted-foreground",children:["Message: ",d.messageId]}),d.input!==void 0&&d.input!==null&&h.jsx("pre",{className:"text-xs bg-muted p-2 rounded overflow-x-auto",children:JSON.stringify(d.input,null,2)})]});case"agent.tool_end":return h.jsxs("div",{className:"space-y-1",children:[h.jsx("div",{className:"font-medium",children:d.name}),d.messageId&&h.jsxs("div",{className:"text-xs text-muted-foreground",children:["Message: ",d.messageId]}),d.isError&&h.jsx("span",{className:"text-xs text-destructive",children:"Error"}),d.output&&h.jsx("pre",{className:"text-xs bg-muted p-2 rounded overflow-x-auto",children:d.output})]});case"agent.compaction":return h.jsxs("div",{className:"space-y-1",children:[d.messageId&&h.jsxs("div",{className:"text-xs text-muted-foreground",children:["Message: ",d.messageId]}),h.jsxs("span",{children:["Reason: ",d.reason]})]});case"agent.memory_changed":return h.jsxs("div",{className:"space-y-1",children:[h.jsxs("div",{className:"text-xs text-muted-foreground",children:["Reason: ",d.reason," · Source: ",d.source]}),d.messageId&&h.jsxs("div",{className:"text-xs text-muted-foreground",children:["Message: ",d.messageId]}),d.providerId&&h.jsxs("div",{className:"text-xs text-muted-foreground",children:["Provider: ",d.providerId]}),h.jsxs("div",{className:"text-xs text-muted-foreground",children:["Timestamp: ",d.timestamp]}),d.files.length>0&&h.jsx("pre",{className:"text-xs bg-muted p-2 rounded overflow-x-auto",children:d.files.join(`
141
- `)})]});case"agent.skill_used":return h.jsxs("div",{className:"space-y-1",children:[h.jsx("div",{className:"font-medium",children:d.skillName}),d.messageId&&h.jsxs("div",{className:"text-xs text-muted-foreground",children:["Message: ",d.messageId]}),h.jsxs("div",{className:"text-xs text-muted-foreground",children:["Agent: ",d.agent]}),h.jsxs("div",{className:"text-xs text-muted-foreground",children:["Task: ",d.taskId]})]});case"agent.subagent_spawn":return h.jsxs("div",{className:"space-y-1",children:[h.jsxs("div",{children:["Child Session: ",d.childSessionId]}),d.messageId&&h.jsxs("div",{className:"text-xs text-muted-foreground",children:["Message: ",d.messageId]}),h.jsxs("div",{className:"text-xs text-muted-foreground",children:["Task: ",d.task]}),d.label&&h.jsxs("div",{className:"text-xs text-muted-foreground",children:["Label: ",d.label]})]});case"agent.subagent_complete":return h.jsxs("div",{className:"space-y-1",children:[h.jsxs("div",{children:["Child Session: ",d.childSessionId]}),d.messageId&&h.jsxs("div",{className:"text-xs text-muted-foreground",children:["Message: ",d.messageId]}),h.jsxs("div",{className:"text-xs text-muted-foreground",children:["Status: ",d.status]})]});case"agent.hitl_requested":{const E=d.request,I=E.input.mode==="choice"?E.input.choices??[]:[];return h.jsx(lh,{sessionId:d.sessionId,requestId:E.requestId,title:E.title,prompt:E.prompt,preview:(w=E.preview)==null?void 0:w.content,choices:I,allowText:E.input.mode==="text"||E.input.mode==="choice"&&!!E.input.allowFreeText,pending:u.has(E.requestId),onSubmit:i,onCancel:p})}case"agent.hitl_resumed":return h.jsxs("div",{children:["Request resumed: ",d.requestId]});case"agent.hitl_expired":return h.jsxs("div",{children:["Request expired: ",d.requestId," · ",d.reason]});case"agent.hitl_cancelled":return h.jsxs("div",{children:["Request cancelled: ",d.requestId,d.reason?` · ${d.reason}`:""]});case"agent.ui_tool_request":return h.jsx(oh,{sessionId:d.sessionId,requestId:d.request.requestId,toolName:d.request.toolName,schema:d.request.schema,extra:d.request.extra,pending:u.has(d.request.requestId),onSubmit:c});case"agent.ui_tool_result":return h.jsxs("div",{className:"space-y-1",children:[h.jsx("div",{className:"font-medium",children:d.toolName}),h.jsxs("div",{className:"text-xs text-muted-foreground",children:["Request resumed: ",d.requestId]}),h.jsx("pre",{className:"text-xs bg-muted p-2 rounded overflow-x-auto",children:JSON.stringify(d.values,null,2)})]});case"agent.done":return h.jsxs("div",{className:"space-y-1",children:[h.jsxs("div",{className:"text-xs text-muted-foreground",children:["Total: ",ri(s.totalTimeMs),h.jsxs("span",{className:"ml-2",children:["Agent: ",ri(s.agentTimeMs)]})]}),d.messageId&&h.jsxs("div",{className:"text-xs text-muted-foreground",children:["Message: ",d.messageId]}),d.result.paused&&h.jsxs("div",{className:"rounded-md border border-amber-300 bg-amber-50 px-3 py-2 text-amber-900",children:[h.jsxs("div",{className:"font-medium",children:["Paused for HITL: ",d.result.paused.title]}),h.jsxs("div",{className:"text-xs",children:["Request: ",d.result.paused.requestId," · Kind: ",d.result.paused.kind]})]}),d.result.text&&h.jsx("div",{className:"whitespace-pre-wrap break-words",children:d.result.paused&&d.result.text==="HITL_PAUSED"?"Run paused and waiting for human input.":d.result.text}),d.result.error&&h.jsxs("div",{className:"text-sm text-destructive",children:["Error: ",d.result.error]}),d.result.aborted&&h.jsx("div",{className:"text-sm text-yellow-500",children:"Aborted"}),((C=d.result.usage)==null?void 0:C.total)&&h.jsxs("div",{className:"text-xs text-muted-foreground",children:["Tokens: ",d.result.usage.total]})]});case"agent.error":return h.jsxs("div",{className:"space-y-1",children:[d.messageId&&h.jsxs("div",{className:"text-xs text-muted-foreground",children:["Message: ",d.messageId]}),h.jsx("span",{className:"text-destructive",children:d.message})]});case"session.reset":{const E=d.action==="new"?"new session":"reset session";return h.jsxs("div",{className:"space-y-1",children:[h.jsxs("div",{className:"text-xs text-muted-foreground",children:[E," · Session: ",d.sessionId]}),d.previousSessionId&&h.jsxs("div",{className:"text-xs text-muted-foreground",children:["Previous: ",d.previousSessionId]}),h.jsxs("div",{className:"text-sm",children:["Trigger: ",d.message]})]})}case"server.info":return h.jsx("span",{className:"text-blue-500",children:d.message});case"server.error":return h.jsx("span",{className:"text-destructive",children:d.message});case"sessions.list":return h.jsxs("span",{children:["Sessions: ",d.sessions.length]});case"session.get":return h.jsxs("span",{children:["Session loaded: ",d.sessionId]});default:return null}}function lh(s){const[u,i]=Ar.useState("");return h.jsxs("div",{className:"space-y-3 rounded-lg border border-amber-200 bg-amber-50 p-3",children:[h.jsxs("div",{children:[h.jsx("div",{className:"font-semibold",children:s.title}),h.jsx("div",{className:"text-sm text-slate-700 whitespace-pre-wrap",children:s.prompt})]}),s.preview?h.jsx("pre",{className:"max-h-56 overflow-auto rounded bg-white p-2 text-xs whitespace-pre-wrap",children:s.preview}):null,s.allowText?h.jsx("textarea",{className:"w-full rounded border bg-white p-2 text-sm",placeholder:"Optional response...",value:u,onChange:c=>i(c.target.value),disabled:s.pending}):null,s.pending?h.jsx("div",{className:"text-xs font-medium text-amber-700",children:"Submitting HITL response..."}):null,h.jsxs("div",{className:"flex flex-wrap gap-2",children:[s.choices.map(c=>h.jsx(Lt,{size:"sm",disabled:s.pending,onClick:()=>{var p;return(p=s.onSubmit)==null?void 0:p.call(s,{sessionId:s.sessionId,requestId:s.requestId,choiceId:c.id,text:u.trim()||void 0})},children:c.label},c.id)),s.choices.length===0?h.jsx(Lt,{size:"sm",disabled:s.pending,onClick:()=>{var c;return(c=s.onSubmit)==null?void 0:c.call(s,{sessionId:s.sessionId,requestId:s.requestId,text:u.trim()||void 0})},children:"Submit"}):null,h.jsx(Lt,{size:"sm",variant:"outline",disabled:s.pending,onClick:()=>{var c;return(c=s.onCancel)==null?void 0:c.call(s,{sessionId:s.sessionId,requestId:s.requestId})},children:"Cancel"})]})]})}function oh(s){const u=Ar.useMemo(()=>ih(s.schema,s.extra),[s.schema,s.extra]),[i,c]=Ar.useState(()=>ch(u)),p=Ar.useCallback((d,w)=>{c(C=>({...C,[d]:w}))},[]);return h.jsxs("div",{className:"space-y-3 rounded-lg border border-violet-200 bg-violet-50 p-3",children:[h.jsxs("div",{children:[h.jsx("div",{className:"font-semibold",children:s.schema.title}),h.jsxs("div",{className:"text-xs text-muted-foreground",children:["Tool: ",s.toolName]}),s.schema.description?h.jsx("div",{className:"text-sm text-slate-700 whitespace-pre-wrap",children:s.schema.description}):null]}),h.jsx("div",{className:"space-y-3",children:u.map(d=>h.jsx(sh,{field:d,value:i[d.name],disabled:s.pending,onChange:w=>p(d.name,w)},d.name))}),s.pending?h.jsx("div",{className:"text-xs font-medium text-violet-700",children:"Submitting UI tool response..."}):null,h.jsx("div",{className:"flex flex-wrap gap-2",children:h.jsx(Lt,{size:"sm",disabled:s.pending,onClick:()=>{var d;return(d=s.onSubmit)==null?void 0:d.call(s,{sessionId:s.sessionId,requestId:s.requestId,values:i})},children:"Submit"})})]})}function Pc(s){return!s||!("enum"in s)||!Array.isArray(s.enum)?[]:s.enum.filter(u=>typeof u=="string")}function sh(s){const{field:u,value:i,disabled:c,onChange:p}=s,d=u.schema.title??u.name,w=u.schema.description||u.placeholder,C="w-full rounded border bg-white p-2 text-sm";if(u.schema.type==="boolean")return h.jsxs("label",{className:"block space-y-1",children:[h.jsxs("div",{className:"text-sm font-medium",children:[d,u.required?" *":""]}),h.jsx("input",{type:"checkbox",checked:!!i,disabled:c,onChange:I=>p(I.target.checked)}),w?h.jsx("div",{className:"text-xs text-muted-foreground",children:w}):null]});if(u.schema.type==="array"){const I=Pc(u.schema.items);return h.jsxs("label",{className:"block space-y-1",children:[h.jsxs("div",{className:"text-sm font-medium",children:[d,u.required?" *":""]}),h.jsx("select",{multiple:!0,className:C,value:Array.isArray(i)?i.filter(z=>typeof z=="string"):[],disabled:c,onChange:z=>p(Array.from(z.target.selectedOptions,A=>A.value)),children:I.map(z=>{var A;return h.jsx("option",{value:z,children:((A=u.enumLabels)==null?void 0:A[z])??z},z)})}),w?h.jsx("div",{className:"text-xs text-muted-foreground",children:w}):null]})}const E=Pc(u.schema);return E.length>0?h.jsxs("label",{className:"block space-y-1",children:[h.jsxs("div",{className:"text-sm font-medium",children:[d,u.required?" *":""]}),h.jsxs("select",{className:C,value:typeof i=="string"?i:"",disabled:c,onChange:I=>p(I.target.value),children:[h.jsx("option",{value:"",children:u.placeholder??"Select an option"}),E.map(I=>{var z;return h.jsx("option",{value:I,children:((z=u.enumLabels)==null?void 0:z[I])??I},I)})]}),w?h.jsx("div",{className:"text-xs text-muted-foreground",children:w}):null]}):u.widget==="textarea"?h.jsxs("label",{className:"block space-y-1",children:[h.jsxs("div",{className:"text-sm font-medium",children:[d,u.required?" *":""]}),h.jsx("textarea",{className:C,value:typeof i=="string"?i:"",placeholder:u.placeholder,disabled:c,onChange:I=>p(I.target.value)}),w?h.jsx("div",{className:"text-xs text-muted-foreground",children:w}):null]}):h.jsxs("label",{className:"block space-y-1",children:[h.jsxs("div",{className:"text-sm font-medium",children:[d,u.required?" *":""]}),h.jsx("input",{type:uh(u),className:C,value:typeof i=="number"?String(i):typeof i=="string"?i:"",placeholder:u.placeholder,disabled:c,onChange:I=>{if(u.schema.type==="number"||u.schema.type==="integer"){p(I.target.value===""?"":Number(I.target.value));return}p(I.target.value)}}),w?h.jsx("div",{className:"text-xs text-muted-foreground",children:w}):null]})}function ih(s,u){const i=ah(u),c=new Set(s.required??[]);return Object.entries(s.properties).map(([p,d])=>{var w,C,E,I,z;return{name:p,schema:d,required:c.has(p),widget:(C=(w=i.fields)==null?void 0:w[p])==null?void 0:C.widget,placeholder:(I=(E=i.fields)==null?void 0:E[p])==null?void 0:I.placeholder,enumLabels:(z=i.enumLabels)==null?void 0:z[p]}})}function uh(s){return s.widget==="file"?"file":s.schema.type==="number"||s.schema.type==="integer"?"number":s.schema.type==="string"&&s.schema.format==="date"?"date":"text"}function ah(s){const u=s==null?void 0:s.ui;return!u||typeof u!="object"?{}:u}function ch(s){const u={};for(const i of s){if("default"in i.schema&&i.schema.default!==void 0){u[i.name]=i.schema.default;continue}if(i.schema.type==="boolean"){u[i.name]=!1;continue}if(i.schema.type==="array"){u[i.name]=[];continue}u[i.name]=""}return u}function ri(s){return s===void 0?"--":s<1e3?`${s} ms`:`${(s/1e3).toFixed(2)} s`}function dh(s){const u=new Date(s);return Number.isNaN(u.getTime())?"未知时间":Dc(u,"MM/dd HH:mm")}function fh({sessions:s,currentSessionId:u,onSelectSession:i,onDeleteSession:c,onCreateSession:p}){return h.jsxs("div",{className:"flex flex-col h-full",children:[h.jsxs("div",{className:"p-4 border-b",children:[h.jsx("h2",{className:"text-lg font-semibold mb-3",children:"会话列表"}),h.jsx(Lt,{onClick:p,className:"w-full",size:"sm",children:"+ 新建会话"})]}),h.jsx(ai,{className:"flex-1",children:h.jsx("div",{className:"p-2 space-y-2",children:s.length===0?h.jsxs("div",{className:"flex flex-col items-center justify-center h-48 text-muted-foreground text-sm p-4",children:[h.jsx(ii,{className:"h-8 w-8 mb-2 opacity-50"}),h.jsx("p",{children:"暂无会话"})]}):s.map(d=>h.jsx(ci,{className:`p-3 cursor-pointer transition-all hover:shadow-md ${u===d.sessionId?"ring-2 ring-primary bg-accent":""}`,onClick:()=>i(d.sessionId),children:h.jsxs("div",{className:"flex items-start justify-between gap-2",children:[h.jsxs("div",{className:"flex-1 min-w-0",children:[h.jsx("h3",{className:"font-medium text-sm truncate mb-1",children:d.title||"未命名会话"}),h.jsxs("div",{className:"space-y-0.5",children:[h.jsxs("div",{className:"text-xs text-muted-foreground",children:["创建于 ",dh(d.createdAt)]}),h.jsxs("div",{className:"text-xs text-muted-foreground",children:[d.messageCount," 条消息"]})]})]}),c&&h.jsx(Lt,{variant:"ghost",size:"icon",className:"h-6 w-6 flex-shrink-0",onClick:w=>{w.stopPropagation(),c(d.sessionId)},children:h.jsx(op,{className:"h-3 w-3"})})]})},d.sessionId))})})]})}function ph(){const[s,u]=q.useState(""),[i,c]=q.useState([]),[p,d]=q.useState(null),[w,C]=q.useState(""),[E,I]=q.useState([]),[z,A]=q.useState("idle"),[Q,K]=q.useState({}),[B,O]=q.useState(!1),[F,re]=q.useState(null),[ue,je]=q.useState(0),[fe,we]=q.useState([]),Pe=q.useRef(null),ye=q.useRef(null),Ie=q.useRef(null),Ae=q.useCallback(y=>{I(T=>[...T,{timestamp:new Date,message:y}])},[]),{send:ve}=ip(`ws://${location.host}/ws`,{onMessage:q.useCallback(y=>{var T;switch("sessionId"in y&&y.sessionId&&y.sessionId.trim()!==""&&y.sessionId!==p&&(console.log("[App] Updating currentSessionId from",p,"to",y.sessionId,"via",y.type),d(y.sessionId)),I(R=>{const G=new Date,te=y.type==="agent.start"&&ye.current!==null?G.getTime()-ye.current:void 0;y.type==="agent.start"&&(Ie.current=G.getTime());const ae=y.type==="agent.done"&&ye.current!==null?G.getTime()-ye.current:void 0,oe=y.type==="agent.done"&&Ie.current!==null?G.getTime()-Ie.current:void 0;if(y.type==="agent.done"&&(ye.current=null,Ie.current=null),y.type==="agent.text"){const ce=R[R.length-1];if(ce&&ce.message.type==="agent.text")return[...R.slice(0,-1),{timestamp:G,message:{type:"agent.text",sessionId:y.sessionId,messageId:y.messageId,parentSessionId:y.parentSessionId,depth:y.depth,transport:y.transport,delta:ce.message.delta+y.delta}}]}return[...R,{timestamp:G,message:y,startLatencyMs:te,totalTimeMs:ae,agentTimeMs:oe}]}),y.type){case"agent.start":A("running");break;case"agent.done":A("idle"),K({tokensUsed:(T=y.result.usage)==null?void 0:T.total});break;case"agent.hitl_requested":case"agent.ui_tool_request":A("idle");break;case"agent.hitl_resumed":case"agent.ui_tool_result":we(R=>R.filter(G=>G!==y.requestId)),A("running");break;case"agent.hitl_cancelled":case"agent.hitl_expired":we(R=>R.filter(G=>G!==y.requestId)),A("idle");break;case"agent.error":case"server.error":A("error");break;case"sessions.list":c(y.sessions);break;case"session.get":d(y.sessionId);break;case"commands.list":re(y.commands);break}},[]),onOpen:q.useCallback(()=>{O(!0)},[]),onClose:q.useCallback(()=>{O(!1)},[])});q.useEffect(()=>{fetch("/api/config").then(y=>y.json()).then(({dataDir:y})=>{u(y),ve({type:"sessions.list",dataDir:y})}).catch(y=>{console.error("Failed to fetch config:",y)})},[ve]),q.useEffect(()=>{!s||!w.trimStart().startsWith("/")||F||ve({type:"commands.list",dataDir:s})},[w,F,s,ve]);const $e=q.useCallback(y=>{if(!y.trim()||!s)return;const T=typeof crypto<"u"&&"randomUUID"in crypto?crypto.randomUUID():`${Date.now()}-${Math.random().toString(16).slice(2)}`,R={type:"agent.send",sessionId:p||void 0,messageId:T,dataDir:s,message:y.trim()};console.log("[App] Sending message with sessionId:",p||"NONE (new session)"),console.log("[App] Full message:",R),ve(R),ye.current=Date.now(),C(""),A("running"),K({})},[s,p,ve]),Z=q.useCallback(()=>{$e(w)},[w,$e]),Re=q.useCallback(()=>{if(!p)return;ve({type:"agent.abort",sessionId:p})},[p,ve]),Oe=q.useCallback(y=>{ve({type:"session.get",sessionId:y,dataDir:s}),I([])},[s,ve]),Le=q.useCallback(async y=>{we(T=>T.includes(y.requestId)?T:[...T,y.requestId]);try{const T=await fetch("/api/hitl/resume",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({dataDir:s,sessionId:y.sessionId,requestId:y.requestId,input:y.input})});if(!T.ok){const R=await T.json().catch(()=>null);throw new Error((R==null?void 0:R.error)??`HTTP ${T.status}`)}A("running")}catch(T){we(R=>R.filter(G=>G!==y.requestId)),A("error"),Ae({type:"server.error",message:`Failed to resume request: ${T.message}`})}},[Ae,s]),Ne=q.useCallback(y=>Le({sessionId:y.sessionId,requestId:y.requestId,input:{action:"submit",values:{selectedChoiceIds:y.choiceId?[y.choiceId]:void 0,text:y.text},idempotencyKey:`${y.requestId}:${y.choiceId??"text"}:${y.text??""}`}}),[Le]),de=q.useCallback(y=>Le({sessionId:y.sessionId,requestId:y.requestId,input:{values:y.values}}),[Le]),M=q.useCallback(async y=>{we(T=>T.includes(y.requestId)?T:[...T,y.requestId]);try{const T=await fetch("/api/hitl/cancel",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({dataDir:s,sessionId:y.sessionId,requestId:y.requestId,reason:"Cancelled from console UI"})});if(!T.ok){const R=await T.json().catch(()=>null);throw new Error((R==null?void 0:R.error)??`HTTP ${T.status}`)}A("running")}catch(T){we(R=>R.filter(G=>G!==y.requestId)),A("error"),Ae({type:"server.error",message:`Failed to cancel HITL request: ${T.message}`})}},[Ae,s]),H=q.useCallback(()=>{d(null),I([]),C(""),K({}),A("idle"),I([{timestamp:new Date,message:{type:"server.info",message:"✨ 已准备好创建新会话,请输入消息开始..."}}])},[]),L=q.useCallback(y=>{const T=Ic(w,F);if(T.length>0){if(y.key==="ArrowDown"){y.preventDefault(),je(R=>(R+1)%T.length);return}if(y.key==="ArrowUp"){y.preventDefault(),je(R=>(R-1+T.length)%T.length);return}if(y.key==="Tab"){y.preventDefault();const R=T[ue]??T[0];R&&C(li(w,R));return}}if(y.key==="Enter"&&!y.shiftKey){if(y.preventDefault(),T.length>0){const R=T[ue]??T[0];if(R){const G=li(w,R);$e(G);return}}Z()}},[Z,w,F,ue]),v=Ic(w,F);return h.jsxs("div",{className:"h-screen flex flex-col bg-background",children:[h.jsxs("header",{className:"border-b px-6 py-3 flex items-center justify-between",children:[h.jsxs("div",{children:[h.jsx("h1",{className:"text-xl font-bold",children:"AIMax CLI 调试控制台"}),h.jsxs("p",{className:"text-sm text-muted-foreground",children:["Data Dir: ",s||"Loading..."]})]}),h.jsxs("div",{className:"flex items-center gap-4",children:[h.jsxs("div",{className:"flex items-center gap-2",children:[h.jsx("div",{className:`h-2 w-2 rounded-full ${B?"bg-green-500":"bg-red-500"}`}),h.jsx("span",{className:"text-sm text-muted-foreground",children:B?"已连接":"未连接"})]}),h.jsxs("div",{className:"flex items-center gap-2",children:[h.jsx("span",{className:"text-sm text-muted-foreground",children:"状态:"}),h.jsx("span",{className:`text-sm font-medium ${z==="running"?"text-blue-500":z==="error"?"text-red-500":"text-green-500"}`,children:z==="running"?"运行中":z==="error"?"错误":"空闲"}),z==="running"&&h.jsx(np,{className:"h-4 w-4 animate-spin"})]})]})]}),h.jsxs("div",{className:"flex-1 flex overflow-hidden",children:[h.jsx("aside",{className:"w-80 border-r",children:h.jsx(fh,{sessions:i,currentSessionId:p,onSelectSession:Oe,onCreateSession:H})}),h.jsxs("main",{className:"flex-1 flex flex-col overflow-hidden",children:[h.jsx("div",{className:"flex-1 border-b",children:h.jsx(th,{events:E,pendingRequestIds:fe,onSubmitHitl:Ne,onSubmitUiTool:de,onCancelHitl:M})}),h.jsxs("div",{className:"border-t p-4 space-y-3",children:[h.jsxs("div",{className:"relative",children:[h.jsx("textarea",{ref:Pe,value:w,onChange:y=>C(y.target.value),onKeyDown:L,placeholder:"输入消息或指令... (Shift+Enter 换行, Enter 发送)",className:"w-full min-h-[80px] max-h-[200px] p-3 pr-12 rounded-md border border-input bg-background text-sm ring-offset-background placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50",disabled:z==="running"||!B}),v.length>0&&h.jsx("div",{className:"absolute left-0 right-0 bottom-[calc(100%+8px)] bg-background border border-input rounded-md shadow-lg max-h-56 overflow-auto z-10",children:v.map((y,T)=>h.jsx("button",{type:"button",className:`w-full text-left px-3 py-2 text-sm hover:bg-accent hover:text-accent-foreground ${T===ue?"bg-accent text-accent-foreground":""}`,onMouseDown:R=>{R.preventDefault(),C(li(w,y))},children:h.jsxs("div",{className:"flex items-center justify-between gap-3",children:[h.jsx("span",{className:"font-mono",children:y.name}),h.jsx("span",{className:"text-xs text-muted-foreground truncate",children:y.description})]})},y.name))}),h.jsx(Lt,{onClick:Z,disabled:!w.trim()||z==="running"||!B,className:"absolute right-2 bottom-3 p-2 h-9 w-9",size:"icon",children:h.jsx(rp,{className:"h-4 w-4"})})]}),h.jsxs("div",{className:"flex items-center justify-between",children:[h.jsx("div",{className:"flex gap-2",children:z==="running"&&p&&h.jsxs(Lt,{onClick:Re,disabled:!B,variant:"destructive",size:"sm",children:[h.jsx(lp,{className:"h-4 w-4 mr-2"}),"中止"]})}),h.jsxs("div",{className:"flex items-center gap-4 text-sm text-muted-foreground",children:[Q.tokensUsed&&h.jsxs("span",{children:["Tokens: ",Q.tokensUsed]}),Q.costUsd&&h.jsxs("span",{children:["Cost: $",Q.costUsd.toFixed(4)]}),p&&h.jsxs("span",{className:"font-mono text-xs",children:["Session: ",p.slice(0,8),"..."]})]})]})]})]})]})]})}function Ic(s,u){if(!u)return[];const i=s.trimStart();if(!i.startsWith("/"))return[];const p=(i.split(/\s+/)[0]??"").toLowerCase(),d=u.all;return!p||p==="/"?d.slice(0,10):d.filter(w=>w.name.toLowerCase().startsWith(p)).slice(0,10)}function li(s,u){var w;const i=((w=s.match(/^\s*/))==null?void 0:w[0])??"",c=s.search(/\s/),p=c===-1?"":s.slice(c),d=p&&p.trim().length>0?p:" ";return`${i}${u.name}${d}`}const mh=Gf.createRoot(document.getElementById("root"));mh.render(h.jsx(Ar.StrictMode,{children:h.jsx(ph,{})}));
141
+ `)})]});case"agent.skill_used":return h.jsxs("div",{className:"space-y-1",children:[h.jsx("div",{className:"font-medium",children:d.skillName}),d.messageId&&h.jsxs("div",{className:"text-xs text-muted-foreground",children:["Message: ",d.messageId]}),h.jsxs("div",{className:"text-xs text-muted-foreground",children:["Agent: ",d.agent]}),h.jsxs("div",{className:"text-xs text-muted-foreground",children:["Task: ",d.taskId]})]});case"agent.subagent_spawn":return h.jsxs("div",{className:"space-y-1",children:[h.jsxs("div",{children:["Child Session: ",d.childSessionId]}),d.messageId&&h.jsxs("div",{className:"text-xs text-muted-foreground",children:["Message: ",d.messageId]}),h.jsxs("div",{className:"text-xs text-muted-foreground",children:["Task: ",d.task]}),d.label&&h.jsxs("div",{className:"text-xs text-muted-foreground",children:["Label: ",d.label]})]});case"agent.subagent_complete":return h.jsxs("div",{className:"space-y-1",children:[h.jsxs("div",{children:["Child Session: ",d.childSessionId]}),d.messageId&&h.jsxs("div",{className:"text-xs text-muted-foreground",children:["Message: ",d.messageId]}),h.jsxs("div",{className:"text-xs text-muted-foreground",children:["Status: ",d.status]})]});case"agent.hitl_requested":{const E=d.request,I=E.input.mode==="choice"?E.input.choices??[]:[];return h.jsx(lh,{sessionId:d.sessionId,requestId:E.requestId,title:E.title,prompt:E.prompt,preview:(w=E.preview)==null?void 0:w.content,choices:I,allowText:E.input.mode==="text"||E.input.mode==="choice"&&!!E.input.allowFreeText,pending:u.has(E.requestId),onSubmit:i,onCancel:p})}case"agent.hitl_resumed":return h.jsxs("div",{children:["Request resumed: ",d.requestId]});case"agent.hitl_expired":return h.jsxs("div",{children:["Request expired: ",d.requestId," · ",d.reason]});case"agent.hitl_cancelled":return h.jsxs("div",{children:["Request cancelled: ",d.requestId,d.reason?` · ${d.reason}`:""]});case"agent.ui_tool_request":return h.jsx(oh,{sessionId:d.sessionId,requestId:d.request.requestId,toolName:d.request.toolName,schema:d.request.outputSchema,extra:d.request.extra,pending:u.has(d.request.requestId),onSubmit:c});case"agent.ui_tool_result":return h.jsxs("div",{className:"space-y-1",children:[h.jsx("div",{className:"font-medium",children:d.toolName}),h.jsxs("div",{className:"text-xs text-muted-foreground",children:["Request resumed: ",d.requestId]}),h.jsx("pre",{className:"text-xs bg-muted p-2 rounded overflow-x-auto",children:JSON.stringify(d.values,null,2)})]});case"agent.done":return h.jsxs("div",{className:"space-y-1",children:[h.jsxs("div",{className:"text-xs text-muted-foreground",children:["Total: ",ri(s.totalTimeMs),h.jsxs("span",{className:"ml-2",children:["Agent: ",ri(s.agentTimeMs)]})]}),d.messageId&&h.jsxs("div",{className:"text-xs text-muted-foreground",children:["Message: ",d.messageId]}),d.result.paused&&h.jsxs("div",{className:"rounded-md border border-amber-300 bg-amber-50 px-3 py-2 text-amber-900",children:[h.jsxs("div",{className:"font-medium",children:["Paused for HITL: ",d.result.paused.title]}),h.jsxs("div",{className:"text-xs",children:["Request: ",d.result.paused.requestId," · Kind: ",d.result.paused.kind]})]}),d.result.text&&h.jsx("div",{className:"whitespace-pre-wrap break-words",children:d.result.paused&&d.result.text==="HITL_PAUSED"?"Run paused and waiting for human input.":d.result.text}),d.result.error&&h.jsxs("div",{className:"text-sm text-destructive",children:["Error: ",d.result.error]}),d.result.aborted&&h.jsx("div",{className:"text-sm text-yellow-500",children:"Aborted"}),((C=d.result.usage)==null?void 0:C.total)&&h.jsxs("div",{className:"text-xs text-muted-foreground",children:["Tokens: ",d.result.usage.total]})]});case"agent.error":return h.jsxs("div",{className:"space-y-1",children:[d.messageId&&h.jsxs("div",{className:"text-xs text-muted-foreground",children:["Message: ",d.messageId]}),h.jsx("span",{className:"text-destructive",children:d.message})]});case"session.reset":{const E=d.action==="new"?"new session":"reset session";return h.jsxs("div",{className:"space-y-1",children:[h.jsxs("div",{className:"text-xs text-muted-foreground",children:[E," · Session: ",d.sessionId]}),d.previousSessionId&&h.jsxs("div",{className:"text-xs text-muted-foreground",children:["Previous: ",d.previousSessionId]}),h.jsxs("div",{className:"text-sm",children:["Trigger: ",d.message]})]})}case"server.info":return h.jsx("span",{className:"text-blue-500",children:d.message});case"server.error":return h.jsx("span",{className:"text-destructive",children:d.message});case"sessions.list":return h.jsxs("span",{children:["Sessions: ",d.sessions.length]});case"session.get":return h.jsxs("span",{children:["Session loaded: ",d.sessionId]});default:return null}}function lh(s){const[u,i]=Ar.useState("");return h.jsxs("div",{className:"space-y-3 rounded-lg border border-amber-200 bg-amber-50 p-3",children:[h.jsxs("div",{children:[h.jsx("div",{className:"font-semibold",children:s.title}),h.jsx("div",{className:"text-sm text-slate-700 whitespace-pre-wrap",children:s.prompt})]}),s.preview?h.jsx("pre",{className:"max-h-56 overflow-auto rounded bg-white p-2 text-xs whitespace-pre-wrap",children:s.preview}):null,s.allowText?h.jsx("textarea",{className:"w-full rounded border bg-white p-2 text-sm",placeholder:"Optional response...",value:u,onChange:c=>i(c.target.value),disabled:s.pending}):null,s.pending?h.jsx("div",{className:"text-xs font-medium text-amber-700",children:"Submitting HITL response..."}):null,h.jsxs("div",{className:"flex flex-wrap gap-2",children:[s.choices.map(c=>h.jsx(Lt,{size:"sm",disabled:s.pending,onClick:()=>{var p;return(p=s.onSubmit)==null?void 0:p.call(s,{sessionId:s.sessionId,requestId:s.requestId,choiceId:c.id,text:u.trim()||void 0})},children:c.label},c.id)),s.choices.length===0?h.jsx(Lt,{size:"sm",disabled:s.pending,onClick:()=>{var c;return(c=s.onSubmit)==null?void 0:c.call(s,{sessionId:s.sessionId,requestId:s.requestId,text:u.trim()||void 0})},children:"Submit"}):null,h.jsx(Lt,{size:"sm",variant:"outline",disabled:s.pending,onClick:()=>{var c;return(c=s.onCancel)==null?void 0:c.call(s,{sessionId:s.sessionId,requestId:s.requestId})},children:"Cancel"})]})]})}function oh(s){const u=Ar.useMemo(()=>ih(s.schema,s.extra),[s.schema,s.extra]),[i,c]=Ar.useState(()=>ch(u)),p=Ar.useCallback((d,w)=>{c(C=>({...C,[d]:w}))},[]);return h.jsxs("div",{className:"space-y-3 rounded-lg border border-violet-200 bg-violet-50 p-3",children:[h.jsxs("div",{children:[h.jsx("div",{className:"font-semibold",children:s.schema.title}),h.jsxs("div",{className:"text-xs text-muted-foreground",children:["Tool: ",s.toolName]}),s.schema.description?h.jsx("div",{className:"text-sm text-slate-700 whitespace-pre-wrap",children:s.schema.description}):null]}),h.jsx("div",{className:"space-y-3",children:u.map(d=>h.jsx(sh,{field:d,value:i[d.name],disabled:s.pending,onChange:w=>p(d.name,w)},d.name))}),s.pending?h.jsx("div",{className:"text-xs font-medium text-violet-700",children:"Submitting UI tool response..."}):null,h.jsx("div",{className:"flex flex-wrap gap-2",children:h.jsx(Lt,{size:"sm",disabled:s.pending,onClick:()=>{var d;return(d=s.onSubmit)==null?void 0:d.call(s,{sessionId:s.sessionId,requestId:s.requestId,values:i})},children:"Submit"})})]})}function Pc(s){return!s||!("enum"in s)||!Array.isArray(s.enum)?[]:s.enum.filter(u=>typeof u=="string")}function sh(s){const{field:u,value:i,disabled:c,onChange:p}=s,d=u.schema.title??u.name,w=u.schema.description||u.placeholder,C="w-full rounded border bg-white p-2 text-sm";if(u.schema.type==="boolean")return h.jsxs("label",{className:"block space-y-1",children:[h.jsxs("div",{className:"text-sm font-medium",children:[d,u.required?" *":""]}),h.jsx("input",{type:"checkbox",checked:!!i,disabled:c,onChange:I=>p(I.target.checked)}),w?h.jsx("div",{className:"text-xs text-muted-foreground",children:w}):null]});if(u.schema.type==="array"){const I=Pc(u.schema.items);return h.jsxs("label",{className:"block space-y-1",children:[h.jsxs("div",{className:"text-sm font-medium",children:[d,u.required?" *":""]}),h.jsx("select",{multiple:!0,className:C,value:Array.isArray(i)?i.filter(z=>typeof z=="string"):[],disabled:c,onChange:z=>p(Array.from(z.target.selectedOptions,A=>A.value)),children:I.map(z=>{var A;return h.jsx("option",{value:z,children:((A=u.enumLabels)==null?void 0:A[z])??z},z)})}),w?h.jsx("div",{className:"text-xs text-muted-foreground",children:w}):null]})}const E=Pc(u.schema);return E.length>0?h.jsxs("label",{className:"block space-y-1",children:[h.jsxs("div",{className:"text-sm font-medium",children:[d,u.required?" *":""]}),h.jsxs("select",{className:C,value:typeof i=="string"?i:"",disabled:c,onChange:I=>p(I.target.value),children:[h.jsx("option",{value:"",children:u.placeholder??"Select an option"}),E.map(I=>{var z;return h.jsx("option",{value:I,children:((z=u.enumLabels)==null?void 0:z[I])??I},I)})]}),w?h.jsx("div",{className:"text-xs text-muted-foreground",children:w}):null]}):u.widget==="textarea"?h.jsxs("label",{className:"block space-y-1",children:[h.jsxs("div",{className:"text-sm font-medium",children:[d,u.required?" *":""]}),h.jsx("textarea",{className:C,value:typeof i=="string"?i:"",placeholder:u.placeholder,disabled:c,onChange:I=>p(I.target.value)}),w?h.jsx("div",{className:"text-xs text-muted-foreground",children:w}):null]}):h.jsxs("label",{className:"block space-y-1",children:[h.jsxs("div",{className:"text-sm font-medium",children:[d,u.required?" *":""]}),h.jsx("input",{type:uh(u),className:C,value:typeof i=="number"?String(i):typeof i=="string"?i:"",placeholder:u.placeholder,disabled:c,onChange:I=>{if(u.schema.type==="number"||u.schema.type==="integer"){p(I.target.value===""?"":Number(I.target.value));return}p(I.target.value)}}),w?h.jsx("div",{className:"text-xs text-muted-foreground",children:w}):null]})}function ih(s,u){const i=ah(u),c=new Set(s.required??[]);return Object.entries(s.properties).map(([p,d])=>{var w,C,E,I,z;return{name:p,schema:d,required:c.has(p),widget:(C=(w=i.fields)==null?void 0:w[p])==null?void 0:C.widget,placeholder:(I=(E=i.fields)==null?void 0:E[p])==null?void 0:I.placeholder,enumLabels:(z=i.enumLabels)==null?void 0:z[p]}})}function uh(s){return s.widget==="file"?"file":s.schema.type==="number"||s.schema.type==="integer"?"number":s.schema.type==="string"&&s.schema.format==="date"?"date":"text"}function ah(s){const u=s==null?void 0:s.ui;return!u||typeof u!="object"?{}:u}function ch(s){const u={};for(const i of s){if("default"in i.schema&&i.schema.default!==void 0){u[i.name]=i.schema.default;continue}if(i.schema.type==="boolean"){u[i.name]=!1;continue}if(i.schema.type==="array"){u[i.name]=[];continue}u[i.name]=""}return u}function ri(s){return s===void 0?"--":s<1e3?`${s} ms`:`${(s/1e3).toFixed(2)} s`}function dh(s){const u=new Date(s);return Number.isNaN(u.getTime())?"未知时间":Dc(u,"MM/dd HH:mm")}function fh({sessions:s,currentSessionId:u,onSelectSession:i,onDeleteSession:c,onCreateSession:p}){return h.jsxs("div",{className:"flex flex-col h-full",children:[h.jsxs("div",{className:"p-4 border-b",children:[h.jsx("h2",{className:"text-lg font-semibold mb-3",children:"会话列表"}),h.jsx(Lt,{onClick:p,className:"w-full",size:"sm",children:"+ 新建会话"})]}),h.jsx(ai,{className:"flex-1",children:h.jsx("div",{className:"p-2 space-y-2",children:s.length===0?h.jsxs("div",{className:"flex flex-col items-center justify-center h-48 text-muted-foreground text-sm p-4",children:[h.jsx(ii,{className:"h-8 w-8 mb-2 opacity-50"}),h.jsx("p",{children:"暂无会话"})]}):s.map(d=>h.jsx(ci,{className:`p-3 cursor-pointer transition-all hover:shadow-md ${u===d.sessionId?"ring-2 ring-primary bg-accent":""}`,onClick:()=>i(d.sessionId),children:h.jsxs("div",{className:"flex items-start justify-between gap-2",children:[h.jsxs("div",{className:"flex-1 min-w-0",children:[h.jsx("h3",{className:"font-medium text-sm truncate mb-1",children:d.title||"未命名会话"}),h.jsxs("div",{className:"space-y-0.5",children:[h.jsxs("div",{className:"text-xs text-muted-foreground",children:["创建于 ",dh(d.createdAt)]}),h.jsxs("div",{className:"text-xs text-muted-foreground",children:[d.messageCount," 条消息"]})]})]}),c&&h.jsx(Lt,{variant:"ghost",size:"icon",className:"h-6 w-6 flex-shrink-0",onClick:w=>{w.stopPropagation(),c(d.sessionId)},children:h.jsx(op,{className:"h-3 w-3"})})]})},d.sessionId))})})]})}function ph(){const[s,u]=q.useState(""),[i,c]=q.useState([]),[p,d]=q.useState(null),[w,C]=q.useState(""),[E,I]=q.useState([]),[z,A]=q.useState("idle"),[Q,K]=q.useState({}),[B,O]=q.useState(!1),[F,re]=q.useState(null),[ue,je]=q.useState(0),[fe,we]=q.useState([]),Pe=q.useRef(null),ye=q.useRef(null),Ie=q.useRef(null),Ae=q.useCallback(y=>{I(T=>[...T,{timestamp:new Date,message:y}])},[]),{send:ve}=ip(`ws://${location.host}/ws`,{onMessage:q.useCallback(y=>{var T;switch("sessionId"in y&&y.sessionId&&y.sessionId.trim()!==""&&y.sessionId!==p&&(console.log("[App] Updating currentSessionId from",p,"to",y.sessionId,"via",y.type),d(y.sessionId)),I(R=>{const G=new Date,te=y.type==="agent.start"&&ye.current!==null?G.getTime()-ye.current:void 0;y.type==="agent.start"&&(Ie.current=G.getTime());const ae=y.type==="agent.done"&&ye.current!==null?G.getTime()-ye.current:void 0,oe=y.type==="agent.done"&&Ie.current!==null?G.getTime()-Ie.current:void 0;if(y.type==="agent.done"&&(ye.current=null,Ie.current=null),y.type==="agent.text"){const ce=R[R.length-1];if(ce&&ce.message.type==="agent.text")return[...R.slice(0,-1),{timestamp:G,message:{type:"agent.text",sessionId:y.sessionId,messageId:y.messageId,parentSessionId:y.parentSessionId,depth:y.depth,transport:y.transport,delta:ce.message.delta+y.delta}}]}return[...R,{timestamp:G,message:y,startLatencyMs:te,totalTimeMs:ae,agentTimeMs:oe}]}),y.type){case"agent.start":A("running");break;case"agent.done":A("idle"),K({tokensUsed:(T=y.result.usage)==null?void 0:T.total});break;case"agent.hitl_requested":case"agent.ui_tool_request":A("idle");break;case"agent.hitl_resumed":case"agent.ui_tool_result":we(R=>R.filter(G=>G!==y.requestId)),A("running");break;case"agent.hitl_cancelled":case"agent.hitl_expired":we(R=>R.filter(G=>G!==y.requestId)),A("idle");break;case"agent.error":case"server.error":A("error");break;case"sessions.list":c(y.sessions);break;case"session.get":d(y.sessionId);break;case"commands.list":re(y.commands);break}},[]),onOpen:q.useCallback(()=>{O(!0)},[]),onClose:q.useCallback(()=>{O(!1)},[])});q.useEffect(()=>{fetch("/api/config").then(y=>y.json()).then(({dataDir:y})=>{u(y),ve({type:"sessions.list",dataDir:y})}).catch(y=>{console.error("Failed to fetch config:",y)})},[ve]),q.useEffect(()=>{!s||!w.trimStart().startsWith("/")||F||ve({type:"commands.list",dataDir:s})},[w,F,s,ve]);const $e=q.useCallback(y=>{if(!y.trim()||!s)return;const T=typeof crypto<"u"&&"randomUUID"in crypto?crypto.randomUUID():`${Date.now()}-${Math.random().toString(16).slice(2)}`,R={type:"agent.send",sessionId:p||void 0,messageId:T,dataDir:s,message:y.trim()};console.log("[App] Sending message with sessionId:",p||"NONE (new session)"),console.log("[App] Full message:",R),ve(R),ye.current=Date.now(),C(""),A("running"),K({})},[s,p,ve]),Z=q.useCallback(()=>{$e(w)},[w,$e]),Re=q.useCallback(()=>{if(!p)return;ve({type:"agent.abort",sessionId:p})},[p,ve]),Oe=q.useCallback(y=>{ve({type:"session.get",sessionId:y,dataDir:s}),I([])},[s,ve]),Le=q.useCallback(async y=>{we(T=>T.includes(y.requestId)?T:[...T,y.requestId]);try{const T=await fetch("/api/hitl/resume",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({dataDir:s,sessionId:y.sessionId,requestId:y.requestId,input:y.input})});if(!T.ok){const R=await T.json().catch(()=>null);throw new Error((R==null?void 0:R.error)??`HTTP ${T.status}`)}A("running")}catch(T){we(R=>R.filter(G=>G!==y.requestId)),A("error"),Ae({type:"server.error",message:`Failed to resume request: ${T.message}`})}},[Ae,s]),Ne=q.useCallback(y=>Le({sessionId:y.sessionId,requestId:y.requestId,input:{action:"submit",values:{selectedChoiceIds:y.choiceId?[y.choiceId]:void 0,text:y.text},idempotencyKey:`${y.requestId}:${y.choiceId??"text"}:${y.text??""}`}}),[Le]),de=q.useCallback(y=>Le({sessionId:y.sessionId,requestId:y.requestId,input:{values:y.values}}),[Le]),M=q.useCallback(async y=>{we(T=>T.includes(y.requestId)?T:[...T,y.requestId]);try{const T=await fetch("/api/hitl/cancel",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({dataDir:s,sessionId:y.sessionId,requestId:y.requestId,reason:"Cancelled from console UI"})});if(!T.ok){const R=await T.json().catch(()=>null);throw new Error((R==null?void 0:R.error)??`HTTP ${T.status}`)}A("running")}catch(T){we(R=>R.filter(G=>G!==y.requestId)),A("error"),Ae({type:"server.error",message:`Failed to cancel HITL request: ${T.message}`})}},[Ae,s]),H=q.useCallback(()=>{d(null),I([]),C(""),K({}),A("idle"),I([{timestamp:new Date,message:{type:"server.info",message:"✨ 已准备好创建新会话,请输入消息开始..."}}])},[]),L=q.useCallback(y=>{const T=Ic(w,F);if(T.length>0){if(y.key==="ArrowDown"){y.preventDefault(),je(R=>(R+1)%T.length);return}if(y.key==="ArrowUp"){y.preventDefault(),je(R=>(R-1+T.length)%T.length);return}if(y.key==="Tab"){y.preventDefault();const R=T[ue]??T[0];R&&C(li(w,R));return}}if(y.key==="Enter"&&!y.shiftKey){if(y.preventDefault(),T.length>0){const R=T[ue]??T[0];if(R){const G=li(w,R);$e(G);return}}Z()}},[Z,w,F,ue]),v=Ic(w,F);return h.jsxs("div",{className:"h-screen flex flex-col bg-background",children:[h.jsxs("header",{className:"border-b px-6 py-3 flex items-center justify-between",children:[h.jsxs("div",{children:[h.jsx("h1",{className:"text-xl font-bold",children:"AIMax CLI 调试控制台"}),h.jsxs("p",{className:"text-sm text-muted-foreground",children:["Data Dir: ",s||"Loading..."]})]}),h.jsxs("div",{className:"flex items-center gap-4",children:[h.jsxs("div",{className:"flex items-center gap-2",children:[h.jsx("div",{className:`h-2 w-2 rounded-full ${B?"bg-green-500":"bg-red-500"}`}),h.jsx("span",{className:"text-sm text-muted-foreground",children:B?"已连接":"未连接"})]}),h.jsxs("div",{className:"flex items-center gap-2",children:[h.jsx("span",{className:"text-sm text-muted-foreground",children:"状态:"}),h.jsx("span",{className:`text-sm font-medium ${z==="running"?"text-blue-500":z==="error"?"text-red-500":"text-green-500"}`,children:z==="running"?"运行中":z==="error"?"错误":"空闲"}),z==="running"&&h.jsx(np,{className:"h-4 w-4 animate-spin"})]})]})]}),h.jsxs("div",{className:"flex-1 flex overflow-hidden",children:[h.jsx("aside",{className:"w-80 border-r",children:h.jsx(fh,{sessions:i,currentSessionId:p,onSelectSession:Oe,onCreateSession:H})}),h.jsxs("main",{className:"flex-1 flex flex-col overflow-hidden",children:[h.jsx("div",{className:"flex-1 border-b",children:h.jsx(th,{events:E,pendingRequestIds:fe,onSubmitHitl:Ne,onSubmitUiTool:de,onCancelHitl:M})}),h.jsxs("div",{className:"border-t p-4 space-y-3",children:[h.jsxs("div",{className:"relative",children:[h.jsx("textarea",{ref:Pe,value:w,onChange:y=>C(y.target.value),onKeyDown:L,placeholder:"输入消息或指令... (Shift+Enter 换行, Enter 发送)",className:"w-full min-h-[80px] max-h-[200px] p-3 pr-12 rounded-md border border-input bg-background text-sm ring-offset-background placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50",disabled:z==="running"||!B}),v.length>0&&h.jsx("div",{className:"absolute left-0 right-0 bottom-[calc(100%+8px)] bg-background border border-input rounded-md shadow-lg max-h-56 overflow-auto z-10",children:v.map((y,T)=>h.jsx("button",{type:"button",className:`w-full text-left px-3 py-2 text-sm hover:bg-accent hover:text-accent-foreground ${T===ue?"bg-accent text-accent-foreground":""}`,onMouseDown:R=>{R.preventDefault(),C(li(w,y))},children:h.jsxs("div",{className:"flex items-center justify-between gap-3",children:[h.jsx("span",{className:"font-mono",children:y.name}),h.jsx("span",{className:"text-xs text-muted-foreground truncate",children:y.description})]})},y.name))}),h.jsx(Lt,{onClick:Z,disabled:!w.trim()||z==="running"||!B,className:"absolute right-2 bottom-3 p-2 h-9 w-9",size:"icon",children:h.jsx(rp,{className:"h-4 w-4"})})]}),h.jsxs("div",{className:"flex items-center justify-between",children:[h.jsx("div",{className:"flex gap-2",children:z==="running"&&p&&h.jsxs(Lt,{onClick:Re,disabled:!B,variant:"destructive",size:"sm",children:[h.jsx(lp,{className:"h-4 w-4 mr-2"}),"中止"]})}),h.jsxs("div",{className:"flex items-center gap-4 text-sm text-muted-foreground",children:[Q.tokensUsed&&h.jsxs("span",{children:["Tokens: ",Q.tokensUsed]}),Q.costUsd&&h.jsxs("span",{children:["Cost: $",Q.costUsd.toFixed(4)]}),p&&h.jsxs("span",{className:"font-mono text-xs",children:["Session: ",p.slice(0,8),"..."]})]})]})]})]})]})]})}function Ic(s,u){if(!u)return[];const i=s.trimStart();if(!i.startsWith("/"))return[];const p=(i.split(/\s+/)[0]??"").toLowerCase(),d=u.all;return!p||p==="/"?d.slice(0,10):d.filter(w=>w.name.toLowerCase().startsWith(p)).slice(0,10)}function li(s,u){var w;const i=((w=s.match(/^\s*/))==null?void 0:w[0])??"",c=s.search(/\s/),p=c===-1?"":s.slice(c),d=p&&p.trim().length>0?p:" ";return`${i}${u.name}${d}`}const mh=Gf.createRoot(document.getElementById("root"));mh.render(h.jsx(Ar.StrictMode,{children:h.jsx(ph,{})}));
@@ -4,7 +4,7 @@
4
4
  <meta charset="UTF-8">
5
5
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
6
6
  <title>AIMax CLI 调试控制台</title>
7
- <script type="module" crossorigin src="/assets/main-r30FMOAm.js"></script>
7
+ <script type="module" crossorigin src="/assets/main-0NLhfmNT.js"></script>
8
8
  <link rel="stylesheet" crossorigin href="/assets/main-DnC1n1zE.css">
9
9
  </head>
10
10
  <body>
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gencode/console",
3
- "version": "0.0.9",
3
+ "version": "0.0.10",
4
4
  "type": "module",
5
5
  "bin": {
6
6
  "aimax-console": "./dist/server/index.js"
@@ -25,8 +25,8 @@
25
25
  "ws": "^8.18.0",
26
26
  "react": "^18.3.1",
27
27
  "react-dom": "^18.3.1",
28
- "@gencode/cli": "0.0.41",
29
- "@gencode/shared": "0.0.14"
28
+ "@gencode/cli": "0.0.42",
29
+ "@gencode/shared": "0.0.15"
30
30
  },
31
31
  "devDependencies": {
32
32
  "@types/ws": "^8.5.13",