@markus-global/cli 0.8.5-rc.1 → 0.8.5

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.
Files changed (52) hide show
  1. package/dist/web-ui/assets/{arc-Bsag-Glv.js → arc-BdRlL2iO.js} +1 -1
  2. package/dist/web-ui/assets/{architectureDiagram-3BPJPVTR-Bsoce9kv.js → architectureDiagram-3BPJPVTR-D0tUssz3.js} +1 -1
  3. package/dist/web-ui/assets/{blockDiagram-GPEHLZMM-yKU648MS.js → blockDiagram-GPEHLZMM-BpzalW_a.js} +1 -1
  4. package/dist/web-ui/assets/{c4Diagram-AAUBKEIU-D9jqfIyV.js → c4Diagram-AAUBKEIU-BCAI0V-n.js} +1 -1
  5. package/dist/web-ui/assets/channel-CVrfB_bR.js +1 -0
  6. package/dist/web-ui/assets/{chunk-2J33WTMH-CvLORSm0.js → chunk-2J33WTMH-Dg7rYV2F.js} +1 -1
  7. package/dist/web-ui/assets/{chunk-4BX2VUAB-BZK80okI.js → chunk-4BX2VUAB-NjIIklhn.js} +1 -1
  8. package/dist/web-ui/assets/{chunk-55IACEB6-BitRVHKz.js → chunk-55IACEB6-D1NbvEGQ.js} +1 -1
  9. package/dist/web-ui/assets/{chunk-727SXJPM-D1wO8ccL.js → chunk-727SXJPM-D4yVMcHy.js} +1 -1
  10. package/dist/web-ui/assets/{chunk-AQP2D5EJ-Dp5afjp3.js → chunk-AQP2D5EJ-BZ2R83hR.js} +1 -1
  11. package/dist/web-ui/assets/{chunk-FMBD7UC4-cLk0KREg.js → chunk-FMBD7UC4-dKKoHR7V.js} +1 -1
  12. package/dist/web-ui/assets/{chunk-ND2GUHAM-DD3gGcwY.js → chunk-ND2GUHAM-8DcNh3kD.js} +1 -1
  13. package/dist/web-ui/assets/{chunk-QZHKN3VN-cFGEueLz.js → chunk-QZHKN3VN-QK1OECHO.js} +1 -1
  14. package/dist/web-ui/assets/classDiagram-4FO5ZUOK-vzqgiM0p.js +1 -0
  15. package/dist/web-ui/assets/classDiagram-v2-Q7XG4LA2-vzqgiM0p.js +1 -0
  16. package/dist/web-ui/assets/{cose-bilkent-S5V4N54A-BcN_2hrp.js → cose-bilkent-S5V4N54A-70zGiErc.js} +1 -1
  17. package/dist/web-ui/assets/{dagre-BM42HDAG-CO_IlaG_.js → dagre-BM42HDAG-CjH95T53.js} +1 -1
  18. package/dist/web-ui/assets/{diagram-2AECGRRQ-Nbt4IydR.js → diagram-2AECGRRQ-D1h-kJfb.js} +1 -1
  19. package/dist/web-ui/assets/{diagram-5GNKFQAL-CIpLuKrx.js → diagram-5GNKFQAL-BfpyuUIG.js} +1 -1
  20. package/dist/web-ui/assets/{diagram-KO2AKTUF-DIQUaXHZ.js → diagram-KO2AKTUF-BAPzH4PL.js} +1 -1
  21. package/dist/web-ui/assets/{diagram-LMA3HP47-62f0WnnG.js → diagram-LMA3HP47-BzZcoqw9.js} +1 -1
  22. package/dist/web-ui/assets/{diagram-OG6HWLK6-jRDG8kTS.js → diagram-OG6HWLK6-UzfnxP-8.js} +1 -1
  23. package/dist/web-ui/assets/{erDiagram-TEJ5UH35-DBxHwsak.js → erDiagram-TEJ5UH35-C5lPAlAw.js} +1 -1
  24. package/dist/web-ui/assets/{flowDiagram-I6XJVG4X-CID468IB.js → flowDiagram-I6XJVG4X-B3yPTMtT.js} +1 -1
  25. package/dist/web-ui/assets/{ganttDiagram-6RSMTGT7-Bna3kLSY.js → ganttDiagram-6RSMTGT7-M0LiSJYB.js} +1 -1
  26. package/dist/web-ui/assets/{gitGraphDiagram-PVQCEYII-CPy_4OVv.js → gitGraphDiagram-PVQCEYII-DMJ8bJ-V.js} +1 -1
  27. package/dist/web-ui/assets/{index-ejNkFdfR.js → index-C0TJwd4k.js} +2 -2
  28. package/dist/web-ui/assets/{infoDiagram-5YYISTIA-DL0FQqmP.js → infoDiagram-5YYISTIA-H3O_dXaX.js} +1 -1
  29. package/dist/web-ui/assets/{ishikawaDiagram-YF4QCWOH-Cfk_Dhf3.js → ishikawaDiagram-YF4QCWOH-BRM-2a0M.js} +1 -1
  30. package/dist/web-ui/assets/{journeyDiagram-JHISSGLW-DYGBieTo.js → journeyDiagram-JHISSGLW-ETvNwLl4.js} +1 -1
  31. package/dist/web-ui/assets/{kanban-definition-UN3LZRKU-BXJ8grdW.js → kanban-definition-UN3LZRKU-D066SbN9.js} +1 -1
  32. package/dist/web-ui/assets/{linear-D-CiXdaS.js → linear-w-ZA_ecm.js} +1 -1
  33. package/dist/web-ui/assets/{mermaid.core-BHJDz64r.js → mermaid.core-rPZMstL0.js} +5 -5
  34. package/dist/web-ui/assets/{mindmap-definition-RKZ34NQL-B8z5oNDH.js → mindmap-definition-RKZ34NQL-BKYYirSK.js} +1 -1
  35. package/dist/web-ui/assets/{pieDiagram-4H26LBE5-DyK-mtmy.js → pieDiagram-4H26LBE5-Cwjk7qIl.js} +1 -1
  36. package/dist/web-ui/assets/{quadrantDiagram-W4KKPZXB-vrSbdkia.js → quadrantDiagram-W4KKPZXB-V5VbcvJY.js} +1 -1
  37. package/dist/web-ui/assets/{requirementDiagram-4Y6WPE33-CgqB56TU.js → requirementDiagram-4Y6WPE33-D2uVfqfP.js} +1 -1
  38. package/dist/web-ui/assets/{sankeyDiagram-5OEKKPKP-BKw6c5Hg.js → sankeyDiagram-5OEKKPKP-C8ejeGTc.js} +1 -1
  39. package/dist/web-ui/assets/{sequenceDiagram-3UESZ5HK-tfL1U11H.js → sequenceDiagram-3UESZ5HK-CI3unFup.js} +1 -1
  40. package/dist/web-ui/assets/{stateDiagram-AJRCARHV-CxQ0FH92.js → stateDiagram-AJRCARHV-C4edfdOw.js} +1 -1
  41. package/dist/web-ui/assets/stateDiagram-v2-BHNVJYJU-CzloKUKx.js +1 -0
  42. package/dist/web-ui/assets/{timeline-definition-PNZ67QCA-DkvoQzvL.js → timeline-definition-PNZ67QCA-BrkWr53g.js} +1 -1
  43. package/dist/web-ui/assets/{vennDiagram-CIIHVFJN-yVw45STE.js → vennDiagram-CIIHVFJN-C8mr8EAq.js} +1 -1
  44. package/dist/web-ui/assets/{wardley-L42UT6IY-GoL7yU6X.js → wardley-L42UT6IY-BFlL89Fu.js} +1 -1
  45. package/dist/web-ui/assets/{wardleyDiagram-YWT4CUSO-C6vYm0ap.js → wardleyDiagram-YWT4CUSO-CezrtcCI.js} +1 -1
  46. package/dist/web-ui/assets/{xychartDiagram-2RQKCTM6-80M84XUq.js → xychartDiagram-2RQKCTM6-DrvIX-i_.js} +1 -1
  47. package/dist/web-ui/index.html +1 -1
  48. package/package.json +1 -1
  49. package/dist/web-ui/assets/channel-B_s3gBqG.js +0 -1
  50. package/dist/web-ui/assets/classDiagram-4FO5ZUOK-CkMU_D5p.js +0 -1
  51. package/dist/web-ui/assets/classDiagram-v2-Q7XG4LA2-CkMU_D5p.js +0 -1
  52. package/dist/web-ui/assets/stateDiagram-v2-BHNVJYJU-CxL4o1Ly.js +0 -1
@@ -646,7 +646,7 @@ l0,-`+(r+144)+`c-2,-159.3,-10,-310.7,-24,-454c-53.3,-528,-210,-949.7,
646
646
  `},m]}}const gQ=e=>({IMPORTANT:{scope:"meta",begin:"!important"},BLOCK_COMMENT:e.C_BLOCK_COMMENT_MODE,HEXCOLOR:{scope:"number",begin:/#(([0-9a-fA-F]{3,4})|(([0-9a-fA-F]{2}){3,4}))\b/},FUNCTION_DISPATCH:{className:"built_in",begin:/[\w-]+(?=\()/},ATTRIBUTE_SELECTOR_MODE:{scope:"selector-attr",begin:/\[/,end:/\]/,illegal:"$",contains:[e.APOS_STRING_MODE,e.QUOTE_STRING_MODE]},CSS_NUMBER_MODE:{scope:"number",begin:e.NUMBER_RE+"(%|em|ex|ch|rem|vw|vh|vmin|vmax|cm|mm|in|pt|pc|px|deg|grad|rad|turn|s|ms|Hz|kHz|dpi|dpcm|dppx)?",relevance:0},CSS_VARIABLE:{className:"attr",begin:/--[A-Za-z_][A-Za-z0-9_-]*/}}),xQ=["a","abbr","address","article","aside","audio","b","blockquote","body","button","canvas","caption","cite","code","dd","del","details","dfn","div","dl","dt","em","fieldset","figcaption","figure","footer","form","h1","h2","h3","h4","h5","h6","header","hgroup","html","i","iframe","img","input","ins","kbd","label","legend","li","main","mark","menu","nav","object","ol","optgroup","option","p","picture","q","quote","samp","section","select","source","span","strong","summary","sup","table","tbody","td","textarea","tfoot","th","thead","time","tr","ul","var","video"],bQ=["defs","g","marker","mask","pattern","svg","switch","symbol","feBlend","feColorMatrix","feComponentTransfer","feComposite","feConvolveMatrix","feDiffuseLighting","feDisplacementMap","feFlood","feGaussianBlur","feImage","feMerge","feMorphology","feOffset","feSpecularLighting","feTile","feTurbulence","linearGradient","radialGradient","stop","circle","ellipse","image","line","path","polygon","polyline","rect","text","use","textPath","tspan","foreignObject","clipPath"],yQ=[...xQ,...bQ],vQ=["any-hover","any-pointer","aspect-ratio","color","color-gamut","color-index","device-aspect-ratio","device-height","device-width","display-mode","forced-colors","grid","height","hover","inverted-colors","monochrome","orientation","overflow-block","overflow-inline","pointer","prefers-color-scheme","prefers-contrast","prefers-reduced-motion","prefers-reduced-transparency","resolution","scan","scripting","update","width","min-width","max-width","min-height","max-height"].sort().reverse(),iT=["active","any-link","blank","checked","current","default","defined","dir","disabled","drop","empty","enabled","first","first-child","first-of-type","fullscreen","future","focus","focus-visible","focus-within","has","host","host-context","hover","indeterminate","in-range","invalid","is","lang","last-child","last-of-type","left","link","local-link","not","nth-child","nth-col","nth-last-child","nth-last-col","nth-last-of-type","nth-of-type","only-child","only-of-type","optional","out-of-range","past","placeholder-shown","read-only","read-write","required","right","root","scope","target","target-within","user-invalid","valid","visited","where"].sort().reverse(),oT=["after","backdrop","before","cue","cue-region","first-letter","first-line","grammar-error","marker","part","placeholder","selection","slotted","spelling-error"].sort().reverse(),wQ=["accent-color","align-content","align-items","align-self","alignment-baseline","all","anchor-name","animation","animation-composition","animation-delay","animation-direction","animation-duration","animation-fill-mode","animation-iteration-count","animation-name","animation-play-state","animation-range","animation-range-end","animation-range-start","animation-timeline","animation-timing-function","appearance","aspect-ratio","backdrop-filter","backface-visibility","background","background-attachment","background-blend-mode","background-clip","background-color","background-image","background-origin","background-position","background-position-x","background-position-y","background-repeat","background-size","baseline-shift","block-size","border","border-block","border-block-color","border-block-end","border-block-end-color","border-block-end-style","border-block-end-width","border-block-start","border-block-start-color","border-block-start-style","border-block-start-width","border-block-style","border-block-width","border-bottom","border-bottom-color","border-bottom-left-radius","border-bottom-right-radius","border-bottom-style","border-bottom-width","border-collapse","border-color","border-end-end-radius","border-end-start-radius","border-image","border-image-outset","border-image-repeat","border-image-slice","border-image-source","border-image-width","border-inline","border-inline-color","border-inline-end","border-inline-end-color","border-inline-end-style","border-inline-end-width","border-inline-start","border-inline-start-color","border-inline-start-style","border-inline-start-width","border-inline-style","border-inline-width","border-left","border-left-color","border-left-style","border-left-width","border-radius","border-right","border-right-color","border-right-style","border-right-width","border-spacing","border-start-end-radius","border-start-start-radius","border-style","border-top","border-top-color","border-top-left-radius","border-top-right-radius","border-top-style","border-top-width","border-width","bottom","box-align","box-decoration-break","box-direction","box-flex","box-flex-group","box-lines","box-ordinal-group","box-orient","box-pack","box-shadow","box-sizing","break-after","break-before","break-inside","caption-side","caret-color","clear","clip","clip-path","clip-rule","color","color-interpolation","color-interpolation-filters","color-profile","color-rendering","color-scheme","column-count","column-fill","column-gap","column-rule","column-rule-color","column-rule-style","column-rule-width","column-span","column-width","columns","contain","contain-intrinsic-block-size","contain-intrinsic-height","contain-intrinsic-inline-size","contain-intrinsic-size","contain-intrinsic-width","container","container-name","container-type","content","content-visibility","counter-increment","counter-reset","counter-set","cue","cue-after","cue-before","cursor","cx","cy","direction","display","dominant-baseline","empty-cells","enable-background","field-sizing","fill","fill-opacity","fill-rule","filter","flex","flex-basis","flex-direction","flex-flow","flex-grow","flex-shrink","flex-wrap","float","flood-color","flood-opacity","flow","font","font-display","font-family","font-feature-settings","font-kerning","font-language-override","font-optical-sizing","font-palette","font-size","font-size-adjust","font-smooth","font-smoothing","font-stretch","font-style","font-synthesis","font-synthesis-position","font-synthesis-small-caps","font-synthesis-style","font-synthesis-weight","font-variant","font-variant-alternates","font-variant-caps","font-variant-east-asian","font-variant-emoji","font-variant-ligatures","font-variant-numeric","font-variant-position","font-variation-settings","font-weight","forced-color-adjust","gap","glyph-orientation-horizontal","glyph-orientation-vertical","grid","grid-area","grid-auto-columns","grid-auto-flow","grid-auto-rows","grid-column","grid-column-end","grid-column-start","grid-gap","grid-row","grid-row-end","grid-row-start","grid-template","grid-template-areas","grid-template-columns","grid-template-rows","hanging-punctuation","height","hyphenate-character","hyphenate-limit-chars","hyphens","icon","image-orientation","image-rendering","image-resolution","ime-mode","initial-letter","initial-letter-align","inline-size","inset","inset-area","inset-block","inset-block-end","inset-block-start","inset-inline","inset-inline-end","inset-inline-start","isolation","justify-content","justify-items","justify-self","kerning","left","letter-spacing","lighting-color","line-break","line-height","line-height-step","list-style","list-style-image","list-style-position","list-style-type","margin","margin-block","margin-block-end","margin-block-start","margin-bottom","margin-inline","margin-inline-end","margin-inline-start","margin-left","margin-right","margin-top","margin-trim","marker","marker-end","marker-mid","marker-start","marks","mask","mask-border","mask-border-mode","mask-border-outset","mask-border-repeat","mask-border-slice","mask-border-source","mask-border-width","mask-clip","mask-composite","mask-image","mask-mode","mask-origin","mask-position","mask-repeat","mask-size","mask-type","masonry-auto-flow","math-depth","math-shift","math-style","max-block-size","max-height","max-inline-size","max-width","min-block-size","min-height","min-inline-size","min-width","mix-blend-mode","nav-down","nav-index","nav-left","nav-right","nav-up","none","normal","object-fit","object-position","offset","offset-anchor","offset-distance","offset-path","offset-position","offset-rotate","opacity","order","orphans","outline","outline-color","outline-offset","outline-style","outline-width","overflow","overflow-anchor","overflow-block","overflow-clip-margin","overflow-inline","overflow-wrap","overflow-x","overflow-y","overlay","overscroll-behavior","overscroll-behavior-block","overscroll-behavior-inline","overscroll-behavior-x","overscroll-behavior-y","padding","padding-block","padding-block-end","padding-block-start","padding-bottom","padding-inline","padding-inline-end","padding-inline-start","padding-left","padding-right","padding-top","page","page-break-after","page-break-before","page-break-inside","paint-order","pause","pause-after","pause-before","perspective","perspective-origin","place-content","place-items","place-self","pointer-events","position","position-anchor","position-visibility","print-color-adjust","quotes","r","resize","rest","rest-after","rest-before","right","rotate","row-gap","ruby-align","ruby-position","scale","scroll-behavior","scroll-margin","scroll-margin-block","scroll-margin-block-end","scroll-margin-block-start","scroll-margin-bottom","scroll-margin-inline","scroll-margin-inline-end","scroll-margin-inline-start","scroll-margin-left","scroll-margin-right","scroll-margin-top","scroll-padding","scroll-padding-block","scroll-padding-block-end","scroll-padding-block-start","scroll-padding-bottom","scroll-padding-inline","scroll-padding-inline-end","scroll-padding-inline-start","scroll-padding-left","scroll-padding-right","scroll-padding-top","scroll-snap-align","scroll-snap-stop","scroll-snap-type","scroll-timeline","scroll-timeline-axis","scroll-timeline-name","scrollbar-color","scrollbar-gutter","scrollbar-width","shape-image-threshold","shape-margin","shape-outside","shape-rendering","speak","speak-as","src","stop-color","stop-opacity","stroke","stroke-dasharray","stroke-dashoffset","stroke-linecap","stroke-linejoin","stroke-miterlimit","stroke-opacity","stroke-width","tab-size","table-layout","text-align","text-align-all","text-align-last","text-anchor","text-combine-upright","text-decoration","text-decoration-color","text-decoration-line","text-decoration-skip","text-decoration-skip-ink","text-decoration-style","text-decoration-thickness","text-emphasis","text-emphasis-color","text-emphasis-position","text-emphasis-style","text-indent","text-justify","text-orientation","text-overflow","text-rendering","text-shadow","text-size-adjust","text-transform","text-underline-offset","text-underline-position","text-wrap","text-wrap-mode","text-wrap-style","timeline-scope","top","touch-action","transform","transform-box","transform-origin","transform-style","transition","transition-behavior","transition-delay","transition-duration","transition-property","transition-timing-function","translate","unicode-bidi","user-modify","user-select","vector-effect","vertical-align","view-timeline","view-timeline-axis","view-timeline-inset","view-timeline-name","view-transition-name","visibility","voice-balance","voice-duration","voice-family","voice-pitch","voice-range","voice-rate","voice-stress","voice-volume","white-space","white-space-collapse","widows","width","will-change","word-break","word-spacing","word-wrap","writing-mode","x","y","z-index","zoom"].sort().reverse(),kQ=iT.concat(oT).sort().reverse();function NQ(e){const n=gQ(e),r=kQ,s="and or not only",a="[\\w-]+",i="("+a+"|@\\{"+a+"\\})",l=[],c=[],u=function(w){return{className:"string",begin:"~?"+w+".*?"+w}},m=function(w,S,T){return{className:w,begin:S,relevance:T}},f={$pattern:/[a-z-]+/,keyword:s,attribute:vQ.join(" ")},p={begin:"\\(",end:"\\)",contains:c,keywords:f,relevance:0};c.push(e.C_LINE_COMMENT_MODE,e.C_BLOCK_COMMENT_MODE,u("'"),u('"'),n.CSS_NUMBER_MODE,{begin:"(url|data-uri)\\(",starts:{className:"string",end:"[\\)\\n]",excludeEnd:!0}},n.HEXCOLOR,p,m("variable","@@?"+a,10),m("variable","@\\{"+a+"\\}"),m("built_in","~?`[^`]*?`"),{className:"attribute",begin:a+"\\s*:",end:":",returnBegin:!0,excludeEnd:!0},n.IMPORTANT,{beginKeywords:"and not"},n.FUNCTION_DISPATCH);const b=c.concat({begin:/\{/,end:/\}/,contains:l}),x={beginKeywords:"when",endsWithParent:!0,contains:[{beginKeywords:"and not"}].concat(c)},v={begin:i+"\\s*:",returnBegin:!0,end:/[;}]/,relevance:0,contains:[{begin:/-(webkit|moz|ms|o)-/},n.CSS_VARIABLE,{className:"attribute",begin:"\\b("+wQ.join("|")+")\\b",end:/(?=:)/,starts:{endsWithParent:!0,illegal:"[<=$]",relevance:0,contains:c}}]},N={className:"keyword",begin:"@(import|media|charset|font-face|(-[a-z]+-)?keyframes|supports|document|namespace|page|viewport|host)\\b",starts:{end:"[;{}]",keywords:f,returnEnd:!0,contains:c,relevance:0}},C={className:"variable",variants:[{begin:"@"+a+"\\s*:",relevance:15},{begin:"@"+a}],starts:{end:"[;}]",returnEnd:!0,contains:b}},k={variants:[{begin:"[\\.#:&\\[>]",end:"[;{}]"},{begin:i,end:/\{/}],returnBegin:!0,returnEnd:!0,illegal:`[<='$"]`,relevance:0,contains:[e.C_LINE_COMMENT_MODE,e.C_BLOCK_COMMENT_MODE,x,m("keyword","all\\b"),m("variable","@\\{"+a+"\\}"),{begin:"\\b("+yQ.join("|")+")\\b",className:"selector-tag"},n.CSS_NUMBER_MODE,m("selector-tag",i,0),m("selector-id","#"+i),m("selector-class","\\."+i,0),m("selector-tag","&",0),n.ATTRIBUTE_SELECTOR_MODE,{className:"selector-pseudo",begin:":("+iT.join("|")+")"},{className:"selector-pseudo",begin:":(:)?("+oT.join("|")+")"},{begin:/\(/,end:/\)/,relevance:0,contains:b},{begin:"!important"},n.FUNCTION_DISPATCH]},j={begin:a+`:(:)?(${r.join("|")})`,returnBegin:!0,contains:[k]};return l.push(e.C_LINE_COMMENT_MODE,e.C_BLOCK_COMMENT_MODE,N,C,j,v,k,x,n.FUNCTION_DISPATCH),{name:"Less",case_insensitive:!0,illegal:`[=>'/<($"]`,contains:l}}function jQ(e){const n="\\[=*\\[",r="\\]=*\\]",s={begin:n,end:r,contains:["self"]},a=[e.COMMENT("--(?!"+n+")","$"),e.COMMENT("--"+n,r,{contains:[s],relevance:10})];return{name:"Lua",aliases:["pluto"],keywords:{$pattern:e.UNDERSCORE_IDENT_RE,literal:"true false nil",keyword:"and break do else elseif end for goto if in local not or repeat return then until while",built_in:"_G _ENV _VERSION __index __newindex __mode __call __metatable __tostring __len __gc __add __sub __mul __div __mod __pow __concat __unm __eq __lt __le assert collectgarbage dofile error getfenv getmetatable ipairs load loadfile loadstring module next pairs pcall print rawequal rawget rawset require select setfenv setmetatable tonumber tostring type unpack xpcall arg self coroutine resume yield status wrap create running debug getupvalue debug sethook getmetatable gethook setmetatable setlocal traceback setfenv getinfo setupvalue getlocal getregistry getfenv io lines write close flush open output type read stderr stdin input stdout popen tmpfile math log max acos huge ldexp pi cos tanh pow deg tan cosh sinh random randomseed frexp ceil floor rad abs sqrt modf asin min mod fmod log10 atan2 exp sin atan os exit setlocale date getenv difftime remove time clock tmpname rename execute package preload loadlib loaded loaders cpath config path seeall string sub upper len gfind rep find match char dump gmatch reverse byte format gsub lower table setn insert getn foreachi maxn foreach concat sort remove"},contains:a.concat([{className:"function",beginKeywords:"function",end:"\\)",contains:[e.inherit(e.TITLE_MODE,{begin:"([_a-zA-Z]\\w*\\.)*([_a-zA-Z]\\w*:)?[_a-zA-Z]\\w*"}),{className:"params",begin:"\\(",endsWithParent:!0,contains:a}].concat(a)},e.C_NUMBER_MODE,e.APOS_STRING_MODE,e.QUOTE_STRING_MODE,{className:"string",begin:n,end:r,contains:[s],relevance:5}])}}function SQ(e){const n={className:"variable",variants:[{begin:"\\$\\("+e.UNDERSCORE_IDENT_RE+"\\)",contains:[e.BACKSLASH_ESCAPE]},{begin:/\$[@%<?\^\+\*]/}]},r={className:"string",begin:/"/,end:/"/,contains:[e.BACKSLASH_ESCAPE,n]},s={className:"variable",begin:/\$\([\w-]+\s/,end:/\)/,keywords:{built_in:"subst patsubst strip findstring filter filter-out sort word wordlist firstword lastword dir notdir suffix basename addsuffix addprefix join wildcard realpath abspath error warning shell origin flavor foreach if or and call eval file value"},contains:[n,r]},a={begin:"^"+e.UNDERSCORE_IDENT_RE+"\\s*(?=[:+?]?=)"},i={className:"meta",begin:/^\.PHONY:/,end:/$/,keywords:{$pattern:/[\.\w]+/,keyword:".PHONY"}},l={className:"section",begin:/^[^\s]+:/,end:/$/,contains:[n]};return{name:"Makefile",aliases:["mk","mak","make"],keywords:{$pattern:/[\w-]+/,keyword:"define endef undefine ifdef ifndef ifeq ifneq else endif include -include sinclude override export unexport private vpath"},contains:[e.HASH_COMMENT_MODE,n,r,s,a,i,l]}}function CQ(e){const n=e.regex,r={begin:/<\/?[A-Za-z_]/,end:">",subLanguage:"xml",relevance:0},s={begin:"^[-\\*]{3,}",end:"$"},a={className:"code",variants:[{begin:"(`{3,})[^`](.|\\n)*?\\1`*[ ]*"},{begin:"(~{3,})[^~](.|\\n)*?\\1~*[ ]*"},{begin:"```",end:"```+[ ]*$"},{begin:"~~~",end:"~~~+[ ]*$"},{begin:"`.+?`"},{begin:"(?=^( {4}|\\t))",contains:[{begin:"^( {4}|\\t)",end:"(\\n)$"}],relevance:0}]},i={className:"bullet",begin:"^[ ]*([*+-]|(\\d+\\.))(?=\\s+)",end:"\\s+",excludeEnd:!0},l={begin:/^\[[^\n]+\]:/,returnBegin:!0,contains:[{className:"symbol",begin:/\[/,end:/\]/,excludeBegin:!0,excludeEnd:!0},{className:"link",begin:/:\s*/,end:/$/,excludeBegin:!0}]},c=/[A-Za-z][A-Za-z0-9+.-]*/,u={variants:[{begin:/\[.+?\]\[.*?\]/,relevance:0},{begin:/\[.+?\]\(((data|javascript|mailto):|(?:http|ftp)s?:\/\/).*?\)/,relevance:2},{begin:n.concat(/\[.+?\]\(/,c,/:\/\/.*?\)/),relevance:2},{begin:/\[.+?\]\([./?&#].*?\)/,relevance:1},{begin:/\[.*?\]\(.*?\)/,relevance:0}],returnBegin:!0,contains:[{match:/\[(?=\])/},{className:"string",relevance:0,begin:"\\[",end:"\\]",excludeBegin:!0,returnEnd:!0},{className:"link",relevance:0,begin:"\\]\\(",end:"\\)",excludeBegin:!0,excludeEnd:!0},{className:"symbol",relevance:0,begin:"\\]\\[",end:"\\]",excludeBegin:!0,excludeEnd:!0}]},m={className:"strong",contains:[],variants:[{begin:/_{2}(?!\s)/,end:/_{2}/},{begin:/\*{2}(?!\s)/,end:/\*{2}/}]},f={className:"emphasis",contains:[],variants:[{begin:/\*(?![*\s])/,end:/\*/},{begin:/_(?![_\s])/,end:/_/,relevance:0}]},p=e.inherit(m,{contains:[]}),b=e.inherit(f,{contains:[]});m.contains.push(b),f.contains.push(p);let x=[r,u];return[m,f,p,b].forEach(k=>{k.contains=k.contains.concat(x)}),x=x.concat(m,f),{name:"Markdown",aliases:["md","mkdown","mkd"],contains:[{className:"section",variants:[{begin:"^#{1,6}",end:"$",contains:x},{begin:"(?=^.+?\\n[=-]{2,}$)",contains:[{begin:"^[=-]*$"},{begin:"^",end:"\\n",contains:x}]}]},r,i,m,f,{className:"quote",begin:"^>\\s+",contains:x,end:"$"},a,s,u,l,{scope:"literal",match:/&([a-zA-Z0-9]+|#[0-9]{1,7}|#[Xx][0-9a-fA-F]{1,6});/}]}}function EQ(e){const n={className:"built_in",begin:"\\b(AV|CA|CF|CG|CI|CL|CM|CN|CT|MK|MP|MTK|MTL|NS|SCN|SK|UI|WK|XC)\\w+"},r=/[a-zA-Z@][a-zA-Z0-9_]*/,c={"variable.language":["this","super"],$pattern:r,keyword:["while","export","sizeof","typedef","const","struct","for","union","volatile","static","mutable","if","do","return","goto","enum","else","break","extern","asm","case","default","register","explicit","typename","switch","continue","inline","readonly","assign","readwrite","self","@synchronized","id","typeof","nonatomic","IBOutlet","IBAction","strong","weak","copy","in","out","inout","bycopy","byref","oneway","__strong","__weak","__block","__autoreleasing","@private","@protected","@public","@try","@property","@end","@throw","@catch","@finally","@autoreleasepool","@synthesize","@dynamic","@selector","@optional","@required","@encode","@package","@import","@defs","@compatibility_alias","__bridge","__bridge_transfer","__bridge_retained","__bridge_retain","__covariant","__contravariant","__kindof","_Nonnull","_Nullable","_Null_unspecified","__FUNCTION__","__PRETTY_FUNCTION__","__attribute__","getter","setter","retain","unsafe_unretained","nonnull","nullable","null_unspecified","null_resettable","class","instancetype","NS_DESIGNATED_INITIALIZER","NS_UNAVAILABLE","NS_REQUIRES_SUPER","NS_RETURNS_INNER_POINTER","NS_INLINE","NS_AVAILABLE","NS_DEPRECATED","NS_ENUM","NS_OPTIONS","NS_SWIFT_UNAVAILABLE","NS_ASSUME_NONNULL_BEGIN","NS_ASSUME_NONNULL_END","NS_REFINED_FOR_SWIFT","NS_SWIFT_NAME","NS_SWIFT_NOTHROW","NS_DURING","NS_HANDLER","NS_ENDHANDLER","NS_VALUERETURN","NS_VOIDRETURN"],literal:["false","true","FALSE","TRUE","nil","YES","NO","NULL"],built_in:["dispatch_once_t","dispatch_queue_t","dispatch_sync","dispatch_async","dispatch_once"],type:["int","float","char","unsigned","signed","short","long","double","wchar_t","unichar","void","bool","BOOL","id|0","_Bool"]},u={$pattern:r,keyword:["@interface","@class","@protocol","@implementation"]};return{name:"Objective-C",aliases:["mm","objc","obj-c","obj-c++","objective-c++"],keywords:c,illegal:"</",contains:[n,e.C_LINE_COMMENT_MODE,e.C_BLOCK_COMMENT_MODE,e.C_NUMBER_MODE,e.QUOTE_STRING_MODE,e.APOS_STRING_MODE,{className:"string",variants:[{begin:'@"',end:'"',illegal:"\\n",contains:[e.BACKSLASH_ESCAPE]}]},{className:"meta",begin:/#\s*[a-z]+\b/,end:/$/,keywords:{keyword:"if else elif endif define undef warning error line pragma ifdef ifndef include"},contains:[{begin:/\\\n/,relevance:0},e.inherit(e.QUOTE_STRING_MODE,{className:"string"}),{className:"string",begin:/<.*?>/,end:/$/,illegal:"\\n"},e.C_LINE_COMMENT_MODE,e.C_BLOCK_COMMENT_MODE]},{className:"class",begin:"("+u.keyword.join("|")+")\\b",end:/(\{|$)/,excludeEnd:!0,keywords:u,contains:[e.UNDERSCORE_TITLE_MODE]},{begin:"\\."+e.UNDERSCORE_IDENT_RE,relevance:0}]}}function TQ(e){const n=e.regex,r=["abs","accept","alarm","and","atan2","bind","binmode","bless","break","caller","chdir","chmod","chomp","chop","chown","chr","chroot","class","close","closedir","connect","continue","cos","crypt","dbmclose","dbmopen","defined","delete","die","do","dump","each","else","elsif","endgrent","endhostent","endnetent","endprotoent","endpwent","endservent","eof","eval","exec","exists","exit","exp","fcntl","field","fileno","flock","for","foreach","fork","format","formline","getc","getgrent","getgrgid","getgrnam","gethostbyaddr","gethostbyname","gethostent","getlogin","getnetbyaddr","getnetbyname","getnetent","getpeername","getpgrp","getpriority","getprotobyname","getprotobynumber","getprotoent","getpwent","getpwnam","getpwuid","getservbyname","getservbyport","getservent","getsockname","getsockopt","given","glob","gmtime","goto","grep","gt","hex","if","index","int","ioctl","join","keys","kill","last","lc","lcfirst","length","link","listen","local","localtime","log","lstat","lt","ma","map","method","mkdir","msgctl","msgget","msgrcv","msgsnd","my","ne","next","no","not","oct","open","opendir","or","ord","our","pack","package","pipe","pop","pos","print","printf","prototype","push","q|0","qq","quotemeta","qw","qx","rand","read","readdir","readline","readlink","readpipe","recv","redo","ref","rename","require","reset","return","reverse","rewinddir","rindex","rmdir","say","scalar","seek","seekdir","select","semctl","semget","semop","send","setgrent","sethostent","setnetent","setpgrp","setpriority","setprotoent","setpwent","setservent","setsockopt","shift","shmctl","shmget","shmread","shmwrite","shutdown","sin","sleep","socket","socketpair","sort","splice","split","sprintf","sqrt","srand","stat","state","study","sub","substr","symlink","syscall","sysopen","sysread","sysseek","system","syswrite","tell","telldir","tie","tied","time","times","tr","truncate","uc","ucfirst","umask","undef","unless","unlink","unpack","unshift","untie","until","use","utime","values","vec","wait","waitpid","wantarray","warn","when","while","write","x|0","xor","y|0"],s=/[dualxmsipngr]{0,12}/,a={$pattern:/[\w.]+/,keyword:r.join(" ")},i={className:"subst",begin:"[$@]\\{",end:"\\}",keywords:a},l={begin:/->\{/,end:/\}/},c={scope:"attr",match:/\s+:\s*\w+(\s*\(.*?\))?/},u={scope:"variable",variants:[{begin:/\$\d/},{begin:n.concat(/[$%@](?!")(\^\w\b|#\w+(::\w+)*|\{\w+\}|\w+(::\w*)*)/,"(?![A-Za-z])(?![@$%])")},{begin:/[$%@](?!")[^\s\w{=]|\$=/,relevance:0}],contains:[c]},m={className:"number",variants:[{match:/0?\.[0-9][0-9_]+\b/},{match:/\bv?(0|[1-9][0-9_]*(\.[0-9_]+)?|[1-9][0-9_]*)\b/},{match:/\b0[0-7][0-7_]*\b/},{match:/\b0x[0-9a-fA-F][0-9a-fA-F_]*\b/},{match:/\b0b[0-1][0-1_]*\b/}],relevance:0},f=[e.BACKSLASH_ESCAPE,i,u],p=[/!/,/\//,/\|/,/\?/,/'/,/"/,/#/],b=(N,C,k="\\1")=>{const j=k==="\\1"?k:n.concat(k,C);return n.concat(n.concat("(?:",N,")"),C,/(?:\\.|[^\\\/])*?/,j,/(?:\\.|[^\\\/])*?/,k,s)},x=(N,C,k)=>n.concat(n.concat("(?:",N,")"),C,/(?:\\.|[^\\\/])*?/,k,s),v=[u,e.HASH_COMMENT_MODE,e.COMMENT(/^=\w/,/=cut/,{endsWithParent:!0}),l,{className:"string",contains:f,variants:[{begin:"q[qwxr]?\\s*\\(",end:"\\)",relevance:5},{begin:"q[qwxr]?\\s*\\[",end:"\\]",relevance:5},{begin:"q[qwxr]?\\s*\\{",end:"\\}",relevance:5},{begin:"q[qwxr]?\\s*\\|",end:"\\|",relevance:5},{begin:"q[qwxr]?\\s*<",end:">",relevance:5},{begin:"qw\\s+q",end:"q",relevance:5},{begin:"'",end:"'",contains:[e.BACKSLASH_ESCAPE]},{begin:'"',end:'"'},{begin:"`",end:"`",contains:[e.BACKSLASH_ESCAPE]},{begin:/\{\w+\}/,relevance:0},{begin:"-?\\w+\\s*=>",relevance:0}]},m,{begin:"(\\/\\/|"+e.RE_STARTERS_RE+"|\\b(split|return|print|reverse|grep)\\b)\\s*",keywords:"split return print reverse grep",relevance:0,contains:[e.HASH_COMMENT_MODE,{className:"regexp",variants:[{begin:b("s|tr|y",n.either(...p,{capture:!0}))},{begin:b("s|tr|y","\\(","\\)")},{begin:b("s|tr|y","\\[","\\]")},{begin:b("s|tr|y","\\{","\\}")}],relevance:2},{className:"regexp",variants:[{begin:/(m|qr)\/\//,relevance:0},{begin:x("(?:m|qr)?",/\//,/\//)},{begin:x("m|qr",n.either(...p,{capture:!0}),/\1/)},{begin:x("m|qr",/\(/,/\)/)},{begin:x("m|qr",/\[/,/\]/)},{begin:x("m|qr",/\{/,/\}/)}]}]},{className:"function",beginKeywords:"sub method",end:"(\\s*\\(.*?\\))?[;{]",excludeEnd:!0,relevance:5,contains:[e.TITLE_MODE,c]},{className:"class",beginKeywords:"class",end:"[;{]",excludeEnd:!0,relevance:5,contains:[e.TITLE_MODE,c,m]},{begin:"-\\w\\b",relevance:0},{begin:"^__DATA__$",end:"^__END__$",subLanguage:"mojolicious",contains:[{begin:"^@@.*",end:"$",className:"comment"}]}];return i.contains=v,l.contains=v,{name:"Perl",aliases:["pl","pm"],keywords:a,contains:v}}function AQ(e){const n=e.regex,r=/(?![A-Za-z0-9])(?![$])/,s=n.concat(/[a-zA-Z_\x7f-\xff][a-zA-Z0-9_\x7f-\xff]*/,r),a=n.concat(/(\\?[A-Z][a-z0-9_\x7f-\xff]+|\\?[A-Z]+(?=[A-Z][a-z0-9_\x7f-\xff])){1,}/,r),i=n.concat(/[A-Z]+/,r),l={scope:"variable",match:"\\$+"+s},c={scope:"meta",variants:[{begin:/<\?php/,relevance:10},{begin:/<\?=/},{begin:/<\?/,relevance:.1},{begin:/\?>/}]},u={scope:"subst",variants:[{begin:/\$\w+/},{begin:/\{\$/,end:/\}/}]},m=e.inherit(e.APOS_STRING_MODE,{illegal:null}),f=e.inherit(e.QUOTE_STRING_MODE,{illegal:null,contains:e.QUOTE_STRING_MODE.contains.concat(u)}),p={begin:/<<<[ \t]*(?:(\w+)|"(\w+)")\n/,end:/[ \t]*(\w+)\b/,contains:e.QUOTE_STRING_MODE.contains.concat(u),"on:begin":(A,H)=>{H.data._beginMatch=A[1]||A[2]},"on:end":(A,H)=>{H.data._beginMatch!==A[1]&&H.ignoreMatch()}},b=e.END_SAME_AS_BEGIN({begin:/<<<[ \t]*'(\w+)'\n/,end:/[ \t]*(\w+)\b/}),x=`[
647
647
  ]`,v={scope:"string",variants:[f,m,p,b]},N={scope:"number",variants:[{begin:"\\b0[bB][01]+(?:_[01]+)*\\b"},{begin:"\\b0[oO][0-7]+(?:_[0-7]+)*\\b"},{begin:"\\b0[xX][\\da-fA-F]+(?:_[\\da-fA-F]+)*\\b"},{begin:"(?:\\b\\d+(?:_\\d+)*(\\.(?:\\d+(?:_\\d+)*))?|\\B\\.\\d+)(?:[eE][+-]?\\d+)?"}],relevance:0},C=["false","null","true"],k=["__CLASS__","__DIR__","__FILE__","__FUNCTION__","__COMPILER_HALT_OFFSET__","__LINE__","__METHOD__","__NAMESPACE__","__TRAIT__","die","echo","exit","include","include_once","print","require","require_once","array","abstract","and","as","binary","bool","boolean","break","callable","case","catch","class","clone","const","continue","declare","default","do","double","else","elseif","empty","enddeclare","endfor","endforeach","endif","endswitch","endwhile","enum","eval","extends","final","finally","float","for","foreach","from","global","goto","if","implements","instanceof","insteadof","int","integer","interface","isset","iterable","list","match|0","mixed","new","never","object","or","private","protected","public","readonly","real","return","string","switch","throw","trait","try","unset","use","var","void","while","xor","yield"],j=["Error|0","AppendIterator","ArgumentCountError","ArithmeticError","ArrayIterator","ArrayObject","AssertionError","BadFunctionCallException","BadMethodCallException","CachingIterator","CallbackFilterIterator","CompileError","Countable","DirectoryIterator","DivisionByZeroError","DomainException","EmptyIterator","ErrorException","Exception","FilesystemIterator","FilterIterator","GlobIterator","InfiniteIterator","InvalidArgumentException","IteratorIterator","LengthException","LimitIterator","LogicException","MultipleIterator","NoRewindIterator","OutOfBoundsException","OutOfRangeException","OuterIterator","OverflowException","ParentIterator","ParseError","RangeException","RecursiveArrayIterator","RecursiveCachingIterator","RecursiveCallbackFilterIterator","RecursiveDirectoryIterator","RecursiveFilterIterator","RecursiveIterator","RecursiveIteratorIterator","RecursiveRegexIterator","RecursiveTreeIterator","RegexIterator","RuntimeException","SeekableIterator","SplDoublyLinkedList","SplFileInfo","SplFileObject","SplFixedArray","SplHeap","SplMaxHeap","SplMinHeap","SplObjectStorage","SplObserver","SplPriorityQueue","SplQueue","SplStack","SplSubject","SplTempFileObject","TypeError","UnderflowException","UnexpectedValueException","UnhandledMatchError","ArrayAccess","BackedEnum","Closure","Fiber","Generator","Iterator","IteratorAggregate","Serializable","Stringable","Throwable","Traversable","UnitEnum","WeakReference","WeakMap","Directory","__PHP_Incomplete_Class","parent","php_user_filter","self","static","stdClass"],S={keyword:k,literal:(A=>{const H=[];return A.forEach(D=>{H.push(D),D.toLowerCase()===D?H.push(D.toUpperCase()):H.push(D.toLowerCase())}),H})(C),built_in:j},T=A=>A.map(H=>H.replace(/\|\d+$/,"")),R={variants:[{match:[/new/,n.concat(x,"+"),n.concat("(?!",T(j).join("\\b|"),"\\b)"),a],scope:{1:"keyword",4:"title.class"}}]},I=n.concat(s,"\\b(?!\\()"),P={variants:[{match:[n.concat(/::/,n.lookahead(/(?!class\b)/)),I],scope:{2:"variable.constant"}},{match:[/::/,/class/],scope:{2:"variable.language"}},{match:[a,n.concat(/::/,n.lookahead(/(?!class\b)/)),I],scope:{1:"title.class",3:"variable.constant"}},{match:[a,n.concat("::",n.lookahead(/(?!class\b)/))],scope:{1:"title.class"}},{match:[a,/::/,/class/],scope:{1:"title.class",3:"variable.language"}}]},L={scope:"attr",match:n.concat(s,n.lookahead(":"),n.lookahead(/(?!::)/))},M={relevance:0,begin:/\(/,end:/\)/,keywords:S,contains:[L,l,P,e.C_BLOCK_COMMENT_MODE,v,N,R]},$={relevance:0,match:[/\b/,n.concat("(?!fn\\b|function\\b|",T(k).join("\\b|"),"|",T(j).join("\\b|"),"\\b)"),s,n.concat(x,"*"),n.lookahead(/(?=\()/)],scope:{3:"title.function.invoke"},contains:[M]};M.contains.push($);const U=[L,P,e.C_BLOCK_COMMENT_MODE,v,N,R],z={begin:n.concat(/#\[\s*\\?/,n.either(a,i)),beginScope:"meta",end:/]/,endScope:"meta",keywords:{literal:C,keyword:["new","array"]},contains:[{begin:/\[/,end:/]/,keywords:{literal:C,keyword:["new","array"]},contains:["self",...U]},...U,{scope:"meta",variants:[{match:a},{match:i}]}]};return{case_insensitive:!1,keywords:S,contains:[z,e.HASH_COMMENT_MODE,e.COMMENT("//","$"),e.COMMENT("/\\*","\\*/",{contains:[{scope:"doctag",match:"@[A-Za-z]+"}]}),{match:/__halt_compiler\(\);/,keywords:"__halt_compiler",starts:{scope:"comment",end:e.MATCH_NOTHING_RE,contains:[{match:/\?>/,scope:"meta",endsParent:!0}]}},c,{scope:"variable.language",match:/\$this\b/},l,$,P,{match:[/const/,/\s/,s],scope:{1:"keyword",3:"variable.constant"}},R,{scope:"function",relevance:0,beginKeywords:"fn function",end:/[;{]/,excludeEnd:!0,illegal:"[$%\\[]",contains:[{beginKeywords:"use"},e.UNDERSCORE_TITLE_MODE,{begin:"=>",endsParent:!0},{scope:"params",begin:"\\(",end:"\\)",excludeBegin:!0,excludeEnd:!0,keywords:S,contains:["self",z,l,P,e.C_BLOCK_COMMENT_MODE,v,N]}]},{scope:"class",variants:[{beginKeywords:"enum",illegal:/[($"]/},{beginKeywords:"class interface trait",illegal:/[:($"]/}],relevance:0,end:/\{/,excludeEnd:!0,contains:[{beginKeywords:"extends implements"},e.UNDERSCORE_TITLE_MODE]},{beginKeywords:"namespace",relevance:0,end:";",illegal:/[.']/,contains:[e.inherit(e.UNDERSCORE_TITLE_MODE,{scope:"title.class"})]},{beginKeywords:"use",relevance:0,end:";",contains:[{match:/\b(as|const|function)\b/,scope:"keyword"},e.UNDERSCORE_TITLE_MODE]},v,N]}}function MQ(e){return{name:"PHP template",subLanguage:"xml",contains:[{begin:/<\?(php|=)?/,end:/\?>/,subLanguage:"php",contains:[{begin:"/\\*",end:"\\*/",skip:!0},{begin:'b"',end:'"',skip:!0},{begin:"b'",end:"'",skip:!0},e.inherit(e.APOS_STRING_MODE,{illegal:null,className:null,contains:null,skip:!0}),e.inherit(e.QUOTE_STRING_MODE,{illegal:null,className:null,contains:null,skip:!0})]}]}}function _Q(e){return{name:"Plain text",aliases:["text","txt"],disableAutodetect:!0}}function RQ(e){const n=e.regex,r=new RegExp("[\\p{XID_Start}_]\\p{XID_Continue}*","u"),s=["and","as","assert","async","await","break","case","class","continue","def","del","elif","else","except","finally","for","from","global","if","import","in","is","lambda","match","nonlocal|10","not","or","pass","raise","return","try","while","with","yield"],c={$pattern:/[A-Za-z]\w+|__\w+__/,keyword:s,built_in:["__import__","abs","all","any","ascii","bin","bool","breakpoint","bytearray","bytes","callable","chr","classmethod","compile","complex","delattr","dict","dir","divmod","enumerate","eval","exec","filter","float","format","frozenset","getattr","globals","hasattr","hash","help","hex","id","input","int","isinstance","issubclass","iter","len","list","locals","map","max","memoryview","min","next","object","oct","open","ord","pow","print","property","range","repr","reversed","round","set","setattr","slice","sorted","staticmethod","str","sum","super","tuple","type","vars","zip"],literal:["__debug__","Ellipsis","False","None","NotImplemented","True"],type:["Any","Callable","Coroutine","Dict","List","Literal","Generic","Optional","Sequence","Set","Tuple","Type","Union"]},u={className:"meta",begin:/^(>>>|\.\.\.) /},m={className:"subst",begin:/\{/,end:/\}/,keywords:c,illegal:/#/},f={begin:/\{\{/,relevance:0},p={className:"string",contains:[e.BACKSLASH_ESCAPE],variants:[{begin:/([uU]|[bB]|[rR]|[bB][rR]|[rR][bB])?'''/,end:/'''/,contains:[e.BACKSLASH_ESCAPE,u],relevance:10},{begin:/([uU]|[bB]|[rR]|[bB][rR]|[rR][bB])?"""/,end:/"""/,contains:[e.BACKSLASH_ESCAPE,u],relevance:10},{begin:/([fF][rR]|[rR][fF]|[fF])'''/,end:/'''/,contains:[e.BACKSLASH_ESCAPE,u,f,m]},{begin:/([fF][rR]|[rR][fF]|[fF])"""/,end:/"""/,contains:[e.BACKSLASH_ESCAPE,u,f,m]},{begin:/([uU]|[rR])'/,end:/'/,relevance:10},{begin:/([uU]|[rR])"/,end:/"/,relevance:10},{begin:/([bB]|[bB][rR]|[rR][bB])'/,end:/'/},{begin:/([bB]|[bB][rR]|[rR][bB])"/,end:/"/},{begin:/([fF][rR]|[rR][fF]|[fF])'/,end:/'/,contains:[e.BACKSLASH_ESCAPE,f,m]},{begin:/([fF][rR]|[rR][fF]|[fF])"/,end:/"/,contains:[e.BACKSLASH_ESCAPE,f,m]},e.APOS_STRING_MODE,e.QUOTE_STRING_MODE]},b="[0-9](_?[0-9])*",x=`(\\b(${b}))?\\.(${b})|\\b(${b})\\.`,v=`\\b|${s.join("|")}`,N={className:"number",relevance:0,variants:[{begin:`(\\b(${b})|(${x}))[eE][+-]?(${b})[jJ]?(?=${v})`},{begin:`(${x})[jJ]?`},{begin:`\\b([1-9](_?[0-9])*|0+(_?0)*)[lLjJ]?(?=${v})`},{begin:`\\b0[bB](_?[01])+[lL]?(?=${v})`},{begin:`\\b0[oO](_?[0-7])+[lL]?(?=${v})`},{begin:`\\b0[xX](_?[0-9a-fA-F])+[lL]?(?=${v})`},{begin:`\\b(${b})[jJ](?=${v})`}]},C={className:"comment",begin:n.lookahead(/# type:/),end:/$/,keywords:c,contains:[{begin:/# type:/},{begin:/#/,end:/\b\B/,endsWithParent:!0}]},k={className:"params",variants:[{className:"",begin:/\(\s*\)/,skip:!0},{begin:/\(/,end:/\)/,excludeBegin:!0,excludeEnd:!0,keywords:c,contains:["self",u,N,p,e.HASH_COMMENT_MODE]}]};return m.contains=[p,N,u],{name:"Python",aliases:["py","gyp","ipython"],unicodeRegex:!0,keywords:c,illegal:/(<\/|\?)|=>/,contains:[u,N,{scope:"variable.language",match:/\bself\b/},{beginKeywords:"if",relevance:0},{match:/\bor\b/,scope:"keyword"},p,C,e.HASH_COMMENT_MODE,{match:[/\bdef/,/\s+/,r],scope:{1:"keyword",3:"title.function"},contains:[k]},{variants:[{match:[/\bclass/,/\s+/,r,/\s*/,/\(\s*/,r,/\s*\)/]},{match:[/\bclass/,/\s+/,r]}],scope:{1:"keyword",3:"title.class",6:"title.class.inherited"}},{className:"meta",begin:/^[\t ]*@/,end:/(?=#)|$/,contains:[N,k,p]}]}}function IQ(e){return{aliases:["pycon"],contains:[{className:"meta.prompt",starts:{end:/ |$/,starts:{end:"$",subLanguage:"python"}},variants:[{begin:/^>>>(?=[ ]|$)/},{begin:/^\.\.\.(?=[ ]|$)/}]}]}}function DQ(e){const n=e.regex,r=/(?:(?:[a-zA-Z]|\.[._a-zA-Z])[._a-zA-Z0-9]*)|\.(?!\d)/,s=n.either(/0[xX][0-9a-fA-F]+\.[0-9a-fA-F]*[pP][+-]?\d+i?/,/0[xX][0-9a-fA-F]+(?:[pP][+-]?\d+)?[Li]?/,/(?:\d+(?:\.\d*)?|\.\d+)(?:[eE][+-]?\d+)?[Li]?/),a=/[=!<>:]=|\|\||&&|:::?|<-|<<-|->>|->|\|>|[-+*\/?!$&|:<=>@^~]|\*\*/,i=n.either(/[()]/,/[{}]/,/\[\[/,/[[\]]/,/\\/,/,/);return{name:"R",keywords:{$pattern:r,keyword:"function if in break next repeat else for while",literal:"NULL NA TRUE FALSE Inf NaN NA_integer_|10 NA_real_|10 NA_character_|10 NA_complex_|10",built_in:"LETTERS letters month.abb month.name pi T F abs acos acosh all any anyNA Arg as.call as.character as.complex as.double as.environment as.integer as.logical as.null.default as.numeric as.raw asin asinh atan atanh attr attributes baseenv browser c call ceiling class Conj cos cosh cospi cummax cummin cumprod cumsum digamma dim dimnames emptyenv exp expression floor forceAndCall gamma gc.time globalenv Im interactive invisible is.array is.atomic is.call is.character is.complex is.double is.environment is.expression is.finite is.function is.infinite is.integer is.language is.list is.logical is.matrix is.na is.name is.nan is.null is.numeric is.object is.pairlist is.raw is.recursive is.single is.symbol lazyLoadDBfetch length lgamma list log max min missing Mod names nargs nzchar oldClass on.exit pos.to.env proc.time prod quote range Re rep retracemem return round seq_along seq_len seq.int sign signif sin sinh sinpi sqrt standardGeneric substitute sum switch tan tanh tanpi tracemem trigamma trunc unclass untracemem UseMethod xtfrm"},contains:[e.COMMENT(/#'/,/$/,{contains:[{scope:"doctag",match:/@examples/,starts:{end:n.lookahead(n.either(/\n^#'\s*(?=@[a-zA-Z]+)/,/\n^(?!#')/)),endsParent:!0}},{scope:"doctag",begin:"@param",end:/$/,contains:[{scope:"variable",variants:[{match:r},{match:/`(?:\\.|[^`\\])+`/}],endsParent:!0}]},{scope:"doctag",match:/@[a-zA-Z]+/},{scope:"keyword",match:/\\[a-zA-Z]+/}]}),e.HASH_COMMENT_MODE,{scope:"string",contains:[e.BACKSLASH_ESCAPE],variants:[e.END_SAME_AS_BEGIN({begin:/[rR]"(-*)\(/,end:/\)(-*)"/}),e.END_SAME_AS_BEGIN({begin:/[rR]"(-*)\{/,end:/\}(-*)"/}),e.END_SAME_AS_BEGIN({begin:/[rR]"(-*)\[/,end:/\](-*)"/}),e.END_SAME_AS_BEGIN({begin:/[rR]'(-*)\(/,end:/\)(-*)'/}),e.END_SAME_AS_BEGIN({begin:/[rR]'(-*)\{/,end:/\}(-*)'/}),e.END_SAME_AS_BEGIN({begin:/[rR]'(-*)\[/,end:/\](-*)'/}),{begin:'"',end:'"',relevance:0},{begin:"'",end:"'",relevance:0}]},{relevance:0,variants:[{scope:{1:"operator",2:"number"},match:[a,s]},{scope:{1:"operator",2:"number"},match:[/%[^%]*%/,s]},{scope:{1:"punctuation",2:"number"},match:[i,s]},{scope:{2:"number"},match:[/[^a-zA-Z0-9._]|^/,s]}]},{scope:{3:"operator"},match:[r,/\s+/,/<-/,/\s+/]},{scope:"operator",relevance:0,variants:[{match:a},{match:/%[^%]*%/}]},{scope:"punctuation",relevance:0,match:i},{begin:"`",end:"`",contains:[{begin:/\\./}]}]}}function LQ(e){const n=e.regex,r="([a-zA-Z_]\\w*[!?=]?|[-+~]@|<<|>>|=~|===?|<=>|[<>]=?|\\*\\*|[-/+%^&*~`|]|\\[\\]=?)",s=n.either(/\b([A-Z]+[a-z0-9]+)+/,/\b([A-Z]+[a-z0-9]+)+[A-Z]+/),a=n.concat(s,/(::\w+)*/),l={"variable.constant":["__FILE__","__LINE__","__ENCODING__"],"variable.language":["self","super"],keyword:["alias","and","begin","BEGIN","break","case","class","defined","do","else","elsif","end","END","ensure","for","if","in","module","next","not","or","redo","require","rescue","retry","return","then","undef","unless","until","when","while","yield",...["include","extend","prepend","public","private","protected","raise","throw"]],built_in:["proc","lambda","attr_accessor","attr_reader","attr_writer","define_method","private_constant","module_function"],literal:["true","false","nil"]},c={className:"doctag",begin:"@[A-Za-z]+"},u={begin:"#<",end:">"},m=[e.COMMENT("#","$",{contains:[c]}),e.COMMENT("^=begin","^=end",{contains:[c],relevance:10}),e.COMMENT("^__END__",e.MATCH_NOTHING_RE)],f={className:"subst",begin:/#\{/,end:/\}/,keywords:l},p={className:"string",contains:[e.BACKSLASH_ESCAPE,f],variants:[{begin:/'/,end:/'/},{begin:/"/,end:/"/},{begin:/`/,end:/`/},{begin:/%[qQwWx]?\(/,end:/\)/},{begin:/%[qQwWx]?\[/,end:/\]/},{begin:/%[qQwWx]?\{/,end:/\}/},{begin:/%[qQwWx]?</,end:/>/},{begin:/%[qQwWx]?\//,end:/\//},{begin:/%[qQwWx]?%/,end:/%/},{begin:/%[qQwWx]?-/,end:/-/},{begin:/%[qQwWx]?\|/,end:/\|/},{begin:/\B\?(\\\d{1,3})/},{begin:/\B\?(\\x[A-Fa-f0-9]{1,2})/},{begin:/\B\?(\\u\{?[A-Fa-f0-9]{1,6}\}?)/},{begin:/\B\?(\\M-\\C-|\\M-\\c|\\c\\M-|\\M-|\\C-\\M-)[\x20-\x7e]/},{begin:/\B\?\\(c|C-)[\x20-\x7e]/},{begin:/\B\?\\?\S/},{begin:n.concat(/<<[-~]?'?/,n.lookahead(/(\w+)(?=\W)[^\n]*\n(?:[^\n]*\n)*?\s*\1\b/)),contains:[e.END_SAME_AS_BEGIN({begin:/(\w+)/,end:/(\w+)/,contains:[e.BACKSLASH_ESCAPE,f]})]}]},b="[1-9](_?[0-9])*|0",x="[0-9](_?[0-9])*",v={className:"number",relevance:0,variants:[{begin:`\\b(${b})(\\.(${x}))?([eE][+-]?(${x})|r)?i?\\b`},{begin:"\\b0[dD][0-9](_?[0-9])*r?i?\\b"},{begin:"\\b0[bB][0-1](_?[0-1])*r?i?\\b"},{begin:"\\b0[oO][0-7](_?[0-7])*r?i?\\b"},{begin:"\\b0[xX][0-9a-fA-F](_?[0-9a-fA-F])*r?i?\\b"},{begin:"\\b0(_?[0-7])+r?i?\\b"}]},N={variants:[{match:/\(\)/},{className:"params",begin:/\(/,end:/(?=\))/,excludeBegin:!0,endsParent:!0,keywords:l}]},R=[p,{variants:[{match:[/class\s+/,a,/\s+<\s+/,a]},{match:[/\b(class|module)\s+/,a]}],scope:{2:"title.class",4:"title.class.inherited"},keywords:l},{match:[/(include|extend)\s+/,a],scope:{2:"title.class"},keywords:l},{relevance:0,match:[a,/\.new[. (]/],scope:{1:"title.class"}},{relevance:0,match:/\b[A-Z][A-Z_0-9]+\b/,className:"variable.constant"},{relevance:0,match:s,scope:"title.class"},{match:[/def/,/\s+/,r],scope:{1:"keyword",3:"title.function"},contains:[N]},{begin:e.IDENT_RE+"::"},{className:"symbol",begin:e.UNDERSCORE_IDENT_RE+"(!|\\?)?:",relevance:0},{className:"symbol",begin:":(?!\\s)",contains:[p,{begin:r}],relevance:0},v,{className:"variable",begin:"(\\$\\W)|((\\$|@@?)(\\w+))(?=[^@$?])(?![A-Za-z])(?![@$?'])"},{className:"params",begin:/\|(?!=)/,end:/\|/,excludeBegin:!0,excludeEnd:!0,relevance:0,keywords:l},{begin:"("+e.RE_STARTERS_RE+"|unless)\\s*",keywords:"unless",contains:[{className:"regexp",contains:[e.BACKSLASH_ESCAPE,f],illegal:/\n/,variants:[{begin:"/",end:"/[a-z]*"},{begin:/%r\{/,end:/\}[a-z]*/},{begin:"%r\\(",end:"\\)[a-z]*"},{begin:"%r!",end:"![a-z]*"},{begin:"%r\\[",end:"\\][a-z]*"}]}].concat(u,m),relevance:0}].concat(u,m);f.contains=R,N.contains=R;const M=[{begin:/^\s*=>/,starts:{end:"$",contains:R}},{className:"meta.prompt",begin:"^("+"[>?]>"+"|"+"[\\w#]+\\(\\w+\\):\\d+:\\d+[>*]"+"|"+"(\\w+-)?\\d+\\.\\d+\\.\\d+(p\\d+)?[^\\d][^>]+>"+")(?=[ ])",starts:{end:"$",keywords:l,contains:R}}];return m.unshift(u),{name:"Ruby",aliases:["rb","gemspec","podspec","thor","irb"],keywords:l,illegal:/\/\*/,contains:[e.SHEBANG({binary:"ruby"})].concat(M).concat(m).concat(R)}}function OQ(e){const n=e.regex,r=/(r#)?/,s=n.concat(r,e.UNDERSCORE_IDENT_RE),a=n.concat(r,e.IDENT_RE),i={className:"title.function.invoke",relevance:0,begin:n.concat(/\b/,/(?!let|for|while|if|else|match\b)/,a,n.lookahead(/\s*\(/))},l="([ui](8|16|32|64|128|size)|f(32|64))?",c=["abstract","as","async","await","become","box","break","const","continue","crate","do","dyn","else","enum","extern","false","final","fn","for","if","impl","in","let","loop","macro","match","mod","move","mut","override","priv","pub","ref","return","self","Self","static","struct","super","trait","true","try","type","typeof","union","unsafe","unsized","use","virtual","where","while","yield"],u=["true","false","Some","None","Ok","Err"],m=["drop ","Copy","Send","Sized","Sync","Drop","Fn","FnMut","FnOnce","ToOwned","Clone","Debug","PartialEq","PartialOrd","Eq","Ord","AsRef","AsMut","Into","From","Default","Iterator","Extend","IntoIterator","DoubleEndedIterator","ExactSizeIterator","SliceConcatExt","ToString","assert!","assert_eq!","bitflags!","bytes!","cfg!","col!","concat!","concat_idents!","debug_assert!","debug_assert_eq!","env!","eprintln!","panic!","file!","format!","format_args!","include_bytes!","include_str!","line!","local_data_key!","module_path!","option_env!","print!","println!","select!","stringify!","try!","unimplemented!","unreachable!","vec!","write!","writeln!","macro_rules!","assert_ne!","debug_assert_ne!"],f=["i8","i16","i32","i64","i128","isize","u8","u16","u32","u64","u128","usize","f32","f64","str","char","bool","Box","Option","Result","String","Vec"];return{name:"Rust",aliases:["rs"],keywords:{$pattern:e.IDENT_RE+"!?",type:f,keyword:c,literal:u,built_in:m},illegal:"</",contains:[e.C_LINE_COMMENT_MODE,e.COMMENT("/\\*","\\*/",{contains:["self"]}),e.inherit(e.QUOTE_STRING_MODE,{begin:/b?"/,illegal:null}),{className:"symbol",begin:/'[a-zA-Z_][a-zA-Z0-9_]*(?!')/},{scope:"string",variants:[{begin:/b?r(#*)"(.|\n)*?"\1(?!#)/},{begin:/b?'/,end:/'/,contains:[{scope:"char.escape",match:/\\('|\w|x\w{2}|u\w{4}|U\w{8})/}]}]},{className:"number",variants:[{begin:"\\b0b([01_]+)"+l},{begin:"\\b0o([0-7_]+)"+l},{begin:"\\b0x([A-Fa-f0-9_]+)"+l},{begin:"\\b(\\d[\\d_]*(\\.[0-9_]+)?([eE][+-]?[0-9_]+)?)"+l}],relevance:0},{begin:[/fn/,/\s+/,s],className:{1:"keyword",3:"title.function"}},{className:"meta",begin:"#!?\\[",end:"\\]",contains:[{className:"string",begin:/"/,end:/"/,contains:[e.BACKSLASH_ESCAPE]}]},{begin:[/let/,/\s+/,/(?:mut\s+)?/,s],className:{1:"keyword",3:"keyword",4:"variable"}},{begin:[/for/,/\s+/,s,/\s+/,/in/],className:{1:"keyword",3:"variable",5:"keyword"}},{begin:[/type/,/\s+/,s],className:{1:"keyword",3:"title.class"}},{begin:[/(?:trait|enum|struct|union|impl|for)/,/\s+/,s],className:{1:"keyword",3:"title.class"}},{begin:e.IDENT_RE+"::",keywords:{keyword:"Self",built_in:m,type:f}},{className:"punctuation",begin:"->"},i]}}const PQ=e=>({IMPORTANT:{scope:"meta",begin:"!important"},BLOCK_COMMENT:e.C_BLOCK_COMMENT_MODE,HEXCOLOR:{scope:"number",begin:/#(([0-9a-fA-F]{3,4})|(([0-9a-fA-F]{2}){3,4}))\b/},FUNCTION_DISPATCH:{className:"built_in",begin:/[\w-]+(?=\()/},ATTRIBUTE_SELECTOR_MODE:{scope:"selector-attr",begin:/\[/,end:/\]/,illegal:"$",contains:[e.APOS_STRING_MODE,e.QUOTE_STRING_MODE]},CSS_NUMBER_MODE:{scope:"number",begin:e.NUMBER_RE+"(%|em|ex|ch|rem|vw|vh|vmin|vmax|cm|mm|in|pt|pc|px|deg|grad|rad|turn|s|ms|Hz|kHz|dpi|dpcm|dppx)?",relevance:0},CSS_VARIABLE:{className:"attr",begin:/--[A-Za-z_][A-Za-z0-9_-]*/}}),BQ=["a","abbr","address","article","aside","audio","b","blockquote","body","button","canvas","caption","cite","code","dd","del","details","dfn","div","dl","dt","em","fieldset","figcaption","figure","footer","form","h1","h2","h3","h4","h5","h6","header","hgroup","html","i","iframe","img","input","ins","kbd","label","legend","li","main","mark","menu","nav","object","ol","optgroup","option","p","picture","q","quote","samp","section","select","source","span","strong","summary","sup","table","tbody","td","textarea","tfoot","th","thead","time","tr","ul","var","video"],$Q=["defs","g","marker","mask","pattern","svg","switch","symbol","feBlend","feColorMatrix","feComponentTransfer","feComposite","feConvolveMatrix","feDiffuseLighting","feDisplacementMap","feFlood","feGaussianBlur","feImage","feMerge","feMorphology","feOffset","feSpecularLighting","feTile","feTurbulence","linearGradient","radialGradient","stop","circle","ellipse","image","line","path","polygon","polyline","rect","text","use","textPath","tspan","foreignObject","clipPath"],zQ=[...BQ,...$Q],FQ=["any-hover","any-pointer","aspect-ratio","color","color-gamut","color-index","device-aspect-ratio","device-height","device-width","display-mode","forced-colors","grid","height","hover","inverted-colors","monochrome","orientation","overflow-block","overflow-inline","pointer","prefers-color-scheme","prefers-contrast","prefers-reduced-motion","prefers-reduced-transparency","resolution","scan","scripting","update","width","min-width","max-width","min-height","max-height"].sort().reverse(),HQ=["active","any-link","blank","checked","current","default","defined","dir","disabled","drop","empty","enabled","first","first-child","first-of-type","fullscreen","future","focus","focus-visible","focus-within","has","host","host-context","hover","indeterminate","in-range","invalid","is","lang","last-child","last-of-type","left","link","local-link","not","nth-child","nth-col","nth-last-child","nth-last-col","nth-last-of-type","nth-of-type","only-child","only-of-type","optional","out-of-range","past","placeholder-shown","read-only","read-write","required","right","root","scope","target","target-within","user-invalid","valid","visited","where"].sort().reverse(),UQ=["after","backdrop","before","cue","cue-region","first-letter","first-line","grammar-error","marker","part","placeholder","selection","slotted","spelling-error"].sort().reverse(),qQ=["accent-color","align-content","align-items","align-self","alignment-baseline","all","anchor-name","animation","animation-composition","animation-delay","animation-direction","animation-duration","animation-fill-mode","animation-iteration-count","animation-name","animation-play-state","animation-range","animation-range-end","animation-range-start","animation-timeline","animation-timing-function","appearance","aspect-ratio","backdrop-filter","backface-visibility","background","background-attachment","background-blend-mode","background-clip","background-color","background-image","background-origin","background-position","background-position-x","background-position-y","background-repeat","background-size","baseline-shift","block-size","border","border-block","border-block-color","border-block-end","border-block-end-color","border-block-end-style","border-block-end-width","border-block-start","border-block-start-color","border-block-start-style","border-block-start-width","border-block-style","border-block-width","border-bottom","border-bottom-color","border-bottom-left-radius","border-bottom-right-radius","border-bottom-style","border-bottom-width","border-collapse","border-color","border-end-end-radius","border-end-start-radius","border-image","border-image-outset","border-image-repeat","border-image-slice","border-image-source","border-image-width","border-inline","border-inline-color","border-inline-end","border-inline-end-color","border-inline-end-style","border-inline-end-width","border-inline-start","border-inline-start-color","border-inline-start-style","border-inline-start-width","border-inline-style","border-inline-width","border-left","border-left-color","border-left-style","border-left-width","border-radius","border-right","border-right-color","border-right-style","border-right-width","border-spacing","border-start-end-radius","border-start-start-radius","border-style","border-top","border-top-color","border-top-left-radius","border-top-right-radius","border-top-style","border-top-width","border-width","bottom","box-align","box-decoration-break","box-direction","box-flex","box-flex-group","box-lines","box-ordinal-group","box-orient","box-pack","box-shadow","box-sizing","break-after","break-before","break-inside","caption-side","caret-color","clear","clip","clip-path","clip-rule","color","color-interpolation","color-interpolation-filters","color-profile","color-rendering","color-scheme","column-count","column-fill","column-gap","column-rule","column-rule-color","column-rule-style","column-rule-width","column-span","column-width","columns","contain","contain-intrinsic-block-size","contain-intrinsic-height","contain-intrinsic-inline-size","contain-intrinsic-size","contain-intrinsic-width","container","container-name","container-type","content","content-visibility","counter-increment","counter-reset","counter-set","cue","cue-after","cue-before","cursor","cx","cy","direction","display","dominant-baseline","empty-cells","enable-background","field-sizing","fill","fill-opacity","fill-rule","filter","flex","flex-basis","flex-direction","flex-flow","flex-grow","flex-shrink","flex-wrap","float","flood-color","flood-opacity","flow","font","font-display","font-family","font-feature-settings","font-kerning","font-language-override","font-optical-sizing","font-palette","font-size","font-size-adjust","font-smooth","font-smoothing","font-stretch","font-style","font-synthesis","font-synthesis-position","font-synthesis-small-caps","font-synthesis-style","font-synthesis-weight","font-variant","font-variant-alternates","font-variant-caps","font-variant-east-asian","font-variant-emoji","font-variant-ligatures","font-variant-numeric","font-variant-position","font-variation-settings","font-weight","forced-color-adjust","gap","glyph-orientation-horizontal","glyph-orientation-vertical","grid","grid-area","grid-auto-columns","grid-auto-flow","grid-auto-rows","grid-column","grid-column-end","grid-column-start","grid-gap","grid-row","grid-row-end","grid-row-start","grid-template","grid-template-areas","grid-template-columns","grid-template-rows","hanging-punctuation","height","hyphenate-character","hyphenate-limit-chars","hyphens","icon","image-orientation","image-rendering","image-resolution","ime-mode","initial-letter","initial-letter-align","inline-size","inset","inset-area","inset-block","inset-block-end","inset-block-start","inset-inline","inset-inline-end","inset-inline-start","isolation","justify-content","justify-items","justify-self","kerning","left","letter-spacing","lighting-color","line-break","line-height","line-height-step","list-style","list-style-image","list-style-position","list-style-type","margin","margin-block","margin-block-end","margin-block-start","margin-bottom","margin-inline","margin-inline-end","margin-inline-start","margin-left","margin-right","margin-top","margin-trim","marker","marker-end","marker-mid","marker-start","marks","mask","mask-border","mask-border-mode","mask-border-outset","mask-border-repeat","mask-border-slice","mask-border-source","mask-border-width","mask-clip","mask-composite","mask-image","mask-mode","mask-origin","mask-position","mask-repeat","mask-size","mask-type","masonry-auto-flow","math-depth","math-shift","math-style","max-block-size","max-height","max-inline-size","max-width","min-block-size","min-height","min-inline-size","min-width","mix-blend-mode","nav-down","nav-index","nav-left","nav-right","nav-up","none","normal","object-fit","object-position","offset","offset-anchor","offset-distance","offset-path","offset-position","offset-rotate","opacity","order","orphans","outline","outline-color","outline-offset","outline-style","outline-width","overflow","overflow-anchor","overflow-block","overflow-clip-margin","overflow-inline","overflow-wrap","overflow-x","overflow-y","overlay","overscroll-behavior","overscroll-behavior-block","overscroll-behavior-inline","overscroll-behavior-x","overscroll-behavior-y","padding","padding-block","padding-block-end","padding-block-start","padding-bottom","padding-inline","padding-inline-end","padding-inline-start","padding-left","padding-right","padding-top","page","page-break-after","page-break-before","page-break-inside","paint-order","pause","pause-after","pause-before","perspective","perspective-origin","place-content","place-items","place-self","pointer-events","position","position-anchor","position-visibility","print-color-adjust","quotes","r","resize","rest","rest-after","rest-before","right","rotate","row-gap","ruby-align","ruby-position","scale","scroll-behavior","scroll-margin","scroll-margin-block","scroll-margin-block-end","scroll-margin-block-start","scroll-margin-bottom","scroll-margin-inline","scroll-margin-inline-end","scroll-margin-inline-start","scroll-margin-left","scroll-margin-right","scroll-margin-top","scroll-padding","scroll-padding-block","scroll-padding-block-end","scroll-padding-block-start","scroll-padding-bottom","scroll-padding-inline","scroll-padding-inline-end","scroll-padding-inline-start","scroll-padding-left","scroll-padding-right","scroll-padding-top","scroll-snap-align","scroll-snap-stop","scroll-snap-type","scroll-timeline","scroll-timeline-axis","scroll-timeline-name","scrollbar-color","scrollbar-gutter","scrollbar-width","shape-image-threshold","shape-margin","shape-outside","shape-rendering","speak","speak-as","src","stop-color","stop-opacity","stroke","stroke-dasharray","stroke-dashoffset","stroke-linecap","stroke-linejoin","stroke-miterlimit","stroke-opacity","stroke-width","tab-size","table-layout","text-align","text-align-all","text-align-last","text-anchor","text-combine-upright","text-decoration","text-decoration-color","text-decoration-line","text-decoration-skip","text-decoration-skip-ink","text-decoration-style","text-decoration-thickness","text-emphasis","text-emphasis-color","text-emphasis-position","text-emphasis-style","text-indent","text-justify","text-orientation","text-overflow","text-rendering","text-shadow","text-size-adjust","text-transform","text-underline-offset","text-underline-position","text-wrap","text-wrap-mode","text-wrap-style","timeline-scope","top","touch-action","transform","transform-box","transform-origin","transform-style","transition","transition-behavior","transition-delay","transition-duration","transition-property","transition-timing-function","translate","unicode-bidi","user-modify","user-select","vector-effect","vertical-align","view-timeline","view-timeline-axis","view-timeline-inset","view-timeline-name","view-transition-name","visibility","voice-balance","voice-duration","voice-family","voice-pitch","voice-range","voice-rate","voice-stress","voice-volume","white-space","white-space-collapse","widows","width","will-change","word-break","word-spacing","word-wrap","writing-mode","x","y","z-index","zoom"].sort().reverse();function VQ(e){const n=PQ(e),r=UQ,s=HQ,a="@[a-z-]+",i="and or not only",c={className:"variable",begin:"(\\$"+"[a-zA-Z-][a-zA-Z0-9_-]*"+")\\b",relevance:0};return{name:"SCSS",case_insensitive:!0,illegal:"[=/|']",contains:[e.C_LINE_COMMENT_MODE,e.C_BLOCK_COMMENT_MODE,n.CSS_NUMBER_MODE,{className:"selector-id",begin:"#[A-Za-z0-9_-]+",relevance:0},{className:"selector-class",begin:"\\.[A-Za-z0-9_-]+",relevance:0},n.ATTRIBUTE_SELECTOR_MODE,{className:"selector-tag",begin:"\\b("+zQ.join("|")+")\\b",relevance:0},{className:"selector-pseudo",begin:":("+s.join("|")+")"},{className:"selector-pseudo",begin:":(:)?("+r.join("|")+")"},c,{begin:/\(/,end:/\)/,contains:[n.CSS_NUMBER_MODE]},n.CSS_VARIABLE,{className:"attribute",begin:"\\b("+qQ.join("|")+")\\b"},{begin:"\\b(whitespace|wait|w-resize|visible|vertical-text|vertical-ideographic|uppercase|upper-roman|upper-alpha|underline|transparent|top|thin|thick|text|text-top|text-bottom|tb-rl|table-header-group|table-footer-group|sw-resize|super|strict|static|square|solid|small-caps|separate|se-resize|scroll|s-resize|rtl|row-resize|ridge|right|repeat|repeat-y|repeat-x|relative|progress|pointer|overline|outside|outset|oblique|nowrap|not-allowed|normal|none|nw-resize|no-repeat|no-drop|newspaper|ne-resize|n-resize|move|middle|medium|ltr|lr-tb|lowercase|lower-roman|lower-alpha|loose|list-item|line|line-through|line-edge|lighter|left|keep-all|justify|italic|inter-word|inter-ideograph|inside|inset|inline|inline-block|inherit|inactive|ideograph-space|ideograph-parenthesis|ideograph-numeric|ideograph-alpha|horizontal|hidden|help|hand|groove|fixed|ellipsis|e-resize|double|dotted|distribute|distribute-space|distribute-letter|distribute-all-lines|disc|disabled|default|decimal|dashed|crosshair|collapse|col-resize|circle|char|center|capitalize|break-word|break-all|bottom|both|bolder|bold|block|bidi-override|below|baseline|auto|always|all-scroll|absolute|table|table-cell)\\b"},{begin:/:/,end:/[;}{]/,relevance:0,contains:[n.BLOCK_COMMENT,c,n.HEXCOLOR,n.CSS_NUMBER_MODE,e.QUOTE_STRING_MODE,e.APOS_STRING_MODE,n.IMPORTANT,n.FUNCTION_DISPATCH]},{begin:"@(page|font-face)",keywords:{$pattern:a,keyword:"@page @font-face"}},{begin:"@",end:"[{;]",returnBegin:!0,keywords:{$pattern:/[a-z-]+/,keyword:i,attribute:FQ.join(" ")},contains:[{begin:a,className:"keyword"},{begin:/[a-z-]+(?=:)/,className:"attribute"},c,e.QUOTE_STRING_MODE,e.APOS_STRING_MODE,n.HEXCOLOR,n.CSS_NUMBER_MODE]},n.FUNCTION_DISPATCH]}}function WQ(e){return{name:"Shell Session",aliases:["console","shellsession"],contains:[{className:"meta.prompt",begin:/^\s{0,3}[/~\w\d[\]()@-]*[>%$#][ ]?/,starts:{end:/[^\\](?=\s*$)/,subLanguage:"bash"}}]}}function KQ(e){const n=e.regex,r=e.COMMENT("--","$"),s={scope:"string",variants:[{begin:/'/,end:/'/,contains:[{match:/''/}]}]},a={begin:/"/,end:/"/,contains:[{match:/""/}]},i=["true","false","unknown"],l=["double precision","large object","with timezone","without timezone"],c=["bigint","binary","blob","boolean","char","character","clob","date","dec","decfloat","decimal","float","int","integer","interval","nchar","nclob","national","numeric","real","row","smallint","time","timestamp","varchar","varying","varbinary"],u=["add","asc","collation","desc","final","first","last","view"],m=["abs","acos","all","allocate","alter","and","any","are","array","array_agg","array_max_cardinality","as","asensitive","asin","asymmetric","at","atan","atomic","authorization","avg","begin","begin_frame","begin_partition","between","bigint","binary","blob","boolean","both","by","call","called","cardinality","cascaded","case","cast","ceil","ceiling","char","char_length","character","character_length","check","classifier","clob","close","coalesce","collate","collect","column","commit","condition","connect","constraint","contains","convert","copy","corr","corresponding","cos","cosh","count","covar_pop","covar_samp","create","cross","cube","cume_dist","current","current_catalog","current_date","current_default_transform_group","current_path","current_role","current_row","current_schema","current_time","current_timestamp","current_path","current_role","current_transform_group_for_type","current_user","cursor","cycle","date","day","deallocate","dec","decimal","decfloat","declare","default","define","delete","dense_rank","deref","describe","deterministic","disconnect","distinct","double","drop","dynamic","each","element","else","empty","end","end_frame","end_partition","end-exec","equals","escape","every","except","exec","execute","exists","exp","external","extract","false","fetch","filter","first_value","float","floor","for","foreign","frame_row","free","from","full","function","fusion","get","global","grant","group","grouping","groups","having","hold","hour","identity","in","indicator","initial","inner","inout","insensitive","insert","int","integer","intersect","intersection","interval","into","is","join","json_array","json_arrayagg","json_exists","json_object","json_objectagg","json_query","json_table","json_table_primitive","json_value","lag","language","large","last_value","lateral","lead","leading","left","like","like_regex","listagg","ln","local","localtime","localtimestamp","log","log10","lower","match","match_number","match_recognize","matches","max","member","merge","method","min","minute","mod","modifies","module","month","multiset","national","natural","nchar","nclob","new","no","none","normalize","not","nth_value","ntile","null","nullif","numeric","octet_length","occurrences_regex","of","offset","old","omit","on","one","only","open","or","order","out","outer","over","overlaps","overlay","parameter","partition","pattern","per","percent","percent_rank","percentile_cont","percentile_disc","period","portion","position","position_regex","power","precedes","precision","prepare","primary","procedure","ptf","range","rank","reads","real","recursive","ref","references","referencing","regr_avgx","regr_avgy","regr_count","regr_intercept","regr_r2","regr_slope","regr_sxx","regr_sxy","regr_syy","release","result","return","returns","revoke","right","rollback","rollup","row","row_number","rows","running","savepoint","scope","scroll","search","second","seek","select","sensitive","session_user","set","show","similar","sin","sinh","skip","smallint","some","specific","specifictype","sql","sqlexception","sqlstate","sqlwarning","sqrt","start","static","stddev_pop","stddev_samp","submultiset","subset","substring","substring_regex","succeeds","sum","symmetric","system","system_time","system_user","table","tablesample","tan","tanh","then","time","timestamp","timezone_hour","timezone_minute","to","trailing","translate","translate_regex","translation","treat","trigger","trim","trim_array","true","truncate","uescape","union","unique","unknown","unnest","update","upper","user","using","value","values","value_of","var_pop","var_samp","varbinary","varchar","varying","versioning","when","whenever","where","width_bucket","window","with","within","without","year"],f=["abs","acos","array_agg","asin","atan","avg","cast","ceil","ceiling","coalesce","corr","cos","cosh","count","covar_pop","covar_samp","cume_dist","dense_rank","deref","element","exp","extract","first_value","floor","json_array","json_arrayagg","json_exists","json_object","json_objectagg","json_query","json_table","json_table_primitive","json_value","lag","last_value","lead","listagg","ln","log","log10","lower","max","min","mod","nth_value","ntile","nullif","percent_rank","percentile_cont","percentile_disc","position","position_regex","power","rank","regr_avgx","regr_avgy","regr_count","regr_intercept","regr_r2","regr_slope","regr_sxx","regr_sxy","regr_syy","row_number","sin","sinh","sqrt","stddev_pop","stddev_samp","substring","substring_regex","sum","tan","tanh","translate","translate_regex","treat","trim","trim_array","unnest","upper","value_of","var_pop","var_samp","width_bucket"],p=["current_catalog","current_date","current_default_transform_group","current_path","current_role","current_schema","current_transform_group_for_type","current_user","session_user","system_time","system_user","current_time","localtime","current_timestamp","localtimestamp"],b=["create table","insert into","primary key","foreign key","not null","alter table","add constraint","grouping sets","on overflow","character set","respect nulls","ignore nulls","nulls first","nulls last","depth first","breadth first"],x=f,v=[...m,...u].filter(T=>!f.includes(T)),N={scope:"variable",match:/@[a-z0-9][a-z0-9_]*/},C={scope:"operator",match:/[-+*/=%^~]|&&?|\|\|?|!=?|<(?:=>?|<|>)?|>[>=]?/,relevance:0},k={match:n.concat(/\b/,n.either(...x),/\s*\(/),relevance:0,keywords:{built_in:x}};function j(T){return n.concat(/\b/,n.either(...T.map(R=>R.replace(/\s+/,"\\s+"))),/\b/)}const w={scope:"keyword",match:j(b),relevance:0};function S(T,{exceptions:R,when:I}={}){const P=I;return R=R||[],T.map(L=>L.match(/\|\d+$/)||R.includes(L)?L:P(L)?`${L}|0`:L)}return{name:"SQL",case_insensitive:!0,illegal:/[{}]|<\//,keywords:{$pattern:/\b[\w\.]+/,keyword:S(v,{when:T=>T.length<3}),literal:i,type:c,built_in:p},contains:[{scope:"type",match:j(l)},w,k,N,s,a,e.C_NUMBER_MODE,e.C_BLOCK_COMMENT_MODE,r,C]}}function lT(e){return e?typeof e=="string"?e:e.source:null}function t0(e){return ns("(?=",e,")")}function ns(...e){return e.map(r=>lT(r)).join("")}function GQ(e){const n=e[e.length-1];return typeof n=="object"&&n.constructor===Object?(e.splice(e.length-1,1),n):{}}function wa(...e){return"("+(GQ(e).capture?"":"?:")+e.map(s=>lT(s)).join("|")+")"}const Mv=e=>ns(/\b/,e,/\w$/.test(e)?/\b/:/\B/),YQ=["Protocol","Type"].map(Mv),SN=["init","self"].map(Mv),XQ=["Any","Self"],Tb=["actor","any","associatedtype","async","await",/as\?/,/as!/,"as","borrowing","break","case","catch","class","consume","consuming","continue","convenience","copy","default","defer","deinit","didSet","distributed","do","dynamic","each","else","enum","extension","fallthrough",/fileprivate\(set\)/,"fileprivate","final","for","func","get","guard","if","import","indirect","infix",/init\?/,/init!/,"inout",/internal\(set\)/,"internal","in","is","isolated","nonisolated","lazy","let","macro","mutating","nonmutating",/open\(set\)/,"open","operator","optional","override","package","postfix","precedencegroup","prefix",/private\(set\)/,"private","protocol",/public\(set\)/,"public","repeat","required","rethrows","return","set","some","static","struct","subscript","super","switch","throws","throw",/try\?/,/try!/,"try","typealias",/unowned\(safe\)/,/unowned\(unsafe\)/,"unowned","var","weak","where","while","willSet"],CN=["false","nil","true"],QQ=["assignment","associativity","higherThan","left","lowerThan","none","right"],ZQ=["#colorLiteral","#column","#dsohandle","#else","#elseif","#endif","#error","#file","#fileID","#fileLiteral","#filePath","#function","#if","#imageLiteral","#keyPath","#line","#selector","#sourceLocation","#warning"],EN=["abs","all","any","assert","assertionFailure","debugPrint","dump","fatalError","getVaList","isKnownUniquelyReferenced","max","min","numericCast","pointwiseMax","pointwiseMin","precondition","preconditionFailure","print","readLine","repeatElement","sequence","stride","swap","swift_unboxFromSwiftValueWithType","transcode","type","unsafeBitCast","unsafeDowncast","withExtendedLifetime","withUnsafeMutablePointer","withUnsafePointer","withVaList","withoutActuallyEscaping","zip"],cT=wa(/[/=\-+!*%<>&|^~?]/,/[\u00A1-\u00A7]/,/[\u00A9\u00AB]/,/[\u00AC\u00AE]/,/[\u00B0\u00B1]/,/[\u00B6\u00BB\u00BF\u00D7\u00F7]/,/[\u2016-\u2017]/,/[\u2020-\u2027]/,/[\u2030-\u203E]/,/[\u2041-\u2053]/,/[\u2055-\u205E]/,/[\u2190-\u23FF]/,/[\u2500-\u2775]/,/[\u2794-\u2BFF]/,/[\u2E00-\u2E7F]/,/[\u3001-\u3003]/,/[\u3008-\u3020]/,/[\u3030]/),dT=wa(cT,/[\u0300-\u036F]/,/[\u1DC0-\u1DFF]/,/[\u20D0-\u20FF]/,/[\uFE00-\uFE0F]/,/[\uFE20-\uFE2F]/),Ab=ns(cT,dT,"*"),uT=wa(/[a-zA-Z_]/,/[\u00A8\u00AA\u00AD\u00AF\u00B2-\u00B5\u00B7-\u00BA]/,/[\u00BC-\u00BE\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u00FF]/,/[\u0100-\u02FF\u0370-\u167F\u1681-\u180D\u180F-\u1DBF]/,/[\u1E00-\u1FFF]/,/[\u200B-\u200D\u202A-\u202E\u203F-\u2040\u2054\u2060-\u206F]/,/[\u2070-\u20CF\u2100-\u218F\u2460-\u24FF\u2776-\u2793]/,/[\u2C00-\u2DFF\u2E80-\u2FFF]/,/[\u3004-\u3007\u3021-\u302F\u3031-\u303F\u3040-\uD7FF]/,/[\uF900-\uFD3D\uFD40-\uFDCF\uFDF0-\uFE1F\uFE30-\uFE44]/,/[\uFE47-\uFEFE\uFF00-\uFFFD]/),zh=wa(uT,/\d/,/[\u0300-\u036F\u1DC0-\u1DFF\u20D0-\u20FF\uFE20-\uFE2F]/),Qi=ns(uT,zh,"*"),Df=ns(/[A-Z]/,zh,"*"),JQ=["attached","autoclosure",ns(/convention\(/,wa("swift","block","c"),/\)/),"discardableResult","dynamicCallable","dynamicMemberLookup","escaping","freestanding","frozen","GKInspectable","IBAction","IBDesignable","IBInspectable","IBOutlet","IBSegueAction","inlinable","main","nonobjc","NSApplicationMain","NSCopying","NSManaged",ns(/objc\(/,Qi,/\)/),"objc","objcMembers","propertyWrapper","requires_stored_property_inits","resultBuilder","Sendable","testable","UIApplicationMain","unchecked","unknown","usableFromInline","warn_unqualified_access"],eZ=["iOS","iOSApplicationExtension","macOS","macOSApplicationExtension","macCatalyst","macCatalystApplicationExtension","watchOS","watchOSApplicationExtension","tvOS","tvOSApplicationExtension","swift"];function tZ(e){const n={match:/\s+/,relevance:0},r=e.COMMENT("/\\*","\\*/",{contains:["self"]}),s=[e.C_LINE_COMMENT_MODE,r],a={match:[/\./,wa(...YQ,...SN)],className:{2:"keyword"}},i={match:ns(/\./,wa(...Tb)),relevance:0},l=Tb.filter(ue=>typeof ue=="string").concat(["_|0"]),c=Tb.filter(ue=>typeof ue!="string").concat(XQ).map(Mv),u={variants:[{className:"keyword",match:wa(...c,...SN)}]},m={$pattern:wa(/\b\w+/,/#\w+/),keyword:l.concat(ZQ),literal:CN},f=[a,i,u],p={match:ns(/\./,wa(...EN)),relevance:0},b={className:"built_in",match:ns(/\b/,wa(...EN),/(?=\()/)},x=[p,b],v={match:/->/,relevance:0},N={className:"operator",relevance:0,variants:[{match:Ab},{match:`\\.(\\.|${dT})+`}]},C=[v,N],k="([0-9]_*)+",j="([0-9a-fA-F]_*)+",w={className:"number",relevance:0,variants:[{match:`\\b(${k})(\\.(${k}))?([eE][+-]?(${k}))?\\b`},{match:`\\b0x(${j})(\\.(${j}))?([pP][+-]?(${k}))?\\b`},{match:/\b0o([0-7]_*)+\b/},{match:/\b0b([01]_*)+\b/}]},S=(ue="")=>({className:"subst",variants:[{match:ns(/\\/,ue,/[0\\tnr"']/)},{match:ns(/\\/,ue,/u\{[0-9a-fA-F]{1,8}\}/)}]}),T=(ue="")=>({className:"subst",match:ns(/\\/,ue,/[\t ]*(?:[\r\n]|\r\n)/)}),R=(ue="")=>({className:"subst",label:"interpol",begin:ns(/\\/,ue,/\(/),end:/\)/}),I=(ue="")=>({begin:ns(ue,/"""/),end:ns(/"""/,ue),contains:[S(ue),T(ue),R(ue)]}),P=(ue="")=>({begin:ns(ue,/"/),end:ns(/"/,ue),contains:[S(ue),R(ue)]}),L={className:"string",variants:[I(),I("#"),I("##"),I("###"),P(),P("#"),P("##"),P("###")]},M=[e.BACKSLASH_ESCAPE,{begin:/\[/,end:/\]/,relevance:0,contains:[e.BACKSLASH_ESCAPE]}],$={begin:/\/[^\s](?=[^/\n]*\/)/,end:/\//,contains:M},U=ue=>{const Le=ns(ue,/\//),$e=ns(/\//,ue);return{begin:Le,end:$e,contains:[...M,{scope:"comment",begin:`#(?!.*${$e})`,end:/$/}]}},z={scope:"regexp",variants:[U("###"),U("##"),U("#"),$]},A={match:ns(/`/,Qi,/`/)},H={className:"variable",match:/\$\d+/},D={className:"variable",match:`\\$${zh}+`},O=[A,H,D],q={match:/(@|#(un)?)available/,scope:"keyword",starts:{contains:[{begin:/\(/,end:/\)/,keywords:eZ,contains:[...C,w,L]}]}},J={scope:"keyword",match:ns(/@/,wa(...JQ),t0(wa(/\(/,/\s+/)))},B={scope:"meta",match:ns(/@/,Qi)},V=[q,J,B],X={match:t0(/\b[A-Z]/),relevance:0,contains:[{className:"type",match:ns(/(AV|CA|CF|CG|CI|CL|CM|CN|CT|MK|MP|MTK|MTL|NS|SCN|SK|UI|WK|XC)/,zh,"+")},{className:"type",match:Df,relevance:0},{match:/[?!]+/,relevance:0},{match:/\.\.\./,relevance:0},{match:ns(/\s+&\s+/,t0(Df)),relevance:0}]},K={begin:/</,end:/>/,keywords:m,contains:[...s,...f,...V,v,X]};X.contains.push(K);const ee={match:ns(Qi,/\s*:/),keywords:"_|0",relevance:0},Q={begin:/\(/,end:/\)/,relevance:0,keywords:m,contains:["self",ee,...s,z,...f,...x,...C,w,L,...O,...V,X]},ne={begin:/</,end:/>/,keywords:"repeat each",contains:[...s,X]},te={begin:wa(t0(ns(Qi,/\s*:/)),t0(ns(Qi,/\s+/,Qi,/\s*:/))),end:/:/,relevance:0,contains:[{className:"keyword",match:/\b_\b/},{className:"params",match:Qi}]},Y={begin:/\(/,end:/\)/,keywords:m,contains:[te,...s,...f,...C,w,L,...V,X,Q],endsParent:!0,illegal:/["']/},oe={match:[/(func|macro)/,/\s+/,wa(A.match,Qi,Ab)],className:{1:"keyword",3:"title.function"},contains:[ne,Y,n],illegal:[/\[/,/%/]},ge={match:[/\b(?:subscript|init[?!]?)/,/\s*(?=[<(])/],className:{1:"keyword"},contains:[ne,Y,n],illegal:/\[|%/},ye={match:[/operator/,/\s+/,Ab],className:{1:"keyword",3:"title"}},we={begin:[/precedencegroup/,/\s+/,Df],className:{1:"keyword",3:"title"},contains:[X],keywords:[...QQ,...CN],end:/}/},Ce={match:[/class\b/,/\s+/,/func\b/,/\s+/,/\b[A-Za-z_][A-Za-z0-9_]*\b/],scope:{1:"keyword",3:"keyword",5:"title.function"}},ie={match:[/class\b/,/\s+/,/var\b/],scope:{1:"keyword",3:"keyword"}},Te={begin:[/(struct|protocol|class|extension|enum|actor)/,/\s+/,Qi,/\s*/],beginScope:{1:"keyword",3:"title.class"},keywords:m,contains:[ne,...f,{begin:/:/,end:/\{/,keywords:m,contains:[{scope:"title.class.inherited",match:Df},...f],relevance:0}]};for(const ue of L.variants){const Le=ue.contains.find(je=>je.label==="interpol");Le.keywords=m;const $e=[...f,...x,...C,w,L,...O];Le.contains=[...$e,{begin:/\(/,end:/\)/,contains:["self",...$e]}]}return{name:"Swift",keywords:m,contains:[...s,oe,ge,Ce,ie,Te,ye,we,{beginKeywords:"import",end:/$/,contains:[...s],relevance:0},z,...f,...x,...C,w,L,...O,...V,X,Q]}}const Fh="[A-Za-z$_][0-9A-Za-z$_]*",mT=["as","in","of","if","for","while","finally","var","new","function","do","return","void","else","break","catch","instanceof","with","throw","case","default","try","switch","continue","typeof","delete","let","yield","const","class","debugger","async","await","static","import","from","export","extends","using"],fT=["true","false","null","undefined","NaN","Infinity"],hT=["Object","Function","Boolean","Symbol","Math","Date","Number","BigInt","String","RegExp","Array","Float32Array","Float64Array","Int8Array","Uint8Array","Uint8ClampedArray","Int16Array","Int32Array","Uint16Array","Uint32Array","BigInt64Array","BigUint64Array","Set","Map","WeakSet","WeakMap","ArrayBuffer","SharedArrayBuffer","Atomics","DataView","JSON","Promise","Generator","GeneratorFunction","AsyncFunction","Reflect","Proxy","Intl","WebAssembly"],pT=["Error","EvalError","InternalError","RangeError","ReferenceError","SyntaxError","TypeError","URIError"],gT=["setInterval","setTimeout","clearInterval","clearTimeout","require","exports","eval","isFinite","isNaN","parseFloat","parseInt","decodeURI","decodeURIComponent","encodeURI","encodeURIComponent","escape","unescape"],xT=["arguments","this","super","console","window","document","localStorage","sessionStorage","module","global"],bT=[].concat(gT,hT,pT);function nZ(e){const n=e.regex,r=(q,{after:J})=>{const B="</"+q[0].slice(1);return q.input.indexOf(B,J)!==-1},s=Fh,a={begin:"<>",end:"</>"},i=/<[A-Za-z0-9\\._:-]+\s*\/>/,l={begin:/<[A-Za-z0-9\\._:-]+/,end:/\/[A-Za-z0-9\\._:-]+>|\/>/,isTrulyOpeningTag:(q,J)=>{const B=q[0].length+q.index,V=q.input[B];if(V==="<"||V===","){J.ignoreMatch();return}V===">"&&(r(q,{after:B})||J.ignoreMatch());let X;const K=q.input.substring(B);if(X=K.match(/^\s*=/)){J.ignoreMatch();return}if((X=K.match(/^\s+extends\s+/))&&X.index===0){J.ignoreMatch();return}}},c={$pattern:Fh,keyword:mT,literal:fT,built_in:bT,"variable.language":xT},u="[0-9](_?[0-9])*",m=`\\.(${u})`,f="0|[1-9](_?[0-9])*|0[0-7]*[89][0-9]*",p={className:"number",variants:[{begin:`(\\b(${f})((${m})|\\.)?|(${m}))[eE][+-]?(${u})\\b`},{begin:`\\b(${f})\\b((${m})\\b|\\.)?|(${m})\\b`},{begin:"\\b(0|[1-9](_?[0-9])*)n\\b"},{begin:"\\b0[xX][0-9a-fA-F](_?[0-9a-fA-F])*n?\\b"},{begin:"\\b0[bB][0-1](_?[0-1])*n?\\b"},{begin:"\\b0[oO][0-7](_?[0-7])*n?\\b"},{begin:"\\b0[0-7]+n?\\b"}],relevance:0},b={className:"subst",begin:"\\$\\{",end:"\\}",keywords:c,contains:[]},x={begin:".?html`",end:"",starts:{end:"`",returnEnd:!1,contains:[e.BACKSLASH_ESCAPE,b],subLanguage:"xml"}},v={begin:".?css`",end:"",starts:{end:"`",returnEnd:!1,contains:[e.BACKSLASH_ESCAPE,b],subLanguage:"css"}},N={begin:".?gql`",end:"",starts:{end:"`",returnEnd:!1,contains:[e.BACKSLASH_ESCAPE,b],subLanguage:"graphql"}},C={className:"string",begin:"`",end:"`",contains:[e.BACKSLASH_ESCAPE,b]},j={className:"comment",variants:[e.COMMENT(/\/\*\*(?!\/)/,"\\*/",{relevance:0,contains:[{begin:"(?=@[A-Za-z]+)",relevance:0,contains:[{className:"doctag",begin:"@[A-Za-z]+"},{className:"type",begin:"\\{",end:"\\}",excludeEnd:!0,excludeBegin:!0,relevance:0},{className:"variable",begin:s+"(?=\\s*(-)|$)",endsParent:!0,relevance:0},{begin:/(?=[^\n])\s/,relevance:0}]}]}),e.C_BLOCK_COMMENT_MODE,e.C_LINE_COMMENT_MODE]},w=[e.APOS_STRING_MODE,e.QUOTE_STRING_MODE,x,v,N,C,{match:/\$\d+/},p];b.contains=w.concat({begin:/\{/,end:/\}/,keywords:c,contains:["self"].concat(w)});const S=[].concat(j,b.contains),T=S.concat([{begin:/(\s*)\(/,end:/\)/,keywords:c,contains:["self"].concat(S)}]),R={className:"params",begin:/(\s*)\(/,end:/\)/,excludeBegin:!0,excludeEnd:!0,keywords:c,contains:T},I={variants:[{match:[/class/,/\s+/,s,/\s+/,/extends/,/\s+/,n.concat(s,"(",n.concat(/\./,s),")*")],scope:{1:"keyword",3:"title.class",5:"keyword",7:"title.class.inherited"}},{match:[/class/,/\s+/,s],scope:{1:"keyword",3:"title.class"}}]},P={relevance:0,match:n.either(/\bJSON/,/\b[A-Z][a-z]+([A-Z][a-z]*|\d)*/,/\b[A-Z]{2,}([A-Z][a-z]+|\d)+([A-Z][a-z]*)*/,/\b[A-Z]{2,}[a-z]+([A-Z][a-z]+|\d)*([A-Z][a-z]*)*/),className:"title.class",keywords:{_:[...hT,...pT]}},L={label:"use_strict",className:"meta",relevance:10,begin:/^\s*['"]use (strict|asm)['"]/},M={variants:[{match:[/function/,/\s+/,s,/(?=\s*\()/]},{match:[/function/,/\s*(?=\()/]}],className:{1:"keyword",3:"title.function"},label:"func.def",contains:[R],illegal:/%/},$={relevance:0,match:/\b[A-Z][A-Z_0-9]+\b/,className:"variable.constant"};function U(q){return n.concat("(?!",q.join("|"),")")}const z={match:n.concat(/\b/,U([...gT,"super","import"].map(q=>`${q}\\s*\\(`)),s,n.lookahead(/\s*\(/)),className:"title.function",relevance:0},A={begin:n.concat(/\./,n.lookahead(n.concat(s,/(?![0-9A-Za-z$_(])/))),end:s,excludeBegin:!0,keywords:"prototype",className:"property",relevance:0},H={match:[/get|set/,/\s+/,s,/(?=\()/],className:{1:"keyword",3:"title.function"},contains:[{begin:/\(\)/},R]},D="(\\([^()]*(\\([^()]*(\\([^()]*\\)[^()]*)*\\)[^()]*)*\\)|"+e.UNDERSCORE_IDENT_RE+")\\s*=>",O={match:[/const|var|let/,/\s+/,s,/\s*/,/=\s*/,/(async\s*)?/,n.lookahead(D)],keywords:"async",className:{1:"keyword",3:"title.function"},contains:[R]};return{name:"JavaScript",aliases:["js","jsx","mjs","cjs"],keywords:c,exports:{PARAMS_CONTAINS:T,CLASS_REFERENCE:P},illegal:/#(?![$_A-z])/,contains:[e.SHEBANG({label:"shebang",binary:"node",relevance:5}),L,e.APOS_STRING_MODE,e.QUOTE_STRING_MODE,x,v,N,C,j,{match:/\$\d+/},p,P,{scope:"attr",match:s+n.lookahead(":"),relevance:0},O,{begin:"("+e.RE_STARTERS_RE+"|\\b(case|return|throw)\\b)\\s*",keywords:"return throw case",relevance:0,contains:[j,e.REGEXP_MODE,{className:"function",begin:D,returnBegin:!0,end:"\\s*=>",contains:[{className:"params",variants:[{begin:e.UNDERSCORE_IDENT_RE,relevance:0},{className:null,begin:/\(\s*\)/,skip:!0},{begin:/(\s*)\(/,end:/\)/,excludeBegin:!0,excludeEnd:!0,keywords:c,contains:T}]}]},{begin:/,/,relevance:0},{match:/\s+/,relevance:0},{variants:[{begin:a.begin,end:a.end},{match:i},{begin:l.begin,"on:begin":l.isTrulyOpeningTag,end:l.end}],subLanguage:"xml",contains:[{begin:l.begin,end:l.end,skip:!0,contains:["self"]}]}]},M,{beginKeywords:"while if switch catch for"},{begin:"\\b(?!function)"+e.UNDERSCORE_IDENT_RE+"\\([^()]*(\\([^()]*(\\([^()]*\\)[^()]*)*\\)[^()]*)*\\)\\s*\\{",returnBegin:!0,label:"func.def",contains:[R,e.inherit(e.TITLE_MODE,{begin:s,className:"title.function"})]},{match:/\.\.\./,relevance:0},A,{match:"\\$"+s,relevance:0},{match:[/\bconstructor(?=\s*\()/],className:{1:"title.function"},contains:[R]},z,$,I,H,{match:/\$[(.]/}]}}function rZ(e){const n=e.regex,r=nZ(e),s=Fh,a=["any","void","number","boolean","string","object","never","symbol","bigint","unknown"],i={begin:[/namespace/,/\s+/,e.IDENT_RE],beginScope:{1:"keyword",3:"title.class"}},l={beginKeywords:"interface",end:/\{/,excludeEnd:!0,keywords:{keyword:"interface extends",built_in:a},contains:[r.exports.CLASS_REFERENCE]},c={className:"meta",relevance:10,begin:/^\s*['"]use strict['"]/},u=["type","interface","public","private","protected","implements","declare","abstract","readonly","enum","override","satisfies"],m={$pattern:Fh,keyword:mT.concat(u),literal:fT,built_in:bT.concat(a),"variable.language":xT},f={className:"meta",begin:"@"+s},p=(N,C,k)=>{const j=N.contains.findIndex(w=>w.label===C);if(j===-1)throw new Error("can not find mode to replace");N.contains.splice(j,1,k)};Object.assign(r.keywords,m),r.exports.PARAMS_CONTAINS.push(f);const b=r.contains.find(N=>N.scope==="attr"),x=Object.assign({},b,{match:n.concat(s,n.lookahead(/\s*\?:/))});r.exports.PARAMS_CONTAINS.push([r.exports.CLASS_REFERENCE,b,x]),r.contains=r.contains.concat([f,i,l,x]),p(r,"shebang",e.SHEBANG()),p(r,"use_strict",c);const v=r.contains.find(N=>N.label==="func.def");return v.relevance=0,Object.assign(r,{name:"TypeScript",aliases:["ts","tsx","mts","cts"]}),r}function sZ(e){const n=e.regex,r={className:"string",begin:/"(""|[^/n])"C\b/},s={className:"string",begin:/"/,end:/"/,illegal:/\n/,contains:[{begin:/""/}]},a=/\d{1,2}\/\d{1,2}\/\d{4}/,i=/\d{4}-\d{1,2}-\d{1,2}/,l=/(\d|1[012])(:\d+){0,2} *(AM|PM)/,c=/\d{1,2}(:\d{1,2}){1,2}/,u={className:"literal",variants:[{begin:n.concat(/# */,n.either(i,a),/ *#/)},{begin:n.concat(/# */,c,/ *#/)},{begin:n.concat(/# */,l,/ *#/)},{begin:n.concat(/# */,n.either(i,a),/ +/,n.either(l,c),/ *#/)}]},m={className:"number",relevance:0,variants:[{begin:/\b\d[\d_]*((\.[\d_]+(E[+-]?[\d_]+)?)|(E[+-]?[\d_]+))[RFD@!#]?/},{begin:/\b\d[\d_]*((U?[SIL])|[%&])?/},{begin:/&H[\dA-F_]+((U?[SIL])|[%&])?/},{begin:/&O[0-7_]+((U?[SIL])|[%&])?/},{begin:/&B[01_]+((U?[SIL])|[%&])?/}]},f={className:"label",begin:/^\w+:/},p=e.COMMENT(/'''/,/$/,{contains:[{className:"doctag",begin:/<\/?/,end:/>/}]}),b=e.COMMENT(null,/$/,{variants:[{begin:/'/},{begin:/([\t ]|^)REM(?=\s)/}]});return{name:"Visual Basic .NET",aliases:["vb"],case_insensitive:!0,classNameAliases:{label:"symbol"},keywords:{keyword:"addhandler alias aggregate ansi as async assembly auto binary by byref byval call case catch class compare const continue custom declare default delegate dim distinct do each equals else elseif end enum erase error event exit explicit finally for friend from function get global goto group handles if implements imports in inherits interface into iterator join key let lib loop me mid module mustinherit mustoverride mybase myclass namespace narrowing new next notinheritable notoverridable of off on operator option optional order overloads overridable overrides paramarray partial preserve private property protected public raiseevent readonly redim removehandler resume return select set shadows shared skip static step stop structure strict sub synclock take text then throw to try unicode until using when where while widening with withevents writeonly yield",built_in:"addressof and andalso await directcast gettype getxmlnamespace is isfalse isnot istrue like mod nameof new not or orelse trycast typeof xor cbool cbyte cchar cdate cdbl cdec cint clng cobj csbyte cshort csng cstr cuint culng cushort",type:"boolean byte char date decimal double integer long object sbyte short single string uinteger ulong ushort",literal:"true false nothing"},illegal:"//|\\{|\\}|endif|gosub|variant|wend|^\\$ ",contains:[r,s,u,m,f,p,b,{className:"meta",begin:/[\t ]*#(const|disable|else|elseif|enable|end|externalsource|if|region)\b/,end:/$/,keywords:{keyword:"const disable else elseif enable end externalsource if region then"},contains:[b]}]}}function aZ(e){e.regex;const n=e.COMMENT(/\(;/,/;\)/);n.contains.push("self");const r=e.COMMENT(/;;/,/$/),s=["anyfunc","block","br","br_if","br_table","call","call_indirect","data","drop","elem","else","end","export","func","global.get","global.set","local.get","local.set","local.tee","get_global","get_local","global","if","import","local","loop","memory","memory.grow","memory.size","module","mut","nop","offset","param","result","return","select","set_global","set_local","start","table","tee_local","then","type","unreachable"],a={begin:[/(?:func|call|call_indirect)/,/\s+/,/\$[^\s)]+/],className:{1:"keyword",3:"title.function"}},i={className:"variable",begin:/\$[\w_]+/},l={match:/(\((?!;)|\))+/,className:"punctuation",relevance:0},c={className:"number",relevance:0,match:/[+-]?\b(?:\d(?:_?\d)*(?:\.\d(?:_?\d)*)?(?:[eE][+-]?\d(?:_?\d)*)?|0x[\da-fA-F](?:_?[\da-fA-F])*(?:\.[\da-fA-F](?:_?[\da-fA-D])*)?(?:[pP][+-]?\d(?:_?\d)*)?)\b|\binf\b|\bnan(?::0x[\da-fA-F](?:_?[\da-fA-D])*)?\b/},u={match:/(i32|i64|f32|f64)(?!\.)/,className:"type"},m={className:"keyword",match:/\b(f32|f64|i32|i64)(?:\.(?:abs|add|and|ceil|clz|const|convert_[su]\/i(?:32|64)|copysign|ctz|demote\/f64|div(?:_[su])?|eqz?|extend_[su]\/i32|floor|ge(?:_[su])?|gt(?:_[su])?|le(?:_[su])?|load(?:(?:8|16|32)_[su])?|lt(?:_[su])?|max|min|mul|nearest|neg?|or|popcnt|promote\/f32|reinterpret\/[fi](?:32|64)|rem_[su]|rot[lr]|shl|shr_[su]|store(?:8|16|32)?|sqrt|sub|trunc(?:_[su]\/f(?:32|64))?|wrap\/i64|xor))\b/};return{name:"WebAssembly",keywords:{$pattern:/[\w.]+/,keyword:s},contains:[r,n,{match:[/(?:offset|align)/,/\s*/,/=/],className:{1:"keyword",3:"operator"}},i,l,a,e.QUOTE_STRING_MODE,u,m,c]}}function iZ(e){const n=e.regex,r=n.concat(/[\p{L}_]/u,n.optional(/[\p{L}0-9_.-]*:/u),/[\p{L}0-9_.-]*/u),s=/[\p{L}0-9._:-]+/u,a={className:"symbol",begin:/&[a-z]+;|&#[0-9]+;|&#x[a-f0-9]+;/},i={begin:/\s/,contains:[{className:"keyword",begin:/#?[a-z_][a-z1-9_-]+/,illegal:/\n/}]},l=e.inherit(i,{begin:/\(/,end:/\)/}),c=e.inherit(e.APOS_STRING_MODE,{className:"string"}),u=e.inherit(e.QUOTE_STRING_MODE,{className:"string"}),m={endsWithParent:!0,illegal:/</,relevance:0,contains:[{className:"attr",begin:s,relevance:0},{begin:/=\s*/,relevance:0,contains:[{className:"string",endsParent:!0,variants:[{begin:/"/,end:/"/,contains:[a]},{begin:/'/,end:/'/,contains:[a]},{begin:/[^\s"'=<>`]+/}]}]}]};return{name:"HTML, XML",aliases:["html","xhtml","rss","atom","xjb","xsd","xsl","plist","wsf","svg"],case_insensitive:!0,unicodeRegex:!0,contains:[{className:"meta",begin:/<![a-z]/,end:/>/,relevance:10,contains:[i,u,c,l,{begin:/\[/,end:/\]/,contains:[{className:"meta",begin:/<![a-z]/,end:/>/,contains:[i,l,u,c]}]}]},e.COMMENT(/<!--/,/-->/,{relevance:10}),{begin:/<!\[CDATA\[/,end:/\]\]>/,relevance:10},a,{className:"meta",end:/\?>/,variants:[{begin:/<\?xml/,relevance:10,contains:[u]},{begin:/<\?[a-z][a-z0-9]+/}]},{className:"tag",begin:/<style(?=\s|>)/,end:/>/,keywords:{name:"style"},contains:[m],starts:{end:/<\/style>/,returnEnd:!0,subLanguage:["css","xml"]}},{className:"tag",begin:/<script(?=\s|>)/,end:/>/,keywords:{name:"script"},contains:[m],starts:{end:/<\/script>/,returnEnd:!0,subLanguage:["javascript","handlebars","xml"]}},{className:"tag",begin:/<>|<\/>/},{className:"tag",begin:n.concat(/</,n.lookahead(n.concat(r,n.either(/\/>/,/>/,/\s/)))),end:/\/?>/,contains:[{className:"name",begin:r,relevance:0,starts:m}]},{className:"tag",begin:n.concat(/<\//,n.lookahead(n.concat(r,/>/))),contains:[{className:"name",begin:r,relevance:0},{begin:/>/,relevance:0,endsParent:!0}]}]}}function oZ(e){const n="true false yes no null",r="[\\w#;/?:@&=+$,.~*'()[\\]]+",s={className:"attr",variants:[{begin:/[\w*@][\w*@ :()\./-]*:(?=[ \t]|$)/},{begin:/"[\w*@][\w*@ :()\./-]*":(?=[ \t]|$)/},{begin:/'[\w*@][\w*@ :()\./-]*':(?=[ \t]|$)/}]},a={className:"template-variable",variants:[{begin:/\{\{/,end:/\}\}/},{begin:/%\{/,end:/\}/}]},i={className:"string",relevance:0,begin:/'/,end:/'/,contains:[{match:/''/,scope:"char.escape",relevance:0}]},l={className:"string",relevance:0,variants:[{begin:/"/,end:/"/},{begin:/\S+/}],contains:[e.BACKSLASH_ESCAPE,a]},c=e.inherit(l,{variants:[{begin:/'/,end:/'/,contains:[{begin:/''/,relevance:0}]},{begin:/"/,end:/"/},{begin:/[^\s,{}[\]]+/}]}),b={className:"number",begin:"\\b"+"[0-9]{4}(-[0-9][0-9]){0,2}"+"([Tt \\t][0-9][0-9]?(:[0-9][0-9]){2})?"+"(\\.[0-9]*)?"+"([ \\t])*(Z|[-+][0-9][0-9]?(:[0-9][0-9])?)?"+"\\b"},x={end:",",endsWithParent:!0,excludeEnd:!0,keywords:n,relevance:0},v={begin:/\{/,end:/\}/,contains:[x],illegal:"\\n",relevance:0},N={begin:"\\[",end:"\\]",contains:[x],illegal:"\\n",relevance:0},C=[s,{className:"meta",begin:"^---\\s*$",relevance:10},{className:"string",begin:"[\\|>]([1-9]?[+-])?[ ]*\\n( +)[^ ][^\\n]*\\n(\\2[^\\n]+\\n?)*"},{begin:"<%[%=-]?",end:"[%-]?%>",subLanguage:"ruby",excludeBegin:!0,excludeEnd:!0,relevance:0},{className:"type",begin:"!\\w+!"+r},{className:"type",begin:"!<"+r+">"},{className:"type",begin:"!"+r},{className:"type",begin:"!!"+r},{className:"meta",begin:"&"+e.UNDERSCORE_IDENT_RE+"$"},{className:"meta",begin:"\\*"+e.UNDERSCORE_IDENT_RE+"$"},{className:"bullet",begin:"-(?=[ ]|$)",relevance:0},e.HASH_COMMENT_MODE,{beginKeywords:n,keywords:{literal:n}},b,{className:"number",begin:e.C_NUMBER_RE+"\\b",relevance:0},v,N,i,l],k=[...C];return k.pop(),k.push(c),x.contains=k,{name:"YAML",case_insensitive:!0,aliases:["yml"],contains:C}}const lZ={arduino:UX,bash:qX,c:VX,cpp:WX,csharp:KX,css:nQ,diff:rQ,go:sQ,graphql:aQ,ini:iQ,java:oQ,javascript:mQ,json:fQ,kotlin:pQ,less:NQ,lua:jQ,makefile:SQ,markdown:CQ,objectivec:EQ,perl:TQ,php:AQ,"php-template":MQ,plaintext:_Q,python:RQ,"python-repl":IQ,r:DQ,ruby:LQ,rust:OQ,scss:VQ,shell:WQ,sql:KQ,swift:tZ,typescript:rZ,vbnet:sZ,wasm:aZ,xml:iZ,yaml:oZ};var Mb,TN;function cZ(){if(TN)return Mb;TN=1;function e(be){return be instanceof Map?be.clear=be.delete=be.set=function(){throw new Error("map is read-only")}:be instanceof Set&&(be.add=be.clear=be.delete=function(){throw new Error("set is read-only")}),Object.freeze(be),Object.getOwnPropertyNames(be).forEach(Je=>{const it=be[Je],It=typeof it;(It==="object"||It==="function")&&!Object.isFrozen(it)&&e(it)}),be}class n{constructor(Je){Je.data===void 0&&(Je.data={}),this.data=Je.data,this.isMatchIgnored=!1}ignoreMatch(){this.isMatchIgnored=!0}}function r(be){return be.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&#x27;")}function s(be,...Je){const it=Object.create(null);for(const It in be)it[It]=be[It];return Je.forEach(function(It){for(const sn in It)it[sn]=It[sn]}),it}const a="</span>",i=be=>!!be.scope,l=(be,{prefix:Je})=>{if(be.startsWith("language:"))return be.replace("language:","language-");if(be.includes(".")){const it=be.split(".");return[`${Je}${it.shift()}`,...it.map((It,sn)=>`${It}${"_".repeat(sn+1)}`)].join(" ")}return`${Je}${be}`};class c{constructor(Je,it){this.buffer="",this.classPrefix=it.classPrefix,Je.walk(this)}addText(Je){this.buffer+=r(Je)}openNode(Je){if(!i(Je))return;const it=l(Je.scope,{prefix:this.classPrefix});this.span(it)}closeNode(Je){i(Je)&&(this.buffer+=a)}value(){return this.buffer}span(Je){this.buffer+=`<span class="${Je}">`}}const u=(be={})=>{const Je={children:[]};return Object.assign(Je,be),Je};class m{constructor(){this.rootNode=u(),this.stack=[this.rootNode]}get top(){return this.stack[this.stack.length-1]}get root(){return this.rootNode}add(Je){this.top.children.push(Je)}openNode(Je){const it=u({scope:Je});this.add(it),this.stack.push(it)}closeNode(){if(this.stack.length>1)return this.stack.pop()}closeAllNodes(){for(;this.closeNode(););}toJSON(){return JSON.stringify(this.rootNode,null,4)}walk(Je){return this.constructor._walk(Je,this.rootNode)}static _walk(Je,it){return typeof it=="string"?Je.addText(it):it.children&&(Je.openNode(it),it.children.forEach(It=>this._walk(Je,It)),Je.closeNode(it)),Je}static _collapse(Je){typeof Je!="string"&&Je.children&&(Je.children.every(it=>typeof it=="string")?Je.children=[Je.children.join("")]:Je.children.forEach(it=>{m._collapse(it)}))}}class f extends m{constructor(Je){super(),this.options=Je}addText(Je){Je!==""&&this.add(Je)}startScope(Je){this.openNode(Je)}endScope(){this.closeNode()}__addSublanguage(Je,it){const It=Je.root;it&&(It.scope=`language:${it}`),this.add(It)}toHTML(){return new c(this,this.options).value()}finalize(){return this.closeAllNodes(),!0}}function p(be){return be?typeof be=="string"?be:be.source:null}function b(be){return N("(?=",be,")")}function x(be){return N("(?:",be,")*")}function v(be){return N("(?:",be,")?")}function N(...be){return be.map(it=>p(it)).join("")}function C(be){const Je=be[be.length-1];return typeof Je=="object"&&Je.constructor===Object?(be.splice(be.length-1,1),Je):{}}function k(...be){return"("+(C(be).capture?"":"?:")+be.map(It=>p(It)).join("|")+")"}function j(be){return new RegExp(be.toString()+"|").exec("").length-1}function w(be,Je){const it=be&&be.exec(Je);return it&&it.index===0}const S=/\[(?:[^\\\]]|\\.)*\]|\(\??|\\([1-9][0-9]*)|\\./;function T(be,{joinWith:Je}){let it=0;return be.map(It=>{it+=1;const sn=it;let An=p(It),Ut="";for(;An.length>0;){const Dt=S.exec(An);if(!Dt){Ut+=An;break}Ut+=An.substring(0,Dt.index),An=An.substring(Dt.index+Dt[0].length),Dt[0][0]==="\\"&&Dt[1]?Ut+="\\"+String(Number(Dt[1])+sn):(Ut+=Dt[0],Dt[0]==="("&&it++)}return Ut}).map(It=>`(${It})`).join(Je)}const R=/\b\B/,I="[a-zA-Z]\\w*",P="[a-zA-Z_]\\w*",L="\\b\\d+(\\.\\d+)?",M="(-?)(\\b0[xX][a-fA-F0-9]+|(\\b\\d+(\\.\\d*)?|\\.\\d+)([eE][-+]?\\d+)?)",$="\\b(0b[01]+)",U="!|!=|!==|%|%=|&|&&|&=|\\*|\\*=|\\+|\\+=|,|-|-=|/=|/|:|;|<<|<<=|<=|<|===|==|=|>>>=|>>=|>=|>>>|>>|>|\\?|\\[|\\{|\\(|\\^|\\^=|\\||\\|=|\\|\\||~",z=(be={})=>{const Je=/^#![ ]*\//;return be.binary&&(be.begin=N(Je,/.*\b/,be.binary,/\b.*/)),s({scope:"meta",begin:Je,end:/$/,relevance:0,"on:begin":(it,It)=>{it.index!==0&&It.ignoreMatch()}},be)},A={begin:"\\\\[\\s\\S]",relevance:0},H={scope:"string",begin:"'",end:"'",illegal:"\\n",contains:[A]},D={scope:"string",begin:'"',end:'"',illegal:"\\n",contains:[A]},O={begin:/\b(a|an|the|are|I'm|isn't|don't|doesn't|won't|but|just|should|pretty|simply|enough|gonna|going|wtf|so|such|will|you|your|they|like|more)\b/},q=function(be,Je,it={}){const It=s({scope:"comment",begin:be,end:Je,contains:[]},it);It.contains.push({scope:"doctag",begin:"[ ]*(?=(TODO|FIXME|NOTE|BUG|OPTIMIZE|HACK|XXX):)",end:/(TODO|FIXME|NOTE|BUG|OPTIMIZE|HACK|XXX):/,excludeBegin:!0,relevance:0});const sn=k("I","a","is","so","us","to","at","if","in","it","on",/[A-Za-z]+['](d|ve|re|ll|t|s|n)/,/[A-Za-z]+[-][a-z]+/,/[A-Za-z][a-z]{2,}/);return It.contains.push({begin:N(/[ ]+/,"(",sn,/[.]?[:]?([.][ ]|[ ])/,"){3}")}),It},J=q("//","$"),B=q("/\\*","\\*/"),V=q("#","$"),X={scope:"number",begin:L,relevance:0},K={scope:"number",begin:M,relevance:0},ee={scope:"number",begin:$,relevance:0},Q={scope:"regexp",begin:/\/(?=[^/\n]*\/)/,end:/\/[gimuy]*/,contains:[A,{begin:/\[/,end:/\]/,relevance:0,contains:[A]}]},ne={scope:"title",begin:I,relevance:0},te={scope:"title",begin:P,relevance:0},Y={begin:"\\.\\s*"+P,relevance:0};var ge=Object.freeze({__proto__:null,APOS_STRING_MODE:H,BACKSLASH_ESCAPE:A,BINARY_NUMBER_MODE:ee,BINARY_NUMBER_RE:$,COMMENT:q,C_BLOCK_COMMENT_MODE:B,C_LINE_COMMENT_MODE:J,C_NUMBER_MODE:K,C_NUMBER_RE:M,END_SAME_AS_BEGIN:function(be){return Object.assign(be,{"on:begin":(Je,it)=>{it.data._beginMatch=Je[1]},"on:end":(Je,it)=>{it.data._beginMatch!==Je[1]&&it.ignoreMatch()}})},HASH_COMMENT_MODE:V,IDENT_RE:I,MATCH_NOTHING_RE:R,METHOD_GUARD:Y,NUMBER_MODE:X,NUMBER_RE:L,PHRASAL_WORDS_MODE:O,QUOTE_STRING_MODE:D,REGEXP_MODE:Q,RE_STARTERS_RE:U,SHEBANG:z,TITLE_MODE:ne,UNDERSCORE_IDENT_RE:P,UNDERSCORE_TITLE_MODE:te});function ye(be,Je){be.input[be.index-1]==="."&&Je.ignoreMatch()}function we(be,Je){be.className!==void 0&&(be.scope=be.className,delete be.className)}function Ce(be,Je){Je&&be.beginKeywords&&(be.begin="\\b("+be.beginKeywords.split(" ").join("|")+")(?!\\.)(?=\\b|\\s)",be.__beforeBegin=ye,be.keywords=be.keywords||be.beginKeywords,delete be.beginKeywords,be.relevance===void 0&&(be.relevance=0))}function ie(be,Je){Array.isArray(be.illegal)&&(be.illegal=k(...be.illegal))}function Te(be,Je){if(be.match){if(be.begin||be.end)throw new Error("begin & end are not supported with match");be.begin=be.match,delete be.match}}function ue(be,Je){be.relevance===void 0&&(be.relevance=1)}const Le=(be,Je)=>{if(!be.beforeMatch)return;if(be.starts)throw new Error("beforeMatch cannot be used with starts");const it=Object.assign({},be);Object.keys(be).forEach(It=>{delete be[It]}),be.keywords=it.keywords,be.begin=N(it.beforeMatch,b(it.begin)),be.starts={relevance:0,contains:[Object.assign(it,{endsParent:!0})]},be.relevance=0,delete it.beforeMatch},$e=["of","and","for","in","not","or","if","then","parent","list","value"],je="keyword";function Ee(be,Je,it=je){const It=Object.create(null);return typeof be=="string"?sn(it,be.split(" ")):Array.isArray(be)?sn(it,be):Object.keys(be).forEach(function(An){Object.assign(It,Ee(be[An],Je,An))}),It;function sn(An,Ut){Je&&(Ut=Ut.map(Dt=>Dt.toLowerCase())),Ut.forEach(function(Dt){const on=Dt.split("|");It[on[0]]=[An,We(on[0],on[1])]})}}function We(be,Je){return Je?Number(Je):Ve(be)?0:1}function Ve(be){return $e.includes(be.toLowerCase())}const de={},ve=be=>{console.error(be)},Ne=(be,...Je)=>{console.log(`WARN: ${be}`,...Je)},W=(be,Je)=>{de[`${be}/${Je}`]||(console.log(`Deprecated as of ${be}. ${Je}`),de[`${be}/${Je}`]=!0)},re=new Error;function Ae(be,Je,{key:it}){let It=0;const sn=be[it],An={},Ut={};for(let Dt=1;Dt<=Je.length;Dt++)Ut[Dt+It]=sn[Dt],An[Dt+It]=!0,It+=j(Je[Dt-1]);be[it]=Ut,be[it]._emit=An,be[it]._multi=!0}function xe(be){if(Array.isArray(be.begin)){if(be.skip||be.excludeBegin||be.returnBegin)throw ve("skip, excludeBegin, returnBegin not compatible with beginScope: {}"),re;if(typeof be.beginScope!="object"||be.beginScope===null)throw ve("beginScope must be object"),re;Ae(be,be.begin,{key:"beginScope"}),be.begin=T(be.begin,{joinWith:""})}}function tt(be){if(Array.isArray(be.end)){if(be.skip||be.excludeEnd||be.returnEnd)throw ve("skip, excludeEnd, returnEnd not compatible with endScope: {}"),re;if(typeof be.endScope!="object"||be.endScope===null)throw ve("endScope must be object"),re;Ae(be,be.end,{key:"endScope"}),be.end=T(be.end,{joinWith:""})}}function vt(be){be.scope&&typeof be.scope=="object"&&be.scope!==null&&(be.beginScope=be.scope,delete be.scope)}function xt(be){vt(be),typeof be.beginScope=="string"&&(be.beginScope={_wrap:be.beginScope}),typeof be.endScope=="string"&&(be.endScope={_wrap:be.endScope}),xe(be),tt(be)}function Me(be){function Je(Ut,Dt){return new RegExp(p(Ut),"m"+(be.case_insensitive?"i":"")+(be.unicodeRegex?"u":"")+(Dt?"g":""))}class it{constructor(){this.matchIndexes={},this.regexes=[],this.matchAt=1,this.position=0}addRule(Dt,on){on.position=this.position++,this.matchIndexes[this.matchAt]=on,this.regexes.push([on,Dt]),this.matchAt+=j(Dt)+1}compile(){this.regexes.length===0&&(this.exec=()=>null);const Dt=this.regexes.map(on=>on[1]);this.matcherRe=Je(T(Dt,{joinWith:"|"}),!0),this.lastIndex=0}exec(Dt){this.matcherRe.lastIndex=this.lastIndex;const on=this.matcherRe.exec(Dt);if(!on)return null;const Ln=on.findIndex((Wr,er)=>er>0&&Wr!==void 0),On=this.matchIndexes[Ln];return on.splice(0,Ln),Object.assign(on,On)}}class It{constructor(){this.rules=[],this.multiRegexes=[],this.count=0,this.lastIndex=0,this.regexIndex=0}getMatcher(Dt){if(this.multiRegexes[Dt])return this.multiRegexes[Dt];const on=new it;return this.rules.slice(Dt).forEach(([Ln,On])=>on.addRule(Ln,On)),on.compile(),this.multiRegexes[Dt]=on,on}resumingScanAtSamePosition(){return this.regexIndex!==0}considerAll(){this.regexIndex=0}addRule(Dt,on){this.rules.push([Dt,on]),on.type==="begin"&&this.count++}exec(Dt){const on=this.getMatcher(this.regexIndex);on.lastIndex=this.lastIndex;let Ln=on.exec(Dt);if(this.resumingScanAtSamePosition()&&!(Ln&&Ln.index===this.lastIndex)){const On=this.getMatcher(0);On.lastIndex=this.lastIndex+1,Ln=On.exec(Dt)}return Ln&&(this.regexIndex+=Ln.position+1,this.regexIndex===this.count&&this.considerAll()),Ln}}function sn(Ut){const Dt=new It;return Ut.contains.forEach(on=>Dt.addRule(on.begin,{rule:on,type:"begin"})),Ut.terminatorEnd&&Dt.addRule(Ut.terminatorEnd,{type:"end"}),Ut.illegal&&Dt.addRule(Ut.illegal,{type:"illegal"}),Dt}function An(Ut,Dt){const on=Ut;if(Ut.isCompiled)return on;[we,Te,xt,Le].forEach(On=>On(Ut,Dt)),be.compilerExtensions.forEach(On=>On(Ut,Dt)),Ut.__beforeBegin=null,[Ce,ie,ue].forEach(On=>On(Ut,Dt)),Ut.isCompiled=!0;let Ln=null;return typeof Ut.keywords=="object"&&Ut.keywords.$pattern&&(Ut.keywords=Object.assign({},Ut.keywords),Ln=Ut.keywords.$pattern,delete Ut.keywords.$pattern),Ln=Ln||/\w+/,Ut.keywords&&(Ut.keywords=Ee(Ut.keywords,be.case_insensitive)),on.keywordPatternRe=Je(Ln,!0),Dt&&(Ut.begin||(Ut.begin=/\B|\b/),on.beginRe=Je(on.begin),!Ut.end&&!Ut.endsWithParent&&(Ut.end=/\B|\b/),Ut.end&&(on.endRe=Je(on.end)),on.terminatorEnd=p(on.end)||"",Ut.endsWithParent&&Dt.terminatorEnd&&(on.terminatorEnd+=(Ut.end?"|":"")+Dt.terminatorEnd)),Ut.illegal&&(on.illegalRe=Je(Ut.illegal)),Ut.contains||(Ut.contains=[]),Ut.contains=[].concat(...Ut.contains.map(function(On){return Re(On==="self"?Ut:On)})),Ut.contains.forEach(function(On){An(On,on)}),Ut.starts&&An(Ut.starts,Dt),on.matcher=sn(on),on}if(be.compilerExtensions||(be.compilerExtensions=[]),be.contains&&be.contains.includes("self"))throw new Error("ERR: contains `self` is not supported at the top-level of a language. See documentation.");return be.classNameAliases=s(be.classNameAliases||{}),An(be)}function Ke(be){return be?be.endsWithParent||Ke(be.starts):!1}function Re(be){return be.variants&&!be.cachedVariants&&(be.cachedVariants=be.variants.map(function(Je){return s(be,{variants:null},Je)})),be.cachedVariants?be.cachedVariants:Ke(be)?s(be,{starts:be.starts?s(be.starts):null}):Object.isFrozen(be)?s(be):be}var qe="11.11.1";class ct extends Error{constructor(Je,it){super(Je),this.name="HTMLInjectionError",this.html=it}}const Bt=r,gt=s,cn=Symbol("nomatch"),st=7,Ct=function(be){const Je=Object.create(null),it=Object.create(null),It=[];let sn=!0;const An="Could not find the language '{}', did you forget to load/include a language module?",Ut={disableAutodetect:!0,name:"Plain text",contains:[]};let Dt={ignoreUnescapedHTML:!1,throwUnescapedHTML:!1,noHighlightRe:/^(no-?highlight)$/i,languageDetectRe:/\blang(?:uage)?-([\w-]+)\b/i,classPrefix:"hljs-",cssSelector:"pre code",languages:null,__emitter:f};function on(pe){return Dt.noHighlightRe.test(pe)}function Ln(pe){let Ye=pe.className+" ";Ye+=pe.parentNode?pe.parentNode.className:"";const lt=Dt.languageDetectRe.exec(Ye);if(lt){const St=En(lt[1]);return St||(Ne(An.replace("{}",lt[1])),Ne("Falling back to no-highlight mode for this block.",pe)),St?lt[1]:"no-highlight"}return Ye.split(/\s+/).find(St=>on(St)||En(St))}function On(pe,Ye,lt){let St="",Jt="";typeof Ye=="object"?(St=pe,lt=Ye.ignoreIllegals,Jt=Ye.language):(W("10.7.0","highlight(lang, code, ...args) has been deprecated."),W("10.7.0",`Please use highlight(code, options) instead.
648
648
  https://github.com/highlightjs/highlight.js/issues/2277`),Jt=pe,St=Ye),lt===void 0&&(lt=!0);const gn={code:St,language:Jt};pr("before:highlight",gn);const tr=gn.result?gn.result:Wr(gn.language,gn.code,lt);return tr.code=gn.code,pr("after:highlight",tr),tr}function Wr(pe,Ye,lt,St){const Jt=Object.create(null);function gn(Ft,_t){return Ft.keywords[_t]}function tr(){if(!wt.keywords){Rn.addText(mn);return}let Ft=0;wt.keywordPatternRe.lastIndex=0;let _t=wt.keywordPatternRe.exec(mn),vn="";for(;_t;){vn+=mn.substring(Ft,_t.index);const zn=nr.case_insensitive?_t[0].toLowerCase():_t[0],Cr=gn(wt,zn);if(Cr){const[ps,oi]=Cr;if(Rn.addText(vn),vn="",Jt[zn]=(Jt[zn]||0)+1,Jt[zn]<=st&&(Ir+=oi),ps.startsWith("_"))vn+=_t[0];else{const la=nr.classNameAliases[ps]||ps;Pn(_t[0],la)}}else vn+=_t[0];Ft=wt.keywordPatternRe.lastIndex,_t=wt.keywordPatternRe.exec(mn)}vn+=mn.substring(Ft),Rn.addText(vn)}function Wn(){if(mn==="")return;let Ft=null;if(typeof wt.subLanguage=="string"){if(!Je[wt.subLanguage]){Rn.addText(mn);return}Ft=Wr(wt.subLanguage,mn,!0,tn[wt.subLanguage]),tn[wt.subLanguage]=Ft._top}else Ft=br(mn,wt.subLanguage.length?wt.subLanguage:null);wt.relevance>0&&(Ir+=Ft.relevance),Rn.__addSublanguage(Ft._emitter,Ft.language)}function Pt(){wt.subLanguage!=null?Wn():tr(),mn=""}function Pn(Ft,_t){Ft!==""&&(Rn.startScope(_t),Rn.addText(Ft),Rn.endScope())}function kr(Ft,_t){let vn=1;const zn=_t.length-1;for(;vn<=zn;){if(!Ft._emit[vn]){vn++;continue}const Cr=nr.classNameAliases[Ft[vn]]||Ft[vn],ps=_t[vn];Cr?Pn(ps,Cr):(mn=ps,tr(),mn=""),vn++}}function rr(Ft,_t){return Ft.scope&&typeof Ft.scope=="string"&&Rn.openNode(nr.classNameAliases[Ft.scope]||Ft.scope),Ft.beginScope&&(Ft.beginScope._wrap?(Pn(mn,nr.classNameAliases[Ft.beginScope._wrap]||Ft.beginScope._wrap),mn=""):Ft.beginScope._multi&&(kr(Ft.beginScope,_t),mn="")),wt=Object.create(Ft,{parent:{value:wt}}),wt}function Bn(Ft,_t,vn){let zn=w(Ft.endRe,vn);if(zn){if(Ft["on:end"]){const Cr=new n(Ft);Ft["on:end"](_t,Cr),Cr.isMatchIgnored&&(zn=!1)}if(zn){for(;Ft.endsParent&&Ft.parent;)Ft=Ft.parent;return Ft}}if(Ft.endsWithParent)return Bn(Ft.parent,_t,vn)}function Sr(Ft){return wt.matcher.regexIndex===0?(mn+=Ft[0],1):(Ms=!0,0)}function Kn(Ft){const _t=Ft[0],vn=Ft.rule,zn=new n(vn),Cr=[vn.__beforeBegin,vn["on:begin"]];for(const ps of Cr)if(ps&&(ps(Ft,zn),zn.isMatchIgnored))return Sr(_t);return vn.skip?mn+=_t:(vn.excludeBegin&&(mn+=_t),Pt(),!vn.returnBegin&&!vn.excludeBegin&&(mn=_t)),rr(vn,Ft),vn.returnBegin?0:_t.length}function $n(Ft){const _t=Ft[0],vn=Ye.substring(Ft.index),zn=Bn(wt,Ft,vn);if(!zn)return cn;const Cr=wt;wt.endScope&&wt.endScope._wrap?(Pt(),Pn(_t,wt.endScope._wrap)):wt.endScope&&wt.endScope._multi?(Pt(),kr(wt.endScope,Ft)):Cr.skip?mn+=_t:(Cr.returnEnd||Cr.excludeEnd||(mn+=_t),Pt(),Cr.excludeEnd&&(mn=_t));do wt.scope&&Rn.closeNode(),!wt.skip&&!wt.subLanguage&&(Ir+=wt.relevance),wt=wt.parent;while(wt!==zn.parent);return zn.starts&&rr(zn.starts,Ft),Cr.returnEnd?0:_t.length}function Gr(){const Ft=[];for(let _t=wt;_t!==nr;_t=_t.parent)_t.scope&&Ft.unshift(_t.scope);Ft.forEach(_t=>Rn.openNode(_t))}let yn={};function Br(Ft,_t){const vn=_t&&_t[0];if(mn+=Ft,vn==null)return Pt(),0;if(yn.type==="begin"&&_t.type==="end"&&yn.index===_t.index&&vn===""){if(mn+=Ye.slice(_t.index,_t.index+1),!sn){const zn=new Error(`0 width match regex (${pe})`);throw zn.languageName=pe,zn.badRule=yn.rule,zn}return 1}if(yn=_t,_t.type==="begin")return Kn(_t);if(_t.type==="illegal"&&!lt){const zn=new Error('Illegal lexeme "'+vn+'" for mode "'+(wt.scope||"<unnamed>")+'"');throw zn.mode=wt,zn}else if(_t.type==="end"){const zn=$n(_t);if(zn!==cn)return zn}if(_t.type==="illegal"&&vn==="")return mn+=`
649
- `,1;if(Ua>1e5&&Ua>_t.index*3)throw new Error("potential infinite loop, way more iterations than matches");return mn+=vn,vn.length}const nr=En(pe);if(!nr)throw ve(An.replace("{}",pe)),new Error('Unknown language: "'+pe+'"');const Fe=Me(nr);let jt="",wt=St||Fe;const tn={},Rn=new Dt.__emitter(Dt);Gr();let mn="",Ir=0,is=0,Ua=0,Ms=!1;try{if(nr.__emitTokens)nr.__emitTokens(Ye,Rn);else{for(wt.matcher.considerAll();;){Ua++,Ms?Ms=!1:wt.matcher.considerAll(),wt.matcher.lastIndex=is;const Ft=wt.matcher.exec(Ye);if(!Ft)break;const _t=Ye.substring(is,Ft.index),vn=Br(_t,Ft);is=Ft.index+vn}Br(Ye.substring(is))}return Rn.finalize(),jt=Rn.toHTML(),{language:pe,value:jt,relevance:Ir,illegal:!1,_emitter:Rn,_top:wt}}catch(Ft){if(Ft.message&&Ft.message.includes("Illegal"))return{language:pe,value:Bt(Ye),illegal:!0,relevance:0,_illegalBy:{message:Ft.message,index:is,context:Ye.slice(is-100,is+100),mode:Ft.mode,resultSoFar:jt},_emitter:Rn};if(sn)return{language:pe,value:Bt(Ye),illegal:!1,relevance:0,errorRaised:Ft,_emitter:Rn,_top:wt};throw Ft}}function er(pe){const Ye={value:Bt(pe),illegal:!1,relevance:0,_top:Ut,_emitter:new Dt.__emitter(Dt)};return Ye._emitter.addText(pe),Ye}function br(pe,Ye){Ye=Ye||Dt.languages||Object.keys(Je);const lt=er(pe),St=Ye.filter(En).filter($t).map(Pt=>Wr(Pt,pe,!1));St.unshift(lt);const Jt=St.sort((Pt,Pn)=>{if(Pt.relevance!==Pn.relevance)return Pn.relevance-Pt.relevance;if(Pt.language&&Pn.language){if(En(Pt.language).supersetOf===Pn.language)return 1;if(En(Pn.language).supersetOf===Pt.language)return-1}return 0}),[gn,tr]=Jt,Wn=gn;return Wn.secondBest=tr,Wn}function Mr(pe,Ye,lt){const St=Ye&&it[Ye]||lt;pe.classList.add("hljs"),pe.classList.add(`language-${St}`)}function Cn(pe){let Ye=null;const lt=Ln(pe);if(on(lt))return;if(pr("before:highlightElement",{el:pe,language:lt}),pe.dataset.highlighted){console.log("Element previously highlighted. To highlight again, first unset `dataset.highlighted`.",pe);return}if(pe.children.length>0&&(Dt.ignoreUnescapedHTML||(console.warn("One of your code blocks includes unescaped HTML. This is a potentially serious security risk."),console.warn("https://github.com/highlightjs/highlight.js/wiki/security"),console.warn("The element with unescaped HTML:"),console.warn(pe)),Dt.throwUnescapedHTML))throw new ct("One of your code blocks includes unescaped HTML.",pe.innerHTML);Ye=pe;const St=Ye.textContent,Jt=lt?On(St,{language:lt,ignoreIllegals:!0}):br(St);pe.innerHTML=Jt.value,pe.dataset.highlighted="yes",Mr(pe,lt,Jt.language),pe.result={language:Jt.language,re:Jt.relevance,relevance:Jt.relevance},Jt.secondBest&&(pe.secondBest={language:Jt.secondBest.language,relevance:Jt.secondBest.relevance}),pr("after:highlightElement",{el:pe,result:Jt,text:St})}function Un(pe){Dt=gt(Dt,pe)}const ar=()=>{fr(),W("10.6.0","initHighlighting() deprecated. Use highlightAll() now.")};function mr(){fr(),W("10.6.0","initHighlightingOnLoad() deprecated. Use highlightAll() now.")}let Kr=!1;function fr(){function pe(){fr()}if(document.readyState==="loading"){Kr||window.addEventListener("DOMContentLoaded",pe,!1),Kr=!0;return}document.querySelectorAll(Dt.cssSelector).forEach(Cn)}function Zn(pe,Ye){let lt=null;try{lt=Ye(be)}catch(St){if(ve("Language definition for '{}' could not be registered.".replace("{}",pe)),sn)ve(St);else throw St;lt=Ut}lt.name||(lt.name=pe),Je[pe]=lt,lt.rawDefinition=Ye.bind(null,be),lt.aliases&&Oe(lt.aliases,{languageName:pe})}function ir(pe){delete Je[pe];for(const Ye of Object.keys(it))it[Ye]===pe&&delete it[Ye]}function hr(){return Object.keys(Je)}function En(pe){return pe=(pe||"").toLowerCase(),Je[pe]||Je[it[pe]]}function Oe(pe,{languageName:Ye}){typeof pe=="string"&&(pe=[pe]),pe.forEach(lt=>{it[lt.toLowerCase()]=Ye})}function $t(pe){const Ye=En(pe);return Ye&&!Ye.disableAutodetect}function jn(pe){pe["before:highlightBlock"]&&!pe["before:highlightElement"]&&(pe["before:highlightElement"]=Ye=>{pe["before:highlightBlock"](Object.assign({block:Ye.el},Ye))}),pe["after:highlightBlock"]&&!pe["after:highlightElement"]&&(pe["after:highlightElement"]=Ye=>{pe["after:highlightBlock"](Object.assign({block:Ye.el},Ye))})}function Wt(pe){jn(pe),It.push(pe)}function pn(pe){const Ye=It.indexOf(pe);Ye!==-1&&It.splice(Ye,1)}function pr(pe,Ye){const lt=pe;It.forEach(function(St){St[lt]&&St[lt](Ye)})}function Yt(pe){return W("10.7.0","highlightBlock will be removed entirely in v12.0"),W("10.7.0","Please use highlightElement now."),Cn(pe)}Object.assign(be,{highlight:On,highlightAuto:br,highlightAll:fr,highlightElement:Cn,highlightBlock:Yt,configure:Un,initHighlighting:ar,initHighlightingOnLoad:mr,registerLanguage:Zn,unregisterLanguage:ir,listLanguages:hr,getLanguage:En,registerAliases:Oe,autoDetection:$t,inherit:gt,addPlugin:Wt,removePlugin:pn}),be.debugMode=function(){sn=!1},be.safeMode=function(){sn=!0},be.versionString=qe,be.regex={concat:N,lookahead:b,either:k,optional:v,anyNumberOfTimes:x};for(const pe in ge)typeof ge[pe]=="object"&&e(ge[pe]);return Object.assign(be,ge),be},en=Ct({});return en.newInstance=()=>Ct({}),Mb=en,en.HighlightJS=en,en.default=en,Mb}var dZ=cZ();const uZ=Tc(dZ),AN={},mZ="hljs-";function fZ(e){const n=uZ.newInstance();return e&&i(e),{highlight:r,highlightAuto:s,listLanguages:a,register:i,registerAlias:l,registered:c};function r(u,m,f){const p=f||AN,b=typeof p.prefix=="string"?p.prefix:mZ;if(!n.getLanguage(u))throw new Error("Unknown language: `"+u+"` is not registered");n.configure({__emitter:hZ,classPrefix:b});const x=n.highlight(m,{ignoreIllegals:!0,language:u});if(x.errorRaised)throw new Error("Could not highlight with `Highlight.js`",{cause:x.errorRaised});const v=x._emitter.root,N=v.data;return N.language=x.language,N.relevance=x.relevance,v}function s(u,m){const p=(m||AN).subset||a();let b=-1,x=0,v;for(;++b<p.length;){const N=p[b];if(!n.getLanguage(N))continue;const C=r(N,u,m);C.data&&C.data.relevance!==void 0&&C.data.relevance>x&&(x=C.data.relevance,v=C)}return v||{type:"root",children:[],data:{language:void 0,relevance:x}}}function a(){return n.listLanguages()}function i(u,m){if(typeof u=="string")n.registerLanguage(u,m);else{let f;for(f in u)Object.hasOwn(u,f)&&n.registerLanguage(f,u[f])}}function l(u,m){if(typeof u=="string")n.registerAliases(typeof m=="string"?m:[...m],{languageName:u});else{let f;for(f in u)if(Object.hasOwn(u,f)){const p=u[f];n.registerAliases(typeof p=="string"?p:[...p],{languageName:f})}}}function c(u){return!!n.getLanguage(u)}}class hZ{constructor(n){this.options=n,this.root={type:"root",children:[],data:{language:void 0,relevance:0}},this.stack=[this.root]}addText(n){if(n==="")return;const r=this.stack[this.stack.length-1],s=r.children[r.children.length-1];s&&s.type==="text"?s.value+=n:r.children.push({type:"text",value:n})}startScope(n){this.openNode(String(n))}endScope(){this.closeNode()}__addSublanguage(n,r){const s=this.stack[this.stack.length-1],a=n.root.children;r?s.children.push({type:"element",tagName:"span",properties:{className:[r]},children:a}):s.children.push(...a)}openNode(n){const r=this,s=n.split(".").map(function(l,c){return c?l+"_".repeat(c):r.options.classPrefix+l}),a=this.stack[this.stack.length-1],i={type:"element",tagName:"span",properties:{className:s},children:[]};a.children.push(i),this.stack.push(i)}closeNode(){this.stack.pop()}finalize(){}toHTML(){return""}}const pZ={};function yT(e){const n=e||pZ,r=n.aliases,s=n.detect||!1,a=n.languages||lZ,i=n.plainText,l=n.prefix,c=n.subset;let u="hljs";const m=fZ(a);if(r&&m.registerAlias(r),l){const f=l.indexOf("-");u=f===-1?l:l.slice(0,f)}return function(f,p){hp(f,"element",function(b,x,v){if(b.tagName!=="code"||!v||v.type!=="element"||v.tagName!=="pre")return;const N=gZ(b);if(N===!1||!N&&!s||N&&i&&i.includes(N))return;Array.isArray(b.properties.className)||(b.properties.className=[]),b.properties.className.includes(u)||b.properties.className.unshift(u);const C=ZE(b,{whitespace:"pre"});let k;try{k=N?m.highlight(N,C,{prefix:l}):m.highlightAuto(C,{prefix:l,subset:c})}catch(j){const w=j;if(N&&/Unknown language/.test(w.message)){p.message("Cannot highlight as `"+N+"`, it’s not registered",{ancestors:[v,b],cause:w,place:b.position,ruleId:"missing-language",source:"rehype-highlight"});return}throw w}!N&&k.data&&k.data.language&&b.properties.className.push("language-"+k.data.language),k.children.length>0&&(b.children=k.children)})}}function gZ(e){const n=e.properties.className;let r=-1;if(!Array.isArray(n))return;let s;for(;++r<n.length;){const a=String(n[r]);if(a==="no-highlight"||a==="nohighlight")return!1;!s&&a.slice(0,5)==="lang-"&&(s=a.slice(5)),!s&&a.slice(0,9)==="language-"&&(s=a.slice(9))}return s}const xZ="modulepreload",bZ=function(e){return"/"+e},MN={},ql=function(n,r,s){let a=Promise.resolve();if(r&&r.length>0){let u=function(m){return Promise.all(m.map(f=>Promise.resolve(f).then(p=>({status:"fulfilled",value:p}),p=>({status:"rejected",reason:p}))))};document.getElementsByTagName("link");const l=document.querySelector("meta[property=csp-nonce]"),c=l?.nonce||l?.getAttribute("nonce");a=u(r.map(m=>{if(m=bZ(m),m in MN)return;MN[m]=!0;const f=m.endsWith(".css"),p=f?'[rel="stylesheet"]':"";if(document.querySelector(`link[href="${m}"]${p}`))return;const b=document.createElement("link");if(b.rel=f?"stylesheet":xZ,f||(b.as="script"),b.crossOrigin="",b.href=m,c&&b.setAttribute("nonce",c),document.head.appendChild(b),f)return new Promise((x,v)=>{b.addEventListener("load",x),b.addEventListener("error",()=>v(new Error(`Unable to preload CSS for ${m}`)))})}))}function i(l){const c=new Event("vite:preloadError",{cancelable:!0});if(c.payload=l,window.dispatchEvent(c),!c.defaultPrevented)throw l}return a.then(l=>{for(const c of l||[])c.status==="rejected"&&i(c.reason);return n().catch(i)})};g.lazy(()=>ql(()=>Promise.resolve().then(()=>Mp),void 0).then(e=>({default:e.MarkdownMessage})));const yZ=g.lazy(()=>ql(()=>Promise.resolve().then(()=>Cne),void 0).then(e=>({default:e.ContentRenderer})));let gd=[],_N=60;function vZ(e){const n=g.useRef(e);n.current=e;const[r]=g.useState(()=>++_N);return g.useEffect(()=>{const s=()=>n.current();gd.push(s);const a=i=>{i.key==="Escape"&&gd[gd.length-1]===s&&(i.preventDefault(),s())};return window.addEventListener("keydown",a,!0),()=>{window.removeEventListener("keydown",a,!0),gd=gd.filter(i=>i!==s),gd.length===0&&(_N=60)}},[]),r}const RN=500,Dl=new Map,Hh=new Set,ph=new Map;let gh=null;function wZ(){if(Dl.size<=RN)return;const e=Dl.size-RN,n=Dl.keys();for(let r=0;r<e;r++){const{value:s,done:a}=n.next();if(a)break;Dl.delete(s)}}function IN(e,n){Dl.delete(e),Dl.set(e,n),wZ()}function DN(e){const n=ph.get(e);if(n)for(const r of n)r()}function kZ(){gh=null;const e=[...Hh];Hh.clear(),e.length!==0&&ae.files.check(e).then(({results:n})=>{for(const[r,s]of Object.entries(n))IN(r,s),DN(r)}).catch(()=>{for(const n of e)IN(n,{exists:!1,isFile:!1,type:"unknown"}),DN(n)})}function NZ(e){Dl.has(e)||Hh.has(e)||(Hh.add(e),gh&&clearTimeout(gh),gh=setTimeout(kZ,30))}function jZ(e,n){let r=ph.get(e);return r||(r=new Set,ph.set(e,r)),r.add(n),()=>{r.delete(n),r.size===0&&ph.delete(e)}}function SZ(e){const n=g.useCallback(a=>jZ(e,a),[e]),r=g.useCallback(()=>Dl.get(e),[e]),s=g.useSyncExternalStore(n,r,r);return g.useEffect(()=>{NZ(e)},[e]),s}const CZ=/^(?:\/[\w.\-@+]+(?:\/[\w.\-@+ ]*)*|~\/[\w.\-@+]+(?:\/[\w.\-@+ ]*)*|[A-Z]:\\[\w.\-@+ ]+(?:\\[\w.\-@+ ]*)*|\.\.?\/[\w.\-@+]+(?:\/[\w.\-@+ ]*)*)$/;function EZ(e){return e.length<2||e.length>500?!1:CZ.test(e)}function TZ({filePath:e,onClose:n}){const r=vZ(n),[s,a]=g.useState(!0),[i,l]=g.useState(null),[c,u]=g.useState(""),[m,f]=g.useState(""),[p,b]=g.useState("");g.useEffect(()=>{a(!0),l(null),ae.files.preview(e).then(v=>{u(v.content),f(v.type),b(v.name)}).catch(v=>{l(String(v?.message||v))}).finally(()=>{a(!1)})},[e]);const x=p||e.split(/[/\\]/).pop()||e;return ao.createPortal(t.jsx("div",{className:"fixed inset-0 bg-black/40 flex items-center justify-center",style:{zIndex:r},onClick:n,children:t.jsxs("div",{className:"bg-surface-secondary border border-border-default rounded-xl shadow-2xl w-[90vw] max-w-3xl max-h-[85vh] flex flex-col overflow-hidden",onClick:v=>v.stopPropagation(),children:[t.jsxs("div",{className:"flex items-center justify-between px-4 py-3 border-b border-border-default bg-surface-elevated/50 shrink-0",children:[t.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[t.jsx("svg",{className:"w-4 h-4 shrink-0 text-fg-secondary",viewBox:"0 0 20 20",fill:"currentColor",children:t.jsx("path",{fillRule:"evenodd",d:"M4 4a2 2 0 012-2h4.586A2 2 0 0112 2.586L15.414 6A2 2 0 0116 7.414V16a2 2 0 01-2 2H6a2 2 0 01-2-2V4z",clipRule:"evenodd"})}),t.jsx("span",{className:"text-sm font-medium text-fg-primary truncate",children:x}),t.jsx("span",{className:"text-xs text-fg-tertiary truncate hidden sm:inline",children:e})]}),t.jsxs("div",{className:"flex items-center gap-2 shrink-0",children:[t.jsx("button",{className:"text-xs text-fg-secondary hover:text-fg-primary px-2 py-1 rounded hover:bg-surface-elevated transition-colors",onClick:()=>ae.files.reveal(e),title:"Reveal in file explorer",children:t.jsx("svg",{className:"w-4 h-4",viewBox:"0 0 20 20",fill:"currentColor",children:t.jsx("path",{d:"M4.5 17a2.5 2.5 0 01-2.5-2.5v-9A2.5 2.5 0 014.5 3h3.672a1.5 1.5 0 011.06.44L10.56 4.77a.5.5 0 00.354.147H15.5A2.5 2.5 0 0118 7.417v7.083A2.5 2.5 0 0115.5 17h-11z"})})}),t.jsx("button",{className:"text-fg-secondary hover:text-fg-primary p-1 rounded hover:bg-surface-elevated transition-colors",onClick:n,children:t.jsx("svg",{className:"w-4 h-4",viewBox:"0 0 20 20",fill:"currentColor",children:t.jsx("path",{fillRule:"evenodd",d:"M4.293 4.293a1 1 0 011.414 0L10 8.586l4.293-4.293a1 1 0 111.414 1.414L11.414 10l4.293 4.293a1 1 0 01-1.414 1.414L10 11.414l-4.293 4.293a1 1 0 01-1.414-1.414L8.586 10 4.293 5.707a1 1 0 010-1.414z",clipRule:"evenodd"})})})]})]}),t.jsxs("div",{className:"flex-1 overflow-y-auto p-5",children:[s&&t.jsx("div",{className:"flex items-center justify-center py-12",children:t.jsx("div",{className:"w-5 h-5 border-2 border-brand-500/30 border-t-brand-500 rounded-full animate-spin"})}),i&&t.jsxs("div",{className:"text-center py-12 text-fg-secondary text-sm",children:[t.jsx("p",{className:"text-red-400 mb-1",children:"Failed to load file"}),t.jsx("p",{className:"text-xs text-fg-tertiary",children:i})]}),!s&&!i&&m==="image"&&t.jsx("div",{className:"flex justify-center",children:t.jsx("img",{src:`data:image/png;base64,${c}`,alt:x,className:"max-w-full rounded"})}),!s&&!i&&m!=="image"&&t.jsx(g.Suspense,{fallback:t.jsx("div",{className:"text-xs text-fg-tertiary",children:"Loading…"}),children:t.jsx(yZ,{content:c,format:m==="text"?"text":m,className:"text-sm"})})]})]})}),document.body)}function AZ({path:e}){const n=SZ(e),[r,s]=g.useState(null),a=n?.exists??!1,i=n?.type==="markdown"||n?.type==="html"||n?.type==="json"||n?.type==="text",l=g.useCallback(m=>{m.preventDefault(),m.stopPropagation(),a&&(i?s(e):ae.files.reveal(e))},[a,i,e]),c="inline w-3 h-3 align-[-0.125em]",u=i?t.jsx("svg",{className:c,viewBox:"0 0 20 20",fill:"currentColor",children:t.jsx("path",{fillRule:"evenodd",d:"M4 4a2 2 0 012-2h4.586A2 2 0 0112 2.586L15.414 6A2 2 0 0116 7.414V16a2 2 0 01-2 2H6a2 2 0 01-2-2V4zm2 6a1 1 0 011-1h6a1 1 0 110 2H7a1 1 0 01-1-1zm1 3a1 1 0 100 2h6a1 1 0 100-2H7z",clipRule:"evenodd"})}):t.jsx("svg",{className:c,viewBox:"0 0 20 20",fill:"currentColor",children:t.jsx("path",{fillRule:"evenodd",d:"M4 4a2 2 0 012-2h4.586A2 2 0 0112 2.586L15.414 6A2 2 0 0116 7.414V16a2 2 0 01-2 2H6a2 2 0 01-2-2V4z",clipRule:"evenodd"})});return n?a?t.jsxs(t.Fragment,{children:[t.jsxs("code",{className:"bg-brand-500/10 px-1.5 py-0.5 rounded text-xs font-mono text-brand-500 cursor-pointer hover:bg-brand-500/20 transition-colors border border-brand-500/20 hover:border-brand-500/40 break-all",onClick:l,title:i?"Click to preview":"Click to reveal in file explorer",role:"button",tabIndex:0,children:[t.jsxs("span",{className:"whitespace-nowrap",children:[u,e.charAt(0)]}),e.slice(1)]}),r&&t.jsx(TZ,{filePath:r,onClose:()=>s(null)})]}):t.jsx("code",{className:"bg-surface-secondary/50 px-1.5 py-0.5 rounded text-xs font-mono text-fg-tertiary border border-border-default/30 line-through decoration-fg-tertiary/30 break-all",title:"File not found",children:e}):t.jsx("code",{className:"bg-surface-secondary px-1.5 py-0.5 rounded text-xs font-mono text-fg-secondary break-all",children:e})}let _b=null;function MZ(){return _b||(_b=ql(()=>import("./mermaid.core-BHJDz64r.js").then(e=>e.b9),[]).then(e=>(e.default.initialize({startOnLoad:!1,securityLevel:"loose",fontFamily:"inherit"}),e))),_b}function _Z(){const e=document.documentElement;return e.classList.contains("light")?!1:e.classList.contains("dark")||e.classList.contains("cyberpunk")||e.classList.contains("mono")?!0:!window.matchMedia("(prefers-color-scheme: light)").matches}function RZ(e){const n=window.matchMedia("(prefers-color-scheme: dark)");n.addEventListener("change",e);const r=new MutationObserver(e);return r.observe(document.documentElement,{attributes:!0,attributeFilter:["class"]}),()=>{n.removeEventListener("change",e),r.disconnect()}}function IZ(){return _Z()}function DZ(){return g.useSyncExternalStore(RZ,IZ)}function vT({code:e}){const n=g.useRef(null),[r,s]=g.useState(null),[a,i]=g.useState(!0),l=g.useId(),c=g.useRef(0),u=g.useRef(null),m=DZ();return g.useEffect(()=>{if(!e.trim()||u.current&&u.current.code===e&&u.current.dark===m)return;let f=!1;return i(!0),s(null),c.current+=1,(async()=>{try{const p=await MZ();if(f)return;p.default.initialize({startOnLoad:!1,theme:m?"dark":"default",securityLevel:"loose",fontFamily:"inherit"});const b=`mermaid-${l.replace(/:/g,"")}-${c.current}`,{svg:x}=await p.default.render(b,e.trim());if(f)return;n.current&&(n.current.innerHTML=x,u.current={code:e,dark:m})}catch(p){f||s(p instanceof Error?p.message:String(p))}finally{f||i(!1)}})(),()=>{f=!0}},[e,l,m]),r?t.jsxs("div",{className:"my-2 rounded-lg overflow-hidden border border-red-500/30",children:[t.jsxs("div",{className:"flex items-center gap-1.5 px-3 py-1.5 bg-red-500/10 border-b border-red-500/20",children:[t.jsx("svg",{className:"w-3.5 h-3.5 text-red-400",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:t.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M12 9v2m0 4h.01m-6.938 4h13.856c1.54 0 2.502-1.667 1.732-2.5L13.732 4c-.77-.833-1.964-.833-2.732 0L4.082 16.5c-.77.833.192 2.5 1.732 2.5z"})}),t.jsx("span",{className:"text-[10px] font-medium text-red-400",children:"Mermaid render error"})]}),t.jsx("pre",{className:"p-3 bg-surface-secondary text-xs text-fg-secondary overflow-x-auto font-mono",children:e})]}):t.jsxs("div",{className:"not-prose my-2 rounded-lg bg-surface-secondary border border-border-subtle p-4 overflow-x-auto",children:[a&&t.jsxs("div",{className:"flex items-center gap-2 text-xs text-fg-tertiary",children:[t.jsx("div",{className:"w-4 h-4 border-2 border-fg-tertiary/30 border-t-fg-tertiary rounded-full animate-spin"}),"Rendering diagram…"]}),t.jsx("div",{ref:n,className:`flex justify-center [&>svg]:max-w-full${a?" hidden":""}`})]})}const LZ="/assets/viz-global-C_AyN6D9.js";let Lf=!1,Rb=null;function OZ(){return Lf?Promise.resolve():new Promise((e,n)=>{const r=document.querySelector("script[data-plantuml-viz]");if(r){globalThis.Viz?(Lf=!0,e()):(r.addEventListener("load",()=>{Lf=!0,e()}),r.addEventListener("error",()=>n(new Error("Failed to load viz-global.js"))));return}const s=document.createElement("script");s.setAttribute("data-plantuml-viz",""),s.src=LZ,s.onload=()=>{Lf=!0,e()},s.onerror=()=>n(new Error("Failed to load viz-global.js")),document.head.appendChild(s)})}function PZ(){return Rb||(Rb=OZ().then(()=>ql(()=>import("./plantuml-DezRDxd4.js"),[]))),Rb}let LN=Promise.resolve();function BZ(e,n){const r=LN.then(()=>new Promise((s,a)=>{PZ().then(({renderToString:i})=>{const l=e.split(/\r\n|\r|\n/);i(l,s,a,{dark:n})}).catch(a)}));return LN=r.then(()=>{},()=>{}),r}function $Z(){const e=document.documentElement;return e.classList.contains("light")?!1:e.classList.contains("dark")||e.classList.contains("cyberpunk")||e.classList.contains("mono")?!0:!window.matchMedia("(prefers-color-scheme: light)").matches}function zZ(e){const n=window.matchMedia("(prefers-color-scheme: dark)");n.addEventListener("change",e);const r=new MutationObserver(e);return r.observe(document.documentElement,{attributes:!0,attributeFilter:["class"]}),()=>{n.removeEventListener("change",e),r.disconnect()}}function FZ(){return g.useSyncExternalStore(zZ,()=>$Z())}function wT({code:e}){const[n,r]=g.useState(null),[s,a]=g.useState(null),[i,l]=g.useState(!0),c=g.useRef(null),u=FZ();return g.useEffect(()=>{if(!e.trim()||c.current&&c.current.code===e&&c.current.dark===u)return;let m=!1;return l(!0),a(null),BZ(e.trim(),u).then(f=>{m||(r(f),c.current={code:e,dark:u})}).catch(f=>{m||a(f instanceof Error?f.message:String(f))}).finally(()=>{m||l(!1)}),()=>{m=!0}},[e,u]),s?t.jsxs("div",{className:"my-2 rounded-lg overflow-hidden border border-red-500/30",children:[t.jsxs("div",{className:"flex items-center gap-1.5 px-3 py-1.5 bg-red-500/10 border-b border-red-500/20",children:[t.jsx("svg",{className:"w-3.5 h-3.5 text-red-400",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:t.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M12 9v2m0 4h.01m-6.938 4h13.856c1.54 0 2.502-1.667 1.732-2.5L13.732 4c-.77-.833-1.964-.833-2.732 0L4.082 16.5c-.77.833.192 2.5 1.732 2.5z"})}),t.jsx("span",{className:"text-[10px] font-medium text-red-400",children:"PlantUML render error"})]}),t.jsx("pre",{className:"p-3 bg-surface-secondary text-xs text-fg-secondary overflow-x-auto font-mono",children:e})]}):t.jsxs("div",{className:"not-prose my-2 rounded-lg bg-surface-secondary border border-border-subtle p-4 overflow-x-auto",children:[i&&t.jsxs("div",{className:"flex items-center gap-2 text-xs text-fg-tertiary",children:[t.jsx("div",{className:"w-4 h-4 border-2 border-fg-tertiary/30 border-t-fg-tertiary rounded-full animate-spin"}),"Rendering diagram…"]}),n&&t.jsx("div",{className:`flex justify-center [&>svg]:max-w-full${i?" hidden":""}`,dangerouslySetInnerHTML:{__html:n}})]})}function HZ(e,n,r){const s=e.cloneNode(!0),a=r?.fontFamily??"-apple-system,BlinkMacSystemFont,'Segoe UI','Noto Sans',Helvetica,Arial,sans-serif",i=r?.fontSize??"15px",l=r?.headingScales??{h1:1.6,h2:1.35,h3:1.15,h4:1},c=n==="light"?{bg:"#ffffff",text:"#24292f",heading:"#1f2328",strong:"#1f2328",link:"#0969da",codeBg:"#eff1f3",codeText:"#24292f",preBg:"#f6f8fa",preText:"#24292f",preBorder:"#d0d7de",border:"#d0d7de",blockquoteBorder:"#d0d7de",blockquoteText:"#656d76",tableBorder:"#d0d7de",tableHeaderBg:"#f6f8fa",tableHeaderText:"#24292f",hrColor:"#d8dee4"}:{bg:"#0d1117",text:"#e6edf3",heading:"#f0f6fc",strong:"#f0f6fc",link:"#58a6ff",codeBg:"#161b22",codeText:"#e6edf3",preBg:"#161b22",preText:"#e6edf3",preBorder:"#30363d",border:"#30363d",blockquoteBorder:"#3b82f6",blockquoteText:"#8b949e",tableBorder:"#30363d",tableHeaderBg:"#161b22",tableHeaderText:"#e6edf3",hrColor:"#21262d"},u={p:`margin:0 0 10px;color:${c.text};line-height:1.7;`,h1:`font-size:${l.h1}em;font-weight:700;color:${c.heading};margin:20px 0 10px;line-height:1.3;border-bottom:1px solid ${c.border};padding-bottom:6px;`,h2:`font-size:${l.h2}em;font-weight:700;color:${c.heading};margin:18px 0 8px;line-height:1.3;`,h3:`font-size:${l.h3}em;font-weight:600;color:${c.heading};margin:14px 0 6px;line-height:1.3;`,h4:`font-size:${l.h4}em;font-weight:600;color:${c.heading};margin:12px 0 4px;`,strong:`font-weight:600;color:${c.strong};`,em:"font-style:italic;",a:`color:${c.link};text-decoration:underline;`,ul:"padding-left:1.5em;margin:0 0 10px;",ol:"padding-left:1.5em;margin:0 0 10px;",li:`margin:3px 0;line-height:1.7;color:${c.text};`,blockquote:`border-left:3px solid ${c.blockquoteBorder};padding:2px 0 2px 14px;margin:10px 0;color:${c.blockquoteText};`,hr:`border:none;border-top:1px solid ${c.hrColor};margin:20px 0;`,table:"border-collapse:collapse;width:100%;margin:10px 0;",thead:`background:${c.tableHeaderBg};`,th:`border:1px solid ${c.tableBorder};padding:8px 12px;text-align:left;font-weight:600;color:${c.tableHeaderText};`,td:`border:1px solid ${c.tableBorder};padding:8px 12px;color:${c.text};`,img:"max-width:100%;height:auto;"};function m(f){f.removeAttribute("class");const p=f.tagName.toLowerCase();if(p==="pre"){f.setAttribute("style",`background:${c.preBg};color:${c.preText};padding:14px;border-radius:6px;overflow-x:auto;margin:10px 0;font-size:0.88em;line-height:1.5;border:1px solid ${c.preBorder};`);const b=f.querySelector("code");b&&(b.removeAttribute("class"),b.setAttribute("style","background:transparent;padding:0;border-radius:0;color:inherit;font-family:'SFMono-Regular',Consolas,'Liberation Mono',Menlo,monospace;font-size:inherit;"));return}p==="code"?f.setAttribute("style",`background:${c.codeBg};color:${c.codeText};padding:2px 6px;border-radius:4px;font-size:0.9em;font-family:'SFMono-Regular',Consolas,'Liberation Mono',Menlo,monospace;`):u[p]&&f.setAttribute("style",u[p]),Array.from(f.children).forEach(m)}return s.removeAttribute("class"),Array.from(s.children).forEach(f=>m(f)),`<div style="background:${c.bg};color:${c.text};padding:20px 24px;font-family:${a};font-size:${i};line-height:1.7;max-width:800px;">${s.innerHTML}</div>`}async function Ap(e){try{return await navigator.clipboard.writeText(e),!0}catch{try{const n=document.createElement("textarea");n.value=e,n.style.cssText="position:fixed;left:-9999px;top:-9999px;opacity:0",document.body.appendChild(n),n.select();const r=document.execCommand("copy");return document.body.removeChild(n),r}catch{return!1}}}async function UZ(e,n,r,s){const a=HZ(e,n,s);try{return await navigator.clipboard.write([new ClipboardItem({"text/html":new Blob([a],{type:"text/html"}),"text/plain":new Blob([r],{type:"text/plain"})})]),{ok:!0,method:"html"}}catch{return{ok:await Ap(r),method:"text"}}}function my({code:e,language:n,children:r}){const{t:s}=ht("common"),[a,i]=g.useState("rendered"),[l,c]=g.useState(!1),u=g.useCallback(async()=>{await Ap(e)&&(c(!0),setTimeout(()=>c(!1),1800))},[e]);return t.jsxs("div",{className:"not-prose my-2 rounded-lg overflow-hidden border border-border-subtle",children:[t.jsxs("div",{className:"flex items-center justify-between px-3 py-1.5 border-b border-border-subtle bg-surface-secondary",children:[t.jsx("span",{className:"text-[10px] font-medium text-fg-tertiary uppercase tracking-wider select-none",children:n}),t.jsxs("div",{className:"flex items-center gap-1",children:[t.jsx("button",{onClick:()=>i("rendered"),className:`px-2 py-0.5 rounded text-[10px] font-medium transition-colors ${a==="rendered"?"bg-brand-600/20 text-brand-500":"text-fg-tertiary hover:text-fg-secondary"}`,children:t.jsxs("span",{className:"flex items-center gap-1",children:[t.jsxs("svg",{className:"w-3 h-3",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:[t.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M15 12a3 3 0 11-6 0 3 3 0 016 0z"}),t.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M2.458 12C3.732 7.943 7.523 5 12 5c4.478 0 8.268 2.943 9.542 7-1.274 4.057-5.064 7-9.542 7-4.477 0-8.268-2.943-9.542-7z"})]}),s("markdown.viewRendered")]})}),t.jsx("button",{onClick:()=>i("source"),className:`px-2 py-0.5 rounded text-[10px] font-medium transition-colors ${a==="source"?"bg-brand-600/20 text-brand-500":"text-fg-tertiary hover:text-fg-secondary"}`,children:t.jsxs("span",{className:"flex items-center gap-1",children:[t.jsx("svg",{className:"w-3 h-3",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:t.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M10 20l4-16m4 4l4 4-4 4M6 16l-4-4 4-4"})}),s("markdown.viewSource")]})})]})]}),a==="rendered"?t.jsx("div",{children:r}):t.jsxs("div",{className:"relative group/source",children:[t.jsx("pre",{className:"p-3 overflow-x-auto text-xs font-mono text-fg-secondary bg-surface-secondary leading-relaxed whitespace-pre-wrap break-words",children:e}),t.jsx("button",{onClick:u,className:"absolute top-2 right-2 p-1.5 rounded-md bg-surface-elevated/80 hover:bg-surface-overlay text-fg-tertiary hover:text-fg-primary backdrop-blur-sm border border-border-default/50 transition-all opacity-0 group-hover/source:opacity-100",title:s("markdown.copyContent"),children:l?t.jsx("svg",{className:"w-3.5 h-3.5 text-green-400",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:t.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M5 13l4 4L19 7"})}):t.jsx("svg",{className:"w-3.5 h-3.5",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:t.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M8 16H6a2 2 0 01-2-2V6a2 2 0 012-2h8a2 2 0 012 2v2m-6 12h8a2 2 0 002-2v-8a2 2 0 00-2-2h-8a2 2 0 00-2 2v8a2 2 0 002 2z"})})})]})]})}function Of(e,n){const r=/```[\s\S]*?```|`[^`\n]+`/g;let s=0,a="";for(const i of e.matchAll(r))a+=n(e.slice(s,i.index)),a+=i[0],s=i.index+i[0].length;return a+=n(e.slice(s)),a}function ON(e){let n=e.replace(/\\\[([\s\S]*?)\\\]/g,(r,s)=>`$$${s}$$`);return n=n.replace(/\\\((.+?)\\\)/g,(r,s)=>`$${s}$`),n}const Pf="#mention:";function qZ(e,n){if(!n||n.length===0)return e.replace(/@\[([^\]]+)\]|@([\w\p{L}\p{N}]+)/gu,(i,l,c)=>{const u=l??c;return`[@${u}](${Pf}${encodeURIComponent(u)})`});const r=[...n].sort((i,l)=>l.length-i.length);let s="",a=0;for(;a<e.length;){const i=e.indexOf("@",a);if(i<0){s+=e.slice(a);break}if(s+=e.slice(a,i),e[i+1]==="["){const f=e.indexOf("]",i+2);if(f>i+2){const p=e.slice(i+2,f);s+=`[@${p}](${Pf}${encodeURIComponent(p)})`,a=f+1;continue}}const l=e.slice(i+1),c=l.toLowerCase(),u=r.find(f=>c.startsWith(f.toLowerCase()));if(u){const f=l.slice(0,u.length);s+=`[@${f}](${Pf}${encodeURIComponent(f)})`,a=i+1+u.length;continue}const m=l.match(/^([\w\p{L}\p{N}]+)/u);if(m){const f=m[1];s+=`[@${f}](${Pf}${encodeURIComponent(f)})`,a=i+1+f.length;continue}s+="@",a=i+1}return s}const kT="#entity:",VZ=new RegExp("(?<!\\[)(?<!#entity:)\\b(tsk|req|proj|dlv|agt)_[a-f0-9]{6,}\\b(?!\\]\\(#entity:)","gi"),WZ=/`\[([^\]]+)\]\(#entity:((?:tsk|req|proj|dlv|agt)_[a-f0-9]{6,})\)`/gi;function KZ(e){return e.replace(WZ,(n,r,s)=>`[${r}](${kT}${s})`)}function GZ(e){return e.replace(VZ,n=>`[${n}](${kT}${n})`)}function YZ(e){const n=e.trim();return n.startsWith("@startuml")&&n.endsWith("@enduml")}const XZ=/^(graph\s|flowchart\s|sequenceDiagram|classDiagram|stateDiagram|erDiagram|gantt|pie|gitGraph|mindmap|timeline|journey)/m;function QZ(e){return XZ.test(e.trim())}const ZZ={js:"JavaScript",javascript:"JavaScript",ts:"TypeScript",typescript:"TypeScript",tsx:"TSX",jsx:"JSX",py:"Python",python:"Python",rb:"Ruby",ruby:"Ruby",rs:"Rust",rust:"Rust",go:"Go",java:"Java",kotlin:"Kotlin",swift:"Swift",cpp:"C++",c:"C",cs:"C#",csharp:"C#",php:"PHP",sql:"SQL",sh:"Shell",bash:"Bash",zsh:"Zsh",shell:"Shell",html:"HTML",css:"CSS",scss:"SCSS",less:"LESS",json:"JSON",yaml:"YAML",yml:"YAML",xml:"XML",toml:"TOML",ini:"INI",md:"Markdown",markdown:"Markdown",dockerfile:"Dockerfile",docker:"Dockerfile",graphql:"GraphQL",gql:"GraphQL",lua:"Lua",perl:"Perl",r:"R",scala:"Scala",elixir:"Elixir",erlang:"Erlang",haskell:"Haskell",clojure:"Clojure",dart:"Dart",zig:"Zig",nim:"Nim",powershell:"PowerShell",ps1:"PowerShell",vue:"Vue",svelte:"Svelte",plaintext:"Text",text:"Text",txt:"Text"};function JZ(e){return ZZ[e.toLowerCase()]??e.charAt(0).toUpperCase()+e.slice(1)}function eJ(e){const n=e.match(/language-(\S+)/);return n?n[1]:null}const tJ=[vT,wT];function nJ(e){for(const n of g.Children.toArray(e))if(g.isValidElement(n)&&typeof n.props?.className=="string"){const r=n.props.className;return eJ(r)}return null}function w0(e){if(typeof e=="string")return e;if(typeof e=="number")return String(e);if(!e)return"";if(Array.isArray(e))return e.map(w0).join("");if(g.isValidElement(e)){const n=e.props;return w0(n.children)}return""}function rJ({children:e}){const{t:n}=ht("common"),r=nJ(e),s=g.useRef(null),[a,i]=g.useState(!1),[l,c]=g.useState("rendered"),u=g.useCallback(async()=>{let f;l==="source"?f=w0(e):f=s.current?.querySelector("code")?.textContent??"";try{await navigator.clipboard.writeText(f),i(!0),setTimeout(()=>i(!1),1800)}catch{}},[l,e]);if(g.Children.toArray(e).some(f=>g.isValidElement(f)&&tJ.includes(f.type))){const f=w0(e),p=r==="mermaid"||r==="plantuml"?r:"diagram";return t.jsx(my,{code:f,language:p,children:e})}return r==="mermaid"||r==="plantuml"?t.jsx(t.Fragment,{children:e}):t.jsxs("div",{className:"not-prose relative group/code my-2 rounded-lg overflow-hidden bg-surface-secondary border border-border-subtle",children:[r&&t.jsxs("div",{className:"flex items-center justify-between px-3 py-1.5 border-b border-border-subtle",children:[t.jsx("span",{className:"text-[10px] font-medium text-fg-tertiary uppercase tracking-wider select-none",children:JZ(r)}),t.jsxs("div",{className:"flex items-center gap-1",children:[t.jsx("button",{onClick:()=>c("rendered"),className:`px-1.5 py-0.5 rounded text-[10px] font-medium transition-colors ${l==="rendered"?"bg-brand-600/20 text-brand-500":"text-fg-tertiary hover:text-fg-secondary"}`,children:n("markdown.viewRendered")}),t.jsx("button",{onClick:()=>c("source"),className:`px-1.5 py-0.5 rounded text-[10px] font-medium transition-colors ${l==="source"?"bg-brand-600/20 text-brand-500":"text-fg-tertiary hover:text-fg-secondary"}`,children:n("markdown.viewSource")})]})]}),t.jsxs("div",{className:"relative",children:[l==="rendered"?t.jsx("pre",{ref:s,className:"p-3 overflow-x-auto text-xs [&>code]:p-0 [&>code]:rounded-none [&>code]:text-fg-secondary",children:g.Children.map(e,f=>g.isValidElement(f)?g.cloneElement(f,{style:{background:"transparent",padding:0}}):f)}):t.jsx("pre",{className:"p-3 overflow-x-auto text-xs font-mono text-fg-secondary whitespace-pre-wrap break-words",children:w0(e)}),t.jsx("button",{onClick:u,className:"absolute top-2 right-2 p-1.5 rounded-md bg-surface-elevated/80 hover:bg-surface-overlay text-fg-tertiary hover:text-fg-primary backdrop-blur-sm border border-border-default/50 transition-all opacity-0 group-hover/code:opacity-100",title:n("markdown.copyContent"),children:a?t.jsx("svg",{className:"w-3.5 h-3.5 text-green-400",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:t.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M5 13l4 4L19 7"})}):t.jsx("svg",{className:"w-3.5 h-3.5",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:t.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M8 16H6a2 2 0 01-2-2V6a2 2 0 012-2h8a2 2 0 012 2v2m-6 12h8a2 2 0 002-2v-8a2 2 0 00-2-2h-8a2 2 0 00-2 2v8a2 2 0 002 2z"})})})]})]})}const NT="markus-copy-typography",PN={fontFamily:"default",fontSize:15,headingScale:"standard"};function jT(){try{const e=localStorage.getItem(NT);if(e)return{...PN,...JSON.parse(e)}}catch{}return PN}function sJ(e){localStorage.setItem(NT,JSON.stringify(e))}function aJ(e){const n={default:"-apple-system, BlinkMacSystemFont, 'Segoe UI', 'Noto Sans', Helvetica, Arial, sans-serif",serif:"Georgia, 'Times New Roman', Times, serif","sans-serif":"-apple-system, BlinkMacSystemFont, 'Segoe UI', Helvetica, Arial, sans-serif",mono:"'SFMono-Regular', Consolas, 'Liberation Mono', Menlo, monospace"},r={compact:{h1:1.3,h2:1.15,h3:1.05,h4:1},standard:{h1:1.6,h2:1.35,h3:1.15,h4:1},large:{h1:2,h2:1.6,h3:1.3,h4:1.1}};return{fontFamily:n[e.fontFamily]??n.default,fontSize:`${e.fontSize}px`,headingScales:r[e.headingScale]??r.standard}}function iJ({onClose:e}){const{t:n}=ht("common"),[r,s]=g.useState(jT);g.useEffect(()=>{sJ(r)},[r]);const a=g.useCallback((i,l)=>{s(c=>({...c,[i]:l}))},[]);return t.jsxs("div",{className:"px-3 py-2 space-y-3 max-w-[260px]",children:[t.jsxs("div",{className:"flex items-center justify-between mb-1",children:[t.jsx("span",{className:"font-medium text-fg-primary text-xs",children:n("markdown.typographySettings")}),t.jsx("button",{onClick:e,className:"text-fg-tertiary hover:text-fg-primary p-0.5",children:t.jsx("svg",{className:"w-3 h-3",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:t.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M6 18L18 6M6 6l12 12"})})})]}),t.jsx("p",{className:"text-[10px] text-fg-tertiary",children:n("markdown.typographyDesc")}),t.jsxs("div",{children:[t.jsx("label",{className:"text-[10px] text-fg-tertiary font-medium block mb-1",children:n("markdown.fontFamily")}),t.jsxs("select",{value:r.fontFamily,onChange:i=>a("fontFamily",i.target.value),className:"w-full px-2 py-1 text-xs rounded bg-surface-primary border border-border-subtle text-fg-secondary focus:outline-none focus:ring-1 focus:ring-brand-500/50",children:[t.jsx("option",{value:"default",children:n("markdown.fontDefault")}),t.jsx("option",{value:"serif",children:n("markdown.fontSerif")}),t.jsx("option",{value:"sans-serif",children:n("markdown.fontSansSerif")}),t.jsx("option",{value:"mono",children:n("markdown.fontMono")})]})]}),t.jsxs("div",{children:[t.jsxs("label",{className:"text-[10px] text-fg-tertiary font-medium block mb-1",children:[n("markdown.fontSize"),": ",r.fontSize,"px"]}),t.jsx("input",{type:"range",min:10,max:24,step:1,value:r.fontSize,onChange:i=>a("fontSize",Number(i.target.value)),className:"w-full h-1 rounded-full appearance-none bg-border-subtle [&::-webkit-slider-thumb]:appearance-none [&::-webkit-slider-thumb]:w-3 [&::-webkit-slider-thumb]:h-3 [&::-webkit-slider-thumb]:rounded-full [&::-webkit-slider-thumb]:bg-brand-500"}),t.jsxs("div",{className:"flex justify-between text-[9px] text-fg-tertiary mt-0.5",children:[t.jsx("span",{children:"10px"}),t.jsx("span",{children:"24px"})]})]}),t.jsxs("div",{children:[t.jsx("label",{className:"text-[10px] text-fg-tertiary font-medium block mb-1",children:n("markdown.headingScale")}),t.jsx("div",{className:"flex gap-1",children:["compact","standard","large"].map(i=>t.jsx("button",{onClick:()=>a("headingScale",i),className:`flex-1 px-2 py-1 rounded text-[10px] font-medium transition-colors ${r.headingScale===i?"bg-brand-600/20 text-brand-500":"bg-surface-primary text-fg-tertiary hover:text-fg-secondary border border-border-subtle"}`,children:n(`markdown.scale${i.charAt(0).toUpperCase()+i.slice(1)}`)},i))})]})]})}const BN=[VC,lX,KE],$N=[[FX,{strict:"ignore"}],[yT,{detect:!0,ignoreMissing:!0}]],oJ=/<think>([\s\S]*?)(<\/think>|$)/g;function lJ(e){const n=[];let r=e.replace(oJ,(s,a)=>{const i=a.trim();return i&&n.push(i),""});return r=r.replace(/<\/think>/g,"").replace(/<think>/g,""),{thinking:n,rest:r.trim()}}const zN="#mention:",FN="#entity:",cJ=/^\[([^\]]+)\]\(#entity:((tsk|req|proj|dlv|agt)_[a-f0-9]{6,})\)$/i,fy={tsk:{icon:"📋",label:"Task"},req:{icon:"📝",label:"Requirement"},proj:{icon:"📁",label:"Project"},dlv:{icon:"📦",label:"Deliverable"},agt:{icon:"🤖",label:"Agent"}};function Al(e){e.startsWith("tsk_")?Rt.navigate(Be.WORK,{openTask:e}):e.startsWith("req_")?Rt.navigate(Be.WORK,{openRequirement:e}):e.startsWith("proj_")?Rt.navigate(Be.WORK,{projectId:e}):e.startsWith("dlv_")?Rt.navigate(Be.DELIVERABLES,{openDeliverable:e}):e.startsWith("agt_")&&Rt.navigate(Be.TEAM,{agentId:e})}function dJ(e){return/^(tsk|req|proj|dlv|agt)_[a-f0-9]{6,}$/i.test(e)}const HN={p:({children:e})=>t.jsx("p",{className:"mb-2 last:mb-0 leading-relaxed text-fg-secondary",children:e}),h1:({children:e})=>t.jsx("h1",{className:"text-base font-bold mb-2 mt-3 first:mt-0 text-fg-primary",children:e}),h2:({children:e})=>t.jsx("h2",{className:"text-sm font-bold mb-2 mt-3 first:mt-0 text-fg-primary",children:e}),h3:({children:e})=>t.jsx("h3",{className:"text-sm font-semibold mb-1 mt-2 first:mt-0 text-fg-primary",children:e}),h4:({children:e})=>t.jsx("h4",{className:"text-sm font-semibold mb-1 mt-2 first:mt-0 text-fg-primary",children:e}),h5:({children:e})=>t.jsx("h5",{className:"text-xs font-semibold mb-1 mt-2 first:mt-0 text-fg-primary",children:e}),h6:({children:e})=>t.jsx("h6",{className:"text-xs font-medium mb-1 mt-2 first:mt-0 text-fg-primary",children:e}),ul:({children:e})=>t.jsx("ul",{className:"list-disc pl-4 mb-2 space-y-0.5",children:e}),ol:({children:e})=>t.jsx("ol",{className:"list-decimal pl-4 mb-2 space-y-0.5",children:e}),li:({children:e})=>t.jsx("li",{className:"leading-relaxed text-fg-secondary marker:text-fg-secondary",children:e}),code:({children:e,className:n})=>{const r=typeof e=="string"?e:String(e??""),s=r.trim();if(n?.includes("language-plantuml")||YZ(s))return t.jsx(my,{code:s,language:"plantuml",children:t.jsx(wT,{code:s})});if(n?.includes("language-mermaid")||!n&&QZ(s))return t.jsx(my,{code:s,language:"mermaid",children:t.jsx(vT,{code:s})});if(n?.includes("language-"))return t.jsx("code",{className:`${n} text-fg-secondary font-mono text-xs`,children:e});if(dJ(r)){const i=r.split("_")[0],l=fy[i];return t.jsxs("span",{"data-entity-link":r,className:"inline-flex items-center gap-0.5 px-1 py-0.5 rounded bg-brand-500/10 text-brand-500 text-xs font-mono cursor-pointer hover:bg-brand-500/20 transition-colors",onClick:c=>{c.preventDefault(),c.stopPropagation(),Al(r)},title:l?`${l.label}: ${r}`:r,children:[l&&t.jsx("span",{className:"text-[10px]",children:l.icon}),t.jsxs("span",{children:[r.slice(0,i.length+1+8),"…"]})]})}const a=r.match(cJ);if(a){const i=a[2],l=i.split("_")[0],c=fy[l];return t.jsxs("span",{"data-entity-link":i,className:"inline-flex items-center gap-0.5 px-1 py-0.5 rounded bg-brand-500/10 text-brand-500 text-xs font-mono cursor-pointer hover:bg-brand-500/20 transition-colors",onClick:u=>{u.preventDefault(),u.stopPropagation(),Al(i)},title:c?`${c.label}: ${i}`:i,children:[c&&t.jsx("span",{className:"text-[10px]",children:c.icon}),t.jsxs("span",{children:[i.slice(0,l.length+1+8),"…"]})]})}return EZ(r)?t.jsx(AZ,{path:r}):t.jsx("code",{className:"bg-surface-secondary px-1.5 py-0.5 rounded text-xs font-mono text-brand-500 break-all",children:e})},pre:({children:e})=>t.jsx(rJ,{children:e}),strong:({children:e})=>t.jsx("strong",{className:"font-bold text-fg-primary",children:e}),em:({children:e})=>t.jsx("em",{className:"italic text-fg-secondary",children:e}),del:({children:e})=>t.jsx("del",{className:"line-through text-fg-tertiary",children:e}),blockquote:({children:e})=>t.jsx("blockquote",{className:"border-l-2 border-brand-500 pl-3 my-2 text-fg-secondary italic",children:e}),a:({href:e,children:n})=>t.jsx("a",{href:e,target:"_blank",rel:"noopener noreferrer",className:"text-brand-500 hover:text-brand-500 underline break-all",children:n}),hr:()=>t.jsx("hr",{className:"border-border-default my-3"}),table:({children:e})=>t.jsx("div",{className:"overflow-x-auto my-2",children:t.jsx("table",{className:"min-w-full text-sm border-collapse border border-border-default",children:e})}),thead:({children:e})=>t.jsx("thead",{className:"bg-surface-secondary",children:e}),tbody:({children:e})=>t.jsx("tbody",{className:"divide-y divide-border-default",children:e}),tr:({children:e})=>t.jsx("tr",{className:"hover:bg-surface-elevated/50 transition-colors",children:e}),th:({children:e})=>t.jsx("th",{className:"px-3 py-2 text-left text-sm font-semibold text-fg-primary border border-border-default",children:e}),td:({children:e})=>t.jsx("td",{className:"px-3 py-2 text-sm text-fg-primary border border-border-default",children:e})},uJ=/^(?:\/[\w.\-@+ ]|~\/|\.\.?\/|[A-Z]:\\)/,mJ=/\.(png|jpe?g|gif|webp|svg|bmp|ico)$/i;function fJ(e){return uJ.test(e)&&mJ.test(e)}function hJ(e,n){if(e.startsWith("/")||e.startsWith("~/")||/^[A-Z]:\\/.test(e))return e;if((e.startsWith("./")||e.startsWith("../"))&&n){const s=((n.endsWith("/")?n:n+"/")+e).split("/"),a=[];for(const i of s)i===".."?a.pop():i!=="."&&i!==""&&a.push(i);return"/"+a.join("/")}return e}function pJ(e){return`/api/files/image?path=${encodeURIComponent(e)}`}const UN=new Set,qN=new Set;function gJ({src:e,alt:n,onPreview:r,basePath:s}){const a=g.useMemo(()=>fJ(e)?pJ(hJ(e,s)):e,[e,s]),i=UN.has(a),l=qN.has(a),[c,u]=g.useState(i),[m,f]=g.useState(i),[p,b]=g.useState(l),x=g.useRef(null);return g.useEffect(()=>{if(c||i||l)return;const v=x.current;if(!v)return;const N=new IntersectionObserver(([C])=>{C?.isIntersecting&&(u(!0),N.disconnect())},{rootMargin:"200px"});return N.observe(v),()=>N.disconnect()},[c,i,l]),l?t.jsxs("span",{className:"inline-flex items-center gap-1.5 px-3 py-2 text-xs text-fg-tertiary bg-surface-elevated rounded-lg border border-border-default",children:[t.jsxs("svg",{className:"w-4 h-4 shrink-0",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:1.5,children:[t.jsx("rect",{x:"3",y:"3",width:"18",height:"18",rx:"2",ry:"2"}),t.jsx("circle",{cx:"8.5",cy:"8.5",r:"1.5"}),t.jsx("polyline",{points:"21 15 16 10 5 21"})]}),"Failed to load image"]}):t.jsxs("span",{ref:x,className:"inline-block align-middle max-w-full",children:[!m&&!p&&t.jsx("span",{className:"block w-full min-h-[80px] max-w-[400px] bg-surface-elevated rounded-lg animate-pulse"}),p?t.jsxs("span",{className:"inline-flex items-center gap-1.5 px-3 py-2 text-xs text-fg-tertiary bg-surface-elevated rounded-lg border border-border-default",children:[t.jsxs("svg",{className:"w-4 h-4 shrink-0",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:1.5,children:[t.jsx("rect",{x:"3",y:"3",width:"18",height:"18",rx:"2",ry:"2"}),t.jsx("circle",{cx:"8.5",cy:"8.5",r:"1.5"}),t.jsx("polyline",{points:"21 15 16 10 5 21"})]}),"Failed to load image"]}):c?t.jsx("img",{src:a,alt:n??"",onLoad:()=>{UN.add(a),f(!0)},onError:()=>{qN.add(a),b(!0)},onClick:()=>r?.(a),className:`max-w-full h-auto rounded-lg cursor-pointer hover:opacity-90 transition-opacity my-1${m?"":" absolute opacity-0 pointer-events-none"}`,style:{maxHeight:"400px",objectFit:"contain"}}):null]})}function xJ({src:e,onClose:n}){return g.useEffect(()=>{const r=s=>{s.key==="Escape"&&n()};return document.addEventListener("keydown",r),()=>document.removeEventListener("keydown",r)},[n]),ao.createPortal(t.jsxs("div",{className:"fixed inset-0 z-[9999] bg-black/80 flex items-center justify-center p-4",onClick:n,children:[t.jsx("button",{onClick:n,className:"absolute top-4 right-4 w-10 h-10 rounded-full bg-white/10 hover:bg-white/20 flex items-center justify-center transition-colors z-10",children:t.jsxs("svg",{className:"w-6 h-6 text-white",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2,children:[t.jsx("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),t.jsx("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]})}),t.jsx("img",{src:e,alt:"Preview",className:"max-w-full max-h-[90vh] object-contain rounded-lg",onClick:r=>r.stopPropagation()})]}),document.body)}function bJ(e=640){const[n,r]=g.useState(()=>window.innerWidth<e);return g.useEffect(()=>{const s=window.matchMedia(`(max-width: ${e-1}px)`),a=i=>r(i.matches);return s.addEventListener("change",a),r(s.matches),()=>s.removeEventListener("change",a)},[e]),n}function yJ({content:e,contentRef:n}){const{t:r}=ht("common"),[s,a]=g.useState(!1),[i,l]=g.useState(!1),[c,u]=g.useState(!1),[m,f]=g.useState(null),p=g.useRef(null),b=bJ();g.useEffect(()=>{if(!s)return;const C=k=>{p.current&&!p.current.contains(k.target)&&(a(!1),l(!1),u(!1))};return document.addEventListener("mousedown",C),()=>document.removeEventListener("mousedown",C)},[s]);const x=g.useCallback(C=>{f(C),setTimeout(()=>f(null),1500)},[]),v=async()=>{const C=await Ap(e);x(r(C?"markdown.copied":"markdown.failed")),a(!1)},N=async C=>{const k=n.current?.firstElementChild;if(!k)return;const j=jT(),w=aJ(j),S=await UZ(k,C,e,{fontFamily:w.fontFamily,fontSize:w.fontSize,headingScales:w.headingScales}),T=r(C==="light"?"markdown.themeLight":"markdown.themeDark");x(S.ok?S.method==="html"?r("markdown.htmlCopied",{theme:T}):r("markdown.textCopied"):r("markdown.failed")),a(!1)};return t.jsxs("div",{className:"absolute top-1 right-1 z-10 opacity-0 group-hover/md:opacity-100 transition-opacity",ref:p,children:[m&&t.jsx("div",{className:"absolute right-0 top-full mt-1 z-20 px-2 py-0.5 rounded bg-surface-elevated border border-border-default text-[10px] text-fg-secondary whitespace-nowrap shadow-lg",children:m}),t.jsx("button",{onClick:()=>a(C=>!C),className:"p-1.5 rounded-lg bg-surface-elevated/80 hover:bg-surface-overlay text-fg-secondary hover:text-fg-primary backdrop-blur-sm border border-border-default/50 transition-all",title:r("markdown.copyContent"),children:t.jsx("svg",{className:"w-3.5 h-3.5",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:t.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M8 16H6a2 2 0 01-2-2V6a2 2 0 012-2h8a2 2 0 012 2v2m-6 12h8a2 2 0 002-2v-8a2 2 0 00-2-2h-8a2 2 0 00-2 2v8a2 2 0 002 2z"})})}),s&&t.jsx("div",{className:"absolute right-0 top-full mt-1 bg-surface-elevated border border-border-default rounded-lg shadow-xl py-1 min-w-[180px]",children:c?t.jsx(iJ,{onClose:()=>u(!1)}):i?t.jsxs("div",{className:"px-3 py-2 text-[11px] text-fg-secondary space-y-2 max-w-[260px]",children:[t.jsxs("div",{className:"flex items-center justify-between mb-1",children:[t.jsx("span",{className:"font-medium text-fg-primary text-xs",children:r("markdown.infoTitle")}),t.jsx("button",{onClick:()=>l(!1),className:"text-fg-tertiary hover:text-fg-primary p-0.5",children:t.jsx("svg",{className:"w-3 h-3",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:t.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M6 18L18 6M6 6l12 12"})})})]}),t.jsxs("div",{children:[t.jsx("span",{className:"font-medium text-fg-primary",children:r("markdown.mdAbbrev")})," — ",r("markdown.infoMdDesc")]}),t.jsxs("div",{children:[t.jsx("span",{className:"font-medium text-fg-primary",children:"☀️"})," — ",r("markdown.infoHtmlLightDesc")]}),t.jsxs("div",{children:[t.jsx("span",{className:"font-medium text-fg-primary",children:"🌙"})," — ",r("markdown.infoHtmlDarkDesc")]})]}):t.jsxs(t.Fragment,{children:[t.jsxs("div",{className:"flex items-center justify-between px-3 py-1 border-b border-border-subtle mb-1",children:[t.jsx("span",{className:"text-[10px] text-fg-tertiary font-medium",children:r("markdown.copyContent")}),t.jsxs("div",{className:"flex items-center gap-1",children:[t.jsx("button",{onClick:()=>u(!0),className:"p-0.5 rounded text-fg-tertiary hover:text-fg-primary transition-colors",title:r("markdown.typographySettings"),children:t.jsxs("svg",{className:"w-3.5 h-3.5",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:[t.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M10.325 4.317c.426-1.756 2.924-1.756 3.35 0a1.724 1.724 0 002.573 1.066c1.543-.94 3.31.826 2.37 2.37a1.724 1.724 0 001.066 2.573c1.756.426 1.756 2.924 0 3.35a1.724 1.724 0 00-1.066 2.573c.94 1.543-.826 3.31-2.37 2.37a1.724 1.724 0 00-2.573 1.066c-.426 1.756-2.924 1.756-3.35 0a1.724 1.724 0 00-2.573-1.066c-1.543.94-3.31-.826-2.37-2.37a1.724 1.724 0 00-1.066-2.573c-1.756-.426-1.756-2.924 0-3.35a1.724 1.724 0 001.066-2.573c-.94-1.543.826-3.31 2.37-2.37.996.608 2.296.07 2.572-1.065z"}),t.jsx("circle",{cx:"12",cy:"12",r:"3"})]})}),t.jsx("button",{onClick:()=>l(!0),className:"p-0.5 rounded text-fg-tertiary hover:text-fg-primary transition-colors",title:r("markdown.infoTitle"),children:t.jsxs("svg",{className:"w-3.5 h-3.5",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:[t.jsx("circle",{cx:"12",cy:"12",r:"10"}),t.jsx("path",{strokeLinecap:"round",d:"M12 16v-4m0-4h.01"})]})})]})]}),t.jsxs("button",{onClick:v,className:"w-full px-3 py-2 text-left text-xs text-fg-secondary hover:bg-surface-overlay hover:text-fg-primary transition-colors flex items-center gap-2",children:[t.jsx("span",{className:"w-4 text-center text-fg-tertiary shrink-0 font-mono text-[10px]",children:r("markdown.mdAbbrev")}),r(b?"markdown.copyMdSourceShort":"markdown.copyMdSource")]}),t.jsxs("button",{onClick:()=>N("light"),className:"w-full px-3 py-2 text-left text-xs text-fg-secondary hover:bg-surface-overlay hover:text-fg-primary transition-colors flex items-center gap-2",children:[t.jsx("span",{className:"w-4 text-center shrink-0 text-[10px]",children:"☀️"}),r(b?"markdown.copyHtmlLightShort":"markdown.copyHtmlLight")]}),t.jsxs("button",{onClick:()=>N("dark"),className:"w-full px-3 py-2 text-left text-xs text-fg-secondary hover:bg-surface-overlay hover:text-fg-primary transition-colors flex items-center gap-2",children:[t.jsx("span",{className:"w-4 text-center shrink-0 text-[10px]",children:"🌙"}),r(b?"markdown.copyHtmlDarkShort":"markdown.copyHtmlDark")]})]})})]})}const fs=g.memo(function({content:n,className:r="",onMentionClick:s,knownNames:a,basePath:i}){const{thinking:l,rest:c}=lJ(n),u=g.useRef(null),[m,f]=g.useState(null),p=g.useMemo(()=>{let x=Of(c,ON);return x=Of(x,KZ),x=Of(x,GZ),x=Of(x,v=>qZ(v,a)),x},[c,a]),b=g.useMemo(()=>({...HN,img:({src:x,alt:v})=>t.jsx(gJ,{src:x??"",alt:v,onPreview:f,basePath:i},x??""),a:({href:x,children:v})=>{if(x?.startsWith(zN)){const N=decodeURIComponent(x.slice(zN.length));return t.jsx("span",{className:`text-brand-500 font-medium${s?" cursor-pointer hover:underline":""}`,onClick:s?C=>{C.preventDefault(),C.stopPropagation(),s(N,C)}:void 0,title:N,children:v})}if(x?.startsWith(FN)){const N=x.slice(FN.length),C=N.split("_")[0],k=fy[C];return t.jsxs("span",{"data-entity-link":N,className:"inline-flex items-center gap-0.5 px-1 py-0.5 rounded bg-brand-500/10 text-brand-500 text-xs font-mono cursor-pointer hover:bg-brand-500/20 transition-colors",onClick:j=>{j.preventDefault(),j.stopPropagation(),Al(N)},title:k?`${k.label}: ${N}`:N,children:[k&&t.jsx("span",{className:"text-[10px]",children:k.icon}),t.jsxs("span",{children:[N.slice(0,C.length+1+8),"…"]})]})}{const N=x?.match(/^(workflow|task|requirement|project|deliverable|agent):(.+)$/);if(N){const[,C,k]=N,w={workflow:{icon:"⚙️",nav:()=>Rt.navigate(Be.WORK,{boardType:"workflows"})},task:{icon:"✅",nav:()=>Al(k)},requirement:{icon:"📋",nav:()=>Al(k)},project:{icon:"📁",nav:()=>Al(k)},deliverable:{icon:"📦",nav:()=>Al(k)},agent:{icon:"🤖",nav:()=>Al(k)}}[C];if(w)return t.jsxs("span",{className:"inline-flex items-center gap-0.5 px-1 py-0.5 rounded bg-brand-500/10 text-brand-500 text-xs font-medium cursor-pointer hover:bg-brand-500/20 transition-colors",onClick:S=>{S.preventDefault(),S.stopPropagation(),w.nav()},title:`${C}: ${k}`,children:[t.jsx("span",{className:"text-[10px]",children:w.icon}),t.jsx("span",{children:v})]})}}return t.jsx("a",{href:x,target:"_blank",rel:"noopener noreferrer",className:"text-brand-500 hover:text-brand-500 underline break-all",children:v})}}),[s,i]);return t.jsxs("div",{className:"relative group/md",children:[t.jsx(yJ,{content:n,contentRef:u}),t.jsx("div",{ref:u,children:t.jsxs("div",{className:`prose prose-sm max-w-none break-words pr-8 text-fg-secondary ${r}`,children:[l.length>0&&(()=>{const x=l.join(`
649
+ `,1;if(Ua>1e5&&Ua>_t.index*3)throw new Error("potential infinite loop, way more iterations than matches");return mn+=vn,vn.length}const nr=En(pe);if(!nr)throw ve(An.replace("{}",pe)),new Error('Unknown language: "'+pe+'"');const Fe=Me(nr);let jt="",wt=St||Fe;const tn={},Rn=new Dt.__emitter(Dt);Gr();let mn="",Ir=0,is=0,Ua=0,Ms=!1;try{if(nr.__emitTokens)nr.__emitTokens(Ye,Rn);else{for(wt.matcher.considerAll();;){Ua++,Ms?Ms=!1:wt.matcher.considerAll(),wt.matcher.lastIndex=is;const Ft=wt.matcher.exec(Ye);if(!Ft)break;const _t=Ye.substring(is,Ft.index),vn=Br(_t,Ft);is=Ft.index+vn}Br(Ye.substring(is))}return Rn.finalize(),jt=Rn.toHTML(),{language:pe,value:jt,relevance:Ir,illegal:!1,_emitter:Rn,_top:wt}}catch(Ft){if(Ft.message&&Ft.message.includes("Illegal"))return{language:pe,value:Bt(Ye),illegal:!0,relevance:0,_illegalBy:{message:Ft.message,index:is,context:Ye.slice(is-100,is+100),mode:Ft.mode,resultSoFar:jt},_emitter:Rn};if(sn)return{language:pe,value:Bt(Ye),illegal:!1,relevance:0,errorRaised:Ft,_emitter:Rn,_top:wt};throw Ft}}function er(pe){const Ye={value:Bt(pe),illegal:!1,relevance:0,_top:Ut,_emitter:new Dt.__emitter(Dt)};return Ye._emitter.addText(pe),Ye}function br(pe,Ye){Ye=Ye||Dt.languages||Object.keys(Je);const lt=er(pe),St=Ye.filter(En).filter($t).map(Pt=>Wr(Pt,pe,!1));St.unshift(lt);const Jt=St.sort((Pt,Pn)=>{if(Pt.relevance!==Pn.relevance)return Pn.relevance-Pt.relevance;if(Pt.language&&Pn.language){if(En(Pt.language).supersetOf===Pn.language)return 1;if(En(Pn.language).supersetOf===Pt.language)return-1}return 0}),[gn,tr]=Jt,Wn=gn;return Wn.secondBest=tr,Wn}function Mr(pe,Ye,lt){const St=Ye&&it[Ye]||lt;pe.classList.add("hljs"),pe.classList.add(`language-${St}`)}function Cn(pe){let Ye=null;const lt=Ln(pe);if(on(lt))return;if(pr("before:highlightElement",{el:pe,language:lt}),pe.dataset.highlighted){console.log("Element previously highlighted. To highlight again, first unset `dataset.highlighted`.",pe);return}if(pe.children.length>0&&(Dt.ignoreUnescapedHTML||(console.warn("One of your code blocks includes unescaped HTML. This is a potentially serious security risk."),console.warn("https://github.com/highlightjs/highlight.js/wiki/security"),console.warn("The element with unescaped HTML:"),console.warn(pe)),Dt.throwUnescapedHTML))throw new ct("One of your code blocks includes unescaped HTML.",pe.innerHTML);Ye=pe;const St=Ye.textContent,Jt=lt?On(St,{language:lt,ignoreIllegals:!0}):br(St);pe.innerHTML=Jt.value,pe.dataset.highlighted="yes",Mr(pe,lt,Jt.language),pe.result={language:Jt.language,re:Jt.relevance,relevance:Jt.relevance},Jt.secondBest&&(pe.secondBest={language:Jt.secondBest.language,relevance:Jt.secondBest.relevance}),pr("after:highlightElement",{el:pe,result:Jt,text:St})}function Un(pe){Dt=gt(Dt,pe)}const ar=()=>{fr(),W("10.6.0","initHighlighting() deprecated. Use highlightAll() now.")};function mr(){fr(),W("10.6.0","initHighlightingOnLoad() deprecated. Use highlightAll() now.")}let Kr=!1;function fr(){function pe(){fr()}if(document.readyState==="loading"){Kr||window.addEventListener("DOMContentLoaded",pe,!1),Kr=!0;return}document.querySelectorAll(Dt.cssSelector).forEach(Cn)}function Zn(pe,Ye){let lt=null;try{lt=Ye(be)}catch(St){if(ve("Language definition for '{}' could not be registered.".replace("{}",pe)),sn)ve(St);else throw St;lt=Ut}lt.name||(lt.name=pe),Je[pe]=lt,lt.rawDefinition=Ye.bind(null,be),lt.aliases&&Oe(lt.aliases,{languageName:pe})}function ir(pe){delete Je[pe];for(const Ye of Object.keys(it))it[Ye]===pe&&delete it[Ye]}function hr(){return Object.keys(Je)}function En(pe){return pe=(pe||"").toLowerCase(),Je[pe]||Je[it[pe]]}function Oe(pe,{languageName:Ye}){typeof pe=="string"&&(pe=[pe]),pe.forEach(lt=>{it[lt.toLowerCase()]=Ye})}function $t(pe){const Ye=En(pe);return Ye&&!Ye.disableAutodetect}function jn(pe){pe["before:highlightBlock"]&&!pe["before:highlightElement"]&&(pe["before:highlightElement"]=Ye=>{pe["before:highlightBlock"](Object.assign({block:Ye.el},Ye))}),pe["after:highlightBlock"]&&!pe["after:highlightElement"]&&(pe["after:highlightElement"]=Ye=>{pe["after:highlightBlock"](Object.assign({block:Ye.el},Ye))})}function Wt(pe){jn(pe),It.push(pe)}function pn(pe){const Ye=It.indexOf(pe);Ye!==-1&&It.splice(Ye,1)}function pr(pe,Ye){const lt=pe;It.forEach(function(St){St[lt]&&St[lt](Ye)})}function Yt(pe){return W("10.7.0","highlightBlock will be removed entirely in v12.0"),W("10.7.0","Please use highlightElement now."),Cn(pe)}Object.assign(be,{highlight:On,highlightAuto:br,highlightAll:fr,highlightElement:Cn,highlightBlock:Yt,configure:Un,initHighlighting:ar,initHighlightingOnLoad:mr,registerLanguage:Zn,unregisterLanguage:ir,listLanguages:hr,getLanguage:En,registerAliases:Oe,autoDetection:$t,inherit:gt,addPlugin:Wt,removePlugin:pn}),be.debugMode=function(){sn=!1},be.safeMode=function(){sn=!0},be.versionString=qe,be.regex={concat:N,lookahead:b,either:k,optional:v,anyNumberOfTimes:x};for(const pe in ge)typeof ge[pe]=="object"&&e(ge[pe]);return Object.assign(be,ge),be},en=Ct({});return en.newInstance=()=>Ct({}),Mb=en,en.HighlightJS=en,en.default=en,Mb}var dZ=cZ();const uZ=Tc(dZ),AN={},mZ="hljs-";function fZ(e){const n=uZ.newInstance();return e&&i(e),{highlight:r,highlightAuto:s,listLanguages:a,register:i,registerAlias:l,registered:c};function r(u,m,f){const p=f||AN,b=typeof p.prefix=="string"?p.prefix:mZ;if(!n.getLanguage(u))throw new Error("Unknown language: `"+u+"` is not registered");n.configure({__emitter:hZ,classPrefix:b});const x=n.highlight(m,{ignoreIllegals:!0,language:u});if(x.errorRaised)throw new Error("Could not highlight with `Highlight.js`",{cause:x.errorRaised});const v=x._emitter.root,N=v.data;return N.language=x.language,N.relevance=x.relevance,v}function s(u,m){const p=(m||AN).subset||a();let b=-1,x=0,v;for(;++b<p.length;){const N=p[b];if(!n.getLanguage(N))continue;const C=r(N,u,m);C.data&&C.data.relevance!==void 0&&C.data.relevance>x&&(x=C.data.relevance,v=C)}return v||{type:"root",children:[],data:{language:void 0,relevance:x}}}function a(){return n.listLanguages()}function i(u,m){if(typeof u=="string")n.registerLanguage(u,m);else{let f;for(f in u)Object.hasOwn(u,f)&&n.registerLanguage(f,u[f])}}function l(u,m){if(typeof u=="string")n.registerAliases(typeof m=="string"?m:[...m],{languageName:u});else{let f;for(f in u)if(Object.hasOwn(u,f)){const p=u[f];n.registerAliases(typeof p=="string"?p:[...p],{languageName:f})}}}function c(u){return!!n.getLanguage(u)}}class hZ{constructor(n){this.options=n,this.root={type:"root",children:[],data:{language:void 0,relevance:0}},this.stack=[this.root]}addText(n){if(n==="")return;const r=this.stack[this.stack.length-1],s=r.children[r.children.length-1];s&&s.type==="text"?s.value+=n:r.children.push({type:"text",value:n})}startScope(n){this.openNode(String(n))}endScope(){this.closeNode()}__addSublanguage(n,r){const s=this.stack[this.stack.length-1],a=n.root.children;r?s.children.push({type:"element",tagName:"span",properties:{className:[r]},children:a}):s.children.push(...a)}openNode(n){const r=this,s=n.split(".").map(function(l,c){return c?l+"_".repeat(c):r.options.classPrefix+l}),a=this.stack[this.stack.length-1],i={type:"element",tagName:"span",properties:{className:s},children:[]};a.children.push(i),this.stack.push(i)}closeNode(){this.stack.pop()}finalize(){}toHTML(){return""}}const pZ={};function yT(e){const n=e||pZ,r=n.aliases,s=n.detect||!1,a=n.languages||lZ,i=n.plainText,l=n.prefix,c=n.subset;let u="hljs";const m=fZ(a);if(r&&m.registerAlias(r),l){const f=l.indexOf("-");u=f===-1?l:l.slice(0,f)}return function(f,p){hp(f,"element",function(b,x,v){if(b.tagName!=="code"||!v||v.type!=="element"||v.tagName!=="pre")return;const N=gZ(b);if(N===!1||!N&&!s||N&&i&&i.includes(N))return;Array.isArray(b.properties.className)||(b.properties.className=[]),b.properties.className.includes(u)||b.properties.className.unshift(u);const C=ZE(b,{whitespace:"pre"});let k;try{k=N?m.highlight(N,C,{prefix:l}):m.highlightAuto(C,{prefix:l,subset:c})}catch(j){const w=j;if(N&&/Unknown language/.test(w.message)){p.message("Cannot highlight as `"+N+"`, it’s not registered",{ancestors:[v,b],cause:w,place:b.position,ruleId:"missing-language",source:"rehype-highlight"});return}throw w}!N&&k.data&&k.data.language&&b.properties.className.push("language-"+k.data.language),k.children.length>0&&(b.children=k.children)})}}function gZ(e){const n=e.properties.className;let r=-1;if(!Array.isArray(n))return;let s;for(;++r<n.length;){const a=String(n[r]);if(a==="no-highlight"||a==="nohighlight")return!1;!s&&a.slice(0,5)==="lang-"&&(s=a.slice(5)),!s&&a.slice(0,9)==="language-"&&(s=a.slice(9))}return s}const xZ="modulepreload",bZ=function(e){return"/"+e},MN={},ql=function(n,r,s){let a=Promise.resolve();if(r&&r.length>0){let u=function(m){return Promise.all(m.map(f=>Promise.resolve(f).then(p=>({status:"fulfilled",value:p}),p=>({status:"rejected",reason:p}))))};document.getElementsByTagName("link");const l=document.querySelector("meta[property=csp-nonce]"),c=l?.nonce||l?.getAttribute("nonce");a=u(r.map(m=>{if(m=bZ(m),m in MN)return;MN[m]=!0;const f=m.endsWith(".css"),p=f?'[rel="stylesheet"]':"";if(document.querySelector(`link[href="${m}"]${p}`))return;const b=document.createElement("link");if(b.rel=f?"stylesheet":xZ,f||(b.as="script"),b.crossOrigin="",b.href=m,c&&b.setAttribute("nonce",c),document.head.appendChild(b),f)return new Promise((x,v)=>{b.addEventListener("load",x),b.addEventListener("error",()=>v(new Error(`Unable to preload CSS for ${m}`)))})}))}function i(l){const c=new Event("vite:preloadError",{cancelable:!0});if(c.payload=l,window.dispatchEvent(c),!c.defaultPrevented)throw l}return a.then(l=>{for(const c of l||[])c.status==="rejected"&&i(c.reason);return n().catch(i)})};g.lazy(()=>ql(()=>Promise.resolve().then(()=>Mp),void 0).then(e=>({default:e.MarkdownMessage})));const yZ=g.lazy(()=>ql(()=>Promise.resolve().then(()=>Cne),void 0).then(e=>({default:e.ContentRenderer})));let gd=[],_N=60;function vZ(e){const n=g.useRef(e);n.current=e;const[r]=g.useState(()=>++_N);return g.useEffect(()=>{const s=()=>n.current();gd.push(s);const a=i=>{i.key==="Escape"&&gd[gd.length-1]===s&&(i.preventDefault(),s())};return window.addEventListener("keydown",a,!0),()=>{window.removeEventListener("keydown",a,!0),gd=gd.filter(i=>i!==s),gd.length===0&&(_N=60)}},[]),r}const RN=500,Dl=new Map,Hh=new Set,ph=new Map;let gh=null;function wZ(){if(Dl.size<=RN)return;const e=Dl.size-RN,n=Dl.keys();for(let r=0;r<e;r++){const{value:s,done:a}=n.next();if(a)break;Dl.delete(s)}}function IN(e,n){Dl.delete(e),Dl.set(e,n),wZ()}function DN(e){const n=ph.get(e);if(n)for(const r of n)r()}function kZ(){gh=null;const e=[...Hh];Hh.clear(),e.length!==0&&ae.files.check(e).then(({results:n})=>{for(const[r,s]of Object.entries(n))IN(r,s),DN(r)}).catch(()=>{for(const n of e)IN(n,{exists:!1,isFile:!1,type:"unknown"}),DN(n)})}function NZ(e){Dl.has(e)||Hh.has(e)||(Hh.add(e),gh&&clearTimeout(gh),gh=setTimeout(kZ,30))}function jZ(e,n){let r=ph.get(e);return r||(r=new Set,ph.set(e,r)),r.add(n),()=>{r.delete(n),r.size===0&&ph.delete(e)}}function SZ(e){const n=g.useCallback(a=>jZ(e,a),[e]),r=g.useCallback(()=>Dl.get(e),[e]),s=g.useSyncExternalStore(n,r,r);return g.useEffect(()=>{NZ(e)},[e]),s}const CZ=/^(?:\/[\w.\-@+]+(?:\/[\w.\-@+ ]*)*|~\/[\w.\-@+]+(?:\/[\w.\-@+ ]*)*|[A-Z]:\\[\w.\-@+ ]+(?:\\[\w.\-@+ ]*)*|\.\.?\/[\w.\-@+]+(?:\/[\w.\-@+ ]*)*)$/;function EZ(e){return e.length<2||e.length>500?!1:CZ.test(e)}function TZ({filePath:e,onClose:n}){const r=vZ(n),[s,a]=g.useState(!0),[i,l]=g.useState(null),[c,u]=g.useState(""),[m,f]=g.useState(""),[p,b]=g.useState("");g.useEffect(()=>{a(!0),l(null),ae.files.preview(e).then(v=>{u(v.content),f(v.type),b(v.name)}).catch(v=>{l(String(v?.message||v))}).finally(()=>{a(!1)})},[e]);const x=p||e.split(/[/\\]/).pop()||e;return ao.createPortal(t.jsx("div",{className:"fixed inset-0 bg-black/40 flex items-center justify-center",style:{zIndex:r},onClick:n,children:t.jsxs("div",{className:"bg-surface-secondary border border-border-default rounded-xl shadow-2xl w-[90vw] max-w-3xl max-h-[85vh] flex flex-col overflow-hidden",onClick:v=>v.stopPropagation(),children:[t.jsxs("div",{className:"flex items-center justify-between px-4 py-3 border-b border-border-default bg-surface-elevated/50 shrink-0",children:[t.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[t.jsx("svg",{className:"w-4 h-4 shrink-0 text-fg-secondary",viewBox:"0 0 20 20",fill:"currentColor",children:t.jsx("path",{fillRule:"evenodd",d:"M4 4a2 2 0 012-2h4.586A2 2 0 0112 2.586L15.414 6A2 2 0 0116 7.414V16a2 2 0 01-2 2H6a2 2 0 01-2-2V4z",clipRule:"evenodd"})}),t.jsx("span",{className:"text-sm font-medium text-fg-primary truncate",children:x}),t.jsx("span",{className:"text-xs text-fg-tertiary truncate hidden sm:inline",children:e})]}),t.jsxs("div",{className:"flex items-center gap-2 shrink-0",children:[t.jsx("button",{className:"text-xs text-fg-secondary hover:text-fg-primary px-2 py-1 rounded hover:bg-surface-elevated transition-colors",onClick:()=>ae.files.reveal(e),title:"Reveal in file explorer",children:t.jsx("svg",{className:"w-4 h-4",viewBox:"0 0 20 20",fill:"currentColor",children:t.jsx("path",{d:"M4.5 17a2.5 2.5 0 01-2.5-2.5v-9A2.5 2.5 0 014.5 3h3.672a1.5 1.5 0 011.06.44L10.56 4.77a.5.5 0 00.354.147H15.5A2.5 2.5 0 0118 7.417v7.083A2.5 2.5 0 0115.5 17h-11z"})})}),t.jsx("button",{className:"text-fg-secondary hover:text-fg-primary p-1 rounded hover:bg-surface-elevated transition-colors",onClick:n,children:t.jsx("svg",{className:"w-4 h-4",viewBox:"0 0 20 20",fill:"currentColor",children:t.jsx("path",{fillRule:"evenodd",d:"M4.293 4.293a1 1 0 011.414 0L10 8.586l4.293-4.293a1 1 0 111.414 1.414L11.414 10l4.293 4.293a1 1 0 01-1.414 1.414L10 11.414l-4.293 4.293a1 1 0 01-1.414-1.414L8.586 10 4.293 5.707a1 1 0 010-1.414z",clipRule:"evenodd"})})})]})]}),t.jsxs("div",{className:"flex-1 overflow-y-auto p-5",children:[s&&t.jsx("div",{className:"flex items-center justify-center py-12",children:t.jsx("div",{className:"w-5 h-5 border-2 border-brand-500/30 border-t-brand-500 rounded-full animate-spin"})}),i&&t.jsxs("div",{className:"text-center py-12 text-fg-secondary text-sm",children:[t.jsx("p",{className:"text-red-400 mb-1",children:"Failed to load file"}),t.jsx("p",{className:"text-xs text-fg-tertiary",children:i})]}),!s&&!i&&m==="image"&&t.jsx("div",{className:"flex justify-center",children:t.jsx("img",{src:`data:image/png;base64,${c}`,alt:x,className:"max-w-full rounded"})}),!s&&!i&&m!=="image"&&t.jsx(g.Suspense,{fallback:t.jsx("div",{className:"text-xs text-fg-tertiary",children:"Loading…"}),children:t.jsx(yZ,{content:c,format:m==="text"?"text":m,className:"text-sm"})})]})]})}),document.body)}function AZ({path:e}){const n=SZ(e),[r,s]=g.useState(null),a=n?.exists??!1,i=n?.type==="markdown"||n?.type==="html"||n?.type==="json"||n?.type==="text",l=g.useCallback(m=>{m.preventDefault(),m.stopPropagation(),a&&(i?s(e):ae.files.reveal(e))},[a,i,e]),c="inline w-3 h-3 align-[-0.125em]",u=i?t.jsx("svg",{className:c,viewBox:"0 0 20 20",fill:"currentColor",children:t.jsx("path",{fillRule:"evenodd",d:"M4 4a2 2 0 012-2h4.586A2 2 0 0112 2.586L15.414 6A2 2 0 0116 7.414V16a2 2 0 01-2 2H6a2 2 0 01-2-2V4zm2 6a1 1 0 011-1h6a1 1 0 110 2H7a1 1 0 01-1-1zm1 3a1 1 0 100 2h6a1 1 0 100-2H7z",clipRule:"evenodd"})}):t.jsx("svg",{className:c,viewBox:"0 0 20 20",fill:"currentColor",children:t.jsx("path",{fillRule:"evenodd",d:"M4 4a2 2 0 012-2h4.586A2 2 0 0112 2.586L15.414 6A2 2 0 0116 7.414V16a2 2 0 01-2 2H6a2 2 0 01-2-2V4z",clipRule:"evenodd"})});return n?a?t.jsxs(t.Fragment,{children:[t.jsxs("code",{className:"bg-brand-500/10 px-1.5 py-0.5 rounded text-xs font-mono text-brand-500 cursor-pointer hover:bg-brand-500/20 transition-colors border border-brand-500/20 hover:border-brand-500/40 break-all",onClick:l,title:i?"Click to preview":"Click to reveal in file explorer",role:"button",tabIndex:0,children:[t.jsxs("span",{className:"whitespace-nowrap",children:[u,e.charAt(0)]}),e.slice(1)]}),r&&t.jsx(TZ,{filePath:r,onClose:()=>s(null)})]}):t.jsx("code",{className:"bg-surface-secondary/50 px-1.5 py-0.5 rounded text-xs font-mono text-fg-tertiary border border-border-default/30 line-through decoration-fg-tertiary/30 break-all",title:"File not found",children:e}):t.jsx("code",{className:"bg-surface-secondary px-1.5 py-0.5 rounded text-xs font-mono text-fg-secondary break-all",children:e})}let _b=null;function MZ(){return _b||(_b=ql(()=>import("./mermaid.core-rPZMstL0.js").then(e=>e.b9),[]).then(e=>(e.default.initialize({startOnLoad:!1,securityLevel:"loose",fontFamily:"inherit"}),e))),_b}function _Z(){const e=document.documentElement;return e.classList.contains("light")?!1:e.classList.contains("dark")||e.classList.contains("cyberpunk")||e.classList.contains("mono")?!0:!window.matchMedia("(prefers-color-scheme: light)").matches}function RZ(e){const n=window.matchMedia("(prefers-color-scheme: dark)");n.addEventListener("change",e);const r=new MutationObserver(e);return r.observe(document.documentElement,{attributes:!0,attributeFilter:["class"]}),()=>{n.removeEventListener("change",e),r.disconnect()}}function IZ(){return _Z()}function DZ(){return g.useSyncExternalStore(RZ,IZ)}function vT({code:e}){const n=g.useRef(null),[r,s]=g.useState(null),[a,i]=g.useState(!0),l=g.useId(),c=g.useRef(0),u=g.useRef(null),m=DZ();return g.useEffect(()=>{if(!e.trim()||u.current&&u.current.code===e&&u.current.dark===m)return;let f=!1;return i(!0),s(null),c.current+=1,(async()=>{try{const p=await MZ();if(f)return;p.default.initialize({startOnLoad:!1,theme:m?"dark":"default",securityLevel:"loose",fontFamily:"inherit"});const b=`mermaid-${l.replace(/:/g,"")}-${c.current}`,{svg:x}=await p.default.render(b,e.trim());if(f)return;n.current&&(n.current.innerHTML=x,u.current={code:e,dark:m})}catch(p){f||s(p instanceof Error?p.message:String(p))}finally{f||i(!1)}})(),()=>{f=!0}},[e,l,m]),r?t.jsxs("div",{className:"my-2 rounded-lg overflow-hidden border border-red-500/30",children:[t.jsxs("div",{className:"flex items-center gap-1.5 px-3 py-1.5 bg-red-500/10 border-b border-red-500/20",children:[t.jsx("svg",{className:"w-3.5 h-3.5 text-red-400",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:t.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M12 9v2m0 4h.01m-6.938 4h13.856c1.54 0 2.502-1.667 1.732-2.5L13.732 4c-.77-.833-1.964-.833-2.732 0L4.082 16.5c-.77.833.192 2.5 1.732 2.5z"})}),t.jsx("span",{className:"text-[10px] font-medium text-red-400",children:"Mermaid render error"})]}),t.jsx("pre",{className:"p-3 bg-surface-secondary text-xs text-fg-secondary overflow-x-auto font-mono",children:e})]}):t.jsxs("div",{className:"not-prose my-2 rounded-lg bg-surface-secondary border border-border-subtle p-4 overflow-x-auto",children:[a&&t.jsxs("div",{className:"flex items-center gap-2 text-xs text-fg-tertiary",children:[t.jsx("div",{className:"w-4 h-4 border-2 border-fg-tertiary/30 border-t-fg-tertiary rounded-full animate-spin"}),"Rendering diagram…"]}),t.jsx("div",{ref:n,className:`flex justify-center [&>svg]:max-w-full${a?" hidden":""}`})]})}const LZ="/assets/viz-global-C_AyN6D9.js";let Lf=!1,Rb=null;function OZ(){return Lf?Promise.resolve():new Promise((e,n)=>{const r=document.querySelector("script[data-plantuml-viz]");if(r){globalThis.Viz?(Lf=!0,e()):(r.addEventListener("load",()=>{Lf=!0,e()}),r.addEventListener("error",()=>n(new Error("Failed to load viz-global.js"))));return}const s=document.createElement("script");s.setAttribute("data-plantuml-viz",""),s.src=LZ,s.onload=()=>{Lf=!0,e()},s.onerror=()=>n(new Error("Failed to load viz-global.js")),document.head.appendChild(s)})}function PZ(){return Rb||(Rb=OZ().then(()=>ql(()=>import("./plantuml-DezRDxd4.js"),[]))),Rb}let LN=Promise.resolve();function BZ(e,n){const r=LN.then(()=>new Promise((s,a)=>{PZ().then(({renderToString:i})=>{const l=e.split(/\r\n|\r|\n/);i(l,s,a,{dark:n})}).catch(a)}));return LN=r.then(()=>{},()=>{}),r}function $Z(){const e=document.documentElement;return e.classList.contains("light")?!1:e.classList.contains("dark")||e.classList.contains("cyberpunk")||e.classList.contains("mono")?!0:!window.matchMedia("(prefers-color-scheme: light)").matches}function zZ(e){const n=window.matchMedia("(prefers-color-scheme: dark)");n.addEventListener("change",e);const r=new MutationObserver(e);return r.observe(document.documentElement,{attributes:!0,attributeFilter:["class"]}),()=>{n.removeEventListener("change",e),r.disconnect()}}function FZ(){return g.useSyncExternalStore(zZ,()=>$Z())}function wT({code:e}){const[n,r]=g.useState(null),[s,a]=g.useState(null),[i,l]=g.useState(!0),c=g.useRef(null),u=FZ();return g.useEffect(()=>{if(!e.trim()||c.current&&c.current.code===e&&c.current.dark===u)return;let m=!1;return l(!0),a(null),BZ(e.trim(),u).then(f=>{m||(r(f),c.current={code:e,dark:u})}).catch(f=>{m||a(f instanceof Error?f.message:String(f))}).finally(()=>{m||l(!1)}),()=>{m=!0}},[e,u]),s?t.jsxs("div",{className:"my-2 rounded-lg overflow-hidden border border-red-500/30",children:[t.jsxs("div",{className:"flex items-center gap-1.5 px-3 py-1.5 bg-red-500/10 border-b border-red-500/20",children:[t.jsx("svg",{className:"w-3.5 h-3.5 text-red-400",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:t.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M12 9v2m0 4h.01m-6.938 4h13.856c1.54 0 2.502-1.667 1.732-2.5L13.732 4c-.77-.833-1.964-.833-2.732 0L4.082 16.5c-.77.833.192 2.5 1.732 2.5z"})}),t.jsx("span",{className:"text-[10px] font-medium text-red-400",children:"PlantUML render error"})]}),t.jsx("pre",{className:"p-3 bg-surface-secondary text-xs text-fg-secondary overflow-x-auto font-mono",children:e})]}):t.jsxs("div",{className:"not-prose my-2 rounded-lg bg-surface-secondary border border-border-subtle p-4 overflow-x-auto",children:[i&&t.jsxs("div",{className:"flex items-center gap-2 text-xs text-fg-tertiary",children:[t.jsx("div",{className:"w-4 h-4 border-2 border-fg-tertiary/30 border-t-fg-tertiary rounded-full animate-spin"}),"Rendering diagram…"]}),n&&t.jsx("div",{className:`flex justify-center [&>svg]:max-w-full${i?" hidden":""}`,dangerouslySetInnerHTML:{__html:n}})]})}function HZ(e,n,r){const s=e.cloneNode(!0),a=r?.fontFamily??"-apple-system,BlinkMacSystemFont,'Segoe UI','Noto Sans',Helvetica,Arial,sans-serif",i=r?.fontSize??"15px",l=r?.headingScales??{h1:1.6,h2:1.35,h3:1.15,h4:1},c=n==="light"?{bg:"#ffffff",text:"#24292f",heading:"#1f2328",strong:"#1f2328",link:"#0969da",codeBg:"#eff1f3",codeText:"#24292f",preBg:"#f6f8fa",preText:"#24292f",preBorder:"#d0d7de",border:"#d0d7de",blockquoteBorder:"#d0d7de",blockquoteText:"#656d76",tableBorder:"#d0d7de",tableHeaderBg:"#f6f8fa",tableHeaderText:"#24292f",hrColor:"#d8dee4"}:{bg:"#0d1117",text:"#e6edf3",heading:"#f0f6fc",strong:"#f0f6fc",link:"#58a6ff",codeBg:"#161b22",codeText:"#e6edf3",preBg:"#161b22",preText:"#e6edf3",preBorder:"#30363d",border:"#30363d",blockquoteBorder:"#3b82f6",blockquoteText:"#8b949e",tableBorder:"#30363d",tableHeaderBg:"#161b22",tableHeaderText:"#e6edf3",hrColor:"#21262d"},u={p:`margin:0 0 10px;color:${c.text};line-height:1.7;`,h1:`font-size:${l.h1}em;font-weight:700;color:${c.heading};margin:20px 0 10px;line-height:1.3;border-bottom:1px solid ${c.border};padding-bottom:6px;`,h2:`font-size:${l.h2}em;font-weight:700;color:${c.heading};margin:18px 0 8px;line-height:1.3;`,h3:`font-size:${l.h3}em;font-weight:600;color:${c.heading};margin:14px 0 6px;line-height:1.3;`,h4:`font-size:${l.h4}em;font-weight:600;color:${c.heading};margin:12px 0 4px;`,strong:`font-weight:600;color:${c.strong};`,em:"font-style:italic;",a:`color:${c.link};text-decoration:underline;`,ul:"padding-left:1.5em;margin:0 0 10px;",ol:"padding-left:1.5em;margin:0 0 10px;",li:`margin:3px 0;line-height:1.7;color:${c.text};`,blockquote:`border-left:3px solid ${c.blockquoteBorder};padding:2px 0 2px 14px;margin:10px 0;color:${c.blockquoteText};`,hr:`border:none;border-top:1px solid ${c.hrColor};margin:20px 0;`,table:"border-collapse:collapse;width:100%;margin:10px 0;",thead:`background:${c.tableHeaderBg};`,th:`border:1px solid ${c.tableBorder};padding:8px 12px;text-align:left;font-weight:600;color:${c.tableHeaderText};`,td:`border:1px solid ${c.tableBorder};padding:8px 12px;color:${c.text};`,img:"max-width:100%;height:auto;"};function m(f){f.removeAttribute("class");const p=f.tagName.toLowerCase();if(p==="pre"){f.setAttribute("style",`background:${c.preBg};color:${c.preText};padding:14px;border-radius:6px;overflow-x:auto;margin:10px 0;font-size:0.88em;line-height:1.5;border:1px solid ${c.preBorder};`);const b=f.querySelector("code");b&&(b.removeAttribute("class"),b.setAttribute("style","background:transparent;padding:0;border-radius:0;color:inherit;font-family:'SFMono-Regular',Consolas,'Liberation Mono',Menlo,monospace;font-size:inherit;"));return}p==="code"?f.setAttribute("style",`background:${c.codeBg};color:${c.codeText};padding:2px 6px;border-radius:4px;font-size:0.9em;font-family:'SFMono-Regular',Consolas,'Liberation Mono',Menlo,monospace;`):u[p]&&f.setAttribute("style",u[p]),Array.from(f.children).forEach(m)}return s.removeAttribute("class"),Array.from(s.children).forEach(f=>m(f)),`<div style="background:${c.bg};color:${c.text};padding:20px 24px;font-family:${a};font-size:${i};line-height:1.7;max-width:800px;">${s.innerHTML}</div>`}async function Ap(e){try{return await navigator.clipboard.writeText(e),!0}catch{try{const n=document.createElement("textarea");n.value=e,n.style.cssText="position:fixed;left:-9999px;top:-9999px;opacity:0",document.body.appendChild(n),n.select();const r=document.execCommand("copy");return document.body.removeChild(n),r}catch{return!1}}}async function UZ(e,n,r,s){const a=HZ(e,n,s);try{return await navigator.clipboard.write([new ClipboardItem({"text/html":new Blob([a],{type:"text/html"}),"text/plain":new Blob([r],{type:"text/plain"})})]),{ok:!0,method:"html"}}catch{return{ok:await Ap(r),method:"text"}}}function my({code:e,language:n,children:r}){const{t:s}=ht("common"),[a,i]=g.useState("rendered"),[l,c]=g.useState(!1),u=g.useCallback(async()=>{await Ap(e)&&(c(!0),setTimeout(()=>c(!1),1800))},[e]);return t.jsxs("div",{className:"not-prose my-2 rounded-lg overflow-hidden border border-border-subtle",children:[t.jsxs("div",{className:"flex items-center justify-between px-3 py-1.5 border-b border-border-subtle bg-surface-secondary",children:[t.jsx("span",{className:"text-[10px] font-medium text-fg-tertiary uppercase tracking-wider select-none",children:n}),t.jsxs("div",{className:"flex items-center gap-1",children:[t.jsx("button",{onClick:()=>i("rendered"),className:`px-2 py-0.5 rounded text-[10px] font-medium transition-colors ${a==="rendered"?"bg-brand-600/20 text-brand-500":"text-fg-tertiary hover:text-fg-secondary"}`,children:t.jsxs("span",{className:"flex items-center gap-1",children:[t.jsxs("svg",{className:"w-3 h-3",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:[t.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M15 12a3 3 0 11-6 0 3 3 0 016 0z"}),t.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M2.458 12C3.732 7.943 7.523 5 12 5c4.478 0 8.268 2.943 9.542 7-1.274 4.057-5.064 7-9.542 7-4.477 0-8.268-2.943-9.542-7z"})]}),s("markdown.viewRendered")]})}),t.jsx("button",{onClick:()=>i("source"),className:`px-2 py-0.5 rounded text-[10px] font-medium transition-colors ${a==="source"?"bg-brand-600/20 text-brand-500":"text-fg-tertiary hover:text-fg-secondary"}`,children:t.jsxs("span",{className:"flex items-center gap-1",children:[t.jsx("svg",{className:"w-3 h-3",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:t.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M10 20l4-16m4 4l4 4-4 4M6 16l-4-4 4-4"})}),s("markdown.viewSource")]})})]})]}),a==="rendered"?t.jsx("div",{children:r}):t.jsxs("div",{className:"relative group/source",children:[t.jsx("pre",{className:"p-3 overflow-x-auto text-xs font-mono text-fg-secondary bg-surface-secondary leading-relaxed whitespace-pre-wrap break-words",children:e}),t.jsx("button",{onClick:u,className:"absolute top-2 right-2 p-1.5 rounded-md bg-surface-elevated/80 hover:bg-surface-overlay text-fg-tertiary hover:text-fg-primary backdrop-blur-sm border border-border-default/50 transition-all opacity-0 group-hover/source:opacity-100",title:s("markdown.copyContent"),children:l?t.jsx("svg",{className:"w-3.5 h-3.5 text-green-400",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:t.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M5 13l4 4L19 7"})}):t.jsx("svg",{className:"w-3.5 h-3.5",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:t.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M8 16H6a2 2 0 01-2-2V6a2 2 0 012-2h8a2 2 0 012 2v2m-6 12h8a2 2 0 002-2v-8a2 2 0 00-2-2h-8a2 2 0 00-2 2v8a2 2 0 002 2z"})})})]})]})}function Of(e,n){const r=/```[\s\S]*?```|`[^`\n]+`/g;let s=0,a="";for(const i of e.matchAll(r))a+=n(e.slice(s,i.index)),a+=i[0],s=i.index+i[0].length;return a+=n(e.slice(s)),a}function ON(e){let n=e.replace(/\\\[([\s\S]*?)\\\]/g,(r,s)=>`$$${s}$$`);return n=n.replace(/\\\((.+?)\\\)/g,(r,s)=>`$${s}$`),n}const Pf="#mention:";function qZ(e,n){if(!n||n.length===0)return e.replace(/@\[([^\]]+)\]|@([\w\p{L}\p{N}]+)/gu,(i,l,c)=>{const u=l??c;return`[@${u}](${Pf}${encodeURIComponent(u)})`});const r=[...n].sort((i,l)=>l.length-i.length);let s="",a=0;for(;a<e.length;){const i=e.indexOf("@",a);if(i<0){s+=e.slice(a);break}if(s+=e.slice(a,i),e[i+1]==="["){const f=e.indexOf("]",i+2);if(f>i+2){const p=e.slice(i+2,f);s+=`[@${p}](${Pf}${encodeURIComponent(p)})`,a=f+1;continue}}const l=e.slice(i+1),c=l.toLowerCase(),u=r.find(f=>c.startsWith(f.toLowerCase()));if(u){const f=l.slice(0,u.length);s+=`[@${f}](${Pf}${encodeURIComponent(f)})`,a=i+1+u.length;continue}const m=l.match(/^([\w\p{L}\p{N}]+)/u);if(m){const f=m[1];s+=`[@${f}](${Pf}${encodeURIComponent(f)})`,a=i+1+f.length;continue}s+="@",a=i+1}return s}const kT="#entity:",VZ=new RegExp("(?<!\\[)(?<!#entity:)\\b(tsk|req|proj|dlv|agt)_[a-f0-9]{6,}\\b(?!\\]\\(#entity:)","gi"),WZ=/`\[([^\]]+)\]\(#entity:((?:tsk|req|proj|dlv|agt)_[a-f0-9]{6,})\)`/gi;function KZ(e){return e.replace(WZ,(n,r,s)=>`[${r}](${kT}${s})`)}function GZ(e){return e.replace(VZ,n=>`[${n}](${kT}${n})`)}function YZ(e){const n=e.trim();return n.startsWith("@startuml")&&n.endsWith("@enduml")}const XZ=/^(graph\s|flowchart\s|sequenceDiagram|classDiagram|stateDiagram|erDiagram|gantt|pie|gitGraph|mindmap|timeline|journey)/m;function QZ(e){return XZ.test(e.trim())}const ZZ={js:"JavaScript",javascript:"JavaScript",ts:"TypeScript",typescript:"TypeScript",tsx:"TSX",jsx:"JSX",py:"Python",python:"Python",rb:"Ruby",ruby:"Ruby",rs:"Rust",rust:"Rust",go:"Go",java:"Java",kotlin:"Kotlin",swift:"Swift",cpp:"C++",c:"C",cs:"C#",csharp:"C#",php:"PHP",sql:"SQL",sh:"Shell",bash:"Bash",zsh:"Zsh",shell:"Shell",html:"HTML",css:"CSS",scss:"SCSS",less:"LESS",json:"JSON",yaml:"YAML",yml:"YAML",xml:"XML",toml:"TOML",ini:"INI",md:"Markdown",markdown:"Markdown",dockerfile:"Dockerfile",docker:"Dockerfile",graphql:"GraphQL",gql:"GraphQL",lua:"Lua",perl:"Perl",r:"R",scala:"Scala",elixir:"Elixir",erlang:"Erlang",haskell:"Haskell",clojure:"Clojure",dart:"Dart",zig:"Zig",nim:"Nim",powershell:"PowerShell",ps1:"PowerShell",vue:"Vue",svelte:"Svelte",plaintext:"Text",text:"Text",txt:"Text"};function JZ(e){return ZZ[e.toLowerCase()]??e.charAt(0).toUpperCase()+e.slice(1)}function eJ(e){const n=e.match(/language-(\S+)/);return n?n[1]:null}const tJ=[vT,wT];function nJ(e){for(const n of g.Children.toArray(e))if(g.isValidElement(n)&&typeof n.props?.className=="string"){const r=n.props.className;return eJ(r)}return null}function w0(e){if(typeof e=="string")return e;if(typeof e=="number")return String(e);if(!e)return"";if(Array.isArray(e))return e.map(w0).join("");if(g.isValidElement(e)){const n=e.props;return w0(n.children)}return""}function rJ({children:e}){const{t:n}=ht("common"),r=nJ(e),s=g.useRef(null),[a,i]=g.useState(!1),[l,c]=g.useState("rendered"),u=g.useCallback(async()=>{let f;l==="source"?f=w0(e):f=s.current?.querySelector("code")?.textContent??"";try{await navigator.clipboard.writeText(f),i(!0),setTimeout(()=>i(!1),1800)}catch{}},[l,e]);if(g.Children.toArray(e).some(f=>g.isValidElement(f)&&tJ.includes(f.type))){const f=w0(e),p=r==="mermaid"||r==="plantuml"?r:"diagram";return t.jsx(my,{code:f,language:p,children:e})}return r==="mermaid"||r==="plantuml"?t.jsx(t.Fragment,{children:e}):t.jsxs("div",{className:"not-prose relative group/code my-2 rounded-lg overflow-hidden bg-surface-secondary border border-border-subtle",children:[r&&t.jsxs("div",{className:"flex items-center justify-between px-3 py-1.5 border-b border-border-subtle",children:[t.jsx("span",{className:"text-[10px] font-medium text-fg-tertiary uppercase tracking-wider select-none",children:JZ(r)}),t.jsxs("div",{className:"flex items-center gap-1",children:[t.jsx("button",{onClick:()=>c("rendered"),className:`px-1.5 py-0.5 rounded text-[10px] font-medium transition-colors ${l==="rendered"?"bg-brand-600/20 text-brand-500":"text-fg-tertiary hover:text-fg-secondary"}`,children:n("markdown.viewRendered")}),t.jsx("button",{onClick:()=>c("source"),className:`px-1.5 py-0.5 rounded text-[10px] font-medium transition-colors ${l==="source"?"bg-brand-600/20 text-brand-500":"text-fg-tertiary hover:text-fg-secondary"}`,children:n("markdown.viewSource")})]})]}),t.jsxs("div",{className:"relative",children:[l==="rendered"?t.jsx("pre",{ref:s,className:"p-3 overflow-x-auto text-xs [&>code]:p-0 [&>code]:rounded-none [&>code]:text-fg-secondary",children:g.Children.map(e,f=>g.isValidElement(f)?g.cloneElement(f,{style:{background:"transparent",padding:0}}):f)}):t.jsx("pre",{className:"p-3 overflow-x-auto text-xs font-mono text-fg-secondary whitespace-pre-wrap break-words",children:w0(e)}),t.jsx("button",{onClick:u,className:"absolute top-2 right-2 p-1.5 rounded-md bg-surface-elevated/80 hover:bg-surface-overlay text-fg-tertiary hover:text-fg-primary backdrop-blur-sm border border-border-default/50 transition-all opacity-0 group-hover/code:opacity-100",title:n("markdown.copyContent"),children:a?t.jsx("svg",{className:"w-3.5 h-3.5 text-green-400",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:t.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M5 13l4 4L19 7"})}):t.jsx("svg",{className:"w-3.5 h-3.5",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:t.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M8 16H6a2 2 0 01-2-2V6a2 2 0 012-2h8a2 2 0 012 2v2m-6 12h8a2 2 0 002-2v-8a2 2 0 00-2-2h-8a2 2 0 00-2 2v8a2 2 0 002 2z"})})})]})]})}const NT="markus-copy-typography",PN={fontFamily:"default",fontSize:15,headingScale:"standard"};function jT(){try{const e=localStorage.getItem(NT);if(e)return{...PN,...JSON.parse(e)}}catch{}return PN}function sJ(e){localStorage.setItem(NT,JSON.stringify(e))}function aJ(e){const n={default:"-apple-system, BlinkMacSystemFont, 'Segoe UI', 'Noto Sans', Helvetica, Arial, sans-serif",serif:"Georgia, 'Times New Roman', Times, serif","sans-serif":"-apple-system, BlinkMacSystemFont, 'Segoe UI', Helvetica, Arial, sans-serif",mono:"'SFMono-Regular', Consolas, 'Liberation Mono', Menlo, monospace"},r={compact:{h1:1.3,h2:1.15,h3:1.05,h4:1},standard:{h1:1.6,h2:1.35,h3:1.15,h4:1},large:{h1:2,h2:1.6,h3:1.3,h4:1.1}};return{fontFamily:n[e.fontFamily]??n.default,fontSize:`${e.fontSize}px`,headingScales:r[e.headingScale]??r.standard}}function iJ({onClose:e}){const{t:n}=ht("common"),[r,s]=g.useState(jT);g.useEffect(()=>{sJ(r)},[r]);const a=g.useCallback((i,l)=>{s(c=>({...c,[i]:l}))},[]);return t.jsxs("div",{className:"px-3 py-2 space-y-3 max-w-[260px]",children:[t.jsxs("div",{className:"flex items-center justify-between mb-1",children:[t.jsx("span",{className:"font-medium text-fg-primary text-xs",children:n("markdown.typographySettings")}),t.jsx("button",{onClick:e,className:"text-fg-tertiary hover:text-fg-primary p-0.5",children:t.jsx("svg",{className:"w-3 h-3",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:t.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M6 18L18 6M6 6l12 12"})})})]}),t.jsx("p",{className:"text-[10px] text-fg-tertiary",children:n("markdown.typographyDesc")}),t.jsxs("div",{children:[t.jsx("label",{className:"text-[10px] text-fg-tertiary font-medium block mb-1",children:n("markdown.fontFamily")}),t.jsxs("select",{value:r.fontFamily,onChange:i=>a("fontFamily",i.target.value),className:"w-full px-2 py-1 text-xs rounded bg-surface-primary border border-border-subtle text-fg-secondary focus:outline-none focus:ring-1 focus:ring-brand-500/50",children:[t.jsx("option",{value:"default",children:n("markdown.fontDefault")}),t.jsx("option",{value:"serif",children:n("markdown.fontSerif")}),t.jsx("option",{value:"sans-serif",children:n("markdown.fontSansSerif")}),t.jsx("option",{value:"mono",children:n("markdown.fontMono")})]})]}),t.jsxs("div",{children:[t.jsxs("label",{className:"text-[10px] text-fg-tertiary font-medium block mb-1",children:[n("markdown.fontSize"),": ",r.fontSize,"px"]}),t.jsx("input",{type:"range",min:10,max:24,step:1,value:r.fontSize,onChange:i=>a("fontSize",Number(i.target.value)),className:"w-full h-1 rounded-full appearance-none bg-border-subtle [&::-webkit-slider-thumb]:appearance-none [&::-webkit-slider-thumb]:w-3 [&::-webkit-slider-thumb]:h-3 [&::-webkit-slider-thumb]:rounded-full [&::-webkit-slider-thumb]:bg-brand-500"}),t.jsxs("div",{className:"flex justify-between text-[9px] text-fg-tertiary mt-0.5",children:[t.jsx("span",{children:"10px"}),t.jsx("span",{children:"24px"})]})]}),t.jsxs("div",{children:[t.jsx("label",{className:"text-[10px] text-fg-tertiary font-medium block mb-1",children:n("markdown.headingScale")}),t.jsx("div",{className:"flex gap-1",children:["compact","standard","large"].map(i=>t.jsx("button",{onClick:()=>a("headingScale",i),className:`flex-1 px-2 py-1 rounded text-[10px] font-medium transition-colors ${r.headingScale===i?"bg-brand-600/20 text-brand-500":"bg-surface-primary text-fg-tertiary hover:text-fg-secondary border border-border-subtle"}`,children:n(`markdown.scale${i.charAt(0).toUpperCase()+i.slice(1)}`)},i))})]})]})}const BN=[VC,lX,KE],$N=[[FX,{strict:"ignore"}],[yT,{detect:!0,ignoreMissing:!0}]],oJ=/<think>([\s\S]*?)(<\/think>|$)/g;function lJ(e){const n=[];let r=e.replace(oJ,(s,a)=>{const i=a.trim();return i&&n.push(i),""});return r=r.replace(/<\/think>/g,"").replace(/<think>/g,""),{thinking:n,rest:r.trim()}}const zN="#mention:",FN="#entity:",cJ=/^\[([^\]]+)\]\(#entity:((tsk|req|proj|dlv|agt)_[a-f0-9]{6,})\)$/i,fy={tsk:{icon:"📋",label:"Task"},req:{icon:"📝",label:"Requirement"},proj:{icon:"📁",label:"Project"},dlv:{icon:"📦",label:"Deliverable"},agt:{icon:"🤖",label:"Agent"}};function Al(e){e.startsWith("tsk_")?Rt.navigate(Be.WORK,{openTask:e}):e.startsWith("req_")?Rt.navigate(Be.WORK,{openRequirement:e}):e.startsWith("proj_")?Rt.navigate(Be.WORK,{projectId:e}):e.startsWith("dlv_")?Rt.navigate(Be.DELIVERABLES,{openDeliverable:e}):e.startsWith("agt_")&&Rt.navigate(Be.TEAM,{agentId:e})}function dJ(e){return/^(tsk|req|proj|dlv|agt)_[a-f0-9]{6,}$/i.test(e)}const HN={p:({children:e})=>t.jsx("p",{className:"mb-2 last:mb-0 leading-relaxed text-fg-secondary",children:e}),h1:({children:e})=>t.jsx("h1",{className:"text-base font-bold mb-2 mt-3 first:mt-0 text-fg-primary",children:e}),h2:({children:e})=>t.jsx("h2",{className:"text-sm font-bold mb-2 mt-3 first:mt-0 text-fg-primary",children:e}),h3:({children:e})=>t.jsx("h3",{className:"text-sm font-semibold mb-1 mt-2 first:mt-0 text-fg-primary",children:e}),h4:({children:e})=>t.jsx("h4",{className:"text-sm font-semibold mb-1 mt-2 first:mt-0 text-fg-primary",children:e}),h5:({children:e})=>t.jsx("h5",{className:"text-xs font-semibold mb-1 mt-2 first:mt-0 text-fg-primary",children:e}),h6:({children:e})=>t.jsx("h6",{className:"text-xs font-medium mb-1 mt-2 first:mt-0 text-fg-primary",children:e}),ul:({children:e})=>t.jsx("ul",{className:"list-disc pl-4 mb-2 space-y-0.5",children:e}),ol:({children:e})=>t.jsx("ol",{className:"list-decimal pl-4 mb-2 space-y-0.5",children:e}),li:({children:e})=>t.jsx("li",{className:"leading-relaxed text-fg-secondary marker:text-fg-secondary",children:e}),code:({children:e,className:n})=>{const r=typeof e=="string"?e:String(e??""),s=r.trim();if(n?.includes("language-plantuml")||YZ(s))return t.jsx(my,{code:s,language:"plantuml",children:t.jsx(wT,{code:s})});if(n?.includes("language-mermaid")||!n&&QZ(s))return t.jsx(my,{code:s,language:"mermaid",children:t.jsx(vT,{code:s})});if(n?.includes("language-"))return t.jsx("code",{className:`${n} text-fg-secondary font-mono text-xs`,children:e});if(dJ(r)){const i=r.split("_")[0],l=fy[i];return t.jsxs("span",{"data-entity-link":r,className:"inline-flex items-center gap-0.5 px-1 py-0.5 rounded bg-brand-500/10 text-brand-500 text-xs font-mono cursor-pointer hover:bg-brand-500/20 transition-colors",onClick:c=>{c.preventDefault(),c.stopPropagation(),Al(r)},title:l?`${l.label}: ${r}`:r,children:[l&&t.jsx("span",{className:"text-[10px]",children:l.icon}),t.jsxs("span",{children:[r.slice(0,i.length+1+8),"…"]})]})}const a=r.match(cJ);if(a){const i=a[2],l=i.split("_")[0],c=fy[l];return t.jsxs("span",{"data-entity-link":i,className:"inline-flex items-center gap-0.5 px-1 py-0.5 rounded bg-brand-500/10 text-brand-500 text-xs font-mono cursor-pointer hover:bg-brand-500/20 transition-colors",onClick:u=>{u.preventDefault(),u.stopPropagation(),Al(i)},title:c?`${c.label}: ${i}`:i,children:[c&&t.jsx("span",{className:"text-[10px]",children:c.icon}),t.jsxs("span",{children:[i.slice(0,l.length+1+8),"…"]})]})}return EZ(r)?t.jsx(AZ,{path:r}):t.jsx("code",{className:"bg-surface-secondary px-1.5 py-0.5 rounded text-xs font-mono text-brand-500 break-all",children:e})},pre:({children:e})=>t.jsx(rJ,{children:e}),strong:({children:e})=>t.jsx("strong",{className:"font-bold text-fg-primary",children:e}),em:({children:e})=>t.jsx("em",{className:"italic text-fg-secondary",children:e}),del:({children:e})=>t.jsx("del",{className:"line-through text-fg-tertiary",children:e}),blockquote:({children:e})=>t.jsx("blockquote",{className:"border-l-2 border-brand-500 pl-3 my-2 text-fg-secondary italic",children:e}),a:({href:e,children:n})=>t.jsx("a",{href:e,target:"_blank",rel:"noopener noreferrer",className:"text-brand-500 hover:text-brand-500 underline break-all",children:n}),hr:()=>t.jsx("hr",{className:"border-border-default my-3"}),table:({children:e})=>t.jsx("div",{className:"overflow-x-auto my-2",children:t.jsx("table",{className:"min-w-full text-sm border-collapse border border-border-default",children:e})}),thead:({children:e})=>t.jsx("thead",{className:"bg-surface-secondary",children:e}),tbody:({children:e})=>t.jsx("tbody",{className:"divide-y divide-border-default",children:e}),tr:({children:e})=>t.jsx("tr",{className:"hover:bg-surface-elevated/50 transition-colors",children:e}),th:({children:e})=>t.jsx("th",{className:"px-3 py-2 text-left text-sm font-semibold text-fg-primary border border-border-default",children:e}),td:({children:e})=>t.jsx("td",{className:"px-3 py-2 text-sm text-fg-primary border border-border-default",children:e})},uJ=/^(?:\/[\w.\-@+ ]|~\/|\.\.?\/|[A-Z]:\\)/,mJ=/\.(png|jpe?g|gif|webp|svg|bmp|ico)$/i;function fJ(e){return uJ.test(e)&&mJ.test(e)}function hJ(e,n){if(e.startsWith("/")||e.startsWith("~/")||/^[A-Z]:\\/.test(e))return e;if((e.startsWith("./")||e.startsWith("../"))&&n){const s=((n.endsWith("/")?n:n+"/")+e).split("/"),a=[];for(const i of s)i===".."?a.pop():i!=="."&&i!==""&&a.push(i);return"/"+a.join("/")}return e}function pJ(e){return`/api/files/image?path=${encodeURIComponent(e)}`}const UN=new Set,qN=new Set;function gJ({src:e,alt:n,onPreview:r,basePath:s}){const a=g.useMemo(()=>fJ(e)?pJ(hJ(e,s)):e,[e,s]),i=UN.has(a),l=qN.has(a),[c,u]=g.useState(i),[m,f]=g.useState(i),[p,b]=g.useState(l),x=g.useRef(null);return g.useEffect(()=>{if(c||i||l)return;const v=x.current;if(!v)return;const N=new IntersectionObserver(([C])=>{C?.isIntersecting&&(u(!0),N.disconnect())},{rootMargin:"200px"});return N.observe(v),()=>N.disconnect()},[c,i,l]),l?t.jsxs("span",{className:"inline-flex items-center gap-1.5 px-3 py-2 text-xs text-fg-tertiary bg-surface-elevated rounded-lg border border-border-default",children:[t.jsxs("svg",{className:"w-4 h-4 shrink-0",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:1.5,children:[t.jsx("rect",{x:"3",y:"3",width:"18",height:"18",rx:"2",ry:"2"}),t.jsx("circle",{cx:"8.5",cy:"8.5",r:"1.5"}),t.jsx("polyline",{points:"21 15 16 10 5 21"})]}),"Failed to load image"]}):t.jsxs("span",{ref:x,className:"inline-block align-middle max-w-full",children:[!m&&!p&&t.jsx("span",{className:"block w-full min-h-[80px] max-w-[400px] bg-surface-elevated rounded-lg animate-pulse"}),p?t.jsxs("span",{className:"inline-flex items-center gap-1.5 px-3 py-2 text-xs text-fg-tertiary bg-surface-elevated rounded-lg border border-border-default",children:[t.jsxs("svg",{className:"w-4 h-4 shrink-0",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:1.5,children:[t.jsx("rect",{x:"3",y:"3",width:"18",height:"18",rx:"2",ry:"2"}),t.jsx("circle",{cx:"8.5",cy:"8.5",r:"1.5"}),t.jsx("polyline",{points:"21 15 16 10 5 21"})]}),"Failed to load image"]}):c?t.jsx("img",{src:a,alt:n??"",onLoad:()=>{UN.add(a),f(!0)},onError:()=>{qN.add(a),b(!0)},onClick:()=>r?.(a),className:`max-w-full h-auto rounded-lg cursor-pointer hover:opacity-90 transition-opacity my-1${m?"":" absolute opacity-0 pointer-events-none"}`,style:{maxHeight:"400px",objectFit:"contain"}}):null]})}function xJ({src:e,onClose:n}){return g.useEffect(()=>{const r=s=>{s.key==="Escape"&&n()};return document.addEventListener("keydown",r),()=>document.removeEventListener("keydown",r)},[n]),ao.createPortal(t.jsxs("div",{className:"fixed inset-0 z-[9999] bg-black/80 flex items-center justify-center p-4",onClick:n,children:[t.jsx("button",{onClick:n,className:"absolute top-4 right-4 w-10 h-10 rounded-full bg-white/10 hover:bg-white/20 flex items-center justify-center transition-colors z-10",children:t.jsxs("svg",{className:"w-6 h-6 text-white",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2,children:[t.jsx("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),t.jsx("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]})}),t.jsx("img",{src:e,alt:"Preview",className:"max-w-full max-h-[90vh] object-contain rounded-lg",onClick:r=>r.stopPropagation()})]}),document.body)}function bJ(e=640){const[n,r]=g.useState(()=>window.innerWidth<e);return g.useEffect(()=>{const s=window.matchMedia(`(max-width: ${e-1}px)`),a=i=>r(i.matches);return s.addEventListener("change",a),r(s.matches),()=>s.removeEventListener("change",a)},[e]),n}function yJ({content:e,contentRef:n}){const{t:r}=ht("common"),[s,a]=g.useState(!1),[i,l]=g.useState(!1),[c,u]=g.useState(!1),[m,f]=g.useState(null),p=g.useRef(null),b=bJ();g.useEffect(()=>{if(!s)return;const C=k=>{p.current&&!p.current.contains(k.target)&&(a(!1),l(!1),u(!1))};return document.addEventListener("mousedown",C),()=>document.removeEventListener("mousedown",C)},[s]);const x=g.useCallback(C=>{f(C),setTimeout(()=>f(null),1500)},[]),v=async()=>{const C=await Ap(e);x(r(C?"markdown.copied":"markdown.failed")),a(!1)},N=async C=>{const k=n.current?.firstElementChild;if(!k)return;const j=jT(),w=aJ(j),S=await UZ(k,C,e,{fontFamily:w.fontFamily,fontSize:w.fontSize,headingScales:w.headingScales}),T=r(C==="light"?"markdown.themeLight":"markdown.themeDark");x(S.ok?S.method==="html"?r("markdown.htmlCopied",{theme:T}):r("markdown.textCopied"):r("markdown.failed")),a(!1)};return t.jsxs("div",{className:"absolute top-1 right-1 z-10 opacity-0 group-hover/md:opacity-100 transition-opacity",ref:p,children:[m&&t.jsx("div",{className:"absolute right-0 top-full mt-1 z-20 px-2 py-0.5 rounded bg-surface-elevated border border-border-default text-[10px] text-fg-secondary whitespace-nowrap shadow-lg",children:m}),t.jsx("button",{onClick:()=>a(C=>!C),className:"p-1.5 rounded-lg bg-surface-elevated/80 hover:bg-surface-overlay text-fg-secondary hover:text-fg-primary backdrop-blur-sm border border-border-default/50 transition-all",title:r("markdown.copyContent"),children:t.jsx("svg",{className:"w-3.5 h-3.5",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:t.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M8 16H6a2 2 0 01-2-2V6a2 2 0 012-2h8a2 2 0 012 2v2m-6 12h8a2 2 0 002-2v-8a2 2 0 00-2-2h-8a2 2 0 00-2 2v8a2 2 0 002 2z"})})}),s&&t.jsx("div",{className:"absolute right-0 top-full mt-1 bg-surface-elevated border border-border-default rounded-lg shadow-xl py-1 min-w-[180px]",children:c?t.jsx(iJ,{onClose:()=>u(!1)}):i?t.jsxs("div",{className:"px-3 py-2 text-[11px] text-fg-secondary space-y-2 max-w-[260px]",children:[t.jsxs("div",{className:"flex items-center justify-between mb-1",children:[t.jsx("span",{className:"font-medium text-fg-primary text-xs",children:r("markdown.infoTitle")}),t.jsx("button",{onClick:()=>l(!1),className:"text-fg-tertiary hover:text-fg-primary p-0.5",children:t.jsx("svg",{className:"w-3 h-3",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:t.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M6 18L18 6M6 6l12 12"})})})]}),t.jsxs("div",{children:[t.jsx("span",{className:"font-medium text-fg-primary",children:r("markdown.mdAbbrev")})," — ",r("markdown.infoMdDesc")]}),t.jsxs("div",{children:[t.jsx("span",{className:"font-medium text-fg-primary",children:"☀️"})," — ",r("markdown.infoHtmlLightDesc")]}),t.jsxs("div",{children:[t.jsx("span",{className:"font-medium text-fg-primary",children:"🌙"})," — ",r("markdown.infoHtmlDarkDesc")]})]}):t.jsxs(t.Fragment,{children:[t.jsxs("div",{className:"flex items-center justify-between px-3 py-1 border-b border-border-subtle mb-1",children:[t.jsx("span",{className:"text-[10px] text-fg-tertiary font-medium",children:r("markdown.copyContent")}),t.jsxs("div",{className:"flex items-center gap-1",children:[t.jsx("button",{onClick:()=>u(!0),className:"p-0.5 rounded text-fg-tertiary hover:text-fg-primary transition-colors",title:r("markdown.typographySettings"),children:t.jsxs("svg",{className:"w-3.5 h-3.5",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:[t.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M10.325 4.317c.426-1.756 2.924-1.756 3.35 0a1.724 1.724 0 002.573 1.066c1.543-.94 3.31.826 2.37 2.37a1.724 1.724 0 001.066 2.573c1.756.426 1.756 2.924 0 3.35a1.724 1.724 0 00-1.066 2.573c.94 1.543-.826 3.31-2.37 2.37a1.724 1.724 0 00-2.573 1.066c-.426 1.756-2.924 1.756-3.35 0a1.724 1.724 0 00-2.573-1.066c-1.543.94-3.31-.826-2.37-2.37a1.724 1.724 0 00-1.066-2.573c-1.756-.426-1.756-2.924 0-3.35a1.724 1.724 0 001.066-2.573c-.94-1.543.826-3.31 2.37-2.37.996.608 2.296.07 2.572-1.065z"}),t.jsx("circle",{cx:"12",cy:"12",r:"3"})]})}),t.jsx("button",{onClick:()=>l(!0),className:"p-0.5 rounded text-fg-tertiary hover:text-fg-primary transition-colors",title:r("markdown.infoTitle"),children:t.jsxs("svg",{className:"w-3.5 h-3.5",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:[t.jsx("circle",{cx:"12",cy:"12",r:"10"}),t.jsx("path",{strokeLinecap:"round",d:"M12 16v-4m0-4h.01"})]})})]})]}),t.jsxs("button",{onClick:v,className:"w-full px-3 py-2 text-left text-xs text-fg-secondary hover:bg-surface-overlay hover:text-fg-primary transition-colors flex items-center gap-2",children:[t.jsx("span",{className:"w-4 text-center text-fg-tertiary shrink-0 font-mono text-[10px]",children:r("markdown.mdAbbrev")}),r(b?"markdown.copyMdSourceShort":"markdown.copyMdSource")]}),t.jsxs("button",{onClick:()=>N("light"),className:"w-full px-3 py-2 text-left text-xs text-fg-secondary hover:bg-surface-overlay hover:text-fg-primary transition-colors flex items-center gap-2",children:[t.jsx("span",{className:"w-4 text-center shrink-0 text-[10px]",children:"☀️"}),r(b?"markdown.copyHtmlLightShort":"markdown.copyHtmlLight")]}),t.jsxs("button",{onClick:()=>N("dark"),className:"w-full px-3 py-2 text-left text-xs text-fg-secondary hover:bg-surface-overlay hover:text-fg-primary transition-colors flex items-center gap-2",children:[t.jsx("span",{className:"w-4 text-center shrink-0 text-[10px]",children:"🌙"}),r(b?"markdown.copyHtmlDarkShort":"markdown.copyHtmlDark")]})]})})]})}const fs=g.memo(function({content:n,className:r="",onMentionClick:s,knownNames:a,basePath:i}){const{thinking:l,rest:c}=lJ(n),u=g.useRef(null),[m,f]=g.useState(null),p=g.useMemo(()=>{let x=Of(c,ON);return x=Of(x,KZ),x=Of(x,GZ),x=Of(x,v=>qZ(v,a)),x},[c,a]),b=g.useMemo(()=>({...HN,img:({src:x,alt:v})=>t.jsx(gJ,{src:x??"",alt:v,onPreview:f,basePath:i},x??""),a:({href:x,children:v})=>{if(x?.startsWith(zN)){const N=decodeURIComponent(x.slice(zN.length));return t.jsx("span",{className:`text-brand-500 font-medium${s?" cursor-pointer hover:underline":""}`,onClick:s?C=>{C.preventDefault(),C.stopPropagation(),s(N,C)}:void 0,title:N,children:v})}if(x?.startsWith(FN)){const N=x.slice(FN.length),C=N.split("_")[0],k=fy[C];return t.jsxs("span",{"data-entity-link":N,className:"inline-flex items-center gap-0.5 px-1 py-0.5 rounded bg-brand-500/10 text-brand-500 text-xs font-mono cursor-pointer hover:bg-brand-500/20 transition-colors",onClick:j=>{j.preventDefault(),j.stopPropagation(),Al(N)},title:k?`${k.label}: ${N}`:N,children:[k&&t.jsx("span",{className:"text-[10px]",children:k.icon}),t.jsxs("span",{children:[N.slice(0,C.length+1+8),"…"]})]})}{const N=x?.match(/^(workflow|task|requirement|project|deliverable|agent):(.+)$/);if(N){const[,C,k]=N,w={workflow:{icon:"⚙️",nav:()=>Rt.navigate(Be.WORK,{boardType:"workflows"})},task:{icon:"✅",nav:()=>Al(k)},requirement:{icon:"📋",nav:()=>Al(k)},project:{icon:"📁",nav:()=>Al(k)},deliverable:{icon:"📦",nav:()=>Al(k)},agent:{icon:"🤖",nav:()=>Al(k)}}[C];if(w)return t.jsxs("span",{className:"inline-flex items-center gap-0.5 px-1 py-0.5 rounded bg-brand-500/10 text-brand-500 text-xs font-medium cursor-pointer hover:bg-brand-500/20 transition-colors",onClick:S=>{S.preventDefault(),S.stopPropagation(),w.nav()},title:`${C}: ${k}`,children:[t.jsx("span",{className:"text-[10px]",children:w.icon}),t.jsx("span",{children:v})]})}}return t.jsx("a",{href:x,target:"_blank",rel:"noopener noreferrer",className:"text-brand-500 hover:text-brand-500 underline break-all",children:v})}}),[s,i]);return t.jsxs("div",{className:"relative group/md",children:[t.jsx(yJ,{content:n,contentRef:u}),t.jsx("div",{ref:u,children:t.jsxs("div",{className:`prose prose-sm max-w-none break-words pr-8 text-fg-secondary ${r}`,children:[l.length>0&&(()=>{const x=l.join(`
650
650
 
651
651
  `),v=x.split(`
652
652
  `)[0]??"",N=v.length>80?v.slice(0,80)+"…":v;return t.jsxs("details",{className:"mb-3 rounded-lg bg-surface-elevated/60 border border-border-default/50 overflow-hidden group/think",children:[t.jsxs("summary",{className:"cursor-pointer select-none px-3 py-2 text-xs text-fg-secondary hover:text-fg-secondary transition-colors flex items-center gap-1.5 min-w-0",children:[t.jsx("svg",{className:"w-3 h-3 shrink-0 transition-transform group-open/think:rotate-90",viewBox:"0 0 20 20",fill:"currentColor",children:t.jsx("path",{fillRule:"evenodd",d:"M7.21 14.77a.75.75 0 01.02-1.06L11.168 10 7.23 6.29a.75.75 0 111.04-1.08l4.5 4.25a.75.75 0 010 1.08l-4.5 4.25a.75.75 0 01-1.06-.02z",clipRule:"evenodd"})}),t.jsx("span",{className:"shrink-0",children:"Thinking"}),t.jsx("span",{className:"truncate text-fg-tertiary ml-1 group-open/think:hidden",children:N})]}),t.jsx("div",{className:"px-3 pb-3 border-t border-border-default/50",children:t.jsx("div",{className:"mt-2 pl-3 border-l-2 border-brand-500/40 text-xs text-fg-secondary leading-relaxed",children:t.jsx(G1,{remarkPlugins:BN,rehypePlugins:$N,components:HN,children:ON(x)})})})]})})(),t.jsx(G1,{remarkPlugins:BN,rehypePlugins:$N,components:b,children:p})]})}),m&&t.jsx(xJ,{src:m,onClose:()=>f(null)})]})},(e,n)=>e.content===n.content&&e.className===n.className&&e.basePath===n.basePath&&e.onMentionClick===n.onMentionClick&&vJ(e.knownNames,n.knownNames));function vJ(e,n){if(e===n)return!0;if(!e||!n||e.length!==n.length)return!1;for(let r=0;r<e.length;r++)if(e[r]!==n[r])return!1;return!0}const Mp=Object.freeze(Object.defineProperty({__proto__:null,MarkdownMessage:fs},Symbol.toStringTag,{value:"Module"})),wJ=1920,kJ=10*1024*1024,VN=5,NJ=.8;function jJ(e,n,r){return new Promise((s,a)=>{const i=new Image;i.onload=()=>{let{width:l,height:c}=i;if(l<=n&&c<=n){s(e);return}l>c?(c=Math.round(c*(n/l)),l=n):(l=Math.round(l*(n/c)),c=n);const u=document.createElement("canvas");u.width=l,u.height=c;const m=u.getContext("2d");if(!m){a(new Error("Failed to get canvas context"));return}m.drawImage(i,0,0,l,c),s(u.toDataURL("image/jpeg",r))},i.onerror=()=>a(new Error("Failed to load image")),i.src=e})}function SJ({candidates:e,filter:n,anchorRef:r,onSelect:s,selectedIndex:a,onIndexChange:i}){const{t:l}=ht("common"),[c,u]=g.useState(null),m=g.useRef(null),f=e.filter(p=>p.name.toLowerCase().includes(n));return g.useEffect(()=>{const p=r.current;if(!p)return;const b=p.getBoundingClientRect();u({top:b.top+window.scrollY-4,left:b.left+window.scrollX+8})},[r,n]),g.useEffect(()=>{if(!m.current||!c)return;if(m.current.getBoundingClientRect().top<8){const b=r.current;if(!b)return;const x=b.getBoundingClientRect();u({top:x.bottom+window.scrollY+4,left:c.left})}},[c,r]),g.useEffect(()=>{a>=f.length&&i(Math.max(0,f.length-1))},[f.length,a,i]),g.useEffect(()=>{if(!m.current)return;m.current.querySelector('[data-selected="true"]')?.scrollIntoView({block:"nearest"})},[a]),!c||f.length===0?null:ao.createPortal(t.jsxs("div",{ref:m,style:{position:"absolute",top:c.top,left:c.left,transform:"translateY(-100%)"},className:"w-60 bg-surface-overlay border border-border-default rounded-lg shadow-xl z-[9999] max-h-48 overflow-y-auto",children:[t.jsx("div",{className:"px-2.5 py-1.5 text-[10px] text-fg-tertiary font-medium uppercase tracking-wider border-b border-border-default",children:l("commentInput.mentionHeading")}),f.map((p,b)=>t.jsxs("button",{"data-selected":b===a,onMouseDown:x=>{x.preventDefault(),s(p)},onMouseEnter:()=>i(b),className:`w-full text-left px-3 py-2 text-xs flex items-center gap-2 transition-colors ${b===a?"bg-brand-500/15 text-brand-500":"hover:bg-surface-elevated"}`,children:[t.jsx("span",{className:`w-6 h-6 rounded-full flex items-center justify-center text-[10px] font-bold shrink-0 ${p.type==="human"?"bg-green-500/20 text-green-500":"bg-brand-500/20 text-brand-500"}`,children:p.name.slice(0,2).toUpperCase()}),t.jsxs("div",{className:"flex-1 min-w-0",children:[t.jsx("span",{className:"text-fg-primary font-medium",children:p.name}),t.jsx("span",{className:"text-fg-tertiary text-[10px] ml-1.5",children:p.subtitle??p.type})]}),p.type==="agent"&&t.jsx("span",{className:`w-1.5 h-1.5 rounded-full shrink-0 ${p.online?"bg-green-400":"bg-gray-500"}`})]},p.id))]}),document.body)}function CJ(e){return/^\w+$/.test(e)?`@${e}`:`@[${e}]`}const WN=/@\[([^\]]+)\]|@([\w\p{L}\p{N}]+)/gu;function EJ(e){const n=[];let r;for(WN.lastIndex=0;(r=WN.exec(e))!==null;)n.push(r[1]??r[2]);return n}function KN(e,n,r){const s=[];let a=0;const i=n.map(c=>c.name).sort((c,u)=>u.length-c.length);let l=0;for(;l<e.length;){const c=e.indexOf("@",l);if(c<0){s.push(t.jsx("span",{children:e.slice(l)},a++));break}if(c>l&&s.push(t.jsx("span",{children:e.slice(l,c)},a++)),e[c+1]==="["){const x=e.indexOf("]",c+2);if(x>c+2){const v=e.slice(c+2,x),N=n.find(C=>C.name.toLowerCase()===v.toLowerCase());s.push(t.jsxs("span",{className:`text-brand-500 font-medium ${r&&N?"cursor-pointer hover:underline":""}`,onClick:r&&N?C=>r(N,C):void 0,title:N?`${N.name} (${N.role})`:void 0,children:["@",v]},a++)),l=x+1;continue}}const u=e.slice(c+1),m=u.toLowerCase(),f=i.find(x=>m.startsWith(x.toLowerCase()));if(f){const x=n.find(v=>v.name.toLowerCase()===f.toLowerCase());s.push(t.jsxs("span",{className:`text-brand-500 font-medium ${r&&x?"cursor-pointer hover:underline":""}`,onClick:r&&x?v=>r(x,v):void 0,title:x?`${x.name} (${x.role})`:void 0,children:["@",f]},a++)),l=c+1+f.length;continue}const p=/^([\w\p{L}\p{N}]+)/u,b=u.match(p);if(b){const x=b[1],v=n.find(N=>N.name.toLowerCase()===x.toLowerCase());s.push(t.jsxs("span",{className:`text-brand-500 font-medium ${r&&v?"cursor-pointer hover:underline":""}`,onClick:r&&v?N=>r(v,N):void 0,title:v?`${v.name} (${v.role})`:void 0,children:["@",x]},a++)),l=c+1+x.length;continue}s.push(t.jsx("span",{children:"@"},a++)),l=c+1}return s.length>0?s:[t.jsx("span",{children:e},0)]}function ST({agents:e,humans:n,onSubmit:r,placeholder:s,replyTo:a,onCancelReply:i}){const{t:l}=ht("common"),[c,u]=g.useState(""),[m,f]=g.useState(!1),[p,b]=g.useState(null),[x,v]=g.useState(!1),[N,C]=g.useState(""),[k,j]=g.useState([]),[w,S]=g.useState(0),[T,R]=g.useState([]),[I,P]=g.useState(!1),L=g.useRef(null),M=g.useRef(null),$=g.useRef(null),U=g.useMemo(()=>{const ne=(n??[]).map(te=>({id:te.id,name:te.name,type:"human",subtitle:te.role}));for(const te of e)ne.push({id:te.id,name:te.name,type:"agent",subtitle:te.role,online:te.status==="idle"||te.status==="working"});return ne},[e,n]),z=U.filter(ne=>ne.name.toLowerCase().includes(N)),A=g.useCallback(ne=>{const te=Array.from(ne).filter(Y=>Y.type.startsWith("image/"));if(te.length!==0)for(const Y of te){if(Y.size>kJ)continue;const oe=new FileReader;oe.onload=()=>{const ge=oe.result;jJ(ge,wJ,NJ).then(ye=>{R(we=>we.length>=VN?we:[...we,{id:`img_${Date.now()}_${Math.random().toString(36).slice(2,6)}`,dataUrl:ye,name:Y.name}])})},oe.readAsDataURL(Y)}},[]),H=g.useCallback(ne=>{R(te=>te.filter(Y=>Y.id!==ne))},[]),D=g.useCallback(ne=>{const te=ne.clipboardData?.files;if(te&&te.length>0){const Y=Array.from(te).filter(oe=>oe.type.startsWith("image/"));Y.length>0&&(ne.preventDefault(),A(Y))}},[A]),O=g.useCallback(ne=>{ne.preventDefault(),P(!1);const te=ne.dataTransfer?.files;te&&te.length>0&&A(Array.from(te).filter(Y=>Y.type.startsWith("image/")))},[A]),q=g.useCallback(ne=>{ne.preventDefault(),P(!0)},[]),J=g.useCallback(()=>{P(!1)},[]),B=async()=>{if(!(!c.trim()&&T.length===0)){f(!0),b(null),$.current={content:c,mentions:[...k],images:[...T]};try{await r(c,k,[...T],a?.id),u(""),j([]),R([]),$.current=null,i?.()}catch(ne){b(String(ne instanceof Error?ne.message:ne)||l("commentInput.sendFailed"))}f(!1)}},V=async()=>{if(!$.current)return;const{content:ne,mentions:te,images:Y}=$.current;f(!0),b(null);try{await r(ne,te,Y),u(""),j([]),R([]),$.current=null}catch(oe){b(String(oe instanceof Error?oe.message:oe)||l("commentInput.sendFailed"))}f(!1)},X=g.useCallback(ne=>{u(te=>{const Y=te.lastIndexOf("@"),oe=CJ(ne.name);return Y>=0?te.slice(0,Y)+oe+" ":te+oe+" "}),k.includes(ne.id)||j(te=>[...te,ne.id]),v(!1),C(""),S(0),L.current?.focus()},[k]),K=ne=>{u(ne),b(null);const te=ne.lastIndexOf("@");if(te>=0&&(te===0||ne[te-1]===" ")){const oe=ne.slice(te+1).toLowerCase();if(U.some(ye=>ye.name.toLowerCase().includes(oe))){C(oe),v(!0),S(0);return}}v(!1)},ee=ne=>{if(x&&z.length>0){const te=ne.key==="ArrowUp"||ne.ctrlKey&&ne.key==="p",Y=ne.key==="ArrowDown"||ne.ctrlKey&&ne.key==="n",oe=ne.key==="Enter"||ne.key==="Tab",ge=ne.key==="Escape";if(te){ne.preventDefault(),S(ye=>(ye-1+z.length)%z.length);return}if(Y){ne.preventDefault(),S(ye=>(ye+1)%z.length);return}if(oe){ne.preventDefault();const ye=z[w];ye&&X(ye);return}if(ge){ne.preventDefault(),v(!1);return}}ne.key==="Enter"&&!ne.shiftKey&&(ne.preventDefault(),B())},Q=g.useCallback(()=>{setTimeout(()=>v(!1),200)},[]);return t.jsxs("div",{className:"relative",onDragOver:q,onDragLeave:J,onDrop:O,children:[I&&t.jsx("div",{className:"absolute inset-0 z-50 flex items-center justify-center bg-brand-500/10 rounded-lg border-2 border-dashed border-brand-500",children:t.jsx("span",{className:"text-sm text-brand-500 font-medium",children:l("commentInput.dragDropHint")})}),x&&t.jsx(SJ,{candidates:U,filter:N,anchorRef:L,onSelect:X,selectedIndex:w,onIndexChange:S}),t.jsxs("div",{className:"border border-border-default rounded-lg bg-surface-elevated",children:[a&&t.jsxs("div",{className:"flex items-center gap-2 px-2.5 pt-2 pb-1 border-b border-border-default/50",children:[t.jsxs("div",{className:"flex-1 min-w-0 pl-2 border-l-2 border-brand-500/50",children:[t.jsx("span",{className:"text-[10px] font-medium text-brand-500",children:a.authorName}),t.jsx("p",{className:"text-[10px] text-fg-tertiary truncate",children:a.content})]}),t.jsx("button",{onClick:i,className:"text-fg-tertiary hover:text-fg-secondary shrink-0 p-0.5",children:t.jsxs("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[t.jsx("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),t.jsx("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]})})]}),k.length>0&&t.jsx("div",{className:"flex gap-1 px-2.5 pt-2 flex-wrap",children:k.map(ne=>{const te=U.find(Y=>Y.id===ne);return t.jsxs("span",{className:`inline-flex items-center gap-1 px-1.5 py-0.5 text-[10px] rounded-full ${te?.type==="human"?"bg-green-500/15 text-green-500":"bg-brand-500/15 text-brand-500"}`,children:["@",te?.name??ne,t.jsx("button",{onClick:()=>j(Y=>Y.filter(oe=>oe!==ne)),className:"hover:text-red-400",children:"×"})]},ne)})}),t.jsx("textarea",{ref:L,value:c,onChange:ne=>K(ne.target.value),onKeyDown:ee,onBlur:Q,onPaste:D,placeholder:s??l("commentInput.placeholder"),rows:2,className:"w-full px-2.5 py-2 text-xs bg-transparent text-fg-primary placeholder-fg-tertiary outline-none resize-none"}),T.length>0&&t.jsx("div",{className:"flex items-center gap-1.5 px-2.5 pb-1.5 overflow-x-auto",children:T.map(ne=>t.jsxs("div",{className:"relative group/img shrink-0",children:[t.jsx("img",{src:ne.dataUrl,alt:ne.name,className:"w-12 h-12 rounded-lg object-cover border border-border-default"}),t.jsx("button",{onClick:()=>H(ne.id),className:"absolute -top-1.5 -right-1.5 w-4 h-4 bg-surface-secondary border border-gray-600 rounded-full flex items-center justify-center text-fg-secondary hover:text-red-500 hover:border-red-500 text-[10px] opacity-0 group-hover/img:opacity-100 transition-opacity",title:l("commentInput.removeImage"),children:"×"})]},ne.id))}),p&&t.jsxs("div",{className:"flex items-center gap-2 px-2.5 pb-1.5",children:[t.jsx("span",{className:"text-[11px] text-red-400 flex-1 truncate",children:p}),t.jsxs("button",{onClick:V,disabled:m,className:"text-[11px] text-amber-500 hover:text-amber-400 font-medium transition-colors flex items-center gap-1",children:[t.jsxs("svg",{className:"w-3 h-3",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[t.jsx("polyline",{points:"23 4 23 10 17 10"}),t.jsx("path",{d:"M20.49 15a9 9 0 11-2.12-9.36L23 10"})]}),l("commentInput.retry")]})]}),t.jsxs("div",{className:"flex items-center justify-between px-2.5 pb-2",children:[t.jsx("button",{type:"button",onClick:()=>M.current?.click(),disabled:m||T.length>=VN,className:"p-1 text-fg-tertiary hover:text-brand-500 disabled:opacity-30 disabled:cursor-not-allowed transition-colors",title:l("commentInput.attachImage"),children:t.jsxs("svg",{className:"w-4 h-4",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[t.jsx("rect",{x:"3",y:"3",width:"18",height:"18",rx:"2",ry:"2"}),t.jsx("circle",{cx:"8.5",cy:"8.5",r:"1.5"}),t.jsx("polyline",{points:"21 15 16 10 5 21"})]})}),t.jsx("input",{ref:M,type:"file",accept:"image/*",multiple:!0,className:"hidden",onChange:ne=>{ne.target.files&&A(ne.target.files),ne.target.value=""}}),t.jsx("button",{onClick:B,disabled:!c.trim()&&T.length===0||m,className:"px-3 py-1 text-[11px] font-medium bg-brand-500 text-white rounded-md hover:bg-brand-600 disabled:opacity-40 disabled:cursor-not-allowed transition-colors",children:l(m?"commentInput.sending":"commentInput.submit")})]})]})]})}function pc({title:e,message:n,confirmLabel:r,checkboxes:s,onConfirm:a,onCancel:i}){const{t:l}=ht("common"),[c,u]=g.useState(()=>{const m={};for(const f of s??[])m[f.id]=f.defaultChecked??!1;return m});return t.jsx("div",{className:"fixed inset-0 bg-black/60 flex items-center justify-center z-[60]",onClick:i,children:t.jsxs("div",{className:"bg-surface-secondary border border-border-default rounded-xl p-6 w-[360px] shadow-2xl",onClick:m=>m.stopPropagation(),children:[t.jsx("h3",{className:"font-semibold text-base mb-2",children:e}),t.jsx("p",{className:"text-sm text-fg-secondary mb-4 leading-relaxed",children:n}),s&&s.length>0&&t.jsx("div",{className:"mb-4 space-y-2",children:s.map(m=>t.jsxs("label",{className:"flex items-center gap-2 text-sm text-fg-secondary cursor-pointer",children:[t.jsx("input",{type:"checkbox",checked:c[m.id]??!1,onChange:f=>u(p=>({...p,[m.id]:f.target.checked})),className:"rounded bg-surface-elevated border-border-default"}),m.label]},m.id))}),t.jsxs("div",{className:"flex justify-end gap-2",children:[t.jsx("button",{onClick:i,className:"px-4 py-1.5 text-sm border border-border-default rounded-lg hover:bg-surface-elevated transition-colors",children:l("cancel")}),t.jsx("button",{onClick:()=>a(s?c:void 0),className:"px-4 py-1.5 text-sm bg-red-600 hover:bg-red-500 text-white rounded-lg transition-colors",children:r??l("confirm")})]})]})})}function I0({children:e,onClose:n,title:r,width:s="w-[440px]"}){return t.jsx("div",{className:"fixed inset-0 bg-black/60 flex items-center justify-center z-50",onClick:n,children:t.jsxs("div",{className:`bg-surface-secondary border border-border-default rounded-xl p-6 ${s} shadow-2xl max-h-[90vh] overflow-y-auto`,onClick:a=>a.stopPropagation(),children:[t.jsx("h3",{className:"text-base font-semibold mb-5",children:r}),e]})})}function Id({label:e,children:n}){return t.jsxs("div",{children:[t.jsx("label",{className:"block text-xs text-fg-secondary mb-1.5 font-medium",children:e}),n]})}function TJ({onClose:e,onCreate:n}){const{t:r}=ht(["team","common"]),[s,a]=g.useState(""),[i,l]=g.useState("");return t.jsx(I0,{onClose:e,title:r("team:modals.createTeam.title"),children:t.jsxs("div",{className:"space-y-4",children:[t.jsx(Id,{label:r("team:modals.createTeam.teamName"),children:t.jsx("input",{value:s,onChange:c=>a(c.target.value),placeholder:r("team:modals.createTeam.teamNamePlaceholder"),className:"input",autoFocus:!0,onKeyDown:c=>{c.key==="Enter"&&s.trim()&&n(s.trim(),i.trim()||void 0)}})}),t.jsx(Id,{label:r("team:modals.createTeam.description"),children:t.jsx("textarea",{value:i,onChange:c=>l(c.target.value),placeholder:r("team:modals.createTeam.descriptionPlaceholder"),className:"input",rows:2})}),t.jsx("div",{className:"text-xs text-fg-tertiary",children:r("team:modals.createTeam.hint")}),t.jsx("div",{className:"text-xs text-fg-tertiary bg-brand-500/5 border border-brand-500/20 rounded-lg px-3 py-2",children:t.jsx(N6,{i18nKey:"modals.createTeam.tipTrans",ns:"team",components:{0:t.jsx("span",{className:"text-brand-400 font-medium"}),1:t.jsx("span",{className:"text-brand-400"})}})}),t.jsxs("div",{className:"flex justify-end gap-3 pt-2",children:[t.jsx("button",{onClick:e,className:"px-4 py-2 text-sm border border-border-default rounded-lg hover:bg-surface-elevated",children:r("common:cancel")}),t.jsx("button",{onClick:()=>s.trim()&&n(s.trim(),i.trim()||void 0),disabled:!s.trim(),className:"px-4 py-2 text-sm bg-brand-600 hover:bg-brand-500 disabled:opacity-40 rounded-lg text-white",children:r("team:modals.createTeam.createTeam")})]})]})})}function AJ({onClose:e,onAdd:n}){const{t:r}=ht(["team","common"]),[s,a]=g.useState(""),[i,l]=g.useState("member"),[c,u]=g.useState(""),[m,f]=g.useState(""),[p,b]=g.useState(!1),[x,v]=g.useState(null),[N,C]=g.useState(!1),k=x?.inviteToken?`${window.location.origin}/#invite?token=${x.inviteToken}`:null,j=async()=>{if(f(""),!s.trim()){f(r("team:modals.addHuman.nameRequired"));return}if(!c.trim()){f(r("team:modals.addHuman.emailRequired"));return}if(!/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(c.trim())){f(r("team:modals.addHuman.invalidEmail"));return}b(!0);try{const S=await n(s.trim(),i,c.trim());v({...S,userName:s.trim()})}catch(S){f(S instanceof Error?S.message:String(S))}finally{b(!1)}},w=()=>{k&&(navigator.clipboard.writeText(k),C(!0),setTimeout(()=>C(!1),2e3))};return x?t.jsxs(I0,{onClose:e,title:r("team:modals.addHuman.title"),width:"w-[460px]",children:[t.jsxs("div",{className:"text-center py-4",children:[t.jsx("div",{className:"w-12 h-12 rounded-full bg-green-600/20 flex items-center justify-center mx-auto mb-3",children:t.jsx("svg",{width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",className:"text-green-500",children:t.jsx("polyline",{points:"20 6 9 17 4 12"})})}),t.jsx("div",{className:"text-base font-medium mb-1",children:r("team:modals.addHuman.memberCreated",{name:x.userName})}),k?t.jsxs(t.Fragment,{children:[t.jsx("div",{className:"text-xs text-fg-secondary mt-1 mb-4",children:r("team:modals.addHuman.inviteHint")}),t.jsxs("div",{className:"bg-surface-primary border border-border-default rounded-lg p-3 text-left mb-3",children:[t.jsx("div",{className:"text-[10px] text-fg-tertiary uppercase mb-1.5",children:r("team:modals.addHuman.inviteLink")}),t.jsx("div",{className:"text-xs text-fg-primary break-all font-mono select-all",children:k})]}),t.jsx("button",{onClick:w,className:`w-full py-2.5 text-sm font-medium rounded-lg transition-colors ${N?"bg-green-600 text-white":"bg-brand-700 hover:bg-brand-600 text-white"}`,children:r(N?"common:copied":"team:modals.addHuman.copyInviteLink")})]}):t.jsx("div",{className:"text-xs text-fg-secondary mt-1",children:r("team:modals.addHuman.memberCreatedNoInvite")})]}),t.jsx("div",{className:"flex justify-end pt-3",children:t.jsx("button",{onClick:e,className:"px-5 py-2 text-sm bg-surface-elevated hover:bg-surface-overlay rounded-lg text-fg-secondary border border-border-default",children:r("common:done")})})]}):t.jsx(I0,{onClose:e,title:r("team:modals.addHuman.title"),width:"w-[460px]",children:t.jsxs("div",{className:"space-y-4",children:[t.jsxs("div",{className:"text-xs text-fg-secondary bg-surface-primary border border-border-default rounded-lg px-3 py-2.5 leading-relaxed",children:[t.jsx("div",{className:"font-semibold text-fg-primary mb-1",children:r("team:modals.addHuman.sharedInstanceTitle")}),r("team:modals.addHuman.sharedInstanceDesc"),t.jsxs("div",{className:"mt-1.5 text-fg-tertiary",children:[r("team:modals.addHuman.orgHint")," ",t.jsx("a",{href:"#settings/organization",className:"text-brand-500 hover:text-brand-400 underline",children:r("team:modals.addHuman.orgLink")})]})]}),t.jsx(Id,{label:r("team:modals.addHuman.name"),children:t.jsx("input",{value:s,onChange:S=>a(S.target.value),placeholder:r("team:modals.addHuman.namePlaceholder"),className:"input",autoFocus:!0})}),t.jsx(Id,{label:r("team:modals.addHuman.role"),children:t.jsxs("select",{value:i,onChange:S=>l(S.target.value),className:"input",children:[t.jsx("option",{value:"owner",children:r("common:role.owner")}),t.jsx("option",{value:"admin",children:r("common:role.admin")}),t.jsx("option",{value:"member",children:r("common:role.member")}),t.jsx("option",{value:"guest",children:r("common:role.guest")})]})}),t.jsx(Id,{label:r("team:modals.addHuman.emailRequired"),children:t.jsx("input",{value:c,onChange:S=>u(S.target.value),type:"email",placeholder:r("team:modals.addHuman.emailPlaceholder"),className:"input"})}),t.jsx("div",{className:"text-xs text-fg-tertiary bg-brand-500/5 border border-brand-500/20 rounded-lg px-3 py-2",children:r("team:modals.addHuman.inviteFlowHint")}),m&&t.jsx("div",{className:"text-xs text-red-500 bg-red-500/10 border border-red-500/30 rounded-lg px-3 py-2",children:m}),t.jsxs("div",{className:"flex justify-end gap-3 pt-2",children:[t.jsx("button",{onClick:e,className:"px-4 py-2 text-sm border border-border-default rounded-lg hover:bg-surface-elevated",children:r("common:cancel")}),t.jsx("button",{onClick:j,disabled:p,className:"px-4 py-2 text-sm bg-green-700 hover:bg-green-600 disabled:opacity-50 rounded-lg text-white",children:r(p?"common:saving":"team:modals.addHuman.addMember")})]})]})})}function MJ({teamId:e,ungrouped:n,onClose:r,onAdd:s}){const{t:a}=ht(["team","common"]);return t.jsx(I0,{onClose:r,title:a("team:modals.addExisting.title"),children:t.jsxs("div",{className:"space-y-3",children:[t.jsx("div",{className:"text-xs text-fg-tertiary",children:a("team:modals.addExisting.hint")}),n.length===0?t.jsx("div",{className:"text-center py-8 text-sm text-fg-tertiary",children:a("team:modals.addExisting.allInTeam")}):t.jsx("div",{className:"space-y-2 max-h-72 overflow-y-auto",children:n.map(i=>t.jsxs("button",{onClick:()=>s(i.id,i.type),className:"w-full flex items-center gap-3 px-4 py-3 rounded-lg border border-border-default hover:border-brand-500 hover:bg-brand-500/10 text-left transition-all",children:[t.jsx("div",{className:`w-8 h-8 rounded-lg flex items-center justify-center text-xs font-bold text-white ${i.type==="agent"?"bg-brand-600":"bg-green-600"}`,children:i.name.charAt(0)}),t.jsxs("div",{className:"flex-1",children:[t.jsx("div",{className:"font-medium text-sm",children:i.name}),t.jsxs("div",{className:"text-xs text-fg-tertiary",children:[i.role," · ",i.type==="agent"?a("team:modals.addExisting.typeAgent"):a("team:modals.addExisting.typeHuman")]})]}),i.status&&t.jsx("span",{className:`w-2 h-2 rounded-full ${i.status==="idle"?"bg-green-400":i.status==="working"?"bg-blue-400":"bg-gray-600"}`})]},i.id))}),t.jsx("div",{className:"flex justify-end pt-2",children:t.jsx("button",{onClick:r,className:"px-4 py-2 text-sm border border-border-default rounded-lg hover:bg-surface-elevated",children:a("common:close")})})]})})}function _J({onClose:e,onConnected:n}){const{t:r}=ht(["team","common"]),[s,a]=g.useState(""),[i,l]=g.useState(""),[c,u]=g.useState(!1),[m,f]=g.useState(null),[p,b]=g.useState(null),x=async()=>{if(!s.trim()){l(r("team:modals.openClaw.agentNameRequired"));return}const N=s.trim().toLowerCase().replace(/\s+/g,"-");u(!0),l("");try{const C=await fetch("/api/external-agents/register",{method:"POST",headers:{"Content-Type":"application/json"},credentials:"include",body:JSON.stringify({externalAgentId:N,agentName:s.trim(),orgId:"default",capabilities:["general"]})});if(!C.ok){const j=await C.json().catch(()=>({}));throw new Error(j.error??`HTTP ${C.status}`)}const k=await C.json();f({externalAgentId:N,markusAgentId:k.registration?.markusAgentId,token:k.token,gatewayUrl:k.gatewayUrl})}catch(C){l(String(C))}u(!1)},v=(N,C)=>{navigator.clipboard.writeText(N),b(C),setTimeout(()=>b(null),2e3)};return t.jsx(I0,{onClose:e,title:r("team:modals.openClaw.title"),width:"w-[560px]",children:m?(()=>{const N=m.gatewayUrl??`${window.location.origin}/api/gateway`,C=m.token?r("team:modals.openClaw.bearerTokenLine",{token:m.token}):"",k=r("team:modals.openClaw.connectionPromptBody",{gwUrl:N,externalAgentId:m.externalAgentId,tokenSection:C});return t.jsxs(t.Fragment,{children:[t.jsxs("div",{className:"text-center py-6",children:[t.jsx("div",{className:"text-3xl mb-3 text-green-600",children:"✓"}),t.jsx("div",{className:"text-base text-green-600 font-medium mb-1",children:r("team:modals.openClaw.agentRegistered")}),t.jsx("div",{className:"text-sm text-fg-secondary mt-1",children:t.jsx("strong",{children:s})})]}),t.jsxs("div",{className:"bg-brand-500/10 border border-brand-500/30 rounded-xl p-4",children:[t.jsx("div",{className:"text-xs text-fg-secondary mb-3",children:r("team:modals.openClaw.copyInstruction")}),t.jsx("button",{onClick:()=>v(k,"prompt"),className:`w-full py-2.5 text-sm font-medium rounded-lg transition-colors ${p==="prompt"?"bg-green-600 text-white":"bg-brand-700 hover:bg-brand-600 text-white"}`,children:r(p==="prompt"?"common:copied":"team:modals.openClaw.copyPrompt")})]}),t.jsx("div",{className:"flex justify-end pt-5",children:t.jsx("button",{onClick:()=>{n()},className:"px-5 py-2 text-sm bg-surface-elevated hover:bg-surface-overlay rounded-lg text-fg-secondary border border-border-default",children:r("team:modals.openClaw.done")})})]})})():t.jsxs(t.Fragment,{children:[t.jsx("div",{className:"text-xs text-fg-secondary mb-4",children:r("team:modals.openClaw.description")}),t.jsxs("div",{className:"space-y-4",children:[t.jsx(Id,{label:r("team:modals.openClaw.agentName"),children:t.jsx("input",{className:"input",placeholder:r("team:modals.openClaw.agentNamePlaceholder"),value:s,onChange:N=>a(N.target.value),autoFocus:!0})}),i&&t.jsx("div",{className:"text-xs text-red-500 bg-red-500/10 border border-red-500/30 rounded-lg px-3 py-2",children:i}),t.jsxs("div",{className:"flex justify-end gap-3 pt-2",children:[t.jsx("button",{onClick:e,className:"px-4 py-2 text-sm border border-border-default rounded-lg hover:bg-surface-elevated",children:r("common:cancel")}),t.jsx("button",{onClick:x,disabled:c,className:"px-4 py-2 text-sm bg-brand-700 hover:bg-brand-600 rounded-lg text-white disabled:opacity-50",children:r(c?"team:modals.openClaw.connecting":"team:modals.openClaw.importAgent")})]})]})]})})}let Ib=new Map;function RJ({agents:e,humans:n,authUser:r,onClose:s,onCreate:a}){const{t:i}=ht(["team","common"]),[l,c]=g.useState(""),[u,m]=g.useState(new Set),[f,p]=g.useState(""),[b,x]=g.useState(!1),v=g.useMemo(()=>{const j=[];for(const w of e)j.push({id:w.id,name:w.name,type:"agent",subtitle:w.role||"Agent"});for(const w of n)w.id!==r?.id&&j.push({id:w.id,name:w.name,type:"human",subtitle:w.email||w.role||"Human"});return j},[e,n,r]),N=g.useMemo(()=>{if(!f)return v;const j=f.toLowerCase();return v.filter(w=>w.name.toLowerCase().includes(j)||w.subtitle.toLowerCase().includes(j))},[v,f]),C=j=>{m(w=>{const S=new Set(w);return S.has(j)?S.delete(j):S.add(j),S})},k=async()=>{if(!l.trim()||u.size===0)return;x(!0);const j=[...u],w={},S={};for(const T of j){const R=v.find(I=>I.id===T);R&&(w[T]=R.type,S[T]=R.name)}await a(l.trim(),j,w,S),x(!1)};return t.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50",onClick:s,children:t.jsxs("div",{className:"bg-surface-elevated rounded-xl border border-border-default shadow-2xl w-[400px] max-w-[90vw] max-h-[80vh] flex flex-col",onClick:j=>j.stopPropagation(),children:[t.jsxs("div",{className:"px-5 py-4 border-b border-border-default",children:[t.jsx("h3",{className:"text-sm font-semibold",children:i("modals.createGroupChat.title")}),t.jsx("p",{className:"text-[11px] text-fg-tertiary mt-0.5",children:i("modals.createGroupChat.subtitle")})]}),t.jsx("div",{className:"px-5 py-3 border-b border-border-default",children:t.jsx("input",{value:l,onChange:j=>c(j.target.value),placeholder:i("modals.createGroupChat.groupNamePlaceholder"),className:"w-full bg-surface-primary border border-border-default rounded-lg px-3 py-2 text-sm text-fg-primary placeholder:text-fg-muted outline-none focus:ring-1 focus:ring-brand-500/50",autoFocus:!0})}),t.jsx("div",{className:"px-5 py-2 border-b border-border-default",children:t.jsx("input",{value:f,onChange:j=>p(j.target.value),placeholder:i("modals.createGroupChat.searchPlaceholder"),className:"w-full bg-surface-primary border border-border-default rounded-lg px-3 py-1.5 text-xs text-fg-primary placeholder:text-fg-muted outline-none focus:ring-1 focus:ring-brand-500/50"})}),t.jsxs("div",{className:"flex-1 overflow-y-auto px-3 py-2 min-h-0 max-h-[300px]",children:[N.length===0&&t.jsx("p",{className:"text-xs text-fg-tertiary px-2 py-4 text-center",children:i("modals.createGroupChat.noMembersFound")}),N.map(j=>t.jsxs("button",{onClick:()=>C(j.id),className:`w-full flex items-center gap-2.5 px-2 py-1.5 rounded-lg text-xs mb-0.5 transition-colors ${u.has(j.id)?"bg-brand-500/10 text-brand-500":"text-fg-secondary hover:bg-surface-overlay"}`,children:[t.jsx("div",{className:`w-4 h-4 rounded border flex items-center justify-center shrink-0 transition-colors ${u.has(j.id)?"bg-brand-500 border-brand-500":"border-border-default"}`,children:u.has(j.id)&&t.jsx("svg",{width:"10",height:"10",viewBox:"0 0 24 24",fill:"none",stroke:"white",strokeWidth:"3",strokeLinecap:"round",strokeLinejoin:"round",children:t.jsx("polyline",{points:"20 6 9 17 4 12"})})}),t.jsx(_r,{name:j.name,size:20,bgClass:j.type==="agent"?"bg-brand-500/15 text-brand-500":"bg-green-500/15 text-green-600"}),t.jsxs("div",{className:"flex-1 min-w-0 text-left",children:[t.jsx("span",{className:"truncate text-[11px] font-medium block",children:j.name}),t.jsx("span",{className:"text-[9px] text-fg-tertiary",children:j.subtitle})]}),t.jsx("span",{className:`text-[8px] px-1.5 py-0.5 rounded-full font-medium ${j.type==="agent"?"bg-brand-500/10 text-brand-500":"bg-green-500/10 text-green-600"}`,children:j.type==="agent"?i("modals.addExisting.typeAgent"):i("modals.addExisting.typeHuman")})]},j.id))]}),t.jsxs("div",{className:"px-5 py-3 border-t border-border-default flex items-center justify-between",children:[t.jsx("span",{className:"text-[10px] text-fg-tertiary",children:i("modals.createGroupChat.selected",{count:u.size})}),t.jsxs("div",{className:"flex gap-2",children:[t.jsx("button",{onClick:s,className:"px-3 py-1.5 text-xs text-fg-secondary hover:text-fg-primary rounded-lg hover:bg-surface-overlay transition-colors",children:i("common:cancel")}),t.jsx("button",{onClick:k,disabled:!l.trim()||u.size===0||b,className:"px-4 py-1.5 text-xs font-medium text-white bg-brand-600 hover:bg-brand-500 rounded-lg transition-colors disabled:opacity-50 disabled:pointer-events-none",children:i(b?"modals.createGroupChat.creating":"modals.createGroupChat.create")})]})]})]})})}function IJ({authUser:e,agents:n,teams:r,humans:s,tasks:a,externalAgents:i,groupChats:l,chatMode:c,selectedAgent:u,activeChannel:m,activeDmUserId:f,onSelectAgent:p,onSelectChannel:b,onSelectDm:x,onSelectTeam:v,selectedTeamId:N,onRefreshTeams:C,onRefreshAgents:k,onRefreshHumans:j,onRefreshGroupChats:w,onViewProfile:S,onManageGroupMembers:T,unreadByAgent:R,unreadByChannel:I,width:P,onResizeStart:L,hidden:M,onCollapse:$,initialLoading:U,previewMode:z}){const{t:A}=ht(["team","common"]),H=ea(),D=Zd(Be.TEAM),O=e?.role==="owner"||e?.role==="admin",q=g.useMemo(()=>new Set(i.map(pe=>pe.markusAgentId).filter(Boolean)),[i]),[J,B]=g.useState([]),[V,X]=g.useState(new Set),[K,ee]=g.useState(!1),[Q,ne]=g.useState(!1),[te,Y]=g.useState(null),[oe,ge]=g.useState(!1),[ye,we]=g.useState(!1),[Ce,ie]=g.useState(null),[Te,ue]=g.useState(null),[Le,$e]=g.useState(null),[je,Ee]=g.useState(null),[We,Ve]=g.useState(null),[de,ve]=g.useState(null),[Ne,W]=g.useState(!1),re=g.useRef(null),[Ae,xe]=g.useState(null),tt=g.useRef(null),vt=g.useRef(null),[xt,Me]=g.useState(null),Ke=(pe,Ye="success")=>{Me({message:pe,type:Ye}),setTimeout(()=>Me(null),3e3)},[Re,qe]=g.useState(null),[ct,Bt]=g.useState(!1),gt=g.useRef(!1);g.useEffect(()=>{if(z)return;ae.governance.getSystemStatus().then(lt=>{gt.current=!0,qe(lt.globalPaused)}).catch(()=>{gt.current=!0,qe(!1)});const pe=Tn.on("system:pause-all",()=>{gt.current&&qe(!0)}),Ye=Tn.on("system:resume-all",()=>{gt.current&&qe(!1)});return()=>{pe(),Ye()}},[]),g.useEffect(()=>{if(!z)return;const pe=setTimeout(()=>{const Ye=vt.current,lt=tt.current;Ye&&lt&&lt.scrollTo({top:Ye.offsetTop-lt.offsetTop-8,behavior:"instant"})},100);return()=>clearTimeout(pe)},[z]);const cn=g.useCallback(()=>{Re!==null&&Ct({title:A(Re?"modals.resumeAll.title":"modals.pauseAll.title"),message:A(Re?"modals.resumeAll.message":"modals.pauseAll.message"),confirmLabel:A(Re?"chat.resume":"chat.pause"),onConfirm:async()=>{Bt(!0);try{Re?(await ae.governance.resumeAll(),qe(!1)):(await ae.governance.pauseAll(),qe(!0))}catch{}Bt(!1)}})},[Re]),[st,Ct]=g.useState(null),en=(pe,Ye,lt,St,Jt)=>{Ct({title:pe,message:Ye,onConfirm:lt,confirmLabel:St,checkboxes:Jt})},[be,Je]=g.useState(null),[it,It]=g.useState(null),sn=g.useRef(null),An=g.useRef(null),[Ut,Dt]=g.useState(!1),[on,Ln]=g.useState(null),[On,Wr]=g.useState(""),er=g.useCallback((pe,Ye=176,lt=480)=>{const St=pe.currentTarget.getBoundingClientRect(),Jt=window.innerWidth,gn=window.innerHeight,tr=8;let Wn=St.left,Pt=St.bottom+4;return Wn+Ye>Jt-tr&&(Wn=Math.max(tr,Jt-Ye-tr)),Pt+lt>gn-tr&&(Pt=St.top-lt-4),Pt=Math.max(tr,Pt),{x:Wn,y:Pt}},[]),[br,Mr]=g.useState(Ib),Cn=g.useMemo(()=>n.map(pe=>pe.id).sort().join(","),[n]);g.useEffect(()=>{if(!n.length||!D)return;let pe=!1;const Ye=async()=>{const tr=[];if(await Promise.allSettled(n.map(async Wn=>{try{const{sessions:Pt}=await ae.sessions.listByAgent(Wn.id,1);if(!Pt.length)return;const{messages:Pn}=await ae.sessions.getMessages(Pt[0].id,1);if(Pn.length){const kr=Pn[0],rr=kr.metadata?.segments;let Bn=kr.content;if(rr&&rr.length>0){const Kn=[...rr].reverse().find($n=>$n.type==="text");Kn&&Kn.type==="text"&&(Bn=Kn.content)}const Sr=Bn.replace(/<think>[\s\S]*?(<\/think>|$)/g,"").replace(/<(invoke|function_calls|antml:\w+)\b[\s\S]*?(<\/\1>|$)/g,"").replace(/\n+/g," ").trim().slice(0,80);Sr&&tr.push([Wn.id,Sr])}}catch{}})),!pe){const Wn=new Map(tr);Ib=Wn,Mr(Wn)}};Ye();const lt=setInterval(Ye,12e4),St=new Set(n.map(tr=>tr.id)),Jt=tr=>tr.replace(/<think>[\s\S]*?(<\/think>|$)/g,"").replace(/<(invoke|function_calls|antml:\w+)\b[\s\S]*?(<\/\1>|$)/g,"").replace(/\n+/g," ").trim().slice(0,80),gn=Tn.on("chat:proactive_message",tr=>{const Wn=tr.payload,Pt=Wn.agentId??"",Pn=Wn.message??"";if(!Pt||!Pn||!St.has(Pt))return;const kr=Jt(Pn);kr&&Mr(rr=>{const Bn=new Map(rr);return Bn.set(Pt,kr),Ib=Bn,Bn})});return()=>{pe=!0,clearInterval(lt),gn()}},[Cn,D]);const Un=g.useCallback(()=>{z||ae.teams.list().then(pe=>B(pe.ungrouped)).catch(()=>{})},[z]);g.useEffect(()=>{Un()},[Un]),g.useEffect(()=>{if(!D)return;const pe=Tn.on("team:update",Un),Ye=Tn.on("agent:removed",Un);return()=>{pe(),Ye()}},[Un,D]),g.useEffect(()=>{if(!Te&&!Le&&!je&&!Ne&&!de)return;const pe=()=>{ue(null),$e(null),Ee(null),ve(null),W(!1)},Ye=setTimeout(()=>document.addEventListener("click",pe),0);return()=>{clearTimeout(Ye),document.removeEventListener("click",pe)}},[Te,Le,je,Ne,de]);const ar=(pe,Ye)=>{en(`${A("common:delete")} "${Ye}"?`,A("modals.deleteTeam.message"),async lt=>{const St=lt?.deleteMembers??!0,Jt=lt?.purgeFiles??!1;await ae.teams.delete(pe,St,{purgeFiles:Jt}),C(),Un(),window.dispatchEvent(new CustomEvent("markus:data-changed"))},A("contextMenu.deleteTeam"),[{id:"deleteMembers",label:A("modals.deleteTeam.deleteMembers"),defaultChecked:!0},{id:"purgeFiles",label:A("modals.deleteTeam.purgeFiles"),defaultChecked:!1}])},mr=async(pe,Ye)=>{try{const St=await(Ye==="start"?ae.teams.startAll:ae.teams.stopAll)(pe),Jt=St.success?.length??0,gn=St.failed?.length??0;gn>0?Ke(A("batchAction.failed",{action:A(`batchAction.operation.${Ye}`),ok:Jt,fail:gn}),"error"):Jt>0&&Ke(A("batchAction.succeeded",{count:Jt,action:A(`batchAction.past.${Ye}`)}),"success"),k()}catch(lt){Ke(A("batchAction.failedToRun",{action:A(`batchAction.operation.${Ye}`),error:lt instanceof Error?lt.message:String(lt)}),"error")}},Kr=async(pe,Ye,lt)=>{await ae.teams.update(pe,{managerId:Ye,managerType:lt}),C()},fr=async pe=>{if(!On.trim()){Ln(null);return}await ae.teams.update(pe,{name:On.trim()}),Ln(null),C()},Zn=async(pe,Ye)=>{Ye==="offline"?await ae.agents.start(pe):await ae.agents.stop(pe),k()},ir=(pe,Ye)=>{en(A("modals.removeFromTeam.title"),A("modals.removeFromTeam.message"),async()=>{await ae.teams.removeMember(pe,Ye),C(),Un()},A("common:remove"))},hr=(pe,Ye,lt)=>{en(`${A("common:remove")} "${Ye}"?`,A(lt==="agent"?"modals.removeAgent.message":"modals.removeHuman.message"),async St=>{if(lt==="agent"){const Jt=St?.purgeFiles??!1;await ae.agents.remove(pe,{purgeFiles:Jt})}else await ae.users.remove(pe);k(),C(),j?.(),Un(),window.dispatchEvent(new CustomEvent("markus:data-changed"))},A("common:remove"),lt==="agent"?[{id:"purgeFiles",label:A("modals.removeAgent.purgeFiles"),defaultChecked:!1}]:void 0)},En=(pe,Ye,lt)=>{An.current={x:pe.clientX,y:pe.clientY},sn.current=setTimeout(()=>{Je({agentId:Ye,fromTeamId:lt}),Dt(!0)},200)},Oe=pe=>{if(!An.current||!sn.current)return;const Ye=Math.abs(pe.clientX-An.current.x),lt=Math.abs(pe.clientY-An.current.y);(Ye>5||lt>5)&&(Ut||(clearTimeout(sn.current),sn.current=null))},$t=async()=>{if(sn.current&&(clearTimeout(sn.current),sn.current=null),An.current=null,Ut&&be&&it){const pe=it==="_ungrouped"?void 0:it;try{if(be.fromTeamId&&be.fromTeamId!==pe&&await ae.teams.removeMember(be.fromTeamId,be.agentId),pe&&pe!==be.fromTeamId){const Ye=n.find(lt=>lt.id===be.agentId);await ae.teams.addMember(pe,be.agentId,"agent")}C(),k(),Un()}catch(Ye){Ke(A("batchAction.moveFailed",{error:Ye instanceof Error?Ye.message:String(Ye)}),"error")}}Je(null),It(null),Dt(!1)},jn=g.useMemo(()=>new Map(r.map(pe=>[pe.id,pe])),[r]),Wt=g.useMemo(()=>{const pe=new Map,Ye=[];for(const lt of n)if(lt.teamId&&jn.has(lt.teamId)){const St=pe.get(lt.teamId)??[];St.push(lt),pe.set(lt.teamId,St)}else Ye.push(lt);return{byTeam:pe,ungrouped:Ye}},[n,jn]),pn=(pe,Ye)=>{const lt=c==="direct"&&u===pe.id,St=q.has(pe.id),Jt=pe.status!=="error"&&!!pe.lastError&&!!pe.lastErrorAt&&Date.now()-new Date(pe.lastErrorAt).getTime()<1800*1e3,gn=pe.status==="offline",tr=pe.status==="idle"&&!Jt?"bg-green-500":pe.status==="working"&&!Jt?"bg-blue-500 animate-pulse":pe.status==="error"?"bg-red-500":Jt?"bg-amber-500":"bg-gray-600",Pt=(void 0)?.managerId===pe.id,Pn=pe.role?.toLowerCase().replace(/[-_]/g," ").trim(),kr=pe.name.toLowerCase().trim(),rr=Pn&&Pn!==kr,Bn=br.get(pe.id)||pe.currentActivity?.label?.slice(0,60)||"",Sr=pe.status==="idle"?A("common:status.online"):pe.status==="working"?A("common:status.working"):pe.status==="error"?A("common:status.error"):A("common:status.offline");return t.jsx("div",{className:`relative mb-0.5 ${Ut&&be?.agentId===pe.id?"opacity-40":""}`,onPointerDown:Kn=>En(Kn,pe.id,Ye),onPointerMove:Oe,onPointerUp:$t,children:t.jsxs("button",{onClick:()=>{Ut||p(pe.id)},onContextMenu:Kn=>{if(!O)return;Kn.preventDefault();const $n=er(Kn);$e({agentId:pe.id,teamId:Ye,...$n})},className:`w-full flex items-center gap-2.5 px-2.5 py-2 rounded-lg text-xs transition-colors select-none ${H?"":"touch-none"} ${gn?"opacity-50 text-fg-tertiary":"text-fg-primary"} ${lt?"bg-surface-overlay":"hover:bg-surface-overlay/60"}`,children:[t.jsx(_r,{name:pe.name,avatarUrl:pe.avatarUrl,size:28,bgClass:gn?"bg-surface-overlay/60 text-fg-tertiary":"bg-surface-overlay text-fg-primary"}),t.jsxs("div",{className:"flex-1 min-w-0 text-left",children:[t.jsxs("div",{className:"flex items-center gap-1",children:[t.jsx("span",{className:"truncate font-medium text-[12px] leading-tight",children:pe.name}),rr&&t.jsxs("span",{className:"text-[9px] text-fg-secondary shrink-0 truncate max-w-[80px]",children:["(",pe.role,")"]}),Pt&&t.jsx("svg",{width:"10",height:"10",viewBox:"0 0 24 24",fill:"currentColor",className:"text-amber-500 shrink-0",children:t.jsx("polygon",{points:"12 2 15.09 8.26 22 9.27 17 14.14 18.18 21.02 12 17.77 5.82 21.02 7 14.14 2 9.27 8.91 8.26 12 2"})}),St&&t.jsx("span",{className:"text-[8px] px-1 py-0 rounded bg-brand-500/20 text-brand-400 font-medium shrink-0 leading-relaxed",children:"EXT"}),gn&&t.jsx("span",{className:"text-[8px] px-1 py-0 rounded bg-gray-500/20 text-gray-400 font-medium shrink-0 leading-relaxed",children:A("common:status.offline")})]}),t.jsx("div",{className:"truncate text-[10px] leading-tight mt-0.5 text-fg-secondary",children:Bn||" "})]}),t.jsxs("span",{className:"flex items-center gap-1.5 shrink-0",children:[(R?.get(pe.id)??0)>0&&t.jsx("span",{className:"min-w-[16px] h-[16px] flex items-center justify-center text-[9px] font-semibold text-white bg-red-500 rounded-full px-1 leading-none",children:R.get(pe.id)}),pe.mailboxDepth!=null&&pe.mailboxDepth>0&&t.jsx("span",{className:"text-[8px] text-fg-tertiary bg-surface-overlay rounded-full px-1 leading-relaxed",children:pe.mailboxDepth}),t.jsx("span",{title:Sr,onClick:Kn=>{Kn.stopPropagation(),S(pe.id)},className:`w-2 h-2 rounded-full cursor-pointer transition-transform duration-150 hover:scale-[2] ${tr}`}),H&&O&&t.jsx("span",{role:"button",tabIndex:0,onClick:Kn=>{if(Kn.stopPropagation(),Le?.agentId===pe.id)$e(null);else{const $n=er(Kn);$e({agentId:pe.id,teamId:Ye,...$n})}},className:"w-5 h-5 flex items-center justify-center text-fg-tertiary hover:text-fg-secondary rounded transition-colors",title:A("chat.moreOptions"),children:t.jsxs("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[t.jsx("circle",{cx:"12",cy:"12",r:"1"}),t.jsx("circle",{cx:"12",cy:"5",r:"1"}),t.jsx("circle",{cx:"12",cy:"19",r:"1"})]})})]})]})},pe.id)},pr=(pe,Ye,lt,St)=>{const Jt=Ut&&it===pe&&be?.fromTeamId!==pe,gn=Ae===pe,tr=N===pe,Wn=R?(Wt.byTeam.get(pe)??[]).reduce((yn,Br)=>yn+(R.get(Br.id)??0),0):0,Pt=l.find(yn=>yn.type==="team"&&yn.teamId===pe),Pn=Pt&&I?I[Pt.channelKey]??0:0,kr=Wn+Pn,rr=Wt.byTeam.get(pe)??[],Bn=rr.filter(yn=>yn.status==="offline").length,Sr=rr.length,Kn=Sr>0&&Bn===Sr,$n=Bn>0&&!Kn,Gr=Kn?"bg-gray-500":$n?"bg-amber-500":"bg-green-500";return t.jsxs("div",{"data-team-id":pe,className:`mb-0.5 rounded-lg transition-all duration-500 ${Jt?"ring-1 ring-brand-500/50 bg-brand-500/5":""} ${gn?"ring-2 ring-brand-500 bg-brand-500/10":""}`,onPointerEnter:()=>{Ut&&It(pe)},onPointerLeave:()=>{Ut&&it===pe&&It(null)},children:[t.jsxs("div",{className:"group/teamhdr flex items-center gap-0.5",children:[t.jsxs("button",{onClick:()=>{v&&pe!=="_ungrouped"&&v(pe)},onContextMenu:yn=>{if(!O||!Ye)return;yn.preventDefault();const Br=er(yn);ue({teamId:pe,...Br})},className:`flex-1 flex items-center gap-2.5 px-2.5 py-2 rounded-lg text-xs transition-colors min-w-0 ${Kn?"opacity-50 text-fg-tertiary":"text-fg-primary"} ${tr?"bg-surface-overlay":"hover:bg-surface-overlay/60"}`,children:[t.jsxs("div",{className:`w-7 h-7 rounded-full flex items-center justify-center shrink-0 relative ${Kn?"bg-surface-overlay/60 text-fg-tertiary":"bg-surface-overlay text-fg-primary"}`,children:[t.jsxs("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round",children:[t.jsx("path",{d:"M17 21v-2a4 4 0 0 0-4-4H5a4 4 0 0 0-4 4v2"}),t.jsx("circle",{cx:"9",cy:"7",r:"4"}),t.jsx("path",{d:"M23 21v-2a4 4 0 0 0-3-3.87"}),t.jsx("path",{d:"M16 3.13a4 4 0 0 1 0 7.75"})]}),Sr>0&&t.jsx("span",{className:`absolute -bottom-0.5 -right-0.5 w-2.5 h-2.5 rounded-full border-2 border-surface-primary ${Gr}`})]}),t.jsxs("div",{className:"flex-1 min-w-0 text-left",children:[on===pe?t.jsx("input",{className:"bg-transparent border-b border-brand-500 text-fg-primary text-[12px] font-medium outline-none w-full",value:On,onChange:yn=>Wr(yn.target.value),onBlur:()=>fr(pe),onKeyDown:yn=>{yn.key==="Enter"&&fr(pe),yn.key==="Escape"&&Ln(null)},onClick:yn=>yn.stopPropagation(),autoFocus:!0}):t.jsx("span",{className:"truncate font-medium text-[12px] leading-tight block",children:St}),t.jsxs("div",{className:"text-[10px] text-fg-secondary leading-tight mt-0.5 flex items-center gap-1.5",children:[A("chat.members_other",{count:lt}),Kn&&t.jsx("span",{className:"text-[8px] px-1 py-0 rounded bg-gray-500/20 text-gray-400 font-medium leading-relaxed",children:A("common:status.offline")}),$n&&t.jsxs("span",{className:"text-[8px] px-1 py-0 rounded bg-amber-500/20 text-amber-500 font-medium leading-relaxed",children:[Bn,"/",Sr]})]})]}),kr>0&&t.jsx("span",{className:"min-w-[16px] h-[16px] flex items-center justify-center text-[9px] font-semibold text-white bg-red-500 rounded-full px-1 leading-none shrink-0",children:kr}),t.jsx("svg",{className:"w-3.5 h-3.5 text-fg-muted shrink-0",fill:"currentColor",viewBox:"0 0 20 20",children:t.jsx("path",{fillRule:"evenodd",d:"M7.21 14.77a.75.75 0 01.02-1.06L11.168 10 7.23 6.29a.75.75 0 111.04-1.08l4.5 4.25a.75.75 0 010 1.08l-4.5 4.25a.75.75 0 01-1.06-.02z",clipRule:"evenodd"})})]}),O&&Ye&&t.jsx("button",{onClick:yn=>{if(yn.stopPropagation(),Te?.teamId===pe)ue(null);else{const Br=er(yn);ue({teamId:pe,...Br})}},className:"w-7 h-7 flex items-center justify-center text-fg-muted hover:text-fg-primary rounded-md hover:bg-white/[0.08] transition-colors shrink-0",title:A("chat.moreOptions"),children:t.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[t.jsx("circle",{cx:"12",cy:"12",r:"1"}),t.jsx("circle",{cx:"12",cy:"5",r:"1"}),t.jsx("circle",{cx:"12",cy:"19",r:"1"})]})})]}),Jt&&Ut&&t.jsx("div",{className:"text-[9px] text-brand-500 px-4 py-0.5 animate-pulse",children:A("chat.dropHere")})]},pe)},Yt=g.useMemo(()=>{const pe=new Map,Ye=[],lt=[];for(const St of l)if(St.type==="custom")lt.push(St);else if(St.teamId){const Jt=pe.get(St.teamId)??[];Jt.push(St),pe.set(St.teamId,Jt)}else{const Jt=r.find(gn=>St.name.toLowerCase().includes(gn.name.toLowerCase())||gn.name.toLowerCase().includes(St.name.toLowerCase()));if(Jt){const gn=pe.get(Jt.id)??[];gn.push(St),pe.set(Jt.id,gn)}else Ye.push(St)}return{byTeam:pe,unmatched:Ye,custom:lt}},[l,r]);return t.jsxs(t.Fragment,{children:[t.jsxs("div",{className:`bg-surface-primary flex flex-col ${P!=null?"shrink-0":"flex-1 min-w-0"}`,style:M?{display:"none"}:P!=null?{width:P}:void 0,children:[t.jsxs("div",{className:"px-4 h-14 flex items-center shrink-0 gap-2",children:[H&&t.jsx(Ac,{}),!H&&$&&t.jsx("button",{onClick:$,className:"w-8 h-8 flex items-center justify-center rounded-lg transition-colors shrink-0 bg-brand-500/15 text-brand-500 hover:bg-brand-500/25",children:t.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[t.jsx("rect",{x:"3",y:"3",width:"18",height:"18",rx:"2",ry:"2"}),t.jsx("line",{x1:"9",y1:"3",x2:"9",y2:"21"})]})}),t.jsx("h2",{className:"text-lg font-semibold",children:A("chat.title")}),O&&t.jsxs("div",{className:"ml-auto relative",ref:re,children:[t.jsxs("button",{onClick:()=>W(!Ne),className:"flex items-center gap-1 px-2.5 py-1 text-xs font-medium text-fg-secondary hover:text-fg-primary bg-surface-elevated/60 hover:bg-surface-elevated rounded-md transition-colors",children:[t.jsx("span",{className:"text-brand-500",children:"+"})," ",A("chat.manage"),t.jsx("svg",{className:`w-2.5 h-2.5 transition-transform ${Ne?"rotate-180":""}`,fill:"currentColor",viewBox:"0 0 20 20",children:t.jsx("path",{fillRule:"evenodd",d:"M5.23 7.21a.75.75 0 011.06.02L10 11.168l3.71-3.938a.75.75 0 111.08 1.04l-4.25 4.5a.75.75 0 01-1.08 0l-4.25-4.5a.75.75 0 01.02-1.06z",clipRule:"evenodd"})})]}),Ne&&t.jsxs("div",{ref:pe=>{if(!pe)return;const Ye=pe.getBoundingClientRect(),lt=window.innerWidth,St=8;Ye.right>lt-St&&(pe.style.left="auto",pe.style.right="0"),Ye.left<St&&(pe.style.left="0",pe.style.right="auto")},className:"absolute right-0 top-full mt-1 w-48 max-w-[calc(100vw-1rem)] bg-surface-secondary border border-border-default rounded-lg shadow-xl z-30 overflow-hidden",children:[t.jsxs("button",{onClick:()=>{W(!1),ie("agent")},className:"w-full text-left px-4 py-2.5 text-xs text-fg-secondary hover:bg-surface-elevated transition-colors",children:[t.jsxs("div",{className:"font-medium flex items-center gap-1.5",children:[t.jsxs("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[t.jsx("rect",{x:"3",y:"11",width:"18",height:"10",rx:"2"}),t.jsx("circle",{cx:"12",cy:"5",r:"2"}),t.jsx("path",{d:"M12 7v4"}),t.jsx("circle",{cx:"9",cy:"16",r:"1",fill:"currentColor",stroke:"none"}),t.jsx("circle",{cx:"15",cy:"16",r:"1",fill:"currentColor",stroke:"none"})]}),A("chat.addAgent")]}),t.jsx("div",{className:"text-[10px] text-fg-tertiary mt-0.5 pl-[18px]",children:A("chat.addAgentDesc")})]}),t.jsxs("button",{onClick:()=>{W(!1),ie("team")},className:"w-full text-left px-4 py-2.5 text-xs text-fg-secondary hover:bg-surface-elevated border-t border-border-default transition-colors",children:[t.jsxs("div",{className:"font-medium flex items-center gap-1.5",children:[t.jsxs("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[t.jsx("path",{d:"M16 21v-2a4 4 0 0 0-4-4H6a4 4 0 0 0-4 4v2"}),t.jsx("circle",{cx:"9",cy:"7",r:"4"}),t.jsx("line",{x1:"19",y1:"8",x2:"19",y2:"14"}),t.jsx("line",{x1:"22",y1:"11",x2:"16",y2:"11"})]}),A("chat.newTeam")]}),t.jsx("div",{className:"text-[10px] text-fg-tertiary mt-0.5 pl-[18px]",children:A("chat.newTeamDesc")})]}),t.jsxs("button",{onClick:()=>{W(!1),ne(!0)},className:"w-full text-left px-4 py-2.5 text-xs text-green-600 hover:bg-surface-elevated border-t border-border-default transition-colors",children:[t.jsxs("div",{className:"font-medium flex items-center gap-1.5",children:[t.jsxs("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[t.jsx("path",{d:"M16 21v-2a4 4 0 0 0-4-4H6a4 4 0 0 0-4 4v2"}),t.jsx("circle",{cx:"9",cy:"7",r:"4"}),t.jsx("path",{d:"M20 8v6"}),t.jsx("path",{d:"M23 11h-6"})]}),A("chat.addHuman")]}),t.jsx("div",{className:"text-[10px] text-fg-tertiary mt-0.5 pl-[18px]",children:A("chat.addHumanDesc")})]}),t.jsxs("button",{onClick:()=>{W(!1),we(!0)},className:"w-full text-left px-4 py-2.5 text-xs text-fg-secondary hover:bg-surface-elevated border-t border-border-default transition-colors",children:[t.jsxs("div",{className:"font-medium flex items-center gap-1.5",children:[t.jsxs("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[t.jsx("path",{d:"M14 9a2 2 0 0 1-2 2H6l-4 4V4a2 2 0 0 1 2-2h8a2 2 0 0 1 2 2z"}),t.jsx("path",{d:"M18 9h2a2 2 0 0 1 2 2v11l-4-4h-6a2 2 0 0 1-2-2v-1"})]}),A("chat.newGroupChat")]}),t.jsx("div",{className:"text-[10px] text-fg-tertiary mt-0.5 pl-[18px]",children:A("chat.newGroupChatDesc")})]}),Re!==null&&t.jsxs("button",{onClick:()=>{W(!1),cn()},disabled:ct,className:`w-full text-left px-4 py-2.5 text-xs hover:bg-surface-elevated border-t border-border-default transition-colors disabled:opacity-50 ${Re?"text-green-600":"text-red-500"}`,children:[t.jsx("div",{className:"font-medium flex items-center gap-1.5",children:Re?t.jsxs(t.Fragment,{children:[t.jsx("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"currentColor",children:t.jsx("polygon",{points:"5 3 19 12 5 21 5 3"})})," ",A("chat.resume")]}):t.jsxs(t.Fragment,{children:[t.jsx("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"currentColor",children:t.jsx("rect",{x:"4",y:"4",width:"16",height:"16",rx:"2"})})," ",A("contextMenu.stopAll")]})}),t.jsx("div",{className:"text-[10px] text-fg-tertiary mt-0.5 pl-[18px]",children:A(Re?"modals.resumeAll.title":"modals.pauseAll.title")})]})]})]})]}),t.jsxs("div",{ref:tt,className:"flex-1 overflow-y-auto px-3 py-2 flex flex-col",children:[t.jsxs("div",{className:"mb-2",children:[t.jsx("p",{className:"text-[10px] font-semibold text-fg-muted uppercase tracking-wider mb-1.5 px-2.5",children:A("chat.people")}),e&&t.jsxs("button",{onClick:()=>x(e.id),className:`w-full flex items-center gap-2.5 px-2.5 py-2 rounded-lg text-xs mb-0.5 transition-colors text-fg-primary ${c==="dm"&&(f===e.id||!f)?"bg-surface-overlay":"hover:bg-surface-overlay/60"}`,children:[t.jsx(_r,{name:e.name,avatarUrl:e.avatarUrl,size:28,bgClass:"bg-brand-500/15 text-brand-400"}),t.jsxs("div",{className:"flex-1 min-w-0 text-left",children:[t.jsx("div",{className:"truncate font-medium text-[12px] leading-tight",children:e.name}),t.jsx("div",{className:"text-fg-secondary truncate text-[10px] leading-tight mt-0.5",children:A("chat.myNotes")})]}),t.jsx("span",{className:"text-fg-secondary shrink-0",children:t.jsxs("svg",{width:"10",height:"10",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[t.jsx("path",{d:"M11 4H4a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2v-7"}),t.jsx("path",{d:"M18.5 2.5a2.121 2.121 0 0 1 3 3L12 15l-4 1 1-4 9.5-9.5z"})]})})]}),s.filter(pe=>pe.id!==e?.id).map(pe=>{const Ye=e?.id?`dm:${[e.id,pe.id].sort().join(":")}`:"",lt=Ye&&I?I[Ye]??0:0;return t.jsxs("button",{onClick:()=>x(pe.id),onContextMenu:St=>{if(!O||pe.id===e?.id)return;St.preventDefault();const Jt=er(St);Ee({userId:pe.id,...Jt})},className:`w-full flex items-center gap-2.5 px-2.5 py-2 rounded-lg text-xs mb-0.5 transition-colors text-fg-primary ${c==="dm"&&f===pe.id?"bg-green-500/15":"hover:bg-surface-overlay/60"}`,children:[t.jsx(_r,{name:pe.name,avatarUrl:pe.avatarUrl,size:28,bgClass:"bg-green-500/10 text-green-500"}),t.jsxs("div",{className:"flex-1 min-w-0 text-left",children:[t.jsx("div",{className:"truncate font-medium text-[12px] leading-tight",children:pe.name}),t.jsx("div",{className:"text-fg-secondary truncate text-[10px] leading-tight mt-0.5",children:pe.email||pe.role})]}),lt>0?t.jsx("span",{className:"min-w-[16px] h-[16px] flex items-center justify-center text-[9px] font-semibold text-white bg-red-500 rounded-full px-1 leading-none shrink-0",children:lt}):t.jsx("span",{className:"w-2 h-2 rounded-full bg-green-500 shrink-0"})]},pe.id)})]}),Yt.custom.length>0&&t.jsxs("div",{className:"mb-2",children:[t.jsx("p",{className:"text-[10px] font-semibold text-fg-muted uppercase tracking-wider mb-1 px-2.5",children:A("chat.groups")}),Yt.custom.map(pe=>{const Ye=c==="channel"&&m===pe.channelKey;return t.jsxs("button",{onClick:()=>b(pe.channelKey),onContextMenu:lt=>{lt.preventDefault();const St=er(lt);ve({gcId:pe.id,...St})},className:`w-full flex items-center gap-2.5 px-2.5 py-2 rounded-lg text-xs mb-0.5 transition-colors text-fg-primary ${Ye?"bg-surface-overlay":"hover:bg-surface-overlay/60"}`,children:[t.jsx("div",{className:"w-7 h-7 rounded-lg flex items-center justify-center shrink-0 bg-surface-overlay text-fg-primary",children:t.jsx("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round",children:t.jsx("path",{d:"M21 15a2 2 0 0 1-2 2H7l-4 4V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2z"})})}),t.jsxs("div",{className:"flex-1 min-w-0 text-left",children:[t.jsx("span",{className:"truncate font-medium text-[12px] leading-tight block",children:pe.name}),t.jsx("div",{className:"text-[10px] text-fg-secondary leading-tight mt-0.5",children:A("chat.members_other",{count:pe.memberCount??0})})]})]},pe.id)})]}),U?t.jsx("div",{className:"space-y-3 px-1 mb-2",children:[...Array(6)].map((pe,Ye)=>t.jsxs("div",{className:"flex items-center gap-2.5 animate-pulse",children:[t.jsx("div",{className:"w-6 h-6 rounded-lg bg-surface-overlay shrink-0"}),t.jsxs("div",{className:"flex-1 space-y-1.5",children:[t.jsx("div",{className:"h-2.5 bg-surface-overlay rounded w-24"}),t.jsx("div",{className:"h-2 bg-surface-overlay rounded w-36"})]}),t.jsx("div",{className:"w-2 h-2 rounded-full bg-surface-overlay shrink-0"})]},Ye))}):n.length===0&&r.length===0?t.jsx("p",{className:"text-xs text-fg-tertiary px-1 mb-2",children:A("chat.noAgentsYet")}):null,Yt.unmatched.map(pe=>{const Ye=I?.[pe.channelKey]??0;return t.jsxs("button",{onClick:()=>b(pe.channelKey),className:`w-full flex items-center gap-2.5 px-2.5 py-2 rounded-lg text-xs mb-0.5 transition-colors text-fg-primary ${c==="channel"&&m===pe.channelKey?"bg-surface-overlay":"hover:bg-surface-overlay/60"}`,children:[t.jsx("div",{className:"w-7 h-7 rounded-full flex items-center justify-center shrink-0 bg-surface-overlay text-fg-primary",children:t.jsx("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round",children:t.jsx("path",{d:"M21 15a2 2 0 0 1-2 2H7l-4 4V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2z"})})}),t.jsxs("div",{className:"flex-1 min-w-0 text-left",children:[t.jsx("span",{className:"truncate font-medium text-[12px] leading-tight block",children:pe.name}),t.jsx("div",{className:"text-[10px] text-fg-secondary leading-tight mt-0.5",children:A("chat.groupChat")})]}),Ye>0?t.jsx("span",{className:"min-w-[16px] h-[16px] flex items-center justify-center text-[9px] font-semibold text-white bg-red-500 rounded-full px-1 leading-none",children:Ye}):pe.memberCount!==void 0&&pe.memberCount>0?t.jsx("span",{className:"text-[9px] text-fg-secondary shrink-0",children:pe.memberCount}):null]},pe.id)}),Wt.ungrouped.length>0&&t.jsxs("div",{className:"mb-2",children:[t.jsx("p",{className:"text-[10px] font-semibold text-fg-muted uppercase tracking-wider mb-1.5 px-2.5",children:A("chat.agents")}),Wt.ungrouped.map(pe=>pn(pe))]}),r.length>0&&t.jsxs("div",{className:"mb-2",ref:vt,children:[t.jsx("p",{className:"text-[10px] font-semibold text-fg-muted uppercase tracking-wider mb-1.5 px-2.5",children:A("chat.teams")}),r.map(pe=>{const Ye=Wt.byTeam.get(pe.id)??[],lt=pe.members?.length||Ye.length;return pr(pe.id,pe,lt,pe.name)})]}),r.length===0&&Wt.ungrouped.length===0&&n.length>0&&n.map(pe=>pn(pe))]})]}),L&&t.jsx("div",{className:"w-1.5 cursor-col-resize shrink-0 group relative flex items-center justify-center",onMouseDown:L,children:t.jsx("div",{className:"w-px h-2/3 border-l border-dashed border-transparent group-hover:border-border-default group-active:border-fg-tertiary transition-colors"})}),Te&&(()=>{const pe=Wt.byTeam.get(Te.teamId)??[],Ye=pe.some(St=>St.status==="offline"),lt=pe.some(St=>St.status!=="offline");return t.jsxs("div",{className:"fixed bg-surface-elevated border border-border-default rounded-lg shadow-xl py-1 z-50 w-44 max-w-[calc(100vw-1rem)] max-h-[calc(100vh-1rem)] overflow-y-auto",style:{left:Te.x,top:Te.y},onClick:St=>St.stopPropagation(),children:[t.jsxs("button",{onClick:()=>{const St=jn.get(Te.teamId);St&&(Ln(Te.teamId),Wr(St.name)),ue(null)},className:"w-full text-left px-3 py-2 text-xs hover:bg-surface-overlay text-fg-secondary flex items-center gap-2",children:[t.jsxs("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[t.jsx("path",{d:"M11 4H4a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2v-7"}),t.jsx("path",{d:"M18.5 2.5a2.121 2.121 0 0 1 3 3L12 15l-4 1 1-4 9.5-9.5z"})]}),A("contextMenu.renameTeam")]}),Ye&&t.jsxs("button",{onClick:()=>{mr(Te.teamId,"start"),ue(null)},className:"w-full text-left px-3 py-2 text-xs hover:bg-surface-overlay text-green-600 flex items-center gap-2",children:[t.jsx("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"currentColor",children:t.jsx("polygon",{points:"5 3 19 12 5 21 5 3"})}),A("contextMenu.startAll")]}),lt&&t.jsxs("button",{onClick:()=>{mr(Te.teamId,"stop"),ue(null)},className:"w-full text-left px-3 py-2 text-xs hover:bg-surface-overlay text-red-500 flex items-center gap-2",children:[t.jsx("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"currentColor",children:t.jsx("rect",{x:"4",y:"4",width:"16",height:"16",rx:"2"})}),A("contextMenu.stopAll")]}),t.jsx("div",{className:"border-t border-border-default/50 my-1"}),t.jsxs("button",{onClick:()=>{ue(null),Rt.navigate(Be.STORE)},className:"w-full text-left px-3 py-2 text-xs hover:bg-surface-overlay text-brand-500 flex items-center gap-2",children:[t.jsxs("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[t.jsx("line",{x1:"12",y1:"5",x2:"12",y2:"19"}),t.jsx("line",{x1:"5",y1:"12",x2:"19",y2:"12"})]}),A("chat.addAgent")]}),J.length>0&&t.jsxs("button",{onClick:()=>{ue(null),Y(Te.teamId)},className:"w-full text-left px-3 py-2 text-xs hover:bg-surface-overlay text-fg-secondary flex items-center gap-2",children:[t.jsxs("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[t.jsx("path",{d:"M16 21v-2a4 4 0 0 0-4-4H5a4 4 0 0 0-4 4v2"}),t.jsx("circle",{cx:"8.5",cy:"7",r:"4"}),t.jsx("polyline",{points:"17 11 19 13 23 9"})]}),A("contextMenu.addExisting")]}),t.jsx("div",{className:"border-t border-border-default/50 my-1"}),t.jsxs("button",{onClick:()=>{const St=jn.get(Te.teamId);St&&ar(Te.teamId,St.name),ue(null)},className:"w-full text-left px-3 py-2 text-xs hover:bg-surface-overlay text-red-500 flex items-center gap-2",children:[t.jsxs("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[t.jsx("polyline",{points:"3 6 5 6 21 6"}),t.jsx("path",{d:"M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6m3 0V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2"})]}),A("contextMenu.deleteTeam")]})]})})(),Le&&(()=>{const pe=n.find(Jt=>Jt.id===Le.agentId);if(!pe||!O)return null;const lt=(Le.teamId?jn.get(Le.teamId):void 0)?.managerId===pe.id,St=pe.id===e?.id;return t.jsxs("div",{className:"fixed bg-surface-elevated border border-border-default rounded-lg shadow-xl py-1 z-50 w-44 max-w-[calc(100vw-1rem)] max-h-[calc(100vh-1rem)] overflow-y-auto",style:{left:Le.x,top:Le.y},onClick:Jt=>Jt.stopPropagation(),children:[t.jsxs("button",{onClick:()=>{$e(null),S(pe.id)},className:"w-full text-left px-3 py-2 text-xs hover:bg-surface-overlay text-brand-500 flex items-center gap-2",children:[t.jsxs("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[t.jsx("path",{d:"M20 21v-2a4 4 0 0 0-4-4H8a4 4 0 0 0-4 4v2"}),t.jsx("circle",{cx:"12",cy:"7",r:"4"})]}),A("contextMenu.viewProfile")]}),pe.status==="offline"?t.jsxs("button",{onClick:()=>{Zn(pe.id,"offline"),$e(null)},className:"w-full text-left px-3 py-2 text-xs hover:bg-surface-overlay text-green-600 flex items-center gap-2",children:[t.jsx("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"currentColor",children:t.jsx("polygon",{points:"5 3 19 12 5 21 5 3"})}),A("contextMenu.start")]}):t.jsxs("button",{onClick:()=>{Zn(pe.id,pe.status??"idle"),$e(null)},className:"w-full text-left px-3 py-2 text-xs hover:bg-surface-overlay text-red-500 flex items-center gap-2",children:[t.jsx("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"currentColor",children:t.jsx("rect",{x:"4",y:"4",width:"16",height:"16",rx:"2"})}),A("contextMenu.stop")]}),Le.teamId&&!lt&&t.jsxs("button",{onClick:()=>{Kr(Le.teamId,pe.id,"agent"),$e(null)},className:"w-full text-left px-3 py-2 text-xs hover:bg-surface-overlay text-amber-600 flex items-center gap-2",children:[t.jsx("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"currentColor",children:t.jsx("polygon",{points:"12 2 15.09 8.26 22 9.27 17 14.14 18.18 21.02 12 17.77 5.82 21.02 7 14.14 2 9.27 8.91 8.26 12 2"})}),A("contextMenu.setAsManager")]}),Le.teamId&&t.jsxs("button",{onClick:()=>{ir(Le.teamId,pe.id),$e(null)},className:"w-full text-left px-3 py-2 text-xs hover:bg-surface-overlay text-fg-secondary flex items-center gap-2",children:[t.jsxs("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[t.jsx("polyline",{points:"9 14 4 9 9 4"}),t.jsx("path",{d:"M20 20v-7a4 4 0 0 0-4-4H4"})]}),A("contextMenu.removeFromTeam")]}),r.length>0&&t.jsxs(t.Fragment,{children:[t.jsx("div",{className:"border-t border-border-default/50 my-1"}),t.jsxs("div",{className:"px-3 py-1 text-[10px] text-fg-tertiary uppercase flex items-center gap-1.5",children:[t.jsxs("svg",{width:"10",height:"10",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[t.jsx("path",{d:"M5 12h14"}),t.jsx("path",{d:"M12 5l7 7-7 7"})]}),A("contextMenu.moveTo")]}),r.filter(Jt=>Jt.id!==Le.teamId).map(Jt=>t.jsx("button",{onClick:async()=>{Le.teamId&&await ae.teams.removeMember(Le.teamId,pe.id),await ae.teams.addMember(Jt.id,pe.id,"agent"),C(),k(),Un(),$e(null)},className:"w-full text-left px-3 py-2 text-xs hover:bg-surface-overlay text-fg-secondary pl-7",children:Jt.name},Jt.id))]}),t.jsx("div",{className:"border-t border-border-default/50 my-1"}),!St&&pe.role?.toLowerCase()!=="secretary"&&t.jsxs("button",{onClick:()=>{hr(pe.id,pe.name,"agent"),$e(null)},className:"w-full text-left px-3 py-2 text-xs hover:bg-surface-overlay text-red-500 flex items-center gap-2",children:[t.jsxs("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[t.jsx("polyline",{points:"3 6 5 6 21 6"}),t.jsx("path",{d:"M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6m3 0V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2"})]}),A("contextMenu.removeFromOrg")]})]})})(),je&&(()=>{const pe=s.find(Ye=>Ye.id===je.userId);return!pe||!O?null:t.jsx("div",{className:"fixed bg-surface-elevated border border-border-default rounded-lg shadow-xl py-1 z-50 w-44 max-w-[calc(100vw-1rem)] max-h-[calc(100vh-1rem)] overflow-y-auto",style:{left:je.x,top:je.y},onClick:Ye=>Ye.stopPropagation(),children:t.jsxs("button",{onClick:()=>{hr(pe.id,pe.name,"human"),Ee(null)},className:"w-full text-left px-3 py-2 text-xs hover:bg-surface-overlay text-red-500 flex items-center gap-2",children:[t.jsxs("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[t.jsx("polyline",{points:"3 6 5 6 21 6"}),t.jsx("path",{d:"M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6m3 0V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2"})]}),A("contextMenu.removeFromOrg")]})})})(),K&&t.jsx(TJ,{onClose:()=>ee(!1),onCreate:async(pe,Ye)=>{try{const{team:lt}=await ae.teams.create(pe,Ye);ee(!1),C(),xe(lt.id),window.dispatchEvent(new Event("markus:check-license-limits")),setTimeout(()=>{document.querySelector(`[data-team-id="${lt.id}"]`)?.scrollIntoView({behavior:"smooth",block:"center"})},300),setTimeout(()=>xe(null),3e3)}catch(lt){alert(A("chat.failedToCreateTeam",{message:lt instanceof Error?lt.message:String(lt)}))}}}),Q&&t.jsx(AJ,{onClose:()=>{ne(!1),j?.()},onAdd:async(pe,Ye,lt)=>{const{inviteToken:St}=await ae.users.create(pe,Ye,void 0,lt);return j?.(),{inviteToken:St}}}),te!==null&&t.jsx(MJ,{teamId:te,ungrouped:J,onClose:()=>Y(null),onAdd:async(pe,Ye)=>{await ae.teams.addMember(te,pe,Ye),Y(null),C(),Un()}}),oe&&t.jsx(_J,{onClose:()=>ge(!1),onConnected:()=>{ge(!1),k(),C()}}),de&&(()=>{const pe=l.find(Ye=>Ye.id===de.gcId);return pe?t.jsxs("div",{className:"fixed bg-surface-elevated border border-border-default rounded-lg shadow-xl py-1 z-50 w-44 max-w-[calc(100vw-1rem)] max-h-[calc(100vh-1rem)] overflow-y-auto",style:{left:de.x,top:de.y},onClick:Ye=>Ye.stopPropagation(),children:[pe.type==="custom"&&t.jsxs("button",{onClick:()=>{ve(null),T?T(pe.channelKey):b(pe.channelKey)},className:"w-full text-left px-3 py-2 text-xs hover:bg-surface-overlay text-fg-secondary flex items-center gap-2",children:[t.jsxs("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[t.jsx("path",{d:"M17 21v-2a4 4 0 0 0-4-4H5a4 4 0 0 0-4 4v2"}),t.jsx("circle",{cx:"9",cy:"7",r:"4"}),t.jsx("path",{d:"M23 21v-2a4 4 0 0 0-3-3.87"}),t.jsx("path",{d:"M16 3.13a4 4 0 0 1 0 7.75"})]}),A("contextMenu.manageMembers")]}),t.jsxs("button",{onClick:async()=>{ve(null),en(A("modals.deleteGroupChat.title"),A("modals.deleteGroupChat.message",{name:pe.name}),async()=>{await ae.groupChats.delete(pe.id),w()},A("modals.deleteGroupChat.confirm"))},className:"w-full text-left px-3 py-2 text-xs hover:bg-surface-overlay text-red-500 flex items-center gap-2",children:[t.jsxs("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[t.jsx("polyline",{points:"3 6 5 6 21 6"}),t.jsx("path",{d:"M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6m3 0V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2"})]}),A("modals.deleteGroupChat.menuLabel")]})]}):null})(),ye&&t.jsx(RJ,{agents:n,humans:s,authUser:e,onClose:()=>we(!1),onCreate:async(pe,Ye,lt,St)=>{await ae.groupChats.create({name:pe,memberIds:Ye,memberTypes:lt,memberNames:St,creatorId:e?.id,creatorName:e?.name}),we(!1),w()}}),Ce&&t.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50",onClick:()=>ie(null),children:t.jsxs("div",{className:"bg-surface-elevated rounded-xl border border-border-default shadow-2xl w-[340px] max-w-[90vw] overflow-hidden",onClick:pe=>pe.stopPropagation(),children:[t.jsxs("div",{className:"px-5 py-4 border-b border-border-default",children:[t.jsx("h3",{className:"text-sm font-semibold",children:A(Ce==="agent"?"chat.addAgent":"chat.newTeam")}),t.jsx("p",{className:"text-[11px] text-fg-tertiary mt-0.5",children:A("chat.methodChoiceSubtitle")})]}),t.jsxs("div",{className:"p-3 space-y-2",children:[t.jsxs("button",{onClick:()=>{const pe=Ce;ie(null);const Ye=n.find(lt=>lt.role==="secretary")??n.find(lt=>lt.name?.toLowerCase().includes("secretary"));Ye?(p(Ye.id),Rt.navigate(Be.TEAM,{agentId:Ye.id,prefillMessage:A(pe==="agent"?"chat.addAgentPrefill":"chat.newTeamPrefill")})):pe==="agent"?Rt.navigate(Be.STORE):ee(!0)},className:"w-full flex items-center gap-3 px-4 py-3 rounded-lg border border-brand-500/30 bg-brand-500/5 hover:bg-brand-500/10 transition-colors text-left",children:[t.jsx("div",{className:"w-8 h-8 rounded-full bg-brand-500/15 flex items-center justify-center shrink-0",children:t.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",className:"text-brand-500",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[t.jsx("path",{d:"M9.937 15.5A2 2 0 0 0 8.5 14.063l-6.135-1.582a.5.5 0 0 1 0-.962L8.5 9.936A2 2 0 0 0 9.937 8.5l1.582-6.135a.5.5 0 0 1 .963 0L14.063 8.5A2 2 0 0 0 15.5 9.937l6.135 1.581a.5.5 0 0 1 0 .964L15.5 14.063a2 2 0 0 0-1.437 1.437l-1.582 6.135a.5.5 0 0 1-.963 0z"}),t.jsx("path",{d:"M20 3v4"}),t.jsx("path",{d:"M22 5h-4"})]})}),t.jsxs("div",{className:"flex-1 min-w-0",children:[t.jsx("div",{className:"text-xs font-medium text-brand-500",children:A("chat.methodSecretary")}),t.jsx("div",{className:"text-[10px] text-fg-tertiary mt-0.5",children:A("chat.methodSecretaryDesc")})]}),t.jsx("span",{className:"text-[9px] px-1.5 py-0.5 rounded-full bg-brand-500/10 text-brand-500 font-medium shrink-0",children:A("chat.recommended")})]}),t.jsxs("button",{onClick:()=>{const pe=Ce;ie(null),pe==="agent"?Rt.navigate(Be.STORE):ee(!0)},className:"w-full flex items-center gap-3 px-4 py-3 rounded-lg border border-border-default hover:bg-surface-overlay transition-colors text-left",children:[t.jsx("div",{className:"w-8 h-8 rounded-full bg-surface-overlay flex items-center justify-center shrink-0",children:t.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",className:"text-fg-secondary",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[t.jsx("path",{d:"M2 12s3-7 10-7 10 7 10 7-3 7-10 7-10-7-10-7z"}),t.jsx("circle",{cx:"12",cy:"12",r:"3"})]})}),t.jsxs("div",{className:"flex-1 min-w-0",children:[t.jsx("div",{className:"text-xs font-medium text-fg-secondary",children:A("chat.methodManual")}),t.jsx("div",{className:"text-[10px] text-fg-tertiary mt-0.5",children:A(Ce==="agent"?"chat.methodManualAgentDesc":"chat.methodManualTeamDesc")})]})]})]}),t.jsx("div",{className:"px-5 py-3 border-t border-border-default flex justify-end",children:t.jsx("button",{onClick:()=>ie(null),className:"px-3 py-1.5 text-xs text-fg-secondary hover:text-fg-primary rounded-lg hover:bg-surface-overlay transition-colors",children:A("common:cancel")})})]})}),st&&t.jsx(pc,{title:st.title,message:st.message,confirmLabel:st.confirmLabel,checkboxes:st.checkboxes,onConfirm:pe=>{st.onConfirm(pe),Ct(null)},onCancel:()=>Ct(null)}),xt&&t.jsx("div",{className:`fixed bottom-6 left-1/2 -translate-x-1/2 z-50 px-4 py-2.5 rounded-lg shadow-xl text-sm font-medium ${xt.type==="error"?"bg-red-500/10 text-red-500 border border-red-500/30":"bg-surface-elevated/95 text-fg-primary border border-border-default/50"}`,children:xt.message})]})}function GN({team:e,agents:n,humans:r,authUser:s,groupChat:a,chatMode:i,selectedAgent:l,activeChannel:c,teams:u,onSelectAgent:m,onSelectChannel:f,onSelectDm:p,onBack:b,onViewProfile:x,onRefreshAgents:v,onRefreshTeams:N,unreadByAgent:C,width:k,onResizeStart:j}){const{t:w}=ht(["team","common"]),S=s?.role==="owner"||s?.role==="admin",T=g.useMemo(()=>n.filter(H=>H.teamId===e.id),[n,e.id]),R=g.useMemo(()=>{const H=new Set((e.members??[]).filter(D=>D.type==="human").map(D=>D.id));return r.filter(D=>H.has(D.id))},[e.members,r]),I=a&&i==="channel"&&c===a.channelKey,[P,L]=g.useState(null),M=g.useCallback((H,D=176,O=480)=>{const q=H.currentTarget.getBoundingClientRect(),J=window.innerWidth,B=window.innerHeight,V=8;let X=q.left,K=q.bottom+4;return X+D>J-V&&(X=Math.max(V,J-D-V)),K+O>B-V&&(K=Math.max(V,q.top-O-4)),{x:X,y:K}},[]);g.useEffect(()=>{if(!P)return;const H=()=>L(null),D=setTimeout(()=>document.addEventListener("click",H),0);return()=>{clearTimeout(D),document.removeEventListener("click",H)}},[P]);const $=g.useCallback(async(H,D)=>{D==="offline"?await ae.agents.start(H):await ae.agents.stop(H),v()},[v]),U=g.useCallback(async H=>{await ae.teams.update(e.id,{managerId:H,managerType:"agent"}),N()},[e.id,N]),z=g.useCallback(async H=>{await ae.teams.removeMember(e.id,H),N(),v()},[e.id,N,v]),A=g.useCallback(async(H,D)=>{await ae.teams.removeMember(e.id,H),await ae.teams.addMember(D,H,"agent"),N(),v()},[e.id,N,v]);return t.jsxs(t.Fragment,{children:[t.jsxs("div",{className:"bg-surface-primary flex flex-col shrink-0",style:k!=null?{width:k}:{width:260},children:[t.jsxs("div",{className:"px-3 h-14 flex items-center gap-2 shrink-0",children:[t.jsx("button",{onClick:b,className:"w-8 h-8 flex items-center justify-center rounded-lg bg-brand-500/15 text-brand-500 transition-colors shrink-0",title:w("common:back",{defaultValue:"Back"}),children:t.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[t.jsx("rect",{x:"3",y:"3",width:"18",height:"18",rx:"2",ry:"2"}),t.jsx("line",{x1:"9",y1:"3",x2:"9",y2:"21"})]})}),t.jsxs("div",{className:"flex-1 min-w-0",children:[t.jsx("div",{className:"truncate font-semibold text-sm",children:e.name}),e.description&&t.jsx("div",{className:"truncate text-[10px] text-fg-tertiary",children:e.description})]})]}),t.jsxs("div",{className:"flex-1 overflow-y-auto px-3 py-2 flex flex-col",children:[a&&t.jsxs("div",{className:"mb-3",children:[t.jsx("p",{className:"text-[10px] font-semibold text-fg-muted uppercase tracking-wider mb-1.5 px-2.5",children:w("chat.groupChat",{defaultValue:"Group Chat"})}),t.jsxs("button",{onClick:()=>f(a.channelKey),className:`w-full flex items-center gap-2.5 px-2.5 py-2 rounded-lg text-xs transition-colors text-fg-primary ${I?"bg-surface-overlay":"hover:bg-surface-overlay/60"}`,children:[t.jsx("div",{className:"w-7 h-7 rounded-lg flex items-center justify-center shrink-0 bg-surface-overlay text-fg-primary",children:t.jsx("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round",children:t.jsx("path",{d:"M21 15a2 2 0 0 1-2 2H7l-4 4V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2z"})})}),t.jsxs("div",{className:"flex-1 min-w-0 text-left",children:[t.jsx("span",{className:"truncate font-medium text-[12px] leading-tight block",children:e.name}),t.jsx("div",{className:"text-[10px] text-fg-secondary leading-tight mt-0.5",children:w("chat.members_other",{count:a.memberCount||T.length+R.length})})]})]})]}),T.length>0&&t.jsxs("div",{className:"mb-3",children:[t.jsxs("p",{className:"text-[10px] font-semibold text-fg-muted uppercase tracking-wider mb-1.5 px-2.5",children:[w("chat.agents",{defaultValue:"Agents"}),t.jsx("span",{className:"ml-1 text-fg-tertiary font-normal",children:T.length})]}),T.map(H=>{const D=i==="direct"&&l===H.id,O=e.managerId===H.id,q=H.status==="offline",J=H.status!=="error"&&!!H.lastError&&!!H.lastErrorAt&&Date.now()-new Date(H.lastErrorAt).getTime()<1800*1e3,B=H.status==="idle"&&!J?"bg-green-500":H.status==="working"&&!J?"bg-blue-500 animate-pulse":H.status==="error"?"bg-red-500":J?"bg-amber-500":"bg-gray-600";return t.jsxs("button",{onClick:()=>m(H.id),onContextMenu:V=>{if(!S)return;V.preventDefault();const X=M(V);L({agentId:H.id,...X})},className:`w-full flex items-center gap-2.5 px-2.5 py-2 rounded-lg text-xs mb-0.5 transition-colors ${q?"opacity-50 text-fg-tertiary":"text-fg-primary"} ${D?"bg-surface-overlay":"hover:bg-surface-overlay/60"}`,children:[t.jsx(_r,{name:H.name,avatarUrl:H.avatarUrl,size:28,bgClass:q?"bg-surface-overlay/60 text-fg-tertiary":"bg-surface-overlay text-fg-primary"}),t.jsxs("div",{className:"flex-1 min-w-0 text-left",children:[t.jsxs("div",{className:"flex items-center gap-1",children:[t.jsx("span",{className:"truncate font-medium text-[12px] leading-tight",children:H.name}),O&&t.jsx("svg",{width:"10",height:"10",viewBox:"0 0 24 24",fill:"currentColor",className:"text-amber-500 shrink-0",children:t.jsx("polygon",{points:"12 2 15.09 8.26 22 9.27 17 14.14 18.18 21.02 12 17.77 5.82 21.02 7 14.14 2 9.27 8.91 8.26 12 2"})}),q&&t.jsx("span",{className:"text-[8px] px-1 py-0 rounded bg-gray-500/20 text-gray-400 font-medium shrink-0 leading-relaxed",children:w("common:status.offline")})]}),t.jsx("div",{className:"truncate text-[10px] leading-tight mt-0.5 text-fg-secondary",children:H.role||" "})]}),(C?.get(H.id)??0)>0&&t.jsx("span",{className:"min-w-[16px] h-[16px] flex items-center justify-center text-[9px] font-semibold text-white bg-red-500 rounded-full px-1 leading-none shrink-0",children:C.get(H.id)}),t.jsx("span",{title:H.status,onClick:V=>{V.stopPropagation(),x(H.id)},className:`w-2 h-2 rounded-full cursor-pointer transition-transform duration-150 hover:scale-[2] shrink-0 ${B}`})]},H.id)})]}),R.length>0&&t.jsxs("div",{className:"mb-3",children:[t.jsxs("p",{className:"text-[10px] font-semibold text-fg-muted uppercase tracking-wider mb-1.5 px-2.5",children:[w("chat.people"),t.jsx("span",{className:"ml-1 text-fg-tertiary font-normal",children:R.length})]}),R.map(H=>{const D=H.id===s?.id;return t.jsxs("button",{onClick:()=>p(H.id),className:"w-full flex items-center gap-2.5 px-2.5 py-2 rounded-lg text-xs mb-0.5 transition-colors text-fg-primary hover:bg-white/[0.08]",children:[t.jsx(_r,{name:H.name,avatarUrl:H.avatarUrl,size:28,bgClass:"bg-green-500/10 text-green-500"}),t.jsxs("div",{className:"flex-1 min-w-0 text-left",children:[t.jsxs("div",{className:"truncate font-medium text-[12px] leading-tight",children:[H.name,D?` (${w("chat.you",{defaultValue:"You"})})`:""]}),t.jsx("div",{className:"text-fg-secondary truncate text-[10px] leading-tight mt-0.5",children:H.email||H.role})]}),t.jsx("span",{className:"w-2 h-2 rounded-full bg-green-500 shrink-0"})]},H.id)})]}),T.length===0&&R.length===0&&t.jsx("div",{className:"text-xs text-fg-tertiary text-center py-6 px-2",children:w("chat.noMembers",{defaultValue:"No members in this team yet."})})]})]}),j&&t.jsx("div",{className:"w-1.5 cursor-col-resize shrink-0 group relative flex items-center justify-center",onMouseDown:j,children:t.jsx("div",{className:"w-px h-2/3 border-l border-dashed border-transparent group-hover:border-border-default group-active:border-fg-tertiary transition-colors"})}),P&&(()=>{const H=T.find(O=>O.id===P.agentId);if(!H||!S)return null;const D=e.managerId===H.id;return t.jsxs("div",{className:"fixed bg-surface-elevated border border-border-default rounded-lg shadow-xl py-1 z-50 w-44 max-w-[calc(100vw-1rem)] max-h-[calc(100vh-1rem)] overflow-y-auto",style:{left:P.x,top:P.y},onClick:O=>O.stopPropagation(),children:[t.jsxs("button",{onClick:()=>{L(null),x(H.id)},className:"w-full text-left px-3 py-2 text-xs hover:bg-surface-overlay text-brand-500 flex items-center gap-2",children:[t.jsxs("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[t.jsx("path",{d:"M20 21v-2a4 4 0 0 0-4-4H8a4 4 0 0 0-4 4v2"}),t.jsx("circle",{cx:"12",cy:"7",r:"4"})]}),w("contextMenu.viewProfile")]}),H.status==="offline"?t.jsxs("button",{onClick:()=>{$(H.id,"offline"),L(null)},className:"w-full text-left px-3 py-2 text-xs hover:bg-surface-overlay text-green-600 flex items-center gap-2",children:[t.jsx("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"currentColor",children:t.jsx("polygon",{points:"5 3 19 12 5 21 5 3"})}),w("contextMenu.start")]}):t.jsxs("button",{onClick:()=>{$(H.id,H.status??"idle"),L(null)},className:"w-full text-left px-3 py-2 text-xs hover:bg-surface-overlay text-red-500 flex items-center gap-2",children:[t.jsx("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"currentColor",children:t.jsx("rect",{x:"4",y:"4",width:"16",height:"16",rx:"2"})}),w("contextMenu.stop")]}),!D&&t.jsxs("button",{onClick:()=>{U(H.id),L(null)},className:"w-full text-left px-3 py-2 text-xs hover:bg-surface-overlay text-amber-600 flex items-center gap-2",children:[t.jsx("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"currentColor",children:t.jsx("polygon",{points:"12 2 15.09 8.26 22 9.27 17 14.14 18.18 21.02 12 17.77 5.82 21.02 7 14.14 2 9.27 8.91 8.26 12 2"})}),w("contextMenu.setAsManager")]}),t.jsxs("button",{onClick:()=>{z(H.id),L(null)},className:"w-full text-left px-3 py-2 text-xs hover:bg-surface-overlay text-fg-secondary flex items-center gap-2",children:[t.jsxs("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[t.jsx("polyline",{points:"9 14 4 9 9 4"}),t.jsx("path",{d:"M20 20v-7a4 4 0 0 0-4-4H4"})]}),w("contextMenu.removeFromTeam")]}),u.filter(O=>O.id!==e.id).length>0&&t.jsxs(t.Fragment,{children:[t.jsx("div",{className:"border-t border-border-default/50 my-1"}),t.jsxs("div",{className:"px-3 py-1 text-[10px] text-fg-tertiary uppercase flex items-center gap-1.5",children:[t.jsxs("svg",{width:"10",height:"10",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[t.jsx("path",{d:"M5 12h14"}),t.jsx("path",{d:"M12 5l7 7-7 7"})]}),w("contextMenu.moveTo")]}),u.filter(O=>O.id!==e.id).map(O=>t.jsxs("button",{onClick:()=>{A(H.id,O.id),L(null)},className:"w-full text-left px-3 py-2 text-xs hover:bg-surface-overlay text-fg-secondary flex items-center gap-2",children:[t.jsxs("svg",{width:"10",height:"10",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[t.jsx("path",{d:"M17 21v-2a4 4 0 0 0-4-4H5a4 4 0 0 0-4 4v2"}),t.jsx("circle",{cx:"9",cy:"7",r:"4"}),t.jsx("path",{d:"M23 21v-2a4 4 0 0 0-3-3.87"}),t.jsx("path",{d:"M16 3.13a4 4 0 0 1 0 7.75"})]}),O.name]},O.id))]}),t.jsx("div",{className:"border-t border-border-default/50 my-1"}),t.jsxs("button",{onClick:async()=>{await ae.agents.remove(H.id),v(),L(null)},className:"w-full text-left px-3 py-2 text-xs hover:bg-surface-overlay text-red-500 flex items-center gap-2",children:[t.jsxs("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[t.jsx("polyline",{points:"3 6 5 6 21 6"}),t.jsx("path",{d:"M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6m3 0V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2"})]}),w("contextMenu.removeFromOrg")]})]})})()]})}const YN={shell_execute:{label:"Running command",icon:"⌨"},file_read:{label:"Reading file",icon:"📄"},file_write:{label:"Writing file",icon:"✏"},file_edit:{label:"Editing file",icon:"✏"},file_list:{label:"Listing files",icon:"📂"},web_fetch:{label:"Fetching page",icon:"🌐"},web_search:{label:"Searching web",icon:"🔍"},web_extract:{label:"Extracting content",icon:"📑"},create_task:{label:"Creating task",icon:"📌"},task_create:{label:"Creating task",icon:"📌"},create_subtask:{label:"Adding subtask",icon:"📌"},update_task:{label:"Updating task",icon:"✅"},task_update:{label:"Updating task",icon:"✅"},add_task_note:{label:"Adding note",icon:"📝"},task_add_note:{label:"Adding note",icon:"📝"},task_list:{label:"Listing tasks",icon:"📋"},requirement_propose:{label:"Proposing requirement",icon:"📋"},requirement_list:{label:"Listing requirements",icon:"📋"},git_status:{label:"Git status",icon:"🔀"},git_diff:{label:"Git diff",icon:"🔀"},git_log:{label:"Git log",icon:"📜"},git_branch:{label:"Git branch",icon:"🌿"},git_add:{label:"Git add",icon:"➕"},git_commit:{label:"Git commit",icon:"💾"},code_search:{label:"Searching code",icon:"🔍"},project_structure:{label:"Project structure",icon:"🗂"},code_stats:{label:"Code stats",icon:"📊"},navigate_page:{label:"Opening page",icon:"🌐"},new_page:{label:"Opening new tab",icon:"🌐"},close_page:{label:"Closing tab",icon:"🌐"},select_page:{label:"Switching tab",icon:"🌐"},list_pages:{label:"Listing tabs",icon:"🌐"},click:{label:"Clicking element",icon:"👆"},hover:{label:"Hovering element",icon:"👆"},fill:{label:"Filling field",icon:"⌨"},fill_form:{label:"Filling form",icon:"⌨"},type_text:{label:"Typing text",icon:"⌨"},press_key:{label:"Pressing key",icon:"⌨"},take_screenshot:{label:"Screenshot",icon:"📸"},take_snapshot:{label:"Page snapshot",icon:"📋"},evaluate_script:{label:"Running script",icon:"⚙"},wait_for:{label:"Waiting",icon:"⏳"},list_console_messages:{label:"Console logs",icon:"🔍"},list_network_requests:{label:"Network requests",icon:"🔍"},lighthouse_audit:{label:"Running audit",icon:"📊"},agent_send_message:{label:"Messaging colleague",icon:"💬"},agent_list:{label:"Checking team",icon:"👥"},memory_save:{label:"Saving memory",icon:"💾"},memory_search:{label:"Searching memory",icon:"🔍"},feishu_send_message:{label:"Sending Feishu msg",icon:"✉"},feishu_search_docs:{label:"Searching Feishu",icon:"🔍"},spawn_subagent:{label:"Spawn Subagent",icon:"◎"},spawn_subagents:{label:"Spawn Subagents",icon:"◎"},invoke_coding_tool:{label:"Invoke Coding Tool",icon:"🛠"},coding_tool_apply:{label:"Apply Coding Result",icon:"🔀"}};function kc(e){const n=e.includes("__")?e.split("__").pop():e;return YN[n]??YN[e]??{label:n.replace(/_/g," ").replace(/\b\w/g,r=>r.toUpperCase()),icon:"⚙"}}function Fd(e){return e==null?"":e<1e3?`${e}ms`:`${(e/1e3).toFixed(1)}s`}function DJ(e){const n=new Date(e);if(isNaN(n.getTime()))return e;const r=String(n.getMonth()+1).padStart(2,"0"),s=String(n.getDate()).padStart(2,"0"),a=String(n.getHours()).padStart(2,"0"),i=String(n.getMinutes()).padStart(2,"0"),l=String(n.getSeconds()).padStart(2,"0");return`${r}-${s} ${a}:${i}:${l}`}function hy(e,n){return e.length<=n?e:e.slice(0,n)+"…"}function XN(e){try{const n=JSON.parse(e);return JSON.stringify(n,null,2)}catch{return e}}function LJ(e){return!e||typeof e!="object"?[]:Object.entries(e).filter(([,r])=>r!=null).map(([r,s])=>({key:r,value:typeof s=="string"?s:JSON.stringify(s,null,2)}))}function OJ(e){if(e.tool!=="shell_execute"||!e.args||typeof e.args!="object")return null;const n=e.args.command;return typeof n=="string"?n:null}function QN(e,n){const r=new Map;let s=null;for(const a of e)if(a.type==="tool_start"&&(a.content==="spawn_subagent"||a.content==="spawn_subagents"))s=a.seq,r.set(a.seq,[]);else if(a.type==="tool_end"&&(a.content==="spawn_subagent"||a.content==="spawn_subagents")){if(s!==null){const i=r.get(s);i&&r.set(a.seq,i)}s=null}else if(s!==null&&a.type.startsWith("subagent_")){const i=a.type.replace("subagent_",""),l=a.metadata;r.get(s)?.push({eventType:i,content:a.content,metadata:l})}return n.map(a=>{if(a.type!=="tool")return a;const i=a.key;if(!i)return a;const l=i.replace(/^t[se]_/,""),c=parseInt(l,10);if(isNaN(c))return a;const u=r.get(c);return!u||u.length===0?a:{...a,info:{...a.info,subagentLogs:u}}})}function D0(e){const n=new Set;for(let r=0;r<e.length;r++){const s=e[r];if(s.type==="tool"&&(s.info.status==="done"||s.info.status==="error"))for(let a=r-1;a>=0;a--){const i=e[a];if(i.type==="tool"&&i.info.status==="running"&&i.info.tool===s.info.tool&&!n.has(a)){n.add(a);break}}}return e.filter((r,s)=>!n.has(s))}function L0(e){const n=DJ(e.createdAt),r=e.createdAt,s=e.metadata;switch(e.type){case"text":return s?.isThinking?{type:"thinking",content:e.content,time:n,timestamp:r}:{type:"text",content:e.content,time:n,timestamp:r};case"status":{const a=s?.action;return a&&["chat","chat_stream","task_execution","respond_in_session"].includes(a)?null:{type:"status",content:e.content,time:n,timestamp:r}}case"error":return{type:"error",content:e.content,time:n,timestamp:r};case"tool_start":return{type:"tool",time:n,timestamp:r,key:`es_${e.seq}`,info:{tool:e.content,status:"running",args:s?.arguments}};case"tool_end":return{type:"tool",time:n,timestamp:r,key:`ee_${e.seq}`,info:{tool:e.content,status:s?.success===!1?"error":"done",args:s?.arguments,result:s?.result,error:s?.error,durationMs:s?.durationMs,subagentLogs:s?.subagentLogs}};default:return null}}function CT(e,n){if(e!=="task_create"&&e!=="create_task"||!n)return null;try{const r=JSON.parse(n);if(!r.task)return null;const s=r.task;return{taskId:s.id,title:s.title,description:s.description,assignedAgentId:s.assignedAgentId,priority:s.priority}}catch{return null}}function ET(e,n){if(e!=="requirement_propose"||!n)return null;try{const r=JSON.parse(n);if(r.status!=="success"||!r.requirement)return null;const s=r.requirement;return s.status!=="pending"?null:{requirementId:s.id,title:s.title,description:s.description,priority:s.priority}}catch{return null}}const PJ={"claude-code":{label:"Claude Code",icon:"🤖",badgeClass:"bg-orange-500/15 text-orange-500"},codex:{label:"Codex",icon:"⬡",badgeClass:"bg-emerald-500/15 text-emerald-500"},"cursor-agent":{label:"Cursor",icon:"▶",badgeClass:"bg-blue-500/15 text-blue-500"}},Dd=["created","context_injected","running"],BJ=new Set(["completed","failed","cancelled","timeout"]),ZN={created:"Created",context_injected:"Context injected",running:"Running",completed:"Completed",failed:"Failed",cancelled:"Cancelled",timeout:"Timed out"};function $J(e){return PJ[e]??{label:e.replace(/-/g," ").replace(/\b\w/g,n=>n.toUpperCase()),icon:"⚙",badgeClass:"bg-surface-elevated text-fg-tertiary"}}function zJ(e,n){if(e.cost?.durationMs!=null)return e.cost.durationMs;const r=e.startedAt??e.createdAt,s=new Date(r).getTime();if(!Number.isNaN(s)){if(e.completedAt){const a=new Date(e.completedAt).getTime();return Number.isNaN(a)?void 0:Math.max(0,a-s)}if(e.status==="running"||e.status==="context_injected")return Math.max(0,n-s)}}function FJ(e){if(e==="completed"||BJ.has(e))return Dd.length;const n=Dd.indexOf(e);return n>=0?n:0}function HJ({session:e,className:n}){const r=$J(e.tool),[s,a]=g.useState(!1),[i,l]=g.useState(()=>Date.now()),c=e.status==="running"||e.status==="context_injected"||e.status==="created",u=e.status==="failed"||e.status==="timeout"||e.result?.success===!1,m=e.status==="completed"||e.result?.success===!0;g.useEffect(()=>{if(!c)return;const v=setInterval(()=>l(Date.now()),1e3);return()=>clearInterval(v)},[c]);const f=g.useMemo(()=>zJ(e,i),[e,i]),p=FJ(e.status),b=e.result?.rawOutput??(m||u?e.result?.summary:void 0),x=c?"border-brand-500/40 bg-brand-500/5":u?"border-red-500/30 bg-red-500/5":m?"border-green-500/30 bg-green-500/5":"border-border-default bg-surface-secondary/30";return t.jsxs("div",{className:`my-2 rounded-lg border ${x} p-3 max-w-2xl transition-colors ${n??""}`,children:[t.jsxs("div",{className:"flex items-start gap-2",children:[t.jsx("span",{className:"text-sm mt-0.5",children:r.icon}),t.jsxs("div",{className:"flex-1 min-w-0",children:[t.jsxs("div",{className:"flex items-center gap-1.5 flex-wrap",children:[t.jsx("span",{className:`text-[10px] px-1.5 py-0.5 rounded font-medium ${r.badgeClass}`,children:r.label}),t.jsx("span",{className:`text-[10px] font-medium ${c?"text-brand-500":u?"text-red-500":m?"text-green-500":"text-fg-tertiary"}`,children:ZN[e.status]??e.status}),f!=null&&t.jsx("span",{className:"text-[10px] text-fg-tertiary tabular-nums",children:Fd(f)}),e.cost?.estimatedCostUsd!=null&&t.jsxs("span",{className:"text-[10px] text-fg-tertiary tabular-nums",children:["$",e.cost.estimatedCostUsd.toFixed(4)]})]}),t.jsx("div",{className:"text-xs text-fg-secondary mt-1 line-clamp-2",children:e.prompt})]}),c&&t.jsxs("svg",{className:"w-3.5 h-3.5 animate-spin text-brand-500 shrink-0 mt-0.5",viewBox:"0 0 24 24",fill:"none",children:[t.jsx("circle",{className:"opacity-25",cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"4"}),t.jsx("path",{className:"opacity-75",fill:"currentColor",d:"M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4z"})]})]}),t.jsxs("div",{className:"flex items-center gap-1 mt-3 ml-6",children:[Dd.map((v,N)=>{const C=p>N||p===N&&!c&&m,k=p===N&&c,j=u&&N===Dd.length-1&&e.status!=="completed";return t.jsxs("div",{className:"flex items-center gap-1 flex-1 min-w-0",children:[t.jsx("div",{className:`w-2 h-2 rounded-full shrink-0 ${j?"bg-red-500":C?"bg-green-500":k?"bg-brand-500 animate-pulse":"bg-gray-600"}`,title:ZN[v]}),N<Dd.length-1&&t.jsx("div",{className:`h-px flex-1 ${C?"bg-green-500/50":"bg-border-default/60"}`})]},v)}),t.jsx("div",{className:`w-2 h-2 rounded-full shrink-0 ${u?"bg-red-500":m?"bg-green-500":"bg-gray-600"}`,title:u?"Failed":"Done"})]}),(e.progressMessage||e.progressPercent!=null)&&c&&t.jsxs("div",{className:"mt-2 ml-6 space-y-1",children:[e.progressPercent!=null&&t.jsx("div",{className:"h-1 bg-surface-elevated rounded-full overflow-hidden",children:t.jsx("div",{className:"h-full bg-brand-500 transition-all duration-300",style:{width:`${Math.min(100,Math.max(0,e.progressPercent))}%`}})}),e.progressMessage&&t.jsx("div",{className:"text-[11px] text-fg-tertiary font-mono truncate",children:e.progressMessage})]}),e.result&&!c&&t.jsxs("div",{className:"mt-2 ml-6 space-y-1.5",children:[e.result.summary&&t.jsx("div",{className:"text-xs text-fg-secondary",children:e.result.summary}),e.result.diffStats&&t.jsxs("div",{className:"flex items-center gap-3 text-[10px] font-mono",children:[t.jsxs("span",{className:"text-fg-tertiary",children:[e.result.diffStats.filesChanged," files"]}),t.jsxs("span",{className:"text-green-500",children:["+",e.result.diffStats.additions]}),t.jsxs("span",{className:"text-red-500",children:["−",e.result.diffStats.deletions]})]}),e.cost&&(e.cost.inputTokens!=null||e.cost.outputTokens!=null)&&t.jsxs("div",{className:"text-[10px] text-fg-tertiary",children:[e.cost.inputTokens!=null&&t.jsxs("span",{children:[e.cost.inputTokens.toLocaleString()," in"]}),e.cost.inputTokens!=null&&e.cost.outputTokens!=null&&t.jsx("span",{className:"mx-1",children:"·"}),e.cost.outputTokens!=null&&t.jsxs("span",{children:[e.cost.outputTokens.toLocaleString()," out"]})]})]}),b&&t.jsxs("div",{className:"mt-2 ml-6 border-t border-border-default/30 pt-2",children:[t.jsxs("button",{type:"button",onClick:()=>a(!s),className:"flex items-center gap-1.5 text-[10px] text-fg-tertiary hover:text-fg-secondary transition-colors",children:[t.jsx("svg",{className:`w-3 h-3 transition-transform ${s?"rotate-90":""}`,fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:t.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M9 5l7 7-7 7"})}),t.jsx("span",{className:"font-medium uppercase tracking-wider",children:"Raw output"})]}),s&&t.jsx("pre",{className:"mt-2 text-[11px] text-fg-tertiary bg-surface-elevated/70 rounded-lg px-3 py-2 overflow-x-auto max-h-48 overflow-y-auto whitespace-pre-wrap break-all font-mono",children:b})]})]})}function py({label:e}){const{t:n}=ht("common");return t.jsxs("div",{className:"flex items-center gap-1.5 text-xs text-fg-secondary py-0.5",children:[t.jsx("span",{children:e??n("execution.thinking")}),t.jsx("span",{className:"flex gap-0.5",children:[0,150,300].map(r=>t.jsx("span",{className:"w-1 h-1 rounded-full bg-brand-400 animate-bounce",style:{animationDelay:`${r}ms`,animationDuration:"1s"}},r))})]})}const JN=150;function gy({content:e,className:n}){const[r,s]=g.useState(e),a=g.useRef(0),i=g.useRef(null);g.useEffect(()=>{const c=Date.now(),u=c-a.current;return u>=JN?(a.current=c,s(e)):i.current||(i.current=setTimeout(()=>{a.current=Date.now(),i.current=null,s(e)},JN-u)),()=>{i.current&&(clearTimeout(i.current),i.current=null)}},[e]);const l=g.useMemo(()=>r,[r]);return t.jsxs("div",{className:"bg-surface-elevated/50 rounded-lg px-3 py-2.5 my-1 min-w-0 overflow-hidden",children:[t.jsx(fs,{content:l,className:n??"text-sm text-fg-secondary break-words"}),t.jsx("span",{className:"inline-block w-0.5 h-4 bg-brand-400 animate-pulse ml-0.5 align-middle"})]})}function UJ({info:e,onClose:n}){const{t:r}=ht("common"),s=kc(e.tool),a=LJ(e.args),i=e.status==="running",l=e.status!=="error";return g.useEffect(()=>{const c=u=>{u.key==="Escape"&&n()};return document.addEventListener("keydown",c),()=>document.removeEventListener("keydown",c)},[n]),t.jsxs("div",{className:"fixed inset-0 z-[60] flex items-center justify-center",onClick:n,children:[t.jsx("div",{className:"absolute inset-0 bg-black/60"}),t.jsxs("div",{className:"relative bg-surface-secondary border border-border-default rounded-xl shadow-2xl w-[560px] max-w-[92vw] max-h-[80vh] overflow-hidden flex flex-col",onClick:c=>c.stopPropagation(),children:[t.jsxs("div",{className:"px-5 py-3 border-b border-border-default flex items-center justify-between shrink-0",children:[t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx("span",{className:"opacity-60 text-sm",children:s.icon}),t.jsx("span",{className:`text-sm font-semibold ${i?"text-brand-500":l?"text-fg-primary":"text-red-500"}`,children:s.label}),t.jsx("span",{className:`text-xs px-1.5 py-0.5 rounded ${i?"bg-brand-500/15 text-brand-500":l?"bg-green-500/15 text-green-600":"bg-red-500/15 text-red-500"}`,children:r(i?"execution.toolRunning":l?"execution.toolSuccess":"execution.toolFailed")})]}),t.jsxs("div",{className:"flex items-center gap-3",children:[e.durationMs!=null&&t.jsx("span",{className:"text-xs text-fg-tertiary",children:Fd(e.durationMs)}),t.jsx("button",{onClick:n,className:"text-fg-tertiary hover:text-fg-secondary text-lg leading-none",children:"×"})]})]}),t.jsxs("div",{className:"flex-1 overflow-y-auto px-5 py-4 space-y-4",children:[a.length>0&&t.jsxs("div",{children:[t.jsx("h4",{className:"text-[10px] font-semibold text-fg-tertiary uppercase tracking-wider mb-2",children:r("execution.arguments")}),t.jsx("div",{className:"space-y-2",children:a.map(({key:c,value:u})=>t.jsxs("div",{children:[t.jsx("div",{className:"text-[11px] text-brand-500 font-medium mb-0.5",children:c}),t.jsx("pre",{className:"text-xs text-fg-secondary bg-surface-elevated/70 rounded-lg px-3 py-2 overflow-x-auto max-h-80 overflow-y-auto whitespace-pre-wrap break-all font-mono",children:u})]},c))})]}),!i&&e.result&&t.jsxs("div",{children:[t.jsx("h4",{className:"text-[10px] font-semibold text-fg-tertiary uppercase tracking-wider mb-2",children:r("execution.result")}),t.jsx("pre",{className:"text-xs text-fg-secondary bg-surface-elevated/70 rounded-lg px-3 py-2 overflow-x-auto overflow-y-auto max-h-[60vh] whitespace-pre-wrap break-all font-mono",children:XN(e.result)})]}),!i&&e.error&&t.jsxs("div",{children:[t.jsx("h4",{className:"text-[10px] font-semibold text-red-500 uppercase tracking-wider mb-2",children:r("execution.error")}),t.jsx("pre",{className:"text-xs text-red-500 bg-red-500/10 border border-red-500/20 rounded-lg px-3 py-2 overflow-x-auto max-h-60 overflow-y-auto whitespace-pre-wrap break-all font-mono",children:XN(String(e.error))})]}),e.subagentLogs&&e.subagentLogs.length>0&&t.jsxs("div",{children:[t.jsx("h4",{className:"text-[10px] font-semibold text-fg-tertiary uppercase tracking-wider mb-2",children:r("execution.subagentExecution")}),t.jsx("div",{className:"bg-surface-elevated/50 rounded-lg px-3 py-2 space-y-1 max-h-[50vh] overflow-y-auto",children:e.subagentLogs.map((c,u)=>{const m=c.eventType==="started"?"▶":c.eventType==="completed"?"✓":c.eventType==="error"?"✗":c.eventType==="tool_start"?"◎":c.eventType==="tool_end"?"●":c.eventType==="thinking"?"💭":"→",f=c.eventType==="error"?"text-red-500":c.eventType==="completed"?"text-green-500":c.eventType==="started"?"text-brand-500":"text-fg-tertiary";return t.jsxs("div",{className:"flex items-start gap-1.5 text-xs",children:[t.jsx("span",{className:`shrink-0 ${f}`,children:m}),t.jsx("span",{className:`font-mono break-all ${f}`,children:c.content})]},u)})})]}),!a.length&&!i&&!e.result&&!e.error&&!e.subagentLogs?.length&&t.jsx("div",{className:"text-sm text-fg-tertiary italic py-4 text-center",children:r("execution.noToolDetail")})]})]})]})}const TT={urgent:"text-red-500",high:"text-amber-500",medium:"text-blue-500",low:"text-fg-tertiary"},ej={pending:"pending",in_progress:"in_progress",completed:"completed",review:"review",blocked:"blocked",failed:"failed",cancelled:"cancelled",archived:"archived"},tj={pending:{icon:"⏳",labelKey:"execution.card.pendingApproval",borderClass:"border-amber-500/40",bgClass:"bg-amber-500/5",badgeClass:"bg-amber-500/15 text-amber-600",textClass:""},approving:{icon:"⏳",labelKey:"execution.card.approving",borderClass:"border-amber-500/40",bgClass:"bg-amber-500/5",badgeClass:"bg-amber-500/15 text-amber-600",textClass:""},rejecting:{icon:"⏳",labelKey:"execution.card.rejecting",borderClass:"border-amber-500/40",bgClass:"bg-amber-500/5",badgeClass:"bg-amber-500/15 text-amber-600",textClass:""},in_progress:{icon:"▶",labelKey:"execution.card.inProgress",borderClass:"border-blue-500/40",bgClass:"bg-blue-500/5",badgeClass:"bg-blue-500/15 text-blue-500",textClass:"text-blue-500"},completed:{icon:"✅",labelKey:"execution.card.completed",borderClass:"border-green-500/30",bgClass:"bg-green-500/5",badgeClass:"bg-green-500/15 text-green-500",textClass:"text-green-500"},review:{icon:"👀",labelKey:"execution.card.inReview",borderClass:"border-purple-500/40",bgClass:"bg-purple-500/5",badgeClass:"bg-purple-500/15 text-purple-500",textClass:"text-purple-500"},blocked:{icon:"🚫",labelKey:"execution.card.blocked",borderClass:"border-orange-500/40",bgClass:"bg-orange-500/5",badgeClass:"bg-orange-500/15 text-orange-500",textClass:"text-orange-500"},failed:{icon:"❌",labelKey:"execution.card.failed",borderClass:"border-red-500/30",bgClass:"bg-red-500/5",badgeClass:"bg-red-500/15 text-red-500",textClass:"text-red-500"},cancelled:{icon:"⊘",labelKey:"execution.card.cancelled",borderClass:"border-border-default/40",bgClass:"bg-surface-secondary/30",badgeClass:"bg-surface-elevated text-fg-tertiary",textClass:"text-fg-tertiary"},archived:{icon:"📦",labelKey:"execution.card.archived",borderClass:"border-border-default/40",bgClass:"bg-surface-secondary/30",badgeClass:"bg-surface-elevated text-fg-tertiary",textClass:"text-fg-tertiary"},loading:{icon:"⏳",labelKey:"execution.card.loading",borderClass:"border-border-default/40",bgClass:"bg-surface-secondary/30",badgeClass:"bg-surface-elevated text-fg-tertiary",textClass:""}};function AT({info:e}){const{t:n}=ht("common"),[r,s]=g.useState("loading");g.useEffect(()=>{let f=!1;return ae.tasks.get(e.taskId).then(({task:p})=>{f||s(ej[p.status]??"pending")}).catch(()=>{f||s("pending")}),()=>{f=!0}},[e.taskId]),g.useEffect(()=>Tn.on("task:update",f=>{const p=f.payload;p.taskId===e.taskId&&p.status&&s(ej[p.status]??"pending")}),[e.taskId]);const a=()=>{window.dispatchEvent(new CustomEvent("markus:mark-read-by-ref",{detail:{taskId:e.taskId}}))},i=async()=>{s("approving");try{await ae.tasks.approve(e.taskId),s("in_progress"),a()}catch{s("pending")}},l=async()=>{s("rejecting");try{await ae.tasks.reject(e.taskId),s("cancelled"),a()}catch{s("pending")}},c=r==="pending"||r==="approving"||r==="rejecting",u=tj[r]??tj.loading,m=()=>Rt.navigate(Be.WORK,{openTask:e.taskId});return t.jsxs("div",{className:`my-2 rounded-lg border ${u.borderClass} ${u.bgClass} p-3 max-w-md transition-colors`,children:[t.jsxs("div",{className:"flex items-start gap-2 mb-1 cursor-pointer group",role:"button",tabIndex:0,onClick:m,onKeyDown:f=>f.key==="Enter"&&m(),children:[t.jsx("span",{className:"text-sm mt-0.5",children:u.icon}),t.jsxs("div",{className:"flex-1 min-w-0",children:[t.jsxs("div",{className:"flex items-center gap-1.5",children:[t.jsx("span",{className:`text-[10px] px-1.5 py-0.5 rounded font-medium ${u.badgeClass}`,children:n("execution.taskBadge")}),!c&&r!=="loading"&&t.jsx("span",{className:`text-[10px] font-medium ${u.textClass}`,children:n(u.labelKey)})]}),t.jsx("div",{className:`text-sm font-medium truncate mt-1 group-hover:underline ${!c&&r!=="loading"?"text-fg-secondary":"text-fg-primary"}`,children:e.title}),e.description&&t.jsx("div",{className:"text-xs text-fg-secondary mt-0.5 line-clamp-2",children:e.description}),t.jsxs("div",{className:"flex items-center gap-2 mt-1.5 text-[11px] text-fg-tertiary",children:[e.priority&&t.jsx("span",{className:TT[e.priority]??"text-fg-tertiary",children:n(`priority.${e.priority}`,{defaultValue:e.priority})}),t.jsx("span",{className:"opacity-50",children:n("execution.idPrefix",{id:e.taskId.slice(0,8)})})]})]})]}),c&&t.jsxs("div",{className:"flex items-center gap-2 mt-2 pt-2 border-t border-border-default/30",children:[t.jsx("button",{onClick:i,disabled:r!=="pending",className:"flex-1 px-3 py-1.5 text-xs font-medium rounded-md bg-green-600 hover:bg-green-500 text-white transition-colors disabled:opacity-50 disabled:cursor-not-allowed",children:n(r==="approving"?"execution.card.approving":"approve")}),t.jsx("button",{onClick:l,disabled:r!=="pending",className:"flex-1 px-3 py-1.5 text-xs font-medium rounded-md bg-surface-elevated hover:bg-surface-overlay text-fg-secondary border border-border-default transition-colors disabled:opacity-50 disabled:cursor-not-allowed",children:n(r==="rejecting"?"execution.card.rejecting":"reject")})]})]})}const nj={pending:"pending",in_progress:"in_progress",completed:"completed",rejected:"rejected",cancelled:"cancelled",archived:"archived"},rj={pending:{icon:"📋",labelKey:"execution.card.pendingApproval",borderClass:"border-amber-500/40",bgClass:"bg-amber-500/5",badgeClass:"bg-amber-500/15 text-amber-600",textClass:""},approving:{icon:"⏳",labelKey:"execution.card.approving",borderClass:"border-amber-500/40",bgClass:"bg-amber-500/5",badgeClass:"bg-amber-500/15 text-amber-600",textClass:""},rejecting:{icon:"⏳",labelKey:"execution.card.rejecting",borderClass:"border-amber-500/40",bgClass:"bg-amber-500/5",badgeClass:"bg-amber-500/15 text-amber-600",textClass:""},in_progress:{icon:"▶",labelKey:"execution.card.inProgress",borderClass:"border-blue-500/40",bgClass:"bg-blue-500/5",badgeClass:"bg-blue-500/15 text-blue-500",textClass:"text-blue-500"},completed:{icon:"✅",labelKey:"execution.card.completed",borderClass:"border-green-500/30",bgClass:"bg-green-500/5",badgeClass:"bg-green-500/15 text-green-500",textClass:"text-green-500"},rejected:{icon:"❌",labelKey:"execution.card.rejected",borderClass:"border-red-500/30",bgClass:"bg-red-500/5",badgeClass:"bg-red-500/15 text-red-500",textClass:"text-red-500"},cancelled:{icon:"⊘",labelKey:"execution.card.cancelled",borderClass:"border-border-default/40",bgClass:"bg-surface-secondary/30",badgeClass:"bg-surface-elevated text-fg-tertiary",textClass:"text-fg-tertiary"},archived:{icon:"📦",labelKey:"execution.card.archived",borderClass:"border-border-default/40",bgClass:"bg-surface-secondary/30",badgeClass:"bg-surface-elevated text-fg-tertiary",textClass:"text-fg-tertiary"},loading:{icon:"⏳",labelKey:"execution.card.loading",borderClass:"border-border-default/40",bgClass:"bg-surface-secondary/30",badgeClass:"bg-surface-elevated text-fg-tertiary",textClass:""}},qJ=["requirement:approved","requirement:rejected","requirement:updated","requirement:completed","requirement:cancelled","requirement:resubmitted"];function MT({info:e}){const{t:n}=ht("common"),[r,s]=g.useState("loading"),[a,i]=g.useState(""),[l,c]=g.useState(!1);g.useEffect(()=>{let v=!1;return ae.requirements.get(e.requirementId).then(({requirement:N})=>{v||s(nj[N.status]??"pending")}).catch(()=>{v||s("pending")}),()=>{v=!0}},[e.requirementId]),g.useEffect(()=>{const v=qJ.map(N=>Tn.on(N,C=>{const k=C.payload;k.id===e.requirementId&&k.status&&s(nj[k.status]??"pending")}));return()=>v.forEach(N=>N())},[e.requirementId]);const u=()=>{window.dispatchEvent(new CustomEvent("markus:mark-read-by-ref",{detail:{requirementId:e.requirementId}}))},m=async()=>{s("approving");try{await ae.requirements.approve(e.requirementId),s("in_progress"),u()}catch{s("pending")}},f=async()=>{if(!l){c(!0);return}if(a.trim()){s("rejecting");try{await ae.requirements.reject(e.requirementId,a.trim()),s("rejected"),u()}catch{s("pending")}}},p=r==="pending"||r==="approving"||r==="rejecting",b=rj[r]??rj.loading,x=()=>Rt.navigate(Be.WORK,{openRequirement:e.requirementId});return t.jsxs("div",{className:`my-2 rounded-lg border ${b.borderClass} ${b.bgClass} p-3 max-w-md transition-colors`,children:[t.jsxs("div",{className:"flex items-start gap-2 mb-1 cursor-pointer group",role:"button",tabIndex:0,onClick:x,onKeyDown:v=>v.key==="Enter"&&x(),children:[t.jsx("span",{className:"text-sm mt-0.5",children:b.icon}),t.jsxs("div",{className:"flex-1 min-w-0",children:[t.jsxs("div",{className:"flex items-center gap-1.5",children:[t.jsx("span",{className:`text-[10px] px-1.5 py-0.5 rounded font-medium ${b.badgeClass}`,children:n("execution.reqBadge")}),!p&&r!=="loading"&&t.jsx("span",{className:`text-[10px] font-medium ${b.textClass}`,children:n(b.labelKey)})]}),t.jsx("div",{className:`text-sm font-medium truncate mt-1 group-hover:underline ${!p&&r!=="loading"?"text-fg-secondary":"text-fg-primary"}`,children:e.title}),e.description&&t.jsx("div",{className:"text-xs text-fg-secondary mt-0.5 line-clamp-3",children:e.description}),t.jsxs("div",{className:"flex items-center gap-2 mt-1.5 text-[11px] text-fg-tertiary",children:[e.priority&&t.jsx("span",{className:TT[e.priority]??"text-fg-tertiary",children:n(`priority.${e.priority}`,{defaultValue:e.priority})}),t.jsx("span",{className:"opacity-50",children:n("execution.idPrefix",{id:e.requirementId.slice(0,8)})})]})]})]}),p&&t.jsxs("div",{className:"mt-2 pt-2 border-t border-border-default/30 space-y-2",children:[l&&t.jsx("input",{type:"text",value:a,onChange:v=>i(v.target.value),placeholder:n("execution.rejectionReasonPlaceholder"),className:"w-full px-2 py-1.5 text-xs rounded-md bg-surface-secondary border border-border-default text-fg-primary placeholder:text-fg-tertiary focus:outline-none focus:border-brand-500",onKeyDown:v=>v.key==="Enter"&&f(),autoFocus:!0}),t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx("button",{onClick:m,disabled:r!=="pending",className:"flex-1 px-3 py-1.5 text-xs font-medium rounded-md bg-green-600 hover:bg-green-500 text-white transition-colors disabled:opacity-50 disabled:cursor-not-allowed",children:n(r==="approving"?"execution.card.approving":"approve")}),t.jsx("button",{onClick:f,disabled:r!=="pending"||l&&!a.trim(),className:"flex-1 px-3 py-1.5 text-xs font-medium rounded-md bg-surface-elevated hover:bg-surface-overlay text-fg-secondary border border-border-default transition-colors disabled:opacity-50 disabled:cursor-not-allowed",children:n(r==="rejecting"?"execution.card.rejecting":"reject")})]})]})]})}const VJ={"claude-code":{label:"Claude Code",badgeClass:"bg-orange-500/15 text-orange-500"},codex:{label:"Codex",badgeClass:"bg-emerald-500/15 text-emerald-500"},"cursor-agent":{label:"Cursor",badgeClass:"bg-blue-500/15 text-blue-500"}};function WJ({session:e,info:n,onClose:r}){const s=n.args&&typeof n.args=="object"&&!Array.isArray(n.args)?n.args:{},a=e.status==="running"||e.status==="created"||e.status==="context_injected",i=e.status==="failed"||e.status==="timeout",l=e.status==="completed",c=VJ[e.tool]??{label:e.tool,badgeClass:"bg-surface-elevated text-fg-tertiary"},[u,m]=g.useState(!1);g.useEffect(()=>{const x=v=>{v.key==="Escape"&&r()};return document.addEventListener("keydown",x),()=>document.removeEventListener("keydown",x)},[r]);const f=e.cost?.durationMs??n.durationMs,p=typeof s.model=="string"?s.model:void 0,b=typeof s.mode=="string"?s.mode:void 0;return t.jsxs("div",{className:"fixed inset-0 z-[60] flex items-center justify-center",onClick:r,children:[t.jsx("div",{className:"absolute inset-0 bg-black/60"}),t.jsxs("div",{className:"relative bg-surface-secondary border border-border-default rounded-xl shadow-2xl w-[640px] max-w-[92vw] max-h-[80vh] overflow-hidden flex flex-col",onClick:x=>x.stopPropagation(),children:[t.jsxs("div",{className:"px-5 py-3 border-b border-border-default flex items-center justify-between shrink-0",children:[t.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[t.jsx("span",{className:`text-xs px-2 py-0.5 rounded font-medium ${c.badgeClass}`,children:c.label}),t.jsx("span",{className:`text-xs px-1.5 py-0.5 rounded ${a?"bg-brand-500/15 text-brand-500":l?"bg-green-500/15 text-green-600":"bg-red-500/15 text-red-500"}`,children:a?"Running":l?"Completed":i?"Failed":e.status}),f!=null&&t.jsx("span",{className:"text-xs text-fg-tertiary tabular-nums",children:Fd(f)}),p&&t.jsx("span",{className:"text-[10px] bg-surface-elevated px-1.5 py-0.5 rounded text-fg-tertiary font-mono",children:p}),b&&t.jsx("span",{className:"text-[10px] bg-surface-elevated px-1.5 py-0.5 rounded text-fg-tertiary",children:b})]}),t.jsx("button",{onClick:r,className:"text-fg-tertiary hover:text-fg-secondary text-lg leading-none ml-2",children:"×"})]}),t.jsxs("div",{className:"flex-1 overflow-y-auto px-5 py-4 space-y-4",children:[t.jsxs("div",{children:[t.jsx("h4",{className:"text-[10px] font-semibold text-fg-tertiary uppercase tracking-wider mb-2",children:"Prompt"}),t.jsx("pre",{className:"text-xs text-fg-secondary bg-surface-elevated/70 rounded-lg px-3 py-2 overflow-x-auto max-h-40 overflow-y-auto whitespace-pre-wrap break-all font-mono",children:e.prompt})]}),Object.keys(s).length>0&&t.jsxs("div",{children:[t.jsx("h4",{className:"text-[10px] font-semibold text-fg-tertiary uppercase tracking-wider mb-2",children:"Input Arguments"}),t.jsx("div",{className:"space-y-1.5",children:Object.entries(s).filter(([x])=>x!=="prompt").map(([x,v])=>t.jsxs("div",{className:"flex items-start gap-2 text-xs",children:[t.jsxs("span",{className:"text-brand-500 font-medium shrink-0 font-mono",children:[x,":"]}),t.jsx("span",{className:"text-fg-secondary font-mono break-all",children:typeof v=="string"?v:JSON.stringify(v)})]},x))})]}),e.result&&!a&&t.jsxs("div",{children:[t.jsx("h4",{className:"text-[10px] font-semibold text-fg-tertiary uppercase tracking-wider mb-2",children:"Result"}),t.jsxs("div",{className:"space-y-2",children:[e.result.summary&&t.jsx("div",{className:"text-xs text-fg-secondary",children:e.result.summary}),e.result.diffStats&&t.jsxs("div",{className:"flex items-center gap-3 text-xs font-mono",children:[t.jsxs("span",{className:"text-fg-tertiary",children:[e.result.diffStats.filesChanged," files changed"]}),t.jsxs("span",{className:"text-green-500",children:["+",e.result.diffStats.additions]}),t.jsxs("span",{className:"text-red-500",children:["-",e.result.diffStats.deletions]})]}),e.result.modifiedFiles&&e.result.modifiedFiles.length>0&&t.jsxs("div",{children:[t.jsx("div",{className:"text-[10px] text-fg-tertiary mb-1",children:"Modified files:"}),t.jsx("div",{className:"bg-surface-elevated/70 rounded-lg px-3 py-2 max-h-32 overflow-y-auto",children:e.result.modifiedFiles.map((x,v)=>t.jsx("div",{className:"text-[11px] text-fg-secondary font-mono truncate",children:x},v))})]}),e.result.error&&t.jsx("pre",{className:"text-xs text-red-500 bg-red-500/10 border border-red-500/20 rounded-lg px-3 py-2 overflow-x-auto max-h-60 overflow-y-auto whitespace-pre-wrap break-all font-mono",children:e.result.error})]})]}),e.cost&&(e.cost.inputTokens!=null||e.cost.outputTokens!=null||e.cost.estimatedCostUsd!=null)&&t.jsxs("div",{children:[t.jsx("h4",{className:"text-[10px] font-semibold text-fg-tertiary uppercase tracking-wider mb-2",children:"Cost"}),t.jsxs("div",{className:"flex items-center gap-4 text-xs text-fg-secondary",children:[e.cost.inputTokens!=null&&t.jsxs("span",{children:[e.cost.inputTokens.toLocaleString()," input tokens"]}),e.cost.outputTokens!=null&&t.jsxs("span",{children:[e.cost.outputTokens.toLocaleString()," output tokens"]}),e.cost.estimatedCostUsd!=null&&t.jsxs("span",{className:"font-medium",children:["$",e.cost.estimatedCostUsd.toFixed(4)]}),f!=null&&t.jsx("span",{className:"text-fg-tertiary",children:Fd(f)})]})]}),e.result?.rawOutput&&t.jsxs("div",{children:[t.jsxs("button",{type:"button",onClick:()=>m(!u),className:"flex items-center gap-1.5 text-[10px] text-fg-tertiary hover:text-fg-secondary transition-colors",children:[t.jsx("svg",{className:`w-3 h-3 transition-transform ${u?"rotate-90":""}`,fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:t.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M9 5l7 7-7 7"})}),t.jsx("span",{className:"font-semibold uppercase tracking-wider",children:"Raw Output"})]}),u&&t.jsx("pre",{className:"mt-2 text-[11px] text-fg-tertiary bg-surface-elevated/70 rounded-lg px-3 py-2 overflow-x-auto max-h-[50vh] overflow-y-auto whitespace-pre-wrap break-all font-mono",children:e.result.rawOutput})]})]})]})]})}function KJ(e){if(e.tool!=="invoke_coding_tool")return null;const n=e.args&&typeof e.args=="object"&&!Array.isArray(e.args)?e.args:{},r=typeof n.tool=="string"?n.tool:"unknown",s=typeof n.prompt=="string"?n.prompt:"",i={running:"running",done:"completed",error:"failed",stopped:"cancelled"}[e.status]??e.status;let l,c;if(e.result)try{const m=JSON.parse(e.result);if(m&&typeof m=="object"){const f=m.result&&typeof m.result=="object"?m.result:m;l={success:f.success??m.success??e.status==="done",summary:f.summary??f.message??m.summary??m.message??"Completed",diffStats:f.diffStats??m.diffStats,modifiedFiles:f.modifiedFiles??m.modifiedFiles,exitCode:f.exitCode??m.exitCode,rawOutput:f.rawOutput??f.output??m.rawOutput??m.output,error:f.error??m.error},f.cost?c=f.cost:m.cost&&(c=m.cost)}}catch{l={success:e.status==="done",summary:e.result.slice(0,500),rawOutput:e.result}}e.durationMs!=null&&(c={...c,durationMs:e.durationMs});let u;if(e.liveOutput&&e.status==="running"){const m=e.liveOutput.trim().split(`
@@ -773,4 +773,4 @@ Minimum version required to store current data is: `+$+`.
773
773
  ${Ee.content}`);T.trim()&&ge.push(T.trim());const ye=ge.join(`
774
774
 
775
775
  `);if(!ye)return;R(""),M([]),A.current=!0,S(!0),P([]);const we=`a_${Date.now()}`,Ce={id:`u_${Date.now()}`,sender:"user",text:ye,time:new Date().toLocaleTimeString()},ie=new Date().toISOString();v(Ee=>[...Ee,Ce,{id:we,sender:"agent",text:"",time:new Date().toLocaleTimeString(),rawCreatedAt:ie,segments:[]}]);let Te=!1;const ue=Ee=>{v(We=>{const Ve=[...We],de=Ve.findIndex(xt=>xt.id===we);if(de<0)return We;const ve=Ve[de].segments??[],Ne=ve[ve.length-1],W=Ne?.type==="text"?Ne.thinking??"":"";let re="",Ae="",xe=Ee;for(;xe.length>0;)if(Te){const xt=xe.indexOf("</think>");xt>=0?(re+=xe.slice(0,xt),xe=xe.slice(xt+8),Te=!1):(re+=xe,xe="")}else{const xt=xe.indexOf("<think>");xt>=0?(Ae+=xe.slice(0,xt),xe=xe.slice(xt+7),Te=!0):(Ae+=xe,xe="")}const tt=W+re||void 0,vt=Ne?.type==="text"?[...ve.slice(0,-1),{type:"text",content:Ne.content+Ae,thinking:tt,createdAt:Ne.createdAt}]:[...ve,{type:"text",content:Ae,thinking:tt,createdAt:new Date().toISOString()}];return Ve[de]={...Ve[de],text:Ve[de].text+Ae,segments:vt},Ve})},Le=Ee=>{if(Ee.type==="session_start"&&Ee.sessionId){C(Ee.sessionId);return}v(We=>{const Ve=[...We],de=Ve.findIndex(Ne=>Ne.id===we);if(de<0)return We;const ve=[...Ve[de].committedSegments??[]];return Ee.type==="thinking_commit"?ve.push({type:"text",content:"",thinking:Ee.content,createdAt:Ee.createdAt}):ve.push({type:"text",content:Ee.content,createdAt:Ee.createdAt}),Ve[de]={...Ve[de],committedSegments:ve},Ve})},$e=Ee=>{Ee.phase!=="heartbeat"&&(Ee.phase==="start"?(P(We=>[...We,{...Ee,phase:"start",ts:Date.now()}]),v(We=>{const Ve=[...We],de=Ve.findIndex(xe=>xe.id===we);if(de<0)return We;const ve=[...Ve[de].segments??[]],Ne=`${Ee.tool}_${Date.now()}`,W=new Date().toISOString();let re=!1;if(Ee.arguments)for(let xe=ve.length-1;xe>=0;xe--){const tt=ve[xe];if(tt.type==="tool"&&tt.tool===Ee.tool&&tt.status==="running"){ve[xe]={...tt,args:Ee.arguments},re=!0;break}}re||ve.push({type:"tool",key:Ne,tool:Ee.tool,status:"running",args:Ee.arguments,createdAt:W});const Ae=[...Ve[de].committedSegments??[]];return Ee.arguments!==void 0&&Ae.push({type:"tool",key:Ne,tool:Ee.tool,status:"running",args:Ee.arguments,createdAt:W}),Ve[de]={...Ve[de],segments:ve,committedSegments:Ae},Ve})):Ee.phase==="output"?v(We=>{const Ve=[...We],de=Ve.findIndex(Ne=>Ne.id===we);if(de<0)return We;const ve=[...Ve[de].segments??[]];for(let Ne=ve.length-1;Ne>=0;Ne--){const W=ve[Ne];if(W.type==="tool"&&W.tool===Ee.tool&&W.status==="running"){ve[Ne]={...W,liveOutput:(W.liveOutput??"")+(Ee.output??"")};break}}return Ve[de]={...Ve[de],segments:ve},Ve}):Ee.phase==="end"&&(P(We=>[...We,{...Ee,phase:"end",ts:Date.now()}]),v(We=>{const Ve=[...We],de=Ve.findIndex(re=>re.id===we);if(de<0)return We;const ve=new Date().toISOString(),Ne=[...Ve[de].segments??[]];for(let re=Ne.length-1;re>=0;re--){const Ae=Ne[re];if(Ae.type==="tool"&&Ae.tool===Ee.tool&&Ae.status==="running"){Ne[re]={...Ae,status:Ee.success===!1?"error":"done",args:Ee.arguments,result:Ee.result,error:Ee.error,durationMs:Ee.durationMs,liveOutput:void 0,createdAt:ve};break}}const W=[...Ve[de].committedSegments??[]];for(let re=W.length-1;re>=0;re--){const Ae=W[re];if(Ae.type==="tool"&&Ae.tool===Ee.tool&&Ae.status==="running"){W[re]={...Ae,status:Ee.success===!1?"error":"done",args:Ee.arguments,result:Ee.result,error:Ee.error,durationMs:Ee.durationMs,liveOutput:void 0,createdAt:ve};break}}return Ve[de]={...Ve[de],segments:Ne,committedSegments:W},Ve})))},je=new AbortController;z.current=je;try{const Ee=await ae.agents.messageStream(e,ye,ue,$e,je.signal,void 0,N,void 0,void 0,Le);Ee.merged&&v(We=>We.filter(Ve=>Ve.id!==we)),!Ee.merged&&Ee.segments?.length&&v(We=>{const Ve=[...We],de=Ve.findIndex(W=>W.id===we);if(de<0)return We;const ve=Ee.segments.map((W,re)=>W.type==="tool"?{type:"tool",key:`${W.tool}_${re}`,tool:W.tool,status:W.status,args:W.arguments,result:W.result,error:W.error,durationMs:W.durationMs,createdAt:W.createdAt}:{type:"text",content:W.content,thinking:W.thinking,createdAt:W.createdAt});let Ne=Ee.content||Ve[de].text;return Ne||(Ne=ve.filter(W=>W.type==="text").map(W=>W.content).join("")),Ve[de]={...Ve[de],text:Ne,segments:ve,committedSegments:ve},Ve}),!Ee.merged&&!Ee.segments?.length&&v(We=>{const Ve=[...We],de=Ve.findIndex(Ae=>Ae.id===we);if(de<0)return We;const ve=Ve[de],Ne=ve.committedSegments??[],re=Ne.filter(Ae=>Ae.type==="text"&&!!Ae.content).map(Ae=>Ae.content).join("")||Ee.content||ve.text;return(Ne.length>0||re)&&(Ve[de]={...ve,text:re,segments:Ne.length>0?Ne:ve.segments}),Ve}),Ee.sessionId&&C(Ee.sessionId)}catch(Ee){const We=Ee?.sessionId;We&&C(We);const Ve=yy(Ee,m);v(Ve?de=>{const ve=[...de],Ne=ve.findIndex(W=>W.id===we);if(Ne>=0){const W=ve[Ne].segments??[];ve[Ne]={...ve[Ne],text:Ve,isError:!0,segments:[...W,{type:"text",content:Ve}]}}return ve}:de=>{const ve=[...de],Ne=ve.findIndex(W=>W.id===we);if(Ne>=0){const W=ve[Ne];if(!(W.text||W.segments&&W.segments.length>0&&W.segments.some(Ae=>Ae.type==="text"&&(Ae.content||Ae.thinking)||Ae.type==="tool")))return de.filter(Ae=>Ae.id!==we);ve[Ne]={...W,isStopped:!0}}return ve})}v(Ee=>{const We=[...Ee],Ve=We.findIndex(de=>de.id===we);if(Ve>=0){const de=(We[Ve].segments??[]).map(ve=>ve.type==="tool"&&ve.status==="running"?{...ve,status:"stopped"}:ve);We[Ve]={...We[Ve],segments:de}}return We}),S(!1),P([]),z.current=null},[T,e,N,m,L,i]),Q=x[x.length-1],ne=w&&Q?.sender==="agent",[te,Y]=g.useState([]);g.useEffect(()=>{let ge=!1;return(async()=>{const we=[];try{const[Ce,ie,Te,ue,Le]=await Promise.all([ae.projects.list().catch(()=>({projects:[]})),ae.requirements.list().catch(()=>({requirements:[]})),ae.tasks.list({pageSize:100}).catch(()=>({tasks:[]})),ae.deliverables.search({limit:100}).catch(()=>({results:[]})),ae.teams.list().catch(()=>({teams:[],ungrouped:[]}))]);for(const $e of Ce.projects)we.push({id:$e.id,name:$e.name,type:"project",role:$e.status});for(const $e of ie.requirements)we.push({id:$e.id,name:$e.title,type:"requirement",role:$e.priority});for(const $e of Te.tasks)we.push({id:$e.id,name:$e.title,type:"task",role:$e.status});for(const $e of ue.results)we.push({id:$e.id,name:$e.title,type:"deliverable",role:$e.type});for(const $e of Le.teams)try{const je=await ae.workflows.list($e.id);for(const Ee of je.workflows)we.push({id:Ee.name,name:Ee.displayName||Ee.name,type:"workflow",role:`v${Ee.version}`})}catch{}}catch{}ge||Y(we)})(),()=>{ge=!0}},[]);const oe=g.useMemo(()=>{const ge=r.map(ye=>({id:ye.id,name:ye.name,role:ye.role,avatarUrl:ye.avatarUrl,type:"agent"}));return[...te,...ge,...l??[]]},[r,te,l]);return t.jsxs("div",{className:`flex flex-col bg-surface-primary border-l border-border-default ${u}`,style:c?{width:c}:{width:400},children:[t.jsxs("div",{className:"h-12 px-4 flex items-center gap-2 shrink-0 border-b border-border-default",children:[t.jsx(_r,{name:p,avatarUrl:f?.avatarUrl,size:24,bgClass:"bg-brand-500/15 text-brand-600",className:"rounded-md"}),t.jsx("span",{className:"text-sm font-medium text-fg-primary truncate flex-1",children:p}),a&&t.jsx("button",{onClick:a,className:"text-fg-tertiary hover:text-fg-secondary transition-colors p-1",children:t.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[t.jsx("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),t.jsx("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]})})]}),t.jsxs("div",{ref:$,className:"flex-1 overflow-y-auto px-3 py-3 space-y-3",onScroll:X,children:[k?t.jsx("div",{className:"flex items-center justify-center h-full",children:t.jsxs("svg",{className:"animate-spin h-5 w-5 text-fg-tertiary",viewBox:"0 0 24 24",fill:"none",children:[t.jsx("circle",{className:"opacity-25",cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"4"}),t.jsx("path",{className:"opacity-75",fill:"currentColor",d:"M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4z"})]})}):x.length===0?t.jsxs("div",{className:"flex flex-col items-center justify-center h-full gap-3",children:[t.jsx(_r,{name:p,avatarUrl:f?.avatarUrl,size:40,bgClass:"bg-brand-500/20 text-brand-500"}),t.jsx("p",{className:"text-fg-secondary text-sm font-medium",children:O})]}):x.map((ge,ye)=>{const we=ye>0?x[ye-1]:null,Ce=Wh(ge.rawCreatedAt),ie=we?Wh(we.rawCreatedAt):"",Te=Ce&&Ce!==ie,ue=ye===x.length-1,Le=ne&&ue,$e=Le;return t.jsxs("div",{children:[Te&&t.jsxs("div",{className:"flex items-center gap-3 py-1 my-1",children:[t.jsx("div",{className:"flex-1 h-px bg-border-default"}),t.jsx("span",{className:"text-[10px] text-fg-tertiary font-medium uppercase tracking-wider shrink-0",children:BT(ge.rawCreatedAt,D)}),t.jsx("div",{className:"flex-1 h-px bg-border-default"})]}),t.jsxs("div",{className:"flex gap-2",children:[t.jsx("div",{className:"shrink-0 mt-0.5",children:t.jsx(_r,{name:ge.sender==="user"?b:p,avatarUrl:ge.sender==="user"?s?.avatarUrl:f?.avatarUrl,size:24,bgClass:ge.sender==="user"?"bg-brand-600":"bg-brand-500/15 text-brand-600",className:"rounded-md"})}),t.jsxs("div",{className:"min-w-0 flex-1",children:[t.jsxs("div",{className:"flex items-baseline gap-1.5",children:[t.jsx("span",{className:"text-xs font-medium text-fg-primary",children:ge.sender==="user"?b:p}),t.jsx("span",{className:"text-[10px] text-fg-tertiary",children:PT(ge.time,ge.rawCreatedAt,D)})]}),t.jsx("div",{className:`mt-0.5 ${ge.sender==="agent"?"py-0.5":"bg-surface-secondary rounded-xl px-3 py-2 w-fit max-w-full"} ${ge.isError?"border-b-2 border-red-500/60":""} ${$e&&ge.sender==="agent"?"streaming-bubble":""}`,children:ge.sender==="user"?t.jsx("div",{className:"text-sm text-fg-secondary whitespace-pre-wrap",children:ge.text}):ge.segments&&ge.segments.length>0?t.jsx(zT,{msg:ge,isStreaming:Le,liveActivities:Le?I:[],onViewModeChange:()=>{}}):t.jsx(fs,{content:ge.text,className:"text-sm text-fg-secondary"})})]})]})]},ge.id)}),t.jsx("div",{ref:U})]}),B&&t.jsx("div",{className:"flex justify-center -mt-10 relative z-10 pointer-events-none",children:t.jsx("button",{onClick:()=>q("smooth"),className:"pointer-events-auto w-8 h-8 rounded-full bg-surface-elevated border border-border-default shadow-md flex items-center justify-center text-fg-tertiary hover:text-fg-secondary transition-colors",title:m("page.scrollToBottom"),children:t.jsx("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:t.jsx("polyline",{points:"6 9 12 15 18 9"})})})}),t.jsx("div",{className:"px-3 py-2 shrink-0 border-t border-border-default",children:t.jsx(Ude,{value:T,onChange:R,onSend:ee,disabled:!e,placeholder:m("page.placeholder.direct"),sending:w,onStop:K,contextChips:i,mentionItems:oe,onMentionChipsChange:M,compact:!0,className:"shadow-none border-0"})})]})}const vd={file:{icon:"📄",color:"bg-green-500/10 text-green-600"},directory:{icon:"📁",color:"bg-blue-500/10 text-blue-600"}},Vde=["file","directory"];function sh(e){return/^https?:\/\//i.test(e)}function Wde(e,n){const r=Date.now(),s=new Date(e).getTime(),a=r-s,i=Math.floor(a/6e4);if(i<1)return n("time.justNow");if(i<60)return n("time.minutesAgo",{count:i});const l=Math.floor(i/60);if(l<24)return n("time.hoursAgo",{count:l});const c=Math.floor(l/24);if(c===1)return n("time.yesterday");if(c<30)return n("time.daysAgo",{count:c});const u=Math.floor(c/30);return u<12?n("time.monthsAgo",{count:u}):n("time.yearsAgo",{count:Math.floor(u/12)})}const Tl={agent:{icon:"✦",color:"bg-brand-500/10 text-brand-500"},team:{icon:"◈",color:"bg-blue-500/10 text-blue-600"},skill:{icon:"⬡",color:"bg-amber-500/10 text-amber-600"}};function s6({authUser:e,previewMode:n,previewData:r}={}){const{t:s}=ht(["deliverables","common"]),a=ea(),i=Zd(Be.DELIVERABLES),l=P0({side:"left",defaultWidth:384,minWidth:280,maxWidth:600,storageKey:"markus_deliverables_list"}),[c,u]=g.useState(!1),m=g.useRef(c);m.current=c,g.useEffect(()=>{if(!a)return;const Fe=()=>{m.current&&u(!1)};return window.addEventListener("popstate",Fe),()=>window.removeEventListener("popstate",Fe)},[a]);const f=100,p=5e3,[b,x]=g.useState(r?.items??[]),[v,N]=g.useState(r?.items?.length??0),[C,k]=g.useState(!1),[j,w]=g.useState(r?.projects??[]),[S,T]=g.useState(r?.agents??[]),[R,I]=g.useState([]),[P,L]=g.useState(!r),[M,$]=g.useState(""),[U,z]=g.useState(""),[A,H]=g.useState(""),[D,O]=g.useState(""),[q,J]=g.useState("date"),[B,V]=g.useState(()=>r?.initialSelectedId&&r.items?r.items.find(Fe=>Fe.id===r.initialSelectedId)??r.items[0]??null:r?.items?.[0]??null),[X,K]=g.useState(null),[ee,Q]=g.useState(""),[ne,te]=g.useState(!0),[Y,oe]=g.useState(()=>{const Fe=new Date,jt=`${Fe.getFullYear()}-${String(Fe.getMonth()+1).padStart(2,"0")}-${String(Fe.getDate()).padStart(2,"0")}`;return new Set([jt])}),[ge,ye]=g.useState(!1),[we,Ce]=g.useState(!1),ie=g.useMemo(()=>[{id:"date"},{id:"project"},{id:"team"},{id:"agent"}],[]),Te=g.useCallback(Fe=>{J(Fe)},[]),ue=zl(ie,q,Te),Le=g.useRef(null),[$e,je]=g.useState(null),[Ee,We]=g.useState("markdown"),[Ve,de]=g.useState(null),[ve,Ne]=g.useState(!1),[W,re]=g.useState(!1),[Ae,xe]=g.useState(!1),[tt,vt]=g.useState(null),[xt,Me]=g.useState(""),[Ke,Re]=g.useState(new Set),[qe,ct]=g.useState(!1),[Bt,gt]=g.useState(!1),[cn,st]=g.useState([]),[Ct,en]=g.useState(null),[be,Je]=g.useState(!1),[it,It]=g.useState(""),[sn,An]=g.useState(!1),[Ut,Dt]=g.useState(!1),[on,Ln]=g.useState(null),On=g.useRef(null),Wr=g.useCallback(Fe=>{Fe&&(Fe.style.height="auto",Fe.style.height=Fe.scrollHeight+"px")},[]),er=g.useRef(void 0);g.useEffect(()=>{Wr(On.current)},[it,be,Wr]);const br=(Fe,jt)=>{K({type:Fe,text:jt}),setTimeout(()=>K(null),3e3)},Mr=async Fe=>{await Ap(Fe)?(xe(!0),setTimeout(()=>xe(!1),1500)):br("error",s("detail.copyFailed"))},Cn=g.useMemo(()=>new Map(S.map(Fe=>[Fe.id,Fe])),[S]),Un=g.useMemo(()=>new Map(j.map(Fe=>[Fe.id,Fe])),[j]),ar=g.useMemo(()=>new Map(R.map(Fe=>[Fe.id,Fe])),[R]),mr=g.useCallback(Fe=>{if(!Fe||Fe==="default")return null;const jt=Un.get(Fe)?.name;return!jt||jt==="default"?null:jt},[Un]);g.useEffect(()=>{n||(ae.projects.list().then(Fe=>w(Fe.projects)).catch(()=>{}),ae.agents.list().then(Fe=>T(Fe.agents??[])).catch(()=>{}),ae.teams.list().then(Fe=>I(Fe.teams??[])).catch(()=>{}),ae.system.storage().then(Fe=>Me(Fe.dataDir+"/shared")).catch(()=>{}),ae.deliverables.checkHealth().then(Fe=>Re(new Set(Fe.missingFiles))).catch(()=>{}))},[n]),g.useEffect(()=>(er.current=setTimeout(()=>z(M),300),()=>clearTimeout(er.current)),[M]);const Kr=g.useMemo(()=>({q:U||void 0,type:A||void 0,artifactType:D||void 0}),[U,A,D]),fr=q==="date"?f:p,Zn=g.useCallback(async()=>{L(!0),Le.current?.scrollTo({top:0,behavior:"instant"});try{const{results:Fe,total:jt}=await ae.deliverables.search({...Kr,offset:0,limit:fr});x(Fe),N(jt),V(wt=>wt&&Fe.some(tn=>tn.id===wt.id)?wt:null)}catch{x([]),N(0),V(null)}L(!1)},[Kr,fr]),ir=g.useCallback(async()=>{if(!(C||b.length>=v)){k(!0);try{const{results:Fe,total:jt}=await ae.deliverables.search({...Kr,offset:b.length,limit:fr});x(wt=>[...wt,...Fe]),N(jt)}catch{}k(!1)}},[Kr,fr,b.length,v,C]);g.useEffect(()=>{n||Zn()},[Zn,n]),g.useEffect(()=>{!n||!r||(x(r.items??[]),N(r.items?.length??0),w(r.projects??[]),T(r.agents??[]),r.initialSelectedId&&V(r.items?.find(Fe=>Fe.id===r.initialSelectedId)??r.items?.[0]??null))},[n,r]);const hr=g.useRef(B);hr.current=B,g.useEffect(()=>{if(n||!i)return;const Fe=Tn.on("deliverable:created",()=>Zn()),jt=Tn.on("deliverable:updated",tn=>{Zn();const Rn=tn.payload?.deliverableId;Rn&&hr.current?.id===Rn&&ae.deliverables.get(Rn).then(mn=>{mn.deliverable&&(V(mn.deliverable),Yt(mn.deliverable))}).catch(()=>{})}),wt=Tn.on("deliverable:removed",()=>Zn());return()=>{Fe(),jt(),wt()}},[Zn,i,n]);const En=g.useRef(null),Oe=g.useRef(b);Oe.current=b;const $t=g.useCallback(Fe=>{const jt=tn=>{V(tn),a&&(u(!0),history.pushState({mobileDetail:Be.DELIVERABLES},"",window.location.hash))},wt=Oe.current.find(tn=>tn.id===Fe);if(wt){jt(wt);return}ae.deliverables.get(Fe).then(tn=>{tn.deliverable&&jt(tn.deliverable)}).catch(()=>{})},[a]);g.useEffect(()=>{if(n)return;const Fe=localStorage.getItem("markus_nav_openDeliverable");Fe&&(localStorage.removeItem("markus_nav_openDeliverable"),Oe.current.length>0?$t(Fe):En.current=Fe);const jt=wt=>{const tn=wt.detail;tn?.params?.openDeliverable&&(localStorage.removeItem("markus_nav_openDeliverable"),$t(tn.params.openDeliverable))};return window.addEventListener("markus:navigate",jt),()=>window.removeEventListener("markus:navigate",jt)},[$t,n]),g.useEffect(()=>{const Fe=En.current;!Fe||b.length===0||(En.current=null,$t(Fe))},[b,$t]);const jn=g.useCallback(()=>{const Fe=Le.current;!Fe||P||C||b.length>=v||Fe.scrollHeight<=Fe.clientHeight+100&&ir()},[P,C,b.length,v,ir]);g.useEffect(()=>{const Fe=Le.current;if(!Fe)return;const jt=()=>{Fe.scrollTop+Fe.clientHeight>=Fe.scrollHeight-100&&ir()};return Fe.addEventListener("scroll",jt,{passive:!0}),()=>Fe.removeEventListener("scroll",jt)},[ir]),g.useEffect(()=>{jn()},[jn,ne,Y]);const Wt=g.useMemo(()=>{const Fe=new Map;for(const wt of b){let tn,Rn;if(q==="project"){const mn=mr(wt.projectId);tn=mn?wt.projectId??"_none":"_none",Rn=mn??s("noProject")}else if(q==="team"){const Ir=(wt.agentId?Cn.get(wt.agentId):void 0)?.teamId??"_none";tn=Ir,Rn=Ir!=="_none"?ar.get(Ir)?.name??Ir:s("noTeam")}else if(q==="agent")tn=wt.agentId??"_none",Rn=wt.agentId?Cn.get(wt.agentId)?.name??wt.agentId:s("common:unknown");else{const mn=new Date(wt.updatedAt);tn=`${mn.getFullYear()}-${String(mn.getMonth()+1).padStart(2,"0")}-${String(mn.getDate()).padStart(2,"0")}`,Rn=tn}Fe.has(tn)||Fe.set(tn,{label:Rn,items:[]}),Fe.get(tn).items.push(wt)}const jt=[...Fe.entries()];return q==="date"?jt.sort((wt,tn)=>tn[0].localeCompare(wt[0])):jt.sort((wt,tn)=>wt[1].label.localeCompare(tn[1].label)),jt},[b,q,Un,Cn,ar,s]);g.useEffect(()=>{if(q==="date"&&ne){const Fe=new Date,jt=`${Fe.getFullYear()}-${String(Fe.getMonth()+1).padStart(2,"0")}-${String(Fe.getDate()).padStart(2,"0")}`;oe(new Set([jt]))}else oe(new Set)},[q]);const pn=async Fe=>{Q("remove");try{await ae.deliverables.remove(Fe.id),br("success",s("removed")),V(null),Zn()}catch(jt){br("error",s("common:error",{message:String(jt)}))}Q("")},pr=()=>{Rt.navigate(Be.BUILDER)},Yt=async Fe=>{if(Fe.reference&&!sh(Fe.reference)){if(Fe.type==="directory"){re(!0);return}Ne(!0);try{const jt=await ae.files.preview(Fe.reference);jt.type==="image"&&jt.mimeType?de({src:`data:${jt.mimeType};base64,${jt.content}`,name:jt.name}):(je(jt.content),We(o8({format:Fe.format,reference:Fe.reference,content:jt.content})))}catch{je(null),Fe.type==="file"&&re(!0)}Ne(!1)}};g.useEffect(()=>{n||(je(null),We("markdown"),de(null),re(!1),B&&Yt(B))},[B?.id,n]);const pe=g.useCallback(Fe=>ne!==Y.has(Fe),[ne,Y]),Ye=Wt.length>0&&Wt.every(([Fe])=>pe(Fe)),lt=g.useCallback(Fe=>{oe(jt=>{const wt=new Set(jt);return wt.has(Fe)?wt.delete(Fe):wt.add(Fe),wt})},[]),St=g.useCallback(()=>{te(Fe=>!Fe),oe(new Set)},[]),Jt=!!(A||D||U),gn=g.useCallback(()=>{H(""),O(""),$(""),z("")},[]),tr=g.useMemo(()=>Wt.flatMap(([,Fe])=>Fe.items),[Wt]),Wn=g.useRef(null);g.useEffect(()=>{const Fe=jt=>{if(jt.target instanceof HTMLInputElement||jt.target instanceof HTMLTextAreaElement){jt.key==="Escape"&&(jt.target.blur(),jt.preventDefault());return}if((jt.metaKey||jt.ctrlKey)&&jt.key==="f"){jt.preventDefault(),Wn.current?.focus();return}if(jt.key==="ArrowDown"||jt.key==="ArrowUp"){jt.preventDefault();const wt=tr;if(wt.length===0)return;const tn=B?wt.findIndex(mn=>mn.id===B.id):-1,Rn=jt.key==="ArrowDown"?Math.min(tn+1,wt.length-1):Math.max(tn-1,0);rr(wt[Rn])}};return window.addEventListener("keydown",Fe),()=>window.removeEventListener("keydown",Fe)},[tr,B]);const Pt=g.useRef(null),Pn=g.useCallback(Fe=>{if(!a)return;const jt=Le.current;!jt||jt.scrollTop>0||(Pt.current={y:Fe.touches[0].clientY,scrollTop:jt.scrollTop})},[a]),kr=g.useCallback(Fe=>{if(!a||!Pt.current||we)return;const jt=Fe.changedTouches[0].clientY-Pt.current.y;Pt.current=null,jt>80&&Le.current&&Le.current.scrollTop<=0&&(Ce(!0),Zn().finally(()=>Ce(!1)))},[a,we,Zn]),rr=Fe=>{const jt=()=>{V(Fe),st([]),Je(!1),An(!1),a&&(gt(!1),u(!0),history.pushState({mobileDetail:Be.DELIVERABLES},"",window.location.hash))};sn?Ln({action:jt}):jt()},Bn=()=>{if(!sn){const Fe=$e??B?.summary??"";It(Fe)}Je(!0)},Sr=()=>{sn?Ln({action:()=>{Je(!1),An(!1)}}):Je(!1)},Kn=async()=>{if(!(!B?.reference||Ut)){Dt(!0);try{await ae.files.write(B.reference,it),je(it),An(!1),Je(!1),br("success",s("detail.saved"))}catch(Fe){br("error",s("detail.saveFailed")+": "+String(Fe))}Dt(!1)}},$n=()=>{Je(!1),An(!1),Ln(null)};g.useEffect(()=>{if(!sn)return;const Fe=jt=>{jt.preventDefault()};return window.addEventListener("beforeunload",Fe),()=>window.removeEventListener("beforeunload",Fe)},[sn]),g.useEffect(()=>{if(!sn)return;const Fe=jt=>{jt.preventDefault(),jt.stopImmediatePropagation(),Ln({action:()=>{Je(!1),An(!1);const{page:wt,params:tn}=jt.detail||{};wt&&Rt.navigate(wt,tn)}})};return window.addEventListener("markus:navigate",Fe),()=>window.removeEventListener("markus:navigate",Fe)},[sn]);const Gr=g.useRef(!1);g.useEffect(()=>{if(!Bt){Gr.current=!1;return}if(a||Gr.current)return;const Fe=400,jt=qe?0:l.width??384;window.innerWidth-160-jt-Fe<480&&!qe&&ct(!0)},[Bt,a,qe,l.width]);const yn=g.useRef(null),Br=g.useCallback((Fe,jt)=>{const wt=Fe.length>30?`${Fe.slice(0,15)}…${Fe.slice(-12)}`:Fe,tn=`sel_${Date.now()}`;let Rn;if(jt){const mn=B?.reference??"";Rn=["[html-selection]",`Text: "${Fe}"`,`CSS Selector: ${jt.cssSelector}`,`XPath: ${jt.xpath}`,mn?`File: ${mn}`:""].filter(Boolean).join(`
776
- `)}else Rn=Fe;st(mn=>[...mn,{id:tn,label:jt?`🌐 ${wt}`:wt,type:"selection",content:Rn,onRemove:()=>st(Ir=>Ir.filter(is=>is.id!==tn))}]),Bt||gt(!0),en(null),window.getSelection()?.removeAllRanges()},[Bt,B?.reference]),nr=g.useCallback(Fe=>{if(!Fe.text.trim())return;const wt=yn.current?.querySelector("iframe")?.getBoundingClientRect(),tn=(wt?.left??0)+Fe.rect.x+Fe.rect.width/2,Rn=(wt?.top??0)+Fe.rect.y;en({x:tn,y:Rn,text:Fe.text,htmlMeta:{xpath:Fe.xpath,cssSelector:Fe.cssSelector}})},[]);return g.useEffect(()=>{const Fe=yn.current;if(!Fe)return;const jt=()=>{requestAnimationFrame(()=>{const tn=window.getSelection(),Rn=tn?.toString().trim();if(!Rn||!tn?.rangeCount){en(null);return}const mn=tn.getRangeAt(0);if(!Fe.contains(mn.commonAncestorContainer)){en(null);return}const Ir=mn.getBoundingClientRect();en({x:Ir.left+Ir.width/2,y:Ir.top,text:Rn})})},wt=tn=>{const Rn=document.getElementById("selection-toolbar");Rn&&Rn.contains(tn.target)||en(null)};return Fe.addEventListener("mouseup",jt),document.addEventListener("mousedown",wt),()=>{Fe.removeEventListener("mouseup",jt),document.removeEventListener("mousedown",wt)}},[]),t.jsxs("div",{className:"flex-1 overflow-hidden flex",children:[t.jsxs("div",{className:`${a?"flex-1 min-w-0":"shrink-0"} flex flex-col bg-surface-secondary rounded-xl m-1 mr-0`,style:a?c?{display:"none"}:void 0:qe?{display:"none"}:{width:l.width},children:[t.jsxs("div",{className:"p-4 space-y-3",children:[t.jsx("div",{className:"flex items-center justify-between gap-2",children:t.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[a&&t.jsx(Ac,{}),!a&&t.jsx("button",{onClick:()=>ct(!0),className:"w-8 h-8 flex items-center justify-center rounded-lg transition-colors shrink-0 bg-brand-500/15 text-brand-500 hover:bg-brand-500/25",title:s("sidebar.collapse"),children:t.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[t.jsx("rect",{x:"3",y:"3",width:"18",height:"18",rx:"2",ry:"2"}),t.jsx("line",{x1:"9",y1:"3",x2:"9",y2:"21"})]})}),t.jsxs("h2",{className:"text-sm font-semibold text-fg-secondary truncate",children:[s("title"),v>0&&t.jsxs("span",{className:"ml-1.5 text-fg-tertiary font-normal",children:["(",v,")"]})]})]})}),t.jsxs("div",{className:"relative",children:[t.jsxs("svg",{className:"absolute left-3 top-1/2 -translate-y-1/2 w-3.5 h-3.5 text-fg-muted pointer-events-none",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round",children:[t.jsx("circle",{cx:"11",cy:"11",r:"8"}),t.jsx("line",{x1:"21",y1:"21",x2:"16.65",y2:"16.65"})]}),t.jsx("input",{ref:Wn,value:M,onChange:Fe=>$(Fe.target.value),placeholder:s("searchPlaceholder"),className:"w-full bg-surface-elevated border border-border-default rounded-lg pl-8 pr-8 py-2 text-sm text-fg-primary focus:border-brand-500 focus:outline-none transition-colors"}),M&&t.jsx("button",{onClick:()=>{$(""),z("")},className:"absolute right-2.5 top-1/2 -translate-y-1/2 w-4 h-4 flex items-center justify-center rounded-full bg-surface-overlay text-fg-tertiary hover:text-fg-secondary transition-colors",children:t.jsxs("svg",{width:"10",height:"10",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"3",strokeLinecap:"round",children:[t.jsx("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),t.jsx("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]})})]}),xt&&!a&&t.jsxs("div",{className:"flex items-center gap-2 px-2.5 py-1.5 bg-surface-elevated rounded-lg text-[10px] text-fg-tertiary",children:[t.jsx("span",{className:"truncate font-mono",children:xt}),t.jsx("button",{onClick:()=>{ae.system.openPath(xt)},className:"shrink-0 underline hover:text-fg-secondary transition-colors",children:s("common:open")})]}),a&&t.jsxs("button",{onClick:()=>ye(Fe=>!Fe),className:`flex items-center gap-1.5 px-2.5 py-1.5 rounded-lg text-xs transition-colors ${ge||Jt?"bg-brand-500/15 text-brand-500":"bg-surface-elevated text-fg-secondary"}`,children:[t.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[t.jsx("line",{x1:"4",y1:"6",x2:"20",y2:"6"}),t.jsx("line",{x1:"8",y1:"12",x2:"20",y2:"12"}),t.jsx("line",{x1:"12",y1:"18",x2:"20",y2:"18"})]}),s("filters.filtersLabel"),Jt&&t.jsx("span",{className:"w-1.5 h-1.5 rounded-full bg-brand-500"}),t.jsx("svg",{className:`w-3 h-3 ml-auto transition-transform ${ge?"rotate-180":""}`,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",children:t.jsx("polyline",{points:"6 9 12 15 18 9"})})]}),t.jsxs("div",{className:a&&!ge?"hidden":"space-y-3",children:[t.jsxs("div",{className:"flex gap-1 overflow-x-auto scrollbar-hide filter-pills-fade",children:[t.jsx(T1,{label:s("filters.allTypes"),value:"",current:A||D||"",onClick:()=>{H(""),O("")}}),Vde.map(Fe=>t.jsx(T1,{label:`${vd[Fe]?.icon??""} ${Fe}`,value:Fe,current:A,onClick:jt=>{H(jt),O("")}},Fe)),["agent","team","skill"].map(Fe=>t.jsx(T1,{label:`${Tl[Fe].icon} ${s(`artifactTypes.${Fe}`)}`,value:Fe,current:D,onClick:jt=>{O(jt),H("")}},Fe))]}),t.jsxs("div",{className:"flex gap-1.5 items-center",children:[t.jsx("span",{className:"text-[10px] text-fg-tertiary",children:s("filters.group")}),["date","project","team","agent"].map(Fe=>t.jsx("button",{onClick:()=>{J(Fe)},className:`px-2 py-1 rounded text-xs transition-colors ${q===Fe?"bg-brand-600 text-white":"bg-surface-elevated text-fg-secondary hover:bg-surface-overlay"}`,children:s(`groupBy.${Fe}`)},Fe)),Wt.length>1&&t.jsx("button",{onClick:St,className:"ml-auto px-1.5 py-1 rounded text-[10px] text-fg-tertiary hover:text-fg-secondary hover:bg-surface-elevated transition-colors",title:s(Ye?"expandAllTooltip":"collapseAllTooltip"),children:s(Ye?"expandAll":"collapseAll")})]})]}),Jt&&t.jsxs("div",{className:"flex items-center gap-1 flex-wrap",children:[U&&t.jsxs("span",{className:"inline-flex items-center gap-1 px-1.5 py-0.5 rounded bg-brand-500/10 text-brand-500 text-[10px]",children:["“",U,"”",t.jsx("button",{onClick:()=>{$(""),z("")},className:"hover:text-brand-400",children:t.jsxs("svg",{width:"8",height:"8",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"3",strokeLinecap:"round",children:[t.jsx("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),t.jsx("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]})})]}),A&&t.jsxs("span",{className:"inline-flex items-center gap-1 px-1.5 py-0.5 rounded bg-brand-500/10 text-brand-500 text-[10px]",children:[vd[A]?.icon," ",A,t.jsx("button",{onClick:()=>H(""),className:"hover:text-brand-400",children:t.jsxs("svg",{width:"8",height:"8",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"3",strokeLinecap:"round",children:[t.jsx("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),t.jsx("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]})})]}),D&&t.jsxs("span",{className:"inline-flex items-center gap-1 px-1.5 py-0.5 rounded bg-brand-500/10 text-brand-500 text-[10px]",children:[Tl[D]?.icon," ",s(`artifactTypes.${D}`),t.jsx("button",{onClick:()=>O(""),className:"hover:text-brand-400",children:t.jsxs("svg",{width:"8",height:"8",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"3",strokeLinecap:"round",children:[t.jsx("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),t.jsx("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]})})]}),t.jsx("button",{onClick:gn,className:"text-[10px] text-fg-tertiary hover:text-brand-500 ml-auto transition-colors",children:s("filters.clearAll")})]})]}),X&&t.jsx("div",{className:`mx-4 mt-2 px-3 py-1.5 text-xs rounded-lg ${X.type==="success"?"bg-green-500/15 text-green-600":"bg-red-500/15 text-red-500"}`,children:X.text}),t.jsxs("div",{ref:Le,className:"flex-1 overflow-y-auto p-2 space-y-1 transition-opacity duration-150",style:{opacity:P?.5:1},onTouchStart:a?Fe=>{ue.onTouchStart(Fe),Pn(Fe)}:void 0,onTouchEnd:a?Fe=>{ue.onTouchEnd(Fe),kr(Fe)}:void 0,children:[we&&t.jsxs("div",{className:"flex items-center justify-center gap-2 py-2 text-brand-500",children:[t.jsx(a6,{})," ",t.jsx("span",{className:"text-[10px]",children:s("filters.refreshing")})]}),P?t.jsx("div",{className:"p-4 space-y-3",children:[1,2,3].map(Fe=>t.jsxs("div",{className:"animate-pulse space-y-2",children:[t.jsx("div",{className:"h-4 bg-surface-elevated rounded w-3/4"}),t.jsx("div",{className:"h-3 bg-surface-elevated rounded w-1/2"})]},Fe))}):b.length===0?t.jsxs("div",{className:"flex flex-col items-center justify-center py-16 px-6 text-center",children:[t.jsx("svg",{className:"w-12 h-12 text-fg-muted mb-3",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:1,children:t.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M19.5 14.25v-2.625a3.375 3.375 0 00-3.375-3.375h-1.5A1.125 1.125 0 0113.5 7.125v-1.5a3.375 3.375 0 00-3.375-3.375H8.25m0 12.75h7.5m-7.5 3H12M10.5 2.25H5.625c-.621 0-1.125.504-1.125 1.125v17.25c0 .621.504 1.125 1.125 1.125h12.75c.621 0 1.125-.504 1.125-1.125V11.25a9 9 0 00-9-9z"})}),Jt?t.jsxs(t.Fragment,{children:[t.jsx("p",{className:"text-sm text-fg-secondary",children:s("empty.noResults")}),t.jsx("p",{className:"text-xs text-fg-tertiary mt-1 mb-3",children:s("empty.noResultsHint")}),t.jsx("button",{onClick:gn,className:"text-xs px-3 py-1.5 rounded-lg bg-brand-600 hover:bg-brand-500 text-white transition-colors",children:s("filters.clearAll")})]}):t.jsxs(t.Fragment,{children:[t.jsx("p",{className:"text-sm text-fg-secondary",children:s("empty.title")}),t.jsx("p",{className:"text-xs text-fg-tertiary mt-1 mb-3",children:s("empty.subtitle")}),t.jsx("button",{onClick:()=>Rt.navigate(Be.WORK),className:"text-xs px-3 py-1.5 rounded-lg bg-brand-600 hover:bg-brand-500 text-white transition-colors",children:s("empty.goToWork")})]})]}):Wt.map(([Fe,jt])=>{const wt=pe(Fe);return t.jsxs("div",{className:"mb-1",children:[t.jsxs("button",{onClick:()=>lt(Fe),className:"w-full flex items-center gap-1.5 px-2 py-2 rounded-md hover:bg-surface-elevated/50 transition-colors group/header border-b border-border-subtle/50",children:[t.jsx("svg",{className:`w-3 h-3 text-fg-tertiary transition-transform duration-200 shrink-0 ${wt?"":"rotate-90"}`,fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2.5,children:t.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M9 5l7 7-7 7"})}),t.jsx("span",{className:"text-[11px] font-semibold text-fg-tertiary uppercase tracking-wider truncate",children:jt.label}),t.jsxs("span",{className:"text-[10px] text-fg-muted bg-surface-elevated px-1.5 py-0.5 rounded-full shrink-0",children:[jt.items.length,b.length<v?"+":""]})]}),t.jsx("div",{className:`overflow-hidden transition-all duration-200 ${wt?"max-h-0 opacity-0":"max-h-[5000px] opacity-100"}`,children:jt.items.map(tn=>t.jsx("button",{onClick:()=>rr(tn),className:`w-full text-left px-3 py-2 rounded-lg transition-all duration-150 ${B?.id===tn.id?"bg-brand-600/15 border-l-2 border-l-brand-500 border-y border-r border-y-brand-500/20 border-r-brand-500/20":"hover:bg-surface-elevated/60 border-l-2 border-l-transparent border-y border-r border-transparent"}`,children:t.jsxs("div",{className:"flex items-center gap-1.5 min-w-0",children:[tn.artifactType&&Tl[tn.artifactType]?t.jsx("span",{className:`text-[10px] px-1 py-0.5 rounded font-medium shrink-0 ${Tl[tn.artifactType].color}`,children:Tl[tn.artifactType].icon}):t.jsx("span",{className:`text-[10px] px-1 py-0.5 rounded font-medium uppercase shrink-0 ${vd[tn.type]?.color??"bg-surface-overlay text-fg-secondary"}`,children:vd[tn.type]?.icon??tn.type.charAt(0)}),t.jsx("span",{className:"text-sm font-medium text-fg-primary truncate flex-1",children:tn.title}),Ke.has(tn.id)&&t.jsx("span",{className:"shrink-0 text-amber-500",title:s("detail.fileMissing"),children:t.jsxs("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[t.jsx("path",{d:"M10.29 3.86L1.82 18a2 2 0 001.71 3h16.94a2 2 0 001.71-3L13.71 3.86a2 2 0 00-3.42 0z"}),t.jsx("line",{x1:"12",y1:"9",x2:"12",y2:"13"}),t.jsx("line",{x1:"12",y1:"17",x2:"12.01",y2:"17"})]})}),t.jsx("span",{className:"text-[10px] text-fg-muted shrink-0",children:Wde(tn.updatedAt,s)})]})},tn.id))})]},Fe)}),C&&t.jsxs("div",{className:"flex items-center justify-center gap-2 py-3 text-fg-tertiary",children:[t.jsx(a6,{})," ",t.jsx("span",{className:"text-[10px]",children:s("common:loadingMore")})]}),!P&&b.length>0&&t.jsx("div",{className:"text-center text-[10px] text-fg-tertiary py-2",children:b.length<v?s("count.partial",{loaded:b.length,total:v}):s("count.total",{total:v})})]})]}),!a&&t.jsx("div",{className:"w-2 shrink-0 cursor-col-resize group relative flex items-center justify-center hover:bg-brand-500/5 transition-colors",onMouseDown:l.onResizeStart,children:t.jsxs("div",{className:"flex flex-col gap-1 items-center opacity-0 group-hover:opacity-100 transition-opacity",children:[t.jsx("div",{className:"w-1 h-1 rounded-full bg-fg-muted"}),t.jsx("div",{className:"w-1 h-1 rounded-full bg-fg-muted"}),t.jsx("div",{className:"w-1 h-1 rounded-full bg-fg-muted"})]})}),(!a||c)&&t.jsxs("div",{className:"flex-1 overflow-hidden min-w-0 flex relative",children:[t.jsxs("div",{ref:yn,className:"flex-1 overflow-y-auto min-w-0",children:[qe&&!a&&t.jsxs("div",{className:"sticky top-0 z-10 bg-surface-primary/80 backdrop-blur-sm px-4 py-2 flex items-center gap-2",children:[t.jsx("button",{onClick:()=>{Gr.current=!0,ct(!1)},className:"w-8 h-8 flex items-center justify-center rounded-lg transition-colors shrink-0 text-fg-tertiary hover:text-fg-secondary hover:bg-surface-elevated",title:s("sidebar.expand"),children:t.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[t.jsx("rect",{x:"3",y:"3",width:"18",height:"18",rx:"2",ry:"2"}),t.jsx("line",{x1:"9",y1:"3",x2:"9",y2:"21"})]})}),t.jsx("span",{className:"text-sm font-medium text-fg-secondary truncate",children:B?.title??s("detail.details")})]}),a&&t.jsxs("div",{className:"sticky top-0 z-10 bg-surface-secondary px-4 py-2.5 flex items-center gap-2",children:[t.jsx("button",{onClick:()=>history.back(),className:"text-fg-secondary hover:text-fg-primary transition-colors p-1 -ml-1",children:t.jsx("svg",{width:"20",height:"20",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:t.jsx("polyline",{points:"15 18 9 12 15 6"})})}),t.jsx("span",{className:"text-sm font-medium truncate",children:B?.title??s("detail.details")})]}),B?t.jsxs("div",{className:"p-6 space-y-4",children:[!n&&Ke.has(B.id)&&t.jsxs("div",{className:"flex items-center gap-2 px-3 py-2 bg-amber-500/10 border border-amber-500/20 rounded-lg text-amber-600 text-xs",children:[t.jsxs("svg",{className:"w-4 h-4 shrink-0",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[t.jsx("path",{d:"M10.29 3.86L1.82 18a2 2 0 001.71 3h16.94a2 2 0 001.71-3L13.71 3.86a2 2 0 00-3.42 0z"}),t.jsx("line",{x1:"12",y1:"9",x2:"12",y2:"13"}),t.jsx("line",{x1:"12",y1:"17",x2:"12.01",y2:"17"})]}),t.jsx("span",{children:s("detail.fileMissing")})]}),t.jsxs("div",{className:"space-y-3",children:[t.jsxs("div",{className:"flex items-start justify-between gap-3",children:[t.jsx("h2",{className:"text-xl font-semibold text-fg-primary",children:B.title}),!n&&t.jsx("button",{onClick:()=>vt(B),disabled:!!ee,className:"p-1.5 rounded-lg text-fg-tertiary hover:text-red-500 hover:bg-red-500/10 transition-colors disabled:opacity-50 shrink-0",title:s("common:remove"),children:t.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[t.jsx("polyline",{points:"3 6 5 6 21 6"}),t.jsx("path",{d:"M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6m3 0V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2"})]})})]}),t.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[t.jsxs("span",{className:`px-2 py-0.5 rounded text-xs font-medium uppercase ${vd[B.type]?.color??"bg-surface-overlay text-fg-secondary"}`,children:[vd[B.type]?.icon??""," ",B.type]}),B.artifactType&&Tl[B.artifactType]&&t.jsxs("span",{className:`px-2 py-0.5 rounded text-xs font-medium ${Tl[B.artifactType].color}`,children:[Tl[B.artifactType].icon," ",s("detail.builderWithType",{type:s(`artifactTypes.${B.artifactType}`)})]}),B.tags.length>0&&B.tags.map(Fe=>t.jsx("span",{className:"px-2 py-0.5 text-xs bg-surface-elevated text-fg-secondary rounded",children:Fe},Fe))]}),(B.taskId||B.agentId||mr(B.projectId))&&t.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[B.taskId&&t.jsx("button",{onClick:()=>Rt.navigate(Be.WORK,{openTask:B.taskId}),className:"text-xs text-brand-500 hover:underline bg-brand-500/10 px-2 py-0.5 rounded",children:s("links.task",{id:`${B.taskId.slice(0,12)}...`})}),B.agentId&&t.jsx("button",{onClick:()=>Rt.navigate(Be.TEAM,{selectAgent:B.agentId}),className:"text-xs text-blue-600 hover:underline bg-blue-500/10 px-2 py-0.5 rounded",children:s("links.agent",{name:Cn.get(B.agentId)?.name??B.agentId.slice(0,12)})}),mr(B.projectId)&&t.jsx("button",{onClick:()=>Rt.navigate(Be.WORK,{projectId:B.projectId}),className:"text-xs text-blue-600 hover:underline bg-blue-500/10 px-2 py-0.5 rounded",children:s("links.project",{name:mr(B.projectId)})})]}),(B.diffStats||B.testResults)&&t.jsxs("div",{className:"flex gap-3 flex-wrap",children:[B.diffStats&&t.jsxs("div",{className:"bg-surface-elevated rounded-lg px-3 py-2 text-xs flex items-center gap-2",children:[t.jsxs("span",{className:"text-fg-tertiary font-medium",children:[s("diffStats.title"),":"]}),t.jsx("span",{className:"text-fg-secondary",children:s("diffStats.files",{count:B.diffStats.filesChanged})}),t.jsxs("span",{className:"text-green-600",children:["+",B.diffStats.additions]}),t.jsxs("span",{className:"text-red-500",children:["-",B.diffStats.deletions]})]}),B.testResults&&t.jsxs("div",{className:"bg-surface-elevated rounded-lg px-3 py-2 text-xs flex items-center gap-2",children:[t.jsxs("span",{className:"text-fg-tertiary font-medium",children:[s("testResults.title"),":"]}),t.jsx("span",{className:"text-green-600",children:s("testResults.passed",{count:B.testResults.passed})}),t.jsx("span",{className:"text-red-500",children:s("testResults.failed",{count:B.testResults.failed})}),t.jsx("span",{className:"text-fg-secondary",children:s("testResults.skipped",{count:B.testResults.skipped})})]})]}),t.jsxs("div",{className:"flex items-center gap-4 text-[10px] text-fg-tertiary flex-wrap",children:[t.jsxs("span",{children:[s("metadata.created")," ",new Date(B.createdAt).toLocaleString()]}),t.jsxs("span",{children:[s("metadata.updated")," ",new Date(B.updatedAt).toLocaleString()]}),t.jsx("span",{className:"text-fg-muted select-all",children:B.id.slice(0,12)})]}),B.reference&&!sh(B.reference)&&B.type==="file"&&t.jsxs("div",{className:"flex items-center gap-2 bg-surface-elevated rounded-lg px-3 py-2",children:[t.jsx("button",{onClick:()=>{ae.files.reveal(B.reference).catch(()=>br("error",s("detail.failedToOpenBrowser")))},className:"text-xs font-mono text-brand-500 hover:text-brand-500 hover:underline truncate flex-1 text-left cursor-pointer",title:s("detail.openInFileBrowser"),children:B.reference}),t.jsx("button",{onClick:()=>{ae.files.reveal(B.reference).catch(()=>br("error",s("detail.failedToOpenBrowser")))},className:"px-2 py-1 text-[10px] rounded bg-brand-600/20 text-brand-500 hover:bg-brand-600/30 transition-colors shrink-0",title:s("detail.revealInFinder"),children:s("common:open")}),t.jsx("button",{onClick:()=>Mr(B.reference),className:`px-2 py-1 text-[10px] rounded transition-colors shrink-0 ${Ae?"bg-green-500/20 text-green-600":"bg-surface-overlay/50 text-fg-secondary hover:bg-surface-overlay"}`,title:s("detail.copyPath"),children:s(Ae?"common:copied":"common:copy")})]}),B.reference&&!sh(B.reference)&&B.type!=="file"&&B.type!=="directory"&&t.jsx("span",{className:"text-xs text-fg-tertiary font-mono break-all",children:B.reference})]}),B.artifactType&&B.artifactData?t.jsxs("div",{className:"space-y-4",children:[t.jsx("div",{className:"bg-surface-elevated rounded-xl p-5",children:t.jsx(zde,{artifact:B.artifactData,mode:B.artifactType})}),B.reference&&t.jsxs("div",{className:"px-3 py-2 bg-surface-elevated rounded-lg",children:[t.jsx("span",{className:"text-[10px] text-fg-tertiary uppercase tracking-wider block mb-1",children:s("detail.artifactDirectory")}),t.jsx("span",{className:"text-xs text-fg-secondary font-mono break-all",children:B.reference})]}),t.jsx("div",{className:"flex gap-2",children:t.jsx("button",{onClick:pr,className:"flex-1 px-4 py-2.5 bg-brand-600 hover:bg-brand-500 text-white text-sm font-medium rounded-lg transition-colors",children:s("detail.openInBuilder")})}),B.summary&&t.jsx("div",{className:"bg-surface-elevated rounded-xl p-5",children:t.jsx(fs,{content:B.summary,className:"text-fg-secondary text-sm"})})]}):B.reference&&sh(B.reference)?t.jsxs("div",{className:"space-y-4",children:[B.summary&&t.jsx("div",{className:"bg-surface-elevated rounded-xl p-5",children:t.jsx(fs,{content:B.summary,className:"text-fg-secondary text-sm"})}),t.jsxs("div",{className:"flex flex-col items-center justify-center py-10",children:[t.jsxs("svg",{className:"w-10 h-10 text-fg-muted mb-3",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round",children:[t.jsx("path",{d:"M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6"}),t.jsx("polyline",{points:"15 3 21 3 21 9"}),t.jsx("line",{x1:"10",y1:"14",x2:"21",y2:"3"})]}),t.jsx("p",{className:"text-xs text-fg-tertiary font-mono mb-4 px-4 text-center break-all select-all",children:B.reference}),t.jsx("button",{onClick:()=>window.open(B.reference,"_blank","noopener,noreferrer"),className:"px-6 py-2.5 bg-brand-600 hover:bg-brand-500 text-white text-sm font-medium rounded-lg transition-colors",children:s("detail.openUrl")})]})]}):B.type==="directory"&&B.reference?t.jsxs("div",{className:"space-y-4",children:[B.summary&&t.jsx("div",{className:"bg-surface-elevated rounded-xl p-5",children:t.jsx(fs,{content:B.summary,className:"text-fg-secondary text-sm"})}),t.jsxs("div",{className:"flex flex-col items-center justify-center py-10",children:[t.jsx("svg",{className:"w-10 h-10 text-fg-muted mb-3",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round",children:t.jsx("path",{d:"M22 19a2 2 0 0 1-2 2H4a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h5l2 3h9a2 2 0 0 1 2 2z"})}),t.jsx("p",{className:"text-xs text-fg-tertiary font-mono mb-4 px-4 text-center break-all select-all",children:B.reference}),t.jsx("button",{onClick:()=>{ae.files.reveal(B.reference).catch(()=>br("error",s("detail.failedToOpenBrowser")))},className:"px-6 py-2.5 bg-brand-600 hover:bg-brand-500 text-white text-sm font-medium rounded-lg transition-colors",children:s("detail.openInFileBrowser")})]})]}):t.jsxs("div",{className:"bg-surface-elevated rounded-xl overflow-hidden",children:[($e||B.summary)&&!ve&&!Ve&&!W&&B.reference&&B.type==="file"&&(Ee==="markdown"||Ee==="text"||Ee==="html")&&t.jsxs("div",{className:"flex items-center gap-2 px-4 py-2 border-b border-border-subtle bg-surface-secondary/50",children:[t.jsx("button",{onClick:Sr,className:`px-3 py-1 rounded text-xs font-medium transition-colors ${be?"text-fg-tertiary hover:text-fg-secondary":"bg-brand-600/20 text-brand-500"}`,children:s("detail.preview")}),t.jsx("button",{onClick:Bn,className:`px-3 py-1 rounded text-xs font-medium transition-colors ${be?"bg-brand-600/20 text-brand-500":"text-fg-tertiary hover:text-fg-secondary"}`,children:s("detail.edit")}),t.jsx("div",{className:"flex-1"}),be&&t.jsx("button",{onClick:Kn,disabled:!sn||Ut,className:"px-3 py-1 rounded text-xs font-medium bg-brand-600 hover:bg-brand-500 text-white transition-colors disabled:opacity-40 disabled:cursor-not-allowed",children:s(Ut?"detail.saving":"detail.save")})]}),t.jsx("div",{className:"p-5",children:ve?t.jsxs("div",{className:"animate-pulse space-y-4",children:[t.jsx("div",{className:"h-4 bg-surface-overlay/60 rounded w-full"}),t.jsx("div",{className:"h-4 bg-surface-overlay/60 rounded w-5/6"}),t.jsx("div",{className:"h-4 bg-surface-overlay/60 rounded w-4/6"}),t.jsx("div",{className:"h-32 bg-surface-overlay/40 rounded-lg w-full mt-2"}),t.jsx("div",{className:"h-4 bg-surface-overlay/60 rounded w-3/4"}),t.jsx("div",{className:"h-4 bg-surface-overlay/60 rounded w-2/3"})]}):Ve?t.jsxs("div",{className:"flex flex-col items-center gap-2",children:[t.jsx("img",{src:Ve.src,alt:Ve.name,className:"max-w-full max-h-[60vh] rounded-lg object-contain"}),t.jsx("span",{className:"text-xs text-fg-tertiary",children:Ve.name})]}):$e?be?t.jsx("div",{className:"animate-fadeIn",children:t.jsx("textarea",{ref:On,value:it,onChange:Fe=>{It(Fe.target.value),An(!0)},className:"w-full min-h-[120px] p-3 text-sm font-mono bg-surface-primary border border-border-subtle rounded-lg text-fg-secondary focus:outline-none focus:ring-1 focus:ring-brand-500/50 overflow-hidden",style:{resize:"none"},spellCheck:!1})},"edit"):t.jsx("div",{className:"animate-fadeIn",children:t.jsx(Bv,{content:$e,format:Ee,className:"text-fg-secondary text-sm",onHtmlSelection:nr})},"preview"):W?t.jsxs("div",{className:"space-y-3",children:[t.jsx("p",{className:"text-sm text-fg-secondary",children:s("detail.cannotPreview",{type:B.type})}),t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx("button",{onClick:()=>{ae.files.reveal(B.reference).catch(()=>br("error",s("detail.failedToOpen")))},className:"text-xs bg-surface-elevated px-3 py-2 rounded text-brand-500 hover:text-brand-500 hover:underline flex-1 truncate text-left cursor-pointer font-mono",title:s("detail.openInFileBrowser"),children:B.reference}),t.jsx("button",{onClick:()=>{ae.files.reveal(B.reference).catch(()=>br("error",s("detail.failedToOpen")))},className:"px-3 py-2 text-xs rounded-lg bg-brand-600/20 text-brand-500 hover:bg-brand-600/30 transition-colors shrink-0",children:s("common:open")}),t.jsx("button",{onClick:()=>Mr(B.reference),className:`px-3 py-2 text-xs rounded-lg transition-colors shrink-0 ${Ae?"bg-green-500/20 text-green-600":"bg-surface-overlay/50 text-fg-secondary hover:bg-surface-overlay"}`,children:s(Ae?"common:copied":"common:copy")})]})]}):B.summary?be?t.jsx("textarea",{ref:On,value:it,onChange:Fe=>{It(Fe.target.value),An(!0)},className:"w-full min-h-[120px] p-3 text-sm font-mono bg-surface-primary border border-border-subtle rounded-lg text-fg-secondary focus:outline-none focus:ring-1 focus:ring-brand-500/50 overflow-hidden",style:{resize:"none"},spellCheck:!1}):t.jsx(fs,{content:B.summary,className:"text-fg-secondary text-sm"}):t.jsx("p",{className:"text-sm text-fg-tertiary italic",children:s("detail.noContent")})})]})]}):t.jsx("div",{className:"flex-1 flex items-center justify-center h-full",children:t.jsxs("div",{className:"text-center text-fg-tertiary space-y-3 max-w-xs",children:[t.jsx("div",{className:"w-16 h-16 mx-auto rounded-2xl bg-surface-elevated/60 flex items-center justify-center",children:t.jsx("svg",{className:"w-8 h-8 text-fg-muted",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:1,children:t.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M19.5 14.25v-2.625a3.375 3.375 0 00-3.375-3.375h-1.5A1.125 1.125 0 0113.5 7.125v-1.5a3.375 3.375 0 00-3.375-3.375H8.25m0 12.75h7.5m-7.5 3H12M10.5 2.25H5.625c-.621 0-1.125.504-1.125 1.125v17.25c0 .621.504 1.125 1.125 1.125h12.75c.621 0 1.125-.504 1.125-1.125V11.25a9 9 0 00-9-9z"})})}),t.jsx("p",{className:"text-sm text-fg-secondary",children:s("detail.selectToView")}),!a&&t.jsx("p",{className:"text-[10px] text-fg-muted",children:s("detail.keyboardHint")})]})})]}),B?.agentId&&!Bt&&!a&&t.jsx("button",{onClick:()=>gt(!0),className:"absolute bottom-6 right-6 w-12 h-12 rounded-full bg-brand-600 hover:bg-brand-500 text-white shadow-lg shadow-black/20 flex items-center justify-center transition-all hover:scale-105 z-20 animate-fab-in",title:s("chat.openChat"),children:t.jsx("svg",{width:"20",height:"20",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:t.jsx("path",{d:"M21 15a2 2 0 0 1-2 2H7l-4 4V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2z"})})}),Bt&&B?.agentId&&!a&&t.jsx(qde,{agentId:B.agentId,agents:S,authUser:e,onClose:()=>{gt(!1),st([])},contextChips:[{id:`deliverable_ctx_${B.id}`,label:`📦 ${B.title}`,type:"deliverable",content:`${s("chat.currentDeliverable")}: ${B.title} (id: ${B.id})`},...cn],width:400})]}),Ct&&t.jsx("div",{id:"selection-toolbar",className:"fixed z-50 -translate-x-1/2 -translate-y-full bg-surface-elevated border border-border-default rounded-lg shadow-xl overflow-hidden",style:{left:Ct.x,top:Ct.y-8},children:t.jsxs("button",{onMouseDown:Fe=>{Fe.preventDefault(),Fe.stopPropagation(),Br(Ct.text,Ct.htmlMeta)},className:"px-3 py-1.5 text-xs text-fg-secondary hover:bg-surface-overlay hover:text-fg-primary transition-colors flex items-center gap-1.5 whitespace-nowrap",children:[t.jsx("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:t.jsx("path",{d:"M21 15a2 2 0 0 1-2 2H7l-4 4V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2z"})}),s("contextMenu.addToConversation")]})}),tt&&t.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/60",onClick:()=>vt(null),children:t.jsxs("div",{className:"bg-surface-secondary border border-border-default rounded-xl p-6 max-w-sm mx-4 shadow-2xl",onClick:Fe=>Fe.stopPropagation(),children:[t.jsxs("div",{className:"flex items-center gap-3 mb-4",children:[t.jsx("div",{className:"w-10 h-10 rounded-full bg-red-500/15 flex items-center justify-center shrink-0",children:t.jsxs("svg",{className:"w-5 h-5 text-red-500",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[t.jsx("polyline",{points:"3 6 5 6 21 6"}),t.jsx("path",{d:"M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6m3 0V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2"})]})}),t.jsxs("div",{children:[t.jsx("div",{className:"text-sm font-medium text-fg-primary",children:s("detail.confirmRemoveTitle")}),t.jsx("div",{className:"text-xs text-fg-secondary mt-0.5",children:s("detail.confirmRemoveMessage",{name:tt.title})})]})]}),t.jsxs("div",{className:"flex justify-end gap-2",children:[t.jsx("button",{onClick:()=>vt(null),className:"px-4 py-1.5 text-xs text-fg-secondary hover:text-fg-primary border border-border-default hover:border-gray-600 rounded-lg transition-colors",children:s("common:cancel")}),t.jsx("button",{onClick:()=>{const Fe=tt;vt(null),pn(Fe)},disabled:!!ee,className:"px-4 py-1.5 text-xs bg-red-600 hover:bg-red-500 text-white rounded-lg transition-colors disabled:opacity-50",children:s("common:remove")})]})]})}),on&&t.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/60",onClick:()=>Ln(null),children:t.jsxs("div",{className:"bg-surface-secondary border border-border-default rounded-xl p-6 max-w-sm mx-4 shadow-2xl",onClick:Fe=>Fe.stopPropagation(),children:[t.jsxs("div",{className:"flex items-center gap-3 mb-4",children:[t.jsx("div",{className:"w-10 h-10 rounded-full bg-amber-500/15 flex items-center justify-center shrink-0",children:t.jsx("svg",{className:"w-5 h-5 text-amber-500",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:t.jsx("path",{d:"M12 9v2m0 4h.01m-6.938 4h13.856c1.54 0 2.502-1.667 1.732-2.5L13.732 4c-.77-.833-1.964-.833-2.732 0L4.082 16.5c-.77.833.192 2.5 1.732 2.5z"})})}),t.jsxs("div",{children:[t.jsx("div",{className:"text-sm font-medium text-fg-primary",children:s("detail.unsavedTitle")}),t.jsx("div",{className:"text-xs text-fg-secondary mt-0.5",children:s("detail.unsavedMessage")})]})]}),t.jsxs("div",{className:"flex justify-end gap-2",children:[t.jsx("button",{onClick:()=>Ln(null),className:"px-4 py-1.5 text-xs text-fg-secondary hover:text-fg-primary border border-border-default hover:border-gray-600 rounded-lg transition-colors",children:s("common:cancel")}),t.jsx("button",{onClick:()=>{$n(),on.action()},className:"px-4 py-1.5 text-xs text-fg-secondary hover:text-fg-primary border border-border-default hover:border-gray-600 rounded-lg transition-colors",children:s("detail.discard")}),t.jsx("button",{onClick:async()=>{await Kn(),on.action(),Ln(null)},className:"px-4 py-1.5 text-xs bg-brand-600 hover:bg-brand-500 text-white rounded-lg transition-colors",children:s("detail.saveAndLeave")})]})]})})]})}function T1({label:e,value:n,current:r,onClick:s}){return t.jsx("button",{onClick:()=>s(r===n?"":n),className:`px-2 py-1 rounded text-xs whitespace-nowrap shrink-0 transition-colors ${r===n?"bg-brand-600 text-white":"bg-surface-elevated text-fg-secondary hover:bg-surface-overlay"}`,children:e})}function a6(){return t.jsxs("svg",{className:"animate-spin h-3.5 w-3.5",viewBox:"0 0 24 24",fill:"none",children:[t.jsx("circle",{className:"opacity-25",cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"4"}),t.jsx("path",{className:"opacity-75",fill:"currentColor",d:"M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4z"})]})}function Do(e){return e.toLocaleString()}function Ed(e){return e<.01?`$${e.toFixed(4)}`:`$${e.toFixed(2)}`}function Kde(e){return e>=1024*1024*1024?`${(e/(1024*1024*1024)).toFixed(1)} GB`:e>=1024*1024?`${(e/(1024*1024)).toFixed(1)} MB`:e>=1024?`${(e/1024).toFixed(1)} KB`:`${e} B`}function i6({authUser:e}){const{t:n}=ht(["reports","common"]),r=ea(),s=Zd(Be.REPORTS),[a,i]=g.useState("weekly"),[l,c]=g.useState(null),[u,m]=g.useState(!0),[f,p]=g.useState(""),[b,x]=g.useState(null),[v,N]=g.useState([]),[C,k]=g.useState("totalTokens"),[j,w]=g.useState(!0),[S,T]=g.useState("generate"),[R,I]=g.useState([]),[P,L]=g.useState(null),[M,$]=g.useState([]),[U,z]=g.useState(""),[A,H]=g.useState(""),D=Y=>{H(Y),setTimeout(()=>H(""),3e3)},O=g.useCallback(async Y=>{m(!0),p("");try{const{report:oe}=await ae.reports.generate({period:Y,scope:"org",orgId:"default"});c(oe)}catch(oe){p(String(oe)),c(null)}m(!1)},[]),q=g.useCallback(()=>{ae.usage.summary().then(Y=>x(Y.usage)).catch(()=>{}),ae.usage.agents().then(Y=>N(Y.agents)).catch(()=>{})},[]),J=g.useCallback(async()=>{try{const{reports:Y}=await ae.reports.list();I(Y)}catch{}},[]),B=g.useCallback(async Y=>{L(Y);try{const{feedback:oe}=await ae.reports.getFeedback(Y.id);$(oe)}catch{$([])}},[]);g.useEffect(()=>{O(a)},[a,O]),g.useEffect(()=>{if(!s)return;q();const Y=setInterval(q,3e4);return()=>clearInterval(Y)},[q,s]),g.useEffect(()=>{S==="history"&&J()},[S,J]);const V=g.useMemo(()=>[...v].sort((Y,oe)=>{const ge=Y[C],ye=oe[C];return j?ye-ge:ge-ye}),[v,C,j]),X=v.reduce((Y,oe)=>Y+oe.estimatedCost,0),K=v.reduce((Y,oe)=>Y+oe.tokensUsedToday,0),ee=v.reduce((Y,oe)=>Y+(oe.costToday??0),0),Q=Math.max(1,...v.map(Y=>Y.totalTokens)),ne=Y=>{C===Y?w(!j):(k(Y),w(!0))},te=g.useMemo(()=>({daily:n("period.today"),weekly:n("period.thisWeek"),monthly:n("period.thisMonth")}),[n]);return t.jsx("div",{className:"flex-1 overflow-y-auto",children:t.jsxs("div",{className:"max-w-5xl mx-auto w-full p-6 space-y-6",children:[t.jsxs("div",{className:"flex flex-col gap-3 md:flex-row md:items-center md:justify-between",children:[t.jsxs("div",{className:"flex items-center gap-4 flex-wrap",children:[r&&t.jsx(Ac,{}),t.jsx("h1",{className:"text-xl font-semibold text-fg-primary",children:n("title")}),t.jsxs("div",{className:"flex gap-1 bg-surface-elevated rounded-lg p-0.5",children:[t.jsx("button",{onClick:()=>T("generate"),className:`px-3 py-1.5 text-xs rounded-md transition-colors ${S==="generate"?"bg-surface-overlay text-fg-primary shadow-sm":"text-fg-tertiary hover:text-fg-secondary"}`,children:n("tabs.generate")}),t.jsxs("button",{onClick:()=>T("history"),className:`px-3 py-1.5 text-xs rounded-md transition-colors ${S==="history"?"bg-surface-overlay text-fg-primary shadow-sm":"text-fg-tertiary hover:text-fg-secondary"}`,children:[n("tabs.history"),R.length>0?` (${R.length})`:""]})]})]}),t.jsxs("div",{className:"flex items-center gap-3 flex-wrap",children:[A&&t.jsx("span",{className:"px-2.5 py-1 bg-green-500/10 text-green-600 text-xs rounded-lg",children:A}),S==="generate"&&t.jsx("div",{className:"flex gap-1 bg-surface-elevated rounded-lg p-0.5",children:["daily","weekly","monthly"].map(Y=>t.jsx("button",{onClick:()=>i(Y),className:`px-3 py-1.5 text-xs rounded-md transition-colors ${a===Y?"bg-surface-overlay text-fg-primary shadow-sm":"text-fg-tertiary hover:text-fg-secondary"}`,children:n(`period.${Y}`)},Y))})]})]}),S==="history"&&!P&&t.jsx("section",{className:"bg-surface-elevated rounded-xl overflow-hidden",children:R.length===0?t.jsx("div",{className:"p-8 text-center text-fg-tertiary text-sm",children:n("noReportsYet")}):t.jsx("div",{className:"divide-y divide-border-default/50",children:R.map(Y=>t.jsxs("button",{onClick:()=>B(Y),className:"w-full text-left px-5 py-3 flex items-center gap-4 hover:bg-surface-elevated/30 transition-colors",children:[t.jsxs("div",{className:"flex-1 min-w-0",children:[t.jsx("div",{className:"text-sm font-medium text-fg-primary",children:n("reportType",{type:Y.type})}),t.jsxs("div",{className:"text-xs text-fg-tertiary mt-0.5",children:[new Date(Y.periodStart).toLocaleDateString()," — ",new Date(Y.periodEnd).toLocaleDateString()]})]}),Y.plan&&t.jsx("span",{className:`px-2 py-0.5 rounded-full text-[10px] font-medium shrink-0 ${Y.plan.status==="approved"?"bg-green-500/10 text-green-600":Y.plan.status==="rejected"?"bg-red-500/10 text-red-500":"bg-amber-500/10 text-amber-600"}`,children:Y.plan.status==="pending"?n("upcomingPlan.planPending"):n("upcomingPlan.planStatus",{status:Y.plan.status})}),t.jsx("span",{className:"text-[10px] text-fg-tertiary shrink-0",children:new Date(Y.generatedAt).toLocaleDateString()})]},Y.id))})}),S==="history"&&P&&t.jsxs(t.Fragment,{children:[t.jsxs("div",{className:"flex items-center gap-3",children:[t.jsx("button",{onClick:()=>{L(null),$([])},className:"text-xs text-fg-tertiary hover:text-fg-secondary",children:n("backToList")}),t.jsx("span",{className:"text-sm font-medium text-fg-primary",children:n("reportType",{type:P.type})}),t.jsxs("span",{className:"text-xs text-fg-tertiary",children:[new Date(P.periodStart).toLocaleDateString()," — ",new Date(P.periodEnd).toLocaleDateString()]})]}),P.metrics&&t.jsxs("section",{className:"bg-surface-elevated rounded-xl p-5",children:[t.jsx("h3",{className:"text-xs font-semibold text-fg-secondary mb-3",children:n("taskMetrics.title")}),t.jsxs("div",{className:"grid grid-cols-2 md:grid-cols-5 gap-4",children:[t.jsx(Xi,{label:n("taskMetrics.completed"),value:P.metrics.tasksCompleted,color:"text-green-600"}),t.jsx(Xi,{label:n("taskMetrics.inProgress"),value:P.metrics.tasksInProgress,color:"text-brand-500"}),t.jsx(Xi,{label:n("taskMetrics.created"),value:P.metrics.tasksCreated,color:"text-blue-600"}),t.jsx(Xi,{label:n("taskMetrics.blocked"),value:P.metrics.tasksBlocked,color:"text-amber-600"}),t.jsx(Xi,{label:n("taskMetrics.failed"),value:P.metrics.tasksFailed,color:"text-red-500"})]})]}),P.costSummary&&t.jsxs("section",{className:"bg-surface-elevated rounded-xl p-5",children:[t.jsx("h3",{className:"text-xs font-semibold text-fg-secondary mb-3",children:n("costOverview.title")}),t.jsxs("div",{className:"grid grid-cols-2 lg:grid-cols-3 gap-4",children:[t.jsxs("div",{children:[t.jsx("div",{className:"text-2xl font-bold text-fg-primary",children:P.costSummary.totalTokens.toLocaleString()}),t.jsx("div",{className:"text-xs text-fg-tertiary",children:n("costOverview.totalTokens")})]}),t.jsxs("div",{children:[t.jsx("div",{className:"text-2xl font-bold text-fg-primary",children:Ed(P.costSummary.totalEstimatedCost)}),t.jsx("div",{className:"text-xs text-fg-tertiary",children:n("costOverview.estimatedCost")})]}),t.jsxs("div",{children:[t.jsxs("div",{className:`text-2xl font-bold ${P.costSummary.trend==="decreasing"?"text-green-600":P.costSummary.trend==="increasing"?"text-red-500":"text-fg-primary"}`,children:[P.costSummary.trend==="decreasing"?"↓":P.costSummary.trend==="increasing"?"↑":"→"," ",P.costSummary.trend]}),t.jsx("div",{className:"text-xs text-fg-tertiary",children:n("costOverview.trend")})]})]}),P.costSummary.byAgent&&P.costSummary.byAgent.length>0&&t.jsx("div",{className:"mt-4 pt-3 border-t border-border-default/50 space-y-1.5",children:P.costSummary.byAgent.map((Y,oe)=>t.jsxs("div",{className:"flex items-center justify-between text-xs",children:[t.jsx("span",{className:"text-fg-secondary",children:Y.agentId}),t.jsx("span",{className:"text-fg-tertiary tabular-nums",children:n("costOverview.byAgentRow",{tokens:Do(Y.tokens),cost:Ed(Y.cost)})})]},oe))})]}),P.taskSummary&&t.jsxs("section",{className:"bg-surface-elevated rounded-xl p-5 overflow-hidden",children:[t.jsx("h3",{className:"text-xs font-semibold text-fg-secondary mb-3",children:n("taskSummary.title")}),t.jsxs("div",{className:"space-y-4 min-w-0",children:[P.taskSummary.completed.length>0&&t.jsx(wd,{title:n("taskSummary.completedCount",{count:P.taskSummary.completed.length}),color:"emerald",items:P.taskSummary.completed.map(Y=>({id:Y.id,label:Y.title,sub:Y.agent}))}),P.taskSummary.inProgress.length>0&&t.jsx(wd,{title:n("taskSummary.inProgressCount",{count:P.taskSummary.inProgress.length}),color:"indigo",items:P.taskSummary.inProgress.map(Y=>({id:Y.id,label:Y.title,sub:Y.agent}))}),P.taskSummary.blocked.length>0&&t.jsx(wd,{title:n("taskSummary.blockedCount",{count:P.taskSummary.blocked.length}),color:"amber",items:P.taskSummary.blocked.map(Y=>({id:Y.id,label:Y.title,sub:Y.reason||Y.agent}))}),P.taskSummary.completed.length===0&&P.taskSummary.inProgress.length===0&&P.taskSummary.blocked.length===0&&t.jsx("p",{className:"text-sm text-fg-tertiary",children:n("taskSummary.noTasksInPeriod")})]})]}),P.highlights&&P.highlights.length>0&&t.jsxs("section",{className:"bg-surface-elevated rounded-xl p-5",children:[t.jsx("h3",{className:"text-xs font-semibold text-fg-secondary mb-2",children:n("highlights")}),t.jsx("ul",{className:"list-disc list-inside space-y-1 text-sm text-fg-secondary",children:P.highlights.map((Y,oe)=>t.jsx("li",{children:Y},oe))})]}),P.blockers&&P.blockers.length>0&&t.jsxs("section",{className:"bg-surface-secondary border border-amber-500/20 rounded-xl p-5",children:[t.jsx("h3",{className:"text-xs font-semibold text-amber-600 mb-2",children:n("blockers")}),t.jsx("ul",{className:"list-disc list-inside space-y-1 text-sm text-fg-secondary",children:P.blockers.map((Y,oe)=>t.jsx("li",{children:Y},oe))})]}),P.plan&&t.jsxs("section",{className:"bg-surface-elevated rounded-xl p-5",children:[t.jsxs("div",{className:"flex items-center justify-between mb-3",children:[t.jsxs("h3",{className:"text-xs font-semibold text-fg-secondary",children:[n("upcomingPlan.title"),t.jsx("span",{className:`ml-2 px-1.5 py-0.5 rounded text-[10px] font-medium ${P.plan.status==="approved"?"bg-green-500/10 text-green-600":P.plan.status==="rejected"?"bg-red-500/10 text-red-500":"bg-amber-500/10 text-amber-600"}`,children:n(`common:status.${P.plan.status}`,{defaultValue:P.plan.status})})]}),P.plan.status==="pending"&&t.jsxs("div",{className:"flex gap-2",children:[t.jsx("button",{onClick:async()=>{try{const{report:Y}=await ae.reports.approvePlan(P.id,{approvedBy:e?.id??"unknown"});L(Y),D(n("upcomingPlan.planApproved")),J()}catch(Y){D(n("common:error",{message:String(Y)}))}},className:"px-3 py-1.5 text-xs font-medium bg-green-600 text-white rounded-lg hover:bg-green-500 transition-colors",children:n("upcomingPlan.approvePlan")}),t.jsx("button",{onClick:async()=>{const Y=prompt(n("upcomingPlan.rejectionReason"));if(Y)try{const{report:oe}=await ae.reports.rejectPlan(P.id,{rejectedBy:e?.id??"unknown",reason:Y});L(oe),D(n("upcomingPlan.planRejected")),J()}catch(oe){D(n("common:error",{message:String(oe)}))}},className:"px-3 py-1.5 text-xs font-medium border border-border-default text-fg-secondary rounded-lg hover:bg-surface-overlay transition-colors",children:n("upcomingPlan.rejectPlan")})]})]}),P.plan.items&&P.plan.items.length>0&&t.jsx("div",{className:"space-y-1.5",children:P.plan.items.map((Y,oe)=>t.jsxs("div",{className:"flex items-center gap-2 text-sm text-fg-secondary",children:[t.jsx("span",{className:`px-1.5 py-0.5 rounded text-[10px] font-medium ${Y.priority==="high"?"bg-red-500/10 text-red-500":Y.priority==="medium"?"bg-amber-500/10 text-amber-600":"bg-gray-500/10 text-fg-tertiary"}`,children:Y.priority}),t.jsx("span",{children:Y.title}),Y.assignee&&t.jsx("span",{className:"text-[10px] text-fg-tertiary ml-auto",children:Y.assignee})]},oe))})]}),!P.metrics&&!P.taskSummary&&!P.costSummary&&t.jsx("section",{className:"bg-surface-elevated rounded-xl p-8 text-center",children:t.jsx("p",{className:"text-sm text-fg-tertiary",children:n("noDetailedMetrics")})}),t.jsxs("section",{className:"bg-surface-elevated rounded-xl p-5",children:[t.jsx("h3",{className:"text-xs font-semibold text-fg-secondary mb-3",children:n("feedback.title",{count:M.length})}),M.length>0&&t.jsx("div",{className:"space-y-2 mb-4",children:M.map(Y=>t.jsxs("div",{className:"p-3 bg-surface-elevated/50 rounded-lg",children:[t.jsxs("div",{className:"flex items-center gap-2 text-[10px] text-fg-tertiary mb-1",children:[t.jsx("span",{className:"font-medium text-fg-secondary",children:Y.authorName}),t.jsx("span",{children:Y.type}),t.jsx("span",{children:new Date(Y.createdAt).toLocaleDateString()})]}),t.jsx("p",{className:"text-xs text-fg-secondary",children:Y.content})]},Y.id))}),t.jsxs("div",{className:"flex gap-2",children:[t.jsx("input",{value:U,onChange:Y=>z(Y.target.value),placeholder:n("feedback.placeholder"),className:"flex-1 px-3 py-2 text-xs bg-surface-elevated border border-border-default rounded-lg text-fg-primary placeholder:text-fg-tertiary",onKeyDown:Y=>{Y.key==="Enter"&&U.trim()&&ae.reports.addFeedback(P.id,{author:e?.id??"unknown",type:"comment",content:U.trim()}).then(({feedback:oe})=>{$(ge=>[...ge,oe]),z(""),D(n("feedback.added"))}).catch(oe=>D(n("common:error",{message:String(oe)})))}}),t.jsx("button",{onClick:()=>{U.trim()&&ae.reports.addFeedback(P.id,{author:e?.id??"unknown",type:"comment",content:U.trim()}).then(({feedback:Y})=>{$(oe=>[...oe,Y]),z(""),D(n("feedback.added"))}).catch(Y=>D(n("common:error",{message:String(Y)})))},disabled:!U.trim(),className:"px-3 py-2 text-xs bg-brand-600 text-white rounded-lg hover:bg-brand-500 disabled:opacity-40 disabled:cursor-not-allowed transition-colors",children:n("common:send")})]})]})]}),S==="generate"&&b&&t.jsxs("div",{className:`grid gap-4 ${b.storageBytes>0?"grid-cols-2 lg:grid-cols-4":"grid-cols-3"}`,children:[t.jsx(ah,{label:n("usage.llmTokens"),value:Do(b.llmTokens),color:"text-brand-500"}),t.jsx(ah,{label:n("usage.toolCalls"),value:Do(b.toolCalls),color:"text-blue-600"}),t.jsx(ah,{label:n("usage.messages"),value:Do(b.messages),color:"text-green-600"}),b.storageBytes>0&&t.jsx(ah,{label:n("usage.storage"),value:Kde(b.storageBytes),color:"text-amber-600"})]}),S==="generate"&&(u?t.jsx("div",{className:"flex items-center justify-center h-32 text-fg-tertiary text-sm",children:n("common:loading")}):f?t.jsx("div",{className:"flex items-center justify-center h-32 text-red-500 text-sm",children:f}):l?t.jsxs(t.Fragment,{children:[t.jsxs("div",{className:"text-xs text-fg-tertiary",children:[te[a]," · ",new Date(l.periodStart).toLocaleDateString()," — ",new Date(l.periodEnd).toLocaleDateString()]}),l.metrics&&t.jsxs("section",{className:"bg-surface-elevated rounded-xl p-5",children:[t.jsx("h3",{className:"text-xs font-semibold text-fg-secondary mb-3",children:n("taskMetrics.title")}),t.jsxs("div",{className:"grid grid-cols-2 md:grid-cols-5 gap-4",children:[t.jsx(Xi,{label:n("taskMetrics.completed"),value:l.metrics.tasksCompleted,color:"text-green-600"}),t.jsx(Xi,{label:n("taskMetrics.inProgress"),value:l.metrics.tasksInProgress,color:"text-brand-500"}),t.jsx(Xi,{label:n("taskMetrics.created"),value:l.metrics.tasksCreated,color:"text-blue-600"}),t.jsx(Xi,{label:n("taskMetrics.blocked"),value:l.metrics.tasksBlocked,color:"text-amber-600"}),t.jsx(Xi,{label:n("taskMetrics.failed"),value:l.metrics.tasksFailed,color:"text-red-500"})]})]}),t.jsxs("section",{className:"bg-surface-elevated rounded-xl p-5",children:[t.jsx("h3",{className:"text-xs font-semibold text-fg-secondary mb-3",children:n("costOverview.title")}),t.jsxs("div",{className:"grid grid-cols-3 gap-4",children:[t.jsxs("div",{children:[t.jsx("div",{className:"text-2xl font-bold text-fg-primary",children:Ed(X)}),t.jsx("div",{className:"text-xs text-fg-tertiary",children:n("costOverview.estCostAllTime")})]}),t.jsxs("div",{children:[t.jsx("div",{className:"text-2xl font-bold text-fg-primary",children:Do(K)}),t.jsx("div",{className:"text-xs text-fg-tertiary",children:n("costOverview.tokensToday")})]}),t.jsxs("div",{children:[t.jsx("div",{className:"text-2xl font-bold text-fg-primary",children:Ed(ee)}),t.jsx("div",{className:"text-xs text-fg-tertiary",children:n("costOverview.costToday")})]})]})]}),l.taskSummary&&t.jsxs("section",{className:"bg-surface-elevated rounded-xl p-5",children:[t.jsx("h3",{className:"text-xs font-semibold text-fg-secondary mb-3",children:n("taskSummary.title")}),t.jsxs("div",{className:"space-y-4",children:[l.taskSummary.completed.length>0&&t.jsx(wd,{title:n("taskSummary.completedCount",{count:l.taskSummary.completed.length}),color:"emerald",items:l.taskSummary.completed.map(Y=>({id:Y.id,label:Y.title,sub:Y.agent}))}),l.taskSummary.inProgress.length>0&&t.jsx(wd,{title:n("taskSummary.inProgressCount",{count:l.taskSummary.inProgress.length}),color:"indigo",items:l.taskSummary.inProgress.map(Y=>({id:Y.id,label:Y.title,sub:Y.agent}))}),l.taskSummary.blocked.length>0&&t.jsx(wd,{title:n("taskSummary.blockedCount",{count:l.taskSummary.blocked.length}),color:"amber",items:l.taskSummary.blocked.map(Y=>({id:Y.id,label:Y.title,sub:Y.reason||Y.agent}))}),l.taskSummary.completed.length===0&&l.taskSummary.inProgress.length===0&&l.taskSummary.blocked.length===0&&t.jsx("p",{className:"text-sm text-fg-tertiary",children:n("taskSummary.noTasksInPeriod")})]})]})]}):null),S==="generate"&&t.jsxs("section",{className:"bg-surface-elevated rounded-xl overflow-hidden",children:[t.jsx("div",{className:"px-5 py-4 border-b border-border-default",children:t.jsx("h3",{className:"text-sm font-semibold text-fg-secondary",children:n("perAgentUsage.title")})}),v.length===0?t.jsx("div",{className:"p-8 text-center text-fg-tertiary text-sm",children:n("perAgentUsage.noData")}):t.jsx("div",{className:"overflow-x-auto",children:t.jsxs("table",{className:"w-full",children:[t.jsx("thead",{children:t.jsxs("tr",{className:"border-b border-border-default text-xs text-fg-tertiary uppercase tracking-wider",children:[t.jsx("th",{className:"px-4 py-3 text-left font-medium",children:n("perAgentUsage.agent")}),t.jsx(l0,{label:n("perAgentUsage.totalTokens"),col:"totalTokens",current:C,desc:j,onSort:ne}),t.jsx(l0,{label:n("perAgentUsage.today"),col:"tokensUsedToday",current:C,desc:j,onSort:ne}),t.jsx(l0,{label:n("perAgentUsage.requests"),col:"requestCount",current:C,desc:j,onSort:ne}),t.jsx(l0,{label:n("perAgentUsage.toolCalls"),col:"toolCalls",current:C,desc:j,onSort:ne}),t.jsx(l0,{label:n("perAgentUsage.estCost"),col:"estimatedCost",current:C,desc:j,onSort:ne,align:"right"})]})}),t.jsx("tbody",{children:V.map(Y=>t.jsx(Gde,{agent:Y,maxTokens:Q},Y.agentId))}),t.jsx("tfoot",{children:t.jsxs("tr",{className:"border-t border-border-default bg-surface-elevated/30",children:[t.jsx("td",{className:"px-4 py-3 text-sm font-medium text-fg-secondary",children:n("perAgentUsage.totalAgents",{count:v.length})}),t.jsx("td",{className:"px-4 py-3 text-sm font-medium text-fg-secondary tabular-nums",children:Do(v.reduce((Y,oe)=>Y+oe.totalTokens,0))}),t.jsx("td",{className:"px-4 py-3 text-sm font-medium text-fg-secondary tabular-nums",children:Do(K)}),t.jsx("td",{className:"px-4 py-3 text-sm font-medium text-fg-secondary tabular-nums",children:v.reduce((Y,oe)=>Y+oe.requestCount,0)}),t.jsx("td",{className:"px-4 py-3 text-sm font-medium text-fg-secondary tabular-nums",children:v.reduce((Y,oe)=>Y+oe.toolCalls,0)}),t.jsx("td",{className:"px-4 py-3 text-sm font-medium text-right text-fg-secondary tabular-nums",children:Ed(X)})]})})]})})]})]})})}function Xi({label:e,value:n,color:r}){return t.jsxs("div",{className:"text-center",children:[t.jsx("div",{className:`text-2xl font-bold ${r}`,children:n}),t.jsx("div",{className:"text-[10px] text-fg-tertiary mt-0.5",children:e})]})}function wd({title:e,color:n,items:r}){return t.jsxs("div",{className:"min-w-0 overflow-hidden",children:[t.jsx("div",{className:`text-xs font-medium text-${n}-400 mb-1.5`,children:e}),t.jsx("div",{className:"space-y-1.5",children:r.map((s,a)=>t.jsxs("div",{className:`text-sm text-fg-secondary min-w-0 ${s.id?"cursor-pointer hover:text-fg-primary group":""}`,onClick:s.id?()=>Rt.navigate(Be.WORK,{openTask:s.id}):void 0,children:[t.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[t.jsx("span",{className:`w-1.5 h-1.5 rounded-full bg-${n}-500 shrink-0`}),t.jsx("span",{className:`truncate min-w-0 ${s.id?"group-hover:text-brand-500 transition-colors":""}`,children:s.label})]}),s.sub&&s.sub!=="unassigned"&&t.jsx("div",{className:"text-[10px] text-fg-tertiary ml-3.5 mt-0.5 break-all line-clamp-2",children:s.sub})]},s.id??a))})]})}function ah({label:e,value:n,color:r}){return t.jsxs("div",{className:"bg-surface-elevated rounded-xl p-5",children:[t.jsx("div",{className:"text-sm text-fg-secondary mb-2",children:e}),t.jsx("div",{className:`text-2xl font-bold ${r}`,children:n})]})}function l0({label:e,col:n,current:r,desc:s,onSort:a,align:i}){const l=r===n?s?"↓":"↑":"↕",c=r===n?"text-brand-500":"text-fg-muted";return t.jsxs("th",{className:`px-4 py-3 ${i==="right"?"text-right":"text-left"} font-medium cursor-pointer select-none hover:text-fg-secondary`,onClick:()=>a(n),children:[e,t.jsx("span",{className:`ml-1 ${c}`,children:l})]})}function Gde({agent:e,maxTokens:n}){const r=n>0?Math.min(100,e.totalTokens/n*100):0,s=e.status==="working"?"bg-blue-500":e.status==="idle"?"bg-green-500":e.status==="error"?"bg-red-500":"bg-gray-600";return t.jsxs("tr",{className:"border-b border-border-default/50 hover:bg-surface-elevated/30 transition-colors cursor-pointer",onClick:()=>Rt.navigate(Be.TEAM,{selectAgent:e.agentId}),children:[t.jsx("td",{className:"px-4 py-3",children:t.jsxs("div",{className:"flex items-center gap-2.5",children:[t.jsx("div",{className:`w-2 h-2 rounded-full ${s}`}),t.jsxs("div",{children:[t.jsx("div",{className:"text-sm font-medium text-fg-primary hover:text-brand-500 transition-colors",children:e.agentName}),t.jsx("div",{className:"text-xs text-fg-tertiary",children:e.role})]})]})}),t.jsx("td",{className:"px-4 py-3",children:t.jsxs("div",{className:"flex items-center gap-3",children:[t.jsx("div",{className:"flex-1 bg-surface-elevated rounded-full h-1.5 overflow-hidden max-w-[120px]",children:t.jsx("div",{className:"h-full bg-brand-500 rounded-full",style:{width:`${r}%`}})}),t.jsx("span",{className:"text-sm text-fg-secondary tabular-nums",children:Do(e.totalTokens)})]})}),t.jsx("td",{className:"px-4 py-3 text-sm text-fg-secondary tabular-nums",children:Do(e.tokensUsedToday)}),t.jsx("td",{className:"px-4 py-3 text-sm text-fg-secondary tabular-nums",children:e.requestCount}),t.jsx("td",{className:"px-4 py-3 text-sm text-fg-secondary tabular-nums",children:e.toolCalls}),t.jsx("td",{className:"px-4 py-3 text-sm text-right text-fg-secondary tabular-nums",children:Ed(e.estimatedCost)})]})}const ih={urgent:"bg-red-500",high:"bg-amber-500",normal:"bg-blue-500",low:"bg-gray-400"},kd={approval_request:"M9 12l2 2 4-4 M21 12a9 9 0 1 1-18 0 9 9 0 0 1 18 0z",task_completed:"M22 11.08V12a10 10 0 1 1-5.93-9.14 M22 4L12 14.01l-3-3",task_created:"M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z M14 2v6h6 M16 13H8 M16 17H8 M10 9H8",task_review:"M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z M14 2v6h6 M16 13H8 M16 17H8 M10 9H8",task_failed:"M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z M14 2v6h6 M16 13H8 M16 17H8 M10 9H8",requirement_created:"M11 4H4a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2v-7 M18.5 2.5a2.121 2.121 0 0 1 3 3L12 15l-4 1 1-4 9.5-9.5z",requirement_decision:"M12 22s8-4 8-10V5l-8-3-8 3v7c0 6 8 10 8 10z",agent_report:"M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z M14 2v6h6 M16 13H8 M16 17H8",direct_message:"M21 15a2 2 0 0 1-2 2H7l-4 4V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2z",group_message:"M17 21v-2a4 4 0 0 0-4-4H5a4 4 0 0 0-4 4v2 M9 7a4 4 0 1 0 0-8 4 4 0 0 0 0 8z M23 21v-2a4 4 0 0 0-3-3.87 M16 3.13a4 4 0 0 1 0 7.75",system:"M12 22s8-4 8-10V5l-8-3-8 3v7c0 6 8 10 8 10z"},o6={approval_request:"text-amber-500",task_completed:"text-green-500",task_failed:"text-red-500",task_created:"text-blue-500",task_review:"text-purple-500",requirement_created:"text-amber-500",requirement_decision:"text-green-500",agent_report:"text-blue-500",direct_message:"text-green-500",group_message:"text-brand-500",system:"text-fg-tertiary"};function Nd(e,n){const r=Date.now()-new Date(e).getTime(),s=Math.floor(r/6e4);if(s<1)return n("common:time.now");if(s<60)return n("common:time.minutesAgo",{count:s});const a=Math.floor(s/60);return a<24?n("common:time.hoursAgo",{count:a}):n("common:time.daysAgo",{count:Math.floor(a/24)})}function oh(e,n){const r=e.actionType;if(r==="open_chat")return n("team:notifications.actionHints.openChat");if(r==="navigate")return n("team:notifications.actionHints.viewDetails");const s=e.metadata??{};switch(e.type){case"task_completed":case"task_created":case"task_review":case"task_failed":return s.taskId?n("team:notifications.actionHints.viewTask"):null;case"requirement_created":case"requirement_decision":return s.requirementId?n("team:notifications.actionHints.viewRequirement"):null;case"agent_report":return s.agentId?n("team:notifications.actionHints.viewAgent"):null;case"direct_message":return n("team:notifications.actionHints.openChat");case"group_message":return n("team:notifications.actionHints.openChat");case"approval_request":return n("team:notifications.actionHints.viewApproval");default:return s.taskId?n("team:notifications.actionHints.viewTask"):s.requirementId?n("team:notifications.actionHints.viewRequirement"):s.agentId?n("team:notifications.actionHints.viewAgent"):null}}function Yde(){try{const e=new AudioContext,n=e.currentTime,r=e.createGain();r.connect(e.destination),r.gain.setValueAtTime(.15,n),r.gain.exponentialRampToValueAtTime(.01,n+.6);const s=e.createOscillator();s.type="sine",s.frequency.setValueAtTime(880,n),s.frequency.setValueAtTime(1174.66,n+.15),s.connect(r),s.start(n),s.stop(n+.6),s.onended=()=>e.close()}catch{}}function sA({collapsed:e,userId:n,embeddedMode:r,onClose:s,sidebarMode:a,isActive:i,label:l,iconPath:c}){const{t:u}=ht(["team","common"]),[m,f]=g.useState(!1),[p,b]=g.useState("approvals"),[x,v]=g.useState([]),[N,C]=g.useState([]),[k,j]=g.useState(null),[w,S]=g.useState(null),[T,R]=g.useState({}),[I,P]=g.useState(0),L=g.useRef(null),M=g.useRef(null),[$,U]=g.useState({top:0,left:0,width:448,maxHeight:576}),z=g.useRef(null),A=g.useRef(!1),[H,D]=g.useState(!0),[O,q]=g.useState(!1),J=g.useRef(null),B=g.useRef("approvals"),V=30,X=g.useCallback(async()=>{try{const[W,re]=await Promise.all([ae.notifications.list(n,!1,{limit:V,offset:0}),ae.approvals.list()]);if(v(W.notifications),P(W.unreadCount??W.notifications.filter(Ae=>!Ae.read).length),D(W.totalCount!=null?W.notifications.length<W.totalCount:W.notifications.length>=V),C(re.approvals),!A.current){const Ae=re.approvals.filter(xe=>xe.status==="pending").length;z.current=Ae,A.current=!0}}catch{}},[n]),K=g.useCallback(async()=>{if(!(O||!H)){q(!0);try{const W=await ae.notifications.list(n,!1,{limit:V,offset:x.length});W.notifications.length>0&&v(re=>[...re,...W.notifications.filter(Ae=>!re.some(xe=>xe.id===Ae.id))]),D(W.totalCount!=null?x.length+W.notifications.length<W.totalCount:W.notifications.length>=V)}catch{}q(!1)}},[n,x.length,O,H]),ee=g.useCallback(W=>{const re=W.detail;if(!re)return;const{taskId:Ae,requirementId:xe}=re;!Ae&&!xe||v(tt=>{const vt=tt.filter(xt=>!xt.read&&(Ae&&xt.metadata?.taskId===Ae||xe&&xt.metadata?.requirementId===xe));if(vt.length===0)return tt;for(const xt of vt)ae.notifications.markRead(xt.id).catch(()=>{});return P(xt=>Math.max(0,xt-vt.length)),tt.map(xt=>vt.some(Me=>Me.id===xt.id)?{...xt,read:!0}:xt)})},[]);g.useEffect(()=>{X();const W=setInterval(X,6e4),re=()=>X(),Ae=()=>{f(!0),X()};window.addEventListener("markus:notifications-changed",re),window.addEventListener("markus:mark-read-by-ref",ee),window.addEventListener("markus:open-notifications",Ae);const xe=Tn.on("notification:created",()=>X()),tt=Tn.on("approval:created",()=>X());return()=>{clearInterval(W),window.removeEventListener("markus:notifications-changed",re),window.removeEventListener("markus:mark-read-by-ref",ee),window.removeEventListener("markus:open-notifications",Ae),xe(),tt()}},[X,ee]);const Q=g.useCallback(()=>{if(!L.current)return;const W=L.current.getBoundingClientRect(),re=window.innerWidth,Ae=window.innerHeight,xe=Math.min(448,re-16),tt=Math.min(576,Ae-16);let vt=W.right+8,xt=W.top;vt+xe>re-8&&(vt=Math.max(8,re-xe-8)),xt+tt>Ae-8&&(xt=Math.max(8,Ae-tt-8)),U({top:xt,left:vt,width:xe,maxHeight:tt})},[]);g.useLayoutEffect(()=>{m&&Q()},[m,Q]),g.useEffect(()=>{if(m)return window.addEventListener("resize",Q),()=>window.removeEventListener("resize",Q)},[m,Q]),g.useEffect(()=>{if(!m)return;const W=re=>{L.current?.contains(re.target)||M.current?.contains(re.target)||f(!1)};return document.addEventListener("mousedown",W),()=>document.removeEventListener("mousedown",W)},[m]),g.useEffect(()=>{if(!m)return;const W=N.some(Ae=>Ae.status==="pending"),re=x.some(Ae=>!Ae.read);b(W&&!re?"approvals":!W&&re?"notifications":B.current)},[m]);const ne=new Set(N.filter(W=>W.status==="pending").map(W=>W.id)),te=new Set(N.map(W=>W.id)),Y=x.filter(W=>!(W.type==="approval_request"&&W.metadata?.approvalId&&te.has(W.metadata.approvalId))),oe=x.filter(W=>W.type==="approval_request"&&!W.read&&W.metadata?.approvalId&&ne.has(W.metadata.approvalId)).length,ge=Math.max(0,I-oe),ye=ne.size,we=ge+ye;g.useEffect(()=>{z.current!==null&&ye>z.current&&Yde(),z.current=ye},[ye]);const Ce=async W=>{await ae.notifications.markRead(W),v(re=>re.map(Ae=>Ae.id===W?{...Ae,read:!0}:Ae)),P(re=>Math.max(0,re-1))},ie=W=>{const re=W.metadata??{},Ae=W.actionType,xe=W.actionTarget;if(Ae==="open_chat"&&xe)try{const tt=typeof xe=="string"?JSON.parse(xe):xe;if(tt.agentId){const vt={agentId:tt.agentId};tt.sessionId&&(vt.sessionId=tt.sessionId),Rt.navigate(Be.TEAM,vt);return}}catch{}if(Ae==="navigate"&&xe)try{const tt=typeof xe=="string"?JSON.parse(xe):xe;if(tt.path){if(tt.path.startsWith("/team")){const vt={},xt=new URLSearchParams(tt.path.split("?")[1]||"");for(const[Me,Ke]of xt.entries())vt[Me]=Ke;Rt.navigate(Be.TEAM,vt);return}if(tt.path.startsWith("/work")){const vt={},xt=new URLSearchParams(tt.path.split("?")[1]||"");for(const[Me,Ke]of xt.entries())vt[Me]=Ke;Rt.navigate(Be.WORK,vt);return}}}catch{}switch(W.type){case"approval_request":{const tt=re.approvalId,vt=tt?N.find(Re=>Re.id===tt):void 0,xt=vt?.details?.taskId??re.taskId,Me=vt?.details?.requirementId??re.requirementId,Ke=vt?.details?.agentId??vt?.agentId;xt?Rt.navigate(Be.WORK,{openTask:xt}):Me?Rt.navigate(Be.WORK,{openRequirement:Me}):Ke?Rt.navigate(Be.TEAM,{agentId:Ke}):Rt.navigate(Be.WORK);break}case"task_completed":case"task_created":case"task_review":case"task_failed":re.taskId?Rt.navigate(Be.WORK,{openTask:re.taskId}):Rt.navigate(Be.WORK);break;case"requirement_created":case"requirement_decision":re.requirementId?Rt.navigate(Be.WORK,{openRequirement:re.requirementId}):Rt.navigate(Be.WORK);break;case"agent_report":case"system":{if(re.agentId){const tt={agentId:re.agentId};re.sessionId&&(tt.sessionId=re.sessionId),Rt.navigate(Be.TEAM,tt)}else Rt.navigate(Be.TEAM);break}case"direct_message":{const tt=re.senderId;tt?Rt.navigate(Be.TEAM,{dm:tt}):Rt.navigate(Be.TEAM);break}case"group_message":{const tt=re.channel;tt?Rt.navigate(Be.TEAM,{channel:tt}):Rt.navigate(Be.TEAM);break}default:re.taskId?Rt.navigate(Be.WORK,{openTask:re.taskId}):re.requirementId?Rt.navigate(Be.WORK,{openRequirement:re.requirementId}):re.projectId?Rt.navigate(Be.WORK,{projectId:re.projectId}):re.agentId&&Rt.navigate(Be.TEAM,{agentId:re.agentId});break}},Te=async W=>{W.read||Ce(W.id);const re=W.metadata??{},Ae=re.taskId,xe=re.requirementId;if(Ae||xe){const tt=x.filter(vt=>vt.id!==W.id&&!vt.read&&(Ae&&vt.metadata?.taskId===Ae||xe&&vt.metadata?.requirementId===xe));for(const vt of tt)Ce(vt.id)}ie(W)},ue=async(W,re,Ae,xe)=>{j(W);try{const{approval:tt}=await ae.approvals.respond(W,re,n,Ae,xe);C(Ke=>Ke.map(Re=>Re.id===W?tt:Re)),S(null),R(Ke=>{const Re={...Ke};return delete Re[W],Re});const vt=tt.details?.taskId,xt=tt.details?.requirementId,Me=x.filter(Ke=>!Ke.read&&(Ke.type==="approval_request"&&Ke.metadata?.approvalId===W||vt&&Ke.metadata?.taskId===vt||xt&&Ke.metadata?.requirementId===xt));if(Me.length>0){for(const Re of Me)ae.notifications.markRead(Re.id).catch(()=>{});const Ke=new Set(Me.map(Re=>Re.id));v(Re=>Re.map(qe=>Ke.has(qe.id)?{...qe,read:!0}:qe)),P(Re=>Math.max(0,Re-Me.length))}na("/approvals"),na("/notifications"),na("/tasks"),na("/taskboard"),na("/requirements"),window.dispatchEvent(new CustomEvent("markus:data-changed")),window.dispatchEvent(new CustomEvent("markus:notifications-changed")),setTimeout(()=>X(),800)}catch{}j(null)},Le=async()=>{try{if(!n)return;await ae.notifications.markAllRead(n),v(W=>W.map(re=>({...re,read:!0}))),P(0),na("/notifications")}catch{const W=Y.filter(re=>!re.read);await Promise.all(W.map(re=>ae.notifications.markRead(re.id))),v(re=>re.map(Ae=>({...Ae,read:!0}))),P(0),na("/notifications")}},$e=W=>{const re=W.details?.subType;return re==="requirement_resubmit"?u("team:notifications.approvalType.requirementResubmit"):re==="requirement"||W.details?.requirementId?u("team:notifications.approvalType.requirement"):re==="task_review"?u("team:notifications.approvalType.taskReview"):re==="task"||W.details?.taskId?u("team:notifications.approvalType.task"):W.details?.toolName?u("team:notifications.approvalType.toolExecution"):null},je=W=>{const re=[];re.push(W.agentName);const Ae=W.details?.taskTitle,xe=W.details?.taskId;Ae?re.push(Ae):xe&&re.push(`Task ${xe.slice(0,8)}`);const tt=W.details?.requirementId;return tt&&!xe&&re.push(`Req ${tt.slice(0,8)}`),re.join(" · ")},Ee=[...N].sort((W,re)=>new Date(re.requestedAt).getTime()-new Date(W.requestedAt).getTime()),We=Ee.filter(W=>W.status==="pending"),Ve=Ee.filter(W=>W.status!=="pending"),de=W=>{const re=W.details?.taskId,Ae=W.details?.requirementId,xe=W.details?.agentId??W.agentId;re?Rt.navigate(Be.WORK,{openTask:re}):Ae?Rt.navigate(Be.WORK,{openRequirement:Ae}):xe?Rt.navigate(Be.TEAM,{agentId:xe}):Rt.navigate(Be.WORK)},ve=()=>{f(!1),s?.()},Ne=t.jsxs(t.Fragment,{children:[t.jsxs("div",{className:"flex border-b border-border-default shrink-0",children:[t.jsxs("button",{onClick:()=>{b("approvals"),B.current="approvals"},className:`flex-1 px-3 py-2.5 text-xs font-medium transition-colors ${p==="approvals"?"text-fg-primary border-b-2 border-brand-500":"text-fg-tertiary hover:text-fg-secondary"}`,children:[u("team:notifications.approvals"),ye>0?` (${ye})`:""]}),t.jsxs("button",{onClick:()=>{b("notifications"),B.current="notifications"},className:`flex-1 px-3 py-2.5 text-xs font-medium transition-colors ${p==="notifications"?"text-fg-primary border-b-2 border-brand-500":"text-fg-tertiary hover:text-fg-secondary"}`,children:[u("team:notifications.notifications"),ge>0?` (${ge})`:""]}),t.jsx("button",{onClick:ve,className:"px-2 py-2 text-fg-tertiary hover:text-fg-primary transition-colors shrink-0",title:u("common:close"),children:t.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[t.jsx("path",{d:"M18 6L6 18"}),t.jsx("path",{d:"M6 6l12 12"})]})})]}),p==="notifications"&&I>0&&t.jsx("div",{className:"flex justify-end px-3 py-1.5 border-b border-border-default/50 shrink-0",children:t.jsx("button",{onClick:Le,className:"text-[10px] text-brand-500 hover:text-brand-400 transition-colors",children:u("team:notifications.markAllRead")})}),t.jsxs("div",{ref:J,className:"flex-1 overflow-y-auto",onScroll:W=>{if(p!=="notifications"||!H||O)return;const re=W.currentTarget;re.scrollTop+re.clientHeight>=re.scrollHeight-80&&K()},children:[p==="approvals"&&(N.length===0?t.jsx("div",{className:"p-6 text-center text-xs text-fg-tertiary",children:u("team:notifications.noApprovals")}):t.jsxs("div",{className:"divide-y divide-border-default/50",children:[We.map(W=>{const re=W.details?.command,Ae=re?W.description.replace(/\s*Command:.*$/,""):W.description;return t.jsxs("div",{className:"px-3 py-3 space-y-2.5",children:[t.jsxs("div",{className:"cursor-pointer hover:bg-surface-overlay/50 -mx-3 -mt-3 px-3 pt-3 pb-1 rounded-t-md transition-colors",onClick:()=>de(W),children:[t.jsxs("div",{className:"flex items-start gap-2",children:[t.jsx("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",className:"text-amber-500 mt-0.5 shrink-0",children:t.jsx("path",{d:kd.approval_request})}),t.jsxs("div",{className:"flex-1 min-w-0",children:[t.jsxs("div",{className:"flex items-center gap-2",children:[$e(W)&&t.jsx("span",{className:"text-[10px] text-amber-500 font-medium shrink-0",children:$e(W)}),t.jsx("span",{className:"text-xs text-fg-primary font-medium truncate",children:W.title}),t.jsx("span",{className:"text-[10px] text-fg-tertiary shrink-0",children:Nd(W.requestedAt,u)})]}),t.jsx("div",{className:"text-[11px] text-fg-tertiary mt-0.5",children:W.agentName})]})]}),t.jsx("div",{className:"mt-2.5 text-[11px] text-fg-secondary leading-relaxed",children:t.jsx(fs,{content:Ae,className:"text-[11px] [&_h1]:text-xs [&_h2]:text-[11px] [&_h3]:text-[11px] [&_p]:text-[11px] [&_li]:text-[11px]"})}),re&&t.jsx("pre",{className:"text-[11px] text-fg-primary bg-surface-overlay border border-border-default rounded-md px-2.5 py-2 overflow-x-auto whitespace-pre-wrap break-all font-mono leading-relaxed mt-2",children:re})]}),(()=>{const xe=W.details?.subType,tt=xe==="task"||xe==="requirement"||xe==="requirement_resubmit",vt=W.options&&W.options.length>0,xt=(T[W.id]??"").trim();return vt?t.jsxs("div",{className:"space-y-1.5",children:[W.options.map((Me,Ke)=>t.jsxs("button",{disabled:k===W.id,onClick:()=>ue(W.id,Me.id!=="reject",xt||void 0,Me.id),className:`w-full px-3 py-2 text-left text-[11px] font-medium rounded-md disabled:opacity-50 transition-colors flex items-center gap-2 ${Me.id==="reject"||Me.id==="request_changes"?"border border-border-default text-fg-secondary hover:bg-surface-overlay":"bg-brand-600 text-white hover:bg-brand-700"}`,title:Me.description,children:[t.jsx("span",{className:"w-5 h-5 rounded-full bg-white/20 flex items-center justify-center text-[10px] font-bold shrink-0",children:String.fromCharCode(65+Ke)}),Me.label]},Me.id)),t.jsxs("div",{className:"flex gap-1.5 mt-1",children:[t.jsx("input",{type:"text",placeholder:u("team:notifications.freeformPlaceholder"),value:T[W.id]??"",onChange:Me=>R(Ke=>({...Ke,[W.id]:Me.target.value})),onKeyDown:Me=>{Me.key==="Enter"&&(T[W.id]??"").trim()&&ue(W.id,!0,(T[W.id]??"").trim(),"custom")},className:"flex-1 px-2.5 py-1.5 text-[11px] bg-surface-overlay border border-border-default rounded-md text-fg-primary placeholder:text-fg-tertiary focus:outline-none focus:ring-1 focus:ring-brand-500/50"}),t.jsx("button",{disabled:k===W.id||!(T[W.id]??"").trim(),onClick:()=>ue(W.id,!0,(T[W.id]??"").trim(),"custom"),className:"px-2.5 py-1.5 text-[11px] font-medium bg-brand-600 text-white rounded-md hover:bg-brand-700 disabled:opacity-50 transition-colors",children:u("common:send")})]})]}):tt?t.jsxs("div",{className:"space-y-1.5",children:[t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsxs("button",{disabled:k===W.id,onClick:()=>ue(W.id,!0,void 0,"approve"),className:"px-3 py-1.5 text-[11px] font-medium bg-green-600 text-white rounded-md hover:bg-green-700 disabled:opacity-50 transition-colors inline-flex items-center gap-1.5",children:[t.jsx("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round",children:t.jsx("path",{d:"M20 6L9 17l-5-5"})}),u("common:approve")]}),t.jsxs("button",{disabled:k===W.id,onClick:()=>ue(W.id,!1,void 0,"reject"),className:"px-3 py-1.5 text-[11px] font-medium bg-red-600/80 text-white rounded-md hover:bg-red-700 disabled:opacity-50 transition-colors inline-flex items-center gap-1.5",children:[t.jsxs("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round",children:[t.jsx("path",{d:"M18 6L6 18"}),t.jsx("path",{d:"M6 6l12 12"})]}),u("common:reject")]}),w!==W.id&&t.jsxs("button",{disabled:k===W.id,onClick:()=>S(W.id),className:"px-3 py-1.5 text-[11px] font-medium border border-amber-500/50 text-amber-500 rounded-md hover:bg-amber-500/10 disabled:opacity-50 transition-colors inline-flex items-center gap-1.5",children:[t.jsxs("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[t.jsx("path",{d:"M11 4H4a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2v-7"}),t.jsx("path",{d:"M18.5 2.5a2.121 2.121 0 0 1 3 3L12 15l-4 1 1-4 9.5-9.5z"})]}),u("team:notifications.needsAdjustment")]})]}),w===W.id&&t.jsxs("div",{className:"space-y-1.5",children:[t.jsx("input",{type:"text",autoFocus:!0,placeholder:u("team:notifications.adjustmentPlaceholder"),value:T[W.id]??"",onChange:Me=>R(Ke=>({...Ke,[W.id]:Me.target.value})),onKeyDown:Me=>{Me.key==="Enter"&&(T[W.id]??"").trim()&&ue(W.id,!1,(T[W.id]??"").trim(),"needs_adjustment"),Me.key==="Escape"&&S(null)},className:"w-full px-2.5 py-1.5 text-[11px] bg-surface-overlay border border-border-default rounded-md text-fg-primary placeholder:text-fg-tertiary focus:outline-none focus:ring-1 focus:ring-amber-500/50"}),t.jsxs("div",{className:"flex gap-2",children:[t.jsx("button",{disabled:k===W.id||!(T[W.id]??"").trim(),onClick:()=>ue(W.id,!1,(T[W.id]??"").trim(),"needs_adjustment"),className:"px-2.5 py-1.5 text-[11px] font-medium bg-amber-600 text-white rounded-md hover:bg-amber-700 disabled:opacity-50 transition-colors",children:u("team:notifications.confirmAdjustment")}),t.jsx("button",{onClick:()=>S(null),className:"px-2.5 py-1.5 text-[11px] font-medium border border-border-default text-fg-secondary rounded-md hover:bg-surface-overlay transition-colors",children:u("common:cancel")})]})]})]}):t.jsxs("div",{className:"space-y-1.5",children:[t.jsx("input",{type:"text",placeholder:u("team:notifications.commentPlaceholder"),value:T[W.id]??"",onChange:Me=>R(Ke=>({...Ke,[W.id]:Me.target.value})),onKeyDown:Me=>{Me.key==="Enter"&&ue(W.id,!0,xt||void 0,"approve")},className:"w-full px-2.5 py-1.5 text-[11px] bg-surface-overlay border border-border-default rounded-md text-fg-primary placeholder:text-fg-tertiary focus:outline-none focus:ring-1 focus:ring-brand-500/50"}),t.jsxs("div",{className:"flex gap-2",children:[t.jsx("button",{disabled:k===W.id,onClick:()=>ue(W.id,!0,xt||void 0,"approve"),className:"flex-1 px-2.5 py-1.5 text-[11px] font-medium bg-green-600 text-white rounded-md hover:bg-green-700 disabled:opacity-50 transition-colors",children:u("common:approve")}),t.jsx("button",{disabled:k===W.id,onClick:()=>ue(W.id,!1,xt||void 0,"reject"),className:"flex-1 px-2.5 py-1.5 text-[11px] font-medium border border-border-default text-fg-secondary rounded-md hover:bg-surface-overlay disabled:opacity-50 transition-colors",children:u("common:reject")})]})]})})()]},W.id)}),Ve.length>0&&t.jsxs(t.Fragment,{children:[We.length>0&&t.jsx("div",{className:"px-3 py-1.5 text-[10px] font-medium text-fg-tertiary uppercase tracking-wider bg-surface-overlay/30",children:u("team:notifications.approvalHistory")}),Ve.slice(0,50).map(W=>t.jsxs("button",{onClick:()=>de(W),className:"w-full text-left px-3 py-2.5 hover:bg-surface-overlay/50 transition-colors group",children:[t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx("span",{className:`w-1.5 h-1.5 rounded-full shrink-0 ${W.status==="approved"?"bg-green-500":W.status==="cancelled"||W.status==="expired"?"bg-gray-400":"bg-red-500"}`}),$e(W)&&t.jsx("span",{className:"text-[10px] text-fg-tertiary font-medium shrink-0",children:$e(W)}),t.jsx("span",{className:"text-xs text-fg-secondary truncate flex-1 group-hover:text-fg-primary",children:W.title}),t.jsx("span",{className:`text-[10px] font-medium shrink-0 ${W.status==="approved"?"text-green-500":W.status==="cancelled"||W.status==="expired"?"text-fg-muted":"text-red-500"}`,children:u(`common:status.${W.status}`,{defaultValue:W.status})})]}),t.jsxs("div",{className:"flex items-center gap-1.5 mt-0.5 pl-3.5",children:[t.jsx("span",{className:"text-[10px] text-fg-muted truncate",children:je(W)}),t.jsx("span",{className:"text-[10px] text-fg-muted shrink-0",children:"·"}),t.jsx("span",{className:"text-[10px] text-fg-muted shrink-0",children:Nd(W.respondedAt??W.requestedAt,u)})]}),W.responseComment&&t.jsxs("p",{className:"text-[10px] text-fg-muted mt-0.5 pl-3.5 truncate",children:["“",W.responseComment,"”"]})]},W.id))]})]})),p==="notifications"&&(Y.length===0?t.jsx("div",{className:"p-6 text-center text-xs text-fg-tertiary",children:u("team:notifications.noNotifications")}):t.jsxs("div",{className:"divide-y divide-border-default/50",children:[Y.map(W=>{const re=o6[W.type]??"text-fg-tertiary";return t.jsxs("div",{role:"button",tabIndex:0,onClick:()=>Te(W),onKeyDown:Ae=>{(Ae.key==="Enter"||Ae.key===" ")&&(Ae.preventDefault(),Te(W))},className:`w-full text-left px-3 py-2.5 flex gap-2.5 transition-colors cursor-pointer ${W.read?"opacity-50 hover:opacity-70":"hover:bg-surface-overlay"}`,children:[t.jsx("div",{className:"shrink-0 mt-0.5",children:t.jsx("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",className:re,children:t.jsx("path",{d:kd[W.type]??kd.system})})}),t.jsxs("div",{className:"flex-1 min-w-0",children:[t.jsxs("div",{className:"flex items-center gap-1.5",children:[!W.read&&t.jsx("span",{className:`w-1.5 h-1.5 rounded-full shrink-0 ${ih[W.priority]??ih.normal}`}),t.jsx("span",{className:"text-xs text-fg-primary font-medium truncate",children:W.title})]}),t.jsx("div",{className:"text-[11px] text-fg-tertiary mt-0.5 ",children:t.jsx(fs,{content:W.body,className:"text-[11px] [&_h1]:text-xs [&_h2]:text-[11px] [&_h3]:text-[11px] [&_p]:text-[11px] [&_li]:text-[11px] [&_p]:text-fg-tertiary"})}),t.jsxs("div",{className:"flex items-center gap-2 mt-0.5",children:[t.jsx("span",{className:"text-[10px] text-fg-muted",children:Nd(W.createdAt,u)}),oh(W,u)&&t.jsx("span",{className:`text-[10px] font-medium ${re}`,children:oh(W,u)})]})]})]},W.id)}),O&&t.jsx("div",{className:"py-3 text-center",children:t.jsxs("svg",{className:"animate-spin h-4 w-4 text-fg-tertiary mx-auto",viewBox:"0 0 24 24",fill:"none",children:[t.jsx("circle",{className:"opacity-25",cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"4"}),t.jsx("path",{className:"opacity-75",fill:"currentColor",d:"M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4z"})]})})]}))]})]});if(r){const W=["approvals","notifications"],re=W.indexOf(p),Ae=(()=>{let xe=0,tt=0;return{onTouchStart:vt=>{xe=vt.touches[0].clientX,tt=vt.touches[0].clientY},onTouchEnd:vt=>{const xt=vt.changedTouches[0].clientX-xe,Me=vt.changedTouches[0].clientY-tt;Math.abs(xt)>60&&Math.abs(xt)>Math.abs(Me)*1.5&&(xt<0&&re<W.length-1&&b(W[re+1]),xt>0&&re>0&&b(W[re-1]))}}})();return t.jsxs("div",{className:"flex flex-col h-full overflow-hidden",children:[t.jsx("div",{className:"flex border-b border-border-default shrink-0",children:W.map(xe=>t.jsx("button",{onClick:()=>b(xe),className:`flex-1 px-3 py-3 text-sm font-medium transition-colors ${p===xe?"text-fg-primary border-b-2 border-brand-500":"text-fg-tertiary"}`,children:xe==="approvals"?t.jsxs(t.Fragment,{children:[u("team:notifications.approvals"),ye>0?` (${ye})`:""]}):t.jsxs(t.Fragment,{children:[u("team:notifications.notifications"),ge>0?` (${ge})`:""]})},xe))}),p==="notifications"&&I>0&&t.jsx("div",{className:"flex justify-end px-3 py-1.5 border-b border-border-default/50 shrink-0",children:t.jsx("button",{onClick:Le,className:"text-[10px] text-brand-500 hover:text-brand-400 transition-colors",children:u("team:notifications.markAllRead")})}),t.jsx("div",{className:"flex-1 overflow-hidden relative",...Ae,children:t.jsxs("div",{className:"flex h-full transition-transform duration-300 ease-out",style:{transform:`translateX(-${re*100}%)`},children:[t.jsx("div",{className:"w-full shrink-0 h-full overflow-y-auto scrollbar-thin",children:N.length===0?t.jsx("div",{className:"p-6 text-center text-xs text-fg-tertiary",children:u("team:notifications.noApprovals")}):t.jsxs("div",{className:"divide-y divide-border-default/50",children:[We.map(xe=>{const tt=xe.details?.command,vt=tt?xe.description.replace(/\s*Command:.*$/,""):xe.description;return t.jsxs("div",{className:"px-3 py-3 space-y-2.5",children:[t.jsxs("div",{className:"cursor-pointer hover:bg-surface-overlay/50 -mx-3 -mt-3 px-3 pt-3 pb-1 rounded-t-md transition-colors",onClick:()=>de(xe),children:[t.jsxs("div",{className:"flex items-start gap-2",children:[t.jsx("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",className:"text-amber-500 mt-0.5 shrink-0",children:t.jsx("path",{d:kd.approval_request})}),t.jsxs("div",{className:"flex-1 min-w-0",children:[t.jsxs("div",{className:"flex items-center gap-2",children:[$e(xe)&&t.jsx("span",{className:"text-[10px] text-amber-500 font-medium shrink-0",children:$e(xe)}),t.jsx("span",{className:"text-xs text-fg-primary font-medium truncate",children:xe.title}),t.jsx("span",{className:"text-[10px] text-fg-tertiary shrink-0",children:Nd(xe.requestedAt,u)})]}),t.jsx("div",{className:"text-[11px] text-fg-tertiary mt-0.5",children:xe.agentName})]})]}),t.jsx("div",{className:"mt-2.5 text-[11px] text-fg-secondary leading-relaxed",children:t.jsx(fs,{content:vt,className:"text-[11px] [&_h1]:text-xs [&_h2]:text-[11px] [&_h3]:text-[11px] [&_p]:text-[11px] [&_li]:text-[11px]"})}),tt&&t.jsx("pre",{className:"text-[11px] text-fg-primary bg-surface-overlay border border-border-default rounded-md px-2.5 py-2 overflow-x-auto whitespace-pre-wrap break-all font-mono leading-relaxed mt-2",children:tt})]}),(()=>{const xt=xe.details?.subType,Me=xt==="task"||xt==="requirement"||xt==="requirement_resubmit",Ke=xe.options&&xe.options.length>0,Re=(T[xe.id]??"").trim();return Ke?t.jsxs("div",{className:"space-y-1.5",children:[xe.options.map((qe,ct)=>t.jsxs("button",{disabled:k===xe.id,onClick:()=>ue(xe.id,qe.id!=="reject",Re||void 0,qe.id),className:`w-full px-3 py-2 text-left text-[11px] font-medium rounded-md disabled:opacity-50 transition-colors flex items-center gap-2 ${qe.id==="reject"||qe.id==="request_changes"?"border border-border-default text-fg-secondary hover:bg-surface-overlay":"bg-brand-600 text-white hover:bg-brand-700"}`,title:qe.description,children:[t.jsx("span",{className:"w-5 h-5 rounded-full bg-white/20 flex items-center justify-center text-[10px] font-bold shrink-0",children:String.fromCharCode(65+ct)}),qe.label]},qe.id)),t.jsxs("div",{className:"flex gap-1.5 mt-1",children:[t.jsx("input",{type:"text",placeholder:u("team:notifications.freeformPlaceholder"),value:T[xe.id]??"",onChange:qe=>R(ct=>({...ct,[xe.id]:qe.target.value})),onKeyDown:qe=>{qe.key==="Enter"&&(T[xe.id]??"").trim()&&ue(xe.id,!0,(T[xe.id]??"").trim(),"custom")},className:"flex-1 px-2.5 py-1.5 text-[11px] bg-surface-overlay border border-border-default rounded-md text-fg-primary placeholder:text-fg-tertiary focus:outline-none focus:ring-1 focus:ring-brand-500/50"}),t.jsx("button",{disabled:k===xe.id||!(T[xe.id]??"").trim(),onClick:()=>ue(xe.id,!0,(T[xe.id]??"").trim(),"custom"),className:"px-2.5 py-1.5 text-[11px] font-medium bg-brand-600 text-white rounded-md hover:bg-brand-700 disabled:opacity-50 transition-colors",children:u("common:send")})]})]}):Me?t.jsxs("div",{className:"space-y-1.5",children:[t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsxs("button",{disabled:k===xe.id,onClick:()=>ue(xe.id,!0,void 0,"approve"),className:"px-3 py-1.5 text-[11px] font-medium bg-green-600 text-white rounded-md hover:bg-green-700 disabled:opacity-50 transition-colors inline-flex items-center gap-1.5",children:[t.jsx("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round",children:t.jsx("path",{d:"M20 6L9 17l-5-5"})}),u("common:approve")]}),t.jsxs("button",{disabled:k===xe.id,onClick:()=>ue(xe.id,!1,void 0,"reject"),className:"px-3 py-1.5 text-[11px] font-medium bg-red-600/80 text-white rounded-md hover:bg-red-700 disabled:opacity-50 transition-colors inline-flex items-center gap-1.5",children:[t.jsxs("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round",children:[t.jsx("path",{d:"M18 6L6 18"}),t.jsx("path",{d:"M6 6l12 12"})]}),u("common:reject")]}),w!==xe.id&&t.jsxs("button",{disabled:k===xe.id,onClick:()=>S(xe.id),className:"px-3 py-1.5 text-[11px] font-medium border border-amber-500/50 text-amber-500 rounded-md hover:bg-amber-500/10 disabled:opacity-50 transition-colors inline-flex items-center gap-1.5",children:[t.jsxs("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[t.jsx("path",{d:"M11 4H4a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2v-7"}),t.jsx("path",{d:"M18.5 2.5a2.121 2.121 0 0 1 3 3L12 15l-4 1 1-4 9.5-9.5z"})]}),u("team:notifications.needsAdjustment")]})]}),w===xe.id&&t.jsxs("div",{className:"space-y-1.5",children:[t.jsx("input",{type:"text",autoFocus:!0,placeholder:u("team:notifications.adjustmentPlaceholder"),value:T[xe.id]??"",onChange:qe=>R(ct=>({...ct,[xe.id]:qe.target.value})),onKeyDown:qe=>{qe.key==="Enter"&&(T[xe.id]??"").trim()&&ue(xe.id,!1,(T[xe.id]??"").trim(),"needs_adjustment"),qe.key==="Escape"&&S(null)},className:"w-full px-2.5 py-1.5 text-[11px] bg-surface-overlay border border-border-default rounded-md text-fg-primary placeholder:text-fg-tertiary focus:outline-none focus:ring-1 focus:ring-amber-500/50"}),t.jsxs("div",{className:"flex gap-2",children:[t.jsx("button",{disabled:k===xe.id||!(T[xe.id]??"").trim(),onClick:()=>ue(xe.id,!1,(T[xe.id]??"").trim(),"needs_adjustment"),className:"px-2.5 py-1.5 text-[11px] font-medium bg-amber-600 text-white rounded-md hover:bg-amber-700 disabled:opacity-50 transition-colors",children:u("team:notifications.confirmAdjustment")}),t.jsx("button",{onClick:()=>S(null),className:"px-2.5 py-1.5 text-[11px] font-medium border border-border-default text-fg-secondary rounded-md hover:bg-surface-overlay transition-colors",children:u("common:cancel")})]})]})]}):t.jsxs("div",{className:"space-y-1.5",children:[t.jsx("input",{type:"text",placeholder:u("team:notifications.commentPlaceholder"),value:T[xe.id]??"",onChange:qe=>R(ct=>({...ct,[xe.id]:qe.target.value})),onKeyDown:qe=>{qe.key==="Enter"&&ue(xe.id,!0,Re||void 0,"approve")},className:"w-full px-2.5 py-1.5 text-[11px] bg-surface-overlay border border-border-default rounded-md text-fg-primary placeholder:text-fg-tertiary focus:outline-none focus:ring-1 focus:ring-brand-500/50"}),t.jsxs("div",{className:"flex gap-2",children:[t.jsx("button",{disabled:k===xe.id,onClick:()=>ue(xe.id,!0,Re||void 0,"approve"),className:"flex-1 px-2.5 py-1.5 text-[11px] font-medium bg-green-600 text-white rounded-md hover:bg-green-700 disabled:opacity-50 transition-colors",children:u("common:approve")}),t.jsx("button",{disabled:k===xe.id,onClick:()=>ue(xe.id,!1,Re||void 0,"reject"),className:"flex-1 px-2.5 py-1.5 text-[11px] font-medium border border-border-default text-fg-secondary rounded-md hover:bg-surface-overlay disabled:opacity-50 transition-colors",children:u("common:reject")})]})]})})()]},xe.id)}),Ve.length>0&&t.jsxs(t.Fragment,{children:[We.length>0&&t.jsx("div",{className:"px-3 py-1.5 text-[10px] font-medium text-fg-tertiary uppercase tracking-wider bg-surface-overlay/30",children:u("team:notifications.approvalHistory")}),Ve.slice(0,50).map(xe=>t.jsxs("button",{onClick:()=>de(xe),className:"w-full text-left px-3 py-2.5 hover:bg-surface-overlay/50 transition-colors",children:[t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx("span",{className:`w-1.5 h-1.5 rounded-full shrink-0 ${xe.status==="approved"?"bg-green-500":xe.status==="cancelled"||xe.status==="expired"?"bg-gray-400":"bg-red-500"}`}),t.jsx("span",{className:"text-xs text-fg-secondary truncate flex-1",children:xe.title}),t.jsx("span",{className:`text-[10px] font-medium shrink-0 ${xe.status==="approved"?"text-green-500":xe.status==="cancelled"||xe.status==="expired"?"text-fg-muted":"text-red-500"}`,children:u(`common:status.${xe.status}`,{defaultValue:xe.status})})]}),t.jsxs("div",{className:"flex items-center gap-1.5 mt-0.5 pl-3.5",children:[t.jsx("span",{className:"text-[10px] text-fg-muted truncate",children:je(xe)}),t.jsx("span",{className:"text-[10px] text-fg-muted shrink-0",children:"·"}),t.jsx("span",{className:"text-[10px] text-fg-muted shrink-0",children:Nd(xe.respondedAt??xe.requestedAt,u)})]})]},xe.id))]})]})}),t.jsx("div",{className:"w-full shrink-0 h-full overflow-y-auto scrollbar-thin",children:Y.length===0?t.jsx("div",{className:"p-6 text-center text-xs text-fg-tertiary",children:u("team:notifications.noNotifications")}):t.jsx("div",{className:"divide-y divide-border-default/50",children:Y.slice(0,50).map(xe=>{const tt=o6[xe.type]??"text-fg-tertiary";return t.jsxs("button",{onClick:()=>Te(xe),className:`w-full text-left px-3 py-2.5 flex gap-2.5 transition-colors ${xe.read?"opacity-50 hover:opacity-70":"hover:bg-surface-overlay"}`,children:[t.jsx("div",{className:"shrink-0 mt-0.5",children:t.jsx("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",className:tt,children:t.jsx("path",{d:kd[xe.type]??kd.system})})}),t.jsxs("div",{className:"flex-1 min-w-0",children:[t.jsxs("div",{className:"flex items-center gap-1.5",children:[!xe.read&&t.jsx("span",{className:`w-1.5 h-1.5 rounded-full shrink-0 ${ih[xe.priority]??ih.normal}`}),t.jsx("span",{className:"text-xs text-fg-primary font-medium truncate",children:xe.title})]}),t.jsx("div",{className:"text-[11px] text-fg-tertiary mt-0.5 ",children:t.jsx(fs,{content:xe.body,className:"text-[11px] [&_h1]:text-xs [&_h2]:text-[11px] [&_h3]:text-[11px] [&_p]:text-[11px] [&_li]:text-[11px] [&_p]:text-fg-tertiary"})}),t.jsxs("div",{className:"flex items-center gap-2 mt-0.5",children:[t.jsx("span",{className:"text-[10px] text-fg-muted",children:Nd(xe.createdAt,u)}),oh(xe,u)&&t.jsx("span",{className:`text-[10px] font-medium ${tt}`,children:oh(xe,u)})]})]})]},xe.id)})})})]})})]})}if(a){const W=c||"M18 8A6 6 0 0 0 6 8c0 7-3 9-3 9h18s-3-2-3-9 M13.73 21a2 2 0 0 1-3.46 0";return t.jsxs(t.Fragment,{children:[t.jsxs("button",{ref:L,onClick:()=>{f(!m),m||X()},title:e?l||u("team:notifications.bellTitle"):void 0,className:`w-full flex items-center ${e?"flex-col justify-center px-1 py-1.5 gap-0.5":"gap-3 px-3 py-[7px]"} rounded-lg text-[13px] font-medium mb-0.5 transition-colors relative text-fg-primary ${m||i?"bg-surface-overlay":"hover:bg-surface-overlay/60"}`,children:[t.jsx("svg",{width:e?16:18,height:e?16:18,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.75",strokeLinecap:"round",strokeLinejoin:"round",className:"shrink-0",children:t.jsx("path",{d:W})}),e?t.jsx("span",{className:"text-[9px] leading-tight truncate w-full text-center",children:l}):t.jsx("span",{className:"truncate",children:l}),we>0&&t.jsx("span",{className:`absolute ${e?"top-0.5 right-1":"top-1 left-[22px]"} min-w-[16px] h-4 px-1 rounded-full bg-red-500 text-white text-[10px] font-bold flex items-center justify-center leading-none`,children:we>99?u("common:badgeOverLimit"):we})]}),m&&ao.createPortal(t.jsx("div",{ref:M,className:"fixed bg-surface-secondary border border-border-default rounded-xl shadow-2xl z-[9999] flex flex-col overflow-hidden",style:{top:$.top,left:$.left,width:$.width,maxHeight:$.maxHeight},children:Ne}),document.body)]})}return t.jsxs(t.Fragment,{children:[t.jsxs("button",{ref:L,onClick:()=>{f(!m),m||X()},className:`relative flex items-center justify-center rounded-md transition-colors ${e?"w-8 h-8":"w-7 h-7"} ${m?"bg-surface-overlay text-fg-primary":"text-fg-tertiary hover:text-fg-secondary hover:bg-surface-overlay"}`,title:u("team:notifications.bellTitle"),children:[t.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[t.jsx("path",{d:"M18 8A6 6 0 0 0 6 8c0 7-3 9-3 9h18s-3-2-3-9"}),t.jsx("path",{d:"M13.73 21a2 2 0 0 1-3.46 0"})]}),we>0&&t.jsx("span",{className:"absolute -top-0.5 -right-0.5 min-w-[16px] h-4 px-1 rounded-full bg-red-500 text-white text-[10px] font-bold flex items-center justify-center leading-none",children:we>99?u("common:badgeOverLimit"):we})]}),m&&ao.createPortal(t.jsx("div",{ref:M,className:"fixed bg-surface-secondary border border-border-default rounded-xl shadow-2xl z-[9999] flex flex-col overflow-hidden",style:{top:$.top,left:$.left,width:$.width,maxHeight:$.maxHeight},children:Ne}),document.body)]})}function Xde({authUser:e}){const{t:n}=ht("nav"),r=ea();return t.jsxs("div",{className:"flex-1 flex flex-col overflow-hidden",children:[t.jsxs("div",{className:"flex items-center gap-2 px-4 h-14",children:[r&&t.jsx(Ac,{}),t.jsx("h2",{className:"text-base font-bold",children:n("notifications")})]}),t.jsx("div",{className:"flex-1 overflow-hidden",children:t.jsx(sA,{collapsed:!1,userId:e?.id,embeddedMode:!0})})]})}function Qde(){const{t:e}=ht(["common","home","work"]),[n,r]=g.useState(""),[s,a]=g.useState("all"),[i,l]=g.useState({agents:[],tasks:[],requirements:[],projects:[],deliverables:[],workflows:[]}),[c,u]=g.useState(!1),[m,f]=g.useState(!1),p=g.useRef(null),b=g.useRef(void 0);g.useEffect(()=>{setTimeout(()=>p.current?.focus(),100)},[]);const x=g.useCallback(async k=>{if(!k.trim()){l({agents:[],tasks:[],requirements:[],projects:[],deliverables:[],workflows:[]}),f(!1);return}u(!0),f(!0);const j=k.toLowerCase();try{const[w,S,T,R,I,P]=await Promise.allSettled([ae.agents.list(),ae.tasks.list({search:k,pageSize:20}),ae.requirements.list(),ae.projects.list(),ae.deliverables.search({q:k,limit:20}),ae.teams.list()]),L=w.status==="fulfilled"?w.value.agents.filter(H=>H.name?.toLowerCase().includes(j)||H.role?.toLowerCase().includes(j)):[],M=S.status==="fulfilled"?S.value.tasks:[],$=T.status==="fulfilled"?T.value.requirements.filter(H=>H.title?.toLowerCase().includes(j)||H.description?.toLowerCase().includes(j)):[],U=R.status==="fulfilled"?R.value.projects.filter(H=>H.name?.toLowerCase().includes(j)||H.description?.toLowerCase().includes(j)):[],z=I.status==="fulfilled"?I.value.results:[],A=[];if(P.status==="fulfilled"){const H=await Promise.allSettled(P.value.teams.map(D=>ae.workflows.list(D.id)));for(const D of H)if(D.status==="fulfilled")for(const O of D.value.workflows)(O.name.toLowerCase().includes(j)||(O.displayName||"").toLowerCase().includes(j)||O.description?.toLowerCase().includes(j))&&A.push(O)}l({agents:L,tasks:M,requirements:$,projects:U,deliverables:z,workflows:A})}catch{l({agents:[],tasks:[],requirements:[],projects:[],deliverables:[],workflows:[]})}finally{u(!1)}},[]),v=k=>{r(k),b.current&&clearTimeout(b.current),b.current=setTimeout(()=>x(k),400)},N=[{id:"all",label:e("common:all",{defaultValue:"全部"})},{id:"agents",label:e("common:agents",{defaultValue:"智能体"})},{id:"tasks",label:e("common:tasks",{defaultValue:"任务"})},{id:"requirements",label:e("common:requirements",{defaultValue:"需求"})},{id:"projects",label:e("common:projects",{defaultValue:"项目"})},{id:"deliverables",label:e("common:deliverables",{defaultValue:"交付物"})},{id:"workflows",label:e("common:workflows",{defaultValue:"工作流"})}],C=i.agents.length>0||i.tasks.length>0||i.requirements.length>0||i.projects.length>0||i.deliverables.length>0||i.workflows.length>0;return t.jsxs("div",{className:"flex-1 flex flex-col overflow-hidden",children:[t.jsxs("div",{className:"shrink-0 px-4 pt-4 pb-2 space-y-3",children:[t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx("button",{onClick:()=>Rt.navigate(Be.HOME),className:"p-1.5 rounded-lg hover:bg-surface-overlay transition-colors shrink-0",children:t.jsxs("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[t.jsx("path",{d:"M19 12H5"}),t.jsx("polyline",{points:"12 19 5 12 12 5"})]})}),t.jsxs("div",{className:"flex-1 relative",children:[t.jsxs("svg",{className:"absolute left-3 top-1/2 -translate-y-1/2 text-fg-tertiary",width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[t.jsx("circle",{cx:"11",cy:"11",r:"8"}),t.jsx("line",{x1:"21",y1:"21",x2:"16.65",y2:"16.65"})]}),t.jsx("input",{ref:p,value:n,onChange:k=>v(k.target.value),placeholder:e("common:search"),className:"w-full bg-surface-elevated border border-border-default rounded-xl pl-9 pr-3 py-2.5 text-sm text-fg-primary placeholder:text-fg-tertiary focus:border-brand-500 focus:outline-none transition-colors"}),n&&t.jsx("button",{onClick:()=>{r(""),l({agents:[],tasks:[],requirements:[],projects:[],deliverables:[],workflows:[]}),f(!1),p.current?.focus()},className:"absolute right-3 top-1/2 -translate-y-1/2 text-fg-tertiary hover:text-fg-secondary",children:t.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[t.jsx("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),t.jsx("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]})})]})]}),t.jsx("div",{className:"flex gap-1 overflow-x-auto scrollbar-hide",children:N.map(k=>t.jsx("button",{onClick:()=>a(k.id),className:`px-3 py-1.5 text-xs rounded-lg whitespace-nowrap transition-colors ${s===k.id?"bg-brand-600 text-white":"bg-surface-elevated text-fg-secondary hover:text-fg-primary"}`,children:k.label},k.id))})]}),t.jsxs("div",{className:"flex-1 overflow-y-auto px-4 pb-4",children:[c&&t.jsx("div",{className:"flex items-center justify-center py-12",children:t.jsx("div",{className:"text-fg-tertiary text-sm animate-pulse",children:e("common:loading")})}),!c&&m&&!C&&t.jsxs("div",{className:"flex flex-col items-center justify-center py-12 text-center",children:[t.jsxs("svg",{width:"40",height:"40",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.5",className:"text-fg-tertiary mb-3",children:[t.jsx("circle",{cx:"11",cy:"11",r:"8"}),t.jsx("line",{x1:"21",y1:"21",x2:"16.65",y2:"16.65"})]}),t.jsx("p",{className:"text-sm text-fg-tertiary",children:e("common:noResults",{defaultValue:"没有找到相关结果"})})]}),!c&&C&&t.jsxs("div",{className:"space-y-4",children:[(s==="all"||s==="agents")&&i.agents.length>0&&t.jsxs("section",{children:[t.jsx("h3",{className:"text-xs font-medium text-fg-tertiary uppercase mb-2",children:e("common:agents",{defaultValue:"智能体"})}),t.jsx("div",{className:"space-y-1",children:(s==="all"?i.agents.slice(0,8):i.agents).map(k=>t.jsxs("button",{onClick:()=>Rt.navigate(Be.TEAM,{agentId:k.id}),className:"w-full flex items-center gap-3 px-3 py-2.5 rounded-xl hover:bg-surface-overlay transition-colors text-left",children:[t.jsx(_r,{name:k.name||"Agent",avatarUrl:k.avatarUrl,size:32}),t.jsxs("div",{className:"flex-1 min-w-0",children:[t.jsx("div",{className:"text-sm font-medium text-fg-primary truncate",children:k.name}),t.jsx("div",{className:"text-xs text-fg-tertiary truncate",children:k.role||k.status})]}),t.jsx(Zde,{status:k.status})]},k.id))}),s==="all"&&i.agents.length>8&&t.jsxs("button",{onClick:()=>a("agents"),className:"mt-1 w-full text-xs text-brand-500 hover:text-brand-400 py-1.5 rounded-lg hover:bg-surface-overlay transition-colors",children:[e("common:showAll",{defaultValue:"查看全部"})," (",i.agents.length,")"]})]}),(s==="all"||s==="tasks")&&i.tasks.length>0&&t.jsxs("section",{children:[t.jsx("h3",{className:"text-xs font-medium text-fg-tertiary uppercase mb-2",children:e("common:tasks",{defaultValue:"任务"})}),t.jsx("div",{className:"space-y-1",children:(s==="all"?i.tasks.slice(0,8):i.tasks).map(k=>t.jsxs("button",{onClick:()=>Rt.navigate(Be.WORK,{openTask:k.id}),className:"w-full flex items-center gap-3 px-3 py-2.5 rounded-xl hover:bg-surface-overlay transition-colors text-left",children:[t.jsx(Jde,{status:k.status}),t.jsxs("div",{className:"flex-1 min-w-0",children:[t.jsx("div",{className:"text-sm text-fg-primary truncate",children:k.title}),t.jsxs("div",{className:"text-xs text-fg-tertiary truncate",children:[k.status," · ",k.priority||""]})]})]},k.id))}),s==="all"&&i.tasks.length>8&&t.jsxs("button",{onClick:()=>a("tasks"),className:"mt-1 w-full text-xs text-brand-500 hover:text-brand-400 py-1.5 rounded-lg hover:bg-surface-overlay transition-colors",children:[e("common:showAll",{defaultValue:"查看全部"})," (",i.tasks.length,")"]})]}),(s==="all"||s==="requirements")&&i.requirements.length>0&&t.jsxs("section",{children:[t.jsx("h3",{className:"text-xs font-medium text-fg-tertiary uppercase mb-2",children:e("common:requirements",{defaultValue:"需求"})}),t.jsx("div",{className:"space-y-1",children:(s==="all"?i.requirements.slice(0,8):i.requirements).map(k=>t.jsxs("button",{onClick:()=>Rt.navigate(Be.WORK,{openRequirement:k.id}),className:"w-full flex items-center gap-3 px-3 py-2.5 rounded-xl hover:bg-surface-overlay transition-colors text-left",children:[t.jsx("div",{className:`w-8 h-8 rounded-lg flex items-center justify-center shrink-0 ${k.status==="approved"?"text-green-500 bg-green-500/15":k.status==="pending"?"text-amber-500 bg-amber-500/15":k.status==="rejected"?"text-red-500 bg-red-500/15":"text-fg-tertiary bg-surface-elevated"}`,children:t.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[t.jsx("path",{d:"M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z"}),t.jsx("polyline",{points:"14 2 14 8 20 8"}),t.jsx("line",{x1:"16",y1:"13",x2:"8",y2:"13"}),t.jsx("line",{x1:"16",y1:"17",x2:"8",y2:"17"})]})}),t.jsxs("div",{className:"flex-1 min-w-0",children:[t.jsx("div",{className:"text-sm text-fg-primary truncate",children:k.title}),t.jsxs("div",{className:"text-xs text-fg-tertiary truncate",children:[k.status," · ",k.priority||""]})]})]},k.id))}),s==="all"&&i.requirements.length>8&&t.jsxs("button",{onClick:()=>a("requirements"),className:"mt-1 w-full text-xs text-brand-500 hover:text-brand-400 py-1.5 rounded-lg hover:bg-surface-overlay transition-colors",children:[e("common:showAll",{defaultValue:"查看全部"})," (",i.requirements.length,")"]})]}),(s==="all"||s==="projects")&&i.projects.length>0&&t.jsxs("section",{children:[t.jsx("h3",{className:"text-xs font-medium text-fg-tertiary uppercase mb-2",children:e("common:projects",{defaultValue:"项目"})}),t.jsx("div",{className:"space-y-1",children:(s==="all"?i.projects.slice(0,8):i.projects).map(k=>t.jsxs("button",{onClick:()=>Rt.navigate(Be.WORK,{projectId:k.id}),className:"w-full flex items-center gap-3 px-3 py-2.5 rounded-xl hover:bg-surface-overlay transition-colors text-left",children:[t.jsx("div",{className:"w-8 h-8 rounded-lg bg-brand-500/15 flex items-center justify-center shrink-0",children:t.jsx("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",className:"text-brand-500",children:t.jsx("path",{d:"M22 19a2 2 0 0 1-2 2H4a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h5l2 3h9a2 2 0 0 1 2 2z"})})}),t.jsxs("div",{className:"flex-1 min-w-0",children:[t.jsx("div",{className:"text-sm text-fg-primary truncate",children:k.name}),k.description&&t.jsx("div",{className:"text-xs text-fg-tertiary truncate",children:k.description})]})]},k.id))}),s==="all"&&i.projects.length>8&&t.jsxs("button",{onClick:()=>a("projects"),className:"mt-1 w-full text-xs text-brand-500 hover:text-brand-400 py-1.5 rounded-lg hover:bg-surface-overlay transition-colors",children:[e("common:showAll",{defaultValue:"查看全部"})," (",i.projects.length,")"]})]}),(s==="all"||s==="deliverables")&&i.deliverables.length>0&&t.jsxs("section",{children:[t.jsx("h3",{className:"text-xs font-medium text-fg-tertiary uppercase mb-2",children:e("common:deliverables",{defaultValue:"交付物"})}),t.jsx("div",{className:"space-y-1",children:(s==="all"?i.deliverables.slice(0,8):i.deliverables).map(k=>t.jsxs("button",{onClick:()=>Rt.navigate(Be.DELIVERABLES,{openDeliverable:k.id}),className:"w-full flex items-center gap-3 px-3 py-2.5 rounded-xl hover:bg-surface-overlay transition-colors text-left",children:[t.jsx("div",{className:"w-8 h-8 rounded-lg bg-purple-500/15 flex items-center justify-center shrink-0",children:t.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",className:"text-purple-500",children:[t.jsx("path",{d:"M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z"}),t.jsx("polyline",{points:"14 2 14 8 20 8"})]})}),t.jsxs("div",{className:"flex-1 min-w-0",children:[t.jsx("div",{className:"text-sm text-fg-primary truncate",children:k.title}),t.jsxs("div",{className:"text-xs text-fg-tertiary truncate",children:[k.type," · ",k.status]})]})]},k.id))}),s==="all"&&i.deliverables.length>8&&t.jsxs("button",{onClick:()=>a("deliverables"),className:"mt-1 w-full text-xs text-brand-500 hover:text-brand-400 py-1.5 rounded-lg hover:bg-surface-overlay transition-colors",children:[e("common:showAll",{defaultValue:"查看全部"})," (",i.deliverables.length,")"]})]}),(s==="all"||s==="workflows")&&i.workflows.length>0&&t.jsxs("section",{children:[t.jsx("h3",{className:"text-xs font-medium text-fg-tertiary uppercase mb-2",children:e("common:workflows",{defaultValue:"工作流"})}),t.jsx("div",{className:"space-y-1",children:(s==="all"?i.workflows.slice(0,8):i.workflows).map(k=>t.jsxs("button",{onClick:()=>Rt.navigate(Be.WORK,{boardType:"workflows"}),className:"w-full flex items-center gap-3 px-3 py-2.5 rounded-xl hover:bg-surface-overlay transition-colors text-left",children:[t.jsx("div",{className:"w-8 h-8 rounded-lg bg-teal-500/15 flex items-center justify-center shrink-0",children:t.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",className:"text-teal-500",children:[t.jsx("circle",{cx:"12",cy:"12",r:"3"}),t.jsx("path",{d:"M19.4 15a1.65 1.65 0 0 0 .33 1.82l.06.06a2 2 0 0 1 0 2.83 2 2 0 0 1-2.83 0l-.06-.06a1.65 1.65 0 0 0-1.82-.33 1.65 1.65 0 0 0-1 1.51V21a2 2 0 0 1-2 2 2 2 0 0 1-2-2v-.09A1.65 1.65 0 0 0 9 19.4a1.65 1.65 0 0 0-1.82.33l-.06.06a2 2 0 0 1-2.83 0 2 2 0 0 1 0-2.83l.06-.06A1.65 1.65 0 0 0 4.68 15a1.65 1.65 0 0 0-1.51-1H3a2 2 0 0 1-2-2 2 2 0 0 1 2-2h.09A1.65 1.65 0 0 0 4.6 9a1.65 1.65 0 0 0-.33-1.82l-.06-.06a2 2 0 0 1 0-2.83 2 2 0 0 1 2.83 0l.06.06A1.65 1.65 0 0 0 9 4.68a1.65 1.65 0 0 0 1-1.51V3a2 2 0 0 1 2-2 2 2 0 0 1 2 2v.09a1.65 1.65 0 0 0 1 1.51 1.65 1.65 0 0 0 1.82-.33l.06-.06a2 2 0 0 1 2.83 0 2 2 0 0 1 0 2.83l-.06.06A1.65 1.65 0 0 0 19.4 9a1.65 1.65 0 0 0 1.51 1H21a2 2 0 0 1 2 2 2 2 0 0 1-2 2h-.09a1.65 1.65 0 0 0-1.51 1z"})]})}),t.jsxs("div",{className:"flex-1 min-w-0",children:[t.jsx("div",{className:"text-sm text-fg-primary truncate",children:k.displayName||k.name}),t.jsxs("div",{className:"text-xs text-fg-tertiary truncate",children:[k.stepCount," steps · v",k.version]})]})]},k.name))}),s==="all"&&i.workflows.length>8&&t.jsxs("button",{onClick:()=>a("workflows"),className:"mt-1 w-full text-xs text-brand-500 hover:text-brand-400 py-1.5 rounded-lg hover:bg-surface-overlay transition-colors",children:[e("common:showAll",{defaultValue:"查看全部"})," (",i.workflows.length,")"]})]})]}),!c&&!m&&t.jsxs("div",{className:"flex flex-col items-center justify-center py-12 text-center",children:[t.jsxs("svg",{width:"40",height:"40",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.5",className:"text-fg-tertiary mb-3",children:[t.jsx("circle",{cx:"11",cy:"11",r:"8"}),t.jsx("line",{x1:"21",y1:"21",x2:"16.65",y2:"16.65"})]}),t.jsx("p",{className:"text-sm text-fg-tertiary",children:e("common:search")})]})]})]})}function Zde({status:e}){const n=e==="active"||e==="idle"?"bg-green-500":e==="working"||e==="busy"?"bg-blue-500":"bg-gray-400";return t.jsx("span",{className:`w-2 h-2 rounded-full shrink-0 ${n}`})}function Jde({status:e}){const n=e==="completed"?"text-green-500 bg-green-500/15":e==="in_progress"?"text-blue-500 bg-blue-500/15":e==="pending"?"text-amber-500 bg-amber-500/15":"text-fg-tertiary bg-surface-elevated";return t.jsx("div",{className:`w-8 h-8 rounded-lg flex items-center justify-center shrink-0 ${n}`,children:t.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[t.jsx("path",{d:"M9 11l3 3L22 4"}),t.jsx("path",{d:"M21 12v7a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h11"})]})})}function A1({d:e,size:n=18}){return t.jsx("svg",{width:n,height:n,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.75",strokeLinecap:"round",strokeLinejoin:"round",className:"shrink-0",children:t.jsx("path",{d:e})})}function eue({currentPage:e,onNavigate:n,authUser:r,collapsed:s,onToggleCollapse:a}){const{t:i}=ht(["nav","common"]);return t.jsxs("aside",{className:"h-dvh bg-surface-secondary flex flex-col shrink-0 overflow-hidden",children:[t.jsx("div",{className:`flex items-center ${s?"px-2 py-3.5 justify-center":"px-4 h-14 justify-between"}`,children:t.jsxs("button",{onClick:a,title:i(s?"sidebar.expandSidebar":"sidebar.collapseSidebar"),className:"flex items-center gap-2.5 min-w-0 group",children:[t.jsx("img",{src:"/logo.png",alt:"Markus",className:"w-8 h-8 rounded-lg shrink-0"}),!s&&t.jsx("span",{className:"text-[15px] font-bold tracking-tight text-fg-primary whitespace-nowrap",children:"Markus"})]})}),t.jsx("nav",{className:`${s?"p-1":"px-3 py-2"} flex-1 overflow-y-auto scrollbar-thin`,children:hF.map((l,c)=>{const u=pF.filter(f=>f.section===l.key&&f.id!==Be.SETTINGS);if(u.length===0)return null;const m=i(`sections.${l.key}`);return t.jsx("div",{children:t.jsxs("div",{className:c>0?"mt-3":"",children:[!s&&m&&t.jsx("div",{className:"px-3 py-1.5 mb-1 text-[10px] font-semibold text-fg-muted uppercase tracking-[0.1em]",children:m}),s&&c>0&&t.jsx("div",{className:"my-3"}),u.map(f=>{if(f.id===Be.NOTIFICATIONS)return t.jsx(sA,{sidebarMode:!0,collapsed:s,userId:r?.id,label:i(f.id),iconPath:uh[f.id],isActive:e===f.id},f.id);const p=e===f.id;return t.jsxs("button",{onClick:()=>n(f.id),title:s?i(f.id):void 0,className:`w-full flex items-center ${s?"flex-col justify-center px-1 py-1.5 gap-0.5":"gap-3 px-3 py-[7px]"} rounded-lg text-[13px] font-medium mb-0.5 transition-colors text-fg-primary ${p?"bg-surface-overlay":"hover:bg-surface-overlay/60"}`,children:[t.jsx(A1,{d:uh[f.id]??"",size:s?16:18}),s?t.jsx("span",{className:"text-[9px] leading-tight truncate w-full text-center",children:i(f.id)}):t.jsx("span",{className:"truncate",children:i(f.id)})]},f.id)})]})},l.key)})}),t.jsxs("div",{className:`shrink-0 ${s?"p-1":"px-3 pb-2"} flex items-center ${s?"flex-col gap-1":"justify-between"}`,children:[window.markusDesktop&&t.jsx("button",{onClick:()=>window.markusDesktop?.openInBrowser(),title:i("common:openInBrowser","Open in Browser"),className:"flex items-center justify-center w-8 h-8 rounded-lg transition-colors text-fg-secondary hover:bg-surface-overlay/60 hover:text-fg-primary",children:t.jsx(A1,{d:"M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6M15 3h6v6M10 14 21 3",size:16})}),t.jsx("button",{onClick:()=>n(Be.SETTINGS),title:i(Be.SETTINGS),className:"flex items-center justify-center w-8 h-8 rounded-lg transition-colors text-fg-secondary hover:bg-surface-overlay/60 hover:text-fg-primary",children:t.jsx(A1,{d:uh[Be.SETTINGS],size:16})}),!s&&t.jsxs("span",{className:"text-[10px] text-fg-muted select-none",children:["v","0.8.5-rc.1"]})]})]})}function tue({currentPage:e,onNavigate:n,userId:r}){const{t:s}=ht("nav"),[a,i]=g.useState(0),{counts:l}=OT({enabled:!0}),c=g.useMemo(()=>{let m=0;for(const f of Object.values(l))m+=f;return m},[l]),u=g.useCallback(async()=>{try{const m=await ae.notifications.list(r,!1);i(m.unreadCount??m.notifications.filter(f=>!f.read).length)}catch{}},[r]);return g.useEffect(()=>{u();const m=setInterval(u,15e3),f=()=>u();return window.addEventListener("markus:notifications-changed",f),()=>{clearInterval(m),window.removeEventListener("markus:notifications-changed",f)}},[u]),t.jsx("nav",{className:"fixed bottom-0 left-0 right-0 z-50 bg-surface-secondary flex items-stretch h-14 safe-area-bottom",children:gF.map(m=>{const f=m.group.includes(e),p=m.id===Be.NOTIFICATIONS,b=m.id===Be.TEAM;return t.jsxs("button",{onClick:()=>n(m.id),className:`flex-1 flex flex-col items-center justify-center gap-0.5 transition-colors ${f?"text-fg-primary":"text-fg-tertiary active:text-fg-secondary"}`,children:[t.jsxs("div",{className:"relative",children:[t.jsx("svg",{width:20,height:20,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:f?2:1.75,strokeLinecap:"round",strokeLinejoin:"round",className:"shrink-0",children:t.jsx("path",{d:uh[m.id]})}),p&&a>0&&t.jsx("span",{className:"absolute -top-1.5 -right-2 min-w-[16px] h-4 px-1 flex items-center justify-center bg-red-500 text-white text-[9px] font-bold rounded-full leading-none",children:a>99?"99+":a}),b&&c>0&&t.jsx("span",{className:"absolute -top-1.5 -right-2 min-w-[16px] h-4 px-1 flex items-center justify-center bg-red-500 text-white text-[9px] font-bold rounded-full leading-none",children:c>99?"99+":c})]}),t.jsx("span",{className:`text-[10px] leading-tight ${f?"font-semibold":""}`,children:s(m.id)})]},m.id)})})}const aA=["builder","agents","teams","skills"];function nue(){const e=localStorage.getItem("markus_nav_storeTab");return e&&(localStorage.removeItem("markus_nav_storeTab"),aA.includes(e))?e:"builder"}function rue({authUser:e}){const{t:n}=ht(["nav","common"]),r=g.useMemo(()=>[{id:"builder",label:n("nav:builder")},{id:"agents",label:n("nav:tabs.agents")},{id:"teams",label:n("nav:tabs.teams")},{id:"skills",label:n("nav:tabs.skills")}],[n]),[s,a]=g.useState(nue),i=zl(r,s,a);return g.useEffect(()=>{const l=c=>{const u=c.detail;u.params?.storeTab&&aA.includes(u.params.storeTab)&&a(u.params.storeTab)};return window.addEventListener("markus:navigate",l),()=>window.removeEventListener("markus:navigate",l)},[]),t.jsxs("div",{className:"flex-1 overflow-hidden flex flex-col",onTouchStart:i.onTouchStart,onTouchEnd:i.onTouchEnd,children:[t.jsxs("div",{className:"flex items-center shrink-0 overflow-x-auto scrollbar-hide",children:[t.jsx(Ac,{className:"ml-2"}),r.map(l=>t.jsx("button",{onClick:()=>a(l.id),className:`flex-1 min-w-0 px-3 py-2.5 text-xs font-medium text-center whitespace-nowrap transition-colors border-b-2 ${s===l.id?"border-brand-500 text-brand-500":"border-transparent text-fg-tertiary"}`,children:l.label},l.id))]}),t.jsxs("div",{className:"flex-1 overflow-hidden flex flex-col",children:[s==="builder"&&t.jsx(s8,{}),s==="agents"&&t.jsx(ZT,{authUser:e}),s==="teams"&&t.jsx(t8,{}),s==="skills"&&t.jsx(n8,{})]})]})}const l6="usageType",M1="profile";function sue({onComplete:e,theme:n,onThemeChange:r,skipProfile:s}){const{t:a}=ht(["onboarding","common"]),[i,l]=g.useState(0),[c,u]=g.useState(""),[m,f]=g.useState(""),[p,b]=g.useState(""),[x,v]=g.useState(""),[N,C]=g.useState(!1),[k,j]=g.useState(""),[w,S]=g.useState(!1),[T,R]=g.useState(null);g.useEffect(()=>{ae.auth.me().then(({user:ye})=>{ye.name&&u(ye.name),ye.email&&f(ye.email),ye.avatarUrl&&R(ye.avatarUrl);const we=ye.name||ye.email?.split("@")[0]||"";we&&M(a("usageType.defaultOrgName",{name:we}))}).catch(()=>{}),ae.hubOrgs.invitations().then(ye=>{ye.invitations?.length>0&&D(ye.invitations)}).catch(()=>{})},[]);const[I,P]=g.useState(null),[L,M]=g.useState(""),[$,U]=g.useState(!1),[z,A]=g.useState(!1),[H,D]=g.useState([]),[O,q]=g.useState(null),[J,B]=g.useState(null),[V,X]=g.useState(!0),K=async()=>{if(j(""),!c.trim()){j(a("profile.errors.nameRequired"));return}if(!m.trim()){j(a("profile.errors.emailRequired"));return}if(!/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(m.trim())){j(a("profile.errors.emailInvalid"));return}if(p&&p.length<6){j(a("profile.errors.passwordTooShort"));return}if(p&&p!==x){j(a("profile.errors.passwordMismatch"));return}C(!0);try{await ae.auth.updateProfile(c.trim(),m.trim()),p&&await ae.auth.changePassword("",p),S(!0)}catch{j(a("profile.errors.saveFailed"))}finally{C(!1)}},ee=[{value:"system",label:a("theme.system"),icon:"💻",desc:a("theme.systemDesc")},{value:"light",label:a("theme.light"),icon:"☀️",desc:a("theme.lightDesc")},{value:"dark",label:a("theme.dark"),icon:"🌊",desc:a("theme.darkDesc")},{value:"cyberpunk",label:a("theme.cyberpunk"),icon:"🔮",desc:a("theme.cyberpunkDesc")},{value:"mono",label:a("theme.mono"),icon:"⬛",desc:a("theme.monoDesc")}],Q=[{id:"welcome",title:a("welcome.title"),subtitle:a("welcome.subtitle"),content:t.jsx("p",{className:"text-fg-secondary text-sm leading-relaxed",children:t.jsx(N6,{i18nKey:"welcome.description",ns:"onboarding",components:{strong:t.jsx("strong",{className:"text-fg-primary"})}})})},{id:l6,title:a("usageType.title",{defaultValue:"How will you use Markus?"}),subtitle:a("usageType.subtitle",{defaultValue:"This helps us tailor your experience."}),content:t.jsxs("div",{className:"space-y-4",children:[t.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[t.jsxs("button",{onClick:()=>{P("personal"),A(!0)},className:`flex flex-col items-center gap-3 rounded-xl border-2 p-5 transition-all text-left ${I==="personal"?"border-brand-500 bg-brand-500/10":"border-border-default hover:border-fg-tertiary bg-surface-elevated/30"}`,children:[t.jsx("span",{className:"text-2xl",children:"👤"}),t.jsxs("div",{children:[t.jsx("div",{className:"font-medium text-fg-primary text-sm text-center",children:a("usageType.personal",{defaultValue:"Personal"})}),t.jsx("div",{className:"text-[11px] text-fg-tertiary mt-1 text-center",children:a("usageType.personalDesc",{defaultValue:"Individual use with your own AI agents."})})]})]}),t.jsxs("button",{onClick:()=>{P("organization"),A(!1)},className:`flex flex-col items-center gap-3 rounded-xl border-2 p-5 transition-all text-left ${I==="organization"?"border-brand-500 bg-brand-500/10":"border-border-default hover:border-fg-tertiary bg-surface-elevated/30"}`,children:[t.jsx("span",{className:"text-2xl",children:"🏢"}),t.jsxs("div",{children:[t.jsx("div",{className:"font-medium text-fg-primary text-sm text-center",children:a("usageType.organization",{defaultValue:"Team & Enterprise"})}),t.jsx("div",{className:"text-[11px] text-fg-tertiary mt-1 text-center",children:a("usageType.organizationDesc",{defaultValue:"For teams sharing licenses and collaborating."})})]})]})]}),I==="organization"&&t.jsxs("div",{className:"space-y-4 mt-4",children:[H.length>0&&t.jsxs("div",{className:"space-y-2",children:[t.jsx("div",{className:"text-xs text-fg-tertiary font-medium",children:a("usageType.pendingInvitations")}),H.map(ye=>t.jsxs("div",{className:"flex items-center justify-between px-4 py-3 rounded-xl border border-amber-500/20 bg-amber-500/5",children:[t.jsxs("div",{children:[t.jsx("div",{className:"text-sm font-medium text-fg-primary",children:ye.orgName}),t.jsx("div",{className:"text-[11px] text-fg-tertiary",children:a("usageType.invitedBy",{name:ye.invitedBy})})]}),t.jsx("button",{onClick:async()=>{q(ye.orgId);try{await ae.hubOrgs.acceptInvitation(ye.orgId),B(ye.orgId),A(!0)}catch{}finally{q(null)}},disabled:O===ye.orgId||J===ye.orgId,className:"px-3 py-1.5 text-xs rounded-lg bg-brand-600 hover:bg-brand-500 disabled:opacity-40 text-white transition-colors",children:J===ye.orgId?a("usageType.accepted"):O===ye.orgId?a("usageType.accepting"):a("usageType.acceptAndJoin")})]},ye.orgId)),t.jsx("div",{className:"text-[11px] text-fg-tertiary text-center pt-1",children:a("usageType.orCreateNew")})]}),t.jsxs("div",{className:"space-y-1",children:[t.jsx("label",{className:"text-xs text-fg-tertiary font-medium",children:a("usageType.orgNameLabel")}),t.jsx("input",{type:"text",value:L,onChange:ye=>{M(ye.target.value),A(!1)},placeholder:a("usageType.orgNamePlaceholder"),className:"w-full px-4 py-2.5 bg-surface-elevated border border-border-default rounded-xl text-sm text-fg-primary focus:border-brand-500 outline-none transition-colors"})]}),t.jsx("button",{onClick:async()=>{if(L.trim()){U(!0);try{const we=(await ae.hubOrgs.mine()).orgs?.[0];we?.id&&await ae.hubOrgs.update(we.id,{name:L.trim()}),A(!0)}catch{}finally{U(!1)}}},disabled:$||!L.trim()||z,className:"w-full px-4 py-2.5 bg-brand-600 hover:bg-brand-500 disabled:opacity-40 text-white text-sm rounded-xl transition-colors",children:a($?"common:saving":z?"usageType.orgNameSaved":"usageType.setOrgName")})]})]})},{id:M1,title:a("profile.title"),subtitle:a("profile.subtitle"),content:w?t.jsxs("div",{className:"flex items-center gap-3 bg-green-500/10 border border-green-500/30 rounded-xl p-4",children:[t.jsx("span",{className:"text-green-600 text-lg",children:"✓"}),t.jsxs("div",{children:[t.jsx("div",{className:"text-sm font-medium text-green-600",children:a("profile.saved")}),t.jsxs("div",{className:"text-xs text-fg-secondary mt-0.5",children:[c," · ",m]})]})]}):t.jsxs("div",{className:"space-y-4",children:[t.jsx("div",{className:"flex justify-center",children:t.jsx(R6,{currentUrl:T,name:c,size:64,targetType:"user"})}),t.jsxs("div",{className:"space-y-1",children:[t.jsxs("label",{className:"text-xs text-fg-tertiary font-medium",children:[a("profile.nameLabel")," ",t.jsx("span",{className:"text-red-500",children:"*"})]}),t.jsx("input",{type:"text",value:c,onChange:ye=>u(ye.target.value),placeholder:a("profile.namePlaceholder"),className:"w-full px-4 py-2.5 bg-surface-elevated border border-border-default rounded-xl text-sm text-fg-primary focus:border-brand-500 outline-none transition-colors",autoFocus:!0})]}),t.jsxs("div",{className:"space-y-1",children:[t.jsxs("label",{className:"text-xs text-fg-tertiary font-medium",children:[a("profile.emailLabel")," ",t.jsx("span",{className:"text-red-500",children:"*"})]}),t.jsx("input",{type:"email",value:m,onChange:ye=>f(ye.target.value),placeholder:a("profile.emailPlaceholder"),className:"w-full px-4 py-2.5 bg-surface-elevated border border-border-default rounded-xl text-sm text-fg-primary focus:border-brand-500 outline-none transition-colors"})]}),t.jsxs("div",{className:"space-y-1",children:[t.jsx("label",{className:"text-xs text-fg-tertiary font-medium",children:a("profile.newPasswordLabel")}),t.jsx("input",{type:"password",value:p,onChange:ye=>b(ye.target.value),placeholder:a("profile.newPasswordPlaceholder"),className:"w-full px-4 py-2.5 bg-surface-elevated border border-border-default rounded-xl text-sm text-fg-primary focus:border-brand-500 outline-none transition-colors"})]}),p&&t.jsxs("div",{className:"space-y-1",children:[t.jsx("label",{className:"text-xs text-fg-tertiary font-medium",children:a("profile.confirmPasswordLabel")}),t.jsx("input",{type:"password",value:x,onChange:ye=>v(ye.target.value),placeholder:a("profile.confirmPasswordPlaceholder"),className:"w-full px-4 py-2.5 bg-surface-elevated border border-border-default rounded-xl text-sm text-fg-primary focus:border-brand-500 outline-none transition-colors"})]}),k&&t.jsx("div",{className:"px-3 py-2 bg-red-500/10 border border-red-500/30 rounded-lg text-xs text-red-500",children:k}),t.jsx("button",{onClick:()=>{K()},disabled:N||!c.trim()||!m.trim(),className:"w-full px-4 py-2.5 bg-brand-600 hover:bg-brand-500 disabled:opacity-40 text-white text-sm rounded-xl transition-colors",children:a(N?"common:saving":"profile.saveProfile")})]})},{id:"theme",title:a("theme.title"),subtitle:a("theme.subtitle"),content:t.jsxs("div",{className:"space-y-4",children:[t.jsx("div",{className:"grid grid-cols-3 gap-3",children:ee.map(ye=>t.jsxs("button",{onClick:()=>r(ye.value),className:`flex flex-col items-center gap-2 rounded-xl border-2 p-5 transition-all ${n===ye.value?"border-brand-500 bg-brand-500/10":"border-border-default hover:border-fg-tertiary bg-surface-elevated/30"}`,children:[t.jsx("span",{className:"text-2xl",children:ye.icon}),t.jsx("span",{className:"text-sm font-medium text-fg-primary",children:ye.label}),t.jsx("span",{className:"text-[11px] text-fg-tertiary leading-tight text-center",children:ye.desc})]},ye.value))}),t.jsxs("label",{className:"flex items-center gap-2.5 p-3 bg-surface-elevated/30 rounded-lg cursor-pointer group",children:[t.jsx("input",{type:"checkbox",checked:V,onChange:ye=>X(ye.target.checked),className:"accent-brand-500 shrink-0"}),t.jsx("span",{className:"text-[11px] text-fg-tertiary",children:a("done.telemetry")})]})]})}],ne=s?Q.filter(ye=>ye.id!==M1):Q,te=ne.findIndex(ye=>ye.id===l6),Y=ne.findIndex(ye=>ye.id===M1),oe=()=>{i===te&&te>=0&&!I||i===te&&I==="organization"&&!z||i===Y&&Y>=0&&!w||(i<ne.length-1?l(i+1):(fetch("/api/settings/telemetry",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({enabled:V})}).catch(()=>{}),e()))},ge=ne[i];return t.jsx("div",{className:"min-h-dvh bg-surface-primary flex items-center justify-center p-4",children:t.jsx("div",{className:"w-full max-w-lg",children:t.jsxs("div",{className:"bg-surface-elevated rounded-2xl p-8",children:[t.jsx("div",{className:"flex gap-1.5 mb-8",children:ne.map((ye,we)=>t.jsx("div",{className:`h-1 flex-1 rounded-full transition-colors ${we<=i?"bg-brand-500":"bg-surface-elevated"}`},we))}),t.jsx("h2",{className:"text-2xl font-bold text-fg-primary",children:ge.title}),t.jsx("p",{className:"text-sm text-fg-secondary mt-1 mb-6",children:ge.subtitle}),ge.content,t.jsxs("div",{className:"flex justify-between mt-8",children:[i>0?t.jsx("button",{onClick:()=>l(i-1),className:"px-4 py-2 text-sm text-fg-secondary hover:text-fg-primary transition-colors",children:a("common:back")}):t.jsx("button",{onClick:e,className:"px-4 py-2 text-sm text-fg-tertiary hover:text-fg-secondary transition-colors",children:a("common:skip")}),t.jsxs("div",{className:"flex items-center gap-3",children:[te>=0&&i===te&&!I&&t.jsx("button",{onClick:()=>{P("personal"),A(!0),l(i+1)},className:"px-4 py-2 text-sm text-fg-tertiary hover:text-fg-secondary transition-colors",children:a("common:skip")}),Y>=0&&i===Y&&!w&&t.jsx("button",{onClick:()=>l(i+1),className:"px-4 py-2 text-sm text-fg-tertiary hover:text-fg-secondary transition-colors",children:a("common:skip")}),t.jsx("button",{onClick:oe,disabled:Y>=0&&i===Y&&!w||te>=0&&i===te&&(!I||I==="organization"&&!z),className:`px-6 py-2.5 text-white text-sm rounded-xl transition-colors ${Y>=0&&i===Y&&!w||te>=0&&i===te&&(!I||I==="organization"&&!z)?"bg-brand-600/40 cursor-not-allowed":"bg-brand-600 hover:bg-brand-500"}`,children:i===ne.length-1?a("getStarted"):a("common:next")})]})]})]})})})}function aue({onLogin:e,hasOwner:n,hasMultipleUsers:r}){const{t:s}=ht("auth"),[a,i]=g.useState(null),[l,c]=g.useState(""),[u,m]=g.useState(!1),[f,p]=g.useState(""),[b,x]=g.useState(""),v=async(k,j=!1)=>{c(""),i(k??"hub");try{await ka(k);const w=Ja(),S=lp();if(!w||!S){c(s("login.hubUnavailable"));return}const{user:T,needsOnboarding:R}=await ae.auth.hubLogin(w,S);e(T,R??!1,{fromHub:!0})}catch(w){const S=w instanceof Error?w.message:"";if(!S.includes("cancelled")){if(!j&&Ja())return E0(),v(k,!0);c(S||s("login.hubUnavailable"))}}finally{i(null)}},N=async k=>{if(k.preventDefault(),!(!f.trim()||!b)){c(""),i("local");try{const{user:j,needsOnboarding:w}=await ae.auth.login(f.trim(),b);e(j,w??!1)}catch{c(s("login.invalidCredentials"))}finally{i(null)}}},C=s(n?"login.welcomeBack":"login.getStarted");return t.jsxs("div",{className:"min-h-dvh bg-surface-primary flex flex-col items-center justify-center p-4 relative overflow-hidden",children:[t.jsx("div",{className:"absolute inset-0 bg-[radial-gradient(ellipse_at_top,_var(--tw-gradient-stops))] from-brand-950/50 via-transparent to-transparent"}),t.jsxs("div",{className:"w-full max-w-sm relative z-10 flex-1 flex flex-col justify-center",children:[t.jsxs("div",{className:"text-center mb-8",children:[t.jsx("img",{src:"/logo.png",alt:"Markus",className:"w-14 h-14 mx-auto mb-3 rounded-xl shadow-lg shadow-black/40"}),t.jsx("div",{className:"text-2xl font-extrabold tracking-tight text-fg-primary mb-1",children:"Markus"}),t.jsx("div",{className:"text-sm text-fg-tertiary",children:C})]}),t.jsx("div",{className:"bg-surface-secondary/80 backdrop-blur-sm border border-border-default rounded-2xl p-8 space-y-4 shadow-2xl shadow-black/30",children:u?t.jsxs(t.Fragment,{children:[t.jsxs("form",{onSubmit:N,className:"space-y-3",children:[t.jsx("div",{className:"space-y-1",children:t.jsx("input",{type:"email",value:f,onChange:k=>p(k.target.value),autoComplete:"email",autoFocus:!0,placeholder:s("login.email"),className:"w-full px-4 py-2.5 bg-surface-elevated border border-border-default rounded-xl text-sm text-fg-primary focus:border-brand-500 outline-none transition-colors placeholder:text-fg-tertiary",required:!0})}),t.jsx("div",{className:"space-y-1",children:t.jsx("input",{type:"password",value:b,onChange:k=>x(k.target.value),autoComplete:"current-password",placeholder:s("login.password"),className:"w-full px-4 py-2.5 bg-surface-elevated border border-border-default rounded-xl text-sm text-fg-primary focus:border-brand-500 outline-none transition-colors placeholder:text-fg-tertiary",required:!0})}),l&&t.jsx("div",{className:"px-3 py-2 bg-red-500/10 border border-red-500/30 rounded-lg text-xs text-red-500",children:l}),!r&&t.jsx("p",{className:"text-[11px] text-fg-tertiary",children:s("login.defaultCredentials")}),t.jsx("button",{type:"submit",disabled:a==="local"||!f||!b,className:"w-full py-2.5 bg-brand-600 hover:bg-brand-500 disabled:opacity-50 text-white text-sm font-medium rounded-xl transition-all",children:s(a==="local"?"login.signingIn":"login.signIn")})]}),t.jsx("div",{className:"pt-1 text-center",children:t.jsx("button",{onClick:()=>{m(!1),c("")},className:"text-xs text-fg-tertiary hover:text-fg-secondary transition-colors",children:s("login.backToHub")})})]}):t.jsxs(t.Fragment,{children:[t.jsxs("button",{onClick:()=>v("google"),disabled:!!a,className:"w-full flex items-center justify-center gap-3 py-2.5 px-4 bg-surface-elevated hover:bg-surface-elevated/80 border border-border-default rounded-xl text-sm text-fg-primary font-medium transition-all disabled:opacity-50",children:[t.jsxs("svg",{className:"w-5 h-5",viewBox:"0 0 24 24",children:[t.jsx("path",{fill:"#4285F4",d:"M22.56 12.25c0-.78-.07-1.53-.2-2.25H12v4.26h5.92a5.06 5.06 0 01-2.2 3.32v2.77h3.57c2.08-1.92 3.28-4.74 3.28-8.1z"}),t.jsx("path",{fill:"#34A853",d:"M12 23c2.97 0 5.46-.98 7.28-2.66l-3.57-2.77c-.98.66-2.23 1.06-3.71 1.06-2.86 0-5.29-1.93-6.16-4.53H2.18v2.84C3.99 20.53 7.7 23 12 23z"}),t.jsx("path",{fill:"#FBBC05",d:"M5.84 14.09c-.22-.66-.35-1.36-.35-2.09s.13-1.43.35-2.09V7.07H2.18C1.43 8.55 1 10.22 1 12s.43 3.45 1.18 4.93l2.85-2.22.81-.62z"}),t.jsx("path",{fill:"#EA4335",d:"M12 5.38c1.62 0 3.06.56 4.21 1.64l3.15-3.15C17.45 2.09 14.97 1 12 1 7.7 1 3.99 3.47 2.18 7.07l3.66 2.84c.87-2.6 3.3-4.53 6.16-4.53z"})]}),s(a==="google"?"login.connectingHub":"login.withGoogle")]}),t.jsxs("button",{onClick:()=>v("github"),disabled:!!a,className:"w-full flex items-center justify-center gap-3 py-2.5 px-4 bg-surface-elevated hover:bg-surface-elevated/80 border border-border-default rounded-xl text-sm text-fg-primary font-medium transition-all disabled:opacity-50",children:[t.jsx("svg",{className:"w-5 h-5",viewBox:"0 0 24 24",fill:"currentColor",children:t.jsx("path",{d:"M12 0C5.37 0 0 5.37 0 12c0 5.31 3.435 9.795 8.205 11.385.6.105.825-.255.825-.57 0-.285-.015-1.23-.015-2.235-3.015.555-3.795-.735-4.035-1.41-.135-.345-.72-1.41-1.23-1.695-.42-.225-1.02-.78-.015-.795.945-.015 1.62.87 1.845 1.23 1.08 1.815 2.805 1.305 3.495.99.105-.78.42-1.305.765-1.605-2.67-.3-5.46-1.335-5.46-5.925 0-1.305.465-2.385 1.23-3.225-.12-.3-.54-1.53.12-3.18 0 0 1.005-.315 3.3 1.23.96-.27 1.98-.405 3-.405s2.04.135 3 .405c2.295-1.56 3.3-1.23 3.3-1.23.66 1.65.24 2.88.12 3.18.765.84 1.23 1.905 1.23 3.225 0 4.605-2.805 5.625-5.475 5.925.435.375.81 1.095.81 2.22 0 1.605-.015 2.895-.015 3.3 0 .315.225.69.825.57A12.02 12.02 0 0024 12c0-6.63-5.37-12-12-12z"})}),s(a==="github"?"login.connectingHub":"login.withGithub")]}),t.jsxs("button",{onClick:()=>v("email"),disabled:!!a,className:"w-full flex items-center justify-center gap-3 py-2.5 px-4 bg-surface-elevated hover:bg-surface-elevated/80 border border-border-default rounded-xl text-sm text-fg-primary font-medium transition-all disabled:opacity-50",children:[t.jsx("svg",{className:"w-5 h-5",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:1.5,children:t.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M21.75 6.75v10.5a2.25 2.25 0 01-2.25 2.25h-15a2.25 2.25 0 01-2.25-2.25V6.75m19.5 0A2.25 2.25 0 0019.5 4.5h-15a2.25 2.25 0 00-2.25 2.25m19.5 0v.243a2.25 2.25 0 01-1.07 1.916l-7.5 4.615a2.25 2.25 0 01-2.36 0L3.32 8.91a2.25 2.25 0 01-1.07-1.916V6.75"})}),s(a==="email"?"login.connectingHub":"login.withEmail")]}),t.jsx("p",{className:"text-center text-[11px] text-fg-tertiary pt-1",children:s("login.terms")}),l&&t.jsx("div",{className:"px-3 py-2 bg-red-500/10 border border-red-500/30 rounded-lg text-xs text-red-500",children:l}),t.jsx("div",{className:"pt-1 text-center",children:t.jsx("button",{onClick:()=>m(!0),className:"text-xs text-fg-tertiary hover:text-fg-secondary transition-colors",children:s("login.useLocalAccount")})})]})})]}),t.jsxs("div",{className:"relative z-10 flex flex-wrap items-center justify-center gap-x-5 gap-y-1 py-6 text-[11px] text-fg-tertiary",children:[t.jsx("a",{href:"https://markus.global",target:"_blank",rel:"noopener noreferrer",className:"hover:text-fg-secondary transition-colors",children:"markus.global"}),t.jsx("a",{href:"mailto:business@markus.global",className:"hover:text-fg-secondary transition-colors",children:s("login.contactSales")})]})]})}function iue({token:e,onComplete:n}){const{t:r}=ht("auth"),[s,a]=g.useState(null),[i,l]=g.useState(""),[c,u]=g.useState(""),[m,f]=g.useState(""),[p,b]=g.useState(!1),[x,v]=g.useState(!1),[N,C]=g.useState(!1);g.useEffect(()=>{ae.auth.inviteInfo(e).then(j=>a(j)).catch(()=>C(!0))},[e]);const k=async j=>{if(j.preventDefault(),f(""),i.length<6){f(r("invite.passwordMinLength"));return}if(i!==c){f(r("invite.passwordsDoNotMatch"));return}b(!0);try{await ae.auth.setup(e,i),v(!0),setTimeout(()=>{window.location.hash="",n()},2e3)}catch{f(r("invite.error"))}finally{b(!1)}};return t.jsxs("div",{className:"min-h-dvh bg-surface-primary flex items-center justify-center p-4 relative overflow-hidden",children:[t.jsx("div",{className:"absolute inset-0 bg-[radial-gradient(ellipse_at_top,_var(--tw-gradient-stops))] from-brand-950/50 via-transparent to-transparent"}),t.jsxs("div",{className:"w-full max-w-sm relative z-10",children:[t.jsxs("div",{className:"text-center mb-8",children:[t.jsx("img",{src:"/logo.png",alt:"Markus",className:"w-14 h-14 mx-auto mb-3 rounded-xl shadow-lg shadow-black/40"}),t.jsx("div",{className:"text-2xl font-extrabold tracking-tight text-fg-primary mb-1",children:"Markus"}),t.jsx("div",{className:"text-sm text-fg-tertiary",children:r("invite.subtitle")})]}),t.jsx("div",{className:"bg-surface-secondary/80 backdrop-blur-sm border border-border-default rounded-2xl p-8 space-y-5 shadow-2xl shadow-black/30",children:N?t.jsxs("div",{className:"text-center space-y-3",children:[t.jsx("div",{className:"text-red-500 text-3xl",children:"⚠"}),t.jsx("p",{className:"text-sm text-fg-secondary",children:r("invite.invalidLink")}),t.jsx("button",{onClick:()=>{window.location.hash="",n()},className:"text-sm text-brand-500 hover:text-brand-400",children:r("login.signIn")})]}):x?t.jsxs("div",{className:"text-center space-y-3",children:[t.jsx("div",{className:"text-green-500 text-3xl",children:"✓"}),t.jsx("p",{className:"text-sm text-fg-secondary",children:r("invite.setupComplete")})]}):s?t.jsxs("form",{onSubmit:k,className:"space-y-5",children:[t.jsx("h2",{className:"text-lg font-semibold text-fg-primary text-center",children:r("invite.greeting",{name:s.name})}),t.jsx("p",{className:"text-xs text-fg-tertiary text-center",children:s.email}),t.jsxs("div",{className:"space-y-1",children:[t.jsx("label",{className:"text-xs text-fg-tertiary font-medium",children:r("invite.setPassword")}),t.jsx("input",{type:"password",value:i,onChange:j=>l(j.target.value),autoComplete:"new-password",autoFocus:!0,className:"w-full px-4 py-2.5 bg-surface-elevated border border-border-default rounded-xl text-sm text-fg-primary focus:border-brand-500 outline-none transition-colors",required:!0})]}),t.jsxs("div",{className:"space-y-1",children:[t.jsx("label",{className:"text-xs text-fg-tertiary font-medium",children:r("invite.confirmPassword")}),t.jsx("input",{type:"password",value:c,onChange:j=>u(j.target.value),autoComplete:"new-password",className:"w-full px-4 py-2.5 bg-surface-elevated border border-border-default rounded-xl text-sm text-fg-primary focus:border-brand-500 outline-none transition-colors",required:!0})]}),m&&t.jsx("div",{className:"px-3 py-2 bg-red-500/10 border border-red-500/30 rounded-lg text-xs text-red-500",children:m}),t.jsx("button",{type:"submit",disabled:p||!i||!c,className:"w-full py-2.5 bg-brand-600 hover:bg-brand-500 disabled:opacity-50 text-white text-sm font-medium rounded-xl transition-all shadow-md shadow-brand-900/40 hover:shadow-lg hover:shadow-brand-900/50",children:r(p?"invite.settingUp":"invite.setupAccount")})]}):t.jsx("div",{className:"text-center text-fg-tertiary text-sm animate-pulse py-4",children:"Loading…"})})]})]})}function oue({onComplete:e,isFirstTime:n}){const{t:r}=ht("auth"),[s,a]=g.useState(""),[i,l]=g.useState(""),[c,u]=g.useState(""),[m,f]=g.useState(""),[p,b]=g.useState(!1),x=async v=>{if(v.preventDefault(),f(""),i.length<6){f(r("changePassword.passwordMinLength"));return}if(i!==c){f(r("changePassword.passwordsDoNotMatch"));return}b(!0);try{await ae.auth.changePassword(s,i),e()}catch{f(r("changePassword.failedToChange"))}finally{b(!1)}};return t.jsxs("div",{className:"min-h-dvh bg-surface-primary flex items-center justify-center p-4 relative overflow-hidden",children:[t.jsx("div",{className:"absolute inset-0 bg-[radial-gradient(ellipse_at_top,_var(--tw-gradient-stops))] from-brand-950/50 via-transparent to-transparent"}),t.jsxs("div",{className:"w-full max-w-sm relative z-10",children:[t.jsxs("div",{className:"text-center mb-8",children:[t.jsx("img",{src:"/logo.png",alt:"Markus",className:"w-14 h-14 mx-auto mb-3 rounded-xl shadow-lg shadow-black/40"}),t.jsx("div",{className:"text-2xl font-extrabold tracking-tight text-fg-primary mb-1",children:"Markus"}),t.jsx("div",{className:"text-sm text-fg-tertiary",children:r("login.subtitle")})]}),t.jsxs("form",{onSubmit:x,className:"bg-surface-secondary/80 backdrop-blur-sm border border-border-default rounded-2xl p-8 space-y-5 shadow-2xl shadow-black/30",children:[t.jsxs("div",{children:[t.jsx("h2",{className:"text-lg font-semibold text-fg-primary text-center",children:r(n?"changePassword.setYourPassword":"changePassword.changePassword")}),n&&t.jsx("p",{className:"text-xs text-amber-600/80 text-center mt-2",children:r("changePassword.defaultPasswordWarning")})]}),!n&&t.jsxs("div",{className:"space-y-1",children:[t.jsx("label",{className:"text-xs text-fg-tertiary font-medium",children:r("changePassword.currentPassword")}),t.jsx("input",{type:"password",value:s,onChange:v=>a(v.target.value),autoComplete:"current-password",className:"w-full px-4 py-2.5 bg-surface-elevated border border-border-default rounded-xl text-sm text-fg-primary focus:border-brand-500 outline-none transition-colors"})]}),t.jsxs("div",{className:"space-y-1",children:[t.jsx("label",{className:"text-xs text-fg-tertiary font-medium",children:r("changePassword.newPassword")}),t.jsx("input",{type:"password",value:i,onChange:v=>l(v.target.value),autoComplete:"new-password",className:"w-full px-4 py-2.5 bg-surface-elevated border border-border-default rounded-xl text-sm text-fg-primary focus:border-brand-500 outline-none transition-colors",required:!0,minLength:6})]}),t.jsxs("div",{className:"space-y-1",children:[t.jsx("label",{className:"text-xs text-fg-tertiary font-medium",children:r("changePassword.confirmNewPassword")}),t.jsx("input",{type:"password",value:c,onChange:v=>u(v.target.value),autoComplete:"new-password",className:"w-full px-4 py-2.5 bg-surface-elevated border border-border-default rounded-xl text-sm text-fg-primary focus:border-brand-500 outline-none transition-colors",required:!0})]}),m&&t.jsx("div",{className:"px-3 py-2 bg-red-500/10 border border-red-500/30 rounded-lg text-xs text-red-500",children:m}),t.jsx("button",{type:"submit",disabled:p||!i||!c,className:"w-full py-2.5 bg-brand-600 hover:bg-brand-500 disabled:opacity-50 text-white text-sm font-medium rounded-xl transition-colors",children:r(p?"changePassword.saving":n?"changePassword.setPasswordAndContinue":"changePassword.changePassword")})]})]})]})}const Sh={agents:[],tasks:[],requirements:[],projects:[],deliverables:[],workflows:[]},lue={team:["agents","workflows","tasks","requirements","projects","deliverables"],work:["workflows","projects","requirements","tasks","agents","deliverables"],deliverables:["deliverables","agents","tasks","requirements","projects","workflows"]},cue=["agents","tasks","requirements","projects","deliverables","workflows"];let c6="",d6="all",u6=Sh,m6=!1;function due({onClose:e,currentPage:n}){const{t:r}=ht(["common","home","work"]),[s,a]=g.useState(c6),[i,l]=g.useState(d6),[c,u]=g.useState(u6),[m,f]=g.useState(!1),[p,b]=g.useState(m6),[x,v]=g.useState(-1);g.useEffect(()=>{c6=s},[s]),g.useEffect(()=>{d6=i},[i]),g.useEffect(()=>{u6=c},[c]),g.useEffect(()=>{m6=p},[p]);const N=g.useRef(null),C=g.useRef(void 0),k=g.useRef(null),j=g.useRef(null);g.useEffect(()=>{setTimeout(()=>{N.current?.focus(),N.current?.select()},100)},[]);const w=g.useCallback(async z=>{if(!z.trim()){u(Sh),b(!1),v(-1);return}f(!0),b(!0),v(-1);const A=z.toLowerCase();try{const[H,D,O,q,J,B]=await Promise.allSettled([ae.agents.list(),ae.tasks.list({search:z,pageSize:20}),ae.requirements.list(),ae.projects.list(),ae.deliverables.search({q:z,limit:20}),ae.teams.list()]),V=H.status==="fulfilled"?H.value.agents.filter(te=>te.name?.toLowerCase().includes(A)||te.role?.toLowerCase().includes(A)):[],X=D.status==="fulfilled"?D.value.tasks:[],K=O.status==="fulfilled"?O.value.requirements.filter(te=>te.title?.toLowerCase().includes(A)||te.description?.toLowerCase().includes(A)):[],ee=q.status==="fulfilled"?q.value.projects.filter(te=>te.name?.toLowerCase().includes(A)||te.description?.toLowerCase().includes(A)):[],Q=J.status==="fulfilled"?J.value.results:[],ne=[];if(B.status==="fulfilled"){const te=await Promise.allSettled(B.value.teams.map(Y=>ae.workflows.list(Y.id)));for(const Y of te)if(Y.status==="fulfilled")for(const oe of Y.value.workflows)(oe.name.toLowerCase().includes(A)||(oe.displayName||"").toLowerCase().includes(A)||oe.description?.toLowerCase().includes(A))&&ne.push(oe)}u({agents:V,tasks:X,requirements:K,projects:ee,deliverables:Q,workflows:ne})}catch{u(Sh)}finally{f(!1)}},[]),S=z=>{a(z),C.current&&clearTimeout(C.current),C.current=setTimeout(()=>w(z),400)},T=g.useCallback((z,A)=>{e(),Rt.navigate(z,A)},[e]),R=[{id:"all",label:r("common:all",{defaultValue:"全部"})},{id:"agents",label:r("common:agents",{defaultValue:"智能体"})},{id:"tasks",label:r("common:tasks",{defaultValue:"任务"})},{id:"requirements",label:r("common:requirements",{defaultValue:"需求"})},{id:"projects",label:r("common:projects",{defaultValue:"项目"})},{id:"deliverables",label:r("common:deliverables",{defaultValue:"交付物"})},{id:"workflows",label:r("common:workflows",{defaultValue:"工作流"})}],I=g.useMemo(()=>lue[n||""]||cue,[n]),P=g.useMemo(()=>{const z=[],A=i==="all"?8:void 0,H=D=>{if(i!=="all"&&i!==D)return;const O=c[D].length;if(D==="workflows"){const q=A?c.workflows.slice(0,A):c.workflows;for(const J of q)z.push({id:J.name,type:"workflow",page:Be.WORK,params:{boardType:"workflows"}})}else{const q=c[D],J=A?q.slice(0,A):q;for(const B of J)switch(D){case"agents":z.push({id:B.id,type:"agent",page:Be.TEAM,params:{agentId:B.id}});break;case"tasks":z.push({id:B.id,type:"task",page:Be.WORK,params:{openTask:B.id}});break;case"requirements":z.push({id:B.id,type:"requirement",page:Be.WORK,params:{openRequirement:B.id}});break;case"projects":z.push({id:B.id,type:"project",page:Be.WORK,params:{projectId:B.id}});break;case"deliverables":z.push({id:B.id,type:"deliverable",page:Be.DELIVERABLES,params:{openDeliverable:B.id}});break}}A&&O>A&&z.push({id:`more_${D}`,type:"showMore",page:"",expandCategory:D,totalCount:O})};for(const D of I)H(D);return z},[c,i,I]),L=g.useCallback(z=>{if(z.type==="showMore"&&z.expandCategory){l(z.expandCategory),v(-1);return}T(z.page,z.params)},[T]);g.useEffect(()=>{const z=j.current;if(!z||x<0)return;const A=z.querySelector(`[data-idx="${x}"]`);A&&A.scrollIntoView({block:"nearest"})},[x]);const M=g.useCallback(z=>{if(z.key==="Escape"){e();return}if(z.key==="Tab"){z.preventDefault();const D=R.map(J=>J.id),O=D.indexOf(i),q=z.shiftKey?O<=0?D.length-1:O-1:O>=D.length-1?0:O+1;l(D[q]),v(-1);return}const A=z.ctrlKey&&z.key==="n"||z.key==="ArrowDown",H=z.ctrlKey&&z.key==="p"||z.key==="ArrowUp";if(A||H){z.preventDefault(),v(D=>{const O=P.length-1;return O<0?-1:A?D>=O?0:D+1:D<=0?O:D-1});return}z.key==="Enter"&&(z.preventDefault(),x>=0&&x<P.length&&L(P[x]))},[e,P,x,L,R,i]);g.useEffect(()=>(document.addEventListener("keydown",M),()=>document.removeEventListener("keydown",M)),[M]);const $=P.length>0;let U=0;return t.jsx("div",{ref:k,className:"fixed inset-0 bg-black/50 flex items-start justify-center z-50 pt-[8vh]",onClick:z=>{z.target===k.current&&e()},children:t.jsxs("div",{className:"bg-surface-primary border border-border-default rounded-2xl shadow-2xl w-full max-w-3xl max-h-[78vh] flex flex-col overflow-hidden animate-fadeIn",children:[t.jsxs("div",{className:"shrink-0 px-5 pt-4 pb-3 border-b border-border-default space-y-3",children:[t.jsxs("div",{className:"relative",children:[t.jsxs("svg",{className:"absolute left-3 top-1/2 -translate-y-1/2 text-fg-tertiary",width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[t.jsx("circle",{cx:"11",cy:"11",r:"8"}),t.jsx("line",{x1:"21",y1:"21",x2:"16.65",y2:"16.65"})]}),t.jsx("input",{ref:N,value:s,onChange:z=>S(z.target.value),placeholder:r("common:search"),className:"w-full bg-surface-elevated border border-border-default rounded-xl pl-9 pr-9 py-2.5 text-sm text-fg-primary placeholder:text-fg-tertiary focus:border-brand-500 focus:outline-none transition-colors"}),s&&t.jsx("button",{onClick:()=>{a(""),u(Sh),b(!1),v(-1),N.current?.focus()},className:"absolute right-3 top-1/2 -translate-y-1/2 text-fg-tertiary hover:text-fg-secondary",children:t.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[t.jsx("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),t.jsx("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]})})]}),t.jsx("div",{className:"flex gap-1 overflow-x-auto scrollbar-hide",children:R.map(z=>t.jsx("button",{onClick:()=>{l(z.id),v(-1)},className:`px-3 py-1.5 text-xs rounded-lg whitespace-nowrap transition-colors ${i===z.id?"bg-brand-600 text-white":"bg-surface-elevated text-fg-secondary hover:text-fg-primary"}`,children:z.label},z.id))})]}),t.jsxs("div",{ref:j,className:"flex-1 overflow-y-auto px-5 py-3",children:[m&&t.jsx("div",{className:"flex items-center justify-center py-8",children:t.jsx("div",{className:"text-fg-tertiary text-sm animate-pulse",children:r("common:loading")})}),!m&&p&&!$&&t.jsxs("div",{className:"flex flex-col items-center justify-center py-8 text-center",children:[t.jsxs("svg",{width:"36",height:"36",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.5",className:"text-fg-tertiary mb-2",children:[t.jsx("circle",{cx:"11",cy:"11",r:"8"}),t.jsx("line",{x1:"21",y1:"21",x2:"16.65",y2:"16.65"})]}),t.jsx("p",{className:"text-sm text-fg-tertiary",children:r("common:noResults",{defaultValue:"没有找到相关结果"})})]}),!m&&$&&t.jsx("div",{className:"space-y-4",children:I.map(z=>{if(i!=="all"&&i!==z)return null;const A=i==="all"?8:void 0,H=D=>{const O=U++,q=D==="agents"?c.agents.length:D==="tasks"?c.tasks.length:D==="requirements"?c.requirements.length:D==="projects"?c.projects.length:D==="workflows"?c.workflows.length:c.deliverables.length;return t.jsxs("button",{"data-idx":O,onClick:()=>{l(D),v(-1)},className:`mt-1 w-full text-xs py-1.5 rounded-lg transition-colors ${O===x?"bg-brand-600/15 ring-1 ring-brand-500/40 text-brand-500":"text-brand-500 hover:text-brand-400 hover:bg-surface-overlay"}`,children:[r("common:showAll",{defaultValue:"查看全部"})," (",q,")"]})};return z==="agents"&&c.agents.length>0?t.jsxs("section",{children:[t.jsx("h3",{className:"text-xs font-medium text-fg-tertiary uppercase mb-2",children:r("common:agents",{defaultValue:"智能体"})}),t.jsx("div",{className:"space-y-0.5",children:(A?c.agents.slice(0,A):c.agents).map(D=>{const O=U++;return t.jsxs("button",{"data-idx":O,onClick:()=>T(Be.TEAM,{agentId:D.id}),className:`w-full flex items-center gap-3 px-3 py-2 rounded-xl transition-colors text-left ${O===x?"bg-brand-600/15 ring-1 ring-brand-500/40":"hover:bg-surface-overlay"}`,children:[t.jsx(_r,{name:D.name||"Agent",avatarUrl:D.avatarUrl,size:28}),t.jsxs("div",{className:"flex-1 min-w-0",children:[t.jsx("div",{className:"text-sm font-medium text-fg-primary truncate",children:D.name}),t.jsx("div",{className:"text-xs text-fg-tertiary truncate",children:D.role||D.status})]}),t.jsx(uue,{status:D.status})]},D.id)})}),A&&c.agents.length>A&&H("agents")]},"agents"):z==="tasks"&&c.tasks.length>0?t.jsxs("section",{children:[t.jsx("h3",{className:"text-xs font-medium text-fg-tertiary uppercase mb-2",children:r("common:tasks",{defaultValue:"任务"})}),t.jsx("div",{className:"space-y-0.5",children:(A?c.tasks.slice(0,A):c.tasks).map(D=>{const O=U++;return t.jsxs("button",{"data-idx":O,onClick:()=>T(Be.WORK,{openTask:D.id}),className:`w-full flex items-center gap-3 px-3 py-2 rounded-xl transition-colors text-left ${O===x?"bg-brand-600/15 ring-1 ring-brand-500/40":"hover:bg-surface-overlay"}`,children:[t.jsx(mue,{status:D.status}),t.jsxs("div",{className:"flex-1 min-w-0",children:[t.jsx("div",{className:"text-sm text-fg-primary truncate",children:D.title}),t.jsxs("div",{className:"text-xs text-fg-tertiary truncate",children:[D.status," · ",D.priority||""]})]})]},D.id)})}),A&&c.tasks.length>A&&H("tasks")]},"tasks"):z==="requirements"&&c.requirements.length>0?t.jsxs("section",{children:[t.jsx("h3",{className:"text-xs font-medium text-fg-tertiary uppercase mb-2",children:r("common:requirements",{defaultValue:"需求"})}),t.jsx("div",{className:"space-y-0.5",children:(A?c.requirements.slice(0,A):c.requirements).map(D=>{const O=U++;return t.jsxs("button",{"data-idx":O,onClick:()=>T(Be.WORK,{openRequirement:D.id}),className:`w-full flex items-center gap-3 px-3 py-2 rounded-xl transition-colors text-left ${O===x?"bg-brand-600/15 ring-1 ring-brand-500/40":"hover:bg-surface-overlay"}`,children:[t.jsx("div",{className:`w-7 h-7 rounded-lg flex items-center justify-center shrink-0 ${D.status==="approved"?"text-green-500 bg-green-500/15":D.status==="pending"?"text-amber-500 bg-amber-500/15":D.status==="rejected"?"text-red-500 bg-red-500/15":"text-fg-tertiary bg-surface-elevated"}`,children:t.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[t.jsx("path",{d:"M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z"}),t.jsx("polyline",{points:"14 2 14 8 20 8"}),t.jsx("line",{x1:"16",y1:"13",x2:"8",y2:"13"}),t.jsx("line",{x1:"16",y1:"17",x2:"8",y2:"17"})]})}),t.jsxs("div",{className:"flex-1 min-w-0",children:[t.jsx("div",{className:"text-sm text-fg-primary truncate",children:D.title}),t.jsxs("div",{className:"text-xs text-fg-tertiary truncate",children:[D.status," · ",D.priority||""]})]})]},D.id)})}),A&&c.requirements.length>A&&H("requirements")]},"requirements"):z==="projects"&&c.projects.length>0?t.jsxs("section",{children:[t.jsx("h3",{className:"text-xs font-medium text-fg-tertiary uppercase mb-2",children:r("common:projects",{defaultValue:"项目"})}),t.jsx("div",{className:"space-y-0.5",children:(A?c.projects.slice(0,A):c.projects).map(D=>{const O=U++;return t.jsxs("button",{"data-idx":O,onClick:()=>T(Be.WORK,{projectId:D.id}),className:`w-full flex items-center gap-3 px-3 py-2 rounded-xl transition-colors text-left ${O===x?"bg-brand-600/15 ring-1 ring-brand-500/40":"hover:bg-surface-overlay"}`,children:[t.jsx("div",{className:"w-7 h-7 rounded-lg bg-brand-500/15 flex items-center justify-center shrink-0",children:t.jsx("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",className:"text-brand-500",children:t.jsx("path",{d:"M22 19a2 2 0 0 1-2 2H4a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h5l2 3h9a2 2 0 0 1 2 2z"})})}),t.jsxs("div",{className:"flex-1 min-w-0",children:[t.jsx("div",{className:"text-sm text-fg-primary truncate",children:D.name}),D.description&&t.jsx("div",{className:"text-xs text-fg-tertiary truncate",children:D.description})]})]},D.id)})}),A&&c.projects.length>A&&H("projects")]},"projects"):z==="deliverables"&&c.deliverables.length>0?t.jsxs("section",{children:[t.jsx("h3",{className:"text-xs font-medium text-fg-tertiary uppercase mb-2",children:r("common:deliverables",{defaultValue:"交付物"})}),t.jsx("div",{className:"space-y-0.5",children:(A?c.deliverables.slice(0,A):c.deliverables).map(D=>{const O=U++;return t.jsxs("button",{"data-idx":O,onClick:()=>T(Be.DELIVERABLES,{openDeliverable:D.id}),className:`w-full flex items-center gap-3 px-3 py-2 rounded-xl transition-colors text-left ${O===x?"bg-brand-600/15 ring-1 ring-brand-500/40":"hover:bg-surface-overlay"}`,children:[t.jsx("div",{className:"w-7 h-7 rounded-lg bg-purple-500/15 flex items-center justify-center shrink-0",children:t.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",className:"text-purple-500",children:[t.jsx("path",{d:"M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z"}),t.jsx("polyline",{points:"14 2 14 8 20 8"})]})}),t.jsxs("div",{className:"flex-1 min-w-0",children:[t.jsx("div",{className:"text-sm text-fg-primary truncate",children:D.title}),t.jsxs("div",{className:"text-xs text-fg-tertiary truncate",children:[D.type," · ",D.status]})]})]},D.id)})}),A&&c.deliverables.length>A&&H("deliverables")]},"deliverables"):z==="workflows"&&c.workflows.length>0?t.jsxs("section",{children:[t.jsx("h3",{className:"text-xs font-medium text-fg-tertiary uppercase mb-2",children:r("common:workflows",{defaultValue:"工作流"})}),t.jsx("div",{className:"space-y-0.5",children:(A?c.workflows.slice(0,A):c.workflows).map(D=>{const O=U++;return t.jsxs("button",{"data-idx":O,onClick:()=>T(Be.WORK,{boardType:"workflows"}),className:`w-full flex items-center gap-3 px-3 py-2 rounded-xl transition-colors text-left ${O===x?"bg-brand-600/15 ring-1 ring-brand-500/40":"hover:bg-surface-overlay"}`,children:[t.jsx("div",{className:"w-7 h-7 rounded-lg bg-teal-500/15 flex items-center justify-center shrink-0",children:t.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",className:"text-teal-500",children:[t.jsx("circle",{cx:"12",cy:"12",r:"3"}),t.jsx("path",{d:"M19.4 15a1.65 1.65 0 0 0 .33 1.82l.06.06a2 2 0 0 1 0 2.83 2 2 0 0 1-2.83 0l-.06-.06a1.65 1.65 0 0 0-1.82-.33 1.65 1.65 0 0 0-1 1.51V21a2 2 0 0 1-2 2 2 2 0 0 1-2-2v-.09A1.65 1.65 0 0 0 9 19.4a1.65 1.65 0 0 0-1.82.33l-.06.06a2 2 0 0 1-2.83 0 2 2 0 0 1 0-2.83l.06-.06A1.65 1.65 0 0 0 4.68 15a1.65 1.65 0 0 0-1.51-1H3a2 2 0 0 1-2-2 2 2 0 0 1 2-2h.09A1.65 1.65 0 0 0 4.6 9a1.65 1.65 0 0 0-.33-1.82l-.06-.06a2 2 0 0 1 0-2.83 2 2 0 0 1 2.83 0l.06.06A1.65 1.65 0 0 0 9 4.68a1.65 1.65 0 0 0 1-1.51V3a2 2 0 0 1 2-2 2 2 0 0 1 2 2v.09a1.65 1.65 0 0 0 1 1.51 1.65 1.65 0 0 0 1.82-.33l.06-.06a2 2 0 0 1 2.83 0 2 2 0 0 1 0 2.83l-.06.06A1.65 1.65 0 0 0 19.4 9a1.65 1.65 0 0 0 1.51 1H21a2 2 0 0 1 2 2 2 2 0 0 1-2 2h-.09a1.65 1.65 0 0 0-1.51 1z"})]})}),t.jsxs("div",{className:"flex-1 min-w-0",children:[t.jsx("div",{className:"text-sm text-fg-primary truncate",children:D.displayName||D.name}),t.jsxs("div",{className:"text-xs text-fg-tertiary truncate",children:[D.stepCount," steps · v",D.version]})]})]},D.name)})}),A&&c.workflows.length>A&&H("workflows")]},"workflows"):null})}),!m&&!p&&t.jsxs("div",{className:"flex flex-col items-center justify-center py-8 text-center",children:[t.jsxs("svg",{width:"36",height:"36",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.5",className:"text-fg-tertiary mb-2",children:[t.jsx("circle",{cx:"11",cy:"11",r:"8"}),t.jsx("line",{x1:"21",y1:"21",x2:"16.65",y2:"16.65"})]}),t.jsx("p",{className:"text-sm text-fg-tertiary",children:r("common:searchHint",{defaultValue:"输入关键词搜索"})})]})]}),t.jsxs("div",{className:"shrink-0 px-5 py-2 border-t border-border-default flex items-center gap-4 text-xs text-fg-tertiary flex-wrap",children:[t.jsxs("span",{children:[t.jsx("kbd",{className:"px-1.5 py-0.5 rounded bg-surface-elevated border border-border-default text-[11px] font-medium",children:navigator.platform.toUpperCase().includes("MAC")?"Cmd+P":"Ctrl+P"})," ",r("common:toggle",{defaultValue:"唤起/关闭"})]}),t.jsxs("span",{children:[t.jsx("kbd",{className:"px-1.5 py-0.5 rounded bg-surface-elevated border border-border-default text-[11px] font-medium",children:"Tab"})," ",r("common:switchTab",{defaultValue:"切换分类"})]}),t.jsxs("span",{children:[t.jsx("kbd",{className:"px-1.5 py-0.5 rounded bg-surface-elevated border border-border-default text-[11px] font-medium",children:"↑↓"})," ",r("common:navigate",{defaultValue:"导航"})]}),t.jsxs("span",{children:[t.jsx("kbd",{className:"px-1.5 py-0.5 rounded bg-surface-elevated border border-border-default text-[11px] font-medium",children:"Enter"})," ",r("common:open",{defaultValue:"打开"})]}),t.jsxs("span",{children:[t.jsx("kbd",{className:"px-1.5 py-0.5 rounded bg-surface-elevated border border-border-default text-[11px] font-medium",children:"Esc"})," ",r("common:close",{defaultValue:"关闭"})]})]})]})})}function uue({status:e}){const n=e==="active"||e==="idle"?"bg-green-500":e==="working"||e==="busy"?"bg-blue-500":"bg-gray-400";return t.jsx("span",{className:`w-2 h-2 rounded-full shrink-0 ${n}`})}function mue({status:e}){const n=e==="completed"?"text-green-500 bg-green-500/15":e==="in_progress"?"text-blue-500 bg-blue-500/15":e==="pending"?"text-amber-500 bg-amber-500/15":"text-fg-tertiary bg-surface-elevated";return t.jsx("div",{className:`w-7 h-7 rounded-lg flex items-center justify-center shrink-0 ${n}`,children:t.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[t.jsx("path",{d:"M9 11l3 3L22 4"}),t.jsx("path",{d:"M21 12v7a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h11"})]})})}const fue={visibility:"hidden",position:"absolute",inset:0,pointerEvents:"none",zIndex:-1},hue=g.memo(function({id:n,activePage:r,children:s}){const a=n===r;return t.jsx("div",{className:"flex-1 overflow-hidden flex flex-col",style:a?void 0:fue,children:s})},(e,n)=>{const r=e.id===e.activePage,s=n.id===n.activePage;return r!==s?!1:s?e.children===n.children:!0}),_1={};function pue(){const{t:e}=ht("common"),[n,r]=g.useState(fc),[s,a]=g.useState(()=>!localStorage.getItem("markus_onboarded")),[i,l]=g.useState(!0),c=ea(),u=Ree(),m=P0({side:"left",defaultWidth:160,minWidth:140,maxWidth:400,collapsedWidth:64,storageKey:"markus_sidebar"}),[f,p]=g.useState(()=>new Set([fc()])),[b,x]=g.useState("loading"),[v,N]=g.useState(null),[C,k]=g.useState({hasOwner:!1,hasMultipleUsers:!1}),[j,w]=g.useState(!1),[S,T]=g.useState(!1),[R,I]=g.useState(null),[P,L]=g.useState(!1),[M,$]=g.useState(null),[U,z]=g.useState(()=>{const te=localStorage.getItem("markus_update_dismissed");return te||null}),[A,H]=g.useState(null),[D,O]=g.useState(!1),q=g.useCallback(()=>{ae.license.get().then(te=>{if(te.plan==="enterprise"){H(null);return}if(te.usage&&te.limits){const Y=te.limits.maxTeams>0&&te.usage.teams>=te.limits.maxTeams,oe=te.limits.maxToolCallsPerDay>0&&te.usage.toolCallsToday>=te.limits.maxToolCallsPerDay;Y||oe?(H({teams:Y||void 0,toolCalls:oe||void 0}),O(!1)):H(null)}}).catch(()=>{})},[]);g.useEffect(()=>{const te=()=>{document.visibilityState==="visible"&&q()};window.addEventListener("markus:check-license-limits",q),document.addEventListener("visibilitychange",te);const Y=setInterval(q,300*1e3);return()=>{window.removeEventListener("markus:check-license-limits",q),document.removeEventListener("visibilitychange",te),clearInterval(Y)}},[q]);const[J,B]=g.useState(!1);g.useEffect(()=>{if(c)return;const te=navigator.platform.toUpperCase().includes("MAC"),Y=ge=>{te&&ge.metaKey&&!ge.ctrlKey&&ge.key==="p"?(ge.preventDefault(),B(ye=>!ye)):!te&&ge.ctrlKey&&!ge.metaKey&&ge.key==="p"&&(ge.preventDefault(),B(ye=>!ye))},oe=()=>B(!0);return document.addEventListener("keydown",Y),window.addEventListener("markus:open-search",oe),()=>{document.removeEventListener("keydown",Y),window.removeEventListener("markus:open-search",oe)}},[c]);const V=g.useCallback(te=>{let Y=Rl(te);c?Y=fF[Y]??Y:Y===Be.NOTIFICATIONS&&(Y=Be.HOME);const oe=fc(),ge=window.location.hash.slice(1);ge!==oe?_1[oe]=ge:delete _1[oe];const ye=Y!==Be.WORK?_1[Y]:void 0;ye&&ye!==Y?(history.pushState(null,"","#"+Y),history.pushState(null,"","#"+ye)):history.pushState(null,"","#"+Y),window.dispatchEvent(new HashChangeEvent("hashchange")),r(Y),p(we=>we.has(Y)?we:new Set([...we,Y]))},[c]);g.useEffect(()=>{Rt.setHandler(te=>V(te))},[V]),g.useEffect(()=>{if(!window.markusDesktop)return;!c&&n!==Be.SETTINGS&&!m.collapsed?window.markusDesktop.setTrafficLightPosition(16,16):window.markusDesktop.setTrafficLightPosition(6,16)},[m.collapsed,n,c]),g.useEffect(()=>{window.markusDesktop&&window.markusDesktop.onNotificationClick(te=>{if(te.openNotifications&&window.dispatchEvent(new CustomEvent("markus:open-notifications")),te.page){const Y=Rl(te.page);te.params&&Object.entries(te.params).forEach(([oe,ge])=>localStorage.setItem(`markus_nav_${oe}`,ge)),V(Y),window.dispatchEvent(new CustomEvent("markus:navigate",{detail:{page:Y,params:te.params}}))}})},[V]);const X=g.useCallback(()=>{fetch("/api/settings/llm").then(te=>te.ok?te.json():null).then(te=>{if(te?.providers){const Y=Object.values(te.providers).some(oe=>oe.configured);I(Y)}}).catch(()=>{})},[]);g.useEffect(()=>{const te=new URLSearchParams(window.location.search),Y=te.get("install");if(Y&&fc()!==Be.STORE){const ye=te.get("type"),Ce=ye&&{agent:"agents",team:"teams",skill:"skills"}[ye]||"agents";localStorage.setItem("markus_nav_installItem",Y),localStorage.setItem("markus_nav_storeTab",Ce),te.delete("install"),te.delete("type");const ie=te.toString();window.history.replaceState(null,"",window.location.pathname+(ie?`?${ie}`:"")+"#store"),setTimeout(()=>Rt.navigate(Be.STORE,{storeTab:Ce,installItem:Y}),300)}ae.auth.me().then(({user:ye})=>{x(ye),N(!0),Tn.connect(ye.id),X(),ae.health().then(Ce=>{Ce.updateAvailable&&Ce.latestVersion&&$({latestVersion:Ce.latestVersion,currentVersion:Ce.version})}).catch(()=>{}),q();const we=()=>{dc($a.builderArtifacts,()=>ae.builder.artifacts.list()),dc($a.builderAgents,()=>ae.agents.list()),dc($a.builderHubMyItems,()=>Xn.myItems()),dc($a.builderInstalled,()=>ae.builder.artifacts.installed()),dc($a.hubAgents,()=>Xn.search({type:"agent",limit:50})),dc($a.hubTeams,()=>Xn.search({type:"team",limit:50})),dc($a.hubSkills,()=>Xn.search({type:"skill",limit:50}))};typeof requestIdleCallback=="function"?requestIdleCallback(we,{timeout:5e3}):setTimeout(we,3e3)}).catch(()=>{x(null),ae.auth.status().then(({initialized:ye,hasOwner:we,hasMultipleUsers:Ce})=>{N(ye),k({hasOwner:we,hasMultipleUsers:Ce})}).catch(()=>N(!0))}),Tn.connect();const oe=Tn.on("notification",()=>{window.dispatchEvent(new CustomEvent("markus:notifications-changed"))}),ge=()=>{const ye=fc();r(ye),p(we=>we.has(ye)?we:new Set([...we,ye]))};return window.addEventListener("hashchange",ge),window.addEventListener("popstate",ge),()=>{oe(),Tn.disconnect(),window.removeEventListener("hashchange",ge),window.removeEventListener("popstate",ge)}},[]);const K=b!=="loading"&&b!==null?b:void 0,ee=g.useMemo(()=>c?{[Be.HOME]:t.jsx(Pk,{authUser:K}),[Be.TEAM]:t.jsx(Sj,{authUser:K}),[Be.BUILDER]:t.jsx(rue,{authUser:K}),[Be.SETTINGS]:t.jsx(u3,{theme:u.mode,onThemeChange:u.setMode,authUser:K,onLogout:()=>{ae.auth.logout().catch(()=>{}),E0(),x(null)},onUserUpdated:te=>x(te)}),[Be.WORK]:t.jsx(t6,{authUser:K}),[Be.DELIVERABLES]:t.jsx(s6,{authUser:K}),[Be.NOTIFICATIONS]:t.jsx(Xde,{authUser:K}),[Be.REPORTS]:t.jsx(i6,{authUser:K}),[Be.SEARCH]:t.jsx(Qde,{})}:{[Be.HOME]:t.jsx(Pk,{authUser:K}),[Be.TEAM]:t.jsx(Sj,{authUser:K}),[Be.SETTINGS]:t.jsx(u3,{theme:u.mode,onThemeChange:u.setMode,authUser:K,onLogout:()=>{ae.auth.logout().catch(()=>{}),E0(),x(null)},onUserUpdated:te=>x(te)}),[Be.STORE]:t.jsx(gne,{authUser:K}),[Be.BUILDER]:t.jsx(s8,{authUser:K}),[Be.WORK]:t.jsx(t6,{authUser:K}),[Be.DELIVERABLES]:t.jsx(s6,{authUser:K}),[Be.REPORTS]:t.jsx(i6,{authUser:K})},[K?.id,K?.role,u.mode,c]);if(b==="loading"||b===null&&v===null)return t.jsx("div",{className:"min-h-dvh bg-surface-primary flex items-center justify-center",children:t.jsx("div",{className:"text-fg-tertiary text-sm animate-pulse",children:e("loading")})});const ne=(typeof window<"u"?window.location.hash:"").match(/^#invite\?token=([a-f0-9]+)/);return ne?t.jsx(iue,{token:ne[1],onComplete:()=>{window.location.hash="",localStorage.removeItem("markus_onboarded"),a(!0),w(!0),x("loading"),ae.auth.me().then(te=>x(te.user)).catch(()=>x(null))}}):b===null?t.jsx(aue,{hasOwner:C.hasOwner,hasMultipleUsers:C.hasMultipleUsers,onLogin:(te,Y,oe)=>{x(te),Y?(localStorage.removeItem("markus_onboarded"),a(!0),oe?.fromHub&&w(!0)):localStorage.getItem("markus_onboarded")||(localStorage.setItem("markus_onboarded","1"),a(!1))}}):S?t.jsx(oue,{onComplete:()=>T(!1),isFirstTime:!0}):s?t.jsx(sue,{theme:u.mode,onThemeChange:u.setMode,skipProfile:j,onComplete:()=>{localStorage.setItem("markus_onboarded","1"),a(!1),w(!1),X(),V(Be.HOME)}}):t.jsxs("div",{className:`flex h-dvh bg-surface-primary text-fg-primary overflow-x-hidden ${c?"flex-col":""}`,children:[!c&&n!==Be.SETTINGS&&t.jsxs(t.Fragment,{children:[t.jsx("div",{className:"relative z-40 shrink-0",style:{width:m.width},children:t.jsx(eue,{currentPage:n,onNavigate:te=>{V(te),l(!1)},authUser:b,collapsed:m.collapsed,onToggleCollapse:m.toggle})}),t.jsx("div",{className:`${m.collapsed?"w-0":"w-1.5 cursor-col-resize"} shrink-0 group relative z-10 flex items-center justify-center`,onMouseDown:m.collapsed?void 0:m.onResizeStart,children:!m.collapsed&&t.jsx("div",{className:"w-px h-2/3 border-l border-dashed border-transparent group-hover:border-border-default group-active:border-fg-tertiary transition-colors"})})]}),t.jsxs("div",{className:`flex-1 overflow-hidden flex flex-col min-w-0 ${c&&n!==Be.SETTINGS&&n!==Be.SEARCH?"pb-14":""}`,children:[R===!1&&!P&&n!==Be.SETTINGS&&t.jsxs("div",{className:"flex items-center justify-between px-4 py-2 bg-amber-500/10 border-b border-amber-500/30 text-amber-600 text-sm shrink-0",children:[t.jsx("span",{className:c?"text-xs":"",children:e("llmBanner.message")}),t.jsxs("div",{className:"flex items-center gap-3",children:[t.jsx("button",{onClick:()=>{window.location.hash="#settings/providers"},className:"px-3 py-1 bg-amber-700/50 hover:bg-amber-700/70 text-white text-xs rounded-lg transition-colors",children:e("llmBanner.goToSettings")}),t.jsx("button",{onClick:()=>L(!0),className:"text-amber-500 hover:text-amber-600 text-xs",children:e("dismiss")})]})]}),M&&U!==M.latestVersion&&t.jsxs("div",{className:"flex items-center justify-between px-4 py-2 bg-brand-500/10 border-b border-brand-500/30 text-brand-400 text-sm shrink-0",children:[t.jsx("span",{className:c?"text-xs":"",children:e("update.available",{latest:M.latestVersion,current:M.currentVersion})}),t.jsxs("span",{className:"flex items-center gap-3 shrink-0",children:[t.jsx("a",{href:"https://markus.global/download",target:"_blank",rel:"noopener noreferrer",className:"text-xs font-medium text-brand-400 hover:text-brand-300 transition-colors",children:e("update.download")}),t.jsx("button",{onClick:()=>{z(M.latestVersion),localStorage.setItem("markus_update_dismissed",M.latestVersion)},className:"text-fg-tertiary hover:text-fg-secondary text-xs shrink-0",children:e("dismiss")})]})]}),A&&!D&&n!==Be.SETTINGS&&t.jsxs("div",{className:"flex items-center justify-between px-4 py-2 bg-orange-500/10 border-b border-orange-500/30 text-orange-400 text-sm shrink-0",children:[t.jsx("span",{className:c?"text-xs":"",children:A.teams&&A.toolCalls?e("license.limitReachedBoth"):A.teams?e("license.limitReachedTeams"):e("license.limitReachedToolCalls")}),t.jsxs("span",{className:"flex items-center gap-3 shrink-0",children:[t.jsx("button",{onClick:()=>{window.location.hash="settings/account"},className:"px-3 py-1 bg-orange-600/50 hover:bg-orange-600/70 text-white text-xs rounded-lg transition-colors",children:e("license.upgradeLicense")}),t.jsx("button",{onClick:()=>O(!0),className:"text-fg-tertiary hover:text-fg-secondary text-xs shrink-0",children:e("dismiss")})]})]}),t.jsx("main",{className:"flex-1 overflow-hidden flex flex-col relative",children:Object.keys(ee).map(te=>f.has(te)?t.jsx(hue,{id:te,activePage:n,children:ee[te]},te):null)})]}),c&&n!==Be.SETTINGS&&n!==Be.SEARCH&&t.jsx(tue,{currentPage:n,onNavigate:V,userId:K?.id}),c&&t.jsx(yF,{authUser:K,onNavigate:V}),!c&&J&&t.jsx(due,{onClose:()=>B(!1),currentPage:n})]})}RM.createRoot(document.getElementById("root")).render(t.jsx(g.StrictMode,{children:t.jsx(pue,{})}));export{rm as C,za as R,ql as _,k0 as a,Fv as d,N8 as e,Tc as g,bue as h,to as i,xue as k,C8 as n,Nse as r,ei as s};
776
+ `)}else Rn=Fe;st(mn=>[...mn,{id:tn,label:jt?`🌐 ${wt}`:wt,type:"selection",content:Rn,onRemove:()=>st(Ir=>Ir.filter(is=>is.id!==tn))}]),Bt||gt(!0),en(null),window.getSelection()?.removeAllRanges()},[Bt,B?.reference]),nr=g.useCallback(Fe=>{if(!Fe.text.trim())return;const wt=yn.current?.querySelector("iframe")?.getBoundingClientRect(),tn=(wt?.left??0)+Fe.rect.x+Fe.rect.width/2,Rn=(wt?.top??0)+Fe.rect.y;en({x:tn,y:Rn,text:Fe.text,htmlMeta:{xpath:Fe.xpath,cssSelector:Fe.cssSelector}})},[]);return g.useEffect(()=>{const Fe=yn.current;if(!Fe)return;const jt=()=>{requestAnimationFrame(()=>{const tn=window.getSelection(),Rn=tn?.toString().trim();if(!Rn||!tn?.rangeCount){en(null);return}const mn=tn.getRangeAt(0);if(!Fe.contains(mn.commonAncestorContainer)){en(null);return}const Ir=mn.getBoundingClientRect();en({x:Ir.left+Ir.width/2,y:Ir.top,text:Rn})})},wt=tn=>{const Rn=document.getElementById("selection-toolbar");Rn&&Rn.contains(tn.target)||en(null)};return Fe.addEventListener("mouseup",jt),document.addEventListener("mousedown",wt),()=>{Fe.removeEventListener("mouseup",jt),document.removeEventListener("mousedown",wt)}},[]),t.jsxs("div",{className:"flex-1 overflow-hidden flex",children:[t.jsxs("div",{className:`${a?"flex-1 min-w-0":"shrink-0"} flex flex-col bg-surface-secondary rounded-xl m-1 mr-0`,style:a?c?{display:"none"}:void 0:qe?{display:"none"}:{width:l.width},children:[t.jsxs("div",{className:"p-4 space-y-3",children:[t.jsx("div",{className:"flex items-center justify-between gap-2",children:t.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[a&&t.jsx(Ac,{}),!a&&t.jsx("button",{onClick:()=>ct(!0),className:"w-8 h-8 flex items-center justify-center rounded-lg transition-colors shrink-0 bg-brand-500/15 text-brand-500 hover:bg-brand-500/25",title:s("sidebar.collapse"),children:t.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[t.jsx("rect",{x:"3",y:"3",width:"18",height:"18",rx:"2",ry:"2"}),t.jsx("line",{x1:"9",y1:"3",x2:"9",y2:"21"})]})}),t.jsxs("h2",{className:"text-sm font-semibold text-fg-secondary truncate",children:[s("title"),v>0&&t.jsxs("span",{className:"ml-1.5 text-fg-tertiary font-normal",children:["(",v,")"]})]})]})}),t.jsxs("div",{className:"relative",children:[t.jsxs("svg",{className:"absolute left-3 top-1/2 -translate-y-1/2 w-3.5 h-3.5 text-fg-muted pointer-events-none",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round",children:[t.jsx("circle",{cx:"11",cy:"11",r:"8"}),t.jsx("line",{x1:"21",y1:"21",x2:"16.65",y2:"16.65"})]}),t.jsx("input",{ref:Wn,value:M,onChange:Fe=>$(Fe.target.value),placeholder:s("searchPlaceholder"),className:"w-full bg-surface-elevated border border-border-default rounded-lg pl-8 pr-8 py-2 text-sm text-fg-primary focus:border-brand-500 focus:outline-none transition-colors"}),M&&t.jsx("button",{onClick:()=>{$(""),z("")},className:"absolute right-2.5 top-1/2 -translate-y-1/2 w-4 h-4 flex items-center justify-center rounded-full bg-surface-overlay text-fg-tertiary hover:text-fg-secondary transition-colors",children:t.jsxs("svg",{width:"10",height:"10",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"3",strokeLinecap:"round",children:[t.jsx("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),t.jsx("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]})})]}),xt&&!a&&t.jsxs("div",{className:"flex items-center gap-2 px-2.5 py-1.5 bg-surface-elevated rounded-lg text-[10px] text-fg-tertiary",children:[t.jsx("span",{className:"truncate font-mono",children:xt}),t.jsx("button",{onClick:()=>{ae.system.openPath(xt)},className:"shrink-0 underline hover:text-fg-secondary transition-colors",children:s("common:open")})]}),a&&t.jsxs("button",{onClick:()=>ye(Fe=>!Fe),className:`flex items-center gap-1.5 px-2.5 py-1.5 rounded-lg text-xs transition-colors ${ge||Jt?"bg-brand-500/15 text-brand-500":"bg-surface-elevated text-fg-secondary"}`,children:[t.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[t.jsx("line",{x1:"4",y1:"6",x2:"20",y2:"6"}),t.jsx("line",{x1:"8",y1:"12",x2:"20",y2:"12"}),t.jsx("line",{x1:"12",y1:"18",x2:"20",y2:"18"})]}),s("filters.filtersLabel"),Jt&&t.jsx("span",{className:"w-1.5 h-1.5 rounded-full bg-brand-500"}),t.jsx("svg",{className:`w-3 h-3 ml-auto transition-transform ${ge?"rotate-180":""}`,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",children:t.jsx("polyline",{points:"6 9 12 15 18 9"})})]}),t.jsxs("div",{className:a&&!ge?"hidden":"space-y-3",children:[t.jsxs("div",{className:"flex gap-1 overflow-x-auto scrollbar-hide filter-pills-fade",children:[t.jsx(T1,{label:s("filters.allTypes"),value:"",current:A||D||"",onClick:()=>{H(""),O("")}}),Vde.map(Fe=>t.jsx(T1,{label:`${vd[Fe]?.icon??""} ${Fe}`,value:Fe,current:A,onClick:jt=>{H(jt),O("")}},Fe)),["agent","team","skill"].map(Fe=>t.jsx(T1,{label:`${Tl[Fe].icon} ${s(`artifactTypes.${Fe}`)}`,value:Fe,current:D,onClick:jt=>{O(jt),H("")}},Fe))]}),t.jsxs("div",{className:"flex gap-1.5 items-center",children:[t.jsx("span",{className:"text-[10px] text-fg-tertiary",children:s("filters.group")}),["date","project","team","agent"].map(Fe=>t.jsx("button",{onClick:()=>{J(Fe)},className:`px-2 py-1 rounded text-xs transition-colors ${q===Fe?"bg-brand-600 text-white":"bg-surface-elevated text-fg-secondary hover:bg-surface-overlay"}`,children:s(`groupBy.${Fe}`)},Fe)),Wt.length>1&&t.jsx("button",{onClick:St,className:"ml-auto px-1.5 py-1 rounded text-[10px] text-fg-tertiary hover:text-fg-secondary hover:bg-surface-elevated transition-colors",title:s(Ye?"expandAllTooltip":"collapseAllTooltip"),children:s(Ye?"expandAll":"collapseAll")})]})]}),Jt&&t.jsxs("div",{className:"flex items-center gap-1 flex-wrap",children:[U&&t.jsxs("span",{className:"inline-flex items-center gap-1 px-1.5 py-0.5 rounded bg-brand-500/10 text-brand-500 text-[10px]",children:["“",U,"”",t.jsx("button",{onClick:()=>{$(""),z("")},className:"hover:text-brand-400",children:t.jsxs("svg",{width:"8",height:"8",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"3",strokeLinecap:"round",children:[t.jsx("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),t.jsx("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]})})]}),A&&t.jsxs("span",{className:"inline-flex items-center gap-1 px-1.5 py-0.5 rounded bg-brand-500/10 text-brand-500 text-[10px]",children:[vd[A]?.icon," ",A,t.jsx("button",{onClick:()=>H(""),className:"hover:text-brand-400",children:t.jsxs("svg",{width:"8",height:"8",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"3",strokeLinecap:"round",children:[t.jsx("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),t.jsx("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]})})]}),D&&t.jsxs("span",{className:"inline-flex items-center gap-1 px-1.5 py-0.5 rounded bg-brand-500/10 text-brand-500 text-[10px]",children:[Tl[D]?.icon," ",s(`artifactTypes.${D}`),t.jsx("button",{onClick:()=>O(""),className:"hover:text-brand-400",children:t.jsxs("svg",{width:"8",height:"8",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"3",strokeLinecap:"round",children:[t.jsx("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),t.jsx("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]})})]}),t.jsx("button",{onClick:gn,className:"text-[10px] text-fg-tertiary hover:text-brand-500 ml-auto transition-colors",children:s("filters.clearAll")})]})]}),X&&t.jsx("div",{className:`mx-4 mt-2 px-3 py-1.5 text-xs rounded-lg ${X.type==="success"?"bg-green-500/15 text-green-600":"bg-red-500/15 text-red-500"}`,children:X.text}),t.jsxs("div",{ref:Le,className:"flex-1 overflow-y-auto p-2 space-y-1 transition-opacity duration-150",style:{opacity:P?.5:1},onTouchStart:a?Fe=>{ue.onTouchStart(Fe),Pn(Fe)}:void 0,onTouchEnd:a?Fe=>{ue.onTouchEnd(Fe),kr(Fe)}:void 0,children:[we&&t.jsxs("div",{className:"flex items-center justify-center gap-2 py-2 text-brand-500",children:[t.jsx(a6,{})," ",t.jsx("span",{className:"text-[10px]",children:s("filters.refreshing")})]}),P?t.jsx("div",{className:"p-4 space-y-3",children:[1,2,3].map(Fe=>t.jsxs("div",{className:"animate-pulse space-y-2",children:[t.jsx("div",{className:"h-4 bg-surface-elevated rounded w-3/4"}),t.jsx("div",{className:"h-3 bg-surface-elevated rounded w-1/2"})]},Fe))}):b.length===0?t.jsxs("div",{className:"flex flex-col items-center justify-center py-16 px-6 text-center",children:[t.jsx("svg",{className:"w-12 h-12 text-fg-muted mb-3",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:1,children:t.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M19.5 14.25v-2.625a3.375 3.375 0 00-3.375-3.375h-1.5A1.125 1.125 0 0113.5 7.125v-1.5a3.375 3.375 0 00-3.375-3.375H8.25m0 12.75h7.5m-7.5 3H12M10.5 2.25H5.625c-.621 0-1.125.504-1.125 1.125v17.25c0 .621.504 1.125 1.125 1.125h12.75c.621 0 1.125-.504 1.125-1.125V11.25a9 9 0 00-9-9z"})}),Jt?t.jsxs(t.Fragment,{children:[t.jsx("p",{className:"text-sm text-fg-secondary",children:s("empty.noResults")}),t.jsx("p",{className:"text-xs text-fg-tertiary mt-1 mb-3",children:s("empty.noResultsHint")}),t.jsx("button",{onClick:gn,className:"text-xs px-3 py-1.5 rounded-lg bg-brand-600 hover:bg-brand-500 text-white transition-colors",children:s("filters.clearAll")})]}):t.jsxs(t.Fragment,{children:[t.jsx("p",{className:"text-sm text-fg-secondary",children:s("empty.title")}),t.jsx("p",{className:"text-xs text-fg-tertiary mt-1 mb-3",children:s("empty.subtitle")}),t.jsx("button",{onClick:()=>Rt.navigate(Be.WORK),className:"text-xs px-3 py-1.5 rounded-lg bg-brand-600 hover:bg-brand-500 text-white transition-colors",children:s("empty.goToWork")})]})]}):Wt.map(([Fe,jt])=>{const wt=pe(Fe);return t.jsxs("div",{className:"mb-1",children:[t.jsxs("button",{onClick:()=>lt(Fe),className:"w-full flex items-center gap-1.5 px-2 py-2 rounded-md hover:bg-surface-elevated/50 transition-colors group/header border-b border-border-subtle/50",children:[t.jsx("svg",{className:`w-3 h-3 text-fg-tertiary transition-transform duration-200 shrink-0 ${wt?"":"rotate-90"}`,fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2.5,children:t.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M9 5l7 7-7 7"})}),t.jsx("span",{className:"text-[11px] font-semibold text-fg-tertiary uppercase tracking-wider truncate",children:jt.label}),t.jsxs("span",{className:"text-[10px] text-fg-muted bg-surface-elevated px-1.5 py-0.5 rounded-full shrink-0",children:[jt.items.length,b.length<v?"+":""]})]}),t.jsx("div",{className:`overflow-hidden transition-all duration-200 ${wt?"max-h-0 opacity-0":"max-h-[5000px] opacity-100"}`,children:jt.items.map(tn=>t.jsx("button",{onClick:()=>rr(tn),className:`w-full text-left px-3 py-2 rounded-lg transition-all duration-150 ${B?.id===tn.id?"bg-brand-600/15 border-l-2 border-l-brand-500 border-y border-r border-y-brand-500/20 border-r-brand-500/20":"hover:bg-surface-elevated/60 border-l-2 border-l-transparent border-y border-r border-transparent"}`,children:t.jsxs("div",{className:"flex items-center gap-1.5 min-w-0",children:[tn.artifactType&&Tl[tn.artifactType]?t.jsx("span",{className:`text-[10px] px-1 py-0.5 rounded font-medium shrink-0 ${Tl[tn.artifactType].color}`,children:Tl[tn.artifactType].icon}):t.jsx("span",{className:`text-[10px] px-1 py-0.5 rounded font-medium uppercase shrink-0 ${vd[tn.type]?.color??"bg-surface-overlay text-fg-secondary"}`,children:vd[tn.type]?.icon??tn.type.charAt(0)}),t.jsx("span",{className:"text-sm font-medium text-fg-primary truncate flex-1",children:tn.title}),Ke.has(tn.id)&&t.jsx("span",{className:"shrink-0 text-amber-500",title:s("detail.fileMissing"),children:t.jsxs("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[t.jsx("path",{d:"M10.29 3.86L1.82 18a2 2 0 001.71 3h16.94a2 2 0 001.71-3L13.71 3.86a2 2 0 00-3.42 0z"}),t.jsx("line",{x1:"12",y1:"9",x2:"12",y2:"13"}),t.jsx("line",{x1:"12",y1:"17",x2:"12.01",y2:"17"})]})}),t.jsx("span",{className:"text-[10px] text-fg-muted shrink-0",children:Wde(tn.updatedAt,s)})]})},tn.id))})]},Fe)}),C&&t.jsxs("div",{className:"flex items-center justify-center gap-2 py-3 text-fg-tertiary",children:[t.jsx(a6,{})," ",t.jsx("span",{className:"text-[10px]",children:s("common:loadingMore")})]}),!P&&b.length>0&&t.jsx("div",{className:"text-center text-[10px] text-fg-tertiary py-2",children:b.length<v?s("count.partial",{loaded:b.length,total:v}):s("count.total",{total:v})})]})]}),!a&&t.jsx("div",{className:"w-2 shrink-0 cursor-col-resize group relative flex items-center justify-center hover:bg-brand-500/5 transition-colors",onMouseDown:l.onResizeStart,children:t.jsxs("div",{className:"flex flex-col gap-1 items-center opacity-0 group-hover:opacity-100 transition-opacity",children:[t.jsx("div",{className:"w-1 h-1 rounded-full bg-fg-muted"}),t.jsx("div",{className:"w-1 h-1 rounded-full bg-fg-muted"}),t.jsx("div",{className:"w-1 h-1 rounded-full bg-fg-muted"})]})}),(!a||c)&&t.jsxs("div",{className:"flex-1 overflow-hidden min-w-0 flex relative",children:[t.jsxs("div",{ref:yn,className:"flex-1 overflow-y-auto min-w-0",children:[qe&&!a&&t.jsxs("div",{className:"sticky top-0 z-10 bg-surface-primary/80 backdrop-blur-sm px-4 py-2 flex items-center gap-2",children:[t.jsx("button",{onClick:()=>{Gr.current=!0,ct(!1)},className:"w-8 h-8 flex items-center justify-center rounded-lg transition-colors shrink-0 text-fg-tertiary hover:text-fg-secondary hover:bg-surface-elevated",title:s("sidebar.expand"),children:t.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[t.jsx("rect",{x:"3",y:"3",width:"18",height:"18",rx:"2",ry:"2"}),t.jsx("line",{x1:"9",y1:"3",x2:"9",y2:"21"})]})}),t.jsx("span",{className:"text-sm font-medium text-fg-secondary truncate",children:B?.title??s("detail.details")})]}),a&&t.jsxs("div",{className:"sticky top-0 z-10 bg-surface-secondary px-4 py-2.5 flex items-center gap-2",children:[t.jsx("button",{onClick:()=>history.back(),className:"text-fg-secondary hover:text-fg-primary transition-colors p-1 -ml-1",children:t.jsx("svg",{width:"20",height:"20",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:t.jsx("polyline",{points:"15 18 9 12 15 6"})})}),t.jsx("span",{className:"text-sm font-medium truncate",children:B?.title??s("detail.details")})]}),B?t.jsxs("div",{className:"p-6 space-y-4",children:[!n&&Ke.has(B.id)&&t.jsxs("div",{className:"flex items-center gap-2 px-3 py-2 bg-amber-500/10 border border-amber-500/20 rounded-lg text-amber-600 text-xs",children:[t.jsxs("svg",{className:"w-4 h-4 shrink-0",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[t.jsx("path",{d:"M10.29 3.86L1.82 18a2 2 0 001.71 3h16.94a2 2 0 001.71-3L13.71 3.86a2 2 0 00-3.42 0z"}),t.jsx("line",{x1:"12",y1:"9",x2:"12",y2:"13"}),t.jsx("line",{x1:"12",y1:"17",x2:"12.01",y2:"17"})]}),t.jsx("span",{children:s("detail.fileMissing")})]}),t.jsxs("div",{className:"space-y-3",children:[t.jsxs("div",{className:"flex items-start justify-between gap-3",children:[t.jsx("h2",{className:"text-xl font-semibold text-fg-primary",children:B.title}),!n&&t.jsx("button",{onClick:()=>vt(B),disabled:!!ee,className:"p-1.5 rounded-lg text-fg-tertiary hover:text-red-500 hover:bg-red-500/10 transition-colors disabled:opacity-50 shrink-0",title:s("common:remove"),children:t.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[t.jsx("polyline",{points:"3 6 5 6 21 6"}),t.jsx("path",{d:"M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6m3 0V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2"})]})})]}),t.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[t.jsxs("span",{className:`px-2 py-0.5 rounded text-xs font-medium uppercase ${vd[B.type]?.color??"bg-surface-overlay text-fg-secondary"}`,children:[vd[B.type]?.icon??""," ",B.type]}),B.artifactType&&Tl[B.artifactType]&&t.jsxs("span",{className:`px-2 py-0.5 rounded text-xs font-medium ${Tl[B.artifactType].color}`,children:[Tl[B.artifactType].icon," ",s("detail.builderWithType",{type:s(`artifactTypes.${B.artifactType}`)})]}),B.tags.length>0&&B.tags.map(Fe=>t.jsx("span",{className:"px-2 py-0.5 text-xs bg-surface-elevated text-fg-secondary rounded",children:Fe},Fe))]}),(B.taskId||B.agentId||mr(B.projectId))&&t.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[B.taskId&&t.jsx("button",{onClick:()=>Rt.navigate(Be.WORK,{openTask:B.taskId}),className:"text-xs text-brand-500 hover:underline bg-brand-500/10 px-2 py-0.5 rounded",children:s("links.task",{id:`${B.taskId.slice(0,12)}...`})}),B.agentId&&t.jsx("button",{onClick:()=>Rt.navigate(Be.TEAM,{selectAgent:B.agentId}),className:"text-xs text-blue-600 hover:underline bg-blue-500/10 px-2 py-0.5 rounded",children:s("links.agent",{name:Cn.get(B.agentId)?.name??B.agentId.slice(0,12)})}),mr(B.projectId)&&t.jsx("button",{onClick:()=>Rt.navigate(Be.WORK,{projectId:B.projectId}),className:"text-xs text-blue-600 hover:underline bg-blue-500/10 px-2 py-0.5 rounded",children:s("links.project",{name:mr(B.projectId)})})]}),(B.diffStats||B.testResults)&&t.jsxs("div",{className:"flex gap-3 flex-wrap",children:[B.diffStats&&t.jsxs("div",{className:"bg-surface-elevated rounded-lg px-3 py-2 text-xs flex items-center gap-2",children:[t.jsxs("span",{className:"text-fg-tertiary font-medium",children:[s("diffStats.title"),":"]}),t.jsx("span",{className:"text-fg-secondary",children:s("diffStats.files",{count:B.diffStats.filesChanged})}),t.jsxs("span",{className:"text-green-600",children:["+",B.diffStats.additions]}),t.jsxs("span",{className:"text-red-500",children:["-",B.diffStats.deletions]})]}),B.testResults&&t.jsxs("div",{className:"bg-surface-elevated rounded-lg px-3 py-2 text-xs flex items-center gap-2",children:[t.jsxs("span",{className:"text-fg-tertiary font-medium",children:[s("testResults.title"),":"]}),t.jsx("span",{className:"text-green-600",children:s("testResults.passed",{count:B.testResults.passed})}),t.jsx("span",{className:"text-red-500",children:s("testResults.failed",{count:B.testResults.failed})}),t.jsx("span",{className:"text-fg-secondary",children:s("testResults.skipped",{count:B.testResults.skipped})})]})]}),t.jsxs("div",{className:"flex items-center gap-4 text-[10px] text-fg-tertiary flex-wrap",children:[t.jsxs("span",{children:[s("metadata.created")," ",new Date(B.createdAt).toLocaleString()]}),t.jsxs("span",{children:[s("metadata.updated")," ",new Date(B.updatedAt).toLocaleString()]}),t.jsx("span",{className:"text-fg-muted select-all",children:B.id.slice(0,12)})]}),B.reference&&!sh(B.reference)&&B.type==="file"&&t.jsxs("div",{className:"flex items-center gap-2 bg-surface-elevated rounded-lg px-3 py-2",children:[t.jsx("button",{onClick:()=>{ae.files.reveal(B.reference).catch(()=>br("error",s("detail.failedToOpenBrowser")))},className:"text-xs font-mono text-brand-500 hover:text-brand-500 hover:underline truncate flex-1 text-left cursor-pointer",title:s("detail.openInFileBrowser"),children:B.reference}),t.jsx("button",{onClick:()=>{ae.files.reveal(B.reference).catch(()=>br("error",s("detail.failedToOpenBrowser")))},className:"px-2 py-1 text-[10px] rounded bg-brand-600/20 text-brand-500 hover:bg-brand-600/30 transition-colors shrink-0",title:s("detail.revealInFinder"),children:s("common:open")}),t.jsx("button",{onClick:()=>Mr(B.reference),className:`px-2 py-1 text-[10px] rounded transition-colors shrink-0 ${Ae?"bg-green-500/20 text-green-600":"bg-surface-overlay/50 text-fg-secondary hover:bg-surface-overlay"}`,title:s("detail.copyPath"),children:s(Ae?"common:copied":"common:copy")})]}),B.reference&&!sh(B.reference)&&B.type!=="file"&&B.type!=="directory"&&t.jsx("span",{className:"text-xs text-fg-tertiary font-mono break-all",children:B.reference})]}),B.artifactType&&B.artifactData?t.jsxs("div",{className:"space-y-4",children:[t.jsx("div",{className:"bg-surface-elevated rounded-xl p-5",children:t.jsx(zde,{artifact:B.artifactData,mode:B.artifactType})}),B.reference&&t.jsxs("div",{className:"px-3 py-2 bg-surface-elevated rounded-lg",children:[t.jsx("span",{className:"text-[10px] text-fg-tertiary uppercase tracking-wider block mb-1",children:s("detail.artifactDirectory")}),t.jsx("span",{className:"text-xs text-fg-secondary font-mono break-all",children:B.reference})]}),t.jsx("div",{className:"flex gap-2",children:t.jsx("button",{onClick:pr,className:"flex-1 px-4 py-2.5 bg-brand-600 hover:bg-brand-500 text-white text-sm font-medium rounded-lg transition-colors",children:s("detail.openInBuilder")})}),B.summary&&t.jsx("div",{className:"bg-surface-elevated rounded-xl p-5",children:t.jsx(fs,{content:B.summary,className:"text-fg-secondary text-sm"})})]}):B.reference&&sh(B.reference)?t.jsxs("div",{className:"space-y-4",children:[B.summary&&t.jsx("div",{className:"bg-surface-elevated rounded-xl p-5",children:t.jsx(fs,{content:B.summary,className:"text-fg-secondary text-sm"})}),t.jsxs("div",{className:"flex flex-col items-center justify-center py-10",children:[t.jsxs("svg",{className:"w-10 h-10 text-fg-muted mb-3",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round",children:[t.jsx("path",{d:"M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6"}),t.jsx("polyline",{points:"15 3 21 3 21 9"}),t.jsx("line",{x1:"10",y1:"14",x2:"21",y2:"3"})]}),t.jsx("p",{className:"text-xs text-fg-tertiary font-mono mb-4 px-4 text-center break-all select-all",children:B.reference}),t.jsx("button",{onClick:()=>window.open(B.reference,"_blank","noopener,noreferrer"),className:"px-6 py-2.5 bg-brand-600 hover:bg-brand-500 text-white text-sm font-medium rounded-lg transition-colors",children:s("detail.openUrl")})]})]}):B.type==="directory"&&B.reference?t.jsxs("div",{className:"space-y-4",children:[B.summary&&t.jsx("div",{className:"bg-surface-elevated rounded-xl p-5",children:t.jsx(fs,{content:B.summary,className:"text-fg-secondary text-sm"})}),t.jsxs("div",{className:"flex flex-col items-center justify-center py-10",children:[t.jsx("svg",{className:"w-10 h-10 text-fg-muted mb-3",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round",children:t.jsx("path",{d:"M22 19a2 2 0 0 1-2 2H4a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h5l2 3h9a2 2 0 0 1 2 2z"})}),t.jsx("p",{className:"text-xs text-fg-tertiary font-mono mb-4 px-4 text-center break-all select-all",children:B.reference}),t.jsx("button",{onClick:()=>{ae.files.reveal(B.reference).catch(()=>br("error",s("detail.failedToOpenBrowser")))},className:"px-6 py-2.5 bg-brand-600 hover:bg-brand-500 text-white text-sm font-medium rounded-lg transition-colors",children:s("detail.openInFileBrowser")})]})]}):t.jsxs("div",{className:"bg-surface-elevated rounded-xl overflow-hidden",children:[($e||B.summary)&&!ve&&!Ve&&!W&&B.reference&&B.type==="file"&&(Ee==="markdown"||Ee==="text"||Ee==="html")&&t.jsxs("div",{className:"flex items-center gap-2 px-4 py-2 border-b border-border-subtle bg-surface-secondary/50",children:[t.jsx("button",{onClick:Sr,className:`px-3 py-1 rounded text-xs font-medium transition-colors ${be?"text-fg-tertiary hover:text-fg-secondary":"bg-brand-600/20 text-brand-500"}`,children:s("detail.preview")}),t.jsx("button",{onClick:Bn,className:`px-3 py-1 rounded text-xs font-medium transition-colors ${be?"bg-brand-600/20 text-brand-500":"text-fg-tertiary hover:text-fg-secondary"}`,children:s("detail.edit")}),t.jsx("div",{className:"flex-1"}),be&&t.jsx("button",{onClick:Kn,disabled:!sn||Ut,className:"px-3 py-1 rounded text-xs font-medium bg-brand-600 hover:bg-brand-500 text-white transition-colors disabled:opacity-40 disabled:cursor-not-allowed",children:s(Ut?"detail.saving":"detail.save")})]}),t.jsx("div",{className:"p-5",children:ve?t.jsxs("div",{className:"animate-pulse space-y-4",children:[t.jsx("div",{className:"h-4 bg-surface-overlay/60 rounded w-full"}),t.jsx("div",{className:"h-4 bg-surface-overlay/60 rounded w-5/6"}),t.jsx("div",{className:"h-4 bg-surface-overlay/60 rounded w-4/6"}),t.jsx("div",{className:"h-32 bg-surface-overlay/40 rounded-lg w-full mt-2"}),t.jsx("div",{className:"h-4 bg-surface-overlay/60 rounded w-3/4"}),t.jsx("div",{className:"h-4 bg-surface-overlay/60 rounded w-2/3"})]}):Ve?t.jsxs("div",{className:"flex flex-col items-center gap-2",children:[t.jsx("img",{src:Ve.src,alt:Ve.name,className:"max-w-full max-h-[60vh] rounded-lg object-contain"}),t.jsx("span",{className:"text-xs text-fg-tertiary",children:Ve.name})]}):$e?be?t.jsx("div",{className:"animate-fadeIn",children:t.jsx("textarea",{ref:On,value:it,onChange:Fe=>{It(Fe.target.value),An(!0)},className:"w-full min-h-[120px] p-3 text-sm font-mono bg-surface-primary border border-border-subtle rounded-lg text-fg-secondary focus:outline-none focus:ring-1 focus:ring-brand-500/50 overflow-hidden",style:{resize:"none"},spellCheck:!1})},"edit"):t.jsx("div",{className:"animate-fadeIn",children:t.jsx(Bv,{content:$e,format:Ee,className:"text-fg-secondary text-sm",onHtmlSelection:nr})},"preview"):W?t.jsxs("div",{className:"space-y-3",children:[t.jsx("p",{className:"text-sm text-fg-secondary",children:s("detail.cannotPreview",{type:B.type})}),t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx("button",{onClick:()=>{ae.files.reveal(B.reference).catch(()=>br("error",s("detail.failedToOpen")))},className:"text-xs bg-surface-elevated px-3 py-2 rounded text-brand-500 hover:text-brand-500 hover:underline flex-1 truncate text-left cursor-pointer font-mono",title:s("detail.openInFileBrowser"),children:B.reference}),t.jsx("button",{onClick:()=>{ae.files.reveal(B.reference).catch(()=>br("error",s("detail.failedToOpen")))},className:"px-3 py-2 text-xs rounded-lg bg-brand-600/20 text-brand-500 hover:bg-brand-600/30 transition-colors shrink-0",children:s("common:open")}),t.jsx("button",{onClick:()=>Mr(B.reference),className:`px-3 py-2 text-xs rounded-lg transition-colors shrink-0 ${Ae?"bg-green-500/20 text-green-600":"bg-surface-overlay/50 text-fg-secondary hover:bg-surface-overlay"}`,children:s(Ae?"common:copied":"common:copy")})]})]}):B.summary?be?t.jsx("textarea",{ref:On,value:it,onChange:Fe=>{It(Fe.target.value),An(!0)},className:"w-full min-h-[120px] p-3 text-sm font-mono bg-surface-primary border border-border-subtle rounded-lg text-fg-secondary focus:outline-none focus:ring-1 focus:ring-brand-500/50 overflow-hidden",style:{resize:"none"},spellCheck:!1}):t.jsx(fs,{content:B.summary,className:"text-fg-secondary text-sm"}):t.jsx("p",{className:"text-sm text-fg-tertiary italic",children:s("detail.noContent")})})]})]}):t.jsx("div",{className:"flex-1 flex items-center justify-center h-full",children:t.jsxs("div",{className:"text-center text-fg-tertiary space-y-3 max-w-xs",children:[t.jsx("div",{className:"w-16 h-16 mx-auto rounded-2xl bg-surface-elevated/60 flex items-center justify-center",children:t.jsx("svg",{className:"w-8 h-8 text-fg-muted",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:1,children:t.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M19.5 14.25v-2.625a3.375 3.375 0 00-3.375-3.375h-1.5A1.125 1.125 0 0113.5 7.125v-1.5a3.375 3.375 0 00-3.375-3.375H8.25m0 12.75h7.5m-7.5 3H12M10.5 2.25H5.625c-.621 0-1.125.504-1.125 1.125v17.25c0 .621.504 1.125 1.125 1.125h12.75c.621 0 1.125-.504 1.125-1.125V11.25a9 9 0 00-9-9z"})})}),t.jsx("p",{className:"text-sm text-fg-secondary",children:s("detail.selectToView")}),!a&&t.jsx("p",{className:"text-[10px] text-fg-muted",children:s("detail.keyboardHint")})]})})]}),B?.agentId&&!Bt&&!a&&t.jsx("button",{onClick:()=>gt(!0),className:"absolute bottom-6 right-6 w-12 h-12 rounded-full bg-brand-600 hover:bg-brand-500 text-white shadow-lg shadow-black/20 flex items-center justify-center transition-all hover:scale-105 z-20 animate-fab-in",title:s("chat.openChat"),children:t.jsx("svg",{width:"20",height:"20",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:t.jsx("path",{d:"M21 15a2 2 0 0 1-2 2H7l-4 4V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2z"})})}),Bt&&B?.agentId&&!a&&t.jsx(qde,{agentId:B.agentId,agents:S,authUser:e,onClose:()=>{gt(!1),st([])},contextChips:[{id:`deliverable_ctx_${B.id}`,label:`📦 ${B.title}`,type:"deliverable",content:`${s("chat.currentDeliverable")}: ${B.title} (id: ${B.id})`},...cn],width:400})]}),Ct&&t.jsx("div",{id:"selection-toolbar",className:"fixed z-50 -translate-x-1/2 -translate-y-full bg-surface-elevated border border-border-default rounded-lg shadow-xl overflow-hidden",style:{left:Ct.x,top:Ct.y-8},children:t.jsxs("button",{onMouseDown:Fe=>{Fe.preventDefault(),Fe.stopPropagation(),Br(Ct.text,Ct.htmlMeta)},className:"px-3 py-1.5 text-xs text-fg-secondary hover:bg-surface-overlay hover:text-fg-primary transition-colors flex items-center gap-1.5 whitespace-nowrap",children:[t.jsx("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:t.jsx("path",{d:"M21 15a2 2 0 0 1-2 2H7l-4 4V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2z"})}),s("contextMenu.addToConversation")]})}),tt&&t.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/60",onClick:()=>vt(null),children:t.jsxs("div",{className:"bg-surface-secondary border border-border-default rounded-xl p-6 max-w-sm mx-4 shadow-2xl",onClick:Fe=>Fe.stopPropagation(),children:[t.jsxs("div",{className:"flex items-center gap-3 mb-4",children:[t.jsx("div",{className:"w-10 h-10 rounded-full bg-red-500/15 flex items-center justify-center shrink-0",children:t.jsxs("svg",{className:"w-5 h-5 text-red-500",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[t.jsx("polyline",{points:"3 6 5 6 21 6"}),t.jsx("path",{d:"M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6m3 0V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2"})]})}),t.jsxs("div",{children:[t.jsx("div",{className:"text-sm font-medium text-fg-primary",children:s("detail.confirmRemoveTitle")}),t.jsx("div",{className:"text-xs text-fg-secondary mt-0.5",children:s("detail.confirmRemoveMessage",{name:tt.title})})]})]}),t.jsxs("div",{className:"flex justify-end gap-2",children:[t.jsx("button",{onClick:()=>vt(null),className:"px-4 py-1.5 text-xs text-fg-secondary hover:text-fg-primary border border-border-default hover:border-gray-600 rounded-lg transition-colors",children:s("common:cancel")}),t.jsx("button",{onClick:()=>{const Fe=tt;vt(null),pn(Fe)},disabled:!!ee,className:"px-4 py-1.5 text-xs bg-red-600 hover:bg-red-500 text-white rounded-lg transition-colors disabled:opacity-50",children:s("common:remove")})]})]})}),on&&t.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/60",onClick:()=>Ln(null),children:t.jsxs("div",{className:"bg-surface-secondary border border-border-default rounded-xl p-6 max-w-sm mx-4 shadow-2xl",onClick:Fe=>Fe.stopPropagation(),children:[t.jsxs("div",{className:"flex items-center gap-3 mb-4",children:[t.jsx("div",{className:"w-10 h-10 rounded-full bg-amber-500/15 flex items-center justify-center shrink-0",children:t.jsx("svg",{className:"w-5 h-5 text-amber-500",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:t.jsx("path",{d:"M12 9v2m0 4h.01m-6.938 4h13.856c1.54 0 2.502-1.667 1.732-2.5L13.732 4c-.77-.833-1.964-.833-2.732 0L4.082 16.5c-.77.833.192 2.5 1.732 2.5z"})})}),t.jsxs("div",{children:[t.jsx("div",{className:"text-sm font-medium text-fg-primary",children:s("detail.unsavedTitle")}),t.jsx("div",{className:"text-xs text-fg-secondary mt-0.5",children:s("detail.unsavedMessage")})]})]}),t.jsxs("div",{className:"flex justify-end gap-2",children:[t.jsx("button",{onClick:()=>Ln(null),className:"px-4 py-1.5 text-xs text-fg-secondary hover:text-fg-primary border border-border-default hover:border-gray-600 rounded-lg transition-colors",children:s("common:cancel")}),t.jsx("button",{onClick:()=>{$n(),on.action()},className:"px-4 py-1.5 text-xs text-fg-secondary hover:text-fg-primary border border-border-default hover:border-gray-600 rounded-lg transition-colors",children:s("detail.discard")}),t.jsx("button",{onClick:async()=>{await Kn(),on.action(),Ln(null)},className:"px-4 py-1.5 text-xs bg-brand-600 hover:bg-brand-500 text-white rounded-lg transition-colors",children:s("detail.saveAndLeave")})]})]})})]})}function T1({label:e,value:n,current:r,onClick:s}){return t.jsx("button",{onClick:()=>s(r===n?"":n),className:`px-2 py-1 rounded text-xs whitespace-nowrap shrink-0 transition-colors ${r===n?"bg-brand-600 text-white":"bg-surface-elevated text-fg-secondary hover:bg-surface-overlay"}`,children:e})}function a6(){return t.jsxs("svg",{className:"animate-spin h-3.5 w-3.5",viewBox:"0 0 24 24",fill:"none",children:[t.jsx("circle",{className:"opacity-25",cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"4"}),t.jsx("path",{className:"opacity-75",fill:"currentColor",d:"M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4z"})]})}function Do(e){return e.toLocaleString()}function Ed(e){return e<.01?`$${e.toFixed(4)}`:`$${e.toFixed(2)}`}function Kde(e){return e>=1024*1024*1024?`${(e/(1024*1024*1024)).toFixed(1)} GB`:e>=1024*1024?`${(e/(1024*1024)).toFixed(1)} MB`:e>=1024?`${(e/1024).toFixed(1)} KB`:`${e} B`}function i6({authUser:e}){const{t:n}=ht(["reports","common"]),r=ea(),s=Zd(Be.REPORTS),[a,i]=g.useState("weekly"),[l,c]=g.useState(null),[u,m]=g.useState(!0),[f,p]=g.useState(""),[b,x]=g.useState(null),[v,N]=g.useState([]),[C,k]=g.useState("totalTokens"),[j,w]=g.useState(!0),[S,T]=g.useState("generate"),[R,I]=g.useState([]),[P,L]=g.useState(null),[M,$]=g.useState([]),[U,z]=g.useState(""),[A,H]=g.useState(""),D=Y=>{H(Y),setTimeout(()=>H(""),3e3)},O=g.useCallback(async Y=>{m(!0),p("");try{const{report:oe}=await ae.reports.generate({period:Y,scope:"org",orgId:"default"});c(oe)}catch(oe){p(String(oe)),c(null)}m(!1)},[]),q=g.useCallback(()=>{ae.usage.summary().then(Y=>x(Y.usage)).catch(()=>{}),ae.usage.agents().then(Y=>N(Y.agents)).catch(()=>{})},[]),J=g.useCallback(async()=>{try{const{reports:Y}=await ae.reports.list();I(Y)}catch{}},[]),B=g.useCallback(async Y=>{L(Y);try{const{feedback:oe}=await ae.reports.getFeedback(Y.id);$(oe)}catch{$([])}},[]);g.useEffect(()=>{O(a)},[a,O]),g.useEffect(()=>{if(!s)return;q();const Y=setInterval(q,3e4);return()=>clearInterval(Y)},[q,s]),g.useEffect(()=>{S==="history"&&J()},[S,J]);const V=g.useMemo(()=>[...v].sort((Y,oe)=>{const ge=Y[C],ye=oe[C];return j?ye-ge:ge-ye}),[v,C,j]),X=v.reduce((Y,oe)=>Y+oe.estimatedCost,0),K=v.reduce((Y,oe)=>Y+oe.tokensUsedToday,0),ee=v.reduce((Y,oe)=>Y+(oe.costToday??0),0),Q=Math.max(1,...v.map(Y=>Y.totalTokens)),ne=Y=>{C===Y?w(!j):(k(Y),w(!0))},te=g.useMemo(()=>({daily:n("period.today"),weekly:n("period.thisWeek"),monthly:n("period.thisMonth")}),[n]);return t.jsx("div",{className:"flex-1 overflow-y-auto",children:t.jsxs("div",{className:"max-w-5xl mx-auto w-full p-6 space-y-6",children:[t.jsxs("div",{className:"flex flex-col gap-3 md:flex-row md:items-center md:justify-between",children:[t.jsxs("div",{className:"flex items-center gap-4 flex-wrap",children:[r&&t.jsx(Ac,{}),t.jsx("h1",{className:"text-xl font-semibold text-fg-primary",children:n("title")}),t.jsxs("div",{className:"flex gap-1 bg-surface-elevated rounded-lg p-0.5",children:[t.jsx("button",{onClick:()=>T("generate"),className:`px-3 py-1.5 text-xs rounded-md transition-colors ${S==="generate"?"bg-surface-overlay text-fg-primary shadow-sm":"text-fg-tertiary hover:text-fg-secondary"}`,children:n("tabs.generate")}),t.jsxs("button",{onClick:()=>T("history"),className:`px-3 py-1.5 text-xs rounded-md transition-colors ${S==="history"?"bg-surface-overlay text-fg-primary shadow-sm":"text-fg-tertiary hover:text-fg-secondary"}`,children:[n("tabs.history"),R.length>0?` (${R.length})`:""]})]})]}),t.jsxs("div",{className:"flex items-center gap-3 flex-wrap",children:[A&&t.jsx("span",{className:"px-2.5 py-1 bg-green-500/10 text-green-600 text-xs rounded-lg",children:A}),S==="generate"&&t.jsx("div",{className:"flex gap-1 bg-surface-elevated rounded-lg p-0.5",children:["daily","weekly","monthly"].map(Y=>t.jsx("button",{onClick:()=>i(Y),className:`px-3 py-1.5 text-xs rounded-md transition-colors ${a===Y?"bg-surface-overlay text-fg-primary shadow-sm":"text-fg-tertiary hover:text-fg-secondary"}`,children:n(`period.${Y}`)},Y))})]})]}),S==="history"&&!P&&t.jsx("section",{className:"bg-surface-elevated rounded-xl overflow-hidden",children:R.length===0?t.jsx("div",{className:"p-8 text-center text-fg-tertiary text-sm",children:n("noReportsYet")}):t.jsx("div",{className:"divide-y divide-border-default/50",children:R.map(Y=>t.jsxs("button",{onClick:()=>B(Y),className:"w-full text-left px-5 py-3 flex items-center gap-4 hover:bg-surface-elevated/30 transition-colors",children:[t.jsxs("div",{className:"flex-1 min-w-0",children:[t.jsx("div",{className:"text-sm font-medium text-fg-primary",children:n("reportType",{type:Y.type})}),t.jsxs("div",{className:"text-xs text-fg-tertiary mt-0.5",children:[new Date(Y.periodStart).toLocaleDateString()," — ",new Date(Y.periodEnd).toLocaleDateString()]})]}),Y.plan&&t.jsx("span",{className:`px-2 py-0.5 rounded-full text-[10px] font-medium shrink-0 ${Y.plan.status==="approved"?"bg-green-500/10 text-green-600":Y.plan.status==="rejected"?"bg-red-500/10 text-red-500":"bg-amber-500/10 text-amber-600"}`,children:Y.plan.status==="pending"?n("upcomingPlan.planPending"):n("upcomingPlan.planStatus",{status:Y.plan.status})}),t.jsx("span",{className:"text-[10px] text-fg-tertiary shrink-0",children:new Date(Y.generatedAt).toLocaleDateString()})]},Y.id))})}),S==="history"&&P&&t.jsxs(t.Fragment,{children:[t.jsxs("div",{className:"flex items-center gap-3",children:[t.jsx("button",{onClick:()=>{L(null),$([])},className:"text-xs text-fg-tertiary hover:text-fg-secondary",children:n("backToList")}),t.jsx("span",{className:"text-sm font-medium text-fg-primary",children:n("reportType",{type:P.type})}),t.jsxs("span",{className:"text-xs text-fg-tertiary",children:[new Date(P.periodStart).toLocaleDateString()," — ",new Date(P.periodEnd).toLocaleDateString()]})]}),P.metrics&&t.jsxs("section",{className:"bg-surface-elevated rounded-xl p-5",children:[t.jsx("h3",{className:"text-xs font-semibold text-fg-secondary mb-3",children:n("taskMetrics.title")}),t.jsxs("div",{className:"grid grid-cols-2 md:grid-cols-5 gap-4",children:[t.jsx(Xi,{label:n("taskMetrics.completed"),value:P.metrics.tasksCompleted,color:"text-green-600"}),t.jsx(Xi,{label:n("taskMetrics.inProgress"),value:P.metrics.tasksInProgress,color:"text-brand-500"}),t.jsx(Xi,{label:n("taskMetrics.created"),value:P.metrics.tasksCreated,color:"text-blue-600"}),t.jsx(Xi,{label:n("taskMetrics.blocked"),value:P.metrics.tasksBlocked,color:"text-amber-600"}),t.jsx(Xi,{label:n("taskMetrics.failed"),value:P.metrics.tasksFailed,color:"text-red-500"})]})]}),P.costSummary&&t.jsxs("section",{className:"bg-surface-elevated rounded-xl p-5",children:[t.jsx("h3",{className:"text-xs font-semibold text-fg-secondary mb-3",children:n("costOverview.title")}),t.jsxs("div",{className:"grid grid-cols-2 lg:grid-cols-3 gap-4",children:[t.jsxs("div",{children:[t.jsx("div",{className:"text-2xl font-bold text-fg-primary",children:P.costSummary.totalTokens.toLocaleString()}),t.jsx("div",{className:"text-xs text-fg-tertiary",children:n("costOverview.totalTokens")})]}),t.jsxs("div",{children:[t.jsx("div",{className:"text-2xl font-bold text-fg-primary",children:Ed(P.costSummary.totalEstimatedCost)}),t.jsx("div",{className:"text-xs text-fg-tertiary",children:n("costOverview.estimatedCost")})]}),t.jsxs("div",{children:[t.jsxs("div",{className:`text-2xl font-bold ${P.costSummary.trend==="decreasing"?"text-green-600":P.costSummary.trend==="increasing"?"text-red-500":"text-fg-primary"}`,children:[P.costSummary.trend==="decreasing"?"↓":P.costSummary.trend==="increasing"?"↑":"→"," ",P.costSummary.trend]}),t.jsx("div",{className:"text-xs text-fg-tertiary",children:n("costOverview.trend")})]})]}),P.costSummary.byAgent&&P.costSummary.byAgent.length>0&&t.jsx("div",{className:"mt-4 pt-3 border-t border-border-default/50 space-y-1.5",children:P.costSummary.byAgent.map((Y,oe)=>t.jsxs("div",{className:"flex items-center justify-between text-xs",children:[t.jsx("span",{className:"text-fg-secondary",children:Y.agentId}),t.jsx("span",{className:"text-fg-tertiary tabular-nums",children:n("costOverview.byAgentRow",{tokens:Do(Y.tokens),cost:Ed(Y.cost)})})]},oe))})]}),P.taskSummary&&t.jsxs("section",{className:"bg-surface-elevated rounded-xl p-5 overflow-hidden",children:[t.jsx("h3",{className:"text-xs font-semibold text-fg-secondary mb-3",children:n("taskSummary.title")}),t.jsxs("div",{className:"space-y-4 min-w-0",children:[P.taskSummary.completed.length>0&&t.jsx(wd,{title:n("taskSummary.completedCount",{count:P.taskSummary.completed.length}),color:"emerald",items:P.taskSummary.completed.map(Y=>({id:Y.id,label:Y.title,sub:Y.agent}))}),P.taskSummary.inProgress.length>0&&t.jsx(wd,{title:n("taskSummary.inProgressCount",{count:P.taskSummary.inProgress.length}),color:"indigo",items:P.taskSummary.inProgress.map(Y=>({id:Y.id,label:Y.title,sub:Y.agent}))}),P.taskSummary.blocked.length>0&&t.jsx(wd,{title:n("taskSummary.blockedCount",{count:P.taskSummary.blocked.length}),color:"amber",items:P.taskSummary.blocked.map(Y=>({id:Y.id,label:Y.title,sub:Y.reason||Y.agent}))}),P.taskSummary.completed.length===0&&P.taskSummary.inProgress.length===0&&P.taskSummary.blocked.length===0&&t.jsx("p",{className:"text-sm text-fg-tertiary",children:n("taskSummary.noTasksInPeriod")})]})]}),P.highlights&&P.highlights.length>0&&t.jsxs("section",{className:"bg-surface-elevated rounded-xl p-5",children:[t.jsx("h3",{className:"text-xs font-semibold text-fg-secondary mb-2",children:n("highlights")}),t.jsx("ul",{className:"list-disc list-inside space-y-1 text-sm text-fg-secondary",children:P.highlights.map((Y,oe)=>t.jsx("li",{children:Y},oe))})]}),P.blockers&&P.blockers.length>0&&t.jsxs("section",{className:"bg-surface-secondary border border-amber-500/20 rounded-xl p-5",children:[t.jsx("h3",{className:"text-xs font-semibold text-amber-600 mb-2",children:n("blockers")}),t.jsx("ul",{className:"list-disc list-inside space-y-1 text-sm text-fg-secondary",children:P.blockers.map((Y,oe)=>t.jsx("li",{children:Y},oe))})]}),P.plan&&t.jsxs("section",{className:"bg-surface-elevated rounded-xl p-5",children:[t.jsxs("div",{className:"flex items-center justify-between mb-3",children:[t.jsxs("h3",{className:"text-xs font-semibold text-fg-secondary",children:[n("upcomingPlan.title"),t.jsx("span",{className:`ml-2 px-1.5 py-0.5 rounded text-[10px] font-medium ${P.plan.status==="approved"?"bg-green-500/10 text-green-600":P.plan.status==="rejected"?"bg-red-500/10 text-red-500":"bg-amber-500/10 text-amber-600"}`,children:n(`common:status.${P.plan.status}`,{defaultValue:P.plan.status})})]}),P.plan.status==="pending"&&t.jsxs("div",{className:"flex gap-2",children:[t.jsx("button",{onClick:async()=>{try{const{report:Y}=await ae.reports.approvePlan(P.id,{approvedBy:e?.id??"unknown"});L(Y),D(n("upcomingPlan.planApproved")),J()}catch(Y){D(n("common:error",{message:String(Y)}))}},className:"px-3 py-1.5 text-xs font-medium bg-green-600 text-white rounded-lg hover:bg-green-500 transition-colors",children:n("upcomingPlan.approvePlan")}),t.jsx("button",{onClick:async()=>{const Y=prompt(n("upcomingPlan.rejectionReason"));if(Y)try{const{report:oe}=await ae.reports.rejectPlan(P.id,{rejectedBy:e?.id??"unknown",reason:Y});L(oe),D(n("upcomingPlan.planRejected")),J()}catch(oe){D(n("common:error",{message:String(oe)}))}},className:"px-3 py-1.5 text-xs font-medium border border-border-default text-fg-secondary rounded-lg hover:bg-surface-overlay transition-colors",children:n("upcomingPlan.rejectPlan")})]})]}),P.plan.items&&P.plan.items.length>0&&t.jsx("div",{className:"space-y-1.5",children:P.plan.items.map((Y,oe)=>t.jsxs("div",{className:"flex items-center gap-2 text-sm text-fg-secondary",children:[t.jsx("span",{className:`px-1.5 py-0.5 rounded text-[10px] font-medium ${Y.priority==="high"?"bg-red-500/10 text-red-500":Y.priority==="medium"?"bg-amber-500/10 text-amber-600":"bg-gray-500/10 text-fg-tertiary"}`,children:Y.priority}),t.jsx("span",{children:Y.title}),Y.assignee&&t.jsx("span",{className:"text-[10px] text-fg-tertiary ml-auto",children:Y.assignee})]},oe))})]}),!P.metrics&&!P.taskSummary&&!P.costSummary&&t.jsx("section",{className:"bg-surface-elevated rounded-xl p-8 text-center",children:t.jsx("p",{className:"text-sm text-fg-tertiary",children:n("noDetailedMetrics")})}),t.jsxs("section",{className:"bg-surface-elevated rounded-xl p-5",children:[t.jsx("h3",{className:"text-xs font-semibold text-fg-secondary mb-3",children:n("feedback.title",{count:M.length})}),M.length>0&&t.jsx("div",{className:"space-y-2 mb-4",children:M.map(Y=>t.jsxs("div",{className:"p-3 bg-surface-elevated/50 rounded-lg",children:[t.jsxs("div",{className:"flex items-center gap-2 text-[10px] text-fg-tertiary mb-1",children:[t.jsx("span",{className:"font-medium text-fg-secondary",children:Y.authorName}),t.jsx("span",{children:Y.type}),t.jsx("span",{children:new Date(Y.createdAt).toLocaleDateString()})]}),t.jsx("p",{className:"text-xs text-fg-secondary",children:Y.content})]},Y.id))}),t.jsxs("div",{className:"flex gap-2",children:[t.jsx("input",{value:U,onChange:Y=>z(Y.target.value),placeholder:n("feedback.placeholder"),className:"flex-1 px-3 py-2 text-xs bg-surface-elevated border border-border-default rounded-lg text-fg-primary placeholder:text-fg-tertiary",onKeyDown:Y=>{Y.key==="Enter"&&U.trim()&&ae.reports.addFeedback(P.id,{author:e?.id??"unknown",type:"comment",content:U.trim()}).then(({feedback:oe})=>{$(ge=>[...ge,oe]),z(""),D(n("feedback.added"))}).catch(oe=>D(n("common:error",{message:String(oe)})))}}),t.jsx("button",{onClick:()=>{U.trim()&&ae.reports.addFeedback(P.id,{author:e?.id??"unknown",type:"comment",content:U.trim()}).then(({feedback:Y})=>{$(oe=>[...oe,Y]),z(""),D(n("feedback.added"))}).catch(Y=>D(n("common:error",{message:String(Y)})))},disabled:!U.trim(),className:"px-3 py-2 text-xs bg-brand-600 text-white rounded-lg hover:bg-brand-500 disabled:opacity-40 disabled:cursor-not-allowed transition-colors",children:n("common:send")})]})]})]}),S==="generate"&&b&&t.jsxs("div",{className:`grid gap-4 ${b.storageBytes>0?"grid-cols-2 lg:grid-cols-4":"grid-cols-3"}`,children:[t.jsx(ah,{label:n("usage.llmTokens"),value:Do(b.llmTokens),color:"text-brand-500"}),t.jsx(ah,{label:n("usage.toolCalls"),value:Do(b.toolCalls),color:"text-blue-600"}),t.jsx(ah,{label:n("usage.messages"),value:Do(b.messages),color:"text-green-600"}),b.storageBytes>0&&t.jsx(ah,{label:n("usage.storage"),value:Kde(b.storageBytes),color:"text-amber-600"})]}),S==="generate"&&(u?t.jsx("div",{className:"flex items-center justify-center h-32 text-fg-tertiary text-sm",children:n("common:loading")}):f?t.jsx("div",{className:"flex items-center justify-center h-32 text-red-500 text-sm",children:f}):l?t.jsxs(t.Fragment,{children:[t.jsxs("div",{className:"text-xs text-fg-tertiary",children:[te[a]," · ",new Date(l.periodStart).toLocaleDateString()," — ",new Date(l.periodEnd).toLocaleDateString()]}),l.metrics&&t.jsxs("section",{className:"bg-surface-elevated rounded-xl p-5",children:[t.jsx("h3",{className:"text-xs font-semibold text-fg-secondary mb-3",children:n("taskMetrics.title")}),t.jsxs("div",{className:"grid grid-cols-2 md:grid-cols-5 gap-4",children:[t.jsx(Xi,{label:n("taskMetrics.completed"),value:l.metrics.tasksCompleted,color:"text-green-600"}),t.jsx(Xi,{label:n("taskMetrics.inProgress"),value:l.metrics.tasksInProgress,color:"text-brand-500"}),t.jsx(Xi,{label:n("taskMetrics.created"),value:l.metrics.tasksCreated,color:"text-blue-600"}),t.jsx(Xi,{label:n("taskMetrics.blocked"),value:l.metrics.tasksBlocked,color:"text-amber-600"}),t.jsx(Xi,{label:n("taskMetrics.failed"),value:l.metrics.tasksFailed,color:"text-red-500"})]})]}),t.jsxs("section",{className:"bg-surface-elevated rounded-xl p-5",children:[t.jsx("h3",{className:"text-xs font-semibold text-fg-secondary mb-3",children:n("costOverview.title")}),t.jsxs("div",{className:"grid grid-cols-3 gap-4",children:[t.jsxs("div",{children:[t.jsx("div",{className:"text-2xl font-bold text-fg-primary",children:Ed(X)}),t.jsx("div",{className:"text-xs text-fg-tertiary",children:n("costOverview.estCostAllTime")})]}),t.jsxs("div",{children:[t.jsx("div",{className:"text-2xl font-bold text-fg-primary",children:Do(K)}),t.jsx("div",{className:"text-xs text-fg-tertiary",children:n("costOverview.tokensToday")})]}),t.jsxs("div",{children:[t.jsx("div",{className:"text-2xl font-bold text-fg-primary",children:Ed(ee)}),t.jsx("div",{className:"text-xs text-fg-tertiary",children:n("costOverview.costToday")})]})]})]}),l.taskSummary&&t.jsxs("section",{className:"bg-surface-elevated rounded-xl p-5",children:[t.jsx("h3",{className:"text-xs font-semibold text-fg-secondary mb-3",children:n("taskSummary.title")}),t.jsxs("div",{className:"space-y-4",children:[l.taskSummary.completed.length>0&&t.jsx(wd,{title:n("taskSummary.completedCount",{count:l.taskSummary.completed.length}),color:"emerald",items:l.taskSummary.completed.map(Y=>({id:Y.id,label:Y.title,sub:Y.agent}))}),l.taskSummary.inProgress.length>0&&t.jsx(wd,{title:n("taskSummary.inProgressCount",{count:l.taskSummary.inProgress.length}),color:"indigo",items:l.taskSummary.inProgress.map(Y=>({id:Y.id,label:Y.title,sub:Y.agent}))}),l.taskSummary.blocked.length>0&&t.jsx(wd,{title:n("taskSummary.blockedCount",{count:l.taskSummary.blocked.length}),color:"amber",items:l.taskSummary.blocked.map(Y=>({id:Y.id,label:Y.title,sub:Y.reason||Y.agent}))}),l.taskSummary.completed.length===0&&l.taskSummary.inProgress.length===0&&l.taskSummary.blocked.length===0&&t.jsx("p",{className:"text-sm text-fg-tertiary",children:n("taskSummary.noTasksInPeriod")})]})]})]}):null),S==="generate"&&t.jsxs("section",{className:"bg-surface-elevated rounded-xl overflow-hidden",children:[t.jsx("div",{className:"px-5 py-4 border-b border-border-default",children:t.jsx("h3",{className:"text-sm font-semibold text-fg-secondary",children:n("perAgentUsage.title")})}),v.length===0?t.jsx("div",{className:"p-8 text-center text-fg-tertiary text-sm",children:n("perAgentUsage.noData")}):t.jsx("div",{className:"overflow-x-auto",children:t.jsxs("table",{className:"w-full",children:[t.jsx("thead",{children:t.jsxs("tr",{className:"border-b border-border-default text-xs text-fg-tertiary uppercase tracking-wider",children:[t.jsx("th",{className:"px-4 py-3 text-left font-medium",children:n("perAgentUsage.agent")}),t.jsx(l0,{label:n("perAgentUsage.totalTokens"),col:"totalTokens",current:C,desc:j,onSort:ne}),t.jsx(l0,{label:n("perAgentUsage.today"),col:"tokensUsedToday",current:C,desc:j,onSort:ne}),t.jsx(l0,{label:n("perAgentUsage.requests"),col:"requestCount",current:C,desc:j,onSort:ne}),t.jsx(l0,{label:n("perAgentUsage.toolCalls"),col:"toolCalls",current:C,desc:j,onSort:ne}),t.jsx(l0,{label:n("perAgentUsage.estCost"),col:"estimatedCost",current:C,desc:j,onSort:ne,align:"right"})]})}),t.jsx("tbody",{children:V.map(Y=>t.jsx(Gde,{agent:Y,maxTokens:Q},Y.agentId))}),t.jsx("tfoot",{children:t.jsxs("tr",{className:"border-t border-border-default bg-surface-elevated/30",children:[t.jsx("td",{className:"px-4 py-3 text-sm font-medium text-fg-secondary",children:n("perAgentUsage.totalAgents",{count:v.length})}),t.jsx("td",{className:"px-4 py-3 text-sm font-medium text-fg-secondary tabular-nums",children:Do(v.reduce((Y,oe)=>Y+oe.totalTokens,0))}),t.jsx("td",{className:"px-4 py-3 text-sm font-medium text-fg-secondary tabular-nums",children:Do(K)}),t.jsx("td",{className:"px-4 py-3 text-sm font-medium text-fg-secondary tabular-nums",children:v.reduce((Y,oe)=>Y+oe.requestCount,0)}),t.jsx("td",{className:"px-4 py-3 text-sm font-medium text-fg-secondary tabular-nums",children:v.reduce((Y,oe)=>Y+oe.toolCalls,0)}),t.jsx("td",{className:"px-4 py-3 text-sm font-medium text-right text-fg-secondary tabular-nums",children:Ed(X)})]})})]})})]})]})})}function Xi({label:e,value:n,color:r}){return t.jsxs("div",{className:"text-center",children:[t.jsx("div",{className:`text-2xl font-bold ${r}`,children:n}),t.jsx("div",{className:"text-[10px] text-fg-tertiary mt-0.5",children:e})]})}function wd({title:e,color:n,items:r}){return t.jsxs("div",{className:"min-w-0 overflow-hidden",children:[t.jsx("div",{className:`text-xs font-medium text-${n}-400 mb-1.5`,children:e}),t.jsx("div",{className:"space-y-1.5",children:r.map((s,a)=>t.jsxs("div",{className:`text-sm text-fg-secondary min-w-0 ${s.id?"cursor-pointer hover:text-fg-primary group":""}`,onClick:s.id?()=>Rt.navigate(Be.WORK,{openTask:s.id}):void 0,children:[t.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[t.jsx("span",{className:`w-1.5 h-1.5 rounded-full bg-${n}-500 shrink-0`}),t.jsx("span",{className:`truncate min-w-0 ${s.id?"group-hover:text-brand-500 transition-colors":""}`,children:s.label})]}),s.sub&&s.sub!=="unassigned"&&t.jsx("div",{className:"text-[10px] text-fg-tertiary ml-3.5 mt-0.5 break-all line-clamp-2",children:s.sub})]},s.id??a))})]})}function ah({label:e,value:n,color:r}){return t.jsxs("div",{className:"bg-surface-elevated rounded-xl p-5",children:[t.jsx("div",{className:"text-sm text-fg-secondary mb-2",children:e}),t.jsx("div",{className:`text-2xl font-bold ${r}`,children:n})]})}function l0({label:e,col:n,current:r,desc:s,onSort:a,align:i}){const l=r===n?s?"↓":"↑":"↕",c=r===n?"text-brand-500":"text-fg-muted";return t.jsxs("th",{className:`px-4 py-3 ${i==="right"?"text-right":"text-left"} font-medium cursor-pointer select-none hover:text-fg-secondary`,onClick:()=>a(n),children:[e,t.jsx("span",{className:`ml-1 ${c}`,children:l})]})}function Gde({agent:e,maxTokens:n}){const r=n>0?Math.min(100,e.totalTokens/n*100):0,s=e.status==="working"?"bg-blue-500":e.status==="idle"?"bg-green-500":e.status==="error"?"bg-red-500":"bg-gray-600";return t.jsxs("tr",{className:"border-b border-border-default/50 hover:bg-surface-elevated/30 transition-colors cursor-pointer",onClick:()=>Rt.navigate(Be.TEAM,{selectAgent:e.agentId}),children:[t.jsx("td",{className:"px-4 py-3",children:t.jsxs("div",{className:"flex items-center gap-2.5",children:[t.jsx("div",{className:`w-2 h-2 rounded-full ${s}`}),t.jsxs("div",{children:[t.jsx("div",{className:"text-sm font-medium text-fg-primary hover:text-brand-500 transition-colors",children:e.agentName}),t.jsx("div",{className:"text-xs text-fg-tertiary",children:e.role})]})]})}),t.jsx("td",{className:"px-4 py-3",children:t.jsxs("div",{className:"flex items-center gap-3",children:[t.jsx("div",{className:"flex-1 bg-surface-elevated rounded-full h-1.5 overflow-hidden max-w-[120px]",children:t.jsx("div",{className:"h-full bg-brand-500 rounded-full",style:{width:`${r}%`}})}),t.jsx("span",{className:"text-sm text-fg-secondary tabular-nums",children:Do(e.totalTokens)})]})}),t.jsx("td",{className:"px-4 py-3 text-sm text-fg-secondary tabular-nums",children:Do(e.tokensUsedToday)}),t.jsx("td",{className:"px-4 py-3 text-sm text-fg-secondary tabular-nums",children:e.requestCount}),t.jsx("td",{className:"px-4 py-3 text-sm text-fg-secondary tabular-nums",children:e.toolCalls}),t.jsx("td",{className:"px-4 py-3 text-sm text-right text-fg-secondary tabular-nums",children:Ed(e.estimatedCost)})]})}const ih={urgent:"bg-red-500",high:"bg-amber-500",normal:"bg-blue-500",low:"bg-gray-400"},kd={approval_request:"M9 12l2 2 4-4 M21 12a9 9 0 1 1-18 0 9 9 0 0 1 18 0z",task_completed:"M22 11.08V12a10 10 0 1 1-5.93-9.14 M22 4L12 14.01l-3-3",task_created:"M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z M14 2v6h6 M16 13H8 M16 17H8 M10 9H8",task_review:"M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z M14 2v6h6 M16 13H8 M16 17H8 M10 9H8",task_failed:"M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z M14 2v6h6 M16 13H8 M16 17H8 M10 9H8",requirement_created:"M11 4H4a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2v-7 M18.5 2.5a2.121 2.121 0 0 1 3 3L12 15l-4 1 1-4 9.5-9.5z",requirement_decision:"M12 22s8-4 8-10V5l-8-3-8 3v7c0 6 8 10 8 10z",agent_report:"M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z M14 2v6h6 M16 13H8 M16 17H8",direct_message:"M21 15a2 2 0 0 1-2 2H7l-4 4V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2z",group_message:"M17 21v-2a4 4 0 0 0-4-4H5a4 4 0 0 0-4 4v2 M9 7a4 4 0 1 0 0-8 4 4 0 0 0 0 8z M23 21v-2a4 4 0 0 0-3-3.87 M16 3.13a4 4 0 0 1 0 7.75",system:"M12 22s8-4 8-10V5l-8-3-8 3v7c0 6 8 10 8 10z"},o6={approval_request:"text-amber-500",task_completed:"text-green-500",task_failed:"text-red-500",task_created:"text-blue-500",task_review:"text-purple-500",requirement_created:"text-amber-500",requirement_decision:"text-green-500",agent_report:"text-blue-500",direct_message:"text-green-500",group_message:"text-brand-500",system:"text-fg-tertiary"};function Nd(e,n){const r=Date.now()-new Date(e).getTime(),s=Math.floor(r/6e4);if(s<1)return n("common:time.now");if(s<60)return n("common:time.minutesAgo",{count:s});const a=Math.floor(s/60);return a<24?n("common:time.hoursAgo",{count:a}):n("common:time.daysAgo",{count:Math.floor(a/24)})}function oh(e,n){const r=e.actionType;if(r==="open_chat")return n("team:notifications.actionHints.openChat");if(r==="navigate")return n("team:notifications.actionHints.viewDetails");const s=e.metadata??{};switch(e.type){case"task_completed":case"task_created":case"task_review":case"task_failed":return s.taskId?n("team:notifications.actionHints.viewTask"):null;case"requirement_created":case"requirement_decision":return s.requirementId?n("team:notifications.actionHints.viewRequirement"):null;case"agent_report":return s.agentId?n("team:notifications.actionHints.viewAgent"):null;case"direct_message":return n("team:notifications.actionHints.openChat");case"group_message":return n("team:notifications.actionHints.openChat");case"approval_request":return n("team:notifications.actionHints.viewApproval");default:return s.taskId?n("team:notifications.actionHints.viewTask"):s.requirementId?n("team:notifications.actionHints.viewRequirement"):s.agentId?n("team:notifications.actionHints.viewAgent"):null}}function Yde(){try{const e=new AudioContext,n=e.currentTime,r=e.createGain();r.connect(e.destination),r.gain.setValueAtTime(.15,n),r.gain.exponentialRampToValueAtTime(.01,n+.6);const s=e.createOscillator();s.type="sine",s.frequency.setValueAtTime(880,n),s.frequency.setValueAtTime(1174.66,n+.15),s.connect(r),s.start(n),s.stop(n+.6),s.onended=()=>e.close()}catch{}}function sA({collapsed:e,userId:n,embeddedMode:r,onClose:s,sidebarMode:a,isActive:i,label:l,iconPath:c}){const{t:u}=ht(["team","common"]),[m,f]=g.useState(!1),[p,b]=g.useState("approvals"),[x,v]=g.useState([]),[N,C]=g.useState([]),[k,j]=g.useState(null),[w,S]=g.useState(null),[T,R]=g.useState({}),[I,P]=g.useState(0),L=g.useRef(null),M=g.useRef(null),[$,U]=g.useState({top:0,left:0,width:448,maxHeight:576}),z=g.useRef(null),A=g.useRef(!1),[H,D]=g.useState(!0),[O,q]=g.useState(!1),J=g.useRef(null),B=g.useRef("approvals"),V=30,X=g.useCallback(async()=>{try{const[W,re]=await Promise.all([ae.notifications.list(n,!1,{limit:V,offset:0}),ae.approvals.list()]);if(v(W.notifications),P(W.unreadCount??W.notifications.filter(Ae=>!Ae.read).length),D(W.totalCount!=null?W.notifications.length<W.totalCount:W.notifications.length>=V),C(re.approvals),!A.current){const Ae=re.approvals.filter(xe=>xe.status==="pending").length;z.current=Ae,A.current=!0}}catch{}},[n]),K=g.useCallback(async()=>{if(!(O||!H)){q(!0);try{const W=await ae.notifications.list(n,!1,{limit:V,offset:x.length});W.notifications.length>0&&v(re=>[...re,...W.notifications.filter(Ae=>!re.some(xe=>xe.id===Ae.id))]),D(W.totalCount!=null?x.length+W.notifications.length<W.totalCount:W.notifications.length>=V)}catch{}q(!1)}},[n,x.length,O,H]),ee=g.useCallback(W=>{const re=W.detail;if(!re)return;const{taskId:Ae,requirementId:xe}=re;!Ae&&!xe||v(tt=>{const vt=tt.filter(xt=>!xt.read&&(Ae&&xt.metadata?.taskId===Ae||xe&&xt.metadata?.requirementId===xe));if(vt.length===0)return tt;for(const xt of vt)ae.notifications.markRead(xt.id).catch(()=>{});return P(xt=>Math.max(0,xt-vt.length)),tt.map(xt=>vt.some(Me=>Me.id===xt.id)?{...xt,read:!0}:xt)})},[]);g.useEffect(()=>{X();const W=setInterval(X,6e4),re=()=>X(),Ae=()=>{f(!0),X()};window.addEventListener("markus:notifications-changed",re),window.addEventListener("markus:mark-read-by-ref",ee),window.addEventListener("markus:open-notifications",Ae);const xe=Tn.on("notification:created",()=>X()),tt=Tn.on("approval:created",()=>X());return()=>{clearInterval(W),window.removeEventListener("markus:notifications-changed",re),window.removeEventListener("markus:mark-read-by-ref",ee),window.removeEventListener("markus:open-notifications",Ae),xe(),tt()}},[X,ee]);const Q=g.useCallback(()=>{if(!L.current)return;const W=L.current.getBoundingClientRect(),re=window.innerWidth,Ae=window.innerHeight,xe=Math.min(448,re-16),tt=Math.min(576,Ae-16);let vt=W.right+8,xt=W.top;vt+xe>re-8&&(vt=Math.max(8,re-xe-8)),xt+tt>Ae-8&&(xt=Math.max(8,Ae-tt-8)),U({top:xt,left:vt,width:xe,maxHeight:tt})},[]);g.useLayoutEffect(()=>{m&&Q()},[m,Q]),g.useEffect(()=>{if(m)return window.addEventListener("resize",Q),()=>window.removeEventListener("resize",Q)},[m,Q]),g.useEffect(()=>{if(!m)return;const W=re=>{L.current?.contains(re.target)||M.current?.contains(re.target)||f(!1)};return document.addEventListener("mousedown",W),()=>document.removeEventListener("mousedown",W)},[m]),g.useEffect(()=>{if(!m)return;const W=N.some(Ae=>Ae.status==="pending"),re=x.some(Ae=>!Ae.read);b(W&&!re?"approvals":!W&&re?"notifications":B.current)},[m]);const ne=new Set(N.filter(W=>W.status==="pending").map(W=>W.id)),te=new Set(N.map(W=>W.id)),Y=x.filter(W=>!(W.type==="approval_request"&&W.metadata?.approvalId&&te.has(W.metadata.approvalId))),oe=x.filter(W=>W.type==="approval_request"&&!W.read&&W.metadata?.approvalId&&ne.has(W.metadata.approvalId)).length,ge=Math.max(0,I-oe),ye=ne.size,we=ge+ye;g.useEffect(()=>{z.current!==null&&ye>z.current&&Yde(),z.current=ye},[ye]);const Ce=async W=>{await ae.notifications.markRead(W),v(re=>re.map(Ae=>Ae.id===W?{...Ae,read:!0}:Ae)),P(re=>Math.max(0,re-1))},ie=W=>{const re=W.metadata??{},Ae=W.actionType,xe=W.actionTarget;if(Ae==="open_chat"&&xe)try{const tt=typeof xe=="string"?JSON.parse(xe):xe;if(tt.agentId){const vt={agentId:tt.agentId};tt.sessionId&&(vt.sessionId=tt.sessionId),Rt.navigate(Be.TEAM,vt);return}}catch{}if(Ae==="navigate"&&xe)try{const tt=typeof xe=="string"?JSON.parse(xe):xe;if(tt.path){if(tt.path.startsWith("/team")){const vt={},xt=new URLSearchParams(tt.path.split("?")[1]||"");for(const[Me,Ke]of xt.entries())vt[Me]=Ke;Rt.navigate(Be.TEAM,vt);return}if(tt.path.startsWith("/work")){const vt={},xt=new URLSearchParams(tt.path.split("?")[1]||"");for(const[Me,Ke]of xt.entries())vt[Me]=Ke;Rt.navigate(Be.WORK,vt);return}}}catch{}switch(W.type){case"approval_request":{const tt=re.approvalId,vt=tt?N.find(Re=>Re.id===tt):void 0,xt=vt?.details?.taskId??re.taskId,Me=vt?.details?.requirementId??re.requirementId,Ke=vt?.details?.agentId??vt?.agentId;xt?Rt.navigate(Be.WORK,{openTask:xt}):Me?Rt.navigate(Be.WORK,{openRequirement:Me}):Ke?Rt.navigate(Be.TEAM,{agentId:Ke}):Rt.navigate(Be.WORK);break}case"task_completed":case"task_created":case"task_review":case"task_failed":re.taskId?Rt.navigate(Be.WORK,{openTask:re.taskId}):Rt.navigate(Be.WORK);break;case"requirement_created":case"requirement_decision":re.requirementId?Rt.navigate(Be.WORK,{openRequirement:re.requirementId}):Rt.navigate(Be.WORK);break;case"agent_report":case"system":{if(re.agentId){const tt={agentId:re.agentId};re.sessionId&&(tt.sessionId=re.sessionId),Rt.navigate(Be.TEAM,tt)}else Rt.navigate(Be.TEAM);break}case"direct_message":{const tt=re.senderId;tt?Rt.navigate(Be.TEAM,{dm:tt}):Rt.navigate(Be.TEAM);break}case"group_message":{const tt=re.channel;tt?Rt.navigate(Be.TEAM,{channel:tt}):Rt.navigate(Be.TEAM);break}default:re.taskId?Rt.navigate(Be.WORK,{openTask:re.taskId}):re.requirementId?Rt.navigate(Be.WORK,{openRequirement:re.requirementId}):re.projectId?Rt.navigate(Be.WORK,{projectId:re.projectId}):re.agentId&&Rt.navigate(Be.TEAM,{agentId:re.agentId});break}},Te=async W=>{W.read||Ce(W.id);const re=W.metadata??{},Ae=re.taskId,xe=re.requirementId;if(Ae||xe){const tt=x.filter(vt=>vt.id!==W.id&&!vt.read&&(Ae&&vt.metadata?.taskId===Ae||xe&&vt.metadata?.requirementId===xe));for(const vt of tt)Ce(vt.id)}ie(W)},ue=async(W,re,Ae,xe)=>{j(W);try{const{approval:tt}=await ae.approvals.respond(W,re,n,Ae,xe);C(Ke=>Ke.map(Re=>Re.id===W?tt:Re)),S(null),R(Ke=>{const Re={...Ke};return delete Re[W],Re});const vt=tt.details?.taskId,xt=tt.details?.requirementId,Me=x.filter(Ke=>!Ke.read&&(Ke.type==="approval_request"&&Ke.metadata?.approvalId===W||vt&&Ke.metadata?.taskId===vt||xt&&Ke.metadata?.requirementId===xt));if(Me.length>0){for(const Re of Me)ae.notifications.markRead(Re.id).catch(()=>{});const Ke=new Set(Me.map(Re=>Re.id));v(Re=>Re.map(qe=>Ke.has(qe.id)?{...qe,read:!0}:qe)),P(Re=>Math.max(0,Re-Me.length))}na("/approvals"),na("/notifications"),na("/tasks"),na("/taskboard"),na("/requirements"),window.dispatchEvent(new CustomEvent("markus:data-changed")),window.dispatchEvent(new CustomEvent("markus:notifications-changed")),setTimeout(()=>X(),800)}catch{}j(null)},Le=async()=>{try{if(!n)return;await ae.notifications.markAllRead(n),v(W=>W.map(re=>({...re,read:!0}))),P(0),na("/notifications")}catch{const W=Y.filter(re=>!re.read);await Promise.all(W.map(re=>ae.notifications.markRead(re.id))),v(re=>re.map(Ae=>({...Ae,read:!0}))),P(0),na("/notifications")}},$e=W=>{const re=W.details?.subType;return re==="requirement_resubmit"?u("team:notifications.approvalType.requirementResubmit"):re==="requirement"||W.details?.requirementId?u("team:notifications.approvalType.requirement"):re==="task_review"?u("team:notifications.approvalType.taskReview"):re==="task"||W.details?.taskId?u("team:notifications.approvalType.task"):W.details?.toolName?u("team:notifications.approvalType.toolExecution"):null},je=W=>{const re=[];re.push(W.agentName);const Ae=W.details?.taskTitle,xe=W.details?.taskId;Ae?re.push(Ae):xe&&re.push(`Task ${xe.slice(0,8)}`);const tt=W.details?.requirementId;return tt&&!xe&&re.push(`Req ${tt.slice(0,8)}`),re.join(" · ")},Ee=[...N].sort((W,re)=>new Date(re.requestedAt).getTime()-new Date(W.requestedAt).getTime()),We=Ee.filter(W=>W.status==="pending"),Ve=Ee.filter(W=>W.status!=="pending"),de=W=>{const re=W.details?.taskId,Ae=W.details?.requirementId,xe=W.details?.agentId??W.agentId;re?Rt.navigate(Be.WORK,{openTask:re}):Ae?Rt.navigate(Be.WORK,{openRequirement:Ae}):xe?Rt.navigate(Be.TEAM,{agentId:xe}):Rt.navigate(Be.WORK)},ve=()=>{f(!1),s?.()},Ne=t.jsxs(t.Fragment,{children:[t.jsxs("div",{className:"flex border-b border-border-default shrink-0",children:[t.jsxs("button",{onClick:()=>{b("approvals"),B.current="approvals"},className:`flex-1 px-3 py-2.5 text-xs font-medium transition-colors ${p==="approvals"?"text-fg-primary border-b-2 border-brand-500":"text-fg-tertiary hover:text-fg-secondary"}`,children:[u("team:notifications.approvals"),ye>0?` (${ye})`:""]}),t.jsxs("button",{onClick:()=>{b("notifications"),B.current="notifications"},className:`flex-1 px-3 py-2.5 text-xs font-medium transition-colors ${p==="notifications"?"text-fg-primary border-b-2 border-brand-500":"text-fg-tertiary hover:text-fg-secondary"}`,children:[u("team:notifications.notifications"),ge>0?` (${ge})`:""]}),t.jsx("button",{onClick:ve,className:"px-2 py-2 text-fg-tertiary hover:text-fg-primary transition-colors shrink-0",title:u("common:close"),children:t.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[t.jsx("path",{d:"M18 6L6 18"}),t.jsx("path",{d:"M6 6l12 12"})]})})]}),p==="notifications"&&I>0&&t.jsx("div",{className:"flex justify-end px-3 py-1.5 border-b border-border-default/50 shrink-0",children:t.jsx("button",{onClick:Le,className:"text-[10px] text-brand-500 hover:text-brand-400 transition-colors",children:u("team:notifications.markAllRead")})}),t.jsxs("div",{ref:J,className:"flex-1 overflow-y-auto",onScroll:W=>{if(p!=="notifications"||!H||O)return;const re=W.currentTarget;re.scrollTop+re.clientHeight>=re.scrollHeight-80&&K()},children:[p==="approvals"&&(N.length===0?t.jsx("div",{className:"p-6 text-center text-xs text-fg-tertiary",children:u("team:notifications.noApprovals")}):t.jsxs("div",{className:"divide-y divide-border-default/50",children:[We.map(W=>{const re=W.details?.command,Ae=re?W.description.replace(/\s*Command:.*$/,""):W.description;return t.jsxs("div",{className:"px-3 py-3 space-y-2.5",children:[t.jsxs("div",{className:"cursor-pointer hover:bg-surface-overlay/50 -mx-3 -mt-3 px-3 pt-3 pb-1 rounded-t-md transition-colors",onClick:()=>de(W),children:[t.jsxs("div",{className:"flex items-start gap-2",children:[t.jsx("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",className:"text-amber-500 mt-0.5 shrink-0",children:t.jsx("path",{d:kd.approval_request})}),t.jsxs("div",{className:"flex-1 min-w-0",children:[t.jsxs("div",{className:"flex items-center gap-2",children:[$e(W)&&t.jsx("span",{className:"text-[10px] text-amber-500 font-medium shrink-0",children:$e(W)}),t.jsx("span",{className:"text-xs text-fg-primary font-medium truncate",children:W.title}),t.jsx("span",{className:"text-[10px] text-fg-tertiary shrink-0",children:Nd(W.requestedAt,u)})]}),t.jsx("div",{className:"text-[11px] text-fg-tertiary mt-0.5",children:W.agentName})]})]}),t.jsx("div",{className:"mt-2.5 text-[11px] text-fg-secondary leading-relaxed",children:t.jsx(fs,{content:Ae,className:"text-[11px] [&_h1]:text-xs [&_h2]:text-[11px] [&_h3]:text-[11px] [&_p]:text-[11px] [&_li]:text-[11px]"})}),re&&t.jsx("pre",{className:"text-[11px] text-fg-primary bg-surface-overlay border border-border-default rounded-md px-2.5 py-2 overflow-x-auto whitespace-pre-wrap break-all font-mono leading-relaxed mt-2",children:re})]}),(()=>{const xe=W.details?.subType,tt=xe==="task"||xe==="requirement"||xe==="requirement_resubmit",vt=W.options&&W.options.length>0,xt=(T[W.id]??"").trim();return vt?t.jsxs("div",{className:"space-y-1.5",children:[W.options.map((Me,Ke)=>t.jsxs("button",{disabled:k===W.id,onClick:()=>ue(W.id,Me.id!=="reject",xt||void 0,Me.id),className:`w-full px-3 py-2 text-left text-[11px] font-medium rounded-md disabled:opacity-50 transition-colors flex items-center gap-2 ${Me.id==="reject"||Me.id==="request_changes"?"border border-border-default text-fg-secondary hover:bg-surface-overlay":"bg-brand-600 text-white hover:bg-brand-700"}`,title:Me.description,children:[t.jsx("span",{className:"w-5 h-5 rounded-full bg-white/20 flex items-center justify-center text-[10px] font-bold shrink-0",children:String.fromCharCode(65+Ke)}),Me.label]},Me.id)),t.jsxs("div",{className:"flex gap-1.5 mt-1",children:[t.jsx("input",{type:"text",placeholder:u("team:notifications.freeformPlaceholder"),value:T[W.id]??"",onChange:Me=>R(Ke=>({...Ke,[W.id]:Me.target.value})),onKeyDown:Me=>{Me.key==="Enter"&&(T[W.id]??"").trim()&&ue(W.id,!0,(T[W.id]??"").trim(),"custom")},className:"flex-1 px-2.5 py-1.5 text-[11px] bg-surface-overlay border border-border-default rounded-md text-fg-primary placeholder:text-fg-tertiary focus:outline-none focus:ring-1 focus:ring-brand-500/50"}),t.jsx("button",{disabled:k===W.id||!(T[W.id]??"").trim(),onClick:()=>ue(W.id,!0,(T[W.id]??"").trim(),"custom"),className:"px-2.5 py-1.5 text-[11px] font-medium bg-brand-600 text-white rounded-md hover:bg-brand-700 disabled:opacity-50 transition-colors",children:u("common:send")})]})]}):tt?t.jsxs("div",{className:"space-y-1.5",children:[t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsxs("button",{disabled:k===W.id,onClick:()=>ue(W.id,!0,void 0,"approve"),className:"px-3 py-1.5 text-[11px] font-medium bg-green-600 text-white rounded-md hover:bg-green-700 disabled:opacity-50 transition-colors inline-flex items-center gap-1.5",children:[t.jsx("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round",children:t.jsx("path",{d:"M20 6L9 17l-5-5"})}),u("common:approve")]}),t.jsxs("button",{disabled:k===W.id,onClick:()=>ue(W.id,!1,void 0,"reject"),className:"px-3 py-1.5 text-[11px] font-medium bg-red-600/80 text-white rounded-md hover:bg-red-700 disabled:opacity-50 transition-colors inline-flex items-center gap-1.5",children:[t.jsxs("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round",children:[t.jsx("path",{d:"M18 6L6 18"}),t.jsx("path",{d:"M6 6l12 12"})]}),u("common:reject")]}),w!==W.id&&t.jsxs("button",{disabled:k===W.id,onClick:()=>S(W.id),className:"px-3 py-1.5 text-[11px] font-medium border border-amber-500/50 text-amber-500 rounded-md hover:bg-amber-500/10 disabled:opacity-50 transition-colors inline-flex items-center gap-1.5",children:[t.jsxs("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[t.jsx("path",{d:"M11 4H4a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2v-7"}),t.jsx("path",{d:"M18.5 2.5a2.121 2.121 0 0 1 3 3L12 15l-4 1 1-4 9.5-9.5z"})]}),u("team:notifications.needsAdjustment")]})]}),w===W.id&&t.jsxs("div",{className:"space-y-1.5",children:[t.jsx("input",{type:"text",autoFocus:!0,placeholder:u("team:notifications.adjustmentPlaceholder"),value:T[W.id]??"",onChange:Me=>R(Ke=>({...Ke,[W.id]:Me.target.value})),onKeyDown:Me=>{Me.key==="Enter"&&(T[W.id]??"").trim()&&ue(W.id,!1,(T[W.id]??"").trim(),"needs_adjustment"),Me.key==="Escape"&&S(null)},className:"w-full px-2.5 py-1.5 text-[11px] bg-surface-overlay border border-border-default rounded-md text-fg-primary placeholder:text-fg-tertiary focus:outline-none focus:ring-1 focus:ring-amber-500/50"}),t.jsxs("div",{className:"flex gap-2",children:[t.jsx("button",{disabled:k===W.id||!(T[W.id]??"").trim(),onClick:()=>ue(W.id,!1,(T[W.id]??"").trim(),"needs_adjustment"),className:"px-2.5 py-1.5 text-[11px] font-medium bg-amber-600 text-white rounded-md hover:bg-amber-700 disabled:opacity-50 transition-colors",children:u("team:notifications.confirmAdjustment")}),t.jsx("button",{onClick:()=>S(null),className:"px-2.5 py-1.5 text-[11px] font-medium border border-border-default text-fg-secondary rounded-md hover:bg-surface-overlay transition-colors",children:u("common:cancel")})]})]})]}):t.jsxs("div",{className:"space-y-1.5",children:[t.jsx("input",{type:"text",placeholder:u("team:notifications.commentPlaceholder"),value:T[W.id]??"",onChange:Me=>R(Ke=>({...Ke,[W.id]:Me.target.value})),onKeyDown:Me=>{Me.key==="Enter"&&ue(W.id,!0,xt||void 0,"approve")},className:"w-full px-2.5 py-1.5 text-[11px] bg-surface-overlay border border-border-default rounded-md text-fg-primary placeholder:text-fg-tertiary focus:outline-none focus:ring-1 focus:ring-brand-500/50"}),t.jsxs("div",{className:"flex gap-2",children:[t.jsx("button",{disabled:k===W.id,onClick:()=>ue(W.id,!0,xt||void 0,"approve"),className:"flex-1 px-2.5 py-1.5 text-[11px] font-medium bg-green-600 text-white rounded-md hover:bg-green-700 disabled:opacity-50 transition-colors",children:u("common:approve")}),t.jsx("button",{disabled:k===W.id,onClick:()=>ue(W.id,!1,xt||void 0,"reject"),className:"flex-1 px-2.5 py-1.5 text-[11px] font-medium border border-border-default text-fg-secondary rounded-md hover:bg-surface-overlay disabled:opacity-50 transition-colors",children:u("common:reject")})]})]})})()]},W.id)}),Ve.length>0&&t.jsxs(t.Fragment,{children:[We.length>0&&t.jsx("div",{className:"px-3 py-1.5 text-[10px] font-medium text-fg-tertiary uppercase tracking-wider bg-surface-overlay/30",children:u("team:notifications.approvalHistory")}),Ve.slice(0,50).map(W=>t.jsxs("button",{onClick:()=>de(W),className:"w-full text-left px-3 py-2.5 hover:bg-surface-overlay/50 transition-colors group",children:[t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx("span",{className:`w-1.5 h-1.5 rounded-full shrink-0 ${W.status==="approved"?"bg-green-500":W.status==="cancelled"||W.status==="expired"?"bg-gray-400":"bg-red-500"}`}),$e(W)&&t.jsx("span",{className:"text-[10px] text-fg-tertiary font-medium shrink-0",children:$e(W)}),t.jsx("span",{className:"text-xs text-fg-secondary truncate flex-1 group-hover:text-fg-primary",children:W.title}),t.jsx("span",{className:`text-[10px] font-medium shrink-0 ${W.status==="approved"?"text-green-500":W.status==="cancelled"||W.status==="expired"?"text-fg-muted":"text-red-500"}`,children:u(`common:status.${W.status}`,{defaultValue:W.status})})]}),t.jsxs("div",{className:"flex items-center gap-1.5 mt-0.5 pl-3.5",children:[t.jsx("span",{className:"text-[10px] text-fg-muted truncate",children:je(W)}),t.jsx("span",{className:"text-[10px] text-fg-muted shrink-0",children:"·"}),t.jsx("span",{className:"text-[10px] text-fg-muted shrink-0",children:Nd(W.respondedAt??W.requestedAt,u)})]}),W.responseComment&&t.jsxs("p",{className:"text-[10px] text-fg-muted mt-0.5 pl-3.5 truncate",children:["“",W.responseComment,"”"]})]},W.id))]})]})),p==="notifications"&&(Y.length===0?t.jsx("div",{className:"p-6 text-center text-xs text-fg-tertiary",children:u("team:notifications.noNotifications")}):t.jsxs("div",{className:"divide-y divide-border-default/50",children:[Y.map(W=>{const re=o6[W.type]??"text-fg-tertiary";return t.jsxs("div",{role:"button",tabIndex:0,onClick:()=>Te(W),onKeyDown:Ae=>{(Ae.key==="Enter"||Ae.key===" ")&&(Ae.preventDefault(),Te(W))},className:`w-full text-left px-3 py-2.5 flex gap-2.5 transition-colors cursor-pointer ${W.read?"opacity-50 hover:opacity-70":"hover:bg-surface-overlay"}`,children:[t.jsx("div",{className:"shrink-0 mt-0.5",children:t.jsx("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",className:re,children:t.jsx("path",{d:kd[W.type]??kd.system})})}),t.jsxs("div",{className:"flex-1 min-w-0",children:[t.jsxs("div",{className:"flex items-center gap-1.5",children:[!W.read&&t.jsx("span",{className:`w-1.5 h-1.5 rounded-full shrink-0 ${ih[W.priority]??ih.normal}`}),t.jsx("span",{className:"text-xs text-fg-primary font-medium truncate",children:W.title})]}),t.jsx("div",{className:"text-[11px] text-fg-tertiary mt-0.5 ",children:t.jsx(fs,{content:W.body,className:"text-[11px] [&_h1]:text-xs [&_h2]:text-[11px] [&_h3]:text-[11px] [&_p]:text-[11px] [&_li]:text-[11px] [&_p]:text-fg-tertiary"})}),t.jsxs("div",{className:"flex items-center gap-2 mt-0.5",children:[t.jsx("span",{className:"text-[10px] text-fg-muted",children:Nd(W.createdAt,u)}),oh(W,u)&&t.jsx("span",{className:`text-[10px] font-medium ${re}`,children:oh(W,u)})]})]})]},W.id)}),O&&t.jsx("div",{className:"py-3 text-center",children:t.jsxs("svg",{className:"animate-spin h-4 w-4 text-fg-tertiary mx-auto",viewBox:"0 0 24 24",fill:"none",children:[t.jsx("circle",{className:"opacity-25",cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"4"}),t.jsx("path",{className:"opacity-75",fill:"currentColor",d:"M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4z"})]})})]}))]})]});if(r){const W=["approvals","notifications"],re=W.indexOf(p),Ae=(()=>{let xe=0,tt=0;return{onTouchStart:vt=>{xe=vt.touches[0].clientX,tt=vt.touches[0].clientY},onTouchEnd:vt=>{const xt=vt.changedTouches[0].clientX-xe,Me=vt.changedTouches[0].clientY-tt;Math.abs(xt)>60&&Math.abs(xt)>Math.abs(Me)*1.5&&(xt<0&&re<W.length-1&&b(W[re+1]),xt>0&&re>0&&b(W[re-1]))}}})();return t.jsxs("div",{className:"flex flex-col h-full overflow-hidden",children:[t.jsx("div",{className:"flex border-b border-border-default shrink-0",children:W.map(xe=>t.jsx("button",{onClick:()=>b(xe),className:`flex-1 px-3 py-3 text-sm font-medium transition-colors ${p===xe?"text-fg-primary border-b-2 border-brand-500":"text-fg-tertiary"}`,children:xe==="approvals"?t.jsxs(t.Fragment,{children:[u("team:notifications.approvals"),ye>0?` (${ye})`:""]}):t.jsxs(t.Fragment,{children:[u("team:notifications.notifications"),ge>0?` (${ge})`:""]})},xe))}),p==="notifications"&&I>0&&t.jsx("div",{className:"flex justify-end px-3 py-1.5 border-b border-border-default/50 shrink-0",children:t.jsx("button",{onClick:Le,className:"text-[10px] text-brand-500 hover:text-brand-400 transition-colors",children:u("team:notifications.markAllRead")})}),t.jsx("div",{className:"flex-1 overflow-hidden relative",...Ae,children:t.jsxs("div",{className:"flex h-full transition-transform duration-300 ease-out",style:{transform:`translateX(-${re*100}%)`},children:[t.jsx("div",{className:"w-full shrink-0 h-full overflow-y-auto scrollbar-thin",children:N.length===0?t.jsx("div",{className:"p-6 text-center text-xs text-fg-tertiary",children:u("team:notifications.noApprovals")}):t.jsxs("div",{className:"divide-y divide-border-default/50",children:[We.map(xe=>{const tt=xe.details?.command,vt=tt?xe.description.replace(/\s*Command:.*$/,""):xe.description;return t.jsxs("div",{className:"px-3 py-3 space-y-2.5",children:[t.jsxs("div",{className:"cursor-pointer hover:bg-surface-overlay/50 -mx-3 -mt-3 px-3 pt-3 pb-1 rounded-t-md transition-colors",onClick:()=>de(xe),children:[t.jsxs("div",{className:"flex items-start gap-2",children:[t.jsx("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",className:"text-amber-500 mt-0.5 shrink-0",children:t.jsx("path",{d:kd.approval_request})}),t.jsxs("div",{className:"flex-1 min-w-0",children:[t.jsxs("div",{className:"flex items-center gap-2",children:[$e(xe)&&t.jsx("span",{className:"text-[10px] text-amber-500 font-medium shrink-0",children:$e(xe)}),t.jsx("span",{className:"text-xs text-fg-primary font-medium truncate",children:xe.title}),t.jsx("span",{className:"text-[10px] text-fg-tertiary shrink-0",children:Nd(xe.requestedAt,u)})]}),t.jsx("div",{className:"text-[11px] text-fg-tertiary mt-0.5",children:xe.agentName})]})]}),t.jsx("div",{className:"mt-2.5 text-[11px] text-fg-secondary leading-relaxed",children:t.jsx(fs,{content:vt,className:"text-[11px] [&_h1]:text-xs [&_h2]:text-[11px] [&_h3]:text-[11px] [&_p]:text-[11px] [&_li]:text-[11px]"})}),tt&&t.jsx("pre",{className:"text-[11px] text-fg-primary bg-surface-overlay border border-border-default rounded-md px-2.5 py-2 overflow-x-auto whitespace-pre-wrap break-all font-mono leading-relaxed mt-2",children:tt})]}),(()=>{const xt=xe.details?.subType,Me=xt==="task"||xt==="requirement"||xt==="requirement_resubmit",Ke=xe.options&&xe.options.length>0,Re=(T[xe.id]??"").trim();return Ke?t.jsxs("div",{className:"space-y-1.5",children:[xe.options.map((qe,ct)=>t.jsxs("button",{disabled:k===xe.id,onClick:()=>ue(xe.id,qe.id!=="reject",Re||void 0,qe.id),className:`w-full px-3 py-2 text-left text-[11px] font-medium rounded-md disabled:opacity-50 transition-colors flex items-center gap-2 ${qe.id==="reject"||qe.id==="request_changes"?"border border-border-default text-fg-secondary hover:bg-surface-overlay":"bg-brand-600 text-white hover:bg-brand-700"}`,title:qe.description,children:[t.jsx("span",{className:"w-5 h-5 rounded-full bg-white/20 flex items-center justify-center text-[10px] font-bold shrink-0",children:String.fromCharCode(65+ct)}),qe.label]},qe.id)),t.jsxs("div",{className:"flex gap-1.5 mt-1",children:[t.jsx("input",{type:"text",placeholder:u("team:notifications.freeformPlaceholder"),value:T[xe.id]??"",onChange:qe=>R(ct=>({...ct,[xe.id]:qe.target.value})),onKeyDown:qe=>{qe.key==="Enter"&&(T[xe.id]??"").trim()&&ue(xe.id,!0,(T[xe.id]??"").trim(),"custom")},className:"flex-1 px-2.5 py-1.5 text-[11px] bg-surface-overlay border border-border-default rounded-md text-fg-primary placeholder:text-fg-tertiary focus:outline-none focus:ring-1 focus:ring-brand-500/50"}),t.jsx("button",{disabled:k===xe.id||!(T[xe.id]??"").trim(),onClick:()=>ue(xe.id,!0,(T[xe.id]??"").trim(),"custom"),className:"px-2.5 py-1.5 text-[11px] font-medium bg-brand-600 text-white rounded-md hover:bg-brand-700 disabled:opacity-50 transition-colors",children:u("common:send")})]})]}):Me?t.jsxs("div",{className:"space-y-1.5",children:[t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsxs("button",{disabled:k===xe.id,onClick:()=>ue(xe.id,!0,void 0,"approve"),className:"px-3 py-1.5 text-[11px] font-medium bg-green-600 text-white rounded-md hover:bg-green-700 disabled:opacity-50 transition-colors inline-flex items-center gap-1.5",children:[t.jsx("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round",children:t.jsx("path",{d:"M20 6L9 17l-5-5"})}),u("common:approve")]}),t.jsxs("button",{disabled:k===xe.id,onClick:()=>ue(xe.id,!1,void 0,"reject"),className:"px-3 py-1.5 text-[11px] font-medium bg-red-600/80 text-white rounded-md hover:bg-red-700 disabled:opacity-50 transition-colors inline-flex items-center gap-1.5",children:[t.jsxs("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round",children:[t.jsx("path",{d:"M18 6L6 18"}),t.jsx("path",{d:"M6 6l12 12"})]}),u("common:reject")]}),w!==xe.id&&t.jsxs("button",{disabled:k===xe.id,onClick:()=>S(xe.id),className:"px-3 py-1.5 text-[11px] font-medium border border-amber-500/50 text-amber-500 rounded-md hover:bg-amber-500/10 disabled:opacity-50 transition-colors inline-flex items-center gap-1.5",children:[t.jsxs("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[t.jsx("path",{d:"M11 4H4a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2v-7"}),t.jsx("path",{d:"M18.5 2.5a2.121 2.121 0 0 1 3 3L12 15l-4 1 1-4 9.5-9.5z"})]}),u("team:notifications.needsAdjustment")]})]}),w===xe.id&&t.jsxs("div",{className:"space-y-1.5",children:[t.jsx("input",{type:"text",autoFocus:!0,placeholder:u("team:notifications.adjustmentPlaceholder"),value:T[xe.id]??"",onChange:qe=>R(ct=>({...ct,[xe.id]:qe.target.value})),onKeyDown:qe=>{qe.key==="Enter"&&(T[xe.id]??"").trim()&&ue(xe.id,!1,(T[xe.id]??"").trim(),"needs_adjustment"),qe.key==="Escape"&&S(null)},className:"w-full px-2.5 py-1.5 text-[11px] bg-surface-overlay border border-border-default rounded-md text-fg-primary placeholder:text-fg-tertiary focus:outline-none focus:ring-1 focus:ring-amber-500/50"}),t.jsxs("div",{className:"flex gap-2",children:[t.jsx("button",{disabled:k===xe.id||!(T[xe.id]??"").trim(),onClick:()=>ue(xe.id,!1,(T[xe.id]??"").trim(),"needs_adjustment"),className:"px-2.5 py-1.5 text-[11px] font-medium bg-amber-600 text-white rounded-md hover:bg-amber-700 disabled:opacity-50 transition-colors",children:u("team:notifications.confirmAdjustment")}),t.jsx("button",{onClick:()=>S(null),className:"px-2.5 py-1.5 text-[11px] font-medium border border-border-default text-fg-secondary rounded-md hover:bg-surface-overlay transition-colors",children:u("common:cancel")})]})]})]}):t.jsxs("div",{className:"space-y-1.5",children:[t.jsx("input",{type:"text",placeholder:u("team:notifications.commentPlaceholder"),value:T[xe.id]??"",onChange:qe=>R(ct=>({...ct,[xe.id]:qe.target.value})),onKeyDown:qe=>{qe.key==="Enter"&&ue(xe.id,!0,Re||void 0,"approve")},className:"w-full px-2.5 py-1.5 text-[11px] bg-surface-overlay border border-border-default rounded-md text-fg-primary placeholder:text-fg-tertiary focus:outline-none focus:ring-1 focus:ring-brand-500/50"}),t.jsxs("div",{className:"flex gap-2",children:[t.jsx("button",{disabled:k===xe.id,onClick:()=>ue(xe.id,!0,Re||void 0,"approve"),className:"flex-1 px-2.5 py-1.5 text-[11px] font-medium bg-green-600 text-white rounded-md hover:bg-green-700 disabled:opacity-50 transition-colors",children:u("common:approve")}),t.jsx("button",{disabled:k===xe.id,onClick:()=>ue(xe.id,!1,Re||void 0,"reject"),className:"flex-1 px-2.5 py-1.5 text-[11px] font-medium border border-border-default text-fg-secondary rounded-md hover:bg-surface-overlay disabled:opacity-50 transition-colors",children:u("common:reject")})]})]})})()]},xe.id)}),Ve.length>0&&t.jsxs(t.Fragment,{children:[We.length>0&&t.jsx("div",{className:"px-3 py-1.5 text-[10px] font-medium text-fg-tertiary uppercase tracking-wider bg-surface-overlay/30",children:u("team:notifications.approvalHistory")}),Ve.slice(0,50).map(xe=>t.jsxs("button",{onClick:()=>de(xe),className:"w-full text-left px-3 py-2.5 hover:bg-surface-overlay/50 transition-colors",children:[t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx("span",{className:`w-1.5 h-1.5 rounded-full shrink-0 ${xe.status==="approved"?"bg-green-500":xe.status==="cancelled"||xe.status==="expired"?"bg-gray-400":"bg-red-500"}`}),t.jsx("span",{className:"text-xs text-fg-secondary truncate flex-1",children:xe.title}),t.jsx("span",{className:`text-[10px] font-medium shrink-0 ${xe.status==="approved"?"text-green-500":xe.status==="cancelled"||xe.status==="expired"?"text-fg-muted":"text-red-500"}`,children:u(`common:status.${xe.status}`,{defaultValue:xe.status})})]}),t.jsxs("div",{className:"flex items-center gap-1.5 mt-0.5 pl-3.5",children:[t.jsx("span",{className:"text-[10px] text-fg-muted truncate",children:je(xe)}),t.jsx("span",{className:"text-[10px] text-fg-muted shrink-0",children:"·"}),t.jsx("span",{className:"text-[10px] text-fg-muted shrink-0",children:Nd(xe.respondedAt??xe.requestedAt,u)})]})]},xe.id))]})]})}),t.jsx("div",{className:"w-full shrink-0 h-full overflow-y-auto scrollbar-thin",children:Y.length===0?t.jsx("div",{className:"p-6 text-center text-xs text-fg-tertiary",children:u("team:notifications.noNotifications")}):t.jsx("div",{className:"divide-y divide-border-default/50",children:Y.slice(0,50).map(xe=>{const tt=o6[xe.type]??"text-fg-tertiary";return t.jsxs("button",{onClick:()=>Te(xe),className:`w-full text-left px-3 py-2.5 flex gap-2.5 transition-colors ${xe.read?"opacity-50 hover:opacity-70":"hover:bg-surface-overlay"}`,children:[t.jsx("div",{className:"shrink-0 mt-0.5",children:t.jsx("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",className:tt,children:t.jsx("path",{d:kd[xe.type]??kd.system})})}),t.jsxs("div",{className:"flex-1 min-w-0",children:[t.jsxs("div",{className:"flex items-center gap-1.5",children:[!xe.read&&t.jsx("span",{className:`w-1.5 h-1.5 rounded-full shrink-0 ${ih[xe.priority]??ih.normal}`}),t.jsx("span",{className:"text-xs text-fg-primary font-medium truncate",children:xe.title})]}),t.jsx("div",{className:"text-[11px] text-fg-tertiary mt-0.5 ",children:t.jsx(fs,{content:xe.body,className:"text-[11px] [&_h1]:text-xs [&_h2]:text-[11px] [&_h3]:text-[11px] [&_p]:text-[11px] [&_li]:text-[11px] [&_p]:text-fg-tertiary"})}),t.jsxs("div",{className:"flex items-center gap-2 mt-0.5",children:[t.jsx("span",{className:"text-[10px] text-fg-muted",children:Nd(xe.createdAt,u)}),oh(xe,u)&&t.jsx("span",{className:`text-[10px] font-medium ${tt}`,children:oh(xe,u)})]})]})]},xe.id)})})})]})})]})}if(a){const W=c||"M18 8A6 6 0 0 0 6 8c0 7-3 9-3 9h18s-3-2-3-9 M13.73 21a2 2 0 0 1-3.46 0";return t.jsxs(t.Fragment,{children:[t.jsxs("button",{ref:L,onClick:()=>{f(!m),m||X()},title:e?l||u("team:notifications.bellTitle"):void 0,className:`w-full flex items-center ${e?"flex-col justify-center px-1 py-1.5 gap-0.5":"gap-3 px-3 py-[7px]"} rounded-lg text-[13px] font-medium mb-0.5 transition-colors relative text-fg-primary ${m||i?"bg-surface-overlay":"hover:bg-surface-overlay/60"}`,children:[t.jsx("svg",{width:e?16:18,height:e?16:18,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.75",strokeLinecap:"round",strokeLinejoin:"round",className:"shrink-0",children:t.jsx("path",{d:W})}),e?t.jsx("span",{className:"text-[9px] leading-tight truncate w-full text-center",children:l}):t.jsx("span",{className:"truncate",children:l}),we>0&&t.jsx("span",{className:`absolute ${e?"top-0.5 right-1":"top-1 left-[22px]"} min-w-[16px] h-4 px-1 rounded-full bg-red-500 text-white text-[10px] font-bold flex items-center justify-center leading-none`,children:we>99?u("common:badgeOverLimit"):we})]}),m&&ao.createPortal(t.jsx("div",{ref:M,className:"fixed bg-surface-secondary border border-border-default rounded-xl shadow-2xl z-[9999] flex flex-col overflow-hidden",style:{top:$.top,left:$.left,width:$.width,maxHeight:$.maxHeight},children:Ne}),document.body)]})}return t.jsxs(t.Fragment,{children:[t.jsxs("button",{ref:L,onClick:()=>{f(!m),m||X()},className:`relative flex items-center justify-center rounded-md transition-colors ${e?"w-8 h-8":"w-7 h-7"} ${m?"bg-surface-overlay text-fg-primary":"text-fg-tertiary hover:text-fg-secondary hover:bg-surface-overlay"}`,title:u("team:notifications.bellTitle"),children:[t.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[t.jsx("path",{d:"M18 8A6 6 0 0 0 6 8c0 7-3 9-3 9h18s-3-2-3-9"}),t.jsx("path",{d:"M13.73 21a2 2 0 0 1-3.46 0"})]}),we>0&&t.jsx("span",{className:"absolute -top-0.5 -right-0.5 min-w-[16px] h-4 px-1 rounded-full bg-red-500 text-white text-[10px] font-bold flex items-center justify-center leading-none",children:we>99?u("common:badgeOverLimit"):we})]}),m&&ao.createPortal(t.jsx("div",{ref:M,className:"fixed bg-surface-secondary border border-border-default rounded-xl shadow-2xl z-[9999] flex flex-col overflow-hidden",style:{top:$.top,left:$.left,width:$.width,maxHeight:$.maxHeight},children:Ne}),document.body)]})}function Xde({authUser:e}){const{t:n}=ht("nav"),r=ea();return t.jsxs("div",{className:"flex-1 flex flex-col overflow-hidden",children:[t.jsxs("div",{className:"flex items-center gap-2 px-4 h-14",children:[r&&t.jsx(Ac,{}),t.jsx("h2",{className:"text-base font-bold",children:n("notifications")})]}),t.jsx("div",{className:"flex-1 overflow-hidden",children:t.jsx(sA,{collapsed:!1,userId:e?.id,embeddedMode:!0})})]})}function Qde(){const{t:e}=ht(["common","home","work"]),[n,r]=g.useState(""),[s,a]=g.useState("all"),[i,l]=g.useState({agents:[],tasks:[],requirements:[],projects:[],deliverables:[],workflows:[]}),[c,u]=g.useState(!1),[m,f]=g.useState(!1),p=g.useRef(null),b=g.useRef(void 0);g.useEffect(()=>{setTimeout(()=>p.current?.focus(),100)},[]);const x=g.useCallback(async k=>{if(!k.trim()){l({agents:[],tasks:[],requirements:[],projects:[],deliverables:[],workflows:[]}),f(!1);return}u(!0),f(!0);const j=k.toLowerCase();try{const[w,S,T,R,I,P]=await Promise.allSettled([ae.agents.list(),ae.tasks.list({search:k,pageSize:20}),ae.requirements.list(),ae.projects.list(),ae.deliverables.search({q:k,limit:20}),ae.teams.list()]),L=w.status==="fulfilled"?w.value.agents.filter(H=>H.name?.toLowerCase().includes(j)||H.role?.toLowerCase().includes(j)):[],M=S.status==="fulfilled"?S.value.tasks:[],$=T.status==="fulfilled"?T.value.requirements.filter(H=>H.title?.toLowerCase().includes(j)||H.description?.toLowerCase().includes(j)):[],U=R.status==="fulfilled"?R.value.projects.filter(H=>H.name?.toLowerCase().includes(j)||H.description?.toLowerCase().includes(j)):[],z=I.status==="fulfilled"?I.value.results:[],A=[];if(P.status==="fulfilled"){const H=await Promise.allSettled(P.value.teams.map(D=>ae.workflows.list(D.id)));for(const D of H)if(D.status==="fulfilled")for(const O of D.value.workflows)(O.name.toLowerCase().includes(j)||(O.displayName||"").toLowerCase().includes(j)||O.description?.toLowerCase().includes(j))&&A.push(O)}l({agents:L,tasks:M,requirements:$,projects:U,deliverables:z,workflows:A})}catch{l({agents:[],tasks:[],requirements:[],projects:[],deliverables:[],workflows:[]})}finally{u(!1)}},[]),v=k=>{r(k),b.current&&clearTimeout(b.current),b.current=setTimeout(()=>x(k),400)},N=[{id:"all",label:e("common:all",{defaultValue:"全部"})},{id:"agents",label:e("common:agents",{defaultValue:"智能体"})},{id:"tasks",label:e("common:tasks",{defaultValue:"任务"})},{id:"requirements",label:e("common:requirements",{defaultValue:"需求"})},{id:"projects",label:e("common:projects",{defaultValue:"项目"})},{id:"deliverables",label:e("common:deliverables",{defaultValue:"交付物"})},{id:"workflows",label:e("common:workflows",{defaultValue:"工作流"})}],C=i.agents.length>0||i.tasks.length>0||i.requirements.length>0||i.projects.length>0||i.deliverables.length>0||i.workflows.length>0;return t.jsxs("div",{className:"flex-1 flex flex-col overflow-hidden",children:[t.jsxs("div",{className:"shrink-0 px-4 pt-4 pb-2 space-y-3",children:[t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx("button",{onClick:()=>Rt.navigate(Be.HOME),className:"p-1.5 rounded-lg hover:bg-surface-overlay transition-colors shrink-0",children:t.jsxs("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[t.jsx("path",{d:"M19 12H5"}),t.jsx("polyline",{points:"12 19 5 12 12 5"})]})}),t.jsxs("div",{className:"flex-1 relative",children:[t.jsxs("svg",{className:"absolute left-3 top-1/2 -translate-y-1/2 text-fg-tertiary",width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[t.jsx("circle",{cx:"11",cy:"11",r:"8"}),t.jsx("line",{x1:"21",y1:"21",x2:"16.65",y2:"16.65"})]}),t.jsx("input",{ref:p,value:n,onChange:k=>v(k.target.value),placeholder:e("common:search"),className:"w-full bg-surface-elevated border border-border-default rounded-xl pl-9 pr-3 py-2.5 text-sm text-fg-primary placeholder:text-fg-tertiary focus:border-brand-500 focus:outline-none transition-colors"}),n&&t.jsx("button",{onClick:()=>{r(""),l({agents:[],tasks:[],requirements:[],projects:[],deliverables:[],workflows:[]}),f(!1),p.current?.focus()},className:"absolute right-3 top-1/2 -translate-y-1/2 text-fg-tertiary hover:text-fg-secondary",children:t.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[t.jsx("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),t.jsx("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]})})]})]}),t.jsx("div",{className:"flex gap-1 overflow-x-auto scrollbar-hide",children:N.map(k=>t.jsx("button",{onClick:()=>a(k.id),className:`px-3 py-1.5 text-xs rounded-lg whitespace-nowrap transition-colors ${s===k.id?"bg-brand-600 text-white":"bg-surface-elevated text-fg-secondary hover:text-fg-primary"}`,children:k.label},k.id))})]}),t.jsxs("div",{className:"flex-1 overflow-y-auto px-4 pb-4",children:[c&&t.jsx("div",{className:"flex items-center justify-center py-12",children:t.jsx("div",{className:"text-fg-tertiary text-sm animate-pulse",children:e("common:loading")})}),!c&&m&&!C&&t.jsxs("div",{className:"flex flex-col items-center justify-center py-12 text-center",children:[t.jsxs("svg",{width:"40",height:"40",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.5",className:"text-fg-tertiary mb-3",children:[t.jsx("circle",{cx:"11",cy:"11",r:"8"}),t.jsx("line",{x1:"21",y1:"21",x2:"16.65",y2:"16.65"})]}),t.jsx("p",{className:"text-sm text-fg-tertiary",children:e("common:noResults",{defaultValue:"没有找到相关结果"})})]}),!c&&C&&t.jsxs("div",{className:"space-y-4",children:[(s==="all"||s==="agents")&&i.agents.length>0&&t.jsxs("section",{children:[t.jsx("h3",{className:"text-xs font-medium text-fg-tertiary uppercase mb-2",children:e("common:agents",{defaultValue:"智能体"})}),t.jsx("div",{className:"space-y-1",children:(s==="all"?i.agents.slice(0,8):i.agents).map(k=>t.jsxs("button",{onClick:()=>Rt.navigate(Be.TEAM,{agentId:k.id}),className:"w-full flex items-center gap-3 px-3 py-2.5 rounded-xl hover:bg-surface-overlay transition-colors text-left",children:[t.jsx(_r,{name:k.name||"Agent",avatarUrl:k.avatarUrl,size:32}),t.jsxs("div",{className:"flex-1 min-w-0",children:[t.jsx("div",{className:"text-sm font-medium text-fg-primary truncate",children:k.name}),t.jsx("div",{className:"text-xs text-fg-tertiary truncate",children:k.role||k.status})]}),t.jsx(Zde,{status:k.status})]},k.id))}),s==="all"&&i.agents.length>8&&t.jsxs("button",{onClick:()=>a("agents"),className:"mt-1 w-full text-xs text-brand-500 hover:text-brand-400 py-1.5 rounded-lg hover:bg-surface-overlay transition-colors",children:[e("common:showAll",{defaultValue:"查看全部"})," (",i.agents.length,")"]})]}),(s==="all"||s==="tasks")&&i.tasks.length>0&&t.jsxs("section",{children:[t.jsx("h3",{className:"text-xs font-medium text-fg-tertiary uppercase mb-2",children:e("common:tasks",{defaultValue:"任务"})}),t.jsx("div",{className:"space-y-1",children:(s==="all"?i.tasks.slice(0,8):i.tasks).map(k=>t.jsxs("button",{onClick:()=>Rt.navigate(Be.WORK,{openTask:k.id}),className:"w-full flex items-center gap-3 px-3 py-2.5 rounded-xl hover:bg-surface-overlay transition-colors text-left",children:[t.jsx(Jde,{status:k.status}),t.jsxs("div",{className:"flex-1 min-w-0",children:[t.jsx("div",{className:"text-sm text-fg-primary truncate",children:k.title}),t.jsxs("div",{className:"text-xs text-fg-tertiary truncate",children:[k.status," · ",k.priority||""]})]})]},k.id))}),s==="all"&&i.tasks.length>8&&t.jsxs("button",{onClick:()=>a("tasks"),className:"mt-1 w-full text-xs text-brand-500 hover:text-brand-400 py-1.5 rounded-lg hover:bg-surface-overlay transition-colors",children:[e("common:showAll",{defaultValue:"查看全部"})," (",i.tasks.length,")"]})]}),(s==="all"||s==="requirements")&&i.requirements.length>0&&t.jsxs("section",{children:[t.jsx("h3",{className:"text-xs font-medium text-fg-tertiary uppercase mb-2",children:e("common:requirements",{defaultValue:"需求"})}),t.jsx("div",{className:"space-y-1",children:(s==="all"?i.requirements.slice(0,8):i.requirements).map(k=>t.jsxs("button",{onClick:()=>Rt.navigate(Be.WORK,{openRequirement:k.id}),className:"w-full flex items-center gap-3 px-3 py-2.5 rounded-xl hover:bg-surface-overlay transition-colors text-left",children:[t.jsx("div",{className:`w-8 h-8 rounded-lg flex items-center justify-center shrink-0 ${k.status==="approved"?"text-green-500 bg-green-500/15":k.status==="pending"?"text-amber-500 bg-amber-500/15":k.status==="rejected"?"text-red-500 bg-red-500/15":"text-fg-tertiary bg-surface-elevated"}`,children:t.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[t.jsx("path",{d:"M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z"}),t.jsx("polyline",{points:"14 2 14 8 20 8"}),t.jsx("line",{x1:"16",y1:"13",x2:"8",y2:"13"}),t.jsx("line",{x1:"16",y1:"17",x2:"8",y2:"17"})]})}),t.jsxs("div",{className:"flex-1 min-w-0",children:[t.jsx("div",{className:"text-sm text-fg-primary truncate",children:k.title}),t.jsxs("div",{className:"text-xs text-fg-tertiary truncate",children:[k.status," · ",k.priority||""]})]})]},k.id))}),s==="all"&&i.requirements.length>8&&t.jsxs("button",{onClick:()=>a("requirements"),className:"mt-1 w-full text-xs text-brand-500 hover:text-brand-400 py-1.5 rounded-lg hover:bg-surface-overlay transition-colors",children:[e("common:showAll",{defaultValue:"查看全部"})," (",i.requirements.length,")"]})]}),(s==="all"||s==="projects")&&i.projects.length>0&&t.jsxs("section",{children:[t.jsx("h3",{className:"text-xs font-medium text-fg-tertiary uppercase mb-2",children:e("common:projects",{defaultValue:"项目"})}),t.jsx("div",{className:"space-y-1",children:(s==="all"?i.projects.slice(0,8):i.projects).map(k=>t.jsxs("button",{onClick:()=>Rt.navigate(Be.WORK,{projectId:k.id}),className:"w-full flex items-center gap-3 px-3 py-2.5 rounded-xl hover:bg-surface-overlay transition-colors text-left",children:[t.jsx("div",{className:"w-8 h-8 rounded-lg bg-brand-500/15 flex items-center justify-center shrink-0",children:t.jsx("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",className:"text-brand-500",children:t.jsx("path",{d:"M22 19a2 2 0 0 1-2 2H4a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h5l2 3h9a2 2 0 0 1 2 2z"})})}),t.jsxs("div",{className:"flex-1 min-w-0",children:[t.jsx("div",{className:"text-sm text-fg-primary truncate",children:k.name}),k.description&&t.jsx("div",{className:"text-xs text-fg-tertiary truncate",children:k.description})]})]},k.id))}),s==="all"&&i.projects.length>8&&t.jsxs("button",{onClick:()=>a("projects"),className:"mt-1 w-full text-xs text-brand-500 hover:text-brand-400 py-1.5 rounded-lg hover:bg-surface-overlay transition-colors",children:[e("common:showAll",{defaultValue:"查看全部"})," (",i.projects.length,")"]})]}),(s==="all"||s==="deliverables")&&i.deliverables.length>0&&t.jsxs("section",{children:[t.jsx("h3",{className:"text-xs font-medium text-fg-tertiary uppercase mb-2",children:e("common:deliverables",{defaultValue:"交付物"})}),t.jsx("div",{className:"space-y-1",children:(s==="all"?i.deliverables.slice(0,8):i.deliverables).map(k=>t.jsxs("button",{onClick:()=>Rt.navigate(Be.DELIVERABLES,{openDeliverable:k.id}),className:"w-full flex items-center gap-3 px-3 py-2.5 rounded-xl hover:bg-surface-overlay transition-colors text-left",children:[t.jsx("div",{className:"w-8 h-8 rounded-lg bg-purple-500/15 flex items-center justify-center shrink-0",children:t.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",className:"text-purple-500",children:[t.jsx("path",{d:"M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z"}),t.jsx("polyline",{points:"14 2 14 8 20 8"})]})}),t.jsxs("div",{className:"flex-1 min-w-0",children:[t.jsx("div",{className:"text-sm text-fg-primary truncate",children:k.title}),t.jsxs("div",{className:"text-xs text-fg-tertiary truncate",children:[k.type," · ",k.status]})]})]},k.id))}),s==="all"&&i.deliverables.length>8&&t.jsxs("button",{onClick:()=>a("deliverables"),className:"mt-1 w-full text-xs text-brand-500 hover:text-brand-400 py-1.5 rounded-lg hover:bg-surface-overlay transition-colors",children:[e("common:showAll",{defaultValue:"查看全部"})," (",i.deliverables.length,")"]})]}),(s==="all"||s==="workflows")&&i.workflows.length>0&&t.jsxs("section",{children:[t.jsx("h3",{className:"text-xs font-medium text-fg-tertiary uppercase mb-2",children:e("common:workflows",{defaultValue:"工作流"})}),t.jsx("div",{className:"space-y-1",children:(s==="all"?i.workflows.slice(0,8):i.workflows).map(k=>t.jsxs("button",{onClick:()=>Rt.navigate(Be.WORK,{boardType:"workflows"}),className:"w-full flex items-center gap-3 px-3 py-2.5 rounded-xl hover:bg-surface-overlay transition-colors text-left",children:[t.jsx("div",{className:"w-8 h-8 rounded-lg bg-teal-500/15 flex items-center justify-center shrink-0",children:t.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",className:"text-teal-500",children:[t.jsx("circle",{cx:"12",cy:"12",r:"3"}),t.jsx("path",{d:"M19.4 15a1.65 1.65 0 0 0 .33 1.82l.06.06a2 2 0 0 1 0 2.83 2 2 0 0 1-2.83 0l-.06-.06a1.65 1.65 0 0 0-1.82-.33 1.65 1.65 0 0 0-1 1.51V21a2 2 0 0 1-2 2 2 2 0 0 1-2-2v-.09A1.65 1.65 0 0 0 9 19.4a1.65 1.65 0 0 0-1.82.33l-.06.06a2 2 0 0 1-2.83 0 2 2 0 0 1 0-2.83l.06-.06A1.65 1.65 0 0 0 4.68 15a1.65 1.65 0 0 0-1.51-1H3a2 2 0 0 1-2-2 2 2 0 0 1 2-2h.09A1.65 1.65 0 0 0 4.6 9a1.65 1.65 0 0 0-.33-1.82l-.06-.06a2 2 0 0 1 0-2.83 2 2 0 0 1 2.83 0l.06.06A1.65 1.65 0 0 0 9 4.68a1.65 1.65 0 0 0 1-1.51V3a2 2 0 0 1 2-2 2 2 0 0 1 2 2v.09a1.65 1.65 0 0 0 1 1.51 1.65 1.65 0 0 0 1.82-.33l.06-.06a2 2 0 0 1 2.83 0 2 2 0 0 1 0 2.83l-.06.06A1.65 1.65 0 0 0 19.4 9a1.65 1.65 0 0 0 1.51 1H21a2 2 0 0 1 2 2 2 2 0 0 1-2 2h-.09a1.65 1.65 0 0 0-1.51 1z"})]})}),t.jsxs("div",{className:"flex-1 min-w-0",children:[t.jsx("div",{className:"text-sm text-fg-primary truncate",children:k.displayName||k.name}),t.jsxs("div",{className:"text-xs text-fg-tertiary truncate",children:[k.stepCount," steps · v",k.version]})]})]},k.name))}),s==="all"&&i.workflows.length>8&&t.jsxs("button",{onClick:()=>a("workflows"),className:"mt-1 w-full text-xs text-brand-500 hover:text-brand-400 py-1.5 rounded-lg hover:bg-surface-overlay transition-colors",children:[e("common:showAll",{defaultValue:"查看全部"})," (",i.workflows.length,")"]})]})]}),!c&&!m&&t.jsxs("div",{className:"flex flex-col items-center justify-center py-12 text-center",children:[t.jsxs("svg",{width:"40",height:"40",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.5",className:"text-fg-tertiary mb-3",children:[t.jsx("circle",{cx:"11",cy:"11",r:"8"}),t.jsx("line",{x1:"21",y1:"21",x2:"16.65",y2:"16.65"})]}),t.jsx("p",{className:"text-sm text-fg-tertiary",children:e("common:search")})]})]})]})}function Zde({status:e}){const n=e==="active"||e==="idle"?"bg-green-500":e==="working"||e==="busy"?"bg-blue-500":"bg-gray-400";return t.jsx("span",{className:`w-2 h-2 rounded-full shrink-0 ${n}`})}function Jde({status:e}){const n=e==="completed"?"text-green-500 bg-green-500/15":e==="in_progress"?"text-blue-500 bg-blue-500/15":e==="pending"?"text-amber-500 bg-amber-500/15":"text-fg-tertiary bg-surface-elevated";return t.jsx("div",{className:`w-8 h-8 rounded-lg flex items-center justify-center shrink-0 ${n}`,children:t.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[t.jsx("path",{d:"M9 11l3 3L22 4"}),t.jsx("path",{d:"M21 12v7a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h11"})]})})}function A1({d:e,size:n=18}){return t.jsx("svg",{width:n,height:n,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.75",strokeLinecap:"round",strokeLinejoin:"round",className:"shrink-0",children:t.jsx("path",{d:e})})}function eue({currentPage:e,onNavigate:n,authUser:r,collapsed:s,onToggleCollapse:a}){const{t:i}=ht(["nav","common"]);return t.jsxs("aside",{className:"h-dvh bg-surface-secondary flex flex-col shrink-0 overflow-hidden",children:[t.jsx("div",{className:`flex items-center ${s?"px-2 py-3.5 justify-center":"px-4 h-14 justify-between"}`,children:t.jsxs("button",{onClick:a,title:i(s?"sidebar.expandSidebar":"sidebar.collapseSidebar"),className:"flex items-center gap-2.5 min-w-0 group",children:[t.jsx("img",{src:"/logo.png",alt:"Markus",className:"w-8 h-8 rounded-lg shrink-0"}),!s&&t.jsx("span",{className:"text-[15px] font-bold tracking-tight text-fg-primary whitespace-nowrap",children:"Markus"})]})}),t.jsx("nav",{className:`${s?"p-1":"px-3 py-2"} flex-1 overflow-y-auto scrollbar-thin`,children:hF.map((l,c)=>{const u=pF.filter(f=>f.section===l.key&&f.id!==Be.SETTINGS);if(u.length===0)return null;const m=i(`sections.${l.key}`);return t.jsx("div",{children:t.jsxs("div",{className:c>0?"mt-3":"",children:[!s&&m&&t.jsx("div",{className:"px-3 py-1.5 mb-1 text-[10px] font-semibold text-fg-muted uppercase tracking-[0.1em]",children:m}),s&&c>0&&t.jsx("div",{className:"my-3"}),u.map(f=>{if(f.id===Be.NOTIFICATIONS)return t.jsx(sA,{sidebarMode:!0,collapsed:s,userId:r?.id,label:i(f.id),iconPath:uh[f.id],isActive:e===f.id},f.id);const p=e===f.id;return t.jsxs("button",{onClick:()=>n(f.id),title:s?i(f.id):void 0,className:`w-full flex items-center ${s?"flex-col justify-center px-1 py-1.5 gap-0.5":"gap-3 px-3 py-[7px]"} rounded-lg text-[13px] font-medium mb-0.5 transition-colors text-fg-primary ${p?"bg-surface-overlay":"hover:bg-surface-overlay/60"}`,children:[t.jsx(A1,{d:uh[f.id]??"",size:s?16:18}),s?t.jsx("span",{className:"text-[9px] leading-tight truncate w-full text-center",children:i(f.id)}):t.jsx("span",{className:"truncate",children:i(f.id)})]},f.id)})]})},l.key)})}),t.jsxs("div",{className:`shrink-0 ${s?"p-1":"px-3 pb-2"} flex items-center ${s?"flex-col gap-1":"justify-between"}`,children:[window.markusDesktop&&t.jsx("button",{onClick:()=>window.markusDesktop?.openInBrowser(),title:i("common:openInBrowser","Open in Browser"),className:"flex items-center justify-center w-8 h-8 rounded-lg transition-colors text-fg-secondary hover:bg-surface-overlay/60 hover:text-fg-primary",children:t.jsx(A1,{d:"M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6M15 3h6v6M10 14 21 3",size:16})}),t.jsx("button",{onClick:()=>n(Be.SETTINGS),title:i(Be.SETTINGS),className:"flex items-center justify-center w-8 h-8 rounded-lg transition-colors text-fg-secondary hover:bg-surface-overlay/60 hover:text-fg-primary",children:t.jsx(A1,{d:uh[Be.SETTINGS],size:16})}),!s&&t.jsxs("span",{className:"text-[10px] text-fg-muted select-none",children:["v","0.8.5"]})]})]})}function tue({currentPage:e,onNavigate:n,userId:r}){const{t:s}=ht("nav"),[a,i]=g.useState(0),{counts:l}=OT({enabled:!0}),c=g.useMemo(()=>{let m=0;for(const f of Object.values(l))m+=f;return m},[l]),u=g.useCallback(async()=>{try{const m=await ae.notifications.list(r,!1);i(m.unreadCount??m.notifications.filter(f=>!f.read).length)}catch{}},[r]);return g.useEffect(()=>{u();const m=setInterval(u,15e3),f=()=>u();return window.addEventListener("markus:notifications-changed",f),()=>{clearInterval(m),window.removeEventListener("markus:notifications-changed",f)}},[u]),t.jsx("nav",{className:"fixed bottom-0 left-0 right-0 z-50 bg-surface-secondary flex items-stretch h-14 safe-area-bottom",children:gF.map(m=>{const f=m.group.includes(e),p=m.id===Be.NOTIFICATIONS,b=m.id===Be.TEAM;return t.jsxs("button",{onClick:()=>n(m.id),className:`flex-1 flex flex-col items-center justify-center gap-0.5 transition-colors ${f?"text-fg-primary":"text-fg-tertiary active:text-fg-secondary"}`,children:[t.jsxs("div",{className:"relative",children:[t.jsx("svg",{width:20,height:20,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:f?2:1.75,strokeLinecap:"round",strokeLinejoin:"round",className:"shrink-0",children:t.jsx("path",{d:uh[m.id]})}),p&&a>0&&t.jsx("span",{className:"absolute -top-1.5 -right-2 min-w-[16px] h-4 px-1 flex items-center justify-center bg-red-500 text-white text-[9px] font-bold rounded-full leading-none",children:a>99?"99+":a}),b&&c>0&&t.jsx("span",{className:"absolute -top-1.5 -right-2 min-w-[16px] h-4 px-1 flex items-center justify-center bg-red-500 text-white text-[9px] font-bold rounded-full leading-none",children:c>99?"99+":c})]}),t.jsx("span",{className:`text-[10px] leading-tight ${f?"font-semibold":""}`,children:s(m.id)})]},m.id)})})}const aA=["builder","agents","teams","skills"];function nue(){const e=localStorage.getItem("markus_nav_storeTab");return e&&(localStorage.removeItem("markus_nav_storeTab"),aA.includes(e))?e:"builder"}function rue({authUser:e}){const{t:n}=ht(["nav","common"]),r=g.useMemo(()=>[{id:"builder",label:n("nav:builder")},{id:"agents",label:n("nav:tabs.agents")},{id:"teams",label:n("nav:tabs.teams")},{id:"skills",label:n("nav:tabs.skills")}],[n]),[s,a]=g.useState(nue),i=zl(r,s,a);return g.useEffect(()=>{const l=c=>{const u=c.detail;u.params?.storeTab&&aA.includes(u.params.storeTab)&&a(u.params.storeTab)};return window.addEventListener("markus:navigate",l),()=>window.removeEventListener("markus:navigate",l)},[]),t.jsxs("div",{className:"flex-1 overflow-hidden flex flex-col",onTouchStart:i.onTouchStart,onTouchEnd:i.onTouchEnd,children:[t.jsxs("div",{className:"flex items-center shrink-0 overflow-x-auto scrollbar-hide",children:[t.jsx(Ac,{className:"ml-2"}),r.map(l=>t.jsx("button",{onClick:()=>a(l.id),className:`flex-1 min-w-0 px-3 py-2.5 text-xs font-medium text-center whitespace-nowrap transition-colors border-b-2 ${s===l.id?"border-brand-500 text-brand-500":"border-transparent text-fg-tertiary"}`,children:l.label},l.id))]}),t.jsxs("div",{className:"flex-1 overflow-hidden flex flex-col",children:[s==="builder"&&t.jsx(s8,{}),s==="agents"&&t.jsx(ZT,{authUser:e}),s==="teams"&&t.jsx(t8,{}),s==="skills"&&t.jsx(n8,{})]})]})}const l6="usageType",M1="profile";function sue({onComplete:e,theme:n,onThemeChange:r,skipProfile:s}){const{t:a}=ht(["onboarding","common"]),[i,l]=g.useState(0),[c,u]=g.useState(""),[m,f]=g.useState(""),[p,b]=g.useState(""),[x,v]=g.useState(""),[N,C]=g.useState(!1),[k,j]=g.useState(""),[w,S]=g.useState(!1),[T,R]=g.useState(null);g.useEffect(()=>{ae.auth.me().then(({user:ye})=>{ye.name&&u(ye.name),ye.email&&f(ye.email),ye.avatarUrl&&R(ye.avatarUrl);const we=ye.name||ye.email?.split("@")[0]||"";we&&M(a("usageType.defaultOrgName",{name:we}))}).catch(()=>{}),ae.hubOrgs.invitations().then(ye=>{ye.invitations?.length>0&&D(ye.invitations)}).catch(()=>{})},[]);const[I,P]=g.useState(null),[L,M]=g.useState(""),[$,U]=g.useState(!1),[z,A]=g.useState(!1),[H,D]=g.useState([]),[O,q]=g.useState(null),[J,B]=g.useState(null),[V,X]=g.useState(!0),K=async()=>{if(j(""),!c.trim()){j(a("profile.errors.nameRequired"));return}if(!m.trim()){j(a("profile.errors.emailRequired"));return}if(!/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(m.trim())){j(a("profile.errors.emailInvalid"));return}if(p&&p.length<6){j(a("profile.errors.passwordTooShort"));return}if(p&&p!==x){j(a("profile.errors.passwordMismatch"));return}C(!0);try{await ae.auth.updateProfile(c.trim(),m.trim()),p&&await ae.auth.changePassword("",p),S(!0)}catch{j(a("profile.errors.saveFailed"))}finally{C(!1)}},ee=[{value:"system",label:a("theme.system"),icon:"💻",desc:a("theme.systemDesc")},{value:"light",label:a("theme.light"),icon:"☀️",desc:a("theme.lightDesc")},{value:"dark",label:a("theme.dark"),icon:"🌊",desc:a("theme.darkDesc")},{value:"cyberpunk",label:a("theme.cyberpunk"),icon:"🔮",desc:a("theme.cyberpunkDesc")},{value:"mono",label:a("theme.mono"),icon:"⬛",desc:a("theme.monoDesc")}],Q=[{id:"welcome",title:a("welcome.title"),subtitle:a("welcome.subtitle"),content:t.jsx("p",{className:"text-fg-secondary text-sm leading-relaxed",children:t.jsx(N6,{i18nKey:"welcome.description",ns:"onboarding",components:{strong:t.jsx("strong",{className:"text-fg-primary"})}})})},{id:l6,title:a("usageType.title",{defaultValue:"How will you use Markus?"}),subtitle:a("usageType.subtitle",{defaultValue:"This helps us tailor your experience."}),content:t.jsxs("div",{className:"space-y-4",children:[t.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[t.jsxs("button",{onClick:()=>{P("personal"),A(!0)},className:`flex flex-col items-center gap-3 rounded-xl border-2 p-5 transition-all text-left ${I==="personal"?"border-brand-500 bg-brand-500/10":"border-border-default hover:border-fg-tertiary bg-surface-elevated/30"}`,children:[t.jsx("span",{className:"text-2xl",children:"👤"}),t.jsxs("div",{children:[t.jsx("div",{className:"font-medium text-fg-primary text-sm text-center",children:a("usageType.personal",{defaultValue:"Personal"})}),t.jsx("div",{className:"text-[11px] text-fg-tertiary mt-1 text-center",children:a("usageType.personalDesc",{defaultValue:"Individual use with your own AI agents."})})]})]}),t.jsxs("button",{onClick:()=>{P("organization"),A(!1)},className:`flex flex-col items-center gap-3 rounded-xl border-2 p-5 transition-all text-left ${I==="organization"?"border-brand-500 bg-brand-500/10":"border-border-default hover:border-fg-tertiary bg-surface-elevated/30"}`,children:[t.jsx("span",{className:"text-2xl",children:"🏢"}),t.jsxs("div",{children:[t.jsx("div",{className:"font-medium text-fg-primary text-sm text-center",children:a("usageType.organization",{defaultValue:"Team & Enterprise"})}),t.jsx("div",{className:"text-[11px] text-fg-tertiary mt-1 text-center",children:a("usageType.organizationDesc",{defaultValue:"For teams sharing licenses and collaborating."})})]})]})]}),I==="organization"&&t.jsxs("div",{className:"space-y-4 mt-4",children:[H.length>0&&t.jsxs("div",{className:"space-y-2",children:[t.jsx("div",{className:"text-xs text-fg-tertiary font-medium",children:a("usageType.pendingInvitations")}),H.map(ye=>t.jsxs("div",{className:"flex items-center justify-between px-4 py-3 rounded-xl border border-amber-500/20 bg-amber-500/5",children:[t.jsxs("div",{children:[t.jsx("div",{className:"text-sm font-medium text-fg-primary",children:ye.orgName}),t.jsx("div",{className:"text-[11px] text-fg-tertiary",children:a("usageType.invitedBy",{name:ye.invitedBy})})]}),t.jsx("button",{onClick:async()=>{q(ye.orgId);try{await ae.hubOrgs.acceptInvitation(ye.orgId),B(ye.orgId),A(!0)}catch{}finally{q(null)}},disabled:O===ye.orgId||J===ye.orgId,className:"px-3 py-1.5 text-xs rounded-lg bg-brand-600 hover:bg-brand-500 disabled:opacity-40 text-white transition-colors",children:J===ye.orgId?a("usageType.accepted"):O===ye.orgId?a("usageType.accepting"):a("usageType.acceptAndJoin")})]},ye.orgId)),t.jsx("div",{className:"text-[11px] text-fg-tertiary text-center pt-1",children:a("usageType.orCreateNew")})]}),t.jsxs("div",{className:"space-y-1",children:[t.jsx("label",{className:"text-xs text-fg-tertiary font-medium",children:a("usageType.orgNameLabel")}),t.jsx("input",{type:"text",value:L,onChange:ye=>{M(ye.target.value),A(!1)},placeholder:a("usageType.orgNamePlaceholder"),className:"w-full px-4 py-2.5 bg-surface-elevated border border-border-default rounded-xl text-sm text-fg-primary focus:border-brand-500 outline-none transition-colors"})]}),t.jsx("button",{onClick:async()=>{if(L.trim()){U(!0);try{const we=(await ae.hubOrgs.mine()).orgs?.[0];we?.id&&await ae.hubOrgs.update(we.id,{name:L.trim()}),A(!0)}catch{}finally{U(!1)}}},disabled:$||!L.trim()||z,className:"w-full px-4 py-2.5 bg-brand-600 hover:bg-brand-500 disabled:opacity-40 text-white text-sm rounded-xl transition-colors",children:a($?"common:saving":z?"usageType.orgNameSaved":"usageType.setOrgName")})]})]})},{id:M1,title:a("profile.title"),subtitle:a("profile.subtitle"),content:w?t.jsxs("div",{className:"flex items-center gap-3 bg-green-500/10 border border-green-500/30 rounded-xl p-4",children:[t.jsx("span",{className:"text-green-600 text-lg",children:"✓"}),t.jsxs("div",{children:[t.jsx("div",{className:"text-sm font-medium text-green-600",children:a("profile.saved")}),t.jsxs("div",{className:"text-xs text-fg-secondary mt-0.5",children:[c," · ",m]})]})]}):t.jsxs("div",{className:"space-y-4",children:[t.jsx("div",{className:"flex justify-center",children:t.jsx(R6,{currentUrl:T,name:c,size:64,targetType:"user"})}),t.jsxs("div",{className:"space-y-1",children:[t.jsxs("label",{className:"text-xs text-fg-tertiary font-medium",children:[a("profile.nameLabel")," ",t.jsx("span",{className:"text-red-500",children:"*"})]}),t.jsx("input",{type:"text",value:c,onChange:ye=>u(ye.target.value),placeholder:a("profile.namePlaceholder"),className:"w-full px-4 py-2.5 bg-surface-elevated border border-border-default rounded-xl text-sm text-fg-primary focus:border-brand-500 outline-none transition-colors",autoFocus:!0})]}),t.jsxs("div",{className:"space-y-1",children:[t.jsxs("label",{className:"text-xs text-fg-tertiary font-medium",children:[a("profile.emailLabel")," ",t.jsx("span",{className:"text-red-500",children:"*"})]}),t.jsx("input",{type:"email",value:m,onChange:ye=>f(ye.target.value),placeholder:a("profile.emailPlaceholder"),className:"w-full px-4 py-2.5 bg-surface-elevated border border-border-default rounded-xl text-sm text-fg-primary focus:border-brand-500 outline-none transition-colors"})]}),t.jsxs("div",{className:"space-y-1",children:[t.jsx("label",{className:"text-xs text-fg-tertiary font-medium",children:a("profile.newPasswordLabel")}),t.jsx("input",{type:"password",value:p,onChange:ye=>b(ye.target.value),placeholder:a("profile.newPasswordPlaceholder"),className:"w-full px-4 py-2.5 bg-surface-elevated border border-border-default rounded-xl text-sm text-fg-primary focus:border-brand-500 outline-none transition-colors"})]}),p&&t.jsxs("div",{className:"space-y-1",children:[t.jsx("label",{className:"text-xs text-fg-tertiary font-medium",children:a("profile.confirmPasswordLabel")}),t.jsx("input",{type:"password",value:x,onChange:ye=>v(ye.target.value),placeholder:a("profile.confirmPasswordPlaceholder"),className:"w-full px-4 py-2.5 bg-surface-elevated border border-border-default rounded-xl text-sm text-fg-primary focus:border-brand-500 outline-none transition-colors"})]}),k&&t.jsx("div",{className:"px-3 py-2 bg-red-500/10 border border-red-500/30 rounded-lg text-xs text-red-500",children:k}),t.jsx("button",{onClick:()=>{K()},disabled:N||!c.trim()||!m.trim(),className:"w-full px-4 py-2.5 bg-brand-600 hover:bg-brand-500 disabled:opacity-40 text-white text-sm rounded-xl transition-colors",children:a(N?"common:saving":"profile.saveProfile")})]})},{id:"theme",title:a("theme.title"),subtitle:a("theme.subtitle"),content:t.jsxs("div",{className:"space-y-4",children:[t.jsx("div",{className:"grid grid-cols-3 gap-3",children:ee.map(ye=>t.jsxs("button",{onClick:()=>r(ye.value),className:`flex flex-col items-center gap-2 rounded-xl border-2 p-5 transition-all ${n===ye.value?"border-brand-500 bg-brand-500/10":"border-border-default hover:border-fg-tertiary bg-surface-elevated/30"}`,children:[t.jsx("span",{className:"text-2xl",children:ye.icon}),t.jsx("span",{className:"text-sm font-medium text-fg-primary",children:ye.label}),t.jsx("span",{className:"text-[11px] text-fg-tertiary leading-tight text-center",children:ye.desc})]},ye.value))}),t.jsxs("label",{className:"flex items-center gap-2.5 p-3 bg-surface-elevated/30 rounded-lg cursor-pointer group",children:[t.jsx("input",{type:"checkbox",checked:V,onChange:ye=>X(ye.target.checked),className:"accent-brand-500 shrink-0"}),t.jsx("span",{className:"text-[11px] text-fg-tertiary",children:a("done.telemetry")})]})]})}],ne=s?Q.filter(ye=>ye.id!==M1):Q,te=ne.findIndex(ye=>ye.id===l6),Y=ne.findIndex(ye=>ye.id===M1),oe=()=>{i===te&&te>=0&&!I||i===te&&I==="organization"&&!z||i===Y&&Y>=0&&!w||(i<ne.length-1?l(i+1):(fetch("/api/settings/telemetry",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({enabled:V})}).catch(()=>{}),e()))},ge=ne[i];return t.jsx("div",{className:"min-h-dvh bg-surface-primary flex items-center justify-center p-4",children:t.jsx("div",{className:"w-full max-w-lg",children:t.jsxs("div",{className:"bg-surface-elevated rounded-2xl p-8",children:[t.jsx("div",{className:"flex gap-1.5 mb-8",children:ne.map((ye,we)=>t.jsx("div",{className:`h-1 flex-1 rounded-full transition-colors ${we<=i?"bg-brand-500":"bg-surface-elevated"}`},we))}),t.jsx("h2",{className:"text-2xl font-bold text-fg-primary",children:ge.title}),t.jsx("p",{className:"text-sm text-fg-secondary mt-1 mb-6",children:ge.subtitle}),ge.content,t.jsxs("div",{className:"flex justify-between mt-8",children:[i>0?t.jsx("button",{onClick:()=>l(i-1),className:"px-4 py-2 text-sm text-fg-secondary hover:text-fg-primary transition-colors",children:a("common:back")}):t.jsx("button",{onClick:e,className:"px-4 py-2 text-sm text-fg-tertiary hover:text-fg-secondary transition-colors",children:a("common:skip")}),t.jsxs("div",{className:"flex items-center gap-3",children:[te>=0&&i===te&&!I&&t.jsx("button",{onClick:()=>{P("personal"),A(!0),l(i+1)},className:"px-4 py-2 text-sm text-fg-tertiary hover:text-fg-secondary transition-colors",children:a("common:skip")}),Y>=0&&i===Y&&!w&&t.jsx("button",{onClick:()=>l(i+1),className:"px-4 py-2 text-sm text-fg-tertiary hover:text-fg-secondary transition-colors",children:a("common:skip")}),t.jsx("button",{onClick:oe,disabled:Y>=0&&i===Y&&!w||te>=0&&i===te&&(!I||I==="organization"&&!z),className:`px-6 py-2.5 text-white text-sm rounded-xl transition-colors ${Y>=0&&i===Y&&!w||te>=0&&i===te&&(!I||I==="organization"&&!z)?"bg-brand-600/40 cursor-not-allowed":"bg-brand-600 hover:bg-brand-500"}`,children:i===ne.length-1?a("getStarted"):a("common:next")})]})]})]})})})}function aue({onLogin:e,hasOwner:n,hasMultipleUsers:r}){const{t:s}=ht("auth"),[a,i]=g.useState(null),[l,c]=g.useState(""),[u,m]=g.useState(!1),[f,p]=g.useState(""),[b,x]=g.useState(""),v=async(k,j=!1)=>{c(""),i(k??"hub");try{await ka(k);const w=Ja(),S=lp();if(!w||!S){c(s("login.hubUnavailable"));return}const{user:T,needsOnboarding:R}=await ae.auth.hubLogin(w,S);e(T,R??!1,{fromHub:!0})}catch(w){const S=w instanceof Error?w.message:"";if(!S.includes("cancelled")){if(!j&&Ja())return E0(),v(k,!0);c(S||s("login.hubUnavailable"))}}finally{i(null)}},N=async k=>{if(k.preventDefault(),!(!f.trim()||!b)){c(""),i("local");try{const{user:j,needsOnboarding:w}=await ae.auth.login(f.trim(),b);e(j,w??!1)}catch{c(s("login.invalidCredentials"))}finally{i(null)}}},C=s(n?"login.welcomeBack":"login.getStarted");return t.jsxs("div",{className:"min-h-dvh bg-surface-primary flex flex-col items-center justify-center p-4 relative overflow-hidden",children:[t.jsx("div",{className:"absolute inset-0 bg-[radial-gradient(ellipse_at_top,_var(--tw-gradient-stops))] from-brand-950/50 via-transparent to-transparent"}),t.jsxs("div",{className:"w-full max-w-sm relative z-10 flex-1 flex flex-col justify-center",children:[t.jsxs("div",{className:"text-center mb-8",children:[t.jsx("img",{src:"/logo.png",alt:"Markus",className:"w-14 h-14 mx-auto mb-3 rounded-xl shadow-lg shadow-black/40"}),t.jsx("div",{className:"text-2xl font-extrabold tracking-tight text-fg-primary mb-1",children:"Markus"}),t.jsx("div",{className:"text-sm text-fg-tertiary",children:C})]}),t.jsx("div",{className:"bg-surface-secondary/80 backdrop-blur-sm border border-border-default rounded-2xl p-8 space-y-4 shadow-2xl shadow-black/30",children:u?t.jsxs(t.Fragment,{children:[t.jsxs("form",{onSubmit:N,className:"space-y-3",children:[t.jsx("div",{className:"space-y-1",children:t.jsx("input",{type:"email",value:f,onChange:k=>p(k.target.value),autoComplete:"email",autoFocus:!0,placeholder:s("login.email"),className:"w-full px-4 py-2.5 bg-surface-elevated border border-border-default rounded-xl text-sm text-fg-primary focus:border-brand-500 outline-none transition-colors placeholder:text-fg-tertiary",required:!0})}),t.jsx("div",{className:"space-y-1",children:t.jsx("input",{type:"password",value:b,onChange:k=>x(k.target.value),autoComplete:"current-password",placeholder:s("login.password"),className:"w-full px-4 py-2.5 bg-surface-elevated border border-border-default rounded-xl text-sm text-fg-primary focus:border-brand-500 outline-none transition-colors placeholder:text-fg-tertiary",required:!0})}),l&&t.jsx("div",{className:"px-3 py-2 bg-red-500/10 border border-red-500/30 rounded-lg text-xs text-red-500",children:l}),!r&&t.jsx("p",{className:"text-[11px] text-fg-tertiary",children:s("login.defaultCredentials")}),t.jsx("button",{type:"submit",disabled:a==="local"||!f||!b,className:"w-full py-2.5 bg-brand-600 hover:bg-brand-500 disabled:opacity-50 text-white text-sm font-medium rounded-xl transition-all",children:s(a==="local"?"login.signingIn":"login.signIn")})]}),t.jsx("div",{className:"pt-1 text-center",children:t.jsx("button",{onClick:()=>{m(!1),c("")},className:"text-xs text-fg-tertiary hover:text-fg-secondary transition-colors",children:s("login.backToHub")})})]}):t.jsxs(t.Fragment,{children:[t.jsxs("button",{onClick:()=>v("google"),disabled:!!a,className:"w-full flex items-center justify-center gap-3 py-2.5 px-4 bg-surface-elevated hover:bg-surface-elevated/80 border border-border-default rounded-xl text-sm text-fg-primary font-medium transition-all disabled:opacity-50",children:[t.jsxs("svg",{className:"w-5 h-5",viewBox:"0 0 24 24",children:[t.jsx("path",{fill:"#4285F4",d:"M22.56 12.25c0-.78-.07-1.53-.2-2.25H12v4.26h5.92a5.06 5.06 0 01-2.2 3.32v2.77h3.57c2.08-1.92 3.28-4.74 3.28-8.1z"}),t.jsx("path",{fill:"#34A853",d:"M12 23c2.97 0 5.46-.98 7.28-2.66l-3.57-2.77c-.98.66-2.23 1.06-3.71 1.06-2.86 0-5.29-1.93-6.16-4.53H2.18v2.84C3.99 20.53 7.7 23 12 23z"}),t.jsx("path",{fill:"#FBBC05",d:"M5.84 14.09c-.22-.66-.35-1.36-.35-2.09s.13-1.43.35-2.09V7.07H2.18C1.43 8.55 1 10.22 1 12s.43 3.45 1.18 4.93l2.85-2.22.81-.62z"}),t.jsx("path",{fill:"#EA4335",d:"M12 5.38c1.62 0 3.06.56 4.21 1.64l3.15-3.15C17.45 2.09 14.97 1 12 1 7.7 1 3.99 3.47 2.18 7.07l3.66 2.84c.87-2.6 3.3-4.53 6.16-4.53z"})]}),s(a==="google"?"login.connectingHub":"login.withGoogle")]}),t.jsxs("button",{onClick:()=>v("github"),disabled:!!a,className:"w-full flex items-center justify-center gap-3 py-2.5 px-4 bg-surface-elevated hover:bg-surface-elevated/80 border border-border-default rounded-xl text-sm text-fg-primary font-medium transition-all disabled:opacity-50",children:[t.jsx("svg",{className:"w-5 h-5",viewBox:"0 0 24 24",fill:"currentColor",children:t.jsx("path",{d:"M12 0C5.37 0 0 5.37 0 12c0 5.31 3.435 9.795 8.205 11.385.6.105.825-.255.825-.57 0-.285-.015-1.23-.015-2.235-3.015.555-3.795-.735-4.035-1.41-.135-.345-.72-1.41-1.23-1.695-.42-.225-1.02-.78-.015-.795.945-.015 1.62.87 1.845 1.23 1.08 1.815 2.805 1.305 3.495.99.105-.78.42-1.305.765-1.605-2.67-.3-5.46-1.335-5.46-5.925 0-1.305.465-2.385 1.23-3.225-.12-.3-.54-1.53.12-3.18 0 0 1.005-.315 3.3 1.23.96-.27 1.98-.405 3-.405s2.04.135 3 .405c2.295-1.56 3.3-1.23 3.3-1.23.66 1.65.24 2.88.12 3.18.765.84 1.23 1.905 1.23 3.225 0 4.605-2.805 5.625-5.475 5.925.435.375.81 1.095.81 2.22 0 1.605-.015 2.895-.015 3.3 0 .315.225.69.825.57A12.02 12.02 0 0024 12c0-6.63-5.37-12-12-12z"})}),s(a==="github"?"login.connectingHub":"login.withGithub")]}),t.jsxs("button",{onClick:()=>v("email"),disabled:!!a,className:"w-full flex items-center justify-center gap-3 py-2.5 px-4 bg-surface-elevated hover:bg-surface-elevated/80 border border-border-default rounded-xl text-sm text-fg-primary font-medium transition-all disabled:opacity-50",children:[t.jsx("svg",{className:"w-5 h-5",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:1.5,children:t.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M21.75 6.75v10.5a2.25 2.25 0 01-2.25 2.25h-15a2.25 2.25 0 01-2.25-2.25V6.75m19.5 0A2.25 2.25 0 0019.5 4.5h-15a2.25 2.25 0 00-2.25 2.25m19.5 0v.243a2.25 2.25 0 01-1.07 1.916l-7.5 4.615a2.25 2.25 0 01-2.36 0L3.32 8.91a2.25 2.25 0 01-1.07-1.916V6.75"})}),s(a==="email"?"login.connectingHub":"login.withEmail")]}),t.jsx("p",{className:"text-center text-[11px] text-fg-tertiary pt-1",children:s("login.terms")}),l&&t.jsx("div",{className:"px-3 py-2 bg-red-500/10 border border-red-500/30 rounded-lg text-xs text-red-500",children:l}),t.jsx("div",{className:"pt-1 text-center",children:t.jsx("button",{onClick:()=>m(!0),className:"text-xs text-fg-tertiary hover:text-fg-secondary transition-colors",children:s("login.useLocalAccount")})})]})})]}),t.jsxs("div",{className:"relative z-10 flex flex-wrap items-center justify-center gap-x-5 gap-y-1 py-6 text-[11px] text-fg-tertiary",children:[t.jsx("a",{href:"https://markus.global",target:"_blank",rel:"noopener noreferrer",className:"hover:text-fg-secondary transition-colors",children:"markus.global"}),t.jsx("a",{href:"mailto:business@markus.global",className:"hover:text-fg-secondary transition-colors",children:s("login.contactSales")})]})]})}function iue({token:e,onComplete:n}){const{t:r}=ht("auth"),[s,a]=g.useState(null),[i,l]=g.useState(""),[c,u]=g.useState(""),[m,f]=g.useState(""),[p,b]=g.useState(!1),[x,v]=g.useState(!1),[N,C]=g.useState(!1);g.useEffect(()=>{ae.auth.inviteInfo(e).then(j=>a(j)).catch(()=>C(!0))},[e]);const k=async j=>{if(j.preventDefault(),f(""),i.length<6){f(r("invite.passwordMinLength"));return}if(i!==c){f(r("invite.passwordsDoNotMatch"));return}b(!0);try{await ae.auth.setup(e,i),v(!0),setTimeout(()=>{window.location.hash="",n()},2e3)}catch{f(r("invite.error"))}finally{b(!1)}};return t.jsxs("div",{className:"min-h-dvh bg-surface-primary flex items-center justify-center p-4 relative overflow-hidden",children:[t.jsx("div",{className:"absolute inset-0 bg-[radial-gradient(ellipse_at_top,_var(--tw-gradient-stops))] from-brand-950/50 via-transparent to-transparent"}),t.jsxs("div",{className:"w-full max-w-sm relative z-10",children:[t.jsxs("div",{className:"text-center mb-8",children:[t.jsx("img",{src:"/logo.png",alt:"Markus",className:"w-14 h-14 mx-auto mb-3 rounded-xl shadow-lg shadow-black/40"}),t.jsx("div",{className:"text-2xl font-extrabold tracking-tight text-fg-primary mb-1",children:"Markus"}),t.jsx("div",{className:"text-sm text-fg-tertiary",children:r("invite.subtitle")})]}),t.jsx("div",{className:"bg-surface-secondary/80 backdrop-blur-sm border border-border-default rounded-2xl p-8 space-y-5 shadow-2xl shadow-black/30",children:N?t.jsxs("div",{className:"text-center space-y-3",children:[t.jsx("div",{className:"text-red-500 text-3xl",children:"⚠"}),t.jsx("p",{className:"text-sm text-fg-secondary",children:r("invite.invalidLink")}),t.jsx("button",{onClick:()=>{window.location.hash="",n()},className:"text-sm text-brand-500 hover:text-brand-400",children:r("login.signIn")})]}):x?t.jsxs("div",{className:"text-center space-y-3",children:[t.jsx("div",{className:"text-green-500 text-3xl",children:"✓"}),t.jsx("p",{className:"text-sm text-fg-secondary",children:r("invite.setupComplete")})]}):s?t.jsxs("form",{onSubmit:k,className:"space-y-5",children:[t.jsx("h2",{className:"text-lg font-semibold text-fg-primary text-center",children:r("invite.greeting",{name:s.name})}),t.jsx("p",{className:"text-xs text-fg-tertiary text-center",children:s.email}),t.jsxs("div",{className:"space-y-1",children:[t.jsx("label",{className:"text-xs text-fg-tertiary font-medium",children:r("invite.setPassword")}),t.jsx("input",{type:"password",value:i,onChange:j=>l(j.target.value),autoComplete:"new-password",autoFocus:!0,className:"w-full px-4 py-2.5 bg-surface-elevated border border-border-default rounded-xl text-sm text-fg-primary focus:border-brand-500 outline-none transition-colors",required:!0})]}),t.jsxs("div",{className:"space-y-1",children:[t.jsx("label",{className:"text-xs text-fg-tertiary font-medium",children:r("invite.confirmPassword")}),t.jsx("input",{type:"password",value:c,onChange:j=>u(j.target.value),autoComplete:"new-password",className:"w-full px-4 py-2.5 bg-surface-elevated border border-border-default rounded-xl text-sm text-fg-primary focus:border-brand-500 outline-none transition-colors",required:!0})]}),m&&t.jsx("div",{className:"px-3 py-2 bg-red-500/10 border border-red-500/30 rounded-lg text-xs text-red-500",children:m}),t.jsx("button",{type:"submit",disabled:p||!i||!c,className:"w-full py-2.5 bg-brand-600 hover:bg-brand-500 disabled:opacity-50 text-white text-sm font-medium rounded-xl transition-all shadow-md shadow-brand-900/40 hover:shadow-lg hover:shadow-brand-900/50",children:r(p?"invite.settingUp":"invite.setupAccount")})]}):t.jsx("div",{className:"text-center text-fg-tertiary text-sm animate-pulse py-4",children:"Loading…"})})]})]})}function oue({onComplete:e,isFirstTime:n}){const{t:r}=ht("auth"),[s,a]=g.useState(""),[i,l]=g.useState(""),[c,u]=g.useState(""),[m,f]=g.useState(""),[p,b]=g.useState(!1),x=async v=>{if(v.preventDefault(),f(""),i.length<6){f(r("changePassword.passwordMinLength"));return}if(i!==c){f(r("changePassword.passwordsDoNotMatch"));return}b(!0);try{await ae.auth.changePassword(s,i),e()}catch{f(r("changePassword.failedToChange"))}finally{b(!1)}};return t.jsxs("div",{className:"min-h-dvh bg-surface-primary flex items-center justify-center p-4 relative overflow-hidden",children:[t.jsx("div",{className:"absolute inset-0 bg-[radial-gradient(ellipse_at_top,_var(--tw-gradient-stops))] from-brand-950/50 via-transparent to-transparent"}),t.jsxs("div",{className:"w-full max-w-sm relative z-10",children:[t.jsxs("div",{className:"text-center mb-8",children:[t.jsx("img",{src:"/logo.png",alt:"Markus",className:"w-14 h-14 mx-auto mb-3 rounded-xl shadow-lg shadow-black/40"}),t.jsx("div",{className:"text-2xl font-extrabold tracking-tight text-fg-primary mb-1",children:"Markus"}),t.jsx("div",{className:"text-sm text-fg-tertiary",children:r("login.subtitle")})]}),t.jsxs("form",{onSubmit:x,className:"bg-surface-secondary/80 backdrop-blur-sm border border-border-default rounded-2xl p-8 space-y-5 shadow-2xl shadow-black/30",children:[t.jsxs("div",{children:[t.jsx("h2",{className:"text-lg font-semibold text-fg-primary text-center",children:r(n?"changePassword.setYourPassword":"changePassword.changePassword")}),n&&t.jsx("p",{className:"text-xs text-amber-600/80 text-center mt-2",children:r("changePassword.defaultPasswordWarning")})]}),!n&&t.jsxs("div",{className:"space-y-1",children:[t.jsx("label",{className:"text-xs text-fg-tertiary font-medium",children:r("changePassword.currentPassword")}),t.jsx("input",{type:"password",value:s,onChange:v=>a(v.target.value),autoComplete:"current-password",className:"w-full px-4 py-2.5 bg-surface-elevated border border-border-default rounded-xl text-sm text-fg-primary focus:border-brand-500 outline-none transition-colors"})]}),t.jsxs("div",{className:"space-y-1",children:[t.jsx("label",{className:"text-xs text-fg-tertiary font-medium",children:r("changePassword.newPassword")}),t.jsx("input",{type:"password",value:i,onChange:v=>l(v.target.value),autoComplete:"new-password",className:"w-full px-4 py-2.5 bg-surface-elevated border border-border-default rounded-xl text-sm text-fg-primary focus:border-brand-500 outline-none transition-colors",required:!0,minLength:6})]}),t.jsxs("div",{className:"space-y-1",children:[t.jsx("label",{className:"text-xs text-fg-tertiary font-medium",children:r("changePassword.confirmNewPassword")}),t.jsx("input",{type:"password",value:c,onChange:v=>u(v.target.value),autoComplete:"new-password",className:"w-full px-4 py-2.5 bg-surface-elevated border border-border-default rounded-xl text-sm text-fg-primary focus:border-brand-500 outline-none transition-colors",required:!0})]}),m&&t.jsx("div",{className:"px-3 py-2 bg-red-500/10 border border-red-500/30 rounded-lg text-xs text-red-500",children:m}),t.jsx("button",{type:"submit",disabled:p||!i||!c,className:"w-full py-2.5 bg-brand-600 hover:bg-brand-500 disabled:opacity-50 text-white text-sm font-medium rounded-xl transition-colors",children:r(p?"changePassword.saving":n?"changePassword.setPasswordAndContinue":"changePassword.changePassword")})]})]})]})}const Sh={agents:[],tasks:[],requirements:[],projects:[],deliverables:[],workflows:[]},lue={team:["agents","workflows","tasks","requirements","projects","deliverables"],work:["workflows","projects","requirements","tasks","agents","deliverables"],deliverables:["deliverables","agents","tasks","requirements","projects","workflows"]},cue=["agents","tasks","requirements","projects","deliverables","workflows"];let c6="",d6="all",u6=Sh,m6=!1;function due({onClose:e,currentPage:n}){const{t:r}=ht(["common","home","work"]),[s,a]=g.useState(c6),[i,l]=g.useState(d6),[c,u]=g.useState(u6),[m,f]=g.useState(!1),[p,b]=g.useState(m6),[x,v]=g.useState(-1);g.useEffect(()=>{c6=s},[s]),g.useEffect(()=>{d6=i},[i]),g.useEffect(()=>{u6=c},[c]),g.useEffect(()=>{m6=p},[p]);const N=g.useRef(null),C=g.useRef(void 0),k=g.useRef(null),j=g.useRef(null);g.useEffect(()=>{setTimeout(()=>{N.current?.focus(),N.current?.select()},100)},[]);const w=g.useCallback(async z=>{if(!z.trim()){u(Sh),b(!1),v(-1);return}f(!0),b(!0),v(-1);const A=z.toLowerCase();try{const[H,D,O,q,J,B]=await Promise.allSettled([ae.agents.list(),ae.tasks.list({search:z,pageSize:20}),ae.requirements.list(),ae.projects.list(),ae.deliverables.search({q:z,limit:20}),ae.teams.list()]),V=H.status==="fulfilled"?H.value.agents.filter(te=>te.name?.toLowerCase().includes(A)||te.role?.toLowerCase().includes(A)):[],X=D.status==="fulfilled"?D.value.tasks:[],K=O.status==="fulfilled"?O.value.requirements.filter(te=>te.title?.toLowerCase().includes(A)||te.description?.toLowerCase().includes(A)):[],ee=q.status==="fulfilled"?q.value.projects.filter(te=>te.name?.toLowerCase().includes(A)||te.description?.toLowerCase().includes(A)):[],Q=J.status==="fulfilled"?J.value.results:[],ne=[];if(B.status==="fulfilled"){const te=await Promise.allSettled(B.value.teams.map(Y=>ae.workflows.list(Y.id)));for(const Y of te)if(Y.status==="fulfilled")for(const oe of Y.value.workflows)(oe.name.toLowerCase().includes(A)||(oe.displayName||"").toLowerCase().includes(A)||oe.description?.toLowerCase().includes(A))&&ne.push(oe)}u({agents:V,tasks:X,requirements:K,projects:ee,deliverables:Q,workflows:ne})}catch{u(Sh)}finally{f(!1)}},[]),S=z=>{a(z),C.current&&clearTimeout(C.current),C.current=setTimeout(()=>w(z),400)},T=g.useCallback((z,A)=>{e(),Rt.navigate(z,A)},[e]),R=[{id:"all",label:r("common:all",{defaultValue:"全部"})},{id:"agents",label:r("common:agents",{defaultValue:"智能体"})},{id:"tasks",label:r("common:tasks",{defaultValue:"任务"})},{id:"requirements",label:r("common:requirements",{defaultValue:"需求"})},{id:"projects",label:r("common:projects",{defaultValue:"项目"})},{id:"deliverables",label:r("common:deliverables",{defaultValue:"交付物"})},{id:"workflows",label:r("common:workflows",{defaultValue:"工作流"})}],I=g.useMemo(()=>lue[n||""]||cue,[n]),P=g.useMemo(()=>{const z=[],A=i==="all"?8:void 0,H=D=>{if(i!=="all"&&i!==D)return;const O=c[D].length;if(D==="workflows"){const q=A?c.workflows.slice(0,A):c.workflows;for(const J of q)z.push({id:J.name,type:"workflow",page:Be.WORK,params:{boardType:"workflows"}})}else{const q=c[D],J=A?q.slice(0,A):q;for(const B of J)switch(D){case"agents":z.push({id:B.id,type:"agent",page:Be.TEAM,params:{agentId:B.id}});break;case"tasks":z.push({id:B.id,type:"task",page:Be.WORK,params:{openTask:B.id}});break;case"requirements":z.push({id:B.id,type:"requirement",page:Be.WORK,params:{openRequirement:B.id}});break;case"projects":z.push({id:B.id,type:"project",page:Be.WORK,params:{projectId:B.id}});break;case"deliverables":z.push({id:B.id,type:"deliverable",page:Be.DELIVERABLES,params:{openDeliverable:B.id}});break}}A&&O>A&&z.push({id:`more_${D}`,type:"showMore",page:"",expandCategory:D,totalCount:O})};for(const D of I)H(D);return z},[c,i,I]),L=g.useCallback(z=>{if(z.type==="showMore"&&z.expandCategory){l(z.expandCategory),v(-1);return}T(z.page,z.params)},[T]);g.useEffect(()=>{const z=j.current;if(!z||x<0)return;const A=z.querySelector(`[data-idx="${x}"]`);A&&A.scrollIntoView({block:"nearest"})},[x]);const M=g.useCallback(z=>{if(z.key==="Escape"){e();return}if(z.key==="Tab"){z.preventDefault();const D=R.map(J=>J.id),O=D.indexOf(i),q=z.shiftKey?O<=0?D.length-1:O-1:O>=D.length-1?0:O+1;l(D[q]),v(-1);return}const A=z.ctrlKey&&z.key==="n"||z.key==="ArrowDown",H=z.ctrlKey&&z.key==="p"||z.key==="ArrowUp";if(A||H){z.preventDefault(),v(D=>{const O=P.length-1;return O<0?-1:A?D>=O?0:D+1:D<=0?O:D-1});return}z.key==="Enter"&&(z.preventDefault(),x>=0&&x<P.length&&L(P[x]))},[e,P,x,L,R,i]);g.useEffect(()=>(document.addEventListener("keydown",M),()=>document.removeEventListener("keydown",M)),[M]);const $=P.length>0;let U=0;return t.jsx("div",{ref:k,className:"fixed inset-0 bg-black/50 flex items-start justify-center z-50 pt-[8vh]",onClick:z=>{z.target===k.current&&e()},children:t.jsxs("div",{className:"bg-surface-primary border border-border-default rounded-2xl shadow-2xl w-full max-w-3xl max-h-[78vh] flex flex-col overflow-hidden animate-fadeIn",children:[t.jsxs("div",{className:"shrink-0 px-5 pt-4 pb-3 border-b border-border-default space-y-3",children:[t.jsxs("div",{className:"relative",children:[t.jsxs("svg",{className:"absolute left-3 top-1/2 -translate-y-1/2 text-fg-tertiary",width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[t.jsx("circle",{cx:"11",cy:"11",r:"8"}),t.jsx("line",{x1:"21",y1:"21",x2:"16.65",y2:"16.65"})]}),t.jsx("input",{ref:N,value:s,onChange:z=>S(z.target.value),placeholder:r("common:search"),className:"w-full bg-surface-elevated border border-border-default rounded-xl pl-9 pr-9 py-2.5 text-sm text-fg-primary placeholder:text-fg-tertiary focus:border-brand-500 focus:outline-none transition-colors"}),s&&t.jsx("button",{onClick:()=>{a(""),u(Sh),b(!1),v(-1),N.current?.focus()},className:"absolute right-3 top-1/2 -translate-y-1/2 text-fg-tertiary hover:text-fg-secondary",children:t.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[t.jsx("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),t.jsx("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]})})]}),t.jsx("div",{className:"flex gap-1 overflow-x-auto scrollbar-hide",children:R.map(z=>t.jsx("button",{onClick:()=>{l(z.id),v(-1)},className:`px-3 py-1.5 text-xs rounded-lg whitespace-nowrap transition-colors ${i===z.id?"bg-brand-600 text-white":"bg-surface-elevated text-fg-secondary hover:text-fg-primary"}`,children:z.label},z.id))})]}),t.jsxs("div",{ref:j,className:"flex-1 overflow-y-auto px-5 py-3",children:[m&&t.jsx("div",{className:"flex items-center justify-center py-8",children:t.jsx("div",{className:"text-fg-tertiary text-sm animate-pulse",children:r("common:loading")})}),!m&&p&&!$&&t.jsxs("div",{className:"flex flex-col items-center justify-center py-8 text-center",children:[t.jsxs("svg",{width:"36",height:"36",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.5",className:"text-fg-tertiary mb-2",children:[t.jsx("circle",{cx:"11",cy:"11",r:"8"}),t.jsx("line",{x1:"21",y1:"21",x2:"16.65",y2:"16.65"})]}),t.jsx("p",{className:"text-sm text-fg-tertiary",children:r("common:noResults",{defaultValue:"没有找到相关结果"})})]}),!m&&$&&t.jsx("div",{className:"space-y-4",children:I.map(z=>{if(i!=="all"&&i!==z)return null;const A=i==="all"?8:void 0,H=D=>{const O=U++,q=D==="agents"?c.agents.length:D==="tasks"?c.tasks.length:D==="requirements"?c.requirements.length:D==="projects"?c.projects.length:D==="workflows"?c.workflows.length:c.deliverables.length;return t.jsxs("button",{"data-idx":O,onClick:()=>{l(D),v(-1)},className:`mt-1 w-full text-xs py-1.5 rounded-lg transition-colors ${O===x?"bg-brand-600/15 ring-1 ring-brand-500/40 text-brand-500":"text-brand-500 hover:text-brand-400 hover:bg-surface-overlay"}`,children:[r("common:showAll",{defaultValue:"查看全部"})," (",q,")"]})};return z==="agents"&&c.agents.length>0?t.jsxs("section",{children:[t.jsx("h3",{className:"text-xs font-medium text-fg-tertiary uppercase mb-2",children:r("common:agents",{defaultValue:"智能体"})}),t.jsx("div",{className:"space-y-0.5",children:(A?c.agents.slice(0,A):c.agents).map(D=>{const O=U++;return t.jsxs("button",{"data-idx":O,onClick:()=>T(Be.TEAM,{agentId:D.id}),className:`w-full flex items-center gap-3 px-3 py-2 rounded-xl transition-colors text-left ${O===x?"bg-brand-600/15 ring-1 ring-brand-500/40":"hover:bg-surface-overlay"}`,children:[t.jsx(_r,{name:D.name||"Agent",avatarUrl:D.avatarUrl,size:28}),t.jsxs("div",{className:"flex-1 min-w-0",children:[t.jsx("div",{className:"text-sm font-medium text-fg-primary truncate",children:D.name}),t.jsx("div",{className:"text-xs text-fg-tertiary truncate",children:D.role||D.status})]}),t.jsx(uue,{status:D.status})]},D.id)})}),A&&c.agents.length>A&&H("agents")]},"agents"):z==="tasks"&&c.tasks.length>0?t.jsxs("section",{children:[t.jsx("h3",{className:"text-xs font-medium text-fg-tertiary uppercase mb-2",children:r("common:tasks",{defaultValue:"任务"})}),t.jsx("div",{className:"space-y-0.5",children:(A?c.tasks.slice(0,A):c.tasks).map(D=>{const O=U++;return t.jsxs("button",{"data-idx":O,onClick:()=>T(Be.WORK,{openTask:D.id}),className:`w-full flex items-center gap-3 px-3 py-2 rounded-xl transition-colors text-left ${O===x?"bg-brand-600/15 ring-1 ring-brand-500/40":"hover:bg-surface-overlay"}`,children:[t.jsx(mue,{status:D.status}),t.jsxs("div",{className:"flex-1 min-w-0",children:[t.jsx("div",{className:"text-sm text-fg-primary truncate",children:D.title}),t.jsxs("div",{className:"text-xs text-fg-tertiary truncate",children:[D.status," · ",D.priority||""]})]})]},D.id)})}),A&&c.tasks.length>A&&H("tasks")]},"tasks"):z==="requirements"&&c.requirements.length>0?t.jsxs("section",{children:[t.jsx("h3",{className:"text-xs font-medium text-fg-tertiary uppercase mb-2",children:r("common:requirements",{defaultValue:"需求"})}),t.jsx("div",{className:"space-y-0.5",children:(A?c.requirements.slice(0,A):c.requirements).map(D=>{const O=U++;return t.jsxs("button",{"data-idx":O,onClick:()=>T(Be.WORK,{openRequirement:D.id}),className:`w-full flex items-center gap-3 px-3 py-2 rounded-xl transition-colors text-left ${O===x?"bg-brand-600/15 ring-1 ring-brand-500/40":"hover:bg-surface-overlay"}`,children:[t.jsx("div",{className:`w-7 h-7 rounded-lg flex items-center justify-center shrink-0 ${D.status==="approved"?"text-green-500 bg-green-500/15":D.status==="pending"?"text-amber-500 bg-amber-500/15":D.status==="rejected"?"text-red-500 bg-red-500/15":"text-fg-tertiary bg-surface-elevated"}`,children:t.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[t.jsx("path",{d:"M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z"}),t.jsx("polyline",{points:"14 2 14 8 20 8"}),t.jsx("line",{x1:"16",y1:"13",x2:"8",y2:"13"}),t.jsx("line",{x1:"16",y1:"17",x2:"8",y2:"17"})]})}),t.jsxs("div",{className:"flex-1 min-w-0",children:[t.jsx("div",{className:"text-sm text-fg-primary truncate",children:D.title}),t.jsxs("div",{className:"text-xs text-fg-tertiary truncate",children:[D.status," · ",D.priority||""]})]})]},D.id)})}),A&&c.requirements.length>A&&H("requirements")]},"requirements"):z==="projects"&&c.projects.length>0?t.jsxs("section",{children:[t.jsx("h3",{className:"text-xs font-medium text-fg-tertiary uppercase mb-2",children:r("common:projects",{defaultValue:"项目"})}),t.jsx("div",{className:"space-y-0.5",children:(A?c.projects.slice(0,A):c.projects).map(D=>{const O=U++;return t.jsxs("button",{"data-idx":O,onClick:()=>T(Be.WORK,{projectId:D.id}),className:`w-full flex items-center gap-3 px-3 py-2 rounded-xl transition-colors text-left ${O===x?"bg-brand-600/15 ring-1 ring-brand-500/40":"hover:bg-surface-overlay"}`,children:[t.jsx("div",{className:"w-7 h-7 rounded-lg bg-brand-500/15 flex items-center justify-center shrink-0",children:t.jsx("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",className:"text-brand-500",children:t.jsx("path",{d:"M22 19a2 2 0 0 1-2 2H4a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h5l2 3h9a2 2 0 0 1 2 2z"})})}),t.jsxs("div",{className:"flex-1 min-w-0",children:[t.jsx("div",{className:"text-sm text-fg-primary truncate",children:D.name}),D.description&&t.jsx("div",{className:"text-xs text-fg-tertiary truncate",children:D.description})]})]},D.id)})}),A&&c.projects.length>A&&H("projects")]},"projects"):z==="deliverables"&&c.deliverables.length>0?t.jsxs("section",{children:[t.jsx("h3",{className:"text-xs font-medium text-fg-tertiary uppercase mb-2",children:r("common:deliverables",{defaultValue:"交付物"})}),t.jsx("div",{className:"space-y-0.5",children:(A?c.deliverables.slice(0,A):c.deliverables).map(D=>{const O=U++;return t.jsxs("button",{"data-idx":O,onClick:()=>T(Be.DELIVERABLES,{openDeliverable:D.id}),className:`w-full flex items-center gap-3 px-3 py-2 rounded-xl transition-colors text-left ${O===x?"bg-brand-600/15 ring-1 ring-brand-500/40":"hover:bg-surface-overlay"}`,children:[t.jsx("div",{className:"w-7 h-7 rounded-lg bg-purple-500/15 flex items-center justify-center shrink-0",children:t.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",className:"text-purple-500",children:[t.jsx("path",{d:"M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z"}),t.jsx("polyline",{points:"14 2 14 8 20 8"})]})}),t.jsxs("div",{className:"flex-1 min-w-0",children:[t.jsx("div",{className:"text-sm text-fg-primary truncate",children:D.title}),t.jsxs("div",{className:"text-xs text-fg-tertiary truncate",children:[D.type," · ",D.status]})]})]},D.id)})}),A&&c.deliverables.length>A&&H("deliverables")]},"deliverables"):z==="workflows"&&c.workflows.length>0?t.jsxs("section",{children:[t.jsx("h3",{className:"text-xs font-medium text-fg-tertiary uppercase mb-2",children:r("common:workflows",{defaultValue:"工作流"})}),t.jsx("div",{className:"space-y-0.5",children:(A?c.workflows.slice(0,A):c.workflows).map(D=>{const O=U++;return t.jsxs("button",{"data-idx":O,onClick:()=>T(Be.WORK,{boardType:"workflows"}),className:`w-full flex items-center gap-3 px-3 py-2 rounded-xl transition-colors text-left ${O===x?"bg-brand-600/15 ring-1 ring-brand-500/40":"hover:bg-surface-overlay"}`,children:[t.jsx("div",{className:"w-7 h-7 rounded-lg bg-teal-500/15 flex items-center justify-center shrink-0",children:t.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",className:"text-teal-500",children:[t.jsx("circle",{cx:"12",cy:"12",r:"3"}),t.jsx("path",{d:"M19.4 15a1.65 1.65 0 0 0 .33 1.82l.06.06a2 2 0 0 1 0 2.83 2 2 0 0 1-2.83 0l-.06-.06a1.65 1.65 0 0 0-1.82-.33 1.65 1.65 0 0 0-1 1.51V21a2 2 0 0 1-2 2 2 2 0 0 1-2-2v-.09A1.65 1.65 0 0 0 9 19.4a1.65 1.65 0 0 0-1.82.33l-.06.06a2 2 0 0 1-2.83 0 2 2 0 0 1 0-2.83l.06-.06A1.65 1.65 0 0 0 4.68 15a1.65 1.65 0 0 0-1.51-1H3a2 2 0 0 1-2-2 2 2 0 0 1 2-2h.09A1.65 1.65 0 0 0 4.6 9a1.65 1.65 0 0 0-.33-1.82l-.06-.06a2 2 0 0 1 0-2.83 2 2 0 0 1 2.83 0l.06.06A1.65 1.65 0 0 0 9 4.68a1.65 1.65 0 0 0 1-1.51V3a2 2 0 0 1 2-2 2 2 0 0 1 2 2v.09a1.65 1.65 0 0 0 1 1.51 1.65 1.65 0 0 0 1.82-.33l.06-.06a2 2 0 0 1 2.83 0 2 2 0 0 1 0 2.83l-.06.06A1.65 1.65 0 0 0 19.4 9a1.65 1.65 0 0 0 1.51 1H21a2 2 0 0 1 2 2 2 2 0 0 1-2 2h-.09a1.65 1.65 0 0 0-1.51 1z"})]})}),t.jsxs("div",{className:"flex-1 min-w-0",children:[t.jsx("div",{className:"text-sm text-fg-primary truncate",children:D.displayName||D.name}),t.jsxs("div",{className:"text-xs text-fg-tertiary truncate",children:[D.stepCount," steps · v",D.version]})]})]},D.name)})}),A&&c.workflows.length>A&&H("workflows")]},"workflows"):null})}),!m&&!p&&t.jsxs("div",{className:"flex flex-col items-center justify-center py-8 text-center",children:[t.jsxs("svg",{width:"36",height:"36",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.5",className:"text-fg-tertiary mb-2",children:[t.jsx("circle",{cx:"11",cy:"11",r:"8"}),t.jsx("line",{x1:"21",y1:"21",x2:"16.65",y2:"16.65"})]}),t.jsx("p",{className:"text-sm text-fg-tertiary",children:r("common:searchHint",{defaultValue:"输入关键词搜索"})})]})]}),t.jsxs("div",{className:"shrink-0 px-5 py-2 border-t border-border-default flex items-center gap-4 text-xs text-fg-tertiary flex-wrap",children:[t.jsxs("span",{children:[t.jsx("kbd",{className:"px-1.5 py-0.5 rounded bg-surface-elevated border border-border-default text-[11px] font-medium",children:navigator.platform.toUpperCase().includes("MAC")?"Cmd+P":"Ctrl+P"})," ",r("common:toggle",{defaultValue:"唤起/关闭"})]}),t.jsxs("span",{children:[t.jsx("kbd",{className:"px-1.5 py-0.5 rounded bg-surface-elevated border border-border-default text-[11px] font-medium",children:"Tab"})," ",r("common:switchTab",{defaultValue:"切换分类"})]}),t.jsxs("span",{children:[t.jsx("kbd",{className:"px-1.5 py-0.5 rounded bg-surface-elevated border border-border-default text-[11px] font-medium",children:"↑↓"})," ",r("common:navigate",{defaultValue:"导航"})]}),t.jsxs("span",{children:[t.jsx("kbd",{className:"px-1.5 py-0.5 rounded bg-surface-elevated border border-border-default text-[11px] font-medium",children:"Enter"})," ",r("common:open",{defaultValue:"打开"})]}),t.jsxs("span",{children:[t.jsx("kbd",{className:"px-1.5 py-0.5 rounded bg-surface-elevated border border-border-default text-[11px] font-medium",children:"Esc"})," ",r("common:close",{defaultValue:"关闭"})]})]})]})})}function uue({status:e}){const n=e==="active"||e==="idle"?"bg-green-500":e==="working"||e==="busy"?"bg-blue-500":"bg-gray-400";return t.jsx("span",{className:`w-2 h-2 rounded-full shrink-0 ${n}`})}function mue({status:e}){const n=e==="completed"?"text-green-500 bg-green-500/15":e==="in_progress"?"text-blue-500 bg-blue-500/15":e==="pending"?"text-amber-500 bg-amber-500/15":"text-fg-tertiary bg-surface-elevated";return t.jsx("div",{className:`w-7 h-7 rounded-lg flex items-center justify-center shrink-0 ${n}`,children:t.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[t.jsx("path",{d:"M9 11l3 3L22 4"}),t.jsx("path",{d:"M21 12v7a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h11"})]})})}const fue={visibility:"hidden",position:"absolute",inset:0,pointerEvents:"none",zIndex:-1},hue=g.memo(function({id:n,activePage:r,children:s}){const a=n===r;return t.jsx("div",{className:"flex-1 overflow-hidden flex flex-col",style:a?void 0:fue,children:s})},(e,n)=>{const r=e.id===e.activePage,s=n.id===n.activePage;return r!==s?!1:s?e.children===n.children:!0}),_1={};function pue(){const{t:e}=ht("common"),[n,r]=g.useState(fc),[s,a]=g.useState(()=>!localStorage.getItem("markus_onboarded")),[i,l]=g.useState(!0),c=ea(),u=Ree(),m=P0({side:"left",defaultWidth:160,minWidth:140,maxWidth:400,collapsedWidth:64,storageKey:"markus_sidebar"}),[f,p]=g.useState(()=>new Set([fc()])),[b,x]=g.useState("loading"),[v,N]=g.useState(null),[C,k]=g.useState({hasOwner:!1,hasMultipleUsers:!1}),[j,w]=g.useState(!1),[S,T]=g.useState(!1),[R,I]=g.useState(null),[P,L]=g.useState(!1),[M,$]=g.useState(null),[U,z]=g.useState(()=>{const te=localStorage.getItem("markus_update_dismissed");return te||null}),[A,H]=g.useState(null),[D,O]=g.useState(!1),q=g.useCallback(()=>{ae.license.get().then(te=>{if(te.plan==="enterprise"){H(null);return}if(te.usage&&te.limits){const Y=te.limits.maxTeams>0&&te.usage.teams>=te.limits.maxTeams,oe=te.limits.maxToolCallsPerDay>0&&te.usage.toolCallsToday>=te.limits.maxToolCallsPerDay;Y||oe?(H({teams:Y||void 0,toolCalls:oe||void 0}),O(!1)):H(null)}}).catch(()=>{})},[]);g.useEffect(()=>{const te=()=>{document.visibilityState==="visible"&&q()};window.addEventListener("markus:check-license-limits",q),document.addEventListener("visibilitychange",te);const Y=setInterval(q,300*1e3);return()=>{window.removeEventListener("markus:check-license-limits",q),document.removeEventListener("visibilitychange",te),clearInterval(Y)}},[q]);const[J,B]=g.useState(!1);g.useEffect(()=>{if(c)return;const te=navigator.platform.toUpperCase().includes("MAC"),Y=ge=>{te&&ge.metaKey&&!ge.ctrlKey&&ge.key==="p"?(ge.preventDefault(),B(ye=>!ye)):!te&&ge.ctrlKey&&!ge.metaKey&&ge.key==="p"&&(ge.preventDefault(),B(ye=>!ye))},oe=()=>B(!0);return document.addEventListener("keydown",Y),window.addEventListener("markus:open-search",oe),()=>{document.removeEventListener("keydown",Y),window.removeEventListener("markus:open-search",oe)}},[c]);const V=g.useCallback(te=>{let Y=Rl(te);c?Y=fF[Y]??Y:Y===Be.NOTIFICATIONS&&(Y=Be.HOME);const oe=fc(),ge=window.location.hash.slice(1);ge!==oe?_1[oe]=ge:delete _1[oe];const ye=Y!==Be.WORK?_1[Y]:void 0;ye&&ye!==Y?(history.pushState(null,"","#"+Y),history.pushState(null,"","#"+ye)):history.pushState(null,"","#"+Y),window.dispatchEvent(new HashChangeEvent("hashchange")),r(Y),p(we=>we.has(Y)?we:new Set([...we,Y]))},[c]);g.useEffect(()=>{Rt.setHandler(te=>V(te))},[V]),g.useEffect(()=>{if(!window.markusDesktop)return;!c&&n!==Be.SETTINGS&&!m.collapsed?window.markusDesktop.setTrafficLightPosition(16,16):window.markusDesktop.setTrafficLightPosition(6,16)},[m.collapsed,n,c]),g.useEffect(()=>{window.markusDesktop&&window.markusDesktop.onNotificationClick(te=>{if(te.openNotifications&&window.dispatchEvent(new CustomEvent("markus:open-notifications")),te.page){const Y=Rl(te.page);te.params&&Object.entries(te.params).forEach(([oe,ge])=>localStorage.setItem(`markus_nav_${oe}`,ge)),V(Y),window.dispatchEvent(new CustomEvent("markus:navigate",{detail:{page:Y,params:te.params}}))}})},[V]);const X=g.useCallback(()=>{fetch("/api/settings/llm").then(te=>te.ok?te.json():null).then(te=>{if(te?.providers){const Y=Object.values(te.providers).some(oe=>oe.configured);I(Y)}}).catch(()=>{})},[]);g.useEffect(()=>{const te=new URLSearchParams(window.location.search),Y=te.get("install");if(Y&&fc()!==Be.STORE){const ye=te.get("type"),Ce=ye&&{agent:"agents",team:"teams",skill:"skills"}[ye]||"agents";localStorage.setItem("markus_nav_installItem",Y),localStorage.setItem("markus_nav_storeTab",Ce),te.delete("install"),te.delete("type");const ie=te.toString();window.history.replaceState(null,"",window.location.pathname+(ie?`?${ie}`:"")+"#store"),setTimeout(()=>Rt.navigate(Be.STORE,{storeTab:Ce,installItem:Y}),300)}ae.auth.me().then(({user:ye})=>{x(ye),N(!0),Tn.connect(ye.id),X(),ae.health().then(Ce=>{Ce.updateAvailable&&Ce.latestVersion&&$({latestVersion:Ce.latestVersion,currentVersion:Ce.version})}).catch(()=>{}),q();const we=()=>{dc($a.builderArtifacts,()=>ae.builder.artifacts.list()),dc($a.builderAgents,()=>ae.agents.list()),dc($a.builderHubMyItems,()=>Xn.myItems()),dc($a.builderInstalled,()=>ae.builder.artifacts.installed()),dc($a.hubAgents,()=>Xn.search({type:"agent",limit:50})),dc($a.hubTeams,()=>Xn.search({type:"team",limit:50})),dc($a.hubSkills,()=>Xn.search({type:"skill",limit:50}))};typeof requestIdleCallback=="function"?requestIdleCallback(we,{timeout:5e3}):setTimeout(we,3e3)}).catch(()=>{x(null),ae.auth.status().then(({initialized:ye,hasOwner:we,hasMultipleUsers:Ce})=>{N(ye),k({hasOwner:we,hasMultipleUsers:Ce})}).catch(()=>N(!0))}),Tn.connect();const oe=Tn.on("notification",()=>{window.dispatchEvent(new CustomEvent("markus:notifications-changed"))}),ge=()=>{const ye=fc();r(ye),p(we=>we.has(ye)?we:new Set([...we,ye]))};return window.addEventListener("hashchange",ge),window.addEventListener("popstate",ge),()=>{oe(),Tn.disconnect(),window.removeEventListener("hashchange",ge),window.removeEventListener("popstate",ge)}},[]);const K=b!=="loading"&&b!==null?b:void 0,ee=g.useMemo(()=>c?{[Be.HOME]:t.jsx(Pk,{authUser:K}),[Be.TEAM]:t.jsx(Sj,{authUser:K}),[Be.BUILDER]:t.jsx(rue,{authUser:K}),[Be.SETTINGS]:t.jsx(u3,{theme:u.mode,onThemeChange:u.setMode,authUser:K,onLogout:()=>{ae.auth.logout().catch(()=>{}),E0(),x(null)},onUserUpdated:te=>x(te)}),[Be.WORK]:t.jsx(t6,{authUser:K}),[Be.DELIVERABLES]:t.jsx(s6,{authUser:K}),[Be.NOTIFICATIONS]:t.jsx(Xde,{authUser:K}),[Be.REPORTS]:t.jsx(i6,{authUser:K}),[Be.SEARCH]:t.jsx(Qde,{})}:{[Be.HOME]:t.jsx(Pk,{authUser:K}),[Be.TEAM]:t.jsx(Sj,{authUser:K}),[Be.SETTINGS]:t.jsx(u3,{theme:u.mode,onThemeChange:u.setMode,authUser:K,onLogout:()=>{ae.auth.logout().catch(()=>{}),E0(),x(null)},onUserUpdated:te=>x(te)}),[Be.STORE]:t.jsx(gne,{authUser:K}),[Be.BUILDER]:t.jsx(s8,{authUser:K}),[Be.WORK]:t.jsx(t6,{authUser:K}),[Be.DELIVERABLES]:t.jsx(s6,{authUser:K}),[Be.REPORTS]:t.jsx(i6,{authUser:K})},[K?.id,K?.role,u.mode,c]);if(b==="loading"||b===null&&v===null)return t.jsx("div",{className:"min-h-dvh bg-surface-primary flex items-center justify-center",children:t.jsx("div",{className:"text-fg-tertiary text-sm animate-pulse",children:e("loading")})});const ne=(typeof window<"u"?window.location.hash:"").match(/^#invite\?token=([a-f0-9]+)/);return ne?t.jsx(iue,{token:ne[1],onComplete:()=>{window.location.hash="",localStorage.removeItem("markus_onboarded"),a(!0),w(!0),x("loading"),ae.auth.me().then(te=>x(te.user)).catch(()=>x(null))}}):b===null?t.jsx(aue,{hasOwner:C.hasOwner,hasMultipleUsers:C.hasMultipleUsers,onLogin:(te,Y,oe)=>{x(te),Y?(localStorage.removeItem("markus_onboarded"),a(!0),oe?.fromHub&&w(!0)):localStorage.getItem("markus_onboarded")||(localStorage.setItem("markus_onboarded","1"),a(!1))}}):S?t.jsx(oue,{onComplete:()=>T(!1),isFirstTime:!0}):s?t.jsx(sue,{theme:u.mode,onThemeChange:u.setMode,skipProfile:j,onComplete:()=>{localStorage.setItem("markus_onboarded","1"),a(!1),w(!1),X(),V(Be.HOME)}}):t.jsxs("div",{className:`flex h-dvh bg-surface-primary text-fg-primary overflow-x-hidden ${c?"flex-col":""}`,children:[!c&&n!==Be.SETTINGS&&t.jsxs(t.Fragment,{children:[t.jsx("div",{className:"relative z-40 shrink-0",style:{width:m.width},children:t.jsx(eue,{currentPage:n,onNavigate:te=>{V(te),l(!1)},authUser:b,collapsed:m.collapsed,onToggleCollapse:m.toggle})}),t.jsx("div",{className:`${m.collapsed?"w-0":"w-1.5 cursor-col-resize"} shrink-0 group relative z-10 flex items-center justify-center`,onMouseDown:m.collapsed?void 0:m.onResizeStart,children:!m.collapsed&&t.jsx("div",{className:"w-px h-2/3 border-l border-dashed border-transparent group-hover:border-border-default group-active:border-fg-tertiary transition-colors"})})]}),t.jsxs("div",{className:`flex-1 overflow-hidden flex flex-col min-w-0 ${c&&n!==Be.SETTINGS&&n!==Be.SEARCH?"pb-14":""}`,children:[R===!1&&!P&&n!==Be.SETTINGS&&t.jsxs("div",{className:"flex items-center justify-between px-4 py-2 bg-amber-500/10 border-b border-amber-500/30 text-amber-600 text-sm shrink-0",children:[t.jsx("span",{className:c?"text-xs":"",children:e("llmBanner.message")}),t.jsxs("div",{className:"flex items-center gap-3",children:[t.jsx("button",{onClick:()=>{window.location.hash="#settings/providers"},className:"px-3 py-1 bg-amber-700/50 hover:bg-amber-700/70 text-white text-xs rounded-lg transition-colors",children:e("llmBanner.goToSettings")}),t.jsx("button",{onClick:()=>L(!0),className:"text-amber-500 hover:text-amber-600 text-xs",children:e("dismiss")})]})]}),M&&U!==M.latestVersion&&t.jsxs("div",{className:"flex items-center justify-between px-4 py-2 bg-brand-500/10 border-b border-brand-500/30 text-brand-400 text-sm shrink-0",children:[t.jsx("span",{className:c?"text-xs":"",children:e("update.available",{latest:M.latestVersion,current:M.currentVersion})}),t.jsxs("span",{className:"flex items-center gap-3 shrink-0",children:[t.jsx("a",{href:"https://markus.global/download",target:"_blank",rel:"noopener noreferrer",className:"text-xs font-medium text-brand-400 hover:text-brand-300 transition-colors",children:e("update.download")}),t.jsx("button",{onClick:()=>{z(M.latestVersion),localStorage.setItem("markus_update_dismissed",M.latestVersion)},className:"text-fg-tertiary hover:text-fg-secondary text-xs shrink-0",children:e("dismiss")})]})]}),A&&!D&&n!==Be.SETTINGS&&t.jsxs("div",{className:"flex items-center justify-between px-4 py-2 bg-orange-500/10 border-b border-orange-500/30 text-orange-400 text-sm shrink-0",children:[t.jsx("span",{className:c?"text-xs":"",children:A.teams&&A.toolCalls?e("license.limitReachedBoth"):A.teams?e("license.limitReachedTeams"):e("license.limitReachedToolCalls")}),t.jsxs("span",{className:"flex items-center gap-3 shrink-0",children:[t.jsx("button",{onClick:()=>{window.location.hash="settings/account"},className:"px-3 py-1 bg-orange-600/50 hover:bg-orange-600/70 text-white text-xs rounded-lg transition-colors",children:e("license.upgradeLicense")}),t.jsx("button",{onClick:()=>O(!0),className:"text-fg-tertiary hover:text-fg-secondary text-xs shrink-0",children:e("dismiss")})]})]}),t.jsx("main",{className:"flex-1 overflow-hidden flex flex-col relative",children:Object.keys(ee).map(te=>f.has(te)?t.jsx(hue,{id:te,activePage:n,children:ee[te]},te):null)})]}),c&&n!==Be.SETTINGS&&n!==Be.SEARCH&&t.jsx(tue,{currentPage:n,onNavigate:V,userId:K?.id}),c&&t.jsx(yF,{authUser:K,onNavigate:V}),!c&&J&&t.jsx(due,{onClose:()=>B(!1),currentPage:n})]})}RM.createRoot(document.getElementById("root")).render(t.jsx(g.StrictMode,{children:t.jsx(pue,{})}));export{rm as C,za as R,ql as _,k0 as a,Fv as d,N8 as e,Tc as g,bue as h,to as i,xue as k,C8 as n,Nse as r,ei as s};