@markus-global/cli 0.9.0-rc.2 → 0.9.0-rc.3

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 (60) hide show
  1. package/dist/web-ui/assets/{CommentInput-BdHK8MVv.js → CommentInput-Bj4xm_0q.js} +1 -1
  2. package/dist/web-ui/assets/{ContentRenderer-DM6YgtR6.js → ContentRenderer-DJR6tazg.js} +2 -2
  3. package/dist/web-ui/assets/{Deliverables-C12uk40-.js → Deliverables-DNtKj0sj.js} +1 -1
  4. package/dist/web-ui/assets/{Notifications-DMCefB8x.js → Notifications-DVH6Mzj8.js} +1 -1
  5. package/dist/web-ui/assets/{Search-BPvYYWNf.js → Search-BCVHO-UZ.js} +1 -1
  6. package/dist/web-ui/assets/{Settings-W8E04XTX.js → Settings-DmdHgt3w.js} +1 -1
  7. package/dist/web-ui/assets/{Store-BaUTI4Mp.js → Store-D3QUTsdm.js} +1 -1
  8. package/dist/web-ui/assets/{Team-DwZHZVWj.js → Team-Bfmg0l_n.js} +5 -5
  9. package/dist/web-ui/assets/{Work-DEC8BWR6.js → Work-Bv86FM_l.js} +1 -1
  10. package/dist/web-ui/assets/{arc--SFGztmO.js → arc-N7XKgiq9.js} +1 -1
  11. package/dist/web-ui/assets/{architectureDiagram-3BPJPVTR-CtikSEyD.js → architectureDiagram-3BPJPVTR-B9dE6TsK.js} +1 -1
  12. package/dist/web-ui/assets/{blockDiagram-GPEHLZMM-CR2WAbWZ.js → blockDiagram-GPEHLZMM-F9dI3ne4.js} +1 -1
  13. package/dist/web-ui/assets/{c4Diagram-AAUBKEIU-CU-JfT9g.js → c4Diagram-AAUBKEIU-C4uxCoT3.js} +1 -1
  14. package/dist/web-ui/assets/channel-CKUho8Ij.js +1 -0
  15. package/dist/web-ui/assets/{chunk-2J33WTMH-B9mRSrlW.js → chunk-2J33WTMH-C-JaAV_t.js} +1 -1
  16. package/dist/web-ui/assets/{chunk-4BX2VUAB-Q4X8Ma46.js → chunk-4BX2VUAB-CFu4XINz.js} +1 -1
  17. package/dist/web-ui/assets/{chunk-55IACEB6-Dve8Bfn_.js → chunk-55IACEB6-am-FYaO4.js} +1 -1
  18. package/dist/web-ui/assets/{chunk-727SXJPM-yA-DEgml.js → chunk-727SXJPM-oFp2O06n.js} +1 -1
  19. package/dist/web-ui/assets/{chunk-AQP2D5EJ-RAEMTrGW.js → chunk-AQP2D5EJ-D3ztK2IN.js} +1 -1
  20. package/dist/web-ui/assets/{chunk-FMBD7UC4-Ds8an_g4.js → chunk-FMBD7UC4--UxOMokz.js} +1 -1
  21. package/dist/web-ui/assets/{chunk-ND2GUHAM-C1mQ7WC1.js → chunk-ND2GUHAM-dW5KhfCy.js} +1 -1
  22. package/dist/web-ui/assets/{chunk-QZHKN3VN-DxVIG9uG.js → chunk-QZHKN3VN-BxEsECBV.js} +1 -1
  23. package/dist/web-ui/assets/classDiagram-4FO5ZUOK-Db6o506Z.js +1 -0
  24. package/dist/web-ui/assets/classDiagram-v2-Q7XG4LA2-Db6o506Z.js +1 -0
  25. package/dist/web-ui/assets/{cose-bilkent-S5V4N54A-4cbtB1vb.js → cose-bilkent-S5V4N54A-CMeu-NaM.js} +1 -1
  26. package/dist/web-ui/assets/{dagre-BM42HDAG-CmLcheSp.js → dagre-BM42HDAG-_gFPoYt6.js} +1 -1
  27. package/dist/web-ui/assets/{diagram-2AECGRRQ-neg3Oknk.js → diagram-2AECGRRQ-D1zc59WR.js} +1 -1
  28. package/dist/web-ui/assets/{diagram-5GNKFQAL-B0UcIJtg.js → diagram-5GNKFQAL-BP7NL_Xd.js} +1 -1
  29. package/dist/web-ui/assets/{diagram-KO2AKTUF-Cr5dM7Xs.js → diagram-KO2AKTUF-BBiIPIyO.js} +1 -1
  30. package/dist/web-ui/assets/{diagram-LMA3HP47-BXoasAX9.js → diagram-LMA3HP47-JGzyNoDe.js} +1 -1
  31. package/dist/web-ui/assets/{diagram-OG6HWLK6-C1STD3vd.js → diagram-OG6HWLK6-B2x4C5DU.js} +1 -1
  32. package/dist/web-ui/assets/{erDiagram-TEJ5UH35-BijN4PLx.js → erDiagram-TEJ5UH35-DxevkYX3.js} +1 -1
  33. package/dist/web-ui/assets/{flowDiagram-I6XJVG4X-CPZB8WC0.js → flowDiagram-I6XJVG4X-B0vbkdpF.js} +1 -1
  34. package/dist/web-ui/assets/{ganttDiagram-6RSMTGT7-BdqKGCZw.js → ganttDiagram-6RSMTGT7-D8jQLXlf.js} +1 -1
  35. package/dist/web-ui/assets/{gitGraphDiagram-PVQCEYII-B2URUqgF.js → gitGraphDiagram-PVQCEYII-aZQDAek2.js} +1 -1
  36. package/dist/web-ui/assets/{index-9k0fBbZW.js → index-CARLXeBD.js} +4 -4
  37. package/dist/web-ui/assets/{infoDiagram-5YYISTIA-b7a-4EMc.js → infoDiagram-5YYISTIA-DCMR5FfI.js} +1 -1
  38. package/dist/web-ui/assets/{ishikawaDiagram-YF4QCWOH-xhnufycU.js → ishikawaDiagram-YF4QCWOH-Mckf4TpB.js} +1 -1
  39. package/dist/web-ui/assets/{journeyDiagram-JHISSGLW-DbJH_wnT.js → journeyDiagram-JHISSGLW-DptiYm_W.js} +1 -1
  40. package/dist/web-ui/assets/{kanban-definition-UN3LZRKU-Wkm28OtU.js → kanban-definition-UN3LZRKU-Dkx4UOeT.js} +1 -1
  41. package/dist/web-ui/assets/{mermaid.core-C53surqX.js → mermaid.core-5DInlSXg.js} +5 -5
  42. package/dist/web-ui/assets/{mindmap-definition-RKZ34NQL-BVQH4krW.js → mindmap-definition-RKZ34NQL-Cxf5JBdT.js} +1 -1
  43. package/dist/web-ui/assets/{pieDiagram-4H26LBE5-D7AavThJ.js → pieDiagram-4H26LBE5-DeiOrnCq.js} +1 -1
  44. package/dist/web-ui/assets/{quadrantDiagram-W4KKPZXB-BLqc6exo.js → quadrantDiagram-W4KKPZXB-CwbFHP0V.js} +1 -1
  45. package/dist/web-ui/assets/{requirementDiagram-4Y6WPE33-CgiXQt7P.js → requirementDiagram-4Y6WPE33-DD4CHqjV.js} +1 -1
  46. package/dist/web-ui/assets/{sankeyDiagram-5OEKKPKP-CD6Ra_XU.js → sankeyDiagram-5OEKKPKP-0Esk_WE4.js} +1 -1
  47. package/dist/web-ui/assets/{sequenceDiagram-3UESZ5HK-Dcnz4H6M.js → sequenceDiagram-3UESZ5HK-DAaYZp-s.js} +1 -1
  48. package/dist/web-ui/assets/{stateDiagram-AJRCARHV-ilFYxRSt.js → stateDiagram-AJRCARHV-Bk8zbgM8.js} +1 -1
  49. package/dist/web-ui/assets/stateDiagram-v2-BHNVJYJU-D3_A1JUM.js +1 -0
  50. package/dist/web-ui/assets/{timeline-definition-PNZ67QCA-D2Jccw-a.js → timeline-definition-PNZ67QCA-VMDDQXF7.js} +1 -1
  51. package/dist/web-ui/assets/{vennDiagram-CIIHVFJN-5rQ9vPCY.js → vennDiagram-CIIHVFJN-t441C5cW.js} +1 -1
  52. package/dist/web-ui/assets/{wardley-L42UT6IY-BD25dVuq.js → wardley-L42UT6IY-ef1g-URe.js} +1 -1
  53. package/dist/web-ui/assets/{wardleyDiagram-YWT4CUSO-DPeh0B2q.js → wardleyDiagram-YWT4CUSO-CgkWJVbt.js} +1 -1
  54. package/dist/web-ui/assets/{xychartDiagram-2RQKCTM6-Co2SBgqk.js → xychartDiagram-2RQKCTM6-DvQtq-r1.js} +1 -1
  55. package/dist/web-ui/index.html +1 -1
  56. package/package.json +1 -1
  57. package/dist/web-ui/assets/channel-DtEzbZw1.js +0 -1
  58. package/dist/web-ui/assets/classDiagram-4FO5ZUOK-CD9j9DoV.js +0 -1
  59. package/dist/web-ui/assets/classDiagram-v2-Q7XG4LA2-CD9j9DoV.js +0 -1
  60. package/dist/web-ui/assets/stateDiagram-v2-BHNVJYJU-DBTSRf0f.js +0 -1
@@ -1,4 +1,4 @@
1
- const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/mermaid.core-C53surqX.js","assets/transform-CpIVI4vC.js","assets/Team-DwZHZVWj.js","assets/CommentInput-BdHK8MVv.js","assets/ContentRenderer-DM6YgtR6.js","assets/ChatHelpers-DDWzuvqW.js","assets/Work-DEC8BWR6.js","assets/value-DIujSiJ7.js","assets/Work-BZV40eAE.css","assets/Deliverables-C12uk40-.js"])))=>i.map(i=>d[i]);
1
+ const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/mermaid.core-5DInlSXg.js","assets/transform-CpIVI4vC.js","assets/Team-Bfmg0l_n.js","assets/CommentInput-Bj4xm_0q.js","assets/ContentRenderer-DJR6tazg.js","assets/ChatHelpers-DDWzuvqW.js","assets/Work-Bv86FM_l.js","assets/value-DIujSiJ7.js","assets/Work-BZV40eAE.css","assets/Deliverables-DNtKj0sj.js"])))=>i.map(i=>d[i]);
2
2
  (function(){const t=document.createElement("link").relList;if(t&&t.supports&&t.supports("modulepreload"))return;for(const o of document.querySelectorAll('link[rel="modulepreload"]'))r(o);new MutationObserver(o=>{for(const l of o)if(l.type==="childList")for(const u of l.addedNodes)u.tagName==="LINK"&&u.rel==="modulepreload"&&r(u)}).observe(document,{childList:!0,subtree:!0});function n(o){const l={};return o.integrity&&(l.integrity=o.integrity),o.referrerPolicy&&(l.referrerPolicy=o.referrerPolicy),o.crossOrigin==="use-credentials"?l.credentials="include":o.crossOrigin==="anonymous"?l.credentials="omit":l.credentials="same-origin",l}function r(o){if(o.ep)return;o.ep=!0;const l=n(o);fetch(o.href,l)}})();function xc(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var $f={exports:{}},Hl={};var cy;function jS(){if(cy)return Hl;cy=1;var e=Symbol.for("react.transitional.element"),t=Symbol.for("react.fragment");function n(r,o,l){var u=null;if(l!==void 0&&(u=""+l),o.key!==void 0&&(u=""+o.key),"key"in o){l={};for(var d in o)d!=="key"&&(l[d]=o[d])}else l=o;return o=l.ref,{$$typeof:e,type:r,key:u,ref:o!==void 0?o:null,props:l}}return Hl.Fragment=t,Hl.jsx=n,Hl.jsxs=n,Hl}var uy;function MS(){return uy||(uy=1,$f.exports=jS()),$f.exports}var s=MS(),Hf={exports:{}},Rt={};var dy;function RS(){if(dy)return Rt;dy=1;var e=Symbol.for("react.transitional.element"),t=Symbol.for("react.portal"),n=Symbol.for("react.fragment"),r=Symbol.for("react.strict_mode"),o=Symbol.for("react.profiler"),l=Symbol.for("react.consumer"),u=Symbol.for("react.context"),d=Symbol.for("react.forward_ref"),m=Symbol.for("react.suspense"),h=Symbol.for("react.memo"),p=Symbol.for("react.lazy"),g=Symbol.for("react.activity"),x=Symbol.iterator;function y(G){return G===null||typeof G!="object"?null:(G=x&&G[x]||G["@@iterator"],typeof G=="function"?G:null)}var w={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},N=Object.assign,T={};function C(G,ce,I){this.props=G,this.context=ce,this.refs=T,this.updater=I||w}C.prototype.isReactComponent={},C.prototype.setState=function(G,ce){if(typeof G!="object"&&typeof G!="function"&&G!=null)throw Error("takes an object of state variables to update or a function which returns an object of state variables.");this.updater.enqueueSetState(this,G,ce,"setState")},C.prototype.forceUpdate=function(G){this.updater.enqueueForceUpdate(this,G,"forceUpdate")};function j(){}j.prototype=C.prototype;function _(G,ce,I){this.props=G,this.context=ce,this.refs=T,this.updater=I||w}var O=_.prototype=new j;O.constructor=_,N(O,C.prototype),O.isPureReactComponent=!0;var z=Array.isArray;function D(){}var H={H:null,A:null,T:null,S:null},W=Object.prototype.hasOwnProperty;function Z(G,ce,I){var Ee=I.ref;return{$$typeof:e,type:G,key:ce,ref:Ee!==void 0?Ee:null,props:I}}function U(G,ce){return Z(G.type,ce,G.props)}function Y(G){return typeof G=="object"&&G!==null&&G.$$typeof===e}function ae(G){var ce={"=":"=0",":":"=2"};return"$"+G.replace(/[=:]/g,function(I){return ce[I]})}var X=/\/+/g;function F(G,ce){return typeof G=="object"&&G!==null&&G.key!=null?ae(""+G.key):ce.toString(36)}function J(G){switch(G.status){case"fulfilled":return G.value;case"rejected":throw G.reason;default:switch(typeof G.status=="string"?G.then(D,D):(G.status="pending",G.then(function(ce){G.status==="pending"&&(G.status="fulfilled",G.value=ce)},function(ce){G.status==="pending"&&(G.status="rejected",G.reason=ce)})),G.status){case"fulfilled":return G.value;case"rejected":throw G.reason}}throw G}function B(G,ce,I,Ee,Ue){var De=typeof G;(De==="undefined"||De==="boolean")&&(G=null);var Ke=!1;if(G===null)Ke=!0;else switch(De){case"bigint":case"string":case"number":Ke=!0;break;case"object":switch(G.$$typeof){case e:case t:Ke=!0;break;case p:return Ke=G._init,B(Ke(G._payload),ce,I,Ee,Ue)}}if(Ke)return Ue=Ue(G),Ke=Ee===""?"."+F(G,0):Ee,z(Ue)?(I="",Ke!=null&&(I=Ke.replace(X,"$&/")+"/"),B(Ue,ce,I,"",function(ct){return ct})):Ue!=null&&(Y(Ue)&&(Ue=U(Ue,I+(Ue.key==null||G&&G.key===Ue.key?"":(""+Ue.key).replace(X,"$&/")+"/")+Ke)),ce.push(Ue)),1;Ke=0;var st=Ee===""?".":Ee+":";if(z(G))for(var mt=0;mt<G.length;mt++)Ee=G[mt],De=st+F(Ee,mt),Ke+=B(Ee,ce,I,De,Ue);else if(mt=y(G),typeof mt=="function")for(G=mt.call(G),mt=0;!(Ee=G.next()).done;)Ee=Ee.value,De=st+F(Ee,mt++),Ke+=B(Ee,ce,I,De,Ue);else if(De==="object"){if(typeof G.then=="function")return B(J(G),ce,I,Ee,Ue);throw ce=String(G),Error("Objects are not valid as a React child (found: "+(ce==="[object Object]"?"object with keys {"+Object.keys(G).join(", ")+"}":ce)+"). If you meant to render a collection of children, use an array instead.")}return Ke}function Q(G,ce,I){if(G==null)return G;var Ee=[],Ue=0;return B(G,Ee,"","",function(De){return ce.call(I,De,Ue++)}),Ee}function re(G){if(G._status===-1){var ce=G._result;ce=ce(),ce.then(function(I){(G._status===0||G._status===-1)&&(G._status=1,G._result=I)},function(I){(G._status===0||G._status===-1)&&(G._status=2,G._result=I)}),G._status===-1&&(G._status=0,G._result=ce)}if(G._status===1)return G._result.default;throw G._result}var we=typeof reportError=="function"?reportError:function(G){if(typeof window=="object"&&typeof window.ErrorEvent=="function"){var ce=new window.ErrorEvent("error",{bubbles:!0,cancelable:!0,message:typeof G=="object"&&G!==null&&typeof G.message=="string"?String(G.message):String(G),error:G});if(!window.dispatchEvent(ce))return}else if(typeof process=="object"&&typeof process.emit=="function"){process.emit("uncaughtException",G);return}console.error(G)},$={map:Q,forEach:function(G,ce,I){Q(G,function(){ce.apply(this,arguments)},I)},count:function(G){var ce=0;return Q(G,function(){ce++}),ce},toArray:function(G){return Q(G,function(ce){return ce})||[]},only:function(G){if(!Y(G))throw Error("React.Children.only expected to receive a single React element child.");return G}};return Rt.Activity=g,Rt.Children=$,Rt.Component=C,Rt.Fragment=n,Rt.Profiler=o,Rt.PureComponent=_,Rt.StrictMode=r,Rt.Suspense=m,Rt.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE=H,Rt.__COMPILER_RUNTIME={__proto__:null,c:function(G){return H.H.useMemoCache(G)}},Rt.cache=function(G){return function(){return G.apply(null,arguments)}},Rt.cacheSignal=function(){return null},Rt.cloneElement=function(G,ce,I){if(G==null)throw Error("The argument must be a React element, but you passed "+G+".");var Ee=N({},G.props),Ue=G.key;if(ce!=null)for(De in ce.key!==void 0&&(Ue=""+ce.key),ce)!W.call(ce,De)||De==="key"||De==="__self"||De==="__source"||De==="ref"&&ce.ref===void 0||(Ee[De]=ce[De]);var De=arguments.length-2;if(De===1)Ee.children=I;else if(1<De){for(var Ke=Array(De),st=0;st<De;st++)Ke[st]=arguments[st+2];Ee.children=Ke}return Z(G.type,Ue,Ee)},Rt.createContext=function(G){return G={$$typeof:u,_currentValue:G,_currentValue2:G,_threadCount:0,Provider:null,Consumer:null},G.Provider=G,G.Consumer={$$typeof:l,_context:G},G},Rt.createElement=function(G,ce,I){var Ee,Ue={},De=null;if(ce!=null)for(Ee in ce.key!==void 0&&(De=""+ce.key),ce)W.call(ce,Ee)&&Ee!=="key"&&Ee!=="__self"&&Ee!=="__source"&&(Ue[Ee]=ce[Ee]);var Ke=arguments.length-2;if(Ke===1)Ue.children=I;else if(1<Ke){for(var st=Array(Ke),mt=0;mt<Ke;mt++)st[mt]=arguments[mt+2];Ue.children=st}if(G&&G.defaultProps)for(Ee in Ke=G.defaultProps,Ke)Ue[Ee]===void 0&&(Ue[Ee]=Ke[Ee]);return Z(G,De,Ue)},Rt.createRef=function(){return{current:null}},Rt.forwardRef=function(G){return{$$typeof:d,render:G}},Rt.isValidElement=Y,Rt.lazy=function(G){return{$$typeof:p,_payload:{_status:-1,_result:G},_init:re}},Rt.memo=function(G,ce){return{$$typeof:h,type:G,compare:ce===void 0?null:ce}},Rt.startTransition=function(G){var ce=H.T,I={};H.T=I;try{var Ee=G(),Ue=H.S;Ue!==null&&Ue(I,Ee),typeof Ee=="object"&&Ee!==null&&typeof Ee.then=="function"&&Ee.then(D,we)}catch(De){we(De)}finally{ce!==null&&I.types!==null&&(ce.types=I.types),H.T=ce}},Rt.unstable_useCacheRefresh=function(){return H.H.useCacheRefresh()},Rt.use=function(G){return H.H.use(G)},Rt.useActionState=function(G,ce,I){return H.H.useActionState(G,ce,I)},Rt.useCallback=function(G,ce){return H.H.useCallback(G,ce)},Rt.useContext=function(G){return H.H.useContext(G)},Rt.useDebugValue=function(){},Rt.useDeferredValue=function(G,ce){return H.H.useDeferredValue(G,ce)},Rt.useEffect=function(G,ce){return H.H.useEffect(G,ce)},Rt.useEffectEvent=function(G){return H.H.useEffectEvent(G)},Rt.useId=function(){return H.H.useId()},Rt.useImperativeHandle=function(G,ce,I){return H.H.useImperativeHandle(G,ce,I)},Rt.useInsertionEffect=function(G,ce){return H.H.useInsertionEffect(G,ce)},Rt.useLayoutEffect=function(G,ce){return H.H.useLayoutEffect(G,ce)},Rt.useMemo=function(G,ce){return H.H.useMemo(G,ce)},Rt.useOptimistic=function(G,ce){return H.H.useOptimistic(G,ce)},Rt.useReducer=function(G,ce,I){return H.H.useReducer(G,ce,I)},Rt.useRef=function(G){return H.H.useRef(G)},Rt.useState=function(G){return H.H.useState(G)},Rt.useSyncExternalStore=function(G,ce,I){return H.H.useSyncExternalStore(G,ce,I)},Rt.useTransition=function(){return H.H.useTransition()},Rt.version="19.2.4",Rt}var my;function p0(){return my||(my=1,Hf.exports=RS()),Hf.exports}var k=p0();const fW=xc(k);var Ff={exports:{}},Fl={},qf={exports:{}},Gf={};var fy;function OS(){return fy||(fy=1,(function(e){function t(B,Q){var re=B.length;B.push(Q);e:for(;0<re;){var we=re-1>>>1,$=B[we];if(0<o($,Q))B[we]=Q,B[re]=$,re=we;else break e}}function n(B){return B.length===0?null:B[0]}function r(B){if(B.length===0)return null;var Q=B[0],re=B.pop();if(re!==Q){B[0]=re;e:for(var we=0,$=B.length,G=$>>>1;we<G;){var ce=2*(we+1)-1,I=B[ce],Ee=ce+1,Ue=B[Ee];if(0>o(I,re))Ee<$&&0>o(Ue,I)?(B[we]=Ue,B[Ee]=re,we=Ee):(B[we]=I,B[ce]=re,we=ce);else if(Ee<$&&0>o(Ue,re))B[we]=Ue,B[Ee]=re,we=Ee;else break e}}return Q}function o(B,Q){var re=B.sortIndex-Q.sortIndex;return re!==0?re:B.id-Q.id}if(e.unstable_now=void 0,typeof performance=="object"&&typeof performance.now=="function"){var l=performance;e.unstable_now=function(){return l.now()}}else{var u=Date,d=u.now();e.unstable_now=function(){return u.now()-d}}var m=[],h=[],p=1,g=null,x=3,y=!1,w=!1,N=!1,T=!1,C=typeof setTimeout=="function"?setTimeout:null,j=typeof clearTimeout=="function"?clearTimeout:null,_=typeof setImmediate<"u"?setImmediate:null;function O(B){for(var Q=n(h);Q!==null;){if(Q.callback===null)r(h);else if(Q.startTime<=B)r(h),Q.sortIndex=Q.expirationTime,t(m,Q);else break;Q=n(h)}}function z(B){if(N=!1,O(B),!w)if(n(m)!==null)w=!0,D||(D=!0,ae());else{var Q=n(h);Q!==null&&J(z,Q.startTime-B)}}var D=!1,H=-1,W=5,Z=-1;function U(){return T?!0:!(e.unstable_now()-Z<W)}function Y(){if(T=!1,D){var B=e.unstable_now();Z=B;var Q=!0;try{e:{w=!1,N&&(N=!1,j(H),H=-1),y=!0;var re=x;try{t:{for(O(B),g=n(m);g!==null&&!(g.expirationTime>B&&U());){var we=g.callback;if(typeof we=="function"){g.callback=null,x=g.priorityLevel;var $=we(g.expirationTime<=B);if(B=e.unstable_now(),typeof $=="function"){g.callback=$,O(B),Q=!0;break t}g===n(m)&&r(m),O(B)}else r(m);g=n(m)}if(g!==null)Q=!0;else{var G=n(h);G!==null&&J(z,G.startTime-B),Q=!1}}break e}finally{g=null,x=re,y=!1}Q=void 0}}finally{Q?ae():D=!1}}}var ae;if(typeof _=="function")ae=function(){_(Y)};else if(typeof MessageChannel<"u"){var X=new MessageChannel,F=X.port2;X.port1.onmessage=Y,ae=function(){F.postMessage(null)}}else ae=function(){C(Y,0)};function J(B,Q){H=C(function(){B(e.unstable_now())},Q)}e.unstable_IdlePriority=5,e.unstable_ImmediatePriority=1,e.unstable_LowPriority=4,e.unstable_NormalPriority=3,e.unstable_Profiling=null,e.unstable_UserBlockingPriority=2,e.unstable_cancelCallback=function(B){B.callback=null},e.unstable_forceFrameRate=function(B){0>B||125<B?console.error("forceFrameRate takes a positive int between 0 and 125, forcing frame rates higher than 125 fps is not supported"):W=0<B?Math.floor(1e3/B):5},e.unstable_getCurrentPriorityLevel=function(){return x},e.unstable_next=function(B){switch(x){case 1:case 2:case 3:var Q=3;break;default:Q=x}var re=x;x=Q;try{return B()}finally{x=re}},e.unstable_requestPaint=function(){T=!0},e.unstable_runWithPriority=function(B,Q){switch(B){case 1:case 2:case 3:case 4:case 5:break;default:B=3}var re=x;x=B;try{return Q()}finally{x=re}},e.unstable_scheduleCallback=function(B,Q,re){var we=e.unstable_now();switch(typeof re=="object"&&re!==null?(re=re.delay,re=typeof re=="number"&&0<re?we+re:we):re=we,B){case 1:var $=-1;break;case 2:$=250;break;case 5:$=1073741823;break;case 4:$=1e4;break;default:$=5e3}return $=re+$,B={id:p++,callback:Q,priorityLevel:B,startTime:re,expirationTime:$,sortIndex:-1},re>we?(B.sortIndex=re,t(h,B),n(m)===null&&B===n(h)&&(N?(j(H),H=-1):N=!0,J(z,re-we))):(B.sortIndex=$,t(m,B),w||y||(w=!0,D||(D=!0,ae()))),B},e.unstable_shouldYield=U,e.unstable_wrapCallback=function(B){var Q=x;return function(){var re=x;x=Q;try{return B.apply(this,arguments)}finally{x=re}}}})(Gf)),Gf}var hy;function DS(){return hy||(hy=1,qf.exports=OS()),qf.exports}var Vf={exports:{}},nr={};var py;function LS(){if(py)return nr;py=1;var e=p0();function t(m){var h="https://react.dev/errors/"+m;if(1<arguments.length){h+="?args[]="+encodeURIComponent(arguments[1]);for(var p=2;p<arguments.length;p++)h+="&args[]="+encodeURIComponent(arguments[p])}return"Minified React error #"+m+"; visit "+h+" for the full message or use the non-minified dev environment for full errors and additional helpful warnings."}function n(){}var r={d:{f:n,r:function(){throw Error(t(522))},D:n,C:n,L:n,m:n,X:n,S:n,M:n},p:0,findDOMNode:null},o=Symbol.for("react.portal");function l(m,h,p){var g=3<arguments.length&&arguments[3]!==void 0?arguments[3]:null;return{$$typeof:o,key:g==null?null:""+g,children:m,containerInfo:h,implementation:p}}var u=e.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE;function d(m,h){if(m==="font")return"";if(typeof h=="string")return h==="use-credentials"?h:""}return nr.__DOM_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE=r,nr.createPortal=function(m,h){var p=2<arguments.length&&arguments[2]!==void 0?arguments[2]:null;if(!h||h.nodeType!==1&&h.nodeType!==9&&h.nodeType!==11)throw Error(t(299));return l(m,h,null,p)},nr.flushSync=function(m){var h=u.T,p=r.p;try{if(u.T=null,r.p=2,m)return m()}finally{u.T=h,r.p=p,r.d.f()}},nr.preconnect=function(m,h){typeof m=="string"&&(h?(h=h.crossOrigin,h=typeof h=="string"?h==="use-credentials"?h:"":void 0):h=null,r.d.C(m,h))},nr.prefetchDNS=function(m){typeof m=="string"&&r.d.D(m)},nr.preinit=function(m,h){if(typeof m=="string"&&h&&typeof h.as=="string"){var p=h.as,g=d(p,h.crossOrigin),x=typeof h.integrity=="string"?h.integrity:void 0,y=typeof h.fetchPriority=="string"?h.fetchPriority:void 0;p==="style"?r.d.S(m,typeof h.precedence=="string"?h.precedence:void 0,{crossOrigin:g,integrity:x,fetchPriority:y}):p==="script"&&r.d.X(m,{crossOrigin:g,integrity:x,fetchPriority:y,nonce:typeof h.nonce=="string"?h.nonce:void 0})}},nr.preinitModule=function(m,h){if(typeof m=="string")if(typeof h=="object"&&h!==null){if(h.as==null||h.as==="script"){var p=d(h.as,h.crossOrigin);r.d.M(m,{crossOrigin:p,integrity:typeof h.integrity=="string"?h.integrity:void 0,nonce:typeof h.nonce=="string"?h.nonce:void 0})}}else h==null&&r.d.M(m)},nr.preload=function(m,h){if(typeof m=="string"&&typeof h=="object"&&h!==null&&typeof h.as=="string"){var p=h.as,g=d(p,h.crossOrigin);r.d.L(m,p,{crossOrigin:g,integrity:typeof h.integrity=="string"?h.integrity:void 0,nonce:typeof h.nonce=="string"?h.nonce:void 0,type:typeof h.type=="string"?h.type:void 0,fetchPriority:typeof h.fetchPriority=="string"?h.fetchPriority:void 0,referrerPolicy:typeof h.referrerPolicy=="string"?h.referrerPolicy:void 0,imageSrcSet:typeof h.imageSrcSet=="string"?h.imageSrcSet:void 0,imageSizes:typeof h.imageSizes=="string"?h.imageSizes:void 0,media:typeof h.media=="string"?h.media:void 0})}},nr.preloadModule=function(m,h){if(typeof m=="string")if(h){var p=d(h.as,h.crossOrigin);r.d.m(m,{as:typeof h.as=="string"&&h.as!=="script"?h.as:void 0,crossOrigin:p,integrity:typeof h.integrity=="string"?h.integrity:void 0})}else r.d.m(m)},nr.requestFormReset=function(m){r.d.r(m)},nr.unstable_batchedUpdates=function(m,h){return m(h)},nr.useFormState=function(m,h,p){return u.H.useFormState(m,h,p)},nr.useFormStatus=function(){return u.H.useHostTransitionStatus()},nr.version="19.2.4",nr}var gy;function L4(){if(gy)return Vf.exports;gy=1;function e(){if(!(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__>"u"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(e)}catch(t){console.error(t)}}return e(),Vf.exports=LS(),Vf.exports}var by;function IS(){if(by)return Fl;by=1;var e=DS(),t=p0(),n=L4();function r(a){var i="https://react.dev/errors/"+a;if(1<arguments.length){i+="?args[]="+encodeURIComponent(arguments[1]);for(var c=2;c<arguments.length;c++)i+="&args[]="+encodeURIComponent(arguments[c])}return"Minified React error #"+a+"; visit "+i+" for the full message or use the non-minified dev environment for full errors and additional helpful warnings."}function o(a){return!(!a||a.nodeType!==1&&a.nodeType!==9&&a.nodeType!==11)}function l(a){var i=a,c=a;if(a.alternate)for(;i.return;)i=i.return;else{a=i;do i=a,(i.flags&4098)!==0&&(c=i.return),a=i.return;while(a)}return i.tag===3?c:null}function u(a){if(a.tag===13){var i=a.memoizedState;if(i===null&&(a=a.alternate,a!==null&&(i=a.memoizedState)),i!==null)return i.dehydrated}return null}function d(a){if(a.tag===31){var i=a.memoizedState;if(i===null&&(a=a.alternate,a!==null&&(i=a.memoizedState)),i!==null)return i.dehydrated}return null}function m(a){if(l(a)!==a)throw Error(r(188))}function h(a){var i=a.alternate;if(!i){if(i=l(a),i===null)throw Error(r(188));return i!==a?null:a}for(var c=a,f=i;;){var b=c.return;if(b===null)break;var v=b.alternate;if(v===null){if(f=b.return,f!==null){c=f;continue}break}if(b.child===v.child){for(v=b.child;v;){if(v===c)return m(b),a;if(v===f)return m(b),i;v=v.sibling}throw Error(r(188))}if(c.return!==f.return)c=b,f=v;else{for(var A=!1,L=b.child;L;){if(L===c){A=!0,c=b,f=v;break}if(L===f){A=!0,f=b,c=v;break}L=L.sibling}if(!A){for(L=v.child;L;){if(L===c){A=!0,c=v,f=b;break}if(L===f){A=!0,f=v,c=b;break}L=L.sibling}if(!A)throw Error(r(189))}}if(c.alternate!==f)throw Error(r(190))}if(c.tag!==3)throw Error(r(188));return c.stateNode.current===c?a:i}function p(a){var i=a.tag;if(i===5||i===26||i===27||i===6)return a;for(a=a.child;a!==null;){if(i=p(a),i!==null)return i;a=a.sibling}return null}var g=Object.assign,x=Symbol.for("react.element"),y=Symbol.for("react.transitional.element"),w=Symbol.for("react.portal"),N=Symbol.for("react.fragment"),T=Symbol.for("react.strict_mode"),C=Symbol.for("react.profiler"),j=Symbol.for("react.consumer"),_=Symbol.for("react.context"),O=Symbol.for("react.forward_ref"),z=Symbol.for("react.suspense"),D=Symbol.for("react.suspense_list"),H=Symbol.for("react.memo"),W=Symbol.for("react.lazy"),Z=Symbol.for("react.activity"),U=Symbol.for("react.memo_cache_sentinel"),Y=Symbol.iterator;function ae(a){return a===null||typeof a!="object"?null:(a=Y&&a[Y]||a["@@iterator"],typeof a=="function"?a:null)}var X=Symbol.for("react.client.reference");function F(a){if(a==null)return null;if(typeof a=="function")return a.$$typeof===X?null:a.displayName||a.name||null;if(typeof a=="string")return a;switch(a){case N:return"Fragment";case C:return"Profiler";case T:return"StrictMode";case z:return"Suspense";case D:return"SuspenseList";case Z:return"Activity"}if(typeof a=="object")switch(a.$$typeof){case w:return"Portal";case _:return a.displayName||"Context";case j:return(a._context.displayName||"Context")+".Consumer";case O:var i=a.render;return a=a.displayName,a||(a=i.displayName||i.name||"",a=a!==""?"ForwardRef("+a+")":"ForwardRef"),a;case H:return i=a.displayName||null,i!==null?i:F(a.type)||"Memo";case W:i=a._payload,a=a._init;try{return F(a(i))}catch{}}return null}var J=Array.isArray,B=t.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,Q=n.__DOM_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,re={pending:!1,data:null,method:null,action:null},we=[],$=-1;function G(a){return{current:a}}function ce(a){0>$||(a.current=we[$],we[$]=null,$--)}function I(a,i){$++,we[$]=a.current,a.current=i}var Ee=G(null),Ue=G(null),De=G(null),Ke=G(null);function st(a,i){switch(I(De,i),I(Ue,a),I(Ee,null),i.nodeType){case 9:case 11:a=(a=i.documentElement)&&(a=a.namespaceURI)?Rx(a):0;break;default:if(a=i.tagName,i=i.namespaceURI)i=Rx(i),a=Ox(i,a);else switch(a){case"svg":a=1;break;case"math":a=2;break;default:a=0}}ce(Ee),I(Ee,a)}function mt(){ce(Ee),ce(Ue),ce(De)}function ct(a){a.memoizedState!==null&&I(Ke,a);var i=Ee.current,c=Ox(i,a.type);i!==c&&(I(Ue,a),I(Ee,c))}function Dt(a){Ue.current===a&&(ce(Ee),ce(Ue)),Ke.current===a&&(ce(Ke),zl._currentValue=re)}var Mt,Xt;function Me(a){if(Mt===void 0)try{throw Error()}catch(c){var i=c.stack.trim().match(/\n( *(at )?)/);Mt=i&&i[1]||"",Xt=-1<c.stack.indexOf(`
3
3
  at`)?" (<anonymous>)":-1<c.stack.indexOf("@")?"@unknown:0:0":""}return`
4
4
  `+Mt+a+Xt}var Ne=!1;function Re(a,i){if(!a||Ne)return"";Ne=!0;var c=Error.prepareStackTrace;Error.prepareStackTrace=void 0;try{var f={DetermineComponentFrameRoot:function(){try{if(i){var je=function(){throw Error()};if(Object.defineProperty(je.prototype,"props",{set:function(){throw Error()}}),typeof Reflect=="object"&&Reflect.construct){try{Reflect.construct(je,[])}catch(ke){var ve=ke}Reflect.construct(a,[],je)}else{try{je.call()}catch(ke){ve=ke}a.call(je.prototype)}}else{try{throw Error()}catch(ke){ve=ke}(je=a())&&typeof je.catch=="function"&&je.catch(function(){})}}catch(ke){if(ke&&ve&&typeof ke.stack=="string")return[ke.stack,ve.stack]}return[null,null]}};f.DetermineComponentFrameRoot.displayName="DetermineComponentFrameRoot";var b=Object.getOwnPropertyDescriptor(f.DetermineComponentFrameRoot,"name");b&&b.configurable&&Object.defineProperty(f.DetermineComponentFrameRoot,"name",{value:"DetermineComponentFrameRoot"});var v=f.DetermineComponentFrameRoot(),A=v[0],L=v[1];if(A&&L){var ne=A.split(`
@@ -645,7 +645,7 @@ l0,-`+(n+144)+`c-2,-159.3,-10,-310.7,-24,-454c-53.3,-528,-210,-949.7,
645
645
  `},h]}}const VF=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_-]*/}}),KF=["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"],WF=["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"],YF=[...KF,...WF],XF=["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(),Ok=["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(),Dk=["after","backdrop","before","cue","cue-region","first-letter","first-line","grammar-error","marker","part","placeholder","selection","slotted","spelling-error"].sort().reverse(),QF=["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(),ZF=Ok.concat(Dk).sort().reverse();function JF(e){const t=VF(e),n=ZF,r="and or not only",o="[\\w-]+",l="("+o+"|@\\{"+o+"\\})",u=[],d=[],m=function(_){return{className:"string",begin:"~?"+_+".*?"+_}},h=function(_,O,z){return{className:_,begin:O,relevance:z}},p={$pattern:/[a-z-]+/,keyword:r,attribute:XF.join(" ")},g={begin:"\\(",end:"\\)",contains:d,keywords:p,relevance:0};d.push(e.C_LINE_COMMENT_MODE,e.C_BLOCK_COMMENT_MODE,m("'"),m('"'),t.CSS_NUMBER_MODE,{begin:"(url|data-uri)\\(",starts:{className:"string",end:"[\\)\\n]",excludeEnd:!0}},t.HEXCOLOR,g,h("variable","@@?"+o,10),h("variable","@\\{"+o+"\\}"),h("built_in","~?`[^`]*?`"),{className:"attribute",begin:o+"\\s*:",end:":",returnBegin:!0,excludeEnd:!0},t.IMPORTANT,{beginKeywords:"and not"},t.FUNCTION_DISPATCH);const x=d.concat({begin:/\{/,end:/\}/,contains:u}),y={beginKeywords:"when",endsWithParent:!0,contains:[{beginKeywords:"and not"}].concat(d)},w={begin:l+"\\s*:",returnBegin:!0,end:/[;}]/,relevance:0,contains:[{begin:/-(webkit|moz|ms|o)-/},t.CSS_VARIABLE,{className:"attribute",begin:"\\b("+QF.join("|")+")\\b",end:/(?=:)/,starts:{endsWithParent:!0,illegal:"[<=$]",relevance:0,contains:d}}]},N={className:"keyword",begin:"@(import|media|charset|font-face|(-[a-z]+-)?keyframes|supports|document|namespace|page|viewport|host)\\b",starts:{end:"[;{}]",keywords:p,returnEnd:!0,contains:d,relevance:0}},T={className:"variable",variants:[{begin:"@"+o+"\\s*:",relevance:15},{begin:"@"+o}],starts:{end:"[;}]",returnEnd:!0,contains:x}},C={variants:[{begin:"[\\.#:&\\[>]",end:"[;{}]"},{begin:l,end:/\{/}],returnBegin:!0,returnEnd:!0,illegal:`[<='$"]`,relevance:0,contains:[e.C_LINE_COMMENT_MODE,e.C_BLOCK_COMMENT_MODE,y,h("keyword","all\\b"),h("variable","@\\{"+o+"\\}"),{begin:"\\b("+YF.join("|")+")\\b",className:"selector-tag"},t.CSS_NUMBER_MODE,h("selector-tag",l,0),h("selector-id","#"+l),h("selector-class","\\."+l,0),h("selector-tag","&",0),t.ATTRIBUTE_SELECTOR_MODE,{className:"selector-pseudo",begin:":("+Ok.join("|")+")"},{className:"selector-pseudo",begin:":(:)?("+Dk.join("|")+")"},{begin:/\(/,end:/\)/,relevance:0,contains:x},{begin:"!important"},t.FUNCTION_DISPATCH]},j={begin:o+`:(:)?(${n.join("|")})`,returnBegin:!0,contains:[C]};return u.push(e.C_LINE_COMMENT_MODE,e.C_BLOCK_COMMENT_MODE,N,T,j,w,C,y,t.FUNCTION_DISPATCH),{name:"Less",case_insensitive:!0,illegal:`[=>'/<($"]`,contains:u}}function eq(e){const t="\\[=*\\[",n="\\]=*\\]",r={begin:t,end:n,contains:["self"]},o=[e.COMMENT("--(?!"+t+")","$"),e.COMMENT("--"+t,n,{contains:[r],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:o.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:o}].concat(o)},e.C_NUMBER_MODE,e.APOS_STRING_MODE,e.QUOTE_STRING_MODE,{className:"string",begin:t,end:n,contains:[r],relevance:5}])}}function tq(e){const t={className:"variable",variants:[{begin:"\\$\\("+e.UNDERSCORE_IDENT_RE+"\\)",contains:[e.BACKSLASH_ESCAPE]},{begin:/\$[@%<?\^\+\*]/}]},n={className:"string",begin:/"/,end:/"/,contains:[e.BACKSLASH_ESCAPE,t]},r={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:[t,n]},o={begin:"^"+e.UNDERSCORE_IDENT_RE+"\\s*(?=[:+?]?=)"},l={className:"meta",begin:/^\.PHONY:/,end:/$/,keywords:{$pattern:/[\.\w]+/,keyword:".PHONY"}},u={className:"section",begin:/^[^\s]+:/,end:/$/,contains:[t]};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,t,n,r,o,l,u]}}function nq(e){const t=e.regex,n={begin:/<\/?[A-Za-z_]/,end:">",subLanguage:"xml",relevance:0},r={begin:"^[-\\*]{3,}",end:"$"},o={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}]},l={className:"bullet",begin:"^[ ]*([*+-]|(\\d+\\.))(?=\\s+)",end:"\\s+",excludeEnd:!0},u={begin:/^\[[^\n]+\]:/,returnBegin:!0,contains:[{className:"symbol",begin:/\[/,end:/\]/,excludeBegin:!0,excludeEnd:!0},{className:"link",begin:/:\s*/,end:/$/,excludeBegin:!0}]},d=/[A-Za-z][A-Za-z0-9+.-]*/,m={variants:[{begin:/\[.+?\]\[.*?\]/,relevance:0},{begin:/\[.+?\]\(((data|javascript|mailto):|(?:http|ftp)s?:\/\/).*?\)/,relevance:2},{begin:t.concat(/\[.+?\]\(/,d,/:\/\/.*?\)/),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}]},h={className:"strong",contains:[],variants:[{begin:/_{2}(?!\s)/,end:/_{2}/},{begin:/\*{2}(?!\s)/,end:/\*{2}/}]},p={className:"emphasis",contains:[],variants:[{begin:/\*(?![*\s])/,end:/\*/},{begin:/_(?![_\s])/,end:/_/,relevance:0}]},g=e.inherit(h,{contains:[]}),x=e.inherit(p,{contains:[]});h.contains.push(x),p.contains.push(g);let y=[n,m];return[h,p,g,x].forEach(C=>{C.contains=C.contains.concat(y)}),y=y.concat(h,p),{name:"Markdown",aliases:["md","mkdown","mkd"],contains:[{className:"section",variants:[{begin:"^#{1,6}",end:"$",contains:y},{begin:"(?=^.+?\\n[=-]{2,}$)",contains:[{begin:"^[=-]*$"},{begin:"^",end:"\\n",contains:y}]}]},n,l,h,p,{className:"quote",begin:"^>\\s+",contains:y,end:"$"},o,r,m,u,{scope:"literal",match:/&([a-zA-Z0-9]+|#[0-9]{1,7}|#[Xx][0-9a-fA-F]{1,6});/}]}}function rq(e){const t={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+"},n=/[a-zA-Z@][a-zA-Z0-9_]*/,d={"variable.language":["this","super"],$pattern:n,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"]},m={$pattern:n,keyword:["@interface","@class","@protocol","@implementation"]};return{name:"Objective-C",aliases:["mm","objc","obj-c","obj-c++","objective-c++"],keywords:d,illegal:"</",contains:[t,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:"("+m.keyword.join("|")+")\\b",end:/(\{|$)/,excludeEnd:!0,keywords:m,contains:[e.UNDERSCORE_TITLE_MODE]},{begin:"\\."+e.UNDERSCORE_IDENT_RE,relevance:0}]}}function aq(e){const t=e.regex,n=["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"],r=/[dualxmsipngr]{0,12}/,o={$pattern:/[\w.]+/,keyword:n.join(" ")},l={className:"subst",begin:"[$@]\\{",end:"\\}",keywords:o},u={begin:/->\{/,end:/\}/},d={scope:"attr",match:/\s+:\s*\w+(\s*\(.*?\))?/},m={scope:"variable",variants:[{begin:/\$\d/},{begin:t.concat(/[$%@](?!")(\^\w\b|#\w+(::\w+)*|\{\w+\}|\w+(::\w*)*)/,"(?![A-Za-z])(?![@$%])")},{begin:/[$%@](?!")[^\s\w{=]|\$=/,relevance:0}],contains:[d]},h={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},p=[e.BACKSLASH_ESCAPE,l,m],g=[/!/,/\//,/\|/,/\?/,/'/,/"/,/#/],x=(N,T,C="\\1")=>{const j=C==="\\1"?C:t.concat(C,T);return t.concat(t.concat("(?:",N,")"),T,/(?:\\.|[^\\\/])*?/,j,/(?:\\.|[^\\\/])*?/,C,r)},y=(N,T,C)=>t.concat(t.concat("(?:",N,")"),T,/(?:\\.|[^\\\/])*?/,C,r),w=[m,e.HASH_COMMENT_MODE,e.COMMENT(/^=\w/,/=cut/,{endsWithParent:!0}),u,{className:"string",contains:p,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}]},h,{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:x("s|tr|y",t.either(...g,{capture:!0}))},{begin:x("s|tr|y","\\(","\\)")},{begin:x("s|tr|y","\\[","\\]")},{begin:x("s|tr|y","\\{","\\}")}],relevance:2},{className:"regexp",variants:[{begin:/(m|qr)\/\//,relevance:0},{begin:y("(?:m|qr)?",/\//,/\//)},{begin:y("m|qr",t.either(...g,{capture:!0}),/\1/)},{begin:y("m|qr",/\(/,/\)/)},{begin:y("m|qr",/\[/,/\]/)},{begin:y("m|qr",/\{/,/\}/)}]}]},{className:"function",beginKeywords:"sub method",end:"(\\s*\\(.*?\\))?[;{]",excludeEnd:!0,relevance:5,contains:[e.TITLE_MODE,d]},{className:"class",beginKeywords:"class",end:"[;{]",excludeEnd:!0,relevance:5,contains:[e.TITLE_MODE,d,h]},{begin:"-\\w\\b",relevance:0},{begin:"^__DATA__$",end:"^__END__$",subLanguage:"mojolicious",contains:[{begin:"^@@.*",end:"$",className:"comment"}]}];return l.contains=w,u.contains=w,{name:"Perl",aliases:["pl","pm"],keywords:o,contains:w}}function sq(e){const t=e.regex,n=/(?![A-Za-z0-9])(?![$])/,r=t.concat(/[a-zA-Z_\x7f-\xff][a-zA-Z0-9_\x7f-\xff]*/,n),o=t.concat(/(\\?[A-Z][a-z0-9_\x7f-\xff]+|\\?[A-Z]+(?=[A-Z][a-z0-9_\x7f-\xff])){1,}/,n),l=t.concat(/[A-Z]+/,n),u={scope:"variable",match:"\\$+"+r},d={scope:"meta",variants:[{begin:/<\?php/,relevance:10},{begin:/<\?=/},{begin:/<\?/,relevance:.1},{begin:/\?>/}]},m={scope:"subst",variants:[{begin:/\$\w+/},{begin:/\{\$/,end:/\}/}]},h=e.inherit(e.APOS_STRING_MODE,{illegal:null}),p=e.inherit(e.QUOTE_STRING_MODE,{illegal:null,contains:e.QUOTE_STRING_MODE.contains.concat(m)}),g={begin:/<<<[ \t]*(?:(\w+)|"(\w+)")\n/,end:/[ \t]*(\w+)\b/,contains:e.QUOTE_STRING_MODE.contains.concat(m),"on:begin":(F,J)=>{J.data._beginMatch=F[1]||F[2]},"on:end":(F,J)=>{J.data._beginMatch!==F[1]&&J.ignoreMatch()}},x=e.END_SAME_AS_BEGIN({begin:/<<<[ \t]*'(\w+)'\n/,end:/[ \t]*(\w+)\b/}),y=`[
646
646
  ]`,w={scope:"string",variants:[p,h,g,x]},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},T=["false","null","true"],C=["__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"],O={keyword:C,literal:(F=>{const J=[];return F.forEach(B=>{J.push(B),B.toLowerCase()===B?J.push(B.toUpperCase()):J.push(B.toLowerCase())}),J})(T),built_in:j},z=F=>F.map(J=>J.replace(/\|\d+$/,"")),D={variants:[{match:[/new/,t.concat(y,"+"),t.concat("(?!",z(j).join("\\b|"),"\\b)"),o],scope:{1:"keyword",4:"title.class"}}]},H=t.concat(r,"\\b(?!\\()"),W={variants:[{match:[t.concat(/::/,t.lookahead(/(?!class\b)/)),H],scope:{2:"variable.constant"}},{match:[/::/,/class/],scope:{2:"variable.language"}},{match:[o,t.concat(/::/,t.lookahead(/(?!class\b)/)),H],scope:{1:"title.class",3:"variable.constant"}},{match:[o,t.concat("::",t.lookahead(/(?!class\b)/))],scope:{1:"title.class"}},{match:[o,/::/,/class/],scope:{1:"title.class",3:"variable.language"}}]},Z={scope:"attr",match:t.concat(r,t.lookahead(":"),t.lookahead(/(?!::)/))},U={relevance:0,begin:/\(/,end:/\)/,keywords:O,contains:[Z,u,W,e.C_BLOCK_COMMENT_MODE,w,N,D]},Y={relevance:0,match:[/\b/,t.concat("(?!fn\\b|function\\b|",z(C).join("\\b|"),"|",z(j).join("\\b|"),"\\b)"),r,t.concat(y,"*"),t.lookahead(/(?=\()/)],scope:{3:"title.function.invoke"},contains:[U]};U.contains.push(Y);const ae=[Z,W,e.C_BLOCK_COMMENT_MODE,w,N,D],X={begin:t.concat(/#\[\s*\\?/,t.either(o,l)),beginScope:"meta",end:/]/,endScope:"meta",keywords:{literal:T,keyword:["new","array"]},contains:[{begin:/\[/,end:/]/,keywords:{literal:T,keyword:["new","array"]},contains:["self",...ae]},...ae,{scope:"meta",variants:[{match:o},{match:l}]}]};return{case_insensitive:!1,keywords:O,contains:[X,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}]}},d,{scope:"variable.language",match:/\$this\b/},u,Y,W,{match:[/const/,/\s/,r],scope:{1:"keyword",3:"variable.constant"}},D,{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:O,contains:["self",X,u,W,e.C_BLOCK_COMMENT_MODE,w,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]},w,N]}}function iq(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 oq(e){return{name:"Plain text",aliases:["text","txt"],disableAutodetect:!0}}function lq(e){const t=e.regex,n=new RegExp("[\\p{XID_Start}_]\\p{XID_Continue}*","u"),r=["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"],d={$pattern:/[A-Za-z]\w+|__\w+__/,keyword:r,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"]},m={className:"meta",begin:/^(>>>|\.\.\.) /},h={className:"subst",begin:/\{/,end:/\}/,keywords:d,illegal:/#/},p={begin:/\{\{/,relevance:0},g={className:"string",contains:[e.BACKSLASH_ESCAPE],variants:[{begin:/([uU]|[bB]|[rR]|[bB][rR]|[rR][bB])?'''/,end:/'''/,contains:[e.BACKSLASH_ESCAPE,m],relevance:10},{begin:/([uU]|[bB]|[rR]|[bB][rR]|[rR][bB])?"""/,end:/"""/,contains:[e.BACKSLASH_ESCAPE,m],relevance:10},{begin:/([fF][rR]|[rR][fF]|[fF])'''/,end:/'''/,contains:[e.BACKSLASH_ESCAPE,m,p,h]},{begin:/([fF][rR]|[rR][fF]|[fF])"""/,end:/"""/,contains:[e.BACKSLASH_ESCAPE,m,p,h]},{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,p,h]},{begin:/([fF][rR]|[rR][fF]|[fF])"/,end:/"/,contains:[e.BACKSLASH_ESCAPE,p,h]},e.APOS_STRING_MODE,e.QUOTE_STRING_MODE]},x="[0-9](_?[0-9])*",y=`(\\b(${x}))?\\.(${x})|\\b(${x})\\.`,w=`\\b|${r.join("|")}`,N={className:"number",relevance:0,variants:[{begin:`(\\b(${x})|(${y}))[eE][+-]?(${x})[jJ]?(?=${w})`},{begin:`(${y})[jJ]?`},{begin:`\\b([1-9](_?[0-9])*|0+(_?0)*)[lLjJ]?(?=${w})`},{begin:`\\b0[bB](_?[01])+[lL]?(?=${w})`},{begin:`\\b0[oO](_?[0-7])+[lL]?(?=${w})`},{begin:`\\b0[xX](_?[0-9a-fA-F])+[lL]?(?=${w})`},{begin:`\\b(${x})[jJ](?=${w})`}]},T={className:"comment",begin:t.lookahead(/# type:/),end:/$/,keywords:d,contains:[{begin:/# type:/},{begin:/#/,end:/\b\B/,endsWithParent:!0}]},C={className:"params",variants:[{className:"",begin:/\(\s*\)/,skip:!0},{begin:/\(/,end:/\)/,excludeBegin:!0,excludeEnd:!0,keywords:d,contains:["self",m,N,g,e.HASH_COMMENT_MODE]}]};return h.contains=[g,N,m],{name:"Python",aliases:["py","gyp","ipython"],unicodeRegex:!0,keywords:d,illegal:/(<\/|\?)|=>/,contains:[m,N,{scope:"variable.language",match:/\bself\b/},{beginKeywords:"if",relevance:0},{match:/\bor\b/,scope:"keyword"},g,T,e.HASH_COMMENT_MODE,{match:[/\bdef/,/\s+/,n],scope:{1:"keyword",3:"title.function"},contains:[C]},{variants:[{match:[/\bclass/,/\s+/,n,/\s*/,/\(\s*/,n,/\s*\)/]},{match:[/\bclass/,/\s+/,n]}],scope:{1:"keyword",3:"title.class",6:"title.class.inherited"}},{className:"meta",begin:/^[\t ]*@/,end:/(?=#)|$/,contains:[N,C,g]}]}}function cq(e){return{aliases:["pycon"],contains:[{className:"meta.prompt",starts:{end:/ |$/,starts:{end:"$",subLanguage:"python"}},variants:[{begin:/^>>>(?=[ ]|$)/},{begin:/^\.\.\.(?=[ ]|$)/}]}]}}function uq(e){const t=e.regex,n=/(?:(?:[a-zA-Z]|\.[._a-zA-Z])[._a-zA-Z0-9]*)|\.(?!\d)/,r=t.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]?/),o=/[=!<>:]=|\|\||&&|:::?|<-|<<-|->>|->|\|>|[-+*\/?!$&|:<=>@^~]|\*\*/,l=t.either(/[()]/,/[{}]/,/\[\[/,/[[\]]/,/\\/,/,/);return{name:"R",keywords:{$pattern:n,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:t.lookahead(t.either(/\n^#'\s*(?=@[a-zA-Z]+)/,/\n^(?!#')/)),endsParent:!0}},{scope:"doctag",begin:"@param",end:/$/,contains:[{scope:"variable",variants:[{match:n},{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:[o,r]},{scope:{1:"operator",2:"number"},match:[/%[^%]*%/,r]},{scope:{1:"punctuation",2:"number"},match:[l,r]},{scope:{2:"number"},match:[/[^a-zA-Z0-9._]|^/,r]}]},{scope:{3:"operator"},match:[n,/\s+/,/<-/,/\s+/]},{scope:"operator",relevance:0,variants:[{match:o},{match:/%[^%]*%/}]},{scope:"punctuation",relevance:0,match:l},{begin:"`",end:"`",contains:[{begin:/\\./}]}]}}function dq(e){const t=e.regex,n="([a-zA-Z_]\\w*[!?=]?|[-+~]@|<<|>>|=~|===?|<=>|[<>]=?|\\*\\*|[-/+%^&*~`|]|\\[\\]=?)",r=t.either(/\b([A-Z]+[a-z0-9]+)+/,/\b([A-Z]+[a-z0-9]+)+[A-Z]+/),o=t.concat(r,/(::\w+)*/),u={"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"]},d={className:"doctag",begin:"@[A-Za-z]+"},m={begin:"#<",end:">"},h=[e.COMMENT("#","$",{contains:[d]}),e.COMMENT("^=begin","^=end",{contains:[d],relevance:10}),e.COMMENT("^__END__",e.MATCH_NOTHING_RE)],p={className:"subst",begin:/#\{/,end:/\}/,keywords:u},g={className:"string",contains:[e.BACKSLASH_ESCAPE,p],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:t.concat(/<<[-~]?'?/,t.lookahead(/(\w+)(?=\W)[^\n]*\n(?:[^\n]*\n)*?\s*\1\b/)),contains:[e.END_SAME_AS_BEGIN({begin:/(\w+)/,end:/(\w+)/,contains:[e.BACKSLASH_ESCAPE,p]})]}]},x="[1-9](_?[0-9])*|0",y="[0-9](_?[0-9])*",w={className:"number",relevance:0,variants:[{begin:`\\b(${x})(\\.(${y}))?([eE][+-]?(${y})|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:u}]},D=[g,{variants:[{match:[/class\s+/,o,/\s+<\s+/,o]},{match:[/\b(class|module)\s+/,o]}],scope:{2:"title.class",4:"title.class.inherited"},keywords:u},{match:[/(include|extend)\s+/,o],scope:{2:"title.class"},keywords:u},{relevance:0,match:[o,/\.new[. (]/],scope:{1:"title.class"}},{relevance:0,match:/\b[A-Z][A-Z_0-9]+\b/,className:"variable.constant"},{relevance:0,match:r,scope:"title.class"},{match:[/def/,/\s+/,n],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:[g,{begin:n}],relevance:0},w,{className:"variable",begin:"(\\$\\W)|((\\$|@@?)(\\w+))(?=[^@$?])(?![A-Za-z])(?![@$?'])"},{className:"params",begin:/\|(?!=)/,end:/\|/,excludeBegin:!0,excludeEnd:!0,relevance:0,keywords:u},{begin:"("+e.RE_STARTERS_RE+"|unless)\\s*",keywords:"unless",contains:[{className:"regexp",contains:[e.BACKSLASH_ESCAPE,p],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(m,h),relevance:0}].concat(m,h);p.contains=D,N.contains=D;const U=[{begin:/^\s*=>/,starts:{end:"$",contains:D}},{className:"meta.prompt",begin:"^("+"[>?]>"+"|"+"[\\w#]+\\(\\w+\\):\\d+:\\d+[>*]"+"|"+"(\\w+-)?\\d+\\.\\d+\\.\\d+(p\\d+)?[^\\d][^>]+>"+")(?=[ ])",starts:{end:"$",keywords:u,contains:D}}];return h.unshift(m),{name:"Ruby",aliases:["rb","gemspec","podspec","thor","irb"],keywords:u,illegal:/\/\*/,contains:[e.SHEBANG({binary:"ruby"})].concat(U).concat(h).concat(D)}}function mq(e){const t=e.regex,n=/(r#)?/,r=t.concat(n,e.UNDERSCORE_IDENT_RE),o=t.concat(n,e.IDENT_RE),l={className:"title.function.invoke",relevance:0,begin:t.concat(/\b/,/(?!let|for|while|if|else|match\b)/,o,t.lookahead(/\s*\(/))},u="([ui](8|16|32|64|128|size)|f(32|64))?",d=["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"],m=["true","false","Some","None","Ok","Err"],h=["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!"],p=["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:p,keyword:d,literal:m,built_in:h},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_]+)"+u},{begin:"\\b0o([0-7_]+)"+u},{begin:"\\b0x([A-Fa-f0-9_]+)"+u},{begin:"\\b(\\d[\\d_]*(\\.[0-9_]+)?([eE][+-]?[0-9_]+)?)"+u}],relevance:0},{begin:[/fn/,/\s+/,r],className:{1:"keyword",3:"title.function"}},{className:"meta",begin:"#!?\\[",end:"\\]",contains:[{className:"string",begin:/"/,end:/"/,contains:[e.BACKSLASH_ESCAPE]}]},{begin:[/let/,/\s+/,/(?:mut\s+)?/,r],className:{1:"keyword",3:"keyword",4:"variable"}},{begin:[/for/,/\s+/,r,/\s+/,/in/],className:{1:"keyword",3:"variable",5:"keyword"}},{begin:[/type/,/\s+/,r],className:{1:"keyword",3:"title.class"}},{begin:[/(?:trait|enum|struct|union|impl|for)/,/\s+/,r],className:{1:"keyword",3:"title.class"}},{begin:e.IDENT_RE+"::",keywords:{keyword:"Self",built_in:h,type:p}},{className:"punctuation",begin:"->"},l]}}const fq=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_-]*/}}),hq=["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"],pq=["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"],gq=[...hq,...pq],bq=["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(),xq=["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(),yq=["after","backdrop","before","cue","cue-region","first-letter","first-line","grammar-error","marker","part","placeholder","selection","slotted","spelling-error"].sort().reverse(),vq=["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 wq(e){const t=fq(e),n=yq,r=xq,o="@[a-z-]+",l="and or not only",d={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,t.CSS_NUMBER_MODE,{className:"selector-id",begin:"#[A-Za-z0-9_-]+",relevance:0},{className:"selector-class",begin:"\\.[A-Za-z0-9_-]+",relevance:0},t.ATTRIBUTE_SELECTOR_MODE,{className:"selector-tag",begin:"\\b("+gq.join("|")+")\\b",relevance:0},{className:"selector-pseudo",begin:":("+r.join("|")+")"},{className:"selector-pseudo",begin:":(:)?("+n.join("|")+")"},d,{begin:/\(/,end:/\)/,contains:[t.CSS_NUMBER_MODE]},t.CSS_VARIABLE,{className:"attribute",begin:"\\b("+vq.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:[t.BLOCK_COMMENT,d,t.HEXCOLOR,t.CSS_NUMBER_MODE,e.QUOTE_STRING_MODE,e.APOS_STRING_MODE,t.IMPORTANT,t.FUNCTION_DISPATCH]},{begin:"@(page|font-face)",keywords:{$pattern:o,keyword:"@page @font-face"}},{begin:"@",end:"[{;]",returnBegin:!0,keywords:{$pattern:/[a-z-]+/,keyword:l,attribute:bq.join(" ")},contains:[{begin:o,className:"keyword"},{begin:/[a-z-]+(?=:)/,className:"attribute"},d,e.QUOTE_STRING_MODE,e.APOS_STRING_MODE,t.HEXCOLOR,t.CSS_NUMBER_MODE]},t.FUNCTION_DISPATCH]}}function kq(e){return{name:"Shell Session",aliases:["console","shellsession"],contains:[{className:"meta.prompt",begin:/^\s{0,3}[/~\w\d[\]()@-]*[>%$#][ ]?/,starts:{end:/[^\\](?=\s*$)/,subLanguage:"bash"}}]}}function Sq(e){const t=e.regex,n=e.COMMENT("--","$"),r={scope:"string",variants:[{begin:/'/,end:/'/,contains:[{match:/''/}]}]},o={begin:/"/,end:/"/,contains:[{match:/""/}]},l=["true","false","unknown"],u=["double precision","large object","with timezone","without timezone"],d=["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"],m=["add","asc","collation","desc","final","first","last","view"],h=["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"],p=["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"],g=["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"],x=["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"],y=p,w=[...h,...m].filter(z=>!p.includes(z)),N={scope:"variable",match:/@[a-z0-9][a-z0-9_]*/},T={scope:"operator",match:/[-+*/=%^~]|&&?|\|\|?|!=?|<(?:=>?|<|>)?|>[>=]?/,relevance:0},C={match:t.concat(/\b/,t.either(...y),/\s*\(/),relevance:0,keywords:{built_in:y}};function j(z){return t.concat(/\b/,t.either(...z.map(D=>D.replace(/\s+/,"\\s+"))),/\b/)}const _={scope:"keyword",match:j(x),relevance:0};function O(z,{exceptions:D,when:H}={}){const W=H;return D=D||[],z.map(Z=>Z.match(/\|\d+$/)||D.includes(Z)?Z:W(Z)?`${Z}|0`:Z)}return{name:"SQL",case_insensitive:!0,illegal:/[{}]|<\//,keywords:{$pattern:/\b[\w\.]+/,keyword:O(w,{when:z=>z.length<3}),literal:l,type:d,built_in:g},contains:[{scope:"type",match:j(u)},_,C,N,r,o,e.C_NUMBER_MODE,e.C_BLOCK_COMMENT_MODE,n,T]}}function Lk(e){return e?typeof e=="string"?e:e.source:null}function Yl(e){return un("(?=",e,")")}function un(...e){return e.map(n=>Lk(n)).join("")}function Nq(e){const t=e[e.length-1];return typeof t=="object"&&t.constructor===Object?(e.splice(e.length-1,1),t):{}}function cr(...e){return"("+(Nq(e).capture?"":"?:")+e.map(r=>Lk(r)).join("|")+")"}const _g=e=>un(/\b/,e,/\w$/.test(e)?/\b/:/\B/),Cq=["Protocol","Type"].map(_g),_2=["init","self"].map(_g),Tq=["Any","Self"],Ph=["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"],j2=["false","nil","true"],Eq=["assignment","associativity","higherThan","left","lowerThan","none","right"],Aq=["#colorLiteral","#column","#dsohandle","#else","#elseif","#endif","#error","#file","#fileID","#fileLiteral","#filePath","#function","#if","#imageLiteral","#keyPath","#line","#selector","#sourceLocation","#warning"],M2=["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"],Ik=cr(/[/=\-+!*%<>&|^~?]/,/[\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]/),Pk=cr(Ik,/[\u0300-\u036F]/,/[\u1DC0-\u1DFF]/,/[\u20D0-\u20FF]/,/[\uFE00-\uFE0F]/,/[\uFE20-\uFE2F]/),zh=un(Ik,Pk,"*"),zk=cr(/[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]/),r0=cr(zk,/\d/,/[\u0300-\u036F\u1DC0-\u1DFF\u20D0-\u20FF\uFE20-\uFE2F]/),ba=un(zk,r0,"*"),ud=un(/[A-Z]/,r0,"*"),_q=["attached","autoclosure",un(/convention\(/,cr("swift","block","c"),/\)/),"discardableResult","dynamicCallable","dynamicMemberLookup","escaping","freestanding","frozen","GKInspectable","IBAction","IBDesignable","IBInspectable","IBOutlet","IBSegueAction","inlinable","main","nonobjc","NSApplicationMain","NSCopying","NSManaged",un(/objc\(/,ba,/\)/),"objc","objcMembers","propertyWrapper","requires_stored_property_inits","resultBuilder","Sendable","testable","UIApplicationMain","unchecked","unknown","usableFromInline","warn_unqualified_access"],jq=["iOS","iOSApplicationExtension","macOS","macOSApplicationExtension","macCatalyst","macCatalystApplicationExtension","watchOS","watchOSApplicationExtension","tvOS","tvOSApplicationExtension","swift"];function Mq(e){const t={match:/\s+/,relevance:0},n=e.COMMENT("/\\*","\\*/",{contains:["self"]}),r=[e.C_LINE_COMMENT_MODE,n],o={match:[/\./,cr(...Cq,..._2)],className:{2:"keyword"}},l={match:un(/\./,cr(...Ph)),relevance:0},u=Ph.filter(Re=>typeof Re=="string").concat(["_|0"]),d=Ph.filter(Re=>typeof Re!="string").concat(Tq).map(_g),m={variants:[{className:"keyword",match:cr(...d,..._2)}]},h={$pattern:cr(/\b\w+/,/#\w+/),keyword:u.concat(Aq),literal:j2},p=[o,l,m],g={match:un(/\./,cr(...M2)),relevance:0},x={className:"built_in",match:un(/\b/,cr(...M2),/(?=\()/)},y=[g,x],w={match:/->/,relevance:0},N={className:"operator",relevance:0,variants:[{match:zh},{match:`\\.(\\.|${Pk})+`}]},T=[w,N],C="([0-9]_*)+",j="([0-9a-fA-F]_*)+",_={className:"number",relevance:0,variants:[{match:`\\b(${C})(\\.(${C}))?([eE][+-]?(${C}))?\\b`},{match:`\\b0x(${j})(\\.(${j}))?([pP][+-]?(${C}))?\\b`},{match:/\b0o([0-7]_*)+\b/},{match:/\b0b([01]_*)+\b/}]},O=(Re="")=>({className:"subst",variants:[{match:un(/\\/,Re,/[0\\tnr"']/)},{match:un(/\\/,Re,/u\{[0-9a-fA-F]{1,8}\}/)}]}),z=(Re="")=>({className:"subst",match:un(/\\/,Re,/[\t ]*(?:[\r\n]|\r\n)/)}),D=(Re="")=>({className:"subst",label:"interpol",begin:un(/\\/,Re,/\(/),end:/\)/}),H=(Re="")=>({begin:un(Re,/"""/),end:un(/"""/,Re),contains:[O(Re),z(Re),D(Re)]}),W=(Re="")=>({begin:un(Re,/"/),end:un(/"/,Re),contains:[O(Re),D(Re)]}),Z={className:"string",variants:[H(),H("#"),H("##"),H("###"),W(),W("#"),W("##"),W("###")]},U=[e.BACKSLASH_ESCAPE,{begin:/\[/,end:/\]/,relevance:0,contains:[e.BACKSLASH_ESCAPE]}],Y={begin:/\/[^\s](?=[^/\n]*\/)/,end:/\//,contains:U},ae=Re=>{const ut=un(Re,/\//),it=un(/\//,Re);return{begin:ut,end:it,contains:[...U,{scope:"comment",begin:`#(?!.*${it})`,end:/$/}]}},X={scope:"regexp",variants:[ae("###"),ae("##"),ae("#"),Y]},F={match:un(/`/,ba,/`/)},J={className:"variable",match:/\$\d+/},B={className:"variable",match:`\\$${r0}+`},Q=[F,J,B],re={match:/(@|#(un)?)available/,scope:"keyword",starts:{contains:[{begin:/\(/,end:/\)/,keywords:jq,contains:[...T,_,Z]}]}},we={scope:"keyword",match:un(/@/,cr(..._q),Yl(cr(/\(/,/\s+/)))},$={scope:"meta",match:un(/@/,ba)},G=[re,we,$],ce={match:Yl(/\b[A-Z]/),relevance:0,contains:[{className:"type",match:un(/(AV|CA|CF|CG|CI|CL|CM|CN|CT|MK|MP|MTK|MTL|NS|SCN|SK|UI|WK|XC)/,r0,"+")},{className:"type",match:ud,relevance:0},{match:/[?!]+/,relevance:0},{match:/\.\.\./,relevance:0},{match:un(/\s+&\s+/,Yl(ud)),relevance:0}]},I={begin:/</,end:/>/,keywords:h,contains:[...r,...p,...G,w,ce]};ce.contains.push(I);const Ee={match:un(ba,/\s*:/),keywords:"_|0",relevance:0},Ue={begin:/\(/,end:/\)/,relevance:0,keywords:h,contains:["self",Ee,...r,X,...p,...y,...T,_,Z,...Q,...G,ce]},De={begin:/</,end:/>/,keywords:"repeat each",contains:[...r,ce]},Ke={begin:cr(Yl(un(ba,/\s*:/)),Yl(un(ba,/\s+/,ba,/\s*:/))),end:/:/,relevance:0,contains:[{className:"keyword",match:/\b_\b/},{className:"params",match:ba}]},st={begin:/\(/,end:/\)/,keywords:h,contains:[Ke,...r,...p,...T,_,Z,...G,ce,Ue],endsParent:!0,illegal:/["']/},mt={match:[/(func|macro)/,/\s+/,cr(F.match,ba,zh)],className:{1:"keyword",3:"title.function"},contains:[De,st,t],illegal:[/\[/,/%/]},ct={match:[/\b(?:subscript|init[?!]?)/,/\s*(?=[<(])/],className:{1:"keyword"},contains:[De,st,t],illegal:/\[|%/},Dt={match:[/operator/,/\s+/,zh],className:{1:"keyword",3:"title"}},Mt={begin:[/precedencegroup/,/\s+/,ud],className:{1:"keyword",3:"title"},contains:[ce],keywords:[...Eq,...j2],end:/}/},Xt={match:[/class\b/,/\s+/,/func\b/,/\s+/,/\b[A-Za-z_][A-Za-z0-9_]*\b/],scope:{1:"keyword",3:"keyword",5:"title.function"}},Me={match:[/class\b/,/\s+/,/var\b/],scope:{1:"keyword",3:"keyword"}},Ne={begin:[/(struct|protocol|class|extension|enum|actor)/,/\s+/,ba,/\s*/],beginScope:{1:"keyword",3:"title.class"},keywords:h,contains:[De,...p,{begin:/:/,end:/\{/,keywords:h,contains:[{scope:"title.class.inherited",match:ud},...p],relevance:0}]};for(const Re of Z.variants){const ut=Re.contains.find(bt=>bt.label==="interpol");ut.keywords=h;const it=[...p,...y,...T,_,Z,...Q];ut.contains=[...it,{begin:/\(/,end:/\)/,contains:["self",...it]}]}return{name:"Swift",keywords:h,contains:[...r,mt,ct,Xt,Me,Ne,Dt,Mt,{beginKeywords:"import",end:/$/,contains:[...r],relevance:0},X,...p,...y,...T,_,Z,...Q,...G,ce,Ue]}}const a0="[A-Za-z$_][0-9A-Za-z$_]*",Bk=["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"],Uk=["true","false","null","undefined","NaN","Infinity"],$k=["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"],Hk=["Error","EvalError","InternalError","RangeError","ReferenceError","SyntaxError","TypeError","URIError"],Fk=["setInterval","setTimeout","clearInterval","clearTimeout","require","exports","eval","isFinite","isNaN","parseFloat","parseInt","decodeURI","decodeURIComponent","encodeURI","encodeURIComponent","escape","unescape"],qk=["arguments","this","super","console","window","document","localStorage","sessionStorage","module","global"],Gk=[].concat(Fk,$k,Hk);function Rq(e){const t=e.regex,n=(re,{after:we})=>{const $="</"+re[0].slice(1);return re.input.indexOf($,we)!==-1},r=a0,o={begin:"<>",end:"</>"},l=/<[A-Za-z0-9\\._:-]+\s*\/>/,u={begin:/<[A-Za-z0-9\\._:-]+/,end:/\/[A-Za-z0-9\\._:-]+>|\/>/,isTrulyOpeningTag:(re,we)=>{const $=re[0].length+re.index,G=re.input[$];if(G==="<"||G===","){we.ignoreMatch();return}G===">"&&(n(re,{after:$})||we.ignoreMatch());let ce;const I=re.input.substring($);if(ce=I.match(/^\s*=/)){we.ignoreMatch();return}if((ce=I.match(/^\s+extends\s+/))&&ce.index===0){we.ignoreMatch();return}}},d={$pattern:a0,keyword:Bk,literal:Uk,built_in:Gk,"variable.language":qk},m="[0-9](_?[0-9])*",h=`\\.(${m})`,p="0|[1-9](_?[0-9])*|0[0-7]*[89][0-9]*",g={className:"number",variants:[{begin:`(\\b(${p})((${h})|\\.)?|(${h}))[eE][+-]?(${m})\\b`},{begin:`\\b(${p})\\b((${h})\\b|\\.)?|(${h})\\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},x={className:"subst",begin:"\\$\\{",end:"\\}",keywords:d,contains:[]},y={begin:".?html`",end:"",starts:{end:"`",returnEnd:!1,contains:[e.BACKSLASH_ESCAPE,x],subLanguage:"xml"}},w={begin:".?css`",end:"",starts:{end:"`",returnEnd:!1,contains:[e.BACKSLASH_ESCAPE,x],subLanguage:"css"}},N={begin:".?gql`",end:"",starts:{end:"`",returnEnd:!1,contains:[e.BACKSLASH_ESCAPE,x],subLanguage:"graphql"}},T={className:"string",begin:"`",end:"`",contains:[e.BACKSLASH_ESCAPE,x]},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:r+"(?=\\s*(-)|$)",endsParent:!0,relevance:0},{begin:/(?=[^\n])\s/,relevance:0}]}]}),e.C_BLOCK_COMMENT_MODE,e.C_LINE_COMMENT_MODE]},_=[e.APOS_STRING_MODE,e.QUOTE_STRING_MODE,y,w,N,T,{match:/\$\d+/},g];x.contains=_.concat({begin:/\{/,end:/\}/,keywords:d,contains:["self"].concat(_)});const O=[].concat(j,x.contains),z=O.concat([{begin:/(\s*)\(/,end:/\)/,keywords:d,contains:["self"].concat(O)}]),D={className:"params",begin:/(\s*)\(/,end:/\)/,excludeBegin:!0,excludeEnd:!0,keywords:d,contains:z},H={variants:[{match:[/class/,/\s+/,r,/\s+/,/extends/,/\s+/,t.concat(r,"(",t.concat(/\./,r),")*")],scope:{1:"keyword",3:"title.class",5:"keyword",7:"title.class.inherited"}},{match:[/class/,/\s+/,r],scope:{1:"keyword",3:"title.class"}}]},W={relevance:0,match:t.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:{_:[...$k,...Hk]}},Z={label:"use_strict",className:"meta",relevance:10,begin:/^\s*['"]use (strict|asm)['"]/},U={variants:[{match:[/function/,/\s+/,r,/(?=\s*\()/]},{match:[/function/,/\s*(?=\()/]}],className:{1:"keyword",3:"title.function"},label:"func.def",contains:[D],illegal:/%/},Y={relevance:0,match:/\b[A-Z][A-Z_0-9]+\b/,className:"variable.constant"};function ae(re){return t.concat("(?!",re.join("|"),")")}const X={match:t.concat(/\b/,ae([...Fk,"super","import"].map(re=>`${re}\\s*\\(`)),r,t.lookahead(/\s*\(/)),className:"title.function",relevance:0},F={begin:t.concat(/\./,t.lookahead(t.concat(r,/(?![0-9A-Za-z$_(])/))),end:r,excludeBegin:!0,keywords:"prototype",className:"property",relevance:0},J={match:[/get|set/,/\s+/,r,/(?=\()/],className:{1:"keyword",3:"title.function"},contains:[{begin:/\(\)/},D]},B="(\\([^()]*(\\([^()]*(\\([^()]*\\)[^()]*)*\\)[^()]*)*\\)|"+e.UNDERSCORE_IDENT_RE+")\\s*=>",Q={match:[/const|var|let/,/\s+/,r,/\s*/,/=\s*/,/(async\s*)?/,t.lookahead(B)],keywords:"async",className:{1:"keyword",3:"title.function"},contains:[D]};return{name:"JavaScript",aliases:["js","jsx","mjs","cjs"],keywords:d,exports:{PARAMS_CONTAINS:z,CLASS_REFERENCE:W},illegal:/#(?![$_A-z])/,contains:[e.SHEBANG({label:"shebang",binary:"node",relevance:5}),Z,e.APOS_STRING_MODE,e.QUOTE_STRING_MODE,y,w,N,T,j,{match:/\$\d+/},g,W,{scope:"attr",match:r+t.lookahead(":"),relevance:0},Q,{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:B,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:d,contains:z}]}]},{begin:/,/,relevance:0},{match:/\s+/,relevance:0},{variants:[{begin:o.begin,end:o.end},{match:l},{begin:u.begin,"on:begin":u.isTrulyOpeningTag,end:u.end}],subLanguage:"xml",contains:[{begin:u.begin,end:u.end,skip:!0,contains:["self"]}]}]},U,{beginKeywords:"while if switch catch for"},{begin:"\\b(?!function)"+e.UNDERSCORE_IDENT_RE+"\\([^()]*(\\([^()]*(\\([^()]*\\)[^()]*)*\\)[^()]*)*\\)\\s*\\{",returnBegin:!0,label:"func.def",contains:[D,e.inherit(e.TITLE_MODE,{begin:r,className:"title.function"})]},{match:/\.\.\./,relevance:0},F,{match:"\\$"+r,relevance:0},{match:[/\bconstructor(?=\s*\()/],className:{1:"title.function"},contains:[D]},X,Y,H,J,{match:/\$[(.]/}]}}function Oq(e){const t=e.regex,n=Rq(e),r=a0,o=["any","void","number","boolean","string","object","never","symbol","bigint","unknown"],l={begin:[/namespace/,/\s+/,e.IDENT_RE],beginScope:{1:"keyword",3:"title.class"}},u={beginKeywords:"interface",end:/\{/,excludeEnd:!0,keywords:{keyword:"interface extends",built_in:o},contains:[n.exports.CLASS_REFERENCE]},d={className:"meta",relevance:10,begin:/^\s*['"]use strict['"]/},m=["type","interface","public","private","protected","implements","declare","abstract","readonly","enum","override","satisfies"],h={$pattern:a0,keyword:Bk.concat(m),literal:Uk,built_in:Gk.concat(o),"variable.language":qk},p={className:"meta",begin:"@"+r},g=(N,T,C)=>{const j=N.contains.findIndex(_=>_.label===T);if(j===-1)throw new Error("can not find mode to replace");N.contains.splice(j,1,C)};Object.assign(n.keywords,h),n.exports.PARAMS_CONTAINS.push(p);const x=n.contains.find(N=>N.scope==="attr"),y=Object.assign({},x,{match:t.concat(r,t.lookahead(/\s*\?:/))});n.exports.PARAMS_CONTAINS.push([n.exports.CLASS_REFERENCE,x,y]),n.contains=n.contains.concat([p,l,u,y]),g(n,"shebang",e.SHEBANG()),g(n,"use_strict",d);const w=n.contains.find(N=>N.label==="func.def");return w.relevance=0,Object.assign(n,{name:"TypeScript",aliases:["ts","tsx","mts","cts"]}),n}function Dq(e){const t=e.regex,n={className:"string",begin:/"(""|[^/n])"C\b/},r={className:"string",begin:/"/,end:/"/,illegal:/\n/,contains:[{begin:/""/}]},o=/\d{1,2}\/\d{1,2}\/\d{4}/,l=/\d{4}-\d{1,2}-\d{1,2}/,u=/(\d|1[012])(:\d+){0,2} *(AM|PM)/,d=/\d{1,2}(:\d{1,2}){1,2}/,m={className:"literal",variants:[{begin:t.concat(/# */,t.either(l,o),/ *#/)},{begin:t.concat(/# */,d,/ *#/)},{begin:t.concat(/# */,u,/ *#/)},{begin:t.concat(/# */,t.either(l,o),/ +/,t.either(u,d),/ *#/)}]},h={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])|[%&])?/}]},p={className:"label",begin:/^\w+:/},g=e.COMMENT(/'''/,/$/,{contains:[{className:"doctag",begin:/<\/?/,end:/>/}]}),x=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:[n,r,m,h,p,g,x,{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:[x]}]}}function Lq(e){e.regex;const t=e.COMMENT(/\(;/,/;\)/);t.contains.push("self");const n=e.COMMENT(/;;/,/$/),r=["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"],o={begin:[/(?:func|call|call_indirect)/,/\s+/,/\$[^\s)]+/],className:{1:"keyword",3:"title.function"}},l={className:"variable",begin:/\$[\w_]+/},u={match:/(\((?!;)|\))+/,className:"punctuation",relevance:0},d={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/},m={match:/(i32|i64|f32|f64)(?!\.)/,className:"type"},h={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:r},contains:[n,t,{match:[/(?:offset|align)/,/\s*/,/=/],className:{1:"keyword",3:"operator"}},l,u,o,e.QUOTE_STRING_MODE,m,h,d]}}function Iq(e){const t=e.regex,n=t.concat(/[\p{L}_]/u,t.optional(/[\p{L}0-9_.-]*:/u),/[\p{L}0-9_.-]*/u),r=/[\p{L}0-9._:-]+/u,o={className:"symbol",begin:/&[a-z]+;|&#[0-9]+;|&#x[a-f0-9]+;/},l={begin:/\s/,contains:[{className:"keyword",begin:/#?[a-z_][a-z1-9_-]+/,illegal:/\n/}]},u=e.inherit(l,{begin:/\(/,end:/\)/}),d=e.inherit(e.APOS_STRING_MODE,{className:"string"}),m=e.inherit(e.QUOTE_STRING_MODE,{className:"string"}),h={endsWithParent:!0,illegal:/</,relevance:0,contains:[{className:"attr",begin:r,relevance:0},{begin:/=\s*/,relevance:0,contains:[{className:"string",endsParent:!0,variants:[{begin:/"/,end:/"/,contains:[o]},{begin:/'/,end:/'/,contains:[o]},{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:[l,m,d,u,{begin:/\[/,end:/\]/,contains:[{className:"meta",begin:/<![a-z]/,end:/>/,contains:[l,u,m,d]}]}]},e.COMMENT(/<!--/,/-->/,{relevance:10}),{begin:/<!\[CDATA\[/,end:/\]\]>/,relevance:10},o,{className:"meta",end:/\?>/,variants:[{begin:/<\?xml/,relevance:10,contains:[m]},{begin:/<\?[a-z][a-z0-9]+/}]},{className:"tag",begin:/<style(?=\s|>)/,end:/>/,keywords:{name:"style"},contains:[h],starts:{end:/<\/style>/,returnEnd:!0,subLanguage:["css","xml"]}},{className:"tag",begin:/<script(?=\s|>)/,end:/>/,keywords:{name:"script"},contains:[h],starts:{end:/<\/script>/,returnEnd:!0,subLanguage:["javascript","handlebars","xml"]}},{className:"tag",begin:/<>|<\/>/},{className:"tag",begin:t.concat(/</,t.lookahead(t.concat(n,t.either(/\/>/,/>/,/\s/)))),end:/\/?>/,contains:[{className:"name",begin:n,relevance:0,starts:h}]},{className:"tag",begin:t.concat(/<\//,t.lookahead(t.concat(n,/>/))),contains:[{className:"name",begin:n,relevance:0},{begin:/>/,relevance:0,endsParent:!0}]}]}}function Pq(e){const t="true false yes no null",n="[\\w#;/?:@&=+$,.~*'()[\\]]+",r={className:"attr",variants:[{begin:/[\w*@][\w*@ :()\./-]*:(?=[ \t]|$)/},{begin:/"[\w*@][\w*@ :()\./-]*":(?=[ \t]|$)/},{begin:/'[\w*@][\w*@ :()\./-]*':(?=[ \t]|$)/}]},o={className:"template-variable",variants:[{begin:/\{\{/,end:/\}\}/},{begin:/%\{/,end:/\}/}]},l={className:"string",relevance:0,begin:/'/,end:/'/,contains:[{match:/''/,scope:"char.escape",relevance:0}]},u={className:"string",relevance:0,variants:[{begin:/"/,end:/"/},{begin:/\S+/}],contains:[e.BACKSLASH_ESCAPE,o]},d=e.inherit(u,{variants:[{begin:/'/,end:/'/,contains:[{begin:/''/,relevance:0}]},{begin:/"/,end:/"/},{begin:/[^\s,{}[\]]+/}]}),x={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"},y={end:",",endsWithParent:!0,excludeEnd:!0,keywords:t,relevance:0},w={begin:/\{/,end:/\}/,contains:[y],illegal:"\\n",relevance:0},N={begin:"\\[",end:"\\]",contains:[y],illegal:"\\n",relevance:0},T=[r,{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+!"+n},{className:"type",begin:"!<"+n+">"},{className:"type",begin:"!"+n},{className:"type",begin:"!!"+n},{className:"meta",begin:"&"+e.UNDERSCORE_IDENT_RE+"$"},{className:"meta",begin:"\\*"+e.UNDERSCORE_IDENT_RE+"$"},{className:"bullet",begin:"-(?=[ ]|$)",relevance:0},e.HASH_COMMENT_MODE,{beginKeywords:t,keywords:{literal:t}},x,{className:"number",begin:e.C_NUMBER_RE+"\\b",relevance:0},w,N,l,u],C=[...T];return C.pop(),C.push(d),y.contains=C,{name:"YAML",case_insensitive:!0,aliases:["yml"],contains:T}}const zq={arduino:yF,bash:vF,c:wF,cpp:kF,csharp:SF,css:RF,diff:OF,go:DF,graphql:LF,ini:IF,java:PF,javascript:HF,json:FF,kotlin:GF,less:JF,lua:eq,makefile:tq,markdown:nq,objectivec:rq,perl:aq,php:sq,"php-template":iq,plaintext:oq,python:lq,"python-repl":cq,r:uq,ruby:dq,rust:mq,scss:wq,shell:kq,sql:Sq,swift:Mq,typescript:Oq,vbnet:Dq,wasm:Lq,xml:Iq,yaml:Pq};var Bh,R2;function Bq(){if(R2)return Bh;R2=1;function e(q){return q instanceof Map?q.clear=q.delete=q.set=function(){throw new Error("map is read-only")}:q instanceof Set&&(q.add=q.clear=q.delete=function(){throw new Error("set is read-only")}),Object.freeze(q),Object.getOwnPropertyNames(q).forEach(ie=>{const Se=q[ie],Ie=typeof Se;(Ie==="object"||Ie==="function")&&!Object.isFrozen(Se)&&e(Se)}),q}class t{constructor(ie){ie.data===void 0&&(ie.data={}),this.data=ie.data,this.isMatchIgnored=!1}ignoreMatch(){this.isMatchIgnored=!0}}function n(q){return q.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&#x27;")}function r(q,...ie){const Se=Object.create(null);for(const Ie in q)Se[Ie]=q[Ie];return ie.forEach(function(Ie){for(const Xe in Ie)Se[Xe]=Ie[Xe]}),Se}const o="</span>",l=q=>!!q.scope,u=(q,{prefix:ie})=>{if(q.startsWith("language:"))return q.replace("language:","language-");if(q.includes(".")){const Se=q.split(".");return[`${ie}${Se.shift()}`,...Se.map((Ie,Xe)=>`${Ie}${"_".repeat(Xe+1)}`)].join(" ")}return`${ie}${q}`};class d{constructor(ie,Se){this.buffer="",this.classPrefix=Se.classPrefix,ie.walk(this)}addText(ie){this.buffer+=n(ie)}openNode(ie){if(!l(ie))return;const Se=u(ie.scope,{prefix:this.classPrefix});this.span(Se)}closeNode(ie){l(ie)&&(this.buffer+=o)}value(){return this.buffer}span(ie){this.buffer+=`<span class="${ie}">`}}const m=(q={})=>{const ie={children:[]};return Object.assign(ie,q),ie};class h{constructor(){this.rootNode=m(),this.stack=[this.rootNode]}get top(){return this.stack[this.stack.length-1]}get root(){return this.rootNode}add(ie){this.top.children.push(ie)}openNode(ie){const Se=m({scope:ie});this.add(Se),this.stack.push(Se)}closeNode(){if(this.stack.length>1)return this.stack.pop()}closeAllNodes(){for(;this.closeNode(););}toJSON(){return JSON.stringify(this.rootNode,null,4)}walk(ie){return this.constructor._walk(ie,this.rootNode)}static _walk(ie,Se){return typeof Se=="string"?ie.addText(Se):Se.children&&(ie.openNode(Se),Se.children.forEach(Ie=>this._walk(ie,Ie)),ie.closeNode(Se)),ie}static _collapse(ie){typeof ie!="string"&&ie.children&&(ie.children.every(Se=>typeof Se=="string")?ie.children=[ie.children.join("")]:ie.children.forEach(Se=>{h._collapse(Se)}))}}class p extends h{constructor(ie){super(),this.options=ie}addText(ie){ie!==""&&this.add(ie)}startScope(ie){this.openNode(ie)}endScope(){this.closeNode()}__addSublanguage(ie,Se){const Ie=ie.root;Se&&(Ie.scope=`language:${Se}`),this.add(Ie)}toHTML(){return new d(this,this.options).value()}finalize(){return this.closeAllNodes(),!0}}function g(q){return q?typeof q=="string"?q:q.source:null}function x(q){return N("(?=",q,")")}function y(q){return N("(?:",q,")*")}function w(q){return N("(?:",q,")?")}function N(...q){return q.map(Se=>g(Se)).join("")}function T(q){const ie=q[q.length-1];return typeof ie=="object"&&ie.constructor===Object?(q.splice(q.length-1,1),ie):{}}function C(...q){return"("+(T(q).capture?"":"?:")+q.map(Ie=>g(Ie)).join("|")+")"}function j(q){return new RegExp(q.toString()+"|").exec("").length-1}function _(q,ie){const Se=q&&q.exec(ie);return Se&&Se.index===0}const O=/\[(?:[^\\\]]|\\.)*\]|\(\??|\\([1-9][0-9]*)|\\./;function z(q,{joinWith:ie}){let Se=0;return q.map(Ie=>{Se+=1;const Xe=Se;let yt=g(Ie),Pe="";for(;yt.length>0;){const Je=O.exec(yt);if(!Je){Pe+=yt;break}Pe+=yt.substring(0,Je.index),yt=yt.substring(Je.index+Je[0].length),Je[0][0]==="\\"&&Je[1]?Pe+="\\"+String(Number(Je[1])+Xe):(Pe+=Je[0],Je[0]==="("&&Se++)}return Pe}).map(Ie=>`(${Ie})`).join(ie)}const D=/\b\B/,H="[a-zA-Z]\\w*",W="[a-zA-Z_]\\w*",Z="\\b\\d+(\\.\\d+)?",U="(-?)(\\b0[xX][a-fA-F0-9]+|(\\b\\d+(\\.\\d*)?|\\.\\d+)([eE][-+]?\\d+)?)",Y="\\b(0b[01]+)",ae="!|!=|!==|%|%=|&|&&|&=|\\*|\\*=|\\+|\\+=|,|-|-=|/=|/|:|;|<<|<<=|<=|<|===|==|=|>>>=|>>=|>=|>>>|>>|>|\\?|\\[|\\{|\\(|\\^|\\^=|\\||\\|=|\\|\\||~",X=(q={})=>{const ie=/^#![ ]*\//;return q.binary&&(q.begin=N(ie,/.*\b/,q.binary,/\b.*/)),r({scope:"meta",begin:ie,end:/$/,relevance:0,"on:begin":(Se,Ie)=>{Se.index!==0&&Ie.ignoreMatch()}},q)},F={begin:"\\\\[\\s\\S]",relevance:0},J={scope:"string",begin:"'",end:"'",illegal:"\\n",contains:[F]},B={scope:"string",begin:'"',end:'"',illegal:"\\n",contains:[F]},Q={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/},re=function(q,ie,Se={}){const Ie=r({scope:"comment",begin:q,end:ie,contains:[]},Se);Ie.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 Xe=C("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 Ie.contains.push({begin:N(/[ ]+/,"(",Xe,/[.]?[:]?([.][ ]|[ ])/,"){3}")}),Ie},we=re("//","$"),$=re("/\\*","\\*/"),G=re("#","$"),ce={scope:"number",begin:Z,relevance:0},I={scope:"number",begin:U,relevance:0},Ee={scope:"number",begin:Y,relevance:0},Ue={scope:"regexp",begin:/\/(?=[^/\n]*\/)/,end:/\/[gimuy]*/,contains:[F,{begin:/\[/,end:/\]/,relevance:0,contains:[F]}]},De={scope:"title",begin:H,relevance:0},Ke={scope:"title",begin:W,relevance:0},st={begin:"\\.\\s*"+W,relevance:0};var ct=Object.freeze({__proto__:null,APOS_STRING_MODE:J,BACKSLASH_ESCAPE:F,BINARY_NUMBER_MODE:Ee,BINARY_NUMBER_RE:Y,COMMENT:re,C_BLOCK_COMMENT_MODE:$,C_LINE_COMMENT_MODE:we,C_NUMBER_MODE:I,C_NUMBER_RE:U,END_SAME_AS_BEGIN:function(q){return Object.assign(q,{"on:begin":(ie,Se)=>{Se.data._beginMatch=ie[1]},"on:end":(ie,Se)=>{Se.data._beginMatch!==ie[1]&&Se.ignoreMatch()}})},HASH_COMMENT_MODE:G,IDENT_RE:H,MATCH_NOTHING_RE:D,METHOD_GUARD:st,NUMBER_MODE:ce,NUMBER_RE:Z,PHRASAL_WORDS_MODE:Q,QUOTE_STRING_MODE:B,REGEXP_MODE:Ue,RE_STARTERS_RE:ae,SHEBANG:X,TITLE_MODE:De,UNDERSCORE_IDENT_RE:W,UNDERSCORE_TITLE_MODE:Ke});function Dt(q,ie){q.input[q.index-1]==="."&&ie.ignoreMatch()}function Mt(q,ie){q.className!==void 0&&(q.scope=q.className,delete q.className)}function Xt(q,ie){ie&&q.beginKeywords&&(q.begin="\\b("+q.beginKeywords.split(" ").join("|")+")(?!\\.)(?=\\b|\\s)",q.__beforeBegin=Dt,q.keywords=q.keywords||q.beginKeywords,delete q.beginKeywords,q.relevance===void 0&&(q.relevance=0))}function Me(q,ie){Array.isArray(q.illegal)&&(q.illegal=C(...q.illegal))}function Ne(q,ie){if(q.match){if(q.begin||q.end)throw new Error("begin & end are not supported with match");q.begin=q.match,delete q.match}}function Re(q,ie){q.relevance===void 0&&(q.relevance=1)}const ut=(q,ie)=>{if(!q.beforeMatch)return;if(q.starts)throw new Error("beforeMatch cannot be used with starts");const Se=Object.assign({},q);Object.keys(q).forEach(Ie=>{delete q[Ie]}),q.keywords=Se.keywords,q.begin=N(Se.beforeMatch,x(Se.begin)),q.starts={relevance:0,contains:[Object.assign(Se,{endsParent:!0})]},q.relevance=0,delete Se.beforeMatch},it=["of","and","for","in","not","or","if","then","parent","list","value"],bt="keyword";function se(q,ie,Se=bt){const Ie=Object.create(null);return typeof q=="string"?Xe(Se,q.split(" ")):Array.isArray(q)?Xe(Se,q):Object.keys(q).forEach(function(yt){Object.assign(Ie,se(q[yt],ie,yt))}),Ie;function Xe(yt,Pe){ie&&(Pe=Pe.map(Je=>Je.toLowerCase())),Pe.forEach(function(Je){const Nt=Je.split("|");Ie[Nt[0]]=[yt,et(Nt[0],Nt[1])]})}}function et(q,ie){return ie?Number(ie):nt(q)?0:1}function nt(q){return it.includes(q.toLowerCase())}const Ge={},Qe=q=>{console.error(q)},xt=(q,...ie)=>{console.log(`WARN: ${q}`,...ie)},pe=(q,ie)=>{Ge[`${q}/${ie}`]||(console.log(`Deprecated as of ${q}. ${ie}`),Ge[`${q}/${ie}`]=!0)},V=new Error;function xe(q,ie,{key:Se}){let Ie=0;const Xe=q[Se],yt={},Pe={};for(let Je=1;Je<=ie.length;Je++)Pe[Je+Ie]=Xe[Je],yt[Je+Ie]=!0,Ie+=j(ie[Je-1]);q[Se]=Pe,q[Se]._emit=yt,q[Se]._multi=!0}function We(q){if(Array.isArray(q.begin)){if(q.skip||q.excludeBegin||q.returnBegin)throw Qe("skip, excludeBegin, returnBegin not compatible with beginScope: {}"),V;if(typeof q.beginScope!="object"||q.beginScope===null)throw Qe("beginScope must be object"),V;xe(q,q.begin,{key:"beginScope"}),q.begin=z(q.begin,{joinWith:""})}}function he(q){if(Array.isArray(q.end)){if(q.skip||q.excludeEnd||q.returnEnd)throw Qe("skip, excludeEnd, returnEnd not compatible with endScope: {}"),V;if(typeof q.endScope!="object"||q.endScope===null)throw Qe("endScope must be object"),V;xe(q,q.end,{key:"endScope"}),q.end=z(q.end,{joinWith:""})}}function ye(q){q.scope&&typeof q.scope=="object"&&q.scope!==null&&(q.beginScope=q.scope,delete q.scope)}function Ze(q){ye(q),typeof q.beginScope=="string"&&(q.beginScope={_wrap:q.beginScope}),typeof q.endScope=="string"&&(q.endScope={_wrap:q.endScope}),We(q),he(q)}function rt(q){function ie(Pe,Je){return new RegExp(g(Pe),"m"+(q.case_insensitive?"i":"")+(q.unicodeRegex?"u":"")+(Je?"g":""))}class Se{constructor(){this.matchIndexes={},this.regexes=[],this.matchAt=1,this.position=0}addRule(Je,Nt){Nt.position=this.position++,this.matchIndexes[this.matchAt]=Nt,this.regexes.push([Nt,Je]),this.matchAt+=j(Je)+1}compile(){this.regexes.length===0&&(this.exec=()=>null);const Je=this.regexes.map(Nt=>Nt[1]);this.matcherRe=ie(z(Je,{joinWith:"|"}),!0),this.lastIndex=0}exec(Je){this.matcherRe.lastIndex=this.lastIndex;const Nt=this.matcherRe.exec(Je);if(!Nt)return null;const jn=Nt.findIndex((Ea,Ri)=>Ri>0&&Ea!==void 0),vn=this.matchIndexes[jn];return Nt.splice(0,jn),Object.assign(Nt,vn)}}class Ie{constructor(){this.rules=[],this.multiRegexes=[],this.count=0,this.lastIndex=0,this.regexIndex=0}getMatcher(Je){if(this.multiRegexes[Je])return this.multiRegexes[Je];const Nt=new Se;return this.rules.slice(Je).forEach(([jn,vn])=>Nt.addRule(jn,vn)),Nt.compile(),this.multiRegexes[Je]=Nt,Nt}resumingScanAtSamePosition(){return this.regexIndex!==0}considerAll(){this.regexIndex=0}addRule(Je,Nt){this.rules.push([Je,Nt]),Nt.type==="begin"&&this.count++}exec(Je){const Nt=this.getMatcher(this.regexIndex);Nt.lastIndex=this.lastIndex;let jn=Nt.exec(Je);if(this.resumingScanAtSamePosition()&&!(jn&&jn.index===this.lastIndex)){const vn=this.getMatcher(0);vn.lastIndex=this.lastIndex+1,jn=vn.exec(Je)}return jn&&(this.regexIndex+=jn.position+1,this.regexIndex===this.count&&this.considerAll()),jn}}function Xe(Pe){const Je=new Ie;return Pe.contains.forEach(Nt=>Je.addRule(Nt.begin,{rule:Nt,type:"begin"})),Pe.terminatorEnd&&Je.addRule(Pe.terminatorEnd,{type:"end"}),Pe.illegal&&Je.addRule(Pe.illegal,{type:"illegal"}),Je}function yt(Pe,Je){const Nt=Pe;if(Pe.isCompiled)return Nt;[Mt,Ne,Ze,ut].forEach(vn=>vn(Pe,Je)),q.compilerExtensions.forEach(vn=>vn(Pe,Je)),Pe.__beforeBegin=null,[Xt,Me,Re].forEach(vn=>vn(Pe,Je)),Pe.isCompiled=!0;let jn=null;return typeof Pe.keywords=="object"&&Pe.keywords.$pattern&&(Pe.keywords=Object.assign({},Pe.keywords),jn=Pe.keywords.$pattern,delete Pe.keywords.$pattern),jn=jn||/\w+/,Pe.keywords&&(Pe.keywords=se(Pe.keywords,q.case_insensitive)),Nt.keywordPatternRe=ie(jn,!0),Je&&(Pe.begin||(Pe.begin=/\B|\b/),Nt.beginRe=ie(Nt.begin),!Pe.end&&!Pe.endsWithParent&&(Pe.end=/\B|\b/),Pe.end&&(Nt.endRe=ie(Nt.end)),Nt.terminatorEnd=g(Nt.end)||"",Pe.endsWithParent&&Je.terminatorEnd&&(Nt.terminatorEnd+=(Pe.end?"|":"")+Je.terminatorEnd)),Pe.illegal&&(Nt.illegalRe=ie(Pe.illegal)),Pe.contains||(Pe.contains=[]),Pe.contains=[].concat(...Pe.contains.map(function(vn){return Bt(vn==="self"?Pe:vn)})),Pe.contains.forEach(function(vn){yt(vn,Nt)}),Pe.starts&&yt(Pe.starts,Je),Nt.matcher=Xe(Nt),Nt}if(q.compilerExtensions||(q.compilerExtensions=[]),q.contains&&q.contains.includes("self"))throw new Error("ERR: contains `self` is not supported at the top-level of a language. See documentation.");return q.classNameAliases=r(q.classNameAliases||{}),yt(q)}function St(q){return q?q.endsWithParent||St(q.starts):!1}function Bt(q){return q.variants&&!q.cachedVariants&&(q.cachedVariants=q.variants.map(function(ie){return r(q,{variants:null},ie)})),q.cachedVariants?q.cachedVariants:St(q)?r(q,{starts:q.starts?r(q.starts):null}):Object.isFrozen(q)?r(q):q}var wt="11.11.1";class hn extends Error{constructor(ie,Se){super(ie),this.name="HTMLInjectionError",this.html=Se}}const R=n,oe=r,_e=Symbol("nomatch"),de=7,$e=function(q){const ie=Object.create(null),Se=Object.create(null),Ie=[];let Xe=!0;const yt="Could not find the language '{}', did you forget to load/include a language module?",Pe={disableAutodetect:!0,name:"Plain text",contains:[]};let Je={ignoreUnescapedHTML:!1,throwUnescapedHTML:!1,noHighlightRe:/^(no-?highlight)$/i,languageDetectRe:/\blang(?:uage)?-([\w-]+)\b/i,classPrefix:"hljs-",cssSelector:"pre code",languages:null,__emitter:p};function Nt(ze){return Je.noHighlightRe.test(ze)}function jn(ze){let vt=ze.className+" ";vt+=ze.parentNode?ze.parentNode.className:"";const Ut=Je.languageDetectRe.exec(vt);if(Ut){const nn=ir(Ut[1]);return nn||(xt(yt.replace("{}",Ut[1])),xt("Falling back to no-highlight mode for this block.",ze)),nn?Ut[1]:"no-highlight"}return vt.split(/\s+/).find(nn=>Nt(nn)||ir(nn))}function vn(ze,vt,Ut){let nn="",Rn="";typeof vt=="object"?(nn=ze,Ut=vt.ignoreIllegals,Rn=vt.language):(pe("10.7.0","highlight(lang, code, ...args) has been deprecated."),pe("10.7.0",`Please use highlight(code, options) instead.
647
647
  https://github.com/highlightjs/highlight.js/issues/2277`),Rn=ze,nn=vt),Ut===void 0&&(Ut=!0);const tr={code:nn,language:Rn};Ws("before:highlight",tr);const Mr=tr.result?tr.result:Ea(tr.language,tr.code,Ut);return Mr.code=tr.code,Ws("after:highlight",Mr),Mr}function Ea(ze,vt,Ut,nn){const Rn=Object.create(null);function tr(Ye,ht){return Ye.keywords[ht]}function Mr(){if(!Et.keywords){In.addText(rn);return}let Ye=0;Et.keywordPatternRe.lastIndex=0;let ht=Et.keywordPatternRe.exec(rn),Ot="";for(;ht;){Ot+=rn.substring(Ye,ht.index);const Vt=Yn.case_insensitive?ht[0].toLowerCase():ht[0],Nn=tr(Et,Vt);if(Nn){const[Kr,el]=Nn;if(In.addText(Ot),Ot="",Rn[Vt]=(Rn[Vt]||0)+1,Rn[Vt]<=de&&(ls+=el),Kr.startsWith("_"))Ot+=ht[0];else{const Rc=Yn.classNameAliases[Kr]||Kr;Rr(ht[0],Rc)}}else Ot+=ht[0];Ye=Et.keywordPatternRe.lastIndex,ht=Et.keywordPatternRe.exec(rn)}Ot+=rn.substring(Ye),In.addText(Ot)}function gr(){if(rn==="")return;let Ye=null;if(typeof Et.subLanguage=="string"){if(!ie[Et.subLanguage]){In.addText(rn);return}Ye=Ea(Et.subLanguage,rn,!0,Mc[Et.subLanguage]),Mc[Et.subLanguage]=Ye._top}else Ye=Oi(rn,Et.subLanguage.length?Et.subLanguage:null);Et.relevance>0&&(ls+=Ye.relevance),In.__addSublanguage(Ye._emitter,Ye.language)}function pn(){Et.subLanguage!=null?gr():Mr(),rn=""}function Rr(Ye,ht){Ye!==""&&(In.startScope(ht),In.addText(Ye),In.endScope())}function _c(Ye,ht){let Ot=1;const Vt=ht.length-1;for(;Ot<=Vt;){if(!Ye._emit[Ot]){Ot++;continue}const Nn=Yn.classNameAliases[Ye[Ot]]||Ye[Ot],Kr=ht[Ot];Nn?Rr(Kr,Nn):(rn=Kr,Mr(),rn=""),Ot++}}function Li(Ye,ht){return Ye.scope&&typeof Ye.scope=="string"&&In.openNode(Yn.classNameAliases[Ye.scope]||Ye.scope),Ye.beginScope&&(Ye.beginScope._wrap?(Rr(rn,Yn.classNameAliases[Ye.beginScope._wrap]||Ye.beginScope._wrap),rn=""):Ye.beginScope._multi&&(_c(Ye.beginScope,ht),rn="")),Et=Object.create(Ye,{parent:{value:Et}}),Et}function Qo(Ye,ht,Ot){let Vt=_(Ye.endRe,Ot);if(Vt){if(Ye["on:end"]){const Nn=new t(Ye);Ye["on:end"](ht,Nn),Nn.isMatchIgnored&&(Vt=!1)}if(Vt){for(;Ye.endsParent&&Ye.parent;)Ye=Ye.parent;return Ye}}if(Ye.endsWithParent)return Qo(Ye.parent,ht,Ot)}function Ii(Ye){return Et.matcher.regexIndex===0?(rn+=Ye[0],1):(cs=!0,0)}function B0(Ye){const ht=Ye[0],Ot=Ye.rule,Vt=new t(Ot),Nn=[Ot.__beforeBegin,Ot["on:begin"]];for(const Kr of Nn)if(Kr&&(Kr(Ye,Vt),Vt.isMatchIgnored))return Ii(ht);return Ot.skip?rn+=ht:(Ot.excludeBegin&&(rn+=ht),pn(),!Ot.returnBegin&&!Ot.excludeBegin&&(rn=ht)),Li(Ot,Ye),Ot.returnBegin?0:ht.length}function br(Ye){const ht=Ye[0],Ot=vt.substring(Ye.index),Vt=Qo(Et,Ye,Ot);if(!Vt)return _e;const Nn=Et;Et.endScope&&Et.endScope._wrap?(pn(),Rr(ht,Et.endScope._wrap)):Et.endScope&&Et.endScope._multi?(pn(),_c(Et.endScope,Ye)):Nn.skip?rn+=ht:(Nn.returnEnd||Nn.excludeEnd||(rn+=ht),pn(),Nn.excludeEnd&&(rn=ht));do Et.scope&&In.closeNode(),!Et.skip&&!Et.subLanguage&&(ls+=Et.relevance),Et=Et.parent;while(Et!==Vt.parent);return Vt.starts&&Li(Vt.starts,Ye),Nn.returnEnd?0:ht.length}function Zo(){const Ye=[];for(let ht=Et;ht!==Yn;ht=ht.parent)ht.scope&&Ye.unshift(ht.scope);Ye.forEach(ht=>In.openNode(ht))}let Ys={};function Pi(Ye,ht){const Ot=ht&&ht[0];if(rn+=Ye,Ot==null)return pn(),0;if(Ys.type==="begin"&&ht.type==="end"&&Ys.index===ht.index&&Ot===""){if(rn+=vt.slice(ht.index,ht.index+1),!Xe){const Vt=new Error(`0 width match regex (${ze})`);throw Vt.languageName=ze,Vt.badRule=Ys.rule,Vt}return 1}if(Ys=ht,ht.type==="begin")return B0(ht);if(ht.type==="illegal"&&!Ut){const Vt=new Error('Illegal lexeme "'+Ot+'" for mode "'+(Et.scope||"<unnamed>")+'"');throw Vt.mode=Et,Vt}else if(ht.type==="end"){const Vt=br(ht);if(Vt!==_e)return Vt}if(ht.type==="illegal"&&Ot==="")return rn+=`
648
- `,1;if(Jo>1e5&&Jo>ht.index*3)throw new Error("potential infinite loop, way more iterations than matches");return rn+=Ot,Ot.length}const Yn=ir(ze);if(!Yn)throw Qe(yt.replace("{}",ze)),new Error('Unknown language: "'+ze+'"');const jc=rt(Yn);let zi="",Et=nn||jc;const Mc={},In=new Je.__emitter(Je);Zo();let rn="",ls=0,ja=0,Jo=0,cs=!1;try{if(Yn.__emitTokens)Yn.__emitTokens(vt,In);else{for(Et.matcher.considerAll();;){Jo++,cs?cs=!1:Et.matcher.considerAll(),Et.matcher.lastIndex=ja;const Ye=Et.matcher.exec(vt);if(!Ye)break;const ht=vt.substring(ja,Ye.index),Ot=Pi(ht,Ye);ja=Ye.index+Ot}Pi(vt.substring(ja))}return In.finalize(),zi=In.toHTML(),{language:ze,value:zi,relevance:ls,illegal:!1,_emitter:In,_top:Et}}catch(Ye){if(Ye.message&&Ye.message.includes("Illegal"))return{language:ze,value:R(vt),illegal:!0,relevance:0,_illegalBy:{message:Ye.message,index:ja,context:vt.slice(ja-100,ja+100),mode:Ye.mode,resultSoFar:zi},_emitter:In};if(Xe)return{language:ze,value:R(vt),illegal:!1,relevance:0,errorRaised:Ye,_emitter:In,_top:Et};throw Ye}}function Ri(ze){const vt={value:R(ze),illegal:!1,relevance:0,_top:Pe,_emitter:new Je.__emitter(Je)};return vt._emitter.addText(ze),vt}function Oi(ze,vt){vt=vt||Je.languages||Object.keys(ie);const Ut=Ri(ze),nn=vt.filter(ir).filter(is).map(pn=>Ea(pn,ze,!1));nn.unshift(Ut);const Rn=nn.sort((pn,Rr)=>{if(pn.relevance!==Rr.relevance)return Rr.relevance-pn.relevance;if(pn.language&&Rr.language){if(ir(pn.language).supersetOf===Rr.language)return 1;if(ir(Rr.language).supersetOf===pn.language)return-1}return 0}),[tr,Mr]=Rn,gr=tr;return gr.secondBest=Mr,gr}function ma(ze,vt,Ut){const nn=vt&&Se[vt]||Ut;ze.classList.add("hljs"),ze.classList.add(`language-${nn}`)}function Mn(ze){let vt=null;const Ut=jn(ze);if(Nt(Ut))return;if(Ws("before:highlightElement",{el:ze,language:Ut}),ze.dataset.highlighted){console.log("Element previously highlighted. To highlight again, first unset `dataset.highlighted`.",ze);return}if(ze.children.length>0&&(Je.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(ze)),Je.throwUnescapedHTML))throw new hn("One of your code blocks includes unescaped HTML.",ze.innerHTML);vt=ze;const nn=vt.textContent,Rn=Ut?vn(nn,{language:Ut,ignoreIllegals:!0}):Oi(nn);ze.innerHTML=Rn.value,ze.dataset.highlighted="yes",ma(ze,Ut,Rn.language),ze.result={language:Rn.language,re:Rn.relevance,relevance:Rn.relevance},Rn.secondBest&&(ze.secondBest={language:Rn.secondBest.language,relevance:Rn.secondBest.relevance}),Ws("after:highlightElement",{el:ze,result:Rn,text:nn})}function er(ze){Je=oe(Je,ze)}const ss=()=>{Di(),pe("10.6.0","initHighlighting() deprecated. Use highlightAll() now.")};function Yo(){Di(),pe("10.6.0","initHighlightingOnLoad() deprecated. Use highlightAll() now.")}let Tc=!1;function Di(){function ze(){Di()}if(document.readyState==="loading"){Tc||window.addEventListener("DOMContentLoaded",ze,!1),Tc=!0;return}document.querySelectorAll(Je.cssSelector).forEach(Mn)}function Ec(ze,vt){let Ut=null;try{Ut=vt(q)}catch(nn){if(Qe("Language definition for '{}' could not be registered.".replace("{}",ze)),Xe)Qe(nn);else throw nn;Ut=Pe}Ut.name||(Ut.name=ze),ie[ze]=Ut,Ut.rawDefinition=vt.bind(null,q),Ut.aliases&&Aa(Ut.aliases,{languageName:ze})}function Ks(ze){delete ie[ze];for(const vt of Object.keys(Se))Se[vt]===ze&&delete Se[vt]}function Xo(){return Object.keys(ie)}function ir(ze){return ze=(ze||"").toLowerCase(),ie[ze]||ie[Se[ze]]}function Aa(ze,{languageName:vt}){typeof ze=="string"&&(ze=[ze]),ze.forEach(Ut=>{Se[Ut.toLowerCase()]=vt})}function is(ze){const vt=ir(ze);return vt&&!vt.disableAutodetect}function os(ze){ze["before:highlightBlock"]&&!ze["before:highlightElement"]&&(ze["before:highlightElement"]=vt=>{ze["before:highlightBlock"](Object.assign({block:vt.el},vt))}),ze["after:highlightBlock"]&&!ze["after:highlightElement"]&&(ze["after:highlightElement"]=vt=>{ze["after:highlightBlock"](Object.assign({block:vt.el},vt))})}function Ln(ze){os(ze),Ie.push(ze)}function Ac(ze){const vt=Ie.indexOf(ze);vt!==-1&&Ie.splice(vt,1)}function Ws(ze,vt){const Ut=ze;Ie.forEach(function(nn){nn[Ut]&&nn[Ut](vt)})}function _a(ze){return pe("10.7.0","highlightBlock will be removed entirely in v12.0"),pe("10.7.0","Please use highlightElement now."),Mn(ze)}Object.assign(q,{highlight:vn,highlightAuto:Oi,highlightAll:Di,highlightElement:Mn,highlightBlock:_a,configure:er,initHighlighting:ss,initHighlightingOnLoad:Yo,registerLanguage:Ec,unregisterLanguage:Ks,listLanguages:Xo,getLanguage:ir,registerAliases:Aa,autoDetection:is,inherit:oe,addPlugin:Ln,removePlugin:Ac}),q.debugMode=function(){Xe=!1},q.safeMode=function(){Xe=!0},q.versionString=wt,q.regex={concat:N,lookahead:x,either:C,optional:w,anyNumberOfTimes:y};for(const ze in ct)typeof ct[ze]=="object"&&e(ct[ze]);return Object.assign(q,ct),q},qe=$e({});return qe.newInstance=()=>$e({}),Bh=qe,qe.HighlightJS=qe,qe.default=qe,Bh}var Uq=Bq();const $q=xc(Uq),O2={},Hq="hljs-";function Fq(e){const t=$q.newInstance();return e&&l(e),{highlight:n,highlightAuto:r,listLanguages:o,register:l,registerAlias:u,registered:d};function n(m,h,p){const g=p||O2,x=typeof g.prefix=="string"?g.prefix:Hq;if(!t.getLanguage(m))throw new Error("Unknown language: `"+m+"` is not registered");t.configure({__emitter:qq,classPrefix:x});const y=t.highlight(h,{ignoreIllegals:!0,language:m});if(y.errorRaised)throw new Error("Could not highlight with `Highlight.js`",{cause:y.errorRaised});const w=y._emitter.root,N=w.data;return N.language=y.language,N.relevance=y.relevance,w}function r(m,h){const g=(h||O2).subset||o();let x=-1,y=0,w;for(;++x<g.length;){const N=g[x];if(!t.getLanguage(N))continue;const T=n(N,m,h);T.data&&T.data.relevance!==void 0&&T.data.relevance>y&&(y=T.data.relevance,w=T)}return w||{type:"root",children:[],data:{language:void 0,relevance:y}}}function o(){return t.listLanguages()}function l(m,h){if(typeof m=="string")t.registerLanguage(m,h);else{let p;for(p in m)Object.hasOwn(m,p)&&t.registerLanguage(p,m[p])}}function u(m,h){if(typeof m=="string")t.registerAliases(typeof h=="string"?h:[...h],{languageName:m});else{let p;for(p in m)if(Object.hasOwn(m,p)){const g=m[p];t.registerAliases(typeof g=="string"?g:[...g],{languageName:p})}}}function d(m){return!!t.getLanguage(m)}}class qq{constructor(t){this.options=t,this.root={type:"root",children:[],data:{language:void 0,relevance:0}},this.stack=[this.root]}addText(t){if(t==="")return;const n=this.stack[this.stack.length-1],r=n.children[n.children.length-1];r&&r.type==="text"?r.value+=t:n.children.push({type:"text",value:t})}startScope(t){this.openNode(String(t))}endScope(){this.closeNode()}__addSublanguage(t,n){const r=this.stack[this.stack.length-1],o=t.root.children;n?r.children.push({type:"element",tagName:"span",properties:{className:[n]},children:o}):r.children.push(...o)}openNode(t){const n=this,r=t.split(".").map(function(u,d){return d?u+"_".repeat(d):n.options.classPrefix+u}),o=this.stack[this.stack.length-1],l={type:"element",tagName:"span",properties:{className:r},children:[]};o.children.push(l),this.stack.push(l)}closeNode(){this.stack.pop()}finalize(){}toHTML(){return""}}const Gq={};function Vk(e){const t=e||Gq,n=t.aliases,r=t.detect||!1,o=t.languages||zq,l=t.plainText,u=t.prefix,d=t.subset;let m="hljs";const h=Fq(o);if(n&&h.registerAlias(n),u){const p=u.indexOf("-");m=p===-1?u:u.slice(0,p)}return function(p,g){S0(p,"element",function(x,y,w){if(x.tagName!=="code"||!w||w.type!=="element"||w.tagName!=="pre")return;const N=Vq(x);if(N===!1||!N&&!r||N&&l&&l.includes(N))return;Array.isArray(x.properties.className)||(x.properties.className=[]),x.properties.className.includes(m)||x.properties.className.unshift(m);const T=Ck(x,{whitespace:"pre"});let C;try{C=N?h.highlight(N,T,{prefix:u}):h.highlightAuto(T,{prefix:u,subset:d})}catch(j){const _=j;if(N&&/Unknown language/.test(_.message)){g.message("Cannot highlight as `"+N+"`, it’s not registered",{ancestors:[w,x],cause:_,place:x.position,ruleId:"missing-language",source:"rehype-highlight"});return}throw _}!N&&C.data&&C.data.language&&x.properties.className.push("language-"+C.data.language),C.children.length>0&&(x.children=C.children)})}}function Vq(e){const t=e.properties.className;let n=-1;if(!Array.isArray(t))return;let r;for(;++n<t.length;){const o=String(t[n]);if(o==="no-highlight"||o==="nohighlight")return!1;!r&&o.slice(0,5)==="lang-"&&(r=o.slice(5)),!r&&o.slice(0,9)==="language-"&&(r=o.slice(9))}return r}const Kq=10;function D2(e){if(e.kind==="file")return`file:${e.path}`;if(e.kind==="url")return`url:${e.browserId||e.url}`;const t=e.deliverable;return`deliverable:${t.id||`${t.reference||""}|${t.title||""}|${t.summary?.slice(0,48)||""}`||"unknown"}`}function Wq(e){return e.kind==="deliverable"?e.deliverable.title||e.deliverable.reference||"Deliverable":e.kind==="url"?e.title||e.url:e.title||e.path.split(/[/\\]/).pop()||e.path}const Kk=k.createContext(null);function Yq({children:e}){const[t,n]=k.useState(()=>{try{return localStorage.getItem("markus_sidebar_c")==="1"}catch{return!1}}),[r,o]=k.useState([]),[l,u]=k.useState(null),[d,m]=k.useState(!1),[h,p]=k.useState(!1),g=k.useRef([]),x=k.useRef(null),y=k.useRef(null);y.current=l;const w=k.useCallback(X=>n(X),[]),N=k.useCallback(()=>n(X=>!X),[]),T=k.useCallback(X=>{const F=D2(X),J=`tab_${Date.now().toString(36)}_${Math.random().toString(36).slice(2,7)}`;let B=null;o(Q=>{const re=Q.find(G=>D2(G.payload)===F);if(re)return B=re.id,g.current=Q,Q;let $=[{id:J,title:Wq(X),payload:X},...Q];for(;$.length>Kq;){let G=-1;for(let ce=$.length-1;ce>=0;ce--)if(!$[ce].pinned){G=ce;break}if(G<0)break;$=$.filter((ce,I)=>I!==G)}return B=J,g.current=$,$}),B&&(u(B),x.current=B),n(!0)},[]),C=X=>{X?.kind==="url"&&X.browserId&&window.markusDesktop?.browser?.destroy(X.browserId)},j=k.useCallback(X=>{let F,J,B=!1;o(Q=>{const re=Q.findIndex($=>$.id===X);if(re<0)return Q;F=Q[re]?.payload;const we=Q.filter($=>$.id!==X);return g.current=we,B=we.length===0,J=void 0,(x.current===X||we.length===0)&&(J=we[Math.min(re,we.length-1)]?.id??null),we}),B&&m(!1),J!==void 0&&(u(J),x.current=J),C(F)},[]),_=k.useCallback(()=>{let X=[];o(F=>(X=F.map(J=>J.payload),[])),u(null),m(!1),g.current=[],x.current=null;for(const F of X)C(F)},[]),O=k.useCallback(X=>{u(X),x.current=X},[]),z=k.useCallback((X,F)=>{o(J=>{let B=!1;const Q=J.map(re=>{if(re.payload.kind!=="url"||re.payload.browserId!==X)return re;B=!0;const we=F.url??re.payload.url,$=F.title||re.payload.title||we;return{...re,title:$,payload:{...re.payload,url:we,title:$}}});return B&&(g.current=Q),B?Q:J})},[]),D=k.useCallback(()=>{o(X=>X.length===0?X:(g.current=X,y.current&&(x.current=y.current),[])),u(null),m(!1),window.markusDesktop?.browser?.hideAll?.()},[]),H=k.useCallback(()=>{const X=`tab_${Date.now().toString(36)}_${Math.random().toString(36).slice(2,7)}`,F=`eb_${Date.now().toString(36)}_${Math.random().toString(36).slice(2,7)}`;let J,B=!1,Q=!1;o(re=>{if(re.length>0)return g.current=re,y.current&&(x.current=y.current),Q=!0,J=null,[];if(g.current.length>0){B=!0;const $=g.current;return J=x.current&&$.some(ce=>ce.id===x.current)?x.current:$[0].id,$}B=!0;const we={id:X,title:"New Tab",payload:{kind:"url",url:"about:blank",title:"New Tab",browserId:F}};return g.current=[we],J=we.id,[we]}),B&&n(!0),Q?(u(null),m(!1),window.markusDesktop?.browser?.hideAll?.()):J!=null&&(u(J),x.current=J)},[]),W=k.useCallback(X=>m(X),[]),Z=k.useCallback(()=>m(X=>!X),[]),U=r.find(X=>X.id===l)??r[0]??null,Y=U?.payload??null,ae=k.useMemo(()=>({leftCollapsed:t,setLeftCollapsed:w,toggleLeftCollapsed:N,rightPanel:Y,rightPanelOpen:r.length>0,rightPanelTabs:r,activeRightPanelTabId:U?.id??null,openRightPanel:T,closeRightPanel:_,closeRightPanelTab:j,setActiveRightPanelTab:O,updateRightPanelBrowserTab:z,toggleRightPanel:H,collapseRightPanelOnly:D,rightPanelFullscreen:d,setRightPanelFullscreen:W,toggleRightPanelFullscreen:Z,hostAvailable:h,setHostAvailable:p}),[t,w,N,Y,r,U,T,_,j,O,z,H,D,d,W,Z,h]);return s.jsx(Kk.Provider,{value:ae,children:e})}function z0(){return k.useContext(Kk)}k.lazy(()=>qr(()=>Promise.resolve().then(()=>i3),void 0).then(e=>({default:e.MarkdownMessage})));const Xq=k.lazy(()=>qr(()=>import("./ContentRenderer-DM6YgtR6.js"),[]).then(e=>({default:e.ContentRenderer})));let wo=[],L2=60;function Qq(e){const t=k.useRef(e);t.current=e;const[n]=k.useState(()=>++L2);return k.useEffect(()=>{const r=()=>t.current();wo.push(r);const o=l=>{l.key==="Escape"&&wo[wo.length-1]===r&&(l.preventDefault(),r())};return window.addEventListener("keydown",o,!0),()=>{window.removeEventListener("keydown",o,!0),wo=wo.filter(l=>l!==r),wo.length===0&&(L2=60)}},[]),n}const I2=500,Bs=new Map,s0=new Set,Rd=new Map;let Od=null;function Zq(){if(Bs.size<=I2)return;const e=Bs.size-I2,t=Bs.keys();for(let n=0;n<e;n++){const{value:r,done:o}=t.next();if(o)break;Bs.delete(r)}}function P2(e,t){Bs.delete(e),Bs.set(e,t),Zq()}function z2(e){const t=Rd.get(e);if(t)for(const n of t)n()}function Jq(){Od=null;const e=[...s0];s0.clear(),e.length!==0&&Ce.files.check(e).then(({results:t})=>{for(const[n,r]of Object.entries(t))P2(n,r),z2(n)}).catch(()=>{for(const t of e)P2(t,{exists:!1,isFile:!1,type:"unknown"}),z2(t)})}function eG(e){Bs.has(e)||s0.has(e)||(s0.add(e),Od&&clearTimeout(Od),Od=setTimeout(Jq,30))}function tG(e,t){let n=Rd.get(e);return n||(n=new Set,Rd.set(e,n)),n.add(t),()=>{n.delete(t),n.size===0&&Rd.delete(e)}}function nG(e){const t=k.useCallback(o=>tG(e,o),[e]),n=k.useCallback(()=>Bs.get(e),[e]),r=k.useSyncExternalStore(t,n,n);return k.useEffect(()=>{eG(e)},[e]),r}const rG=/^(?:\/[\w.\-@+]+(?:\/[\w.\-@+ ]*)*|~\/[\w.\-@+]+(?:\/[\w.\-@+ ]*)*|[A-Z]:\\[\w.\-@+ ]+(?:\\[\w.\-@+ ]*)*|\.\.?\/[\w.\-@+]+(?:\/[\w.\-@+ ]*)*)$/;function aG(e){return e.length<2||e.length>500?!1:rG.test(e)}function sG({filePath:e,onClose:t}){const n=Qq(t),[r,o]=k.useState(!0),[l,u]=k.useState(null),[d,m]=k.useState(""),[h,p]=k.useState(""),[g,x]=k.useState(""),[y,w]=k.useState(""),[N,T]=k.useState("");k.useEffect(()=>{o(!0),u(null),Ce.files.preview(e).then(j=>{m(typeof j.content=="string"?j.content:""),p(j.type),x(j.name),w(j.mimeType||""),T(j.streamUrl||(j.path?Ce.files.streamUrl(j.path):"")||(j.type==="audio"||j.type==="video"?Ce.files.streamUrl(e):""))}).catch(j=>{u(String(j?.message||j))}).finally(()=>{o(!1)})},[e]);const C=g||e.split(/[/\\]/).pop()||e;return Ja.createPortal(s.jsx("div",{className:"fixed inset-0 bg-black/40 flex items-center justify-center",style:{zIndex:n},onClick:t,children:s.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:j=>j.stopPropagation(),children:[s.jsxs("div",{className:"flex items-center justify-between px-4 py-3 border-b border-border-default bg-surface-elevated/50 shrink-0",children:[s.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[s.jsx("svg",{className:"w-4 h-4 shrink-0 text-fg-secondary",viewBox:"0 0 20 20",fill:"currentColor",children:s.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"})}),s.jsx("span",{className:"text-sm font-medium text-fg-primary truncate",children:C}),s.jsx("span",{className:"text-xs text-fg-tertiary truncate hidden sm:inline",children:e})]}),s.jsxs("div",{className:"flex items-center gap-2 shrink-0",children:[s.jsx("button",{className:"text-xs text-fg-secondary hover:text-fg-primary px-2 py-1 rounded hover:bg-surface-elevated transition-colors",onClick:()=>Ce.files.reveal(e),title:"Reveal in file explorer",children:s.jsx("svg",{className:"w-4 h-4",viewBox:"0 0 20 20",fill:"currentColor",children:s.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"})})}),s.jsx("button",{className:"text-fg-secondary hover:text-fg-primary p-1 rounded hover:bg-surface-elevated transition-colors",onClick:t,children:s.jsx("svg",{className:"w-4 h-4",viewBox:"0 0 20 20",fill:"currentColor",children:s.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"})})})]})]}),s.jsxs("div",{className:"flex-1 overflow-y-auto p-5",children:[r&&s.jsx("div",{className:"flex items-center justify-center py-12",children:s.jsx("div",{className:"w-5 h-5 border-2 border-brand-500/30 border-t-brand-500 rounded-full animate-spin"})}),l&&s.jsxs("div",{className:"text-center py-12 text-fg-secondary text-sm",children:[s.jsx("p",{className:"text-red-400 mb-1",children:"Failed to load file"}),s.jsx("p",{className:"text-xs text-fg-tertiary",children:l})]}),!r&&!l&&h==="image"&&d&&s.jsx("div",{className:"flex justify-center",children:s.jsx("img",{src:`data:${y||"image/png"};base64,${d}`,alt:C,className:"max-w-full rounded"})}),!r&&!l&&h==="audio"&&N&&s.jsx("audio",{controls:!0,preload:"metadata",src:N,className:"w-full"}),!r&&!l&&h==="video"&&N&&s.jsx("video",{controls:!0,preload:"metadata",src:N,className:"w-full max-h-[60vh] rounded-lg bg-black"}),!r&&!l&&(h==="binary"||!d&&h!=="image"&&h!=="audio"&&h!=="video")&&s.jsxs("div",{className:"text-center py-8 space-y-3",children:[s.jsx("p",{className:"text-sm text-fg-secondary",children:"This file type cannot be previewed."}),s.jsx("button",{className:"px-3 py-2 text-xs rounded-lg bg-brand-600/20 text-brand-500 hover:bg-brand-600/30 transition-colors",onClick:()=>{Ce.files.reveal(e)},children:"Reveal in file explorer"})]}),!r&&!l&&d&&h!=="image"&&h!=="audio"&&h!=="video"&&h!=="binary"&&s.jsx(k.Suspense,{fallback:s.jsx("div",{className:"text-xs text-fg-tertiary",children:"Loading…"}),children:s.jsx(Xq,{content:d,format:h==="text"?"text":h,className:"text-sm"})})]})]})}),document.body)}function iG({path:e}){const t=nG(e),[n,r]=k.useState(null),o=z0(),l=t?.exists??!1,u=t?.type==="markdown"||t?.type==="html"||t?.type==="json"||t?.type==="text"||t?.type==="image"||t?.type==="audio"||t?.type==="video",d=k.useCallback(p=>{if(p.preventDefault(),p.stopPropagation(),!!l)if(u){if(o?.hostAvailable){o.openRightPanel({kind:"file",path:e});return}r(e)}else Ce.files.reveal(e)},[l,u,e,o]),m="inline w-3 h-3 align-[-0.125em]",h=u?s.jsx("svg",{className:m,viewBox:"0 0 20 20",fill:"currentColor",children:s.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"})}):s.jsx("svg",{className:m,viewBox:"0 0 20 20",fill:"currentColor",children:s.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 t?l?s.jsxs(s.Fragment,{children:[s.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:d,title:u?"Click to preview":"Click to reveal in file explorer",role:"button",tabIndex:0,children:[s.jsxs("span",{className:"whitespace-nowrap",children:[h,e.charAt(0)]}),e.slice(1)]}),n&&s.jsx(sG,{filePath:n,onClose:()=>r(null)})]}):s.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}):s.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 Uh=null;function oG(){return Uh||(Uh=qr(()=>import("./mermaid.core-C53surqX.js").then(e=>e.b9),__vite__mapDeps([0,1])).then(e=>(e.default.initialize({startOnLoad:!1,securityLevel:"loose",fontFamily:"inherit"}),e))),Uh}function lG(){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 cG(e){const t=window.matchMedia("(prefers-color-scheme: dark)");t.addEventListener("change",e);const n=new MutationObserver(e);return n.observe(document.documentElement,{attributes:!0,attributeFilter:["class"]}),()=>{t.removeEventListener("change",e),n.disconnect()}}function uG(){return lG()}function dG(){return k.useSyncExternalStore(cG,uG)}function Wk({code:e}){const t=k.useRef(null),[n,r]=k.useState(null),[o,l]=k.useState(!0),u=k.useId(),d=k.useRef(0),m=k.useRef(null),h=dG();return k.useEffect(()=>{if(!e.trim()||m.current&&m.current.code===e&&m.current.dark===h)return;let p=!1;return l(!0),r(null),d.current+=1,(async()=>{try{const g=await oG();if(p)return;g.default.initialize({startOnLoad:!1,theme:h?"dark":"default",securityLevel:"loose",fontFamily:"inherit"});const x=`mermaid-${u.replace(/:/g,"")}-${d.current}`,{svg:y}=await g.default.render(x,e.trim());if(p)return;t.current&&(t.current.innerHTML=y,m.current={code:e,dark:h})}catch(g){p||r(g instanceof Error?g.message:String(g))}finally{p||l(!1)}})(),()=>{p=!0}},[e,u,h]),n?s.jsxs("div",{className:"my-2 rounded-lg overflow-hidden border border-red-500/30",children:[s.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:[s.jsx("svg",{className:"w-3.5 h-3.5 text-red-400",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:s.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"})}),s.jsx("span",{className:"text-[10px] font-medium text-red-400",children:"Mermaid render error"})]}),s.jsx("pre",{className:"p-3 bg-surface-secondary text-xs text-fg-secondary overflow-x-auto font-mono",children:e})]}):s.jsxs("div",{className:"not-prose my-2 rounded-lg bg-surface-secondary border border-border-subtle p-4 overflow-x-auto",children:[o&&s.jsxs("div",{className:"flex items-center gap-2 text-xs text-fg-tertiary",children:[s.jsx("div",{className:"w-4 h-4 border-2 border-fg-tertiary/30 border-t-fg-tertiary rounded-full animate-spin"}),"Rendering diagram…"]}),s.jsx("div",{ref:t,className:`flex justify-center [&>svg]:max-w-full${o?" hidden":""}`})]})}const mG="/assets/viz-global-C_AyN6D9.js";let dd=!1,$h=null;function fG(){return dd?Promise.resolve():new Promise((e,t)=>{const n=document.querySelector("script[data-plantuml-viz]");if(n){globalThis.Viz?(dd=!0,e()):(n.addEventListener("load",()=>{dd=!0,e()}),n.addEventListener("error",()=>t(new Error("Failed to load viz-global.js"))));return}const r=document.createElement("script");r.setAttribute("data-plantuml-viz",""),r.src=mG,r.onload=()=>{dd=!0,e()},r.onerror=()=>t(new Error("Failed to load viz-global.js")),document.head.appendChild(r)})}function hG(){return $h||($h=fG().then(()=>qr(()=>import("./plantuml-DezRDxd4.js"),[]))),$h}let B2=Promise.resolve();function pG(e,t){const n=B2.then(()=>new Promise((r,o)=>{hG().then(({renderToString:l})=>{const u=e.split(/\r\n|\r|\n/);l(u,r,o,{dark:t})}).catch(o)}));return B2=n.then(()=>{},()=>{}),n}function gG(){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 bG(e){const t=window.matchMedia("(prefers-color-scheme: dark)");t.addEventListener("change",e);const n=new MutationObserver(e);return n.observe(document.documentElement,{attributes:!0,attributeFilter:["class"]}),()=>{t.removeEventListener("change",e),n.disconnect()}}function xG(){return k.useSyncExternalStore(bG,()=>gG())}function Yk({code:e}){const[t,n]=k.useState(null),[r,o]=k.useState(null),[l,u]=k.useState(!0),d=k.useRef(null),m=xG();return k.useEffect(()=>{if(!e.trim()||d.current&&d.current.code===e&&d.current.dark===m)return;let h=!1;return u(!0),o(null),pG(e.trim(),m).then(p=>{h||(n(p),d.current={code:e,dark:m})}).catch(p=>{h||o(p instanceof Error?p.message:String(p))}).finally(()=>{h||u(!1)}),()=>{h=!0}},[e,m]),r?s.jsxs("div",{className:"my-2 rounded-lg overflow-hidden border border-red-500/30",children:[s.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:[s.jsx("svg",{className:"w-3.5 h-3.5 text-red-400",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:s.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"})}),s.jsx("span",{className:"text-[10px] font-medium text-red-400",children:"PlantUML render error"})]}),s.jsx("pre",{className:"p-3 bg-surface-secondary text-xs text-fg-secondary overflow-x-auto font-mono",children:e})]}):s.jsxs("div",{className:"not-prose my-2 rounded-lg bg-surface-secondary border border-border-subtle p-4 overflow-x-auto",children:[l&&s.jsxs("div",{className:"flex items-center gap-2 text-xs text-fg-tertiary",children:[s.jsx("div",{className:"w-4 h-4 border-2 border-fg-tertiary/30 border-t-fg-tertiary rounded-full animate-spin"}),"Rendering diagram…"]}),t&&s.jsx("div",{className:`flex justify-center [&>svg]:max-w-full${l?" hidden":""}`,dangerouslySetInnerHTML:{__html:t}})]})}function yG(e,t,n){const r=e.cloneNode(!0),o=n?.fontFamily??"-apple-system,BlinkMacSystemFont,'Segoe UI','Noto Sans',Helvetica,Arial,sans-serif",l=n?.fontSize??"15px",u=n?.headingScales??{h1:1.6,h2:1.35,h3:1.15,h4:1},d=t==="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"},m={p:`margin:0 0 10px;color:${d.text};line-height:1.7;`,h1:`font-size:${u.h1}em;font-weight:700;color:${d.heading};margin:20px 0 10px;line-height:1.3;border-bottom:1px solid ${d.border};padding-bottom:6px;`,h2:`font-size:${u.h2}em;font-weight:700;color:${d.heading};margin:18px 0 8px;line-height:1.3;`,h3:`font-size:${u.h3}em;font-weight:600;color:${d.heading};margin:14px 0 6px;line-height:1.3;`,h4:`font-size:${u.h4}em;font-weight:600;color:${d.heading};margin:12px 0 4px;`,strong:`font-weight:600;color:${d.strong};`,em:"font-style:italic;",a:`color:${d.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:${d.text};`,blockquote:`border-left:3px solid ${d.blockquoteBorder};padding:2px 0 2px 14px;margin:10px 0;color:${d.blockquoteText};`,hr:`border:none;border-top:1px solid ${d.hrColor};margin:20px 0;`,table:"border-collapse:collapse;width:100%;margin:10px 0;",thead:`background:${d.tableHeaderBg};`,th:`border:1px solid ${d.tableBorder};padding:8px 12px;text-align:left;font-weight:600;color:${d.tableHeaderText};`,td:`border:1px solid ${d.tableBorder};padding:8px 12px;color:${d.text};`,img:"max-width:100%;height:auto;"};function h(p){p.removeAttribute("class");const g=p.tagName.toLowerCase();if(g==="pre"){p.setAttribute("style",`background:${d.preBg};color:${d.preText};padding:14px;border-radius:6px;overflow-x:auto;margin:10px 0;font-size:0.88em;line-height:1.5;border:1px solid ${d.preBorder};`);const x=p.querySelector("code");x&&(x.removeAttribute("class"),x.setAttribute("style","background:transparent;padding:0;border-radius:0;color:inherit;font-family:'SFMono-Regular',Consolas,'Liberation Mono',Menlo,monospace;font-size:inherit;"));return}g==="code"?p.setAttribute("style",`background:${d.codeBg};color:${d.codeText};padding:2px 6px;border-radius:4px;font-size:0.9em;font-family:'SFMono-Regular',Consolas,'Liberation Mono',Menlo,monospace;`):m[g]&&p.setAttribute("style",m[g]),Array.from(p.children).forEach(h)}return r.removeAttribute("class"),Array.from(r.children).forEach(p=>h(p)),`<div style="background:${d.bg};color:${d.text};padding:20px 24px;font-family:${o};font-size:${l};line-height:1.7;max-width:800px;">${r.innerHTML}</div>`}async function jg(e){try{return await navigator.clipboard.writeText(e),!0}catch{try{const t=document.createElement("textarea");t.value=e,t.style.cssText="position:fixed;left:-9999px;top:-9999px;opacity:0",document.body.appendChild(t),t.select();const n=document.execCommand("copy");return document.body.removeChild(t),n}catch{return!1}}}async function vG(e,t,n,r){const o=yG(e,t,r);try{return await navigator.clipboard.write([new ClipboardItem({"text/html":new Blob([o],{type:"text/html"}),"text/plain":new Blob([n],{type:"text/plain"})})]),{ok:!0,method:"html"}}catch{return{ok:await jg(n),method:"text"}}}function Lp({code:e,language:t,children:n}){const{t:r}=ft("common"),[o,l]=k.useState("rendered"),[u,d]=k.useState(!1),m=k.useCallback(async()=>{await jg(e)&&(d(!0),setTimeout(()=>d(!1),1800))},[e]);return s.jsxs("div",{className:"not-prose my-2 rounded-lg overflow-hidden border border-border-subtle",children:[s.jsxs("div",{className:"flex items-center justify-between px-3 py-1.5 border-b border-border-subtle bg-surface-secondary",children:[s.jsx("span",{className:"text-[10px] font-medium text-fg-tertiary uppercase tracking-wider select-none",children:t}),s.jsxs("div",{className:"flex items-center gap-1",children:[s.jsx("button",{onClick:()=>l("rendered"),className:`px-2 py-0.5 rounded text-[10px] font-medium transition-colors ${o==="rendered"?"bg-brand-600/20 text-brand-500":"text-fg-tertiary hover:text-fg-secondary"}`,children:s.jsxs("span",{className:"flex items-center gap-1",children:[s.jsxs("svg",{className:"w-3 h-3",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:[s.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M15 12a3 3 0 11-6 0 3 3 0 016 0z"}),s.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"})]}),r("markdown.viewRendered")]})}),s.jsx("button",{onClick:()=>l("source"),className:`px-2 py-0.5 rounded text-[10px] font-medium transition-colors ${o==="source"?"bg-brand-600/20 text-brand-500":"text-fg-tertiary hover:text-fg-secondary"}`,children:s.jsxs("span",{className:"flex items-center gap-1",children:[s.jsx("svg",{className:"w-3 h-3",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:s.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M10 20l4-16m4 4l4 4-4 4M6 16l-4-4 4-4"})}),r("markdown.viewSource")]})})]})]}),o==="rendered"?s.jsx("div",{children:n}):s.jsxs("div",{className:"relative group/source",children:[s.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}),s.jsx("button",{onClick:m,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:r("markdown.copyContent"),children:u?s.jsx("svg",{className:"w-3.5 h-3.5 text-green-400",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:s.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M5 13l4 4L19 7"})}):s.jsx("svg",{className:"w-3.5 h-3.5",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:s.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 md(e,t){const n=/```[\s\S]*?```|`[^`\n]+`/g;let r=0,o="";for(const l of e.matchAll(n))o+=t(e.slice(r,l.index)),o+=l[0],r=l.index+l[0].length;return o+=t(e.slice(r)),o}function wG(e){let t=e.replace(/\\\[([\s\S]*?)\\\]/g,(n,r)=>`$$${r}$$`);return t=t.replace(/\\\((.+?)\\\)/g,(n,r)=>`$${r}$`),t}const fd="#mention:";function kG(e,t){if(!t||t.length===0)return e.replace(/@\[([^\]]+)\]|@([\w\p{L}\p{N}]+)/gu,(l,u,d)=>{const m=u??d;return`[@${m}](${fd}${encodeURIComponent(m)})`});const n=[...t].sort((l,u)=>u.length-l.length);let r="",o=0;for(;o<e.length;){const l=e.indexOf("@",o);if(l<0){r+=e.slice(o);break}if(r+=e.slice(o,l),e[l+1]==="["){const p=e.indexOf("]",l+2);if(p>l+2){const g=e.slice(l+2,p);r+=`[@${g}](${fd}${encodeURIComponent(g)})`,o=p+1;continue}}const u=e.slice(l+1),d=u.toLowerCase(),m=n.find(p=>d.startsWith(p.toLowerCase()));if(m){const p=u.slice(0,m.length);r+=`[@${p}](${fd}${encodeURIComponent(p)})`,o=l+1+m.length;continue}const h=u.match(/^([\w\p{L}\p{N}]+)/u);if(h){const p=h[1];r+=`[@${p}](${fd}${encodeURIComponent(p)})`,o=l+1+p.length;continue}r+="@",o=l+1}return r}const Xk="#entity:",SG=new RegExp("(?<!\\[)(?<!\\()(?<!:)(?<!\\/)(?<!\\\\)\\b(tsk|req|proj|dlv|agt|team)_[a-f0-9]{6,}\\b(?!\\]\\(#entity:)","gi"),NG=/`\[([^\]]+)\]\(#entity:((?:tsk|req|proj|dlv|agt|team)_[a-f0-9]{6,})\)`/gi;function CG(e,t){const n=e.slice(0,t),r=n.lastIndexOf("](");return r===-1?!1:n.indexOf(")",r+2)===-1}function TG(e){return e.replace(NG,(t,n,r)=>`[${n}](${Xk}${r})`)}function EG(e){return e.replace(SG,(t,n,r)=>CG(e,r)?t:`[${t}](${Xk}${t})`)}function AG(e){const t=e.trim();return t.startsWith("@startuml")&&t.endsWith("@enduml")}const _G=/^(graph\s|flowchart\s|sequenceDiagram|classDiagram|stateDiagram|erDiagram|gantt|pie|gitGraph|mindmap|timeline|journey)/m;function jG(e){return _G.test(e.trim())}const MG={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 RG(e){return MG[e.toLowerCase()]??e.charAt(0).toUpperCase()+e.slice(1)}function OG(e){const t=e.match(/language-(\S+)/);return t?t[1]:null}const DG=[Wk,Yk];function LG(e){for(const t of k.Children.toArray(e))if(k.isValidElement(t)&&typeof t.props?.className=="string"){const n=t.props.className;return OG(n)}return null}function ac(e){if(typeof e=="string")return e;if(typeof e=="number")return String(e);if(!e)return"";if(Array.isArray(e))return e.map(ac).join("");if(k.isValidElement(e)){const t=e.props;return ac(t.children)}return""}function IG({children:e}){const{t}=ft("common"),n=LG(e),r=k.useRef(null),[o,l]=k.useState(!1),[u,d]=k.useState("rendered"),m=k.useCallback(async()=>{let p;u==="source"?p=ac(e):p=r.current?.querySelector("code")?.textContent??"";try{await navigator.clipboard.writeText(p),l(!0),setTimeout(()=>l(!1),1800)}catch{}},[u,e]);if(k.Children.toArray(e).some(p=>k.isValidElement(p)&&DG.includes(p.type))){const p=ac(e),g=n==="mermaid"||n==="plantuml"?n:"diagram";return s.jsx(Lp,{code:p,language:g,children:e})}return n==="mermaid"||n==="plantuml"?s.jsx(s.Fragment,{children:e}):s.jsxs("div",{className:"not-prose relative group/code my-2 rounded-lg overflow-hidden bg-surface-secondary border border-border-subtle",children:[n&&s.jsxs("div",{className:"flex items-center justify-between px-3 py-1.5 border-b border-border-subtle",children:[s.jsx("span",{className:"text-[10px] font-medium text-fg-tertiary uppercase tracking-wider select-none",children:RG(n)}),s.jsxs("div",{className:"flex items-center gap-1",children:[s.jsx("button",{onClick:()=>d("rendered"),className:`px-1.5 py-0.5 rounded text-[10px] font-medium transition-colors ${u==="rendered"?"bg-brand-600/20 text-brand-500":"text-fg-tertiary hover:text-fg-secondary"}`,children:t("markdown.viewRendered")}),s.jsx("button",{onClick:()=>d("source"),className:`px-1.5 py-0.5 rounded text-[10px] font-medium transition-colors ${u==="source"?"bg-brand-600/20 text-brand-500":"text-fg-tertiary hover:text-fg-secondary"}`,children:t("markdown.viewSource")})]})]}),s.jsxs("div",{className:"relative",children:[u==="rendered"?s.jsx("pre",{ref:r,className:"p-3 overflow-x-auto text-xs [&>code]:p-0 [&>code]:rounded-none [&>code]:text-fg-secondary",children:k.Children.map(e,p=>k.isValidElement(p)?k.cloneElement(p,{style:{background:"transparent",padding:0}}):p)}):s.jsx("pre",{className:"p-3 overflow-x-auto text-xs font-mono text-fg-secondary whitespace-pre-wrap break-words",children:ac(e)}),s.jsx("button",{onClick:m,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:t("markdown.copyContent"),children:o?s.jsx("svg",{className:"w-3.5 h-3.5 text-green-400",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:s.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M5 13l4 4L19 7"})}):s.jsx("svg",{className:"w-3.5 h-3.5",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:s.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 Qk="markus-copy-typography",U2={fontFamily:"default",fontSize:15,headingScale:"standard"};function Zk(){try{const e=localStorage.getItem(Qk);if(e)return{...U2,...JSON.parse(e)}}catch{}return U2}function PG(e){localStorage.setItem(Qk,JSON.stringify(e))}function zG(e){const t={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"},n={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:t[e.fontFamily]??t.default,fontSize:`${e.fontSize}px`,headingScales:n[e.headingScale]??n.standard}}function BG({onClose:e}){const{t}=ft("common"),[n,r]=k.useState(Zk);k.useEffect(()=>{PG(n)},[n]);const o=k.useCallback((l,u)=>{r(d=>({...d,[l]:u}))},[]);return s.jsxs("div",{className:"px-3 py-2 space-y-3 max-w-[260px]",children:[s.jsxs("div",{className:"flex items-center justify-between mb-1",children:[s.jsx("span",{className:"font-medium text-fg-primary text-xs",children:t("markdown.typographySettings")}),s.jsx("button",{onClick:e,className:"text-fg-tertiary hover:text-fg-primary p-0.5",children:s.jsx("svg",{className:"w-3 h-3",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:s.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M6 18L18 6M6 6l12 12"})})})]}),s.jsx("p",{className:"text-[10px] text-fg-tertiary",children:t("markdown.typographyDesc")}),s.jsxs("div",{children:[s.jsx("label",{className:"text-[10px] text-fg-tertiary font-medium block mb-1",children:t("markdown.fontFamily")}),s.jsxs("select",{value:n.fontFamily,onChange:l=>o("fontFamily",l.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:[s.jsx("option",{value:"default",children:t("markdown.fontDefault")}),s.jsx("option",{value:"serif",children:t("markdown.fontSerif")}),s.jsx("option",{value:"sans-serif",children:t("markdown.fontSansSerif")}),s.jsx("option",{value:"mono",children:t("markdown.fontMono")})]})]}),s.jsxs("div",{children:[s.jsxs("label",{className:"text-[10px] text-fg-tertiary font-medium block mb-1",children:[t("markdown.fontSize"),": ",n.fontSize,"px"]}),s.jsx("input",{type:"range",min:10,max:24,step:1,value:n.fontSize,onChange:l=>o("fontSize",Number(l.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"}),s.jsxs("div",{className:"flex justify-between text-[9px] text-fg-tertiary mt-0.5",children:[s.jsx("span",{children:"10px"}),s.jsx("span",{children:"24px"})]})]}),s.jsxs("div",{children:[s.jsx("label",{className:"text-[10px] text-fg-tertiary font-medium block mb-1",children:t("markdown.headingScale")}),s.jsx("div",{className:"flex gap-1",children:["compact","standard","large"].map(l=>s.jsx("button",{onClick:()=>o("headingScale",l),className:`flex-1 px-2 py-1 rounded text-[10px] font-medium transition-colors ${n.headingScale===l?"bg-brand-600/20 text-brand-500":"bg-surface-primary text-fg-tertiary hover:text-fg-secondary border border-border-subtle"}`,children:t(`markdown.scale${l.charAt(0).toUpperCase()+l.slice(1)}`)},l))})]})]})}const UG=k.lazy(()=>qr(()=>Promise.resolve().then(()=>i3),void 0).then(e=>({default:e.MarkdownMessage}))),$G={file:{icon:"📄",color:"bg-green-500/10 text-green-600"},directory:{icon:"📁",color:"bg-blue-500/10 text-blue-600"}},$2={active:{color:"text-green-600 bg-green-500/10"},verified:{color:"text-blue-600 bg-blue-500/10"},outdated:{color:"text-fg-tertiary bg-surface-elevated/50"}};function HG({item:e,onClose:t,onOpenInPage:n}){const{t:r}=ft(["agent","common"]),o=$G[e.type]??{icon:"📎",color:"bg-surface-elevated text-fg-secondary"},l=$2[e.status]??$2.active,u=/^https?:\/\//i.test(e.reference??"");k.useEffect(()=>{const m=h=>{h.key==="Escape"&&t()};return window.addEventListener("keydown",m),()=>window.removeEventListener("keydown",m)},[t]);const d=s.jsxs("div",{className:"fixed inset-0 z-50 flex items-center justify-center p-4",onClick:t,children:[s.jsx("div",{className:"absolute inset-0 bg-black/50 backdrop-blur-sm"}),s.jsxs("div",{className:"relative bg-surface-primary rounded-2xl shadow-2xl border border-border-default w-full max-w-lg max-h-[85vh] overflow-y-auto",onClick:m=>m.stopPropagation(),children:[s.jsxs("div",{className:"sticky top-0 bg-surface-primary/95 backdrop-blur-sm border-b border-border-default px-5 py-4 flex items-start gap-3 rounded-t-2xl z-10",children:[s.jsx("span",{className:`inline-flex items-center justify-center w-10 h-10 rounded-xl text-lg shrink-0 ${o.color}`,children:o.icon}),s.jsxs("div",{className:"flex-1 min-w-0",children:[s.jsx("h3",{className:"text-base font-semibold text-fg-primary",children:e.title}),s.jsxs("div",{className:"flex items-center gap-2 mt-1 flex-wrap",children:[s.jsx("span",{className:`px-1.5 py-0.5 text-[10px] rounded font-medium ${l.color}`,children:e.status}),s.jsx("span",{className:"text-[10px] text-fg-tertiary",children:e.type}),e.format&&s.jsx("span",{className:"text-[10px] px-1.5 py-0.5 bg-surface-elevated rounded text-fg-secondary",children:e.format})]})]}),s.jsx("button",{onClick:t,className:"p-1.5 rounded-lg hover:bg-surface-overlay transition-colors shrink-0 text-fg-tertiary hover:text-fg-primary",children:s.jsxs("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[s.jsx("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),s.jsx("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]})})]}),s.jsxs("div",{className:"px-5 py-4 space-y-4",children:[e.summary&&e.summary.trim()!==e.title.trim()&&s.jsxs("div",{children:[s.jsx("label",{className:"text-[10px] text-fg-tertiary uppercase tracking-wider font-medium",children:r("agent:deliverables.summary")}),s.jsx("div",{className:"mt-1.5",children:s.jsx(k.Suspense,{fallback:s.jsx("p",{className:"text-sm text-fg-secondary",children:e.summary}),children:s.jsx(UG,{content:e.summary,className:"text-sm text-fg-secondary"})})})]}),e.reference&&s.jsxs("div",{children:[s.jsx("label",{className:"text-[10px] text-fg-tertiary uppercase tracking-wider font-medium",children:r("agent:deliverables.reference")}),s.jsxs("div",{className:"mt-1.5 flex items-center gap-2 bg-surface-elevated rounded-lg px-3 py-2",children:[s.jsx("span",{className:"text-xs text-fg-secondary font-mono break-all flex-1 select-all",children:e.reference}),u?s.jsx("button",{onClick:()=>window.open(e.reference,"_blank","noopener,noreferrer"),className:"px-2 py-1 text-[10px] rounded bg-brand-600/20 text-brand-500 hover:bg-brand-600/30 transition-colors shrink-0",children:r("common:open")}):s.jsx("button",{onClick:()=>{Ce.files.reveal(e.reference).catch(()=>{})},className:"px-2 py-1 text-[10px] rounded bg-brand-600/20 text-brand-500 hover:bg-brand-600/30 transition-colors shrink-0",children:r("common:open")})]})]}),e.diffStats&&s.jsxs("div",{className:"flex items-center gap-3 text-xs bg-surface-elevated rounded-lg px-3 py-2",children:[s.jsx("span",{className:"text-fg-tertiary font-medium",children:"Diff:"}),s.jsxs("span",{className:"text-fg-secondary",children:[e.diffStats.filesChanged," file",e.diffStats.filesChanged!==1?"s":""]}),s.jsxs("span",{className:"text-green-500",children:["+",e.diffStats.additions]}),s.jsxs("span",{className:"text-red-500",children:["-",e.diffStats.deletions]})]}),e.testResults&&s.jsxs("div",{className:"flex items-center gap-3 text-xs bg-surface-elevated rounded-lg px-3 py-2",children:[s.jsx("span",{className:"text-fg-tertiary font-medium",children:"Tests:"}),s.jsxs("span",{className:"text-green-500",children:[e.testResults.passed," passed"]}),e.testResults.failed>0&&s.jsxs("span",{className:"text-red-500",children:[e.testResults.failed," failed"]}),e.testResults.skipped>0&&s.jsxs("span",{className:"text-fg-tertiary",children:[e.testResults.skipped," skipped"]})]}),e.tags.length>0&&s.jsx("div",{className:"flex flex-wrap gap-1.5",children:e.tags.map(m=>s.jsx("span",{className:"px-2 py-0.5 text-[11px] bg-surface-elevated rounded-md text-fg-tertiary",children:m},m))}),s.jsxs("div",{className:"flex items-center gap-4 text-[10px] text-fg-tertiary flex-wrap pt-1 border-t border-border-default/50",children:[s.jsxs("span",{children:[r("agent:deliverables.created"),": ",new Date(e.createdAt).toLocaleString()]}),s.jsxs("span",{children:[r("agent:deliverables.updated"),": ",new Date(e.updatedAt).toLocaleString()]}),e.accessCount>0&&s.jsx("span",{children:r("agent:deliverables.accessed",{count:e.accessCount})})]})]}),s.jsxs("div",{className:"sticky bottom-0 bg-surface-primary/95 backdrop-blur-sm border-t border-border-default px-5 py-3 flex items-center justify-end gap-2 rounded-b-2xl",children:[s.jsxs("button",{onClick:()=>n(e.id),className:"px-3 py-1.5 text-xs font-medium text-brand-500 hover:bg-brand-500/10 rounded-lg transition-colors flex items-center gap-1.5",children:[s.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[s.jsx("path",{d:"M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6"}),s.jsx("polyline",{points:"15 3 21 3 21 9"}),s.jsx("line",{x1:"10",y1:"14",x2:"21",y2:"3"})]}),r("agent:deliverables.openInPage")]}),s.jsx("button",{onClick:t,className:"px-3 py-1.5 text-xs font-medium text-fg-secondary bg-surface-elevated hover:bg-surface-overlay rounded-lg transition-colors",children:r("common:close")})]})]})]});return typeof document<"u"?Ja.createPortal(d,document.body):d}const FG={tsk:"task",req:"requirement",proj:"project",dlv:"deliverable",agt:"agent",team:"team"};function Jk(e){return{task:"task",requirement:"requirement",project:"project",deliverable:"deliverable",agent:"agent",team:"team"}[e]}const e3={task:"📋",requirement:"📝",project:"📁",deliverable:"📦",agent:"🤖",team:"👥"},t3={task:"Task",requirement:"Requirement",project:"Project",deliverable:"Deliverable",agent:"Agent",team:"Team"},qG=/^(tsk|req|proj|dlv|agt|team)_[a-f0-9]{6,}$/i;function Ip(e){return qG.test(e.trim())}function GG(e){const t=e.split("_")[0]?.toLowerCase();return t?FG[t]:void 0}function n3(e){e.startsWith("tsk_")?at.navigate(me.WORK,{openTask:e}):e.startsWith("req_")?at.navigate(me.WORK,{openRequirement:e}):e.startsWith("proj_")?at.navigate(me.WORK,{projectId:e}):e.startsWith("dlv_")?at.navigate(me.DELIVERABLES,{openDeliverable:e}):e.startsWith("agt_")?at.navigate(me.TEAM,{agentId:e}):e.startsWith("team_")&&at.navigate(me.TEAM,{selectTeam:e})}const Hh=new Map,hd=new Map;async function VG(e,t){const n={id:e,type:t,title:e,loading:!1};try{switch(t){case"task":{const r=await Ce.tasks.get(e);return{...n,title:r.task.title,status:r.task.status}}case"requirement":{const r=await Ce.requirements.get(e);return{...n,title:r.requirement.title,status:r.requirement.status}}case"project":{const r=await Ce.projects.get(e);return{...n,title:r.project.name,status:r.project.status,summary:r.project.description}}case"deliverable":{const r=await Ce.deliverables.get(e);return{...n,title:r.deliverable.title,status:r.deliverable.status,summary:r.deliverable.summary,deliverable:r.deliverable}}case"agent":{const r=await Ce.agents.get(e);return{...n,title:r.name,summary:r.role}}case"team":{const o=(await Ce.teams.list()).teams.find(l=>l.id===e);return{...n,title:o?.name??e,notFound:!o}}}}catch{}return{...n,notFound:!0}}function r3(e,t){const n=t??GG(e),[r,o]=k.useState(()=>Hh.get(e)??{id:e,type:n??"task",title:e,loading:!!n});return k.useEffect(()=>{if(!n){o({id:e,type:"task",title:e,loading:!1,notFound:!0});return}const l=Hh.get(e);if(l){o(l);return}o(m=>({...m,type:n,loading:!0}));let u=!0,d=hd.get(e);return d||(d=VG(e,n),hd.set(e,d)),d.then(m=>{Hh.set(e,m),hd.delete(e),u&&o(m)}).catch(()=>{hd.delete(e),u&&o({id:e,type:n,title:e,loading:!1,notFound:!0})}),()=>{u=!1}},[e,n]),r}function a3(e){const t=(e.split("_")[0]?.length??3)+1;return e.length>t+8?`${e.slice(0,t+8)}…`:e}function i0({id:e,type:t,label:n}){const r=r3(e,t),o=z0(),l=e3[r.type]??"🔗",u=n??(r.loading||r.notFound?a3(e):r.title),d=m=>{if(m.preventDefault(),m.stopPropagation(),r.type==="deliverable"&&r.deliverable&&o?.hostAvailable){o.openRightPanel({kind:"deliverable",deliverable:r.deliverable});return}n3(e)};return s.jsxs("span",{"data-entity-link":e,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 align-baseline",onClick:d,title:`${t3[r.type]}: ${r.notFound?e:r.title} (${e})`,children:[s.jsx("span",{className:"text-[10px]",children:l}),s.jsx("span",{className:"truncate max-w-[240px] align-baseline",children:u})]})}function KG({id:e,type:t,label:n}){const r=r3(e,t),[o,l]=k.useState(!1),u=z0(),d=e3[r.type]??"🔗",m=()=>{if(r.type==="deliverable"&&r.deliverable){if(u?.hostAvailable){u.openRightPanel({kind:"deliverable",deliverable:r.deliverable});return}l(!0);return}n3(e)},h=r.loading?a3(e):n||(r.notFound?e:r.title);return s.jsxs("span",{className:"not-prose block my-2",children:[s.jsxs("button",{type:"button",onClick:m,className:"w-full max-w-md text-left rounded-xl border border-border-default bg-surface-elevated/30 hover:border-brand-500/40 hover:bg-surface-elevated/50 transition-colors px-3 py-2.5 flex items-start gap-2.5",children:[s.jsx("span",{className:"inline-flex items-center justify-center w-8 h-8 rounded-lg text-sm shrink-0 bg-brand-500/10",children:d}),s.jsxs("span",{className:"flex-1 min-w-0 block",children:[s.jsxs("span",{className:"flex items-center gap-2 flex-wrap",children:[s.jsx("span",{className:"text-[10px] uppercase tracking-wide text-fg-tertiary font-medium",children:t3[r.type]}),r.status&&s.jsx("span",{className:"px-1.5 py-0.5 text-[10px] rounded font-medium bg-brand-500/10 text-brand-500",children:r.status})]}),s.jsx("span",{className:`block text-sm font-medium truncate mt-0.5 ${r.notFound?"font-mono text-fg-tertiary":"text-fg-primary"}`,children:h}),r.summary&&r.summary.trim()!==r.title.trim()&&s.jsx("span",{className:"block text-xs text-fg-tertiary mt-0.5 line-clamp-1",children:r.summary})]}),s.jsx("svg",{className:"w-4 h-4 text-fg-tertiary shrink-0 mt-1",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:s.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M9 5l7 7-7 7"})})]}),o&&r.deliverable&&s.jsx(HG,{item:r.deliverable,onClose:()=>l(!1),onOpenInPage:p=>{l(!1),at.navigate(me.DELIVERABLES,{openDeliverable:p})}})]})}class WG extends k.Component{state={error:null};static getDerivedStateFromError(t){return{error:t}}componentDidUpdate(t){this.state.error&&this.props.resetKeys&&!YG(t.resetKeys,this.props.resetKeys)&&this.setState({error:null})}componentDidCatch(t,n){this.props.onError?.(t,n),console.error("[ErrorBoundary] caught render error:",t,n.componentStack)}reset=()=>this.setState({error:null});render(){const{error:t}=this.state;if(t){const{fallback:n}=this.props;return typeof n=="function"?n(t,this.reset):n??null}return this.props.children}}function YG(e,t){if(e===t)return!0;if(!e||!t||e.length!==t.length)return!1;for(let n=0;n<e.length;n++)if(e[n]!==t[n])return!1;return!0}const XG=/^(deliverable|task|requirement|project|agent|team|workflow):/i;function H2(e){return XG.test(e)?e:V5(e)}const F2=[xw,zH,vk],q2=[[bF,{strict:"ignore"}],[Vk,{detect:!0,ignoreMissing:!0}]],QG=/<think>([\s\S]*?)(<\/think>|$)/g;function ZG(e){const t=[];let n=e.replace(QG,(r,o)=>{const l=o.trim();return l&&t.push(l),""});return n=n.replace(/<\/think>/g,"").replace(/<think>/g,""),{thinking:t,rest:n.trim()}}const G2="#mention:",o0="#entity:",JG=/^\[([^\]]+)\]\(#entity:((tsk|req|proj|dlv|agt|team)_[a-f0-9]{6,})\)$/i,s3=/^(workflow|task|requirement|project|deliverable|agent|team):(.+)$/;function Pp(e){return e.type==="text"?e.value??"":(e.children??[]).map(Pp).join("")}function eV(e){return e.type==="text"&&(e.value??"").trim()===""}function tV(e){if(!e?.children)return null;const t=e.children.filter(r=>!eV(r));if(t.length!==1)return null;const n=t[0];if(n.type==="element"&&n.tagName==="a"){const r=n.properties?.href;if(!r)return null;const o=Pp(n);if(r.startsWith(o0))return{id:r.slice(o0.length)};const l=r.match(s3);return l&&l[1]!=="workflow"?{id:l[2],type:Jk(l[1]),label:o}:null}if(n.type==="element"&&n.tagName==="code"){const r=Pp(n).trim();if(Ip(r))return{id:r}}if(n.type==="text"){const r=(n.value??"").trim();if(Ip(r))return{id:r}}return null}const nV={p:({children:e})=>s.jsx("p",{className:"mb-2 last:mb-0 leading-relaxed text-fg-secondary",children:e}),h1:({children:e})=>s.jsx("h1",{className:"text-base font-bold mb-2 mt-3 first:mt-0 text-fg-primary",children:e}),h2:({children:e})=>s.jsx("h2",{className:"text-sm font-bold mb-2 mt-3 first:mt-0 text-fg-primary",children:e}),h3:({children:e})=>s.jsx("h3",{className:"text-sm font-semibold mb-1 mt-2 first:mt-0 text-fg-primary",children:e}),h4:({children:e})=>s.jsx("h4",{className:"text-sm font-semibold mb-1 mt-2 first:mt-0 text-fg-primary",children:e}),h5:({children:e})=>s.jsx("h5",{className:"text-xs font-semibold mb-1 mt-2 first:mt-0 text-fg-primary",children:e}),h6:({children:e})=>s.jsx("h6",{className:"text-xs font-medium mb-1 mt-2 first:mt-0 text-fg-primary",children:e}),ul:({children:e})=>s.jsx("ul",{className:"list-disc pl-4 mb-2 space-y-0.5",children:e}),ol:({children:e,start:t})=>s.jsx("ol",{start:t,className:"list-decimal pl-7 mb-2 space-y-0.5",children:e}),li:({children:e,value:t})=>s.jsx("li",{value:t,className:"leading-relaxed text-fg-secondary marker:text-fg-secondary",children:e}),code:({children:e,className:t})=>{const n=typeof e=="string"?e:String(e??""),r=n.trim();if(t?.includes("language-plantuml")||AG(r))return s.jsx(Lp,{code:r,language:"plantuml",children:s.jsx(Yk,{code:r})});if(t?.includes("language-mermaid")||!t&&jG(r))return s.jsx(Lp,{code:r,language:"mermaid",children:s.jsx(Wk,{code:r})});if(t?.includes("language-"))return s.jsx("code",{className:`${t} text-fg-secondary font-mono text-xs`,children:e});if(Ip(n))return s.jsx(i0,{id:n.trim()});const o=n.match(JG);return o?s.jsx(i0,{id:o[2],label:o[1]}):aG(n)?s.jsx(iG,{path:n}):s.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})=>s.jsx(IG,{children:e}),strong:({children:e})=>s.jsx("strong",{className:"font-bold text-fg-primary",children:e}),em:({children:e})=>s.jsx("em",{className:"italic text-fg-secondary",children:e}),del:({children:e})=>s.jsx("del",{className:"line-through text-fg-tertiary",children:e}),blockquote:({children:e})=>s.jsx("blockquote",{className:"border-l-2 border-brand-500 pl-3 my-2 text-fg-secondary italic",children:e}),a:({href:e,children:t})=>s.jsx("a",{href:e,target:"_blank",rel:"noopener noreferrer",className:"text-brand-500 hover:text-brand-500 underline break-all",children:t}),hr:()=>s.jsx("hr",{className:"border-border-default my-3"}),table:({children:e})=>s.jsx("div",{className:"overflow-x-auto my-2",children:s.jsx("table",{className:"min-w-full text-sm border-collapse border border-border-default",children:e})}),thead:({children:e})=>s.jsx("thead",{className:"bg-surface-secondary",children:e}),tbody:({children:e})=>s.jsx("tbody",{className:"divide-y divide-border-default",children:e}),tr:({children:e})=>s.jsx("tr",{className:"hover:bg-surface-elevated/50 transition-colors",children:e}),th:({children:e})=>s.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})=>s.jsx("td",{className:"px-3 py-2 text-sm text-fg-primary border border-border-default",children:e})},rV=/^(?:\/[\w.\-@+ ]|~\/|\.\.?\/|[A-Z]:\\)/,aV=/\.(png|jpe?g|gif|webp|svg|bmp|ico)$/i;function sV(e){return rV.test(e)&&aV.test(e)}function iV(e,t){if(e.startsWith("/")||e.startsWith("~/")||/^[A-Z]:\\/.test(e))return e;if((e.startsWith("./")||e.startsWith("../"))&&t){const r=((t.endsWith("/")?t:t+"/")+e).split("/"),o=[];for(const l of r)l===".."?o.pop():l!=="."&&l!==""&&o.push(l);return"/"+o.join("/")}return e}function oV(e){return`/api/files/image?path=${encodeURIComponent(e)}`}const ko=new Map;function lV({src:e,alt:t,onPreview:n,basePath:r}){const o=k.useMemo(()=>sV(e)?oV(iV(e,r)):e,[e,r]),l=o.startsWith("/api/files/image?"),u=ko.get(o),[d,m]=k.useState(u??(l?null:o)),[h,p]=k.useState(!!u),[g,x]=k.useState(!1),[y,w]=k.useState(null),[N,T]=k.useState(0),C=k.useRef(0),j=k.useCallback(()=>{ko.delete(o),x(!1),w(null),p(!1),m(l?null:`${o}${o.includes("?")?"&":"?"}retry=${Date.now()}`),T(_=>_+1)},[o,l]);return k.useEffect(()=>{if(!l)return;const _=ko.get(o);if(_){m(_),p(!0),x(!1),w(null);return}const O=++C.current;x(!1),w(null),p(!1),m(null),(async()=>{try{const z=await fetch(o,{credentials:"same-origin"});if(O!==C.current)return;if(!z.ok){let W=`HTTP ${z.status}`;try{const Z=await z.json();Z.error&&(W=Z.error)}catch{}throw new Error(W)}const D=await z.blob();if(O!==C.current)return;if(D.size===0)throw new Error("Empty image response");if(D.type&&!D.type.startsWith("image/")&&!D.type.includes("octet-stream"))throw new Error(`Unexpected content-type: ${D.type}`);const H=URL.createObjectURL(D);ko.set(o,H),m(H),p(!0),x(!1),w(null)}catch(z){if(O!==C.current)return;const D=z instanceof Error?z.message:String(z);console.warn("[MarkdownImage] failed to load local image",o,z),w(D),x(!0),p(!1)}})()},[l,o,N]),k.useEffect(()=>{l||(m(o),p(!!ko.get(o)),x(!1),w(null))},[o,l,N]),g?s.jsxs("button",{type:"button",onClick:j,title:y??"Click to retry",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 hover:bg-surface-overlay hover:text-fg-secondary cursor-pointer transition-colors max-w-full",children:[s.jsxs("svg",{className:"w-4 h-4 shrink-0",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:1.5,children:[s.jsx("rect",{x:"3",y:"3",width:"18",height:"18",rx:"2",ry:"2"}),s.jsx("circle",{cx:"8.5",cy:"8.5",r:"1.5"}),s.jsx("polyline",{points:"21 15 16 10 5 21"})]}),s.jsxs("span",{className:"truncate",children:["Failed to load image — click to retry",y?` (${y})`:""]})]}):s.jsxs("span",{className:"inline-block align-middle max-w-full",children:[!h&&s.jsx("span",{className:"block w-full min-h-[80px] max-w-[400px] bg-surface-elevated rounded-lg animate-pulse"}),d?s.jsx("img",{src:d,alt:t??"",onLoad:()=>{l||ko.set(o,o),p(!0)},onError:()=>{w("Image decode failed"),x(!0)},onClick:()=>n?.(d),className:`max-w-full h-auto rounded-lg cursor-pointer hover:opacity-90 transition-opacity my-1${h?"":" absolute opacity-0 pointer-events-none"}`,style:{maxHeight:"400px",objectFit:"contain"}}):null]})}async function V2(e){const t=await fetch(e);if(!t.ok)throw new Error(`Failed to fetch image (${t.status})`);return t.blob()}async function cV(e){if(e.type==="image/png")return e;const t=await createImageBitmap(e),n=document.createElement("canvas");n.width=t.width,n.height=t.height;const r=n.getContext("2d");if(!r)throw new Error("Canvas unavailable");return r.drawImage(t,0,0),t.close(),new Promise((o,l)=>{n.toBlob(u=>u?o(u):l(new Error("PNG encode failed")),"image/png")})}function uV(e,t){try{const o=(e.startsWith("data:")?"":new URL(e,window.location.href).pathname).split("/").pop()||"";if(o&&/\.(png|jpe?g|gif|webp|svg|bmp)$/i.test(o))return decodeURIComponent(o)}catch{}return`image.${(t.type.split("/")[1]||"png").replace("jpeg","jpg")}`}function dV({src:e,onClose:t}){const{t:n}=ft("common"),[r,o]=k.useState(null),[l,u]=k.useState(null);Bo(!0),k.useEffect(()=>{const g=x=>{x.key==="Escape"&&t()};return document.addEventListener("keydown",g),()=>document.removeEventListener("keydown",g)},[t]);const d=k.useCallback(g=>{o(g),window.setTimeout(()=>o(null),1600)},[]),m=k.useCallback(async g=>{if(g.stopPropagation(),!l){u("copy");try{const x=await V2(e),y=await cV(x);await navigator.clipboard.write([new ClipboardItem({"image/png":y})]),d(n("imageCopied"))}catch{d(n("imageCopyFailed"))}finally{u(null)}}},[l,d,e,n]),h=k.useCallback(async g=>{if(g.stopPropagation(),!l){u("download");try{const x=await V2(e),y=URL.createObjectURL(x),w=document.createElement("a");w.href=y,w.download=uV(e,x),document.body.appendChild(w),w.click(),w.remove(),URL.revokeObjectURL(y),d(n("imageDownloaded"))}catch{d(n("imageDownloadFailed"))}finally{u(null)}}},[l,d,e,n]),p="inline-flex items-center gap-1.5 px-3 py-1.5 rounded-lg bg-white/10 hover:bg-white/20 text-white text-sm transition-colors disabled:opacity-50";return Ja.createPortal(s.jsxs("div",{className:"fixed inset-0 z-[9999] bg-black/80 flex items-center justify-center p-4",onClick:t,children:[s.jsxs("div",{className:"absolute top-4 right-4 z-10 flex items-center gap-2",onClick:g=>g.stopPropagation(),children:[s.jsxs("button",{type:"button",className:p,onClick:m,disabled:!!l,title:n("copyImage"),children:[s.jsxs("svg",{className:"w-4 h-4",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[s.jsx("rect",{x:"9",y:"9",width:"13",height:"13",rx:"2"}),s.jsx("path",{d:"M5 15H4a2 2 0 01-2-2V4a2 2 0 012-2h9a2 2 0 012 2v1"})]}),n("copy")]}),s.jsxs("button",{type:"button",className:p,onClick:h,disabled:!!l,title:n("downloadImage"),children:[s.jsxs("svg",{className:"w-4 h-4",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[s.jsx("path",{d:"M21 15v4a2 2 0 01-2 2H5a2 2 0 01-2-2v-4"}),s.jsx("polyline",{points:"7 10 12 15 17 10"}),s.jsx("line",{x1:"12",y1:"15",x2:"12",y2:"3"})]}),n("downloadImage")]}),s.jsx("button",{type:"button",onClick:t,className:"w-10 h-10 rounded-full bg-white/10 hover:bg-white/20 flex items-center justify-center transition-colors",title:n("close"),children:s.jsxs("svg",{className:"w-6 h-6 text-white",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2,children:[s.jsx("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),s.jsx("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]})})]}),r&&s.jsx("div",{className:"absolute top-16 left-1/2 -translate-x-1/2 z-10 px-3 py-1.5 rounded-lg bg-black/70 text-white text-xs",children:r}),s.jsx("img",{src:e,alt:"Preview",className:"max-w-full max-h-[90vh] object-contain rounded-lg",onClick:g=>g.stopPropagation()})]}),document.body)}function mV(e=640){const[t,n]=k.useState(()=>window.innerWidth<e);return k.useEffect(()=>{const r=window.matchMedia(`(max-width: ${e-1}px)`),o=l=>n(l.matches);return r.addEventListener("change",o),n(r.matches),()=>r.removeEventListener("change",o)},[e]),t}function fV({content:e,contentRef:t}){const{t:n}=ft("common"),[r,o]=k.useState(!1),[l,u]=k.useState(!1),[d,m]=k.useState(!1),[h,p]=k.useState(null),g=k.useRef(null),x=mV();k.useEffect(()=>{if(!r)return;const T=C=>{g.current&&!g.current.contains(C.target)&&(o(!1),u(!1),m(!1))};return document.addEventListener("mousedown",T),()=>document.removeEventListener("mousedown",T)},[r]);const y=k.useCallback(T=>{p(T),setTimeout(()=>p(null),1500)},[]),w=async()=>{const T=await jg(e);y(n(T?"markdown.copied":"markdown.failed")),o(!1)},N=async T=>{const C=t.current?.firstElementChild;if(!C)return;const j=Zk(),_=zG(j),O=await vG(C,T,e,{fontFamily:_.fontFamily,fontSize:_.fontSize,headingScales:_.headingScales}),z=n(T==="light"?"markdown.themeLight":"markdown.themeDark");y(O.ok?O.method==="html"?n("markdown.htmlCopied",{theme:z}):n("markdown.textCopied"):n("markdown.failed")),o(!1)};return s.jsxs("div",{className:"absolute top-1 right-1 z-10 opacity-0 group-hover/md:opacity-100 transition-opacity",ref:g,children:[h&&s.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:h}),s.jsx("button",{onClick:()=>o(T=>!T),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:n("markdown.copyContent"),children:s.jsx("svg",{className:"w-3.5 h-3.5",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:s.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"})})}),r&&s.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:d?s.jsx(BG,{onClose:()=>m(!1)}):l?s.jsxs("div",{className:"px-3 py-2 text-[11px] text-fg-secondary space-y-2 max-w-[260px]",children:[s.jsxs("div",{className:"flex items-center justify-between mb-1",children:[s.jsx("span",{className:"font-medium text-fg-primary text-xs",children:n("markdown.infoTitle")}),s.jsx("button",{onClick:()=>u(!1),className:"text-fg-tertiary hover:text-fg-primary p-0.5",children:s.jsx("svg",{className:"w-3 h-3",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:s.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M6 18L18 6M6 6l12 12"})})})]}),s.jsxs("div",{children:[s.jsx("span",{className:"font-medium text-fg-primary",children:n("markdown.mdAbbrev")})," — ",n("markdown.infoMdDesc")]}),s.jsxs("div",{children:[s.jsx("span",{className:"font-medium text-fg-primary",children:"☀️"})," — ",n("markdown.infoHtmlLightDesc")]}),s.jsxs("div",{children:[s.jsx("span",{className:"font-medium text-fg-primary",children:"🌙"})," — ",n("markdown.infoHtmlDarkDesc")]})]}):s.jsxs(s.Fragment,{children:[s.jsxs("div",{className:"flex items-center justify-between px-3 py-1 border-b border-border-subtle mb-1",children:[s.jsx("span",{className:"text-[10px] text-fg-tertiary font-medium",children:n("markdown.copyContent")}),s.jsxs("div",{className:"flex items-center gap-1",children:[s.jsx("button",{onClick:()=>m(!0),className:"p-0.5 rounded text-fg-tertiary hover:text-fg-primary transition-colors",title:n("markdown.typographySettings"),children:s.jsxs("svg",{className:"w-3.5 h-3.5",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:[s.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"}),s.jsx("circle",{cx:"12",cy:"12",r:"3"})]})}),s.jsx("button",{onClick:()=>u(!0),className:"p-0.5 rounded text-fg-tertiary hover:text-fg-primary transition-colors",title:n("markdown.infoTitle"),children:s.jsxs("svg",{className:"w-3.5 h-3.5",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:[s.jsx("circle",{cx:"12",cy:"12",r:"10"}),s.jsx("path",{strokeLinecap:"round",d:"M12 16v-4m0-4h.01"})]})})]})]}),s.jsxs("button",{onClick:w,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:[s.jsx("span",{className:"w-4 text-center text-fg-tertiary shrink-0 font-mono text-[10px]",children:n("markdown.mdAbbrev")}),n(x?"markdown.copyMdSourceShort":"markdown.copyMdSource")]}),s.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:[s.jsx("span",{className:"w-4 text-center shrink-0 text-[10px]",children:"☀️"}),n(x?"markdown.copyHtmlLightShort":"markdown.copyHtmlLight")]}),s.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:[s.jsx("span",{className:"w-4 text-center shrink-0 text-[10px]",children:"🌙"}),n(x?"markdown.copyHtmlDarkShort":"markdown.copyHtmlDark")]})]})})]})}const Ar=k.memo(function({content:t,className:n="",onMentionClick:r,knownNames:o,basePath:l}){const{thinking:u,rest:d}=ZG(t),m=k.useRef(null),[h,p]=k.useState(null),g=k.useCallback(w=>{let N=md(w,wG);return N=md(N,TG),N=md(N,EG),N=md(N,T=>kG(T,o)),N},[o]),x=k.useMemo(()=>g(d),[d,g]),y=k.useMemo(()=>({...nV,img:({src:w,alt:N})=>s.jsx(lV,{src:w??"",alt:N,onPreview:p,basePath:l},w??""),p:({children:w,node:N})=>{const T=tV(N);return T?s.jsx(KG,{id:T.id,type:T.type,label:T.label}):s.jsx("p",{className:"mb-2 last:mb-0 leading-relaxed text-fg-secondary",children:w})},a:({href:w,children:N})=>{if(w?.startsWith(G2)){const T=decodeURIComponent(w.slice(G2.length));return s.jsx("span",{className:`text-brand-500 font-medium${r?" cursor-pointer hover:underline":""}`,onClick:r?C=>{C.preventDefault(),C.stopPropagation(),r(T,C)}:void 0,title:T,children:N})}if(w?.startsWith(o0))return s.jsx(i0,{id:w.slice(o0.length)});{const T=w?.match(s3);if(T){const[,C,j]=T;if(C==="workflow")return s.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:O=>{O.preventDefault(),O.stopPropagation(),at.navigate(me.WORK,{boardType:"workflows"})},title:`workflow: ${j}`,children:[s.jsx("span",{className:"text-[10px]",children:"⚙️"}),s.jsx("span",{children:N})]});const _=Jk(C);if(_)return s.jsx(i0,{id:j,type:_,label:N})}}return s.jsx("a",{href:w,target:"_blank",rel:"noopener noreferrer",className:"text-brand-500 hover:text-brand-500 underline break-all",children:N})}}),[r,l]);return s.jsxs("div",{className:"relative group/md",children:[s.jsx(fV,{content:t,contentRef:m}),s.jsx("div",{ref:m,children:s.jsx(WG,{resetKeys:[x],fallback:s.jsx("div",{className:`prose prose-sm max-w-none break-words whitespace-pre-wrap pr-8 text-fg-secondary ${n}`,children:d}),children:s.jsxs("div",{className:`prose prose-sm max-w-none break-words pr-8 text-fg-secondary ${n}`,children:[u.length>0&&(()=>{const w=u.join(`
648
+ `,1;if(Jo>1e5&&Jo>ht.index*3)throw new Error("potential infinite loop, way more iterations than matches");return rn+=Ot,Ot.length}const Yn=ir(ze);if(!Yn)throw Qe(yt.replace("{}",ze)),new Error('Unknown language: "'+ze+'"');const jc=rt(Yn);let zi="",Et=nn||jc;const Mc={},In=new Je.__emitter(Je);Zo();let rn="",ls=0,ja=0,Jo=0,cs=!1;try{if(Yn.__emitTokens)Yn.__emitTokens(vt,In);else{for(Et.matcher.considerAll();;){Jo++,cs?cs=!1:Et.matcher.considerAll(),Et.matcher.lastIndex=ja;const Ye=Et.matcher.exec(vt);if(!Ye)break;const ht=vt.substring(ja,Ye.index),Ot=Pi(ht,Ye);ja=Ye.index+Ot}Pi(vt.substring(ja))}return In.finalize(),zi=In.toHTML(),{language:ze,value:zi,relevance:ls,illegal:!1,_emitter:In,_top:Et}}catch(Ye){if(Ye.message&&Ye.message.includes("Illegal"))return{language:ze,value:R(vt),illegal:!0,relevance:0,_illegalBy:{message:Ye.message,index:ja,context:vt.slice(ja-100,ja+100),mode:Ye.mode,resultSoFar:zi},_emitter:In};if(Xe)return{language:ze,value:R(vt),illegal:!1,relevance:0,errorRaised:Ye,_emitter:In,_top:Et};throw Ye}}function Ri(ze){const vt={value:R(ze),illegal:!1,relevance:0,_top:Pe,_emitter:new Je.__emitter(Je)};return vt._emitter.addText(ze),vt}function Oi(ze,vt){vt=vt||Je.languages||Object.keys(ie);const Ut=Ri(ze),nn=vt.filter(ir).filter(is).map(pn=>Ea(pn,ze,!1));nn.unshift(Ut);const Rn=nn.sort((pn,Rr)=>{if(pn.relevance!==Rr.relevance)return Rr.relevance-pn.relevance;if(pn.language&&Rr.language){if(ir(pn.language).supersetOf===Rr.language)return 1;if(ir(Rr.language).supersetOf===pn.language)return-1}return 0}),[tr,Mr]=Rn,gr=tr;return gr.secondBest=Mr,gr}function ma(ze,vt,Ut){const nn=vt&&Se[vt]||Ut;ze.classList.add("hljs"),ze.classList.add(`language-${nn}`)}function Mn(ze){let vt=null;const Ut=jn(ze);if(Nt(Ut))return;if(Ws("before:highlightElement",{el:ze,language:Ut}),ze.dataset.highlighted){console.log("Element previously highlighted. To highlight again, first unset `dataset.highlighted`.",ze);return}if(ze.children.length>0&&(Je.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(ze)),Je.throwUnescapedHTML))throw new hn("One of your code blocks includes unescaped HTML.",ze.innerHTML);vt=ze;const nn=vt.textContent,Rn=Ut?vn(nn,{language:Ut,ignoreIllegals:!0}):Oi(nn);ze.innerHTML=Rn.value,ze.dataset.highlighted="yes",ma(ze,Ut,Rn.language),ze.result={language:Rn.language,re:Rn.relevance,relevance:Rn.relevance},Rn.secondBest&&(ze.secondBest={language:Rn.secondBest.language,relevance:Rn.secondBest.relevance}),Ws("after:highlightElement",{el:ze,result:Rn,text:nn})}function er(ze){Je=oe(Je,ze)}const ss=()=>{Di(),pe("10.6.0","initHighlighting() deprecated. Use highlightAll() now.")};function Yo(){Di(),pe("10.6.0","initHighlightingOnLoad() deprecated. Use highlightAll() now.")}let Tc=!1;function Di(){function ze(){Di()}if(document.readyState==="loading"){Tc||window.addEventListener("DOMContentLoaded",ze,!1),Tc=!0;return}document.querySelectorAll(Je.cssSelector).forEach(Mn)}function Ec(ze,vt){let Ut=null;try{Ut=vt(q)}catch(nn){if(Qe("Language definition for '{}' could not be registered.".replace("{}",ze)),Xe)Qe(nn);else throw nn;Ut=Pe}Ut.name||(Ut.name=ze),ie[ze]=Ut,Ut.rawDefinition=vt.bind(null,q),Ut.aliases&&Aa(Ut.aliases,{languageName:ze})}function Ks(ze){delete ie[ze];for(const vt of Object.keys(Se))Se[vt]===ze&&delete Se[vt]}function Xo(){return Object.keys(ie)}function ir(ze){return ze=(ze||"").toLowerCase(),ie[ze]||ie[Se[ze]]}function Aa(ze,{languageName:vt}){typeof ze=="string"&&(ze=[ze]),ze.forEach(Ut=>{Se[Ut.toLowerCase()]=vt})}function is(ze){const vt=ir(ze);return vt&&!vt.disableAutodetect}function os(ze){ze["before:highlightBlock"]&&!ze["before:highlightElement"]&&(ze["before:highlightElement"]=vt=>{ze["before:highlightBlock"](Object.assign({block:vt.el},vt))}),ze["after:highlightBlock"]&&!ze["after:highlightElement"]&&(ze["after:highlightElement"]=vt=>{ze["after:highlightBlock"](Object.assign({block:vt.el},vt))})}function Ln(ze){os(ze),Ie.push(ze)}function Ac(ze){const vt=Ie.indexOf(ze);vt!==-1&&Ie.splice(vt,1)}function Ws(ze,vt){const Ut=ze;Ie.forEach(function(nn){nn[Ut]&&nn[Ut](vt)})}function _a(ze){return pe("10.7.0","highlightBlock will be removed entirely in v12.0"),pe("10.7.0","Please use highlightElement now."),Mn(ze)}Object.assign(q,{highlight:vn,highlightAuto:Oi,highlightAll:Di,highlightElement:Mn,highlightBlock:_a,configure:er,initHighlighting:ss,initHighlightingOnLoad:Yo,registerLanguage:Ec,unregisterLanguage:Ks,listLanguages:Xo,getLanguage:ir,registerAliases:Aa,autoDetection:is,inherit:oe,addPlugin:Ln,removePlugin:Ac}),q.debugMode=function(){Xe=!1},q.safeMode=function(){Xe=!0},q.versionString=wt,q.regex={concat:N,lookahead:x,either:C,optional:w,anyNumberOfTimes:y};for(const ze in ct)typeof ct[ze]=="object"&&e(ct[ze]);return Object.assign(q,ct),q},qe=$e({});return qe.newInstance=()=>$e({}),Bh=qe,qe.HighlightJS=qe,qe.default=qe,Bh}var Uq=Bq();const $q=xc(Uq),O2={},Hq="hljs-";function Fq(e){const t=$q.newInstance();return e&&l(e),{highlight:n,highlightAuto:r,listLanguages:o,register:l,registerAlias:u,registered:d};function n(m,h,p){const g=p||O2,x=typeof g.prefix=="string"?g.prefix:Hq;if(!t.getLanguage(m))throw new Error("Unknown language: `"+m+"` is not registered");t.configure({__emitter:qq,classPrefix:x});const y=t.highlight(h,{ignoreIllegals:!0,language:m});if(y.errorRaised)throw new Error("Could not highlight with `Highlight.js`",{cause:y.errorRaised});const w=y._emitter.root,N=w.data;return N.language=y.language,N.relevance=y.relevance,w}function r(m,h){const g=(h||O2).subset||o();let x=-1,y=0,w;for(;++x<g.length;){const N=g[x];if(!t.getLanguage(N))continue;const T=n(N,m,h);T.data&&T.data.relevance!==void 0&&T.data.relevance>y&&(y=T.data.relevance,w=T)}return w||{type:"root",children:[],data:{language:void 0,relevance:y}}}function o(){return t.listLanguages()}function l(m,h){if(typeof m=="string")t.registerLanguage(m,h);else{let p;for(p in m)Object.hasOwn(m,p)&&t.registerLanguage(p,m[p])}}function u(m,h){if(typeof m=="string")t.registerAliases(typeof h=="string"?h:[...h],{languageName:m});else{let p;for(p in m)if(Object.hasOwn(m,p)){const g=m[p];t.registerAliases(typeof g=="string"?g:[...g],{languageName:p})}}}function d(m){return!!t.getLanguage(m)}}class qq{constructor(t){this.options=t,this.root={type:"root",children:[],data:{language:void 0,relevance:0}},this.stack=[this.root]}addText(t){if(t==="")return;const n=this.stack[this.stack.length-1],r=n.children[n.children.length-1];r&&r.type==="text"?r.value+=t:n.children.push({type:"text",value:t})}startScope(t){this.openNode(String(t))}endScope(){this.closeNode()}__addSublanguage(t,n){const r=this.stack[this.stack.length-1],o=t.root.children;n?r.children.push({type:"element",tagName:"span",properties:{className:[n]},children:o}):r.children.push(...o)}openNode(t){const n=this,r=t.split(".").map(function(u,d){return d?u+"_".repeat(d):n.options.classPrefix+u}),o=this.stack[this.stack.length-1],l={type:"element",tagName:"span",properties:{className:r},children:[]};o.children.push(l),this.stack.push(l)}closeNode(){this.stack.pop()}finalize(){}toHTML(){return""}}const Gq={};function Vk(e){const t=e||Gq,n=t.aliases,r=t.detect||!1,o=t.languages||zq,l=t.plainText,u=t.prefix,d=t.subset;let m="hljs";const h=Fq(o);if(n&&h.registerAlias(n),u){const p=u.indexOf("-");m=p===-1?u:u.slice(0,p)}return function(p,g){S0(p,"element",function(x,y,w){if(x.tagName!=="code"||!w||w.type!=="element"||w.tagName!=="pre")return;const N=Vq(x);if(N===!1||!N&&!r||N&&l&&l.includes(N))return;Array.isArray(x.properties.className)||(x.properties.className=[]),x.properties.className.includes(m)||x.properties.className.unshift(m);const T=Ck(x,{whitespace:"pre"});let C;try{C=N?h.highlight(N,T,{prefix:u}):h.highlightAuto(T,{prefix:u,subset:d})}catch(j){const _=j;if(N&&/Unknown language/.test(_.message)){g.message("Cannot highlight as `"+N+"`, it’s not registered",{ancestors:[w,x],cause:_,place:x.position,ruleId:"missing-language",source:"rehype-highlight"});return}throw _}!N&&C.data&&C.data.language&&x.properties.className.push("language-"+C.data.language),C.children.length>0&&(x.children=C.children)})}}function Vq(e){const t=e.properties.className;let n=-1;if(!Array.isArray(t))return;let r;for(;++n<t.length;){const o=String(t[n]);if(o==="no-highlight"||o==="nohighlight")return!1;!r&&o.slice(0,5)==="lang-"&&(r=o.slice(5)),!r&&o.slice(0,9)==="language-"&&(r=o.slice(9))}return r}const Kq=10;function D2(e){if(e.kind==="file")return`file:${e.path}`;if(e.kind==="url")return`url:${e.browserId||e.url}`;const t=e.deliverable;return`deliverable:${t.id||`${t.reference||""}|${t.title||""}|${t.summary?.slice(0,48)||""}`||"unknown"}`}function Wq(e){return e.kind==="deliverable"?e.deliverable.title||e.deliverable.reference||"Deliverable":e.kind==="url"?e.title||e.url:e.title||e.path.split(/[/\\]/).pop()||e.path}const Kk=k.createContext(null);function Yq({children:e}){const[t,n]=k.useState(()=>{try{return localStorage.getItem("markus_sidebar_c")==="1"}catch{return!1}}),[r,o]=k.useState([]),[l,u]=k.useState(null),[d,m]=k.useState(!1),[h,p]=k.useState(!1),g=k.useRef([]),x=k.useRef(null),y=k.useRef(null);y.current=l;const w=k.useCallback(X=>n(X),[]),N=k.useCallback(()=>n(X=>!X),[]),T=k.useCallback(X=>{const F=D2(X),J=`tab_${Date.now().toString(36)}_${Math.random().toString(36).slice(2,7)}`;let B=null;o(Q=>{const re=Q.find(G=>D2(G.payload)===F);if(re)return B=re.id,g.current=Q,Q;let $=[{id:J,title:Wq(X),payload:X},...Q];for(;$.length>Kq;){let G=-1;for(let ce=$.length-1;ce>=0;ce--)if(!$[ce].pinned){G=ce;break}if(G<0)break;$=$.filter((ce,I)=>I!==G)}return B=J,g.current=$,$}),B&&(u(B),x.current=B),n(!0)},[]),C=X=>{X?.kind==="url"&&X.browserId&&window.markusDesktop?.browser?.destroy(X.browserId)},j=k.useCallback(X=>{let F,J,B=!1;o(Q=>{const re=Q.findIndex($=>$.id===X);if(re<0)return Q;F=Q[re]?.payload;const we=Q.filter($=>$.id!==X);return g.current=we,B=we.length===0,J=void 0,(x.current===X||we.length===0)&&(J=we[Math.min(re,we.length-1)]?.id??null),we}),B&&m(!1),J!==void 0&&(u(J),x.current=J),C(F)},[]),_=k.useCallback(()=>{let X=[];o(F=>(X=F.map(J=>J.payload),[])),u(null),m(!1),g.current=[],x.current=null;for(const F of X)C(F)},[]),O=k.useCallback(X=>{u(X),x.current=X},[]),z=k.useCallback((X,F)=>{o(J=>{let B=!1;const Q=J.map(re=>{if(re.payload.kind!=="url"||re.payload.browserId!==X)return re;B=!0;const we=F.url??re.payload.url,$=F.title||re.payload.title||we;return{...re,title:$,payload:{...re.payload,url:we,title:$}}});return B&&(g.current=Q),B?Q:J})},[]),D=k.useCallback(()=>{o(X=>X.length===0?X:(g.current=X,y.current&&(x.current=y.current),[])),u(null),m(!1),window.markusDesktop?.browser?.hideAll?.()},[]),H=k.useCallback(()=>{const X=`tab_${Date.now().toString(36)}_${Math.random().toString(36).slice(2,7)}`,F=`eb_${Date.now().toString(36)}_${Math.random().toString(36).slice(2,7)}`;let J,B=!1,Q=!1;o(re=>{if(re.length>0)return g.current=re,y.current&&(x.current=y.current),Q=!0,J=null,[];if(g.current.length>0){B=!0;const $=g.current;return J=x.current&&$.some(ce=>ce.id===x.current)?x.current:$[0].id,$}B=!0;const we={id:X,title:"New Tab",payload:{kind:"url",url:"about:blank",title:"New Tab",browserId:F}};return g.current=[we],J=we.id,[we]}),B&&n(!0),Q?(u(null),m(!1),window.markusDesktop?.browser?.hideAll?.()):J!=null&&(u(J),x.current=J)},[]),W=k.useCallback(X=>m(X),[]),Z=k.useCallback(()=>m(X=>!X),[]),U=r.find(X=>X.id===l)??r[0]??null,Y=U?.payload??null,ae=k.useMemo(()=>({leftCollapsed:t,setLeftCollapsed:w,toggleLeftCollapsed:N,rightPanel:Y,rightPanelOpen:r.length>0,rightPanelTabs:r,activeRightPanelTabId:U?.id??null,openRightPanel:T,closeRightPanel:_,closeRightPanelTab:j,setActiveRightPanelTab:O,updateRightPanelBrowserTab:z,toggleRightPanel:H,collapseRightPanelOnly:D,rightPanelFullscreen:d,setRightPanelFullscreen:W,toggleRightPanelFullscreen:Z,hostAvailable:h,setHostAvailable:p}),[t,w,N,Y,r,U,T,_,j,O,z,H,D,d,W,Z,h]);return s.jsx(Kk.Provider,{value:ae,children:e})}function z0(){return k.useContext(Kk)}k.lazy(()=>qr(()=>Promise.resolve().then(()=>i3),void 0).then(e=>({default:e.MarkdownMessage})));const Xq=k.lazy(()=>qr(()=>import("./ContentRenderer-DJR6tazg.js"),[]).then(e=>({default:e.ContentRenderer})));let wo=[],L2=60;function Qq(e){const t=k.useRef(e);t.current=e;const[n]=k.useState(()=>++L2);return k.useEffect(()=>{const r=()=>t.current();wo.push(r);const o=l=>{l.key==="Escape"&&wo[wo.length-1]===r&&(l.preventDefault(),r())};return window.addEventListener("keydown",o,!0),()=>{window.removeEventListener("keydown",o,!0),wo=wo.filter(l=>l!==r),wo.length===0&&(L2=60)}},[]),n}const I2=500,Bs=new Map,s0=new Set,Rd=new Map;let Od=null;function Zq(){if(Bs.size<=I2)return;const e=Bs.size-I2,t=Bs.keys();for(let n=0;n<e;n++){const{value:r,done:o}=t.next();if(o)break;Bs.delete(r)}}function P2(e,t){Bs.delete(e),Bs.set(e,t),Zq()}function z2(e){const t=Rd.get(e);if(t)for(const n of t)n()}function Jq(){Od=null;const e=[...s0];s0.clear(),e.length!==0&&Ce.files.check(e).then(({results:t})=>{for(const[n,r]of Object.entries(t))P2(n,r),z2(n)}).catch(()=>{for(const t of e)P2(t,{exists:!1,isFile:!1,type:"unknown"}),z2(t)})}function eG(e){Bs.has(e)||s0.has(e)||(s0.add(e),Od&&clearTimeout(Od),Od=setTimeout(Jq,30))}function tG(e,t){let n=Rd.get(e);return n||(n=new Set,Rd.set(e,n)),n.add(t),()=>{n.delete(t),n.size===0&&Rd.delete(e)}}function nG(e){const t=k.useCallback(o=>tG(e,o),[e]),n=k.useCallback(()=>Bs.get(e),[e]),r=k.useSyncExternalStore(t,n,n);return k.useEffect(()=>{eG(e)},[e]),r}const rG=/^(?:\/[\w.\-@+]+(?:\/[\w.\-@+ ]*)*|~\/[\w.\-@+]+(?:\/[\w.\-@+ ]*)*|[A-Z]:\\[\w.\-@+ ]+(?:\\[\w.\-@+ ]*)*|\.\.?\/[\w.\-@+]+(?:\/[\w.\-@+ ]*)*)$/;function aG(e){return e.length<2||e.length>500?!1:rG.test(e)}function sG({filePath:e,onClose:t}){const n=Qq(t),[r,o]=k.useState(!0),[l,u]=k.useState(null),[d,m]=k.useState(""),[h,p]=k.useState(""),[g,x]=k.useState(""),[y,w]=k.useState(""),[N,T]=k.useState("");k.useEffect(()=>{o(!0),u(null),Ce.files.preview(e).then(j=>{m(typeof j.content=="string"?j.content:""),p(j.type),x(j.name),w(j.mimeType||""),T(j.streamUrl||(j.path?Ce.files.streamUrl(j.path):"")||(j.type==="audio"||j.type==="video"?Ce.files.streamUrl(e):""))}).catch(j=>{u(String(j?.message||j))}).finally(()=>{o(!1)})},[e]);const C=g||e.split(/[/\\]/).pop()||e;return Ja.createPortal(s.jsx("div",{className:"fixed inset-0 bg-black/40 flex items-center justify-center",style:{zIndex:n},onClick:t,children:s.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:j=>j.stopPropagation(),children:[s.jsxs("div",{className:"flex items-center justify-between px-4 py-3 border-b border-border-default bg-surface-elevated/50 shrink-0",children:[s.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[s.jsx("svg",{className:"w-4 h-4 shrink-0 text-fg-secondary",viewBox:"0 0 20 20",fill:"currentColor",children:s.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"})}),s.jsx("span",{className:"text-sm font-medium text-fg-primary truncate",children:C}),s.jsx("span",{className:"text-xs text-fg-tertiary truncate hidden sm:inline",children:e})]}),s.jsxs("div",{className:"flex items-center gap-2 shrink-0",children:[s.jsx("button",{className:"text-xs text-fg-secondary hover:text-fg-primary px-2 py-1 rounded hover:bg-surface-elevated transition-colors",onClick:()=>Ce.files.reveal(e),title:"Reveal in file explorer",children:s.jsx("svg",{className:"w-4 h-4",viewBox:"0 0 20 20",fill:"currentColor",children:s.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"})})}),s.jsx("button",{className:"text-fg-secondary hover:text-fg-primary p-1 rounded hover:bg-surface-elevated transition-colors",onClick:t,children:s.jsx("svg",{className:"w-4 h-4",viewBox:"0 0 20 20",fill:"currentColor",children:s.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"})})})]})]}),s.jsxs("div",{className:"flex-1 overflow-y-auto p-5",children:[r&&s.jsx("div",{className:"flex items-center justify-center py-12",children:s.jsx("div",{className:"w-5 h-5 border-2 border-brand-500/30 border-t-brand-500 rounded-full animate-spin"})}),l&&s.jsxs("div",{className:"text-center py-12 text-fg-secondary text-sm",children:[s.jsx("p",{className:"text-red-400 mb-1",children:"Failed to load file"}),s.jsx("p",{className:"text-xs text-fg-tertiary",children:l})]}),!r&&!l&&h==="image"&&d&&s.jsx("div",{className:"flex justify-center",children:s.jsx("img",{src:`data:${y||"image/png"};base64,${d}`,alt:C,className:"max-w-full rounded"})}),!r&&!l&&h==="audio"&&N&&s.jsx("audio",{controls:!0,preload:"metadata",src:N,className:"w-full"}),!r&&!l&&h==="video"&&N&&s.jsx("video",{controls:!0,preload:"metadata",src:N,className:"w-full max-h-[60vh] rounded-lg bg-black"}),!r&&!l&&(h==="binary"||!d&&h!=="image"&&h!=="audio"&&h!=="video")&&s.jsxs("div",{className:"text-center py-8 space-y-3",children:[s.jsx("p",{className:"text-sm text-fg-secondary",children:"This file type cannot be previewed."}),s.jsx("button",{className:"px-3 py-2 text-xs rounded-lg bg-brand-600/20 text-brand-500 hover:bg-brand-600/30 transition-colors",onClick:()=>{Ce.files.reveal(e)},children:"Reveal in file explorer"})]}),!r&&!l&&d&&h!=="image"&&h!=="audio"&&h!=="video"&&h!=="binary"&&s.jsx(k.Suspense,{fallback:s.jsx("div",{className:"text-xs text-fg-tertiary",children:"Loading…"}),children:s.jsx(Xq,{content:d,format:h==="text"?"text":h,className:"text-sm"})})]})]})}),document.body)}function iG({path:e}){const t=nG(e),[n,r]=k.useState(null),o=z0(),l=t?.exists??!1,u=t?.type==="markdown"||t?.type==="html"||t?.type==="json"||t?.type==="text"||t?.type==="image"||t?.type==="audio"||t?.type==="video",d=k.useCallback(p=>{if(p.preventDefault(),p.stopPropagation(),!!l)if(u){if(o?.hostAvailable){o.openRightPanel({kind:"file",path:e});return}r(e)}else Ce.files.reveal(e)},[l,u,e,o]),m="inline w-3 h-3 align-[-0.125em]",h=u?s.jsx("svg",{className:m,viewBox:"0 0 20 20",fill:"currentColor",children:s.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"})}):s.jsx("svg",{className:m,viewBox:"0 0 20 20",fill:"currentColor",children:s.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 t?l?s.jsxs(s.Fragment,{children:[s.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:d,title:u?"Click to preview":"Click to reveal in file explorer",role:"button",tabIndex:0,children:[s.jsxs("span",{className:"whitespace-nowrap",children:[h,e.charAt(0)]}),e.slice(1)]}),n&&s.jsx(sG,{filePath:n,onClose:()=>r(null)})]}):s.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}):s.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 Uh=null;function oG(){return Uh||(Uh=qr(()=>import("./mermaid.core-5DInlSXg.js").then(e=>e.b9),__vite__mapDeps([0,1])).then(e=>(e.default.initialize({startOnLoad:!1,securityLevel:"loose",fontFamily:"inherit"}),e))),Uh}function lG(){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 cG(e){const t=window.matchMedia("(prefers-color-scheme: dark)");t.addEventListener("change",e);const n=new MutationObserver(e);return n.observe(document.documentElement,{attributes:!0,attributeFilter:["class"]}),()=>{t.removeEventListener("change",e),n.disconnect()}}function uG(){return lG()}function dG(){return k.useSyncExternalStore(cG,uG)}function Wk({code:e}){const t=k.useRef(null),[n,r]=k.useState(null),[o,l]=k.useState(!0),u=k.useId(),d=k.useRef(0),m=k.useRef(null),h=dG();return k.useEffect(()=>{if(!e.trim()||m.current&&m.current.code===e&&m.current.dark===h)return;let p=!1;return l(!0),r(null),d.current+=1,(async()=>{try{const g=await oG();if(p)return;g.default.initialize({startOnLoad:!1,theme:h?"dark":"default",securityLevel:"loose",fontFamily:"inherit"});const x=`mermaid-${u.replace(/:/g,"")}-${d.current}`,{svg:y}=await g.default.render(x,e.trim());if(p)return;t.current&&(t.current.innerHTML=y,m.current={code:e,dark:h})}catch(g){p||r(g instanceof Error?g.message:String(g))}finally{p||l(!1)}})(),()=>{p=!0}},[e,u,h]),n?s.jsxs("div",{className:"my-2 rounded-lg overflow-hidden border border-red-500/30",children:[s.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:[s.jsx("svg",{className:"w-3.5 h-3.5 text-red-400",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:s.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"})}),s.jsx("span",{className:"text-[10px] font-medium text-red-400",children:"Mermaid render error"})]}),s.jsx("pre",{className:"p-3 bg-surface-secondary text-xs text-fg-secondary overflow-x-auto font-mono",children:e})]}):s.jsxs("div",{className:"not-prose my-2 rounded-lg bg-surface-secondary border border-border-subtle p-4 overflow-x-auto",children:[o&&s.jsxs("div",{className:"flex items-center gap-2 text-xs text-fg-tertiary",children:[s.jsx("div",{className:"w-4 h-4 border-2 border-fg-tertiary/30 border-t-fg-tertiary rounded-full animate-spin"}),"Rendering diagram…"]}),s.jsx("div",{ref:t,className:`flex justify-center [&>svg]:max-w-full${o?" hidden":""}`})]})}const mG="/assets/viz-global-C_AyN6D9.js";let dd=!1,$h=null;function fG(){return dd?Promise.resolve():new Promise((e,t)=>{const n=document.querySelector("script[data-plantuml-viz]");if(n){globalThis.Viz?(dd=!0,e()):(n.addEventListener("load",()=>{dd=!0,e()}),n.addEventListener("error",()=>t(new Error("Failed to load viz-global.js"))));return}const r=document.createElement("script");r.setAttribute("data-plantuml-viz",""),r.src=mG,r.onload=()=>{dd=!0,e()},r.onerror=()=>t(new Error("Failed to load viz-global.js")),document.head.appendChild(r)})}function hG(){return $h||($h=fG().then(()=>qr(()=>import("./plantuml-DezRDxd4.js"),[]))),$h}let B2=Promise.resolve();function pG(e,t){const n=B2.then(()=>new Promise((r,o)=>{hG().then(({renderToString:l})=>{const u=e.split(/\r\n|\r|\n/);l(u,r,o,{dark:t})}).catch(o)}));return B2=n.then(()=>{},()=>{}),n}function gG(){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 bG(e){const t=window.matchMedia("(prefers-color-scheme: dark)");t.addEventListener("change",e);const n=new MutationObserver(e);return n.observe(document.documentElement,{attributes:!0,attributeFilter:["class"]}),()=>{t.removeEventListener("change",e),n.disconnect()}}function xG(){return k.useSyncExternalStore(bG,()=>gG())}function Yk({code:e}){const[t,n]=k.useState(null),[r,o]=k.useState(null),[l,u]=k.useState(!0),d=k.useRef(null),m=xG();return k.useEffect(()=>{if(!e.trim()||d.current&&d.current.code===e&&d.current.dark===m)return;let h=!1;return u(!0),o(null),pG(e.trim(),m).then(p=>{h||(n(p),d.current={code:e,dark:m})}).catch(p=>{h||o(p instanceof Error?p.message:String(p))}).finally(()=>{h||u(!1)}),()=>{h=!0}},[e,m]),r?s.jsxs("div",{className:"my-2 rounded-lg overflow-hidden border border-red-500/30",children:[s.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:[s.jsx("svg",{className:"w-3.5 h-3.5 text-red-400",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:s.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"})}),s.jsx("span",{className:"text-[10px] font-medium text-red-400",children:"PlantUML render error"})]}),s.jsx("pre",{className:"p-3 bg-surface-secondary text-xs text-fg-secondary overflow-x-auto font-mono",children:e})]}):s.jsxs("div",{className:"not-prose my-2 rounded-lg bg-surface-secondary border border-border-subtle p-4 overflow-x-auto",children:[l&&s.jsxs("div",{className:"flex items-center gap-2 text-xs text-fg-tertiary",children:[s.jsx("div",{className:"w-4 h-4 border-2 border-fg-tertiary/30 border-t-fg-tertiary rounded-full animate-spin"}),"Rendering diagram…"]}),t&&s.jsx("div",{className:`flex justify-center [&>svg]:max-w-full${l?" hidden":""}`,dangerouslySetInnerHTML:{__html:t}})]})}function yG(e,t,n){const r=e.cloneNode(!0),o=n?.fontFamily??"-apple-system,BlinkMacSystemFont,'Segoe UI','Noto Sans',Helvetica,Arial,sans-serif",l=n?.fontSize??"15px",u=n?.headingScales??{h1:1.6,h2:1.35,h3:1.15,h4:1},d=t==="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"},m={p:`margin:0 0 10px;color:${d.text};line-height:1.7;`,h1:`font-size:${u.h1}em;font-weight:700;color:${d.heading};margin:20px 0 10px;line-height:1.3;border-bottom:1px solid ${d.border};padding-bottom:6px;`,h2:`font-size:${u.h2}em;font-weight:700;color:${d.heading};margin:18px 0 8px;line-height:1.3;`,h3:`font-size:${u.h3}em;font-weight:600;color:${d.heading};margin:14px 0 6px;line-height:1.3;`,h4:`font-size:${u.h4}em;font-weight:600;color:${d.heading};margin:12px 0 4px;`,strong:`font-weight:600;color:${d.strong};`,em:"font-style:italic;",a:`color:${d.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:${d.text};`,blockquote:`border-left:3px solid ${d.blockquoteBorder};padding:2px 0 2px 14px;margin:10px 0;color:${d.blockquoteText};`,hr:`border:none;border-top:1px solid ${d.hrColor};margin:20px 0;`,table:"border-collapse:collapse;width:100%;margin:10px 0;",thead:`background:${d.tableHeaderBg};`,th:`border:1px solid ${d.tableBorder};padding:8px 12px;text-align:left;font-weight:600;color:${d.tableHeaderText};`,td:`border:1px solid ${d.tableBorder};padding:8px 12px;color:${d.text};`,img:"max-width:100%;height:auto;"};function h(p){p.removeAttribute("class");const g=p.tagName.toLowerCase();if(g==="pre"){p.setAttribute("style",`background:${d.preBg};color:${d.preText};padding:14px;border-radius:6px;overflow-x:auto;margin:10px 0;font-size:0.88em;line-height:1.5;border:1px solid ${d.preBorder};`);const x=p.querySelector("code");x&&(x.removeAttribute("class"),x.setAttribute("style","background:transparent;padding:0;border-radius:0;color:inherit;font-family:'SFMono-Regular',Consolas,'Liberation Mono',Menlo,monospace;font-size:inherit;"));return}g==="code"?p.setAttribute("style",`background:${d.codeBg};color:${d.codeText};padding:2px 6px;border-radius:4px;font-size:0.9em;font-family:'SFMono-Regular',Consolas,'Liberation Mono',Menlo,monospace;`):m[g]&&p.setAttribute("style",m[g]),Array.from(p.children).forEach(h)}return r.removeAttribute("class"),Array.from(r.children).forEach(p=>h(p)),`<div style="background:${d.bg};color:${d.text};padding:20px 24px;font-family:${o};font-size:${l};line-height:1.7;max-width:800px;">${r.innerHTML}</div>`}async function jg(e){try{return await navigator.clipboard.writeText(e),!0}catch{try{const t=document.createElement("textarea");t.value=e,t.style.cssText="position:fixed;left:-9999px;top:-9999px;opacity:0",document.body.appendChild(t),t.select();const n=document.execCommand("copy");return document.body.removeChild(t),n}catch{return!1}}}async function vG(e,t,n,r){const o=yG(e,t,r);try{return await navigator.clipboard.write([new ClipboardItem({"text/html":new Blob([o],{type:"text/html"}),"text/plain":new Blob([n],{type:"text/plain"})})]),{ok:!0,method:"html"}}catch{return{ok:await jg(n),method:"text"}}}function Lp({code:e,language:t,children:n}){const{t:r}=ft("common"),[o,l]=k.useState("rendered"),[u,d]=k.useState(!1),m=k.useCallback(async()=>{await jg(e)&&(d(!0),setTimeout(()=>d(!1),1800))},[e]);return s.jsxs("div",{className:"not-prose my-2 rounded-lg overflow-hidden border border-border-subtle",children:[s.jsxs("div",{className:"flex items-center justify-between px-3 py-1.5 border-b border-border-subtle bg-surface-secondary",children:[s.jsx("span",{className:"text-[10px] font-medium text-fg-tertiary uppercase tracking-wider select-none",children:t}),s.jsxs("div",{className:"flex items-center gap-1",children:[s.jsx("button",{onClick:()=>l("rendered"),className:`px-2 py-0.5 rounded text-[10px] font-medium transition-colors ${o==="rendered"?"bg-brand-600/20 text-brand-500":"text-fg-tertiary hover:text-fg-secondary"}`,children:s.jsxs("span",{className:"flex items-center gap-1",children:[s.jsxs("svg",{className:"w-3 h-3",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:[s.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M15 12a3 3 0 11-6 0 3 3 0 016 0z"}),s.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"})]}),r("markdown.viewRendered")]})}),s.jsx("button",{onClick:()=>l("source"),className:`px-2 py-0.5 rounded text-[10px] font-medium transition-colors ${o==="source"?"bg-brand-600/20 text-brand-500":"text-fg-tertiary hover:text-fg-secondary"}`,children:s.jsxs("span",{className:"flex items-center gap-1",children:[s.jsx("svg",{className:"w-3 h-3",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:s.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M10 20l4-16m4 4l4 4-4 4M6 16l-4-4 4-4"})}),r("markdown.viewSource")]})})]})]}),o==="rendered"?s.jsx("div",{children:n}):s.jsxs("div",{className:"relative group/source",children:[s.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}),s.jsx("button",{onClick:m,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:r("markdown.copyContent"),children:u?s.jsx("svg",{className:"w-3.5 h-3.5 text-green-400",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:s.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M5 13l4 4L19 7"})}):s.jsx("svg",{className:"w-3.5 h-3.5",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:s.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 md(e,t){const n=/```[\s\S]*?```|`[^`\n]+`/g;let r=0,o="";for(const l of e.matchAll(n))o+=t(e.slice(r,l.index)),o+=l[0],r=l.index+l[0].length;return o+=t(e.slice(r)),o}function wG(e){let t=e.replace(/\\\[([\s\S]*?)\\\]/g,(n,r)=>`$$${r}$$`);return t=t.replace(/\\\((.+?)\\\)/g,(n,r)=>`$${r}$`),t}const fd="#mention:";function kG(e,t){if(!t||t.length===0)return e.replace(/@\[([^\]]+)\]|@([\w\p{L}\p{N}]+)/gu,(l,u,d)=>{const m=u??d;return`[@${m}](${fd}${encodeURIComponent(m)})`});const n=[...t].sort((l,u)=>u.length-l.length);let r="",o=0;for(;o<e.length;){const l=e.indexOf("@",o);if(l<0){r+=e.slice(o);break}if(r+=e.slice(o,l),e[l+1]==="["){const p=e.indexOf("]",l+2);if(p>l+2){const g=e.slice(l+2,p);r+=`[@${g}](${fd}${encodeURIComponent(g)})`,o=p+1;continue}}const u=e.slice(l+1),d=u.toLowerCase(),m=n.find(p=>d.startsWith(p.toLowerCase()));if(m){const p=u.slice(0,m.length);r+=`[@${p}](${fd}${encodeURIComponent(p)})`,o=l+1+m.length;continue}const h=u.match(/^([\w\p{L}\p{N}]+)/u);if(h){const p=h[1];r+=`[@${p}](${fd}${encodeURIComponent(p)})`,o=l+1+p.length;continue}r+="@",o=l+1}return r}const Xk="#entity:",SG=new RegExp("(?<!\\[)(?<!\\()(?<!:)(?<!\\/)(?<!\\\\)\\b(tsk|req|proj|dlv|agt|team)_[a-f0-9]{6,}\\b(?!\\]\\(#entity:)","gi"),NG=/`\[([^\]]+)\]\(#entity:((?:tsk|req|proj|dlv|agt|team)_[a-f0-9]{6,})\)`/gi;function CG(e,t){const n=e.slice(0,t),r=n.lastIndexOf("](");return r===-1?!1:n.indexOf(")",r+2)===-1}function TG(e){return e.replace(NG,(t,n,r)=>`[${n}](${Xk}${r})`)}function EG(e){return e.replace(SG,(t,n,r)=>CG(e,r)?t:`[${t}](${Xk}${t})`)}function AG(e){const t=e.trim();return t.startsWith("@startuml")&&t.endsWith("@enduml")}const _G=/^(graph\s|flowchart\s|sequenceDiagram|classDiagram|stateDiagram|erDiagram|gantt|pie|gitGraph|mindmap|timeline|journey)/m;function jG(e){return _G.test(e.trim())}const MG={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 RG(e){return MG[e.toLowerCase()]??e.charAt(0).toUpperCase()+e.slice(1)}function OG(e){const t=e.match(/language-(\S+)/);return t?t[1]:null}const DG=[Wk,Yk];function LG(e){for(const t of k.Children.toArray(e))if(k.isValidElement(t)&&typeof t.props?.className=="string"){const n=t.props.className;return OG(n)}return null}function ac(e){if(typeof e=="string")return e;if(typeof e=="number")return String(e);if(!e)return"";if(Array.isArray(e))return e.map(ac).join("");if(k.isValidElement(e)){const t=e.props;return ac(t.children)}return""}function IG({children:e}){const{t}=ft("common"),n=LG(e),r=k.useRef(null),[o,l]=k.useState(!1),[u,d]=k.useState("rendered"),m=k.useCallback(async()=>{let p;u==="source"?p=ac(e):p=r.current?.querySelector("code")?.textContent??"";try{await navigator.clipboard.writeText(p),l(!0),setTimeout(()=>l(!1),1800)}catch{}},[u,e]);if(k.Children.toArray(e).some(p=>k.isValidElement(p)&&DG.includes(p.type))){const p=ac(e),g=n==="mermaid"||n==="plantuml"?n:"diagram";return s.jsx(Lp,{code:p,language:g,children:e})}return n==="mermaid"||n==="plantuml"?s.jsx(s.Fragment,{children:e}):s.jsxs("div",{className:"not-prose relative group/code my-2 rounded-lg overflow-hidden bg-surface-secondary border border-border-subtle",children:[n&&s.jsxs("div",{className:"flex items-center justify-between px-3 py-1.5 border-b border-border-subtle",children:[s.jsx("span",{className:"text-[10px] font-medium text-fg-tertiary uppercase tracking-wider select-none",children:RG(n)}),s.jsxs("div",{className:"flex items-center gap-1",children:[s.jsx("button",{onClick:()=>d("rendered"),className:`px-1.5 py-0.5 rounded text-[10px] font-medium transition-colors ${u==="rendered"?"bg-brand-600/20 text-brand-500":"text-fg-tertiary hover:text-fg-secondary"}`,children:t("markdown.viewRendered")}),s.jsx("button",{onClick:()=>d("source"),className:`px-1.5 py-0.5 rounded text-[10px] font-medium transition-colors ${u==="source"?"bg-brand-600/20 text-brand-500":"text-fg-tertiary hover:text-fg-secondary"}`,children:t("markdown.viewSource")})]})]}),s.jsxs("div",{className:"relative",children:[u==="rendered"?s.jsx("pre",{ref:r,className:"p-3 overflow-x-auto text-xs [&>code]:p-0 [&>code]:rounded-none [&>code]:text-fg-secondary",children:k.Children.map(e,p=>k.isValidElement(p)?k.cloneElement(p,{style:{background:"transparent",padding:0}}):p)}):s.jsx("pre",{className:"p-3 overflow-x-auto text-xs font-mono text-fg-secondary whitespace-pre-wrap break-words",children:ac(e)}),s.jsx("button",{onClick:m,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:t("markdown.copyContent"),children:o?s.jsx("svg",{className:"w-3.5 h-3.5 text-green-400",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:s.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M5 13l4 4L19 7"})}):s.jsx("svg",{className:"w-3.5 h-3.5",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:s.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 Qk="markus-copy-typography",U2={fontFamily:"default",fontSize:15,headingScale:"standard"};function Zk(){try{const e=localStorage.getItem(Qk);if(e)return{...U2,...JSON.parse(e)}}catch{}return U2}function PG(e){localStorage.setItem(Qk,JSON.stringify(e))}function zG(e){const t={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"},n={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:t[e.fontFamily]??t.default,fontSize:`${e.fontSize}px`,headingScales:n[e.headingScale]??n.standard}}function BG({onClose:e}){const{t}=ft("common"),[n,r]=k.useState(Zk);k.useEffect(()=>{PG(n)},[n]);const o=k.useCallback((l,u)=>{r(d=>({...d,[l]:u}))},[]);return s.jsxs("div",{className:"px-3 py-2 space-y-3 max-w-[260px]",children:[s.jsxs("div",{className:"flex items-center justify-between mb-1",children:[s.jsx("span",{className:"font-medium text-fg-primary text-xs",children:t("markdown.typographySettings")}),s.jsx("button",{onClick:e,className:"text-fg-tertiary hover:text-fg-primary p-0.5",children:s.jsx("svg",{className:"w-3 h-3",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:s.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M6 18L18 6M6 6l12 12"})})})]}),s.jsx("p",{className:"text-[10px] text-fg-tertiary",children:t("markdown.typographyDesc")}),s.jsxs("div",{children:[s.jsx("label",{className:"text-[10px] text-fg-tertiary font-medium block mb-1",children:t("markdown.fontFamily")}),s.jsxs("select",{value:n.fontFamily,onChange:l=>o("fontFamily",l.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:[s.jsx("option",{value:"default",children:t("markdown.fontDefault")}),s.jsx("option",{value:"serif",children:t("markdown.fontSerif")}),s.jsx("option",{value:"sans-serif",children:t("markdown.fontSansSerif")}),s.jsx("option",{value:"mono",children:t("markdown.fontMono")})]})]}),s.jsxs("div",{children:[s.jsxs("label",{className:"text-[10px] text-fg-tertiary font-medium block mb-1",children:[t("markdown.fontSize"),": ",n.fontSize,"px"]}),s.jsx("input",{type:"range",min:10,max:24,step:1,value:n.fontSize,onChange:l=>o("fontSize",Number(l.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"}),s.jsxs("div",{className:"flex justify-between text-[9px] text-fg-tertiary mt-0.5",children:[s.jsx("span",{children:"10px"}),s.jsx("span",{children:"24px"})]})]}),s.jsxs("div",{children:[s.jsx("label",{className:"text-[10px] text-fg-tertiary font-medium block mb-1",children:t("markdown.headingScale")}),s.jsx("div",{className:"flex gap-1",children:["compact","standard","large"].map(l=>s.jsx("button",{onClick:()=>o("headingScale",l),className:`flex-1 px-2 py-1 rounded text-[10px] font-medium transition-colors ${n.headingScale===l?"bg-brand-600/20 text-brand-500":"bg-surface-primary text-fg-tertiary hover:text-fg-secondary border border-border-subtle"}`,children:t(`markdown.scale${l.charAt(0).toUpperCase()+l.slice(1)}`)},l))})]})]})}const UG=k.lazy(()=>qr(()=>Promise.resolve().then(()=>i3),void 0).then(e=>({default:e.MarkdownMessage}))),$G={file:{icon:"📄",color:"bg-green-500/10 text-green-600"},directory:{icon:"📁",color:"bg-blue-500/10 text-blue-600"}},$2={active:{color:"text-green-600 bg-green-500/10"},verified:{color:"text-blue-600 bg-blue-500/10"},outdated:{color:"text-fg-tertiary bg-surface-elevated/50"}};function HG({item:e,onClose:t,onOpenInPage:n}){const{t:r}=ft(["agent","common"]),o=$G[e.type]??{icon:"📎",color:"bg-surface-elevated text-fg-secondary"},l=$2[e.status]??$2.active,u=/^https?:\/\//i.test(e.reference??"");k.useEffect(()=>{const m=h=>{h.key==="Escape"&&t()};return window.addEventListener("keydown",m),()=>window.removeEventListener("keydown",m)},[t]);const d=s.jsxs("div",{className:"fixed inset-0 z-50 flex items-center justify-center p-4",onClick:t,children:[s.jsx("div",{className:"absolute inset-0 bg-black/50 backdrop-blur-sm"}),s.jsxs("div",{className:"relative bg-surface-primary rounded-2xl shadow-2xl border border-border-default w-full max-w-lg max-h-[85vh] overflow-y-auto",onClick:m=>m.stopPropagation(),children:[s.jsxs("div",{className:"sticky top-0 bg-surface-primary/95 backdrop-blur-sm border-b border-border-default px-5 py-4 flex items-start gap-3 rounded-t-2xl z-10",children:[s.jsx("span",{className:`inline-flex items-center justify-center w-10 h-10 rounded-xl text-lg shrink-0 ${o.color}`,children:o.icon}),s.jsxs("div",{className:"flex-1 min-w-0",children:[s.jsx("h3",{className:"text-base font-semibold text-fg-primary",children:e.title}),s.jsxs("div",{className:"flex items-center gap-2 mt-1 flex-wrap",children:[s.jsx("span",{className:`px-1.5 py-0.5 text-[10px] rounded font-medium ${l.color}`,children:e.status}),s.jsx("span",{className:"text-[10px] text-fg-tertiary",children:e.type}),e.format&&s.jsx("span",{className:"text-[10px] px-1.5 py-0.5 bg-surface-elevated rounded text-fg-secondary",children:e.format})]})]}),s.jsx("button",{onClick:t,className:"p-1.5 rounded-lg hover:bg-surface-overlay transition-colors shrink-0 text-fg-tertiary hover:text-fg-primary",children:s.jsxs("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[s.jsx("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),s.jsx("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]})})]}),s.jsxs("div",{className:"px-5 py-4 space-y-4",children:[e.summary&&e.summary.trim()!==e.title.trim()&&s.jsxs("div",{children:[s.jsx("label",{className:"text-[10px] text-fg-tertiary uppercase tracking-wider font-medium",children:r("agent:deliverables.summary")}),s.jsx("div",{className:"mt-1.5",children:s.jsx(k.Suspense,{fallback:s.jsx("p",{className:"text-sm text-fg-secondary",children:e.summary}),children:s.jsx(UG,{content:e.summary,className:"text-sm text-fg-secondary"})})})]}),e.reference&&s.jsxs("div",{children:[s.jsx("label",{className:"text-[10px] text-fg-tertiary uppercase tracking-wider font-medium",children:r("agent:deliverables.reference")}),s.jsxs("div",{className:"mt-1.5 flex items-center gap-2 bg-surface-elevated rounded-lg px-3 py-2",children:[s.jsx("span",{className:"text-xs text-fg-secondary font-mono break-all flex-1 select-all",children:e.reference}),u?s.jsx("button",{onClick:()=>window.open(e.reference,"_blank","noopener,noreferrer"),className:"px-2 py-1 text-[10px] rounded bg-brand-600/20 text-brand-500 hover:bg-brand-600/30 transition-colors shrink-0",children:r("common:open")}):s.jsx("button",{onClick:()=>{Ce.files.reveal(e.reference).catch(()=>{})},className:"px-2 py-1 text-[10px] rounded bg-brand-600/20 text-brand-500 hover:bg-brand-600/30 transition-colors shrink-0",children:r("common:open")})]})]}),e.diffStats&&s.jsxs("div",{className:"flex items-center gap-3 text-xs bg-surface-elevated rounded-lg px-3 py-2",children:[s.jsx("span",{className:"text-fg-tertiary font-medium",children:"Diff:"}),s.jsxs("span",{className:"text-fg-secondary",children:[e.diffStats.filesChanged," file",e.diffStats.filesChanged!==1?"s":""]}),s.jsxs("span",{className:"text-green-500",children:["+",e.diffStats.additions]}),s.jsxs("span",{className:"text-red-500",children:["-",e.diffStats.deletions]})]}),e.testResults&&s.jsxs("div",{className:"flex items-center gap-3 text-xs bg-surface-elevated rounded-lg px-3 py-2",children:[s.jsx("span",{className:"text-fg-tertiary font-medium",children:"Tests:"}),s.jsxs("span",{className:"text-green-500",children:[e.testResults.passed," passed"]}),e.testResults.failed>0&&s.jsxs("span",{className:"text-red-500",children:[e.testResults.failed," failed"]}),e.testResults.skipped>0&&s.jsxs("span",{className:"text-fg-tertiary",children:[e.testResults.skipped," skipped"]})]}),e.tags.length>0&&s.jsx("div",{className:"flex flex-wrap gap-1.5",children:e.tags.map(m=>s.jsx("span",{className:"px-2 py-0.5 text-[11px] bg-surface-elevated rounded-md text-fg-tertiary",children:m},m))}),s.jsxs("div",{className:"flex items-center gap-4 text-[10px] text-fg-tertiary flex-wrap pt-1 border-t border-border-default/50",children:[s.jsxs("span",{children:[r("agent:deliverables.created"),": ",new Date(e.createdAt).toLocaleString()]}),s.jsxs("span",{children:[r("agent:deliverables.updated"),": ",new Date(e.updatedAt).toLocaleString()]}),e.accessCount>0&&s.jsx("span",{children:r("agent:deliverables.accessed",{count:e.accessCount})})]})]}),s.jsxs("div",{className:"sticky bottom-0 bg-surface-primary/95 backdrop-blur-sm border-t border-border-default px-5 py-3 flex items-center justify-end gap-2 rounded-b-2xl",children:[s.jsxs("button",{onClick:()=>n(e.id),className:"px-3 py-1.5 text-xs font-medium text-brand-500 hover:bg-brand-500/10 rounded-lg transition-colors flex items-center gap-1.5",children:[s.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[s.jsx("path",{d:"M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6"}),s.jsx("polyline",{points:"15 3 21 3 21 9"}),s.jsx("line",{x1:"10",y1:"14",x2:"21",y2:"3"})]}),r("agent:deliverables.openInPage")]}),s.jsx("button",{onClick:t,className:"px-3 py-1.5 text-xs font-medium text-fg-secondary bg-surface-elevated hover:bg-surface-overlay rounded-lg transition-colors",children:r("common:close")})]})]})]});return typeof document<"u"?Ja.createPortal(d,document.body):d}const FG={tsk:"task",req:"requirement",proj:"project",dlv:"deliverable",agt:"agent",team:"team"};function Jk(e){return{task:"task",requirement:"requirement",project:"project",deliverable:"deliverable",agent:"agent",team:"team"}[e]}const e3={task:"📋",requirement:"📝",project:"📁",deliverable:"📦",agent:"🤖",team:"👥"},t3={task:"Task",requirement:"Requirement",project:"Project",deliverable:"Deliverable",agent:"Agent",team:"Team"},qG=/^(tsk|req|proj|dlv|agt|team)_[a-f0-9]{6,}$/i;function Ip(e){return qG.test(e.trim())}function GG(e){const t=e.split("_")[0]?.toLowerCase();return t?FG[t]:void 0}function n3(e){e.startsWith("tsk_")?at.navigate(me.WORK,{openTask:e}):e.startsWith("req_")?at.navigate(me.WORK,{openRequirement:e}):e.startsWith("proj_")?at.navigate(me.WORK,{projectId:e}):e.startsWith("dlv_")?at.navigate(me.DELIVERABLES,{openDeliverable:e}):e.startsWith("agt_")?at.navigate(me.TEAM,{agentId:e}):e.startsWith("team_")&&at.navigate(me.TEAM,{selectTeam:e})}const Hh=new Map,hd=new Map;async function VG(e,t){const n={id:e,type:t,title:e,loading:!1};try{switch(t){case"task":{const r=await Ce.tasks.get(e);return{...n,title:r.task.title,status:r.task.status}}case"requirement":{const r=await Ce.requirements.get(e);return{...n,title:r.requirement.title,status:r.requirement.status}}case"project":{const r=await Ce.projects.get(e);return{...n,title:r.project.name,status:r.project.status,summary:r.project.description}}case"deliverable":{const r=await Ce.deliverables.get(e);return{...n,title:r.deliverable.title,status:r.deliverable.status,summary:r.deliverable.summary,deliverable:r.deliverable}}case"agent":{const r=await Ce.agents.get(e);return{...n,title:r.name,summary:r.role}}case"team":{const o=(await Ce.teams.list()).teams.find(l=>l.id===e);return{...n,title:o?.name??e,notFound:!o}}}}catch{}return{...n,notFound:!0}}function r3(e,t){const n=t??GG(e),[r,o]=k.useState(()=>Hh.get(e)??{id:e,type:n??"task",title:e,loading:!!n});return k.useEffect(()=>{if(!n){o({id:e,type:"task",title:e,loading:!1,notFound:!0});return}const l=Hh.get(e);if(l){o(l);return}o(m=>({...m,type:n,loading:!0}));let u=!0,d=hd.get(e);return d||(d=VG(e,n),hd.set(e,d)),d.then(m=>{Hh.set(e,m),hd.delete(e),u&&o(m)}).catch(()=>{hd.delete(e),u&&o({id:e,type:n,title:e,loading:!1,notFound:!0})}),()=>{u=!1}},[e,n]),r}function a3(e){const t=(e.split("_")[0]?.length??3)+1;return e.length>t+8?`${e.slice(0,t+8)}…`:e}function i0({id:e,type:t,label:n}){const r=r3(e,t),o=z0(),l=e3[r.type]??"🔗",u=n??(r.loading||r.notFound?a3(e):r.title),d=m=>{if(m.preventDefault(),m.stopPropagation(),r.type==="deliverable"&&r.deliverable&&o?.hostAvailable){o.openRightPanel({kind:"deliverable",deliverable:r.deliverable});return}n3(e)};return s.jsxs("span",{"data-entity-link":e,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 align-baseline",onClick:d,title:`${t3[r.type]}: ${r.notFound?e:r.title} (${e})`,children:[s.jsx("span",{className:"text-[10px]",children:l}),s.jsx("span",{className:"truncate max-w-[240px] align-baseline",children:u})]})}function KG({id:e,type:t,label:n}){const r=r3(e,t),[o,l]=k.useState(!1),u=z0(),d=e3[r.type]??"🔗",m=()=>{if(r.type==="deliverable"&&r.deliverable){if(u?.hostAvailable){u.openRightPanel({kind:"deliverable",deliverable:r.deliverable});return}l(!0);return}n3(e)},h=r.loading?a3(e):n||(r.notFound?e:r.title);return s.jsxs("span",{className:"not-prose block my-2",children:[s.jsxs("button",{type:"button",onClick:m,className:"w-full max-w-md text-left rounded-xl border border-border-default bg-surface-elevated/30 hover:border-brand-500/40 hover:bg-surface-elevated/50 transition-colors px-3 py-2.5 flex items-start gap-2.5",children:[s.jsx("span",{className:"inline-flex items-center justify-center w-8 h-8 rounded-lg text-sm shrink-0 bg-brand-500/10",children:d}),s.jsxs("span",{className:"flex-1 min-w-0 block",children:[s.jsxs("span",{className:"flex items-center gap-2 flex-wrap",children:[s.jsx("span",{className:"text-[10px] uppercase tracking-wide text-fg-tertiary font-medium",children:t3[r.type]}),r.status&&s.jsx("span",{className:"px-1.5 py-0.5 text-[10px] rounded font-medium bg-brand-500/10 text-brand-500",children:r.status})]}),s.jsx("span",{className:`block text-sm font-medium truncate mt-0.5 ${r.notFound?"font-mono text-fg-tertiary":"text-fg-primary"}`,children:h}),r.summary&&r.summary.trim()!==r.title.trim()&&s.jsx("span",{className:"block text-xs text-fg-tertiary mt-0.5 line-clamp-1",children:r.summary})]}),s.jsx("svg",{className:"w-4 h-4 text-fg-tertiary shrink-0 mt-1",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:s.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M9 5l7 7-7 7"})})]}),o&&r.deliverable&&s.jsx(HG,{item:r.deliverable,onClose:()=>l(!1),onOpenInPage:p=>{l(!1),at.navigate(me.DELIVERABLES,{openDeliverable:p})}})]})}class WG extends k.Component{state={error:null};static getDerivedStateFromError(t){return{error:t}}componentDidUpdate(t){this.state.error&&this.props.resetKeys&&!YG(t.resetKeys,this.props.resetKeys)&&this.setState({error:null})}componentDidCatch(t,n){this.props.onError?.(t,n),console.error("[ErrorBoundary] caught render error:",t,n.componentStack)}reset=()=>this.setState({error:null});render(){const{error:t}=this.state;if(t){const{fallback:n}=this.props;return typeof n=="function"?n(t,this.reset):n??null}return this.props.children}}function YG(e,t){if(e===t)return!0;if(!e||!t||e.length!==t.length)return!1;for(let n=0;n<e.length;n++)if(e[n]!==t[n])return!1;return!0}const XG=/^(deliverable|task|requirement|project|agent|team|workflow):/i;function H2(e){return XG.test(e)?e:V5(e)}const F2=[xw,zH,vk],q2=[[bF,{strict:"ignore"}],[Vk,{detect:!0,ignoreMissing:!0}]],QG=/<think>([\s\S]*?)(<\/think>|$)/g;function ZG(e){const t=[];let n=e.replace(QG,(r,o)=>{const l=o.trim();return l&&t.push(l),""});return n=n.replace(/<\/think>/g,"").replace(/<think>/g,""),{thinking:t,rest:n.trim()}}const G2="#mention:",o0="#entity:",JG=/^\[([^\]]+)\]\(#entity:((tsk|req|proj|dlv|agt|team)_[a-f0-9]{6,})\)$/i,s3=/^(workflow|task|requirement|project|deliverable|agent|team):(.+)$/;function Pp(e){return e.type==="text"?e.value??"":(e.children??[]).map(Pp).join("")}function eV(e){return e.type==="text"&&(e.value??"").trim()===""}function tV(e){if(!e?.children)return null;const t=e.children.filter(r=>!eV(r));if(t.length!==1)return null;const n=t[0];if(n.type==="element"&&n.tagName==="a"){const r=n.properties?.href;if(!r)return null;const o=Pp(n);if(r.startsWith(o0))return{id:r.slice(o0.length)};const l=r.match(s3);return l&&l[1]!=="workflow"?{id:l[2],type:Jk(l[1]),label:o}:null}if(n.type==="element"&&n.tagName==="code"){const r=Pp(n).trim();if(Ip(r))return{id:r}}if(n.type==="text"){const r=(n.value??"").trim();if(Ip(r))return{id:r}}return null}const nV={p:({children:e})=>s.jsx("p",{className:"mb-2 last:mb-0 leading-relaxed text-fg-secondary",children:e}),h1:({children:e})=>s.jsx("h1",{className:"text-base font-bold mb-2 mt-3 first:mt-0 text-fg-primary",children:e}),h2:({children:e})=>s.jsx("h2",{className:"text-sm font-bold mb-2 mt-3 first:mt-0 text-fg-primary",children:e}),h3:({children:e})=>s.jsx("h3",{className:"text-sm font-semibold mb-1 mt-2 first:mt-0 text-fg-primary",children:e}),h4:({children:e})=>s.jsx("h4",{className:"text-sm font-semibold mb-1 mt-2 first:mt-0 text-fg-primary",children:e}),h5:({children:e})=>s.jsx("h5",{className:"text-xs font-semibold mb-1 mt-2 first:mt-0 text-fg-primary",children:e}),h6:({children:e})=>s.jsx("h6",{className:"text-xs font-medium mb-1 mt-2 first:mt-0 text-fg-primary",children:e}),ul:({children:e})=>s.jsx("ul",{className:"list-disc pl-4 mb-2 space-y-0.5",children:e}),ol:({children:e,start:t})=>s.jsx("ol",{start:t,className:"list-decimal pl-7 mb-2 space-y-0.5",children:e}),li:({children:e,value:t})=>s.jsx("li",{value:t,className:"leading-relaxed text-fg-secondary marker:text-fg-secondary",children:e}),code:({children:e,className:t})=>{const n=typeof e=="string"?e:String(e??""),r=n.trim();if(t?.includes("language-plantuml")||AG(r))return s.jsx(Lp,{code:r,language:"plantuml",children:s.jsx(Yk,{code:r})});if(t?.includes("language-mermaid")||!t&&jG(r))return s.jsx(Lp,{code:r,language:"mermaid",children:s.jsx(Wk,{code:r})});if(t?.includes("language-"))return s.jsx("code",{className:`${t} text-fg-secondary font-mono text-xs`,children:e});if(Ip(n))return s.jsx(i0,{id:n.trim()});const o=n.match(JG);return o?s.jsx(i0,{id:o[2],label:o[1]}):aG(n)?s.jsx(iG,{path:n}):s.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})=>s.jsx(IG,{children:e}),strong:({children:e})=>s.jsx("strong",{className:"font-bold text-fg-primary",children:e}),em:({children:e})=>s.jsx("em",{className:"italic text-fg-secondary",children:e}),del:({children:e})=>s.jsx("del",{className:"line-through text-fg-tertiary",children:e}),blockquote:({children:e})=>s.jsx("blockquote",{className:"border-l-2 border-brand-500 pl-3 my-2 text-fg-secondary italic",children:e}),a:({href:e,children:t})=>s.jsx("a",{href:e,target:"_blank",rel:"noopener noreferrer",className:"text-brand-500 hover:text-brand-500 underline break-all",children:t}),hr:()=>s.jsx("hr",{className:"border-border-default my-3"}),table:({children:e})=>s.jsx("div",{className:"overflow-x-auto my-2",children:s.jsx("table",{className:"min-w-full text-sm border-collapse border border-border-default",children:e})}),thead:({children:e})=>s.jsx("thead",{className:"bg-surface-secondary",children:e}),tbody:({children:e})=>s.jsx("tbody",{className:"divide-y divide-border-default",children:e}),tr:({children:e})=>s.jsx("tr",{className:"hover:bg-surface-elevated/50 transition-colors",children:e}),th:({children:e})=>s.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})=>s.jsx("td",{className:"px-3 py-2 text-sm text-fg-primary border border-border-default",children:e})},rV=/^(?:\/[\w.\-@+ ]|~\/|\.\.?\/|[A-Z]:\\)/,aV=/\.(png|jpe?g|gif|webp|svg|bmp|ico)$/i;function sV(e){return rV.test(e)&&aV.test(e)}function iV(e,t){if(e.startsWith("/")||e.startsWith("~/")||/^[A-Z]:\\/.test(e))return e;if((e.startsWith("./")||e.startsWith("../"))&&t){const r=((t.endsWith("/")?t:t+"/")+e).split("/"),o=[];for(const l of r)l===".."?o.pop():l!=="."&&l!==""&&o.push(l);return"/"+o.join("/")}return e}function oV(e){return`/api/files/image?path=${encodeURIComponent(e)}`}const ko=new Map;function lV({src:e,alt:t,onPreview:n,basePath:r}){const o=k.useMemo(()=>sV(e)?oV(iV(e,r)):e,[e,r]),l=o.startsWith("/api/files/image?"),u=ko.get(o),[d,m]=k.useState(u??(l?null:o)),[h,p]=k.useState(!!u),[g,x]=k.useState(!1),[y,w]=k.useState(null),[N,T]=k.useState(0),C=k.useRef(0),j=k.useCallback(()=>{ko.delete(o),x(!1),w(null),p(!1),m(l?null:`${o}${o.includes("?")?"&":"?"}retry=${Date.now()}`),T(_=>_+1)},[o,l]);return k.useEffect(()=>{if(!l)return;const _=ko.get(o);if(_){m(_),p(!0),x(!1),w(null);return}const O=++C.current;x(!1),w(null),p(!1),m(null),(async()=>{try{const z=await fetch(o,{credentials:"same-origin"});if(O!==C.current)return;if(!z.ok){let W=`HTTP ${z.status}`;try{const Z=await z.json();Z.error&&(W=Z.error)}catch{}throw new Error(W)}const D=await z.blob();if(O!==C.current)return;if(D.size===0)throw new Error("Empty image response");if(D.type&&!D.type.startsWith("image/")&&!D.type.includes("octet-stream"))throw new Error(`Unexpected content-type: ${D.type}`);const H=URL.createObjectURL(D);ko.set(o,H),m(H),p(!0),x(!1),w(null)}catch(z){if(O!==C.current)return;const D=z instanceof Error?z.message:String(z);console.warn("[MarkdownImage] failed to load local image",o,z),w(D),x(!0),p(!1)}})()},[l,o,N]),k.useEffect(()=>{l||(m(o),p(!!ko.get(o)),x(!1),w(null))},[o,l,N]),g?s.jsxs("button",{type:"button",onClick:j,title:y??"Click to retry",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 hover:bg-surface-overlay hover:text-fg-secondary cursor-pointer transition-colors max-w-full",children:[s.jsxs("svg",{className:"w-4 h-4 shrink-0",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:1.5,children:[s.jsx("rect",{x:"3",y:"3",width:"18",height:"18",rx:"2",ry:"2"}),s.jsx("circle",{cx:"8.5",cy:"8.5",r:"1.5"}),s.jsx("polyline",{points:"21 15 16 10 5 21"})]}),s.jsxs("span",{className:"truncate",children:["Failed to load image — click to retry",y?` (${y})`:""]})]}):s.jsxs("span",{className:"inline-block align-middle max-w-full",children:[!h&&s.jsx("span",{className:"block w-full min-h-[80px] max-w-[400px] bg-surface-elevated rounded-lg animate-pulse"}),d?s.jsx("img",{src:d,alt:t??"",onLoad:()=>{l||ko.set(o,o),p(!0)},onError:()=>{w("Image decode failed"),x(!0)},onClick:()=>n?.(d),className:`max-w-full h-auto rounded-lg cursor-pointer hover:opacity-90 transition-opacity my-1${h?"":" absolute opacity-0 pointer-events-none"}`,style:{maxHeight:"400px",objectFit:"contain"}}):null]})}async function V2(e){const t=await fetch(e);if(!t.ok)throw new Error(`Failed to fetch image (${t.status})`);return t.blob()}async function cV(e){if(e.type==="image/png")return e;const t=await createImageBitmap(e),n=document.createElement("canvas");n.width=t.width,n.height=t.height;const r=n.getContext("2d");if(!r)throw new Error("Canvas unavailable");return r.drawImage(t,0,0),t.close(),new Promise((o,l)=>{n.toBlob(u=>u?o(u):l(new Error("PNG encode failed")),"image/png")})}function uV(e,t){try{const o=(e.startsWith("data:")?"":new URL(e,window.location.href).pathname).split("/").pop()||"";if(o&&/\.(png|jpe?g|gif|webp|svg|bmp)$/i.test(o))return decodeURIComponent(o)}catch{}return`image.${(t.type.split("/")[1]||"png").replace("jpeg","jpg")}`}function dV({src:e,onClose:t}){const{t:n}=ft("common"),[r,o]=k.useState(null),[l,u]=k.useState(null);Bo(!0),k.useEffect(()=>{const g=x=>{x.key==="Escape"&&t()};return document.addEventListener("keydown",g),()=>document.removeEventListener("keydown",g)},[t]);const d=k.useCallback(g=>{o(g),window.setTimeout(()=>o(null),1600)},[]),m=k.useCallback(async g=>{if(g.stopPropagation(),!l){u("copy");try{const x=await V2(e),y=await cV(x);await navigator.clipboard.write([new ClipboardItem({"image/png":y})]),d(n("imageCopied"))}catch{d(n("imageCopyFailed"))}finally{u(null)}}},[l,d,e,n]),h=k.useCallback(async g=>{if(g.stopPropagation(),!l){u("download");try{const x=await V2(e),y=URL.createObjectURL(x),w=document.createElement("a");w.href=y,w.download=uV(e,x),document.body.appendChild(w),w.click(),w.remove(),URL.revokeObjectURL(y),d(n("imageDownloaded"))}catch{d(n("imageDownloadFailed"))}finally{u(null)}}},[l,d,e,n]),p="inline-flex items-center gap-1.5 px-3 py-1.5 rounded-lg bg-white/10 hover:bg-white/20 text-white text-sm transition-colors disabled:opacity-50";return Ja.createPortal(s.jsxs("div",{className:"fixed inset-0 z-[9999] bg-black/80 flex items-center justify-center p-4",onClick:t,children:[s.jsxs("div",{className:"absolute top-4 right-4 z-10 flex items-center gap-2",onClick:g=>g.stopPropagation(),children:[s.jsxs("button",{type:"button",className:p,onClick:m,disabled:!!l,title:n("copyImage"),children:[s.jsxs("svg",{className:"w-4 h-4",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[s.jsx("rect",{x:"9",y:"9",width:"13",height:"13",rx:"2"}),s.jsx("path",{d:"M5 15H4a2 2 0 01-2-2V4a2 2 0 012-2h9a2 2 0 012 2v1"})]}),n("copy")]}),s.jsxs("button",{type:"button",className:p,onClick:h,disabled:!!l,title:n("downloadImage"),children:[s.jsxs("svg",{className:"w-4 h-4",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[s.jsx("path",{d:"M21 15v4a2 2 0 01-2 2H5a2 2 0 01-2-2v-4"}),s.jsx("polyline",{points:"7 10 12 15 17 10"}),s.jsx("line",{x1:"12",y1:"15",x2:"12",y2:"3"})]}),n("downloadImage")]}),s.jsx("button",{type:"button",onClick:t,className:"w-10 h-10 rounded-full bg-white/10 hover:bg-white/20 flex items-center justify-center transition-colors",title:n("close"),children:s.jsxs("svg",{className:"w-6 h-6 text-white",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2,children:[s.jsx("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),s.jsx("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]})})]}),r&&s.jsx("div",{className:"absolute top-16 left-1/2 -translate-x-1/2 z-10 px-3 py-1.5 rounded-lg bg-black/70 text-white text-xs",children:r}),s.jsx("img",{src:e,alt:"Preview",className:"max-w-full max-h-[90vh] object-contain rounded-lg",onClick:g=>g.stopPropagation()})]}),document.body)}function mV(e=640){const[t,n]=k.useState(()=>window.innerWidth<e);return k.useEffect(()=>{const r=window.matchMedia(`(max-width: ${e-1}px)`),o=l=>n(l.matches);return r.addEventListener("change",o),n(r.matches),()=>r.removeEventListener("change",o)},[e]),t}function fV({content:e,contentRef:t}){const{t:n}=ft("common"),[r,o]=k.useState(!1),[l,u]=k.useState(!1),[d,m]=k.useState(!1),[h,p]=k.useState(null),g=k.useRef(null),x=mV();k.useEffect(()=>{if(!r)return;const T=C=>{g.current&&!g.current.contains(C.target)&&(o(!1),u(!1),m(!1))};return document.addEventListener("mousedown",T),()=>document.removeEventListener("mousedown",T)},[r]);const y=k.useCallback(T=>{p(T),setTimeout(()=>p(null),1500)},[]),w=async()=>{const T=await jg(e);y(n(T?"markdown.copied":"markdown.failed")),o(!1)},N=async T=>{const C=t.current?.firstElementChild;if(!C)return;const j=Zk(),_=zG(j),O=await vG(C,T,e,{fontFamily:_.fontFamily,fontSize:_.fontSize,headingScales:_.headingScales}),z=n(T==="light"?"markdown.themeLight":"markdown.themeDark");y(O.ok?O.method==="html"?n("markdown.htmlCopied",{theme:z}):n("markdown.textCopied"):n("markdown.failed")),o(!1)};return s.jsxs("div",{className:"absolute top-1 right-1 z-10 opacity-0 group-hover/md:opacity-100 transition-opacity",ref:g,children:[h&&s.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:h}),s.jsx("button",{onClick:()=>o(T=>!T),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:n("markdown.copyContent"),children:s.jsx("svg",{className:"w-3.5 h-3.5",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:s.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"})})}),r&&s.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:d?s.jsx(BG,{onClose:()=>m(!1)}):l?s.jsxs("div",{className:"px-3 py-2 text-[11px] text-fg-secondary space-y-2 max-w-[260px]",children:[s.jsxs("div",{className:"flex items-center justify-between mb-1",children:[s.jsx("span",{className:"font-medium text-fg-primary text-xs",children:n("markdown.infoTitle")}),s.jsx("button",{onClick:()=>u(!1),className:"text-fg-tertiary hover:text-fg-primary p-0.5",children:s.jsx("svg",{className:"w-3 h-3",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:s.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M6 18L18 6M6 6l12 12"})})})]}),s.jsxs("div",{children:[s.jsx("span",{className:"font-medium text-fg-primary",children:n("markdown.mdAbbrev")})," — ",n("markdown.infoMdDesc")]}),s.jsxs("div",{children:[s.jsx("span",{className:"font-medium text-fg-primary",children:"☀️"})," — ",n("markdown.infoHtmlLightDesc")]}),s.jsxs("div",{children:[s.jsx("span",{className:"font-medium text-fg-primary",children:"🌙"})," — ",n("markdown.infoHtmlDarkDesc")]})]}):s.jsxs(s.Fragment,{children:[s.jsxs("div",{className:"flex items-center justify-between px-3 py-1 border-b border-border-subtle mb-1",children:[s.jsx("span",{className:"text-[10px] text-fg-tertiary font-medium",children:n("markdown.copyContent")}),s.jsxs("div",{className:"flex items-center gap-1",children:[s.jsx("button",{onClick:()=>m(!0),className:"p-0.5 rounded text-fg-tertiary hover:text-fg-primary transition-colors",title:n("markdown.typographySettings"),children:s.jsxs("svg",{className:"w-3.5 h-3.5",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:[s.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"}),s.jsx("circle",{cx:"12",cy:"12",r:"3"})]})}),s.jsx("button",{onClick:()=>u(!0),className:"p-0.5 rounded text-fg-tertiary hover:text-fg-primary transition-colors",title:n("markdown.infoTitle"),children:s.jsxs("svg",{className:"w-3.5 h-3.5",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:[s.jsx("circle",{cx:"12",cy:"12",r:"10"}),s.jsx("path",{strokeLinecap:"round",d:"M12 16v-4m0-4h.01"})]})})]})]}),s.jsxs("button",{onClick:w,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:[s.jsx("span",{className:"w-4 text-center text-fg-tertiary shrink-0 font-mono text-[10px]",children:n("markdown.mdAbbrev")}),n(x?"markdown.copyMdSourceShort":"markdown.copyMdSource")]}),s.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:[s.jsx("span",{className:"w-4 text-center shrink-0 text-[10px]",children:"☀️"}),n(x?"markdown.copyHtmlLightShort":"markdown.copyHtmlLight")]}),s.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:[s.jsx("span",{className:"w-4 text-center shrink-0 text-[10px]",children:"🌙"}),n(x?"markdown.copyHtmlDarkShort":"markdown.copyHtmlDark")]})]})})]})}const Ar=k.memo(function({content:t,className:n="",onMentionClick:r,knownNames:o,basePath:l}){const{thinking:u,rest:d}=ZG(t),m=k.useRef(null),[h,p]=k.useState(null),g=k.useCallback(w=>{let N=md(w,wG);return N=md(N,TG),N=md(N,EG),N=md(N,T=>kG(T,o)),N},[o]),x=k.useMemo(()=>g(d),[d,g]),y=k.useMemo(()=>({...nV,img:({src:w,alt:N})=>s.jsx(lV,{src:w??"",alt:N,onPreview:p,basePath:l},w??""),p:({children:w,node:N})=>{const T=tV(N);return T?s.jsx(KG,{id:T.id,type:T.type,label:T.label}):s.jsx("p",{className:"mb-2 last:mb-0 leading-relaxed text-fg-secondary",children:w})},a:({href:w,children:N})=>{if(w?.startsWith(G2)){const T=decodeURIComponent(w.slice(G2.length));return s.jsx("span",{className:`text-brand-500 font-medium${r?" cursor-pointer hover:underline":""}`,onClick:r?C=>{C.preventDefault(),C.stopPropagation(),r(T,C)}:void 0,title:T,children:N})}if(w?.startsWith(o0))return s.jsx(i0,{id:w.slice(o0.length)});{const T=w?.match(s3);if(T){const[,C,j]=T;if(C==="workflow")return s.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:O=>{O.preventDefault(),O.stopPropagation(),at.navigate(me.WORK,{boardType:"workflows"})},title:`workflow: ${j}`,children:[s.jsx("span",{className:"text-[10px]",children:"⚙️"}),s.jsx("span",{children:N})]});const _=Jk(C);if(_)return s.jsx(i0,{id:j,type:_,label:N})}}return s.jsx("a",{href:w,target:"_blank",rel:"noopener noreferrer",className:"text-brand-500 hover:text-brand-500 underline break-all",children:N})}}),[r,l]);return s.jsxs("div",{className:"relative group/md",children:[s.jsx(fV,{content:t,contentRef:m}),s.jsx("div",{ref:m,children:s.jsx(WG,{resetKeys:[x],fallback:s.jsx("div",{className:`prose prose-sm max-w-none break-words whitespace-pre-wrap pr-8 text-fg-secondary ${n}`,children:d}),children:s.jsxs("div",{className:`prose prose-sm max-w-none break-words pr-8 text-fg-secondary ${n}`,children:[u.length>0&&(()=>{const w=u.join(`
649
649
 
650
650
  `),N=w.split(`
651
651
  `)[0]??"",T=N.length>80?N.slice(0,80)+"…":N;return s.jsxs("details",{className:"mb-3 rounded-lg bg-surface-elevated/60 border border-border-default/50 overflow-hidden group/think",children:[s.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:[s.jsx("svg",{className:"w-3 h-3 shrink-0 transition-transform group-open/think:rotate-90",viewBox:"0 0 20 20",fill:"currentColor",children:s.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"})}),s.jsx("span",{className:"shrink-0",children:"Thinking"}),s.jsx("span",{className:"truncate text-fg-tertiary ml-1 group-open/think:hidden",children:T})]}),s.jsx("div",{className:"px-3 pb-3 border-t border-border-default/50",children:s.jsx("div",{className:"mt-2 pl-3 border-l-2 border-brand-500/40 text-xs text-fg-secondary leading-relaxed",children:s.jsx(bp,{remarkPlugins:F2,rehypePlugins:q2,components:y,urlTransform:H2,children:g(w)})})})]})})(),s.jsx(bp,{remarkPlugins:F2,rehypePlugins:q2,components:y,urlTransform:H2,children:x})]})})}),h&&s.jsx(dV,{src:h,onClose:()=>p(null)})]})},(e,t)=>e.content===t.content&&e.className===t.className&&e.basePath===t.basePath&&e.onMentionClick===t.onMentionClick&&hV(e.knownNames,t.knownNames));function hV(e,t){if(e===t)return!0;if(!e||!t||e.length!==t.length)return!1;for(let n=0;n<e.length;n++)if(e[n]!==t[n])return!1;return!0}const i3=Object.freeze(Object.defineProperty({__proto__:null,MarkdownMessage:Ar},Symbol.toStringTag,{value:"Module"})),zp={suppressAdjustUntil:0};function bc(e=2500){const t=typeof performance<"u"?performance.now():Date.now();zp.suppressAdjustUntil=Math.max(zp.suppressAdjustUntil,t+e)}function wW(){return(typeof performance<"u"?performance.now():Date.now())<zp.suppressAdjustUntil}const K2={shell_execute:{label:"Running command",icon:"⌨"},file_read:{label:"Reading file",icon:"📄"},file_write:{label:"Writing file",icon:"✏"},file_edit:{label:"Editing file",icon:"✏"},apply_patch:{label:"Applying patch",icon:"🔀"},list_directory:{label:"Listing directory",icon:"📂"},glob_find:{label:"Finding files",icon:"🔍"},grep_search:{label:"Searching code",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:"📋"},task_get:{label:"Getting task",icon:"📋"},task_note:{label:"Adding note",icon:"📝"},task_assign:{label:"Assigning task",icon:"👥"},task_submit_review:{label:"Submitting for review",icon:"✅"},task_comment:{label:"Commenting task",icon:"💬"},subtask_create:{label:"Adding subtask",icon:"📌"},subtask_complete:{label:"Completing subtask",icon:"✅"},subtask_cancel:{label:"Cancelling subtask",icon:"🚫"},subtask_list:{label:"Listing subtasks",icon:"📋"},requirement_propose:{label:"Proposing requirement",icon:"📋"},requirement_list:{label:"Listing requirements",icon:"📋"},requirement_get:{label:"Getting requirement",icon:"📋"},requirement_update:{label:"Updating requirement",icon:"📋"},requirement_update_status:{label:"Updating req status",icon:"✅"},requirement_resubmit:{label:"Resubmitting requirement",icon:"📋"},requirement_comment:{label:"Commenting requirement",icon:"💬"},list_projects:{label:"Listing projects",icon:"🗂"},get_project:{label:"Getting project",icon:"🗂"},create_project:{label:"Creating project",icon:"🗂"},update_project:{label:"Updating project",icon:"🗂"},deliverable_create:{label:"Creating deliverable",icon:"📦"},deliverable_search:{label:"Searching deliverables",icon:"🔍"},deliverable_list:{label:"Listing deliverables",icon:"📦"},deliverable_update:{label:"Updating deliverable",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:"💾"},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_colleagues:{label:"Checking team",icon:"👥"},memory_save:{label:"Saving memory",icon:"💾"},memory_search:{label:"Searching memory",icon:"🔍"},memory_list:{label:"Listing memory",icon:"💾"},memory_update:{label:"Updating memory",icon:"💾"},recall_activity:{label:"Recalling activity",icon:"📜"},update_working_memory:{label:"Updating notes",icon:"📝"},notify_user:{label:"Notifying user",icon:"🔔"},request_user_input:{label:"Requesting input",icon:"❓"},request_user_approval:{label:"Requesting approval",icon:"❓"},schedule_wakeup:{label:"Scheduling wakeup",icon:"⏰"},cancel_wakeup:{label:"Cancelling wakeup",icon:"⏰"},set_heartbeat_interval:{label:"Setting heartbeat",icon:"⏱"},discover_tools:{label:"Discovering tools",icon:"🧰"},check_mailbox:{label:"Checking mailbox",icon:"📥"},goal_create:{label:"Creating goal",icon:"🎯"},goal_update:{label:"Updating goal",icon:"🎯"},goal_status:{label:"Goal status",icon:"🎯"},background_exec:{label:"Background command",icon:"⌨"},process:{label:"Managing process",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:"🔀"},generate_image:{label:"Generating image",icon:"🖼"},text_to_speech:{label:"Generating speech",icon:"🔊"},speech_to_text:{label:"Transcribing audio",icon:"🎙"},generate_video:{label:"Generating video",icon:"🎬"},llm_list_providers:{label:"Listing providers",icon:"⚙"},llm_switch_model:{label:"Switching model",icon:"⚙"},llm_switch_default_provider:{label:"Switching provider",icon:"⚙"},llm_add_provider:{label:"Adding provider",icon:"⚙"},llm_edit_provider:{label:"Editing provider",icon:"⚙"},llm_add_model:{label:"Adding model",icon:"⚙"},llm_get_capability_routing:{label:"Checking capability routing",icon:"⚙"},llm_set_capability_routing:{label:"Setting capability routing",icon:"⚙"},team_list:{label:"Listing teams",icon:"👥"},team_status:{label:"Team status",icon:"👥"},team_start:{label:"Starting team",icon:"👥"},team_stop:{label:"Stopping team",icon:"👥"},team_update:{label:"Updating team",icon:"👥"},agent_start:{label:"Starting agent",icon:"◎"},agent_stop:{label:"Stopping agent",icon:"◎"},agent_update:{label:"Updating agent",icon:"◎"},agent_delegate_task:{label:"Delegating task",icon:"📌"},agent_broadcast_status:{label:"Broadcasting status",icon:"📣"},agent_create_group_chat:{label:"Creating group chat",icon:"💬"},agent_list_group_chats:{label:"Listing group chats",icon:"💬"},agent_send_group_message:{label:"Sending group message",icon:"💬"},delete_project:{label:"Deleting project",icon:"🗂"},project_stats:{label:"Project stats",icon:"📊"},hub_search:{label:"Searching Hub",icon:"🔍"},hub_install:{label:"Installing from Hub",icon:"📦"},package_list:{label:"Listing packages",icon:"📦"},package_install:{label:"Installing package",icon:"📦"},memory_delete:{label:"Deleting memory",icon:"💾"},memory_update_longterm:{label:"Updating long-term memory",icon:"💾"},clear_working_memory:{label:"Clearing notes",icon:"📝"},clear_notebook:{label:"Clearing notebook",icon:"📝"},update_notebook:{label:"Updating notebook",icon:"📝"},recall_context:{label:"Recalling context",icon:"📜"},defer_mailbox_item:{label:"Deferring mailbox item",icon:"📥"},drop_mailbox_item:{label:"Dropping mailbox item",icon:"📥"},prioritize_mailbox_item:{label:"Prioritizing mailbox",icon:"📥"},delegate_message:{label:"Delegating message",icon:"💬"},task_board_health:{label:"Checking task board",icon:"📋"},task_check_duplicates:{label:"Checking duplicates",icon:"📋"},task_cleanup_duplicates:{label:"Cleaning duplicates",icon:"📋"},workflow_list:{label:"Listing workflows",icon:"🔄"},workflow_create:{label:"Creating workflow",icon:"🔄"},workflow_update:{label:"Updating workflow",icon:"🔄"},workflow_delete:{label:"Deleting workflow",icon:"🔄"},workflow_run:{label:"Running workflow",icon:"🔄"},workflow_status:{label:"Workflow status",icon:"🔄"},workflow_cancel:{label:"Cancelling workflow",icon:"🔄"},open_page:{label:"Opening page",icon:"🌐"},resize_page:{label:"Resizing page",icon:"🌐"},drag:{label:"Dragging element",icon:"👆"},upload_file:{label:"Uploading file",icon:"📎"},emulate:{label:"Emulating device",icon:"📱"},handle_dialog:{label:"Handling dialog",icon:"💬"},get_console_message:{label:"Console message",icon:"🔍"},get_network_request:{label:"Network request",icon:"🔍"}},W2={shell_execute:"square-terminal",background_exec:"square-terminal",process:"settings",file_read:"file-text",file_write:"edit",file_edit:"edit",apply_patch:"git-branch",list_directory:"folder",glob_find:"search",grep_search:"search",web_fetch:"globe",web_search:"search",web_extract:"file-text",create_task:"clipboard",task_create:"clipboard",create_subtask:"clipboard",update_task:"check-circle",task_update:"check-circle",add_task_note:"edit",task_add_note:"edit",task_note:"edit",task_list:"clipboard",task_get:"clipboard",task_assign:"users",task_submit_review:"check-circle",task_comment:"message-square",subtask_create:"clipboard",subtask_complete:"check-circle",subtask_cancel:"alert-circle",subtask_list:"clipboard",requirement_propose:"clipboard",requirement_list:"clipboard",requirement_get:"clipboard",requirement_update:"clipboard",requirement_update_status:"check-circle",requirement_resubmit:"clipboard",requirement_comment:"message-square",list_projects:"layers",get_project:"layers",create_project:"layers",update_project:"layers",deliverable_create:"package",deliverable_search:"search",deliverable_list:"package",deliverable_update:"edit",git_status:"git-branch",git_diff:"git-branch",git_log:"book-open",git_branch:"git-branch",git_add:"git-branch",git_commit:"save",project_structure:"layers",code_stats:"bar-chart",navigate_page:"globe",new_page:"globe",close_page:"globe",select_page:"globe",list_pages:"globe",click:"target",hover:"target",fill:"terminal",fill_form:"terminal",type_text:"terminal",press_key:"terminal",take_screenshot:"camera",take_snapshot:"camera",evaluate_script:"code",wait_for:"clock",list_console_messages:"terminal",list_network_requests:"globe",lighthouse_audit:"bar-chart",agent_send_message:"message-square",agent_list_colleagues:"users",memory_save:"database",memory_search:"search",memory_list:"database",memory_update:"database",recall_activity:"book-open",update_working_memory:"edit",notify_user:"megaphone",request_user_input:"message-square",request_user_approval:"check-circle",schedule_wakeup:"clock",cancel_wakeup:"clock",set_heartbeat_interval:"clock",discover_tools:"wrench",check_mailbox:"message-square",goal_create:"target",goal_update:"target",goal_status:"target",feishu_send_message:"message-square",feishu_search_docs:"search",spawn_subagent:"bot",spawn_subagents:"bot",invoke_coding_tool:"wrench",coding_tool_apply:"git-branch",generate_image:"camera",text_to_speech:"headphones",speech_to_text:"headphones",generate_video:"camera",llm_list_providers:"settings",llm_switch_model:"settings",llm_switch_default_provider:"settings",llm_add_provider:"settings",llm_edit_provider:"settings",llm_add_model:"settings",llm_get_capability_routing:"settings",llm_set_capability_routing:"settings",team_list:"users",team_status:"users",team_start:"users",team_stop:"users",team_update:"users",agent_start:"bot",agent_stop:"bot",agent_update:"bot",agent_delegate_task:"clipboard",agent_broadcast_status:"megaphone",agent_create_group_chat:"message-square",agent_list_group_chats:"message-square",agent_send_group_message:"message-square",delete_project:"layers",project_stats:"bar-chart",hub_search:"search",hub_install:"package",package_list:"package",package_install:"package",memory_delete:"database",memory_update_longterm:"database",clear_working_memory:"edit",clear_notebook:"edit",update_notebook:"edit",recall_context:"book-open",defer_mailbox_item:"message-square",drop_mailbox_item:"message-square",prioritize_mailbox_item:"message-square",delegate_message:"message-square",task_board_health:"clipboard",task_check_duplicates:"clipboard",task_cleanup_duplicates:"clipboard",workflow_list:"git-branch",workflow_create:"git-branch",workflow_update:"git-branch",workflow_delete:"git-branch",workflow_run:"git-branch",workflow_status:"git-branch",workflow_cancel:"git-branch",open_page:"globe",resize_page:"globe",drag:"target",upload_file:"file-text",emulate:"settings",handle_dialog:"message-square",get_console_message:"terminal",get_network_request:"globe"};function Ci(e){const t=e.includes("__")?e.split("__").pop():e,n=K2[t]??K2[e],r=W2[t]??W2[e]??"settings";return n?{...n,iconName:r,key:t}:{label:t.replace(/_/g," ").replace(/\b\w/g,o=>o.toUpperCase()),icon:"⚙",iconName:r,key:t}}function zo(e){return e==null?"":e<1e3?`${e}ms`:`${(e/1e3).toFixed(1)}s`}function pV(e){const t=new Date(e);if(isNaN(t.getTime()))return e;const n=String(t.getMonth()+1).padStart(2,"0"),r=String(t.getDate()).padStart(2,"0"),o=String(t.getHours()).padStart(2,"0"),l=String(t.getMinutes()).padStart(2,"0"),u=String(t.getSeconds()).padStart(2,"0");return`${n}-${r} ${o}:${l}:${u}`}function Bp(e,t){return e.length<=t?e:e.slice(0,t)+"…"}function Y2(e){try{const t=JSON.parse(e);return JSON.stringify(t,null,2)}catch{return e}}function o3(e){return!e||typeof e!="object"?[]:Object.entries(e).filter(([,n])=>n!=null).map(([n,r])=>({key:n,value:typeof r=="string"?r:JSON.stringify(r,null,2)}))}function gV(e){if(e.tool!=="shell_execute"||!e.args||typeof e.args!="object")return null;const t=e.args.command;return typeof t=="string"?t:null}function kW(e,t){const n=new Map;let r=null;for(const o of e)if(o.type==="tool_start"&&(o.content==="spawn_subagent"||o.content==="spawn_subagents"))r=o.seq,n.set(o.seq,[]);else if(o.type==="tool_end"&&(o.content==="spawn_subagent"||o.content==="spawn_subagents")){if(r!==null){const l=n.get(r);l&&n.set(o.seq,l)}r=null}else if(r!==null&&o.type.startsWith("subagent_")){const l=o.type.replace("subagent_",""),u=o.metadata;n.get(r)?.push({eventType:l,content:o.content,metadata:u})}return t.map(o=>{if(o.type!=="tool")return o;const l=o.key;if(!l)return o;const u=l.replace(/^(?:t[se]_|e[se]_)/,""),d=parseInt(u,10);if(isNaN(d))return o;const m=n.get(d);return!m||m.length===0?o:{...o,info:{...o.info,subagentLogs:m}}})}function X2(e){const t=new Set;for(let n=0;n<e.length;n++){const r=e[n];if(r.type==="tool"&&(r.info.status==="done"||r.info.status==="error"))for(let o=n-1;o>=0;o--){const l=e[o];if(l.type==="tool"&&l.info.status==="running"&&l.info.tool===r.info.tool&&!t.has(o)){t.add(o);break}}}return e.filter((n,r)=>!t.has(r))}function l3(e){const t=pV(e.createdAt),n=e.createdAt,r=e.metadata;switch(e.type){case"text":return r?.isThinking?{type:"thinking",content:e.content,time:t,timestamp:n}:{type:"text",content:e.content,time:t,timestamp:n};case"status":{const o=r?.action;return o&&["chat","chat_stream","task_execution","respond_in_session"].includes(o)?null:{type:"status",content:e.content,time:t,timestamp:n}}case"error":return{type:"error",content:e.content,time:t,timestamp:n};case"tool_start":return{type:"tool",time:t,timestamp:n,key:`es_${e.seq}`,info:{tool:e.content,status:"running",args:r?.arguments,subagentLogs:r?.subagentLogs}};case"tool_end":return{type:"tool",time:t,timestamp:n,key:`ee_${e.seq}`,info:{tool:e.content,status:r?.success===!1?"error":"done",args:r?.arguments,result:r?.result,error:r?.error,durationMs:r?.durationMs,subagentLogs:r?.subagentLogs}};default:return null}}function c3(e,t){if(e!=="task_create"&&e!=="create_task"||!t)return null;try{const n=JSON.parse(t);if(!n.task)return null;const r=n.task;return{taskId:r.id,title:r.title,description:r.description,assignedAgentId:r.assignedAgentId,priority:r.priority}}catch{return null}}function u3(e,t){if(e!=="requirement_propose"||!t)return null;try{const n=JSON.parse(t);if(n.status!=="success"||!n.requirement)return null;const r=n.requirement;return r.status!=="pending"?null:{requirementId:r.id,title:r.title,description:r.description,priority:r.priority}}catch{return null}}const d3={code:s.jsxs(s.Fragment,{children:[s.jsx("polyline",{points:"16 18 22 12 16 6"}),s.jsx("polyline",{points:"8 6 2 12 8 18"})]}),search:s.jsxs(s.Fragment,{children:[s.jsx("circle",{cx:"11",cy:"11",r:"8"}),s.jsx("path",{d:"m21 21-4.3-4.3"})]}),clipboard:s.jsxs(s.Fragment,{children:[s.jsx("rect",{width:"8",height:"4",x:"8",y:"2",rx:"1",ry:"1"}),s.jsx("path",{d:"M16 4h2a2 2 0 0 1 2 2v14a2 2 0 0 1-2 2H6a2 2 0 0 1-2-2V6a2 2 0 0 1 2-2h2"})]}),"check-circle":s.jsxs(s.Fragment,{children:[s.jsx("circle",{cx:"12",cy:"12",r:"10"}),s.jsx("path",{d:"m9 12 2 2 4-4"})]}),server:s.jsxs(s.Fragment,{children:[s.jsx("rect",{width:"20",height:"8",x:"2",y:"2",rx:"2",ry:"2"}),s.jsx("rect",{width:"20",height:"8",x:"2",y:"14",rx:"2",ry:"2"}),s.jsx("line",{x1:"6",x2:"6.01",y1:"6",y2:"6"}),s.jsx("line",{x1:"6",x2:"6.01",y1:"18",y2:"18"})]}),"file-text":s.jsxs(s.Fragment,{children:[s.jsx("path",{d:"M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7Z"}),s.jsx("path",{d:"M14 2v4a2 2 0 0 0 2 2h4"}),s.jsx("path",{d:"M10 9H8"}),s.jsx("path",{d:"M16 13H8"}),s.jsx("path",{d:"M16 17H8"})]}),"book-open":s.jsxs(s.Fragment,{children:[s.jsx("path",{d:"M12 7v14"}),s.jsx("path",{d:"M3 18a1 1 0 0 1-1-1V4a1 1 0 0 1 1-1h5a4 4 0 0 1 4 4 4 4 0 0 1 4-4h5a1 1 0 0 1 1 1v13a1 1 0 0 1-1 1h-6a3 3 0 0 0-3 3 3 3 0 0 0-3-3z"})]}),users:s.jsxs(s.Fragment,{children:[s.jsx("path",{d:"M16 21v-2a4 4 0 0 0-4-4H6a4 4 0 0 0-4 4v2"}),s.jsx("circle",{cx:"9",cy:"7",r:"4"}),s.jsx("path",{d:"M22 21v-2a4 4 0 0 0-3-3.87"}),s.jsx("path",{d:"M16 3.13a4 4 0 0 1 0 7.75"})]}),"dollar-sign":s.jsxs(s.Fragment,{children:[s.jsx("line",{x1:"12",x2:"12",y1:"2",y2:"22"}),s.jsx("path",{d:"M17 5H9.5a3.5 3.5 0 0 0 0 7h5a3.5 3.5 0 0 1 0 7H6"})]}),megaphone:s.jsxs(s.Fragment,{children:[s.jsx("path",{d:"m3 11 18-5v12L3 14v-3z"}),s.jsx("path",{d:"M11.6 16.8a3 3 0 1 1-5.8-1.6"})]}),edit:s.jsxs(s.Fragment,{children:[s.jsx("path",{d:"M12 20h9"}),s.jsx("path",{d:"M16.5 3.5a2.121 2.121 0 0 1 3 3L7 19l-4 1 1-4Z"})]}),headphones:s.jsx(s.Fragment,{children:s.jsx("path",{d:"M3 14h3a2 2 0 0 1 2 2v3a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-5a9 9 0 0 1 18 0v5a2 2 0 0 1-2 2h-1a2 2 0 0 1-2-2v-3a2 2 0 0 1 2-2h3"})}),settings:s.jsxs(s.Fragment,{children:[s.jsx("path",{d:"M12.22 2h-.44a2 2 0 0 0-2 2v.18a2 2 0 0 1-1 1.73l-.43.25a2 2 0 0 1-2 0l-.15-.08a2 2 0 0 0-2.73.73l-.22.38a2 2 0 0 0 .73 2.73l.15.1a2 2 0 0 1 1 1.72v.51a2 2 0 0 1-1 1.74l-.15.09a2 2 0 0 0-.73 2.73l.22.38a2 2 0 0 0 2.73.73l.15-.08a2 2 0 0 1 2 0l.43.25a2 2 0 0 1 1 1.73V20a2 2 0 0 0 2 2h.44a2 2 0 0 0 2-2v-.18a2 2 0 0 1 1-1.73l.43-.25a2 2 0 0 1 2 0l.15.08a2 2 0 0 0 2.73-.73l.22-.39a2 2 0 0 0-.73-2.73l-.15-.08a2 2 0 0 1-1-1.74v-.5a2 2 0 0 1 1-1.74l.15-.09a2 2 0 0 0 .73-2.73l-.22-.38a2 2 0 0 0-2.73-.73l-.15.08a2 2 0 0 1-2 0l-.43-.25a2 2 0 0 1-1-1.73V4a2 2 0 0 0-2-2z"}),s.jsx("circle",{cx:"12",cy:"12",r:"3"})]}),target:s.jsxs(s.Fragment,{children:[s.jsx("circle",{cx:"12",cy:"12",r:"10"}),s.jsx("circle",{cx:"12",cy:"12",r:"6"}),s.jsx("circle",{cx:"12",cy:"12",r:"2"})]}),zap:s.jsx(s.Fragment,{children:s.jsx("polygon",{points:"13 2 3 14 12 14 11 22 21 10 12 10 13 2"})}),terminal:s.jsxs(s.Fragment,{children:[s.jsx("polyline",{points:"4 17 10 11 4 5"}),s.jsx("line",{x1:"12",x2:"20",y1:"19",y2:"19"})]}),sparkles:s.jsxs(s.Fragment,{children:[s.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 .962 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-.962 0z"}),s.jsx("path",{d:"M20 3v4"}),s.jsx("path",{d:"M22 5h-4"})]}),wrench:s.jsx(s.Fragment,{children:s.jsx("path",{d:"M14.7 6.3a1 1 0 0 0 0 1.4l1.6 1.6a1 1 0 0 0 1.4 0l3.77-3.77a6 6 0 0 1-7.94 7.94l-6.91 6.91a2.12 2.12 0 0 1-3-3l6.91-6.91a6 6 0 0 1 7.94-7.94l-3.76 3.76z"})}),globe:s.jsxs(s.Fragment,{children:[s.jsx("circle",{cx:"12",cy:"12",r:"10"}),s.jsx("path",{d:"M12 2a14.5 14.5 0 0 0 0 20 14.5 14.5 0 0 0 0-20"}),s.jsx("path",{d:"M2 12h20"})]}),link:s.jsxs(s.Fragment,{children:[s.jsx("path",{d:"M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71"}),s.jsx("path",{d:"M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71"})]}),bot:s.jsxs(s.Fragment,{children:[s.jsx("path",{d:"M12 8V4H8"}),s.jsx("rect",{width:"16",height:"12",x:"4",y:"8",rx:"2"}),s.jsx("path",{d:"M2 14h2"}),s.jsx("path",{d:"M20 14h2"}),s.jsx("path",{d:"M15 13v2"}),s.jsx("path",{d:"M9 13v2"})]}),"message-square":s.jsx(s.Fragment,{children:s.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"})}),newspaper:s.jsxs(s.Fragment,{children:[s.jsx("path",{d:"M4 22h16a2 2 0 0 0 2-2V4a2 2 0 0 0-2-2H8a2 2 0 0 0-2 2v16a2 2 0 0 1-2 2Zm0 0a2 2 0 0 1-2-2v-9c0-1.1.9-2 2-2h2"}),s.jsx("path",{d:"M18 14h-8"}),s.jsx("path",{d:"M15 18h-5"}),s.jsx("path",{d:"M10 6h8v4h-8V6Z"})]}),layers:s.jsxs(s.Fragment,{children:[s.jsx("path",{d:"m12.83 2.18a2 2 0 0 0-1.66 0L2.6 6.08a1 1 0 0 0 0 1.83l8.58 3.91a2 2 0 0 0 1.66 0l8.58-3.9a1 1 0 0 0 0-1.83Z"}),s.jsx("path",{d:"m22 17.65-9.17 4.16a2 2 0 0 1-1.66 0L2 17.65"}),s.jsx("path",{d:"m22 12.65-9.17 4.16a2 2 0 0 1-1.66 0L2 12.65"})]}),"bar-chart":s.jsxs(s.Fragment,{children:[s.jsx("line",{x1:"12",x2:"12",y1:"20",y2:"10"}),s.jsx("line",{x1:"18",x2:"18",y1:"20",y2:"4"}),s.jsx("line",{x1:"6",x2:"6",y1:"20",y2:"16"})]}),folder:s.jsx(s.Fragment,{children:s.jsx("path",{d:"M20 20a2 2 0 0 0 2-2V8a2 2 0 0 0-2-2h-7.9a2 2 0 0 1-1.69-.9L9.6 3.9A2 2 0 0 0 7.93 3H4a2 2 0 0 0-2 2v13a2 2 0 0 0 2 2Z"})}),"git-branch":s.jsxs(s.Fragment,{children:[s.jsx("line",{x1:"6",x2:"6",y1:"3",y2:"15"}),s.jsx("circle",{cx:"18",cy:"6",r:"3"}),s.jsx("circle",{cx:"6",cy:"18",r:"3"}),s.jsx("path",{d:"M18 9a9 9 0 0 1-9 9"})]}),save:s.jsxs(s.Fragment,{children:[s.jsx("path",{d:"M15.2 3a2 2 0 0 1 1.4.6l3.8 3.8a2 2 0 0 1 .6 1.4V19a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2z"}),s.jsx("path",{d:"M17 21v-7a1 1 0 0 0-1-1H8a1 1 0 0 0-1 1v7"}),s.jsx("path",{d:"M7 3v4a1 1 0 0 0 1 1h7"})]}),camera:s.jsxs(s.Fragment,{children:[s.jsx("path",{d:"M14.5 4h-5L7 7H4a2 2 0 0 0-2 2v9a2 2 0 0 0 2 2h16a2 2 0 0 0 2-2V9a2 2 0 0 0-2-2h-3l-2.5-3z"}),s.jsx("circle",{cx:"12",cy:"13",r:"3"})]}),clock:s.jsxs(s.Fragment,{children:[s.jsx("circle",{cx:"12",cy:"12",r:"10"}),s.jsx("polyline",{points:"12 6 12 12 16 14"})]}),database:s.jsxs(s.Fragment,{children:[s.jsx("ellipse",{cx:"12",cy:"5",rx:"9",ry:"3"}),s.jsx("path",{d:"M3 5v14a9 3 0 0 0 18 0V5"}),s.jsx("path",{d:"M3 12a9 3 0 0 0 18 0"})]}),lightbulb:s.jsxs(s.Fragment,{children:[s.jsx("path",{d:"M15 14c.2-1 .7-1.7 1.5-2.5 1-.9 1.5-2.2 1.5-3.5A6 6 0 0 0 6 8c0 1 .2 2.2 1.5 3.5.7.7 1.3 1.5 1.5 2.5"}),s.jsx("path",{d:"M9 18h6"}),s.jsx("path",{d:"M10 22h4"})]}),"alert-circle":s.jsxs(s.Fragment,{children:[s.jsx("circle",{cx:"12",cy:"12",r:"10"}),s.jsx("line",{x1:"12",x2:"12",y1:"8",y2:"12"}),s.jsx("line",{x1:"12",x2:"12.01",y1:"16",y2:"16"})]}),"square-terminal":s.jsxs(s.Fragment,{children:[s.jsx("path",{d:"m7 11 2-2-2-2"}),s.jsx("path",{d:"M11 13h4"}),s.jsx("rect",{width:"18",height:"18",x:"3",y:"3",rx:"2"})]}),package:s.jsxs(s.Fragment,{children:[s.jsx("path",{d:"m7.5 4.27 9 5.15"}),s.jsx("path",{d:"M21 8a2 2 0 0 0-1-1.73l-7-4a2 2 0 0 0-2 0l-7 4A2 2 0 0 0 3 8v8a2 2 0 0 0 1 1.73l7 4a2 2 0 0 0 2 0l7-4A2 2 0 0 0 21 16Z"}),s.jsx("path",{d:"m3.3 7 8.7 5 8.7-5"}),s.jsx("path",{d:"M12 22V12"})]})};function bV(e){return!!e&&e in d3}function Ko({name:e,size:t=24,className:n=""}){const r=d3[e];return r?s.jsx("svg",{width:t,height:t,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round",className:n,"aria-hidden":!0,children:r}):null}const Q2={"coding-tools":"terminal",markitdown:"file-text","markus-admin-cli":"terminal",codex:"code","self-evolution":"sparkles","team-building":"users","claude-code":"code","skill-building":"wrench","workflow-building":"layers","chrome-devtools":"globe","markus-hub-connector":"link","cursor-agent":"bot","agent-building":"bot","feishu-interaction":"message-square","content-publishing":"edit","research-report":"book-open","daily-digest":"newspaper"},Z2={development:"code",开发工具:"code",devops:"server",data:"bar-chart",数据分析:"bar-chart",productivity:"zap",效率提升:"zap",communication:"message-square",通讯协作:"message-square",browser:"globe",内容创作:"edit","AI 智能":"sparkles"};function Dd(e,t){const n=(e||"").toLowerCase();return Q2[n]?Q2[n]:t&&Z2[t]?Z2[t]:"layers"}function xV(e){const t=[];for(const n of e)if(n.phase!=="output"){if(n.phase==="start"){const r=`${n.tool}_${n.ts}`;t.push({key:r,tool:n.tool,status:"running"})}else for(let r=t.length-1;r>=0;r--)if(t[r].tool===n.tool&&t[r].status==="running"){t[r]={...t[r],status:n.success===!1?"error":"done"};break}}return t}function m3(){return s.jsxs("svg",{className:"w-3 h-3 animate-spin text-brand-500 shrink-0",viewBox:"0 0 24 24",fill:"none",children:[s.jsx("circle",{className:"opacity-25",cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"4"}),s.jsx("path",{className:"opacity-75",fill:"currentColor",d:"M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4z"})]})}function yV(){return s.jsx("span",{className:"flex items-center gap-0.5",children:[0,150,300].map(e=>s.jsx("span",{className:"w-1 h-1 rounded-full bg-brand-400 animate-bounce",style:{animationDelay:`${e}ms`,animationDuration:"1s"}},e))})}function J2({item:e}){const{t}=ft("common"),n=Ci(e.tool);return s.jsxs("div",{className:"flex items-center gap-1.5 py-0.5",children:[s.jsx(Ko,{name:n.iconName,size:15,className:`shrink-0 ${e.status==="running"?"text-brand-500":e.status==="error"?"text-red-500":"text-green-500"}`}),s.jsxs("span",{className:`text-xs ${e.status==="running"?"activity-text-shimmer":e.status==="error"?"text-fg-tertiary":"text-fg-secondary"}`,children:[t(`execution.tools.${n.key}`,{defaultValue:n.label}),e.status==="running"?"…":""]}),e.status==="running"&&s.jsx(m3,{})]})}function vV({activities:e,isActive:t,persistent:n}){const{t:r}=ft("common"),o=xV(e),[l,u]=k.useState(!1),d=o.length>0,m=d&&o.every(w=>w.status!=="running");if(n&&m){const w=o.filter(T=>T.status==="error").length,N=o.filter(T=>T.status==="done").length;return s.jsxs("div",{className:"mb-3 border-b border-border-default/50 pb-2",children:[s.jsxs("button",{onClick:()=>u(T=>!T),className:"flex items-center gap-1.5 text-xs text-fg-tertiary hover:text-fg-secondary transition-colors select-none",children:[s.jsx("span",{className:`transition-transform duration-150 ${l?"rotate-90":""}`,children:"▶"}),s.jsx("span",{className:"font-medium",children:r("activity.step",{count:N})}),w>0&&s.jsxs("span",{className:"text-red-500 ml-0.5",children:["· ",r("activity.failed",{count:w})]}),!l&&s.jsxs("span",{className:"ml-1 flex items-center gap-1",children:[o.slice(0,5).map(T=>{const C=Ci(T.tool);return s.jsx(Ko,{name:C.iconName,size:13,className:`shrink-0 ${T.status==="error"?"text-red-500":"text-green-500"}`},T.key)}),o.length>5&&s.jsxs("span",{className:"text-[10px] text-fg-tertiary",children:["+",o.length-5]})]})]}),l&&s.jsx("div",{className:"mt-2 space-y-0.5",children:o.map((T,C)=>s.jsx(J2,{item:T,idx:C,total:o.length},T.key))})]})}if(!d)return s.jsxs("div",{className:"flex items-center gap-1.5 text-xs py-0.5",children:[s.jsx("span",{className:"mr-0.5 activity-text-shimmer",children:r("activity.thinking")}),s.jsx(yV,{})]});const h=o.filter(w=>w.status==="error").length;let p=null;for(let w=o.length-1;w>=0;w--)if(o[w].status==="running"){p=o[w];break}const g=o[o.length-1];let x;if(p){const w=Ci(p.tool);x=`${r(`execution.tools.${w.key}`,{defaultValue:w.label})}…`}else if(t&&m)x=r("activity.writingResponse");else{const w=Ci(g.tool);x=r(`execution.tools.${w.key}`,{defaultValue:w.label})}const y=!!p||t&&m;return s.jsxs("div",{className:"mb-1",children:[s.jsxs("button",{onClick:w=>{w.stopPropagation(),u(N=>!N)},className:"flex items-center gap-1.5 text-xs w-full min-w-0 select-none text-fg-tertiary hover:text-fg-secondary transition-colors",children:[s.jsx("span",{className:`shrink-0 transition-transform duration-150 ${l?"rotate-90":""}`,children:"▶"}),s.jsx("span",{className:`truncate font-medium ${y?"activity-text-shimmer":"text-fg-secondary"}`,children:x}),s.jsxs("span",{className:"shrink-0",children:["· ",r("activity.step",{count:o.length})]}),h>0&&s.jsxs("span",{className:"text-red-500 shrink-0",children:["· ",r("activity.failed",{count:h})]}),y&&s.jsx(m3,{})]}),l&&s.jsx("div",{className:"mt-1 space-y-0.5",children:o.map((w,N)=>s.jsx(J2,{item:w,idx:N,total:o.length},w.key))})]})}const wV={"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"}},Ro=["created","context_injected","running"],kV=new Set(["completed","failed","cancelled","timeout"]),e4={created:"Created",context_injected:"Context injected",running:"Running",completed:"Completed",failed:"Failed",cancelled:"Cancelled",timeout:"Timed out"};function SV(e){return wV[e]??{label:e.replace(/-/g," ").replace(/\b\w/g,t=>t.toUpperCase()),icon:"⚙",badgeClass:"bg-surface-elevated text-fg-tertiary"}}function NV(e,t){if(e.cost?.durationMs!=null)return e.cost.durationMs;const n=e.startedAt??e.createdAt,r=new Date(n).getTime();if(!Number.isNaN(r)){if(e.completedAt){const o=new Date(e.completedAt).getTime();return Number.isNaN(o)?void 0:Math.max(0,o-r)}if(e.status==="running"||e.status==="context_injected")return Math.max(0,t-r)}}function CV(e){if(e==="completed"||kV.has(e))return Ro.length;const t=Ro.indexOf(e);return t>=0?t:0}function TV({session:e,className:t}){const n=SV(e.tool),[r,o]=k.useState(!1),[l,u]=k.useState(()=>Date.now()),d=e.status==="running"||e.status==="context_injected"||e.status==="created",m=e.status==="failed"||e.status==="timeout"||e.result?.success===!1,h=e.status==="completed"||e.result?.success===!0;k.useEffect(()=>{if(!d)return;const w=setInterval(()=>u(Date.now()),1e3);return()=>clearInterval(w)},[d]);const p=k.useMemo(()=>NV(e,l),[e,l]),g=CV(e.status),x=e.result?.rawOutput??(h||m?e.result?.summary:void 0),y=d?"border-brand-500/40 bg-brand-500/5":m?"border-red-500/30 bg-red-500/5":h?"border-green-500/30 bg-green-500/5":"border-border-default bg-surface-secondary/30";return s.jsxs("div",{className:`my-2 rounded-lg border ${y} p-3 max-w-2xl transition-colors ${t??""}`,children:[s.jsxs("div",{className:"flex items-start gap-2",children:[s.jsx("span",{className:"text-sm mt-0.5",children:n.icon}),s.jsxs("div",{className:"flex-1 min-w-0",children:[s.jsxs("div",{className:"flex items-center gap-1.5 flex-wrap",children:[s.jsx("span",{className:`text-[10px] px-1.5 py-0.5 rounded font-medium ${n.badgeClass}`,children:n.label}),s.jsx("span",{className:`text-[10px] font-medium ${d?"text-brand-500":m?"text-red-500":h?"text-green-500":"text-fg-tertiary"}`,children:e4[e.status]??e.status}),p!=null&&s.jsx("span",{className:"text-[10px] text-fg-tertiary tabular-nums",children:zo(p)}),e.cost?.estimatedCostUsd!=null&&s.jsxs("span",{className:"text-[10px] text-fg-tertiary tabular-nums",children:["$",e.cost.estimatedCostUsd.toFixed(4)]})]}),s.jsx("div",{className:"text-xs text-fg-secondary mt-1 line-clamp-2",children:e.prompt})]}),d&&s.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:[s.jsx("circle",{className:"opacity-25",cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"4"}),s.jsx("path",{className:"opacity-75",fill:"currentColor",d:"M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4z"})]})]}),s.jsxs("div",{className:"flex items-center gap-1 mt-3 ml-6",children:[Ro.map((w,N)=>{const T=g>N||g===N&&!d&&h,C=g===N&&d,j=m&&N===Ro.length-1&&e.status!=="completed";return s.jsxs("div",{className:"flex items-center gap-1 flex-1 min-w-0",children:[s.jsx("div",{className:`w-2 h-2 rounded-full shrink-0 ${j?"bg-red-500":T?"bg-green-500":C?"bg-brand-500 animate-pulse":"bg-gray-600"}`,title:e4[w]}),N<Ro.length-1&&s.jsx("div",{className:`h-px flex-1 ${T?"bg-green-500/50":"bg-border-default/60"}`})]},w)}),s.jsx("div",{className:`w-2 h-2 rounded-full shrink-0 ${m?"bg-red-500":h?"bg-green-500":"bg-gray-600"}`,title:m?"Failed":"Done"})]}),(e.progressMessage||e.progressPercent!=null)&&d&&s.jsxs("div",{className:"mt-2 ml-6 space-y-1",children:[e.progressPercent!=null&&s.jsx("div",{className:"h-1 bg-surface-elevated rounded-full overflow-hidden",children:s.jsx("div",{className:"h-full bg-brand-500 transition-all duration-300",style:{width:`${Math.min(100,Math.max(0,e.progressPercent))}%`}})}),e.progressMessage&&s.jsx("div",{className:"text-[11px] text-fg-tertiary font-mono truncate",children:e.progressMessage})]}),e.result&&!d&&s.jsxs("div",{className:"mt-2 ml-6 space-y-1.5",children:[e.result.summary&&s.jsx("div",{className:"text-xs text-fg-secondary",children:e.result.summary}),e.result.diffStats&&s.jsxs("div",{className:"flex items-center gap-3 text-[10px] font-mono",children:[s.jsxs("span",{className:"text-fg-tertiary",children:[e.result.diffStats.filesChanged," files"]}),s.jsxs("span",{className:"text-green-500",children:["+",e.result.diffStats.additions]}),s.jsxs("span",{className:"text-red-500",children:["−",e.result.diffStats.deletions]})]}),e.cost&&(e.cost.inputTokens!=null||e.cost.outputTokens!=null)&&s.jsxs("div",{className:"text-[10px] text-fg-tertiary",children:[e.cost.inputTokens!=null&&s.jsxs("span",{children:[e.cost.inputTokens.toLocaleString()," in"]}),e.cost.inputTokens!=null&&e.cost.outputTokens!=null&&s.jsx("span",{className:"mx-1",children:"·"}),e.cost.outputTokens!=null&&s.jsxs("span",{children:[e.cost.outputTokens.toLocaleString()," out"]})]})]}),x&&s.jsxs("div",{className:"mt-2 ml-6 border-t border-border-default/30 pt-2",children:[s.jsxs("button",{type:"button",onClick:()=>o(!r),className:"flex items-center gap-1.5 text-[10px] text-fg-tertiary hover:text-fg-secondary transition-colors",children:[s.jsx("svg",{className:`w-3 h-3 transition-transform ${r?"rotate-90":""}`,fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:s.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M9 5l7 7-7 7"})}),s.jsx("span",{className:"font-medium uppercase tracking-wider",children:"Raw output"})]}),r&&s.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:x})]})]})}function EV({label:e}){const{t}=ft("common");return s.jsxs("div",{className:"flex items-center gap-1.5 text-xs py-0.5",children:[s.jsx("span",{className:"activity-text-shimmer",children:e??t("execution.thinking")}),s.jsx("span",{className:"flex gap-0.5",children:[0,150,300].map(n=>s.jsx("span",{className:"w-1 h-1 rounded-full bg-brand-400 animate-bounce",style:{animationDelay:`${n}ms`,animationDuration:"1s"}},n))})]})}const t4=150;function AV({content:e,className:t}){const[n,r]=k.useState(e),o=k.useRef(0),l=k.useRef(null);k.useEffect(()=>{const d=Date.now(),m=d-o.current;return m>=t4?(o.current=d,r(e)):l.current||(l.current=setTimeout(()=>{o.current=Date.now(),l.current=null,r(e)},t4-m)),()=>{l.current&&(clearTimeout(l.current),l.current=null)}},[e]);const u=k.useMemo(()=>n,[n]);return s.jsxs("div",{className:"bg-surface-elevated/50 rounded-lg px-3 py-2.5 my-1 min-w-0 overflow-hidden",children:[s.jsx(Ar,{content:u,className:t??"text-sm text-fg-secondary break-words"}),s.jsx("span",{className:"inline-block w-0.5 h-4 bg-brand-400 animate-pulse ml-0.5 align-middle"})]})}const l0=8e3,pd=120;function Fh({text:e,className:t}){const{t:n}=ft("common"),[r,o]=k.useState(!1),l=e.length>l0,u=!l||r?e:`${e.slice(0,l0)}
@@ -654,7 +654,7 @@ https://github.com/highlightjs/highlight.js/issues/2277`),Rn=ze,nn=vt),Ut===void
654
654
  `)[0]]}),m&&s.jsx("span",{className:"text-[10px] text-fg-tertiary shrink-0 opacity-60",children:r("execution.toolSteps",{count:e.subagentLogs.filter(_=>_.eventType==="tool_end").length})})]}),e.liveOutput&&e.status==="running"&&s.jsx("pre",{ref:T,className:"mt-1 font-mono text-[11px] text-fg-tertiary bg-surface-secondary/60 rounded px-2 py-1.5 max-h-32 overflow-y-auto overflow-x-hidden whitespace-pre-wrap break-all",children:e.liveOutput.length>l0?e.liveOutput.slice(e.liveOutput.length-l0):e.liveOutput}),!h&&d&&e.status==="running"&&C&&s.jsx("div",{className:"mt-1 ml-[23px] font-mono text-[11px] text-fg-tertiary truncate",title:C,children:C}),h&&j&&s.jsx("div",{className:"mt-1 ml-[23px] border-l-2 border-border-default/60 pl-3 max-h-80 overflow-y-auto overflow-x-hidden",children:s.jsx(_V,{info:e,time:t})})]}),l&&!n&&(()=>{const _=c3(e.tool,e.result);if(_)return s.jsx(h3,{info:_});const O=u3(e.tool,e.result);return O?s.jsx(p3,{info:O}):null})()]})}function LV({content:e,time:t,defaultExpanded:n}){const{t:r}=ft("common"),[o,l]=k.useState(n??!1);return k.useEffect(()=>{n&&l(!0)},[n]),s.jsxs("div",{className:"min-w-0 py-0.5 overflow-hidden",children:[s.jsxs("button",{onClick:()=>{bc(),l(u=>!u)},className:"flex items-center gap-2 text-xs w-full min-w-0",children:[s.jsx(Ko,{name:"sparkles",size:15,className:"shrink-0 text-violet-400"}),s.jsx("span",{className:`shrink-0 ${n?"activity-text-shimmer":"text-fg-secondary"}`,children:r("execution.thinking")}),s.jsx("svg",{className:`w-3 h-3 shrink-0 text-fg-tertiary transition-transform ${o?"rotate-90":""}`,fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:s.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M9 5l7 7-7 7"})}),o&&t&&s.jsx("span",{className:"ml-auto shrink-0 text-[10px] text-fg-tertiary tabular-nums",children:t})]}),o&&s.jsx("div",{className:"mt-1.5 ml-[23px] border-l-2 border-border-default/60 pl-3 overflow-hidden",children:s.jsx(Ar,{content:e,className:"text-xs text-fg-tertiary break-words"})})]})}const i4=k.memo(IV);function IV({entry:e,showTime:t,isLast:n,defaultThinkingExpanded:r,hideApprovalCards:o}){const{t:l}=ft("common");if(e.type==="tool")return s.jsx(DV,{info:e.info,showTime:t,time:e.time,isLast:n,hideApprovalCards:o},e.key);if(e.type==="thinking")return s.jsx(LV,{content:e.content,time:e.time,showTime:t,defaultExpanded:r});if(e.type==="text")return e.content.startsWith("⚠")?s.jsx("div",{className:"min-w-0 pl-[23px] pr-1 overflow-hidden",children:s.jsx("p",{className:"text-[13px] text-fg-tertiary leading-relaxed whitespace-pre-wrap break-words",children:e.content.replace(/^⚠\s*/,"")})}):s.jsx("div",{className:"min-w-0 pl-[23px] pr-1 overflow-hidden",children:s.jsx(Ar,{content:e.content,className:"text-sm text-fg-secondary break-words"})});if(e.type==="status"){const u=e.content==="completed"||e.content==="execution_finished",d=e.content==="started",m=e.content==="resumed",h=u?"text-green-600":d?"text-blue-600":m?"text-amber-600":"text-fg-tertiary",p=u?"bg-green-400":d?"bg-blue-400":m?"bg-amber-400":"bg-gray-500";return s.jsxs("div",{className:"flex items-center gap-2 py-0.5 min-w-0",children:[s.jsx("span",{className:"w-[15px] flex justify-center shrink-0",children:s.jsx("span",{className:`w-1.5 h-1.5 rounded-full ${p}`})}),s.jsx("span",{className:`text-xs capitalize ${h}`,children:l(`execution.statusKnown.${e.content}`,{defaultValue:e.content})})]})}return e.type==="error"?s.jsxs("div",{className:"flex items-start gap-2 py-0.5 min-w-0",children:[s.jsx(Ko,{name:"alert-circle",size:15,className:"shrink-0 mt-0.5 text-fg-tertiary"}),s.jsxs("span",{className:"text-xs text-fg-tertiary leading-relaxed break-words min-w-0",children:[s.jsx("span",{className:"font-medium",children:l("execution.errorPrefix")})," ",e.content.replace(/^⚠\s*/,"")]})]}):null}function SW({entries:e,streamingText:t,isActive:n,onExpand:r,showRounds:o,embedded:l}){const{t:u}=ft("common"),d=e.length>0?e[e.length-1]:null,m=e.filter(O=>O.type==="tool_end").length,h=e.filter(O=>O.type==="error").length,p=e.length>0?new Date(e[0].createdAt).getTime():Date.now(),g=d?new Date(d.createdAt).getTime():Date.now(),x=n?Date.now()-p:g-p,y=new Set(e.filter(O=>O.executionRound!=null).map(O=>O.executionRound)),w=y.size>0?Math.max(...y):void 0,N=o&&y.size>1;let T,C,j=null;if(n)if(t)T="✍",C=u("execution.compact.writingResponse"),j=Bp(t.split(`
655
655
  `).pop()??"",80);else if(d?.type==="tool_start"){const O=Ci(d.content);T=O.icon,C=`${u(`execution.tools.${O.key}`,{defaultValue:O.label})}...`;const z=d.metadata?.arguments&&typeof d.metadata.arguments=="object"?d.metadata.arguments.command:void 0;z&&(j=`$ ${Bp(z.split(`
656
656
  `)[0]??"",80)}`)}else if(d?.type==="tool_end"){const O=Ci(d.content);T=O.icon,C=u(`execution.tools.${O.key}`,{defaultValue:O.label})}else T="💭",C=u("execution.compact.thinking");else if(h>0&&d?.type==="error")T="❌",C=u("execution.compact.failed");else{const z=[...e].reverse().find(D=>D.type==="status")?.content??"";z==="completed"||z==="execution_finished"?(T="✅",C=u("execution.compact.completed")):(T="●",C=u("execution.compact.toolsExecuted",{count:m}))}const _=zo(x);return s.jsx("div",{onClick:()=>{bc(),r()},className:`overflow-hidden transition-all cursor-pointer min-w-0 ${l?"hover:bg-surface-elevated/20":`rounded-lg border hover:brightness-110 ${n?"border-2 exec-card-active":"border border-border-default bg-surface-elevated/30 hover:border-brand-500/40"}`}`,children:s.jsxs("div",{className:l?"py-2":"px-3 py-2.5 bg-surface-primary/80",children:[s.jsxs("div",{className:"flex items-center justify-between gap-2",children:[s.jsxs("div",{className:"flex items-center gap-2 min-w-0 flex-1",children:[n?s.jsxs("svg",{className:"w-3.5 h-3.5 animate-spin text-brand-500 shrink-0",viewBox:"0 0 24 24",fill:"none",children:[s.jsx("circle",{className:"opacity-25",cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"4"}),s.jsx("path",{className:"opacity-75",fill:"currentColor",d:"M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4z"})]}):s.jsx("span",{className:"text-sm shrink-0",children:T}),s.jsx("span",{className:`text-xs font-medium truncate ${n?"text-fg-primary":"text-fg-secondary"}`,children:C})]}),_&&s.jsx("span",{className:"text-[10px] text-fg-tertiary tabular-nums shrink-0",children:_})]}),t?s.jsx("div",{className:`mt-1.5 ml-5.5 text-xs text-fg-secondary whitespace-pre-wrap break-words leading-relaxed ${l&&n?"":"max-h-32 overflow-y-auto"}`,children:s.jsx(Ar,{content:t,className:"text-xs"})}):j?s.jsx("div",{className:"mt-1 ml-5.5 text-[11px] font-mono text-fg-tertiary truncate",children:j}):null,s.jsxs("div",{className:"flex items-center justify-between mt-2",children:[s.jsxs("div",{className:"flex items-center gap-2 text-[10px] text-fg-tertiary",children:[m>0&&s.jsxs("span",{children:["🔧 ",u("execution.compact.toolsLine",{count:m})]}),e.some(O=>O.type==="text"&&!O.metadata?.isThinking)&&s.jsxs("span",{children:["💬 ",u("execution.compact.text")]}),e.some(O=>O.type==="text"&&O.metadata?.isThinking)&&s.jsxs("span",{className:"text-purple-400",children:["💭 ",u("execution.compact.thinkingTag")]}),N&&w!=null&&s.jsxs(s.Fragment,{children:[s.jsx("span",{className:"opacity-30",children:"·"}),s.jsx("span",{children:u("execution.compact.round",{n:w})}),s.jsx("span",{className:"opacity-30",children:"·"}),s.jsx("span",{children:u("execution.compact.rounds",{count:y.size})})]})]}),s.jsxs("span",{className:"text-[10px] text-brand-500 flex items-center gap-0.5",children:[u("execution.compact.showFullLog"),s.jsx("svg",{className:"w-3 h-3",viewBox:"0 0 20 20",fill:"currentColor",children:s.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"})})]})]})]})})}function PV(e){const t=new Map;for(const n of e){const r=n.executionRound??1;t.has(r)||t.set(r,[]);const o=l3(n);o&&t.get(r).push(o)}return Array.from(t.entries()).sort(([n],[r])=>n-r).map(([n,r])=>({round:n,entries:r}))}function zV({entries:e,streamingText:t,isActive:n,onCollapse:r,showRounds:o,embedded:l,expandThinking:u,hideApprovalCards:d}){const{t:m}=ft("common"),h=k.useRef(null),[p,g]=k.useState(new Set),x=PV(e),y=o&&x.length>1;k.useEffect(()=>{x.length>0&&g(C=>{const j=new Set(C);return j.add(x[x.length-1].round),j})},[x.length]),k.useEffect(()=>{l||!h.current||!n||(h.current.scrollTop=h.current.scrollHeight)},[e.length,t,n,l]);const w=C=>{bc(),g(j=>{const _=new Set(j);return _.has(C)?_.delete(C):_.add(C),_})},N=y?null:e.map(l3).filter(C=>C!==null),T=N?X2(N):null;return s.jsxs("div",{className:`min-w-0 overflow-hidden ${l?"":"rounded-lg border border-border-default bg-surface-primary/50"}`,children:[r&&s.jsxs("div",{onClick:()=>{bc(),r()},className:`flex items-center cursor-pointer hover:bg-surface-elevated/40 transition-colors ${l?"justify-end py-0.5":"justify-between px-3 py-1.5 border-b border-border-default"}`,children:[!l&&s.jsx("span",{className:"text-[10px] text-fg-tertiary font-medium uppercase tracking-wider",children:m("execution.fullLog.title")}),s.jsxs("span",{className:"text-[10px] text-brand-500 flex items-center gap-0.5",children:[m("execution.fullLog.collapse"),s.jsx("svg",{className:"w-3 h-3 rotate-180",viewBox:"0 0 20 20",fill:"currentColor",children:s.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"})})]})]}),s.jsxs("div",{ref:l?void 0:h,className:`space-y-2.5 min-w-0 overflow-x-hidden ${l?"py-1":"px-3 py-2 max-h-[60vh] overflow-y-auto scrollbar-thin"}`,children:[y?x.map(C=>{const j=p.has(C.round),_=X2(C.entries),O=C.entries.filter(z=>z.type==="tool"&&z.info?.status!=="running").length;return s.jsxs("div",{className:"border border-border-default/50 rounded-lg mb-2 overflow-hidden",children:[s.jsxs("button",{onClick:()=>w(C.round),className:"w-full flex items-center justify-between px-3 py-1.5 bg-surface-elevated/30 hover:bg-surface-elevated/50 transition-colors",children:[s.jsx("span",{className:"text-xs text-fg-secondary font-medium",children:m("execution.compact.round",{n:C.round})}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("span",{className:"text-[10px] text-fg-tertiary",children:m("execution.compact.toolsLine",{count:O})}),s.jsx("svg",{className:`w-3 h-3 text-fg-tertiary transition-transform ${j?"rotate-180":""}`,viewBox:"0 0 20 20",fill:"currentColor",children:s.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"})})]})]}),j&&s.jsx("div",{className:"px-3 py-1.5 space-y-2.5",children:_.map((z,D)=>s.jsx(i4,{entry:z,showTime:!1,isLast:D===_.length-1,defaultThinkingExpanded:!!u,hideApprovalCards:d},D))})]},C.round)}):T&&T.map((C,j)=>s.jsx(i4,{entry:C,showTime:!1,isLast:j===T.length-1,defaultThinkingExpanded:!!u,hideApprovalCards:d},j)),n&&t&&s.jsx(AV,{content:t}),n&&!t&&s.jsx(EV,{})]})]})}function NW({priority:e}){const t=e==="high"||e==="critical";return s.jsxs("div",{className:`inline-flex items-center gap-1 mt-1.5 px-2 py-0.5 rounded-full text-[10px] font-medium ${t?"bg-amber-500/10 text-amber-500 border border-amber-500/20":"bg-brand-500/10 text-brand-400 border border-brand-500/20"}`,children:[s.jsxs("svg",{className:"w-3 h-3",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[s.jsx("path",{d:"M18 8A6 6 0 0 0 6 8c0 7-3 9-3 9h18s-3-2-3-9"}),s.jsx("path",{d:"M13.73 21a2 2 0 0 1-3.46 0"})]}),s.jsxs("span",{children:["Notification",e&&e!=="normal"?` · ${e}`:""]})]})}function CW({name:e,agentId:t,agents:n,onViewProfile:r}){const{t:o}=ft(["team","common"]),[l,u]=k.useState(!1),d=k.useRef(null),m=t?n.find(h=>h.id===t):n.find(h=>h.name===e);return k.useEffect(()=>{if(!l)return;const h=p=>{d.current&&!d.current.contains(p.target)&&u(!1)};return document.addEventListener("mousedown",h),()=>document.removeEventListener("mousedown",h)},[l]),m?s.jsxs("span",{ref:d,className:"relative inline-block",children:[s.jsx("button",{onClick:()=>u(!l),className:"text-fg-tertiary hover:text-brand-500 cursor-pointer transition-colors",children:e}),l&&s.jsxs("div",{className:"absolute left-0 top-full mt-1.5 bg-surface-secondary border border-border-default rounded-xl shadow-2xl z-40 w-56 p-3 space-y-2",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(Us,{name:m.name,avatarUrl:m.avatarUrl,size:28,bgClass:"bg-brand-500/15 text-brand-600"}),s.jsxs("div",{className:"flex-1 min-w-0",children:[s.jsx("div",{className:"text-xs text-fg-primary font-medium truncate",children:m.name}),s.jsxs("div",{className:"text-[10px] text-fg-tertiary",children:[m.role," · ",m.agentRole??o("page.workerRole")]})]}),s.jsx("span",{className:`w-2 h-2 rounded-full shrink-0 ${m.status==="working"?"bg-blue-400 animate-pulse":m.status==="error"?"bg-red-400":"bg-green-400"}`})]}),s.jsx("button",{onClick:()=>{u(!1),r?.(m.id)},className:"w-full text-center text-[10px] text-brand-500 hover:text-brand-500 border border-border-default hover:border-gray-600 rounded-lg py-1 transition-colors",children:o("page.viewProfileArrow")})]})]}):s.jsx("span",{children:e})}function TW({agent:e,anchorRect:t,onClose:n,onViewProfile:r}){const{t:o}=ft(["common","team"]),l=k.useRef(null);k.useEffect(()=>{const h=p=>{l.current&&!l.current.contains(p.target)&&n()};return document.addEventListener("mousedown",h),()=>document.removeEventListener("mousedown",h)},[n]);const u=e.status==="idle"?"bg-green-400":e.status==="working"?"bg-blue-400 animate-pulse":e.status==="error"?"bg-red-400":"bg-gray-500",d=e.status==="idle"?o("common:status.online"):e.status==="working"?o("common:status.working"):e.status==="error"?o("common:status.error"):o("common:status.offline"),m=k.useCallback(h=>{if(!h)return;l.current=h;const p=h.getBoundingClientRect(),g=window.innerWidth,x=window.innerHeight,y=8;p.right>g-y&&(h.style.left=`${Math.max(y,g-p.width-y)}px`),p.left<y&&(h.style.left=`${y}px`),p.bottom>x-y&&(h.style.top=`${Math.max(y,x-p.height-y)}px`)},[]);return s.jsxs("div",{ref:m,className:"fixed z-50 w-64 max-w-[calc(100vw-1rem)] bg-surface-secondary border border-border-default rounded-xl shadow-2xl p-4 space-y-3",style:{top:t.top+40,left:t.left},children:[s.jsxs("div",{className:"flex items-center gap-3",children:[s.jsx(Us,{name:e.name,avatarUrl:e.avatarUrl,size:40,bgClass:"bg-brand-500/15 text-brand-600"}),s.jsxs("div",{className:"flex-1 min-w-0",children:[s.jsx("div",{className:"text-sm text-fg-primary font-medium truncate",children:e.name}),s.jsx("div",{className:"text-[11px] text-fg-tertiary",children:e.role}),s.jsxs("div",{className:"flex items-center gap-1.5 mt-0.5",children:[s.jsx("span",{className:`w-1.5 h-1.5 rounded-full ${u}`}),s.jsx("span",{className:"text-[10px] text-fg-secondary",children:d}),e.agentRole&&s.jsxs("span",{className:"text-[10px] text-fg-tertiary",children:["· ",e.agentRole]})]})]})]}),s.jsx("button",{onClick:()=>{n(),r(e.id)},className:"w-full py-1.5 text-xs text-brand-500 hover:text-brand-500 border border-border-default hover:border-gray-600 rounded-lg transition-colors text-center",children:o("team:page.viewProfileArrow")})]})}function BV(e){const t=String(e);return t.includes("MARKUS_UPSTREAM_ERROR")?!1:t.includes("CU_EXCEEDED")||t.includes("CU_MONTHLY_EXCEEDED")}const g3="markus:credit-notif-muted";let o4=0;function EW(){try{if(localStorage.getItem(g3))return}catch{}const e=Date.now();e-o4<5*6e4||(o4=e,window.dispatchEvent(new CustomEvent("markus:credit-exhausted")))}function UV(){try{localStorage.setItem(g3,"1")}catch{}}function AW(e,t){const n=String(e);if(n.includes("AbortError")||n.includes("abort"))return"";let r="";const o=n.match(/\{[\s\S]*\}/);if(o)try{const d=JSON.parse(o[0]);r=d.error?.message??d.message??""}catch{}if(!r){const d=n.lastIndexOf(": ");d>=0&&(r=n.slice(d+2).trim())}const l=(d,m)=>t(`team:errors.${d}`,m);if(n.includes("MARKUS_UPSTREAM_ERROR"))return l("aiUpstreamBillingMismatch",{detail:r||l("defaultUpstreamBillingMismatch")});if(BV(n)||n.includes("CU_EXCEEDED"))return l("markusCuExceeded");if(n.includes("CU_WINDOW_EXCEEDED"))return l("markusWindowExceeded");if(n.includes("MARKUS_RATE_LIMITED"))return l("markusRateLimited");if(/not available in your region/i.test(n))return l("aiRegionBlocked",{model:(n.match(/\[(?:markus|openrouter):([^\]]+)\]/i)?.[1]||"").trim()||"—"});if(n.includes("401")||/unauthorized|invalid.?api.?key/i.test(n))return l("ai401",{detail:r||l("defaultInvalidApiKey")});if(n.includes("429")||/rate.?limit/i.test(n))return l("ai429",{detail:r||l("defaultTooManyRequests")});if(/\b409\b/.test(n)||/conflict/i.test(n))return l("ai409",{detail:r||l("defaultConflict")});if(n.includes("502")||/bad.?gateway/i.test(n))return l("ai502",{detail:r||l("defaultUpstreamDown")});if(n.includes("503")||/service.?unavailable/i.test(n))return l("ai503",{detail:r||l("defaultServiceDown")});const u=(r||n).replace(/https?:\/\/[^\s]*openrouter\.ai[^\s]*/gi,"").trim();return l("aiGeneric",{detail:(u||n).slice(0,120)})}function _W({msg:e,onCopy:t,onRetry:n,onResume:r,onReply:o,isCopied:l,isLastAgentMsg:u}){const{t:d}=ft(["team","common"]),m=e.isError||e.sender==="agent"&&e.text.startsWith("⚠"),h=e.isStopped,p=u!==!1;return s.jsxs("div",{className:"flex items-center flex-wrap gap-0.5 mt-1",children:[s.jsxs("button",{onClick:()=>t(e),className:"flex items-center gap-1 px-2 py-0.5 rounded text-[11px] text-fg-tertiary hover:text-fg-primary hover:bg-surface-overlay/60 transition-colors",title:d("common:copy"),children:[l?s.jsx("svg",{className:"w-3.5 h-3.5",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:s.jsx("polyline",{points:"20 6 9 17 4 12"})}):s.jsxs("svg",{className:"w-3.5 h-3.5",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[s.jsx("rect",{x:"9",y:"9",width:"13",height:"13",rx:"2"}),s.jsx("path",{d:"M5 15H4a2 2 0 01-2-2V4a2 2 0 012-2h9a2 2 0 012 2v1"})]}),d(l?"common:copied":"common:copy")]}),p&&h&&r&&s.jsxs("button",{onClick:()=>r(e),className:"flex items-center gap-1 px-2 py-0.5 rounded text-[11px] text-green-500 hover:text-green-400 hover:bg-green-500/10 transition-colors",title:d("page.messageActions.resumeTitle"),children:[s.jsx("svg",{className:"w-3.5 h-3.5",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:s.jsx("polygon",{points:"5 3 19 12 5 21 5 3"})}),d("page.messageActions.resumeTitle")]}),p&&h&&n&&s.jsxs("button",{onClick:()=>n(e),className:"flex items-center gap-1 px-2 py-0.5 rounded text-[11px] text-brand-500 hover:text-brand-500 hover:bg-brand-500/10 transition-colors",title:d("page.messageActions.reaskTitle"),children:[s.jsxs("svg",{className:"w-3.5 h-3.5",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[s.jsx("polyline",{points:"23 4 23 10 17 10"}),s.jsx("path",{d:"M20.49 15a9 9 0 11-2.12-9.36L23 10"})]}),d("page.messageActions.reaskTitle")]}),p&&m&&!h&&n&&s.jsxs("button",{onClick:()=>n(e),className:"flex items-center gap-1 px-2 py-0.5 rounded text-[11px] text-amber-600 hover:text-amber-600 hover:bg-amber-500/10 transition-colors",title:d("page.messageActions.retryTitle"),children:[s.jsxs("svg",{className:"w-3.5 h-3.5",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[s.jsx("polyline",{points:"23 4 23 10 17 10"}),s.jsx("path",{d:"M20.49 15a9 9 0 11-2.12-9.36L23 10"})]}),d("page.messageActions.retryTitle")]}),p&&!m&&!h&&e.sender==="agent"&&n&&s.jsxs("button",{onClick:()=>n(e),className:"flex items-center gap-1 px-2 py-0.5 rounded text-[11px] text-fg-tertiary hover:text-fg-primary hover:bg-surface-overlay/60 transition-colors",title:d("page.messageActions.retryTitle"),children:[s.jsxs("svg",{className:"w-3.5 h-3.5",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[s.jsx("polyline",{points:"23 4 23 10 17 10"}),s.jsx("path",{d:"M20.49 15a9 9 0 11-2.12-9.36L23 10"})]}),d("page.messageActions.retryTitle")]}),o&&s.jsxs("button",{onClick:()=>o(e),className:"flex items-center gap-1 px-2 py-0.5 rounded text-[11px] text-fg-tertiary hover:text-fg-primary hover:bg-surface-overlay/60 transition-colors",title:d("page.messageActions.replyTitle"),children:[s.jsxs("svg",{className:"w-3.5 h-3.5",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[s.jsx("polyline",{points:"9 17 4 12 9 7"}),s.jsx("path",{d:"M20 18v-2a4 4 0 00-4-4H4"})]}),d("page.messageActions.replyTitle")]}),e.sender==="agent"&&s.jsx("span",{className:"ml-1 px-1 text-[10px] leading-none text-fg-tertiary/70 select-none whitespace-nowrap",children:d("page.messageActions.aiGeneratedDisclaimer")})]})}function l4(e,t,n){if(!e)return[];const r=[];let o=0;const l=t??"";let d=n?new Date(n).getTime():Date.now();const m=e.some(_=>_.createdAt),h=_=>{if(_.createdAt)return _.createdAt;if(m)return new Date(d).toISOString();const O=new Date(d).toISOString();return _.type==="tool"&&_.durationMs?d+=_.durationMs:d+=1e3,O};let p=!1,g="",x="",y="";const w=()=>{const _=g.trim();_&&r.push({id:`cseg_${o}`,sourceType:"chat",sourceId:"",agentId:l,seq:o++,type:"text",content:_,createdAt:y,metadata:{isThinking:!0}}),g=""},N=()=>{const _=x.trim();_&&r.push({id:`cseg_${o}`,sourceType:"chat",sourceId:"",agentId:l,seq:o++,type:"text",content:_,createdAt:y}),x=""},T="<think>",C="</think>",j=_=>{let O=0;for(;O<_.length;)if(p){const z=_.indexOf(C,O);z===-1?(g+=_.slice(O),O=_.length):(g+=_.slice(O,z),p=!1,w(),O=z+C.length)}else{const z=_.indexOf(T,O);z===-1?(x+=_.slice(O),O=_.length):(x+=_.slice(O,z),N(),p=!0,O=z+T.length)}};for(const _ of e)if(y=h(_),_.type==="tool"){p||N();const O=_.createdAt&&_.durationMs?new Date(new Date(_.createdAt).getTime()-_.durationMs).toISOString():y;r.push({id:`cseg_${o}`,sourceType:"chat",sourceId:"",agentId:l,seq:o++,type:"tool_start",content:_.tool,metadata:{arguments:_.args,..._.status==="running"&&_.subagentLogs?.length?{subagentLogs:_.subagentLogs}:{}},createdAt:O}),_.status!=="running"&&r.push({id:`cseg_${o}`,sourceType:"chat",sourceId:"",agentId:l,seq:o++,type:"tool_end",content:_.tool,metadata:{arguments:_.args,result:_.result,error:_.error,durationMs:_.durationMs,success:_.status!=="error",..._.subagentLogs?.length?{subagentLogs:_.subagentLogs}:{}},createdAt:y})}else _.thinking&&(p||N(),g+=_.thinking,w()),j(_.content);return p?w():N(),r}const jW=k.memo(function({msg:t,isStreaming:n,liveActivities:r,onMentionClick:o,knownNames:l}){const{t:u}=ft(["team","common"]),d=t.segments,m=t.isStopped,h=_=>_.type==="text"?_.content.length+(_.thinking?.length??0):(_.result?.length??0)+(_.subagentLogs?.length??0)*1e3+(_.liveOutput?.length??0),p=d?d.length+":"+(d.length>0?h(d[d.length-1]):0):"",g=d?d.reduce((_,O)=>_+(O.type==="tool"?O.subagentLogs?.length??0:0),0):0,x=k.useMemo(()=>d&&d.length>0?l4(d,t.agentId,t.rawCreatedAt):[],[p,g,t.agentId,t.rawCreatedAt]),y=t.committedSegments,w=y?y.length+":"+(y.length>0?h(y[y.length-1]):0):"",N=y?y.reduce((_,O)=>_+(O.type==="tool"?O.subagentLogs?.length??0:0),0):0,T=k.useMemo(()=>n?x:y&&y.length>0?l4(y,t.agentId,t.rawCreatedAt):x,[n,w,N,t.agentId,t.rawCreatedAt,x]);if(d!==void 0&&d.length>0){const _=d.some(U=>U.type==="tool"),O=d.filter(U=>U.type==="text"),z=n?null:O.map(U=>U.content).join(""),D=U=>U.replace(/<think>[\s\S]*?(<\/think>|$)/g,"").replace(/<(invoke|function_calls|antml:\w+)\b[\s\S]*?(<\/\1>|$)/g,"").replace(/<\/?(invoke|function_calls|antml:\w+)[^>]*>/g,"").trim()||null,W=(z?D(z):null)||(!n&&t.text?D(t.text):null),Z=[];for(const U of d){if(U.type!=="tool")continue;const Y=c3(U.tool,U.result);if(Y){Z.push({key:`task-${Y.taskId}`,kind:"task",info:Y});continue}const ae=u3(U.tool,U.result);ae&&Z.push({key:`req-${ae.requirementId}`,kind:"req",info:ae})}return s.jsxs("div",{className:"space-y-2 min-h-[1em] min-w-0 overflow-x-hidden",children:[_||n?s.jsx(zV,{entries:T,isActive:n,embedded:!0,hideApprovalCards:!0}):W&&s.jsx(Ar,{content:W,onMentionClick:o,knownNames:l}),Z.map(U=>U.kind==="task"?s.jsx(h3,{info:U.info},U.key):s.jsx(p3,{info:U.info},U.key)),!n&&!W&&!_&&Z.length===0&&!m&&!t.isError&&s.jsx("div",{className:"flex items-start gap-1.5 text-[13px] text-fg-tertiary leading-relaxed",children:s.jsx("span",{children:u("page.emptyReply")})}),!n&&(t.isError||t.text.startsWith("⚠"))&&t.text&&!d?.some(U=>U.type==="text"&&U.content&&(U.content===t.text||U.content.startsWith("⚠")))&&s.jsx("p",{className:"mt-1.5 text-[13px] text-fg-tertiary leading-relaxed whitespace-pre-wrap",children:t.text.replace(/^⚠\s*/,"")}),m&&s.jsxs("div",{className:"flex items-center gap-1.5 mt-1.5 text-[11px] text-fg-tertiary",children:[s.jsx("svg",{className:"w-3 h-3 shrink-0",viewBox:"0 0 24 24",fill:"currentColor",children:s.jsx("rect",{x:"4",y:"4",width:"16",height:"16",rx:"2"})}),s.jsx("span",{children:u("page.stopped")})]})]})}const C=(t.activities?.length??0)>0,j=t.text?t.text.replace(/<think>[\s\S]*?(<\/think>|$)/g,"").replace(/<(invoke|function_calls|antml:\w+)\b[\s\S]*?(<\/\1>|$)/g,"").replace(/<\/?(invoke|function_calls|antml:\w+)[^>]*>/g,"").trim():"";return s.jsxs(s.Fragment,{children:[(n||C)&&s.jsx(vV,{activities:n?r:t.activities??[],isActive:n,persistent:!n&&C}),j?t.isError||j.startsWith("⚠")?s.jsx("p",{className:"text-[13px] text-fg-tertiary leading-relaxed whitespace-pre-wrap",children:j.replace(/^⚠\s*/,"")}):s.jsx(Ar,{content:j,onMentionClick:o,knownNames:l}):null,!n&&!j&&!C&&!m&&!t.isError&&t.sender==="agent"&&s.jsx("div",{className:"flex items-start gap-1.5 text-[13px] text-fg-tertiary leading-relaxed",children:s.jsx("span",{children:u("page.emptyReply")})}),m&&s.jsxs("div",{className:"flex items-center gap-1.5 mt-1.5 text-[11px] text-fg-tertiary",children:[s.jsx("svg",{className:"w-3 h-3 shrink-0",viewBox:"0 0 24 24",fill:"currentColor",children:s.jsx("rect",{x:"4",y:"4",width:"16",height:"16",rx:"2"})}),s.jsx("span",{children:u("page.stopped")})]})]})});function $V(e){return e.questions&&e.questions.length>0?e.questions:e.options&&e.options.length>0?[{id:"q1",prompt:e.description||e.title,inputType:"choice",options:e.options,allowMultiple:!1,allowFreeform:e.allowFreeform}]:[{id:"q1",prompt:e.description||e.title,inputType:"text",allowFreeform:!0}]}function HV({approval:e,submitting:t,readOnly:n,onClose:r,onSubmit:o}){const{t:l}=ft(["team","common"]);Bo(!0);const u=k.useMemo(()=>$V(e),[e]),[d,m]=k.useState(0),[h,p]=k.useState(()=>{if(n&&e.answers&&e.answers.length>0){const z={};for(const D of e.answers)z[D.questionId]={selectedOptionIds:D.selectedOptionIds??[],text:D.text??""};return z}return{}}),g=u[d],x=d===u.length-1,y=u.length>1,w=z=>h[z]??{selectedOptionIds:[],text:""},N=(z,D)=>{p(H=>({...H,[z]:{...w(z),...D}}))},T=(z,D)=>{const H=w(z.id);if(z.allowMultiple){const W=H.selectedOptionIds.includes(D);N(z.id,{selectedOptionIds:W?H.selectedOptionIds.filter(Z=>Z!==D):[...H.selectedOptionIds,D],text:W?H.text:""})}else{const W=H.selectedOptionIds.includes(D);N(z.id,{selectedOptionIds:W?[]:[D],text:W?H.text:""})}},C=z=>{const D=w(z.id);return z.inputType==="choice"?D.selectedOptionIds.length>0?!0:!!(z.allowFreeform&&D.text.trim()):D.text.trim().length>0},j=u.every(C),_=()=>u.map(z=>{const D=w(z.id),H={questionId:z.id};return D.selectedOptionIds.length>0&&(H.selectedOptionIds=D.selectedOptionIds),D.text.trim()&&(H.text=D.text.trim()),H}),O=()=>{const z=_();let D=!0,H;if(!e.questions?.length&&e.options?.length){const Z=z[0];H=Z?.selectedOptionIds?.[0]??(Z?.text?"custom":void 0),D=H!=="reject"&&H!=="request_changes"}const W=z.map(Z=>Z.text).filter(Boolean).join(`
657
- `)||void 0;o({approved:D,comment:W,selectedOption:H,answers:z})};return Ja.createPortal(s.jsx("div",{className:"fixed inset-0 z-[10000] flex items-center justify-center p-4 bg-black/50 backdrop-blur-sm",onMouseDown:z=>{z.target===z.currentTarget&&r()},children:s.jsxs("div",{className:"w-full max-w-2xl max-h-[85vh] flex flex-col bg-surface-secondary border border-border-default rounded-2xl shadow-2xl overflow-hidden",children:[s.jsxs("div",{className:"flex items-start gap-3 px-6 py-4 border-b border-border-default shrink-0",children:[s.jsx("div",{className:"w-9 h-9 rounded-lg bg-amber-500/15 text-amber-500 flex items-center justify-center shrink-0",children:s.jsxs("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[s.jsx("path",{d:"M12 2a10 10 0 1 0 0 20 10 10 0 0 0 0-20z"}),s.jsx("path",{d:"M12 8v4"}),s.jsx("path",{d:"M12 16h.01"})]})}),s.jsxs("div",{className:"flex-1 min-w-0",children:[s.jsx("h2",{className:"text-base font-semibold text-fg-primary leading-snug",children:e.title}),s.jsxs("div",{className:"flex items-center gap-2 mt-0.5",children:[s.jsx("p",{className:"text-xs text-fg-tertiary",children:e.agentName}),n&&s.jsxs("span",{className:"inline-flex items-center gap-1 px-1.5 py-0.5 rounded text-[10px] font-medium bg-green-500/15 text-green-600",children:[s.jsx("svg",{width:"10",height:"10",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"3",strokeLinecap:"round",strokeLinejoin:"round",children:s.jsx("path",{d:"M20 6L9 17l-5-5"})}),l("team:userInput.submitted",{defaultValue:"Submitted"})]})]})]}),s.jsx("button",{onClick:r,className:"p-1.5 text-fg-tertiary hover:text-fg-primary rounded-md hover:bg-surface-overlay transition-colors shrink-0",title:l("common:close"),children:s.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[s.jsx("path",{d:"M18 6L6 18"}),s.jsx("path",{d:"M6 6l12 12"})]})})]}),s.jsxs("div",{className:"flex-1 overflow-y-auto px-6 py-5 space-y-4",children:[y&&s.jsx("div",{className:"flex items-center gap-2",children:u.map((z,D)=>s.jsx("button",{onClick:()=>m(D),className:`h-1.5 flex-1 rounded-full transition-colors ${D===d?"bg-brand-500":C(z)?"bg-green-500/60":"bg-border-default"}`,title:`${D+1}. ${z.prompt.slice(0,40)}`},z.id))}),y&&s.jsx("div",{className:"text-[11px] font-medium text-fg-tertiary",children:l("team:userInput.questionProgress",{current:d+1,total:u.length,defaultValue:`Question ${d+1} of ${u.length}`})}),s.jsx("div",{className:"text-sm text-fg-primary leading-relaxed",children:s.jsx(Ar,{content:g.prompt})}),g.inputType==="choice"&&g.options&&s.jsx("div",{className:"space-y-2",children:g.options.map((z,D)=>{const H=w(g.id).selectedOptionIds.includes(z.id);return s.jsxs("button",{onClick:n?void 0:()=>T(g,z.id),disabled:n,className:`w-full px-4 py-3 text-left rounded-xl border transition-colors flex items-start gap-3 ${H?"border-brand-500 bg-brand-500/10":`border-border-default ${n?"":"hover:bg-surface-overlay"}`} ${n?"cursor-default":""} ${n&&!H?"opacity-50":""}`,children:[s.jsx("span",{className:`w-6 h-6 rounded-full flex items-center justify-center text-[11px] font-bold shrink-0 mt-0.5 ${H?"bg-brand-600 text-white":"bg-surface-overlay text-fg-tertiary"}`,children:H?s.jsx("svg",{width:"13",height:"13",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"3",strokeLinecap:"round",strokeLinejoin:"round",children:s.jsx("path",{d:"M20 6L9 17l-5-5"})}):String.fromCharCode(65+D)}),s.jsxs("span",{className:"flex-1 min-w-0 text-sm text-fg-primary [&_p]:my-0 [&_p]:text-sm",children:[s.jsx(Ar,{content:z.label}),z.description&&s.jsx("span",{className:"block text-xs text-fg-tertiary mt-1 [&_p]:my-0 [&_p]:text-xs",children:s.jsx(Ar,{content:z.description})})]})]},z.id)})}),(g.inputType==="text"||g.allowFreeform)&&(!n||w(g.id).text)&&s.jsx("textarea",{rows:g.inputType==="text"?4:2,readOnly:n,placeholder:g.inputType==="text"?l("team:userInput.textPlaceholder",{defaultValue:"Type your answer…"}):l("team:userInput.freeformPlaceholder",{defaultValue:"Or write your own answer…"}),value:w(g.id).text,onChange:z=>{const D=z.target.value;N(g.id,{text:D,selectedOptionIds:D.trim()&&g.inputType==="choice"?[]:w(g.id).selectedOptionIds})},className:`w-full px-3.5 py-2.5 text-sm bg-surface-overlay border border-border-default rounded-xl text-fg-primary placeholder:text-fg-tertiary focus:outline-none resize-y ${n?"cursor-default opacity-80":"focus:ring-1 focus:ring-brand-500/50"}`})]}),s.jsxs("div",{className:"flex items-center justify-between gap-2 px-6 py-4 border-t border-border-default shrink-0",children:[s.jsx("div",{children:y&&d>0&&s.jsx("button",{onClick:()=>m(z=>Math.max(0,z-1)),className:"px-4 py-2 text-sm font-medium text-fg-secondary border border-border-default rounded-lg hover:bg-surface-overlay transition-colors",children:l("team:userInput.previous",{defaultValue:"Previous"})})}),s.jsx("div",{className:"flex items-center gap-2",children:y&&!x?s.jsx("button",{disabled:!n&&!C(g),onClick:()=>m(z=>Math.min(u.length-1,z+1)),className:"px-5 py-2 text-sm font-medium bg-brand-600 text-white rounded-lg hover:bg-brand-700 disabled:opacity-50 transition-colors",children:l("team:userInput.next",{defaultValue:"Next"})}):n?s.jsx("button",{onClick:r,className:"px-5 py-2 text-sm font-medium text-fg-secondary border border-border-default rounded-lg hover:bg-surface-overlay transition-colors",children:l("common:close",{defaultValue:"Close"})}):s.jsxs("button",{disabled:t||!j,onClick:O,className:"px-5 py-2 text-sm font-medium bg-brand-600 text-white rounded-lg hover:bg-brand-700 disabled:opacity-50 transition-colors inline-flex items-center gap-2",children:[t&&s.jsxs("svg",{className:"animate-spin h-4 w-4",viewBox:"0 0 24 24",fill:"none",children:[s.jsx("circle",{className:"opacity-25",cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"4"}),s.jsx("path",{className:"opacity-75",fill:"currentColor",d:"M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4z"})]}),l("team:userInput.submit",{defaultValue:"Submit"})]})})]})]})}),document.body)}function gd(e){return Array.isArray(e.questions)&&e.questions.length>0}const bd={urgent:"bg-red-500",high:"bg-amber-500",normal:"bg-blue-500",low:"bg-gray-400"},So={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"},c4={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 No(e,t){const n=Date.now()-new Date(e).getTime(),r=Math.floor(n/6e4);if(r<1)return t("common:time.now");if(r<60)return t("common:time.minutesAgo",{count:r});const o=Math.floor(r/60);return o<24?t("common:time.hoursAgo",{count:o}):t("common:time.daysAgo",{count:Math.floor(o/24)})}const u4="markus:template-updates-ack";let qh=!1,xd=null;function FV(e){return e.map(t=>`${t.name}@${t.availableVersion}`).sort().join(",")}function d4(e,t){if(e.type!=="system"||!e.metadata?.templateUpdates)return!1;if(!t)return!0;const n=e.metadata.templateUpdatesFingerprint;return!n||n===t}function yd(e,t){const n=e.actionType;if(n==="open_chat")return t("team:notifications.actionHints.openChat");if(n==="navigate")return t("team:notifications.actionHints.viewDetails");const r=e.metadata??{};switch(e.type){case"task_completed":case"task_created":case"task_review":case"task_failed":return r.taskId?t("team:notifications.actionHints.viewTask"):null;case"requirement_created":case"requirement_decision":return r.requirementId?t("team:notifications.actionHints.viewRequirement"):null;case"agent_report":return r.agentId?t("team:notifications.actionHints.viewAgent"):null;case"direct_message":return t("team:notifications.actionHints.openChat");case"group_message":return t("team:notifications.actionHints.openChat");case"approval_request":return t("team:notifications.actionHints.viewApproval");case"system":return r.templateUpdates?t("common:templateUpdates.actionHint"):null;default:return r.taskId?t("team:notifications.actionHints.viewTask"):r.requirementId?t("team:notifications.actionHints.viewRequirement"):r.agentId?t("team:notifications.actionHints.viewAgent"):null}}function Gh(){try{const e=new AudioContext,t=e.currentTime,n=e.createGain();n.connect(e.destination),n.gain.setValueAtTime(.15,t),n.gain.exponentialRampToValueAtTime(.01,t+.6);const r=e.createOscillator();r.type="sine",r.frequency.setValueAtTime(880,t),r.frequency.setValueAtTime(1174.66,t+.15),r.connect(n),r.start(t),r.stop(t+.6),r.onended=()=>e.close()}catch{}}function qV({collapsed:e,userId:t,embeddedMode:n,onClose:r,sidebarMode:o,isActive:l,label:u,iconPath:d}){const{t:m}=ft(["team","common"]),[h,p]=k.useState(!1),[g,x]=k.useState("approvals"),[y,w]=k.useState([]),[N,T]=k.useState([]),[C,j]=k.useState(null),[_,O]=k.useState(null),[z,D]=k.useState(null),[H,W]=k.useState({}),[Z,U]=k.useState(0),Y=k.useRef(null),ae=k.useRef(null),[X,F]=k.useState({top:0,left:0,width:448,maxHeight:576}),J=k.useRef(null),B=k.useRef(!1),[Q,re]=k.useState(!0),[we,$]=k.useState(!1),G=k.useRef(null),ce=k.useRef("approvals"),[I,Ee]=k.useState(!1),Ue=30,De=k.useCallback(async()=>{try{Wa("/approvals"),Wa("/notifications");const[R,oe]=await Promise.all([Ce.notifications.list(t,!1,{limit:Ue,offset:0}),Ce.approvals.list()]);w(R.notifications);const _e=R.unreadCount??R.notifications.filter(de=>!de.read).length;if(U(_e),re(R.totalCount!=null?R.notifications.length<R.totalCount:R.notifications.length>=Ue),T(oe.approvals),!B.current){const de=oe.approvals.filter($e=>$e.status==="pending").length;J.current=de,B.current=!0}}catch{}},[t]),Ke=k.useCallback(async()=>{if(!(we||!Q)){$(!0);try{const R=await Ce.notifications.list(t,!1,{limit:Ue,offset:y.length});R.notifications.length>0&&w(oe=>[...oe,...R.notifications.filter(_e=>!oe.some(de=>de.id===_e.id))]),re(R.totalCount!=null?y.length+R.notifications.length<R.totalCount:R.notifications.length>=Ue)}catch{}$(!1)}},[t,y.length,we,Q]),st=k.useCallback(R=>{const oe=R.detail;if(!oe)return;const{taskId:_e,requirementId:de}=oe;!_e&&!de||w($e=>{const qe=$e.filter(q=>!q.read&&(_e&&q.metadata?.taskId===_e||de&&q.metadata?.requirementId===de));if(qe.length===0)return $e;for(const q of qe)Ce.notifications.markRead(q.id).catch(()=>{});return U(q=>Math.max(0,q-qe.length)),$e.map(q=>qe.some(ie=>ie.id===q.id)?{...q,read:!0}:q)})},[]),mt=k.useRef(y);mt.current=y;const ct=k.useCallback(async()=>{if(!mt.current.some(oe=>!oe.read&&oe.type==="system"&&oe.metadata?.creditExhausted))try{await Ce.notifications.create({title:m("credits.notificationTitle",{ns:"common"}),body:m("credits.notificationBody",{ns:"common"}),type:"system",priority:"urgent",metadata:{creditExhausted:!0}}),De(),Gh()}catch{}},[De,m]),Dt=k.useCallback(async()=>{if(!qh){qh=!0;try{const{updates:R}=await Ce.skills.updates();if(!R.length)return;const oe=FV(R);try{if(localStorage.getItem(u4)===oe)return}catch{}if(xd===oe||mt.current.some(de=>!de.read&&d4(de,oe)))return;try{const $e=(await Ce.notifications.list(t,!0,{limit:50,type:"system"})).notifications.filter(qe=>d4(qe,oe)).sort((qe,q)=>new Date(q.createdAt).getTime()-new Date(qe.createdAt).getTime());if($e.length>0){for(const qe of $e.slice(1))Ce.notifications.markRead(qe.id).catch(()=>{});$e.length>1&&De(),xd=oe;return}}catch{}xd=oe,await Ce.notifications.create({title:m("templateUpdates.notificationTitle",{ns:"common"}),body:m("templateUpdates.notificationBody",{ns:"common",count:R.length}),type:"system",priority:"high",metadata:{templateUpdates:!0,templateUpdatesFingerprint:oe,count:R.length,skills:R.map(de=>de.name)}}),De(),Gh()}catch{xd=null}finally{qh=!1}}},[De,m,t]);k.useEffect(()=>{De();const R=setInterval(De,6e4);let oe=null;const _e=()=>{oe||(oe=setTimeout(()=>{oe=null,De()},400))},de=()=>_e(),$e=()=>{p(!0),De()};window.addEventListener("markus:notifications-changed",de),window.addEventListener("markus:mark-read-by-ref",st),window.addEventListener("markus:open-notifications",$e),window.addEventListener("markus:credit-exhausted",ct);const qe=va.on("notification",_e),q=va.on("approval:requested",_e);return()=>{clearInterval(R),oe&&clearTimeout(oe),window.removeEventListener("markus:notifications-changed",de),window.removeEventListener("markus:mark-read-by-ref",st),window.removeEventListener("markus:open-notifications",$e),window.removeEventListener("markus:credit-exhausted",ct),qe(),q()}},[De,st,ct]),k.useEffect(()=>{Dt();const R=setInterval(()=>{Dt()},5*6e4),oe=()=>{Dt()};return window.addEventListener("markus:data-changed",oe),()=>{clearInterval(R),window.removeEventListener("markus:data-changed",oe)}},[t]);const Mt=k.useCallback(()=>{if(!Y.current)return;const R=Y.current.getBoundingClientRect(),oe=window.innerWidth,_e=window.innerHeight,de=Math.min(448,oe-16),$e=Math.min(576,_e-16);let qe=R.right+8,q=R.top;qe+de>oe-8&&(qe=Math.max(8,oe-de-8)),q+$e>_e-8&&(q=Math.max(8,_e-$e-8)),F({top:q,left:qe,width:de,maxHeight:$e})},[]);k.useLayoutEffect(()=>{h&&Mt()},[h,Mt]),k.useEffect(()=>{if(h)return window.addEventListener("resize",Mt),()=>window.removeEventListener("resize",Mt)},[h,Mt]),k.useEffect(()=>{if(!h)return;const R=oe=>{Y.current?.contains(oe.target)||ae.current?.contains(oe.target)||p(!1)};return document.addEventListener("mousedown",R),()=>document.removeEventListener("mousedown",R)},[h]),k.useEffect(()=>{if(!h)return;const R=N.some(_e=>_e.status==="pending"),oe=y.some(_e=>!_e.read);x(R&&!oe?"approvals":!R&&oe?"notifications":ce.current)},[h]);const Xt=new Set(N.filter(R=>R.status==="pending").map(R=>R.id)),Me=new Set(N.map(R=>R.id)),Ne=y.filter(R=>!(R.type==="approval_request"&&R.metadata?.approvalId&&Me.has(R.metadata.approvalId))),Re=y.filter(R=>R.type==="approval_request"&&!R.read&&R.metadata?.approvalId&&Xt.has(R.metadata.approvalId)).length,ut=Math.max(0,Z-Re),it=Xt.size,bt=ut+it;k.useEffect(()=>{J.current!==null&&it>J.current&&Gh(),J.current=it},[it]);const se=async R=>{await Ce.notifications.markRead(R),w(oe=>oe.map(_e=>_e.id===R?{..._e,read:!0}:_e)),U(oe=>Math.max(0,oe-1))},et=R=>{const oe=R.metadata??{},_e=R.actionType,de=R.actionTarget;if(_e==="open_chat"&&de)try{const $e=typeof de=="string"?JSON.parse(de):de;if($e.agentId){const qe={agentId:$e.agentId};$e.sessionId&&(qe.sessionId=$e.sessionId),at.navigate(me.TEAM,qe);return}}catch{}if(_e==="navigate"&&de)try{const $e=typeof de=="string"?JSON.parse(de):de;if($e.path){if($e.path.startsWith("/team")){const qe={},q=new URLSearchParams($e.path.split("?")[1]||"");for(const[ie,Se]of q.entries())qe[ie]=Se;at.navigate(me.TEAM,qe);return}if($e.path.startsWith("/work")){const qe={},q=new URLSearchParams($e.path.split("?")[1]||"");for(const[ie,Se]of q.entries())qe[ie]=Se;at.navigate(me.WORK,qe);return}}}catch{}switch(R.type){case"approval_request":{const $e=oe.approvalId,qe=$e?N.find(Ie=>Ie.id===$e):void 0;if(qe&&gd(qe)){O(qe);break}const q=qe?.details?.taskId??oe.taskId,ie=qe?.details?.requirementId??oe.requirementId,Se=qe?.details?.agentId??qe?.agentId;q?at.navigate(me.WORK,{openTask:q}):ie?at.navigate(me.WORK,{openRequirement:ie}):Se?at.navigate(me.TEAM,{agentId:Se}):at.navigate(me.WORK);break}case"task_completed":case"task_created":case"task_review":case"task_failed":oe.taskId?at.navigate(me.WORK,{openTask:oe.taskId}):at.navigate(me.WORK);break;case"requirement_created":case"requirement_decision":oe.requirementId?at.navigate(me.WORK,{openRequirement:oe.requirementId}):at.navigate(me.WORK);break;case"agent_report":case"system":{if(oe.creditExhausted){Ee(!0);return}if(oe.templateUpdates){const $e=oe.templateUpdatesFingerprint;if($e)try{localStorage.setItem(u4,$e)}catch{}localStorage.setItem("markus_nav_storeTab","installed"),at.navigate(me.STORE);return}if(oe.agentId){const $e={agentId:oe.agentId};oe.sessionId&&($e.sessionId=oe.sessionId),at.navigate(me.TEAM,$e)}else at.navigate(me.TEAM);break}case"direct_message":{const $e=oe.senderId;$e?at.navigate(me.TEAM,{dm:$e}):at.navigate(me.TEAM);break}case"group_message":{const $e=oe.channel;$e?at.navigate(me.TEAM,{channel:$e}):at.navigate(me.TEAM);break}default:oe.taskId?at.navigate(me.WORK,{openTask:oe.taskId}):oe.requirementId?at.navigate(me.WORK,{openRequirement:oe.requirementId}):oe.projectId?at.navigate(me.WORK,{projectId:oe.projectId}):oe.agentId&&at.navigate(me.TEAM,{agentId:oe.agentId});break}},nt=async R=>{R.read||se(R.id);const oe=R.metadata??{},_e=oe.taskId,de=oe.requirementId;if(_e||de){const $e=y.filter(qe=>qe.id!==R.id&&!qe.read&&(_e&&qe.metadata?.taskId===_e||de&&qe.metadata?.requirementId===de));for(const qe of $e)se(qe.id)}et(R)},Ge=async(R,oe,_e,de,$e)=>{j(R);try{const{approval:qe}=await Ce.approvals.respond(R,oe,t,_e,de,$e);T(Ie=>Ie.map(Xe=>Xe.id===R?qe:Xe)),O(null),D(null),W(Ie=>{const Xe={...Ie};return delete Xe[R],Xe});const q=qe.details?.taskId,ie=qe.details?.requirementId,Se=y.filter(Ie=>!Ie.read&&(Ie.type==="approval_request"&&Ie.metadata?.approvalId===R||q&&Ie.metadata?.taskId===q||ie&&Ie.metadata?.requirementId===ie));if(Se.length>0){for(const Xe of Se)Ce.notifications.markRead(Xe.id).catch(()=>{});const Ie=new Set(Se.map(Xe=>Xe.id));w(Xe=>Xe.map(yt=>Ie.has(yt.id)?{...yt,read:!0}:yt)),U(Xe=>Math.max(0,Xe-Se.length))}Wa("/approvals"),Wa("/notifications"),Wa("/tasks"),Wa("/taskboard"),Wa("/requirements"),window.dispatchEvent(new CustomEvent("markus:data-changed")),window.dispatchEvent(new CustomEvent("markus:notifications-changed")),setTimeout(()=>De(),800)}catch{}j(null)},Qe=async()=>{try{if(!t)return;await Ce.notifications.markAllRead(t),w(R=>R.map(oe=>({...oe,read:!0}))),U(0),Wa("/notifications")}catch{const R=Ne.filter(oe=>!oe.read);await Promise.all(R.map(oe=>Ce.notifications.markRead(oe.id))),w(oe=>oe.map(_e=>({..._e,read:!0}))),U(0),Wa("/notifications")}},xt=R=>{const oe=R.details?.subType;return oe==="requirement_resubmit"?m("team:notifications.approvalType.requirementResubmit"):oe==="requirement"||R.details?.requirementId?m("team:notifications.approvalType.requirement"):oe==="task_review"?m("team:notifications.approvalType.taskReview"):oe==="task"||R.details?.taskId?m("team:notifications.approvalType.task"):R.details?.toolName?m("team:notifications.approvalType.toolExecution"):null},pe=R=>{const oe=[];oe.push(R.agentName);const _e=R.details?.taskTitle,de=R.details?.taskId;_e?oe.push(_e):de&&oe.push(`Task ${de.slice(0,8)}`);const $e=R.details?.requirementId;return $e&&!de&&oe.push(`Req ${$e.slice(0,8)}`),oe.join(" · ")},V=[...N].sort((R,oe)=>new Date(oe.requestedAt).getTime()-new Date(R.requestedAt).getTime()),xe=V.filter(R=>R.status==="pending"),We=V.filter(R=>R.status!=="pending"),he=R=>{const oe=R.details?.taskId,_e=R.details?.requirementId,de=R.details?.agentId??R.agentId;oe?at.navigate(me.WORK,{openTask:oe}):_e?at.navigate(me.WORK,{openRequirement:_e}):de?at.navigate(me.TEAM,{agentId:de}):at.navigate(me.WORK)},ye=()=>{p(!1),r?.()},Ze=R=>s.jsxs("button",{disabled:C===R.id,onClick:()=>O(R),className:"w-full px-3 py-2 text-[11px] font-medium bg-brand-600 text-white rounded-md hover:bg-brand-700 disabled:opacity-50 transition-colors inline-flex items-center justify-center gap-1.5",children:[s.jsx("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:s.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"})}),m("team:userInput.respond",{defaultValue:"Respond"}),R.questions&&R.questions.length>1?` (${R.questions.length})`:""]}),rt=_?s.jsx(HV,{approval:_,submitting:C===_.id,readOnly:_.status!=="pending",onClose:()=>O(null),onSubmit:R=>Ge(_.id,R.approved,R.comment,R.selectedOption,R.answers)}):null,St=s.jsxs(s.Fragment,{children:[s.jsxs("div",{className:"flex border-b border-border-default shrink-0",children:[s.jsxs("button",{onClick:()=>{x("approvals"),ce.current="approvals"},className:`flex-1 px-3 py-2.5 text-xs font-medium transition-colors ${g==="approvals"?"text-fg-primary border-b-2 border-brand-500":"text-fg-tertiary hover:text-fg-secondary"}`,children:[m("team:notifications.approvals"),it>0?` (${it})`:""]}),s.jsxs("button",{onClick:()=>{x("notifications"),ce.current="notifications"},className:`flex-1 px-3 py-2.5 text-xs font-medium transition-colors ${g==="notifications"?"text-fg-primary border-b-2 border-brand-500":"text-fg-tertiary hover:text-fg-secondary"}`,children:[m("team:notifications.notifications"),ut>0?` (${ut})`:""]}),s.jsx("button",{onClick:ye,className:"px-2 py-2 text-fg-tertiary hover:text-fg-primary transition-colors shrink-0",title:m("common:close"),children:s.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[s.jsx("path",{d:"M18 6L6 18"}),s.jsx("path",{d:"M6 6l12 12"})]})})]}),g==="notifications"&&Z>0&&s.jsx("div",{className:"flex justify-end px-3 py-1.5 border-b border-border-default/50 shrink-0",children:s.jsx("button",{onClick:Qe,className:"text-[10px] text-brand-500 hover:text-brand-400 transition-colors",children:m("team:notifications.markAllRead")})}),s.jsxs("div",{ref:G,className:"flex-1 overflow-y-auto",onScroll:R=>{if(g!=="notifications"||!Q||we)return;const oe=R.currentTarget;oe.scrollTop+oe.clientHeight>=oe.scrollHeight-80&&Ke()},children:[g==="approvals"&&(N.length===0?s.jsx("div",{className:"p-6 text-center text-xs text-fg-tertiary",children:m("team:notifications.noApprovals")}):s.jsxs("div",{className:"divide-y divide-border-default/50",children:[xe.map(R=>{const oe=R.details?.command,_e=oe?R.description.replace(/\s*Command:.*$/,""):R.description;return s.jsxs("div",{className:"px-3 py-3 space-y-2.5",children:[s.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:()=>he(R),children:[s.jsxs("div",{className:"flex items-start gap-2",children:[s.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:s.jsx("path",{d:So.approval_request})}),s.jsxs("div",{className:"flex-1 min-w-0",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[xt(R)&&s.jsx("span",{className:"text-[10px] text-amber-500 font-medium shrink-0",children:xt(R)}),s.jsx("span",{className:"text-xs text-fg-primary font-medium truncate",children:R.title}),s.jsx("span",{className:"text-[10px] text-fg-tertiary shrink-0",children:No(R.requestedAt,m)})]}),s.jsx("div",{className:"text-[11px] text-fg-tertiary mt-0.5",children:R.agentName})]})]}),s.jsx("div",{className:"mt-2.5 text-[11px] text-fg-secondary leading-relaxed",children:s.jsx(Ar,{content:_e,className:"text-[11px] [&_h1]:text-xs [&_h2]:text-[11px] [&_h3]:text-[11px] [&_p]:text-[11px] [&_li]:text-[11px]"})}),oe&&s.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:oe})]}),(()=>{if(gd(R))return Ze(R);const de=R.details?.subType,$e=de==="task"||de==="requirement"||de==="requirement_resubmit",qe=R.options&&R.options.length>0,q=(H[R.id]??"").trim();return qe?s.jsxs("div",{className:"space-y-1.5",children:[R.options.map((ie,Se)=>s.jsxs("button",{disabled:C===R.id,onClick:()=>Ge(R.id,ie.id!=="reject",q||void 0,ie.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 ${ie.id==="reject"||ie.id==="request_changes"?"border border-border-default text-fg-secondary hover:bg-surface-overlay":"bg-brand-600 text-white hover:bg-brand-700"}`,title:ie.description,children:[s.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+Se)}),ie.label]},ie.id)),s.jsxs("div",{className:"flex gap-1.5 mt-1",children:[s.jsx("input",{type:"text",placeholder:m("team:notifications.freeformPlaceholder"),value:H[R.id]??"",onChange:ie=>W(Se=>({...Se,[R.id]:ie.target.value})),onKeyDown:ie=>{ie.key==="Enter"&&(H[R.id]??"").trim()&&Ge(R.id,!0,(H[R.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"}),s.jsx("button",{disabled:C===R.id||!(H[R.id]??"").trim(),onClick:()=>Ge(R.id,!0,(H[R.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:m("common:send")})]})]}):$e?s.jsxs("div",{className:"space-y-1.5",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsxs("button",{disabled:C===R.id,onClick:()=>Ge(R.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:[s.jsx("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round",children:s.jsx("path",{d:"M20 6L9 17l-5-5"})}),m("common:approve")]}),s.jsxs("button",{disabled:C===R.id,onClick:()=>Ge(R.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:[s.jsxs("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round",children:[s.jsx("path",{d:"M18 6L6 18"}),s.jsx("path",{d:"M6 6l12 12"})]}),m("common:reject")]}),z!==R.id&&s.jsxs("button",{disabled:C===R.id,onClick:()=>D(R.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:[s.jsxs("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[s.jsx("path",{d:"M11 4H4a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2v-7"}),s.jsx("path",{d:"M18.5 2.5a2.121 2.121 0 0 1 3 3L12 15l-4 1 1-4 9.5-9.5z"})]}),m("team:notifications.needsAdjustment")]})]}),z===R.id&&s.jsxs("div",{className:"space-y-1.5",children:[s.jsx("input",{type:"text",autoFocus:!0,placeholder:m("team:notifications.adjustmentPlaceholder"),value:H[R.id]??"",onChange:ie=>W(Se=>({...Se,[R.id]:ie.target.value})),onKeyDown:ie=>{ie.key==="Enter"&&(H[R.id]??"").trim()&&Ge(R.id,!1,(H[R.id]??"").trim(),"needs_adjustment"),ie.key==="Escape"&&D(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"}),s.jsxs("div",{className:"flex gap-2",children:[s.jsx("button",{disabled:C===R.id||!(H[R.id]??"").trim(),onClick:()=>Ge(R.id,!1,(H[R.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:m("team:notifications.confirmAdjustment")}),s.jsx("button",{onClick:()=>D(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:m("common:cancel")})]})]})]}):s.jsxs("div",{className:"space-y-1.5",children:[s.jsx("input",{type:"text",placeholder:m("team:notifications.commentPlaceholder"),value:H[R.id]??"",onChange:ie=>W(Se=>({...Se,[R.id]:ie.target.value})),onKeyDown:ie=>{ie.key==="Enter"&&Ge(R.id,!0,q||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"}),s.jsxs("div",{className:"flex gap-2",children:[s.jsx("button",{disabled:C===R.id,onClick:()=>Ge(R.id,!0,q||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:m("common:approve")}),s.jsx("button",{disabled:C===R.id,onClick:()=>Ge(R.id,!1,q||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:m("common:reject")})]})]})})()]},R.id)}),We.length>0&&s.jsxs(s.Fragment,{children:[xe.length>0&&s.jsx("div",{className:"px-3 py-1.5 text-[10px] font-medium text-fg-tertiary uppercase tracking-wider bg-surface-overlay/30",children:m("team:notifications.approvalHistory")}),We.slice(0,50).map(R=>s.jsxs("button",{onClick:()=>gd(R)?O(R):he(R),className:"w-full text-left px-3 py-2.5 hover:bg-surface-overlay/50 transition-colors group",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("span",{className:`w-1.5 h-1.5 rounded-full shrink-0 ${R.status==="approved"?"bg-green-500":R.status==="cancelled"||R.status==="expired"?"bg-gray-400":"bg-red-500"}`}),xt(R)&&s.jsx("span",{className:"text-[10px] text-fg-tertiary font-medium shrink-0",children:xt(R)}),s.jsx("span",{className:"text-xs text-fg-secondary truncate flex-1 group-hover:text-fg-primary",children:R.title}),s.jsx("span",{className:`text-[10px] font-medium shrink-0 ${R.status==="approved"?"text-green-500":R.status==="cancelled"||R.status==="expired"?"text-fg-muted":"text-red-500"}`,children:m(`common:status.${R.status}`,{defaultValue:R.status})})]}),s.jsxs("div",{className:"flex items-center gap-1.5 mt-0.5 pl-3.5",children:[s.jsx("span",{className:"text-[10px] text-fg-muted truncate",children:pe(R)}),s.jsx("span",{className:"text-[10px] text-fg-muted shrink-0",children:"·"}),s.jsx("span",{className:"text-[10px] text-fg-muted shrink-0",children:No(R.respondedAt??R.requestedAt,m)})]}),R.responseComment&&s.jsxs("p",{className:"text-[10px] text-fg-muted mt-0.5 pl-3.5 truncate",children:["“",R.responseComment,"”"]})]},R.id))]})]})),g==="notifications"&&(Ne.length===0?s.jsx("div",{className:"p-6 text-center text-xs text-fg-tertiary",children:m("team:notifications.noNotifications")}):s.jsxs("div",{className:"divide-y divide-border-default/50",children:[Ne.map(R=>{const oe=c4[R.type]??"text-fg-tertiary";return s.jsxs("div",{role:"button",tabIndex:0,onClick:()=>nt(R),onKeyDown:_e=>{(_e.key==="Enter"||_e.key===" ")&&(_e.preventDefault(),nt(R))},className:`w-full text-left px-3 py-2.5 flex gap-2.5 transition-colors cursor-pointer ${R.read?"opacity-50 hover:opacity-70":"hover:bg-surface-overlay"}`,children:[s.jsx("div",{className:"shrink-0 mt-0.5",children:s.jsx("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",className:oe,children:s.jsx("path",{d:So[R.type]??So.system})})}),s.jsxs("div",{className:"flex-1 min-w-0",children:[s.jsxs("div",{className:"flex items-center gap-1.5",children:[!R.read&&s.jsx("span",{className:`w-1.5 h-1.5 rounded-full shrink-0 ${bd[R.priority]??bd.normal}`}),s.jsx("span",{className:"text-xs text-fg-primary font-medium truncate",children:R.title})]}),s.jsx("div",{className:"text-[11px] text-fg-tertiary mt-0.5 ",children:s.jsx(Ar,{content:R.body,className:"text-[11px] [&_h1]:text-xs [&_h2]:text-[11px] [&_h3]:text-[11px] [&_p]:text-[11px] [&_li]:text-[11px] [&_p]:text-fg-tertiary"})}),s.jsxs("div",{className:"flex items-center gap-2 mt-0.5",children:[s.jsx("span",{className:"text-[10px] text-fg-muted",children:No(R.createdAt,m)}),yd(R,m)&&s.jsx("span",{className:`text-[10px] font-medium ${oe}`,children:yd(R,m)})]})]})]},R.id)}),we&&s.jsx("div",{className:"py-3 text-center",children:s.jsxs("svg",{className:"animate-spin h-4 w-4 text-fg-tertiary mx-auto",viewBox:"0 0 24 24",fill:"none",children:[s.jsx("circle",{className:"opacity-25",cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"4"}),s.jsx("path",{className:"opacity-75",fill:"currentColor",d:"M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4z"})]})})]}))]})]}),Bt=k.useCallback(R=>{R?.mute&&UV()},[]),wt=k.useCallback(R=>{Bt(R),Ee(!1)},[Bt]),hn=I?s.jsx(dr,{title:m("credits.dialogTitle",{ns:"common"}),message:m("credits.dialogDesc",{ns:"common"}),variant:"primary",cancelLabel:m("credits.configureModels",{ns:"common"}),confirmLabel:m("credits.topUp",{ns:"common"}),checkboxes:[{id:"mute",label:m("credits.dontRemind",{ns:"common"})}],onCancel:()=>Ee(!1),onCancelClick:R=>{wt(R),at.navigate(me.SETTINGS),setTimeout(()=>{window.location.hash="settings/providers"},50)},onConfirm:R=>{const oe=`${lt.getUrl().replace(/\/$/,"")}/settings?tab=billing`;wt(R),Oo(oe)}}):null;if(n){const R=["approvals","notifications"],oe=R.indexOf(g),_e=(()=>{let de=0,$e=0;return{onTouchStart:qe=>{de=qe.touches[0].clientX,$e=qe.touches[0].clientY},onTouchEnd:qe=>{const q=qe.changedTouches[0].clientX-de,ie=qe.changedTouches[0].clientY-$e;Math.abs(q)>60&&Math.abs(q)>Math.abs(ie)*1.5&&(q<0&&oe<R.length-1&&x(R[oe+1]),q>0&&oe>0&&x(R[oe-1]))}}})();return s.jsxs(s.Fragment,{children:[hn,s.jsxs("div",{className:"flex flex-col h-full overflow-hidden",children:[rt,s.jsx("div",{className:"flex border-b border-border-default shrink-0",children:R.map(de=>s.jsx("button",{onClick:()=>x(de),className:`flex-1 px-3 py-3 text-sm font-medium transition-colors ${g===de?"text-fg-primary border-b-2 border-brand-500":"text-fg-tertiary"}`,children:de==="approvals"?s.jsxs(s.Fragment,{children:[m("team:notifications.approvals"),it>0?` (${it})`:""]}):s.jsxs(s.Fragment,{children:[m("team:notifications.notifications"),ut>0?` (${ut})`:""]})},de))}),g==="notifications"&&Z>0&&s.jsx("div",{className:"flex justify-end px-3 py-1.5 border-b border-border-default/50 shrink-0",children:s.jsx("button",{onClick:Qe,className:"text-[10px] text-brand-500 hover:text-brand-400 transition-colors",children:m("team:notifications.markAllRead")})}),s.jsx("div",{className:"flex-1 overflow-hidden relative",..._e,children:s.jsxs("div",{className:"flex h-full transition-transform duration-300 ease-out",style:{transform:`translateX(-${oe*100}%)`},children:[s.jsx("div",{className:"w-full shrink-0 h-full overflow-y-auto scrollbar-thin",children:N.length===0?s.jsx("div",{className:"p-6 text-center text-xs text-fg-tertiary",children:m("team:notifications.noApprovals")}):s.jsxs("div",{className:"divide-y divide-border-default/50",children:[xe.map(de=>{const $e=de.details?.command,qe=$e?de.description.replace(/\s*Command:.*$/,""):de.description;return s.jsxs("div",{className:"px-3 py-3 space-y-2.5",children:[s.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:()=>he(de),children:[s.jsxs("div",{className:"flex items-start gap-2",children:[s.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:s.jsx("path",{d:So.approval_request})}),s.jsxs("div",{className:"flex-1 min-w-0",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[xt(de)&&s.jsx("span",{className:"text-[10px] text-amber-500 font-medium shrink-0",children:xt(de)}),s.jsx("span",{className:"text-xs text-fg-primary font-medium truncate",children:de.title}),s.jsx("span",{className:"text-[10px] text-fg-tertiary shrink-0",children:No(de.requestedAt,m)})]}),s.jsx("div",{className:"text-[11px] text-fg-tertiary mt-0.5",children:de.agentName})]})]}),s.jsx("div",{className:"mt-2.5 text-[11px] text-fg-secondary leading-relaxed",children:s.jsx(Ar,{content:qe,className:"text-[11px] [&_h1]:text-xs [&_h2]:text-[11px] [&_h3]:text-[11px] [&_p]:text-[11px] [&_li]:text-[11px]"})}),$e&&s.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:$e})]}),(()=>{if(gd(de))return Ze(de);const q=de.details?.subType,ie=q==="task"||q==="requirement"||q==="requirement_resubmit",Se=de.options&&de.options.length>0,Ie=(H[de.id]??"").trim();return Se?s.jsxs("div",{className:"space-y-1.5",children:[de.options.map((Xe,yt)=>s.jsxs("button",{disabled:C===de.id,onClick:()=>Ge(de.id,Xe.id!=="reject",Ie||void 0,Xe.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 ${Xe.id==="reject"||Xe.id==="request_changes"?"border border-border-default text-fg-secondary hover:bg-surface-overlay":"bg-brand-600 text-white hover:bg-brand-700"}`,title:Xe.description,children:[s.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+yt)}),Xe.label]},Xe.id)),s.jsxs("div",{className:"flex gap-1.5 mt-1",children:[s.jsx("input",{type:"text",placeholder:m("team:notifications.freeformPlaceholder"),value:H[de.id]??"",onChange:Xe=>W(yt=>({...yt,[de.id]:Xe.target.value})),onKeyDown:Xe=>{Xe.key==="Enter"&&(H[de.id]??"").trim()&&Ge(de.id,!0,(H[de.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"}),s.jsx("button",{disabled:C===de.id||!(H[de.id]??"").trim(),onClick:()=>Ge(de.id,!0,(H[de.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:m("common:send")})]})]}):ie?s.jsxs("div",{className:"space-y-1.5",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsxs("button",{disabled:C===de.id,onClick:()=>Ge(de.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:[s.jsx("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round",children:s.jsx("path",{d:"M20 6L9 17l-5-5"})}),m("common:approve")]}),s.jsxs("button",{disabled:C===de.id,onClick:()=>Ge(de.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:[s.jsxs("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round",children:[s.jsx("path",{d:"M18 6L6 18"}),s.jsx("path",{d:"M6 6l12 12"})]}),m("common:reject")]}),z!==de.id&&s.jsxs("button",{disabled:C===de.id,onClick:()=>D(de.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:[s.jsxs("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[s.jsx("path",{d:"M11 4H4a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2v-7"}),s.jsx("path",{d:"M18.5 2.5a2.121 2.121 0 0 1 3 3L12 15l-4 1 1-4 9.5-9.5z"})]}),m("team:notifications.needsAdjustment")]})]}),z===de.id&&s.jsxs("div",{className:"space-y-1.5",children:[s.jsx("input",{type:"text",autoFocus:!0,placeholder:m("team:notifications.adjustmentPlaceholder"),value:H[de.id]??"",onChange:Xe=>W(yt=>({...yt,[de.id]:Xe.target.value})),onKeyDown:Xe=>{Xe.key==="Enter"&&(H[de.id]??"").trim()&&Ge(de.id,!1,(H[de.id]??"").trim(),"needs_adjustment"),Xe.key==="Escape"&&D(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"}),s.jsxs("div",{className:"flex gap-2",children:[s.jsx("button",{disabled:C===de.id||!(H[de.id]??"").trim(),onClick:()=>Ge(de.id,!1,(H[de.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:m("team:notifications.confirmAdjustment")}),s.jsx("button",{onClick:()=>D(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:m("common:cancel")})]})]})]}):s.jsxs("div",{className:"space-y-1.5",children:[s.jsx("input",{type:"text",placeholder:m("team:notifications.commentPlaceholder"),value:H[de.id]??"",onChange:Xe=>W(yt=>({...yt,[de.id]:Xe.target.value})),onKeyDown:Xe=>{Xe.key==="Enter"&&Ge(de.id,!0,Ie||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"}),s.jsxs("div",{className:"flex gap-2",children:[s.jsx("button",{disabled:C===de.id,onClick:()=>Ge(de.id,!0,Ie||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:m("common:approve")}),s.jsx("button",{disabled:C===de.id,onClick:()=>Ge(de.id,!1,Ie||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:m("common:reject")})]})]})})()]},de.id)}),We.length>0&&s.jsxs(s.Fragment,{children:[xe.length>0&&s.jsx("div",{className:"px-3 py-1.5 text-[10px] font-medium text-fg-tertiary uppercase tracking-wider bg-surface-overlay/30",children:m("team:notifications.approvalHistory")}),We.slice(0,50).map(de=>s.jsxs("button",{onClick:()=>he(de),className:"w-full text-left px-3 py-2.5 hover:bg-surface-overlay/50 transition-colors",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("span",{className:`w-1.5 h-1.5 rounded-full shrink-0 ${de.status==="approved"?"bg-green-500":de.status==="cancelled"||de.status==="expired"?"bg-gray-400":"bg-red-500"}`}),s.jsx("span",{className:"text-xs text-fg-secondary truncate flex-1",children:de.title}),s.jsx("span",{className:`text-[10px] font-medium shrink-0 ${de.status==="approved"?"text-green-500":de.status==="cancelled"||de.status==="expired"?"text-fg-muted":"text-red-500"}`,children:m(`common:status.${de.status}`,{defaultValue:de.status})})]}),s.jsxs("div",{className:"flex items-center gap-1.5 mt-0.5 pl-3.5",children:[s.jsx("span",{className:"text-[10px] text-fg-muted truncate",children:pe(de)}),s.jsx("span",{className:"text-[10px] text-fg-muted shrink-0",children:"·"}),s.jsx("span",{className:"text-[10px] text-fg-muted shrink-0",children:No(de.respondedAt??de.requestedAt,m)})]})]},de.id))]})]})}),s.jsx("div",{className:"w-full shrink-0 h-full overflow-y-auto scrollbar-thin",children:Ne.length===0?s.jsx("div",{className:"p-6 text-center text-xs text-fg-tertiary",children:m("team:notifications.noNotifications")}):s.jsx("div",{className:"divide-y divide-border-default/50",children:Ne.slice(0,50).map(de=>{const $e=c4[de.type]??"text-fg-tertiary";return s.jsxs("button",{onClick:()=>nt(de),className:`w-full text-left px-3 py-2.5 flex gap-2.5 transition-colors ${de.read?"opacity-50 hover:opacity-70":"hover:bg-surface-overlay"}`,children:[s.jsx("div",{className:"shrink-0 mt-0.5",children:s.jsx("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",className:$e,children:s.jsx("path",{d:So[de.type]??So.system})})}),s.jsxs("div",{className:"flex-1 min-w-0",children:[s.jsxs("div",{className:"flex items-center gap-1.5",children:[!de.read&&s.jsx("span",{className:`w-1.5 h-1.5 rounded-full shrink-0 ${bd[de.priority]??bd.normal}`}),s.jsx("span",{className:"text-xs text-fg-primary font-medium truncate",children:de.title})]}),s.jsx("div",{className:"text-[11px] text-fg-tertiary mt-0.5 ",children:s.jsx(Ar,{content:de.body,className:"text-[11px] [&_h1]:text-xs [&_h2]:text-[11px] [&_h3]:text-[11px] [&_p]:text-[11px] [&_li]:text-[11px] [&_p]:text-fg-tertiary"})}),s.jsxs("div",{className:"flex items-center gap-2 mt-0.5",children:[s.jsx("span",{className:"text-[10px] text-fg-muted",children:No(de.createdAt,m)}),yd(de,m)&&s.jsx("span",{className:`text-[10px] font-medium ${$e}`,children:yd(de,m)})]})]})]},de.id)})})})]})})]})]})}if(o){const R=d||"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 s.jsxs(s.Fragment,{children:[rt,s.jsxs("button",{ref:Y,onClick:()=>{p(!h),h||De()},title:e?u||m("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 ${h||l?"bg-surface-overlay":"hover:bg-surface-overlay/60"}`,children:[s.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:s.jsx("path",{d:R})}),e?s.jsx("span",{className:"text-[9px] leading-tight truncate w-full text-center",children:u}):s.jsx("span",{className:"truncate",children:u}),bt>0&&s.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:bt>99?m("common:badgeOverLimit"):bt})]}),h&&Ja.createPortal(s.jsx("div",{ref:ae,className:"fixed bg-surface-secondary border border-border-default rounded-xl shadow-2xl z-[9999] flex flex-col overflow-hidden",style:{top:X.top,left:X.left,width:X.width,maxHeight:X.maxHeight},children:St}),document.body),hn]})}return s.jsxs(s.Fragment,{children:[rt,s.jsxs("button",{ref:Y,onClick:()=>{p(!h),h||De()},className:`relative flex items-center justify-center rounded-md transition-colors ${e?"w-8 h-8":"w-7 h-7"} ${h?"bg-surface-overlay text-fg-primary":"text-fg-tertiary hover:text-fg-secondary hover:bg-surface-overlay"}`,title:m("team:notifications.bellTitle"),children:[s.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[s.jsx("path",{d:"M18 8A6 6 0 0 0 6 8c0 7-3 9-3 9h18s-3-2-3-9"}),s.jsx("path",{d:"M13.73 21a2 2 0 0 1-3.46 0"})]}),bt>0&&s.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:bt>99?m("common:badgeOverLimit"):bt})]}),h&&Ja.createPortal(s.jsx("div",{ref:ae,className:"fixed bg-surface-secondary border border-border-default rounded-xl shadow-2xl z-[9999] flex flex-col overflow-hidden",style:{top:X.top,left:X.left,width:X.width,maxHeight:X.maxHeight},children:St}),document.body),hn]})}function vd({d:e,size:t=14}){return s.jsx("svg",{width:t,height:t,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",className:"shrink-0",children:s.jsx("path",{d:e})})}const Vh=200;function GV({authUser:e,onLogout:t,onEditProfile:n,showSettingsLink:r=!1,collapsed:o=!1,showVersion:l=!1}){const{t:u}=ft(["nav","common"]),[d,m]=k.useState(!1),[h,p]=k.useState(!1),[g,x]=k.useState(()=>lt.isAuthenticated()),[y,w]=k.useState(()=>ua()),[N,T]=k.useState({top:0,left:0}),C=k.useRef(null),j=k.useRef(null),_=k.useCallback(X=>{if(w(ua()),!lt.isAuthenticated()){x(!1);return}if(!X?.validate){x(!0);return}J4().then(F=>{x(F),w(ua())})},[]);k.useEffect(()=>{_({validate:!0});const X=()=>_(),F=()=>_({validate:!0});return window.addEventListener("markus:hub-auth",X),window.addEventListener("focus",F),()=>{window.removeEventListener("markus:hub-auth",X),window.removeEventListener("focus",F)}},[_]);const O=k.useCallback(()=>{if(!C.current)return;const X=C.current.getBoundingClientRect(),F=window.innerWidth,J=window.innerHeight,B=j.current?.offsetHeight??220;let Q=X.right+8;Q+Vh>F-8&&(Q=Math.max(8,X.left-Vh-8));let re=X.top-B-8;re<8&&(re=Math.min(X.bottom+8,J-B-8)),T({top:Math.max(8,re),left:Q})},[]);k.useLayoutEffect(()=>{if(!d)return;O();const X=requestAnimationFrame(()=>O());return()=>cancelAnimationFrame(X)},[d,O,o]),k.useEffect(()=>{if(!d)return;const X=J=>{const B=J.target;C.current?.contains(B)||j.current?.contains(B)||m(!1)},F=()=>O();return document.addEventListener("mousedown",X),window.addEventListener("resize",F),window.addEventListener("scroll",F,!0),()=>{document.removeEventListener("mousedown",X),window.removeEventListener("resize",F),window.removeEventListener("scroll",F,!0)}},[d,O]);const z=e?.name||y?.displayName||y?.username||u("common:userPlaceholder"),D=e?.email||y?.email||"",H=n5(e?.avatarUrl,y?.avatarUrl),W=g?"bg-emerald-500":"bg-fg-muted",Z=g?y?.username?u("sidebar.hubConnectedAs",{username:y.username}):u("sidebar.hubConnected"):u("sidebar.hubDisconnected"),U=!!(g&&y?.username&&e?.name&&y.username.toLowerCase()!==e.name.toLowerCase()&&y.email?.toLowerCase()!==e.email?.toLowerCase()),Y=()=>{m(!1),_({validate:!0}),at.navigate(me.SETTINGS,{tab:"account"})},ae=d&&Ja.createPortal(s.jsxs("div",{ref:j,className:"fixed bg-surface-elevated border border-border-default rounded-xl shadow-xl z-[9999] overflow-hidden",style:{top:N.top,left:N.left,width:Vh},children:[s.jsxs("div",{className:"px-3.5 py-3 border-b border-border-default flex items-start gap-2",children:[s.jsxs("div",{className:"min-w-0 flex-1",children:[s.jsx("div",{className:"text-sm font-medium text-fg-primary truncate",children:z}),D&&s.jsx("div",{className:"text-xs text-fg-tertiary mt-0.5 truncate",children:D})]}),n&&s.jsx("button",{type:"button",onClick:()=>{m(!1),n()},title:u("common:profile.editProfile"),className:"shrink-0 mt-0.5 p-1.5 rounded-md text-fg-tertiary hover:text-fg-secondary hover:bg-surface-overlay transition-colors",children:s.jsx(vd,{d:"M12 20h9M16.5 3.5a2.12 2.12 0 0 1 3 3L7 19l-4 1 1-4Z",size:14})})]}),s.jsxs("button",{type:"button",onClick:Y,className:"w-full px-3.5 py-2.5 border-b border-border-default flex items-center gap-2 hover:bg-surface-overlay transition-colors text-left",children:[s.jsx("span",{className:`w-2 h-2 rounded-full shrink-0 ${W}`}),s.jsxs("span",{className:"min-w-0 flex-1",children:[s.jsx("span",{className:"text-xs text-fg-secondary block truncate",children:Z}),U&&y?.username&&s.jsx("span",{className:"text-[10px] text-amber-500/90 block truncate mt-0.5",children:u("sidebar.hubAccountMismatch",{username:y.username})})]}),s.jsx("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",className:"text-fg-muted shrink-0",children:s.jsx("path",{d:"m9 18 6-6-6-6"})})]}),s.jsxs("div",{className:"py-1",children:[r&&s.jsxs("button",{type:"button",onClick:()=>{m(!1),at.navigate(me.SETTINGS)},className:"w-full flex items-center gap-2.5 px-3.5 py-2 text-sm text-fg-secondary hover:bg-surface-overlay transition-colors",children:[s.jsx(vd,{d:cc[me.SETTINGS]}),u("settings")]}),window.markusDesktop&&s.jsxs("button",{type:"button",onClick:()=>{m(!1),window.markusDesktop?.openInBrowser()},className:"w-full flex items-center gap-2.5 px-3.5 py-2 text-sm text-fg-secondary hover:bg-surface-overlay transition-colors",children:[s.jsx(vd,{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"}),u("common:openInBrowser")]}),t&&s.jsxs("button",{type:"button",onClick:()=>{m(!1),p(!0)},className:"w-full flex items-center gap-2.5 px-3.5 py-2 text-sm text-fg-secondary hover:bg-surface-overlay transition-colors",children:[s.jsx(vd,{d:"M9 21H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h4M16 17l5-5-5-5M21 12H9"}),u("common:signOut")]})]})]}),document.body);return s.jsxs("div",{className:`relative ${o?"flex justify-center":"flex items-center justify-between gap-2 w-full"}`,children:[s.jsxs("button",{ref:C,type:"button",onClick:()=>m(X=>!X),title:z,className:`relative inline-flex items-center justify-center rounded-full transition-opacity hover:opacity-90 ${o?"p-0.5":""}`,children:[s.jsx(Us,{name:z,avatarUrl:H,size:o?28:32,fallback:"icon"}),s.jsx("span",{className:`absolute bottom-0 right-0 w-2.5 h-2.5 rounded-full border-2 border-surface-secondary ${W}`,title:Z})]}),l&&!o&&s.jsxs("span",{className:"text-[10px] text-fg-muted select-none shrink-0",children:["v","0.9.0-rc.2"]}),ae,h&&t&&s.jsx(dr,{title:u("common:signOutConfirmTitle"),message:u("common:signOutConfirmMessage"),confirmLabel:u("common:signOut"),variant:"primary",onConfirm:()=>{p(!1),t()},onCancel:()=>p(!1)})]})}function VV({d:e,size:t=18}){return s.jsx("svg",{width:t,height:t,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.75",strokeLinecap:"round",strokeLinejoin:"round",className:"shrink-0",children:s.jsx("path",{d:e})})}function KV({currentPage:e,onNavigate:t,authUser:n,collapsed:r,onToggleCollapse:o,onLogout:l}){const{t:u}=ft(["nav","common"]);return s.jsxs("aside",{className:"h-dvh bg-surface-secondary flex flex-col shrink-0 overflow-hidden",children:[s.jsx("div",{className:`flex items-center ${r?"px-2 py-3.5 justify-center":"px-4 h-14 justify-between"}`,children:s.jsxs("button",{onClick:o,title:u(r?"sidebar.expandSidebar":"sidebar.collapseSidebar"),className:"flex items-center gap-2.5 min-w-0 group",children:[s.jsx("img",{src:"/logo.png",alt:"Markus",className:"w-8 h-8 rounded-lg shrink-0"}),!r&&s.jsx("span",{className:"text-[15px] font-bold tracking-tight text-fg-primary whitespace-nowrap",children:"Markus"})]})}),s.jsx("nav",{className:`${r?"p-1":"px-3 py-2"} flex-1 overflow-y-auto scrollbar-thin`,children:$O.map((d,m)=>{const h=HO.filter(g=>g.section===d.key);if(h.length===0)return null;const p=u(`sections.${d.key}`);return s.jsx("div",{children:s.jsxs("div",{className:m>0?"mt-3":"",children:[!r&&p&&s.jsx("div",{className:"px-3 py-1.5 mb-1 text-[10px] font-semibold text-fg-muted uppercase tracking-[0.1em]",children:p}),r&&m>0&&s.jsx("div",{className:"my-3"}),h.map(g=>{if(g.id===me.NOTIFICATIONS)return s.jsx(qV,{sidebarMode:!0,collapsed:r,userId:n?.id,label:u(g.id),iconPath:cc[g.id],isActive:e===g.id},g.id);const x=e===g.id;return s.jsxs("button",{onClick:()=>t(g.id),title:r?u(g.id):void 0,className:`w-full flex items-center ${r?"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 ${x?"bg-surface-overlay":"hover:bg-surface-overlay/60"}`,children:[s.jsx(VV,{d:cc[g.id]??"",size:r?16:18}),r?s.jsx("span",{className:"text-[9px] leading-tight truncate w-full text-center",children:u(g.id)}):s.jsx("span",{className:"truncate",children:u(g.id)})]},g.id)})]})},d.key)})}),s.jsx("div",{className:`shrink-0 border-t border-border-subtle ${r?"p-1.5 flex justify-center":"px-3 py-2.5"}`,children:s.jsx(GV,{authUser:n,onLogout:l,onEditProfile:()=>{window.dispatchEvent(new Event("markus:open-edit-profile"))},showSettingsLink:!1,collapsed:r,showVersion:!r})})]})}const WV=6e4;let Ps={},gi={};const Up=new Set,$p=new Set;let b3=0,sc=null,wd=0,Ld=null;function c0(){for(const e of Up)e()}async function Hp(){try{const e=await Ce.unread.getCounts();Ps=e.counts??{},gi=e.sessionAgentMap??{},c0()}catch{}}function YV(){sc||(Hp(),sc=setInterval(Hp,WV),Ld=va.on("chat:unread_update",e=>{const t=e.payload?.conversationKey;t&&!$p.has(t)&&Date.now()>b3&&(Ps[t]=(Ps[t]??0)+1,c0())}))}function XV(){sc&&(clearInterval(sc),sc=null),Ld&&(Ld(),Ld=null)}function QV(e){const t=e?.enabled??!0,[n,r]=k.useState(Ps),[o,l]=k.useState(gi),u=k.useCallback(async()=>{await Hp()},[]),d=k.useCallback(async w=>{const N=new Date().toISOString();delete Ps[w],c0();try{await Ce.unread.markRead(w,N)}catch{}},[]),m=k.useCallback(async()=>{Ps={},c0();try{await Ce.unread.markAllRead()}catch{}},[]),h=k.useCallback(w=>{$p.add(w)},[]),p=k.useCallback(w=>{$p.delete(w),b3=Date.now()+150},[]);k.useEffect(()=>{if(!t)return;wd++,YV();let w=gi;const N=()=>{r({...Ps}),w!==gi&&(w=gi,l({...gi}))};return Up.add(N),r({...Ps}),l({...gi}),()=>{Up.delete(N),wd--,wd<=0&&(wd=0,XV())}},[t]);const g=k.useMemo(()=>Object.values(n).reduce((w,N)=>w+N,0),[n]),x=k.useCallback(w=>n[`session:${w}`]??0,[n]),y=k.useCallback(w=>n[`channel:${w}`]??0,[n]);return{counts:n,totalUnread:g,sessionAgentMap:o,getSessionUnread:x,getChannelUnread:y,markRead:d,markAllRead:m,refresh:u,setActiveKey:h,clearActiveKey:p}}function MW(e,t){return k.useMemo(()=>{const n=new Map;for(const[r,o]of Object.entries(t))if(r.startsWith("session:")){const l=r.slice(8),u=e[l];u&&n.set(u,(n.get(u)??0)+o)}return n},[e,t])}function ZV({currentPage:e,onNavigate:t,userId:n}){const{t:r}=ft("nav"),[o,l]=k.useState(0),{counts:u}=QV({enabled:!0}),d=k.useMemo(()=>{let h=0;for(const p of Object.values(u))h+=p;return h},[u]),m=k.useCallback(async()=>{try{const h=await Ce.notifications.list(n,!1);l(h.unreadCount??h.notifications.filter(p=>!p.read).length)}catch{}},[n]);return k.useEffect(()=>{m();const h=setInterval(()=>{document.visibilityState==="visible"&&m()},3e4),p=()=>m();return window.addEventListener("markus:notifications-changed",p),()=>{clearInterval(h),window.removeEventListener("markus:notifications-changed",p)}},[m]),s.jsx("nav",{className:"fixed bottom-0 left-0 right-0 z-50 bg-surface-secondary flex items-stretch h-14 safe-area-bottom",children:FO.map(h=>{const p=h.group.includes(e),g=h.id===me.NOTIFICATIONS,x=h.id===me.TEAM;return s.jsxs("button",{onClick:()=>t(h.id),className:`flex-1 flex flex-col items-center justify-center gap-0.5 transition-colors ${p?"text-fg-primary":"text-fg-tertiary active:text-fg-secondary"}`,children:[s.jsxs("div",{className:"relative",children:[s.jsx("svg",{width:20,height:20,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:p?2:1.75,strokeLinecap:"round",strokeLinejoin:"round",className:"shrink-0",children:s.jsx("path",{d:cc[h.id]})}),g&&o>0&&s.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:o>99?"99+":o}),x&&d>0&&s.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:d>99?"99+":d})]}),s.jsx("span",{className:`text-[10px] leading-tight ${p?"font-semibold":""}`,children:r(h.id)})]},h.id)})})}const u0=new Map;function pi(e,t){u0.has(e)||u0.set(e,t().catch(()=>{}))}function vi(e){const t=u0.get(e);return u0.delete(e),t}const Tr={builderArtifacts:"builder.artifacts",builderAgents:"builder.agents",builderHubMyItems:"builder.hubMyItems",builderInstalled:"builder.installed",hubAgents:"hub.agents",hubTeams:"hub.teams",hubSkills:"hub.skills"},Ti={agent:{label:"Agent",labelZh:"智能体",gradient:"from-violet-500 to-indigo-600",accent:"#8b5cf6",covers:[["#7c3aed","#4f46e5"],["#8b5cf6","#6366f1"],["#a855f7","#4338ca"],["#6d28d9","#2563eb"]]},team:{label:"Team",labelZh:"AI 小队",gradient:"from-cyan-500 to-blue-600",accent:"#06b6d4",covers:[["#0891b2","#2563eb"],["#06b6d4","#3b82f6"],["#0e7490","#1d4ed8"],["#22d3ee","#4f46e5"]]},skill:{label:"Skill",labelZh:"技能",gradient:"from-amber-500 to-orange-600",accent:"#f59e0b",covers:[["#f59e0b","#ea580c"],["#d97706","#dc2626"],["#fbbf24","#f97316"],["#f59e0b","#b45309"]]},connector:{label:"Connector",labelZh:"连接器",gradient:"from-emerald-500 to-teal-600",accent:"#10b981",covers:[["#10b981","#0d9488"],["#059669","#0891b2"],["#34d399","#14b8a6"],["#16a34a","#0f766e"]]}};function Wo(e){const t=(e||"").toLowerCase();return t==="team"?"team":t==="skill"?"skill":t==="connector"||t==="mcp"?"connector":"agent"}function x3(e){let t=2166136261;for(let n=0;n<e.length;n++)t^=e.charCodeAt(n),t=Math.imul(t,16777619);return t>>>0}const JV={agent:258,team:205,skill:32,connector:162};function Mg(e,t){const n=JV[e],r=x3(t),o=((n+(r%68-34))%360+360)%360,l=(o+22+(r>>>8)%24)%360;return`linear-gradient(${120+r%44}deg, hsl(${o} 72% 56%), hsl(${l} 66% 43%))`}const m4=["M12 2l2.4 6.9L21 9l-5.4 4 2 7-5.6-4.1L6.4 20l2-7L3 9l6.6-.1z","M12 2a10 10 0 100 20 10 10 0 000-20zm0 4a6 6 0 110 12 6 6 0 010-12z","M4 4h7v7H4zM13 4h7v7h-7zM4 13h7v7H4zM13 13h7v7h-7z","M12 2l9 5v10l-9 5-9-5V7z","M3 12a9 9 0 019-9v9h9a9 9 0 11-18 0z","M6 3h12l3 6-9 12L3 9z","M12 3l3 6 6 .9-4.5 4.3 1 6.3L12 18l-5.5 2.5 1-6.3L3 9.9 9 9z","M4 12a8 8 0 018-8v4a4 4 0 00-4 4zm8 8a8 8 0 01-8-8h4a4 4 0 004 4z","M12 2l7 4v12l-7 4-7-4V6z M12 6l-3 1.7v3.4L12 13l3-1.9V7.7z","M3 6h18M3 12h18M3 18h18","M12 2a10 10 0 100 20A6 6 0 0112 8a6 6 0 010 12","M12 2l4 8h-8zM4 12h16l-8 10z"];function y3(e){return m4[x3(e+"g")%m4.length]}function v3(e){return e?e.startsWith("http://")||e.startsWith("https://")||e.startsWith("/")||e.startsWith("data:")||/\.(png|jpe?g|gif|webp|svg)$/i.test(e):!1}function eK(e){return!e||v3(e)?!1:[...e].length<=4&&new RegExp("\\p{Extended_Pictographic}","u").test(e)}function tK(e,t="user"){const n=t==="org"?"shapes":"thumbs",r=encodeURIComponent(e);return`https://api.dicebear.com/9.x/${n}/svg?seed=${r}&radius=50&backgroundType=gradientLinear`}function Ao(e){const t=e??0;return t<1e3?String(t):t<1e6?`${(t/1e3).toFixed(t<1e4?1:0)}k`.replace(".0k","k"):`${(t/1e6).toFixed(1)}M`.replace(".0M","M")}function f4(e,t="usd"){return!e||e<=0?"Free":`${t.toLowerCase()==="usd"?"$":""}${(e/100).toFixed(e%100===0?0:2)}`}const h4={agent:{icon:"✦",label:"Agent",color:"text-brand-500",gradient:"from-brand-500 to-purple-600",bg:"bg-brand-500/10",ring:"ring-brand-500/30"},team:{icon:"◈",label:"Team",color:"text-blue-600",gradient:"from-blue-500 to-blue-600",bg:"bg-blue-500/10",ring:"ring-blue-500/30"},skill:{icon:"⬡",label:"Skill",color:"text-green-600",gradient:"from-green-500 to-green-600",bg:"bg-green-500/10",ring:"ring-green-500/30"}},nK=["development","devops","management","productivity","browser","custom","general"],rK=[{label:"Tech",emojis:["✦","◈","⬡","⚡","🤖","🧠","💡","🎯","🔧","📦","🚀","💻","🛠️","⭐","🔥","💎","⚙️","🧩","🔌","💾","🖥️","📡","🔬","🧪","🏗️","📱","🎮","🕹️","📟","💽","🖨️","⌨️"]},{label:"People",emojis:["👤","👥","🧑‍💻","👨‍💼","👩‍🔬","🧙","🦸","🤝","💪","🎓","👷","🕵️","🧑‍🎨","🧑‍🏫","👨‍🚀","🥷","🧑‍🏭","🧑‍⚕️","🧑‍🔧","🧑‍🍳","👨‍🎤","🦹","🧝","🧞","🧑‍✈️","💂","🤴","👸","🧛","🧟","🧜","🧚"]},{label:"Objects",emojis:["📝","📊","🗂️","📁","🔍","🔑","🌐","💬","🔒","🎨","📐","🗃️","📋","✏️","🖊️","📌","📎","🧲","🪝","🧰","🪜","🧬","🔭","💊","🩺","📕","📗","📘","📙","📓","🗒️","📰"]},{label:"Symbols",emojis:["❤️","🧡","💛","💚","💙","💜","🖤","🤍","♠️","♥️","♦️","♣️","🎵","🎶","💯","✅","❌","⭕","🔴","🟠","🟡","🟢","🔵","🟣","⚫","⚪","🟤","🔶","🔷","▶️","⏸️","⏹️"]},{label:"Nature",emojis:["🌟","🌈","🌊","🌿","🍀","🔮","💫","✨","🌙","☀️","🦋","🐉","🦊","🐺","🦅","🐙","🦁","🐯","🦄","🐲","🌸","🌺","🍄","🌵","🎄","🌴","🍁","🌻","🐝","🦎","🐍","🦈"]},{label:"Activity",emojis:["🎯","🏆","🥇","🎖️","🏅","🎪","🎭","🎬","🎤","🎧","🎼","🎹","🥁","🎸","🎺","🎻","⚽","🏀","🎾","🏐","🎲","🧸","🪁","🎰","🎳","🏹","🥊","🤺","⛷️","🏄","🚴","🧗"]}],aK={shell:{icon:">",color:"bg-amber-500/15 text-amber-400 border-amber-500/30"},file:{icon:"◫",color:"bg-blue-500/15 text-blue-400 border-blue-500/30"},network:{icon:"◎",color:"bg-purple-500/15 text-purple-400 border-purple-500/30"},browser:{icon:"◉",color:"bg-brand-500/15 text-brand-400 border-brand-500/30"}};function Kh({value:e,onChange:t,renderAs:n="span",className:r,editClassName:o,placeholder:l,multiline:u,readOnly:d}){if(d){const _=e||l,z=`${r??""} ${!e?"text-fg-muted italic":""}`;return n==="h1"?s.jsx("h1",{className:z,children:_}):n==="p"?s.jsx("p",{className:z,children:_}):s.jsx("span",{className:z,children:_})}const[m,h]=k.useState(!1),[p,g]=k.useState(e),x=k.useRef(null);k.useEffect(()=>{g(e)},[e]),k.useEffect(()=>{m&&x.current?.focus()},[m]);const y=()=>{h(!1),p!==e&&t(p)},w=()=>{g(e),h(!1)},N=_=>{_.key==="Escape"&&w(),_.key==="Enter"&&!u&&y()};if(m){const _=`bg-transparent outline-none w-full ${o??r??""} ring-1 ring-brand-500/50 rounded px-1 -mx-1`;return u?s.jsx("textarea",{ref:x,value:p,onChange:O=>g(O.target.value),onBlur:y,onKeyDown:N,className:`${_} resize-y min-h-[60px]`,placeholder:l}):s.jsx("input",{ref:x,value:p,onChange:O=>g(O.target.value),onBlur:y,onKeyDown:N,className:_,placeholder:l})}const T=e||l,C=!e,j="cursor-text hover:ring-1 hover:ring-border-default rounded px-1 -mx-1 transition-all";return n==="h1"?s.jsx("h1",{onClick:()=>h(!0),className:`${r??""} ${j} ${C?"text-fg-muted italic":""}`,children:T}):n==="p"?s.jsx("p",{onClick:()=>h(!0),className:`${r??""} ${j} ${C?"text-fg-muted italic":""}`,children:T}):n==="badge"?s.jsx("span",{onClick:()=>h(!0),className:`${r??""} ${j} ${C?"text-fg-muted italic":""}`,children:T}):s.jsx("span",{onClick:()=>h(!0),className:`${r??""} ${j} ${C?"text-fg-muted italic":""}`,children:T})}function sK({value:e,options:t,onChange:n,className:r,readOnly:o}){if(o)return s.jsx("span",{className:r,children:e});const[l,u]=k.useState(!1),[d,m]=k.useState(e),h=k.useRef(null),p=k.useRef(null);k.useEffect(()=>{l&&(m(e),setTimeout(()=>h.current?.focus(),0))},[l,e]);const g=t.filter(y=>y.toLowerCase().includes(d.toLowerCase())),x=y=>{const w=y.trim();w&&w!==e&&n(w),u(!1)};return l?s.jsxs("div",{ref:p,className:"relative inline-block",children:[s.jsx("input",{ref:h,value:d,onChange:y=>m(y.target.value),onKeyDown:y=>{y.key==="Enter"?(y.preventDefault(),x(d)):y.key==="Escape"&&u(!1)},onBlur:y=>{p.current?.contains(y.relatedTarget)||x(d)},className:`${r??""} bg-transparent outline-none ring-1 ring-brand-500/50 rounded w-28`}),g.length>0&&s.jsx("div",{className:"absolute top-full left-0 mt-1 z-50 bg-surface-elevated border border-border-default rounded-lg shadow-xl py-1 min-w-[120px] max-h-40 overflow-y-auto",children:g.map(y=>s.jsx("button",{onMouseDown:w=>{w.preventDefault(),x(y)},className:`block w-full text-left px-3 py-1.5 text-xs hover:bg-surface-secondary/80 transition-colors ${y===e?"text-brand-400 font-medium":"text-fg-secondary"}`,children:y},y))})]}):s.jsx("span",{onClick:()=>u(!0),className:`${r??""} cursor-pointer hover:ring-1 hover:ring-border-default rounded px-1 -mx-1 transition-all`,children:e})}function iK({tags:e,onChange:t,readOnly:n}){if(n)return s.jsx("div",{className:"flex flex-wrap items-center gap-1.5 min-h-[24px]",children:e.map(p=>s.jsx("span",{className:"text-[10px] px-2 py-0.5 bg-surface-elevated text-fg-muted rounded-full border border-border-default",children:p},p))});const{t:r}=ft(["builder"]),[o,l]=k.useState(!1),[u,d]=k.useState(""),m=k.useRef(null);k.useEffect(()=>{o&&m.current?.focus()},[o]);const h=p=>{if((p.key==="Enter"||p.key===",")&&u.trim()){p.preventDefault();const g=u.trim().toLowerCase();e.includes(g)||t([...e,g]),d("")}else p.key==="Backspace"&&!u&&e.length>0?t(e.slice(0,-1)):p.key==="Escape"&&(l(!1),d(""))};return o?s.jsxs("div",{className:"flex flex-wrap items-center gap-1.5 ring-1 ring-brand-500/50 rounded px-2 py-1 -mx-1 min-h-[32px]",children:[e.map(p=>s.jsxs("span",{className:"inline-flex items-center gap-1 text-[10px] bg-surface-elevated text-fg-secondary rounded-full px-2 py-0.5 border border-border-default",children:[p,s.jsx("button",{onClick:()=>t(e.filter(g=>g!==p)),className:"text-fg-muted hover:text-red-500",children:"×"})]},p)),s.jsx("input",{ref:m,value:u,onChange:p=>d(p.target.value),onKeyDown:h,onBlur:()=>{u||l(!1)},className:"flex-1 min-w-[80px] bg-transparent text-xs text-fg-primary placeholder:text-fg-muted focus:outline-none",placeholder:r("detail.typeTagAndEnter")})]}):s.jsx("div",{onClick:()=>l(!0),className:"flex flex-wrap items-center gap-1.5 cursor-text hover:ring-1 hover:ring-border-default rounded px-1 -mx-1 py-0.5 transition-all min-h-[24px]",children:e.length>0?e.map(p=>s.jsx("span",{className:"text-[10px] px-2 py-0.5 bg-surface-elevated text-fg-muted rounded-full border border-border-default",children:p},p)):s.jsx("span",{className:"text-[10px] text-fg-muted italic",children:r("detail.typeTagAndEnter")})})}function Fp({content:e}){return s.jsx("div",{className:`prose prose-invert prose-sm max-w-none
657
+ `)||void 0;o({approved:D,comment:W,selectedOption:H,answers:z})};return Ja.createPortal(s.jsx("div",{className:"fixed inset-0 z-[10000] flex items-center justify-center p-4 bg-black/50 backdrop-blur-sm",onMouseDown:z=>{z.target===z.currentTarget&&r()},children:s.jsxs("div",{className:"w-full max-w-2xl max-h-[85vh] flex flex-col bg-surface-secondary border border-border-default rounded-2xl shadow-2xl overflow-hidden",children:[s.jsxs("div",{className:"flex items-start gap-3 px-6 py-4 border-b border-border-default shrink-0",children:[s.jsx("div",{className:"w-9 h-9 rounded-lg bg-amber-500/15 text-amber-500 flex items-center justify-center shrink-0",children:s.jsxs("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[s.jsx("path",{d:"M12 2a10 10 0 1 0 0 20 10 10 0 0 0 0-20z"}),s.jsx("path",{d:"M12 8v4"}),s.jsx("path",{d:"M12 16h.01"})]})}),s.jsxs("div",{className:"flex-1 min-w-0",children:[s.jsx("h2",{className:"text-base font-semibold text-fg-primary leading-snug",children:e.title}),s.jsxs("div",{className:"flex items-center gap-2 mt-0.5",children:[s.jsx("p",{className:"text-xs text-fg-tertiary",children:e.agentName}),n&&s.jsxs("span",{className:"inline-flex items-center gap-1 px-1.5 py-0.5 rounded text-[10px] font-medium bg-green-500/15 text-green-600",children:[s.jsx("svg",{width:"10",height:"10",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"3",strokeLinecap:"round",strokeLinejoin:"round",children:s.jsx("path",{d:"M20 6L9 17l-5-5"})}),l("team:userInput.submitted",{defaultValue:"Submitted"})]})]})]}),s.jsx("button",{onClick:r,className:"p-1.5 text-fg-tertiary hover:text-fg-primary rounded-md hover:bg-surface-overlay transition-colors shrink-0",title:l("common:close"),children:s.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[s.jsx("path",{d:"M18 6L6 18"}),s.jsx("path",{d:"M6 6l12 12"})]})})]}),s.jsxs("div",{className:"flex-1 overflow-y-auto px-6 py-5 space-y-4",children:[y&&s.jsx("div",{className:"flex items-center gap-2",children:u.map((z,D)=>s.jsx("button",{onClick:()=>m(D),className:`h-1.5 flex-1 rounded-full transition-colors ${D===d?"bg-brand-500":C(z)?"bg-green-500/60":"bg-border-default"}`,title:`${D+1}. ${z.prompt.slice(0,40)}`},z.id))}),y&&s.jsx("div",{className:"text-[11px] font-medium text-fg-tertiary",children:l("team:userInput.questionProgress",{current:d+1,total:u.length,defaultValue:`Question ${d+1} of ${u.length}`})}),s.jsx("div",{className:"text-sm text-fg-primary leading-relaxed",children:s.jsx(Ar,{content:g.prompt})}),g.inputType==="choice"&&g.options&&s.jsx("div",{className:"space-y-2",children:g.options.map((z,D)=>{const H=w(g.id).selectedOptionIds.includes(z.id);return s.jsxs("button",{onClick:n?void 0:()=>T(g,z.id),disabled:n,className:`w-full px-4 py-3 text-left rounded-xl border transition-colors flex items-start gap-3 ${H?"border-brand-500 bg-brand-500/10":`border-border-default ${n?"":"hover:bg-surface-overlay"}`} ${n?"cursor-default":""} ${n&&!H?"opacity-50":""}`,children:[s.jsx("span",{className:`w-6 h-6 rounded-full flex items-center justify-center text-[11px] font-bold shrink-0 mt-0.5 ${H?"bg-brand-600 text-white":"bg-surface-overlay text-fg-tertiary"}`,children:H?s.jsx("svg",{width:"13",height:"13",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"3",strokeLinecap:"round",strokeLinejoin:"round",children:s.jsx("path",{d:"M20 6L9 17l-5-5"})}):String.fromCharCode(65+D)}),s.jsxs("span",{className:"flex-1 min-w-0 text-sm text-fg-primary [&_p]:my-0 [&_p]:text-sm",children:[s.jsx(Ar,{content:z.label}),z.description&&s.jsx("span",{className:"block text-xs text-fg-tertiary mt-1 [&_p]:my-0 [&_p]:text-xs",children:s.jsx(Ar,{content:z.description})})]})]},z.id)})}),(g.inputType==="text"||g.allowFreeform)&&(!n||w(g.id).text)&&s.jsx("textarea",{rows:g.inputType==="text"?4:2,readOnly:n,placeholder:g.inputType==="text"?l("team:userInput.textPlaceholder",{defaultValue:"Type your answer…"}):l("team:userInput.freeformPlaceholder",{defaultValue:"Or write your own answer…"}),value:w(g.id).text,onChange:z=>{const D=z.target.value;N(g.id,{text:D,selectedOptionIds:D.trim()&&g.inputType==="choice"?[]:w(g.id).selectedOptionIds})},className:`w-full px-3.5 py-2.5 text-sm bg-surface-overlay border border-border-default rounded-xl text-fg-primary placeholder:text-fg-tertiary focus:outline-none resize-y ${n?"cursor-default opacity-80":"focus:ring-1 focus:ring-brand-500/50"}`})]}),s.jsxs("div",{className:"flex items-center justify-between gap-2 px-6 py-4 border-t border-border-default shrink-0",children:[s.jsx("div",{children:y&&d>0&&s.jsx("button",{onClick:()=>m(z=>Math.max(0,z-1)),className:"px-4 py-2 text-sm font-medium text-fg-secondary border border-border-default rounded-lg hover:bg-surface-overlay transition-colors",children:l("team:userInput.previous",{defaultValue:"Previous"})})}),s.jsx("div",{className:"flex items-center gap-2",children:y&&!x?s.jsx("button",{disabled:!n&&!C(g),onClick:()=>m(z=>Math.min(u.length-1,z+1)),className:"px-5 py-2 text-sm font-medium bg-brand-600 text-white rounded-lg hover:bg-brand-700 disabled:opacity-50 transition-colors",children:l("team:userInput.next",{defaultValue:"Next"})}):n?s.jsx("button",{onClick:r,className:"px-5 py-2 text-sm font-medium text-fg-secondary border border-border-default rounded-lg hover:bg-surface-overlay transition-colors",children:l("common:close",{defaultValue:"Close"})}):s.jsxs("button",{disabled:t||!j,onClick:O,className:"px-5 py-2 text-sm font-medium bg-brand-600 text-white rounded-lg hover:bg-brand-700 disabled:opacity-50 transition-colors inline-flex items-center gap-2",children:[t&&s.jsxs("svg",{className:"animate-spin h-4 w-4",viewBox:"0 0 24 24",fill:"none",children:[s.jsx("circle",{className:"opacity-25",cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"4"}),s.jsx("path",{className:"opacity-75",fill:"currentColor",d:"M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4z"})]}),l("team:userInput.submit",{defaultValue:"Submit"})]})})]})]})}),document.body)}function gd(e){return Array.isArray(e.questions)&&e.questions.length>0}const bd={urgent:"bg-red-500",high:"bg-amber-500",normal:"bg-blue-500",low:"bg-gray-400"},So={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"},c4={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 No(e,t){const n=Date.now()-new Date(e).getTime(),r=Math.floor(n/6e4);if(r<1)return t("common:time.now");if(r<60)return t("common:time.minutesAgo",{count:r});const o=Math.floor(r/60);return o<24?t("common:time.hoursAgo",{count:o}):t("common:time.daysAgo",{count:Math.floor(o/24)})}const u4="markus:template-updates-ack";let qh=!1,xd=null;function FV(e){return e.map(t=>`${t.name}@${t.availableVersion}`).sort().join(",")}function d4(e,t){if(e.type!=="system"||!e.metadata?.templateUpdates)return!1;if(!t)return!0;const n=e.metadata.templateUpdatesFingerprint;return!n||n===t}function yd(e,t){const n=e.actionType;if(n==="open_chat")return t("team:notifications.actionHints.openChat");if(n==="navigate")return t("team:notifications.actionHints.viewDetails");const r=e.metadata??{};switch(e.type){case"task_completed":case"task_created":case"task_review":case"task_failed":return r.taskId?t("team:notifications.actionHints.viewTask"):null;case"requirement_created":case"requirement_decision":return r.requirementId?t("team:notifications.actionHints.viewRequirement"):null;case"agent_report":return r.agentId?t("team:notifications.actionHints.viewAgent"):null;case"direct_message":return t("team:notifications.actionHints.openChat");case"group_message":return t("team:notifications.actionHints.openChat");case"approval_request":return t("team:notifications.actionHints.viewApproval");case"system":return r.templateUpdates?t("common:templateUpdates.actionHint"):null;default:return r.taskId?t("team:notifications.actionHints.viewTask"):r.requirementId?t("team:notifications.actionHints.viewRequirement"):r.agentId?t("team:notifications.actionHints.viewAgent"):null}}function Gh(){try{const e=new AudioContext,t=e.currentTime,n=e.createGain();n.connect(e.destination),n.gain.setValueAtTime(.15,t),n.gain.exponentialRampToValueAtTime(.01,t+.6);const r=e.createOscillator();r.type="sine",r.frequency.setValueAtTime(880,t),r.frequency.setValueAtTime(1174.66,t+.15),r.connect(n),r.start(t),r.stop(t+.6),r.onended=()=>e.close()}catch{}}function qV({collapsed:e,userId:t,embeddedMode:n,onClose:r,sidebarMode:o,isActive:l,label:u,iconPath:d}){const{t:m}=ft(["team","common"]),[h,p]=k.useState(!1),[g,x]=k.useState("approvals"),[y,w]=k.useState([]),[N,T]=k.useState([]),[C,j]=k.useState(null),[_,O]=k.useState(null),[z,D]=k.useState(null),[H,W]=k.useState({}),[Z,U]=k.useState(0),Y=k.useRef(null),ae=k.useRef(null),[X,F]=k.useState({top:0,left:0,width:448,maxHeight:576}),J=k.useRef(null),B=k.useRef(!1),[Q,re]=k.useState(!0),[we,$]=k.useState(!1),G=k.useRef(null),ce=k.useRef("approvals"),[I,Ee]=k.useState(!1),Ue=30,De=k.useCallback(async()=>{try{Wa("/approvals"),Wa("/notifications");const[R,oe]=await Promise.all([Ce.notifications.list(t,!1,{limit:Ue,offset:0}),Ce.approvals.list()]);w(R.notifications);const _e=R.unreadCount??R.notifications.filter(de=>!de.read).length;if(U(_e),re(R.totalCount!=null?R.notifications.length<R.totalCount:R.notifications.length>=Ue),T(oe.approvals),!B.current){const de=oe.approvals.filter($e=>$e.status==="pending").length;J.current=de,B.current=!0}}catch{}},[t]),Ke=k.useCallback(async()=>{if(!(we||!Q)){$(!0);try{const R=await Ce.notifications.list(t,!1,{limit:Ue,offset:y.length});R.notifications.length>0&&w(oe=>[...oe,...R.notifications.filter(_e=>!oe.some(de=>de.id===_e.id))]),re(R.totalCount!=null?y.length+R.notifications.length<R.totalCount:R.notifications.length>=Ue)}catch{}$(!1)}},[t,y.length,we,Q]),st=k.useCallback(R=>{const oe=R.detail;if(!oe)return;const{taskId:_e,requirementId:de}=oe;!_e&&!de||w($e=>{const qe=$e.filter(q=>!q.read&&(_e&&q.metadata?.taskId===_e||de&&q.metadata?.requirementId===de));if(qe.length===0)return $e;for(const q of qe)Ce.notifications.markRead(q.id).catch(()=>{});return U(q=>Math.max(0,q-qe.length)),$e.map(q=>qe.some(ie=>ie.id===q.id)?{...q,read:!0}:q)})},[]),mt=k.useRef(y);mt.current=y;const ct=k.useCallback(async()=>{if(!mt.current.some(oe=>!oe.read&&oe.type==="system"&&oe.metadata?.creditExhausted))try{await Ce.notifications.create({title:m("credits.notificationTitle",{ns:"common"}),body:m("credits.notificationBody",{ns:"common"}),type:"system",priority:"urgent",metadata:{creditExhausted:!0}}),De(),Gh()}catch{}},[De,m]),Dt=k.useCallback(async()=>{if(!qh){qh=!0;try{const{updates:R}=await Ce.skills.updates();if(!R.length)return;const oe=FV(R);try{if(localStorage.getItem(u4)===oe)return}catch{}if(xd===oe||mt.current.some(de=>!de.read&&d4(de,oe)))return;try{const $e=(await Ce.notifications.list(t,!0,{limit:50,type:"system"})).notifications.filter(qe=>d4(qe,oe)).sort((qe,q)=>new Date(q.createdAt).getTime()-new Date(qe.createdAt).getTime());if($e.length>0){for(const qe of $e.slice(1))Ce.notifications.markRead(qe.id).catch(()=>{});$e.length>1&&De(),xd=oe;return}}catch{}xd=oe,await Ce.notifications.create({title:m("templateUpdates.notificationTitle",{ns:"common"}),body:m("templateUpdates.notificationBody",{ns:"common",count:R.length}),type:"system",priority:"high",metadata:{templateUpdates:!0,templateUpdatesFingerprint:oe,count:R.length,skills:R.map(de=>de.name)}}),De(),Gh()}catch{xd=null}finally{qh=!1}}},[De,m,t]);k.useEffect(()=>{De();const R=setInterval(De,6e4);let oe=null;const _e=()=>{oe||(oe=setTimeout(()=>{oe=null,De()},400))},de=()=>_e(),$e=()=>{p(!0),De()};window.addEventListener("markus:notifications-changed",de),window.addEventListener("markus:mark-read-by-ref",st),window.addEventListener("markus:open-notifications",$e),window.addEventListener("markus:credit-exhausted",ct);const qe=va.on("notification",_e),q=va.on("approval:requested",_e);return()=>{clearInterval(R),oe&&clearTimeout(oe),window.removeEventListener("markus:notifications-changed",de),window.removeEventListener("markus:mark-read-by-ref",st),window.removeEventListener("markus:open-notifications",$e),window.removeEventListener("markus:credit-exhausted",ct),qe(),q()}},[De,st,ct]),k.useEffect(()=>{Dt();const R=setInterval(()=>{Dt()},5*6e4),oe=()=>{Dt()};return window.addEventListener("markus:data-changed",oe),()=>{clearInterval(R),window.removeEventListener("markus:data-changed",oe)}},[t]);const Mt=k.useCallback(()=>{if(!Y.current)return;const R=Y.current.getBoundingClientRect(),oe=window.innerWidth,_e=window.innerHeight,de=Math.min(448,oe-16),$e=Math.min(576,_e-16);let qe=R.right+8,q=R.top;qe+de>oe-8&&(qe=Math.max(8,oe-de-8)),q+$e>_e-8&&(q=Math.max(8,_e-$e-8)),F({top:q,left:qe,width:de,maxHeight:$e})},[]);k.useLayoutEffect(()=>{h&&Mt()},[h,Mt]),k.useEffect(()=>{if(h)return window.addEventListener("resize",Mt),()=>window.removeEventListener("resize",Mt)},[h,Mt]),k.useEffect(()=>{if(!h)return;const R=oe=>{Y.current?.contains(oe.target)||ae.current?.contains(oe.target)||p(!1)};return document.addEventListener("mousedown",R),()=>document.removeEventListener("mousedown",R)},[h]),k.useEffect(()=>{if(!h)return;const R=N.some(_e=>_e.status==="pending"),oe=y.some(_e=>!_e.read);x(R&&!oe?"approvals":!R&&oe?"notifications":ce.current)},[h]);const Xt=new Set(N.filter(R=>R.status==="pending").map(R=>R.id)),Me=new Set(N.map(R=>R.id)),Ne=y.filter(R=>!(R.type==="approval_request"&&R.metadata?.approvalId&&Me.has(R.metadata.approvalId))),Re=y.filter(R=>R.type==="approval_request"&&!R.read&&R.metadata?.approvalId&&Xt.has(R.metadata.approvalId)).length,ut=Math.max(0,Z-Re),it=Xt.size,bt=ut+it;k.useEffect(()=>{J.current!==null&&it>J.current&&Gh(),J.current=it},[it]);const se=async R=>{await Ce.notifications.markRead(R),w(oe=>oe.map(_e=>_e.id===R?{..._e,read:!0}:_e)),U(oe=>Math.max(0,oe-1))},et=R=>{const oe=R.metadata??{},_e=R.actionType,de=R.actionTarget;if(_e==="open_chat"&&de)try{const $e=typeof de=="string"?JSON.parse(de):de;if($e.agentId){const qe={agentId:$e.agentId};$e.sessionId&&(qe.sessionId=$e.sessionId),at.navigate(me.TEAM,qe);return}}catch{}if(_e==="navigate"&&de)try{const $e=typeof de=="string"?JSON.parse(de):de;if($e.path){if($e.path.startsWith("/team")){const qe={},q=new URLSearchParams($e.path.split("?")[1]||"");for(const[ie,Se]of q.entries())qe[ie]=Se;at.navigate(me.TEAM,qe);return}if($e.path.startsWith("/work")){const qe={},q=new URLSearchParams($e.path.split("?")[1]||"");for(const[ie,Se]of q.entries())qe[ie]=Se;at.navigate(me.WORK,qe);return}}}catch{}switch(R.type){case"approval_request":{const $e=oe.approvalId,qe=$e?N.find(Ie=>Ie.id===$e):void 0;if(qe&&gd(qe)){O(qe);break}const q=qe?.details?.taskId??oe.taskId,ie=qe?.details?.requirementId??oe.requirementId,Se=qe?.details?.agentId??qe?.agentId;q?at.navigate(me.WORK,{openTask:q}):ie?at.navigate(me.WORK,{openRequirement:ie}):Se?at.navigate(me.TEAM,{agentId:Se}):at.navigate(me.WORK);break}case"task_completed":case"task_created":case"task_review":case"task_failed":oe.taskId?at.navigate(me.WORK,{openTask:oe.taskId}):at.navigate(me.WORK);break;case"requirement_created":case"requirement_decision":oe.requirementId?at.navigate(me.WORK,{openRequirement:oe.requirementId}):at.navigate(me.WORK);break;case"agent_report":case"system":{if(oe.creditExhausted){Ee(!0);return}if(oe.templateUpdates){const $e=oe.templateUpdatesFingerprint;if($e)try{localStorage.setItem(u4,$e)}catch{}localStorage.setItem("markus_nav_storeTab","installed"),at.navigate(me.STORE);return}if(oe.agentId){const $e={agentId:oe.agentId};oe.sessionId&&($e.sessionId=oe.sessionId),at.navigate(me.TEAM,$e)}else at.navigate(me.TEAM);break}case"direct_message":{const $e=oe.senderId;$e?at.navigate(me.TEAM,{dm:$e}):at.navigate(me.TEAM);break}case"group_message":{const $e=oe.channel;$e?at.navigate(me.TEAM,{channel:$e}):at.navigate(me.TEAM);break}default:oe.taskId?at.navigate(me.WORK,{openTask:oe.taskId}):oe.requirementId?at.navigate(me.WORK,{openRequirement:oe.requirementId}):oe.projectId?at.navigate(me.WORK,{projectId:oe.projectId}):oe.agentId&&at.navigate(me.TEAM,{agentId:oe.agentId});break}},nt=async R=>{R.read||se(R.id);const oe=R.metadata??{},_e=oe.taskId,de=oe.requirementId;if(_e||de){const $e=y.filter(qe=>qe.id!==R.id&&!qe.read&&(_e&&qe.metadata?.taskId===_e||de&&qe.metadata?.requirementId===de));for(const qe of $e)se(qe.id)}et(R)},Ge=async(R,oe,_e,de,$e)=>{j(R);try{const{approval:qe}=await Ce.approvals.respond(R,oe,t,_e,de,$e);T(Ie=>Ie.map(Xe=>Xe.id===R?qe:Xe)),O(null),D(null),W(Ie=>{const Xe={...Ie};return delete Xe[R],Xe});const q=qe.details?.taskId,ie=qe.details?.requirementId,Se=y.filter(Ie=>!Ie.read&&(Ie.type==="approval_request"&&Ie.metadata?.approvalId===R||q&&Ie.metadata?.taskId===q||ie&&Ie.metadata?.requirementId===ie));if(Se.length>0){for(const Xe of Se)Ce.notifications.markRead(Xe.id).catch(()=>{});const Ie=new Set(Se.map(Xe=>Xe.id));w(Xe=>Xe.map(yt=>Ie.has(yt.id)?{...yt,read:!0}:yt)),U(Xe=>Math.max(0,Xe-Se.length))}Wa("/approvals"),Wa("/notifications"),Wa("/tasks"),Wa("/taskboard"),Wa("/requirements"),window.dispatchEvent(new CustomEvent("markus:data-changed")),window.dispatchEvent(new CustomEvent("markus:notifications-changed")),setTimeout(()=>De(),800)}catch{}j(null)},Qe=async()=>{try{if(!t)return;await Ce.notifications.markAllRead(t),w(R=>R.map(oe=>({...oe,read:!0}))),U(0),Wa("/notifications")}catch{const R=Ne.filter(oe=>!oe.read);await Promise.all(R.map(oe=>Ce.notifications.markRead(oe.id))),w(oe=>oe.map(_e=>({..._e,read:!0}))),U(0),Wa("/notifications")}},xt=R=>{const oe=R.details?.subType;return oe==="requirement_resubmit"?m("team:notifications.approvalType.requirementResubmit"):oe==="requirement"||R.details?.requirementId?m("team:notifications.approvalType.requirement"):oe==="task_review"?m("team:notifications.approvalType.taskReview"):oe==="task"||R.details?.taskId?m("team:notifications.approvalType.task"):R.details?.toolName?m("team:notifications.approvalType.toolExecution"):null},pe=R=>{const oe=[];oe.push(R.agentName);const _e=R.details?.taskTitle,de=R.details?.taskId;_e?oe.push(_e):de&&oe.push(`Task ${de.slice(0,8)}`);const $e=R.details?.requirementId;return $e&&!de&&oe.push(`Req ${$e.slice(0,8)}`),oe.join(" · ")},V=[...N].sort((R,oe)=>new Date(oe.requestedAt).getTime()-new Date(R.requestedAt).getTime()),xe=V.filter(R=>R.status==="pending"),We=V.filter(R=>R.status!=="pending"),he=R=>{const oe=R.details?.taskId,_e=R.details?.requirementId,de=R.details?.agentId??R.agentId;oe?at.navigate(me.WORK,{openTask:oe}):_e?at.navigate(me.WORK,{openRequirement:_e}):de?at.navigate(me.TEAM,{agentId:de}):at.navigate(me.WORK)},ye=()=>{p(!1),r?.()},Ze=R=>s.jsxs("button",{disabled:C===R.id,onClick:()=>O(R),className:"w-full px-3 py-2 text-[11px] font-medium bg-brand-600 text-white rounded-md hover:bg-brand-700 disabled:opacity-50 transition-colors inline-flex items-center justify-center gap-1.5",children:[s.jsx("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:s.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"})}),m("team:userInput.respond",{defaultValue:"Respond"}),R.questions&&R.questions.length>1?` (${R.questions.length})`:""]}),rt=_?s.jsx(HV,{approval:_,submitting:C===_.id,readOnly:_.status!=="pending",onClose:()=>O(null),onSubmit:R=>Ge(_.id,R.approved,R.comment,R.selectedOption,R.answers)}):null,St=s.jsxs(s.Fragment,{children:[s.jsxs("div",{className:"flex border-b border-border-default shrink-0",children:[s.jsxs("button",{onClick:()=>{x("approvals"),ce.current="approvals"},className:`flex-1 px-3 py-2.5 text-xs font-medium transition-colors ${g==="approvals"?"text-fg-primary border-b-2 border-brand-500":"text-fg-tertiary hover:text-fg-secondary"}`,children:[m("team:notifications.approvals"),it>0?` (${it})`:""]}),s.jsxs("button",{onClick:()=>{x("notifications"),ce.current="notifications"},className:`flex-1 px-3 py-2.5 text-xs font-medium transition-colors ${g==="notifications"?"text-fg-primary border-b-2 border-brand-500":"text-fg-tertiary hover:text-fg-secondary"}`,children:[m("team:notifications.notifications"),ut>0?` (${ut})`:""]}),s.jsx("button",{onClick:ye,className:"px-2 py-2 text-fg-tertiary hover:text-fg-primary transition-colors shrink-0",title:m("common:close"),children:s.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[s.jsx("path",{d:"M18 6L6 18"}),s.jsx("path",{d:"M6 6l12 12"})]})})]}),g==="notifications"&&Z>0&&s.jsx("div",{className:"flex justify-end px-3 py-1.5 border-b border-border-default/50 shrink-0",children:s.jsx("button",{onClick:Qe,className:"text-[10px] text-brand-500 hover:text-brand-400 transition-colors",children:m("team:notifications.markAllRead")})}),s.jsxs("div",{ref:G,className:"flex-1 overflow-y-auto",onScroll:R=>{if(g!=="notifications"||!Q||we)return;const oe=R.currentTarget;oe.scrollTop+oe.clientHeight>=oe.scrollHeight-80&&Ke()},children:[g==="approvals"&&(N.length===0?s.jsx("div",{className:"p-6 text-center text-xs text-fg-tertiary",children:m("team:notifications.noApprovals")}):s.jsxs("div",{className:"divide-y divide-border-default/50",children:[xe.map(R=>{const oe=R.details?.command,_e=oe?R.description.replace(/\s*Command:.*$/,""):R.description;return s.jsxs("div",{className:"px-3 py-3 space-y-2.5",children:[s.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:()=>he(R),children:[s.jsxs("div",{className:"flex items-start gap-2",children:[s.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:s.jsx("path",{d:So.approval_request})}),s.jsxs("div",{className:"flex-1 min-w-0",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[xt(R)&&s.jsx("span",{className:"text-[10px] text-amber-500 font-medium shrink-0",children:xt(R)}),s.jsx("span",{className:"text-xs text-fg-primary font-medium truncate",children:R.title}),s.jsx("span",{className:"text-[10px] text-fg-tertiary shrink-0",children:No(R.requestedAt,m)})]}),s.jsx("div",{className:"text-[11px] text-fg-tertiary mt-0.5",children:R.agentName})]})]}),s.jsx("div",{className:"mt-2.5 text-[11px] text-fg-secondary leading-relaxed",children:s.jsx(Ar,{content:_e,className:"text-[11px] [&_h1]:text-xs [&_h2]:text-[11px] [&_h3]:text-[11px] [&_p]:text-[11px] [&_li]:text-[11px]"})}),oe&&s.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:oe})]}),(()=>{if(gd(R))return Ze(R);const de=R.details?.subType,$e=de==="task"||de==="requirement"||de==="requirement_resubmit",qe=R.options&&R.options.length>0,q=(H[R.id]??"").trim();return qe?s.jsxs("div",{className:"space-y-1.5",children:[R.options.map((ie,Se)=>s.jsxs("button",{disabled:C===R.id,onClick:()=>Ge(R.id,ie.id!=="reject",q||void 0,ie.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 ${ie.id==="reject"||ie.id==="request_changes"?"border border-border-default text-fg-secondary hover:bg-surface-overlay":"bg-brand-600 text-white hover:bg-brand-700"}`,title:ie.description,children:[s.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+Se)}),ie.label]},ie.id)),s.jsxs("div",{className:"flex gap-1.5 mt-1",children:[s.jsx("input",{type:"text",placeholder:m("team:notifications.freeformPlaceholder"),value:H[R.id]??"",onChange:ie=>W(Se=>({...Se,[R.id]:ie.target.value})),onKeyDown:ie=>{ie.key==="Enter"&&(H[R.id]??"").trim()&&Ge(R.id,!0,(H[R.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"}),s.jsx("button",{disabled:C===R.id||!(H[R.id]??"").trim(),onClick:()=>Ge(R.id,!0,(H[R.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:m("common:send")})]})]}):$e?s.jsxs("div",{className:"space-y-1.5",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsxs("button",{disabled:C===R.id,onClick:()=>Ge(R.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:[s.jsx("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round",children:s.jsx("path",{d:"M20 6L9 17l-5-5"})}),m("common:approve")]}),s.jsxs("button",{disabled:C===R.id,onClick:()=>Ge(R.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:[s.jsxs("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round",children:[s.jsx("path",{d:"M18 6L6 18"}),s.jsx("path",{d:"M6 6l12 12"})]}),m("common:reject")]}),z!==R.id&&s.jsxs("button",{disabled:C===R.id,onClick:()=>D(R.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:[s.jsxs("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[s.jsx("path",{d:"M11 4H4a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2v-7"}),s.jsx("path",{d:"M18.5 2.5a2.121 2.121 0 0 1 3 3L12 15l-4 1 1-4 9.5-9.5z"})]}),m("team:notifications.needsAdjustment")]})]}),z===R.id&&s.jsxs("div",{className:"space-y-1.5",children:[s.jsx("input",{type:"text",autoFocus:!0,placeholder:m("team:notifications.adjustmentPlaceholder"),value:H[R.id]??"",onChange:ie=>W(Se=>({...Se,[R.id]:ie.target.value})),onKeyDown:ie=>{ie.key==="Enter"&&(H[R.id]??"").trim()&&Ge(R.id,!1,(H[R.id]??"").trim(),"needs_adjustment"),ie.key==="Escape"&&D(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"}),s.jsxs("div",{className:"flex gap-2",children:[s.jsx("button",{disabled:C===R.id||!(H[R.id]??"").trim(),onClick:()=>Ge(R.id,!1,(H[R.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:m("team:notifications.confirmAdjustment")}),s.jsx("button",{onClick:()=>D(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:m("common:cancel")})]})]})]}):s.jsxs("div",{className:"space-y-1.5",children:[s.jsx("input",{type:"text",placeholder:m("team:notifications.commentPlaceholder"),value:H[R.id]??"",onChange:ie=>W(Se=>({...Se,[R.id]:ie.target.value})),onKeyDown:ie=>{ie.key==="Enter"&&Ge(R.id,!0,q||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"}),s.jsxs("div",{className:"flex gap-2",children:[s.jsx("button",{disabled:C===R.id,onClick:()=>Ge(R.id,!0,q||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:m("common:approve")}),s.jsx("button",{disabled:C===R.id,onClick:()=>Ge(R.id,!1,q||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:m("common:reject")})]})]})})()]},R.id)}),We.length>0&&s.jsxs(s.Fragment,{children:[xe.length>0&&s.jsx("div",{className:"px-3 py-1.5 text-[10px] font-medium text-fg-tertiary uppercase tracking-wider bg-surface-overlay/30",children:m("team:notifications.approvalHistory")}),We.slice(0,50).map(R=>s.jsxs("button",{onClick:()=>gd(R)?O(R):he(R),className:"w-full text-left px-3 py-2.5 hover:bg-surface-overlay/50 transition-colors group",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("span",{className:`w-1.5 h-1.5 rounded-full shrink-0 ${R.status==="approved"?"bg-green-500":R.status==="cancelled"||R.status==="expired"?"bg-gray-400":"bg-red-500"}`}),xt(R)&&s.jsx("span",{className:"text-[10px] text-fg-tertiary font-medium shrink-0",children:xt(R)}),s.jsx("span",{className:"text-xs text-fg-secondary truncate flex-1 group-hover:text-fg-primary",children:R.title}),s.jsx("span",{className:`text-[10px] font-medium shrink-0 ${R.status==="approved"?"text-green-500":R.status==="cancelled"||R.status==="expired"?"text-fg-muted":"text-red-500"}`,children:m(`common:status.${R.status}`,{defaultValue:R.status})})]}),s.jsxs("div",{className:"flex items-center gap-1.5 mt-0.5 pl-3.5",children:[s.jsx("span",{className:"text-[10px] text-fg-muted truncate",children:pe(R)}),s.jsx("span",{className:"text-[10px] text-fg-muted shrink-0",children:"·"}),s.jsx("span",{className:"text-[10px] text-fg-muted shrink-0",children:No(R.respondedAt??R.requestedAt,m)})]}),R.responseComment&&s.jsxs("p",{className:"text-[10px] text-fg-muted mt-0.5 pl-3.5 truncate",children:["“",R.responseComment,"”"]})]},R.id))]})]})),g==="notifications"&&(Ne.length===0?s.jsx("div",{className:"p-6 text-center text-xs text-fg-tertiary",children:m("team:notifications.noNotifications")}):s.jsxs("div",{className:"divide-y divide-border-default/50",children:[Ne.map(R=>{const oe=c4[R.type]??"text-fg-tertiary";return s.jsxs("div",{role:"button",tabIndex:0,onClick:()=>nt(R),onKeyDown:_e=>{(_e.key==="Enter"||_e.key===" ")&&(_e.preventDefault(),nt(R))},className:`w-full text-left px-3 py-2.5 flex gap-2.5 transition-colors cursor-pointer ${R.read?"opacity-50 hover:opacity-70":"hover:bg-surface-overlay"}`,children:[s.jsx("div",{className:"shrink-0 mt-0.5",children:s.jsx("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",className:oe,children:s.jsx("path",{d:So[R.type]??So.system})})}),s.jsxs("div",{className:"flex-1 min-w-0",children:[s.jsxs("div",{className:"flex items-center gap-1.5",children:[!R.read&&s.jsx("span",{className:`w-1.5 h-1.5 rounded-full shrink-0 ${bd[R.priority]??bd.normal}`}),s.jsx("span",{className:"text-xs text-fg-primary font-medium truncate",children:R.title})]}),s.jsx("div",{className:"text-[11px] text-fg-tertiary mt-0.5 ",children:s.jsx(Ar,{content:R.body,className:"text-[11px] [&_h1]:text-xs [&_h2]:text-[11px] [&_h3]:text-[11px] [&_p]:text-[11px] [&_li]:text-[11px] [&_p]:text-fg-tertiary"})}),s.jsxs("div",{className:"flex items-center gap-2 mt-0.5",children:[s.jsx("span",{className:"text-[10px] text-fg-muted",children:No(R.createdAt,m)}),yd(R,m)&&s.jsx("span",{className:`text-[10px] font-medium ${oe}`,children:yd(R,m)})]})]})]},R.id)}),we&&s.jsx("div",{className:"py-3 text-center",children:s.jsxs("svg",{className:"animate-spin h-4 w-4 text-fg-tertiary mx-auto",viewBox:"0 0 24 24",fill:"none",children:[s.jsx("circle",{className:"opacity-25",cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"4"}),s.jsx("path",{className:"opacity-75",fill:"currentColor",d:"M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4z"})]})})]}))]})]}),Bt=k.useCallback(R=>{R?.mute&&UV()},[]),wt=k.useCallback(R=>{Bt(R),Ee(!1)},[Bt]),hn=I?s.jsx(dr,{title:m("credits.dialogTitle",{ns:"common"}),message:m("credits.dialogDesc",{ns:"common"}),variant:"primary",cancelLabel:m("credits.configureModels",{ns:"common"}),confirmLabel:m("credits.topUp",{ns:"common"}),checkboxes:[{id:"mute",label:m("credits.dontRemind",{ns:"common"})}],onCancel:()=>Ee(!1),onCancelClick:R=>{wt(R),at.navigate(me.SETTINGS),setTimeout(()=>{window.location.hash="settings/providers"},50)},onConfirm:R=>{const oe=`${lt.getUrl().replace(/\/$/,"")}/settings?tab=billing`;wt(R),Oo(oe)}}):null;if(n){const R=["approvals","notifications"],oe=R.indexOf(g),_e=(()=>{let de=0,$e=0;return{onTouchStart:qe=>{de=qe.touches[0].clientX,$e=qe.touches[0].clientY},onTouchEnd:qe=>{const q=qe.changedTouches[0].clientX-de,ie=qe.changedTouches[0].clientY-$e;Math.abs(q)>60&&Math.abs(q)>Math.abs(ie)*1.5&&(q<0&&oe<R.length-1&&x(R[oe+1]),q>0&&oe>0&&x(R[oe-1]))}}})();return s.jsxs(s.Fragment,{children:[hn,s.jsxs("div",{className:"flex flex-col h-full overflow-hidden",children:[rt,s.jsx("div",{className:"flex border-b border-border-default shrink-0",children:R.map(de=>s.jsx("button",{onClick:()=>x(de),className:`flex-1 px-3 py-3 text-sm font-medium transition-colors ${g===de?"text-fg-primary border-b-2 border-brand-500":"text-fg-tertiary"}`,children:de==="approvals"?s.jsxs(s.Fragment,{children:[m("team:notifications.approvals"),it>0?` (${it})`:""]}):s.jsxs(s.Fragment,{children:[m("team:notifications.notifications"),ut>0?` (${ut})`:""]})},de))}),g==="notifications"&&Z>0&&s.jsx("div",{className:"flex justify-end px-3 py-1.5 border-b border-border-default/50 shrink-0",children:s.jsx("button",{onClick:Qe,className:"text-[10px] text-brand-500 hover:text-brand-400 transition-colors",children:m("team:notifications.markAllRead")})}),s.jsx("div",{className:"flex-1 overflow-hidden relative",..._e,children:s.jsxs("div",{className:"flex h-full transition-transform duration-300 ease-out",style:{transform:`translateX(-${oe*100}%)`},children:[s.jsx("div",{className:"w-full shrink-0 h-full overflow-y-auto scrollbar-thin",children:N.length===0?s.jsx("div",{className:"p-6 text-center text-xs text-fg-tertiary",children:m("team:notifications.noApprovals")}):s.jsxs("div",{className:"divide-y divide-border-default/50",children:[xe.map(de=>{const $e=de.details?.command,qe=$e?de.description.replace(/\s*Command:.*$/,""):de.description;return s.jsxs("div",{className:"px-3 py-3 space-y-2.5",children:[s.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:()=>he(de),children:[s.jsxs("div",{className:"flex items-start gap-2",children:[s.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:s.jsx("path",{d:So.approval_request})}),s.jsxs("div",{className:"flex-1 min-w-0",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[xt(de)&&s.jsx("span",{className:"text-[10px] text-amber-500 font-medium shrink-0",children:xt(de)}),s.jsx("span",{className:"text-xs text-fg-primary font-medium truncate",children:de.title}),s.jsx("span",{className:"text-[10px] text-fg-tertiary shrink-0",children:No(de.requestedAt,m)})]}),s.jsx("div",{className:"text-[11px] text-fg-tertiary mt-0.5",children:de.agentName})]})]}),s.jsx("div",{className:"mt-2.5 text-[11px] text-fg-secondary leading-relaxed",children:s.jsx(Ar,{content:qe,className:"text-[11px] [&_h1]:text-xs [&_h2]:text-[11px] [&_h3]:text-[11px] [&_p]:text-[11px] [&_li]:text-[11px]"})}),$e&&s.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:$e})]}),(()=>{if(gd(de))return Ze(de);const q=de.details?.subType,ie=q==="task"||q==="requirement"||q==="requirement_resubmit",Se=de.options&&de.options.length>0,Ie=(H[de.id]??"").trim();return Se?s.jsxs("div",{className:"space-y-1.5",children:[de.options.map((Xe,yt)=>s.jsxs("button",{disabled:C===de.id,onClick:()=>Ge(de.id,Xe.id!=="reject",Ie||void 0,Xe.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 ${Xe.id==="reject"||Xe.id==="request_changes"?"border border-border-default text-fg-secondary hover:bg-surface-overlay":"bg-brand-600 text-white hover:bg-brand-700"}`,title:Xe.description,children:[s.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+yt)}),Xe.label]},Xe.id)),s.jsxs("div",{className:"flex gap-1.5 mt-1",children:[s.jsx("input",{type:"text",placeholder:m("team:notifications.freeformPlaceholder"),value:H[de.id]??"",onChange:Xe=>W(yt=>({...yt,[de.id]:Xe.target.value})),onKeyDown:Xe=>{Xe.key==="Enter"&&(H[de.id]??"").trim()&&Ge(de.id,!0,(H[de.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"}),s.jsx("button",{disabled:C===de.id||!(H[de.id]??"").trim(),onClick:()=>Ge(de.id,!0,(H[de.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:m("common:send")})]})]}):ie?s.jsxs("div",{className:"space-y-1.5",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsxs("button",{disabled:C===de.id,onClick:()=>Ge(de.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:[s.jsx("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round",children:s.jsx("path",{d:"M20 6L9 17l-5-5"})}),m("common:approve")]}),s.jsxs("button",{disabled:C===de.id,onClick:()=>Ge(de.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:[s.jsxs("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round",children:[s.jsx("path",{d:"M18 6L6 18"}),s.jsx("path",{d:"M6 6l12 12"})]}),m("common:reject")]}),z!==de.id&&s.jsxs("button",{disabled:C===de.id,onClick:()=>D(de.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:[s.jsxs("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[s.jsx("path",{d:"M11 4H4a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2v-7"}),s.jsx("path",{d:"M18.5 2.5a2.121 2.121 0 0 1 3 3L12 15l-4 1 1-4 9.5-9.5z"})]}),m("team:notifications.needsAdjustment")]})]}),z===de.id&&s.jsxs("div",{className:"space-y-1.5",children:[s.jsx("input",{type:"text",autoFocus:!0,placeholder:m("team:notifications.adjustmentPlaceholder"),value:H[de.id]??"",onChange:Xe=>W(yt=>({...yt,[de.id]:Xe.target.value})),onKeyDown:Xe=>{Xe.key==="Enter"&&(H[de.id]??"").trim()&&Ge(de.id,!1,(H[de.id]??"").trim(),"needs_adjustment"),Xe.key==="Escape"&&D(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"}),s.jsxs("div",{className:"flex gap-2",children:[s.jsx("button",{disabled:C===de.id||!(H[de.id]??"").trim(),onClick:()=>Ge(de.id,!1,(H[de.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:m("team:notifications.confirmAdjustment")}),s.jsx("button",{onClick:()=>D(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:m("common:cancel")})]})]})]}):s.jsxs("div",{className:"space-y-1.5",children:[s.jsx("input",{type:"text",placeholder:m("team:notifications.commentPlaceholder"),value:H[de.id]??"",onChange:Xe=>W(yt=>({...yt,[de.id]:Xe.target.value})),onKeyDown:Xe=>{Xe.key==="Enter"&&Ge(de.id,!0,Ie||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"}),s.jsxs("div",{className:"flex gap-2",children:[s.jsx("button",{disabled:C===de.id,onClick:()=>Ge(de.id,!0,Ie||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:m("common:approve")}),s.jsx("button",{disabled:C===de.id,onClick:()=>Ge(de.id,!1,Ie||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:m("common:reject")})]})]})})()]},de.id)}),We.length>0&&s.jsxs(s.Fragment,{children:[xe.length>0&&s.jsx("div",{className:"px-3 py-1.5 text-[10px] font-medium text-fg-tertiary uppercase tracking-wider bg-surface-overlay/30",children:m("team:notifications.approvalHistory")}),We.slice(0,50).map(de=>s.jsxs("button",{onClick:()=>he(de),className:"w-full text-left px-3 py-2.5 hover:bg-surface-overlay/50 transition-colors",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("span",{className:`w-1.5 h-1.5 rounded-full shrink-0 ${de.status==="approved"?"bg-green-500":de.status==="cancelled"||de.status==="expired"?"bg-gray-400":"bg-red-500"}`}),s.jsx("span",{className:"text-xs text-fg-secondary truncate flex-1",children:de.title}),s.jsx("span",{className:`text-[10px] font-medium shrink-0 ${de.status==="approved"?"text-green-500":de.status==="cancelled"||de.status==="expired"?"text-fg-muted":"text-red-500"}`,children:m(`common:status.${de.status}`,{defaultValue:de.status})})]}),s.jsxs("div",{className:"flex items-center gap-1.5 mt-0.5 pl-3.5",children:[s.jsx("span",{className:"text-[10px] text-fg-muted truncate",children:pe(de)}),s.jsx("span",{className:"text-[10px] text-fg-muted shrink-0",children:"·"}),s.jsx("span",{className:"text-[10px] text-fg-muted shrink-0",children:No(de.respondedAt??de.requestedAt,m)})]})]},de.id))]})]})}),s.jsx("div",{className:"w-full shrink-0 h-full overflow-y-auto scrollbar-thin",children:Ne.length===0?s.jsx("div",{className:"p-6 text-center text-xs text-fg-tertiary",children:m("team:notifications.noNotifications")}):s.jsx("div",{className:"divide-y divide-border-default/50",children:Ne.slice(0,50).map(de=>{const $e=c4[de.type]??"text-fg-tertiary";return s.jsxs("button",{onClick:()=>nt(de),className:`w-full text-left px-3 py-2.5 flex gap-2.5 transition-colors ${de.read?"opacity-50 hover:opacity-70":"hover:bg-surface-overlay"}`,children:[s.jsx("div",{className:"shrink-0 mt-0.5",children:s.jsx("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",className:$e,children:s.jsx("path",{d:So[de.type]??So.system})})}),s.jsxs("div",{className:"flex-1 min-w-0",children:[s.jsxs("div",{className:"flex items-center gap-1.5",children:[!de.read&&s.jsx("span",{className:`w-1.5 h-1.5 rounded-full shrink-0 ${bd[de.priority]??bd.normal}`}),s.jsx("span",{className:"text-xs text-fg-primary font-medium truncate",children:de.title})]}),s.jsx("div",{className:"text-[11px] text-fg-tertiary mt-0.5 ",children:s.jsx(Ar,{content:de.body,className:"text-[11px] [&_h1]:text-xs [&_h2]:text-[11px] [&_h3]:text-[11px] [&_p]:text-[11px] [&_li]:text-[11px] [&_p]:text-fg-tertiary"})}),s.jsxs("div",{className:"flex items-center gap-2 mt-0.5",children:[s.jsx("span",{className:"text-[10px] text-fg-muted",children:No(de.createdAt,m)}),yd(de,m)&&s.jsx("span",{className:`text-[10px] font-medium ${$e}`,children:yd(de,m)})]})]})]},de.id)})})})]})})]})]})}if(o){const R=d||"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 s.jsxs(s.Fragment,{children:[rt,s.jsxs("button",{ref:Y,onClick:()=>{p(!h),h||De()},title:e?u||m("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 ${h||l?"bg-surface-overlay":"hover:bg-surface-overlay/60"}`,children:[s.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:s.jsx("path",{d:R})}),e?s.jsx("span",{className:"text-[9px] leading-tight truncate w-full text-center",children:u}):s.jsx("span",{className:"truncate",children:u}),bt>0&&s.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:bt>99?m("common:badgeOverLimit"):bt})]}),h&&Ja.createPortal(s.jsx("div",{ref:ae,className:"fixed bg-surface-secondary border border-border-default rounded-xl shadow-2xl z-[9999] flex flex-col overflow-hidden",style:{top:X.top,left:X.left,width:X.width,maxHeight:X.maxHeight},children:St}),document.body),hn]})}return s.jsxs(s.Fragment,{children:[rt,s.jsxs("button",{ref:Y,onClick:()=>{p(!h),h||De()},className:`relative flex items-center justify-center rounded-md transition-colors ${e?"w-8 h-8":"w-7 h-7"} ${h?"bg-surface-overlay text-fg-primary":"text-fg-tertiary hover:text-fg-secondary hover:bg-surface-overlay"}`,title:m("team:notifications.bellTitle"),children:[s.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[s.jsx("path",{d:"M18 8A6 6 0 0 0 6 8c0 7-3 9-3 9h18s-3-2-3-9"}),s.jsx("path",{d:"M13.73 21a2 2 0 0 1-3.46 0"})]}),bt>0&&s.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:bt>99?m("common:badgeOverLimit"):bt})]}),h&&Ja.createPortal(s.jsx("div",{ref:ae,className:"fixed bg-surface-secondary border border-border-default rounded-xl shadow-2xl z-[9999] flex flex-col overflow-hidden",style:{top:X.top,left:X.left,width:X.width,maxHeight:X.maxHeight},children:St}),document.body),hn]})}function vd({d:e,size:t=14}){return s.jsx("svg",{width:t,height:t,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",className:"shrink-0",children:s.jsx("path",{d:e})})}const Vh=200;function GV({authUser:e,onLogout:t,onEditProfile:n,showSettingsLink:r=!1,collapsed:o=!1,showVersion:l=!1}){const{t:u}=ft(["nav","common"]),[d,m]=k.useState(!1),[h,p]=k.useState(!1),[g,x]=k.useState(()=>lt.isAuthenticated()),[y,w]=k.useState(()=>ua()),[N,T]=k.useState({top:0,left:0}),C=k.useRef(null),j=k.useRef(null),_=k.useCallback(X=>{if(w(ua()),!lt.isAuthenticated()){x(!1);return}if(!X?.validate){x(!0);return}J4().then(F=>{x(F),w(ua())})},[]);k.useEffect(()=>{_({validate:!0});const X=()=>_(),F=()=>_({validate:!0});return window.addEventListener("markus:hub-auth",X),window.addEventListener("focus",F),()=>{window.removeEventListener("markus:hub-auth",X),window.removeEventListener("focus",F)}},[_]);const O=k.useCallback(()=>{if(!C.current)return;const X=C.current.getBoundingClientRect(),F=window.innerWidth,J=window.innerHeight,B=j.current?.offsetHeight??220;let Q=X.right+8;Q+Vh>F-8&&(Q=Math.max(8,X.left-Vh-8));let re=X.top-B-8;re<8&&(re=Math.min(X.bottom+8,J-B-8)),T({top:Math.max(8,re),left:Q})},[]);k.useLayoutEffect(()=>{if(!d)return;O();const X=requestAnimationFrame(()=>O());return()=>cancelAnimationFrame(X)},[d,O,o]),k.useEffect(()=>{if(!d)return;const X=J=>{const B=J.target;C.current?.contains(B)||j.current?.contains(B)||m(!1)},F=()=>O();return document.addEventListener("mousedown",X),window.addEventListener("resize",F),window.addEventListener("scroll",F,!0),()=>{document.removeEventListener("mousedown",X),window.removeEventListener("resize",F),window.removeEventListener("scroll",F,!0)}},[d,O]);const z=e?.name||y?.displayName||y?.username||u("common:userPlaceholder"),D=e?.email||y?.email||"",H=n5(e?.avatarUrl,y?.avatarUrl),W=g?"bg-emerald-500":"bg-fg-muted",Z=g?y?.username?u("sidebar.hubConnectedAs",{username:y.username}):u("sidebar.hubConnected"):u("sidebar.hubDisconnected"),U=!!(g&&y?.username&&e?.name&&y.username.toLowerCase()!==e.name.toLowerCase()&&y.email?.toLowerCase()!==e.email?.toLowerCase()),Y=()=>{m(!1),_({validate:!0}),at.navigate(me.SETTINGS,{tab:"account"})},ae=d&&Ja.createPortal(s.jsxs("div",{ref:j,className:"fixed bg-surface-elevated border border-border-default rounded-xl shadow-xl z-[9999] overflow-hidden",style:{top:N.top,left:N.left,width:Vh},children:[s.jsxs("div",{className:"px-3.5 py-3 border-b border-border-default flex items-start gap-2",children:[s.jsxs("div",{className:"min-w-0 flex-1",children:[s.jsx("div",{className:"text-sm font-medium text-fg-primary truncate",children:z}),D&&s.jsx("div",{className:"text-xs text-fg-tertiary mt-0.5 truncate",children:D})]}),n&&s.jsx("button",{type:"button",onClick:()=>{m(!1),n()},title:u("common:profile.editProfile"),className:"shrink-0 mt-0.5 p-1.5 rounded-md text-fg-tertiary hover:text-fg-secondary hover:bg-surface-overlay transition-colors",children:s.jsx(vd,{d:"M12 20h9M16.5 3.5a2.12 2.12 0 0 1 3 3L7 19l-4 1 1-4Z",size:14})})]}),s.jsxs("button",{type:"button",onClick:Y,className:"w-full px-3.5 py-2.5 border-b border-border-default flex items-center gap-2 hover:bg-surface-overlay transition-colors text-left",children:[s.jsx("span",{className:`w-2 h-2 rounded-full shrink-0 ${W}`}),s.jsxs("span",{className:"min-w-0 flex-1",children:[s.jsx("span",{className:"text-xs text-fg-secondary block truncate",children:Z}),U&&y?.username&&s.jsx("span",{className:"text-[10px] text-amber-500/90 block truncate mt-0.5",children:u("sidebar.hubAccountMismatch",{username:y.username})})]}),s.jsx("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",className:"text-fg-muted shrink-0",children:s.jsx("path",{d:"m9 18 6-6-6-6"})})]}),s.jsxs("div",{className:"py-1",children:[r&&s.jsxs("button",{type:"button",onClick:()=>{m(!1),at.navigate(me.SETTINGS)},className:"w-full flex items-center gap-2.5 px-3.5 py-2 text-sm text-fg-secondary hover:bg-surface-overlay transition-colors",children:[s.jsx(vd,{d:cc[me.SETTINGS]}),u("settings")]}),window.markusDesktop&&s.jsxs("button",{type:"button",onClick:()=>{m(!1),window.markusDesktop?.openInBrowser()},className:"w-full flex items-center gap-2.5 px-3.5 py-2 text-sm text-fg-secondary hover:bg-surface-overlay transition-colors",children:[s.jsx(vd,{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"}),u("common:openInBrowser")]}),t&&s.jsxs("button",{type:"button",onClick:()=>{m(!1),p(!0)},className:"w-full flex items-center gap-2.5 px-3.5 py-2 text-sm text-fg-secondary hover:bg-surface-overlay transition-colors",children:[s.jsx(vd,{d:"M9 21H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h4M16 17l5-5-5-5M21 12H9"}),u("common:signOut")]})]})]}),document.body);return s.jsxs("div",{className:`relative ${o?"flex justify-center":"flex items-center justify-between gap-2 w-full"}`,children:[s.jsxs("button",{ref:C,type:"button",onClick:()=>m(X=>!X),title:z,className:`relative inline-flex items-center justify-center rounded-full transition-opacity hover:opacity-90 ${o?"p-0.5":""}`,children:[s.jsx(Us,{name:z,avatarUrl:H,size:o?28:32,fallback:"icon"}),s.jsx("span",{className:`absolute bottom-0 right-0 w-2.5 h-2.5 rounded-full border-2 border-surface-secondary ${W}`,title:Z})]}),l&&!o&&s.jsxs("span",{className:"text-[10px] text-fg-muted select-none shrink-0",children:["v","0.9.0-rc.3"]}),ae,h&&t&&s.jsx(dr,{title:u("common:signOutConfirmTitle"),message:u("common:signOutConfirmMessage"),confirmLabel:u("common:signOut"),variant:"primary",onConfirm:()=>{p(!1),t()},onCancel:()=>p(!1)})]})}function VV({d:e,size:t=18}){return s.jsx("svg",{width:t,height:t,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.75",strokeLinecap:"round",strokeLinejoin:"round",className:"shrink-0",children:s.jsx("path",{d:e})})}function KV({currentPage:e,onNavigate:t,authUser:n,collapsed:r,onToggleCollapse:o,onLogout:l}){const{t:u}=ft(["nav","common"]);return s.jsxs("aside",{className:"h-dvh bg-surface-secondary flex flex-col shrink-0 overflow-hidden",children:[s.jsx("div",{className:`flex items-center ${r?"px-2 py-3.5 justify-center":"px-4 h-14 justify-between"}`,children:s.jsxs("button",{onClick:o,title:u(r?"sidebar.expandSidebar":"sidebar.collapseSidebar"),className:"flex items-center gap-2.5 min-w-0 group",children:[s.jsx("img",{src:"/logo.png",alt:"Markus",className:"w-8 h-8 rounded-lg shrink-0"}),!r&&s.jsx("span",{className:"text-[15px] font-bold tracking-tight text-fg-primary whitespace-nowrap",children:"Markus"})]})}),s.jsx("nav",{className:`${r?"p-1":"px-3 py-2"} flex-1 overflow-y-auto scrollbar-thin`,children:$O.map((d,m)=>{const h=HO.filter(g=>g.section===d.key);if(h.length===0)return null;const p=u(`sections.${d.key}`);return s.jsx("div",{children:s.jsxs("div",{className:m>0?"mt-3":"",children:[!r&&p&&s.jsx("div",{className:"px-3 py-1.5 mb-1 text-[10px] font-semibold text-fg-muted uppercase tracking-[0.1em]",children:p}),r&&m>0&&s.jsx("div",{className:"my-3"}),h.map(g=>{if(g.id===me.NOTIFICATIONS)return s.jsx(qV,{sidebarMode:!0,collapsed:r,userId:n?.id,label:u(g.id),iconPath:cc[g.id],isActive:e===g.id},g.id);const x=e===g.id;return s.jsxs("button",{onClick:()=>t(g.id),title:r?u(g.id):void 0,className:`w-full flex items-center ${r?"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 ${x?"bg-surface-overlay":"hover:bg-surface-overlay/60"}`,children:[s.jsx(VV,{d:cc[g.id]??"",size:r?16:18}),r?s.jsx("span",{className:"text-[9px] leading-tight truncate w-full text-center",children:u(g.id)}):s.jsx("span",{className:"truncate",children:u(g.id)})]},g.id)})]})},d.key)})}),s.jsx("div",{className:`shrink-0 border-t border-border-subtle ${r?"p-1.5 flex justify-center":"px-3 py-2.5"}`,children:s.jsx(GV,{authUser:n,onLogout:l,onEditProfile:()=>{window.dispatchEvent(new Event("markus:open-edit-profile"))},showSettingsLink:!1,collapsed:r,showVersion:!r})})]})}const WV=6e4;let Ps={},gi={};const Up=new Set,$p=new Set;let b3=0,sc=null,wd=0,Ld=null;function c0(){for(const e of Up)e()}async function Hp(){try{const e=await Ce.unread.getCounts();Ps=e.counts??{},gi=e.sessionAgentMap??{},c0()}catch{}}function YV(){sc||(Hp(),sc=setInterval(Hp,WV),Ld=va.on("chat:unread_update",e=>{const t=e.payload?.conversationKey;t&&!$p.has(t)&&Date.now()>b3&&(Ps[t]=(Ps[t]??0)+1,c0())}))}function XV(){sc&&(clearInterval(sc),sc=null),Ld&&(Ld(),Ld=null)}function QV(e){const t=e?.enabled??!0,[n,r]=k.useState(Ps),[o,l]=k.useState(gi),u=k.useCallback(async()=>{await Hp()},[]),d=k.useCallback(async w=>{const N=new Date().toISOString();delete Ps[w],c0();try{await Ce.unread.markRead(w,N)}catch{}},[]),m=k.useCallback(async()=>{Ps={},c0();try{await Ce.unread.markAllRead()}catch{}},[]),h=k.useCallback(w=>{$p.add(w)},[]),p=k.useCallback(w=>{$p.delete(w),b3=Date.now()+150},[]);k.useEffect(()=>{if(!t)return;wd++,YV();let w=gi;const N=()=>{r({...Ps}),w!==gi&&(w=gi,l({...gi}))};return Up.add(N),r({...Ps}),l({...gi}),()=>{Up.delete(N),wd--,wd<=0&&(wd=0,XV())}},[t]);const g=k.useMemo(()=>Object.values(n).reduce((w,N)=>w+N,0),[n]),x=k.useCallback(w=>n[`session:${w}`]??0,[n]),y=k.useCallback(w=>n[`channel:${w}`]??0,[n]);return{counts:n,totalUnread:g,sessionAgentMap:o,getSessionUnread:x,getChannelUnread:y,markRead:d,markAllRead:m,refresh:u,setActiveKey:h,clearActiveKey:p}}function MW(e,t){return k.useMemo(()=>{const n=new Map;for(const[r,o]of Object.entries(t))if(r.startsWith("session:")){const l=r.slice(8),u=e[l];u&&n.set(u,(n.get(u)??0)+o)}return n},[e,t])}function ZV({currentPage:e,onNavigate:t,userId:n}){const{t:r}=ft("nav"),[o,l]=k.useState(0),{counts:u}=QV({enabled:!0}),d=k.useMemo(()=>{let h=0;for(const p of Object.values(u))h+=p;return h},[u]),m=k.useCallback(async()=>{try{const h=await Ce.notifications.list(n,!1);l(h.unreadCount??h.notifications.filter(p=>!p.read).length)}catch{}},[n]);return k.useEffect(()=>{m();const h=setInterval(()=>{document.visibilityState==="visible"&&m()},3e4),p=()=>m();return window.addEventListener("markus:notifications-changed",p),()=>{clearInterval(h),window.removeEventListener("markus:notifications-changed",p)}},[m]),s.jsx("nav",{className:"fixed bottom-0 left-0 right-0 z-50 bg-surface-secondary flex items-stretch h-14 safe-area-bottom",children:FO.map(h=>{const p=h.group.includes(e),g=h.id===me.NOTIFICATIONS,x=h.id===me.TEAM;return s.jsxs("button",{onClick:()=>t(h.id),className:`flex-1 flex flex-col items-center justify-center gap-0.5 transition-colors ${p?"text-fg-primary":"text-fg-tertiary active:text-fg-secondary"}`,children:[s.jsxs("div",{className:"relative",children:[s.jsx("svg",{width:20,height:20,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:p?2:1.75,strokeLinecap:"round",strokeLinejoin:"round",className:"shrink-0",children:s.jsx("path",{d:cc[h.id]})}),g&&o>0&&s.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:o>99?"99+":o}),x&&d>0&&s.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:d>99?"99+":d})]}),s.jsx("span",{className:`text-[10px] leading-tight ${p?"font-semibold":""}`,children:r(h.id)})]},h.id)})})}const u0=new Map;function pi(e,t){u0.has(e)||u0.set(e,t().catch(()=>{}))}function vi(e){const t=u0.get(e);return u0.delete(e),t}const Tr={builderArtifacts:"builder.artifacts",builderAgents:"builder.agents",builderHubMyItems:"builder.hubMyItems",builderInstalled:"builder.installed",hubAgents:"hub.agents",hubTeams:"hub.teams",hubSkills:"hub.skills"},Ti={agent:{label:"Agent",labelZh:"智能体",gradient:"from-violet-500 to-indigo-600",accent:"#8b5cf6",covers:[["#7c3aed","#4f46e5"],["#8b5cf6","#6366f1"],["#a855f7","#4338ca"],["#6d28d9","#2563eb"]]},team:{label:"Team",labelZh:"AI 小队",gradient:"from-cyan-500 to-blue-600",accent:"#06b6d4",covers:[["#0891b2","#2563eb"],["#06b6d4","#3b82f6"],["#0e7490","#1d4ed8"],["#22d3ee","#4f46e5"]]},skill:{label:"Skill",labelZh:"技能",gradient:"from-amber-500 to-orange-600",accent:"#f59e0b",covers:[["#f59e0b","#ea580c"],["#d97706","#dc2626"],["#fbbf24","#f97316"],["#f59e0b","#b45309"]]},connector:{label:"Connector",labelZh:"连接器",gradient:"from-emerald-500 to-teal-600",accent:"#10b981",covers:[["#10b981","#0d9488"],["#059669","#0891b2"],["#34d399","#14b8a6"],["#16a34a","#0f766e"]]}};function Wo(e){const t=(e||"").toLowerCase();return t==="team"?"team":t==="skill"?"skill":t==="connector"||t==="mcp"?"connector":"agent"}function x3(e){let t=2166136261;for(let n=0;n<e.length;n++)t^=e.charCodeAt(n),t=Math.imul(t,16777619);return t>>>0}const JV={agent:258,team:205,skill:32,connector:162};function Mg(e,t){const n=JV[e],r=x3(t),o=((n+(r%68-34))%360+360)%360,l=(o+22+(r>>>8)%24)%360;return`linear-gradient(${120+r%44}deg, hsl(${o} 72% 56%), hsl(${l} 66% 43%))`}const m4=["M12 2l2.4 6.9L21 9l-5.4 4 2 7-5.6-4.1L6.4 20l2-7L3 9l6.6-.1z","M12 2a10 10 0 100 20 10 10 0 000-20zm0 4a6 6 0 110 12 6 6 0 010-12z","M4 4h7v7H4zM13 4h7v7h-7zM4 13h7v7H4zM13 13h7v7h-7z","M12 2l9 5v10l-9 5-9-5V7z","M3 12a9 9 0 019-9v9h9a9 9 0 11-18 0z","M6 3h12l3 6-9 12L3 9z","M12 3l3 6 6 .9-4.5 4.3 1 6.3L12 18l-5.5 2.5 1-6.3L3 9.9 9 9z","M4 12a8 8 0 018-8v4a4 4 0 00-4 4zm8 8a8 8 0 01-8-8h4a4 4 0 004 4z","M12 2l7 4v12l-7 4-7-4V6z M12 6l-3 1.7v3.4L12 13l3-1.9V7.7z","M3 6h18M3 12h18M3 18h18","M12 2a10 10 0 100 20A6 6 0 0112 8a6 6 0 010 12","M12 2l4 8h-8zM4 12h16l-8 10z"];function y3(e){return m4[x3(e+"g")%m4.length]}function v3(e){return e?e.startsWith("http://")||e.startsWith("https://")||e.startsWith("/")||e.startsWith("data:")||/\.(png|jpe?g|gif|webp|svg)$/i.test(e):!1}function eK(e){return!e||v3(e)?!1:[...e].length<=4&&new RegExp("\\p{Extended_Pictographic}","u").test(e)}function tK(e,t="user"){const n=t==="org"?"shapes":"thumbs",r=encodeURIComponent(e);return`https://api.dicebear.com/9.x/${n}/svg?seed=${r}&radius=50&backgroundType=gradientLinear`}function Ao(e){const t=e??0;return t<1e3?String(t):t<1e6?`${(t/1e3).toFixed(t<1e4?1:0)}k`.replace(".0k","k"):`${(t/1e6).toFixed(1)}M`.replace(".0M","M")}function f4(e,t="usd"){return!e||e<=0?"Free":`${t.toLowerCase()==="usd"?"$":""}${(e/100).toFixed(e%100===0?0:2)}`}const h4={agent:{icon:"✦",label:"Agent",color:"text-brand-500",gradient:"from-brand-500 to-purple-600",bg:"bg-brand-500/10",ring:"ring-brand-500/30"},team:{icon:"◈",label:"Team",color:"text-blue-600",gradient:"from-blue-500 to-blue-600",bg:"bg-blue-500/10",ring:"ring-blue-500/30"},skill:{icon:"⬡",label:"Skill",color:"text-green-600",gradient:"from-green-500 to-green-600",bg:"bg-green-500/10",ring:"ring-green-500/30"}},nK=["development","devops","management","productivity","browser","custom","general"],rK=[{label:"Tech",emojis:["✦","◈","⬡","⚡","🤖","🧠","💡","🎯","🔧","📦","🚀","💻","🛠️","⭐","🔥","💎","⚙️","🧩","🔌","💾","🖥️","📡","🔬","🧪","🏗️","📱","🎮","🕹️","📟","💽","🖨️","⌨️"]},{label:"People",emojis:["👤","👥","🧑‍💻","👨‍💼","👩‍🔬","🧙","🦸","🤝","💪","🎓","👷","🕵️","🧑‍🎨","🧑‍🏫","👨‍🚀","🥷","🧑‍🏭","🧑‍⚕️","🧑‍🔧","🧑‍🍳","👨‍🎤","🦹","🧝","🧞","🧑‍✈️","💂","🤴","👸","🧛","🧟","🧜","🧚"]},{label:"Objects",emojis:["📝","📊","🗂️","📁","🔍","🔑","🌐","💬","🔒","🎨","📐","🗃️","📋","✏️","🖊️","📌","📎","🧲","🪝","🧰","🪜","🧬","🔭","💊","🩺","📕","📗","📘","📙","📓","🗒️","📰"]},{label:"Symbols",emojis:["❤️","🧡","💛","💚","💙","💜","🖤","🤍","♠️","♥️","♦️","♣️","🎵","🎶","💯","✅","❌","⭕","🔴","🟠","🟡","🟢","🔵","🟣","⚫","⚪","🟤","🔶","🔷","▶️","⏸️","⏹️"]},{label:"Nature",emojis:["🌟","🌈","🌊","🌿","🍀","🔮","💫","✨","🌙","☀️","🦋","🐉","🦊","🐺","🦅","🐙","🦁","🐯","🦄","🐲","🌸","🌺","🍄","🌵","🎄","🌴","🍁","🌻","🐝","🦎","🐍","🦈"]},{label:"Activity",emojis:["🎯","🏆","🥇","🎖️","🏅","🎪","🎭","🎬","🎤","🎧","🎼","🎹","🥁","🎸","🎺","🎻","⚽","🏀","🎾","🏐","🎲","🧸","🪁","🎰","🎳","🏹","🥊","🤺","⛷️","🏄","🚴","🧗"]}],aK={shell:{icon:">",color:"bg-amber-500/15 text-amber-400 border-amber-500/30"},file:{icon:"◫",color:"bg-blue-500/15 text-blue-400 border-blue-500/30"},network:{icon:"◎",color:"bg-purple-500/15 text-purple-400 border-purple-500/30"},browser:{icon:"◉",color:"bg-brand-500/15 text-brand-400 border-brand-500/30"}};function Kh({value:e,onChange:t,renderAs:n="span",className:r,editClassName:o,placeholder:l,multiline:u,readOnly:d}){if(d){const _=e||l,z=`${r??""} ${!e?"text-fg-muted italic":""}`;return n==="h1"?s.jsx("h1",{className:z,children:_}):n==="p"?s.jsx("p",{className:z,children:_}):s.jsx("span",{className:z,children:_})}const[m,h]=k.useState(!1),[p,g]=k.useState(e),x=k.useRef(null);k.useEffect(()=>{g(e)},[e]),k.useEffect(()=>{m&&x.current?.focus()},[m]);const y=()=>{h(!1),p!==e&&t(p)},w=()=>{g(e),h(!1)},N=_=>{_.key==="Escape"&&w(),_.key==="Enter"&&!u&&y()};if(m){const _=`bg-transparent outline-none w-full ${o??r??""} ring-1 ring-brand-500/50 rounded px-1 -mx-1`;return u?s.jsx("textarea",{ref:x,value:p,onChange:O=>g(O.target.value),onBlur:y,onKeyDown:N,className:`${_} resize-y min-h-[60px]`,placeholder:l}):s.jsx("input",{ref:x,value:p,onChange:O=>g(O.target.value),onBlur:y,onKeyDown:N,className:_,placeholder:l})}const T=e||l,C=!e,j="cursor-text hover:ring-1 hover:ring-border-default rounded px-1 -mx-1 transition-all";return n==="h1"?s.jsx("h1",{onClick:()=>h(!0),className:`${r??""} ${j} ${C?"text-fg-muted italic":""}`,children:T}):n==="p"?s.jsx("p",{onClick:()=>h(!0),className:`${r??""} ${j} ${C?"text-fg-muted italic":""}`,children:T}):n==="badge"?s.jsx("span",{onClick:()=>h(!0),className:`${r??""} ${j} ${C?"text-fg-muted italic":""}`,children:T}):s.jsx("span",{onClick:()=>h(!0),className:`${r??""} ${j} ${C?"text-fg-muted italic":""}`,children:T})}function sK({value:e,options:t,onChange:n,className:r,readOnly:o}){if(o)return s.jsx("span",{className:r,children:e});const[l,u]=k.useState(!1),[d,m]=k.useState(e),h=k.useRef(null),p=k.useRef(null);k.useEffect(()=>{l&&(m(e),setTimeout(()=>h.current?.focus(),0))},[l,e]);const g=t.filter(y=>y.toLowerCase().includes(d.toLowerCase())),x=y=>{const w=y.trim();w&&w!==e&&n(w),u(!1)};return l?s.jsxs("div",{ref:p,className:"relative inline-block",children:[s.jsx("input",{ref:h,value:d,onChange:y=>m(y.target.value),onKeyDown:y=>{y.key==="Enter"?(y.preventDefault(),x(d)):y.key==="Escape"&&u(!1)},onBlur:y=>{p.current?.contains(y.relatedTarget)||x(d)},className:`${r??""} bg-transparent outline-none ring-1 ring-brand-500/50 rounded w-28`}),g.length>0&&s.jsx("div",{className:"absolute top-full left-0 mt-1 z-50 bg-surface-elevated border border-border-default rounded-lg shadow-xl py-1 min-w-[120px] max-h-40 overflow-y-auto",children:g.map(y=>s.jsx("button",{onMouseDown:w=>{w.preventDefault(),x(y)},className:`block w-full text-left px-3 py-1.5 text-xs hover:bg-surface-secondary/80 transition-colors ${y===e?"text-brand-400 font-medium":"text-fg-secondary"}`,children:y},y))})]}):s.jsx("span",{onClick:()=>u(!0),className:`${r??""} cursor-pointer hover:ring-1 hover:ring-border-default rounded px-1 -mx-1 transition-all`,children:e})}function iK({tags:e,onChange:t,readOnly:n}){if(n)return s.jsx("div",{className:"flex flex-wrap items-center gap-1.5 min-h-[24px]",children:e.map(p=>s.jsx("span",{className:"text-[10px] px-2 py-0.5 bg-surface-elevated text-fg-muted rounded-full border border-border-default",children:p},p))});const{t:r}=ft(["builder"]),[o,l]=k.useState(!1),[u,d]=k.useState(""),m=k.useRef(null);k.useEffect(()=>{o&&m.current?.focus()},[o]);const h=p=>{if((p.key==="Enter"||p.key===",")&&u.trim()){p.preventDefault();const g=u.trim().toLowerCase();e.includes(g)||t([...e,g]),d("")}else p.key==="Backspace"&&!u&&e.length>0?t(e.slice(0,-1)):p.key==="Escape"&&(l(!1),d(""))};return o?s.jsxs("div",{className:"flex flex-wrap items-center gap-1.5 ring-1 ring-brand-500/50 rounded px-2 py-1 -mx-1 min-h-[32px]",children:[e.map(p=>s.jsxs("span",{className:"inline-flex items-center gap-1 text-[10px] bg-surface-elevated text-fg-secondary rounded-full px-2 py-0.5 border border-border-default",children:[p,s.jsx("button",{onClick:()=>t(e.filter(g=>g!==p)),className:"text-fg-muted hover:text-red-500",children:"×"})]},p)),s.jsx("input",{ref:m,value:u,onChange:p=>d(p.target.value),onKeyDown:h,onBlur:()=>{u||l(!1)},className:"flex-1 min-w-[80px] bg-transparent text-xs text-fg-primary placeholder:text-fg-muted focus:outline-none",placeholder:r("detail.typeTagAndEnter")})]}):s.jsx("div",{onClick:()=>l(!0),className:"flex flex-wrap items-center gap-1.5 cursor-text hover:ring-1 hover:ring-border-default rounded px-1 -mx-1 py-0.5 transition-all min-h-[24px]",children:e.length>0?e.map(p=>s.jsx("span",{className:"text-[10px] px-2 py-0.5 bg-surface-elevated text-fg-muted rounded-full border border-border-default",children:p},p)):s.jsx("span",{className:"text-[10px] text-fg-muted italic",children:r("detail.typeTagAndEnter")})})}function Fp({content:e}){return s.jsx("div",{className:`prose prose-invert prose-sm max-w-none
658
658
  prose-headings:text-fg-primary prose-headings:font-semibold
659
659
  prose-p:text-fg-secondary prose-p:leading-relaxed
660
660
  prose-a:text-brand-400 prose-a:no-underline hover:prose-a:underline
@@ -663,4 +663,4 @@ https://github.com/highlightjs/highlight.js/issues/2277`),Rn=ze,nn=vt),Ut===void
663
663
  prose-strong:text-fg-primary
664
664
  prose-li:text-fg-secondary
665
665
  prose-hr:border-border-default
666
- prose-blockquote:border-brand-500/40 prose-blockquote:text-fg-secondary`,children:s.jsx(bp,{remarkPlugins:[xw,vk],rehypePlugins:[[Vk,{detect:!0,ignoreMissing:!0}]],children:e})})}function Wh({filename:e,content:t,onSave:n,embedded:r,readOnly:o}){const{t:l}=ft(["builder","common"]),[u,d]=k.useState(!1),[m,h]=k.useState(t),[p,g]=k.useState(!1),x=/\.(md|mdx|markdown)$/i.test(e),y=k.useRef(null);k.useEffect(()=>{h(t)},[t]),k.useEffect(()=>{if(u&&y.current){const T=y.current;T.style.height="auto",T.style.height=Math.max(200,T.scrollHeight)+"px"}},[u,m]);const w=async()=>{g(!0),await n(m),g(!1),d(!1)},N=o?null:s.jsx("div",{className:"flex items-center gap-2",children:u?s.jsxs(s.Fragment,{children:[s.jsx("button",{onClick:()=>{h(t),d(!1)},className:"text-[10px] px-2.5 py-1 rounded-md text-fg-tertiary hover:text-fg-secondary border border-border-default transition-colors",children:l("common:cancel")}),s.jsx("button",{onClick:w,disabled:p,className:"text-[10px] px-2.5 py-1 rounded-md bg-brand-600 hover:bg-brand-500 text-white transition-colors disabled:opacity-50",children:l(p?"common:saving":"common:save")})]}):s.jsxs("button",{onClick:()=>d(!0),className:"text-[10px] px-2.5 py-1 rounded-md text-fg-tertiary hover:text-fg-secondary border border-border-default transition-colors inline-flex items-center gap-1",children:[s.jsxs("svg",{className:"w-3 h-3",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[s.jsx("path",{d:"M11 4H4a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2v-7"}),s.jsx("path",{d:"M18.5 2.5a2.121 2.121 0 0 1 3 3L12 15l-4 1 1-4 9.5-9.5z"})]}),l("detail.edit")]})});return r?s.jsxs("div",{children:[s.jsx("div",{className:"flex items-center justify-end px-4 py-2 border-b border-border-default bg-surface-elevated/20",children:N}),u?s.jsx("textarea",{ref:y,value:m,onChange:T=>h(T.target.value),className:"w-full bg-surface-elevated/20 text-sm text-fg-primary font-mono p-4 focus:outline-none resize-y min-h-[200px] leading-relaxed",spellCheck:!1}):s.jsx("div",{className:"p-4",children:x?s.jsx(Fp,{content:t}):s.jsx("pre",{className:"text-xs leading-relaxed text-fg-secondary whitespace-pre-wrap font-mono",children:t})})]}):s.jsxs("div",{className:"rounded-xl border border-border-default bg-surface-secondary/40 overflow-hidden",children:[s.jsxs("div",{className:"flex items-center justify-between px-4 py-2.5 border-b border-border-default bg-surface-elevated/30",children:[s.jsx("span",{className:"text-xs font-medium text-fg-secondary font-mono",children:e}),N]}),u?s.jsx("textarea",{ref:y,value:m,onChange:T=>h(T.target.value),className:"w-full bg-surface-elevated/20 text-sm text-fg-primary font-mono p-4 focus:outline-none resize-y min-h-[200px] leading-relaxed",spellCheck:!1}):s.jsx("div",{className:"p-4",children:x?s.jsx(Fp,{content:t}):s.jsx("pre",{className:"text-xs leading-relaxed text-fg-secondary whitespace-pre-wrap font-mono",children:t})})]})}const p4={"README.md":0,"ROLE.md":1,"HEARTBEAT.md":2,"POLICIES.md":3,"CONTEXT.md":4,"ANNOUNCEMENT.md":0,"NORMS.md":1};function oK(e){return[...e].sort(([t],[n])=>{const r=p4[t]??99,o=p4[n]??99;return r!==o?r-o:t.localeCompare(n)})}function d0({files:e,onSave:t,noHeader:n,readOnly:r}){const o=k.useMemo(()=>oK(e),[e]),[l,u]=k.useState(0);if(o.length===1)return n?s.jsx(Wh,{filename:o[0][0],content:o[0][1],onSave:p=>t(o[0][0],p),readOnly:r}):s.jsxs("div",{className:"mb-8",children:[s.jsx("h2",{className:"text-sm font-semibold text-fg-primary mb-4 uppercase tracking-wider",children:"Files"}),s.jsx(Wh,{filename:o[0][0],content:o[0][1],onSave:p=>t(o[0][0],p),readOnly:r})]});const[d,m]=o[l]??o[0],h=s.jsxs("div",{className:"rounded-xl border border-border-default bg-surface-secondary/40 overflow-hidden",children:[s.jsx("div",{className:"flex items-center gap-0 overflow-x-auto bg-surface-elevated/30",children:o.map(([p],g)=>s.jsx("button",{onClick:()=>u(g),className:`px-4 py-2.5 text-xs font-medium whitespace-nowrap border-b-2 transition-colors ${g===l?"border-brand-500 text-brand-400 bg-surface-secondary/50":"border-transparent text-fg-tertiary hover:text-fg-secondary hover:bg-surface-elevated/50"}`,children:p},p))}),s.jsx(Wh,{filename:d,content:m,onSave:p=>t(d,p),embedded:!0,readOnly:r},d)]});return n?h:s.jsxs("div",{className:"mb-8",children:[s.jsx("h2",{className:"text-sm font-semibold text-fg-primary mb-4 uppercase tracking-wider",children:"Files"}),h]})}function lK({images:e,artifactType:t,artifactName:n,onUpload:r,onRemove:o,readOnly:l}){const{t:u}=ft(["builder"]),d=k.useRef(null);return e.length===0?l?null:s.jsxs("div",{className:"border-2 border-dashed border-border-default rounded-xl p-6 text-center text-fg-muted text-sm cursor-pointer hover:border-brand-500/30 transition-colors",onClick:()=>d.current?.click(),onDragOver:m=>m.preventDefault(),onDrop:m=>{m.preventDefault();const h=m.dataTransfer.files[0];h?.type.startsWith("image/")&&r(h)},children:[s.jsxs("svg",{className:"w-8 h-8 mx-auto mb-2 text-fg-muted/50",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round",children:[s.jsx("rect",{x:"3",y:"3",width:"18",height:"18",rx:"2"}),s.jsx("circle",{cx:"8.5",cy:"8.5",r:"1.5"}),s.jsx("polyline",{points:"21 15 16 10 5 21"})]}),s.jsx("span",{className:"block",children:u("images.dropOrClick")}),s.jsx("span",{className:"block text-xs text-fg-muted/60 mt-1",children:u("images.hint")}),s.jsx("input",{ref:d,type:"file",accept:"image/*",className:"hidden",onChange:m=>{const h=m.target.files?.[0];h&&r(h),m.target.value=""}})]}):s.jsxs("div",{children:[s.jsxs("div",{className:"flex gap-3 overflow-x-auto pb-2",children:[e.map(m=>{const h=m.split("/").pop()??m;return s.jsxs("div",{className:"relative group shrink-0 rounded-lg border border-border-default overflow-hidden bg-surface-elevated",children:[s.jsx("img",{src:`/api/builder/artifacts/${t}s/${encodeURIComponent(n)}/images/${encodeURIComponent(h)}`,alt:h,className:"h-32 w-auto object-cover"}),!l&&s.jsx("button",{onClick:()=>o(h),className:"absolute top-1.5 right-1.5 w-5 h-5 rounded-full bg-red-600/80 text-white flex items-center justify-center text-[10px] opacity-0 group-hover:opacity-100 transition-opacity",children:"×"})]},m)}),!l&&s.jsx("button",{onClick:()=>d.current?.click(),className:"shrink-0 h-32 w-24 rounded-lg border-2 border-dashed border-border-default flex items-center justify-center text-fg-muted hover:border-brand-500/30 hover:text-brand-400 transition-colors",children:s.jsxs("svg",{className:"w-6 h-6",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[s.jsx("line",{x1:"12",y1:"5",x2:"12",y2:"19"}),s.jsx("line",{x1:"5",y1:"12",x2:"19",y2:"12"})]})})]}),!l&&s.jsx("input",{ref:d,type:"file",accept:"image/*",className:"hidden",onChange:m=>{const h=m.target.files?.[0];h&&r(h),m.target.value=""}})]})}function cK({members:e,teamTopFiles:t,files:n,onFileSave:r,readOnly:o}){const{t:l}=ft(["builder"]),[u,d]=k.useState(0),m=k.useMemo(()=>{const N=new Set;for(const T of Object.keys(n)){const C=T.match(/^members\/([^/]+)\//);C&&N.add(C[1])}return[...N]},[n]),h=k.useMemo(()=>{const N=new Map,T=new Set;for(let _=0;_<e.length;_++){const O=qd(e[_].name);m.includes(O)&&!T.has(O)&&(N.set(_,O),T.add(O))}for(let _=0;_<e.length;_++){if(N.has(_))continue;const O=e[_].roleName;if(O){const z=qd(O);m.includes(z)&&!T.has(z)&&(N.set(_,z),T.add(z))}}for(let _=0;_<e.length;_++){if(N.has(_))continue;const O=e[_].name;for(const z of m){if(T.has(z))continue;const D=n[`members/${z}/ROLE.md`];if(!D)continue;const H=D.match(/^#\s+(.+)$/m)?.[1]?.trim();if(H&&(H.toLowerCase().includes(O.toLowerCase())||O.toLowerCase().includes(H.toLowerCase()))){N.set(_,z),T.add(z);break}}}const C=m.filter(_=>!T.has(_));let j=0;for(let _=0;_<e.length;_++)N.has(_)||j<C.length&&(N.set(_,C[j]),j++);return N},[e,m,n]),p=k.useCallback((N,T)=>{const C=h.get(T);return C?Object.entries(n).filter(([j])=>j.startsWith(`members/${C}/`)):[]},[n,h]),g=k.useMemo(()=>{const N=[{label:l("detail.overview")}];for(const T of e)N.push({label:T.name,role:T.role});return N},[e,l]),x=u>0?e[u-1]:null,y=u-1;return s.jsxs("div",{className:"rounded-xl border border-border-default bg-surface-secondary/40 overflow-hidden",children:[s.jsx("div",{className:"flex items-center gap-0 overflow-x-auto bg-surface-elevated/30 border-b border-border-default",children:g.map((N,T)=>{const C=T===u,j=N.role==="manager",_=T===0?C?"border-brand-500 text-brand-400":"border-transparent text-fg-tertiary hover:text-fg-secondary":j?C?"border-amber-500 text-amber-400":"border-transparent text-fg-tertiary hover:text-fg-secondary":C?"border-blue-500 text-blue-400":"border-transparent text-fg-tertiary hover:text-fg-secondary";return s.jsxs("button",{onClick:()=>d(T),className:`px-4 py-2.5 text-xs font-medium whitespace-nowrap border-b-2 transition-colors flex items-center gap-1.5 ${_} ${C?"bg-surface-secondary/50":"hover:bg-surface-elevated/50"}`,children:[T===0&&s.jsxs("svg",{className:"w-3 h-3",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[s.jsx("path",{d:"M3 9l9-7 9 7v11a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2z"}),s.jsx("polyline",{points:"9 22 9 12 15 12 15 22"})]}),T>0&&s.jsx("span",{className:`w-4 h-4 rounded-full text-[9px] font-bold flex items-center justify-center shrink-0 ${j?"bg-amber-500/20 text-amber-400":"bg-blue-500/20 text-blue-400"}`,children:(N.label[0]??"?").toUpperCase()}),N.label]},T)})}),s.jsx("div",{className:"p-5",children:u===0?s.jsxs("div",{className:"space-y-6",children:[t.length>0&&s.jsx(d0,{noHeader:!0,files:t,onSave:w,readOnly:o}),s.jsxs("div",{children:[s.jsx("div",{className:"text-[10px] font-semibold text-fg-tertiary uppercase tracking-wider mb-3",children:l("sidebar.composition")}),s.jsx("div",{className:"grid gap-2 sm:grid-cols-2",children:e.map((N,T)=>{const C=N.role==="manager";return s.jsxs("button",{onClick:()=>d(T+1),className:"text-left rounded-lg border border-border-default bg-surface-elevated/30 px-4 py-3 flex gap-3 items-center hover:border-gray-600 transition-colors cursor-pointer",children:[s.jsx("div",{className:`w-8 h-8 rounded-full flex items-center justify-center text-xs font-bold shrink-0 ${C?"bg-amber-500/15 text-amber-400 ring-1 ring-amber-500/30":"bg-blue-500/15 text-blue-400 ring-1 ring-blue-500/30"}`,children:(N.name[0]??"?").toUpperCase()}),s.jsxs("div",{className:"flex-1 min-w-0",children:[s.jsxs("div",{className:"flex items-center gap-1.5",children:[s.jsx("span",{className:"text-xs font-medium text-fg-primary truncate",children:N.name}),s.jsx("span",{className:`text-[9px] px-1.5 py-0.5 rounded-full font-medium ${C?"bg-amber-500/15 text-amber-400":"bg-blue-500/15 text-blue-400"}`,children:N.role}),N.count>1&&s.jsxs("span",{className:"text-[9px] text-fg-muted",children:["×",N.count]})]}),N.skills&&N.skills.length>0&&s.jsxs("div",{className:"flex flex-wrap gap-1 mt-1",children:[N.skills.slice(0,3).map(j=>s.jsx("span",{className:"text-[9px] px-1.5 py-0.5 bg-surface-elevated text-fg-muted rounded border border-border-default",children:j},j)),N.skills.length>3&&s.jsxs("span",{className:"text-[9px] text-fg-muted",children:["+",N.skills.length-3]})]})]}),s.jsx("svg",{className:"w-3.5 h-3.5 text-fg-muted shrink-0",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:s.jsx("polyline",{points:"9 18 15 12 9 6"})})]},T)})})]})]}):x?s.jsxs("div",{className:"space-y-4",children:[s.jsxs("div",{className:"flex items-center gap-4",children:[s.jsx("div",{className:`w-12 h-12 rounded-full flex items-center justify-center text-lg font-bold shrink-0 ${x.role==="manager"?"bg-amber-500/15 text-amber-400 ring-2 ring-amber-500/30":"bg-blue-500/15 text-blue-400 ring-2 ring-blue-500/30"}`,children:(x.name[0]??"?").toUpperCase()}),s.jsxs("div",{className:"flex-1 min-w-0",children:[s.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[s.jsx("span",{className:"text-sm font-semibold text-fg-primary",children:x.name}),s.jsx("span",{className:`text-[10px] px-2 py-0.5 rounded-full font-medium ${x.role==="manager"?"bg-amber-500/15 text-amber-400":"bg-blue-500/15 text-blue-400"}`,children:x.role}),x.count>1&&s.jsxs("span",{className:"text-[10px] text-fg-muted",children:["×",x.count]})]}),x.roleName&&s.jsx("div",{className:"text-xs text-fg-tertiary mt-0.5 italic",children:x.roleName})]})]}),x.skills&&x.skills.length>0&&s.jsx("div",{className:"flex flex-wrap gap-1.5",children:x.skills.map(N=>s.jsx("span",{className:"text-[10px] px-2.5 py-1 bg-surface-elevated text-fg-muted rounded-full border border-border-default",children:N},N))}),(()=>{const N=p(x.name,y);return N.length===0?s.jsx("p",{className:"text-xs text-fg-muted italic",children:"No files for this member yet."}):s.jsx(d0,{noHeader:!0,readOnly:o,files:N.map(([T,C])=>[T.replace(/^members\/[^/]+\//,""),C]),onSave:(T,C)=>{const j=N.find(([_])=>_.endsWith(`/${T}`));j&&r(j[0],C)}})})()]}):null})]});function w(N,T){r(N,T)}}function Ai({type:e,name:t,onBack:n,authUser:r,readOnly:o,initialManifest:l,actionSlot:u,contentSlot:d}){const{t:m}=ft(["builder","common"]),h=Uo(),[p,g]=k.useState(!0),[x,y]=k.useState(t),[w,N]=k.useState({}),[T,C]=k.useState(null),[j,_]=k.useState(""),[O,z]=k.useState("idle"),[D,H]=k.useState({shared:!1}),[W,Z]=k.useState(!1),[U,Y]=k.useState(!1),[ae,X]=k.useState(!1),[F,J]=k.useState(!1),[B,Q]=k.useState(!1),[re,we]=k.useState(!1),[$,G]=k.useState(null),[ce,I]=k.useState(""),[Ee,Ue]=k.useState(""),[De,Ke]=k.useState(""),[st,mt]=k.useState(""),[ct,Dt]=k.useState([]),[Mt,Xt]=k.useState(""),Me=k.useRef(null),Ne=k.useRef(l);Ne.current=l,k.useEffect(()=>{y(t)},[t]);const Re=k.useCallback(async()=>{const he=Ne.current;if(he){C(he),I(he.displayName||he.name||t),Ue(he.description||""),Ke(he.version||"1.0.0"),mt(he.category||"general"),Dt(he.tags||[]),Xt(he.icon||""),N(he.files??{}),g(!1);return}g(!0);try{let ye=t;try{const St=await Ce.builder.artifacts.ensureSlugSafe(e,t);ye=St.name,y(ye),St.converted&&(history.replaceState(null,"",Si(me.BUILDER,`${e}/${encodeURIComponent(ye)}`)),window.dispatchEvent(new CustomEvent("markus:data-changed")))}catch{y(t)}const Ze=await Ce.builder.artifacts.get(e,ye);N(Ze.files??{}),_(Ze.path??"");const rt=Ze.files[`${e}.json`]??Ze.files["agent.json"]??Ze.files["team.json"]??Ze.files["skill.json"];if(rt){const St=JSON.parse(rt);C(St),I(St.displayName||St.name||t),Ue(St.description||""),Ke(St.version||"1.0.0"),mt(St.category||"general"),Dt(St.tags||[]),Xt(St.icon||"")}}catch(ye){console.error("Failed to load artifact:",ye)}finally{g(!1)}},[e,t]);k.useEffect(()=>{Re()},[Re]),k.useEffect(()=>{l?.files&&N(l.files)},[l?.files]),k.useEffect(()=>{if(!o){try{const he=localStorage.getItem("markus_builder_shared_map");if(he){const ye=JSON.parse(he),Ze=`${e}/${t}`;ye[Ze]&&H({shared:!0,id:ye[Ze].id,slug:ye[Ze].slug,version:ye[Ze].version,visibility:ye[Ze].visibility??"public"})}}catch{}lt.myItems().then(he=>{const ye=he?.items??[],Ze=e==="agent"?"agent":e==="team"?"team":"skill";for(const rt of ye)if(rt.itemType===Ze&&(rt.slug===t||rt.name===t)){H({shared:!0,id:rt.id,slug:rt.slug,version:rt.version,visibility:rt.visibility??"public",moderationStatus:rt.moderationStatus,pendingReview:rt.pendingReview});return}}).catch(()=>{})}},[e,t,o]);const ut=k.useCallback(async he=>{if(!(!T||o)){z("saving");try{const ye={...T,...he};await Ce.builder.artifacts.save(e,ye),C(ye),z("saved"),setTimeout(()=>z(Ze=>Ze==="saved"?"idle":Ze),2e3)}catch{z("error"),setTimeout(()=>z("idle"),3e3)}}},[T,e]),it=k.useCallback(he=>{Me.current&&clearTimeout(Me.current),Me.current=setTimeout(()=>ut(he),800)},[ut]),bt=k.useCallback((he,ye)=>{const Ze={};he==="displayName"?(I(ye),Ze.displayName=ye,Y(!0)):he==="description"?(Ue(ye),Ze.description=ye,Y(!0)):he==="version"?(Ke(ye),Ze.version=ye,Y(!1),X(!1)):he==="category"?(mt(ye),Ze.category=ye,Y(!0)):he==="tags"?(Dt(ye),Ze.tags=ye,Y(!0)):he==="icon"&&(Xt(ye),Ze.icon=ye||void 0,Y(!0)),it({...T,...Ze})},[T,it]),se=k.useCallback(async(he,ye)=>{try{const Ze={...w,[he]:ye};N(Ze);const rt={...T,files:Ze};await Ce.builder.artifacts.save(e,rt),z("saved"),Y(!0),setTimeout(()=>z(St=>St==="saved"?"idle":St),2e3)}catch{z("error")}},[w,e,T]),et=k.useCallback(async he=>{if(T){Z(!0);try{await lt.ensureAuth();const ye=await Ce.builder.artifacts.ensureSlugSafe(e,x,T.displayName||T.name||x),Ze=ye.name,rt=ye.slug||dc(Ze);if(!rt)throw new Error("Invalid package slug: use English kebab-case for the artifact name (e.g. qwen-multimodal). Chinese-only names cannot be shared — rename the package slug and put the Chinese title in displayName.");const St=ye.displayName||T.displayName||T.name||x;ye.converted&&(y(Ze),C(ie=>ie&&{...ie,name:rt,displayName:St}),history.replaceState(null,"",Si(me.BUILDER,`${e}/${encodeURIComponent(Ze)}`)),window.dispatchEvent(new CustomEvent("markus:data-changed")));const Bt={...T,name:rt,displayName:St},wt=Bt.description||"",hn=Bt.category||"general",R=Bt.tags??[];let oe=Bt.icon||void 0;const _e=Bt.version||"1.0.0";if(oe&&!oe.startsWith("http")&&/\.(png|jpe?g|gif|webp|svg)$/i.test(oe)){const ie=oe.split("/").pop()??oe;try{const Se=await fetch(`/api/builder/artifacts/${e}s/${encodeURIComponent(Ze)}/images/${encodeURIComponent(ie)}`);if(Se.ok){const Ie=await Se.blob(),Xe=new File([Ie],ie,{type:Ie.type}),yt=await lt.uploadImage(Xe);yt?.url&&(oe=yt.url)}}catch{}}let de;const $e=[],qe=Bt.screenshots??[];for(let ie=0;ie<qe.length;ie++){const Se=qe[ie],Ie=Se.split("/").pop()??Se;try{const Xe=await fetch(`/api/builder/artifacts/${e}s/${encodeURIComponent(Ze)}/images/${encodeURIComponent(Ie)}`);if(Xe.ok){const yt=await Xe.blob(),Pe=new File([yt],Ie,{type:yt.type}),Je=await lt.uploadImage(Pe);Je?.url&&($e.push({url:Je.url,alt:Ie,order:ie}),ie===0&&(de=Je.url))}}catch{}}const q=await lt.publishViaProxy({itemType:e==="team"?"team":e==="skill"?"skill":"agent",name:St,slug:rt,description:wt,category:hn,tags:R,icon:oe,version:_e,config:Bt,files:Object.keys(w).length>0?w:void 0,thumbnailUrl:de,images:$e.length>0?$e:void 0,priceCents:he?.priceCents,donationsEnabled:he?.donationsEnabled,visibility:he?.visibility,orgId:he?.orgId});q.id&&(H({shared:!0,id:q.id,slug:q.slug??rt,version:_e,visibility:q.visibility??he?.visibility??"public",moderationStatus:q.moderationStatus,pendingReview:q.pendingReview}),Y(!1),(q.visibility??he?.visibility??"public")!=="org"&&(q.moderationStatus==="pending"||q.pendingReview)?G({title:m("common:share"),message:ye.converted?m("share.convertedAndSubmitted",{previous:t,slug:rt}):q.updated?m("share.updateSubmitted"):m("share.submittedForReview"),variant:"primary"}):ye.converted&&G({title:m("common:share"),message:m("share.convertedSlug",{previous:t,slug:rt}),variant:"primary"}))}catch(ye){console.error("Share to Hub failed:",ye),G({title:m("common:share"),message:ye instanceof Error?ye.message:String(ye),variant:"danger"})}finally{Z(!1)}}},[T,w,e,t,x,m]),nt=async he=>{const ye=new FormData;ye.append("image",he);try{await fetch(`/api/builder/artifacts/${e}s/${encodeURIComponent(x)}/images`,{method:"POST",body:ye,credentials:"include"}),await Re(),Y(!0)}catch(Ze){console.error("Image upload failed:",Ze)}},Ge=async he=>{try{await fetch(`/api/builder/artifacts/${e}s/${encodeURIComponent(x)}/images/${encodeURIComponent(he)}`,{method:"DELETE",credentials:"include"}),await Re(),Y(!0)}catch(ye){console.error("Image remove failed:",ye)}},Qe=h4[e]??h4.agent,xt=T?.screenshots??[],pe=T?.skill?.skillFile?w[T.skill.skillFile]:w["SKILL.md"]??w["README.md"],V=k.useMemo(()=>e!=="agent"?[]:Object.entries(w).filter(([he])=>!he.endsWith(".json")&&!he.startsWith("images/")&&!he.startsWith("members/")),[w,e]),xe=k.useMemo(()=>e!=="team"?[]:Object.entries(w).filter(([he])=>!he.endsWith(".json")&&!he.startsWith("images/")&&!he.startsWith("members/")),[w,e]),We=k.useMemo(()=>{if(e==="agent"||e==="team")return[];const he=new Set;if(e==="skill"){const ye=T?.skill?.skillFile;ye&&w[ye]&&he.add(ye),!ye&&w["SKILL.md"]&&he.add("SKILL.md"),!ye&&!w["SKILL.md"]&&w["README.md"]&&he.add("README.md")}return Object.entries(w).filter(([ye])=>!ye.endsWith(".json")&&!ye.startsWith("images/")&&!ye.startsWith("members/")&&!he.has(ye))},[w,e,T?.skill?.skillFile]);return p?s.jsx("div",{className:"flex-1 overflow-y-auto",children:s.jsxs("div",{className:"px-6 py-8",children:[s.jsxs("button",{onClick:n,className:"text-xs text-brand-400 hover:text-brand-300 mb-4 inline-flex items-center gap-1",children:[s.jsx("svg",{className:"w-3.5 h-3.5",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:s.jsx("polyline",{points:"15 18 9 12 15 6"})}),m("detail.backToBuilder")]}),s.jsx("div",{className:"text-fg-tertiary text-sm animate-pulse py-20 text-center",children:m("common:loading")})]})}):T?s.jsxs("div",{className:"flex-1 overflow-y-auto",children:[s.jsxs("div",{className:`${h?"px-4 py-5":"px-6 py-8"}`,children:[s.jsxs("div",{className:"flex items-center justify-between mb-6",children:[s.jsxs("button",{onClick:n,className:"text-xs text-brand-400 hover:text-brand-300 inline-flex items-center gap-1",children:[s.jsx("svg",{className:"w-3.5 h-3.5",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:s.jsx("polyline",{points:"15 18 9 12 15 6"})}),m(o?"common:back":"detail.backToBuilder")]}),s.jsxs("div",{className:"flex items-center gap-2",children:[!o&&O==="saving"&&s.jsx("span",{className:"text-[10px] text-fg-muted animate-pulse",children:m("detail.saving")}),!o&&O==="saved"&&s.jsxs("span",{className:"text-[10px] text-green-500 inline-flex items-center gap-1",children:[s.jsx("svg",{className:"w-3 h-3",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",children:s.jsx("polyline",{points:"20 6 9 17 4 12"})}),m("detail.saved")]}),!o&&O==="error"&&s.jsx("span",{className:"text-[10px] text-red-500",children:m("detail.saveFailed")}),u,!o&&D.shared&&(()=>{const he=lt.getUser(),ye=he&&D.slug?`${lt.getUrl()}/@${encodeURIComponent(he.username)}/${encodeURIComponent(D.slug)}`:null,Ze=De||T?.version||"1.0.0",rt=D.version!==Ze;return s.jsxs(s.Fragment,{children:[D.moderationStatus==="pending"?s.jsxs("span",{className:"text-xs px-2 py-1.5 rounded-lg border border-amber-500/30 text-amber-400 inline-flex items-center gap-1",title:m("share.underReviewTip"),children:[s.jsxs("svg",{className:"w-3 h-3",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[s.jsx("circle",{cx:"12",cy:"12",r:"10"}),s.jsx("polyline",{points:"12 6 12 12 16 14"})]}),m("share.underReview")]}):D.moderationStatus==="rejected"?s.jsxs("span",{className:"text-xs px-2 py-1.5 rounded-lg border border-red-500/30 text-red-400 inline-flex items-center gap-1",title:m("share.rejectedTip"),children:[s.jsxs("svg",{className:"w-3 h-3",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[s.jsx("circle",{cx:"12",cy:"12",r:"10"}),s.jsx("line",{x1:"15",y1:"9",x2:"9",y2:"15"}),s.jsx("line",{x1:"9",y1:"9",x2:"15",y2:"15"})]}),m("share.rejected")]}):D.pendingReview?s.jsxs("span",{className:"text-xs px-2 py-1.5 rounded-lg border border-amber-500/30 text-amber-400 inline-flex items-center gap-1",title:m("share.updateUnderReviewTip"),children:[s.jsxs("svg",{className:"w-3 h-3",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[s.jsx("circle",{cx:"12",cy:"12",r:"10"}),s.jsx("polyline",{points:"12 6 12 12 16 14"})]}),m("share.updateUnderReview")]}):null,ye&&s.jsxs("a",{href:ye,target:"_blank",rel:"noopener noreferrer",onClick:St=>{Gd()&&(St.preventDefault(),Oo(ye))},className:`text-xs px-3 py-1.5 rounded-lg border transition-colors inline-flex items-center gap-1.5 ${D.visibility==="org"?"border-blue-500/30 text-blue-500 hover:text-blue-400 hover:border-blue-400/50":D.visibility==="unlisted"?"border-gray-500/30 text-fg-tertiary hover:text-fg-secondary hover:border-gray-400/50":"border-green-600/30 text-green-600 hover:text-green-500 hover:border-green-500/50"}`,children:[D.visibility==="org"?s.jsxs("svg",{className:"w-3 h-3",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[s.jsx("path",{d:"M3 21h18"}),s.jsx("path",{d:"M9 8h1"}),s.jsx("path",{d:"M9 12h1"}),s.jsx("path",{d:"M9 16h1"}),s.jsx("path",{d:"M14 8h1"}),s.jsx("path",{d:"M14 12h1"}),s.jsx("path",{d:"M14 16h1"}),s.jsx("path",{d:"M5 21V5a2 2 0 0 1 2-2h10a2 2 0 0 1 2 2v16"})]}):D.visibility==="unlisted"?s.jsxs("svg",{className:"w-3 h-3",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[s.jsx("path",{d:"M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71"}),s.jsx("path",{d:"M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71"})]}):s.jsxs("svg",{className:"w-3 h-3",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[s.jsx("path",{d:"M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6"}),s.jsx("polyline",{points:"15 3 21 3 21 9"}),s.jsx("line",{x1:"10",y1:"14",x2:"21",y2:"3"})]}),D.visibility==="org"?m("visibility.sharedOrg"):D.visibility==="unlisted"?m("visibility.sharedUnlisted"):m("share.viewOnHub")]}),rt&&s.jsx("button",{onClick:()=>{et({visibility:D.visibility})},disabled:W,className:"text-xs px-3 py-1.5 rounded-lg border border-amber-500/30 text-amber-400 hover:bg-amber-500/10 hover:border-amber-500/50 transition-colors disabled:opacity-50",children:W?m("share.updating"):m("share.updateVersion",{version:Ze})})]})})(),!o&&!D.shared&&s.jsx("button",{onClick:()=>Q(!0),disabled:W,className:"text-xs px-3 py-1.5 rounded-lg bg-brand-600 hover:bg-brand-500 text-white transition-colors disabled:opacity-50",children:m(W?"share.sharing":"share.toHub")})]})]}),!o&&U&&!ae&&s.jsxs("div",{className:"mb-4 px-4 py-2.5 rounded-lg bg-amber-50 dark:bg-amber-500/10 border border-amber-300 dark:border-amber-500/20 flex items-center justify-between",children:[s.jsx("span",{className:"text-xs text-amber-800 dark:text-amber-300",children:m("versionBump.contentModified")}),s.jsx("button",{onClick:()=>X(!0),className:"text-xs px-3 py-1 rounded bg-amber-200 dark:bg-amber-500/20 text-amber-800 dark:text-amber-300 hover:bg-amber-300 dark:hover:bg-amber-500/30 transition-colors",children:m("versionBump.bumpVersion")})]}),!o&&ae&&s.jsxs("div",{className:"mb-4 px-4 py-3 rounded-lg bg-amber-50 dark:bg-amber-500/10 border border-amber-300 dark:border-amber-500/20",children:[s.jsxs("div",{className:"flex items-center gap-3",children:[s.jsx("span",{className:"text-xs text-amber-800 dark:text-amber-300",children:m("versionBump.newVersion")}),s.jsx("input",{type:"text",defaultValue:(()=>{const he=(De||"1.0.0").split(".");return he[2]=String(Number(he[2]??0)+1),he.join(".")})(),className:"text-xs px-2 py-1 rounded bg-surface-elevated border border-border-default text-fg-primary w-24 font-mono",onKeyDown:he=>{he.key==="Enter"&&bt("version",he.target.value)}}),s.jsx("button",{onClick:he=>{const ye=he.target.parentElement?.querySelector("input");ye&&bt("version",ye.value)},className:"text-xs px-3 py-1 rounded bg-amber-200 dark:bg-amber-500/20 text-amber-800 dark:text-amber-300 hover:bg-amber-300 dark:hover:bg-amber-500/30 transition-colors",children:m("common:confirm")}),s.jsx("button",{onClick:()=>X(!1),className:"text-xs text-fg-tertiary hover:text-fg-secondary",children:m("common:cancel")})]}),D.shared&&s.jsx("p",{className:"text-[10px] text-fg-tertiary mt-2",children:"After bumping the version, you can share the new version to Hub."})]}),s.jsxs("div",{className:`flex gap-8 ${h?"flex-col":""}`,children:[s.jsxs("div",{className:`${h?"w-full":"flex-1 min-w-0"}`,children:[s.jsxs("div",{className:"flex items-start gap-4 mb-6",children:[s.jsxs("div",{className:"relative",children:[s.jsx("div",{onClick:()=>!o&&we(!re),className:`w-16 h-16 rounded-xl ${Qe.bg} flex items-center justify-center text-3xl shrink-0 ${o?"":"cursor-pointer hover:ring-2"} ${Qe.ring} transition-all overflow-hidden`,children:Mt&&Mt.startsWith("images/")?s.jsx("img",{src:`/api/builder/artifacts/${e}s/${encodeURIComponent(x)}/images/${encodeURIComponent(Mt.replace("images/",""))}`,alt:"",className:"w-full h-full object-cover"}):Mt&&(Mt.startsWith("http")||Mt.startsWith("/"))?s.jsx("img",{src:Mt,alt:"",className:"w-full h-full object-cover"}):(()=>{const he=Mt||"";if(he&&[...he].length<=2&&new RegExp("\\p{Emoji}","u").test(he))return he;const Ze=Ti[Wo(e)].accent;return s.jsx("svg",{width:"36",height:"36",viewBox:"0 0 24 24",fill:"none","aria-hidden":!0,children:s.jsx("path",{d:y3(ce||t||e),fill:Ze})})})()}),!o&&re&&s.jsxs(s.Fragment,{children:[s.jsx("div",{className:"fixed inset-0 z-40",onClick:()=>we(!1)}),s.jsxs("div",{className:"absolute top-full left-0 mt-2 z-50 bg-surface-secondary border border-border-default rounded-xl p-3 shadow-xl w-80",children:[s.jsxs("div",{className:"flex items-center gap-2 mb-3",children:[s.jsx("input",{type:"text",placeholder:m("detail.pasteEmojiOrUrl"),className:"flex-1 text-sm px-2 py-1.5 rounded-lg bg-surface-elevated border border-border-default text-fg-primary placeholder:text-fg-muted",defaultValue:Mt,onKeyDown:he=>{he.key==="Enter"&&(bt("icon",he.target.value),we(!1))}}),s.jsxs("label",{className:"text-[10px] text-brand-400 hover:text-brand-300 cursor-pointer px-1.5 py-1 border border-brand-500/30 rounded-lg",children:[m("detail.upload"),s.jsx("input",{type:"file",accept:"image/*",className:"hidden",onChange:async he=>{const ye=he.target.files?.[0];if(!ye)return;const Ze=new FormData;Ze.append("image",ye);try{const rt=await fetch(`/api/builder/artifacts/${e}s/${encodeURIComponent(x)}/images`,{method:"POST",body:Ze,credentials:"include"});if(rt.ok){const Bt=(await rt.json()).path;if(Xt(Bt),we(!1),T){const wt={...T,icon:Bt};C(wt),await Ce.builder.artifacts.save(e,wt)}Y(!0)}}catch{}}})]}),Mt&&s.jsx("button",{onClick:()=>{bt("icon",""),we(!1)},className:"text-[10px] text-fg-tertiary hover:text-red-400 px-1",children:"✕"})]}),s.jsx("div",{className:"max-h-64 overflow-y-auto",children:rK.map(he=>s.jsxs("div",{className:"mb-2.5",children:[s.jsx("div",{className:"text-[10px] text-fg-tertiary mb-1 sticky top-0 bg-surface-secondary py-0.5",children:he.label}),s.jsx("div",{className:"flex flex-wrap gap-0.5",children:he.emojis.map(ye=>s.jsx("button",{onClick:()=>{bt("icon",ye),we(!1)},className:`w-7 h-7 rounded flex items-center justify-center text-base hover:bg-surface-elevated transition-colors ${Mt===ye?"ring-1.5 ring-brand-500 bg-brand-500/10":""}`,children:ye},ye))})]},he.label))})]})]})]}),s.jsxs("div",{className:"flex-1 min-w-0",children:[s.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[s.jsx(Kh,{value:ce,onChange:he=>bt("displayName",he),renderAs:"h1",className:"text-xl font-bold text-fg-primary",placeholder:m("detail.untitled"),readOnly:o}),s.jsx("span",{className:`text-[10px] font-medium uppercase tracking-wider px-2 py-0.5 rounded-full ${Qe.bg} ${Qe.color}`,children:Qe.label}),s.jsx(Kh,{value:De,onChange:he=>bt("version",he),renderAs:"badge",className:"text-[10px] px-2 py-0.5 rounded-full bg-surface-elevated text-fg-tertiary border border-border-default font-mono",placeholder:"1.0.0",readOnly:o})]}),s.jsx(Kh,{value:Ee,onChange:he=>bt("description",he),renderAs:"p",className:"text-sm text-fg-secondary mt-1.5 leading-relaxed",placeholder:m("detail.addDescription"),multiline:!0,readOnly:o}),s.jsxs("div",{className:"flex items-center gap-2 mt-2 flex-wrap",children:[s.jsx(sK,{value:st,options:nK,onChange:he=>bt("category",he),className:"text-xs px-2 py-0.5 rounded bg-surface-elevated text-fg-tertiary",readOnly:o}),s.jsx(iK,{tags:ct,onChange:he=>bt("tags",he),readOnly:o})]})]})]}),s.jsx("div",{className:"mb-8",children:s.jsx(lK,{images:xt,artifactType:e,artifactName:t,onUpload:nt,onRemove:Ge,readOnly:o})}),d&&s.jsx("div",{className:"mb-8",children:d}),e==="team"&&T.team&&s.jsx("div",{className:"mb-8",children:s.jsx(cK,{members:T.team.members,teamTopFiles:xe,files:w,onFileSave:se,readOnly:o})}),e==="agent"&&V.length>0&&s.jsxs("div",{className:"mb-8",children:[s.jsx("h2",{className:"text-sm font-semibold text-fg-primary mb-4 uppercase tracking-wider",children:"About This Agent"}),s.jsx(d0,{noHeader:!0,files:V,onSave:se,readOnly:o})]}),e==="skill"&&s.jsxs("div",{className:"mb-8",children:[T.skill?.requiredPermissions&&T.skill.requiredPermissions.length>0&&s.jsxs("div",{className:"mb-6",children:[s.jsx("h2",{className:"text-sm font-semibold text-fg-primary mb-3 uppercase tracking-wider",children:m("sidebar.permissions")}),s.jsx("div",{className:"flex flex-wrap gap-2",children:T.skill.requiredPermissions.map(he=>{const ye=aK[he];return s.jsxs("span",{className:`inline-flex items-center gap-1.5 text-xs px-3 py-1.5 rounded-lg border font-medium ${ye?.color??"bg-surface-elevated text-fg-secondary border-border-default"}`,children:[s.jsx("span",{className:"font-mono text-[10px]",children:ye?.icon??"?"})," ",he]},he)})})]}),T.skill?.mcpServers&&Object.keys(T.skill.mcpServers).length>0&&s.jsxs("div",{className:"mb-6",children:[s.jsx("h2",{className:"text-sm font-semibold text-fg-primary mb-3 uppercase tracking-wider",children:"Integrations"}),s.jsx("div",{className:"grid gap-2",children:Object.entries(T.skill.mcpServers).map(([he,ye])=>s.jsxs("div",{className:"rounded-lg border border-border-default bg-surface-secondary/40 px-4 py-3 flex items-center gap-3",children:[s.jsx("span",{className:"w-8 h-8 rounded-lg bg-purple-500/15 flex items-center justify-center text-purple-400 text-sm shrink-0",children:"◎"}),s.jsxs("div",{children:[s.jsx("div",{className:"text-xs font-medium text-fg-primary",children:he}),s.jsx("div",{className:"text-[10px] text-fg-muted font-mono truncate",children:typeof ye=="object"?JSON.stringify(ye).slice(0,80):String(ye)})]})]},he))})]}),pe&&s.jsxs("div",{children:[s.jsx("h2",{className:"text-sm font-semibold text-fg-primary mb-3 uppercase tracking-wider",children:"Instructions"}),s.jsx("div",{className:"rounded-xl border border-border-default bg-surface-secondary/40 p-5",children:s.jsx(Fp,{content:pe})})]})]}),We.length>0&&s.jsx(d0,{files:We,onSave:se,readOnly:o})]}),s.jsx("div",{className:`${h?"w-full":"w-72 shrink-0"}`,children:s.jsxs("div",{className:`${h?"":"sticky top-6"} space-y-4`,children:[s.jsxs("div",{className:"rounded-xl border border-border-default bg-surface-secondary/60 p-4 space-y-3",children:[s.jsx("div",{className:"text-xs font-medium text-fg-tertiary uppercase tracking-wider",children:m("sidebar.info")}),s.jsxs("div",{className:"space-y-2 text-xs",children:[s.jsxs("div",{className:"flex justify-between",children:[s.jsx("span",{className:"text-fg-muted",children:m("sidebar.type")}),s.jsx("span",{className:`font-medium ${Qe.color}`,children:Qe.label})]}),s.jsxs("div",{className:"flex justify-between",children:[s.jsx("span",{className:"text-fg-muted",children:m("sidebar.category")}),s.jsx("span",{className:"text-fg-secondary",children:st})]}),s.jsxs("div",{className:"flex justify-between",children:[s.jsx("span",{className:"text-fg-muted",children:m("sidebar.version")}),s.jsx("span",{className:"text-fg-secondary font-mono",children:De})]}),T.author&&s.jsxs("div",{className:"flex justify-between",children:[s.jsx("span",{className:"text-fg-muted",children:m("sidebar.author")}),s.jsx("span",{className:"text-fg-secondary",children:typeof T.author=="string"?T.author:T.author?.name??""})]})]})]}),e==="agent"&&T.agent&&s.jsxs("div",{className:"rounded-xl border border-border-default bg-surface-secondary/60 p-4 space-y-3",children:[s.jsx("div",{className:"text-xs font-medium text-fg-tertiary uppercase tracking-wider",children:m("sidebar.agentSpecs")}),s.jsxs("div",{className:"space-y-2 text-xs",children:[T.agent.roleName&&s.jsxs("div",{className:"flex justify-between",children:[s.jsx("span",{className:"text-fg-muted",children:m("sidebar.role")}),s.jsx("span",{className:"text-fg-secondary",children:T.agent.roleName})]}),T.agent.llmProvider&&s.jsxs("div",{className:"flex justify-between",children:[s.jsx("span",{className:"text-fg-muted",children:m("sidebar.provider")}),s.jsx("span",{className:"text-fg-secondary",children:T.agent.llmProvider})]}),T.agent.llmModel&&s.jsxs("div",{className:"flex justify-between",children:[s.jsx("span",{className:"text-fg-muted",children:m("sidebar.model")}),s.jsx("span",{className:"text-fg-secondary font-mono",children:T.agent.llmModel})]}),T.agent.temperature!==void 0&&s.jsxs("div",{className:"flex justify-between",children:[s.jsx("span",{className:"text-fg-muted",children:m("sidebar.temperature")}),s.jsx("span",{className:"text-fg-secondary",children:T.agent.temperature})]})]})]}),e==="team"&&T.team&&s.jsxs("div",{className:"rounded-xl border border-border-default bg-surface-secondary/60 p-4 space-y-3",children:[s.jsx("div",{className:"text-xs font-medium text-fg-tertiary uppercase tracking-wider",children:m("sidebar.composition")}),s.jsxs("div",{className:"space-y-2 text-xs",children:[s.jsxs("div",{className:"flex justify-between",children:[s.jsx("span",{className:"text-fg-muted",children:m("sidebar.totalMembers")}),s.jsx("span",{className:"text-fg-secondary",children:T.team.members.reduce((he,ye)=>he+ye.count,0)})]}),s.jsxs("div",{className:"flex justify-between",children:[s.jsx("span",{className:"text-fg-muted",children:m("sidebar.managers")}),s.jsx("span",{className:"text-amber-400",children:T.team.members.filter(he=>he.role==="manager").reduce((he,ye)=>he+ye.count,0)})]}),s.jsxs("div",{className:"flex justify-between",children:[s.jsx("span",{className:"text-fg-muted",children:m("sidebar.workers")}),s.jsx("span",{className:"text-blue-400",children:T.team.members.filter(he=>he.role!=="manager").reduce((he,ye)=>he+ye.count,0)})]})]})]}),e==="skill"&&T.skill&&s.jsxs("div",{className:"rounded-xl border border-border-default bg-surface-secondary/60 p-4 space-y-3",children:[s.jsx("div",{className:"text-xs font-medium text-fg-tertiary uppercase tracking-wider",children:m("sidebar.skillInfo")}),s.jsxs("div",{className:"space-y-2 text-xs",children:[T.skill.alwaysOn!==void 0&&s.jsxs("div",{className:"flex justify-between",children:[s.jsx("span",{className:"text-fg-muted",children:m("sidebar.alwaysOn")}),s.jsx("span",{className:T.skill.alwaysOn?"text-green-400":"text-fg-secondary",children:T.skill.alwaysOn?m("sidebar.yes"):m("sidebar.no")})]}),s.jsxs("div",{className:"flex justify-between",children:[s.jsx("span",{className:"text-fg-muted",children:m("sidebar.skillFile")}),s.jsx("span",{className:"text-fg-secondary font-mono truncate ml-2",children:T.skill.skillFile})]}),T.skill.requiredPermissions&&T.skill.requiredPermissions.length>0&&s.jsxs("div",{children:[s.jsx("span",{className:"text-fg-muted",children:m("sidebar.permissions")}),s.jsx("div",{className:"flex flex-wrap gap-1 mt-1",children:T.skill.requiredPermissions.map(he=>s.jsx("span",{className:"text-[10px] px-1.5 py-0.5 bg-surface-elevated text-fg-muted rounded border border-border-default",children:he},he))})]})]})]}),T.dependencies&&(T.dependencies.skills?.length||T.dependencies.env?.length)?s.jsxs("div",{className:"rounded-xl border border-border-default bg-surface-secondary/60 p-4 space-y-3",children:[s.jsx("div",{className:"text-xs font-medium text-fg-tertiary uppercase tracking-wider",children:m("sidebar.dependencies")}),T.dependencies.skills?.length?s.jsxs("div",{children:[s.jsx("div",{className:"text-[10px] text-fg-muted mb-1",children:m("sidebar.skills")}),s.jsx("div",{className:"flex flex-wrap gap-1",children:T.dependencies.skills.map(he=>s.jsx("span",{className:"text-[10px] px-2 py-0.5 bg-surface-elevated text-fg-secondary rounded border border-border-default",children:he},he))})]}):null,T.dependencies.env?.length?s.jsxs("div",{children:[s.jsx("div",{className:"text-[10px] text-fg-muted mb-1",children:m("sidebar.environment")}),s.jsx("div",{className:"flex flex-wrap gap-1",children:T.dependencies.env.map(he=>s.jsx("span",{className:"text-[10px] px-2 py-0.5 bg-surface-elevated text-fg-secondary rounded font-mono border border-border-default",children:he},he))})]}):null]}):null,!o&&j&&s.jsxs("button",{onClick:()=>Ce.system.openPath(j).catch(()=>{}),className:"w-full text-left rounded-xl border border-border-default bg-surface-secondary/60 px-4 py-3 text-[10px] text-fg-muted hover:text-fg-secondary hover:border-gray-600 transition-colors truncate",title:j,children:[s.jsx("span",{className:"text-fg-tertiary block mb-0.5",children:m("sidebar.openInFinder")}),j.replace(/.*\.markus\//,"~/.markus/")]})]})})]})]}),!o&&F&&s.jsx(dK,{onClose:()=>J(!1),onConfirm:(he,ye)=>{J(!1),et({donationsEnabled:!1,priceCents:he==="paid"?ye:void 0})},isUpdate:D.shared}),!o&&B&&s.jsx(uK,{onClose:()=>Q(!1),onConfirm:(he,ye,Ze,rt)=>{Q(!1),et({visibility:he,orgId:ye,priceCents:Ze,donationsEnabled:rt})}}),$&&s.jsx(dr,{alertOnly:!0,variant:$.variant??"primary",title:$.title,message:$.message,onConfirm:()=>G(null),onCancel:()=>G(null)})]}):s.jsx("div",{className:"flex-1 overflow-y-auto",children:s.jsxs("div",{className:"px-6 py-8",children:[s.jsxs("button",{onClick:n,className:"text-xs text-brand-400 hover:text-brand-300 mb-4 inline-flex items-center gap-1",children:[s.jsx("svg",{className:"w-3.5 h-3.5",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:s.jsx("polyline",{points:"15 18 9 12 15 6"})}),m("detail.backToBuilder")]}),s.jsx("div",{className:"text-fg-tertiary text-sm py-20 text-center",children:m("detail.notFound")})]})})}function uK({onClose:e,onConfirm:t}){const{t:n}=ft(["builder","common"]),[r,o]=k.useState("public"),[l,u]=k.useState([]),[d,m]=k.useState(""),[h,p]=k.useState(!1),[g,x]=k.useState(0),[y,w]=k.useState(!1);k.useEffect(()=>{r==="org"&&l.length===0&&(p(!0),lt.myOrgs().then(C=>{u(C.memberships),C.memberships.length>0&&m(C.memberships[0].id)}).catch(()=>{}).finally(()=>p(!1)))},[r,l.length]);const N=r==="public"||r==="unlisted",T=[{value:"public",icon:s.jsxs("svg",{className:"w-4 h-4",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[s.jsx("circle",{cx:"12",cy:"12",r:"10"}),s.jsx("line",{x1:"2",y1:"12",x2:"22",y2:"12"}),s.jsx("path",{d:"M12 2a15.3 15.3 0 0 1 4 10 15.3 15.3 0 0 1-4 10 15.3 15.3 0 0 1-4-10 15.3 15.3 0 0 1 4-10z"})]}),label:n("visibility.public"),desc:n("visibility.publicDesc")},{value:"org",icon:s.jsxs("svg",{className:"w-4 h-4",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[s.jsx("path",{d:"M3 21h18"}),s.jsx("path",{d:"M9 8h1"}),s.jsx("path",{d:"M9 12h1"}),s.jsx("path",{d:"M9 16h1"}),s.jsx("path",{d:"M14 8h1"}),s.jsx("path",{d:"M14 12h1"}),s.jsx("path",{d:"M14 16h1"}),s.jsx("path",{d:"M5 21V5a2 2 0 0 1 2-2h10a2 2 0 0 1 2 2v16"})]}),label:n("visibility.org"),desc:n("visibility.orgDesc")},{value:"unlisted",icon:s.jsxs("svg",{className:"w-4 h-4",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[s.jsx("path",{d:"M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71"}),s.jsx("path",{d:"M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71"})]}),label:n("visibility.unlisted"),desc:n("visibility.unlistedDesc")}];return s.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/60 backdrop-blur-sm",onClick:e,children:s.jsxs("div",{className:"bg-surface-secondary border border-border-default rounded-xl max-w-sm w-full mx-4 p-6 shadow-2xl",onClick:C=>C.stopPropagation(),children:[s.jsx("h3",{className:"text-base font-semibold text-fg-primary mb-1",children:n("visibility.label")}),s.jsx("p",{className:"text-[11px] text-fg-tertiary mb-4 leading-relaxed",children:n("visibility.subtitle")}),s.jsxs("div",{className:"text-[10px] uppercase tracking-wider text-fg-tertiary font-semibold mb-2",children:["1 · ",n("visibility.public")," / ",n("visibility.org")]}),s.jsx("div",{className:"space-y-2 mb-5",children:T.map(C=>s.jsxs("label",{className:`flex items-center gap-3 p-3 rounded-lg border cursor-pointer transition-colors ${r===C.value?"border-brand-500 bg-brand-500/10":"border-border-default hover:border-gray-600"}`,children:[s.jsx("input",{type:"radio",name:"visibility",checked:r===C.value,onChange:()=>o(C.value),className:"accent-brand-500"}),s.jsx("div",{className:"flex items-center gap-2 text-fg-secondary",children:C.icon}),s.jsxs("div",{children:[s.jsx("div",{className:"text-sm font-medium text-fg-primary",children:C.label}),s.jsx("div",{className:"text-[11px] text-fg-tertiary",children:C.desc})]})]},C.value))}),r==="org"&&s.jsxs("div",{className:"mb-5",children:[s.jsx("label",{className:"text-xs text-fg-secondary block mb-1.5",children:n("visibility.orgSelect")}),h?s.jsx("div",{className:"text-xs text-fg-tertiary py-2",children:"Loading..."}):l.length===0?s.jsx("div",{className:"text-xs text-fg-tertiary py-2",children:n("visibility.orgNone")}):s.jsx("select",{value:d,onChange:C=>m(C.target.value),className:"w-full text-sm px-3 py-2 rounded-lg bg-surface-elevated border border-border-default text-fg-primary",children:l.map(C=>s.jsx("option",{value:C.id,children:C.name},C.id))})]}),N&&s.jsxs("div",{className:"mb-5",children:[s.jsxs("div",{className:"text-[10px] uppercase tracking-wider text-fg-tertiary font-semibold mb-2",children:["2 · ",n("pricing.label")]}),s.jsx("label",{className:"text-xs text-fg-secondary block mb-1.5",children:n("pricing.label")}),s.jsx("div",{className:"grid grid-cols-4 gap-2 mb-3",children:w3.map(C=>s.jsx("button",{type:"button",onClick:()=>x(C.cents),className:`text-sm px-2 py-2 rounded-lg border transition-colors ${g===C.cents?"border-brand-500 bg-brand-500/10 text-fg-primary":"border-border-default text-fg-secondary hover:border-gray-600"}`,children:C.label},C.cents))}),s.jsxs("label",{className:"flex items-center gap-2 cursor-pointer",children:[s.jsx("input",{type:"checkbox",checked:y,onChange:C=>w(C.target.checked),className:"accent-brand-500"}),s.jsx("span",{className:"text-xs text-fg-secondary",children:n("pricing.enableTips")})]})]}),N&&s.jsx("div",{className:"mb-4 text-[11px] text-fg-tertiary rounded-lg border border-border-default px-3 py-2",children:n("pricing.reviewNote")}),s.jsxs("div",{className:"flex gap-3",children:[s.jsx("button",{onClick:e,className:"flex-1 text-sm px-4 py-2 rounded-lg border border-border-default text-fg-secondary hover:text-fg-primary hover:border-gray-600 transition-colors",children:n("common:cancel")}),s.jsx("button",{onClick:()=>t(r,r==="org"?d:void 0,N&&g>0?g:void 0,N?y:void 0),disabled:r==="org"&&!d,className:"flex-1 text-sm px-4 py-2 rounded-lg bg-brand-600 hover:bg-brand-500 text-white transition-colors disabled:opacity-50 disabled:cursor-not-allowed",children:n("shareMode.share")})]})]})})}const w3=[{cents:0,label:"Free"},{cents:100,label:"$1"},{cents:500,label:"$5"},{cents:1e3,label:"$10"}];function dK({onClose:e,onConfirm:t,isUpdate:n}){const{t:r}=ft(["builder","common"]),[o,l]=k.useState(0);return s.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/60 backdrop-blur-sm",onClick:e,children:s.jsxs("div",{className:"bg-surface-secondary border border-border-default rounded-xl max-w-sm w-full mx-4 p-6 shadow-2xl",onClick:u=>u.stopPropagation(),children:[s.jsx("h3",{className:"text-base font-semibold text-fg-primary mb-4",children:r(n?"shareMode.titleUpdate":"share.toHub")}),s.jsx("div",{className:"space-y-2 mb-5",children:w3.map(u=>s.jsxs("label",{className:`flex items-center gap-3 p-3 rounded-lg border cursor-pointer transition-colors ${o===u.cents?"border-brand-500 bg-brand-500/10":"border-border-default hover:border-gray-600"}`,children:[s.jsx("input",{type:"radio",name:"sharePrice",checked:o===u.cents,onChange:()=>l(u.cents),className:"accent-brand-500"}),s.jsxs("div",{children:[s.jsx("div",{className:"text-sm font-medium text-fg-primary",children:u.label}),s.jsx("div",{className:"text-[11px] text-fg-tertiary",children:u.cents===0?r("shareMode.freeDesc"):r("shareMode.paidDesc")})]})]},u.cents))}),s.jsxs("div",{className:"flex gap-3",children:[s.jsx("button",{onClick:e,className:"flex-1 text-sm px-4 py-2 rounded-lg border border-border-default text-fg-secondary hover:text-fg-primary hover:border-gray-600 transition-colors",children:r("common:cancel")}),s.jsx("button",{onClick:()=>t(o>0?"paid":"free",o),className:"flex-1 text-sm px-4 py-2 rounded-lg bg-brand-600 hover:bg-brand-500 text-white transition-colors",children:r(n?"shareMode.update":"shareMode.share")})]})]})})}function m0(e,t){return!e||!v3(e)?null:e.startsWith("http")||e.startsWith("data:")?e:e.startsWith("/")&&t?`${t}${e}`:e}function mK({type:e,seed:t,icon:n,hubBase:r,size:o=44,className:l="",rounded:u="rounded-xl"}){const d=Wo(e),m=m0(n,r),h=k.useMemo(()=>Mg(d,t),[d,t]),p=k.useMemo(()=>y3(t),[t]),[g,x]=k.useState(!1);return m&&!g?s.jsx("img",{src:m,alt:"",onError:()=>x(!0),style:{width:o,height:o},className:`${u} object-cover shrink-0 ${l}`}):eK(n)?s.jsx("div",{style:{width:o,height:o,background:h,fontSize:o*.5},className:`${u} shrink-0 flex items-center justify-center shadow-inner ${l}`,children:s.jsx("span",{className:"drop-shadow-sm",children:n})}):n&&bV(n)?s.jsx("div",{style:{width:o,height:o,background:h},className:`${u} shrink-0 flex items-center justify-center text-white shadow-inner ${l}`,children:s.jsx(Ko,{name:n,size:o*.52,className:"drop-shadow-sm"})}):s.jsx("div",{style:{width:o,height:o,background:h},className:`${u} shrink-0 flex items-center justify-center shadow-inner ${l}`,children:s.jsx("svg",{width:o*.55,height:o*.55,viewBox:"0 0 24 24",fill:"none","aria-hidden":!0,children:s.jsx("path",{d:p,fill:"rgba(255,255,255,0.92)"})})})}function f0({name:e,username:t,avatarUrl:n,hubBase:r,size:o=24,className:l="",verified:u}){const d=t||e||"markus",m=m0(n,r),[h,p]=k.useState(!1),g=m&&!h?m:tK(d);return s.jsxs("span",{className:`relative inline-flex shrink-0 ${l}`,style:{width:o,height:o},children:[s.jsx("img",{src:g,alt:e||t||"",onError:()=>p(!0),className:"w-full h-full rounded-full object-cover ring-1 ring-white/10 bg-surface-elevated"}),u&&s.jsx("span",{className:"absolute -right-0.5 -bottom-0.5 flex items-center justify-center rounded-full bg-brand-500 ring-2 ring-surface-primary",style:{width:o*.42,height:o*.42},children:s.jsx("svg",{viewBox:"0 0 24 24",width:"60%",height:"60%",fill:"white","aria-hidden":!0,children:s.jsx("path",{d:"M9 16.2l-3.5-3.5 1.4-1.4L9 13.4l7.1-7.1 1.4 1.4z"})})})]})}function fK({type:e,className:t=""}){const n=Wo(e),r=Ti[n];return s.jsx("span",{className:`inline-flex items-center gap-1 rounded-full px-2 py-0.5 text-[10px] font-semibold tracking-wide text-white bg-gradient-to-r ${r.gradient} ${t}`,children:r.label})}function g4({rating:e=0}){const t=Math.round(e);return s.jsx("span",{className:"inline-flex items-center","aria-label":`${e} out of 5`,children:[0,1,2,3,4].map(n=>s.jsx("svg",{viewBox:"0 0 24 24",width:"12",height:"12",className:n<t?"text-amber-400":"text-fg-muted/40",fill:"currentColor","aria-hidden":!0,children:s.jsx("path",{d:"M12 2l2.4 6.9L21 9l-5.4 4 2 7-5.6-4.1L6.4 20l2-7L3 9l6.6-.1z"})},n))})}function sa(e){const{type:t,name:n,description:r,seed:o,icon:l,cover:u,hubBase:d,author:m,authorLabel:h,version:p,category:g,tags:x,rating:y=0,ratingCount:w=0,downloadCount:N=0,priceCents:T,currency:C="usd",installed:j,glowing:_,selected:O,showTypeBadge:z=!0,hideStats:D=!1,cornerLabel:H,actions:W,footerLeft:Z,headerAction:U,onClick:Y,className:ae=""}=e,X=Wo(t),F=Ti[X],J=o||n,B=(T??0)>0,Q=!!m0(u||void 0,d),re=Mg(X,J),we=h??m?.displayName??m?.username??"",[$,G]=k.useState(null),ce=j?s.jsx("span",{className:"inline-flex items-center gap-1 rounded-full bg-emerald-500/12 text-emerald-400 border border-emerald-500/25 px-2 py-0.5 text-[10px] font-semibold",children:s.jsx("svg",{className:"w-2.5 h-2.5",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"3.5",children:s.jsx("polyline",{points:"20 6 9 17 4 12"})})}):H?s.jsx("span",{className:"chip",children:H}):B?s.jsx("span",{className:"badge-paid",children:f4(T,C)}):null;if(Q){const I=m0(u||void 0,d);return s.jsxs("div",{onClick:Y,style:{aspectRatio:$??void 0},className:`group asset-card card-shine relative flex flex-col overflow-hidden min-h-[180px] ${Y?"cursor-pointer":""} ${O?"ring-1 ring-brand-500/60":""} ${_?"ring-2 ring-brand-500 shadow-lg shadow-brand-500/20":""} ${ae}`,children:[s.jsx("img",{src:I,alt:"",onLoad:Ee=>{const Ue=Ee.currentTarget;Ue.naturalWidth&&Ue.naturalHeight&&G(Math.min(1.9,Math.max(1,Ue.naturalWidth/Ue.naturalHeight)))},className:"absolute inset-0 w-full h-full object-cover transition-transform duration-[600ms] group-hover:scale-[1.05]"}),s.jsx("div",{className:"absolute inset-0 bg-gradient-to-t from-black/90 via-black/50 to-black/5"}),s.jsx("div",{className:"absolute inset-x-0 top-0 h-20 bg-gradient-to-b from-black/50 to-transparent"}),s.jsxs("div",{className:"relative flex items-start justify-between gap-2 p-3",children:[s.jsx("span",{children:z&&s.jsx(fK,{type:X})}),s.jsxs("span",{className:"flex items-center gap-1.5",onClick:Ee=>Ee.stopPropagation(),children:[j?s.jsx("span",{className:"inline-flex items-center gap-1 rounded-full bg-emerald-500/25 text-emerald-50 border border-emerald-300/40 px-2 py-0.5 text-[10px] font-semibold backdrop-blur-md",children:s.jsx("svg",{className:"w-3 h-3",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"3",children:s.jsx("polyline",{points:"20 6 9 17 4 12"})})}):H?s.jsx("span",{className:"inline-flex items-center rounded-full bg-white/15 text-white border border-white/25 px-2 py-0.5 text-[10px] font-medium backdrop-blur-md",children:H}):U?null:s.jsx("span",{className:B?"badge-paid":"badge-free",children:f4(T,C)}),U]})]}),s.jsxs("div",{className:"relative mt-auto p-4 pt-10 flex flex-col gap-2 text-white",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("h3",{className:"text-[15px] font-semibold truncate drop-shadow-md",children:n}),p&&s.jsxs("span",{className:"shrink-0 rounded-full bg-white/15 border border-white/25 px-1.5 py-0.5 text-[10px] font-medium backdrop-blur-md",children:["v",p]})]}),we&&s.jsxs("div",{className:"flex items-center gap-1.5 text-[11px] text-white/85",children:[m&&s.jsx(f0,{name:m.displayName,username:m.username,avatarUrl:m.avatarUrl,hubBase:d,size:15}),s.jsx("span",{className:"truncate",children:we})]}),r&&s.jsx("p",{className:"text-[12.5px] text-white/80 truncate leading-snug drop-shadow-sm",children:r}),(g||x&&x.length>0)&&s.jsxs("div",{className:"flex flex-nowrap gap-1.5 overflow-hidden",children:[g&&s.jsx("span",{className:"shrink-0 rounded-full bg-white/15 border border-white/20 text-white/95 px-2 py-0.5 text-[10px] font-semibold capitalize backdrop-blur-md",children:g}),x?.slice(0,3).map(Ee=>s.jsx("span",{className:"shrink-0 rounded-full bg-white/10 border border-white/15 text-white/85 px-2 py-0.5 text-[10px] backdrop-blur-md",children:Ee},Ee))]}),(!D||W)&&s.jsxs("div",{className:"flex items-center justify-between gap-2 pt-1 shrink-0",children:[D?s.jsx("span",{}):s.jsxs("div",{className:"flex items-center gap-3 text-[11px] text-white/80",children:[s.jsxs("span",{className:"inline-flex items-center gap-1",children:[s.jsx(g4,{rating:y}),w>0&&s.jsxs("span",{className:"text-white/60",children:["(",Ao(w),")"]})]}),s.jsxs("span",{className:"inline-flex items-center gap-1",children:[s.jsx("svg",{viewBox:"0 0 24 24",width:"12",height:"12",fill:"none",stroke:"currentColor",strokeWidth:"2","aria-hidden":!0,children:s.jsx("path",{d:"M12 3v12m0 0l-4-4m4 4l4-4M5 21h14"})}),Ao(N)]})]}),W&&s.jsx("div",{className:"flex items-center gap-2",onClick:Ee=>Ee.stopPropagation(),children:W})]})]})]})}return s.jsxs("div",{onClick:Y,className:`group asset-card card-shine relative flex flex-col ${Y?"cursor-pointer":""} ${O?"ring-1 ring-brand-500/60":""} ${_?"ring-2 ring-brand-500 shadow-lg shadow-brand-500/20":""} ${ae}`,children:[s.jsx("div",{className:"pointer-events-none absolute inset-x-0 top-0 h-[2px] opacity-0 group-hover:opacity-100 transition-opacity duration-300",style:{background:`linear-gradient(90deg, transparent, ${F.accent}, transparent)`}}),s.jsx("div",{className:"pointer-events-none absolute -top-10 -left-10 w-36 h-36 rounded-full blur-2xl opacity-[0.12] group-hover:opacity-20 transition-opacity duration-300",style:{background:re}}),U&&s.jsx("div",{className:"absolute top-2.5 right-2.5 z-10",onClick:I=>I.stopPropagation(),children:U}),s.jsxs("div",{className:"relative p-4 flex flex-col flex-1 gap-2.5",children:[s.jsxs("div",{className:"flex items-start gap-3",children:[s.jsx(mK,{type:X,seed:J,icon:l,hubBase:d,size:46,rounded:"rounded-2xl",className:"ring-1 ring-white/10 shadow-sm shadow-black/20"}),s.jsxs("div",{className:`min-w-0 flex-1 ${U?"pr-7":""}`,children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("h3",{className:"text-sm font-semibold text-fg-primary truncate group-hover:text-brand-300 transition-colors",children:n}),p&&s.jsxs("span",{className:"chip shrink-0",children:["v",p]}),ce&&s.jsx("span",{className:"ml-auto shrink-0",children:ce})]}),(we||z)&&s.jsxs("div",{className:"mt-1 flex items-center gap-1.5 text-[11px] text-fg-tertiary min-w-0",children:[m&&s.jsx(f0,{name:m.displayName,username:m.username,avatarUrl:m.avatarUrl,hubBase:d,size:15}),we&&s.jsx("span",{className:"truncate",children:we}),z&&s.jsxs(s.Fragment,{children:[we&&s.jsx("span",{className:"text-fg-muted",children:"·"}),s.jsx("span",{className:"font-semibold shrink-0",style:{color:F.accent},children:F.label})]})]})]})]}),r&&s.jsx("p",{className:"text-[13px] text-fg-secondary truncate leading-snug",children:r}),(g||x&&x.length>0)&&s.jsxs("div",{className:"flex flex-wrap gap-1.5",children:[g&&s.jsx("span",{className:"chip-accent capitalize",children:g}),x?.slice(0,3).map(I=>s.jsx("span",{className:"chip",children:I},I)),(x?.length??0)>3&&s.jsxs("span",{className:"text-[10px] text-fg-muted self-center",children:["+",(x?.length??0)-3]})]}),(()=>{const I=Z??(D?null:s.jsxs("span",{className:"flex items-center gap-3 text-[11px] text-fg-tertiary",children:[s.jsxs("span",{className:"inline-flex items-center gap-1",children:[s.jsx(g4,{rating:y}),s.jsx("span",{className:"text-fg-muted",children:w>0?`(${Ao(w)})`:""})]}),s.jsxs("span",{className:"inline-flex items-center gap-1",children:[s.jsx("svg",{viewBox:"0 0 24 24",width:"12",height:"12",fill:"none",stroke:"currentColor",strokeWidth:"2","aria-hidden":!0,children:s.jsx("path",{d:"M12 3v12m0 0l-4-4m4 4l4-4M5 21h14"})}),Ao(N)]})]}));return!I&&!W?null:s.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-2 pt-2 mt-auto border-t border-border-subtle/60",onClick:Ee=>Ee.stopPropagation(),children:[I&&s.jsx("div",{className:"min-w-0 flex items-center gap-2",children:I}),W&&s.jsx("div",{className:"flex flex-wrap items-center gap-2 justify-end",children:W})]})})()]})]})}function Er({children:e,maxCardWidth:t=400,gap:n="1rem",className:r=""}){const o=k.useRef(null),[l,u]=k.useState(0);k.useEffect(()=>{const p=o.current;if(!p)return;u(p.clientWidth);const g=new ResizeObserver(x=>{for(const y of x)u(y.contentRect.width)});return g.observe(p),()=>g.disconnect()},[]);const d=Math.max(1,Math.ceil((l||t)/t)),m=k.Children.toArray(e),h=Array.from({length:d},()=>[]);return m.forEach((p,g)=>{h[g%d].push(p)}),s.jsx("div",{ref:o,className:`flex items-start ${r}`,style:{gap:n},children:h.map((p,g)=>s.jsx("div",{className:"flex flex-col flex-1 min-w-0",style:{gap:n,maxWidth:t},children:p},g))})}function hK(e){const t=e.indexOf(".markus/builder-artifacts/");return t>=0?"~/"+e.slice(t):e}const pK=[{id:"hireAgent",icon:"✦",color:"from-brand-500 to-purple-600",borderColor:"border-brand-500/30 hover:border-brand-400/50",bgColor:"bg-brand-500/10"},{id:"buildTeam",icon:"◈",color:"from-blue-500 to-blue-600",borderColor:"border-blue-500/30 hover:border-blue-400/50",bgColor:"bg-blue-500/10"},{id:"createSkill",icon:"⬡",color:"from-green-500 to-green-600",borderColor:"border-green-500/30 hover:border-green-400/50",bgColor:"bg-green-500/10"}];function gK(){const[e,t]=k.useState(()=>{const r=window.location.hash.slice(1).split("/");return lc(r[0])===me.BUILDER&&r[1]&&r[2]?{type:r[1],name:decodeURIComponent(r[2])}:null});return k.useEffect(()=>{const n=()=>{const o=window.location.hash.slice(1).split("/");lc(o[0])===me.BUILDER&&o[1]&&o[2]?t({type:o[1],name:decodeURIComponent(o[2])}):t(null)};return window.addEventListener("hashchange",n),()=>window.removeEventListener("hashchange",n)},[]),e}const k3="markus_builder_shared_map";function bK(){try{const e=localStorage.getItem(k3);if(!e)return new Map;const t=JSON.parse(e);return new Map(Object.entries(t))}catch{return new Map}}function kd(e){try{localStorage.setItem(k3,JSON.stringify(Object.fromEntries(e)))}catch{}}function S3({authUser:e}={}){const{t}=ft(["builder","common"]),n=Uo(),r=gK(),[o,l]=k.useState([]),[u,d]=k.useState([]),[m,h]=k.useState(!1),[p,g]=k.useState("all"),[x,y]=k.useState(null),[w,N]=k.useState(new Map),[T,C]=k.useState(null),[j,_]=k.useState(null),[O,z]=k.useState(null),[D,H]=k.useState(bK),[W,Z]=k.useState(null),[U,Y]=k.useState(null),[ae,X]=k.useState(null),[F,J]=k.useState(null),[B,Q]=k.useState(null),[re,we]=k.useState("creations"),[$,G]=k.useState([]),[ce,I]=k.useState(""),[Ee,Ue]=k.useState([]),[De,Ke]=k.useState(!1),[st,mt]=k.useState("all"),ct=k.useCallback(()=>{h(!0),Promise.all([(vi(Tr.builderArtifacts)??Ce.builder.artifacts.list()).then(se=>se?.artifacts??[]).catch(()=>[]),(vi(Tr.builderAgents)??Ce.agents.list()).then(se=>se?.agents??[]).catch(()=>[]),(vi(Tr.builderHubMyItems)??lt.myItems()).then(se=>se?.items??[]).catch(()=>[]),(vi(Tr.builderInstalled)??Ce.builder.artifacts.installed()).then(se=>se?.installed??{}).catch(()=>({}))]).then(([se,et,nt,Ge])=>{if(d(se),l(et),nt.length>0){const xt=new Map;for(const pe of nt){const V=pe.itemType==="agent"?"agent":pe.itemType==="team"?"team":"skill";for(const xe of se)xe.type===V&&(pe.slug===xe.name||pe.name===(xe.meta.displayName||xe.meta.name||xe.name))&&xt.set(`${xe.type}/${xe.name}`,{id:pe.id,name:pe.name,slug:pe.slug||xe.name,version:pe.version||"1.0.0",visibility:pe.visibility??"public",moderationStatus:pe.moderationStatus,pendingReview:pe.pendingReview})}xt.size>0&&H(pe=>{const V=new Map(pe);for(const[xe,We]of xt)V.set(xe,We);return kd(V),V})}const Qe=new Map;for(const xt of se){const pe=`${xt.type}/${xt.name}`,V=Ge[pe];V&&Qe.set(pe,{agentId:V.agentId,agentIds:V.agentIds,teamId:V.teamId})}N(Qe)}).finally(()=>h(!1))},[]);k.useEffect(()=>{ct();const se=et=>{et.detail?.page===me.BUILDER&&ct()};return window.addEventListener("markus:navigate",se),()=>window.removeEventListener("markus:navigate",se)},[ct]);const Dt=se=>{const et=o.find(nt=>nt.role==="Secretary"||nt.name==="Secretary");et?at.navigate(me.TEAM,{agentId:et.id,prefillMessage:se}):at.navigate(me.TEAM,{prefillMessage:se})},Mt=async se=>{const et=`${se.type}/${se.name}`;if(!w.has(et)){y({key:et,action:"install"});try{const nt=await Ce.builder.artifacts.install(se.type,se.name),Ge={};nt.agent&&typeof nt.agent=="object"&&(Ge.agentId=nt.agent.id),nt.team&&typeof nt.team=="object"&&(Ge.teamId=nt.team.id),Array.isArray(nt.agents)&&(Ge.agentIds=nt.agents.map(Qe=>Qe.id)),N(Qe=>new Map(Qe).set(et,Ge)),window.dispatchEvent(new CustomEvent("markus:data-changed"))}catch(nt){console.error("Install failed:",nt),Y({title:t("common:install"),message:t("installFailed",{error:String(nt)}),variant:"danger"})}finally{y(null)}}},Xt=async se=>{const et=`${se.type}/${se.name}`;if(w.has(et)){y({key:et,action:"uninstall"});try{await Ce.builder.artifacts.uninstall(se.type,se.name),N(nt=>{const Ge=new Map(nt);return Ge.delete(et),Ge}),window.dispatchEvent(new CustomEvent("markus:data-changed"))}catch(nt){console.error("Uninstall failed:",nt),Y({title:t("common:uninstall"),message:t("uninstallFailed",{error:String(nt)}),variant:"danger"})}finally{y(null)}}},Me=async(se,et)=>{const nt=`${se.type}/${se.name}`;y({key:nt,action:"share"});try{const Ge=await Ce.builder.artifacts.ensureSlugSafe(se.type,se.name,se.meta.displayName||se.meta.name||se.name),Qe=Ge.name,xt=Ge.slug||dc(Qe);if(!xt)throw new Error("Invalid package slug: use English kebab-case for the artifact name (e.g. qwen-multimodal). Chinese-only names cannot be shared — rename the package slug and put the Chinese title in displayName.");const pe=`${se.type}/${Qe}`;Ge.converted&&(d(oe=>oe.map(_e=>_e.type===se.type&&_e.name===se.name?{..._e,name:Qe,path:Ge.path,meta:{..._e.meta,name:Qe,displayName:Ge.displayName??_e.meta.displayName??se.name}}:_e)),H(oe=>{const _e=new Map(oe),de=_e.get(nt);return de&&(_e.delete(nt),_e.set(pe,{...de,slug:xt,name:Ge.displayName??de.name})),kd(_e),_e}),N(oe=>{const _e=new Map(oe),de=_e.get(nt);return de&&(_e.delete(nt),_e.set(pe,de)),_e}));const V=await Ce.builder.artifacts.get(se.type,Qe);let xe={...se.meta,name:Qe,displayName:Ge.displayName??se.meta.displayName??se.name};try{const oe=V.files?.[`${se.type}.json`]??V.files?.["agent.json"]??V.files?.["team.json"]??V.files?.["skill.json"];oe&&(xe={...JSON.parse(oe),...xe,name:Qe,displayName:xe.displayName})}catch{}const We=xe.displayName||xe.name||Qe,he=xe.description||"",ye=xe.category||"general",Ze=Array.isArray(xe.tags)?xe.tags:[];let rt=xe.icon||void 0;const St=xe.version||"1.0.0";if(rt&&!rt.startsWith("http")&&/\.(png|jpe?g|gif|webp|svg)$/i.test(rt)){const oe=rt.split("/").pop()??rt;try{const _e=await fetch(`/api/builder/artifacts/${se.type}s/${encodeURIComponent(Qe)}/images/${encodeURIComponent(oe)}`);if(_e.ok){const de=await _e.blob(),$e=new File([de],oe,{type:de.type}),qe=await lt.uploadImage($e);qe?.url&&(rt=qe.url)}}catch{}}let Bt;const wt=[],hn=Array.isArray(xe.screenshots)?xe.screenshots:[];for(let oe=0;oe<hn.length;oe++){const _e=hn[oe],de=_e.split("/").pop()??_e;try{const $e=await fetch(`/api/builder/artifacts/${se.type}s/${encodeURIComponent(Qe)}/images/${encodeURIComponent(de)}`);if($e.ok){const qe=await $e.blob(),q=new File([qe],de,{type:qe.type}),ie=await lt.uploadImage(q);ie?.url&&(wt.push({url:ie.url,alt:de,order:oe}),(oe===0||xe.thumbnail===_e)&&(Bt=ie.url))}}catch{}}const R=await lt.publishViaProxy({itemType:se.type==="team"?"team":se.type==="skill"?"skill":"agent",name:We,slug:xt,description:he,category:ye,tags:Ze,icon:rt,version:St,config:{...xe,name:Qe,displayName:We},files:V.files&&Object.keys(V.files).length>0?V.files:void 0,thumbnailUrl:Bt,images:wt.length>0?wt:void 0,priceCents:et?.priceCents,donationsEnabled:et?.donationsEnabled,visibility:et?.visibility,orgId:et?.orgId});R.id&&(H(_e=>{const de=new Map(_e);return de.set(pe,{id:R.id,name:We,slug:R.slug??xt,version:St,visibility:R.visibility??et?.visibility??"public",moderationStatus:R.moderationStatus,pendingReview:R.pendingReview}),kd(de),de}),(R.visibility??et?.visibility??"public")!=="org"&&(R.moderationStatus==="pending"||R.pendingReview)?Y({title:t("common:share"),message:Ge.converted?t("share.convertedAndSubmitted",{previous:se.name,slug:xt}):R.updated?t("share.updateSubmitted"):t("share.submittedForReview"),variant:"primary"}):Ge.converted&&Y({title:t("common:share"),message:t("share.convertedSlug",{previous:se.name,slug:xt}),variant:"primary"}))}catch(Ge){console.error("Share failed:",Ge),Y({title:t("common:share"),message:t("shareFailed",{error:Ge instanceof Error?Ge.message:String(Ge)}),variant:"danger"})}finally{y(null)}},Ne=async()=>{if(!W)return;const{key:se}=W,et=D.get(se);if(Z(null),!et)return;const nt=et.id;y({key:se,action:"hubDelete"});try{await lt.deleteItem(nt),H(Ge=>{const Qe=new Map(Ge);return Qe.delete(se),kd(Qe),Qe})}catch(Ge){console.error("Hub delete failed:",Ge),Y({title:t("unshare"),message:t("hubDeleteFailed",{error:String(Ge)}),variant:"danger"})}finally{y(null)}},Re=async()=>{if(!T)return;const se=T,et=`${se.type}/${se.name}`;C(null),y({key:et,action:"delete"});try{await Ce.builder.artifacts.delete(se.type,se.name),d(nt=>nt.filter(Ge=>!(Ge.type===se.type&&Ge.name===se.name))),N(nt=>{const Ge=new Map(nt);return Ge.delete(et),Ge}),window.dispatchEvent(new CustomEvent("markus:data-changed"))}catch(nt){console.error("Delete failed:",nt)}finally{y(null)}},ut=p==="all"?u:u.filter(se=>se.type===p);k.useEffect(()=>{re!=="orgAssets"||$.length>0||lt.myOrgs().then(se=>{G(se.memberships),se.memberships.length>0&&!ce&&I(se.memberships[0].id)}).catch(()=>{})},[re,$.length,ce]),k.useEffect(()=>{re!=="orgAssets"||!ce||(Ke(!0),lt.browseItems({orgId:ce,limit:100}).then(se=>Ue(se.items??[])).catch(()=>Ue([])).finally(()=>Ke(!1)))},[re,ce]);const it=st==="all"?Ee:Ee.filter(se=>se.itemType===st),bt=se=>{history.pushState(null,"",Si(me.BUILDER,`${se.type}/${encodeURIComponent(se.name)}`)),window.dispatchEvent(new HashChangeEvent("hashchange"))};return r?s.jsx(Ai,{type:r.type,name:r.name,authUser:e,onBack:()=>{history.pushState(null,"",Si(me.BUILDER)),window.dispatchEvent(new HashChangeEvent("hashchange"))}}):s.jsx("div",{className:"flex-1 overflow-y-auto",children:s.jsxs("div",{className:`max-w-5xl mx-auto w-full ${n?"px-4 py-5":"px-6 py-6"}`,children:[s.jsxs("div",{className:"mb-6",children:[s.jsxs("div",{className:"flex items-center justify-between mb-4",children:[s.jsxs("div",{children:[s.jsx("h1",{className:"text-xl font-bold text-fg-primary",children:t("title")}),s.jsx("p",{className:"text-xs text-fg-tertiary mt-1",children:t("subtitle")})]}),s.jsx("button",{onClick:ct,className:"text-xs text-fg-tertiary hover:text-fg-secondary transition-colors px-3 py-1.5 rounded-lg border border-border-default hover:border-gray-600",children:t("common:refresh")})]}),s.jsx("div",{className:`grid ${n?"grid-cols-1 gap-2":"grid-cols-3 gap-3"}`,children:pK.map(se=>{const et=t(`prompts.${se.id}Prompt`),nt=t(`prompts.${se.id}Examples`,{returnObjects:!0}),Ge=Array.isArray(nt)?nt:[];return s.jsx("button",{onClick:()=>Dt(et),className:`group text-left w-full rounded-xl border ${se.borderColor} bg-surface-secondary/60 p-4 transition-all hover:bg-surface-secondary/80 hover:shadow-lg`,children:s.jsxs("div",{className:"flex items-start gap-3",children:[s.jsx("div",{className:`w-10 h-10 text-xl rounded-lg ${se.bgColor} flex items-center justify-center shrink-0`,children:se.icon}),s.jsxs("div",{className:"flex-1 min-w-0",children:[s.jsx("h3",{className:`text-sm font-semibold bg-gradient-to-r ${se.color} bg-clip-text text-transparent`,children:t(`prompts.${se.id}`)}),s.jsx("p",{className:"text-[11px] text-fg-tertiary mt-1 leading-relaxed",children:t(`prompts.${se.id}Desc`)}),Ge.length>0&&s.jsx("div",{className:"mt-2 flex flex-wrap gap-1.5",children:Ge.slice(0,2).map((Qe,xt)=>s.jsxs("span",{className:"text-[10px] text-fg-muted bg-surface-elevated/60 rounded-full px-2 py-0.5 border border-border-default",onClick:pe=>{pe.stopPropagation(),Dt(et+Qe)},children:["“",Qe,"”"]},xt))})]})]})},se.id)})})]}),s.jsx("div",{className:"mb-3",children:s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsxs("div",{className:"flex items-center gap-3",children:[s.jsx("button",{onClick:()=>we("creations"),className:`text-sm font-semibold transition-colors ${re==="creations"?"text-fg-primary":"text-fg-tertiary hover:text-fg-secondary"}`,children:t("myCreations.title")}),s.jsx("button",{onClick:()=>we("orgAssets"),className:`text-sm font-semibold transition-colors ${re==="orgAssets"?"text-fg-primary":"text-fg-tertiary hover:text-fg-secondary"}`,children:t("orgAssets.title")})]}),re==="creations"&&s.jsx("div",{className:"flex gap-1.5",children:["all","agent","team","skill"].map(se=>s.jsx("button",{onClick:()=>g(se),className:`text-xs px-2.5 py-1 rounded-lg transition-colors ${p===se?"bg-brand-600 text-white":"text-fg-tertiary hover:text-fg-secondary hover:bg-surface-elevated"}`,children:t(se==="all"?"myCreations.filterAll":se==="agent"?"myCreations.filterAgents":se==="team"?"myCreations.filterTeams":"myCreations.filterSkills")},se))}),re==="orgAssets"&&s.jsx("div",{className:"flex gap-1.5",children:["all","agent","team","skill"].map(se=>s.jsx("button",{onClick:()=>mt(se),className:`text-xs px-2.5 py-1 rounded-lg transition-colors ${st===se?"bg-brand-600 text-white":"text-fg-tertiary hover:text-fg-secondary hover:bg-surface-elevated"}`,children:t(se==="all"?"myCreations.filterAll":se==="agent"?"myCreations.filterAgents":se==="team"?"myCreations.filterTeams":"myCreations.filterSkills")},se))})]})}),re==="orgAssets"&&$.length>0&&s.jsx("div",{className:"flex gap-2 mb-3 overflow-x-auto pb-1",children:$.map(se=>s.jsx("button",{onClick:()=>I(se.id),className:`text-xs px-3 py-1.5 rounded-full whitespace-nowrap border transition-colors ${ce===se.id?"bg-blue-500/15 border-blue-500/40 text-blue-400":"border-border-default text-fg-tertiary hover:text-fg-secondary hover:border-gray-600"}`,children:se.name},se.id))}),re==="orgAssets"&&($.length===0&&!De?s.jsx("div",{className:"text-center py-12",children:s.jsx("div",{className:"text-fg-tertiary text-sm",children:t("orgAssets.noOrgs")})}):De?s.jsx("div",{className:"text-center text-fg-tertiary py-12 text-sm",children:t("orgAssets.loading")}):it.length===0?s.jsx("div",{className:"text-center py-12",children:s.jsx("div",{className:"text-fg-tertiary text-sm",children:t("orgAssets.noItems")})}):s.jsx(Er,{children:it.map(se=>{const et=se.author?.username&&se.slug?`${lt.getUrl()}/@${encodeURIComponent(se.author.username)}/${encodeURIComponent(se.slug)}`:null;return s.jsx(sa,{type:se.itemType,name:se.name,description:se.description,seed:se.slug||se.id||se.name,icon:se.icon,cover:se.thumbnailUrl,hubBase:lt.getUrl(),author:se.author,version:se.version,rating:parseFloat(se.avgRating)||0,ratingCount:se.ratingCount,downloadCount:se.downloadCount,actions:et?s.jsxs("a",{href:et,target:"_blank",rel:"noopener noreferrer",onClick:nt=>{nt.stopPropagation(),Gd()&&(nt.preventDefault(),Oo(et))},className:"text-xs px-3 py-1.5 rounded-lg border border-border-default text-fg-secondary hover:text-fg-primary hover:border-gray-600 transition-colors inline-flex items-center gap-1",children:[s.jsxs("svg",{className:"w-3 h-3",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[s.jsx("path",{d:"M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6"}),s.jsx("polyline",{points:"15 3 21 3 21 9"}),s.jsx("line",{x1:"10",y1:"14",x2:"21",y2:"3"})]}),"Hub"]}):void 0},se.id)})})),re==="creations"&&(m&&u.length===0?s.jsx("div",{className:"text-center text-fg-tertiary py-12 text-sm",children:t("myCreations.loadingArtifacts")}):ut.length===0?s.jsxs("div",{className:"text-center py-12",children:[s.jsx("div",{className:"text-fg-tertiary text-sm",children:t("myCreations.noArtifacts")}),s.jsx("div",{className:"text-fg-muted text-xs mt-1",children:t("myCreations.noArtifactsHint")})]}):s.jsx(Er,{children:ut.map(se=>{const et=se.meta.displayName||se.meta.name||se.name,nt=se.meta.description||"",Ge=`${se.type}/${se.name}`,Qe=x?.key===Ge?x.action:null,xt=D.get(Ge),pe=se.meta.version||"1.0.0",V=!!xt,xe=V&&xt.version!==pe,We=()=>{const wt=lt.getUser();return!xt||!wt?null:`${lt.getUrl()}/@${encodeURIComponent(wt.username)}/${encodeURIComponent(xt.slug)}`},he=V&&(xt?.moderationStatus==="pending"||xt?.moderationStatus==="rejected"||!!xt?.pendingReview),ye=s.jsxs("div",{className:"flex items-center gap-1.5 justify-end",onClick:wt=>wt.stopPropagation(),children:[w.has(Ge)?s.jsxs("button",{onClick:()=>z(se),disabled:!!Qe,className:"text-xs px-3 py-1.5 rounded-lg border border-green-600/30 text-green-600 hover:bg-red-500/10 hover:text-red-500 hover:border-red-500/30 transition-colors disabled:opacity-50 inline-flex items-center gap-1",children:[s.jsxs("svg",{className:"w-3 h-3",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":!0,children:[s.jsx("path",{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4"}),s.jsx("polyline",{points:"17 8 12 3 7 8"}),s.jsx("line",{x1:"12",y1:"3",x2:"12",y2:"15"})]}),t(Qe==="uninstall"?"common:uninstalling":"common:uninstall")]}):s.jsxs("button",{onClick:()=>_(se),disabled:!!Qe,className:"text-xs px-3 py-1.5 rounded-lg bg-brand-600 hover:bg-brand-500 text-white transition-colors disabled:opacity-50 inline-flex items-center gap-1",children:[s.jsxs("svg",{className:"w-3 h-3",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":!0,children:[s.jsx("path",{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4"}),s.jsx("polyline",{points:"7 10 12 15 17 10"}),s.jsx("line",{x1:"12",y1:"15",x2:"12",y2:"3"})]}),t(Qe==="install"?"common:installing":"common:install")]}),V&&he?xt?.moderationStatus==="pending"?s.jsxs("span",{className:"text-xs px-2 py-1.5 rounded-lg border border-amber-500/30 text-amber-400 inline-flex items-center gap-1",title:t("share.underReviewTip"),children:[s.jsxs("svg",{className:"w-3 h-3",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":!0,children:[s.jsx("circle",{cx:"12",cy:"12",r:"10"}),s.jsx("polyline",{points:"12 6 12 12 16 14"})]}),t("share.underReview")]}):xt?.moderationStatus==="rejected"?s.jsxs("span",{className:"text-xs px-2 py-1.5 rounded-lg border border-red-500/30 text-red-400 inline-flex items-center gap-1",title:t("share.rejectedTip"),children:[s.jsxs("svg",{className:"w-3 h-3",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":!0,children:[s.jsx("circle",{cx:"12",cy:"12",r:"10"}),s.jsx("line",{x1:"15",y1:"9",x2:"9",y2:"15"}),s.jsx("line",{x1:"9",y1:"9",x2:"15",y2:"15"})]}),t("share.rejected")]}):s.jsxs("span",{className:"text-xs px-2 py-1.5 rounded-lg border border-amber-500/30 text-amber-400 inline-flex items-center gap-1",title:t("share.updateUnderReviewTip"),children:[s.jsxs("svg",{className:"w-3 h-3",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":!0,children:[s.jsx("circle",{cx:"12",cy:"12",r:"10"}),s.jsx("polyline",{points:"12 6 12 12 16 14"})]}),t("share.updateUnderReview")]}):V?s.jsxs(s.Fragment,{children:[xe&&s.jsxs("button",{onClick:()=>{const wt=xt?.visibility??"public";Me(se,{visibility:wt})},disabled:!!Qe,className:"text-xs px-3 py-1.5 rounded-lg border border-amber-500/30 text-amber-400 hover:bg-amber-500/10 hover:border-amber-500/50 transition-colors disabled:opacity-50 inline-flex items-center gap-1",children:[s.jsxs("svg",{className:"w-3 h-3",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":!0,children:[s.jsx("polyline",{points:"23 4 23 10 17 10"}),s.jsx("polyline",{points:"1 20 1 14 7 14"}),s.jsx("path",{d:"M3.51 9a9 9 0 0 1 14.85-3.36L23 10M1 14l4.64 4.36A9 9 0 0 0 20.49 15"})]}),Qe==="share"?t("common:sharing"):t("share.updateVersion",{version:pe})]}),s.jsxs("a",{href:We()??"#",target:"_blank",rel:"noopener noreferrer",onClick:wt=>{const hn=We();Gd()&&hn&&(wt.preventDefault(),Oo(hn))},className:`text-xs px-3 py-1.5 rounded-lg border transition-colors inline-flex items-center gap-1 ${xt?.visibility==="org"?"border-blue-500/30 text-blue-500 hover:text-blue-400 hover:border-blue-400/40":xt?.visibility==="unlisted"?"border-gray-500/30 text-fg-tertiary hover:text-fg-secondary hover:border-gray-400/40":"border-green-600/30 text-green-600 hover:text-green-500 hover:border-green-500/40"}`,children:[xt?.visibility==="org"?s.jsxs("svg",{className:"w-3 h-3",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":!0,children:[s.jsx("path",{d:"M3 21h18"}),s.jsx("path",{d:"M9 8h1"}),s.jsx("path",{d:"M9 12h1"}),s.jsx("path",{d:"M9 16h1"}),s.jsx("path",{d:"M14 8h1"}),s.jsx("path",{d:"M14 12h1"}),s.jsx("path",{d:"M14 16h1"}),s.jsx("path",{d:"M5 21V5a2 2 0 0 1 2-2h10a2 2 0 0 1 2 2v16"})]}):xt?.visibility==="unlisted"?s.jsxs("svg",{className:"w-3 h-3",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":!0,children:[s.jsx("path",{d:"M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71"}),s.jsx("path",{d:"M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71"})]}):s.jsxs("svg",{className:"w-3 h-3",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":!0,children:[s.jsx("path",{d:"M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6"}),s.jsx("polyline",{points:"15 3 21 3 21 9"}),s.jsx("line",{x1:"10",y1:"14",x2:"21",y2:"3"})]}),xt?.visibility==="org"?t("visibility.sharedOrg"):xt?.visibility==="unlisted"?t("visibility.sharedUnlisted"):t("visibility.shared")]}),s.jsxs("button",{onClick:()=>Z({key:Ge,name:et}),disabled:!!Qe,className:"text-xs px-2.5 py-1.5 rounded-lg border border-border-default text-fg-secondary hover:text-amber-500 hover:border-amber-500/40 hover:bg-amber-500/10 transition-colors disabled:opacity-50 inline-flex items-center gap-1",title:t("removeFromHubTooltip"),children:[s.jsxs("svg",{className:"w-3 h-3",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":!0,children:[s.jsx("path",{d:"M18.84 12.25l1.72-1.71a5 5 0 0 0-7.07-7.07l-1.72 1.71"}),s.jsx("path",{d:"M5.17 11.75l-1.71 1.71a5 5 0 0 0 7.07 7.07l1.71-1.71"}),s.jsx("line",{x1:"2",y1:"2",x2:"22",y2:"22"})]}),t("unshare")]})]}):s.jsxs("button",{onClick:async()=>{await lt.ensureAuth(),Array.isArray(se.meta.screenshots)&&se.meta.screenshots.length>0?Q(se):X(se)},disabled:!!Qe,className:"text-xs px-3 py-1.5 rounded-lg border border-border-default text-fg-secondary hover:text-green-600 hover:border-green-500/30 transition-colors disabled:opacity-50 inline-flex items-center gap-1",children:[s.jsxs("svg",{className:"w-3 h-3",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":!0,children:[s.jsx("circle",{cx:"18",cy:"5",r:"3"}),s.jsx("circle",{cx:"6",cy:"12",r:"3"}),s.jsx("circle",{cx:"18",cy:"19",r:"3"}),s.jsx("line",{x1:"8.59",y1:"13.51",x2:"15.42",y2:"17.49"}),s.jsx("line",{x1:"15.41",y1:"6.51",x2:"8.59",y2:"10.49"})]}),t(Qe==="share"?"common:sharing":"common:share")]})]}),Ze=s.jsx("button",{onClick:()=>C(se),disabled:!!Qe,className:"w-7 h-7 rounded-lg text-fg-muted hover:text-red-500 hover:bg-red-500/10 transition-colors disabled:opacity-50 inline-flex items-center justify-center",title:t("deleteLocalTooltip"),children:s.jsxs("svg",{className:"w-3.5 h-3.5",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":!0,children:[s.jsx("polyline",{points:"3 6 5 6 21 6"}),s.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"})]})}),rt=se.meta.icon,Bt=!!rt&&/\.(png|jpe?g|gif|webp|svg)$/i.test(rt)?rt.startsWith("http")||rt.startsWith("/")?rt:`/api/builder/artifacts/${se.type}s/${encodeURIComponent(se.name)}/images/${encodeURIComponent(rt.split("/").pop()??"")}`:rt;return s.jsx(sa,{type:se.type,name:et,description:nt,seed:Ge,icon:Bt,version:pe,footerLeft:s.jsxs("span",{className:"flex items-center gap-2 text-[10px] text-fg-tertiary min-w-0",children:[s.jsx("button",{onClick:wt=>{wt.stopPropagation(),Ce.system.openPath(se.path).catch(()=>{})},className:"hover:text-fg-secondary transition-colors truncate min-w-0",title:se.path,children:hK(se.path)}),s.jsx("span",{className:"shrink-0",children:"·"}),s.jsx("span",{className:"shrink-0",children:new Date(se.updatedAt).toLocaleDateString()})]}),headerAction:Ze,actions:ye,onClick:()=>bt(se)},Ge)})})),j&&s.jsx(dr,{variant:"primary",title:t("confirmInstall"),message:t("confirmInstallMsg",{name:j.meta.displayName||j.meta.name||j.name}),confirmLabel:t("common:install"),onConfirm:()=>{const se=j;_(null),Mt(se)},onCancel:()=>_(null)}),O&&s.jsx(dr,{variant:"primary",title:t("confirmUninstall"),message:t("confirmUninstallMsg",{name:O.meta.displayName||O.meta.name||O.name}),confirmLabel:t("common:uninstall"),onConfirm:()=>{const se=O;z(null),Xt(se)},onCancel:()=>z(null)}),T&&s.jsx(dr,{title:t("confirmDeleteLocal"),message:t("deleteCannotUndo",{name:T.meta.displayName||T.meta.name||T.name}),confirmLabel:t("common:delete"),onConfirm:Re,onCancel:()=>C(null)}),W&&s.jsx(dr,{title:t("confirmUnshare"),message:t("removeFromHub",{name:W.name}),confirmLabel:t("unshare"),onConfirm:()=>{Ne()},onCancel:()=>Z(null)}),U&&s.jsx(dr,{alertOnly:!0,variant:U.variant??"primary",title:U.title,message:U.message,onConfirm:()=>Y(null),onCancel:()=>Y(null)}),ae&&s.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/60 backdrop-blur-sm",onClick:()=>X(null),children:s.jsxs("div",{className:"bg-surface-secondary border border-border-default rounded-xl max-w-sm w-full mx-4 p-6 shadow-2xl",onClick:se=>se.stopPropagation(),children:[s.jsx("h3",{className:"text-base font-semibold text-fg-primary mb-2",children:t("common:share")}),s.jsx("p",{className:"text-sm text-fg-secondary mb-5",children:t("share.imagePrompt")}),s.jsxs("div",{className:"flex gap-3",children:[s.jsx("button",{onClick:()=>{const se=ae;X(null),Q(se)},className:"flex-1 text-sm px-4 py-2 rounded-lg border border-border-default text-fg-secondary hover:text-fg-primary hover:border-fg-tertiary transition-colors",children:t("share.directly")}),s.jsx("button",{onClick:()=>{const se=ae;X(null),bt(se)},className:"flex-1 text-sm px-4 py-2 rounded-lg bg-brand-600 hover:bg-brand-500 text-white transition-colors",children:t("share.addImagesFirst")})]})]})}),F&&s.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/60 backdrop-blur-sm",onClick:()=>J(null),children:s.jsx("div",{className:"bg-surface-secondary border border-border-default rounded-xl max-w-sm w-full mx-4 p-6 shadow-2xl",onClick:se=>se.stopPropagation(),children:s.jsx(yK,{isUpdate:D.has(`${F.type}/${F.name}`),onCancel:()=>J(null),onConfirm:(se,et)=>{const nt=F;J(null),Me(nt,{priceCents:et>0?et:void 0})}})})}),B&&s.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/60 backdrop-blur-sm",onClick:()=>Q(null),children:s.jsx("div",{className:"bg-surface-secondary border border-border-default rounded-xl max-w-sm w-full mx-4 p-6 shadow-2xl",onClick:se=>se.stopPropagation(),children:s.jsx(xK,{onCancel:()=>Q(null),onConfirm:(se,et,nt,Ge)=>{const Qe=B;Q(null),Me(Qe,{visibility:se,orgId:et,priceCents:nt,donationsEnabled:Ge})}})})})]})})}function xK({onCancel:e,onConfirm:t}){const{t:n}=ft(["builder","common"]),[r,o]=k.useState("public"),[l,u]=k.useState([]),[d,m]=k.useState(""),[h,p]=k.useState(!1),[g,x]=k.useState(0),[y,w]=k.useState(!1);k.useEffect(()=>{r==="org"&&l.length===0&&(p(!0),lt.myOrgs().then(C=>{u(C.memberships),C.memberships.length>0&&m(C.memberships[0].id)}).catch(()=>{}).finally(()=>p(!1)))},[r,l.length]);const N=r==="public"||r==="unlisted",T=[{value:"public",icon:s.jsxs("svg",{className:"w-4 h-4",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[s.jsx("circle",{cx:"12",cy:"12",r:"10"}),s.jsx("line",{x1:"2",y1:"12",x2:"22",y2:"12"}),s.jsx("path",{d:"M12 2a15.3 15.3 0 0 1 4 10 15.3 15.3 0 0 1-4 10 15.3 15.3 0 0 1-4-10 15.3 15.3 0 0 1 4-10z"})]}),label:n("visibility.public"),desc:n("visibility.publicDesc")},{value:"org",icon:s.jsxs("svg",{className:"w-4 h-4",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[s.jsx("path",{d:"M3 21h18"}),s.jsx("path",{d:"M9 8h1"}),s.jsx("path",{d:"M9 12h1"}),s.jsx("path",{d:"M9 16h1"}),s.jsx("path",{d:"M14 8h1"}),s.jsx("path",{d:"M14 12h1"}),s.jsx("path",{d:"M14 16h1"}),s.jsx("path",{d:"M5 21V5a2 2 0 0 1 2-2h10a2 2 0 0 1 2 2v16"})]}),label:n("visibility.org"),desc:n("visibility.orgDesc")},{value:"unlisted",icon:s.jsxs("svg",{className:"w-4 h-4",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[s.jsx("path",{d:"M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71"}),s.jsx("path",{d:"M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71"})]}),label:n("visibility.unlisted"),desc:n("visibility.unlistedDesc")}];return s.jsxs(s.Fragment,{children:[s.jsx("h3",{className:"text-base font-semibold text-fg-primary mb-4",children:n("visibility.label")}),s.jsx("div",{className:"space-y-2 mb-5",children:T.map(C=>s.jsxs("label",{className:`flex items-center gap-3 p-3 rounded-lg border cursor-pointer transition-colors ${r===C.value?"border-brand-500 bg-brand-500/10":"border-border-default hover:border-gray-600"}`,children:[s.jsx("input",{type:"radio",name:"visibility",checked:r===C.value,onChange:()=>o(C.value),className:"accent-brand-500"}),s.jsx("div",{className:"flex items-center gap-2 text-fg-secondary",children:C.icon}),s.jsxs("div",{children:[s.jsx("div",{className:"text-sm font-medium text-fg-primary",children:C.label}),s.jsx("div",{className:"text-[11px] text-fg-tertiary",children:C.desc})]})]},C.value))}),r==="org"&&s.jsxs("div",{className:"mb-5",children:[s.jsx("label",{className:"text-xs text-fg-secondary block mb-1.5",children:n("visibility.orgSelect")}),h?s.jsx("div",{className:"text-xs text-fg-tertiary py-2",children:"Loading..."}):l.length===0?s.jsx("div",{className:"text-xs text-fg-tertiary py-2",children:n("visibility.orgNone")}):s.jsx("select",{value:d,onChange:C=>m(C.target.value),className:"w-full text-sm px-3 py-2 rounded-lg bg-surface-elevated border border-border-default text-fg-primary",children:l.map(C=>s.jsx("option",{value:C.id,children:C.name},C.id))})]}),N&&s.jsxs("div",{className:"mb-5",children:[s.jsx("label",{className:"text-xs text-fg-secondary block mb-1.5",children:n("pricing.label")}),s.jsx("div",{className:"grid grid-cols-4 gap-2 mb-3",children:N3.map(C=>s.jsx("button",{type:"button",onClick:()=>x(C.cents),className:`text-sm px-2 py-2 rounded-lg border transition-colors ${g===C.cents?"border-brand-500 bg-brand-500/10 text-fg-primary":"border-border-default text-fg-secondary hover:border-gray-600"}`,children:C.label},C.cents))}),s.jsxs("label",{className:"flex items-center gap-2 cursor-pointer",children:[s.jsx("input",{type:"checkbox",checked:y,onChange:C=>w(C.target.checked),className:"accent-brand-500"}),s.jsx("span",{className:"text-xs text-fg-secondary",children:n("pricing.enableTips")})]})]}),N&&s.jsx("div",{className:"mb-4 text-[11px] text-fg-tertiary rounded-lg border border-border-default px-3 py-2",children:n("pricing.reviewNote")}),s.jsxs("div",{className:"flex gap-3",children:[s.jsx("button",{onClick:e,className:"flex-1 text-sm px-4 py-2 rounded-lg border border-border-default text-fg-secondary hover:text-fg-primary hover:border-gray-600 transition-colors",children:n("common:cancel")}),s.jsx("button",{onClick:()=>t(r,r==="org"?d:void 0,N&&g>0?g:void 0,N?y:void 0),disabled:r==="org"&&!d,className:"flex-1 text-sm px-4 py-2 rounded-lg bg-brand-600 hover:bg-brand-500 text-white transition-colors disabled:opacity-50 disabled:cursor-not-allowed",children:n("shareMode.share")})]})]})}const N3=[{cents:0,label:"Free"},{cents:100,label:"$1"},{cents:500,label:"$5"},{cents:1e3,label:"$10"}];function yK({isUpdate:e,onCancel:t,onConfirm:n}){const{t:r}=ft(["builder","common"]),[o,l]=k.useState(0);return s.jsxs(s.Fragment,{children:[s.jsx("h3",{className:"text-base font-semibold text-fg-primary mb-4",children:r(e?"shareMode.titleUpdate":"shareMode.title")}),s.jsx("div",{className:"space-y-2 mb-5",children:N3.map(u=>s.jsxs("label",{className:`flex items-center gap-3 p-3 rounded-lg border cursor-pointer transition-colors ${o===u.cents?"border-brand-500 bg-brand-500/10":"border-border-default hover:border-gray-600"}`,children:[s.jsx("input",{type:"radio",name:"sharePrice",checked:o===u.cents,onChange:()=>l(u.cents),className:"accent-brand-500"}),s.jsxs("div",{children:[s.jsx("div",{className:"text-sm font-medium text-fg-primary",children:u.label}),s.jsx("div",{className:"text-[11px] text-fg-tertiary",children:u.cents===0?r("shareMode.freeDesc"):r("shareMode.paidDesc")})]})]},u.cents))}),s.jsxs("div",{className:"flex gap-3",children:[s.jsx("button",{onClick:t,className:"flex-1 text-sm px-4 py-2 rounded-lg border border-border-default text-fg-secondary hover:text-fg-primary hover:border-gray-600 transition-colors",children:r("common:cancel")}),s.jsx("button",{onClick:()=>n(o>0?"paid":"free",o),className:"flex-1 text-sm px-4 py-2 rounded-lg bg-brand-600 hover:bg-brand-500 text-white transition-colors",children:r(e?"shareMode.update":"shareMode.share")})]})]})}const vK=Object.freeze(Object.defineProperty({__proto__:null,AgentBuilder:S3},Symbol.toStringTag,{value:"Module"}));function wK(e,t){const n=e.split(".").map(Number),r=t.split(".").map(Number);for(let o=0;o<Math.max(n.length,r.length);o++){const l=n[o]??0,u=r[o]??0;if(l>u)return!0;if(l<u)return!1}return!1}function h0(e,t){const n=e.i18n?.[t];return n?.displayName||n?.name||e.name}function b4(e,t){return e.i18n?.[t]?.description||e.description}const kK={manager:"bg-brand-500/15 text-brand-500",worker:"bg-blue-500/15 text-blue-600"};function SK({authUser:e,highlightItemId:t,onHighlightDone:n}={}){const{t:r,i18n:o}=ft(["store","common"]),l=o.language,[u,d]=k.useState(""),[m,h]=k.useState([]),[p,g]=k.useState([]),[x,y]=k.useState(null),[w,N]=k.useState({}),[T,C]=k.useState(!1),[j,_]=k.useState(!0),[O,z]=k.useState(new Map),[D,H]=k.useState(new Set),[W,Z]=k.useState(null),[U,Y]=k.useState(null),ae=k.useCallback(async()=>{try{const[J,B]=await Promise.all([Ce.builder.artifacts.list().catch(()=>({artifacts:[]})),Ce.builder.artifacts.installed().catch(()=>({installed:{}}))]),Q=new Map;for(const re of J.artifacts){if(re.type!=="agent")continue;const we=!!B.installed[`agent/${re.name}`];Q.set(re.name,{installed:we,localVersion:re.meta.version||void 0,localUpdatedAt:re.updatedAt})}z(Q)}catch{}},[]),X=k.useCallback(async()=>{_(!0);try{const J=u?lt.search({type:"agent",q:u,limit:50}):vi(Tr.hubAgents)??lt.search({type:"agent",limit:50}),B=new URLSearchParams;u&&B.set("q",u);const Q=fetch("/api/templates?"+B.toString()).then($=>$.json()).catch(()=>({templates:[]})),[re,we]=await Promise.all([J.catch(()=>({items:[],total:0})),Q,ae(),lt.isAuthenticated()?lt.purchases.mine().then($=>H(new Set($.purchases.map(G=>G.itemId)))).catch(()=>{}):Promise.resolve()]);g(re?.items??[]),h(Array.isArray(we.templates)?we.templates:[])}catch{h([]),g([])}finally{_(!1)}},[u,ae]);k.useEffect(()=>{X()},[X]),k.useEffect(()=>{if(!x){N({});return}fetch(`/api/templates/${encodeURIComponent(x.id)}/files`,{credentials:"include"}).then(J=>J.json()).then(J=>N(J.files??{})).catch(()=>N({}))},[x]);const F=async(J,B,Q)=>{try{const re=await fetch("/api/templates/instantiate",{method:"POST",headers:{"Content-Type":"application/json"},credentials:"include",body:JSON.stringify({templateId:J,name:B,orgId:"default",teamId:Q})});if(!re.ok)throw new Error(`Failed: ${re.status}`);C(!1),y(null)}catch(re){Y({title:r("common:create",{defaultValue:"Create"}),message:`Failed to create agent: ${re}`,variant:"danger"})}};if(W)return s.jsx(Ai,{type:W.type,name:W.name,onBack:()=>Z(null)});if(x){const J={type:"agent",name:x.id,displayName:h0(x,l),version:x.version,description:b4(x,l),author:x.author,category:x.category,tags:x.tags,icon:x.icon,files:w,agent:{roleName:x.roleId,agentRole:x.agentRole==="manager"?"manager":"worker"},dependencies:{skills:x.skills}},B=s.jsxs("div",{className:"space-y-6",children:[s.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[s.jsxs("div",{className:"rounded-xl border border-border-default bg-surface-secondary/40 p-5",children:[s.jsx("h3",{className:"text-xs text-fg-tertiary uppercase tracking-wider mb-3",children:r("agentStore.roleConfig")}),s.jsxs("div",{className:"space-y-2.5 text-sm",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("span",{className:"text-fg-tertiary w-20",children:r("agentStore.role")}),s.jsx("span",{className:"text-fg-secondary font-mono text-xs bg-surface-elevated px-2 py-0.5 rounded",children:x.roleId})]}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("span",{className:"text-fg-tertiary w-20",children:r("agentStore.position")}),s.jsx("span",{className:`px-2 py-0.5 rounded text-xs capitalize ${kK[x.agentRole]??""}`,children:x.agentRole})]})]})]}),s.jsxs("div",{className:"rounded-xl border border-border-default bg-surface-secondary/40 p-5",children:[s.jsx("h3",{className:"text-xs text-fg-tertiary uppercase tracking-wider mb-3",children:r("agentStore.skills")}),s.jsxs("div",{className:"flex flex-wrap gap-1.5",children:[x.skills.map(Q=>s.jsx("span",{className:"px-2.5 py-1 text-xs bg-brand-500/10 text-brand-500 rounded-lg border border-brand-500/20",children:Q},Q)),x.skills.length===0&&s.jsx("span",{className:"text-xs text-fg-tertiary italic",children:r("agentStore.noSkills")})]})]})]}),x.starterTasks&&x.starterTasks.length>0&&s.jsxs("div",{className:"rounded-xl border border-border-default bg-surface-secondary/40 p-5",children:[s.jsx("h3",{className:"text-xs text-fg-tertiary uppercase tracking-wider mb-3",children:r("agentStore.starterTasks")}),s.jsx("div",{className:"space-y-2",children:x.starterTasks.map((Q,re)=>s.jsxs("div",{className:"flex items-start gap-3 bg-surface-elevated/50 rounded-lg p-3",children:[s.jsx("span",{className:`inline-block w-2 h-2 rounded-full shrink-0 mt-1 ${Q.priority==="high"?"bg-red-400":Q.priority==="medium"?"bg-amber-400":"bg-green-400"}`}),s.jsxs("div",{children:[s.jsx("div",{className:"text-sm text-fg-primary",children:Q.title}),Q.description&&s.jsx("div",{className:"text-xs text-fg-tertiary mt-0.5",children:Q.description})]})]},re))})]})]});return s.jsxs(s.Fragment,{children:[s.jsx(Ai,{type:"agent",name:x.id,onBack:()=>y(null),readOnly:!0,initialManifest:J,actionSlot:s.jsx("button",{onClick:()=>C(!0),className:"px-4 py-1.5 text-xs bg-brand-600 hover:bg-brand-500 text-white rounded-lg transition-colors font-medium",children:r("agentStore.hireAgent")}),contentSlot:B}),T&&s.jsx(x4,{template:x,lang:l,onClose:()=>C(!1),onHire:F}),U&&s.jsx(dr,{alertOnly:!0,variant:U.variant??"danger",title:U.title,message:U.message,onConfirm:()=>Y(null),onCancel:()=>Y(null)})]})}return s.jsxs("div",{className:"flex-1 overflow-hidden flex flex-col",children:[s.jsxs("div",{className:"px-6 h-14 flex items-center justify-between shrink-0 gap-3",children:[s.jsx("h2",{className:"text-lg font-semibold",children:r("agentStore.title")}),s.jsx("input",{type:"text",placeholder:r("agentStore.searchPlaceholder"),value:u,onChange:J=>d(J.target.value),className:"px-3 py-1.5 bg-surface-elevated border border-border-default rounded-lg text-sm max-w-xs w-full focus:border-brand-500 focus:outline-none"})]}),s.jsx("div",{className:"flex-1 overflow-y-auto p-7 space-y-8",children:j?s.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-4",children:Array.from({length:6}).map((J,B)=>s.jsx("div",{className:"h-56 rounded-2xl skeleton"},B))}):m.length===0&&p.length===0?s.jsxs("div",{className:"text-center py-20",children:[s.jsx("div",{className:"text-4xl mb-4 opacity-30",children:"⧉"}),s.jsx("div",{className:"text-fg-secondary font-medium mb-1",children:u?r("agentStore.noResults",{search:u}):r("agentStore.noAgents")}),s.jsx("div",{className:"text-fg-tertiary text-sm",children:r(u?"agentStore.noResultsHint":"agentStore.noAgentsHint")})]}):s.jsxs(s.Fragment,{children:[m.length>0&&s.jsxs("section",{children:[s.jsxs("div",{className:"flex items-baseline gap-2 mb-3",children:[s.jsx("h3",{className:"section-title",children:r("agentStore.builtin")}),s.jsx("span",{className:"text-xs text-fg-tertiary",children:r("agentStore.available",{count:m.length})})]}),s.jsx(Er,{columns:3,children:m.map(J=>s.jsx(sa,{type:"agent",name:h0(J,l),description:b4(J,l),seed:J.id,icon:J.icon,version:J.version,category:J.category,tags:J.tags,authorLabel:J.author,hideStats:!0,showTypeBadge:!1,cornerLabel:r("agentStore.builtin"),onClick:()=>y(J)},J.id))})]}),p.length>0&&s.jsxs("section",{children:[s.jsx("h3",{className:"section-title mb-3",children:r("agentStore.markusHub")}),s.jsx(Er,{columns:3,children:p.map(J=>s.jsx(NK,{item:J,localInfo:O.get(Cc(J)),purchased:Hd(J,D),onStatusChange:ae,highlight:J.id===t,onHighlightDone:n,onViewDetail:B=>Z({type:"agent",name:B})},J.id))})]})]})}),T&&x&&s.jsx(x4,{template:x,lang:l,onClose:()=>C(!1),onHire:F}),U&&s.jsx(dr,{alertOnly:!0,variant:U.variant??"danger",title:U.title,message:U.message,onConfirm:()=>Y(null),onCancel:()=>Y(null)})]})}function Cc(e,t){if(e.slug&&e.slug.trim())return e.slug.trim();const n=t&&typeof t.name=="string"?t.name.trim():"";return qd(n||e.name,"hub-pkg")}function wi(e){return(async()=>{const t=await lt.download(e.id),n=t.name||e.name,r=t.config??{},o=Cc(e,r),l=t.itemType==="team"?"team":t.itemType==="skill"?"skill":"agent",u={type:"hub",hubItemId:e.id};if(t.files&&Object.keys(t.files).length>0)await Ce.builder.artifacts.import(l,o,t.files,u);else{const d={...r,name:o,displayName:r.displayName||n,description:e.description,source:u};await Ce.builder.artifacts.save(l,d)}return await Ce.builder.artifacts.install(l,o),window.dispatchEvent(new CustomEvent("markus:data-changed")),n})()}async function Rg(e,t){t("checking"),await lt.ensureAuth();const n=await lt.purchases.checkout(e.id);if(n.alreadyOwned)return t("installing"),await wi(e),"installed";try{if((await lt.creator.getBalance()).availableBalance>=(e.priceCents??0)){const l=await lt.purchases.payWithEarnings(e.id);if(l.ok||l.alreadyOwned)return t("installing"),await wi(e),"installed"}}catch{}if(!n.checkoutUrl)throw new Error("No checkout URL");t("checkout_opened");const r=window.open(n.checkoutUrl,"_blank","noopener");return new Promise((o,l)=>{const u=setInterval(async()=>{const d=r?r.closed:!1;try{if((await lt.purchases.checkout(e.id)).alreadyOwned){clearInterval(u),t("installing");try{await wi(e),o("installed")}catch(h){l(h)}return}}catch{}if(d){clearInterval(u);try{if((await lt.purchases.checkout(e.id)).alreadyOwned){t("installing"),await wi(e),o("installed");return}}catch{}o("cancelled")}},2e3)})}function NK({item:e,localInfo:t,purchased:n,onStatusChange:r,highlight:o,onHighlightDone:l,onViewDetail:u}){const{t:d}=ft(["store"]),[m,h]=k.useState(!1),[p,g]=k.useState(""),x=k.useRef(null),[y,w]=k.useState(!1);k.useEffect(()=>{if(o&&x.current){x.current.scrollIntoView({behavior:"smooth",block:"center"}),w(!0);const W=setTimeout(()=>{w(!1),l?.()},4e3);return()=>clearTimeout(W)}},[o,l]);const N=t?.installed??!1,T=N&&e.version&&t?.localVersion&&wK(e.version,t.localVersion),C=(e.priceCents??0)>0,j=async W=>{if(W.stopPropagation(),!m){h(!0),g("");try{await wi(e),g(T?d("card.upgraded"):d("card.installed")+"!"),r()}catch(Z){const U=Z instanceof Error?Z.message:"";U.includes("402")||U.includes("Purchase required")?g(d("card.purchaseRequired")):g(d("card.failed"))}finally{h(!1)}}},_=async W=>{if(W.stopPropagation(),!m){h(!0),g("");try{await Rg(e,U=>{U==="checkout_opened"?g(d("card.waitingPurchase","Waiting for purchase...")):U==="installing"&&g(d("card.installing"))})==="installed"?(g(d("card.installed")+"!"),r()):g("")}catch(Z){g(Z instanceof Error?Z.message:d("card.failed"))}finally{h(!1)}}},O=C?`$${((e.priceCents??0)/100).toFixed(2)}`:null,z=e.slug&&e.author?.username?`${lt.getUrl()}/@${encodeURIComponent(e.author.username)}/${encodeURIComponent(e.slug)}`:null,D=()=>{N&&u?u(Cc(e)):z&&window.open(z,"_blank","noopener,noreferrer")},H=s.jsxs(s.Fragment,{children:[T?s.jsx("button",{onClick:W=>{j(W)},disabled:m,className:"px-3 py-1.5 text-xs bg-amber-600 hover:bg-amber-500 text-white rounded-lg transition-colors disabled:opacity-50",children:m?d("card.upgrading"):d("card.upgrade",{version:e.version})}):N?s.jsxs("button",{onClick:W=>{j(W)},disabled:m,className:"px-3 py-1.5 text-xs bg-surface-elevated hover:bg-surface-overlay text-fg-secondary border border-border-default rounded-lg transition-colors disabled:opacity-50",children:[d("card.installed"),t?.localVersion?` v${t.localVersion}`:""]}):C&&!n?s.jsx("button",{onClick:W=>{_(W)},disabled:m,className:"px-3 py-1.5 text-xs bg-amber-600 hover:bg-amber-500 text-white rounded-lg transition-colors disabled:opacity-50 inline-flex items-center gap-1",children:m?p||d("card.installing"):s.jsxs(s.Fragment,{children:[d("card.buy","Buy")," ",O]})}):s.jsx("button",{onClick:W=>{j(W)},disabled:m,className:"px-3 py-1.5 text-xs bg-brand-600 hover:bg-brand-500 text-white rounded-lg transition-colors disabled:opacity-50",children:d(m?"card.installing":"card.install")}),p&&!(C&&!n)&&s.jsx("span",{className:`text-[10px] ${p===d("card.failed")||p===d("card.purchaseRequired")?"text-red-500":"text-green-600"}`,children:p})]});return s.jsx("div",{ref:x,className:y?"animate-pulse":"",children:s.jsx(sa,{type:"agent",showTypeBadge:!1,name:e.name,description:e.description,seed:e.slug||e.name,icon:e.icon||"bot",cover:e.thumbnailUrl,hubBase:lt.getUrl(),author:e.author,version:e.version,category:e.category,tags:e.tags,rating:parseFloat(e.avgRating)||0,ratingCount:e.ratingCount,downloadCount:e.downloadCount,priceCents:e.priceCents,currency:e.currency,installed:N,glowing:y,onClick:D,actions:H})})}function x4({template:e,lang:t,onClose:n,onHire:r}){const{t:o}=ft(["store"]),[l,u]=k.useState(`${h0(e,t)} Agent`),[d,m]=k.useState(""),[h,p]=k.useState([]),[g,x]=k.useState(!1);k.useEffect(()=>{fetch("/api/teams",{credentials:"include"}).then(w=>w.json()).then(w=>p(w.teams??[])).catch(()=>{})},[]);const y=async()=>{if(l.trim()){x(!0);try{await r(e.id,l.trim(),d||void 0)}finally{x(!1)}}};return s.jsx("div",{className:"fixed inset-0 bg-black/60 flex items-center justify-center z-50",onClick:n,children:s.jsxs("div",{className:"bg-surface-secondary border border-border-default rounded-xl p-6 w-[440px] shadow-2xl",onClick:w=>w.stopPropagation(),children:[s.jsx("div",{className:"flex items-center gap-3 mb-5",children:s.jsxs("div",{children:[s.jsx("h3",{className:"text-base font-semibold",children:o("hireModal.title")}),s.jsx("p",{className:"text-xs text-fg-tertiary",children:o("hireModal.creating",{name:h0(e,t)})})]})}),s.jsxs("div",{className:"space-y-4",children:[s.jsxs("div",{children:[s.jsx("label",{className:"block text-xs text-fg-tertiary mb-1.5",children:o("hireModal.agentName")}),s.jsx("input",{type:"text",value:l,onChange:w=>u(w.target.value),className:"input-field",autoFocus:!0})]}),h.length>0&&s.jsxs("div",{children:[s.jsx("label",{className:"block text-xs text-fg-tertiary mb-1.5",children:o("hireModal.assignTeam")}),s.jsxs("select",{value:d,onChange:w=>m(w.target.value),className:"input-field",children:[s.jsx("option",{value:"",children:o("hireModal.noTeam")}),h.map(w=>s.jsx("option",{value:w.id,children:w.name},w.id))]})]}),s.jsxs("div",{className:"bg-surface-elevated/50 rounded-lg p-3",children:[s.jsx("div",{className:"text-xs text-fg-tertiary mb-2 font-medium",children:o("hireModal.agentConfig")}),s.jsxs("div",{className:"grid grid-cols-2 gap-y-1.5 gap-x-4 text-xs",children:[s.jsx("div",{className:"text-fg-tertiary",children:o("hireModal.role")}),s.jsx("div",{className:"text-fg-secondary font-mono",children:e.roleId}),s.jsx("div",{className:"text-fg-tertiary",children:o("hireModal.position")}),s.jsx("div",{className:"text-fg-secondary capitalize",children:e.agentRole}),s.jsx("div",{className:"text-fg-tertiary",children:o("hireModal.skills")}),s.jsx("div",{className:"text-fg-secondary",children:e.skills.join(", ")||o("hireModal.none")})]})]})]}),s.jsxs("div",{className:"flex justify-end gap-3 mt-6",children:[s.jsx("button",{onClick:n,className:"btn-secondary",children:o("hireModal.cancel")}),s.jsx("button",{onClick:y,disabled:!l.trim()||g,className:"btn-primary",children:o(g?"hireModal.creating_progress":"hireModal.create")})]})]})})}function Yh(e,t){const n=e.i18n?.[t];return n?.displayName||n?.name||e.name}function y4(e,t){return e.i18n?.[t]?.description||e.description}function v4(e,t,n){return e.i18n?.[n]?.members?.[t]||t}function CK(e,t){const n=e.split(".").map(Number),r=t.split(".").map(Number);for(let o=0;o<Math.max(n.length,r.length);o++){const l=n[o]??0,u=r[o]??0;if(l>u)return!0;if(l<u)return!1}return!1}function TK({highlightItemId:e,onHighlightDone:t}={}){const{t:n,i18n:r}=ft(["store","common"]),o=r.language,[l,u]=k.useState(""),[d,m]=k.useState([]),[h,p]=k.useState([]),[g,x]=k.useState(null),[y,w]=k.useState({}),[N,T]=k.useState(!0),[C,j]=k.useState(!1),[_,O]=k.useState(null),[z,D]=k.useState(new Map),[H,W]=k.useState(new Set),[Z,U]=k.useState(null),Y=k.useCallback(async()=>{try{const[F,J]=await Promise.all([Ce.builder.artifacts.list().catch(()=>({artifacts:[]})),Ce.builder.artifacts.installed().catch(()=>({installed:{}}))]),B=new Map;for(const Q of F.artifacts){if(Q.type!=="team")continue;const re=!!J.installed[`team/${Q.name}`];B.set(Q.name,{installed:re,localVersion:Q.meta.version||void 0,localUpdatedAt:Q.updatedAt})}D(B)}catch{}},[]),ae=k.useCallback(async()=>{T(!0);try{const F=l?lt.search({type:"team",q:l,limit:50}):vi(Tr.hubTeams)??lt.search({type:"team",limit:50}),[J,B]=await Promise.all([F.catch(()=>({items:[],total:0})),Ce.teamTemplates.list(l||void 0).catch(()=>({templates:[]})),Y(),lt.isAuthenticated()?lt.purchases.mine().then(Q=>W(new Set(Q.purchases.map(re=>re.itemId)))).catch(()=>{}):Promise.resolve()]);p(J?.items??[]),m(B?.templates??[])}catch{m([]),p([])}finally{T(!1)}},[l,Y]);k.useEffect(()=>{ae()},[ae]),k.useEffect(()=>{if(!g){w({});return}fetch(`/api/team-templates/${encodeURIComponent(g.id)}/files`,{credentials:"include"}).then(F=>F.json()).then(F=>w(F.files??{})).catch(()=>w({}))},[g]);const X=async F=>{j(!0),O(null);try{const B=(await Ce.teams.create(F.name,F.description)).team.id;let Q,re=0;const we=[];for(const G of F.members){const ce=G.count??1;for(let I=0;I<ce;I++){const Ee=G.name??`${F.name} Agent ${I+1}`,Ue=ce>1?`${Ee} ${I+1}`:Ee,De=G.roleName??G.templateId;try{const Ke=await fetch("/api/agents",{method:"POST",headers:{"Content-Type":"application/json"},credentials:"include",body:JSON.stringify({name:Ue,...De?{roleName:De}:{},orgId:"default",teamId:B,agentRole:G.role??"worker",skills:G.skills??[]})});if(Ke.ok){re++;const st=await Ke.json();G.role==="manager"&&!Q&&(Q=st.agent?.id)}else{const st=await Ke.json().catch(()=>({error:`HTTP ${Ke.status}`}));we.push(`${Ue}: ${st.error??Ke.statusText}`)}}catch(Ke){we.push(`${Ue}: ${String(Ke)}`)}}}Q&&await Ce.teams.update(B,{managerId:Q,managerType:"agent"}).catch(()=>{});const $=we.length>0?` (${we.length} failed: ${we[0]})`:"";O({ok:re>0,message:`Team "${Yh(F,o)}" deployed with ${re} agent(s)${$}`})}catch(J){O({ok:!1,message:`Failed: ${J}`})}finally{j(!1)}};if(Z)return s.jsx(Ai,{type:Z.type,name:Z.name,onBack:()=>U(null)});if(g){const F={...y};g.announcements&&(F["ANNOUNCEMENT.md"]=g.announcements),g.norms&&(F["NORMS.md"]=g.norms);const J={type:"team",name:g.id,displayName:Yh(g,o),version:g.version,description:y4(g,o),author:g.author,category:g.category??"general",tags:g.tags??[],files:F,team:{members:g.members.map(Q=>({name:v4(g,Q.name??Q.roleName??Q.templateId??"Agent",o),role:Q.role??"worker",roleName:Q.roleName??Q.templateId,count:Q.count??1,skills:Q.skills??[]}))}},B=s.jsxs("div",{className:"rounded-xl border border-border-default bg-surface-secondary/40 overflow-hidden",children:[s.jsx("div",{className:"px-5 py-3 border-b border-border-default bg-surface-elevated/30",children:s.jsx("h3",{className:"text-xs text-fg-tertiary uppercase tracking-wider",children:n("teamStore.teamComposition")})}),s.jsx("div",{className:"p-5 space-y-2",children:g.members.map((Q,re)=>{const we=v4(g,Q.name??Q.roleName??Q.templateId??"Agent",o);return s.jsxs("div",{className:"flex items-center gap-3 bg-surface-elevated/50 rounded-lg p-3",children:[s.jsx("div",{className:`w-9 h-9 rounded-lg flex items-center justify-center text-sm font-bold shrink-0 ${Q.role==="manager"?"bg-amber-500/15 text-amber-400 ring-1 ring-amber-500/30":"bg-blue-500/15 text-blue-400 ring-1 ring-blue-500/30"}`,children:(we[0]??"?").toUpperCase()}),s.jsxs("div",{className:"min-w-0 flex-1",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("span",{className:"text-sm text-fg-primary font-medium",children:we}),s.jsx("span",{className:`px-1.5 py-0.5 rounded text-[10px] capitalize font-medium ${Q.role==="manager"?"bg-amber-500/15 text-amber-400":"bg-blue-500/15 text-blue-400"}`,children:Q.role??"worker"}),(Q.count??1)>1&&s.jsxs("span",{className:"text-[10px] text-fg-muted",children:["×",Q.count]})]}),(Q.roleName||Q.templateId)&&s.jsx("div",{className:"text-[10px] text-fg-tertiary font-mono mt-0.5",children:Q.roleName??Q.templateId})]}),Q.skills&&Q.skills.length>0&&s.jsxs("div",{className:"flex flex-wrap gap-1 shrink-0",children:[Q.skills.slice(0,3).map($=>s.jsx("span",{className:"px-1.5 py-0.5 text-[9px] bg-surface-elevated text-fg-muted rounded border border-border-default",children:$},$)),Q.skills.length>3&&s.jsxs("span",{className:"text-[9px] text-fg-muted",children:["+",Q.skills.length-3]})]})]},re)})})]});return s.jsx(s.Fragment,{children:s.jsx(Ai,{type:"team",name:g.id,onBack:()=>{x(null),O(null)},readOnly:!0,initialManifest:J,contentSlot:B,actionSlot:s.jsxs(s.Fragment,{children:[_&&s.jsx("span",{className:`text-xs ${_.ok?"text-green-500":"text-red-500"}`,children:_.message}),s.jsx("button",{onClick:()=>{X(g)},disabled:C,className:"px-4 py-1.5 text-xs bg-brand-600 hover:bg-brand-500 text-white rounded-lg transition-colors font-medium disabled:opacity-50",children:n(C?"teamStore.deploying":"teamStore.deployTeam")})]})})})}return s.jsxs("div",{className:"flex-1 overflow-hidden flex flex-col",children:[s.jsxs("div",{className:"px-6 h-14 flex items-center justify-between shrink-0 gap-3",children:[s.jsx("h2",{className:"text-lg font-semibold",children:n("teamStore.title")}),s.jsx("input",{type:"text",placeholder:n("teamStore.searchPlaceholder"),value:l,onChange:F=>u(F.target.value),className:"px-3 py-1.5 bg-surface-elevated border border-border-default rounded-lg text-sm max-w-xs w-full focus:border-brand-500 focus:outline-none"})]}),s.jsx("div",{className:"flex-1 overflow-y-auto p-7 space-y-8",children:N?s.jsx("div",{className:"grid grid-cols-1 lg:grid-cols-2 gap-4",children:Array.from({length:4}).map((F,J)=>s.jsx("div",{className:"h-56 rounded-2xl skeleton"},J))}):d.length===0&&h.length===0?s.jsxs("div",{className:"text-center py-20",children:[s.jsx("div",{className:"text-4xl mb-4 opacity-30",children:"◉"}),s.jsx("div",{className:"text-fg-secondary font-medium mb-1",children:l?n("teamStore.noResults",{search:l}):n("teamStore.noTeams")}),s.jsx("div",{className:"text-fg-tertiary text-sm",children:n(l?"teamStore.noResultsHint":"teamStore.noTeamsHint")})]}):s.jsxs(s.Fragment,{children:[d.length>0&&s.jsxs("section",{children:[s.jsxs("div",{className:"flex items-baseline gap-2 mb-3",children:[s.jsx("h3",{className:"section-title",children:n("teamStore.builtin")}),s.jsx("span",{className:"text-xs text-fg-tertiary",children:n("teamStore.available",{count:d.length})})]}),s.jsx(Er,{columns:2,children:d.map(F=>s.jsx(sa,{type:"team",name:Yh(F,o),description:y4(F,o),seed:F.id,icon:F.icon||"users",version:F.version,category:F.category,tags:F.tags,authorLabel:F.author,hideStats:!0,showTypeBadge:!1,cornerLabel:n("teamStore.builtin"),onClick:()=>x(F)},F.id))})]}),h.length>0&&s.jsxs("section",{children:[s.jsx("h3",{className:"section-title mb-3",children:n("teamStore.markusHub")}),s.jsx(Er,{columns:2,children:h.map(F=>s.jsx(EK,{item:F,localInfo:z.get(Cc(F)),purchased:Hd(F,H),onStatusChange:Y,highlight:F.id===e,onHighlightDone:t,onViewDetail:J=>U({type:"team",name:J})},F.id))})]})]})})]})}function EK({item:e,localInfo:t,purchased:n,onStatusChange:r,highlight:o,onHighlightDone:l,onViewDetail:u}){const{t:d}=ft(["store"]),[m,h]=k.useState(!1),[p,g]=k.useState(""),x=k.useRef(null),[y,w]=k.useState(!1);k.useEffect(()=>{if(o&&x.current){x.current.scrollIntoView({behavior:"smooth",block:"center"}),w(!0);const W=setTimeout(()=>{w(!1),l?.()},4e3);return()=>clearTimeout(W)}},[o,l]);const N=t?.installed??!1,T=N&&e.version&&t?.localVersion&&CK(e.version,t.localVersion),C=(e.priceCents??0)>0,j=C?`$${((e.priceCents??0)/100).toFixed(2)}`:null,_=async W=>{if(W.stopPropagation(),!m){h(!0),g("");try{await wi(e),g(T?d("card.upgraded"):d("card.installed")+"!"),r()}catch(Z){const U=Z instanceof Error?Z.message:"";U.includes("402")||U.includes("Purchase required")?g(d("card.purchaseRequired")):g(d("card.failed"))}finally{h(!1)}}},O=async W=>{if(W.stopPropagation(),!m){h(!0),g("");try{await Rg(e,U=>{U==="checkout_opened"?g(d("card.waitingPurchase","Waiting for purchase...")):U==="installing"&&g(d("card.installing"))})==="installed"?(g(d("card.installed")+"!"),r()):g("")}catch(Z){g(Z instanceof Error?Z.message:d("card.failed"))}finally{h(!1)}}},z=e.slug&&e.author?.username?`${lt.getUrl()}/@${encodeURIComponent(e.author.username)}/${encodeURIComponent(e.slug)}`:null,D=()=>{N&&u?u(Cc(e)):z&&window.open(z,"_blank","noopener,noreferrer")},H=s.jsxs(s.Fragment,{children:[T?s.jsx("button",{onClick:W=>{_(W)},disabled:m,className:"px-3 py-1.5 text-xs bg-amber-600 hover:bg-amber-500 text-white rounded-lg transition-colors disabled:opacity-50",children:m?d("card.upgrading"):d("card.upgrade",{version:e.version})}):N?s.jsxs("button",{onClick:W=>{_(W)},disabled:m,className:"px-3 py-1.5 text-xs bg-surface-elevated hover:bg-surface-overlay text-fg-secondary border border-border-default rounded-lg transition-colors disabled:opacity-50",children:[d("card.installed"),t?.localVersion?` v${t.localVersion}`:""]}):C&&!n?s.jsx("button",{onClick:W=>{O(W)},disabled:m,className:"px-3 py-1.5 text-xs bg-amber-600 hover:bg-amber-500 text-white rounded-lg transition-colors disabled:opacity-50 inline-flex items-center gap-1",children:m?p||d("card.installing"):s.jsxs(s.Fragment,{children:[d("card.buy","Buy")," ",j]})}):s.jsx("button",{onClick:W=>{_(W)},disabled:m,className:"px-3 py-1.5 text-xs bg-brand-600 hover:bg-brand-500 text-white rounded-lg transition-colors disabled:opacity-50",children:d(m?"card.installing":"card.install")}),p&&s.jsx("span",{className:`text-[10px] ${p===d("card.failed")||p===d("card.purchaseRequired")?"text-red-500":"text-green-600"}`,children:p})]});return s.jsx("div",{ref:x,className:y?"animate-pulse":"",children:s.jsx(sa,{type:"team",showTypeBadge:!1,name:e.name,description:e.description,seed:e.slug||e.name,icon:e.icon||"users",cover:e.thumbnailUrl,hubBase:lt.getUrl(),author:e.author,version:e.version,category:e.category,tags:e.tags,rating:parseFloat(e.avgRating)||0,ratingCount:e.ratingCount,downloadCount:e.downloadCount,priceCents:e.priceCents,currency:e.currency,installed:N,glowing:y,onClick:D,actions:H})})}function Xh(e,t){return e.i18n?.[t]?.displayName||e.name}function Qh(e,t){return e.i18n?.[t]?.description||e.description||""}function C3(e,t){const n=e.split(".").map(Number),r=t.split(".").map(Number);for(let o=0;o<Math.max(n.length,r.length);o++){const l=n[o]??0,u=r[o]??0;if(l>u)return!0;if(l<u)return!1}return!1}const AK={development:"bg-blue-500/15 text-blue-600",devops:"bg-amber-500/15 text-amber-600",productivity:"bg-green-500/15 text-green-600",custom:"bg-gray-500/15 text-fg-secondary",browser:"bg-brand-500/15 text-brand-500",communication:"bg-green-500/15 text-green-600",data:"bg-brand-500/15 text-brand-500",platform:"bg-blue-500/15 text-blue-600","AI 智能":"bg-brand-500/15 text-brand-500",开发工具:"bg-blue-500/15 text-blue-600",效率提升:"bg-green-500/15 text-green-600",数据分析:"bg-brand-500/15 text-brand-500",内容创作:"bg-brand-500/15 text-brand-500",安全合规:"bg-red-500/15 text-red-500",通讯协作:"bg-green-500/15 text-green-600"};function _K({item:e,installedSkills:t,purchased:n,onMsg:r,onRefresh:o}){const{t:l}=ft(["store"]),[u,d]=k.useState(!1),m=e.name.toLowerCase().trim().replace(/\s+/g,"-").replace(/[\/\\:*?"<>|]+/g,"").replace(/-{2,}/g,"-").replace(/^-|-$/g,"")||"unnamed",h=t.find(C=>C.name===e.name||C.name===m||!!e.slug&&C.name===e.slug),p=!!h,g=p&&e.version&&h?.version&&C3(e.version,h.version),x=(e.priceCents??0)>0,[y,w]=k.useState(""),N=async()=>{if(!u){d(!0),w("");try{await wi(e),r(g?`Upgraded ${e.name}`:`Installed ${e.name}`,"success"),o()}catch(C){const j=C instanceof Error?C.message:"";j.includes("402")||j.includes("Purchase required")?r(l("card.purchaseRequired"),"error"):r(l("card.failed"),"error")}finally{d(!1)}}},T=async()=>{if(!u){d(!0),w("");try{await Rg(e,j=>{j==="checkout_opened"?w(l("card.waitingPurchase","Waiting for purchase...")):j==="installing"&&w(l("card.installing"))})==="installed"&&(r(`Purchased & installed ${e.name}`,"success"),o()),w("")}catch(C){r(C instanceof Error?C.message:l("card.failed"),"error"),w("")}finally{d(!1)}}};if(g)return s.jsx("button",{onClick:()=>{N()},disabled:u,className:"px-2.5 py-1 text-[10px] bg-amber-600 hover:bg-amber-500 text-white rounded-lg disabled:opacity-50",children:u?l("card.upgrading"):l("card.upgrade",{version:e.version})});if(p)return s.jsxs("span",{className:"px-2.5 py-1 text-[10px] bg-surface-overlay text-fg-secondary rounded-lg",children:[l("card.installed"),h?.version?` (v${h.version})`:""]});if(x&&!n){const C=`$${((e.priceCents??0)/100).toFixed(2)}`;return s.jsx("span",{className:"inline-flex items-center gap-1.5",children:s.jsx("button",{onClick:()=>{T()},disabled:u,className:"px-2.5 py-1 text-[10px] bg-amber-600 hover:bg-amber-500 text-white rounded-lg disabled:opacity-50 inline-flex items-center gap-1",children:u?y||l("card.installing"):s.jsxs(s.Fragment,{children:[l("card.buy","Buy")," ",C]})})})}return s.jsx("button",{onClick:()=>{N()},disabled:u,className:"px-2.5 py-1 text-[10px] bg-brand-600 hover:bg-brand-500 text-white rounded-lg disabled:opacity-50",children:l(u?"card.installing":"card.install")})}function w4({item:e,installedSkills:t,purchased:n,onMsg:r,onRefresh:o,highlight:l,onHighlightDone:u,type:d="skill"}){const m=k.useRef(null),[h,p]=k.useState(!1);k.useEffect(()=>{if(l&&m.current){m.current.scrollIntoView({behavior:"smooth",block:"center"}),p(!0);const y=setTimeout(()=>{p(!1),u?.()},4e3);return()=>clearTimeout(y)}},[l,u]);const g=e.slug&&e.author?.username?`${lt.getUrl()}/@${encodeURIComponent(e.author.username)}/${encodeURIComponent(e.slug)}`:null,x=()=>{g&&window.open(g,"_blank","noopener,noreferrer")};return s.jsx("div",{ref:m,className:h?"animate-pulse":"",children:s.jsx(sa,{type:d,showTypeBadge:d!=="skill",name:e.name,description:e.description,seed:e.slug||e.name,icon:e.icon||Dd(e.slug||e.name,e.category),cover:e.thumbnailUrl,hubBase:lt.getUrl(),author:e.author,version:e.version,category:e.category,tags:e.tags,rating:parseFloat(e.avgRating)||0,ratingCount:e.ratingCount,downloadCount:e.downloadCount,priceCents:e.priceCents,currency:e.currency,onClick:x,actions:s.jsx(_K,{item:e,installedSkills:t,purchased:n,onMsg:r,onRefresh:o})})})}function jK({highlightItemId:e,onHighlightDone:t}={}){const{t:n,i18n:r}=ft(["store","common"]),o=r.language,l=Uo(),[u,d]=k.useState("skills"),[m,h]=k.useState(null),[p,g]=k.useState(new Set),[x,y]=k.useState([]),[w,N]=k.useState(null),[T,C]=k.useState([]),[j,_]=k.useState(0),[O,z]=k.useState(1),[D,H]=k.useState([]),[W,Z]=k.useState(""),[U,Y]=k.useState("score"),[ae,X]=k.useState(""),[F,J]=k.useState(!1),[B,Q]=k.useState([]),[re,we]=k.useState(!1),[$,G]=k.useState([]),[ce,I]=k.useState(""),[Ee,Ue]=k.useState(!1),[De,Ke]=k.useState([]),[st,mt]=k.useState([]),[ct,Dt]=k.useState(new Set),[Mt,Xt]=k.useState(!1),[Me,Ne]=k.useState(""),Re=[{id:"skills",labelKey:"skillStore.tabs.all"},{id:"skillhub",labelKey:"skillStore.tabs.skillhub"},{id:"skillssh",labelKey:"skillStore.tabs.skillssh"}],ut=(V,xe="success")=>{h({text:V,type:xe}),setTimeout(()=>h(null),xe==="error"?1e4:4e3)},it=k.useCallback(async()=>{try{const V=await Ce.skills.list();y(V.skills)}catch{}},[]),bt=k.useCallback(async()=>{we(!0);try{const V=await Ce.skills.builtin();Q(V.skills)}catch{}we(!1)},[]),se=k.useCallback(async V=>{J(!0);try{const xe=await Ce.skills.registrySkillhub({q:V?.q,category:V?.category,page:V?.page??1,limit:24,sort:V?.sort??U});C(xe.skills),_(xe.total),xe.categories?.length&&H(xe.categories)}catch{}J(!1)},[U]),et=k.useCallback(async V=>{Ue(!0);try{const xe=await Ce.skills.registrySkillssh(V);G(xe.skills)}catch{}Ue(!1)},[]),nt=k.useCallback(async V=>{Xt(!0);try{const xe=V?lt.search({type:"skill",q:V,limit:50}):vi(Tr.hubSkills)??lt.search({type:"skill",limit:50}),We=lt.search({subtype:"connector",q:V||void 0,limit:50}).catch(()=>({items:[]})),[he,ye]=await Promise.all([xe,We,lt.isAuthenticated()?lt.purchases.mine().then(Ze=>Dt(new Set(Ze.purchases.map(rt=>rt.itemId)))).catch(()=>{}):Promise.resolve()]);Ke(he?.items??[]),mt(ye?.items??[])}catch{}Xt(!1)},[]);k.useEffect(()=>{it(),bt(),se(),et()},[]),k.useEffect(()=>{u==="skills"&&nt(Me)},[u,Me,nt]);const Ge=async V=>{g(xe=>new Set(xe).add(V.name));try{const xe=await Ce.skills.install({name:V.name,source:"skillhub",slug:V.slug,sourceUrl:V.homepage,description:V.description_zh??V.description,category:"custom",version:V.version});await it(),ut(`"${V.name}" installed (${xe.method}) → ${xe.path}`),window.dispatchEvent(new CustomEvent("markus:data-changed"))}catch{ut(`Download failed for "${V.name}". You can try manually from: ${V.homepage}`,"error")}g(xe=>{const We=new Set(xe);return We.delete(V.name),We})},Qe=async V=>{g(xe=>new Set(xe).add(V.name));try{const xe=await Ce.skills.install({name:V.name,source:"skillssh",sourceUrl:V.url,githubRepo:`${V.author}/${V.repo}`,githubSkillPath:V.name});await it(),ut(`"${V.name}" installed (${xe.method}) → ${xe.path}`),window.dispatchEvent(new CustomEvent("markus:data-changed"))}catch{ut(`Download failed for "${V.name}". You can try manually from: ${V.url}`,"error")}g(xe=>{const We=new Set(xe);return We.delete(V.name),We})},xt=async V=>{g(xe=>new Set(xe).add(V.name));try{const xe=await Ce.skills.install({name:V.name,source:"builtin"});await it(),await bt(),ut(`"${V.name}" installed (${xe.method}) → ${xe.path}`),window.dispatchEvent(new CustomEvent("markus:data-changed"))}catch(xe){ut(`Install failed for "${V.name}": ${xe}`,"error")}g(xe=>{const We=new Set(xe);return We.delete(V.name),We})},pe=$.filter(V=>{if(!ce)return!0;const xe=ce.toLowerCase();return V.name.toLowerCase().includes(xe)||V.repo.toLowerCase().includes(xe)});if(w){const V=w,xe={};V.instructions&&(xe["SKILL.md"]=V.instructions);const We={type:"skill",name:V.name,displayName:Xh(V,o),version:V.version,description:Qh(V,o),author:V.author??"",category:V.category??"general",tags:V.tags,files:xe,skill:{skillFile:V.instructions?"SKILL.md":"",requiredPermissions:V.requiredPermissions,mcpServers:void 0,alwaysOn:!1}},he=V.installed&&V.installedVersion&&C3(V.version,V.installedVersion)?s.jsx("button",{onClick:()=>{xt(V)},disabled:p.has(V.name),className:"px-4 py-1.5 text-xs bg-amber-600 hover:bg-amber-500 text-white rounded-lg disabled:opacity-50 transition-colors",children:p.has(V.name)?n("card.upgrading"):n("card.upgrade",{version:V.version})}):V.installed?s.jsxs("span",{className:"px-4 py-1.5 text-xs bg-green-500/10 text-green-500 rounded-lg border border-green-500/20 inline-flex items-center gap-1",children:[s.jsx("svg",{className:"w-3 h-3",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",children:s.jsx("polyline",{points:"20 6 9 17 4 12"})}),n("card.installed"),V.installedVersion?` v${V.installedVersion}`:""]}):s.jsx("button",{onClick:()=>{xt(V)},disabled:p.has(V.name),className:"px-4 py-1.5 text-xs bg-green-600 hover:bg-green-500 text-white rounded-lg disabled:opacity-50 transition-colors",children:p.has(V.name)?n("card.installing"):n("card.install")}),ye=s.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[s.jsxs("div",{className:"rounded-xl border border-border-default bg-surface-secondary/40 p-5",children:[s.jsx("h3",{className:"text-xs text-fg-tertiary uppercase tracking-wider mb-3",children:n("skillStore.details")}),s.jsxs("div",{className:"space-y-2.5 text-sm",children:[V.category&&s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("span",{className:"text-fg-tertiary w-24",children:n("skillStore.category")}),s.jsx("span",{className:`px-2 py-0.5 rounded-full text-[10px] font-medium capitalize ${AK[V.category]??"bg-gray-500/15 text-fg-secondary"}`,children:V.category})]}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("span",{className:"text-fg-tertiary w-24",children:n("skillStore.version")}),s.jsx("span",{className:"text-fg-secondary font-mono text-xs",children:V.version})]}),V.hasMcpServers&&s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("span",{className:"text-fg-tertiary w-24",children:n("skillStore.integration")}),s.jsx("span",{className:"px-2 py-0.5 rounded text-[10px] bg-purple-500/15 text-purple-400",children:"MCP"})]}),V.hasInstructions&&s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("span",{className:"text-fg-tertiary w-24",children:n("skillStore.instructions")}),s.jsx("span",{className:"text-green-500 text-xs",children:"✓"})]})]})]}),(V.requiredPermissions.length>0||V.tags.length>0)&&s.jsxs("div",{className:"space-y-4",children:[V.requiredPermissions.length>0&&s.jsxs("div",{className:"rounded-xl border border-border-default bg-surface-secondary/40 p-5",children:[s.jsx("h3",{className:"text-xs text-fg-tertiary uppercase tracking-wider mb-3",children:n("skillStore.permissions")}),s.jsx("div",{className:"flex flex-wrap gap-1.5",children:V.requiredPermissions.map(Ze=>s.jsx("span",{className:"px-2.5 py-1 text-xs bg-amber-500/10 text-amber-500 rounded-lg border border-amber-500/20",children:Ze},Ze))})]}),V.tags.length>0&&s.jsxs("div",{className:"rounded-xl border border-border-default bg-surface-secondary/40 p-5",children:[s.jsx("h3",{className:"text-xs text-fg-tertiary uppercase tracking-wider mb-3",children:n("skillStore.tags")}),s.jsx("div",{className:"flex flex-wrap gap-1.5",children:V.tags.map(Ze=>s.jsx("span",{className:"px-2.5 py-1 text-xs bg-surface-elevated text-fg-secondary rounded-lg border border-border-default/50",children:Ze},Ze))})]})]})]});return s.jsxs(s.Fragment,{children:[s.jsx(Ai,{type:"skill",name:V.name,onBack:()=>N(null),readOnly:!0,initialManifest:We,actionSlot:he,contentSlot:ye}),m&&s.jsx("div",{className:`mx-7 mb-2 px-3 py-1.5 text-xs rounded-lg shrink-0 ${m.type==="error"?"bg-red-500/10 text-red-500":"bg-green-500/10 text-green-600"}`,children:m.text})]})}return s.jsxs("div",{className:"flex-1 overflow-hidden flex flex-col",children:[s.jsxs("div",{className:`${l?"px-4":"px-6"} shrink-0`,children:[s.jsx("div",{className:"flex items-center h-14",children:s.jsx("h2",{className:"text-lg font-semibold",children:n("skillStore.title")})}),s.jsx("div",{className:`flex ${l?"flex-wrap":""} gap-1 pb-2 overflow-x-auto scrollbar-hide`,children:Re.map(V=>s.jsx("button",{onClick:()=>d(V.id),className:`px-3 py-1.5 text-xs rounded-lg transition-colors shrink-0 ${u===V.id?"bg-brand-600 text-white":"text-fg-secondary hover:text-fg-primary hover:bg-surface-elevated"}`,children:n(V.labelKey)},V.id))})]}),m&&s.jsx("div",{className:`mx-7 mt-2 px-3 py-1.5 text-xs rounded-lg shrink-0 ${m.type==="error"?"bg-red-500/10 text-red-500":"bg-green-500/10 text-green-600"}`,children:m.text}),u==="skills"&&(()=>{const V=Me.trim().toLowerCase(),xe=V?B.filter(ye=>Xh(ye,o).toLowerCase().includes(V)||Qh(ye,o).toLowerCase().includes(V)):B,We=re&&Mt,he=xe.length===0&&De.length===0&&st.length===0;return s.jsxs("div",{className:`flex-1 overflow-y-auto ${l?"p-4":"p-6"} space-y-8`,children:[s.jsx("div",{className:"flex items-center gap-2",children:s.jsx("input",{value:Me,onChange:ye=>Ne(ye.target.value),placeholder:n("skillStore.searchMarkusHub"),className:`px-3 py-1.5 bg-surface-elevated border border-border-default rounded-lg text-sm text-fg-primary focus:border-brand-500 outline-none ${l?"flex-1 min-w-0":"w-72"}`})}),We&&he?s.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-4",children:Array.from({length:6}).map((ye,Ze)=>s.jsx("div",{className:"h-56 rounded-2xl skeleton"},Ze))}):he?s.jsxs("div",{className:"text-center text-fg-tertiary py-20",children:[s.jsx("div",{className:"text-4xl mb-3 opacity-30",children:"◇"}),s.jsx("div",{children:n("skillStore.noBuiltin")}),s.jsx("div",{className:"text-xs mt-1",children:n("skillStore.noBuiltinHint")})]}):s.jsxs(s.Fragment,{children:[xe.length>0&&s.jsxs("section",{children:[s.jsxs("div",{className:"flex items-baseline gap-2 mb-3",children:[s.jsx("h3",{className:"section-title",children:n("skillStore.tabs.builtin")}),s.jsx("span",{className:"text-xs text-fg-tertiary",children:n("skillStore.builtinCount",{count:xe.length})})]}),s.jsx(Er,{columns:3,children:xe.map(ye=>s.jsx(sa,{type:"skill",name:Xh(ye,o),description:Qh(ye,o),seed:ye.name,icon:Dd(ye.name,ye.category),version:ye.version,category:ye.category,tags:ye.tags,authorLabel:ye.author||void 0,installed:ye.installed,hideStats:!0,showTypeBadge:!1,cornerLabel:ye.installed?void 0:n("skillStore.tabs.builtin"),onClick:()=>N(ye)},ye.name))})]}),De.length>0&&s.jsxs("section",{children:[s.jsx("h3",{className:"section-title mb-3",children:n("skillStore.tabs.markusHub")}),s.jsx(Er,{columns:3,children:De.map(ye=>s.jsx(w4,{item:ye,installedSkills:x,purchased:Hd(ye,ct),onMsg:ut,onRefresh:()=>{it(),nt(Me)},highlight:ye.id===e,onHighlightDone:t},ye.id))})]}),st.length>0&&s.jsxs("section",{children:[s.jsxs("div",{className:"mb-3",children:[s.jsx("h3",{className:"section-title",children:n("tabs.connectors")}),s.jsx("p",{className:"text-xs text-fg-tertiary mt-0.5",children:n("connectorStore.emptyHint","连接器让智能体接入外部工具与服务 (MCP)")})]}),s.jsx(Er,{columns:3,children:st.map(ye=>s.jsx(w4,{item:ye,type:"connector",installedSkills:x,purchased:Hd(ye,ct),onMsg:ut,onRefresh:()=>{it(),nt(Me)},highlight:ye.id===e,onHighlightDone:t},ye.id))})]})]})]})})(),u==="skillhub"&&s.jsxs("div",{className:`flex-1 overflow-y-auto ${l?"p-4":"p-6"}`,children:[s.jsxs("div",{className:"flex items-center gap-2 mb-3 flex-wrap",children:[s.jsxs("select",{value:W,onChange:V=>{Z(V.target.value),z(1),se({q:ae||void 0,category:V.target.value||void 0,page:1})},className:"px-2 py-1.5 bg-surface-elevated border border-border-default rounded-lg text-xs text-fg-secondary outline-none",children:[s.jsx("option",{value:"",children:n("skillStore.allCategories")}),D.map(V=>s.jsx("option",{value:V,children:V},V))]}),s.jsxs("select",{value:U,onChange:V=>{Y(V.target.value),z(1),se({q:ae||void 0,category:W||void 0,page:1,sort:V.target.value})},className:"px-2 py-1.5 bg-surface-elevated border border-border-default rounded-lg text-xs text-fg-secondary outline-none",children:[s.jsx("option",{value:"score",children:n("skillStore.sortScore")}),s.jsx("option",{value:"downloads",children:n("skillStore.sortDownloads")}),s.jsx("option",{value:"stars",children:n("skillStore.sortStars")}),s.jsx("option",{value:"installs",children:n("skillStore.sortInstalls")})]}),!l&&s.jsx("span",{className:"text-xs text-fg-tertiary ml-auto",children:s.jsx("a",{href:"https://skillhub.tencent.com",target:"_blank",rel:"noopener noreferrer",className:"text-brand-500 hover:text-brand-500",children:n("skillStore.visitSite")})})]}),s.jsxs("div",{className:"flex items-center gap-2 mb-5",children:[s.jsx("input",{value:ae,onChange:V=>X(V.target.value),onKeyDown:V=>{V.key==="Enter"&&(z(1),se({q:ae||void 0,category:W||void 0,page:1}))},placeholder:n("skillStore.searchSkillhub"),className:"px-3 py-1.5 bg-surface-elevated border border-border-default rounded-lg text-sm text-fg-primary focus:border-brand-500 outline-none flex-1 min-w-0"}),s.jsx("button",{onClick:()=>{z(1),se({q:ae||void 0,category:W||void 0,page:1})},className:"px-3 py-1.5 bg-brand-600 hover:bg-brand-500 text-white text-xs rounded-lg shrink-0",children:"Search"})]}),F?s.jsx("div",{className:"text-center text-fg-tertiary py-20",children:s.jsx("div",{className:"animate-pulse",children:n("skillStore.loadingSkillhub")})}):T.length===0?s.jsxs("div",{className:"text-center text-fg-tertiary py-20",children:[s.jsx("div",{className:"text-4xl mb-3 opacity-30",children:"◎"}),s.jsx("div",{children:n("skillStore.noSkillhub")})]}):s.jsxs(s.Fragment,{children:[s.jsx("div",{className:"text-xs text-fg-tertiary mb-3",children:n("skillStore.skillhubTotal",{count:j.toLocaleString()})}),s.jsx(Er,{columns:3,children:T.map(V=>{const xe=x.some(We=>We.name===V.name||We.name===V.slug);return s.jsx(sa,{type:"skill",name:V.name,description:V.description_zh??V.description??"",seed:V.slug,icon:Dd(V.slug||V.name,V.tags?.[0]),version:V.version,authorLabel:"SkillHub",showTypeBadge:!1,tags:V.tags,installed:xe,hideStats:!0,onClick:()=>window.open(V.homepage,"_blank","noopener,noreferrer"),footerLeft:s.jsxs("span",{className:"flex items-center gap-2 text-[10px] text-fg-tertiary",children:[V.stars>0&&s.jsxs("span",{className:"text-amber-600",children:["★ ",V.stars.toLocaleString()]}),V.downloads>0&&s.jsxs("span",{children:[V.downloads>=1e4?`${(V.downloads/1e4).toFixed(1)}万`:V.downloads.toLocaleString()," ",n("skillStore.downloads")]})]}),actions:xe?void 0:s.jsx("button",{onClick:()=>{Ge(V)},disabled:p.has(V.name),className:"px-2.5 py-1 text-[10px] bg-brand-600 hover:bg-brand-500 text-white rounded-lg disabled:opacity-50",children:p.has(V.name)?"...":n("card.install")})},V.slug)})}),j>24&&s.jsxs("div",{className:"flex items-center justify-center gap-2 mt-6",children:[s.jsx("button",{disabled:O<=1,onClick:()=>{const V=O-1;z(V),se({q:ae||void 0,category:W||void 0,page:V})},className:"px-3 py-1.5 text-xs bg-surface-elevated text-fg-secondary rounded-lg hover:bg-surface-overlay disabled:opacity-30",children:n("skillStore.prevPage")}),s.jsx("span",{className:"text-xs text-fg-tertiary",children:n("skillStore.pageInfo",{current:O,total:Math.ceil(j/24)})}),s.jsx("button",{disabled:O>=Math.ceil(j/24),onClick:()=>{const V=O+1;z(V),se({q:ae||void 0,category:W||void 0,page:V})},className:"px-3 py-1.5 text-xs bg-surface-elevated text-fg-secondary rounded-lg hover:bg-surface-overlay disabled:opacity-30",children:n("skillStore.nextPage")})]})]})]}),u==="skillssh"&&s.jsxs("div",{className:`flex-1 overflow-y-auto ${l?"p-4":"p-6"}`,children:[s.jsxs("div",{className:`flex ${l?"flex-wrap":""} items-center gap-2 mb-5`,children:[s.jsx("input",{value:ce,onChange:V=>I(V.target.value),onKeyDown:V=>{V.key==="Enter"&&ce.trim()&&et(ce)},placeholder:n("skillStore.searchSkillssh"),className:`px-3 py-1.5 bg-surface-elevated border border-border-default rounded-lg text-sm text-fg-primary focus:border-brand-500 outline-none ${l?"flex-1 min-w-0":"w-72"}`}),s.jsx("button",{onClick:()=>{ce.trim()&&et(ce)},className:"px-3 py-1.5 bg-brand-600 hover:bg-brand-500 text-white text-xs rounded-lg shrink-0",children:"Search"}),!l&&s.jsx("span",{className:"text-xs text-fg-tertiary ml-auto",children:s.jsx("a",{href:"https://skills.sh",target:"_blank",rel:"noopener noreferrer",className:"text-brand-500 hover:text-brand-500",children:n("skillStore.visitSite")})})]}),Ee?s.jsx("div",{className:"text-center text-fg-tertiary py-20",children:s.jsx("div",{className:"animate-pulse",children:n("skillStore.loadingSkillssh")})}):pe.length===0?s.jsxs("div",{className:"text-center text-fg-tertiary py-20",children:[s.jsx("div",{className:"text-4xl mb-3 opacity-30",children:"⬡"}),s.jsx("div",{children:n("skillStore.browseSkillssh")}),s.jsx("div",{className:"text-xs mt-1",children:n("skillStore.browseSkillsshHint")})]}):s.jsx(Er,{columns:3,children:pe.map(V=>{const xe=x.some(We=>We.name===V.name);return s.jsx(sa,{type:"skill",name:V.name,description:V.description||"",seed:`${V.author}-${V.name}`,icon:Dd(V.name),authorLabel:`${V.author}/${V.repo}`,showTypeBadge:!1,installed:xe,hideStats:!0,cornerLabel:xe?void 0:"skills.sh",onClick:()=>window.open(V.url,"_blank","noopener,noreferrer"),footerLeft:V.installs?s.jsxs("span",{className:"text-[10px] text-fg-tertiary",children:[V.installs," installs"]}):void 0,actions:xe?void 0:s.jsx("button",{onClick:()=>{Qe(V)},disabled:p.has(V.name),className:"px-2.5 py-1 text-[10px] bg-brand-600 hover:bg-brand-500 text-white rounded-lg disabled:opacity-50",children:p.has(V.name)?"...":n("card.install")})},`${V.author}-${V.name}`)})})]})]})}const MK=["agent","team","skill","connector"];function Zh({title:e,subtitle:t,onMore:n,moreLabel:r}){return s.jsxs("div",{className:"flex items-end justify-between mb-3",children:[s.jsxs("div",{children:[s.jsx("h3",{className:"section-title",children:e}),t&&s.jsx("p",{className:"section-subtitle",children:t})]}),n&&s.jsxs("button",{className:"section-link",onClick:n,children:[r??"View all"," →"]})]})}function RK({item:e,onOpen:t}){const n=Wo(e.subtype==="connector"?"connector":e.itemType),r=Mg(n,e.slug||e.name),o=Ti[n];return s.jsxs("button",{onClick:t,className:"group relative w-full overflow-hidden rounded-2xl text-left h-44 md:h-52",style:{background:r},children:[s.jsx("div",{className:"absolute inset-0 bg-gradient-to-r from-black/55 via-black/20 to-transparent"}),s.jsx("svg",{className:"absolute -right-8 -bottom-10 opacity-20",width:"220",height:"220",viewBox:"0 0 24 24",fill:"none","aria-hidden":!0,children:s.jsx("path",{d:"M12 2l2.4 6.9L21 9l-5.4 4 2 7-5.6-4.1L6.4 20l2-7L3 9l6.6-.1z",fill:"white"})}),s.jsxs("div",{className:"relative h-full flex flex-col justify-end p-5 md:p-6",children:[s.jsxs("span",{className:"inline-flex w-fit items-center gap-1 rounded-full bg-white/20 backdrop-blur px-2.5 py-0.5 text-[11px] font-semibold text-white mb-2",children:["★ Featured · ",o.label]}),s.jsx("h2",{className:"text-xl md:text-2xl font-bold text-white drop-shadow-sm",children:e.name}),s.jsx("p",{className:"text-sm text-white/85 truncate max-w-lg mt-1",children:e.description}),s.jsxs("div",{className:"flex items-center gap-3 mt-3 text-white/80 text-xs",children:[s.jsxs("span",{className:"inline-flex items-center gap-1.5",children:[s.jsx(f0,{name:e.author?.displayName,username:e.author?.username,avatarUrl:e.author?.avatarUrl,hubBase:lt.getUrl(),size:18}),e.author?.displayName||e.author?.username]}),s.jsxs("span",{children:["↓ ",Ao(e.downloadCount)]}),(e.priceCents??0)>0?s.jsxs("span",{className:"badge-paid",children:["$",((e.priceCents??0)/100).toFixed(0)]}):s.jsx("span",{className:"badge-free",children:"Free"})]})]})]})}function k4({items:e,onOpen:t}){return s.jsx(Er,{columns:3,children:e.map(n=>s.jsx(sa,{type:n.subtype==="connector"?"connector":n.itemType,name:n.name,description:n.description,seed:n.slug||n.name,icon:n.icon,cover:n.thumbnailUrl,hubBase:lt.getUrl(),author:n.author,category:n.category,tags:n.tags,rating:parseFloat(n.avgRating)||0,ratingCount:n.ratingCount,downloadCount:n.downloadCount,priceCents:n.priceCents,currency:n.currency,onClick:()=>t(n)},n.id))})}function S4(){return s.jsx(Er,{columns:3,children:Array.from({length:6}).map((e,t)=>s.jsx("div",{className:"h-64 rounded-2xl skeleton"},t))})}function OK({onOpenType:e}){const{t}=ft(["store","common"]),[n,r]=k.useState([]),[o,l]=k.useState(!0);k.useEffect(()=>{let g=!1;return(async()=>{l(!0);try{const x=await lt.search({limit:60,sort:"popular"});g||r(x.items??[])}catch{g||r([])}finally{g||l(!1)}})(),()=>{g=!0}},[]);const u=k.useMemo(()=>{const g=n.filter(y=>y.featured);return(g.length>0?g:n).slice(0,3)},[n]),d=k.useMemo(()=>[...n].sort((g,x)=>(x.trendingScore??x.downloadCount)-(g.trendingScore??g.downloadCount)).slice(0,10),[n]),m=k.useMemo(()=>[...n].sort((g,x)=>(x.createdAt||"").localeCompare(g.createdAt||"")).slice(0,10),[n]),h=k.useMemo(()=>{const g=new Map;for(const x of n){const y=x.author?.username||x.author?.id;if(!y)continue;const w=g.get(y)??{author:x.author,downloads:0,count:0};w.downloads+=x.downloadCount||0,w.count+=1,g.set(y,w)}return[...g.values()].sort((x,y)=>y.downloads-x.downloads).slice(0,6)},[n]),p=g=>e(Wo(g.subtype==="connector"?"connector":g.itemType),g.id);return s.jsxs("div",{className:"flex-1 overflow-y-auto px-5 md:px-7 py-5 space-y-8",children:[s.jsxs("div",{className:"hero-glow rounded-2xl border border-border-subtle bg-surface-secondary p-5 md:p-6",children:[s.jsx("h1",{className:"text-2xl font-bold text-gradient tracking-tight",children:t("discover.title","Markus 广场")}),s.jsx("p",{className:"text-sm text-fg-tertiary mt-1 max-w-2xl",children:t("discover.subtitle","发现社区共享的智能体、AI 小队、技能与连接器 — 由创作者共建的开放生态。")}),s.jsx("div",{className:"flex flex-wrap gap-2 mt-4",children:MK.map(g=>s.jsxs("button",{onClick:()=>e(g),className:`inline-flex items-center gap-1.5 rounded-full px-3 py-1.5 text-xs font-medium text-white bg-gradient-to-r ${Ti[g].gradient} hover:opacity-90 transition-opacity`,children:[Ti[g].labelZh,s.jsx("span",{className:"opacity-70",children:Ti[g].label})]},g))})]}),o?s.jsx("div",{className:"h-52 rounded-2xl skeleton"}):u.length>0?s.jsx("div",{className:"grid grid-cols-1 lg:grid-cols-3 gap-4",children:u.map(g=>s.jsx(RK,{item:g,onOpen:()=>p(g)},g.id))}):null,s.jsxs("section",{children:[s.jsx(Zh,{title:t("discover.trending","热门趋势"),subtitle:t("discover.trendingSub","社区中下载与评分增长最快的资产")}),o?s.jsx(S4,{}):d.length>0?s.jsx(k4,{items:d,onOpen:p}):s.jsx(DK,{})]}),s.jsxs("section",{children:[s.jsx(Zh,{title:t("discover.fresh","新鲜上架"),subtitle:t("discover.freshSub","来自创作者的最新作品")}),o?s.jsx(S4,{}):m.length>0?s.jsx(k4,{items:m,onOpen:p}):null]}),h.length>0&&s.jsxs("section",{children:[s.jsx(Zh,{title:t("discover.topCreators","顶尖创作者"),subtitle:t("discover.topCreatorsSub","生态贡献榜")}),s.jsx("div",{className:"grid grid-cols-2 md:grid-cols-3 lg:grid-cols-6 gap-3",children:h.map((g,x)=>s.jsxs("div",{className:"asset-card p-4 flex flex-col items-center text-center",children:[s.jsxs("div",{className:"relative",children:[s.jsx(f0,{name:g.author?.displayName,username:g.author?.username,avatarUrl:g.author?.avatarUrl,hubBase:lt.getUrl(),size:48,verified:x<3}),x<3&&s.jsx("span",{className:"absolute -top-1 -left-1 w-5 h-5 rounded-full bg-amber-400 text-black text-[10px] font-bold flex items-center justify-center ring-2 ring-surface-secondary",children:x+1})]}),s.jsx("div",{className:"text-sm font-semibold text-fg-primary truncate w-full mt-2",children:g.author?.displayName||g.author?.username}),s.jsxs("div",{className:"text-[11px] text-fg-tertiary mt-0.5",children:[g.count," 作品 · ↓ ",Ao(g.downloads)]})]},g.author?.username||x))})]})]})}function DK(){const{t:e}=ft(["store"]);return s.jsxs("div",{className:"text-center py-12 rounded-2xl border border-dashed border-border-default",children:[s.jsx("div",{className:"text-3xl mb-2 opacity-40",children:"✦"}),s.jsx("div",{className:"text-fg-secondary font-medium",children:e("discover.empty","生态正在成长中")}),s.jsx("div",{className:"text-fg-tertiary text-sm mt-1",children:e("discover.emptyHint","成为首批创作者,分享你的第一个资产")})]})}function Sd(e,t,n){return e.i18n?.[n]?.[t]}function LK(){const{t:e,i18n:t}=ft(["store","common"]),n=Uo(),r=t.language,[o,l]=k.useState([]),[u,d]=k.useState({}),[m,h]=k.useState(new Set),[p,g]=k.useState(null),[x,y]=k.useState(!0),[w,N]=k.useState(""),[T,C]=k.useState("all"),[j,_]=k.useState(null),O=k.useCallback(async()=>{y(!0);try{const[H,W,Z,U]=await Promise.all([Ce.builder.artifacts.list().catch(()=>({artifacts:[]})),Ce.builder.artifacts.installed().catch(()=>({installed:{}})),Ce.skills.updates().catch(()=>({updates:[],count:0})),Ce.skills.builtin().catch(()=>({skills:[]}))]),Y={};for(const F of Z.updates)Y[F.name]={availableVersion:F.availableVersion,installedVersion:F.installedVersion,displayName:F.displayName,description:F.description};d(Y);const ae=H.artifacts.filter(F=>{const J=`${F.type}/${F.name}`;return!!W.installed[J]}),X=new Set(ae.filter(F=>F.type==="skill").map(F=>F.name));for(const F of U.skills)!F.installed||X.has(F.name)||!(W.installed[`skill/${F.name}`]||Y[F.name])&&!F.updateAvailable||!W.installed[`skill/${F.name}`]&&!Y[F.name]||(ae.push({type:"skill",name:F.name,meta:{displayName:F.i18n?.[r]?.displayName||F.name,description:F.i18n?.[r]?.description||F.description||"",version:F.installedVersion||F.version,author:F.author,category:F.category,tags:F.tags,i18n:F.i18n},path:"",updatedAt:""}),X.add(F.name));for(const[F,J]of Object.entries(Y))X.has(F)||(ae.push({type:"skill",name:F,meta:{displayName:J.displayName||F,description:J.description||"",version:J.installedVersion},path:"",updatedAt:""}),X.add(F));l(ae)}catch{}y(!1)},[r]);k.useEffect(()=>{O()},[O]),k.useEffect(()=>{const H=()=>{O()};return window.addEventListener("markus:data-changed",H),()=>window.removeEventListener("markus:data-changed",H)},[O]),k.useEffect(()=>{if(!p)return;const H=setTimeout(()=>g(null),3e3);return()=>clearTimeout(H)},[p]);const z=async(H,W)=>{if(!m.has(H)){h(Z=>new Set(Z).add(H));try{await Ce.skills.install({name:H,source:"builtin"});try{localStorage.removeItem("markus:template-updates-ack")}catch{}g({text:e("installedTab.updateSuccess",{name:H,version:W}),type:"success"}),window.dispatchEvent(new CustomEvent("markus:data-changed")),await O()}catch{g({text:e("installedTab.updateFailed",{name:H}),type:"error"})}h(Z=>{const U=new Set(Z);return U.delete(H),U})}},D=o.filter(H=>{if(T!=="all"&&H.type!==T)return!1;if(!w)return!0;const W=w.toLowerCase(),Z=(Sd(H.meta,"displayName",r)||H.meta.displayName||H.name).toLowerCase(),U=(Sd(H.meta,"description",r)||H.meta.description||"").toLowerCase();return Z.includes(W)||U.includes(W)}).sort((H,W)=>{const Z=H.type==="skill"&&u[H.name]?1:0;return(W.type==="skill"&&u[W.name]?1:0)-Z});return j?s.jsx(Ai,{type:j.type,name:j.name,onBack:()=>_(null)}):s.jsxs("div",{className:"flex-1 overflow-hidden flex flex-col",children:[s.jsxs("div",{className:`${n?"px-4":"px-6"} h-14 flex items-center shrink-0 gap-3`,children:[s.jsx("h2",{className:"text-lg font-semibold",children:e("installedTab.title")}),Object.keys(u).length>0&&s.jsxs("span",{className:"px-2 py-0.5 text-[11px] font-medium rounded-md bg-amber-500/15 text-amber-600 border border-amber-500/25",children:[e("installedTab.updateAvailable")," · ",Object.keys(u).length]})]}),s.jsxs("div",{className:`flex flex-wrap items-center gap-2 ${n?"px-4":"px-6"} py-2 shrink-0`,children:[s.jsx("div",{className:"flex gap-1",children:["all","agent","team","skill"].map(H=>s.jsx("button",{onClick:()=>C(H),className:`px-3 py-1 text-xs rounded-md transition-colors ${T===H?"bg-brand-600 text-white":"text-fg-secondary hover:text-fg-primary hover:bg-surface-elevated"}`,children:e(`installedTab.filter${H==="all"?"All":H==="agent"?"Agents":H==="team"?"Teams":"Skills"}`)},H))}),s.jsx("div",{className:"flex-1 min-w-[120px]",children:s.jsx("input",{type:"text",placeholder:e("installedTab.searchPlaceholder"),value:w,onChange:H=>N(H.target.value),className:"px-3 py-1.5 bg-surface-elevated border border-border-default rounded-lg text-sm w-full focus:border-brand-500 focus:outline-none"})})]}),s.jsx("div",{className:`flex-1 overflow-y-auto ${n?"p-4":"p-7"}`,children:x?s.jsx("div",{className:"text-center text-fg-tertiary py-20 animate-pulse",children:e("installedTab.loading")}):D.length===0?s.jsxs("div",{className:"text-center py-20",children:[s.jsx("div",{className:"text-4xl mb-4 opacity-30",children:"⧉"}),s.jsx("div",{className:"text-fg-secondary font-medium mb-1",children:e("installedTab.noItems")}),s.jsx("div",{className:"text-fg-tertiary text-sm",children:e("installedTab.noItemsHint")})]}):s.jsx(Er,{columns:3,children:D.map(H=>{const W=Sd(H.meta,"displayName",r)||H.meta.displayName||H.name,Z=Sd(H.meta,"description",r)||H.meta.description||"",U=H.meta.version||"",Y=H.meta.author||"",ae=H.meta.tags??[],X=H.meta.category||"",F=H.meta.icon,J=H.type==="skill"?u[H.name]:void 0;return s.jsx(sa,{type:H.type,name:W,description:Z,seed:H.name,icon:F,author:null,authorLabel:Y||void 0,version:J?J.installedVersion:U,category:X,tags:ae,installed:!J,hideStats:!0,cornerLabel:J?e("installedTab.updateAvailable"):void 0,onClick:()=>{H.path&&_({type:H.type,name:H.name})},actions:J?s.jsx("button",{type:"button",disabled:m.has(H.name),onClick:()=>{z(H.name,J.availableVersion)},className:"px-3 py-1.5 text-xs font-medium bg-amber-600 hover:bg-amber-500 text-white rounded-lg disabled:opacity-50 transition-colors",children:m.has(H.name)?e("installedTab.updating"):e("installedTab.updateTo",{version:J.availableVersion})}):void 0},`${H.type}/${H.name}`)})})}),p&&s.jsx("div",{className:`fixed bottom-6 left-1/2 -translate-x-1/2 z-50 px-4 py-2 rounded-lg text-sm shadow-lg ${p.type==="success"?"bg-emerald-600 text-white":"bg-red-600 text-white"}`,children:p.text})]})}const IK=50,PK=30;function zK(e,t,n,r){const o=k.useRef(0),l=k.useRef(0),u=k.useCallback(m=>{o.current=m.touches[0].clientX,l.current=m.touches[0].clientY},[]),d=k.useCallback(m=>{const h=m.changedTouches[0].clientX-o.current,p=m.changedTouches[0].clientY-l.current,g=Math.abs(h),x=Math.abs(p);if(g<IK||Math.atan2(x,g)*(180/Math.PI)>PK)return;if(r?.scrollContainerRef?.current){const N=r.scrollContainerRef.current,T=N.scrollLeft<=1,C=N.scrollLeft+N.clientWidth>=N.scrollWidth-1;if(h>0&&!T||h<0&&!C)return}const w=e.findIndex(N=>N.id===t);h<0&&w<e.length-1?n(e[w+1].id):h>0&&w>0?n(e[w-1].id):h>0&&w===0&&r?.onSwipeOutLeft?r.onSwipeOutLeft():h<0&&w===e.length-1&&r?.onSwipeOutRight&&r.onSwipeOutRight()},[e,t,n,r]);return{onTouchStart:u,onTouchEnd:d}}const BK=["builder","discover","agents","teams","skills","installed"],UK={agent:"agents",team:"teams",skill:"skills",connector:"skills"};function T3(e){return!!e&&BK.includes(e)}function $K(){const e=localStorage.getItem("markus_nav_installItem"),t=localStorage.getItem("markus_nav_storeTab");return e&&localStorage.removeItem("markus_nav_installItem"),t&&localStorage.removeItem("markus_nav_storeTab"),{tab:T3(t)?t:"builder",installId:e}}function HK({authUser:e}){const{t}=ft(["nav","store","common"]),n=k.useMemo(()=>[{id:"builder",label:t("nav:tabs.create")},{id:"discover",label:t("nav:tabs.discover")},{id:"agents",label:t("nav:tabs.agents")},{id:"teams",label:t("nav:tabs.teams")},{id:"skills",label:t("nav:tabs.skills")},{id:"installed",label:t("nav:tabs.installed")}],[t]),[r]=k.useState($K),[o,l]=k.useState(r.tab),[u,d]=k.useState(r.installId),m=zK(n,o,l);k.useEffect(()=>{const p=g=>{const x=g.detail,y=x.params?.storeTab??localStorage.getItem("markus_nav_storeTab");T3(y)&&l(y);const w=x.params?.installItem??localStorage.getItem("markus_nav_installItem");w&&d(w),localStorage.removeItem("markus_nav_storeTab"),localStorage.removeItem("markus_nav_installItem")};return window.addEventListener("markus:navigate",p),()=>window.removeEventListener("markus:navigate",p)},[]);const h=(p,g)=>{g&&d(g),l(UK[p]??"agents")};return s.jsxs("div",{className:"flex-1 overflow-hidden flex flex-col",onTouchStart:m.onTouchStart,onTouchEnd:m.onTouchEnd,children:[s.jsxs("div",{className:"flex items-center shrink-0 overflow-x-auto scrollbar-hide",children:[s.jsx(s5,{className:"ml-2"}),n.map(p=>s.jsx("button",{onClick:()=>l(p.id),className:`flex-1 min-w-fit px-3 py-2.5 text-xs font-medium text-center whitespace-nowrap transition-colors border-b-2 ${o===p.id?"border-brand-500 text-brand-500":"border-transparent text-fg-tertiary"}`,children:p.label},p.id))]}),s.jsxs("div",{className:"flex-1 overflow-hidden flex flex-col",children:[o==="builder"&&s.jsx(S3,{authUser:e}),o==="discover"&&s.jsx(OK,{onOpenType:h}),o==="agents"&&s.jsx(SK,{authUser:e,highlightItemId:u,onHighlightDone:()=>d(null)}),o==="teams"&&s.jsx(TK,{highlightItemId:u,onHighlightDone:()=>d(null)}),o==="skills"&&s.jsx(jK,{highlightItemId:u,onHighlightDone:()=>d(null)}),o==="installed"&&s.jsx(LK,{})]})]})}const N4="usageType",Jh="profile";function FK({onComplete:e,theme:t,onThemeChange:n,skipProfile:r,onProfileUpdated:o}){const{t:l}=ft(["onboarding","common"]),[u,d]=k.useState(0),[m,h]=k.useState(""),[p,g]=k.useState(""),[x,y]=k.useState(""),[w,N]=k.useState(""),[T,C]=k.useState(!1),[j,_]=k.useState(""),[O,z]=k.useState(!1),[D,H]=k.useState(null);k.useEffect(()=>{Ce.auth.me().then(({user:Ne})=>{Ne.name&&h(Ne.name),Ne.email&&g(Ne.email),Ne.avatarUrl&&H(Ne.avatarUrl);const Re=Ne.name||Ne.email?.split("@")[0]||"";Re&&Y(ut=>ut||l("usageType.defaultOrgName",{name:Re}))}).catch(()=>{}),Ce.settings.getOrg().then(({org:Ne})=>{Ne?.name&&Ne.name!=="My Organization"&&Y(Ne.name)}).catch(()=>{}),yn()&&Ce.hubOrgs.invitations().then(Ne=>{Ne.invitations?.length>0&&we(Ne.invitations)}).catch(()=>{})},[]);const[W,Z]=k.useState(null),[U,Y]=k.useState(""),[ae,X]=k.useState(!1),[F,J]=k.useState(!1),[B,Q]=k.useState(""),[re,we]=k.useState([]),[$,G]=k.useState(null),[ce,I]=k.useState(null),Ee=async()=>{const Ne=U.trim();if(Ne){X(!0),Q("");try{if(await Ce.settings.updateOrg(Ne),yn()){const Re=await Ce.hubOrgs.mine(),ut=Re.orgs?.find(it=>it.role==="owner")??Re.orgs?.[0];ut?.id?await Ce.hubOrgs.update(ut.id,{name:Ne}):await Ce.hubOrgs.create(Ne)}J(!0)}catch{Q(l("usageType.orgNameSaveFailed"))}finally{X(!1)}}},[Ue,De]=k.useState(!0),Ke=async()=>{if(_(""),!m.trim()){_(l("profile.errors.nameRequired"));return}if(!p.trim()){_(l("profile.errors.emailRequired"));return}if(!/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(p.trim())){_(l("profile.errors.emailInvalid"));return}if(x&&x.length<6){_(l("profile.errors.passwordTooShort"));return}if(x&&x!==w){_(l("profile.errors.passwordMismatch"));return}C(!0);try{const{user:Ne}=await Ce.auth.updateProfile(m.trim(),p.trim());x&&await Ce.auth.changePassword("",x),o?.(Ne),z(!0)}catch{_(l("profile.errors.saveFailed"))}finally{C(!1)}},st=[{value:"system",label:l("theme.system"),icon:"💻",desc:l("theme.systemDesc")},{value:"light",label:l("theme.light"),icon:"☀️",desc:l("theme.lightDesc")},{value:"dark",label:l("theme.dark"),icon:"🌊",desc:l("theme.darkDesc")},{value:"cyberpunk",label:l("theme.cyberpunk"),icon:"🔮",desc:l("theme.cyberpunkDesc")},{value:"mono",label:l("theme.mono"),icon:"⬛",desc:l("theme.monoDesc")}],mt=[{id:"welcome",title:l("welcome.title"),subtitle:l("welcome.subtitle"),content:s.jsx("p",{className:"text-fg-secondary text-sm leading-relaxed",children:s.jsx(j7,{i18nKey:"welcome.description",ns:"onboarding",components:{strong:s.jsx("strong",{className:"text-fg-primary"})}})})},{id:N4,title:l("usageType.title",{defaultValue:"How will you use Markus?"}),subtitle:l("usageType.subtitle",{defaultValue:"This helps us tailor your experience."}),content:s.jsxs("div",{className:"space-y-4",children:[s.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[s.jsxs("button",{onClick:()=>{Z("personal"),J(!0)},className:`flex flex-col items-center gap-3 rounded-xl border-2 p-5 transition-all text-left ${W==="personal"?"border-brand-500 bg-brand-500/10":"border-border-default hover:border-fg-tertiary bg-surface-elevated/30"}`,children:[s.jsx("span",{className:"text-2xl",children:"👤"}),s.jsxs("div",{children:[s.jsx("div",{className:"font-medium text-fg-primary text-sm text-center",children:l("usageType.personal",{defaultValue:"Personal"})}),s.jsx("div",{className:"text-[11px] text-fg-tertiary mt-1 text-center",children:l("usageType.personalDesc",{defaultValue:"Individual use with your own AI agents."})})]})]}),s.jsxs("button",{onClick:()=>{Z("organization"),J(!1)},className:`flex flex-col items-center gap-3 rounded-xl border-2 p-5 transition-all text-left ${W==="organization"?"border-brand-500 bg-brand-500/10":"border-border-default hover:border-fg-tertiary bg-surface-elevated/30"}`,children:[s.jsx("span",{className:"text-2xl",children:"🏢"}),s.jsxs("div",{children:[s.jsx("div",{className:"font-medium text-fg-primary text-sm text-center",children:l("usageType.organization",{defaultValue:"Team & Enterprise"})}),s.jsx("div",{className:"text-[11px] text-fg-tertiary mt-1 text-center",children:l("usageType.organizationDesc",{defaultValue:"For teams sharing licenses and collaborating."})})]})]})]}),W==="organization"&&s.jsxs("div",{className:"space-y-4 mt-4",children:[re.length>0&&s.jsxs("div",{className:"space-y-2",children:[s.jsx("div",{className:"text-xs text-fg-tertiary font-medium",children:l("usageType.pendingInvitations")}),re.map(Ne=>s.jsxs("div",{className:"flex items-center justify-between px-4 py-3 rounded-xl border border-amber-500/20 bg-amber-500/5",children:[s.jsxs("div",{children:[s.jsx("div",{className:"text-sm font-medium text-fg-primary",children:Ne.orgName}),s.jsx("div",{className:"text-[11px] text-fg-tertiary",children:l("usageType.invitedBy",{name:Ne.invitedBy})})]}),s.jsx("button",{onClick:async()=>{G(Ne.orgId);try{await Ce.hubOrgs.acceptInvitation(Ne.orgId),I(Ne.orgId),J(!0)}catch{}finally{G(null)}},disabled:$===Ne.orgId||ce===Ne.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:ce===Ne.orgId?l("usageType.accepted"):$===Ne.orgId?l("usageType.accepting"):l("usageType.acceptAndJoin")})]},Ne.orgId)),s.jsx("div",{className:"text-[11px] text-fg-tertiary text-center pt-1",children:l("usageType.orCreateNew")})]}),s.jsxs("div",{className:"space-y-1",children:[s.jsx("label",{className:"text-xs text-fg-tertiary font-medium",children:l("usageType.orgNameLabel")}),s.jsx("input",{type:"text",value:U,onChange:Ne=>{Y(Ne.target.value),J(!1),Q("")},placeholder:l("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"})]}),B&&s.jsx("p",{className:"text-xs text-red-500",children:B}),s.jsx("button",{onClick:()=>{Ee()},disabled:ae||!U.trim()||F,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:l(ae?"common:saving":F?"usageType.orgNameSaved":"usageType.setOrgName")})]})]})},{id:Jh,title:l("profile.title"),subtitle:l("profile.subtitle"),content:O?s.jsxs("div",{className:"flex items-center gap-3 bg-green-500/10 border border-green-500/30 rounded-xl p-4",children:[s.jsx("span",{className:"text-green-600 text-lg",children:"✓"}),s.jsxs("div",{children:[s.jsx("div",{className:"text-sm font-medium text-green-600",children:l("profile.saved")}),s.jsxs("div",{className:"text-xs text-fg-secondary mt-0.5",children:[m," · ",p]})]})]}):s.jsxs("div",{className:"space-y-4",children:[s.jsx("div",{className:"flex justify-center",children:s.jsx(a5,{currentUrl:D,name:m,size:64,targetType:"user"})}),s.jsxs("div",{className:"space-y-1",children:[s.jsxs("label",{className:"text-xs text-fg-tertiary font-medium",children:[l("profile.nameLabel")," ",s.jsx("span",{className:"text-red-500",children:"*"})]}),s.jsx("input",{type:"text",value:m,onChange:Ne=>h(Ne.target.value),placeholder:l("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})]}),s.jsxs("div",{className:"space-y-1",children:[s.jsxs("label",{className:"text-xs text-fg-tertiary font-medium",children:[l("profile.emailLabel")," ",s.jsx("span",{className:"text-red-500",children:"*"})]}),s.jsx("input",{type:"email",value:p,onChange:Ne=>g(Ne.target.value),placeholder:l("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"})]}),s.jsxs("div",{className:"space-y-1",children:[s.jsx("label",{className:"text-xs text-fg-tertiary font-medium",children:l("profile.newPasswordLabel")}),s.jsx("input",{type:"password",value:x,onChange:Ne=>y(Ne.target.value),placeholder:l("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"})]}),x&&s.jsxs("div",{className:"space-y-1",children:[s.jsx("label",{className:"text-xs text-fg-tertiary font-medium",children:l("profile.confirmPasswordLabel")}),s.jsx("input",{type:"password",value:w,onChange:Ne=>N(Ne.target.value),placeholder:l("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"})]}),j&&s.jsx("div",{className:"px-3 py-2 bg-red-500/10 border border-red-500/30 rounded-lg text-xs text-red-500",children:j}),s.jsx("button",{onClick:()=>{Ke()},disabled:T||!m.trim()||!p.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:l(T?"common:saving":"profile.saveProfile")})]})},{id:"theme",title:l("theme.title"),subtitle:l("theme.subtitle"),content:s.jsxs("div",{className:"space-y-4",children:[s.jsx("div",{className:"grid grid-cols-3 gap-3",children:st.map(Ne=>s.jsxs("button",{onClick:()=>n(Ne.value),className:`flex flex-col items-center gap-2 rounded-xl border-2 p-5 transition-all ${t===Ne.value?"border-brand-500 bg-brand-500/10":"border-border-default hover:border-fg-tertiary bg-surface-elevated/30"}`,children:[s.jsx("span",{className:"text-2xl",children:Ne.icon}),s.jsx("span",{className:"text-sm font-medium text-fg-primary",children:Ne.label}),s.jsx("span",{className:"text-[11px] text-fg-tertiary leading-tight text-center",children:Ne.desc})]},Ne.value))}),s.jsxs("label",{className:"flex items-center gap-2.5 p-3 bg-surface-elevated/30 rounded-lg cursor-pointer group",children:[s.jsx("input",{type:"checkbox",checked:Ue,onChange:Ne=>De(Ne.target.checked),className:"accent-brand-500 shrink-0"}),s.jsx("span",{className:"text-[11px] text-fg-tertiary",children:l("done.telemetry")})]})]})}],ct=r?mt.filter(Ne=>Ne.id!==Jh):mt,Dt=ct.findIndex(Ne=>Ne.id===N4),Mt=ct.findIndex(Ne=>Ne.id===Jh),Xt=()=>{u===Dt&&Dt>=0&&!W||u===Dt&&W==="organization"&&!F||u===Mt&&Mt>=0&&!O||(u<ct.length-1?d(u+1):(fetch("/api/settings/telemetry",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({enabled:Ue})}).catch(()=>{}),e()))},Me=ct[u];return s.jsx("div",{className:"min-h-dvh bg-surface-primary flex items-center justify-center p-4",children:s.jsx("div",{className:"w-full max-w-lg",children:s.jsxs("div",{className:"bg-surface-elevated rounded-2xl p-8",children:[s.jsx("div",{className:"flex gap-1.5 mb-8",children:ct.map((Ne,Re)=>s.jsx("div",{className:`h-1 flex-1 rounded-full transition-colors ${Re<=u?"bg-brand-500":"bg-surface-elevated"}`},Re))}),s.jsx("h2",{className:"text-2xl font-bold text-fg-primary",children:Me.title}),s.jsx("p",{className:"text-sm text-fg-secondary mt-1 mb-6",children:Me.subtitle}),Me.content,s.jsxs("div",{className:"flex justify-between mt-8",children:[u>0?s.jsx("button",{onClick:()=>d(u-1),className:"px-4 py-2 text-sm text-fg-secondary hover:text-fg-primary transition-colors",children:l("common:back")}):s.jsx("span",{}),s.jsx("button",{onClick:Xt,disabled:Mt>=0&&u===Mt&&!O||Dt>=0&&u===Dt&&(!W||W==="organization"&&!F),className:`px-6 py-2.5 text-white text-sm rounded-xl transition-colors ${Mt>=0&&u===Mt&&!O||Dt>=0&&u===Dt&&(!W||W==="organization"&&!F)?"bg-brand-600/40 cursor-not-allowed":"bg-brand-600 hover:bg-brand-500"}`,children:u===ct.length-1?l("getStarted"):l("common:next")})]})]})})})}const qK="markus:legal-consent",GK="https://markus.global";function VK({onLogin:e,hasOwner:t}){const{t:n,i18n:r}=ft("auth"),[o,l]=k.useState(null),[u,d]=k.useState(""),[m,h]=k.useState(!1),[p,g]=k.useState(""),[x,y]=k.useState(""),[w,N]=k.useState(!1),[T,C]=k.useState(!1),j=Z=>{const U=(r.language||"").toLowerCase().startsWith("zh")?"?lang=zh":"";return`${GK}${Z}${U}`},_=()=>{try{localStorage.setItem(qK,JSON.stringify({acceptedAt:new Date().toISOString(),terms:!0,privacy:!0}))}catch{}},O=()=>T?(_(),!0):(N(!1),requestAnimationFrame(()=>N(!0)),!1),z=async(Z,U=!1)=>{if(!(!U&&!O())){d(""),l(Z??"hub");try{await na(Z);const Y=yn(),ae=ua();if(!Y||!ae){d(n("login.hubUnavailable"));return}const{user:X,needsOnboarding:F}=await Ce.auth.hubLogin(Y,ae);e(X,F??!1,{fromHub:!0})}catch(Y){const ae=Y instanceof Error?Y.message:"";if(!ae.includes("cancelled")){if(!U&&yn())return Ni(),z(Z,!0);d(ae||n("login.hubUnavailable"))}}finally{l(null)}}};k.useEffect(()=>{const Z=window.markusDesktop;if(!Z?.consumePendingDeepLinkAuth)return;let U=!1;return Z.consumePendingDeepLinkAuth().then(async Y=>{if(!(U||!Y)&&T){d(""),l("hub");try{const ae=await XO(Y),X=yn(),F=ua();if(!ae||!X||!F){d(n("login.hubUnavailable"));return}const{user:J,needsOnboarding:B}=await Ce.auth.hubLogin(X,F);e(J,B??!1,{fromHub:!0})}catch{d(n("login.hubUnavailable"))}finally{U||l(null)}}}).catch(()=>{}),()=>{U=!0}},[]);const D=async Z=>{if(Z.preventDefault(),!(!p.trim()||!x)&&O()){d(""),l("local");try{const{user:U,needsOnboarding:Y}=await Ce.auth.login(p.trim(),x);e(U,Y??!1)}catch{d(n("login.invalidCredentials"))}finally{l(null)}}},H=n(t?"login.welcomeBack":"login.getStarted"),W="w-full flex items-center justify-center gap-3 h-11 px-4 bg-surface-elevated border border-border-default rounded-xl text-sm text-fg-primary font-medium transition-all hover:border-brand-400/60 hover:shadow-sm active:scale-[0.99] disabled:opacity-50 disabled:pointer-events-none";return s.jsxs("div",{className:"min-h-dvh bg-surface-primary flex flex-col items-center justify-center p-4 relative overflow-hidden",children:[s.jsxs("div",{className:"pointer-events-none absolute inset-0 overflow-hidden",children:[s.jsx("div",{className:"absolute -top-48 left-1/2 -translate-x-1/2 h-[42rem] w-[42rem] rounded-full bg-brand-500/20 blur-[120px]"}),s.jsx("div",{className:"absolute top-1/4 -left-40 h-[26rem] w-[26rem] rounded-full bg-brand-400/10 blur-[100px]"}),s.jsx("div",{className:"absolute -bottom-40 -right-32 h-[34rem] w-[34rem] rounded-full bg-brand-600/10 blur-[110px]"})]}),s.jsxs("div",{className:"w-full max-w-[26rem] relative z-10 flex-1 flex flex-col justify-center",children:[s.jsxs("div",{className:"text-center mb-8",children:[s.jsx("img",{src:"/logo.png",alt:"Markus",className:"w-16 h-16 mx-auto mb-4 rounded-2xl shadow-xl shadow-brand-900/20 ring-1 ring-border-default/40"}),s.jsx("div",{className:"text-[1.75rem] leading-none font-extrabold tracking-tight text-fg-primary mb-2",children:"Markus"}),s.jsx("div",{className:"text-sm text-fg-tertiary",children:H})]}),s.jsx("div",{className:"bg-surface-secondary/70 backdrop-blur-xl border border-border-default/80 rounded-3xl p-7 sm:p-8 shadow-2xl shadow-black/10",children:m?s.jsxs("div",{className:"space-y-4",children:[s.jsxs("div",{children:[s.jsx("div",{className:"text-base font-semibold text-fg-primary",children:n("login.localTitle")}),s.jsx("div",{className:"text-xs text-fg-tertiary mt-0.5",children:n("login.localAccountHint")})]}),s.jsxs("form",{onSubmit:D,className:"space-y-3",children:[s.jsx("input",{type:"email",value:p,onChange:Z=>g(Z.target.value),autoComplete:"email",autoFocus:!0,placeholder:n("login.email"),className:"w-full px-4 h-11 bg-surface-elevated border border-border-default rounded-xl text-sm text-fg-primary focus:border-brand-500 focus:ring-2 focus:ring-brand-500/20 outline-none transition-all placeholder:text-fg-tertiary",required:!0}),s.jsx("input",{type:"password",value:x,onChange:Z=>y(Z.target.value),autoComplete:"current-password",placeholder:n("login.password"),className:"w-full px-4 h-11 bg-surface-elevated border border-border-default rounded-xl text-sm text-fg-primary focus:border-brand-500 focus:ring-2 focus:ring-brand-500/20 outline-none transition-all placeholder:text-fg-tertiary",required:!0}),u&&s.jsx("div",{className:"px-3 py-2 bg-red-500/10 border border-red-500/30 rounded-lg text-xs text-red-500",children:u}),!t&&s.jsx("p",{className:"text-[11px] text-fg-tertiary",children:n("login.defaultCredentials")}),s.jsx("button",{type:"submit",disabled:o==="local"||!p||!x,className:"w-full h-11 bg-brand-600 hover:bg-brand-500 disabled:opacity-50 text-white text-sm font-semibold rounded-xl transition-all shadow-md shadow-brand-900/30 hover:shadow-lg active:scale-[0.99]",children:n(o==="local"?"login.signingIn":"login.signIn")})]}),s.jsx("div",{className:"text-center",children:s.jsx("button",{onClick:()=>{h(!1),d("")},className:"text-xs text-fg-tertiary hover:text-fg-secondary transition-colors",children:n("login.backToHub")})})]}):s.jsxs("div",{className:"space-y-3",children:[s.jsxs("button",{onClick:()=>z("google"),disabled:!!o,className:W,children:[s.jsxs("svg",{className:"w-5 h-5",viewBox:"0 0 24 24",children:[s.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"}),s.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"}),s.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"}),s.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"})]}),n(o==="google"?"login.connectingHub":"login.withGoogle")]}),s.jsxs("button",{onClick:()=>z("github"),disabled:!!o,className:W,children:[s.jsx("svg",{className:"w-5 h-5",viewBox:"0 0 24 24",fill:"currentColor",children:s.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"})}),n(o==="github"?"login.connectingHub":"login.withGithub")]}),s.jsxs("button",{onClick:()=>z("email"),disabled:!!o,className:W,children:[s.jsx("svg",{className:"w-5 h-5",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:1.5,children:s.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"})}),n(o==="email"?"login.connectingHub":"login.withEmail")]}),u&&s.jsx("div",{className:"px-3 py-2 bg-red-500/10 border border-red-500/30 rounded-lg text-xs text-red-500",children:u}),s.jsxs("div",{className:"flex items-center gap-3 py-1 text-[11px] text-fg-tertiary",children:[s.jsx("span",{className:"h-px flex-1 bg-border-default"}),n("login.or"),s.jsx("span",{className:"h-px flex-1 bg-border-default"})]}),s.jsx("button",{onClick:()=>{h(!0),d("")},disabled:!!o,className:"w-full h-11 px-4 rounded-xl text-sm text-fg-secondary font-medium transition-all hover:bg-surface-elevated/70 disabled:opacity-50",children:n("login.useLocalAccount")})]})}),s.jsxs("label",{onAnimationEnd:()=>N(!1),className:`mt-5 flex items-start justify-center gap-2 text-[11px] leading-relaxed cursor-pointer select-none px-2 transition-colors ${w?"animate-shake text-fg-primary font-medium":"text-fg-tertiary"}`,children:[s.jsx("input",{type:"checkbox",checked:T,onChange:Z=>{C(Z.target.checked),Z.target.checked&&N(!1)},className:"mt-0.5 h-3.5 w-3.5 shrink-0 accent-brand-600 cursor-pointer"}),s.jsxs("span",{className:"text-center",children:[n("login.consentPrefix")," ",s.jsx("a",{href:j("/terms"),target:"_blank",rel:"noopener noreferrer",className:"text-brand-500 hover:text-brand-400 underline",children:n("login.termsLink")})," ",n("login.consentAnd")," ",s.jsx("a",{href:j("/privacy"),target:"_blank",rel:"noopener noreferrer",className:"text-brand-500 hover:text-brand-400 underline",children:n("login.privacyLink")})]})]})]}),s.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:[s.jsx("a",{href:"https://markus.global",target:"_blank",rel:"noopener noreferrer",className:"hover:text-fg-secondary transition-colors",children:"markus.global"}),s.jsx("a",{href:"mailto:business@markus.global",className:"hover:text-fg-secondary transition-colors",children:n("login.contactSales")})]})]})}function KK({token:e,onComplete:t}){const{t:n}=ft("auth"),[r,o]=k.useState(null),[l,u]=k.useState(""),[d,m]=k.useState(""),[h,p]=k.useState(""),[g,x]=k.useState(!1),[y,w]=k.useState(!1),[N,T]=k.useState(!1);k.useEffect(()=>{Ce.auth.inviteInfo(e).then(j=>o(j)).catch(()=>T(!0))},[e]);const C=async j=>{if(j.preventDefault(),p(""),l.length<6){p(n("invite.passwordMinLength"));return}if(l!==d){p(n("invite.passwordsDoNotMatch"));return}x(!0);try{await Ce.auth.setup(e,l),w(!0),setTimeout(()=>{window.location.hash="",t()},2e3)}catch{p(n("invite.error"))}finally{x(!1)}};return s.jsxs("div",{className:"min-h-dvh bg-surface-primary flex items-center justify-center p-4 relative overflow-hidden",children:[s.jsx("div",{className:"absolute inset-0 bg-[radial-gradient(ellipse_at_top,_var(--tw-gradient-stops))] from-brand-950/50 via-transparent to-transparent"}),s.jsxs("div",{className:"w-full max-w-sm relative z-10",children:[s.jsxs("div",{className:"text-center mb-8",children:[s.jsx("img",{src:"/logo.png",alt:"Markus",className:"w-14 h-14 mx-auto mb-3 rounded-xl shadow-lg shadow-black/40"}),s.jsx("div",{className:"text-2xl font-extrabold tracking-tight text-fg-primary mb-1",children:"Markus"}),s.jsx("div",{className:"text-sm text-fg-tertiary",children:n("invite.subtitle")})]}),s.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?s.jsxs("div",{className:"text-center space-y-3",children:[s.jsx("div",{className:"text-red-500 text-3xl",children:"⚠"}),s.jsx("p",{className:"text-sm text-fg-secondary",children:n("invite.invalidLink")}),s.jsx("button",{onClick:()=>{window.location.hash="",t()},className:"text-sm text-brand-500 hover:text-brand-400",children:n("login.signIn")})]}):y?s.jsxs("div",{className:"text-center space-y-3",children:[s.jsx("div",{className:"text-green-500 text-3xl",children:"✓"}),s.jsx("p",{className:"text-sm text-fg-secondary",children:n("invite.setupComplete")})]}):r?s.jsxs("form",{onSubmit:C,className:"space-y-5",children:[s.jsx("h2",{className:"text-lg font-semibold text-fg-primary text-center",children:n("invite.greeting",{name:r.name})}),s.jsx("p",{className:"text-xs text-fg-tertiary text-center",children:r.email}),s.jsxs("div",{className:"space-y-1",children:[s.jsx("label",{className:"text-xs text-fg-tertiary font-medium",children:n("invite.setPassword")}),s.jsx("input",{type:"password",value:l,onChange:j=>u(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})]}),s.jsxs("div",{className:"space-y-1",children:[s.jsx("label",{className:"text-xs text-fg-tertiary font-medium",children:n("invite.confirmPassword")}),s.jsx("input",{type:"password",value:d,onChange:j=>m(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})]}),h&&s.jsx("div",{className:"px-3 py-2 bg-red-500/10 border border-red-500/30 rounded-lg text-xs text-red-500",children:h}),s.jsx("button",{type:"submit",disabled:g||!l||!d,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:n(g?"invite.settingUp":"invite.setupAccount")})]}):s.jsx("div",{className:"text-center text-fg-tertiary text-sm animate-pulse py-4",children:"Loading…"})})]})]})}function WK({onComplete:e,isFirstTime:t}){const{t:n}=ft("auth"),[r,o]=k.useState(""),[l,u]=k.useState(""),[d,m]=k.useState(""),[h,p]=k.useState(""),[g,x]=k.useState(!1),y=async w=>{if(w.preventDefault(),p(""),l.length<6){p(n("changePassword.passwordMinLength"));return}if(l!==d){p(n("changePassword.passwordsDoNotMatch"));return}x(!0);try{await Ce.auth.changePassword(r,l),e()}catch{p(n("changePassword.failedToChange"))}finally{x(!1)}};return s.jsxs("div",{className:"min-h-dvh bg-surface-primary flex items-center justify-center p-4 relative overflow-hidden",children:[s.jsx("div",{className:"absolute inset-0 bg-[radial-gradient(ellipse_at_top,_var(--tw-gradient-stops))] from-brand-950/50 via-transparent to-transparent"}),s.jsxs("div",{className:"w-full max-w-sm relative z-10",children:[s.jsxs("div",{className:"text-center mb-8",children:[s.jsx("img",{src:"/logo.png",alt:"Markus",className:"w-14 h-14 mx-auto mb-3 rounded-xl shadow-lg shadow-black/40"}),s.jsx("div",{className:"text-2xl font-extrabold tracking-tight text-fg-primary mb-1",children:"Markus"}),s.jsx("div",{className:"text-sm text-fg-tertiary",children:n("login.subtitle")})]}),s.jsxs("form",{onSubmit:y,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:[s.jsxs("div",{children:[s.jsx("h2",{className:"text-lg font-semibold text-fg-primary text-center",children:n(t?"changePassword.setYourPassword":"changePassword.changePassword")}),t&&s.jsx("p",{className:"text-xs text-amber-600/80 text-center mt-2",children:n("changePassword.defaultPasswordWarning")})]}),!t&&s.jsxs("div",{className:"space-y-1",children:[s.jsx("label",{className:"text-xs text-fg-tertiary font-medium",children:n("changePassword.currentPassword")}),s.jsx("input",{type:"password",value:r,onChange:w=>o(w.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"})]}),s.jsxs("div",{className:"space-y-1",children:[s.jsx("label",{className:"text-xs text-fg-tertiary font-medium",children:n("changePassword.newPassword")}),s.jsx("input",{type:"password",value:l,onChange:w=>u(w.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})]}),s.jsxs("div",{className:"space-y-1",children:[s.jsx("label",{className:"text-xs text-fg-tertiary font-medium",children:n("changePassword.confirmNewPassword")}),s.jsx("input",{type:"password",value:d,onChange:w=>m(w.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})]}),h&&s.jsx("div",{className:"px-3 py-2 bg-red-500/10 border border-red-500/30 rounded-lg text-xs text-red-500",children:h}),s.jsx("button",{type:"submit",disabled:g||!l||!d,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:n(g?"changePassword.saving":t?"changePassword.setPasswordAndContinue":"changePassword.changePassword")})]})]})]})}function YK({side:e,defaultWidth:t,minWidth:n,maxWidth:r,collapsedWidth:o=0,storageKey:l}){const[u,d]=k.useState(()=>{try{const N=localStorage.getItem(`${l}_w`);if(N)return Math.max(n,Math.min(r,parseInt(N,10)))}catch{}return t}),[m,h]=k.useState(()=>{try{return localStorage.getItem(`${l}_c`)==="1"}catch{return!1}}),p=k.useRef(!1),g=k.useRef(n),x=k.useRef(r);g.current=n,x.current=r,k.useEffect(()=>{try{localStorage.setItem(`${l}_w`,String(u))}catch{}},[u,l]),k.useEffect(()=>{try{localStorage.setItem(`${l}_c`,m?"1":"0")}catch{}},[m,l]),k.useEffect(()=>{d(N=>Math.max(n,Math.min(r,N)))},[n,r]);const y=k.useCallback(N=>{N.preventDefault(),p.current=!0;const T=N.clientX,C=u,j=O=>{if(!p.current)return;const z=e==="left"?O.clientX-T:T-O.clientX;d(Math.max(g.current,Math.min(x.current,C+z)))},_=()=>{p.current=!1,document.removeEventListener("mousemove",j),document.removeEventListener("mouseup",_),document.body.style.cursor="",document.body.style.userSelect=""};document.addEventListener("mousemove",j),document.addEventListener("mouseup",_),document.body.style.cursor="col-resize",document.body.style.userSelect="none"},[u,e]),w=k.useCallback(()=>h(N=>!N),[]);return{width:m?o:u,rawWidth:u,collapsed:m,toggle:w,setCollapsed:h,setWidth:d,onResizeStart:y}}const RW=[{value:"system",label:"System"},{value:"light",label:"Light"},{value:"dark",label:"Dark"},{value:"cyberpunk",label:"Cyberpunk"},{value:"mono",label:"Mono"}],qp="markus-theme";function C4(e){const t=document.documentElement;t.classList.remove("light","dark","cyberpunk","mono"),e==="light"?t.classList.add("light"):e==="dark"?t.classList.add("dark"):e==="cyberpunk"?t.classList.add("cyberpunk"):e==="mono"&&t.classList.add("mono")}function XK(){try{const e=localStorage.getItem(qp);if(e==="midnight")return localStorage.setItem(qp,"dark"),"dark";if(e==="light"||e==="dark"||e==="system"||e==="cyberpunk"||e==="mono")return e}catch{}return"system"}function QK(){const[e,t]=k.useState(XK),n=k.useCallback(r=>{t(r);try{localStorage.setItem(qp,r)}catch{}C4(r)},[]);return k.useEffect(()=>{C4(e)},[e]),{mode:e,setMode:n}}const Id={agents:[],tasks:[],requirements:[],projects:[],deliverables:[],workflows:[]},ZK={team:["agents","workflows","tasks","requirements","projects","deliverables"],work:["workflows","projects","requirements","tasks","agents","deliverables"],deliverables:["deliverables","agents","tasks","requirements","projects","workflows"]},JK=["agents","tasks","requirements","projects","deliverables","workflows"];let T4="",E4="all",A4=Id,_4=!1;function eW({onClose:e,currentPage:t}){const{t:n}=ft(["common","home","work"]);Bo(!0);const[r,o]=k.useState(T4),[l,u]=k.useState(E4),[d,m]=k.useState(A4),[h,p]=k.useState(!1),[g,x]=k.useState(_4),[y,w]=k.useState(-1);k.useEffect(()=>{T4=r},[r]),k.useEffect(()=>{E4=l},[l]),k.useEffect(()=>{A4=d},[d]),k.useEffect(()=>{_4=g},[g]);const N=k.useRef(null),T=k.useRef(void 0),C=k.useRef(null),j=k.useRef(null);k.useEffect(()=>{setTimeout(()=>{N.current?.focus(),N.current?.select()},100)},[]);const _=k.useCallback(async X=>{if(!X.trim()){m(Id),x(!1),w(-1);return}p(!0),x(!0),w(-1);const F=X.toLowerCase();try{const[J,B,Q,re,we,$]=await Promise.allSettled([Ce.agents.list(),Ce.tasks.list({search:X,pageSize:20}),Ce.requirements.list(),Ce.projects.list(),Ce.deliverables.search({q:X,limit:20}),Ce.teams.list()]),G=J.status==="fulfilled"?J.value.agents.filter(Ke=>Ke.name?.toLowerCase().includes(F)||Ke.role?.toLowerCase().includes(F)):[],ce=B.status==="fulfilled"?B.value.tasks:[],I=Q.status==="fulfilled"?Q.value.requirements.filter(Ke=>Ke.title?.toLowerCase().includes(F)||Ke.description?.toLowerCase().includes(F)):[],Ee=re.status==="fulfilled"?re.value.projects.filter(Ke=>Ke.name?.toLowerCase().includes(F)||Ke.description?.toLowerCase().includes(F)):[],Ue=we.status==="fulfilled"?we.value.results:[],De=[];if($.status==="fulfilled"){const Ke=await Promise.allSettled($.value.teams.map(st=>Ce.workflows.list(st.id)));for(const st of Ke)if(st.status==="fulfilled")for(const mt of st.value.workflows)(mt.name.toLowerCase().includes(F)||(mt.displayName||"").toLowerCase().includes(F)||mt.description?.toLowerCase().includes(F))&&De.push(mt)}m({agents:G,tasks:ce,requirements:I,projects:Ee,deliverables:Ue,workflows:De})}catch{m(Id)}finally{p(!1)}},[]),O=X=>{o(X),T.current&&clearTimeout(T.current),T.current=setTimeout(()=>_(X),400)},z=k.useCallback((X,F)=>{e(),at.navigate(X,F)},[e]),D=[{id:"all",label:n("common:all",{defaultValue:"全部"})},{id:"agents",label:n("common:agents",{defaultValue:"智能体"})},{id:"tasks",label:n("common:tasks",{defaultValue:"任务"})},{id:"requirements",label:n("common:requirements",{defaultValue:"需求"})},{id:"projects",label:n("common:projects",{defaultValue:"项目"})},{id:"deliverables",label:n("common:deliverables",{defaultValue:"交付物"})},{id:"workflows",label:n("common:workflows",{defaultValue:"工作流"})}],H=k.useMemo(()=>ZK[t||""]||JK,[t]),W=k.useMemo(()=>{const X=[],F=l==="all"?8:void 0,J=B=>{if(l!=="all"&&l!==B)return;const Q=d[B].length;if(B==="workflows"){const re=F?d.workflows.slice(0,F):d.workflows;for(const we of re)X.push({id:we.name,type:"workflow",page:me.WORK,params:{boardType:"workflows"}})}else{const re=d[B],we=F?re.slice(0,F):re;for(const $ of we)switch(B){case"agents":X.push({id:$.id,type:"agent",page:me.TEAM,params:{agentId:$.id}});break;case"tasks":X.push({id:$.id,type:"task",page:me.WORK,params:{openTask:$.id}});break;case"requirements":X.push({id:$.id,type:"requirement",page:me.WORK,params:{openRequirement:$.id}});break;case"projects":X.push({id:$.id,type:"project",page:me.WORK,params:{projectId:$.id}});break;case"deliverables":X.push({id:$.id,type:"deliverable",page:me.DELIVERABLES,params:{openDeliverable:$.id}});break}}F&&Q>F&&X.push({id:`more_${B}`,type:"showMore",page:"",expandCategory:B,totalCount:Q})};for(const B of H)J(B);return X},[d,l,H]),Z=k.useCallback(X=>{if(X.type==="showMore"&&X.expandCategory){u(X.expandCategory),w(-1);return}z(X.page,X.params)},[z]);k.useEffect(()=>{const X=j.current;if(!X||y<0)return;const F=X.querySelector(`[data-idx="${y}"]`);F&&F.scrollIntoView({block:"nearest"})},[y]);const U=k.useCallback(X=>{if(X.key==="Escape"){e();return}if(X.key==="Tab"){X.preventDefault();const B=D.map(we=>we.id),Q=B.indexOf(l),re=X.shiftKey?Q<=0?B.length-1:Q-1:Q>=B.length-1?0:Q+1;u(B[re]),w(-1);return}const F=X.ctrlKey&&X.key==="n"||X.key==="ArrowDown",J=X.ctrlKey&&X.key==="p"||X.key==="ArrowUp";if(F||J){X.preventDefault(),w(B=>{const Q=W.length-1;return Q<0?-1:F?B>=Q?0:B+1:B<=0?Q:B-1});return}X.key==="Enter"&&(X.preventDefault(),y>=0&&y<W.length&&Z(W[y]))},[e,W,y,Z,D,l]);k.useEffect(()=>(document.addEventListener("keydown",U),()=>document.removeEventListener("keydown",U)),[U]);const Y=W.length>0;let ae=0;return s.jsx("div",{ref:C,className:"fixed inset-0 bg-black/50 flex items-start justify-center z-50 pt-[8vh]",onClick:X=>{X.target===C.current&&e()},children:s.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:[s.jsxs("div",{className:"shrink-0 px-5 pt-4 pb-3 border-b border-border-default space-y-3",children:[s.jsxs("div",{className:"relative",children:[s.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:[s.jsx("circle",{cx:"11",cy:"11",r:"8"}),s.jsx("line",{x1:"21",y1:"21",x2:"16.65",y2:"16.65"})]}),s.jsx("input",{ref:N,value:r,onChange:X=>O(X.target.value),placeholder:n("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"}),r&&s.jsx("button",{onClick:()=>{o(""),m(Id),x(!1),w(-1),N.current?.focus()},className:"absolute right-3 top-1/2 -translate-y-1/2 text-fg-tertiary hover:text-fg-secondary",children:s.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[s.jsx("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),s.jsx("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]})})]}),s.jsx("div",{className:"flex gap-1 overflow-x-auto scrollbar-hide",children:D.map(X=>s.jsx("button",{onClick:()=>{u(X.id),w(-1)},className:`px-3 py-1.5 text-xs rounded-lg whitespace-nowrap transition-colors ${l===X.id?"bg-brand-600 text-white":"bg-surface-elevated text-fg-secondary hover:text-fg-primary"}`,children:X.label},X.id))})]}),s.jsxs("div",{ref:j,className:"flex-1 overflow-y-auto px-5 py-3",children:[h&&s.jsx("div",{className:"flex items-center justify-center py-8",children:s.jsx("div",{className:"text-fg-tertiary text-sm animate-pulse",children:n("common:loading")})}),!h&&g&&!Y&&s.jsxs("div",{className:"flex flex-col items-center justify-center py-8 text-center",children:[s.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:[s.jsx("circle",{cx:"11",cy:"11",r:"8"}),s.jsx("line",{x1:"21",y1:"21",x2:"16.65",y2:"16.65"})]}),s.jsx("p",{className:"text-sm text-fg-tertiary",children:n("common:noResults",{defaultValue:"没有找到相关结果"})})]}),!h&&Y&&s.jsx("div",{className:"space-y-4",children:H.map(X=>{if(l!=="all"&&l!==X)return null;const F=l==="all"?8:void 0,J=B=>{const Q=ae++,re=B==="agents"?d.agents.length:B==="tasks"?d.tasks.length:B==="requirements"?d.requirements.length:B==="projects"?d.projects.length:B==="workflows"?d.workflows.length:d.deliverables.length;return s.jsxs("button",{"data-idx":Q,onClick:()=>{u(B),w(-1)},className:`mt-1 w-full text-xs py-1.5 rounded-lg transition-colors ${Q===y?"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:[n("common:showAll",{defaultValue:"查看全部"})," (",re,")"]})};return X==="agents"&&d.agents.length>0?s.jsxs("section",{children:[s.jsx("h3",{className:"text-xs font-medium text-fg-tertiary uppercase mb-2",children:n("common:agents",{defaultValue:"智能体"})}),s.jsx("div",{className:"space-y-0.5",children:(F?d.agents.slice(0,F):d.agents).map(B=>{const Q=ae++;return s.jsxs("button",{"data-idx":Q,onClick:()=>z(me.TEAM,{agentId:B.id}),className:`w-full flex items-center gap-3 px-3 py-2 rounded-xl transition-colors text-left ${Q===y?"bg-brand-600/15 ring-1 ring-brand-500/40":"hover:bg-surface-overlay"}`,children:[s.jsx(Us,{name:B.name||"Agent",avatarUrl:B.avatarUrl,size:28}),s.jsxs("div",{className:"flex-1 min-w-0",children:[s.jsx("div",{className:"text-sm font-medium text-fg-primary truncate",children:B.name}),s.jsx("div",{className:"text-xs text-fg-tertiary truncate",children:B.role||B.status})]}),s.jsx(tW,{status:B.status})]},B.id)})}),F&&d.agents.length>F&&J("agents")]},"agents"):X==="tasks"&&d.tasks.length>0?s.jsxs("section",{children:[s.jsx("h3",{className:"text-xs font-medium text-fg-tertiary uppercase mb-2",children:n("common:tasks",{defaultValue:"任务"})}),s.jsx("div",{className:"space-y-0.5",children:(F?d.tasks.slice(0,F):d.tasks).map(B=>{const Q=ae++;return s.jsxs("button",{"data-idx":Q,onClick:()=>z(me.WORK,{openTask:B.id}),className:`w-full flex items-center gap-3 px-3 py-2 rounded-xl transition-colors text-left ${Q===y?"bg-brand-600/15 ring-1 ring-brand-500/40":"hover:bg-surface-overlay"}`,children:[s.jsx(nW,{status:B.status}),s.jsxs("div",{className:"flex-1 min-w-0",children:[s.jsx("div",{className:"text-sm text-fg-primary truncate",children:B.title}),s.jsxs("div",{className:"text-xs text-fg-tertiary truncate",children:[B.status," · ",B.priority||""]})]})]},B.id)})}),F&&d.tasks.length>F&&J("tasks")]},"tasks"):X==="requirements"&&d.requirements.length>0?s.jsxs("section",{children:[s.jsx("h3",{className:"text-xs font-medium text-fg-tertiary uppercase mb-2",children:n("common:requirements",{defaultValue:"需求"})}),s.jsx("div",{className:"space-y-0.5",children:(F?d.requirements.slice(0,F):d.requirements).map(B=>{const Q=ae++;return s.jsxs("button",{"data-idx":Q,onClick:()=>z(me.WORK,{openRequirement:B.id}),className:`w-full flex items-center gap-3 px-3 py-2 rounded-xl transition-colors text-left ${Q===y?"bg-brand-600/15 ring-1 ring-brand-500/40":"hover:bg-surface-overlay"}`,children:[s.jsx("div",{className:`w-7 h-7 rounded-lg flex items-center justify-center shrink-0 ${B.status==="approved"?"text-green-500 bg-green-500/15":B.status==="pending"?"text-amber-500 bg-amber-500/15":B.status==="rejected"?"text-red-500 bg-red-500/15":"text-fg-tertiary bg-surface-elevated"}`,children:s.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[s.jsx("path",{d:"M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z"}),s.jsx("polyline",{points:"14 2 14 8 20 8"}),s.jsx("line",{x1:"16",y1:"13",x2:"8",y2:"13"}),s.jsx("line",{x1:"16",y1:"17",x2:"8",y2:"17"})]})}),s.jsxs("div",{className:"flex-1 min-w-0",children:[s.jsx("div",{className:"text-sm text-fg-primary truncate",children:B.title}),s.jsxs("div",{className:"text-xs text-fg-tertiary truncate",children:[B.status," · ",B.priority||""]})]})]},B.id)})}),F&&d.requirements.length>F&&J("requirements")]},"requirements"):X==="projects"&&d.projects.length>0?s.jsxs("section",{children:[s.jsx("h3",{className:"text-xs font-medium text-fg-tertiary uppercase mb-2",children:n("common:projects",{defaultValue:"项目"})}),s.jsx("div",{className:"space-y-0.5",children:(F?d.projects.slice(0,F):d.projects).map(B=>{const Q=ae++;return s.jsxs("button",{"data-idx":Q,onClick:()=>z(me.WORK,{projectId:B.id}),className:`w-full flex items-center gap-3 px-3 py-2 rounded-xl transition-colors text-left ${Q===y?"bg-brand-600/15 ring-1 ring-brand-500/40":"hover:bg-surface-overlay"}`,children:[s.jsx("div",{className:"w-7 h-7 rounded-lg bg-brand-500/15 flex items-center justify-center shrink-0",children:s.jsx("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",className:"text-brand-500",children:s.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"})})}),s.jsxs("div",{className:"flex-1 min-w-0",children:[s.jsx("div",{className:"text-sm text-fg-primary truncate",children:B.name}),B.description&&s.jsx("div",{className:"text-xs text-fg-tertiary truncate",children:B.description})]})]},B.id)})}),F&&d.projects.length>F&&J("projects")]},"projects"):X==="deliverables"&&d.deliverables.length>0?s.jsxs("section",{children:[s.jsx("h3",{className:"text-xs font-medium text-fg-tertiary uppercase mb-2",children:n("common:deliverables",{defaultValue:"交付物"})}),s.jsx("div",{className:"space-y-0.5",children:(F?d.deliverables.slice(0,F):d.deliverables).map(B=>{const Q=ae++;return s.jsxs("button",{"data-idx":Q,onClick:()=>z(me.DELIVERABLES,{openDeliverable:B.id}),className:`w-full flex items-center gap-3 px-3 py-2 rounded-xl transition-colors text-left ${Q===y?"bg-brand-600/15 ring-1 ring-brand-500/40":"hover:bg-surface-overlay"}`,children:[s.jsx("div",{className:"w-7 h-7 rounded-lg bg-purple-500/15 flex items-center justify-center shrink-0",children:s.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",className:"text-purple-500",children:[s.jsx("path",{d:"M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z"}),s.jsx("polyline",{points:"14 2 14 8 20 8"})]})}),s.jsxs("div",{className:"flex-1 min-w-0",children:[s.jsx("div",{className:"text-sm text-fg-primary truncate",children:B.title}),s.jsxs("div",{className:"text-xs text-fg-tertiary truncate",children:[B.type," · ",B.status]})]})]},B.id)})}),F&&d.deliverables.length>F&&J("deliverables")]},"deliverables"):X==="workflows"&&d.workflows.length>0?s.jsxs("section",{children:[s.jsx("h3",{className:"text-xs font-medium text-fg-tertiary uppercase mb-2",children:n("common:workflows",{defaultValue:"工作流"})}),s.jsx("div",{className:"space-y-0.5",children:(F?d.workflows.slice(0,F):d.workflows).map(B=>{const Q=ae++;return s.jsxs("button",{"data-idx":Q,onClick:()=>z(me.WORK,{boardType:"workflows"}),className:`w-full flex items-center gap-3 px-3 py-2 rounded-xl transition-colors text-left ${Q===y?"bg-brand-600/15 ring-1 ring-brand-500/40":"hover:bg-surface-overlay"}`,children:[s.jsx("div",{className:"w-7 h-7 rounded-lg bg-teal-500/15 flex items-center justify-center shrink-0",children:s.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",className:"text-teal-500",children:[s.jsx("circle",{cx:"12",cy:"12",r:"3"}),s.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"})]})}),s.jsxs("div",{className:"flex-1 min-w-0",children:[s.jsx("div",{className:"text-sm text-fg-primary truncate",children:B.displayName||B.name}),s.jsxs("div",{className:"text-xs text-fg-tertiary truncate",children:[B.stepCount," steps · v",B.version]})]})]},B.name)})}),F&&d.workflows.length>F&&J("workflows")]},"workflows"):null})}),!h&&!g&&s.jsxs("div",{className:"flex flex-col items-center justify-center py-8 text-center",children:[s.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:[s.jsx("circle",{cx:"11",cy:"11",r:"8"}),s.jsx("line",{x1:"21",y1:"21",x2:"16.65",y2:"16.65"})]}),s.jsx("p",{className:"text-sm text-fg-tertiary",children:n("common:searchHint",{defaultValue:"输入关键词搜索"})})]})]}),s.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:[s.jsxs("span",{children:[s.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"})," ",n("common:toggle",{defaultValue:"唤起/关闭"})]}),s.jsxs("span",{children:[s.jsx("kbd",{className:"px-1.5 py-0.5 rounded bg-surface-elevated border border-border-default text-[11px] font-medium",children:"Tab"})," ",n("common:switchTab",{defaultValue:"切换分类"})]}),s.jsxs("span",{children:[s.jsx("kbd",{className:"px-1.5 py-0.5 rounded bg-surface-elevated border border-border-default text-[11px] font-medium",children:"↑↓"})," ",n("common:navigate",{defaultValue:"导航"})]}),s.jsxs("span",{children:[s.jsx("kbd",{className:"px-1.5 py-0.5 rounded bg-surface-elevated border border-border-default text-[11px] font-medium",children:"Enter"})," ",n("common:open",{defaultValue:"打开"})]}),s.jsxs("span",{children:[s.jsx("kbd",{className:"px-1.5 py-0.5 rounded bg-surface-elevated border border-border-default text-[11px] font-medium",children:"Esc"})," ",n("common:close",{defaultValue:"关闭"})]})]})]})})}function tW({status:e}){const t=e==="active"||e==="idle"?"bg-green-500":e==="working"||e==="busy"?"bg-blue-500":"bg-gray-400";return s.jsx("span",{className:`w-2 h-2 rounded-full shrink-0 ${t}`})}function nW({status:e}){const t=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 s.jsx("div",{className:`w-7 h-7 rounded-lg flex items-center justify-center shrink-0 ${t}`,children:s.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[s.jsx("path",{d:"M9 11l3 3L22 4"}),s.jsx("path",{d:"M21 12v7a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h11"})]})})}function rW({authUser:e,onClose:t,onSaved:n,onUserUpdated:r}){const{t:o}=ft("common");Bo(!0);const[l,u]=k.useState(e.name||""),[d,m]=k.useState(e.email||""),[h,p]=k.useState(!1),[g,x]=k.useState(""),[y,w]=k.useState(()=>n5(e.avatarUrl,ua()?.avatarUrl)),N=async T=>{if(T.preventDefault(),!l.trim()){x(o("profile.nameRequired"));return}if(d&&!/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(d.trim())){x(o("profile.invalidEmail"));return}p(!0),x("");try{const{user:C}=await Ce.auth.updateProfile(l.trim(),d.trim());n({...C,avatarUrl:y??C.avatarUrl})}catch{x(o("profile.failedToSave"))}finally{p(!1)}};return s.jsx("div",{className:"fixed inset-0 bg-black/60 flex items-center justify-center z-[10000]",onClick:t,children:s.jsxs("form",{onSubmit:N,className:"bg-surface-secondary border border-border-default rounded-xl p-6 w-[400px] max-w-[calc(100vw-2rem)] shadow-2xl",onClick:T=>T.stopPropagation(),children:[s.jsx("h3",{className:"text-base font-semibold mb-5",children:o("profile.editProfile")}),s.jsx("div",{className:"flex justify-center mb-5",children:s.jsx(a5,{currentUrl:y,name:l,size:72,targetType:"user",targetId:e.id,onUploaded:T=>{w(T),r?.({...e,avatarUrl:T})}})}),s.jsxs("div",{className:"space-y-3",children:[s.jsxs("div",{children:[s.jsx("label",{className:"block text-xs text-fg-tertiary font-medium mb-1",children:o("profile.name")}),s.jsx("input",{value:l,onChange:T=>u(T.target.value),className:"w-full px-3 py-2 bg-surface-elevated border border-border-default rounded-lg text-sm text-fg-primary focus:border-brand-500 outline-none"})]}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-xs text-fg-tertiary font-medium mb-1",children:o("profile.email")}),s.jsx("input",{value:d,onChange:T=>m(T.target.value),type:"email",className:"w-full px-3 py-2 bg-surface-elevated border border-border-default rounded-lg text-sm text-fg-primary focus:border-brand-500 outline-none"})]}),g&&s.jsx("div",{className:"text-xs text-red-500 bg-red-500/10 border border-red-500/30 rounded-lg px-3 py-2",children:g})]}),s.jsxs("div",{className:"flex justify-end gap-3 mt-5",children:[s.jsx("button",{type:"button",onClick:t,className:"px-4 py-2 text-sm border border-border-default rounded-lg hover:bg-surface-elevated",children:o("cancel")}),s.jsx("button",{type:"submit",disabled:h,className:"px-4 py-2 text-sm bg-brand-600 hover:bg-brand-500 disabled:opacity-50 text-white rounded-lg",children:o(h?"saving":"save")})]})]})})}const j4=k.lazy(()=>qr(()=>import("./Team-DwZHZVWj.js"),__vite__mapDeps([2,3,4,5])).then(e=>({default:e.TeamPage}))),M4=k.lazy(()=>qr(()=>import("./Settings-W8E04XTX.js"),[]).then(e=>({default:e.Settings}))),aW=k.lazy(()=>qr(()=>import("./Store-BaUTI4Mp.js"),[]).then(e=>({default:e.StorePage}))),sW=k.lazy(()=>qr(()=>Promise.resolve().then(()=>vK),void 0).then(e=>({default:e.AgentBuilder}))),R4=k.lazy(()=>qr(()=>import("./Work-DEC8BWR6.js"),__vite__mapDeps([6,4,1,7,3,8])).then(e=>({default:e.WorkPage}))),O4=k.lazy(()=>qr(()=>import("./Deliverables-C12uk40-.js"),__vite__mapDeps([9,4,5])).then(e=>({default:e.DeliverablesPage}))),iW=k.lazy(()=>qr(()=>import("./Notifications-DMCefB8x.js"),[]).then(e=>({default:e.NotificationsPage}))),oW=k.lazy(()=>qr(()=>import("./Search-BPvYYWNf.js"),[]).then(e=>({default:e.SearchPage}))),lW={visibility:"hidden",position:"absolute",inset:0,pointerEvents:"none",zIndex:-1};function cW(e){try{const t=navigator.language,n=Intl.DateTimeFormat().resolvedOptions().timeZone,r=e.preferences??{};if(r.locale===t&&r.timezone===n)return;Ce.auth.updatePreferences({locale:t,timezone:n}).catch(()=>{})}catch{}}function uW(){return s.jsx("div",{className:"flex-1 flex items-center justify-center text-fg-tertiary text-sm animate-pulse",children:"Loading..."})}const dW=k.memo(function({id:t,activePage:n,children:r}){const o=t===n;return s.jsx("div",{className:"flex-1 overflow-hidden flex flex-col",style:o?void 0:lW,children:s.jsx(k.Suspense,{fallback:s.jsx(uW,{}),children:r})})},(e,t)=>{const n=e.id===e.activePage,r=t.id===t.activePage;return n!==r?!1:r?e.children===t.children:!0}),Nd={};function E3(e){return typeof window<"u"&&window.matchMedia("(max-width: 767px)").matches?Y4[e]??e:e}function D4(){return E3(_o())}function mW(){const{t:e}=ft("common"),[t,n]=k.useState(D4),[r,o]=k.useState(()=>!localStorage.getItem("markus_onboarded")),[l,u]=k.useState(!0),d=Uo(),m=QK(),h=YK({side:"left",defaultWidth:160,minWidth:140,maxWidth:400,collapsedWidth:64,storageKey:"markus_sidebar"}),[p,g]=k.useState(()=>new Set([D4()])),[x,y]=k.useState("loading"),[w,N]=k.useState(!1),[T,C]=k.useState(null),[j,_]=k.useState({hasOwner:!1,hasMultipleUsers:!1}),[O,z]=k.useState(!1),[D,H]=k.useState(!1),[W,Z]=k.useState(null),[U,Y]=k.useState(!1),[ae,X]=k.useState(null),[F,J]=k.useState(()=>{const Me=localStorage.getItem("markus_update_dismissed");return Me||null}),[B,Q]=k.useState(!1),re=z0(),we=re?.leftCollapsed??!1,$=re?.toggleLeftCollapsed,G=re?.toggleRightPanel,ce=re?.openRightPanel,I=re?.closeRightPanelTab,Ee=re?.updateRightPanelBrowserTab,Ue=k.useRef(re?.rightPanelTabs);Ue.current=re?.rightPanelTabs,k.useEffect(()=>{const Me=window.markusDesktop?.browser?.onPageEvent;if(!(!Me||!ce))return Me(Ne=>{if(Ne.type==="closed"){const Re=Ue.current?.find(ut=>ut.payload.kind==="url"&&ut.payload.browserId===Ne.browserId);Re&&I&&I(Re.id);return}if(Ne.type==="navigated"){Ne.browserId&&Ee&&Ee(Ne.browserId,{url:Ne.url,title:Ne.title||Ne.url});return}if(Ne.type==="opened"||Ne.type==="selected"){if(!Ne.url&&!Ne.browserId||Ne.browserId.startsWith("eb_")&&Ne.type==="opened")return;ce({kind:"url",url:Ne.url||"about:blank",title:Ne.title||Ne.url||"Browser",browserId:Ne.browserId,pageId:Ne.pageId})}})},[ce,I,Ee]);const De=re?.rightPanelOpen??!1;k.useLayoutEffect(()=>{const Me=t===me.TEAM&&De;Jf(Me)},[t,De]),k.useEffect(()=>{window.markusDesktop?.browser?.hideAll?.()},[]);const Ke=k.useRef(!1);k.useEffect(()=>{if(!Ke.current){Ke.current=!0;return}h.setCollapsed(we)},[we,h.setCollapsed]),k.useEffect(()=>{if(d)return;const Me=navigator.platform.toUpperCase().includes("MAC"),Ne=ut=>{Me&&ut.metaKey&&!ut.ctrlKey&&ut.key==="p"?(ut.preventDefault(),Q(it=>!it)):!Me&&ut.ctrlKey&&!ut.metaKey&&ut.key==="p"&&(ut.preventDefault(),Q(it=>!it))},Re=()=>Q(!0);return document.addEventListener("keydown",Ne),window.addEventListener("markus:open-search",Re),()=>{document.removeEventListener("keydown",Ne),window.removeEventListener("markus:open-search",Re)}},[d]),k.useEffect(()=>{if(d||!$||!G)return;const Me=navigator.platform.toUpperCase().includes("MAC"),Ne=Re=>{if(!(Me?Re.metaKey&&!Re.ctrlKey:Re.ctrlKey&&!Re.metaKey)||Re.altKey||Re.shiftKey)return;const it=Re.key.toLowerCase();it==="b"?(Re.preventDefault(),$()):it==="l"&&(Re.preventDefault(),G())};return document.addEventListener("keydown",Ne),()=>document.removeEventListener("keydown",Ne)},[d,$,G]);const st=k.useCallback((Me,Ne)=>{let Re=lc(Me);d?Re=Y4[Re]??Re:Re===me.NOTIFICATIONS&&(Re=me.HOME),Re!==me.TEAM&&Jf(!1);const ut=_o(),it=window.location.hash.slice(1);if(it!==ap(ut)?Nd[ut]=it:delete Nd[ut],Re===me.SETTINGS&&Ne?.tab){const se=`settings/${Ne.tab}`;Nd[Re]=se,history.pushState(null,"","#"+se),window.dispatchEvent(new HashChangeEvent("hashchange")),n(Re),g(et=>et.has(Re)?et:new Set([...et,Re]));return}const bt=Re!==me.WORK?Nd[Re]:void 0;bt&&bt!==ap(Re)?(history.pushState(null,"",Si(Re)),history.pushState(null,"","#"+bt)):history.pushState(null,"",Si(Re)),window.dispatchEvent(new HashChangeEvent("hashchange")),n(Re),g(se=>se.has(Re)?se:new Set([...se,Re]))},[d]);k.useEffect(()=>{at.setHandler((Me,Ne)=>st(Me,Ne))},[st]),k.useEffect(()=>{const Me=()=>N(!0);return window.addEventListener("markus:open-edit-profile",Me),()=>window.removeEventListener("markus:open-edit-profile",Me)},[]),k.useEffect(()=>{if(!window.markusDesktop)return;!d&&t!==me.SETTINGS&&!h.collapsed?window.markusDesktop.setTrafficLightPosition(16,16):window.markusDesktop.setTrafficLightPosition(6,16)},[h.collapsed,t,d]),k.useEffect(()=>{window.markusDesktop&&window.markusDesktop.onNotificationClick(Me=>{if(Me.openNotifications&&window.dispatchEvent(new CustomEvent("markus:open-notifications")),Me.page){const Ne=lc(Me.page);Me.params&&Object.entries(Me.params).forEach(([Re,ut])=>localStorage.setItem(`markus_nav_${Re}`,ut)),st(Ne),window.dispatchEvent(new CustomEvent("markus:navigate",{detail:{page:Ne,params:Me.params}}))}})},[st]);const mt=k.useCallback(()=>{fetch("/api/settings/llm").then(Me=>Me.ok?Me.json():null).then(Me=>{if(Me?.providers){const Ne=Object.values(Me.providers).some(Re=>Re.configured);Z(Ne)}}).catch(()=>{})},[]);k.useEffect(()=>{const Me=new URLSearchParams(window.location.search),Ne=Me.get("install");if(Ne&&_o()!==me.STORE){const it=Me.get("type"),se=it&&{agent:"agents",team:"teams",skill:"skills"}[it]||"agents";localStorage.setItem("markus_nav_installItem",Ne),localStorage.setItem("markus_nav_storeTab",se),Me.delete("install"),Me.delete("type");const et=Me.toString();window.history.replaceState(null,"",window.location.pathname+(et?`?${et}`:"")+Si(me.STORE)),setTimeout(()=>at.navigate(me.STORE,{storeTab:se,installItem:Ne}),300)}Ce.auth.me().then(({user:it})=>{y(it),C(!0),cW(it),va.connect(it.id),mt(),Ce.health().then(se=>{se.updateAvailable&&se.latestVersion&&X({latestVersion:se.latestVersion,currentVersion:se.version})}).catch(()=>{});const bt=()=>{pi(Tr.builderArtifacts,()=>Ce.builder.artifacts.list()),pi(Tr.builderAgents,()=>Ce.agents.list()),pi(Tr.builderHubMyItems,()=>lt.myItems()),pi(Tr.builderInstalled,()=>Ce.builder.artifacts.installed()),pi(Tr.hubAgents,()=>lt.search({type:"agent",limit:50})),pi(Tr.hubTeams,()=>lt.search({type:"team",limit:50})),pi(Tr.hubSkills,()=>lt.search({type:"skill",limit:50}))};typeof requestIdleCallback=="function"?requestIdleCallback(bt,{timeout:5e3}):setTimeout(bt,3e3)}).catch(()=>{y(null),Ce.auth.status().then(({initialized:it,hasOwner:bt,hasMultipleUsers:se})=>{C(it),_({hasOwner:bt,hasMultipleUsers:se})}).catch(()=>C(!0))}),va.connect();const Re=va.on("notification",()=>{window.dispatchEvent(new CustomEvent("markus:notifications-changed"))}),ut=()=>{const it=E3(_o());it!==me.TEAM&&Jf(!1),n(it),g(bt=>bt.has(it)?bt:new Set([...bt,it]))};return window.addEventListener("hashchange",ut),window.addEventListener("popstate",ut),()=>{Re(),va.disconnect(),window.removeEventListener("hashchange",ut),window.removeEventListener("popstate",ut)}},[]);const ct=x!=="loading"&&x!==null?x:void 0,Dt=k.useMemo(()=>d?{[me.HOME]:s.jsx(Vy,{authUser:ct}),[me.TEAM]:s.jsx(j4,{authUser:ct}),[me.BUILDER]:s.jsx(HK,{authUser:ct}),[me.SETTINGS]:s.jsx(M4,{theme:m.mode,onThemeChange:m.setMode,authUser:ct,onLogout:()=>{Ce.auth.logout().catch(()=>{}),Ni(),y(null)},onUserUpdated:Me=>y(Me)}),[me.WORK]:s.jsx(R4,{authUser:ct}),[me.DELIVERABLES]:s.jsx(O4,{authUser:ct}),[me.NOTIFICATIONS]:s.jsx(iW,{authUser:ct}),[me.SEARCH]:s.jsx(oW,{})}:{[me.HOME]:s.jsx(Vy,{authUser:ct}),[me.TEAM]:s.jsx(j4,{authUser:ct}),[me.SETTINGS]:s.jsx(M4,{theme:m.mode,onThemeChange:m.setMode,authUser:ct,onLogout:()=>{Ce.auth.logout().catch(()=>{}),Ni(),y(null)},onUserUpdated:Me=>y(Me)}),[me.STORE]:s.jsx(aW,{authUser:ct}),[me.BUILDER]:s.jsx(sW,{authUser:ct}),[me.WORK]:s.jsx(R4,{authUser:ct}),[me.DELIVERABLES]:s.jsx(O4,{authUser:ct})},[ct?.id,ct?.role,m.mode,d]);if(x==="loading"||x===null&&T===null)return s.jsx("div",{className:"min-h-dvh bg-surface-primary flex items-center justify-center",children:s.jsx("div",{className:"text-fg-tertiary text-sm animate-pulse",children:e("loading")})});const Xt=(typeof window<"u"?window.location.hash:"").match(/^#invite\?token=([a-f0-9]+)/);return Xt?s.jsx(KK,{token:Xt[1],onComplete:()=>{window.location.hash="",localStorage.removeItem("markus_onboarded"),o(!0),z(!0),y("loading"),Ce.auth.me().then(Me=>y(Me.user)).catch(()=>y(null))}}):x===null?s.jsx(VK,{hasOwner:j.hasOwner,hasMultipleUsers:j.hasMultipleUsers,onLogin:(Me,Ne,Re)=>{y(Me),va.connect(Me.id),Ne?(localStorage.removeItem("markus_onboarded"),o(!0),Re?.fromHub&&z(!0)):localStorage.getItem("markus_onboarded")||(localStorage.setItem("markus_onboarded","1"),o(!1))}}):D?s.jsx(WK,{onComplete:()=>H(!1),isFirstTime:!0}):r?s.jsx(FK,{theme:m.mode,onThemeChange:m.setMode,skipProfile:O,onProfileUpdated:Me=>{const Ne={id:Me.id,name:Me.name,email:Me.email,role:Me.role,orgId:Me.orgId??"default",avatarUrl:Me.avatarUrl};y(Ne)},onComplete:()=>{localStorage.setItem("markus_onboarded","1"),o(!1),z(!1),Ce.auth.me().then(Me=>y(Me.user)).catch(()=>{}),mt(),st(me.HOME)}}):s.jsxs("div",{className:`flex h-dvh bg-surface-primary text-fg-primary overflow-x-hidden ${d?"flex-col":""}`,children:[!d&&t!==me.SETTINGS&&s.jsxs(s.Fragment,{children:[s.jsx("div",{className:"relative z-40 shrink-0",style:{width:h.width},children:s.jsx(KV,{currentPage:t,onNavigate:Me=>{st(Me),u(!1)},authUser:x,collapsed:h.collapsed,onToggleCollapse:h.toggle,onLogout:()=>{Ce.auth.logout().catch(()=>{}),Ni(),y(null)}})}),s.jsx("div",{className:`${h.collapsed?"w-0":"w-1.5 cursor-col-resize"} shrink-0 group relative z-10 flex items-center justify-center`,onMouseDown:h.collapsed?void 0:h.onResizeStart,children:!h.collapsed&&s.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"})})]}),s.jsxs("div",{className:`flex-1 overflow-hidden flex flex-col min-w-0 ${d&&t!==me.SETTINGS&&t!==me.SEARCH?"pb-14":""}`,children:[W===!1&&!U&&t!==me.SETTINGS&&s.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:[s.jsx("span",{className:d?"text-xs":"",children:e("llmBanner.message")}),s.jsxs("div",{className:"flex items-center gap-3",children:[s.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")}),s.jsx("button",{onClick:()=>Y(!0),className:"text-amber-500 hover:text-amber-600 text-xs",children:e("dismiss")})]})]}),ae&&F!==ae.latestVersion&&s.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:[s.jsx("span",{className:d?"text-xs":"",children:e("update.available",{latest:ae.latestVersion,current:ae.currentVersion})}),s.jsxs("span",{className:"flex items-center gap-3 shrink-0",children:[s.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")}),s.jsx("button",{onClick:()=>{J(ae.latestVersion),localStorage.setItem("markus_update_dismissed",ae.latestVersion)},className:"text-fg-tertiary hover:text-fg-secondary text-xs shrink-0",children:e("dismiss")})]})]}),s.jsx("main",{className:"flex-1 overflow-hidden flex flex-col relative",children:Object.keys(Dt).map(Me=>p.has(Me)?s.jsx(dW,{id:Me,activePage:t,children:Dt[Me]},Me):null)})]}),d&&t!==me.SETTINGS&&t!==me.SEARCH&&s.jsx(ZV,{currentPage:t,onNavigate:st,userId:ct?.id}),d&&s.jsx(nD,{authUser:ct,onNavigate:st}),!d&&B&&s.jsx(eW,{onClose:()=>Q(!1),currentPage:t}),w&&ct&&s.jsx(rW,{authUser:ct,onClose:()=>N(!1),onUserUpdated:Me=>y(Me),onSaved:Me=>{N(!1),y(Me)}})]})}zS.createRoot(document.getElementById("root")).render(s.jsx(k.StrictMode,{children:s.jsx(Yq,{children:s.jsx(mW,{})})}));export{HV as $,Us as A,xW as B,dr as C,$G as D,IV as E,SW as F,zV as G,bW as H,LK as I,Ci as J,Ko as K,z0 as L,s5 as M,qV as N,QV as O,me as P,MW as Q,wW as R,OK as S,SK as T,Wa as U,CW as V,WG as W,NW as X,_W as Y,TW as Z,qr as _,Uo as a,BV as a0,EW as a1,p0 as a2,R7 as a3,fW as a4,Bo as a5,Si as a6,GO as a7,l3 as a8,kW as a9,X2 as aa,i4 as ab,AV as ac,EV as ad,Gd as ae,RW as af,hW as ag,ua as ah,yn as ai,na as aj,vW as ak,i3 as al,zK as b,TK as c,jK as d,Ja as e,Ce as f,AW as g,jW as h,Ar as i,s as j,tD as k,YK as l,lc as m,at as n,jg as o,xc as p,j7 as q,k as r,pW as s,gW as t,ft as u,qd as v,va as w,lt as x,$2 as y,HG as z};
666
+ prose-blockquote:border-brand-500/40 prose-blockquote:text-fg-secondary`,children:s.jsx(bp,{remarkPlugins:[xw,vk],rehypePlugins:[[Vk,{detect:!0,ignoreMissing:!0}]],children:e})})}function Wh({filename:e,content:t,onSave:n,embedded:r,readOnly:o}){const{t:l}=ft(["builder","common"]),[u,d]=k.useState(!1),[m,h]=k.useState(t),[p,g]=k.useState(!1),x=/\.(md|mdx|markdown)$/i.test(e),y=k.useRef(null);k.useEffect(()=>{h(t)},[t]),k.useEffect(()=>{if(u&&y.current){const T=y.current;T.style.height="auto",T.style.height=Math.max(200,T.scrollHeight)+"px"}},[u,m]);const w=async()=>{g(!0),await n(m),g(!1),d(!1)},N=o?null:s.jsx("div",{className:"flex items-center gap-2",children:u?s.jsxs(s.Fragment,{children:[s.jsx("button",{onClick:()=>{h(t),d(!1)},className:"text-[10px] px-2.5 py-1 rounded-md text-fg-tertiary hover:text-fg-secondary border border-border-default transition-colors",children:l("common:cancel")}),s.jsx("button",{onClick:w,disabled:p,className:"text-[10px] px-2.5 py-1 rounded-md bg-brand-600 hover:bg-brand-500 text-white transition-colors disabled:opacity-50",children:l(p?"common:saving":"common:save")})]}):s.jsxs("button",{onClick:()=>d(!0),className:"text-[10px] px-2.5 py-1 rounded-md text-fg-tertiary hover:text-fg-secondary border border-border-default transition-colors inline-flex items-center gap-1",children:[s.jsxs("svg",{className:"w-3 h-3",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[s.jsx("path",{d:"M11 4H4a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2v-7"}),s.jsx("path",{d:"M18.5 2.5a2.121 2.121 0 0 1 3 3L12 15l-4 1 1-4 9.5-9.5z"})]}),l("detail.edit")]})});return r?s.jsxs("div",{children:[s.jsx("div",{className:"flex items-center justify-end px-4 py-2 border-b border-border-default bg-surface-elevated/20",children:N}),u?s.jsx("textarea",{ref:y,value:m,onChange:T=>h(T.target.value),className:"w-full bg-surface-elevated/20 text-sm text-fg-primary font-mono p-4 focus:outline-none resize-y min-h-[200px] leading-relaxed",spellCheck:!1}):s.jsx("div",{className:"p-4",children:x?s.jsx(Fp,{content:t}):s.jsx("pre",{className:"text-xs leading-relaxed text-fg-secondary whitespace-pre-wrap font-mono",children:t})})]}):s.jsxs("div",{className:"rounded-xl border border-border-default bg-surface-secondary/40 overflow-hidden",children:[s.jsxs("div",{className:"flex items-center justify-between px-4 py-2.5 border-b border-border-default bg-surface-elevated/30",children:[s.jsx("span",{className:"text-xs font-medium text-fg-secondary font-mono",children:e}),N]}),u?s.jsx("textarea",{ref:y,value:m,onChange:T=>h(T.target.value),className:"w-full bg-surface-elevated/20 text-sm text-fg-primary font-mono p-4 focus:outline-none resize-y min-h-[200px] leading-relaxed",spellCheck:!1}):s.jsx("div",{className:"p-4",children:x?s.jsx(Fp,{content:t}):s.jsx("pre",{className:"text-xs leading-relaxed text-fg-secondary whitespace-pre-wrap font-mono",children:t})})]})}const p4={"README.md":0,"ROLE.md":1,"HEARTBEAT.md":2,"POLICIES.md":3,"CONTEXT.md":4,"ANNOUNCEMENT.md":0,"NORMS.md":1};function oK(e){return[...e].sort(([t],[n])=>{const r=p4[t]??99,o=p4[n]??99;return r!==o?r-o:t.localeCompare(n)})}function d0({files:e,onSave:t,noHeader:n,readOnly:r}){const o=k.useMemo(()=>oK(e),[e]),[l,u]=k.useState(0);if(o.length===1)return n?s.jsx(Wh,{filename:o[0][0],content:o[0][1],onSave:p=>t(o[0][0],p),readOnly:r}):s.jsxs("div",{className:"mb-8",children:[s.jsx("h2",{className:"text-sm font-semibold text-fg-primary mb-4 uppercase tracking-wider",children:"Files"}),s.jsx(Wh,{filename:o[0][0],content:o[0][1],onSave:p=>t(o[0][0],p),readOnly:r})]});const[d,m]=o[l]??o[0],h=s.jsxs("div",{className:"rounded-xl border border-border-default bg-surface-secondary/40 overflow-hidden",children:[s.jsx("div",{className:"flex items-center gap-0 overflow-x-auto bg-surface-elevated/30",children:o.map(([p],g)=>s.jsx("button",{onClick:()=>u(g),className:`px-4 py-2.5 text-xs font-medium whitespace-nowrap border-b-2 transition-colors ${g===l?"border-brand-500 text-brand-400 bg-surface-secondary/50":"border-transparent text-fg-tertiary hover:text-fg-secondary hover:bg-surface-elevated/50"}`,children:p},p))}),s.jsx(Wh,{filename:d,content:m,onSave:p=>t(d,p),embedded:!0,readOnly:r},d)]});return n?h:s.jsxs("div",{className:"mb-8",children:[s.jsx("h2",{className:"text-sm font-semibold text-fg-primary mb-4 uppercase tracking-wider",children:"Files"}),h]})}function lK({images:e,artifactType:t,artifactName:n,onUpload:r,onRemove:o,readOnly:l}){const{t:u}=ft(["builder"]),d=k.useRef(null);return e.length===0?l?null:s.jsxs("div",{className:"border-2 border-dashed border-border-default rounded-xl p-6 text-center text-fg-muted text-sm cursor-pointer hover:border-brand-500/30 transition-colors",onClick:()=>d.current?.click(),onDragOver:m=>m.preventDefault(),onDrop:m=>{m.preventDefault();const h=m.dataTransfer.files[0];h?.type.startsWith("image/")&&r(h)},children:[s.jsxs("svg",{className:"w-8 h-8 mx-auto mb-2 text-fg-muted/50",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round",children:[s.jsx("rect",{x:"3",y:"3",width:"18",height:"18",rx:"2"}),s.jsx("circle",{cx:"8.5",cy:"8.5",r:"1.5"}),s.jsx("polyline",{points:"21 15 16 10 5 21"})]}),s.jsx("span",{className:"block",children:u("images.dropOrClick")}),s.jsx("span",{className:"block text-xs text-fg-muted/60 mt-1",children:u("images.hint")}),s.jsx("input",{ref:d,type:"file",accept:"image/*",className:"hidden",onChange:m=>{const h=m.target.files?.[0];h&&r(h),m.target.value=""}})]}):s.jsxs("div",{children:[s.jsxs("div",{className:"flex gap-3 overflow-x-auto pb-2",children:[e.map(m=>{const h=m.split("/").pop()??m;return s.jsxs("div",{className:"relative group shrink-0 rounded-lg border border-border-default overflow-hidden bg-surface-elevated",children:[s.jsx("img",{src:`/api/builder/artifacts/${t}s/${encodeURIComponent(n)}/images/${encodeURIComponent(h)}`,alt:h,className:"h-32 w-auto object-cover"}),!l&&s.jsx("button",{onClick:()=>o(h),className:"absolute top-1.5 right-1.5 w-5 h-5 rounded-full bg-red-600/80 text-white flex items-center justify-center text-[10px] opacity-0 group-hover:opacity-100 transition-opacity",children:"×"})]},m)}),!l&&s.jsx("button",{onClick:()=>d.current?.click(),className:"shrink-0 h-32 w-24 rounded-lg border-2 border-dashed border-border-default flex items-center justify-center text-fg-muted hover:border-brand-500/30 hover:text-brand-400 transition-colors",children:s.jsxs("svg",{className:"w-6 h-6",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[s.jsx("line",{x1:"12",y1:"5",x2:"12",y2:"19"}),s.jsx("line",{x1:"5",y1:"12",x2:"19",y2:"12"})]})})]}),!l&&s.jsx("input",{ref:d,type:"file",accept:"image/*",className:"hidden",onChange:m=>{const h=m.target.files?.[0];h&&r(h),m.target.value=""}})]})}function cK({members:e,teamTopFiles:t,files:n,onFileSave:r,readOnly:o}){const{t:l}=ft(["builder"]),[u,d]=k.useState(0),m=k.useMemo(()=>{const N=new Set;for(const T of Object.keys(n)){const C=T.match(/^members\/([^/]+)\//);C&&N.add(C[1])}return[...N]},[n]),h=k.useMemo(()=>{const N=new Map,T=new Set;for(let _=0;_<e.length;_++){const O=qd(e[_].name);m.includes(O)&&!T.has(O)&&(N.set(_,O),T.add(O))}for(let _=0;_<e.length;_++){if(N.has(_))continue;const O=e[_].roleName;if(O){const z=qd(O);m.includes(z)&&!T.has(z)&&(N.set(_,z),T.add(z))}}for(let _=0;_<e.length;_++){if(N.has(_))continue;const O=e[_].name;for(const z of m){if(T.has(z))continue;const D=n[`members/${z}/ROLE.md`];if(!D)continue;const H=D.match(/^#\s+(.+)$/m)?.[1]?.trim();if(H&&(H.toLowerCase().includes(O.toLowerCase())||O.toLowerCase().includes(H.toLowerCase()))){N.set(_,z),T.add(z);break}}}const C=m.filter(_=>!T.has(_));let j=0;for(let _=0;_<e.length;_++)N.has(_)||j<C.length&&(N.set(_,C[j]),j++);return N},[e,m,n]),p=k.useCallback((N,T)=>{const C=h.get(T);return C?Object.entries(n).filter(([j])=>j.startsWith(`members/${C}/`)):[]},[n,h]),g=k.useMemo(()=>{const N=[{label:l("detail.overview")}];for(const T of e)N.push({label:T.name,role:T.role});return N},[e,l]),x=u>0?e[u-1]:null,y=u-1;return s.jsxs("div",{className:"rounded-xl border border-border-default bg-surface-secondary/40 overflow-hidden",children:[s.jsx("div",{className:"flex items-center gap-0 overflow-x-auto bg-surface-elevated/30 border-b border-border-default",children:g.map((N,T)=>{const C=T===u,j=N.role==="manager",_=T===0?C?"border-brand-500 text-brand-400":"border-transparent text-fg-tertiary hover:text-fg-secondary":j?C?"border-amber-500 text-amber-400":"border-transparent text-fg-tertiary hover:text-fg-secondary":C?"border-blue-500 text-blue-400":"border-transparent text-fg-tertiary hover:text-fg-secondary";return s.jsxs("button",{onClick:()=>d(T),className:`px-4 py-2.5 text-xs font-medium whitespace-nowrap border-b-2 transition-colors flex items-center gap-1.5 ${_} ${C?"bg-surface-secondary/50":"hover:bg-surface-elevated/50"}`,children:[T===0&&s.jsxs("svg",{className:"w-3 h-3",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[s.jsx("path",{d:"M3 9l9-7 9 7v11a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2z"}),s.jsx("polyline",{points:"9 22 9 12 15 12 15 22"})]}),T>0&&s.jsx("span",{className:`w-4 h-4 rounded-full text-[9px] font-bold flex items-center justify-center shrink-0 ${j?"bg-amber-500/20 text-amber-400":"bg-blue-500/20 text-blue-400"}`,children:(N.label[0]??"?").toUpperCase()}),N.label]},T)})}),s.jsx("div",{className:"p-5",children:u===0?s.jsxs("div",{className:"space-y-6",children:[t.length>0&&s.jsx(d0,{noHeader:!0,files:t,onSave:w,readOnly:o}),s.jsxs("div",{children:[s.jsx("div",{className:"text-[10px] font-semibold text-fg-tertiary uppercase tracking-wider mb-3",children:l("sidebar.composition")}),s.jsx("div",{className:"grid gap-2 sm:grid-cols-2",children:e.map((N,T)=>{const C=N.role==="manager";return s.jsxs("button",{onClick:()=>d(T+1),className:"text-left rounded-lg border border-border-default bg-surface-elevated/30 px-4 py-3 flex gap-3 items-center hover:border-gray-600 transition-colors cursor-pointer",children:[s.jsx("div",{className:`w-8 h-8 rounded-full flex items-center justify-center text-xs font-bold shrink-0 ${C?"bg-amber-500/15 text-amber-400 ring-1 ring-amber-500/30":"bg-blue-500/15 text-blue-400 ring-1 ring-blue-500/30"}`,children:(N.name[0]??"?").toUpperCase()}),s.jsxs("div",{className:"flex-1 min-w-0",children:[s.jsxs("div",{className:"flex items-center gap-1.5",children:[s.jsx("span",{className:"text-xs font-medium text-fg-primary truncate",children:N.name}),s.jsx("span",{className:`text-[9px] px-1.5 py-0.5 rounded-full font-medium ${C?"bg-amber-500/15 text-amber-400":"bg-blue-500/15 text-blue-400"}`,children:N.role}),N.count>1&&s.jsxs("span",{className:"text-[9px] text-fg-muted",children:["×",N.count]})]}),N.skills&&N.skills.length>0&&s.jsxs("div",{className:"flex flex-wrap gap-1 mt-1",children:[N.skills.slice(0,3).map(j=>s.jsx("span",{className:"text-[9px] px-1.5 py-0.5 bg-surface-elevated text-fg-muted rounded border border-border-default",children:j},j)),N.skills.length>3&&s.jsxs("span",{className:"text-[9px] text-fg-muted",children:["+",N.skills.length-3]})]})]}),s.jsx("svg",{className:"w-3.5 h-3.5 text-fg-muted shrink-0",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:s.jsx("polyline",{points:"9 18 15 12 9 6"})})]},T)})})]})]}):x?s.jsxs("div",{className:"space-y-4",children:[s.jsxs("div",{className:"flex items-center gap-4",children:[s.jsx("div",{className:`w-12 h-12 rounded-full flex items-center justify-center text-lg font-bold shrink-0 ${x.role==="manager"?"bg-amber-500/15 text-amber-400 ring-2 ring-amber-500/30":"bg-blue-500/15 text-blue-400 ring-2 ring-blue-500/30"}`,children:(x.name[0]??"?").toUpperCase()}),s.jsxs("div",{className:"flex-1 min-w-0",children:[s.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[s.jsx("span",{className:"text-sm font-semibold text-fg-primary",children:x.name}),s.jsx("span",{className:`text-[10px] px-2 py-0.5 rounded-full font-medium ${x.role==="manager"?"bg-amber-500/15 text-amber-400":"bg-blue-500/15 text-blue-400"}`,children:x.role}),x.count>1&&s.jsxs("span",{className:"text-[10px] text-fg-muted",children:["×",x.count]})]}),x.roleName&&s.jsx("div",{className:"text-xs text-fg-tertiary mt-0.5 italic",children:x.roleName})]})]}),x.skills&&x.skills.length>0&&s.jsx("div",{className:"flex flex-wrap gap-1.5",children:x.skills.map(N=>s.jsx("span",{className:"text-[10px] px-2.5 py-1 bg-surface-elevated text-fg-muted rounded-full border border-border-default",children:N},N))}),(()=>{const N=p(x.name,y);return N.length===0?s.jsx("p",{className:"text-xs text-fg-muted italic",children:"No files for this member yet."}):s.jsx(d0,{noHeader:!0,readOnly:o,files:N.map(([T,C])=>[T.replace(/^members\/[^/]+\//,""),C]),onSave:(T,C)=>{const j=N.find(([_])=>_.endsWith(`/${T}`));j&&r(j[0],C)}})})()]}):null})]});function w(N,T){r(N,T)}}function Ai({type:e,name:t,onBack:n,authUser:r,readOnly:o,initialManifest:l,actionSlot:u,contentSlot:d}){const{t:m}=ft(["builder","common"]),h=Uo(),[p,g]=k.useState(!0),[x,y]=k.useState(t),[w,N]=k.useState({}),[T,C]=k.useState(null),[j,_]=k.useState(""),[O,z]=k.useState("idle"),[D,H]=k.useState({shared:!1}),[W,Z]=k.useState(!1),[U,Y]=k.useState(!1),[ae,X]=k.useState(!1),[F,J]=k.useState(!1),[B,Q]=k.useState(!1),[re,we]=k.useState(!1),[$,G]=k.useState(null),[ce,I]=k.useState(""),[Ee,Ue]=k.useState(""),[De,Ke]=k.useState(""),[st,mt]=k.useState(""),[ct,Dt]=k.useState([]),[Mt,Xt]=k.useState(""),Me=k.useRef(null),Ne=k.useRef(l);Ne.current=l,k.useEffect(()=>{y(t)},[t]);const Re=k.useCallback(async()=>{const he=Ne.current;if(he){C(he),I(he.displayName||he.name||t),Ue(he.description||""),Ke(he.version||"1.0.0"),mt(he.category||"general"),Dt(he.tags||[]),Xt(he.icon||""),N(he.files??{}),g(!1);return}g(!0);try{let ye=t;try{const St=await Ce.builder.artifacts.ensureSlugSafe(e,t);ye=St.name,y(ye),St.converted&&(history.replaceState(null,"",Si(me.BUILDER,`${e}/${encodeURIComponent(ye)}`)),window.dispatchEvent(new CustomEvent("markus:data-changed")))}catch{y(t)}const Ze=await Ce.builder.artifacts.get(e,ye);N(Ze.files??{}),_(Ze.path??"");const rt=Ze.files[`${e}.json`]??Ze.files["agent.json"]??Ze.files["team.json"]??Ze.files["skill.json"];if(rt){const St=JSON.parse(rt);C(St),I(St.displayName||St.name||t),Ue(St.description||""),Ke(St.version||"1.0.0"),mt(St.category||"general"),Dt(St.tags||[]),Xt(St.icon||"")}}catch(ye){console.error("Failed to load artifact:",ye)}finally{g(!1)}},[e,t]);k.useEffect(()=>{Re()},[Re]),k.useEffect(()=>{l?.files&&N(l.files)},[l?.files]),k.useEffect(()=>{if(!o){try{const he=localStorage.getItem("markus_builder_shared_map");if(he){const ye=JSON.parse(he),Ze=`${e}/${t}`;ye[Ze]&&H({shared:!0,id:ye[Ze].id,slug:ye[Ze].slug,version:ye[Ze].version,visibility:ye[Ze].visibility??"public"})}}catch{}lt.myItems().then(he=>{const ye=he?.items??[],Ze=e==="agent"?"agent":e==="team"?"team":"skill";for(const rt of ye)if(rt.itemType===Ze&&(rt.slug===t||rt.name===t)){H({shared:!0,id:rt.id,slug:rt.slug,version:rt.version,visibility:rt.visibility??"public",moderationStatus:rt.moderationStatus,pendingReview:rt.pendingReview});return}}).catch(()=>{})}},[e,t,o]);const ut=k.useCallback(async he=>{if(!(!T||o)){z("saving");try{const ye={...T,...he};await Ce.builder.artifacts.save(e,ye),C(ye),z("saved"),setTimeout(()=>z(Ze=>Ze==="saved"?"idle":Ze),2e3)}catch{z("error"),setTimeout(()=>z("idle"),3e3)}}},[T,e]),it=k.useCallback(he=>{Me.current&&clearTimeout(Me.current),Me.current=setTimeout(()=>ut(he),800)},[ut]),bt=k.useCallback((he,ye)=>{const Ze={};he==="displayName"?(I(ye),Ze.displayName=ye,Y(!0)):he==="description"?(Ue(ye),Ze.description=ye,Y(!0)):he==="version"?(Ke(ye),Ze.version=ye,Y(!1),X(!1)):he==="category"?(mt(ye),Ze.category=ye,Y(!0)):he==="tags"?(Dt(ye),Ze.tags=ye,Y(!0)):he==="icon"&&(Xt(ye),Ze.icon=ye||void 0,Y(!0)),it({...T,...Ze})},[T,it]),se=k.useCallback(async(he,ye)=>{try{const Ze={...w,[he]:ye};N(Ze);const rt={...T,files:Ze};await Ce.builder.artifacts.save(e,rt),z("saved"),Y(!0),setTimeout(()=>z(St=>St==="saved"?"idle":St),2e3)}catch{z("error")}},[w,e,T]),et=k.useCallback(async he=>{if(T){Z(!0);try{await lt.ensureAuth();const ye=await Ce.builder.artifacts.ensureSlugSafe(e,x,T.displayName||T.name||x),Ze=ye.name,rt=ye.slug||dc(Ze);if(!rt)throw new Error("Invalid package slug: use English kebab-case for the artifact name (e.g. qwen-multimodal). Chinese-only names cannot be shared — rename the package slug and put the Chinese title in displayName.");const St=ye.displayName||T.displayName||T.name||x;ye.converted&&(y(Ze),C(ie=>ie&&{...ie,name:rt,displayName:St}),history.replaceState(null,"",Si(me.BUILDER,`${e}/${encodeURIComponent(Ze)}`)),window.dispatchEvent(new CustomEvent("markus:data-changed")));const Bt={...T,name:rt,displayName:St},wt=Bt.description||"",hn=Bt.category||"general",R=Bt.tags??[];let oe=Bt.icon||void 0;const _e=Bt.version||"1.0.0";if(oe&&!oe.startsWith("http")&&/\.(png|jpe?g|gif|webp|svg)$/i.test(oe)){const ie=oe.split("/").pop()??oe;try{const Se=await fetch(`/api/builder/artifacts/${e}s/${encodeURIComponent(Ze)}/images/${encodeURIComponent(ie)}`);if(Se.ok){const Ie=await Se.blob(),Xe=new File([Ie],ie,{type:Ie.type}),yt=await lt.uploadImage(Xe);yt?.url&&(oe=yt.url)}}catch{}}let de;const $e=[],qe=Bt.screenshots??[];for(let ie=0;ie<qe.length;ie++){const Se=qe[ie],Ie=Se.split("/").pop()??Se;try{const Xe=await fetch(`/api/builder/artifacts/${e}s/${encodeURIComponent(Ze)}/images/${encodeURIComponent(Ie)}`);if(Xe.ok){const yt=await Xe.blob(),Pe=new File([yt],Ie,{type:yt.type}),Je=await lt.uploadImage(Pe);Je?.url&&($e.push({url:Je.url,alt:Ie,order:ie}),ie===0&&(de=Je.url))}}catch{}}const q=await lt.publishViaProxy({itemType:e==="team"?"team":e==="skill"?"skill":"agent",name:St,slug:rt,description:wt,category:hn,tags:R,icon:oe,version:_e,config:Bt,files:Object.keys(w).length>0?w:void 0,thumbnailUrl:de,images:$e.length>0?$e:void 0,priceCents:he?.priceCents,donationsEnabled:he?.donationsEnabled,visibility:he?.visibility,orgId:he?.orgId});q.id&&(H({shared:!0,id:q.id,slug:q.slug??rt,version:_e,visibility:q.visibility??he?.visibility??"public",moderationStatus:q.moderationStatus,pendingReview:q.pendingReview}),Y(!1),(q.visibility??he?.visibility??"public")!=="org"&&(q.moderationStatus==="pending"||q.pendingReview)?G({title:m("common:share"),message:ye.converted?m("share.convertedAndSubmitted",{previous:t,slug:rt}):q.updated?m("share.updateSubmitted"):m("share.submittedForReview"),variant:"primary"}):ye.converted&&G({title:m("common:share"),message:m("share.convertedSlug",{previous:t,slug:rt}),variant:"primary"}))}catch(ye){console.error("Share to Hub failed:",ye),G({title:m("common:share"),message:ye instanceof Error?ye.message:String(ye),variant:"danger"})}finally{Z(!1)}}},[T,w,e,t,x,m]),nt=async he=>{const ye=new FormData;ye.append("image",he);try{await fetch(`/api/builder/artifacts/${e}s/${encodeURIComponent(x)}/images`,{method:"POST",body:ye,credentials:"include"}),await Re(),Y(!0)}catch(Ze){console.error("Image upload failed:",Ze)}},Ge=async he=>{try{await fetch(`/api/builder/artifacts/${e}s/${encodeURIComponent(x)}/images/${encodeURIComponent(he)}`,{method:"DELETE",credentials:"include"}),await Re(),Y(!0)}catch(ye){console.error("Image remove failed:",ye)}},Qe=h4[e]??h4.agent,xt=T?.screenshots??[],pe=T?.skill?.skillFile?w[T.skill.skillFile]:w["SKILL.md"]??w["README.md"],V=k.useMemo(()=>e!=="agent"?[]:Object.entries(w).filter(([he])=>!he.endsWith(".json")&&!he.startsWith("images/")&&!he.startsWith("members/")),[w,e]),xe=k.useMemo(()=>e!=="team"?[]:Object.entries(w).filter(([he])=>!he.endsWith(".json")&&!he.startsWith("images/")&&!he.startsWith("members/")),[w,e]),We=k.useMemo(()=>{if(e==="agent"||e==="team")return[];const he=new Set;if(e==="skill"){const ye=T?.skill?.skillFile;ye&&w[ye]&&he.add(ye),!ye&&w["SKILL.md"]&&he.add("SKILL.md"),!ye&&!w["SKILL.md"]&&w["README.md"]&&he.add("README.md")}return Object.entries(w).filter(([ye])=>!ye.endsWith(".json")&&!ye.startsWith("images/")&&!ye.startsWith("members/")&&!he.has(ye))},[w,e,T?.skill?.skillFile]);return p?s.jsx("div",{className:"flex-1 overflow-y-auto",children:s.jsxs("div",{className:"px-6 py-8",children:[s.jsxs("button",{onClick:n,className:"text-xs text-brand-400 hover:text-brand-300 mb-4 inline-flex items-center gap-1",children:[s.jsx("svg",{className:"w-3.5 h-3.5",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:s.jsx("polyline",{points:"15 18 9 12 15 6"})}),m("detail.backToBuilder")]}),s.jsx("div",{className:"text-fg-tertiary text-sm animate-pulse py-20 text-center",children:m("common:loading")})]})}):T?s.jsxs("div",{className:"flex-1 overflow-y-auto",children:[s.jsxs("div",{className:`${h?"px-4 py-5":"px-6 py-8"}`,children:[s.jsxs("div",{className:"flex items-center justify-between mb-6",children:[s.jsxs("button",{onClick:n,className:"text-xs text-brand-400 hover:text-brand-300 inline-flex items-center gap-1",children:[s.jsx("svg",{className:"w-3.5 h-3.5",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:s.jsx("polyline",{points:"15 18 9 12 15 6"})}),m(o?"common:back":"detail.backToBuilder")]}),s.jsxs("div",{className:"flex items-center gap-2",children:[!o&&O==="saving"&&s.jsx("span",{className:"text-[10px] text-fg-muted animate-pulse",children:m("detail.saving")}),!o&&O==="saved"&&s.jsxs("span",{className:"text-[10px] text-green-500 inline-flex items-center gap-1",children:[s.jsx("svg",{className:"w-3 h-3",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",children:s.jsx("polyline",{points:"20 6 9 17 4 12"})}),m("detail.saved")]}),!o&&O==="error"&&s.jsx("span",{className:"text-[10px] text-red-500",children:m("detail.saveFailed")}),u,!o&&D.shared&&(()=>{const he=lt.getUser(),ye=he&&D.slug?`${lt.getUrl()}/@${encodeURIComponent(he.username)}/${encodeURIComponent(D.slug)}`:null,Ze=De||T?.version||"1.0.0",rt=D.version!==Ze;return s.jsxs(s.Fragment,{children:[D.moderationStatus==="pending"?s.jsxs("span",{className:"text-xs px-2 py-1.5 rounded-lg border border-amber-500/30 text-amber-400 inline-flex items-center gap-1",title:m("share.underReviewTip"),children:[s.jsxs("svg",{className:"w-3 h-3",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[s.jsx("circle",{cx:"12",cy:"12",r:"10"}),s.jsx("polyline",{points:"12 6 12 12 16 14"})]}),m("share.underReview")]}):D.moderationStatus==="rejected"?s.jsxs("span",{className:"text-xs px-2 py-1.5 rounded-lg border border-red-500/30 text-red-400 inline-flex items-center gap-1",title:m("share.rejectedTip"),children:[s.jsxs("svg",{className:"w-3 h-3",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[s.jsx("circle",{cx:"12",cy:"12",r:"10"}),s.jsx("line",{x1:"15",y1:"9",x2:"9",y2:"15"}),s.jsx("line",{x1:"9",y1:"9",x2:"15",y2:"15"})]}),m("share.rejected")]}):D.pendingReview?s.jsxs("span",{className:"text-xs px-2 py-1.5 rounded-lg border border-amber-500/30 text-amber-400 inline-flex items-center gap-1",title:m("share.updateUnderReviewTip"),children:[s.jsxs("svg",{className:"w-3 h-3",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[s.jsx("circle",{cx:"12",cy:"12",r:"10"}),s.jsx("polyline",{points:"12 6 12 12 16 14"})]}),m("share.updateUnderReview")]}):null,ye&&s.jsxs("a",{href:ye,target:"_blank",rel:"noopener noreferrer",onClick:St=>{Gd()&&(St.preventDefault(),Oo(ye))},className:`text-xs px-3 py-1.5 rounded-lg border transition-colors inline-flex items-center gap-1.5 ${D.visibility==="org"?"border-blue-500/30 text-blue-500 hover:text-blue-400 hover:border-blue-400/50":D.visibility==="unlisted"?"border-gray-500/30 text-fg-tertiary hover:text-fg-secondary hover:border-gray-400/50":"border-green-600/30 text-green-600 hover:text-green-500 hover:border-green-500/50"}`,children:[D.visibility==="org"?s.jsxs("svg",{className:"w-3 h-3",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[s.jsx("path",{d:"M3 21h18"}),s.jsx("path",{d:"M9 8h1"}),s.jsx("path",{d:"M9 12h1"}),s.jsx("path",{d:"M9 16h1"}),s.jsx("path",{d:"M14 8h1"}),s.jsx("path",{d:"M14 12h1"}),s.jsx("path",{d:"M14 16h1"}),s.jsx("path",{d:"M5 21V5a2 2 0 0 1 2-2h10a2 2 0 0 1 2 2v16"})]}):D.visibility==="unlisted"?s.jsxs("svg",{className:"w-3 h-3",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[s.jsx("path",{d:"M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71"}),s.jsx("path",{d:"M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71"})]}):s.jsxs("svg",{className:"w-3 h-3",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[s.jsx("path",{d:"M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6"}),s.jsx("polyline",{points:"15 3 21 3 21 9"}),s.jsx("line",{x1:"10",y1:"14",x2:"21",y2:"3"})]}),D.visibility==="org"?m("visibility.sharedOrg"):D.visibility==="unlisted"?m("visibility.sharedUnlisted"):m("share.viewOnHub")]}),rt&&s.jsx("button",{onClick:()=>{et({visibility:D.visibility})},disabled:W,className:"text-xs px-3 py-1.5 rounded-lg border border-amber-500/30 text-amber-400 hover:bg-amber-500/10 hover:border-amber-500/50 transition-colors disabled:opacity-50",children:W?m("share.updating"):m("share.updateVersion",{version:Ze})})]})})(),!o&&!D.shared&&s.jsx("button",{onClick:()=>Q(!0),disabled:W,className:"text-xs px-3 py-1.5 rounded-lg bg-brand-600 hover:bg-brand-500 text-white transition-colors disabled:opacity-50",children:m(W?"share.sharing":"share.toHub")})]})]}),!o&&U&&!ae&&s.jsxs("div",{className:"mb-4 px-4 py-2.5 rounded-lg bg-amber-50 dark:bg-amber-500/10 border border-amber-300 dark:border-amber-500/20 flex items-center justify-between",children:[s.jsx("span",{className:"text-xs text-amber-800 dark:text-amber-300",children:m("versionBump.contentModified")}),s.jsx("button",{onClick:()=>X(!0),className:"text-xs px-3 py-1 rounded bg-amber-200 dark:bg-amber-500/20 text-amber-800 dark:text-amber-300 hover:bg-amber-300 dark:hover:bg-amber-500/30 transition-colors",children:m("versionBump.bumpVersion")})]}),!o&&ae&&s.jsxs("div",{className:"mb-4 px-4 py-3 rounded-lg bg-amber-50 dark:bg-amber-500/10 border border-amber-300 dark:border-amber-500/20",children:[s.jsxs("div",{className:"flex items-center gap-3",children:[s.jsx("span",{className:"text-xs text-amber-800 dark:text-amber-300",children:m("versionBump.newVersion")}),s.jsx("input",{type:"text",defaultValue:(()=>{const he=(De||"1.0.0").split(".");return he[2]=String(Number(he[2]??0)+1),he.join(".")})(),className:"text-xs px-2 py-1 rounded bg-surface-elevated border border-border-default text-fg-primary w-24 font-mono",onKeyDown:he=>{he.key==="Enter"&&bt("version",he.target.value)}}),s.jsx("button",{onClick:he=>{const ye=he.target.parentElement?.querySelector("input");ye&&bt("version",ye.value)},className:"text-xs px-3 py-1 rounded bg-amber-200 dark:bg-amber-500/20 text-amber-800 dark:text-amber-300 hover:bg-amber-300 dark:hover:bg-amber-500/30 transition-colors",children:m("common:confirm")}),s.jsx("button",{onClick:()=>X(!1),className:"text-xs text-fg-tertiary hover:text-fg-secondary",children:m("common:cancel")})]}),D.shared&&s.jsx("p",{className:"text-[10px] text-fg-tertiary mt-2",children:"After bumping the version, you can share the new version to Hub."})]}),s.jsxs("div",{className:`flex gap-8 ${h?"flex-col":""}`,children:[s.jsxs("div",{className:`${h?"w-full":"flex-1 min-w-0"}`,children:[s.jsxs("div",{className:"flex items-start gap-4 mb-6",children:[s.jsxs("div",{className:"relative",children:[s.jsx("div",{onClick:()=>!o&&we(!re),className:`w-16 h-16 rounded-xl ${Qe.bg} flex items-center justify-center text-3xl shrink-0 ${o?"":"cursor-pointer hover:ring-2"} ${Qe.ring} transition-all overflow-hidden`,children:Mt&&Mt.startsWith("images/")?s.jsx("img",{src:`/api/builder/artifacts/${e}s/${encodeURIComponent(x)}/images/${encodeURIComponent(Mt.replace("images/",""))}`,alt:"",className:"w-full h-full object-cover"}):Mt&&(Mt.startsWith("http")||Mt.startsWith("/"))?s.jsx("img",{src:Mt,alt:"",className:"w-full h-full object-cover"}):(()=>{const he=Mt||"";if(he&&[...he].length<=2&&new RegExp("\\p{Emoji}","u").test(he))return he;const Ze=Ti[Wo(e)].accent;return s.jsx("svg",{width:"36",height:"36",viewBox:"0 0 24 24",fill:"none","aria-hidden":!0,children:s.jsx("path",{d:y3(ce||t||e),fill:Ze})})})()}),!o&&re&&s.jsxs(s.Fragment,{children:[s.jsx("div",{className:"fixed inset-0 z-40",onClick:()=>we(!1)}),s.jsxs("div",{className:"absolute top-full left-0 mt-2 z-50 bg-surface-secondary border border-border-default rounded-xl p-3 shadow-xl w-80",children:[s.jsxs("div",{className:"flex items-center gap-2 mb-3",children:[s.jsx("input",{type:"text",placeholder:m("detail.pasteEmojiOrUrl"),className:"flex-1 text-sm px-2 py-1.5 rounded-lg bg-surface-elevated border border-border-default text-fg-primary placeholder:text-fg-muted",defaultValue:Mt,onKeyDown:he=>{he.key==="Enter"&&(bt("icon",he.target.value),we(!1))}}),s.jsxs("label",{className:"text-[10px] text-brand-400 hover:text-brand-300 cursor-pointer px-1.5 py-1 border border-brand-500/30 rounded-lg",children:[m("detail.upload"),s.jsx("input",{type:"file",accept:"image/*",className:"hidden",onChange:async he=>{const ye=he.target.files?.[0];if(!ye)return;const Ze=new FormData;Ze.append("image",ye);try{const rt=await fetch(`/api/builder/artifacts/${e}s/${encodeURIComponent(x)}/images`,{method:"POST",body:Ze,credentials:"include"});if(rt.ok){const Bt=(await rt.json()).path;if(Xt(Bt),we(!1),T){const wt={...T,icon:Bt};C(wt),await Ce.builder.artifacts.save(e,wt)}Y(!0)}}catch{}}})]}),Mt&&s.jsx("button",{onClick:()=>{bt("icon",""),we(!1)},className:"text-[10px] text-fg-tertiary hover:text-red-400 px-1",children:"✕"})]}),s.jsx("div",{className:"max-h-64 overflow-y-auto",children:rK.map(he=>s.jsxs("div",{className:"mb-2.5",children:[s.jsx("div",{className:"text-[10px] text-fg-tertiary mb-1 sticky top-0 bg-surface-secondary py-0.5",children:he.label}),s.jsx("div",{className:"flex flex-wrap gap-0.5",children:he.emojis.map(ye=>s.jsx("button",{onClick:()=>{bt("icon",ye),we(!1)},className:`w-7 h-7 rounded flex items-center justify-center text-base hover:bg-surface-elevated transition-colors ${Mt===ye?"ring-1.5 ring-brand-500 bg-brand-500/10":""}`,children:ye},ye))})]},he.label))})]})]})]}),s.jsxs("div",{className:"flex-1 min-w-0",children:[s.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[s.jsx(Kh,{value:ce,onChange:he=>bt("displayName",he),renderAs:"h1",className:"text-xl font-bold text-fg-primary",placeholder:m("detail.untitled"),readOnly:o}),s.jsx("span",{className:`text-[10px] font-medium uppercase tracking-wider px-2 py-0.5 rounded-full ${Qe.bg} ${Qe.color}`,children:Qe.label}),s.jsx(Kh,{value:De,onChange:he=>bt("version",he),renderAs:"badge",className:"text-[10px] px-2 py-0.5 rounded-full bg-surface-elevated text-fg-tertiary border border-border-default font-mono",placeholder:"1.0.0",readOnly:o})]}),s.jsx(Kh,{value:Ee,onChange:he=>bt("description",he),renderAs:"p",className:"text-sm text-fg-secondary mt-1.5 leading-relaxed",placeholder:m("detail.addDescription"),multiline:!0,readOnly:o}),s.jsxs("div",{className:"flex items-center gap-2 mt-2 flex-wrap",children:[s.jsx(sK,{value:st,options:nK,onChange:he=>bt("category",he),className:"text-xs px-2 py-0.5 rounded bg-surface-elevated text-fg-tertiary",readOnly:o}),s.jsx(iK,{tags:ct,onChange:he=>bt("tags",he),readOnly:o})]})]})]}),s.jsx("div",{className:"mb-8",children:s.jsx(lK,{images:xt,artifactType:e,artifactName:t,onUpload:nt,onRemove:Ge,readOnly:o})}),d&&s.jsx("div",{className:"mb-8",children:d}),e==="team"&&T.team&&s.jsx("div",{className:"mb-8",children:s.jsx(cK,{members:T.team.members,teamTopFiles:xe,files:w,onFileSave:se,readOnly:o})}),e==="agent"&&V.length>0&&s.jsxs("div",{className:"mb-8",children:[s.jsx("h2",{className:"text-sm font-semibold text-fg-primary mb-4 uppercase tracking-wider",children:"About This Agent"}),s.jsx(d0,{noHeader:!0,files:V,onSave:se,readOnly:o})]}),e==="skill"&&s.jsxs("div",{className:"mb-8",children:[T.skill?.requiredPermissions&&T.skill.requiredPermissions.length>0&&s.jsxs("div",{className:"mb-6",children:[s.jsx("h2",{className:"text-sm font-semibold text-fg-primary mb-3 uppercase tracking-wider",children:m("sidebar.permissions")}),s.jsx("div",{className:"flex flex-wrap gap-2",children:T.skill.requiredPermissions.map(he=>{const ye=aK[he];return s.jsxs("span",{className:`inline-flex items-center gap-1.5 text-xs px-3 py-1.5 rounded-lg border font-medium ${ye?.color??"bg-surface-elevated text-fg-secondary border-border-default"}`,children:[s.jsx("span",{className:"font-mono text-[10px]",children:ye?.icon??"?"})," ",he]},he)})})]}),T.skill?.mcpServers&&Object.keys(T.skill.mcpServers).length>0&&s.jsxs("div",{className:"mb-6",children:[s.jsx("h2",{className:"text-sm font-semibold text-fg-primary mb-3 uppercase tracking-wider",children:"Integrations"}),s.jsx("div",{className:"grid gap-2",children:Object.entries(T.skill.mcpServers).map(([he,ye])=>s.jsxs("div",{className:"rounded-lg border border-border-default bg-surface-secondary/40 px-4 py-3 flex items-center gap-3",children:[s.jsx("span",{className:"w-8 h-8 rounded-lg bg-purple-500/15 flex items-center justify-center text-purple-400 text-sm shrink-0",children:"◎"}),s.jsxs("div",{children:[s.jsx("div",{className:"text-xs font-medium text-fg-primary",children:he}),s.jsx("div",{className:"text-[10px] text-fg-muted font-mono truncate",children:typeof ye=="object"?JSON.stringify(ye).slice(0,80):String(ye)})]})]},he))})]}),pe&&s.jsxs("div",{children:[s.jsx("h2",{className:"text-sm font-semibold text-fg-primary mb-3 uppercase tracking-wider",children:"Instructions"}),s.jsx("div",{className:"rounded-xl border border-border-default bg-surface-secondary/40 p-5",children:s.jsx(Fp,{content:pe})})]})]}),We.length>0&&s.jsx(d0,{files:We,onSave:se,readOnly:o})]}),s.jsx("div",{className:`${h?"w-full":"w-72 shrink-0"}`,children:s.jsxs("div",{className:`${h?"":"sticky top-6"} space-y-4`,children:[s.jsxs("div",{className:"rounded-xl border border-border-default bg-surface-secondary/60 p-4 space-y-3",children:[s.jsx("div",{className:"text-xs font-medium text-fg-tertiary uppercase tracking-wider",children:m("sidebar.info")}),s.jsxs("div",{className:"space-y-2 text-xs",children:[s.jsxs("div",{className:"flex justify-between",children:[s.jsx("span",{className:"text-fg-muted",children:m("sidebar.type")}),s.jsx("span",{className:`font-medium ${Qe.color}`,children:Qe.label})]}),s.jsxs("div",{className:"flex justify-between",children:[s.jsx("span",{className:"text-fg-muted",children:m("sidebar.category")}),s.jsx("span",{className:"text-fg-secondary",children:st})]}),s.jsxs("div",{className:"flex justify-between",children:[s.jsx("span",{className:"text-fg-muted",children:m("sidebar.version")}),s.jsx("span",{className:"text-fg-secondary font-mono",children:De})]}),T.author&&s.jsxs("div",{className:"flex justify-between",children:[s.jsx("span",{className:"text-fg-muted",children:m("sidebar.author")}),s.jsx("span",{className:"text-fg-secondary",children:typeof T.author=="string"?T.author:T.author?.name??""})]})]})]}),e==="agent"&&T.agent&&s.jsxs("div",{className:"rounded-xl border border-border-default bg-surface-secondary/60 p-4 space-y-3",children:[s.jsx("div",{className:"text-xs font-medium text-fg-tertiary uppercase tracking-wider",children:m("sidebar.agentSpecs")}),s.jsxs("div",{className:"space-y-2 text-xs",children:[T.agent.roleName&&s.jsxs("div",{className:"flex justify-between",children:[s.jsx("span",{className:"text-fg-muted",children:m("sidebar.role")}),s.jsx("span",{className:"text-fg-secondary",children:T.agent.roleName})]}),T.agent.llmProvider&&s.jsxs("div",{className:"flex justify-between",children:[s.jsx("span",{className:"text-fg-muted",children:m("sidebar.provider")}),s.jsx("span",{className:"text-fg-secondary",children:T.agent.llmProvider})]}),T.agent.llmModel&&s.jsxs("div",{className:"flex justify-between",children:[s.jsx("span",{className:"text-fg-muted",children:m("sidebar.model")}),s.jsx("span",{className:"text-fg-secondary font-mono",children:T.agent.llmModel})]}),T.agent.temperature!==void 0&&s.jsxs("div",{className:"flex justify-between",children:[s.jsx("span",{className:"text-fg-muted",children:m("sidebar.temperature")}),s.jsx("span",{className:"text-fg-secondary",children:T.agent.temperature})]})]})]}),e==="team"&&T.team&&s.jsxs("div",{className:"rounded-xl border border-border-default bg-surface-secondary/60 p-4 space-y-3",children:[s.jsx("div",{className:"text-xs font-medium text-fg-tertiary uppercase tracking-wider",children:m("sidebar.composition")}),s.jsxs("div",{className:"space-y-2 text-xs",children:[s.jsxs("div",{className:"flex justify-between",children:[s.jsx("span",{className:"text-fg-muted",children:m("sidebar.totalMembers")}),s.jsx("span",{className:"text-fg-secondary",children:T.team.members.reduce((he,ye)=>he+ye.count,0)})]}),s.jsxs("div",{className:"flex justify-between",children:[s.jsx("span",{className:"text-fg-muted",children:m("sidebar.managers")}),s.jsx("span",{className:"text-amber-400",children:T.team.members.filter(he=>he.role==="manager").reduce((he,ye)=>he+ye.count,0)})]}),s.jsxs("div",{className:"flex justify-between",children:[s.jsx("span",{className:"text-fg-muted",children:m("sidebar.workers")}),s.jsx("span",{className:"text-blue-400",children:T.team.members.filter(he=>he.role!=="manager").reduce((he,ye)=>he+ye.count,0)})]})]})]}),e==="skill"&&T.skill&&s.jsxs("div",{className:"rounded-xl border border-border-default bg-surface-secondary/60 p-4 space-y-3",children:[s.jsx("div",{className:"text-xs font-medium text-fg-tertiary uppercase tracking-wider",children:m("sidebar.skillInfo")}),s.jsxs("div",{className:"space-y-2 text-xs",children:[T.skill.alwaysOn!==void 0&&s.jsxs("div",{className:"flex justify-between",children:[s.jsx("span",{className:"text-fg-muted",children:m("sidebar.alwaysOn")}),s.jsx("span",{className:T.skill.alwaysOn?"text-green-400":"text-fg-secondary",children:T.skill.alwaysOn?m("sidebar.yes"):m("sidebar.no")})]}),s.jsxs("div",{className:"flex justify-between",children:[s.jsx("span",{className:"text-fg-muted",children:m("sidebar.skillFile")}),s.jsx("span",{className:"text-fg-secondary font-mono truncate ml-2",children:T.skill.skillFile})]}),T.skill.requiredPermissions&&T.skill.requiredPermissions.length>0&&s.jsxs("div",{children:[s.jsx("span",{className:"text-fg-muted",children:m("sidebar.permissions")}),s.jsx("div",{className:"flex flex-wrap gap-1 mt-1",children:T.skill.requiredPermissions.map(he=>s.jsx("span",{className:"text-[10px] px-1.5 py-0.5 bg-surface-elevated text-fg-muted rounded border border-border-default",children:he},he))})]})]})]}),T.dependencies&&(T.dependencies.skills?.length||T.dependencies.env?.length)?s.jsxs("div",{className:"rounded-xl border border-border-default bg-surface-secondary/60 p-4 space-y-3",children:[s.jsx("div",{className:"text-xs font-medium text-fg-tertiary uppercase tracking-wider",children:m("sidebar.dependencies")}),T.dependencies.skills?.length?s.jsxs("div",{children:[s.jsx("div",{className:"text-[10px] text-fg-muted mb-1",children:m("sidebar.skills")}),s.jsx("div",{className:"flex flex-wrap gap-1",children:T.dependencies.skills.map(he=>s.jsx("span",{className:"text-[10px] px-2 py-0.5 bg-surface-elevated text-fg-secondary rounded border border-border-default",children:he},he))})]}):null,T.dependencies.env?.length?s.jsxs("div",{children:[s.jsx("div",{className:"text-[10px] text-fg-muted mb-1",children:m("sidebar.environment")}),s.jsx("div",{className:"flex flex-wrap gap-1",children:T.dependencies.env.map(he=>s.jsx("span",{className:"text-[10px] px-2 py-0.5 bg-surface-elevated text-fg-secondary rounded font-mono border border-border-default",children:he},he))})]}):null]}):null,!o&&j&&s.jsxs("button",{onClick:()=>Ce.system.openPath(j).catch(()=>{}),className:"w-full text-left rounded-xl border border-border-default bg-surface-secondary/60 px-4 py-3 text-[10px] text-fg-muted hover:text-fg-secondary hover:border-gray-600 transition-colors truncate",title:j,children:[s.jsx("span",{className:"text-fg-tertiary block mb-0.5",children:m("sidebar.openInFinder")}),j.replace(/.*\.markus\//,"~/.markus/")]})]})})]})]}),!o&&F&&s.jsx(dK,{onClose:()=>J(!1),onConfirm:(he,ye)=>{J(!1),et({donationsEnabled:!1,priceCents:he==="paid"?ye:void 0})},isUpdate:D.shared}),!o&&B&&s.jsx(uK,{onClose:()=>Q(!1),onConfirm:(he,ye,Ze,rt)=>{Q(!1),et({visibility:he,orgId:ye,priceCents:Ze,donationsEnabled:rt})}}),$&&s.jsx(dr,{alertOnly:!0,variant:$.variant??"primary",title:$.title,message:$.message,onConfirm:()=>G(null),onCancel:()=>G(null)})]}):s.jsx("div",{className:"flex-1 overflow-y-auto",children:s.jsxs("div",{className:"px-6 py-8",children:[s.jsxs("button",{onClick:n,className:"text-xs text-brand-400 hover:text-brand-300 mb-4 inline-flex items-center gap-1",children:[s.jsx("svg",{className:"w-3.5 h-3.5",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:s.jsx("polyline",{points:"15 18 9 12 15 6"})}),m("detail.backToBuilder")]}),s.jsx("div",{className:"text-fg-tertiary text-sm py-20 text-center",children:m("detail.notFound")})]})})}function uK({onClose:e,onConfirm:t}){const{t:n}=ft(["builder","common"]),[r,o]=k.useState("public"),[l,u]=k.useState([]),[d,m]=k.useState(""),[h,p]=k.useState(!1),[g,x]=k.useState(0),[y,w]=k.useState(!1);k.useEffect(()=>{r==="org"&&l.length===0&&(p(!0),lt.myOrgs().then(C=>{u(C.memberships),C.memberships.length>0&&m(C.memberships[0].id)}).catch(()=>{}).finally(()=>p(!1)))},[r,l.length]);const N=r==="public"||r==="unlisted",T=[{value:"public",icon:s.jsxs("svg",{className:"w-4 h-4",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[s.jsx("circle",{cx:"12",cy:"12",r:"10"}),s.jsx("line",{x1:"2",y1:"12",x2:"22",y2:"12"}),s.jsx("path",{d:"M12 2a15.3 15.3 0 0 1 4 10 15.3 15.3 0 0 1-4 10 15.3 15.3 0 0 1-4-10 15.3 15.3 0 0 1 4-10z"})]}),label:n("visibility.public"),desc:n("visibility.publicDesc")},{value:"org",icon:s.jsxs("svg",{className:"w-4 h-4",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[s.jsx("path",{d:"M3 21h18"}),s.jsx("path",{d:"M9 8h1"}),s.jsx("path",{d:"M9 12h1"}),s.jsx("path",{d:"M9 16h1"}),s.jsx("path",{d:"M14 8h1"}),s.jsx("path",{d:"M14 12h1"}),s.jsx("path",{d:"M14 16h1"}),s.jsx("path",{d:"M5 21V5a2 2 0 0 1 2-2h10a2 2 0 0 1 2 2v16"})]}),label:n("visibility.org"),desc:n("visibility.orgDesc")},{value:"unlisted",icon:s.jsxs("svg",{className:"w-4 h-4",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[s.jsx("path",{d:"M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71"}),s.jsx("path",{d:"M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71"})]}),label:n("visibility.unlisted"),desc:n("visibility.unlistedDesc")}];return s.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/60 backdrop-blur-sm",onClick:e,children:s.jsxs("div",{className:"bg-surface-secondary border border-border-default rounded-xl max-w-sm w-full mx-4 p-6 shadow-2xl",onClick:C=>C.stopPropagation(),children:[s.jsx("h3",{className:"text-base font-semibold text-fg-primary mb-1",children:n("visibility.label")}),s.jsx("p",{className:"text-[11px] text-fg-tertiary mb-4 leading-relaxed",children:n("visibility.subtitle")}),s.jsxs("div",{className:"text-[10px] uppercase tracking-wider text-fg-tertiary font-semibold mb-2",children:["1 · ",n("visibility.public")," / ",n("visibility.org")]}),s.jsx("div",{className:"space-y-2 mb-5",children:T.map(C=>s.jsxs("label",{className:`flex items-center gap-3 p-3 rounded-lg border cursor-pointer transition-colors ${r===C.value?"border-brand-500 bg-brand-500/10":"border-border-default hover:border-gray-600"}`,children:[s.jsx("input",{type:"radio",name:"visibility",checked:r===C.value,onChange:()=>o(C.value),className:"accent-brand-500"}),s.jsx("div",{className:"flex items-center gap-2 text-fg-secondary",children:C.icon}),s.jsxs("div",{children:[s.jsx("div",{className:"text-sm font-medium text-fg-primary",children:C.label}),s.jsx("div",{className:"text-[11px] text-fg-tertiary",children:C.desc})]})]},C.value))}),r==="org"&&s.jsxs("div",{className:"mb-5",children:[s.jsx("label",{className:"text-xs text-fg-secondary block mb-1.5",children:n("visibility.orgSelect")}),h?s.jsx("div",{className:"text-xs text-fg-tertiary py-2",children:"Loading..."}):l.length===0?s.jsx("div",{className:"text-xs text-fg-tertiary py-2",children:n("visibility.orgNone")}):s.jsx("select",{value:d,onChange:C=>m(C.target.value),className:"w-full text-sm px-3 py-2 rounded-lg bg-surface-elevated border border-border-default text-fg-primary",children:l.map(C=>s.jsx("option",{value:C.id,children:C.name},C.id))})]}),N&&s.jsxs("div",{className:"mb-5",children:[s.jsxs("div",{className:"text-[10px] uppercase tracking-wider text-fg-tertiary font-semibold mb-2",children:["2 · ",n("pricing.label")]}),s.jsx("label",{className:"text-xs text-fg-secondary block mb-1.5",children:n("pricing.label")}),s.jsx("div",{className:"grid grid-cols-4 gap-2 mb-3",children:w3.map(C=>s.jsx("button",{type:"button",onClick:()=>x(C.cents),className:`text-sm px-2 py-2 rounded-lg border transition-colors ${g===C.cents?"border-brand-500 bg-brand-500/10 text-fg-primary":"border-border-default text-fg-secondary hover:border-gray-600"}`,children:C.label},C.cents))}),s.jsxs("label",{className:"flex items-center gap-2 cursor-pointer",children:[s.jsx("input",{type:"checkbox",checked:y,onChange:C=>w(C.target.checked),className:"accent-brand-500"}),s.jsx("span",{className:"text-xs text-fg-secondary",children:n("pricing.enableTips")})]})]}),N&&s.jsx("div",{className:"mb-4 text-[11px] text-fg-tertiary rounded-lg border border-border-default px-3 py-2",children:n("pricing.reviewNote")}),s.jsxs("div",{className:"flex gap-3",children:[s.jsx("button",{onClick:e,className:"flex-1 text-sm px-4 py-2 rounded-lg border border-border-default text-fg-secondary hover:text-fg-primary hover:border-gray-600 transition-colors",children:n("common:cancel")}),s.jsx("button",{onClick:()=>t(r,r==="org"?d:void 0,N&&g>0?g:void 0,N?y:void 0),disabled:r==="org"&&!d,className:"flex-1 text-sm px-4 py-2 rounded-lg bg-brand-600 hover:bg-brand-500 text-white transition-colors disabled:opacity-50 disabled:cursor-not-allowed",children:n("shareMode.share")})]})]})})}const w3=[{cents:0,label:"Free"},{cents:100,label:"$1"},{cents:500,label:"$5"},{cents:1e3,label:"$10"}];function dK({onClose:e,onConfirm:t,isUpdate:n}){const{t:r}=ft(["builder","common"]),[o,l]=k.useState(0);return s.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/60 backdrop-blur-sm",onClick:e,children:s.jsxs("div",{className:"bg-surface-secondary border border-border-default rounded-xl max-w-sm w-full mx-4 p-6 shadow-2xl",onClick:u=>u.stopPropagation(),children:[s.jsx("h3",{className:"text-base font-semibold text-fg-primary mb-4",children:r(n?"shareMode.titleUpdate":"share.toHub")}),s.jsx("div",{className:"space-y-2 mb-5",children:w3.map(u=>s.jsxs("label",{className:`flex items-center gap-3 p-3 rounded-lg border cursor-pointer transition-colors ${o===u.cents?"border-brand-500 bg-brand-500/10":"border-border-default hover:border-gray-600"}`,children:[s.jsx("input",{type:"radio",name:"sharePrice",checked:o===u.cents,onChange:()=>l(u.cents),className:"accent-brand-500"}),s.jsxs("div",{children:[s.jsx("div",{className:"text-sm font-medium text-fg-primary",children:u.label}),s.jsx("div",{className:"text-[11px] text-fg-tertiary",children:u.cents===0?r("shareMode.freeDesc"):r("shareMode.paidDesc")})]})]},u.cents))}),s.jsxs("div",{className:"flex gap-3",children:[s.jsx("button",{onClick:e,className:"flex-1 text-sm px-4 py-2 rounded-lg border border-border-default text-fg-secondary hover:text-fg-primary hover:border-gray-600 transition-colors",children:r("common:cancel")}),s.jsx("button",{onClick:()=>t(o>0?"paid":"free",o),className:"flex-1 text-sm px-4 py-2 rounded-lg bg-brand-600 hover:bg-brand-500 text-white transition-colors",children:r(n?"shareMode.update":"shareMode.share")})]})]})})}function m0(e,t){return!e||!v3(e)?null:e.startsWith("http")||e.startsWith("data:")?e:e.startsWith("/")&&t?`${t}${e}`:e}function mK({type:e,seed:t,icon:n,hubBase:r,size:o=44,className:l="",rounded:u="rounded-xl"}){const d=Wo(e),m=m0(n,r),h=k.useMemo(()=>Mg(d,t),[d,t]),p=k.useMemo(()=>y3(t),[t]),[g,x]=k.useState(!1);return m&&!g?s.jsx("img",{src:m,alt:"",onError:()=>x(!0),style:{width:o,height:o},className:`${u} object-cover shrink-0 ${l}`}):eK(n)?s.jsx("div",{style:{width:o,height:o,background:h,fontSize:o*.5},className:`${u} shrink-0 flex items-center justify-center shadow-inner ${l}`,children:s.jsx("span",{className:"drop-shadow-sm",children:n})}):n&&bV(n)?s.jsx("div",{style:{width:o,height:o,background:h},className:`${u} shrink-0 flex items-center justify-center text-white shadow-inner ${l}`,children:s.jsx(Ko,{name:n,size:o*.52,className:"drop-shadow-sm"})}):s.jsx("div",{style:{width:o,height:o,background:h},className:`${u} shrink-0 flex items-center justify-center shadow-inner ${l}`,children:s.jsx("svg",{width:o*.55,height:o*.55,viewBox:"0 0 24 24",fill:"none","aria-hidden":!0,children:s.jsx("path",{d:p,fill:"rgba(255,255,255,0.92)"})})})}function f0({name:e,username:t,avatarUrl:n,hubBase:r,size:o=24,className:l="",verified:u}){const d=t||e||"markus",m=m0(n,r),[h,p]=k.useState(!1),g=m&&!h?m:tK(d);return s.jsxs("span",{className:`relative inline-flex shrink-0 ${l}`,style:{width:o,height:o},children:[s.jsx("img",{src:g,alt:e||t||"",onError:()=>p(!0),className:"w-full h-full rounded-full object-cover ring-1 ring-white/10 bg-surface-elevated"}),u&&s.jsx("span",{className:"absolute -right-0.5 -bottom-0.5 flex items-center justify-center rounded-full bg-brand-500 ring-2 ring-surface-primary",style:{width:o*.42,height:o*.42},children:s.jsx("svg",{viewBox:"0 0 24 24",width:"60%",height:"60%",fill:"white","aria-hidden":!0,children:s.jsx("path",{d:"M9 16.2l-3.5-3.5 1.4-1.4L9 13.4l7.1-7.1 1.4 1.4z"})})})]})}function fK({type:e,className:t=""}){const n=Wo(e),r=Ti[n];return s.jsx("span",{className:`inline-flex items-center gap-1 rounded-full px-2 py-0.5 text-[10px] font-semibold tracking-wide text-white bg-gradient-to-r ${r.gradient} ${t}`,children:r.label})}function g4({rating:e=0}){const t=Math.round(e);return s.jsx("span",{className:"inline-flex items-center","aria-label":`${e} out of 5`,children:[0,1,2,3,4].map(n=>s.jsx("svg",{viewBox:"0 0 24 24",width:"12",height:"12",className:n<t?"text-amber-400":"text-fg-muted/40",fill:"currentColor","aria-hidden":!0,children:s.jsx("path",{d:"M12 2l2.4 6.9L21 9l-5.4 4 2 7-5.6-4.1L6.4 20l2-7L3 9l6.6-.1z"})},n))})}function sa(e){const{type:t,name:n,description:r,seed:o,icon:l,cover:u,hubBase:d,author:m,authorLabel:h,version:p,category:g,tags:x,rating:y=0,ratingCount:w=0,downloadCount:N=0,priceCents:T,currency:C="usd",installed:j,glowing:_,selected:O,showTypeBadge:z=!0,hideStats:D=!1,cornerLabel:H,actions:W,footerLeft:Z,headerAction:U,onClick:Y,className:ae=""}=e,X=Wo(t),F=Ti[X],J=o||n,B=(T??0)>0,Q=!!m0(u||void 0,d),re=Mg(X,J),we=h??m?.displayName??m?.username??"",[$,G]=k.useState(null),ce=j?s.jsx("span",{className:"inline-flex items-center gap-1 rounded-full bg-emerald-500/12 text-emerald-400 border border-emerald-500/25 px-2 py-0.5 text-[10px] font-semibold",children:s.jsx("svg",{className:"w-2.5 h-2.5",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"3.5",children:s.jsx("polyline",{points:"20 6 9 17 4 12"})})}):H?s.jsx("span",{className:"chip",children:H}):B?s.jsx("span",{className:"badge-paid",children:f4(T,C)}):null;if(Q){const I=m0(u||void 0,d);return s.jsxs("div",{onClick:Y,style:{aspectRatio:$??void 0},className:`group asset-card card-shine relative flex flex-col overflow-hidden min-h-[180px] ${Y?"cursor-pointer":""} ${O?"ring-1 ring-brand-500/60":""} ${_?"ring-2 ring-brand-500 shadow-lg shadow-brand-500/20":""} ${ae}`,children:[s.jsx("img",{src:I,alt:"",onLoad:Ee=>{const Ue=Ee.currentTarget;Ue.naturalWidth&&Ue.naturalHeight&&G(Math.min(1.9,Math.max(1,Ue.naturalWidth/Ue.naturalHeight)))},className:"absolute inset-0 w-full h-full object-cover transition-transform duration-[600ms] group-hover:scale-[1.05]"}),s.jsx("div",{className:"absolute inset-0 bg-gradient-to-t from-black/90 via-black/50 to-black/5"}),s.jsx("div",{className:"absolute inset-x-0 top-0 h-20 bg-gradient-to-b from-black/50 to-transparent"}),s.jsxs("div",{className:"relative flex items-start justify-between gap-2 p-3",children:[s.jsx("span",{children:z&&s.jsx(fK,{type:X})}),s.jsxs("span",{className:"flex items-center gap-1.5",onClick:Ee=>Ee.stopPropagation(),children:[j?s.jsx("span",{className:"inline-flex items-center gap-1 rounded-full bg-emerald-500/25 text-emerald-50 border border-emerald-300/40 px-2 py-0.5 text-[10px] font-semibold backdrop-blur-md",children:s.jsx("svg",{className:"w-3 h-3",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"3",children:s.jsx("polyline",{points:"20 6 9 17 4 12"})})}):H?s.jsx("span",{className:"inline-flex items-center rounded-full bg-white/15 text-white border border-white/25 px-2 py-0.5 text-[10px] font-medium backdrop-blur-md",children:H}):U?null:s.jsx("span",{className:B?"badge-paid":"badge-free",children:f4(T,C)}),U]})]}),s.jsxs("div",{className:"relative mt-auto p-4 pt-10 flex flex-col gap-2 text-white",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("h3",{className:"text-[15px] font-semibold truncate drop-shadow-md",children:n}),p&&s.jsxs("span",{className:"shrink-0 rounded-full bg-white/15 border border-white/25 px-1.5 py-0.5 text-[10px] font-medium backdrop-blur-md",children:["v",p]})]}),we&&s.jsxs("div",{className:"flex items-center gap-1.5 text-[11px] text-white/85",children:[m&&s.jsx(f0,{name:m.displayName,username:m.username,avatarUrl:m.avatarUrl,hubBase:d,size:15}),s.jsx("span",{className:"truncate",children:we})]}),r&&s.jsx("p",{className:"text-[12.5px] text-white/80 truncate leading-snug drop-shadow-sm",children:r}),(g||x&&x.length>0)&&s.jsxs("div",{className:"flex flex-nowrap gap-1.5 overflow-hidden",children:[g&&s.jsx("span",{className:"shrink-0 rounded-full bg-white/15 border border-white/20 text-white/95 px-2 py-0.5 text-[10px] font-semibold capitalize backdrop-blur-md",children:g}),x?.slice(0,3).map(Ee=>s.jsx("span",{className:"shrink-0 rounded-full bg-white/10 border border-white/15 text-white/85 px-2 py-0.5 text-[10px] backdrop-blur-md",children:Ee},Ee))]}),(!D||W)&&s.jsxs("div",{className:"flex items-center justify-between gap-2 pt-1 shrink-0",children:[D?s.jsx("span",{}):s.jsxs("div",{className:"flex items-center gap-3 text-[11px] text-white/80",children:[s.jsxs("span",{className:"inline-flex items-center gap-1",children:[s.jsx(g4,{rating:y}),w>0&&s.jsxs("span",{className:"text-white/60",children:["(",Ao(w),")"]})]}),s.jsxs("span",{className:"inline-flex items-center gap-1",children:[s.jsx("svg",{viewBox:"0 0 24 24",width:"12",height:"12",fill:"none",stroke:"currentColor",strokeWidth:"2","aria-hidden":!0,children:s.jsx("path",{d:"M12 3v12m0 0l-4-4m4 4l4-4M5 21h14"})}),Ao(N)]})]}),W&&s.jsx("div",{className:"flex items-center gap-2",onClick:Ee=>Ee.stopPropagation(),children:W})]})]})]})}return s.jsxs("div",{onClick:Y,className:`group asset-card card-shine relative flex flex-col ${Y?"cursor-pointer":""} ${O?"ring-1 ring-brand-500/60":""} ${_?"ring-2 ring-brand-500 shadow-lg shadow-brand-500/20":""} ${ae}`,children:[s.jsx("div",{className:"pointer-events-none absolute inset-x-0 top-0 h-[2px] opacity-0 group-hover:opacity-100 transition-opacity duration-300",style:{background:`linear-gradient(90deg, transparent, ${F.accent}, transparent)`}}),s.jsx("div",{className:"pointer-events-none absolute -top-10 -left-10 w-36 h-36 rounded-full blur-2xl opacity-[0.12] group-hover:opacity-20 transition-opacity duration-300",style:{background:re}}),U&&s.jsx("div",{className:"absolute top-2.5 right-2.5 z-10",onClick:I=>I.stopPropagation(),children:U}),s.jsxs("div",{className:"relative p-4 flex flex-col flex-1 gap-2.5",children:[s.jsxs("div",{className:"flex items-start gap-3",children:[s.jsx(mK,{type:X,seed:J,icon:l,hubBase:d,size:46,rounded:"rounded-2xl",className:"ring-1 ring-white/10 shadow-sm shadow-black/20"}),s.jsxs("div",{className:`min-w-0 flex-1 ${U?"pr-7":""}`,children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("h3",{className:"text-sm font-semibold text-fg-primary truncate group-hover:text-brand-300 transition-colors",children:n}),p&&s.jsxs("span",{className:"chip shrink-0",children:["v",p]}),ce&&s.jsx("span",{className:"ml-auto shrink-0",children:ce})]}),(we||z)&&s.jsxs("div",{className:"mt-1 flex items-center gap-1.5 text-[11px] text-fg-tertiary min-w-0",children:[m&&s.jsx(f0,{name:m.displayName,username:m.username,avatarUrl:m.avatarUrl,hubBase:d,size:15}),we&&s.jsx("span",{className:"truncate",children:we}),z&&s.jsxs(s.Fragment,{children:[we&&s.jsx("span",{className:"text-fg-muted",children:"·"}),s.jsx("span",{className:"font-semibold shrink-0",style:{color:F.accent},children:F.label})]})]})]})]}),r&&s.jsx("p",{className:"text-[13px] text-fg-secondary truncate leading-snug",children:r}),(g||x&&x.length>0)&&s.jsxs("div",{className:"flex flex-wrap gap-1.5",children:[g&&s.jsx("span",{className:"chip-accent capitalize",children:g}),x?.slice(0,3).map(I=>s.jsx("span",{className:"chip",children:I},I)),(x?.length??0)>3&&s.jsxs("span",{className:"text-[10px] text-fg-muted self-center",children:["+",(x?.length??0)-3]})]}),(()=>{const I=Z??(D?null:s.jsxs("span",{className:"flex items-center gap-3 text-[11px] text-fg-tertiary",children:[s.jsxs("span",{className:"inline-flex items-center gap-1",children:[s.jsx(g4,{rating:y}),s.jsx("span",{className:"text-fg-muted",children:w>0?`(${Ao(w)})`:""})]}),s.jsxs("span",{className:"inline-flex items-center gap-1",children:[s.jsx("svg",{viewBox:"0 0 24 24",width:"12",height:"12",fill:"none",stroke:"currentColor",strokeWidth:"2","aria-hidden":!0,children:s.jsx("path",{d:"M12 3v12m0 0l-4-4m4 4l4-4M5 21h14"})}),Ao(N)]})]}));return!I&&!W?null:s.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-2 pt-2 mt-auto border-t border-border-subtle/60",onClick:Ee=>Ee.stopPropagation(),children:[I&&s.jsx("div",{className:"min-w-0 flex items-center gap-2",children:I}),W&&s.jsx("div",{className:"flex flex-wrap items-center gap-2 justify-end",children:W})]})})()]})]})}function Er({children:e,maxCardWidth:t=400,gap:n="1rem",className:r=""}){const o=k.useRef(null),[l,u]=k.useState(0);k.useEffect(()=>{const p=o.current;if(!p)return;u(p.clientWidth);const g=new ResizeObserver(x=>{for(const y of x)u(y.contentRect.width)});return g.observe(p),()=>g.disconnect()},[]);const d=Math.max(1,Math.ceil((l||t)/t)),m=k.Children.toArray(e),h=Array.from({length:d},()=>[]);return m.forEach((p,g)=>{h[g%d].push(p)}),s.jsx("div",{ref:o,className:`flex items-start ${r}`,style:{gap:n},children:h.map((p,g)=>s.jsx("div",{className:"flex flex-col flex-1 min-w-0",style:{gap:n,maxWidth:t},children:p},g))})}function hK(e){const t=e.indexOf(".markus/builder-artifacts/");return t>=0?"~/"+e.slice(t):e}const pK=[{id:"hireAgent",icon:"✦",color:"from-brand-500 to-purple-600",borderColor:"border-brand-500/30 hover:border-brand-400/50",bgColor:"bg-brand-500/10"},{id:"buildTeam",icon:"◈",color:"from-blue-500 to-blue-600",borderColor:"border-blue-500/30 hover:border-blue-400/50",bgColor:"bg-blue-500/10"},{id:"createSkill",icon:"⬡",color:"from-green-500 to-green-600",borderColor:"border-green-500/30 hover:border-green-400/50",bgColor:"bg-green-500/10"}];function gK(){const[e,t]=k.useState(()=>{const r=window.location.hash.slice(1).split("/");return lc(r[0])===me.BUILDER&&r[1]&&r[2]?{type:r[1],name:decodeURIComponent(r[2])}:null});return k.useEffect(()=>{const n=()=>{const o=window.location.hash.slice(1).split("/");lc(o[0])===me.BUILDER&&o[1]&&o[2]?t({type:o[1],name:decodeURIComponent(o[2])}):t(null)};return window.addEventListener("hashchange",n),()=>window.removeEventListener("hashchange",n)},[]),e}const k3="markus_builder_shared_map";function bK(){try{const e=localStorage.getItem(k3);if(!e)return new Map;const t=JSON.parse(e);return new Map(Object.entries(t))}catch{return new Map}}function kd(e){try{localStorage.setItem(k3,JSON.stringify(Object.fromEntries(e)))}catch{}}function S3({authUser:e}={}){const{t}=ft(["builder","common"]),n=Uo(),r=gK(),[o,l]=k.useState([]),[u,d]=k.useState([]),[m,h]=k.useState(!1),[p,g]=k.useState("all"),[x,y]=k.useState(null),[w,N]=k.useState(new Map),[T,C]=k.useState(null),[j,_]=k.useState(null),[O,z]=k.useState(null),[D,H]=k.useState(bK),[W,Z]=k.useState(null),[U,Y]=k.useState(null),[ae,X]=k.useState(null),[F,J]=k.useState(null),[B,Q]=k.useState(null),[re,we]=k.useState("creations"),[$,G]=k.useState([]),[ce,I]=k.useState(""),[Ee,Ue]=k.useState([]),[De,Ke]=k.useState(!1),[st,mt]=k.useState("all"),ct=k.useCallback(()=>{h(!0),Promise.all([(vi(Tr.builderArtifacts)??Ce.builder.artifacts.list()).then(se=>se?.artifacts??[]).catch(()=>[]),(vi(Tr.builderAgents)??Ce.agents.list()).then(se=>se?.agents??[]).catch(()=>[]),(vi(Tr.builderHubMyItems)??lt.myItems()).then(se=>se?.items??[]).catch(()=>[]),(vi(Tr.builderInstalled)??Ce.builder.artifacts.installed()).then(se=>se?.installed??{}).catch(()=>({}))]).then(([se,et,nt,Ge])=>{if(d(se),l(et),nt.length>0){const xt=new Map;for(const pe of nt){const V=pe.itemType==="agent"?"agent":pe.itemType==="team"?"team":"skill";for(const xe of se)xe.type===V&&(pe.slug===xe.name||pe.name===(xe.meta.displayName||xe.meta.name||xe.name))&&xt.set(`${xe.type}/${xe.name}`,{id:pe.id,name:pe.name,slug:pe.slug||xe.name,version:pe.version||"1.0.0",visibility:pe.visibility??"public",moderationStatus:pe.moderationStatus,pendingReview:pe.pendingReview})}xt.size>0&&H(pe=>{const V=new Map(pe);for(const[xe,We]of xt)V.set(xe,We);return kd(V),V})}const Qe=new Map;for(const xt of se){const pe=`${xt.type}/${xt.name}`,V=Ge[pe];V&&Qe.set(pe,{agentId:V.agentId,agentIds:V.agentIds,teamId:V.teamId})}N(Qe)}).finally(()=>h(!1))},[]);k.useEffect(()=>{ct();const se=et=>{et.detail?.page===me.BUILDER&&ct()};return window.addEventListener("markus:navigate",se),()=>window.removeEventListener("markus:navigate",se)},[ct]);const Dt=se=>{const et=o.find(nt=>nt.role==="Secretary"||nt.name==="Secretary");et?at.navigate(me.TEAM,{agentId:et.id,prefillMessage:se}):at.navigate(me.TEAM,{prefillMessage:se})},Mt=async se=>{const et=`${se.type}/${se.name}`;if(!w.has(et)){y({key:et,action:"install"});try{const nt=await Ce.builder.artifacts.install(se.type,se.name),Ge={};nt.agent&&typeof nt.agent=="object"&&(Ge.agentId=nt.agent.id),nt.team&&typeof nt.team=="object"&&(Ge.teamId=nt.team.id),Array.isArray(nt.agents)&&(Ge.agentIds=nt.agents.map(Qe=>Qe.id)),N(Qe=>new Map(Qe).set(et,Ge)),window.dispatchEvent(new CustomEvent("markus:data-changed"))}catch(nt){console.error("Install failed:",nt),Y({title:t("common:install"),message:t("installFailed",{error:String(nt)}),variant:"danger"})}finally{y(null)}}},Xt=async se=>{const et=`${se.type}/${se.name}`;if(w.has(et)){y({key:et,action:"uninstall"});try{await Ce.builder.artifacts.uninstall(se.type,se.name),N(nt=>{const Ge=new Map(nt);return Ge.delete(et),Ge}),window.dispatchEvent(new CustomEvent("markus:data-changed"))}catch(nt){console.error("Uninstall failed:",nt),Y({title:t("common:uninstall"),message:t("uninstallFailed",{error:String(nt)}),variant:"danger"})}finally{y(null)}}},Me=async(se,et)=>{const nt=`${se.type}/${se.name}`;y({key:nt,action:"share"});try{const Ge=await Ce.builder.artifacts.ensureSlugSafe(se.type,se.name,se.meta.displayName||se.meta.name||se.name),Qe=Ge.name,xt=Ge.slug||dc(Qe);if(!xt)throw new Error("Invalid package slug: use English kebab-case for the artifact name (e.g. qwen-multimodal). Chinese-only names cannot be shared — rename the package slug and put the Chinese title in displayName.");const pe=`${se.type}/${Qe}`;Ge.converted&&(d(oe=>oe.map(_e=>_e.type===se.type&&_e.name===se.name?{..._e,name:Qe,path:Ge.path,meta:{..._e.meta,name:Qe,displayName:Ge.displayName??_e.meta.displayName??se.name}}:_e)),H(oe=>{const _e=new Map(oe),de=_e.get(nt);return de&&(_e.delete(nt),_e.set(pe,{...de,slug:xt,name:Ge.displayName??de.name})),kd(_e),_e}),N(oe=>{const _e=new Map(oe),de=_e.get(nt);return de&&(_e.delete(nt),_e.set(pe,de)),_e}));const V=await Ce.builder.artifacts.get(se.type,Qe);let xe={...se.meta,name:Qe,displayName:Ge.displayName??se.meta.displayName??se.name};try{const oe=V.files?.[`${se.type}.json`]??V.files?.["agent.json"]??V.files?.["team.json"]??V.files?.["skill.json"];oe&&(xe={...JSON.parse(oe),...xe,name:Qe,displayName:xe.displayName})}catch{}const We=xe.displayName||xe.name||Qe,he=xe.description||"",ye=xe.category||"general",Ze=Array.isArray(xe.tags)?xe.tags:[];let rt=xe.icon||void 0;const St=xe.version||"1.0.0";if(rt&&!rt.startsWith("http")&&/\.(png|jpe?g|gif|webp|svg)$/i.test(rt)){const oe=rt.split("/").pop()??rt;try{const _e=await fetch(`/api/builder/artifacts/${se.type}s/${encodeURIComponent(Qe)}/images/${encodeURIComponent(oe)}`);if(_e.ok){const de=await _e.blob(),$e=new File([de],oe,{type:de.type}),qe=await lt.uploadImage($e);qe?.url&&(rt=qe.url)}}catch{}}let Bt;const wt=[],hn=Array.isArray(xe.screenshots)?xe.screenshots:[];for(let oe=0;oe<hn.length;oe++){const _e=hn[oe],de=_e.split("/").pop()??_e;try{const $e=await fetch(`/api/builder/artifacts/${se.type}s/${encodeURIComponent(Qe)}/images/${encodeURIComponent(de)}`);if($e.ok){const qe=await $e.blob(),q=new File([qe],de,{type:qe.type}),ie=await lt.uploadImage(q);ie?.url&&(wt.push({url:ie.url,alt:de,order:oe}),(oe===0||xe.thumbnail===_e)&&(Bt=ie.url))}}catch{}}const R=await lt.publishViaProxy({itemType:se.type==="team"?"team":se.type==="skill"?"skill":"agent",name:We,slug:xt,description:he,category:ye,tags:Ze,icon:rt,version:St,config:{...xe,name:Qe,displayName:We},files:V.files&&Object.keys(V.files).length>0?V.files:void 0,thumbnailUrl:Bt,images:wt.length>0?wt:void 0,priceCents:et?.priceCents,donationsEnabled:et?.donationsEnabled,visibility:et?.visibility,orgId:et?.orgId});R.id&&(H(_e=>{const de=new Map(_e);return de.set(pe,{id:R.id,name:We,slug:R.slug??xt,version:St,visibility:R.visibility??et?.visibility??"public",moderationStatus:R.moderationStatus,pendingReview:R.pendingReview}),kd(de),de}),(R.visibility??et?.visibility??"public")!=="org"&&(R.moderationStatus==="pending"||R.pendingReview)?Y({title:t("common:share"),message:Ge.converted?t("share.convertedAndSubmitted",{previous:se.name,slug:xt}):R.updated?t("share.updateSubmitted"):t("share.submittedForReview"),variant:"primary"}):Ge.converted&&Y({title:t("common:share"),message:t("share.convertedSlug",{previous:se.name,slug:xt}),variant:"primary"}))}catch(Ge){console.error("Share failed:",Ge),Y({title:t("common:share"),message:t("shareFailed",{error:Ge instanceof Error?Ge.message:String(Ge)}),variant:"danger"})}finally{y(null)}},Ne=async()=>{if(!W)return;const{key:se}=W,et=D.get(se);if(Z(null),!et)return;const nt=et.id;y({key:se,action:"hubDelete"});try{await lt.deleteItem(nt),H(Ge=>{const Qe=new Map(Ge);return Qe.delete(se),kd(Qe),Qe})}catch(Ge){console.error("Hub delete failed:",Ge),Y({title:t("unshare"),message:t("hubDeleteFailed",{error:String(Ge)}),variant:"danger"})}finally{y(null)}},Re=async()=>{if(!T)return;const se=T,et=`${se.type}/${se.name}`;C(null),y({key:et,action:"delete"});try{await Ce.builder.artifacts.delete(se.type,se.name),d(nt=>nt.filter(Ge=>!(Ge.type===se.type&&Ge.name===se.name))),N(nt=>{const Ge=new Map(nt);return Ge.delete(et),Ge}),window.dispatchEvent(new CustomEvent("markus:data-changed"))}catch(nt){console.error("Delete failed:",nt)}finally{y(null)}},ut=p==="all"?u:u.filter(se=>se.type===p);k.useEffect(()=>{re!=="orgAssets"||$.length>0||lt.myOrgs().then(se=>{G(se.memberships),se.memberships.length>0&&!ce&&I(se.memberships[0].id)}).catch(()=>{})},[re,$.length,ce]),k.useEffect(()=>{re!=="orgAssets"||!ce||(Ke(!0),lt.browseItems({orgId:ce,limit:100}).then(se=>Ue(se.items??[])).catch(()=>Ue([])).finally(()=>Ke(!1)))},[re,ce]);const it=st==="all"?Ee:Ee.filter(se=>se.itemType===st),bt=se=>{history.pushState(null,"",Si(me.BUILDER,`${se.type}/${encodeURIComponent(se.name)}`)),window.dispatchEvent(new HashChangeEvent("hashchange"))};return r?s.jsx(Ai,{type:r.type,name:r.name,authUser:e,onBack:()=>{history.pushState(null,"",Si(me.BUILDER)),window.dispatchEvent(new HashChangeEvent("hashchange"))}}):s.jsx("div",{className:"flex-1 overflow-y-auto",children:s.jsxs("div",{className:`max-w-5xl mx-auto w-full ${n?"px-4 py-5":"px-6 py-6"}`,children:[s.jsxs("div",{className:"mb-6",children:[s.jsxs("div",{className:"flex items-center justify-between mb-4",children:[s.jsxs("div",{children:[s.jsx("h1",{className:"text-xl font-bold text-fg-primary",children:t("title")}),s.jsx("p",{className:"text-xs text-fg-tertiary mt-1",children:t("subtitle")})]}),s.jsx("button",{onClick:ct,className:"text-xs text-fg-tertiary hover:text-fg-secondary transition-colors px-3 py-1.5 rounded-lg border border-border-default hover:border-gray-600",children:t("common:refresh")})]}),s.jsx("div",{className:`grid ${n?"grid-cols-1 gap-2":"grid-cols-3 gap-3"}`,children:pK.map(se=>{const et=t(`prompts.${se.id}Prompt`),nt=t(`prompts.${se.id}Examples`,{returnObjects:!0}),Ge=Array.isArray(nt)?nt:[];return s.jsx("button",{onClick:()=>Dt(et),className:`group text-left w-full rounded-xl border ${se.borderColor} bg-surface-secondary/60 p-4 transition-all hover:bg-surface-secondary/80 hover:shadow-lg`,children:s.jsxs("div",{className:"flex items-start gap-3",children:[s.jsx("div",{className:`w-10 h-10 text-xl rounded-lg ${se.bgColor} flex items-center justify-center shrink-0`,children:se.icon}),s.jsxs("div",{className:"flex-1 min-w-0",children:[s.jsx("h3",{className:`text-sm font-semibold bg-gradient-to-r ${se.color} bg-clip-text text-transparent`,children:t(`prompts.${se.id}`)}),s.jsx("p",{className:"text-[11px] text-fg-tertiary mt-1 leading-relaxed",children:t(`prompts.${se.id}Desc`)}),Ge.length>0&&s.jsx("div",{className:"mt-2 flex flex-wrap gap-1.5",children:Ge.slice(0,2).map((Qe,xt)=>s.jsxs("span",{className:"text-[10px] text-fg-muted bg-surface-elevated/60 rounded-full px-2 py-0.5 border border-border-default",onClick:pe=>{pe.stopPropagation(),Dt(et+Qe)},children:["“",Qe,"”"]},xt))})]})]})},se.id)})})]}),s.jsx("div",{className:"mb-3",children:s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsxs("div",{className:"flex items-center gap-3",children:[s.jsx("button",{onClick:()=>we("creations"),className:`text-sm font-semibold transition-colors ${re==="creations"?"text-fg-primary":"text-fg-tertiary hover:text-fg-secondary"}`,children:t("myCreations.title")}),s.jsx("button",{onClick:()=>we("orgAssets"),className:`text-sm font-semibold transition-colors ${re==="orgAssets"?"text-fg-primary":"text-fg-tertiary hover:text-fg-secondary"}`,children:t("orgAssets.title")})]}),re==="creations"&&s.jsx("div",{className:"flex gap-1.5",children:["all","agent","team","skill"].map(se=>s.jsx("button",{onClick:()=>g(se),className:`text-xs px-2.5 py-1 rounded-lg transition-colors ${p===se?"bg-brand-600 text-white":"text-fg-tertiary hover:text-fg-secondary hover:bg-surface-elevated"}`,children:t(se==="all"?"myCreations.filterAll":se==="agent"?"myCreations.filterAgents":se==="team"?"myCreations.filterTeams":"myCreations.filterSkills")},se))}),re==="orgAssets"&&s.jsx("div",{className:"flex gap-1.5",children:["all","agent","team","skill"].map(se=>s.jsx("button",{onClick:()=>mt(se),className:`text-xs px-2.5 py-1 rounded-lg transition-colors ${st===se?"bg-brand-600 text-white":"text-fg-tertiary hover:text-fg-secondary hover:bg-surface-elevated"}`,children:t(se==="all"?"myCreations.filterAll":se==="agent"?"myCreations.filterAgents":se==="team"?"myCreations.filterTeams":"myCreations.filterSkills")},se))})]})}),re==="orgAssets"&&$.length>0&&s.jsx("div",{className:"flex gap-2 mb-3 overflow-x-auto pb-1",children:$.map(se=>s.jsx("button",{onClick:()=>I(se.id),className:`text-xs px-3 py-1.5 rounded-full whitespace-nowrap border transition-colors ${ce===se.id?"bg-blue-500/15 border-blue-500/40 text-blue-400":"border-border-default text-fg-tertiary hover:text-fg-secondary hover:border-gray-600"}`,children:se.name},se.id))}),re==="orgAssets"&&($.length===0&&!De?s.jsx("div",{className:"text-center py-12",children:s.jsx("div",{className:"text-fg-tertiary text-sm",children:t("orgAssets.noOrgs")})}):De?s.jsx("div",{className:"text-center text-fg-tertiary py-12 text-sm",children:t("orgAssets.loading")}):it.length===0?s.jsx("div",{className:"text-center py-12",children:s.jsx("div",{className:"text-fg-tertiary text-sm",children:t("orgAssets.noItems")})}):s.jsx(Er,{children:it.map(se=>{const et=se.author?.username&&se.slug?`${lt.getUrl()}/@${encodeURIComponent(se.author.username)}/${encodeURIComponent(se.slug)}`:null;return s.jsx(sa,{type:se.itemType,name:se.name,description:se.description,seed:se.slug||se.id||se.name,icon:se.icon,cover:se.thumbnailUrl,hubBase:lt.getUrl(),author:se.author,version:se.version,rating:parseFloat(se.avgRating)||0,ratingCount:se.ratingCount,downloadCount:se.downloadCount,actions:et?s.jsxs("a",{href:et,target:"_blank",rel:"noopener noreferrer",onClick:nt=>{nt.stopPropagation(),Gd()&&(nt.preventDefault(),Oo(et))},className:"text-xs px-3 py-1.5 rounded-lg border border-border-default text-fg-secondary hover:text-fg-primary hover:border-gray-600 transition-colors inline-flex items-center gap-1",children:[s.jsxs("svg",{className:"w-3 h-3",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[s.jsx("path",{d:"M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6"}),s.jsx("polyline",{points:"15 3 21 3 21 9"}),s.jsx("line",{x1:"10",y1:"14",x2:"21",y2:"3"})]}),"Hub"]}):void 0},se.id)})})),re==="creations"&&(m&&u.length===0?s.jsx("div",{className:"text-center text-fg-tertiary py-12 text-sm",children:t("myCreations.loadingArtifacts")}):ut.length===0?s.jsxs("div",{className:"text-center py-12",children:[s.jsx("div",{className:"text-fg-tertiary text-sm",children:t("myCreations.noArtifacts")}),s.jsx("div",{className:"text-fg-muted text-xs mt-1",children:t("myCreations.noArtifactsHint")})]}):s.jsx(Er,{children:ut.map(se=>{const et=se.meta.displayName||se.meta.name||se.name,nt=se.meta.description||"",Ge=`${se.type}/${se.name}`,Qe=x?.key===Ge?x.action:null,xt=D.get(Ge),pe=se.meta.version||"1.0.0",V=!!xt,xe=V&&xt.version!==pe,We=()=>{const wt=lt.getUser();return!xt||!wt?null:`${lt.getUrl()}/@${encodeURIComponent(wt.username)}/${encodeURIComponent(xt.slug)}`},he=V&&(xt?.moderationStatus==="pending"||xt?.moderationStatus==="rejected"||!!xt?.pendingReview),ye=s.jsxs("div",{className:"flex items-center gap-1.5 justify-end",onClick:wt=>wt.stopPropagation(),children:[w.has(Ge)?s.jsxs("button",{onClick:()=>z(se),disabled:!!Qe,className:"text-xs px-3 py-1.5 rounded-lg border border-green-600/30 text-green-600 hover:bg-red-500/10 hover:text-red-500 hover:border-red-500/30 transition-colors disabled:opacity-50 inline-flex items-center gap-1",children:[s.jsxs("svg",{className:"w-3 h-3",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":!0,children:[s.jsx("path",{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4"}),s.jsx("polyline",{points:"17 8 12 3 7 8"}),s.jsx("line",{x1:"12",y1:"3",x2:"12",y2:"15"})]}),t(Qe==="uninstall"?"common:uninstalling":"common:uninstall")]}):s.jsxs("button",{onClick:()=>_(se),disabled:!!Qe,className:"text-xs px-3 py-1.5 rounded-lg bg-brand-600 hover:bg-brand-500 text-white transition-colors disabled:opacity-50 inline-flex items-center gap-1",children:[s.jsxs("svg",{className:"w-3 h-3",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":!0,children:[s.jsx("path",{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4"}),s.jsx("polyline",{points:"7 10 12 15 17 10"}),s.jsx("line",{x1:"12",y1:"15",x2:"12",y2:"3"})]}),t(Qe==="install"?"common:installing":"common:install")]}),V&&he?xt?.moderationStatus==="pending"?s.jsxs("span",{className:"text-xs px-2 py-1.5 rounded-lg border border-amber-500/30 text-amber-400 inline-flex items-center gap-1",title:t("share.underReviewTip"),children:[s.jsxs("svg",{className:"w-3 h-3",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":!0,children:[s.jsx("circle",{cx:"12",cy:"12",r:"10"}),s.jsx("polyline",{points:"12 6 12 12 16 14"})]}),t("share.underReview")]}):xt?.moderationStatus==="rejected"?s.jsxs("span",{className:"text-xs px-2 py-1.5 rounded-lg border border-red-500/30 text-red-400 inline-flex items-center gap-1",title:t("share.rejectedTip"),children:[s.jsxs("svg",{className:"w-3 h-3",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":!0,children:[s.jsx("circle",{cx:"12",cy:"12",r:"10"}),s.jsx("line",{x1:"15",y1:"9",x2:"9",y2:"15"}),s.jsx("line",{x1:"9",y1:"9",x2:"15",y2:"15"})]}),t("share.rejected")]}):s.jsxs("span",{className:"text-xs px-2 py-1.5 rounded-lg border border-amber-500/30 text-amber-400 inline-flex items-center gap-1",title:t("share.updateUnderReviewTip"),children:[s.jsxs("svg",{className:"w-3 h-3",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":!0,children:[s.jsx("circle",{cx:"12",cy:"12",r:"10"}),s.jsx("polyline",{points:"12 6 12 12 16 14"})]}),t("share.updateUnderReview")]}):V?s.jsxs(s.Fragment,{children:[xe&&s.jsxs("button",{onClick:()=>{const wt=xt?.visibility??"public";Me(se,{visibility:wt})},disabled:!!Qe,className:"text-xs px-3 py-1.5 rounded-lg border border-amber-500/30 text-amber-400 hover:bg-amber-500/10 hover:border-amber-500/50 transition-colors disabled:opacity-50 inline-flex items-center gap-1",children:[s.jsxs("svg",{className:"w-3 h-3",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":!0,children:[s.jsx("polyline",{points:"23 4 23 10 17 10"}),s.jsx("polyline",{points:"1 20 1 14 7 14"}),s.jsx("path",{d:"M3.51 9a9 9 0 0 1 14.85-3.36L23 10M1 14l4.64 4.36A9 9 0 0 0 20.49 15"})]}),Qe==="share"?t("common:sharing"):t("share.updateVersion",{version:pe})]}),s.jsxs("a",{href:We()??"#",target:"_blank",rel:"noopener noreferrer",onClick:wt=>{const hn=We();Gd()&&hn&&(wt.preventDefault(),Oo(hn))},className:`text-xs px-3 py-1.5 rounded-lg border transition-colors inline-flex items-center gap-1 ${xt?.visibility==="org"?"border-blue-500/30 text-blue-500 hover:text-blue-400 hover:border-blue-400/40":xt?.visibility==="unlisted"?"border-gray-500/30 text-fg-tertiary hover:text-fg-secondary hover:border-gray-400/40":"border-green-600/30 text-green-600 hover:text-green-500 hover:border-green-500/40"}`,children:[xt?.visibility==="org"?s.jsxs("svg",{className:"w-3 h-3",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":!0,children:[s.jsx("path",{d:"M3 21h18"}),s.jsx("path",{d:"M9 8h1"}),s.jsx("path",{d:"M9 12h1"}),s.jsx("path",{d:"M9 16h1"}),s.jsx("path",{d:"M14 8h1"}),s.jsx("path",{d:"M14 12h1"}),s.jsx("path",{d:"M14 16h1"}),s.jsx("path",{d:"M5 21V5a2 2 0 0 1 2-2h10a2 2 0 0 1 2 2v16"})]}):xt?.visibility==="unlisted"?s.jsxs("svg",{className:"w-3 h-3",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":!0,children:[s.jsx("path",{d:"M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71"}),s.jsx("path",{d:"M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71"})]}):s.jsxs("svg",{className:"w-3 h-3",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":!0,children:[s.jsx("path",{d:"M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6"}),s.jsx("polyline",{points:"15 3 21 3 21 9"}),s.jsx("line",{x1:"10",y1:"14",x2:"21",y2:"3"})]}),xt?.visibility==="org"?t("visibility.sharedOrg"):xt?.visibility==="unlisted"?t("visibility.sharedUnlisted"):t("visibility.shared")]}),s.jsxs("button",{onClick:()=>Z({key:Ge,name:et}),disabled:!!Qe,className:"text-xs px-2.5 py-1.5 rounded-lg border border-border-default text-fg-secondary hover:text-amber-500 hover:border-amber-500/40 hover:bg-amber-500/10 transition-colors disabled:opacity-50 inline-flex items-center gap-1",title:t("removeFromHubTooltip"),children:[s.jsxs("svg",{className:"w-3 h-3",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":!0,children:[s.jsx("path",{d:"M18.84 12.25l1.72-1.71a5 5 0 0 0-7.07-7.07l-1.72 1.71"}),s.jsx("path",{d:"M5.17 11.75l-1.71 1.71a5 5 0 0 0 7.07 7.07l1.71-1.71"}),s.jsx("line",{x1:"2",y1:"2",x2:"22",y2:"22"})]}),t("unshare")]})]}):s.jsxs("button",{onClick:async()=>{await lt.ensureAuth(),Array.isArray(se.meta.screenshots)&&se.meta.screenshots.length>0?Q(se):X(se)},disabled:!!Qe,className:"text-xs px-3 py-1.5 rounded-lg border border-border-default text-fg-secondary hover:text-green-600 hover:border-green-500/30 transition-colors disabled:opacity-50 inline-flex items-center gap-1",children:[s.jsxs("svg",{className:"w-3 h-3",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":!0,children:[s.jsx("circle",{cx:"18",cy:"5",r:"3"}),s.jsx("circle",{cx:"6",cy:"12",r:"3"}),s.jsx("circle",{cx:"18",cy:"19",r:"3"}),s.jsx("line",{x1:"8.59",y1:"13.51",x2:"15.42",y2:"17.49"}),s.jsx("line",{x1:"15.41",y1:"6.51",x2:"8.59",y2:"10.49"})]}),t(Qe==="share"?"common:sharing":"common:share")]})]}),Ze=s.jsx("button",{onClick:()=>C(se),disabled:!!Qe,className:"w-7 h-7 rounded-lg text-fg-muted hover:text-red-500 hover:bg-red-500/10 transition-colors disabled:opacity-50 inline-flex items-center justify-center",title:t("deleteLocalTooltip"),children:s.jsxs("svg",{className:"w-3.5 h-3.5",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":!0,children:[s.jsx("polyline",{points:"3 6 5 6 21 6"}),s.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"})]})}),rt=se.meta.icon,Bt=!!rt&&/\.(png|jpe?g|gif|webp|svg)$/i.test(rt)?rt.startsWith("http")||rt.startsWith("/")?rt:`/api/builder/artifacts/${se.type}s/${encodeURIComponent(se.name)}/images/${encodeURIComponent(rt.split("/").pop()??"")}`:rt;return s.jsx(sa,{type:se.type,name:et,description:nt,seed:Ge,icon:Bt,version:pe,footerLeft:s.jsxs("span",{className:"flex items-center gap-2 text-[10px] text-fg-tertiary min-w-0",children:[s.jsx("button",{onClick:wt=>{wt.stopPropagation(),Ce.system.openPath(se.path).catch(()=>{})},className:"hover:text-fg-secondary transition-colors truncate min-w-0",title:se.path,children:hK(se.path)}),s.jsx("span",{className:"shrink-0",children:"·"}),s.jsx("span",{className:"shrink-0",children:new Date(se.updatedAt).toLocaleDateString()})]}),headerAction:Ze,actions:ye,onClick:()=>bt(se)},Ge)})})),j&&s.jsx(dr,{variant:"primary",title:t("confirmInstall"),message:t("confirmInstallMsg",{name:j.meta.displayName||j.meta.name||j.name}),confirmLabel:t("common:install"),onConfirm:()=>{const se=j;_(null),Mt(se)},onCancel:()=>_(null)}),O&&s.jsx(dr,{variant:"primary",title:t("confirmUninstall"),message:t("confirmUninstallMsg",{name:O.meta.displayName||O.meta.name||O.name}),confirmLabel:t("common:uninstall"),onConfirm:()=>{const se=O;z(null),Xt(se)},onCancel:()=>z(null)}),T&&s.jsx(dr,{title:t("confirmDeleteLocal"),message:t("deleteCannotUndo",{name:T.meta.displayName||T.meta.name||T.name}),confirmLabel:t("common:delete"),onConfirm:Re,onCancel:()=>C(null)}),W&&s.jsx(dr,{title:t("confirmUnshare"),message:t("removeFromHub",{name:W.name}),confirmLabel:t("unshare"),onConfirm:()=>{Ne()},onCancel:()=>Z(null)}),U&&s.jsx(dr,{alertOnly:!0,variant:U.variant??"primary",title:U.title,message:U.message,onConfirm:()=>Y(null),onCancel:()=>Y(null)}),ae&&s.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/60 backdrop-blur-sm",onClick:()=>X(null),children:s.jsxs("div",{className:"bg-surface-secondary border border-border-default rounded-xl max-w-sm w-full mx-4 p-6 shadow-2xl",onClick:se=>se.stopPropagation(),children:[s.jsx("h3",{className:"text-base font-semibold text-fg-primary mb-2",children:t("common:share")}),s.jsx("p",{className:"text-sm text-fg-secondary mb-5",children:t("share.imagePrompt")}),s.jsxs("div",{className:"flex gap-3",children:[s.jsx("button",{onClick:()=>{const se=ae;X(null),Q(se)},className:"flex-1 text-sm px-4 py-2 rounded-lg border border-border-default text-fg-secondary hover:text-fg-primary hover:border-fg-tertiary transition-colors",children:t("share.directly")}),s.jsx("button",{onClick:()=>{const se=ae;X(null),bt(se)},className:"flex-1 text-sm px-4 py-2 rounded-lg bg-brand-600 hover:bg-brand-500 text-white transition-colors",children:t("share.addImagesFirst")})]})]})}),F&&s.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/60 backdrop-blur-sm",onClick:()=>J(null),children:s.jsx("div",{className:"bg-surface-secondary border border-border-default rounded-xl max-w-sm w-full mx-4 p-6 shadow-2xl",onClick:se=>se.stopPropagation(),children:s.jsx(yK,{isUpdate:D.has(`${F.type}/${F.name}`),onCancel:()=>J(null),onConfirm:(se,et)=>{const nt=F;J(null),Me(nt,{priceCents:et>0?et:void 0})}})})}),B&&s.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/60 backdrop-blur-sm",onClick:()=>Q(null),children:s.jsx("div",{className:"bg-surface-secondary border border-border-default rounded-xl max-w-sm w-full mx-4 p-6 shadow-2xl",onClick:se=>se.stopPropagation(),children:s.jsx(xK,{onCancel:()=>Q(null),onConfirm:(se,et,nt,Ge)=>{const Qe=B;Q(null),Me(Qe,{visibility:se,orgId:et,priceCents:nt,donationsEnabled:Ge})}})})})]})})}function xK({onCancel:e,onConfirm:t}){const{t:n}=ft(["builder","common"]),[r,o]=k.useState("public"),[l,u]=k.useState([]),[d,m]=k.useState(""),[h,p]=k.useState(!1),[g,x]=k.useState(0),[y,w]=k.useState(!1);k.useEffect(()=>{r==="org"&&l.length===0&&(p(!0),lt.myOrgs().then(C=>{u(C.memberships),C.memberships.length>0&&m(C.memberships[0].id)}).catch(()=>{}).finally(()=>p(!1)))},[r,l.length]);const N=r==="public"||r==="unlisted",T=[{value:"public",icon:s.jsxs("svg",{className:"w-4 h-4",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[s.jsx("circle",{cx:"12",cy:"12",r:"10"}),s.jsx("line",{x1:"2",y1:"12",x2:"22",y2:"12"}),s.jsx("path",{d:"M12 2a15.3 15.3 0 0 1 4 10 15.3 15.3 0 0 1-4 10 15.3 15.3 0 0 1-4-10 15.3 15.3 0 0 1 4-10z"})]}),label:n("visibility.public"),desc:n("visibility.publicDesc")},{value:"org",icon:s.jsxs("svg",{className:"w-4 h-4",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[s.jsx("path",{d:"M3 21h18"}),s.jsx("path",{d:"M9 8h1"}),s.jsx("path",{d:"M9 12h1"}),s.jsx("path",{d:"M9 16h1"}),s.jsx("path",{d:"M14 8h1"}),s.jsx("path",{d:"M14 12h1"}),s.jsx("path",{d:"M14 16h1"}),s.jsx("path",{d:"M5 21V5a2 2 0 0 1 2-2h10a2 2 0 0 1 2 2v16"})]}),label:n("visibility.org"),desc:n("visibility.orgDesc")},{value:"unlisted",icon:s.jsxs("svg",{className:"w-4 h-4",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[s.jsx("path",{d:"M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71"}),s.jsx("path",{d:"M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71"})]}),label:n("visibility.unlisted"),desc:n("visibility.unlistedDesc")}];return s.jsxs(s.Fragment,{children:[s.jsx("h3",{className:"text-base font-semibold text-fg-primary mb-4",children:n("visibility.label")}),s.jsx("div",{className:"space-y-2 mb-5",children:T.map(C=>s.jsxs("label",{className:`flex items-center gap-3 p-3 rounded-lg border cursor-pointer transition-colors ${r===C.value?"border-brand-500 bg-brand-500/10":"border-border-default hover:border-gray-600"}`,children:[s.jsx("input",{type:"radio",name:"visibility",checked:r===C.value,onChange:()=>o(C.value),className:"accent-brand-500"}),s.jsx("div",{className:"flex items-center gap-2 text-fg-secondary",children:C.icon}),s.jsxs("div",{children:[s.jsx("div",{className:"text-sm font-medium text-fg-primary",children:C.label}),s.jsx("div",{className:"text-[11px] text-fg-tertiary",children:C.desc})]})]},C.value))}),r==="org"&&s.jsxs("div",{className:"mb-5",children:[s.jsx("label",{className:"text-xs text-fg-secondary block mb-1.5",children:n("visibility.orgSelect")}),h?s.jsx("div",{className:"text-xs text-fg-tertiary py-2",children:"Loading..."}):l.length===0?s.jsx("div",{className:"text-xs text-fg-tertiary py-2",children:n("visibility.orgNone")}):s.jsx("select",{value:d,onChange:C=>m(C.target.value),className:"w-full text-sm px-3 py-2 rounded-lg bg-surface-elevated border border-border-default text-fg-primary",children:l.map(C=>s.jsx("option",{value:C.id,children:C.name},C.id))})]}),N&&s.jsxs("div",{className:"mb-5",children:[s.jsx("label",{className:"text-xs text-fg-secondary block mb-1.5",children:n("pricing.label")}),s.jsx("div",{className:"grid grid-cols-4 gap-2 mb-3",children:N3.map(C=>s.jsx("button",{type:"button",onClick:()=>x(C.cents),className:`text-sm px-2 py-2 rounded-lg border transition-colors ${g===C.cents?"border-brand-500 bg-brand-500/10 text-fg-primary":"border-border-default text-fg-secondary hover:border-gray-600"}`,children:C.label},C.cents))}),s.jsxs("label",{className:"flex items-center gap-2 cursor-pointer",children:[s.jsx("input",{type:"checkbox",checked:y,onChange:C=>w(C.target.checked),className:"accent-brand-500"}),s.jsx("span",{className:"text-xs text-fg-secondary",children:n("pricing.enableTips")})]})]}),N&&s.jsx("div",{className:"mb-4 text-[11px] text-fg-tertiary rounded-lg border border-border-default px-3 py-2",children:n("pricing.reviewNote")}),s.jsxs("div",{className:"flex gap-3",children:[s.jsx("button",{onClick:e,className:"flex-1 text-sm px-4 py-2 rounded-lg border border-border-default text-fg-secondary hover:text-fg-primary hover:border-gray-600 transition-colors",children:n("common:cancel")}),s.jsx("button",{onClick:()=>t(r,r==="org"?d:void 0,N&&g>0?g:void 0,N?y:void 0),disabled:r==="org"&&!d,className:"flex-1 text-sm px-4 py-2 rounded-lg bg-brand-600 hover:bg-brand-500 text-white transition-colors disabled:opacity-50 disabled:cursor-not-allowed",children:n("shareMode.share")})]})]})}const N3=[{cents:0,label:"Free"},{cents:100,label:"$1"},{cents:500,label:"$5"},{cents:1e3,label:"$10"}];function yK({isUpdate:e,onCancel:t,onConfirm:n}){const{t:r}=ft(["builder","common"]),[o,l]=k.useState(0);return s.jsxs(s.Fragment,{children:[s.jsx("h3",{className:"text-base font-semibold text-fg-primary mb-4",children:r(e?"shareMode.titleUpdate":"shareMode.title")}),s.jsx("div",{className:"space-y-2 mb-5",children:N3.map(u=>s.jsxs("label",{className:`flex items-center gap-3 p-3 rounded-lg border cursor-pointer transition-colors ${o===u.cents?"border-brand-500 bg-brand-500/10":"border-border-default hover:border-gray-600"}`,children:[s.jsx("input",{type:"radio",name:"sharePrice",checked:o===u.cents,onChange:()=>l(u.cents),className:"accent-brand-500"}),s.jsxs("div",{children:[s.jsx("div",{className:"text-sm font-medium text-fg-primary",children:u.label}),s.jsx("div",{className:"text-[11px] text-fg-tertiary",children:u.cents===0?r("shareMode.freeDesc"):r("shareMode.paidDesc")})]})]},u.cents))}),s.jsxs("div",{className:"flex gap-3",children:[s.jsx("button",{onClick:t,className:"flex-1 text-sm px-4 py-2 rounded-lg border border-border-default text-fg-secondary hover:text-fg-primary hover:border-gray-600 transition-colors",children:r("common:cancel")}),s.jsx("button",{onClick:()=>n(o>0?"paid":"free",o),className:"flex-1 text-sm px-4 py-2 rounded-lg bg-brand-600 hover:bg-brand-500 text-white transition-colors",children:r(e?"shareMode.update":"shareMode.share")})]})]})}const vK=Object.freeze(Object.defineProperty({__proto__:null,AgentBuilder:S3},Symbol.toStringTag,{value:"Module"}));function wK(e,t){const n=e.split(".").map(Number),r=t.split(".").map(Number);for(let o=0;o<Math.max(n.length,r.length);o++){const l=n[o]??0,u=r[o]??0;if(l>u)return!0;if(l<u)return!1}return!1}function h0(e,t){const n=e.i18n?.[t];return n?.displayName||n?.name||e.name}function b4(e,t){return e.i18n?.[t]?.description||e.description}const kK={manager:"bg-brand-500/15 text-brand-500",worker:"bg-blue-500/15 text-blue-600"};function SK({authUser:e,highlightItemId:t,onHighlightDone:n}={}){const{t:r,i18n:o}=ft(["store","common"]),l=o.language,[u,d]=k.useState(""),[m,h]=k.useState([]),[p,g]=k.useState([]),[x,y]=k.useState(null),[w,N]=k.useState({}),[T,C]=k.useState(!1),[j,_]=k.useState(!0),[O,z]=k.useState(new Map),[D,H]=k.useState(new Set),[W,Z]=k.useState(null),[U,Y]=k.useState(null),ae=k.useCallback(async()=>{try{const[J,B]=await Promise.all([Ce.builder.artifacts.list().catch(()=>({artifacts:[]})),Ce.builder.artifacts.installed().catch(()=>({installed:{}}))]),Q=new Map;for(const re of J.artifacts){if(re.type!=="agent")continue;const we=!!B.installed[`agent/${re.name}`];Q.set(re.name,{installed:we,localVersion:re.meta.version||void 0,localUpdatedAt:re.updatedAt})}z(Q)}catch{}},[]),X=k.useCallback(async()=>{_(!0);try{const J=u?lt.search({type:"agent",q:u,limit:50}):vi(Tr.hubAgents)??lt.search({type:"agent",limit:50}),B=new URLSearchParams;u&&B.set("q",u);const Q=fetch("/api/templates?"+B.toString()).then($=>$.json()).catch(()=>({templates:[]})),[re,we]=await Promise.all([J.catch(()=>({items:[],total:0})),Q,ae(),lt.isAuthenticated()?lt.purchases.mine().then($=>H(new Set($.purchases.map(G=>G.itemId)))).catch(()=>{}):Promise.resolve()]);g(re?.items??[]),h(Array.isArray(we.templates)?we.templates:[])}catch{h([]),g([])}finally{_(!1)}},[u,ae]);k.useEffect(()=>{X()},[X]),k.useEffect(()=>{if(!x){N({});return}fetch(`/api/templates/${encodeURIComponent(x.id)}/files`,{credentials:"include"}).then(J=>J.json()).then(J=>N(J.files??{})).catch(()=>N({}))},[x]);const F=async(J,B,Q)=>{try{const re=await fetch("/api/templates/instantiate",{method:"POST",headers:{"Content-Type":"application/json"},credentials:"include",body:JSON.stringify({templateId:J,name:B,orgId:"default",teamId:Q})});if(!re.ok)throw new Error(`Failed: ${re.status}`);C(!1),y(null)}catch(re){Y({title:r("common:create",{defaultValue:"Create"}),message:`Failed to create agent: ${re}`,variant:"danger"})}};if(W)return s.jsx(Ai,{type:W.type,name:W.name,onBack:()=>Z(null)});if(x){const J={type:"agent",name:x.id,displayName:h0(x,l),version:x.version,description:b4(x,l),author:x.author,category:x.category,tags:x.tags,icon:x.icon,files:w,agent:{roleName:x.roleId,agentRole:x.agentRole==="manager"?"manager":"worker"},dependencies:{skills:x.skills}},B=s.jsxs("div",{className:"space-y-6",children:[s.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[s.jsxs("div",{className:"rounded-xl border border-border-default bg-surface-secondary/40 p-5",children:[s.jsx("h3",{className:"text-xs text-fg-tertiary uppercase tracking-wider mb-3",children:r("agentStore.roleConfig")}),s.jsxs("div",{className:"space-y-2.5 text-sm",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("span",{className:"text-fg-tertiary w-20",children:r("agentStore.role")}),s.jsx("span",{className:"text-fg-secondary font-mono text-xs bg-surface-elevated px-2 py-0.5 rounded",children:x.roleId})]}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("span",{className:"text-fg-tertiary w-20",children:r("agentStore.position")}),s.jsx("span",{className:`px-2 py-0.5 rounded text-xs capitalize ${kK[x.agentRole]??""}`,children:x.agentRole})]})]})]}),s.jsxs("div",{className:"rounded-xl border border-border-default bg-surface-secondary/40 p-5",children:[s.jsx("h3",{className:"text-xs text-fg-tertiary uppercase tracking-wider mb-3",children:r("agentStore.skills")}),s.jsxs("div",{className:"flex flex-wrap gap-1.5",children:[x.skills.map(Q=>s.jsx("span",{className:"px-2.5 py-1 text-xs bg-brand-500/10 text-brand-500 rounded-lg border border-brand-500/20",children:Q},Q)),x.skills.length===0&&s.jsx("span",{className:"text-xs text-fg-tertiary italic",children:r("agentStore.noSkills")})]})]})]}),x.starterTasks&&x.starterTasks.length>0&&s.jsxs("div",{className:"rounded-xl border border-border-default bg-surface-secondary/40 p-5",children:[s.jsx("h3",{className:"text-xs text-fg-tertiary uppercase tracking-wider mb-3",children:r("agentStore.starterTasks")}),s.jsx("div",{className:"space-y-2",children:x.starterTasks.map((Q,re)=>s.jsxs("div",{className:"flex items-start gap-3 bg-surface-elevated/50 rounded-lg p-3",children:[s.jsx("span",{className:`inline-block w-2 h-2 rounded-full shrink-0 mt-1 ${Q.priority==="high"?"bg-red-400":Q.priority==="medium"?"bg-amber-400":"bg-green-400"}`}),s.jsxs("div",{children:[s.jsx("div",{className:"text-sm text-fg-primary",children:Q.title}),Q.description&&s.jsx("div",{className:"text-xs text-fg-tertiary mt-0.5",children:Q.description})]})]},re))})]})]});return s.jsxs(s.Fragment,{children:[s.jsx(Ai,{type:"agent",name:x.id,onBack:()=>y(null),readOnly:!0,initialManifest:J,actionSlot:s.jsx("button",{onClick:()=>C(!0),className:"px-4 py-1.5 text-xs bg-brand-600 hover:bg-brand-500 text-white rounded-lg transition-colors font-medium",children:r("agentStore.hireAgent")}),contentSlot:B}),T&&s.jsx(x4,{template:x,lang:l,onClose:()=>C(!1),onHire:F}),U&&s.jsx(dr,{alertOnly:!0,variant:U.variant??"danger",title:U.title,message:U.message,onConfirm:()=>Y(null),onCancel:()=>Y(null)})]})}return s.jsxs("div",{className:"flex-1 overflow-hidden flex flex-col",children:[s.jsxs("div",{className:"px-6 h-14 flex items-center justify-between shrink-0 gap-3",children:[s.jsx("h2",{className:"text-lg font-semibold",children:r("agentStore.title")}),s.jsx("input",{type:"text",placeholder:r("agentStore.searchPlaceholder"),value:u,onChange:J=>d(J.target.value),className:"px-3 py-1.5 bg-surface-elevated border border-border-default rounded-lg text-sm max-w-xs w-full focus:border-brand-500 focus:outline-none"})]}),s.jsx("div",{className:"flex-1 overflow-y-auto p-7 space-y-8",children:j?s.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-4",children:Array.from({length:6}).map((J,B)=>s.jsx("div",{className:"h-56 rounded-2xl skeleton"},B))}):m.length===0&&p.length===0?s.jsxs("div",{className:"text-center py-20",children:[s.jsx("div",{className:"text-4xl mb-4 opacity-30",children:"⧉"}),s.jsx("div",{className:"text-fg-secondary font-medium mb-1",children:u?r("agentStore.noResults",{search:u}):r("agentStore.noAgents")}),s.jsx("div",{className:"text-fg-tertiary text-sm",children:r(u?"agentStore.noResultsHint":"agentStore.noAgentsHint")})]}):s.jsxs(s.Fragment,{children:[m.length>0&&s.jsxs("section",{children:[s.jsxs("div",{className:"flex items-baseline gap-2 mb-3",children:[s.jsx("h3",{className:"section-title",children:r("agentStore.builtin")}),s.jsx("span",{className:"text-xs text-fg-tertiary",children:r("agentStore.available",{count:m.length})})]}),s.jsx(Er,{columns:3,children:m.map(J=>s.jsx(sa,{type:"agent",name:h0(J,l),description:b4(J,l),seed:J.id,icon:J.icon,version:J.version,category:J.category,tags:J.tags,authorLabel:J.author,hideStats:!0,showTypeBadge:!1,cornerLabel:r("agentStore.builtin"),onClick:()=>y(J)},J.id))})]}),p.length>0&&s.jsxs("section",{children:[s.jsx("h3",{className:"section-title mb-3",children:r("agentStore.markusHub")}),s.jsx(Er,{columns:3,children:p.map(J=>s.jsx(NK,{item:J,localInfo:O.get(Cc(J)),purchased:Hd(J,D),onStatusChange:ae,highlight:J.id===t,onHighlightDone:n,onViewDetail:B=>Z({type:"agent",name:B})},J.id))})]})]})}),T&&x&&s.jsx(x4,{template:x,lang:l,onClose:()=>C(!1),onHire:F}),U&&s.jsx(dr,{alertOnly:!0,variant:U.variant??"danger",title:U.title,message:U.message,onConfirm:()=>Y(null),onCancel:()=>Y(null)})]})}function Cc(e,t){if(e.slug&&e.slug.trim())return e.slug.trim();const n=t&&typeof t.name=="string"?t.name.trim():"";return qd(n||e.name,"hub-pkg")}function wi(e){return(async()=>{const t=await lt.download(e.id),n=t.name||e.name,r=t.config??{},o=Cc(e,r),l=t.itemType==="team"?"team":t.itemType==="skill"?"skill":"agent",u={type:"hub",hubItemId:e.id};if(t.files&&Object.keys(t.files).length>0)await Ce.builder.artifacts.import(l,o,t.files,u);else{const d={...r,name:o,displayName:r.displayName||n,description:e.description,source:u};await Ce.builder.artifacts.save(l,d)}return await Ce.builder.artifacts.install(l,o),window.dispatchEvent(new CustomEvent("markus:data-changed")),n})()}async function Rg(e,t){t("checking"),await lt.ensureAuth();const n=await lt.purchases.checkout(e.id);if(n.alreadyOwned)return t("installing"),await wi(e),"installed";try{if((await lt.creator.getBalance()).availableBalance>=(e.priceCents??0)){const l=await lt.purchases.payWithEarnings(e.id);if(l.ok||l.alreadyOwned)return t("installing"),await wi(e),"installed"}}catch{}if(!n.checkoutUrl)throw new Error("No checkout URL");t("checkout_opened");const r=window.open(n.checkoutUrl,"_blank","noopener");return new Promise((o,l)=>{const u=setInterval(async()=>{const d=r?r.closed:!1;try{if((await lt.purchases.checkout(e.id)).alreadyOwned){clearInterval(u),t("installing");try{await wi(e),o("installed")}catch(h){l(h)}return}}catch{}if(d){clearInterval(u);try{if((await lt.purchases.checkout(e.id)).alreadyOwned){t("installing"),await wi(e),o("installed");return}}catch{}o("cancelled")}},2e3)})}function NK({item:e,localInfo:t,purchased:n,onStatusChange:r,highlight:o,onHighlightDone:l,onViewDetail:u}){const{t:d}=ft(["store"]),[m,h]=k.useState(!1),[p,g]=k.useState(""),x=k.useRef(null),[y,w]=k.useState(!1);k.useEffect(()=>{if(o&&x.current){x.current.scrollIntoView({behavior:"smooth",block:"center"}),w(!0);const W=setTimeout(()=>{w(!1),l?.()},4e3);return()=>clearTimeout(W)}},[o,l]);const N=t?.installed??!1,T=N&&e.version&&t?.localVersion&&wK(e.version,t.localVersion),C=(e.priceCents??0)>0,j=async W=>{if(W.stopPropagation(),!m){h(!0),g("");try{await wi(e),g(T?d("card.upgraded"):d("card.installed")+"!"),r()}catch(Z){const U=Z instanceof Error?Z.message:"";U.includes("402")||U.includes("Purchase required")?g(d("card.purchaseRequired")):g(d("card.failed"))}finally{h(!1)}}},_=async W=>{if(W.stopPropagation(),!m){h(!0),g("");try{await Rg(e,U=>{U==="checkout_opened"?g(d("card.waitingPurchase","Waiting for purchase...")):U==="installing"&&g(d("card.installing"))})==="installed"?(g(d("card.installed")+"!"),r()):g("")}catch(Z){g(Z instanceof Error?Z.message:d("card.failed"))}finally{h(!1)}}},O=C?`$${((e.priceCents??0)/100).toFixed(2)}`:null,z=e.slug&&e.author?.username?`${lt.getUrl()}/@${encodeURIComponent(e.author.username)}/${encodeURIComponent(e.slug)}`:null,D=()=>{N&&u?u(Cc(e)):z&&window.open(z,"_blank","noopener,noreferrer")},H=s.jsxs(s.Fragment,{children:[T?s.jsx("button",{onClick:W=>{j(W)},disabled:m,className:"px-3 py-1.5 text-xs bg-amber-600 hover:bg-amber-500 text-white rounded-lg transition-colors disabled:opacity-50",children:m?d("card.upgrading"):d("card.upgrade",{version:e.version})}):N?s.jsxs("button",{onClick:W=>{j(W)},disabled:m,className:"px-3 py-1.5 text-xs bg-surface-elevated hover:bg-surface-overlay text-fg-secondary border border-border-default rounded-lg transition-colors disabled:opacity-50",children:[d("card.installed"),t?.localVersion?` v${t.localVersion}`:""]}):C&&!n?s.jsx("button",{onClick:W=>{_(W)},disabled:m,className:"px-3 py-1.5 text-xs bg-amber-600 hover:bg-amber-500 text-white rounded-lg transition-colors disabled:opacity-50 inline-flex items-center gap-1",children:m?p||d("card.installing"):s.jsxs(s.Fragment,{children:[d("card.buy","Buy")," ",O]})}):s.jsx("button",{onClick:W=>{j(W)},disabled:m,className:"px-3 py-1.5 text-xs bg-brand-600 hover:bg-brand-500 text-white rounded-lg transition-colors disabled:opacity-50",children:d(m?"card.installing":"card.install")}),p&&!(C&&!n)&&s.jsx("span",{className:`text-[10px] ${p===d("card.failed")||p===d("card.purchaseRequired")?"text-red-500":"text-green-600"}`,children:p})]});return s.jsx("div",{ref:x,className:y?"animate-pulse":"",children:s.jsx(sa,{type:"agent",showTypeBadge:!1,name:e.name,description:e.description,seed:e.slug||e.name,icon:e.icon||"bot",cover:e.thumbnailUrl,hubBase:lt.getUrl(),author:e.author,version:e.version,category:e.category,tags:e.tags,rating:parseFloat(e.avgRating)||0,ratingCount:e.ratingCount,downloadCount:e.downloadCount,priceCents:e.priceCents,currency:e.currency,installed:N,glowing:y,onClick:D,actions:H})})}function x4({template:e,lang:t,onClose:n,onHire:r}){const{t:o}=ft(["store"]),[l,u]=k.useState(`${h0(e,t)} Agent`),[d,m]=k.useState(""),[h,p]=k.useState([]),[g,x]=k.useState(!1);k.useEffect(()=>{fetch("/api/teams",{credentials:"include"}).then(w=>w.json()).then(w=>p(w.teams??[])).catch(()=>{})},[]);const y=async()=>{if(l.trim()){x(!0);try{await r(e.id,l.trim(),d||void 0)}finally{x(!1)}}};return s.jsx("div",{className:"fixed inset-0 bg-black/60 flex items-center justify-center z-50",onClick:n,children:s.jsxs("div",{className:"bg-surface-secondary border border-border-default rounded-xl p-6 w-[440px] shadow-2xl",onClick:w=>w.stopPropagation(),children:[s.jsx("div",{className:"flex items-center gap-3 mb-5",children:s.jsxs("div",{children:[s.jsx("h3",{className:"text-base font-semibold",children:o("hireModal.title")}),s.jsx("p",{className:"text-xs text-fg-tertiary",children:o("hireModal.creating",{name:h0(e,t)})})]})}),s.jsxs("div",{className:"space-y-4",children:[s.jsxs("div",{children:[s.jsx("label",{className:"block text-xs text-fg-tertiary mb-1.5",children:o("hireModal.agentName")}),s.jsx("input",{type:"text",value:l,onChange:w=>u(w.target.value),className:"input-field",autoFocus:!0})]}),h.length>0&&s.jsxs("div",{children:[s.jsx("label",{className:"block text-xs text-fg-tertiary mb-1.5",children:o("hireModal.assignTeam")}),s.jsxs("select",{value:d,onChange:w=>m(w.target.value),className:"input-field",children:[s.jsx("option",{value:"",children:o("hireModal.noTeam")}),h.map(w=>s.jsx("option",{value:w.id,children:w.name},w.id))]})]}),s.jsxs("div",{className:"bg-surface-elevated/50 rounded-lg p-3",children:[s.jsx("div",{className:"text-xs text-fg-tertiary mb-2 font-medium",children:o("hireModal.agentConfig")}),s.jsxs("div",{className:"grid grid-cols-2 gap-y-1.5 gap-x-4 text-xs",children:[s.jsx("div",{className:"text-fg-tertiary",children:o("hireModal.role")}),s.jsx("div",{className:"text-fg-secondary font-mono",children:e.roleId}),s.jsx("div",{className:"text-fg-tertiary",children:o("hireModal.position")}),s.jsx("div",{className:"text-fg-secondary capitalize",children:e.agentRole}),s.jsx("div",{className:"text-fg-tertiary",children:o("hireModal.skills")}),s.jsx("div",{className:"text-fg-secondary",children:e.skills.join(", ")||o("hireModal.none")})]})]})]}),s.jsxs("div",{className:"flex justify-end gap-3 mt-6",children:[s.jsx("button",{onClick:n,className:"btn-secondary",children:o("hireModal.cancel")}),s.jsx("button",{onClick:y,disabled:!l.trim()||g,className:"btn-primary",children:o(g?"hireModal.creating_progress":"hireModal.create")})]})]})})}function Yh(e,t){const n=e.i18n?.[t];return n?.displayName||n?.name||e.name}function y4(e,t){return e.i18n?.[t]?.description||e.description}function v4(e,t,n){return e.i18n?.[n]?.members?.[t]||t}function CK(e,t){const n=e.split(".").map(Number),r=t.split(".").map(Number);for(let o=0;o<Math.max(n.length,r.length);o++){const l=n[o]??0,u=r[o]??0;if(l>u)return!0;if(l<u)return!1}return!1}function TK({highlightItemId:e,onHighlightDone:t}={}){const{t:n,i18n:r}=ft(["store","common"]),o=r.language,[l,u]=k.useState(""),[d,m]=k.useState([]),[h,p]=k.useState([]),[g,x]=k.useState(null),[y,w]=k.useState({}),[N,T]=k.useState(!0),[C,j]=k.useState(!1),[_,O]=k.useState(null),[z,D]=k.useState(new Map),[H,W]=k.useState(new Set),[Z,U]=k.useState(null),Y=k.useCallback(async()=>{try{const[F,J]=await Promise.all([Ce.builder.artifacts.list().catch(()=>({artifacts:[]})),Ce.builder.artifacts.installed().catch(()=>({installed:{}}))]),B=new Map;for(const Q of F.artifacts){if(Q.type!=="team")continue;const re=!!J.installed[`team/${Q.name}`];B.set(Q.name,{installed:re,localVersion:Q.meta.version||void 0,localUpdatedAt:Q.updatedAt})}D(B)}catch{}},[]),ae=k.useCallback(async()=>{T(!0);try{const F=l?lt.search({type:"team",q:l,limit:50}):vi(Tr.hubTeams)??lt.search({type:"team",limit:50}),[J,B]=await Promise.all([F.catch(()=>({items:[],total:0})),Ce.teamTemplates.list(l||void 0).catch(()=>({templates:[]})),Y(),lt.isAuthenticated()?lt.purchases.mine().then(Q=>W(new Set(Q.purchases.map(re=>re.itemId)))).catch(()=>{}):Promise.resolve()]);p(J?.items??[]),m(B?.templates??[])}catch{m([]),p([])}finally{T(!1)}},[l,Y]);k.useEffect(()=>{ae()},[ae]),k.useEffect(()=>{if(!g){w({});return}fetch(`/api/team-templates/${encodeURIComponent(g.id)}/files`,{credentials:"include"}).then(F=>F.json()).then(F=>w(F.files??{})).catch(()=>w({}))},[g]);const X=async F=>{j(!0),O(null);try{const B=(await Ce.teams.create(F.name,F.description)).team.id;let Q,re=0;const we=[];for(const G of F.members){const ce=G.count??1;for(let I=0;I<ce;I++){const Ee=G.name??`${F.name} Agent ${I+1}`,Ue=ce>1?`${Ee} ${I+1}`:Ee,De=G.roleName??G.templateId;try{const Ke=await fetch("/api/agents",{method:"POST",headers:{"Content-Type":"application/json"},credentials:"include",body:JSON.stringify({name:Ue,...De?{roleName:De}:{},orgId:"default",teamId:B,agentRole:G.role??"worker",skills:G.skills??[]})});if(Ke.ok){re++;const st=await Ke.json();G.role==="manager"&&!Q&&(Q=st.agent?.id)}else{const st=await Ke.json().catch(()=>({error:`HTTP ${Ke.status}`}));we.push(`${Ue}: ${st.error??Ke.statusText}`)}}catch(Ke){we.push(`${Ue}: ${String(Ke)}`)}}}Q&&await Ce.teams.update(B,{managerId:Q,managerType:"agent"}).catch(()=>{});const $=we.length>0?` (${we.length} failed: ${we[0]})`:"";O({ok:re>0,message:`Team "${Yh(F,o)}" deployed with ${re} agent(s)${$}`})}catch(J){O({ok:!1,message:`Failed: ${J}`})}finally{j(!1)}};if(Z)return s.jsx(Ai,{type:Z.type,name:Z.name,onBack:()=>U(null)});if(g){const F={...y};g.announcements&&(F["ANNOUNCEMENT.md"]=g.announcements),g.norms&&(F["NORMS.md"]=g.norms);const J={type:"team",name:g.id,displayName:Yh(g,o),version:g.version,description:y4(g,o),author:g.author,category:g.category??"general",tags:g.tags??[],files:F,team:{members:g.members.map(Q=>({name:v4(g,Q.name??Q.roleName??Q.templateId??"Agent",o),role:Q.role??"worker",roleName:Q.roleName??Q.templateId,count:Q.count??1,skills:Q.skills??[]}))}},B=s.jsxs("div",{className:"rounded-xl border border-border-default bg-surface-secondary/40 overflow-hidden",children:[s.jsx("div",{className:"px-5 py-3 border-b border-border-default bg-surface-elevated/30",children:s.jsx("h3",{className:"text-xs text-fg-tertiary uppercase tracking-wider",children:n("teamStore.teamComposition")})}),s.jsx("div",{className:"p-5 space-y-2",children:g.members.map((Q,re)=>{const we=v4(g,Q.name??Q.roleName??Q.templateId??"Agent",o);return s.jsxs("div",{className:"flex items-center gap-3 bg-surface-elevated/50 rounded-lg p-3",children:[s.jsx("div",{className:`w-9 h-9 rounded-lg flex items-center justify-center text-sm font-bold shrink-0 ${Q.role==="manager"?"bg-amber-500/15 text-amber-400 ring-1 ring-amber-500/30":"bg-blue-500/15 text-blue-400 ring-1 ring-blue-500/30"}`,children:(we[0]??"?").toUpperCase()}),s.jsxs("div",{className:"min-w-0 flex-1",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("span",{className:"text-sm text-fg-primary font-medium",children:we}),s.jsx("span",{className:`px-1.5 py-0.5 rounded text-[10px] capitalize font-medium ${Q.role==="manager"?"bg-amber-500/15 text-amber-400":"bg-blue-500/15 text-blue-400"}`,children:Q.role??"worker"}),(Q.count??1)>1&&s.jsxs("span",{className:"text-[10px] text-fg-muted",children:["×",Q.count]})]}),(Q.roleName||Q.templateId)&&s.jsx("div",{className:"text-[10px] text-fg-tertiary font-mono mt-0.5",children:Q.roleName??Q.templateId})]}),Q.skills&&Q.skills.length>0&&s.jsxs("div",{className:"flex flex-wrap gap-1 shrink-0",children:[Q.skills.slice(0,3).map($=>s.jsx("span",{className:"px-1.5 py-0.5 text-[9px] bg-surface-elevated text-fg-muted rounded border border-border-default",children:$},$)),Q.skills.length>3&&s.jsxs("span",{className:"text-[9px] text-fg-muted",children:["+",Q.skills.length-3]})]})]},re)})})]});return s.jsx(s.Fragment,{children:s.jsx(Ai,{type:"team",name:g.id,onBack:()=>{x(null),O(null)},readOnly:!0,initialManifest:J,contentSlot:B,actionSlot:s.jsxs(s.Fragment,{children:[_&&s.jsx("span",{className:`text-xs ${_.ok?"text-green-500":"text-red-500"}`,children:_.message}),s.jsx("button",{onClick:()=>{X(g)},disabled:C,className:"px-4 py-1.5 text-xs bg-brand-600 hover:bg-brand-500 text-white rounded-lg transition-colors font-medium disabled:opacity-50",children:n(C?"teamStore.deploying":"teamStore.deployTeam")})]})})})}return s.jsxs("div",{className:"flex-1 overflow-hidden flex flex-col",children:[s.jsxs("div",{className:"px-6 h-14 flex items-center justify-between shrink-0 gap-3",children:[s.jsx("h2",{className:"text-lg font-semibold",children:n("teamStore.title")}),s.jsx("input",{type:"text",placeholder:n("teamStore.searchPlaceholder"),value:l,onChange:F=>u(F.target.value),className:"px-3 py-1.5 bg-surface-elevated border border-border-default rounded-lg text-sm max-w-xs w-full focus:border-brand-500 focus:outline-none"})]}),s.jsx("div",{className:"flex-1 overflow-y-auto p-7 space-y-8",children:N?s.jsx("div",{className:"grid grid-cols-1 lg:grid-cols-2 gap-4",children:Array.from({length:4}).map((F,J)=>s.jsx("div",{className:"h-56 rounded-2xl skeleton"},J))}):d.length===0&&h.length===0?s.jsxs("div",{className:"text-center py-20",children:[s.jsx("div",{className:"text-4xl mb-4 opacity-30",children:"◉"}),s.jsx("div",{className:"text-fg-secondary font-medium mb-1",children:l?n("teamStore.noResults",{search:l}):n("teamStore.noTeams")}),s.jsx("div",{className:"text-fg-tertiary text-sm",children:n(l?"teamStore.noResultsHint":"teamStore.noTeamsHint")})]}):s.jsxs(s.Fragment,{children:[d.length>0&&s.jsxs("section",{children:[s.jsxs("div",{className:"flex items-baseline gap-2 mb-3",children:[s.jsx("h3",{className:"section-title",children:n("teamStore.builtin")}),s.jsx("span",{className:"text-xs text-fg-tertiary",children:n("teamStore.available",{count:d.length})})]}),s.jsx(Er,{columns:2,children:d.map(F=>s.jsx(sa,{type:"team",name:Yh(F,o),description:y4(F,o),seed:F.id,icon:F.icon||"users",version:F.version,category:F.category,tags:F.tags,authorLabel:F.author,hideStats:!0,showTypeBadge:!1,cornerLabel:n("teamStore.builtin"),onClick:()=>x(F)},F.id))})]}),h.length>0&&s.jsxs("section",{children:[s.jsx("h3",{className:"section-title mb-3",children:n("teamStore.markusHub")}),s.jsx(Er,{columns:2,children:h.map(F=>s.jsx(EK,{item:F,localInfo:z.get(Cc(F)),purchased:Hd(F,H),onStatusChange:Y,highlight:F.id===e,onHighlightDone:t,onViewDetail:J=>U({type:"team",name:J})},F.id))})]})]})})]})}function EK({item:e,localInfo:t,purchased:n,onStatusChange:r,highlight:o,onHighlightDone:l,onViewDetail:u}){const{t:d}=ft(["store"]),[m,h]=k.useState(!1),[p,g]=k.useState(""),x=k.useRef(null),[y,w]=k.useState(!1);k.useEffect(()=>{if(o&&x.current){x.current.scrollIntoView({behavior:"smooth",block:"center"}),w(!0);const W=setTimeout(()=>{w(!1),l?.()},4e3);return()=>clearTimeout(W)}},[o,l]);const N=t?.installed??!1,T=N&&e.version&&t?.localVersion&&CK(e.version,t.localVersion),C=(e.priceCents??0)>0,j=C?`$${((e.priceCents??0)/100).toFixed(2)}`:null,_=async W=>{if(W.stopPropagation(),!m){h(!0),g("");try{await wi(e),g(T?d("card.upgraded"):d("card.installed")+"!"),r()}catch(Z){const U=Z instanceof Error?Z.message:"";U.includes("402")||U.includes("Purchase required")?g(d("card.purchaseRequired")):g(d("card.failed"))}finally{h(!1)}}},O=async W=>{if(W.stopPropagation(),!m){h(!0),g("");try{await Rg(e,U=>{U==="checkout_opened"?g(d("card.waitingPurchase","Waiting for purchase...")):U==="installing"&&g(d("card.installing"))})==="installed"?(g(d("card.installed")+"!"),r()):g("")}catch(Z){g(Z instanceof Error?Z.message:d("card.failed"))}finally{h(!1)}}},z=e.slug&&e.author?.username?`${lt.getUrl()}/@${encodeURIComponent(e.author.username)}/${encodeURIComponent(e.slug)}`:null,D=()=>{N&&u?u(Cc(e)):z&&window.open(z,"_blank","noopener,noreferrer")},H=s.jsxs(s.Fragment,{children:[T?s.jsx("button",{onClick:W=>{_(W)},disabled:m,className:"px-3 py-1.5 text-xs bg-amber-600 hover:bg-amber-500 text-white rounded-lg transition-colors disabled:opacity-50",children:m?d("card.upgrading"):d("card.upgrade",{version:e.version})}):N?s.jsxs("button",{onClick:W=>{_(W)},disabled:m,className:"px-3 py-1.5 text-xs bg-surface-elevated hover:bg-surface-overlay text-fg-secondary border border-border-default rounded-lg transition-colors disabled:opacity-50",children:[d("card.installed"),t?.localVersion?` v${t.localVersion}`:""]}):C&&!n?s.jsx("button",{onClick:W=>{O(W)},disabled:m,className:"px-3 py-1.5 text-xs bg-amber-600 hover:bg-amber-500 text-white rounded-lg transition-colors disabled:opacity-50 inline-flex items-center gap-1",children:m?p||d("card.installing"):s.jsxs(s.Fragment,{children:[d("card.buy","Buy")," ",j]})}):s.jsx("button",{onClick:W=>{_(W)},disabled:m,className:"px-3 py-1.5 text-xs bg-brand-600 hover:bg-brand-500 text-white rounded-lg transition-colors disabled:opacity-50",children:d(m?"card.installing":"card.install")}),p&&s.jsx("span",{className:`text-[10px] ${p===d("card.failed")||p===d("card.purchaseRequired")?"text-red-500":"text-green-600"}`,children:p})]});return s.jsx("div",{ref:x,className:y?"animate-pulse":"",children:s.jsx(sa,{type:"team",showTypeBadge:!1,name:e.name,description:e.description,seed:e.slug||e.name,icon:e.icon||"users",cover:e.thumbnailUrl,hubBase:lt.getUrl(),author:e.author,version:e.version,category:e.category,tags:e.tags,rating:parseFloat(e.avgRating)||0,ratingCount:e.ratingCount,downloadCount:e.downloadCount,priceCents:e.priceCents,currency:e.currency,installed:N,glowing:y,onClick:D,actions:H})})}function Xh(e,t){return e.i18n?.[t]?.displayName||e.name}function Qh(e,t){return e.i18n?.[t]?.description||e.description||""}function C3(e,t){const n=e.split(".").map(Number),r=t.split(".").map(Number);for(let o=0;o<Math.max(n.length,r.length);o++){const l=n[o]??0,u=r[o]??0;if(l>u)return!0;if(l<u)return!1}return!1}const AK={development:"bg-blue-500/15 text-blue-600",devops:"bg-amber-500/15 text-amber-600",productivity:"bg-green-500/15 text-green-600",custom:"bg-gray-500/15 text-fg-secondary",browser:"bg-brand-500/15 text-brand-500",communication:"bg-green-500/15 text-green-600",data:"bg-brand-500/15 text-brand-500",platform:"bg-blue-500/15 text-blue-600","AI 智能":"bg-brand-500/15 text-brand-500",开发工具:"bg-blue-500/15 text-blue-600",效率提升:"bg-green-500/15 text-green-600",数据分析:"bg-brand-500/15 text-brand-500",内容创作:"bg-brand-500/15 text-brand-500",安全合规:"bg-red-500/15 text-red-500",通讯协作:"bg-green-500/15 text-green-600"};function _K({item:e,installedSkills:t,purchased:n,onMsg:r,onRefresh:o}){const{t:l}=ft(["store"]),[u,d]=k.useState(!1),m=e.name.toLowerCase().trim().replace(/\s+/g,"-").replace(/[\/\\:*?"<>|]+/g,"").replace(/-{2,}/g,"-").replace(/^-|-$/g,"")||"unnamed",h=t.find(C=>C.name===e.name||C.name===m||!!e.slug&&C.name===e.slug),p=!!h,g=p&&e.version&&h?.version&&C3(e.version,h.version),x=(e.priceCents??0)>0,[y,w]=k.useState(""),N=async()=>{if(!u){d(!0),w("");try{await wi(e),r(g?`Upgraded ${e.name}`:`Installed ${e.name}`,"success"),o()}catch(C){const j=C instanceof Error?C.message:"";j.includes("402")||j.includes("Purchase required")?r(l("card.purchaseRequired"),"error"):r(l("card.failed"),"error")}finally{d(!1)}}},T=async()=>{if(!u){d(!0),w("");try{await Rg(e,j=>{j==="checkout_opened"?w(l("card.waitingPurchase","Waiting for purchase...")):j==="installing"&&w(l("card.installing"))})==="installed"&&(r(`Purchased & installed ${e.name}`,"success"),o()),w("")}catch(C){r(C instanceof Error?C.message:l("card.failed"),"error"),w("")}finally{d(!1)}}};if(g)return s.jsx("button",{onClick:()=>{N()},disabled:u,className:"px-2.5 py-1 text-[10px] bg-amber-600 hover:bg-amber-500 text-white rounded-lg disabled:opacity-50",children:u?l("card.upgrading"):l("card.upgrade",{version:e.version})});if(p)return s.jsxs("span",{className:"px-2.5 py-1 text-[10px] bg-surface-overlay text-fg-secondary rounded-lg",children:[l("card.installed"),h?.version?` (v${h.version})`:""]});if(x&&!n){const C=`$${((e.priceCents??0)/100).toFixed(2)}`;return s.jsx("span",{className:"inline-flex items-center gap-1.5",children:s.jsx("button",{onClick:()=>{T()},disabled:u,className:"px-2.5 py-1 text-[10px] bg-amber-600 hover:bg-amber-500 text-white rounded-lg disabled:opacity-50 inline-flex items-center gap-1",children:u?y||l("card.installing"):s.jsxs(s.Fragment,{children:[l("card.buy","Buy")," ",C]})})})}return s.jsx("button",{onClick:()=>{N()},disabled:u,className:"px-2.5 py-1 text-[10px] bg-brand-600 hover:bg-brand-500 text-white rounded-lg disabled:opacity-50",children:l(u?"card.installing":"card.install")})}function w4({item:e,installedSkills:t,purchased:n,onMsg:r,onRefresh:o,highlight:l,onHighlightDone:u,type:d="skill"}){const m=k.useRef(null),[h,p]=k.useState(!1);k.useEffect(()=>{if(l&&m.current){m.current.scrollIntoView({behavior:"smooth",block:"center"}),p(!0);const y=setTimeout(()=>{p(!1),u?.()},4e3);return()=>clearTimeout(y)}},[l,u]);const g=e.slug&&e.author?.username?`${lt.getUrl()}/@${encodeURIComponent(e.author.username)}/${encodeURIComponent(e.slug)}`:null,x=()=>{g&&window.open(g,"_blank","noopener,noreferrer")};return s.jsx("div",{ref:m,className:h?"animate-pulse":"",children:s.jsx(sa,{type:d,showTypeBadge:d!=="skill",name:e.name,description:e.description,seed:e.slug||e.name,icon:e.icon||Dd(e.slug||e.name,e.category),cover:e.thumbnailUrl,hubBase:lt.getUrl(),author:e.author,version:e.version,category:e.category,tags:e.tags,rating:parseFloat(e.avgRating)||0,ratingCount:e.ratingCount,downloadCount:e.downloadCount,priceCents:e.priceCents,currency:e.currency,onClick:x,actions:s.jsx(_K,{item:e,installedSkills:t,purchased:n,onMsg:r,onRefresh:o})})})}function jK({highlightItemId:e,onHighlightDone:t}={}){const{t:n,i18n:r}=ft(["store","common"]),o=r.language,l=Uo(),[u,d]=k.useState("skills"),[m,h]=k.useState(null),[p,g]=k.useState(new Set),[x,y]=k.useState([]),[w,N]=k.useState(null),[T,C]=k.useState([]),[j,_]=k.useState(0),[O,z]=k.useState(1),[D,H]=k.useState([]),[W,Z]=k.useState(""),[U,Y]=k.useState("score"),[ae,X]=k.useState(""),[F,J]=k.useState(!1),[B,Q]=k.useState([]),[re,we]=k.useState(!1),[$,G]=k.useState([]),[ce,I]=k.useState(""),[Ee,Ue]=k.useState(!1),[De,Ke]=k.useState([]),[st,mt]=k.useState([]),[ct,Dt]=k.useState(new Set),[Mt,Xt]=k.useState(!1),[Me,Ne]=k.useState(""),Re=[{id:"skills",labelKey:"skillStore.tabs.all"},{id:"skillhub",labelKey:"skillStore.tabs.skillhub"},{id:"skillssh",labelKey:"skillStore.tabs.skillssh"}],ut=(V,xe="success")=>{h({text:V,type:xe}),setTimeout(()=>h(null),xe==="error"?1e4:4e3)},it=k.useCallback(async()=>{try{const V=await Ce.skills.list();y(V.skills)}catch{}},[]),bt=k.useCallback(async()=>{we(!0);try{const V=await Ce.skills.builtin();Q(V.skills)}catch{}we(!1)},[]),se=k.useCallback(async V=>{J(!0);try{const xe=await Ce.skills.registrySkillhub({q:V?.q,category:V?.category,page:V?.page??1,limit:24,sort:V?.sort??U});C(xe.skills),_(xe.total),xe.categories?.length&&H(xe.categories)}catch{}J(!1)},[U]),et=k.useCallback(async V=>{Ue(!0);try{const xe=await Ce.skills.registrySkillssh(V);G(xe.skills)}catch{}Ue(!1)},[]),nt=k.useCallback(async V=>{Xt(!0);try{const xe=V?lt.search({type:"skill",q:V,limit:50}):vi(Tr.hubSkills)??lt.search({type:"skill",limit:50}),We=lt.search({subtype:"connector",q:V||void 0,limit:50}).catch(()=>({items:[]})),[he,ye]=await Promise.all([xe,We,lt.isAuthenticated()?lt.purchases.mine().then(Ze=>Dt(new Set(Ze.purchases.map(rt=>rt.itemId)))).catch(()=>{}):Promise.resolve()]);Ke(he?.items??[]),mt(ye?.items??[])}catch{}Xt(!1)},[]);k.useEffect(()=>{it(),bt(),se(),et()},[]),k.useEffect(()=>{u==="skills"&&nt(Me)},[u,Me,nt]);const Ge=async V=>{g(xe=>new Set(xe).add(V.name));try{const xe=await Ce.skills.install({name:V.name,source:"skillhub",slug:V.slug,sourceUrl:V.homepage,description:V.description_zh??V.description,category:"custom",version:V.version});await it(),ut(`"${V.name}" installed (${xe.method}) → ${xe.path}`),window.dispatchEvent(new CustomEvent("markus:data-changed"))}catch{ut(`Download failed for "${V.name}". You can try manually from: ${V.homepage}`,"error")}g(xe=>{const We=new Set(xe);return We.delete(V.name),We})},Qe=async V=>{g(xe=>new Set(xe).add(V.name));try{const xe=await Ce.skills.install({name:V.name,source:"skillssh",sourceUrl:V.url,githubRepo:`${V.author}/${V.repo}`,githubSkillPath:V.name});await it(),ut(`"${V.name}" installed (${xe.method}) → ${xe.path}`),window.dispatchEvent(new CustomEvent("markus:data-changed"))}catch{ut(`Download failed for "${V.name}". You can try manually from: ${V.url}`,"error")}g(xe=>{const We=new Set(xe);return We.delete(V.name),We})},xt=async V=>{g(xe=>new Set(xe).add(V.name));try{const xe=await Ce.skills.install({name:V.name,source:"builtin"});await it(),await bt(),ut(`"${V.name}" installed (${xe.method}) → ${xe.path}`),window.dispatchEvent(new CustomEvent("markus:data-changed"))}catch(xe){ut(`Install failed for "${V.name}": ${xe}`,"error")}g(xe=>{const We=new Set(xe);return We.delete(V.name),We})},pe=$.filter(V=>{if(!ce)return!0;const xe=ce.toLowerCase();return V.name.toLowerCase().includes(xe)||V.repo.toLowerCase().includes(xe)});if(w){const V=w,xe={};V.instructions&&(xe["SKILL.md"]=V.instructions);const We={type:"skill",name:V.name,displayName:Xh(V,o),version:V.version,description:Qh(V,o),author:V.author??"",category:V.category??"general",tags:V.tags,files:xe,skill:{skillFile:V.instructions?"SKILL.md":"",requiredPermissions:V.requiredPermissions,mcpServers:void 0,alwaysOn:!1}},he=V.installed&&V.installedVersion&&C3(V.version,V.installedVersion)?s.jsx("button",{onClick:()=>{xt(V)},disabled:p.has(V.name),className:"px-4 py-1.5 text-xs bg-amber-600 hover:bg-amber-500 text-white rounded-lg disabled:opacity-50 transition-colors",children:p.has(V.name)?n("card.upgrading"):n("card.upgrade",{version:V.version})}):V.installed?s.jsxs("span",{className:"px-4 py-1.5 text-xs bg-green-500/10 text-green-500 rounded-lg border border-green-500/20 inline-flex items-center gap-1",children:[s.jsx("svg",{className:"w-3 h-3",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",children:s.jsx("polyline",{points:"20 6 9 17 4 12"})}),n("card.installed"),V.installedVersion?` v${V.installedVersion}`:""]}):s.jsx("button",{onClick:()=>{xt(V)},disabled:p.has(V.name),className:"px-4 py-1.5 text-xs bg-green-600 hover:bg-green-500 text-white rounded-lg disabled:opacity-50 transition-colors",children:p.has(V.name)?n("card.installing"):n("card.install")}),ye=s.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[s.jsxs("div",{className:"rounded-xl border border-border-default bg-surface-secondary/40 p-5",children:[s.jsx("h3",{className:"text-xs text-fg-tertiary uppercase tracking-wider mb-3",children:n("skillStore.details")}),s.jsxs("div",{className:"space-y-2.5 text-sm",children:[V.category&&s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("span",{className:"text-fg-tertiary w-24",children:n("skillStore.category")}),s.jsx("span",{className:`px-2 py-0.5 rounded-full text-[10px] font-medium capitalize ${AK[V.category]??"bg-gray-500/15 text-fg-secondary"}`,children:V.category})]}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("span",{className:"text-fg-tertiary w-24",children:n("skillStore.version")}),s.jsx("span",{className:"text-fg-secondary font-mono text-xs",children:V.version})]}),V.hasMcpServers&&s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("span",{className:"text-fg-tertiary w-24",children:n("skillStore.integration")}),s.jsx("span",{className:"px-2 py-0.5 rounded text-[10px] bg-purple-500/15 text-purple-400",children:"MCP"})]}),V.hasInstructions&&s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("span",{className:"text-fg-tertiary w-24",children:n("skillStore.instructions")}),s.jsx("span",{className:"text-green-500 text-xs",children:"✓"})]})]})]}),(V.requiredPermissions.length>0||V.tags.length>0)&&s.jsxs("div",{className:"space-y-4",children:[V.requiredPermissions.length>0&&s.jsxs("div",{className:"rounded-xl border border-border-default bg-surface-secondary/40 p-5",children:[s.jsx("h3",{className:"text-xs text-fg-tertiary uppercase tracking-wider mb-3",children:n("skillStore.permissions")}),s.jsx("div",{className:"flex flex-wrap gap-1.5",children:V.requiredPermissions.map(Ze=>s.jsx("span",{className:"px-2.5 py-1 text-xs bg-amber-500/10 text-amber-500 rounded-lg border border-amber-500/20",children:Ze},Ze))})]}),V.tags.length>0&&s.jsxs("div",{className:"rounded-xl border border-border-default bg-surface-secondary/40 p-5",children:[s.jsx("h3",{className:"text-xs text-fg-tertiary uppercase tracking-wider mb-3",children:n("skillStore.tags")}),s.jsx("div",{className:"flex flex-wrap gap-1.5",children:V.tags.map(Ze=>s.jsx("span",{className:"px-2.5 py-1 text-xs bg-surface-elevated text-fg-secondary rounded-lg border border-border-default/50",children:Ze},Ze))})]})]})]});return s.jsxs(s.Fragment,{children:[s.jsx(Ai,{type:"skill",name:V.name,onBack:()=>N(null),readOnly:!0,initialManifest:We,actionSlot:he,contentSlot:ye}),m&&s.jsx("div",{className:`mx-7 mb-2 px-3 py-1.5 text-xs rounded-lg shrink-0 ${m.type==="error"?"bg-red-500/10 text-red-500":"bg-green-500/10 text-green-600"}`,children:m.text})]})}return s.jsxs("div",{className:"flex-1 overflow-hidden flex flex-col",children:[s.jsxs("div",{className:`${l?"px-4":"px-6"} shrink-0`,children:[s.jsx("div",{className:"flex items-center h-14",children:s.jsx("h2",{className:"text-lg font-semibold",children:n("skillStore.title")})}),s.jsx("div",{className:`flex ${l?"flex-wrap":""} gap-1 pb-2 overflow-x-auto scrollbar-hide`,children:Re.map(V=>s.jsx("button",{onClick:()=>d(V.id),className:`px-3 py-1.5 text-xs rounded-lg transition-colors shrink-0 ${u===V.id?"bg-brand-600 text-white":"text-fg-secondary hover:text-fg-primary hover:bg-surface-elevated"}`,children:n(V.labelKey)},V.id))})]}),m&&s.jsx("div",{className:`mx-7 mt-2 px-3 py-1.5 text-xs rounded-lg shrink-0 ${m.type==="error"?"bg-red-500/10 text-red-500":"bg-green-500/10 text-green-600"}`,children:m.text}),u==="skills"&&(()=>{const V=Me.trim().toLowerCase(),xe=V?B.filter(ye=>Xh(ye,o).toLowerCase().includes(V)||Qh(ye,o).toLowerCase().includes(V)):B,We=re&&Mt,he=xe.length===0&&De.length===0&&st.length===0;return s.jsxs("div",{className:`flex-1 overflow-y-auto ${l?"p-4":"p-6"} space-y-8`,children:[s.jsx("div",{className:"flex items-center gap-2",children:s.jsx("input",{value:Me,onChange:ye=>Ne(ye.target.value),placeholder:n("skillStore.searchMarkusHub"),className:`px-3 py-1.5 bg-surface-elevated border border-border-default rounded-lg text-sm text-fg-primary focus:border-brand-500 outline-none ${l?"flex-1 min-w-0":"w-72"}`})}),We&&he?s.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-4",children:Array.from({length:6}).map((ye,Ze)=>s.jsx("div",{className:"h-56 rounded-2xl skeleton"},Ze))}):he?s.jsxs("div",{className:"text-center text-fg-tertiary py-20",children:[s.jsx("div",{className:"text-4xl mb-3 opacity-30",children:"◇"}),s.jsx("div",{children:n("skillStore.noBuiltin")}),s.jsx("div",{className:"text-xs mt-1",children:n("skillStore.noBuiltinHint")})]}):s.jsxs(s.Fragment,{children:[xe.length>0&&s.jsxs("section",{children:[s.jsxs("div",{className:"flex items-baseline gap-2 mb-3",children:[s.jsx("h3",{className:"section-title",children:n("skillStore.tabs.builtin")}),s.jsx("span",{className:"text-xs text-fg-tertiary",children:n("skillStore.builtinCount",{count:xe.length})})]}),s.jsx(Er,{columns:3,children:xe.map(ye=>s.jsx(sa,{type:"skill",name:Xh(ye,o),description:Qh(ye,o),seed:ye.name,icon:Dd(ye.name,ye.category),version:ye.version,category:ye.category,tags:ye.tags,authorLabel:ye.author||void 0,installed:ye.installed,hideStats:!0,showTypeBadge:!1,cornerLabel:ye.installed?void 0:n("skillStore.tabs.builtin"),onClick:()=>N(ye)},ye.name))})]}),De.length>0&&s.jsxs("section",{children:[s.jsx("h3",{className:"section-title mb-3",children:n("skillStore.tabs.markusHub")}),s.jsx(Er,{columns:3,children:De.map(ye=>s.jsx(w4,{item:ye,installedSkills:x,purchased:Hd(ye,ct),onMsg:ut,onRefresh:()=>{it(),nt(Me)},highlight:ye.id===e,onHighlightDone:t},ye.id))})]}),st.length>0&&s.jsxs("section",{children:[s.jsxs("div",{className:"mb-3",children:[s.jsx("h3",{className:"section-title",children:n("tabs.connectors")}),s.jsx("p",{className:"text-xs text-fg-tertiary mt-0.5",children:n("connectorStore.emptyHint","连接器让智能体接入外部工具与服务 (MCP)")})]}),s.jsx(Er,{columns:3,children:st.map(ye=>s.jsx(w4,{item:ye,type:"connector",installedSkills:x,purchased:Hd(ye,ct),onMsg:ut,onRefresh:()=>{it(),nt(Me)},highlight:ye.id===e,onHighlightDone:t},ye.id))})]})]})]})})(),u==="skillhub"&&s.jsxs("div",{className:`flex-1 overflow-y-auto ${l?"p-4":"p-6"}`,children:[s.jsxs("div",{className:"flex items-center gap-2 mb-3 flex-wrap",children:[s.jsxs("select",{value:W,onChange:V=>{Z(V.target.value),z(1),se({q:ae||void 0,category:V.target.value||void 0,page:1})},className:"px-2 py-1.5 bg-surface-elevated border border-border-default rounded-lg text-xs text-fg-secondary outline-none",children:[s.jsx("option",{value:"",children:n("skillStore.allCategories")}),D.map(V=>s.jsx("option",{value:V,children:V},V))]}),s.jsxs("select",{value:U,onChange:V=>{Y(V.target.value),z(1),se({q:ae||void 0,category:W||void 0,page:1,sort:V.target.value})},className:"px-2 py-1.5 bg-surface-elevated border border-border-default rounded-lg text-xs text-fg-secondary outline-none",children:[s.jsx("option",{value:"score",children:n("skillStore.sortScore")}),s.jsx("option",{value:"downloads",children:n("skillStore.sortDownloads")}),s.jsx("option",{value:"stars",children:n("skillStore.sortStars")}),s.jsx("option",{value:"installs",children:n("skillStore.sortInstalls")})]}),!l&&s.jsx("span",{className:"text-xs text-fg-tertiary ml-auto",children:s.jsx("a",{href:"https://skillhub.tencent.com",target:"_blank",rel:"noopener noreferrer",className:"text-brand-500 hover:text-brand-500",children:n("skillStore.visitSite")})})]}),s.jsxs("div",{className:"flex items-center gap-2 mb-5",children:[s.jsx("input",{value:ae,onChange:V=>X(V.target.value),onKeyDown:V=>{V.key==="Enter"&&(z(1),se({q:ae||void 0,category:W||void 0,page:1}))},placeholder:n("skillStore.searchSkillhub"),className:"px-3 py-1.5 bg-surface-elevated border border-border-default rounded-lg text-sm text-fg-primary focus:border-brand-500 outline-none flex-1 min-w-0"}),s.jsx("button",{onClick:()=>{z(1),se({q:ae||void 0,category:W||void 0,page:1})},className:"px-3 py-1.5 bg-brand-600 hover:bg-brand-500 text-white text-xs rounded-lg shrink-0",children:"Search"})]}),F?s.jsx("div",{className:"text-center text-fg-tertiary py-20",children:s.jsx("div",{className:"animate-pulse",children:n("skillStore.loadingSkillhub")})}):T.length===0?s.jsxs("div",{className:"text-center text-fg-tertiary py-20",children:[s.jsx("div",{className:"text-4xl mb-3 opacity-30",children:"◎"}),s.jsx("div",{children:n("skillStore.noSkillhub")})]}):s.jsxs(s.Fragment,{children:[s.jsx("div",{className:"text-xs text-fg-tertiary mb-3",children:n("skillStore.skillhubTotal",{count:j.toLocaleString()})}),s.jsx(Er,{columns:3,children:T.map(V=>{const xe=x.some(We=>We.name===V.name||We.name===V.slug);return s.jsx(sa,{type:"skill",name:V.name,description:V.description_zh??V.description??"",seed:V.slug,icon:Dd(V.slug||V.name,V.tags?.[0]),version:V.version,authorLabel:"SkillHub",showTypeBadge:!1,tags:V.tags,installed:xe,hideStats:!0,onClick:()=>window.open(V.homepage,"_blank","noopener,noreferrer"),footerLeft:s.jsxs("span",{className:"flex items-center gap-2 text-[10px] text-fg-tertiary",children:[V.stars>0&&s.jsxs("span",{className:"text-amber-600",children:["★ ",V.stars.toLocaleString()]}),V.downloads>0&&s.jsxs("span",{children:[V.downloads>=1e4?`${(V.downloads/1e4).toFixed(1)}万`:V.downloads.toLocaleString()," ",n("skillStore.downloads")]})]}),actions:xe?void 0:s.jsx("button",{onClick:()=>{Ge(V)},disabled:p.has(V.name),className:"px-2.5 py-1 text-[10px] bg-brand-600 hover:bg-brand-500 text-white rounded-lg disabled:opacity-50",children:p.has(V.name)?"...":n("card.install")})},V.slug)})}),j>24&&s.jsxs("div",{className:"flex items-center justify-center gap-2 mt-6",children:[s.jsx("button",{disabled:O<=1,onClick:()=>{const V=O-1;z(V),se({q:ae||void 0,category:W||void 0,page:V})},className:"px-3 py-1.5 text-xs bg-surface-elevated text-fg-secondary rounded-lg hover:bg-surface-overlay disabled:opacity-30",children:n("skillStore.prevPage")}),s.jsx("span",{className:"text-xs text-fg-tertiary",children:n("skillStore.pageInfo",{current:O,total:Math.ceil(j/24)})}),s.jsx("button",{disabled:O>=Math.ceil(j/24),onClick:()=>{const V=O+1;z(V),se({q:ae||void 0,category:W||void 0,page:V})},className:"px-3 py-1.5 text-xs bg-surface-elevated text-fg-secondary rounded-lg hover:bg-surface-overlay disabled:opacity-30",children:n("skillStore.nextPage")})]})]})]}),u==="skillssh"&&s.jsxs("div",{className:`flex-1 overflow-y-auto ${l?"p-4":"p-6"}`,children:[s.jsxs("div",{className:`flex ${l?"flex-wrap":""} items-center gap-2 mb-5`,children:[s.jsx("input",{value:ce,onChange:V=>I(V.target.value),onKeyDown:V=>{V.key==="Enter"&&ce.trim()&&et(ce)},placeholder:n("skillStore.searchSkillssh"),className:`px-3 py-1.5 bg-surface-elevated border border-border-default rounded-lg text-sm text-fg-primary focus:border-brand-500 outline-none ${l?"flex-1 min-w-0":"w-72"}`}),s.jsx("button",{onClick:()=>{ce.trim()&&et(ce)},className:"px-3 py-1.5 bg-brand-600 hover:bg-brand-500 text-white text-xs rounded-lg shrink-0",children:"Search"}),!l&&s.jsx("span",{className:"text-xs text-fg-tertiary ml-auto",children:s.jsx("a",{href:"https://skills.sh",target:"_blank",rel:"noopener noreferrer",className:"text-brand-500 hover:text-brand-500",children:n("skillStore.visitSite")})})]}),Ee?s.jsx("div",{className:"text-center text-fg-tertiary py-20",children:s.jsx("div",{className:"animate-pulse",children:n("skillStore.loadingSkillssh")})}):pe.length===0?s.jsxs("div",{className:"text-center text-fg-tertiary py-20",children:[s.jsx("div",{className:"text-4xl mb-3 opacity-30",children:"⬡"}),s.jsx("div",{children:n("skillStore.browseSkillssh")}),s.jsx("div",{className:"text-xs mt-1",children:n("skillStore.browseSkillsshHint")})]}):s.jsx(Er,{columns:3,children:pe.map(V=>{const xe=x.some(We=>We.name===V.name);return s.jsx(sa,{type:"skill",name:V.name,description:V.description||"",seed:`${V.author}-${V.name}`,icon:Dd(V.name),authorLabel:`${V.author}/${V.repo}`,showTypeBadge:!1,installed:xe,hideStats:!0,cornerLabel:xe?void 0:"skills.sh",onClick:()=>window.open(V.url,"_blank","noopener,noreferrer"),footerLeft:V.installs?s.jsxs("span",{className:"text-[10px] text-fg-tertiary",children:[V.installs," installs"]}):void 0,actions:xe?void 0:s.jsx("button",{onClick:()=>{Qe(V)},disabled:p.has(V.name),className:"px-2.5 py-1 text-[10px] bg-brand-600 hover:bg-brand-500 text-white rounded-lg disabled:opacity-50",children:p.has(V.name)?"...":n("card.install")})},`${V.author}-${V.name}`)})})]})]})}const MK=["agent","team","skill","connector"];function Zh({title:e,subtitle:t,onMore:n,moreLabel:r}){return s.jsxs("div",{className:"flex items-end justify-between mb-3",children:[s.jsxs("div",{children:[s.jsx("h3",{className:"section-title",children:e}),t&&s.jsx("p",{className:"section-subtitle",children:t})]}),n&&s.jsxs("button",{className:"section-link",onClick:n,children:[r??"View all"," →"]})]})}function RK({item:e,onOpen:t}){const n=Wo(e.subtype==="connector"?"connector":e.itemType),r=Mg(n,e.slug||e.name),o=Ti[n];return s.jsxs("button",{onClick:t,className:"group relative w-full overflow-hidden rounded-2xl text-left h-44 md:h-52",style:{background:r},children:[s.jsx("div",{className:"absolute inset-0 bg-gradient-to-r from-black/55 via-black/20 to-transparent"}),s.jsx("svg",{className:"absolute -right-8 -bottom-10 opacity-20",width:"220",height:"220",viewBox:"0 0 24 24",fill:"none","aria-hidden":!0,children:s.jsx("path",{d:"M12 2l2.4 6.9L21 9l-5.4 4 2 7-5.6-4.1L6.4 20l2-7L3 9l6.6-.1z",fill:"white"})}),s.jsxs("div",{className:"relative h-full flex flex-col justify-end p-5 md:p-6",children:[s.jsxs("span",{className:"inline-flex w-fit items-center gap-1 rounded-full bg-white/20 backdrop-blur px-2.5 py-0.5 text-[11px] font-semibold text-white mb-2",children:["★ Featured · ",o.label]}),s.jsx("h2",{className:"text-xl md:text-2xl font-bold text-white drop-shadow-sm",children:e.name}),s.jsx("p",{className:"text-sm text-white/85 truncate max-w-lg mt-1",children:e.description}),s.jsxs("div",{className:"flex items-center gap-3 mt-3 text-white/80 text-xs",children:[s.jsxs("span",{className:"inline-flex items-center gap-1.5",children:[s.jsx(f0,{name:e.author?.displayName,username:e.author?.username,avatarUrl:e.author?.avatarUrl,hubBase:lt.getUrl(),size:18}),e.author?.displayName||e.author?.username]}),s.jsxs("span",{children:["↓ ",Ao(e.downloadCount)]}),(e.priceCents??0)>0?s.jsxs("span",{className:"badge-paid",children:["$",((e.priceCents??0)/100).toFixed(0)]}):s.jsx("span",{className:"badge-free",children:"Free"})]})]})]})}function k4({items:e,onOpen:t}){return s.jsx(Er,{columns:3,children:e.map(n=>s.jsx(sa,{type:n.subtype==="connector"?"connector":n.itemType,name:n.name,description:n.description,seed:n.slug||n.name,icon:n.icon,cover:n.thumbnailUrl,hubBase:lt.getUrl(),author:n.author,category:n.category,tags:n.tags,rating:parseFloat(n.avgRating)||0,ratingCount:n.ratingCount,downloadCount:n.downloadCount,priceCents:n.priceCents,currency:n.currency,onClick:()=>t(n)},n.id))})}function S4(){return s.jsx(Er,{columns:3,children:Array.from({length:6}).map((e,t)=>s.jsx("div",{className:"h-64 rounded-2xl skeleton"},t))})}function OK({onOpenType:e}){const{t}=ft(["store","common"]),[n,r]=k.useState([]),[o,l]=k.useState(!0);k.useEffect(()=>{let g=!1;return(async()=>{l(!0);try{const x=await lt.search({limit:60,sort:"popular"});g||r(x.items??[])}catch{g||r([])}finally{g||l(!1)}})(),()=>{g=!0}},[]);const u=k.useMemo(()=>{const g=n.filter(y=>y.featured);return(g.length>0?g:n).slice(0,3)},[n]),d=k.useMemo(()=>[...n].sort((g,x)=>(x.trendingScore??x.downloadCount)-(g.trendingScore??g.downloadCount)).slice(0,10),[n]),m=k.useMemo(()=>[...n].sort((g,x)=>(x.createdAt||"").localeCompare(g.createdAt||"")).slice(0,10),[n]),h=k.useMemo(()=>{const g=new Map;for(const x of n){const y=x.author?.username||x.author?.id;if(!y)continue;const w=g.get(y)??{author:x.author,downloads:0,count:0};w.downloads+=x.downloadCount||0,w.count+=1,g.set(y,w)}return[...g.values()].sort((x,y)=>y.downloads-x.downloads).slice(0,6)},[n]),p=g=>e(Wo(g.subtype==="connector"?"connector":g.itemType),g.id);return s.jsxs("div",{className:"flex-1 overflow-y-auto px-5 md:px-7 py-5 space-y-8",children:[s.jsxs("div",{className:"hero-glow rounded-2xl border border-border-subtle bg-surface-secondary p-5 md:p-6",children:[s.jsx("h1",{className:"text-2xl font-bold text-gradient tracking-tight",children:t("discover.title","Markus 广场")}),s.jsx("p",{className:"text-sm text-fg-tertiary mt-1 max-w-2xl",children:t("discover.subtitle","发现社区共享的智能体、AI 小队、技能与连接器 — 由创作者共建的开放生态。")}),s.jsx("div",{className:"flex flex-wrap gap-2 mt-4",children:MK.map(g=>s.jsxs("button",{onClick:()=>e(g),className:`inline-flex items-center gap-1.5 rounded-full px-3 py-1.5 text-xs font-medium text-white bg-gradient-to-r ${Ti[g].gradient} hover:opacity-90 transition-opacity`,children:[Ti[g].labelZh,s.jsx("span",{className:"opacity-70",children:Ti[g].label})]},g))})]}),o?s.jsx("div",{className:"h-52 rounded-2xl skeleton"}):u.length>0?s.jsx("div",{className:"grid grid-cols-1 lg:grid-cols-3 gap-4",children:u.map(g=>s.jsx(RK,{item:g,onOpen:()=>p(g)},g.id))}):null,s.jsxs("section",{children:[s.jsx(Zh,{title:t("discover.trending","热门趋势"),subtitle:t("discover.trendingSub","社区中下载与评分增长最快的资产")}),o?s.jsx(S4,{}):d.length>0?s.jsx(k4,{items:d,onOpen:p}):s.jsx(DK,{})]}),s.jsxs("section",{children:[s.jsx(Zh,{title:t("discover.fresh","新鲜上架"),subtitle:t("discover.freshSub","来自创作者的最新作品")}),o?s.jsx(S4,{}):m.length>0?s.jsx(k4,{items:m,onOpen:p}):null]}),h.length>0&&s.jsxs("section",{children:[s.jsx(Zh,{title:t("discover.topCreators","顶尖创作者"),subtitle:t("discover.topCreatorsSub","生态贡献榜")}),s.jsx("div",{className:"grid grid-cols-2 md:grid-cols-3 lg:grid-cols-6 gap-3",children:h.map((g,x)=>s.jsxs("div",{className:"asset-card p-4 flex flex-col items-center text-center",children:[s.jsxs("div",{className:"relative",children:[s.jsx(f0,{name:g.author?.displayName,username:g.author?.username,avatarUrl:g.author?.avatarUrl,hubBase:lt.getUrl(),size:48,verified:x<3}),x<3&&s.jsx("span",{className:"absolute -top-1 -left-1 w-5 h-5 rounded-full bg-amber-400 text-black text-[10px] font-bold flex items-center justify-center ring-2 ring-surface-secondary",children:x+1})]}),s.jsx("div",{className:"text-sm font-semibold text-fg-primary truncate w-full mt-2",children:g.author?.displayName||g.author?.username}),s.jsxs("div",{className:"text-[11px] text-fg-tertiary mt-0.5",children:[g.count," 作品 · ↓ ",Ao(g.downloads)]})]},g.author?.username||x))})]})]})}function DK(){const{t:e}=ft(["store"]);return s.jsxs("div",{className:"text-center py-12 rounded-2xl border border-dashed border-border-default",children:[s.jsx("div",{className:"text-3xl mb-2 opacity-40",children:"✦"}),s.jsx("div",{className:"text-fg-secondary font-medium",children:e("discover.empty","生态正在成长中")}),s.jsx("div",{className:"text-fg-tertiary text-sm mt-1",children:e("discover.emptyHint","成为首批创作者,分享你的第一个资产")})]})}function Sd(e,t,n){return e.i18n?.[n]?.[t]}function LK(){const{t:e,i18n:t}=ft(["store","common"]),n=Uo(),r=t.language,[o,l]=k.useState([]),[u,d]=k.useState({}),[m,h]=k.useState(new Set),[p,g]=k.useState(null),[x,y]=k.useState(!0),[w,N]=k.useState(""),[T,C]=k.useState("all"),[j,_]=k.useState(null),O=k.useCallback(async()=>{y(!0);try{const[H,W,Z,U]=await Promise.all([Ce.builder.artifacts.list().catch(()=>({artifacts:[]})),Ce.builder.artifacts.installed().catch(()=>({installed:{}})),Ce.skills.updates().catch(()=>({updates:[],count:0})),Ce.skills.builtin().catch(()=>({skills:[]}))]),Y={};for(const F of Z.updates)Y[F.name]={availableVersion:F.availableVersion,installedVersion:F.installedVersion,displayName:F.displayName,description:F.description};d(Y);const ae=H.artifacts.filter(F=>{const J=`${F.type}/${F.name}`;return!!W.installed[J]}),X=new Set(ae.filter(F=>F.type==="skill").map(F=>F.name));for(const F of U.skills)!F.installed||X.has(F.name)||!(W.installed[`skill/${F.name}`]||Y[F.name])&&!F.updateAvailable||!W.installed[`skill/${F.name}`]&&!Y[F.name]||(ae.push({type:"skill",name:F.name,meta:{displayName:F.i18n?.[r]?.displayName||F.name,description:F.i18n?.[r]?.description||F.description||"",version:F.installedVersion||F.version,author:F.author,category:F.category,tags:F.tags,i18n:F.i18n},path:"",updatedAt:""}),X.add(F.name));for(const[F,J]of Object.entries(Y))X.has(F)||(ae.push({type:"skill",name:F,meta:{displayName:J.displayName||F,description:J.description||"",version:J.installedVersion},path:"",updatedAt:""}),X.add(F));l(ae)}catch{}y(!1)},[r]);k.useEffect(()=>{O()},[O]),k.useEffect(()=>{const H=()=>{O()};return window.addEventListener("markus:data-changed",H),()=>window.removeEventListener("markus:data-changed",H)},[O]),k.useEffect(()=>{if(!p)return;const H=setTimeout(()=>g(null),3e3);return()=>clearTimeout(H)},[p]);const z=async(H,W)=>{if(!m.has(H)){h(Z=>new Set(Z).add(H));try{await Ce.skills.install({name:H,source:"builtin"});try{localStorage.removeItem("markus:template-updates-ack")}catch{}g({text:e("installedTab.updateSuccess",{name:H,version:W}),type:"success"}),window.dispatchEvent(new CustomEvent("markus:data-changed")),await O()}catch{g({text:e("installedTab.updateFailed",{name:H}),type:"error"})}h(Z=>{const U=new Set(Z);return U.delete(H),U})}},D=o.filter(H=>{if(T!=="all"&&H.type!==T)return!1;if(!w)return!0;const W=w.toLowerCase(),Z=(Sd(H.meta,"displayName",r)||H.meta.displayName||H.name).toLowerCase(),U=(Sd(H.meta,"description",r)||H.meta.description||"").toLowerCase();return Z.includes(W)||U.includes(W)}).sort((H,W)=>{const Z=H.type==="skill"&&u[H.name]?1:0;return(W.type==="skill"&&u[W.name]?1:0)-Z});return j?s.jsx(Ai,{type:j.type,name:j.name,onBack:()=>_(null)}):s.jsxs("div",{className:"flex-1 overflow-hidden flex flex-col",children:[s.jsxs("div",{className:`${n?"px-4":"px-6"} h-14 flex items-center shrink-0 gap-3`,children:[s.jsx("h2",{className:"text-lg font-semibold",children:e("installedTab.title")}),Object.keys(u).length>0&&s.jsxs("span",{className:"px-2 py-0.5 text-[11px] font-medium rounded-md bg-amber-500/15 text-amber-600 border border-amber-500/25",children:[e("installedTab.updateAvailable")," · ",Object.keys(u).length]})]}),s.jsxs("div",{className:`flex flex-wrap items-center gap-2 ${n?"px-4":"px-6"} py-2 shrink-0`,children:[s.jsx("div",{className:"flex gap-1",children:["all","agent","team","skill"].map(H=>s.jsx("button",{onClick:()=>C(H),className:`px-3 py-1 text-xs rounded-md transition-colors ${T===H?"bg-brand-600 text-white":"text-fg-secondary hover:text-fg-primary hover:bg-surface-elevated"}`,children:e(`installedTab.filter${H==="all"?"All":H==="agent"?"Agents":H==="team"?"Teams":"Skills"}`)},H))}),s.jsx("div",{className:"flex-1 min-w-[120px]",children:s.jsx("input",{type:"text",placeholder:e("installedTab.searchPlaceholder"),value:w,onChange:H=>N(H.target.value),className:"px-3 py-1.5 bg-surface-elevated border border-border-default rounded-lg text-sm w-full focus:border-brand-500 focus:outline-none"})})]}),s.jsx("div",{className:`flex-1 overflow-y-auto ${n?"p-4":"p-7"}`,children:x?s.jsx("div",{className:"text-center text-fg-tertiary py-20 animate-pulse",children:e("installedTab.loading")}):D.length===0?s.jsxs("div",{className:"text-center py-20",children:[s.jsx("div",{className:"text-4xl mb-4 opacity-30",children:"⧉"}),s.jsx("div",{className:"text-fg-secondary font-medium mb-1",children:e("installedTab.noItems")}),s.jsx("div",{className:"text-fg-tertiary text-sm",children:e("installedTab.noItemsHint")})]}):s.jsx(Er,{columns:3,children:D.map(H=>{const W=Sd(H.meta,"displayName",r)||H.meta.displayName||H.name,Z=Sd(H.meta,"description",r)||H.meta.description||"",U=H.meta.version||"",Y=H.meta.author||"",ae=H.meta.tags??[],X=H.meta.category||"",F=H.meta.icon,J=H.type==="skill"?u[H.name]:void 0;return s.jsx(sa,{type:H.type,name:W,description:Z,seed:H.name,icon:F,author:null,authorLabel:Y||void 0,version:J?J.installedVersion:U,category:X,tags:ae,installed:!J,hideStats:!0,cornerLabel:J?e("installedTab.updateAvailable"):void 0,onClick:()=>{H.path&&_({type:H.type,name:H.name})},actions:J?s.jsx("button",{type:"button",disabled:m.has(H.name),onClick:()=>{z(H.name,J.availableVersion)},className:"px-3 py-1.5 text-xs font-medium bg-amber-600 hover:bg-amber-500 text-white rounded-lg disabled:opacity-50 transition-colors",children:m.has(H.name)?e("installedTab.updating"):e("installedTab.updateTo",{version:J.availableVersion})}):void 0},`${H.type}/${H.name}`)})})}),p&&s.jsx("div",{className:`fixed bottom-6 left-1/2 -translate-x-1/2 z-50 px-4 py-2 rounded-lg text-sm shadow-lg ${p.type==="success"?"bg-emerald-600 text-white":"bg-red-600 text-white"}`,children:p.text})]})}const IK=50,PK=30;function zK(e,t,n,r){const o=k.useRef(0),l=k.useRef(0),u=k.useCallback(m=>{o.current=m.touches[0].clientX,l.current=m.touches[0].clientY},[]),d=k.useCallback(m=>{const h=m.changedTouches[0].clientX-o.current,p=m.changedTouches[0].clientY-l.current,g=Math.abs(h),x=Math.abs(p);if(g<IK||Math.atan2(x,g)*(180/Math.PI)>PK)return;if(r?.scrollContainerRef?.current){const N=r.scrollContainerRef.current,T=N.scrollLeft<=1,C=N.scrollLeft+N.clientWidth>=N.scrollWidth-1;if(h>0&&!T||h<0&&!C)return}const w=e.findIndex(N=>N.id===t);h<0&&w<e.length-1?n(e[w+1].id):h>0&&w>0?n(e[w-1].id):h>0&&w===0&&r?.onSwipeOutLeft?r.onSwipeOutLeft():h<0&&w===e.length-1&&r?.onSwipeOutRight&&r.onSwipeOutRight()},[e,t,n,r]);return{onTouchStart:u,onTouchEnd:d}}const BK=["builder","discover","agents","teams","skills","installed"],UK={agent:"agents",team:"teams",skill:"skills",connector:"skills"};function T3(e){return!!e&&BK.includes(e)}function $K(){const e=localStorage.getItem("markus_nav_installItem"),t=localStorage.getItem("markus_nav_storeTab");return e&&localStorage.removeItem("markus_nav_installItem"),t&&localStorage.removeItem("markus_nav_storeTab"),{tab:T3(t)?t:"builder",installId:e}}function HK({authUser:e}){const{t}=ft(["nav","store","common"]),n=k.useMemo(()=>[{id:"builder",label:t("nav:tabs.create")},{id:"discover",label:t("nav:tabs.discover")},{id:"agents",label:t("nav:tabs.agents")},{id:"teams",label:t("nav:tabs.teams")},{id:"skills",label:t("nav:tabs.skills")},{id:"installed",label:t("nav:tabs.installed")}],[t]),[r]=k.useState($K),[o,l]=k.useState(r.tab),[u,d]=k.useState(r.installId),m=zK(n,o,l);k.useEffect(()=>{const p=g=>{const x=g.detail,y=x.params?.storeTab??localStorage.getItem("markus_nav_storeTab");T3(y)&&l(y);const w=x.params?.installItem??localStorage.getItem("markus_nav_installItem");w&&d(w),localStorage.removeItem("markus_nav_storeTab"),localStorage.removeItem("markus_nav_installItem")};return window.addEventListener("markus:navigate",p),()=>window.removeEventListener("markus:navigate",p)},[]);const h=(p,g)=>{g&&d(g),l(UK[p]??"agents")};return s.jsxs("div",{className:"flex-1 overflow-hidden flex flex-col",onTouchStart:m.onTouchStart,onTouchEnd:m.onTouchEnd,children:[s.jsxs("div",{className:"flex items-center shrink-0 overflow-x-auto scrollbar-hide",children:[s.jsx(s5,{className:"ml-2"}),n.map(p=>s.jsx("button",{onClick:()=>l(p.id),className:`flex-1 min-w-fit px-3 py-2.5 text-xs font-medium text-center whitespace-nowrap transition-colors border-b-2 ${o===p.id?"border-brand-500 text-brand-500":"border-transparent text-fg-tertiary"}`,children:p.label},p.id))]}),s.jsxs("div",{className:"flex-1 overflow-hidden flex flex-col",children:[o==="builder"&&s.jsx(S3,{authUser:e}),o==="discover"&&s.jsx(OK,{onOpenType:h}),o==="agents"&&s.jsx(SK,{authUser:e,highlightItemId:u,onHighlightDone:()=>d(null)}),o==="teams"&&s.jsx(TK,{highlightItemId:u,onHighlightDone:()=>d(null)}),o==="skills"&&s.jsx(jK,{highlightItemId:u,onHighlightDone:()=>d(null)}),o==="installed"&&s.jsx(LK,{})]})]})}const N4="usageType",Jh="profile";function FK({onComplete:e,theme:t,onThemeChange:n,skipProfile:r,onProfileUpdated:o}){const{t:l}=ft(["onboarding","common"]),[u,d]=k.useState(0),[m,h]=k.useState(""),[p,g]=k.useState(""),[x,y]=k.useState(""),[w,N]=k.useState(""),[T,C]=k.useState(!1),[j,_]=k.useState(""),[O,z]=k.useState(!1),[D,H]=k.useState(null);k.useEffect(()=>{Ce.auth.me().then(({user:Ne})=>{Ne.name&&h(Ne.name),Ne.email&&g(Ne.email),Ne.avatarUrl&&H(Ne.avatarUrl);const Re=Ne.name||Ne.email?.split("@")[0]||"";Re&&Y(ut=>ut||l("usageType.defaultOrgName",{name:Re}))}).catch(()=>{}),Ce.settings.getOrg().then(({org:Ne})=>{Ne?.name&&Ne.name!=="My Organization"&&Y(Ne.name)}).catch(()=>{}),yn()&&Ce.hubOrgs.invitations().then(Ne=>{Ne.invitations?.length>0&&we(Ne.invitations)}).catch(()=>{})},[]);const[W,Z]=k.useState(null),[U,Y]=k.useState(""),[ae,X]=k.useState(!1),[F,J]=k.useState(!1),[B,Q]=k.useState(""),[re,we]=k.useState([]),[$,G]=k.useState(null),[ce,I]=k.useState(null),Ee=async()=>{const Ne=U.trim();if(Ne){X(!0),Q("");try{if(await Ce.settings.updateOrg(Ne),yn()){const Re=await Ce.hubOrgs.mine(),ut=Re.orgs?.find(it=>it.role==="owner")??Re.orgs?.[0];ut?.id?await Ce.hubOrgs.update(ut.id,{name:Ne}):await Ce.hubOrgs.create(Ne)}J(!0)}catch{Q(l("usageType.orgNameSaveFailed"))}finally{X(!1)}}},[Ue,De]=k.useState(!0),Ke=async()=>{if(_(""),!m.trim()){_(l("profile.errors.nameRequired"));return}if(!p.trim()){_(l("profile.errors.emailRequired"));return}if(!/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(p.trim())){_(l("profile.errors.emailInvalid"));return}if(x&&x.length<6){_(l("profile.errors.passwordTooShort"));return}if(x&&x!==w){_(l("profile.errors.passwordMismatch"));return}C(!0);try{const{user:Ne}=await Ce.auth.updateProfile(m.trim(),p.trim());x&&await Ce.auth.changePassword("",x),o?.(Ne),z(!0)}catch{_(l("profile.errors.saveFailed"))}finally{C(!1)}},st=[{value:"system",label:l("theme.system"),icon:"💻",desc:l("theme.systemDesc")},{value:"light",label:l("theme.light"),icon:"☀️",desc:l("theme.lightDesc")},{value:"dark",label:l("theme.dark"),icon:"🌊",desc:l("theme.darkDesc")},{value:"cyberpunk",label:l("theme.cyberpunk"),icon:"🔮",desc:l("theme.cyberpunkDesc")},{value:"mono",label:l("theme.mono"),icon:"⬛",desc:l("theme.monoDesc")}],mt=[{id:"welcome",title:l("welcome.title"),subtitle:l("welcome.subtitle"),content:s.jsx("p",{className:"text-fg-secondary text-sm leading-relaxed",children:s.jsx(j7,{i18nKey:"welcome.description",ns:"onboarding",components:{strong:s.jsx("strong",{className:"text-fg-primary"})}})})},{id:N4,title:l("usageType.title",{defaultValue:"How will you use Markus?"}),subtitle:l("usageType.subtitle",{defaultValue:"This helps us tailor your experience."}),content:s.jsxs("div",{className:"space-y-4",children:[s.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[s.jsxs("button",{onClick:()=>{Z("personal"),J(!0)},className:`flex flex-col items-center gap-3 rounded-xl border-2 p-5 transition-all text-left ${W==="personal"?"border-brand-500 bg-brand-500/10":"border-border-default hover:border-fg-tertiary bg-surface-elevated/30"}`,children:[s.jsx("span",{className:"text-2xl",children:"👤"}),s.jsxs("div",{children:[s.jsx("div",{className:"font-medium text-fg-primary text-sm text-center",children:l("usageType.personal",{defaultValue:"Personal"})}),s.jsx("div",{className:"text-[11px] text-fg-tertiary mt-1 text-center",children:l("usageType.personalDesc",{defaultValue:"Individual use with your own AI agents."})})]})]}),s.jsxs("button",{onClick:()=>{Z("organization"),J(!1)},className:`flex flex-col items-center gap-3 rounded-xl border-2 p-5 transition-all text-left ${W==="organization"?"border-brand-500 bg-brand-500/10":"border-border-default hover:border-fg-tertiary bg-surface-elevated/30"}`,children:[s.jsx("span",{className:"text-2xl",children:"🏢"}),s.jsxs("div",{children:[s.jsx("div",{className:"font-medium text-fg-primary text-sm text-center",children:l("usageType.organization",{defaultValue:"Team & Enterprise"})}),s.jsx("div",{className:"text-[11px] text-fg-tertiary mt-1 text-center",children:l("usageType.organizationDesc",{defaultValue:"For teams sharing licenses and collaborating."})})]})]})]}),W==="organization"&&s.jsxs("div",{className:"space-y-4 mt-4",children:[re.length>0&&s.jsxs("div",{className:"space-y-2",children:[s.jsx("div",{className:"text-xs text-fg-tertiary font-medium",children:l("usageType.pendingInvitations")}),re.map(Ne=>s.jsxs("div",{className:"flex items-center justify-between px-4 py-3 rounded-xl border border-amber-500/20 bg-amber-500/5",children:[s.jsxs("div",{children:[s.jsx("div",{className:"text-sm font-medium text-fg-primary",children:Ne.orgName}),s.jsx("div",{className:"text-[11px] text-fg-tertiary",children:l("usageType.invitedBy",{name:Ne.invitedBy})})]}),s.jsx("button",{onClick:async()=>{G(Ne.orgId);try{await Ce.hubOrgs.acceptInvitation(Ne.orgId),I(Ne.orgId),J(!0)}catch{}finally{G(null)}},disabled:$===Ne.orgId||ce===Ne.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:ce===Ne.orgId?l("usageType.accepted"):$===Ne.orgId?l("usageType.accepting"):l("usageType.acceptAndJoin")})]},Ne.orgId)),s.jsx("div",{className:"text-[11px] text-fg-tertiary text-center pt-1",children:l("usageType.orCreateNew")})]}),s.jsxs("div",{className:"space-y-1",children:[s.jsx("label",{className:"text-xs text-fg-tertiary font-medium",children:l("usageType.orgNameLabel")}),s.jsx("input",{type:"text",value:U,onChange:Ne=>{Y(Ne.target.value),J(!1),Q("")},placeholder:l("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"})]}),B&&s.jsx("p",{className:"text-xs text-red-500",children:B}),s.jsx("button",{onClick:()=>{Ee()},disabled:ae||!U.trim()||F,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:l(ae?"common:saving":F?"usageType.orgNameSaved":"usageType.setOrgName")})]})]})},{id:Jh,title:l("profile.title"),subtitle:l("profile.subtitle"),content:O?s.jsxs("div",{className:"flex items-center gap-3 bg-green-500/10 border border-green-500/30 rounded-xl p-4",children:[s.jsx("span",{className:"text-green-600 text-lg",children:"✓"}),s.jsxs("div",{children:[s.jsx("div",{className:"text-sm font-medium text-green-600",children:l("profile.saved")}),s.jsxs("div",{className:"text-xs text-fg-secondary mt-0.5",children:[m," · ",p]})]})]}):s.jsxs("div",{className:"space-y-4",children:[s.jsx("div",{className:"flex justify-center",children:s.jsx(a5,{currentUrl:D,name:m,size:64,targetType:"user"})}),s.jsxs("div",{className:"space-y-1",children:[s.jsxs("label",{className:"text-xs text-fg-tertiary font-medium",children:[l("profile.nameLabel")," ",s.jsx("span",{className:"text-red-500",children:"*"})]}),s.jsx("input",{type:"text",value:m,onChange:Ne=>h(Ne.target.value),placeholder:l("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})]}),s.jsxs("div",{className:"space-y-1",children:[s.jsxs("label",{className:"text-xs text-fg-tertiary font-medium",children:[l("profile.emailLabel")," ",s.jsx("span",{className:"text-red-500",children:"*"})]}),s.jsx("input",{type:"email",value:p,onChange:Ne=>g(Ne.target.value),placeholder:l("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"})]}),s.jsxs("div",{className:"space-y-1",children:[s.jsx("label",{className:"text-xs text-fg-tertiary font-medium",children:l("profile.newPasswordLabel")}),s.jsx("input",{type:"password",value:x,onChange:Ne=>y(Ne.target.value),placeholder:l("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"})]}),x&&s.jsxs("div",{className:"space-y-1",children:[s.jsx("label",{className:"text-xs text-fg-tertiary font-medium",children:l("profile.confirmPasswordLabel")}),s.jsx("input",{type:"password",value:w,onChange:Ne=>N(Ne.target.value),placeholder:l("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"})]}),j&&s.jsx("div",{className:"px-3 py-2 bg-red-500/10 border border-red-500/30 rounded-lg text-xs text-red-500",children:j}),s.jsx("button",{onClick:()=>{Ke()},disabled:T||!m.trim()||!p.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:l(T?"common:saving":"profile.saveProfile")})]})},{id:"theme",title:l("theme.title"),subtitle:l("theme.subtitle"),content:s.jsxs("div",{className:"space-y-4",children:[s.jsx("div",{className:"grid grid-cols-3 gap-3",children:st.map(Ne=>s.jsxs("button",{onClick:()=>n(Ne.value),className:`flex flex-col items-center gap-2 rounded-xl border-2 p-5 transition-all ${t===Ne.value?"border-brand-500 bg-brand-500/10":"border-border-default hover:border-fg-tertiary bg-surface-elevated/30"}`,children:[s.jsx("span",{className:"text-2xl",children:Ne.icon}),s.jsx("span",{className:"text-sm font-medium text-fg-primary",children:Ne.label}),s.jsx("span",{className:"text-[11px] text-fg-tertiary leading-tight text-center",children:Ne.desc})]},Ne.value))}),s.jsxs("label",{className:"flex items-center gap-2.5 p-3 bg-surface-elevated/30 rounded-lg cursor-pointer group",children:[s.jsx("input",{type:"checkbox",checked:Ue,onChange:Ne=>De(Ne.target.checked),className:"accent-brand-500 shrink-0"}),s.jsx("span",{className:"text-[11px] text-fg-tertiary",children:l("done.telemetry")})]})]})}],ct=r?mt.filter(Ne=>Ne.id!==Jh):mt,Dt=ct.findIndex(Ne=>Ne.id===N4),Mt=ct.findIndex(Ne=>Ne.id===Jh),Xt=()=>{u===Dt&&Dt>=0&&!W||u===Dt&&W==="organization"&&!F||u===Mt&&Mt>=0&&!O||(u<ct.length-1?d(u+1):(fetch("/api/settings/telemetry",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({enabled:Ue})}).catch(()=>{}),e()))},Me=ct[u];return s.jsx("div",{className:"min-h-dvh bg-surface-primary flex items-center justify-center p-4",children:s.jsx("div",{className:"w-full max-w-lg",children:s.jsxs("div",{className:"bg-surface-elevated rounded-2xl p-8",children:[s.jsx("div",{className:"flex gap-1.5 mb-8",children:ct.map((Ne,Re)=>s.jsx("div",{className:`h-1 flex-1 rounded-full transition-colors ${Re<=u?"bg-brand-500":"bg-surface-elevated"}`},Re))}),s.jsx("h2",{className:"text-2xl font-bold text-fg-primary",children:Me.title}),s.jsx("p",{className:"text-sm text-fg-secondary mt-1 mb-6",children:Me.subtitle}),Me.content,s.jsxs("div",{className:"flex justify-between mt-8",children:[u>0?s.jsx("button",{onClick:()=>d(u-1),className:"px-4 py-2 text-sm text-fg-secondary hover:text-fg-primary transition-colors",children:l("common:back")}):s.jsx("span",{}),s.jsx("button",{onClick:Xt,disabled:Mt>=0&&u===Mt&&!O||Dt>=0&&u===Dt&&(!W||W==="organization"&&!F),className:`px-6 py-2.5 text-white text-sm rounded-xl transition-colors ${Mt>=0&&u===Mt&&!O||Dt>=0&&u===Dt&&(!W||W==="organization"&&!F)?"bg-brand-600/40 cursor-not-allowed":"bg-brand-600 hover:bg-brand-500"}`,children:u===ct.length-1?l("getStarted"):l("common:next")})]})]})})})}const qK="markus:legal-consent",GK="https://markus.global";function VK({onLogin:e,hasOwner:t}){const{t:n,i18n:r}=ft("auth"),[o,l]=k.useState(null),[u,d]=k.useState(""),[m,h]=k.useState(!1),[p,g]=k.useState(""),[x,y]=k.useState(""),[w,N]=k.useState(!1),[T,C]=k.useState(!1),j=Z=>{const U=(r.language||"").toLowerCase().startsWith("zh")?"?lang=zh":"";return`${GK}${Z}${U}`},_=()=>{try{localStorage.setItem(qK,JSON.stringify({acceptedAt:new Date().toISOString(),terms:!0,privacy:!0}))}catch{}},O=()=>T?(_(),!0):(N(!1),requestAnimationFrame(()=>N(!0)),!1),z=async(Z,U=!1)=>{if(!(!U&&!O())){d(""),l(Z??"hub");try{await na(Z);const Y=yn(),ae=ua();if(!Y||!ae){d(n("login.hubUnavailable"));return}const{user:X,needsOnboarding:F}=await Ce.auth.hubLogin(Y,ae);e(X,F??!1,{fromHub:!0})}catch(Y){const ae=Y instanceof Error?Y.message:"";if(!ae.includes("cancelled")){if(!U&&yn())return Ni(),z(Z,!0);d(ae||n("login.hubUnavailable"))}}finally{l(null)}}};k.useEffect(()=>{const Z=window.markusDesktop;if(!Z?.consumePendingDeepLinkAuth)return;let U=!1;return Z.consumePendingDeepLinkAuth().then(async Y=>{if(!(U||!Y)&&T){d(""),l("hub");try{const ae=await XO(Y),X=yn(),F=ua();if(!ae||!X||!F){d(n("login.hubUnavailable"));return}const{user:J,needsOnboarding:B}=await Ce.auth.hubLogin(X,F);e(J,B??!1,{fromHub:!0})}catch{d(n("login.hubUnavailable"))}finally{U||l(null)}}}).catch(()=>{}),()=>{U=!0}},[]);const D=async Z=>{if(Z.preventDefault(),!(!p.trim()||!x)&&O()){d(""),l("local");try{const{user:U,needsOnboarding:Y}=await Ce.auth.login(p.trim(),x);e(U,Y??!1)}catch{d(n("login.invalidCredentials"))}finally{l(null)}}},H=n(t?"login.welcomeBack":"login.getStarted"),W="w-full flex items-center justify-center gap-3 h-11 px-4 bg-surface-elevated border border-border-default rounded-xl text-sm text-fg-primary font-medium transition-all hover:border-brand-400/60 hover:shadow-sm active:scale-[0.99] disabled:opacity-50 disabled:pointer-events-none";return s.jsxs("div",{className:"min-h-dvh bg-surface-primary flex flex-col items-center justify-center p-4 relative overflow-hidden",children:[s.jsxs("div",{className:"pointer-events-none absolute inset-0 overflow-hidden",children:[s.jsx("div",{className:"absolute -top-48 left-1/2 -translate-x-1/2 h-[42rem] w-[42rem] rounded-full bg-brand-500/20 blur-[120px]"}),s.jsx("div",{className:"absolute top-1/4 -left-40 h-[26rem] w-[26rem] rounded-full bg-brand-400/10 blur-[100px]"}),s.jsx("div",{className:"absolute -bottom-40 -right-32 h-[34rem] w-[34rem] rounded-full bg-brand-600/10 blur-[110px]"})]}),s.jsxs("div",{className:"w-full max-w-[26rem] relative z-10 flex-1 flex flex-col justify-center",children:[s.jsxs("div",{className:"text-center mb-8",children:[s.jsx("img",{src:"/logo.png",alt:"Markus",className:"w-16 h-16 mx-auto mb-4 rounded-2xl shadow-xl shadow-brand-900/20 ring-1 ring-border-default/40"}),s.jsx("div",{className:"text-[1.75rem] leading-none font-extrabold tracking-tight text-fg-primary mb-2",children:"Markus"}),s.jsx("div",{className:"text-sm text-fg-tertiary",children:H})]}),s.jsx("div",{className:"bg-surface-secondary/70 backdrop-blur-xl border border-border-default/80 rounded-3xl p-7 sm:p-8 shadow-2xl shadow-black/10",children:m?s.jsxs("div",{className:"space-y-4",children:[s.jsxs("div",{children:[s.jsx("div",{className:"text-base font-semibold text-fg-primary",children:n("login.localTitle")}),s.jsx("div",{className:"text-xs text-fg-tertiary mt-0.5",children:n("login.localAccountHint")})]}),s.jsxs("form",{onSubmit:D,className:"space-y-3",children:[s.jsx("input",{type:"email",value:p,onChange:Z=>g(Z.target.value),autoComplete:"email",autoFocus:!0,placeholder:n("login.email"),className:"w-full px-4 h-11 bg-surface-elevated border border-border-default rounded-xl text-sm text-fg-primary focus:border-brand-500 focus:ring-2 focus:ring-brand-500/20 outline-none transition-all placeholder:text-fg-tertiary",required:!0}),s.jsx("input",{type:"password",value:x,onChange:Z=>y(Z.target.value),autoComplete:"current-password",placeholder:n("login.password"),className:"w-full px-4 h-11 bg-surface-elevated border border-border-default rounded-xl text-sm text-fg-primary focus:border-brand-500 focus:ring-2 focus:ring-brand-500/20 outline-none transition-all placeholder:text-fg-tertiary",required:!0}),u&&s.jsx("div",{className:"px-3 py-2 bg-red-500/10 border border-red-500/30 rounded-lg text-xs text-red-500",children:u}),!t&&s.jsx("p",{className:"text-[11px] text-fg-tertiary",children:n("login.defaultCredentials")}),s.jsx("button",{type:"submit",disabled:o==="local"||!p||!x,className:"w-full h-11 bg-brand-600 hover:bg-brand-500 disabled:opacity-50 text-white text-sm font-semibold rounded-xl transition-all shadow-md shadow-brand-900/30 hover:shadow-lg active:scale-[0.99]",children:n(o==="local"?"login.signingIn":"login.signIn")})]}),s.jsx("div",{className:"text-center",children:s.jsx("button",{onClick:()=>{h(!1),d("")},className:"text-xs text-fg-tertiary hover:text-fg-secondary transition-colors",children:n("login.backToHub")})})]}):s.jsxs("div",{className:"space-y-3",children:[s.jsxs("button",{onClick:()=>z("google"),disabled:!!o,className:W,children:[s.jsxs("svg",{className:"w-5 h-5",viewBox:"0 0 24 24",children:[s.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"}),s.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"}),s.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"}),s.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"})]}),n(o==="google"?"login.connectingHub":"login.withGoogle")]}),s.jsxs("button",{onClick:()=>z("github"),disabled:!!o,className:W,children:[s.jsx("svg",{className:"w-5 h-5",viewBox:"0 0 24 24",fill:"currentColor",children:s.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"})}),n(o==="github"?"login.connectingHub":"login.withGithub")]}),s.jsxs("button",{onClick:()=>z("email"),disabled:!!o,className:W,children:[s.jsx("svg",{className:"w-5 h-5",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:1.5,children:s.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"})}),n(o==="email"?"login.connectingHub":"login.withEmail")]}),u&&s.jsx("div",{className:"px-3 py-2 bg-red-500/10 border border-red-500/30 rounded-lg text-xs text-red-500",children:u}),s.jsxs("div",{className:"flex items-center gap-3 py-1 text-[11px] text-fg-tertiary",children:[s.jsx("span",{className:"h-px flex-1 bg-border-default"}),n("login.or"),s.jsx("span",{className:"h-px flex-1 bg-border-default"})]}),s.jsx("button",{onClick:()=>{h(!0),d("")},disabled:!!o,className:"w-full h-11 px-4 rounded-xl text-sm text-fg-secondary font-medium transition-all hover:bg-surface-elevated/70 disabled:opacity-50",children:n("login.useLocalAccount")})]})}),s.jsxs("label",{onAnimationEnd:()=>N(!1),className:`mt-5 flex items-start justify-center gap-2 text-[11px] leading-relaxed cursor-pointer select-none px-2 transition-colors ${w?"animate-shake text-fg-primary font-medium":"text-fg-tertiary"}`,children:[s.jsx("input",{type:"checkbox",checked:T,onChange:Z=>{C(Z.target.checked),Z.target.checked&&N(!1)},className:"mt-0.5 h-3.5 w-3.5 shrink-0 accent-brand-600 cursor-pointer"}),s.jsxs("span",{className:"text-center",children:[n("login.consentPrefix")," ",s.jsx("a",{href:j("/terms"),target:"_blank",rel:"noopener noreferrer",className:"text-brand-500 hover:text-brand-400 underline",children:n("login.termsLink")})," ",n("login.consentAnd")," ",s.jsx("a",{href:j("/privacy"),target:"_blank",rel:"noopener noreferrer",className:"text-brand-500 hover:text-brand-400 underline",children:n("login.privacyLink")})]})]})]}),s.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:[s.jsx("a",{href:"https://markus.global",target:"_blank",rel:"noopener noreferrer",className:"hover:text-fg-secondary transition-colors",children:"markus.global"}),s.jsx("a",{href:"mailto:business@markus.global",className:"hover:text-fg-secondary transition-colors",children:n("login.contactSales")})]})]})}function KK({token:e,onComplete:t}){const{t:n}=ft("auth"),[r,o]=k.useState(null),[l,u]=k.useState(""),[d,m]=k.useState(""),[h,p]=k.useState(""),[g,x]=k.useState(!1),[y,w]=k.useState(!1),[N,T]=k.useState(!1);k.useEffect(()=>{Ce.auth.inviteInfo(e).then(j=>o(j)).catch(()=>T(!0))},[e]);const C=async j=>{if(j.preventDefault(),p(""),l.length<6){p(n("invite.passwordMinLength"));return}if(l!==d){p(n("invite.passwordsDoNotMatch"));return}x(!0);try{await Ce.auth.setup(e,l),w(!0),setTimeout(()=>{window.location.hash="",t()},2e3)}catch{p(n("invite.error"))}finally{x(!1)}};return s.jsxs("div",{className:"min-h-dvh bg-surface-primary flex items-center justify-center p-4 relative overflow-hidden",children:[s.jsx("div",{className:"absolute inset-0 bg-[radial-gradient(ellipse_at_top,_var(--tw-gradient-stops))] from-brand-950/50 via-transparent to-transparent"}),s.jsxs("div",{className:"w-full max-w-sm relative z-10",children:[s.jsxs("div",{className:"text-center mb-8",children:[s.jsx("img",{src:"/logo.png",alt:"Markus",className:"w-14 h-14 mx-auto mb-3 rounded-xl shadow-lg shadow-black/40"}),s.jsx("div",{className:"text-2xl font-extrabold tracking-tight text-fg-primary mb-1",children:"Markus"}),s.jsx("div",{className:"text-sm text-fg-tertiary",children:n("invite.subtitle")})]}),s.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?s.jsxs("div",{className:"text-center space-y-3",children:[s.jsx("div",{className:"text-red-500 text-3xl",children:"⚠"}),s.jsx("p",{className:"text-sm text-fg-secondary",children:n("invite.invalidLink")}),s.jsx("button",{onClick:()=>{window.location.hash="",t()},className:"text-sm text-brand-500 hover:text-brand-400",children:n("login.signIn")})]}):y?s.jsxs("div",{className:"text-center space-y-3",children:[s.jsx("div",{className:"text-green-500 text-3xl",children:"✓"}),s.jsx("p",{className:"text-sm text-fg-secondary",children:n("invite.setupComplete")})]}):r?s.jsxs("form",{onSubmit:C,className:"space-y-5",children:[s.jsx("h2",{className:"text-lg font-semibold text-fg-primary text-center",children:n("invite.greeting",{name:r.name})}),s.jsx("p",{className:"text-xs text-fg-tertiary text-center",children:r.email}),s.jsxs("div",{className:"space-y-1",children:[s.jsx("label",{className:"text-xs text-fg-tertiary font-medium",children:n("invite.setPassword")}),s.jsx("input",{type:"password",value:l,onChange:j=>u(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})]}),s.jsxs("div",{className:"space-y-1",children:[s.jsx("label",{className:"text-xs text-fg-tertiary font-medium",children:n("invite.confirmPassword")}),s.jsx("input",{type:"password",value:d,onChange:j=>m(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})]}),h&&s.jsx("div",{className:"px-3 py-2 bg-red-500/10 border border-red-500/30 rounded-lg text-xs text-red-500",children:h}),s.jsx("button",{type:"submit",disabled:g||!l||!d,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:n(g?"invite.settingUp":"invite.setupAccount")})]}):s.jsx("div",{className:"text-center text-fg-tertiary text-sm animate-pulse py-4",children:"Loading…"})})]})]})}function WK({onComplete:e,isFirstTime:t}){const{t:n}=ft("auth"),[r,o]=k.useState(""),[l,u]=k.useState(""),[d,m]=k.useState(""),[h,p]=k.useState(""),[g,x]=k.useState(!1),y=async w=>{if(w.preventDefault(),p(""),l.length<6){p(n("changePassword.passwordMinLength"));return}if(l!==d){p(n("changePassword.passwordsDoNotMatch"));return}x(!0);try{await Ce.auth.changePassword(r,l),e()}catch{p(n("changePassword.failedToChange"))}finally{x(!1)}};return s.jsxs("div",{className:"min-h-dvh bg-surface-primary flex items-center justify-center p-4 relative overflow-hidden",children:[s.jsx("div",{className:"absolute inset-0 bg-[radial-gradient(ellipse_at_top,_var(--tw-gradient-stops))] from-brand-950/50 via-transparent to-transparent"}),s.jsxs("div",{className:"w-full max-w-sm relative z-10",children:[s.jsxs("div",{className:"text-center mb-8",children:[s.jsx("img",{src:"/logo.png",alt:"Markus",className:"w-14 h-14 mx-auto mb-3 rounded-xl shadow-lg shadow-black/40"}),s.jsx("div",{className:"text-2xl font-extrabold tracking-tight text-fg-primary mb-1",children:"Markus"}),s.jsx("div",{className:"text-sm text-fg-tertiary",children:n("login.subtitle")})]}),s.jsxs("form",{onSubmit:y,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:[s.jsxs("div",{children:[s.jsx("h2",{className:"text-lg font-semibold text-fg-primary text-center",children:n(t?"changePassword.setYourPassword":"changePassword.changePassword")}),t&&s.jsx("p",{className:"text-xs text-amber-600/80 text-center mt-2",children:n("changePassword.defaultPasswordWarning")})]}),!t&&s.jsxs("div",{className:"space-y-1",children:[s.jsx("label",{className:"text-xs text-fg-tertiary font-medium",children:n("changePassword.currentPassword")}),s.jsx("input",{type:"password",value:r,onChange:w=>o(w.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"})]}),s.jsxs("div",{className:"space-y-1",children:[s.jsx("label",{className:"text-xs text-fg-tertiary font-medium",children:n("changePassword.newPassword")}),s.jsx("input",{type:"password",value:l,onChange:w=>u(w.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})]}),s.jsxs("div",{className:"space-y-1",children:[s.jsx("label",{className:"text-xs text-fg-tertiary font-medium",children:n("changePassword.confirmNewPassword")}),s.jsx("input",{type:"password",value:d,onChange:w=>m(w.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})]}),h&&s.jsx("div",{className:"px-3 py-2 bg-red-500/10 border border-red-500/30 rounded-lg text-xs text-red-500",children:h}),s.jsx("button",{type:"submit",disabled:g||!l||!d,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:n(g?"changePassword.saving":t?"changePassword.setPasswordAndContinue":"changePassword.changePassword")})]})]})]})}function YK({side:e,defaultWidth:t,minWidth:n,maxWidth:r,collapsedWidth:o=0,storageKey:l}){const[u,d]=k.useState(()=>{try{const N=localStorage.getItem(`${l}_w`);if(N)return Math.max(n,Math.min(r,parseInt(N,10)))}catch{}return t}),[m,h]=k.useState(()=>{try{return localStorage.getItem(`${l}_c`)==="1"}catch{return!1}}),p=k.useRef(!1),g=k.useRef(n),x=k.useRef(r);g.current=n,x.current=r,k.useEffect(()=>{try{localStorage.setItem(`${l}_w`,String(u))}catch{}},[u,l]),k.useEffect(()=>{try{localStorage.setItem(`${l}_c`,m?"1":"0")}catch{}},[m,l]),k.useEffect(()=>{d(N=>Math.max(n,Math.min(r,N)))},[n,r]);const y=k.useCallback(N=>{N.preventDefault(),p.current=!0;const T=N.clientX,C=u,j=O=>{if(!p.current)return;const z=e==="left"?O.clientX-T:T-O.clientX;d(Math.max(g.current,Math.min(x.current,C+z)))},_=()=>{p.current=!1,document.removeEventListener("mousemove",j),document.removeEventListener("mouseup",_),document.body.style.cursor="",document.body.style.userSelect=""};document.addEventListener("mousemove",j),document.addEventListener("mouseup",_),document.body.style.cursor="col-resize",document.body.style.userSelect="none"},[u,e]),w=k.useCallback(()=>h(N=>!N),[]);return{width:m?o:u,rawWidth:u,collapsed:m,toggle:w,setCollapsed:h,setWidth:d,onResizeStart:y}}const RW=[{value:"system",label:"System"},{value:"light",label:"Light"},{value:"dark",label:"Dark"},{value:"cyberpunk",label:"Cyberpunk"},{value:"mono",label:"Mono"}],qp="markus-theme";function C4(e){const t=document.documentElement;t.classList.remove("light","dark","cyberpunk","mono"),e==="light"?t.classList.add("light"):e==="dark"?t.classList.add("dark"):e==="cyberpunk"?t.classList.add("cyberpunk"):e==="mono"&&t.classList.add("mono")}function XK(){try{const e=localStorage.getItem(qp);if(e==="midnight")return localStorage.setItem(qp,"dark"),"dark";if(e==="light"||e==="dark"||e==="system"||e==="cyberpunk"||e==="mono")return e}catch{}return"system"}function QK(){const[e,t]=k.useState(XK),n=k.useCallback(r=>{t(r);try{localStorage.setItem(qp,r)}catch{}C4(r)},[]);return k.useEffect(()=>{C4(e)},[e]),{mode:e,setMode:n}}const Id={agents:[],tasks:[],requirements:[],projects:[],deliverables:[],workflows:[]},ZK={team:["agents","workflows","tasks","requirements","projects","deliverables"],work:["workflows","projects","requirements","tasks","agents","deliverables"],deliverables:["deliverables","agents","tasks","requirements","projects","workflows"]},JK=["agents","tasks","requirements","projects","deliverables","workflows"];let T4="",E4="all",A4=Id,_4=!1;function eW({onClose:e,currentPage:t}){const{t:n}=ft(["common","home","work"]);Bo(!0);const[r,o]=k.useState(T4),[l,u]=k.useState(E4),[d,m]=k.useState(A4),[h,p]=k.useState(!1),[g,x]=k.useState(_4),[y,w]=k.useState(-1);k.useEffect(()=>{T4=r},[r]),k.useEffect(()=>{E4=l},[l]),k.useEffect(()=>{A4=d},[d]),k.useEffect(()=>{_4=g},[g]);const N=k.useRef(null),T=k.useRef(void 0),C=k.useRef(null),j=k.useRef(null);k.useEffect(()=>{setTimeout(()=>{N.current?.focus(),N.current?.select()},100)},[]);const _=k.useCallback(async X=>{if(!X.trim()){m(Id),x(!1),w(-1);return}p(!0),x(!0),w(-1);const F=X.toLowerCase();try{const[J,B,Q,re,we,$]=await Promise.allSettled([Ce.agents.list(),Ce.tasks.list({search:X,pageSize:20}),Ce.requirements.list(),Ce.projects.list(),Ce.deliverables.search({q:X,limit:20}),Ce.teams.list()]),G=J.status==="fulfilled"?J.value.agents.filter(Ke=>Ke.name?.toLowerCase().includes(F)||Ke.role?.toLowerCase().includes(F)):[],ce=B.status==="fulfilled"?B.value.tasks:[],I=Q.status==="fulfilled"?Q.value.requirements.filter(Ke=>Ke.title?.toLowerCase().includes(F)||Ke.description?.toLowerCase().includes(F)):[],Ee=re.status==="fulfilled"?re.value.projects.filter(Ke=>Ke.name?.toLowerCase().includes(F)||Ke.description?.toLowerCase().includes(F)):[],Ue=we.status==="fulfilled"?we.value.results:[],De=[];if($.status==="fulfilled"){const Ke=await Promise.allSettled($.value.teams.map(st=>Ce.workflows.list(st.id)));for(const st of Ke)if(st.status==="fulfilled")for(const mt of st.value.workflows)(mt.name.toLowerCase().includes(F)||(mt.displayName||"").toLowerCase().includes(F)||mt.description?.toLowerCase().includes(F))&&De.push(mt)}m({agents:G,tasks:ce,requirements:I,projects:Ee,deliverables:Ue,workflows:De})}catch{m(Id)}finally{p(!1)}},[]),O=X=>{o(X),T.current&&clearTimeout(T.current),T.current=setTimeout(()=>_(X),400)},z=k.useCallback((X,F)=>{e(),at.navigate(X,F)},[e]),D=[{id:"all",label:n("common:all",{defaultValue:"全部"})},{id:"agents",label:n("common:agents",{defaultValue:"智能体"})},{id:"tasks",label:n("common:tasks",{defaultValue:"任务"})},{id:"requirements",label:n("common:requirements",{defaultValue:"需求"})},{id:"projects",label:n("common:projects",{defaultValue:"项目"})},{id:"deliverables",label:n("common:deliverables",{defaultValue:"交付物"})},{id:"workflows",label:n("common:workflows",{defaultValue:"工作流"})}],H=k.useMemo(()=>ZK[t||""]||JK,[t]),W=k.useMemo(()=>{const X=[],F=l==="all"?8:void 0,J=B=>{if(l!=="all"&&l!==B)return;const Q=d[B].length;if(B==="workflows"){const re=F?d.workflows.slice(0,F):d.workflows;for(const we of re)X.push({id:we.name,type:"workflow",page:me.WORK,params:{boardType:"workflows"}})}else{const re=d[B],we=F?re.slice(0,F):re;for(const $ of we)switch(B){case"agents":X.push({id:$.id,type:"agent",page:me.TEAM,params:{agentId:$.id}});break;case"tasks":X.push({id:$.id,type:"task",page:me.WORK,params:{openTask:$.id}});break;case"requirements":X.push({id:$.id,type:"requirement",page:me.WORK,params:{openRequirement:$.id}});break;case"projects":X.push({id:$.id,type:"project",page:me.WORK,params:{projectId:$.id}});break;case"deliverables":X.push({id:$.id,type:"deliverable",page:me.DELIVERABLES,params:{openDeliverable:$.id}});break}}F&&Q>F&&X.push({id:`more_${B}`,type:"showMore",page:"",expandCategory:B,totalCount:Q})};for(const B of H)J(B);return X},[d,l,H]),Z=k.useCallback(X=>{if(X.type==="showMore"&&X.expandCategory){u(X.expandCategory),w(-1);return}z(X.page,X.params)},[z]);k.useEffect(()=>{const X=j.current;if(!X||y<0)return;const F=X.querySelector(`[data-idx="${y}"]`);F&&F.scrollIntoView({block:"nearest"})},[y]);const U=k.useCallback(X=>{if(X.key==="Escape"){e();return}if(X.key==="Tab"){X.preventDefault();const B=D.map(we=>we.id),Q=B.indexOf(l),re=X.shiftKey?Q<=0?B.length-1:Q-1:Q>=B.length-1?0:Q+1;u(B[re]),w(-1);return}const F=X.ctrlKey&&X.key==="n"||X.key==="ArrowDown",J=X.ctrlKey&&X.key==="p"||X.key==="ArrowUp";if(F||J){X.preventDefault(),w(B=>{const Q=W.length-1;return Q<0?-1:F?B>=Q?0:B+1:B<=0?Q:B-1});return}X.key==="Enter"&&(X.preventDefault(),y>=0&&y<W.length&&Z(W[y]))},[e,W,y,Z,D,l]);k.useEffect(()=>(document.addEventListener("keydown",U),()=>document.removeEventListener("keydown",U)),[U]);const Y=W.length>0;let ae=0;return s.jsx("div",{ref:C,className:"fixed inset-0 bg-black/50 flex items-start justify-center z-50 pt-[8vh]",onClick:X=>{X.target===C.current&&e()},children:s.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:[s.jsxs("div",{className:"shrink-0 px-5 pt-4 pb-3 border-b border-border-default space-y-3",children:[s.jsxs("div",{className:"relative",children:[s.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:[s.jsx("circle",{cx:"11",cy:"11",r:"8"}),s.jsx("line",{x1:"21",y1:"21",x2:"16.65",y2:"16.65"})]}),s.jsx("input",{ref:N,value:r,onChange:X=>O(X.target.value),placeholder:n("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"}),r&&s.jsx("button",{onClick:()=>{o(""),m(Id),x(!1),w(-1),N.current?.focus()},className:"absolute right-3 top-1/2 -translate-y-1/2 text-fg-tertiary hover:text-fg-secondary",children:s.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[s.jsx("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),s.jsx("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]})})]}),s.jsx("div",{className:"flex gap-1 overflow-x-auto scrollbar-hide",children:D.map(X=>s.jsx("button",{onClick:()=>{u(X.id),w(-1)},className:`px-3 py-1.5 text-xs rounded-lg whitespace-nowrap transition-colors ${l===X.id?"bg-brand-600 text-white":"bg-surface-elevated text-fg-secondary hover:text-fg-primary"}`,children:X.label},X.id))})]}),s.jsxs("div",{ref:j,className:"flex-1 overflow-y-auto px-5 py-3",children:[h&&s.jsx("div",{className:"flex items-center justify-center py-8",children:s.jsx("div",{className:"text-fg-tertiary text-sm animate-pulse",children:n("common:loading")})}),!h&&g&&!Y&&s.jsxs("div",{className:"flex flex-col items-center justify-center py-8 text-center",children:[s.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:[s.jsx("circle",{cx:"11",cy:"11",r:"8"}),s.jsx("line",{x1:"21",y1:"21",x2:"16.65",y2:"16.65"})]}),s.jsx("p",{className:"text-sm text-fg-tertiary",children:n("common:noResults",{defaultValue:"没有找到相关结果"})})]}),!h&&Y&&s.jsx("div",{className:"space-y-4",children:H.map(X=>{if(l!=="all"&&l!==X)return null;const F=l==="all"?8:void 0,J=B=>{const Q=ae++,re=B==="agents"?d.agents.length:B==="tasks"?d.tasks.length:B==="requirements"?d.requirements.length:B==="projects"?d.projects.length:B==="workflows"?d.workflows.length:d.deliverables.length;return s.jsxs("button",{"data-idx":Q,onClick:()=>{u(B),w(-1)},className:`mt-1 w-full text-xs py-1.5 rounded-lg transition-colors ${Q===y?"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:[n("common:showAll",{defaultValue:"查看全部"})," (",re,")"]})};return X==="agents"&&d.agents.length>0?s.jsxs("section",{children:[s.jsx("h3",{className:"text-xs font-medium text-fg-tertiary uppercase mb-2",children:n("common:agents",{defaultValue:"智能体"})}),s.jsx("div",{className:"space-y-0.5",children:(F?d.agents.slice(0,F):d.agents).map(B=>{const Q=ae++;return s.jsxs("button",{"data-idx":Q,onClick:()=>z(me.TEAM,{agentId:B.id}),className:`w-full flex items-center gap-3 px-3 py-2 rounded-xl transition-colors text-left ${Q===y?"bg-brand-600/15 ring-1 ring-brand-500/40":"hover:bg-surface-overlay"}`,children:[s.jsx(Us,{name:B.name||"Agent",avatarUrl:B.avatarUrl,size:28}),s.jsxs("div",{className:"flex-1 min-w-0",children:[s.jsx("div",{className:"text-sm font-medium text-fg-primary truncate",children:B.name}),s.jsx("div",{className:"text-xs text-fg-tertiary truncate",children:B.role||B.status})]}),s.jsx(tW,{status:B.status})]},B.id)})}),F&&d.agents.length>F&&J("agents")]},"agents"):X==="tasks"&&d.tasks.length>0?s.jsxs("section",{children:[s.jsx("h3",{className:"text-xs font-medium text-fg-tertiary uppercase mb-2",children:n("common:tasks",{defaultValue:"任务"})}),s.jsx("div",{className:"space-y-0.5",children:(F?d.tasks.slice(0,F):d.tasks).map(B=>{const Q=ae++;return s.jsxs("button",{"data-idx":Q,onClick:()=>z(me.WORK,{openTask:B.id}),className:`w-full flex items-center gap-3 px-3 py-2 rounded-xl transition-colors text-left ${Q===y?"bg-brand-600/15 ring-1 ring-brand-500/40":"hover:bg-surface-overlay"}`,children:[s.jsx(nW,{status:B.status}),s.jsxs("div",{className:"flex-1 min-w-0",children:[s.jsx("div",{className:"text-sm text-fg-primary truncate",children:B.title}),s.jsxs("div",{className:"text-xs text-fg-tertiary truncate",children:[B.status," · ",B.priority||""]})]})]},B.id)})}),F&&d.tasks.length>F&&J("tasks")]},"tasks"):X==="requirements"&&d.requirements.length>0?s.jsxs("section",{children:[s.jsx("h3",{className:"text-xs font-medium text-fg-tertiary uppercase mb-2",children:n("common:requirements",{defaultValue:"需求"})}),s.jsx("div",{className:"space-y-0.5",children:(F?d.requirements.slice(0,F):d.requirements).map(B=>{const Q=ae++;return s.jsxs("button",{"data-idx":Q,onClick:()=>z(me.WORK,{openRequirement:B.id}),className:`w-full flex items-center gap-3 px-3 py-2 rounded-xl transition-colors text-left ${Q===y?"bg-brand-600/15 ring-1 ring-brand-500/40":"hover:bg-surface-overlay"}`,children:[s.jsx("div",{className:`w-7 h-7 rounded-lg flex items-center justify-center shrink-0 ${B.status==="approved"?"text-green-500 bg-green-500/15":B.status==="pending"?"text-amber-500 bg-amber-500/15":B.status==="rejected"?"text-red-500 bg-red-500/15":"text-fg-tertiary bg-surface-elevated"}`,children:s.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[s.jsx("path",{d:"M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z"}),s.jsx("polyline",{points:"14 2 14 8 20 8"}),s.jsx("line",{x1:"16",y1:"13",x2:"8",y2:"13"}),s.jsx("line",{x1:"16",y1:"17",x2:"8",y2:"17"})]})}),s.jsxs("div",{className:"flex-1 min-w-0",children:[s.jsx("div",{className:"text-sm text-fg-primary truncate",children:B.title}),s.jsxs("div",{className:"text-xs text-fg-tertiary truncate",children:[B.status," · ",B.priority||""]})]})]},B.id)})}),F&&d.requirements.length>F&&J("requirements")]},"requirements"):X==="projects"&&d.projects.length>0?s.jsxs("section",{children:[s.jsx("h3",{className:"text-xs font-medium text-fg-tertiary uppercase mb-2",children:n("common:projects",{defaultValue:"项目"})}),s.jsx("div",{className:"space-y-0.5",children:(F?d.projects.slice(0,F):d.projects).map(B=>{const Q=ae++;return s.jsxs("button",{"data-idx":Q,onClick:()=>z(me.WORK,{projectId:B.id}),className:`w-full flex items-center gap-3 px-3 py-2 rounded-xl transition-colors text-left ${Q===y?"bg-brand-600/15 ring-1 ring-brand-500/40":"hover:bg-surface-overlay"}`,children:[s.jsx("div",{className:"w-7 h-7 rounded-lg bg-brand-500/15 flex items-center justify-center shrink-0",children:s.jsx("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",className:"text-brand-500",children:s.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"})})}),s.jsxs("div",{className:"flex-1 min-w-0",children:[s.jsx("div",{className:"text-sm text-fg-primary truncate",children:B.name}),B.description&&s.jsx("div",{className:"text-xs text-fg-tertiary truncate",children:B.description})]})]},B.id)})}),F&&d.projects.length>F&&J("projects")]},"projects"):X==="deliverables"&&d.deliverables.length>0?s.jsxs("section",{children:[s.jsx("h3",{className:"text-xs font-medium text-fg-tertiary uppercase mb-2",children:n("common:deliverables",{defaultValue:"交付物"})}),s.jsx("div",{className:"space-y-0.5",children:(F?d.deliverables.slice(0,F):d.deliverables).map(B=>{const Q=ae++;return s.jsxs("button",{"data-idx":Q,onClick:()=>z(me.DELIVERABLES,{openDeliverable:B.id}),className:`w-full flex items-center gap-3 px-3 py-2 rounded-xl transition-colors text-left ${Q===y?"bg-brand-600/15 ring-1 ring-brand-500/40":"hover:bg-surface-overlay"}`,children:[s.jsx("div",{className:"w-7 h-7 rounded-lg bg-purple-500/15 flex items-center justify-center shrink-0",children:s.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",className:"text-purple-500",children:[s.jsx("path",{d:"M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z"}),s.jsx("polyline",{points:"14 2 14 8 20 8"})]})}),s.jsxs("div",{className:"flex-1 min-w-0",children:[s.jsx("div",{className:"text-sm text-fg-primary truncate",children:B.title}),s.jsxs("div",{className:"text-xs text-fg-tertiary truncate",children:[B.type," · ",B.status]})]})]},B.id)})}),F&&d.deliverables.length>F&&J("deliverables")]},"deliverables"):X==="workflows"&&d.workflows.length>0?s.jsxs("section",{children:[s.jsx("h3",{className:"text-xs font-medium text-fg-tertiary uppercase mb-2",children:n("common:workflows",{defaultValue:"工作流"})}),s.jsx("div",{className:"space-y-0.5",children:(F?d.workflows.slice(0,F):d.workflows).map(B=>{const Q=ae++;return s.jsxs("button",{"data-idx":Q,onClick:()=>z(me.WORK,{boardType:"workflows"}),className:`w-full flex items-center gap-3 px-3 py-2 rounded-xl transition-colors text-left ${Q===y?"bg-brand-600/15 ring-1 ring-brand-500/40":"hover:bg-surface-overlay"}`,children:[s.jsx("div",{className:"w-7 h-7 rounded-lg bg-teal-500/15 flex items-center justify-center shrink-0",children:s.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",className:"text-teal-500",children:[s.jsx("circle",{cx:"12",cy:"12",r:"3"}),s.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"})]})}),s.jsxs("div",{className:"flex-1 min-w-0",children:[s.jsx("div",{className:"text-sm text-fg-primary truncate",children:B.displayName||B.name}),s.jsxs("div",{className:"text-xs text-fg-tertiary truncate",children:[B.stepCount," steps · v",B.version]})]})]},B.name)})}),F&&d.workflows.length>F&&J("workflows")]},"workflows"):null})}),!h&&!g&&s.jsxs("div",{className:"flex flex-col items-center justify-center py-8 text-center",children:[s.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:[s.jsx("circle",{cx:"11",cy:"11",r:"8"}),s.jsx("line",{x1:"21",y1:"21",x2:"16.65",y2:"16.65"})]}),s.jsx("p",{className:"text-sm text-fg-tertiary",children:n("common:searchHint",{defaultValue:"输入关键词搜索"})})]})]}),s.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:[s.jsxs("span",{children:[s.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"})," ",n("common:toggle",{defaultValue:"唤起/关闭"})]}),s.jsxs("span",{children:[s.jsx("kbd",{className:"px-1.5 py-0.5 rounded bg-surface-elevated border border-border-default text-[11px] font-medium",children:"Tab"})," ",n("common:switchTab",{defaultValue:"切换分类"})]}),s.jsxs("span",{children:[s.jsx("kbd",{className:"px-1.5 py-0.5 rounded bg-surface-elevated border border-border-default text-[11px] font-medium",children:"↑↓"})," ",n("common:navigate",{defaultValue:"导航"})]}),s.jsxs("span",{children:[s.jsx("kbd",{className:"px-1.5 py-0.5 rounded bg-surface-elevated border border-border-default text-[11px] font-medium",children:"Enter"})," ",n("common:open",{defaultValue:"打开"})]}),s.jsxs("span",{children:[s.jsx("kbd",{className:"px-1.5 py-0.5 rounded bg-surface-elevated border border-border-default text-[11px] font-medium",children:"Esc"})," ",n("common:close",{defaultValue:"关闭"})]})]})]})})}function tW({status:e}){const t=e==="active"||e==="idle"?"bg-green-500":e==="working"||e==="busy"?"bg-blue-500":"bg-gray-400";return s.jsx("span",{className:`w-2 h-2 rounded-full shrink-0 ${t}`})}function nW({status:e}){const t=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 s.jsx("div",{className:`w-7 h-7 rounded-lg flex items-center justify-center shrink-0 ${t}`,children:s.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[s.jsx("path",{d:"M9 11l3 3L22 4"}),s.jsx("path",{d:"M21 12v7a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h11"})]})})}function rW({authUser:e,onClose:t,onSaved:n,onUserUpdated:r}){const{t:o}=ft("common");Bo(!0);const[l,u]=k.useState(e.name||""),[d,m]=k.useState(e.email||""),[h,p]=k.useState(!1),[g,x]=k.useState(""),[y,w]=k.useState(()=>n5(e.avatarUrl,ua()?.avatarUrl)),N=async T=>{if(T.preventDefault(),!l.trim()){x(o("profile.nameRequired"));return}if(d&&!/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(d.trim())){x(o("profile.invalidEmail"));return}p(!0),x("");try{const{user:C}=await Ce.auth.updateProfile(l.trim(),d.trim());n({...C,avatarUrl:y??C.avatarUrl})}catch{x(o("profile.failedToSave"))}finally{p(!1)}};return s.jsx("div",{className:"fixed inset-0 bg-black/60 flex items-center justify-center z-[10000]",onClick:t,children:s.jsxs("form",{onSubmit:N,className:"bg-surface-secondary border border-border-default rounded-xl p-6 w-[400px] max-w-[calc(100vw-2rem)] shadow-2xl",onClick:T=>T.stopPropagation(),children:[s.jsx("h3",{className:"text-base font-semibold mb-5",children:o("profile.editProfile")}),s.jsx("div",{className:"flex justify-center mb-5",children:s.jsx(a5,{currentUrl:y,name:l,size:72,targetType:"user",targetId:e.id,onUploaded:T=>{w(T),r?.({...e,avatarUrl:T})}})}),s.jsxs("div",{className:"space-y-3",children:[s.jsxs("div",{children:[s.jsx("label",{className:"block text-xs text-fg-tertiary font-medium mb-1",children:o("profile.name")}),s.jsx("input",{value:l,onChange:T=>u(T.target.value),className:"w-full px-3 py-2 bg-surface-elevated border border-border-default rounded-lg text-sm text-fg-primary focus:border-brand-500 outline-none"})]}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-xs text-fg-tertiary font-medium mb-1",children:o("profile.email")}),s.jsx("input",{value:d,onChange:T=>m(T.target.value),type:"email",className:"w-full px-3 py-2 bg-surface-elevated border border-border-default rounded-lg text-sm text-fg-primary focus:border-brand-500 outline-none"})]}),g&&s.jsx("div",{className:"text-xs text-red-500 bg-red-500/10 border border-red-500/30 rounded-lg px-3 py-2",children:g})]}),s.jsxs("div",{className:"flex justify-end gap-3 mt-5",children:[s.jsx("button",{type:"button",onClick:t,className:"px-4 py-2 text-sm border border-border-default rounded-lg hover:bg-surface-elevated",children:o("cancel")}),s.jsx("button",{type:"submit",disabled:h,className:"px-4 py-2 text-sm bg-brand-600 hover:bg-brand-500 disabled:opacity-50 text-white rounded-lg",children:o(h?"saving":"save")})]})]})})}const j4=k.lazy(()=>qr(()=>import("./Team-Bfmg0l_n.js"),__vite__mapDeps([2,3,4,5])).then(e=>({default:e.TeamPage}))),M4=k.lazy(()=>qr(()=>import("./Settings-DmdHgt3w.js"),[]).then(e=>({default:e.Settings}))),aW=k.lazy(()=>qr(()=>import("./Store-D3QUTsdm.js"),[]).then(e=>({default:e.StorePage}))),sW=k.lazy(()=>qr(()=>Promise.resolve().then(()=>vK),void 0).then(e=>({default:e.AgentBuilder}))),R4=k.lazy(()=>qr(()=>import("./Work-Bv86FM_l.js"),__vite__mapDeps([6,4,1,7,3,8])).then(e=>({default:e.WorkPage}))),O4=k.lazy(()=>qr(()=>import("./Deliverables-DNtKj0sj.js"),__vite__mapDeps([9,4,5])).then(e=>({default:e.DeliverablesPage}))),iW=k.lazy(()=>qr(()=>import("./Notifications-DVH6Mzj8.js"),[]).then(e=>({default:e.NotificationsPage}))),oW=k.lazy(()=>qr(()=>import("./Search-BCVHO-UZ.js"),[]).then(e=>({default:e.SearchPage}))),lW={visibility:"hidden",position:"absolute",inset:0,pointerEvents:"none",zIndex:-1};function cW(e){try{const t=navigator.language,n=Intl.DateTimeFormat().resolvedOptions().timeZone,r=e.preferences??{};if(r.locale===t&&r.timezone===n)return;Ce.auth.updatePreferences({locale:t,timezone:n}).catch(()=>{})}catch{}}function uW(){return s.jsx("div",{className:"flex-1 flex items-center justify-center text-fg-tertiary text-sm animate-pulse",children:"Loading..."})}const dW=k.memo(function({id:t,activePage:n,children:r}){const o=t===n;return s.jsx("div",{className:"flex-1 overflow-hidden flex flex-col",style:o?void 0:lW,children:s.jsx(k.Suspense,{fallback:s.jsx(uW,{}),children:r})})},(e,t)=>{const n=e.id===e.activePage,r=t.id===t.activePage;return n!==r?!1:r?e.children===t.children:!0}),Nd={};function E3(e){return typeof window<"u"&&window.matchMedia("(max-width: 767px)").matches?Y4[e]??e:e}function D4(){return E3(_o())}function mW(){const{t:e}=ft("common"),[t,n]=k.useState(D4),[r,o]=k.useState(()=>!localStorage.getItem("markus_onboarded")),[l,u]=k.useState(!0),d=Uo(),m=QK(),h=YK({side:"left",defaultWidth:160,minWidth:140,maxWidth:400,collapsedWidth:64,storageKey:"markus_sidebar"}),[p,g]=k.useState(()=>new Set([D4()])),[x,y]=k.useState("loading"),[w,N]=k.useState(!1),[T,C]=k.useState(null),[j,_]=k.useState({hasOwner:!1,hasMultipleUsers:!1}),[O,z]=k.useState(!1),[D,H]=k.useState(!1),[W,Z]=k.useState(null),[U,Y]=k.useState(!1),[ae,X]=k.useState(null),[F,J]=k.useState(()=>{const Me=localStorage.getItem("markus_update_dismissed");return Me||null}),[B,Q]=k.useState(!1),re=z0(),we=re?.leftCollapsed??!1,$=re?.toggleLeftCollapsed,G=re?.toggleRightPanel,ce=re?.openRightPanel,I=re?.closeRightPanelTab,Ee=re?.updateRightPanelBrowserTab,Ue=k.useRef(re?.rightPanelTabs);Ue.current=re?.rightPanelTabs,k.useEffect(()=>{const Me=window.markusDesktop?.browser?.onPageEvent;if(!(!Me||!ce))return Me(Ne=>{if(Ne.type==="closed"){const Re=Ue.current?.find(ut=>ut.payload.kind==="url"&&ut.payload.browserId===Ne.browserId);Re&&I&&I(Re.id);return}if(Ne.type==="navigated"){Ne.browserId&&Ee&&Ee(Ne.browserId,{url:Ne.url,title:Ne.title||Ne.url});return}if(Ne.type==="opened"||Ne.type==="selected"){if(!Ne.url&&!Ne.browserId||Ne.browserId.startsWith("eb_")&&Ne.type==="opened")return;ce({kind:"url",url:Ne.url||"about:blank",title:Ne.title||Ne.url||"Browser",browserId:Ne.browserId,pageId:Ne.pageId})}})},[ce,I,Ee]);const De=re?.rightPanelOpen??!1;k.useLayoutEffect(()=>{const Me=t===me.TEAM&&De;Jf(Me)},[t,De]),k.useEffect(()=>{window.markusDesktop?.browser?.hideAll?.()},[]);const Ke=k.useRef(!1);k.useEffect(()=>{if(!Ke.current){Ke.current=!0;return}h.setCollapsed(we)},[we,h.setCollapsed]),k.useEffect(()=>{if(d)return;const Me=navigator.platform.toUpperCase().includes("MAC"),Ne=ut=>{Me&&ut.metaKey&&!ut.ctrlKey&&ut.key==="p"?(ut.preventDefault(),Q(it=>!it)):!Me&&ut.ctrlKey&&!ut.metaKey&&ut.key==="p"&&(ut.preventDefault(),Q(it=>!it))},Re=()=>Q(!0);return document.addEventListener("keydown",Ne),window.addEventListener("markus:open-search",Re),()=>{document.removeEventListener("keydown",Ne),window.removeEventListener("markus:open-search",Re)}},[d]),k.useEffect(()=>{if(d||!$||!G)return;const Me=navigator.platform.toUpperCase().includes("MAC"),Ne=Re=>{if(!(Me?Re.metaKey&&!Re.ctrlKey:Re.ctrlKey&&!Re.metaKey)||Re.altKey||Re.shiftKey)return;const it=Re.key.toLowerCase();it==="b"?(Re.preventDefault(),$()):it==="l"&&(Re.preventDefault(),G())};return document.addEventListener("keydown",Ne),()=>document.removeEventListener("keydown",Ne)},[d,$,G]);const st=k.useCallback((Me,Ne)=>{let Re=lc(Me);d?Re=Y4[Re]??Re:Re===me.NOTIFICATIONS&&(Re=me.HOME),Re!==me.TEAM&&Jf(!1);const ut=_o(),it=window.location.hash.slice(1);if(it!==ap(ut)?Nd[ut]=it:delete Nd[ut],Re===me.SETTINGS&&Ne?.tab){const se=`settings/${Ne.tab}`;Nd[Re]=se,history.pushState(null,"","#"+se),window.dispatchEvent(new HashChangeEvent("hashchange")),n(Re),g(et=>et.has(Re)?et:new Set([...et,Re]));return}const bt=Re!==me.WORK?Nd[Re]:void 0;bt&&bt!==ap(Re)?(history.pushState(null,"",Si(Re)),history.pushState(null,"","#"+bt)):history.pushState(null,"",Si(Re)),window.dispatchEvent(new HashChangeEvent("hashchange")),n(Re),g(se=>se.has(Re)?se:new Set([...se,Re]))},[d]);k.useEffect(()=>{at.setHandler((Me,Ne)=>st(Me,Ne))},[st]),k.useEffect(()=>{const Me=()=>N(!0);return window.addEventListener("markus:open-edit-profile",Me),()=>window.removeEventListener("markus:open-edit-profile",Me)},[]),k.useEffect(()=>{if(!window.markusDesktop)return;!d&&t!==me.SETTINGS&&!h.collapsed?window.markusDesktop.setTrafficLightPosition(16,16):window.markusDesktop.setTrafficLightPosition(6,16)},[h.collapsed,t,d]),k.useEffect(()=>{window.markusDesktop&&window.markusDesktop.onNotificationClick(Me=>{if(Me.openNotifications&&window.dispatchEvent(new CustomEvent("markus:open-notifications")),Me.page){const Ne=lc(Me.page);Me.params&&Object.entries(Me.params).forEach(([Re,ut])=>localStorage.setItem(`markus_nav_${Re}`,ut)),st(Ne),window.dispatchEvent(new CustomEvent("markus:navigate",{detail:{page:Ne,params:Me.params}}))}})},[st]);const mt=k.useCallback(()=>{fetch("/api/settings/llm").then(Me=>Me.ok?Me.json():null).then(Me=>{if(Me?.providers){const Ne=Object.values(Me.providers).some(Re=>Re.configured);Z(Ne)}}).catch(()=>{})},[]);k.useEffect(()=>{const Me=new URLSearchParams(window.location.search),Ne=Me.get("install");if(Ne&&_o()!==me.STORE){const it=Me.get("type"),se=it&&{agent:"agents",team:"teams",skill:"skills"}[it]||"agents";localStorage.setItem("markus_nav_installItem",Ne),localStorage.setItem("markus_nav_storeTab",se),Me.delete("install"),Me.delete("type");const et=Me.toString();window.history.replaceState(null,"",window.location.pathname+(et?`?${et}`:"")+Si(me.STORE)),setTimeout(()=>at.navigate(me.STORE,{storeTab:se,installItem:Ne}),300)}Ce.auth.me().then(({user:it})=>{y(it),C(!0),cW(it),va.connect(it.id),mt(),Ce.health().then(se=>{se.updateAvailable&&se.latestVersion&&X({latestVersion:se.latestVersion,currentVersion:se.version})}).catch(()=>{});const bt=()=>{pi(Tr.builderArtifacts,()=>Ce.builder.artifacts.list()),pi(Tr.builderAgents,()=>Ce.agents.list()),pi(Tr.builderHubMyItems,()=>lt.myItems()),pi(Tr.builderInstalled,()=>Ce.builder.artifacts.installed()),pi(Tr.hubAgents,()=>lt.search({type:"agent",limit:50})),pi(Tr.hubTeams,()=>lt.search({type:"team",limit:50})),pi(Tr.hubSkills,()=>lt.search({type:"skill",limit:50}))};typeof requestIdleCallback=="function"?requestIdleCallback(bt,{timeout:5e3}):setTimeout(bt,3e3)}).catch(()=>{y(null),Ce.auth.status().then(({initialized:it,hasOwner:bt,hasMultipleUsers:se})=>{C(it),_({hasOwner:bt,hasMultipleUsers:se})}).catch(()=>C(!0))}),va.connect();const Re=va.on("notification",()=>{window.dispatchEvent(new CustomEvent("markus:notifications-changed"))}),ut=()=>{const it=E3(_o());it!==me.TEAM&&Jf(!1),n(it),g(bt=>bt.has(it)?bt:new Set([...bt,it]))};return window.addEventListener("hashchange",ut),window.addEventListener("popstate",ut),()=>{Re(),va.disconnect(),window.removeEventListener("hashchange",ut),window.removeEventListener("popstate",ut)}},[]);const ct=x!=="loading"&&x!==null?x:void 0,Dt=k.useMemo(()=>d?{[me.HOME]:s.jsx(Vy,{authUser:ct}),[me.TEAM]:s.jsx(j4,{authUser:ct}),[me.BUILDER]:s.jsx(HK,{authUser:ct}),[me.SETTINGS]:s.jsx(M4,{theme:m.mode,onThemeChange:m.setMode,authUser:ct,onLogout:()=>{Ce.auth.logout().catch(()=>{}),Ni(),y(null)},onUserUpdated:Me=>y(Me)}),[me.WORK]:s.jsx(R4,{authUser:ct}),[me.DELIVERABLES]:s.jsx(O4,{authUser:ct}),[me.NOTIFICATIONS]:s.jsx(iW,{authUser:ct}),[me.SEARCH]:s.jsx(oW,{})}:{[me.HOME]:s.jsx(Vy,{authUser:ct}),[me.TEAM]:s.jsx(j4,{authUser:ct}),[me.SETTINGS]:s.jsx(M4,{theme:m.mode,onThemeChange:m.setMode,authUser:ct,onLogout:()=>{Ce.auth.logout().catch(()=>{}),Ni(),y(null)},onUserUpdated:Me=>y(Me)}),[me.STORE]:s.jsx(aW,{authUser:ct}),[me.BUILDER]:s.jsx(sW,{authUser:ct}),[me.WORK]:s.jsx(R4,{authUser:ct}),[me.DELIVERABLES]:s.jsx(O4,{authUser:ct})},[ct?.id,ct?.role,m.mode,d]);if(x==="loading"||x===null&&T===null)return s.jsx("div",{className:"min-h-dvh bg-surface-primary flex items-center justify-center",children:s.jsx("div",{className:"text-fg-tertiary text-sm animate-pulse",children:e("loading")})});const Xt=(typeof window<"u"?window.location.hash:"").match(/^#invite\?token=([a-f0-9]+)/);return Xt?s.jsx(KK,{token:Xt[1],onComplete:()=>{window.location.hash="",localStorage.removeItem("markus_onboarded"),o(!0),z(!0),y("loading"),Ce.auth.me().then(Me=>y(Me.user)).catch(()=>y(null))}}):x===null?s.jsx(VK,{hasOwner:j.hasOwner,hasMultipleUsers:j.hasMultipleUsers,onLogin:(Me,Ne,Re)=>{y(Me),va.connect(Me.id),Ne?(localStorage.removeItem("markus_onboarded"),o(!0),Re?.fromHub&&z(!0)):localStorage.getItem("markus_onboarded")||(localStorage.setItem("markus_onboarded","1"),o(!1))}}):D?s.jsx(WK,{onComplete:()=>H(!1),isFirstTime:!0}):r?s.jsx(FK,{theme:m.mode,onThemeChange:m.setMode,skipProfile:O,onProfileUpdated:Me=>{const Ne={id:Me.id,name:Me.name,email:Me.email,role:Me.role,orgId:Me.orgId??"default",avatarUrl:Me.avatarUrl};y(Ne)},onComplete:()=>{localStorage.setItem("markus_onboarded","1"),o(!1),z(!1),Ce.auth.me().then(Me=>y(Me.user)).catch(()=>{}),mt(),st(me.HOME)}}):s.jsxs("div",{className:`flex h-dvh bg-surface-primary text-fg-primary overflow-x-hidden ${d?"flex-col":""}`,children:[!d&&t!==me.SETTINGS&&s.jsxs(s.Fragment,{children:[s.jsx("div",{className:"relative z-40 shrink-0",style:{width:h.width},children:s.jsx(KV,{currentPage:t,onNavigate:Me=>{st(Me),u(!1)},authUser:x,collapsed:h.collapsed,onToggleCollapse:h.toggle,onLogout:()=>{Ce.auth.logout().catch(()=>{}),Ni(),y(null)}})}),s.jsx("div",{className:`${h.collapsed?"w-0":"w-1.5 cursor-col-resize"} shrink-0 group relative z-10 flex items-center justify-center`,onMouseDown:h.collapsed?void 0:h.onResizeStart,children:!h.collapsed&&s.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"})})]}),s.jsxs("div",{className:`flex-1 overflow-hidden flex flex-col min-w-0 ${d&&t!==me.SETTINGS&&t!==me.SEARCH?"pb-14":""}`,children:[W===!1&&!U&&t!==me.SETTINGS&&s.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:[s.jsx("span",{className:d?"text-xs":"",children:e("llmBanner.message")}),s.jsxs("div",{className:"flex items-center gap-3",children:[s.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")}),s.jsx("button",{onClick:()=>Y(!0),className:"text-amber-500 hover:text-amber-600 text-xs",children:e("dismiss")})]})]}),ae&&F!==ae.latestVersion&&s.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:[s.jsx("span",{className:d?"text-xs":"",children:e("update.available",{latest:ae.latestVersion,current:ae.currentVersion})}),s.jsxs("span",{className:"flex items-center gap-3 shrink-0",children:[s.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")}),s.jsx("button",{onClick:()=>{J(ae.latestVersion),localStorage.setItem("markus_update_dismissed",ae.latestVersion)},className:"text-fg-tertiary hover:text-fg-secondary text-xs shrink-0",children:e("dismiss")})]})]}),s.jsx("main",{className:"flex-1 overflow-hidden flex flex-col relative",children:Object.keys(Dt).map(Me=>p.has(Me)?s.jsx(dW,{id:Me,activePage:t,children:Dt[Me]},Me):null)})]}),d&&t!==me.SETTINGS&&t!==me.SEARCH&&s.jsx(ZV,{currentPage:t,onNavigate:st,userId:ct?.id}),d&&s.jsx(nD,{authUser:ct,onNavigate:st}),!d&&B&&s.jsx(eW,{onClose:()=>Q(!1),currentPage:t}),w&&ct&&s.jsx(rW,{authUser:ct,onClose:()=>N(!1),onUserUpdated:Me=>y(Me),onSaved:Me=>{N(!1),y(Me)}})]})}zS.createRoot(document.getElementById("root")).render(s.jsx(k.StrictMode,{children:s.jsx(Yq,{children:s.jsx(mW,{})})}));export{HV as $,Us as A,xW as B,dr as C,$G as D,IV as E,SW as F,zV as G,bW as H,LK as I,Ci as J,Ko as K,z0 as L,s5 as M,qV as N,QV as O,me as P,MW as Q,wW as R,OK as S,SK as T,Wa as U,CW as V,WG as W,NW as X,_W as Y,TW as Z,qr as _,Uo as a,BV as a0,EW as a1,p0 as a2,R7 as a3,fW as a4,Bo as a5,Si as a6,GO as a7,l3 as a8,kW as a9,X2 as aa,i4 as ab,AV as ac,EV as ad,Gd as ae,RW as af,hW as ag,ua as ah,yn as ai,na as aj,vW as ak,i3 as al,zK as b,TK as c,jK as d,Ja as e,Ce as f,AW as g,jW as h,Ar as i,s as j,tD as k,YK as l,lc as m,at as n,jg as o,xc as p,j7 as q,k as r,pW as s,gW as t,ft as u,qd as v,va as w,lt as x,$2 as y,HG as z};