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

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 (62) hide show
  1. package/dist/markus.mjs +106 -40
  2. package/dist/web-ui/assets/{CommentInput-CIxUL6dU.js → CommentInput-JPZATTdP.js} +1 -1
  3. package/dist/web-ui/assets/{ContentRenderer-Bb_drUpO.js → ContentRenderer-gaxBn1N9.js} +2 -2
  4. package/dist/web-ui/assets/{DeliverableShareModal-BEeIlXig.js → DeliverableShareModal-B6qqZgFc.js} +1 -1
  5. package/dist/web-ui/assets/{Deliverables-CJFzxbLw.js → Deliverables-BUi9KGwf.js} +1 -1
  6. package/dist/web-ui/assets/{Notifications-Cz2LKhGE.js → Notifications-W-Mx_v6q.js} +1 -1
  7. package/dist/web-ui/assets/{Search-dq45wHQN.js → Search-Cxtd9r1S.js} +1 -1
  8. package/dist/web-ui/assets/{Settings-WAXEtxMR.js → Settings-Q87nTBy5.js} +1 -1
  9. package/dist/web-ui/assets/{Store-DOGCOxTK.js → Store-BK54Nx60.js} +1 -1
  10. package/dist/web-ui/assets/{Team-NM2SsmjN.js → Team-CWRLD5sM.js} +4 -4
  11. package/dist/web-ui/assets/{Work-ornw-1Zh.js → Work-xejZ7HCT.js} +1 -1
  12. package/dist/web-ui/assets/{arc-D4xcu8MX.js → arc-BqhlYS08.js} +1 -1
  13. package/dist/web-ui/assets/{architectureDiagram-3BPJPVTR-DP3EZPSb.js → architectureDiagram-3BPJPVTR-C8fUeKGJ.js} +1 -1
  14. package/dist/web-ui/assets/{blockDiagram-GPEHLZMM-BnSHtwXa.js → blockDiagram-GPEHLZMM-eILAtQzQ.js} +1 -1
  15. package/dist/web-ui/assets/{c4Diagram-AAUBKEIU-DpPSihlY.js → c4Diagram-AAUBKEIU-DdV7TyX_.js} +1 -1
  16. package/dist/web-ui/assets/channel-C-TW97LX.js +1 -0
  17. package/dist/web-ui/assets/{chunk-2J33WTMH-DD5lZIGF.js → chunk-2J33WTMH-BwuewEg2.js} +1 -1
  18. package/dist/web-ui/assets/{chunk-4BX2VUAB-D9wu9GG0.js → chunk-4BX2VUAB-Bv26FANh.js} +1 -1
  19. package/dist/web-ui/assets/{chunk-55IACEB6-p_n2ARjh.js → chunk-55IACEB6-DFTeZroI.js} +1 -1
  20. package/dist/web-ui/assets/{chunk-727SXJPM-BiTqi43c.js → chunk-727SXJPM-i7IiTNSf.js} +1 -1
  21. package/dist/web-ui/assets/{chunk-AQP2D5EJ-DVPMedje.js → chunk-AQP2D5EJ-BoPcIU1Z.js} +1 -1
  22. package/dist/web-ui/assets/{chunk-FMBD7UC4-B53AqN8D.js → chunk-FMBD7UC4-DTXl3WfT.js} +1 -1
  23. package/dist/web-ui/assets/{chunk-ND2GUHAM-sACe_lkd.js → chunk-ND2GUHAM-DdzR-Jnl.js} +1 -1
  24. package/dist/web-ui/assets/{chunk-QZHKN3VN-B0qDAQUW.js → chunk-QZHKN3VN-DqSW43I1.js} +1 -1
  25. package/dist/web-ui/assets/classDiagram-4FO5ZUOK-C92nY4nN.js +1 -0
  26. package/dist/web-ui/assets/classDiagram-v2-Q7XG4LA2-C92nY4nN.js +1 -0
  27. package/dist/web-ui/assets/{cose-bilkent-S5V4N54A-BzZayQQf.js → cose-bilkent-S5V4N54A-C-UFRPSb.js} +1 -1
  28. package/dist/web-ui/assets/{dagre-BM42HDAG-DjcfWzm_.js → dagre-BM42HDAG-92ucBloh.js} +1 -1
  29. package/dist/web-ui/assets/{diagram-2AECGRRQ-CEK9T3rW.js → diagram-2AECGRRQ-B8zRoWWP.js} +1 -1
  30. package/dist/web-ui/assets/{diagram-5GNKFQAL-BJsJPwEI.js → diagram-5GNKFQAL-CM3pWtYN.js} +1 -1
  31. package/dist/web-ui/assets/{diagram-KO2AKTUF-BZlki2qo.js → diagram-KO2AKTUF-V7UmwGTe.js} +1 -1
  32. package/dist/web-ui/assets/{diagram-LMA3HP47-Bkmh3WcY.js → diagram-LMA3HP47-DG1RtUeD.js} +1 -1
  33. package/dist/web-ui/assets/{diagram-OG6HWLK6-4THSXHiA.js → diagram-OG6HWLK6-BTwLdZJw.js} +1 -1
  34. package/dist/web-ui/assets/{erDiagram-TEJ5UH35-CPj2HGe-.js → erDiagram-TEJ5UH35-BNXeXKHH.js} +1 -1
  35. package/dist/web-ui/assets/{flowDiagram-I6XJVG4X-Bu8HgFqR.js → flowDiagram-I6XJVG4X-VP_sRWgd.js} +1 -1
  36. package/dist/web-ui/assets/{ganttDiagram-6RSMTGT7-C5gs9b9P.js → ganttDiagram-6RSMTGT7-CvnpoufX.js} +1 -1
  37. package/dist/web-ui/assets/{gitGraphDiagram-PVQCEYII-DxnBgR_T.js → gitGraphDiagram-PVQCEYII-zO7DNQqQ.js} +1 -1
  38. package/dist/web-ui/assets/{index-CiAGgfZx.js → index-B1VN5yM1.js} +4 -4
  39. package/dist/web-ui/assets/{infoDiagram-5YYISTIA-D4M-cR8I.js → infoDiagram-5YYISTIA-BSGbaVLq.js} +1 -1
  40. package/dist/web-ui/assets/{ishikawaDiagram-YF4QCWOH-Oiq6jknk.js → ishikawaDiagram-YF4QCWOH-BatvAQOH.js} +1 -1
  41. package/dist/web-ui/assets/{journeyDiagram-JHISSGLW-D2gmyCKv.js → journeyDiagram-JHISSGLW-Cajy4fZr.js} +1 -1
  42. package/dist/web-ui/assets/{kanban-definition-UN3LZRKU-DqjzkO8l.js → kanban-definition-UN3LZRKU-DLpKR4E5.js} +1 -1
  43. package/dist/web-ui/assets/{mermaid.core-N5tL3hIv.js → mermaid.core-B4fv65oQ.js} +5 -5
  44. package/dist/web-ui/assets/{mindmap-definition-RKZ34NQL-ATHsVy0v.js → mindmap-definition-RKZ34NQL-C2HVqxfu.js} +1 -1
  45. package/dist/web-ui/assets/{pieDiagram-4H26LBE5-CprLr2Gv.js → pieDiagram-4H26LBE5-Bswg7SQl.js} +1 -1
  46. package/dist/web-ui/assets/{quadrantDiagram-W4KKPZXB-0uN86dlU.js → quadrantDiagram-W4KKPZXB-CyYiDqNE.js} +1 -1
  47. package/dist/web-ui/assets/{requirementDiagram-4Y6WPE33-CQmWbZXW.js → requirementDiagram-4Y6WPE33-BWZmKUo8.js} +1 -1
  48. package/dist/web-ui/assets/{sankeyDiagram-5OEKKPKP-D6kdJsQI.js → sankeyDiagram-5OEKKPKP-C3imZVxk.js} +1 -1
  49. package/dist/web-ui/assets/{sequenceDiagram-3UESZ5HK-1Y79snKt.js → sequenceDiagram-3UESZ5HK-BrySebCt.js} +1 -1
  50. package/dist/web-ui/assets/{stateDiagram-AJRCARHV-BqmCPSIN.js → stateDiagram-AJRCARHV-0Lp5CycE.js} +1 -1
  51. package/dist/web-ui/assets/stateDiagram-v2-BHNVJYJU-QVZbqffU.js +1 -0
  52. package/dist/web-ui/assets/{timeline-definition-PNZ67QCA-OG71KAzb.js → timeline-definition-PNZ67QCA-BIGJbkoS.js} +1 -1
  53. package/dist/web-ui/assets/{vennDiagram-CIIHVFJN-V9c-71bn.js → vennDiagram-CIIHVFJN-CS9GEvPk.js} +1 -1
  54. package/dist/web-ui/assets/{wardley-L42UT6IY-C3A6_LpL.js → wardley-L42UT6IY-BSNtMxtd.js} +1 -1
  55. package/dist/web-ui/assets/{wardleyDiagram-YWT4CUSO-B54ZiT7U.js → wardleyDiagram-YWT4CUSO-CaEGOjwH.js} +1 -1
  56. package/dist/web-ui/assets/{xychartDiagram-2RQKCTM6-DpWlpUfV.js → xychartDiagram-2RQKCTM6-Cr_pwOHb.js} +1 -1
  57. package/dist/web-ui/index.html +1 -1
  58. package/package.json +8 -1
  59. package/dist/web-ui/assets/channel-DSB2MBEK.js +0 -1
  60. package/dist/web-ui/assets/classDiagram-4FO5ZUOK-D5cDjaiz.js +0 -1
  61. package/dist/web-ui/assets/classDiagram-v2-Q7XG4LA2-D5cDjaiz.js +0 -1
  62. package/dist/web-ui/assets/stateDiagram-v2-BHNVJYJU-DRaoGsBn.js +0 -1
@@ -1,4 +1,4 @@
1
- const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/mermaid.core-N5tL3hIv.js","assets/transform-CpIVI4vC.js","assets/Team-NM2SsmjN.js","assets/CommentInput-CIxUL6dU.js","assets/ContentRenderer-Bb_drUpO.js","assets/DeliverableShareModal-BEeIlXig.js","assets/Team-DFuMZ0ql.css","assets/Work-ornw-1Zh.js","assets/value-DIujSiJ7.js","assets/Work-BZV40eAE.css","assets/Deliverables-CJFzxbLw.js"])))=>i.map(i=>d[i]);
1
+ const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/mermaid.core-B4fv65oQ.js","assets/transform-CpIVI4vC.js","assets/Team-CWRLD5sM.js","assets/CommentInput-JPZATTdP.js","assets/ContentRenderer-gaxBn1N9.js","assets/DeliverableShareModal-B6qqZgFc.js","assets/Team-DFuMZ0ql.css","assets/Work-xejZ7HCT.js","assets/value-DIujSiJ7.js","assets/Work-BZV40eAE.css","assets/Deliverables-BUi9KGwf.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 c of l.addedNodes)c.tagName==="LINK"&&c.rel==="modulepreload"&&r(c)}).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 Tc(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var Zf={exports:{}},ql={};var Ey;function g7(){if(Ey)return ql;Ey=1;var e=Symbol.for("react.transitional.element"),t=Symbol.for("react.fragment");function n(r,o,l){var c=null;if(l!==void 0&&(c=""+l),o.key!==void 0&&(c=""+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:c,ref:o!==void 0?o:null,props:l}}return ql.Fragment=t,ql.jsx=n,ql.jsxs=n,ql}var _y;function b7(){return _y||(_y=1,Zf.exports=g7()),Zf.exports}var s=b7(),Jf={exports:{}},Ot={};var jy;function x7(){if(jy)return Ot;jy=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"),c=Symbol.for("react.context"),d=Symbol.for("react.forward_ref"),m=Symbol.for("react.suspense"),f=Symbol.for("react.memo"),h=Symbol.for("react.lazy"),g=Symbol.for("react.activity"),y=Symbol.iterator;function x(W){return W===null||typeof W!="object"?null:(W=y&&W[y]||W["@@iterator"],typeof W=="function"?W:null)}var w={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},C=Object.assign,T={};function S(W,pe,P){this.props=W,this.context=pe,this.refs=T,this.updater=P||w}S.prototype.isReactComponent={},S.prototype.setState=function(W,pe){if(typeof W!="object"&&typeof W!="function"&&W!=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,W,pe,"setState")},S.prototype.forceUpdate=function(W){this.updater.enqueueForceUpdate(this,W,"forceUpdate")};function E(){}E.prototype=S.prototype;function j(W,pe,P){this.props=W,this.context=pe,this.refs=T,this.updater=P||w}var L=j.prototype=new E;L.constructor=j,C(L,S.prototype),L.isPureReactComponent=!0;var I=Array.isArray;function O(){}var F={H:null,A:null,T:null,S:null},V=Object.prototype.hasOwnProperty;function X(W,pe,P){var _e=P.ref;return{$$typeof:e,type:W,key:pe,ref:_e!==void 0?_e:null,props:P}}function z(W,pe){return X(W.type,pe,W.props)}function G(W){return typeof W=="object"&&W!==null&&W.$$typeof===e}function se(W){var pe={"=":"=0",":":"=2"};return"$"+W.replace(/[=:]/g,function(P){return pe[P]})}var ee=/\/+/g;function q(W,pe){return typeof W=="object"&&W!==null&&W.key!=null?se(""+W.key):pe.toString(36)}function re(W){switch(W.status){case"fulfilled":return W.value;case"rejected":throw W.reason;default:switch(typeof W.status=="string"?W.then(O,O):(W.status="pending",W.then(function(pe){W.status==="pending"&&(W.status="fulfilled",W.value=pe)},function(pe){W.status==="pending"&&(W.status="rejected",W.reason=pe)})),W.status){case"fulfilled":return W.value;case"rejected":throw W.reason}}throw W}function B(W,pe,P,_e,He){var Pe=typeof W;(Pe==="undefined"||Pe==="boolean")&&(W=null);var Ge=!1;if(W===null)Ge=!0;else switch(Pe){case"bigint":case"string":case"number":Ge=!0;break;case"object":switch(W.$$typeof){case e:case t:Ge=!0;break;case h:return Ge=W._init,B(Ge(W._payload),pe,P,_e,He)}}if(Ge)return He=He(W),Ge=_e===""?"."+q(W,0):_e,I(He)?(P="",Ge!=null&&(P=Ge.replace(ee,"$&/")+"/"),B(He,pe,P,"",function(Ct){return Ct})):He!=null&&(G(He)&&(He=z(He,P+(He.key==null||W&&W.key===He.key?"":(""+He.key).replace(ee,"$&/")+"/")+Ge)),pe.push(He)),1;Ge=0;var ct=_e===""?".":_e+":";if(I(W))for(var mt=0;mt<W.length;mt++)_e=W[mt],Pe=ct+q(_e,mt),Ge+=B(_e,pe,P,Pe,He);else if(mt=x(W),typeof mt=="function")for(W=mt.call(W),mt=0;!(_e=W.next()).done;)_e=_e.value,Pe=ct+q(_e,mt++),Ge+=B(_e,pe,P,Pe,He);else if(Pe==="object"){if(typeof W.then=="function")return B(re(W),pe,P,_e,He);throw pe=String(W),Error("Objects are not valid as a React child (found: "+(pe==="[object Object]"?"object with keys {"+Object.keys(W).join(", ")+"}":pe)+"). If you meant to render a collection of children, use an array instead.")}return Ge}function J(W,pe,P){if(W==null)return W;var _e=[],He=0;return B(W,_e,"","",function(Pe){return pe.call(P,Pe,He++)}),_e}function fe(W){if(W._status===-1){var pe=W._result;pe=pe(),pe.then(function(P){(W._status===0||W._status===-1)&&(W._status=1,W._result=P)},function(P){(W._status===0||W._status===-1)&&(W._status=2,W._result=P)}),W._status===-1&&(W._status=0,W._result=pe)}if(W._status===1)return W._result.default;throw W._result}var Se=typeof reportError=="function"?reportError:function(W){if(typeof window=="object"&&typeof window.ErrorEvent=="function"){var pe=new window.ErrorEvent("error",{bubbles:!0,cancelable:!0,message:typeof W=="object"&&W!==null&&typeof W.message=="string"?String(W.message):String(W),error:W});if(!window.dispatchEvent(pe))return}else if(typeof process=="object"&&typeof process.emit=="function"){process.emit("uncaughtException",W);return}console.error(W)},U={map:J,forEach:function(W,pe,P){J(W,function(){pe.apply(this,arguments)},P)},count:function(W){var pe=0;return J(W,function(){pe++}),pe},toArray:function(W){return J(W,function(pe){return pe})||[]},only:function(W){if(!G(W))throw Error("React.Children.only expected to receive a single React element child.");return W}};return Ot.Activity=g,Ot.Children=U,Ot.Component=S,Ot.Fragment=n,Ot.Profiler=o,Ot.PureComponent=j,Ot.StrictMode=r,Ot.Suspense=m,Ot.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE=F,Ot.__COMPILER_RUNTIME={__proto__:null,c:function(W){return F.H.useMemoCache(W)}},Ot.cache=function(W){return function(){return W.apply(null,arguments)}},Ot.cacheSignal=function(){return null},Ot.cloneElement=function(W,pe,P){if(W==null)throw Error("The argument must be a React element, but you passed "+W+".");var _e=C({},W.props),He=W.key;if(pe!=null)for(Pe in pe.key!==void 0&&(He=""+pe.key),pe)!V.call(pe,Pe)||Pe==="key"||Pe==="__self"||Pe==="__source"||Pe==="ref"&&pe.ref===void 0||(_e[Pe]=pe[Pe]);var Pe=arguments.length-2;if(Pe===1)_e.children=P;else if(1<Pe){for(var Ge=Array(Pe),ct=0;ct<Pe;ct++)Ge[ct]=arguments[ct+2];_e.children=Ge}return X(W.type,He,_e)},Ot.createContext=function(W){return W={$$typeof:c,_currentValue:W,_currentValue2:W,_threadCount:0,Provider:null,Consumer:null},W.Provider=W,W.Consumer={$$typeof:l,_context:W},W},Ot.createElement=function(W,pe,P){var _e,He={},Pe=null;if(pe!=null)for(_e in pe.key!==void 0&&(Pe=""+pe.key),pe)V.call(pe,_e)&&_e!=="key"&&_e!=="__self"&&_e!=="__source"&&(He[_e]=pe[_e]);var Ge=arguments.length-2;if(Ge===1)He.children=P;else if(1<Ge){for(var ct=Array(Ge),mt=0;mt<Ge;mt++)ct[mt]=arguments[mt+2];He.children=ct}if(W&&W.defaultProps)for(_e in Ge=W.defaultProps,Ge)He[_e]===void 0&&(He[_e]=Ge[_e]);return X(W,Pe,He)},Ot.createRef=function(){return{current:null}},Ot.forwardRef=function(W){return{$$typeof:d,render:W}},Ot.isValidElement=G,Ot.lazy=function(W){return{$$typeof:h,_payload:{_status:-1,_result:W},_init:fe}},Ot.memo=function(W,pe){return{$$typeof:f,type:W,compare:pe===void 0?null:pe}},Ot.startTransition=function(W){var pe=F.T,P={};F.T=P;try{var _e=W(),He=F.S;He!==null&&He(P,_e),typeof _e=="object"&&_e!==null&&typeof _e.then=="function"&&_e.then(O,Se)}catch(Pe){Se(Pe)}finally{pe!==null&&P.types!==null&&(pe.types=P.types),F.T=pe}},Ot.unstable_useCacheRefresh=function(){return F.H.useCacheRefresh()},Ot.use=function(W){return F.H.use(W)},Ot.useActionState=function(W,pe,P){return F.H.useActionState(W,pe,P)},Ot.useCallback=function(W,pe){return F.H.useCallback(W,pe)},Ot.useContext=function(W){return F.H.useContext(W)},Ot.useDebugValue=function(){},Ot.useDeferredValue=function(W,pe){return F.H.useDeferredValue(W,pe)},Ot.useEffect=function(W,pe){return F.H.useEffect(W,pe)},Ot.useEffectEvent=function(W){return F.H.useEffectEvent(W)},Ot.useId=function(){return F.H.useId()},Ot.useImperativeHandle=function(W,pe,P){return F.H.useImperativeHandle(W,pe,P)},Ot.useInsertionEffect=function(W,pe){return F.H.useInsertionEffect(W,pe)},Ot.useLayoutEffect=function(W,pe){return F.H.useLayoutEffect(W,pe)},Ot.useMemo=function(W,pe){return F.H.useMemo(W,pe)},Ot.useOptimistic=function(W,pe){return F.H.useOptimistic(W,pe)},Ot.useReducer=function(W,pe,P){return F.H.useReducer(W,pe,P)},Ot.useRef=function(W){return F.H.useRef(W)},Ot.useState=function(W){return F.H.useState(W)},Ot.useSyncExternalStore=function(W,pe,P){return F.H.useSyncExternalStore(W,pe,P)},Ot.useTransition=function(){return F.H.useTransition()},Ot.version="19.2.4",Ot}var My;function A0(){return My||(My=1,Jf.exports=x7()),Jf.exports}var k=A0();const PY=Tc(k);var ep={exports:{}},Gl={},tp={exports:{}},np={};var Ry;function y7(){return Ry||(Ry=1,(function(e){function t(B,J){var fe=B.length;B.push(J);e:for(;0<fe;){var Se=fe-1>>>1,U=B[Se];if(0<o(U,J))B[Se]=J,B[fe]=U,fe=Se;else break e}}function n(B){return B.length===0?null:B[0]}function r(B){if(B.length===0)return null;var J=B[0],fe=B.pop();if(fe!==J){B[0]=fe;e:for(var Se=0,U=B.length,W=U>>>1;Se<W;){var pe=2*(Se+1)-1,P=B[pe],_e=pe+1,He=B[_e];if(0>o(P,fe))_e<U&&0>o(He,P)?(B[Se]=He,B[_e]=fe,Se=_e):(B[Se]=P,B[pe]=fe,Se=pe);else if(_e<U&&0>o(He,fe))B[Se]=He,B[_e]=fe,Se=_e;else break e}}return J}function o(B,J){var fe=B.sortIndex-J.sortIndex;return fe!==0?fe:B.id-J.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 c=Date,d=c.now();e.unstable_now=function(){return c.now()-d}}var m=[],f=[],h=1,g=null,y=3,x=!1,w=!1,C=!1,T=!1,S=typeof setTimeout=="function"?setTimeout:null,E=typeof clearTimeout=="function"?clearTimeout:null,j=typeof setImmediate<"u"?setImmediate:null;function L(B){for(var J=n(f);J!==null;){if(J.callback===null)r(f);else if(J.startTime<=B)r(f),J.sortIndex=J.expirationTime,t(m,J);else break;J=n(f)}}function I(B){if(C=!1,L(B),!w)if(n(m)!==null)w=!0,O||(O=!0,se());else{var J=n(f);J!==null&&re(I,J.startTime-B)}}var O=!1,F=-1,V=5,X=-1;function z(){return T?!0:!(e.unstable_now()-X<V)}function G(){if(T=!1,O){var B=e.unstable_now();X=B;var J=!0;try{e:{w=!1,C&&(C=!1,E(F),F=-1),x=!0;var fe=y;try{t:{for(L(B),g=n(m);g!==null&&!(g.expirationTime>B&&z());){var Se=g.callback;if(typeof Se=="function"){g.callback=null,y=g.priorityLevel;var U=Se(g.expirationTime<=B);if(B=e.unstable_now(),typeof U=="function"){g.callback=U,L(B),J=!0;break t}g===n(m)&&r(m),L(B)}else r(m);g=n(m)}if(g!==null)J=!0;else{var W=n(f);W!==null&&re(I,W.startTime-B),J=!1}}break e}finally{g=null,y=fe,x=!1}J=void 0}}finally{J?se():O=!1}}}var se;if(typeof j=="function")se=function(){j(G)};else if(typeof MessageChannel<"u"){var ee=new MessageChannel,q=ee.port2;ee.port1.onmessage=G,se=function(){q.postMessage(null)}}else se=function(){S(G,0)};function re(B,J){F=S(function(){B(e.unstable_now())},J)}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"):V=0<B?Math.floor(1e3/B):5},e.unstable_getCurrentPriorityLevel=function(){return y},e.unstable_next=function(B){switch(y){case 1:case 2:case 3:var J=3;break;default:J=y}var fe=y;y=J;try{return B()}finally{y=fe}},e.unstable_requestPaint=function(){T=!0},e.unstable_runWithPriority=function(B,J){switch(B){case 1:case 2:case 3:case 4:case 5:break;default:B=3}var fe=y;y=B;try{return J()}finally{y=fe}},e.unstable_scheduleCallback=function(B,J,fe){var Se=e.unstable_now();switch(typeof fe=="object"&&fe!==null?(fe=fe.delay,fe=typeof fe=="number"&&0<fe?Se+fe:Se):fe=Se,B){case 1:var U=-1;break;case 2:U=250;break;case 5:U=1073741823;break;case 4:U=1e4;break;default:U=5e3}return U=fe+U,B={id:h++,callback:J,priorityLevel:B,startTime:fe,expirationTime:U,sortIndex:-1},fe>Se?(B.sortIndex=fe,t(f,B),n(m)===null&&B===n(f)&&(C?(E(F),F=-1):C=!0,re(I,fe-Se))):(B.sortIndex=U,t(m,B),w||x||(w=!0,O||(O=!0,se()))),B},e.unstable_shouldYield=z,e.unstable_wrapCallback=function(B){var J=y;return function(){var fe=y;y=J;try{return B.apply(this,arguments)}finally{y=fe}}}})(np)),np}var Ly;function v7(){return Ly||(Ly=1,tp.exports=y7()),tp.exports}var rp={exports:{}},nr={};var Oy;function w7(){if(Oy)return nr;Oy=1;var e=A0();function t(m){var f="https://react.dev/errors/"+m;if(1<arguments.length){f+="?args[]="+encodeURIComponent(arguments[1]);for(var h=2;h<arguments.length;h++)f+="&args[]="+encodeURIComponent(arguments[h])}return"Minified React error #"+m+"; visit "+f+" 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,f,h){var g=3<arguments.length&&arguments[3]!==void 0?arguments[3]:null;return{$$typeof:o,key:g==null?null:""+g,children:m,containerInfo:f,implementation:h}}var c=e.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE;function d(m,f){if(m==="font")return"";if(typeof f=="string")return f==="use-credentials"?f:""}return nr.__DOM_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE=r,nr.createPortal=function(m,f){var h=2<arguments.length&&arguments[2]!==void 0?arguments[2]:null;if(!f||f.nodeType!==1&&f.nodeType!==9&&f.nodeType!==11)throw Error(t(299));return l(m,f,null,h)},nr.flushSync=function(m){var f=c.T,h=r.p;try{if(c.T=null,r.p=2,m)return m()}finally{c.T=f,r.p=h,r.d.f()}},nr.preconnect=function(m,f){typeof m=="string"&&(f?(f=f.crossOrigin,f=typeof f=="string"?f==="use-credentials"?f:"":void 0):f=null,r.d.C(m,f))},nr.prefetchDNS=function(m){typeof m=="string"&&r.d.D(m)},nr.preinit=function(m,f){if(typeof m=="string"&&f&&typeof f.as=="string"){var h=f.as,g=d(h,f.crossOrigin),y=typeof f.integrity=="string"?f.integrity:void 0,x=typeof f.fetchPriority=="string"?f.fetchPriority:void 0;h==="style"?r.d.S(m,typeof f.precedence=="string"?f.precedence:void 0,{crossOrigin:g,integrity:y,fetchPriority:x}):h==="script"&&r.d.X(m,{crossOrigin:g,integrity:y,fetchPriority:x,nonce:typeof f.nonce=="string"?f.nonce:void 0})}},nr.preinitModule=function(m,f){if(typeof m=="string")if(typeof f=="object"&&f!==null){if(f.as==null||f.as==="script"){var h=d(f.as,f.crossOrigin);r.d.M(m,{crossOrigin:h,integrity:typeof f.integrity=="string"?f.integrity:void 0,nonce:typeof f.nonce=="string"?f.nonce:void 0})}}else f==null&&r.d.M(m)},nr.preload=function(m,f){if(typeof m=="string"&&typeof f=="object"&&f!==null&&typeof f.as=="string"){var h=f.as,g=d(h,f.crossOrigin);r.d.L(m,h,{crossOrigin:g,integrity:typeof f.integrity=="string"?f.integrity:void 0,nonce:typeof f.nonce=="string"?f.nonce:void 0,type:typeof f.type=="string"?f.type:void 0,fetchPriority:typeof f.fetchPriority=="string"?f.fetchPriority:void 0,referrerPolicy:typeof f.referrerPolicy=="string"?f.referrerPolicy:void 0,imageSrcSet:typeof f.imageSrcSet=="string"?f.imageSrcSet:void 0,imageSizes:typeof f.imageSizes=="string"?f.imageSizes:void 0,media:typeof f.media=="string"?f.media:void 0})}},nr.preloadModule=function(m,f){if(typeof m=="string")if(f){var h=d(f.as,f.crossOrigin);r.d.m(m,{as:typeof f.as=="string"&&f.as!=="script"?f.as:void 0,crossOrigin:h,integrity:typeof f.integrity=="string"?f.integrity:void 0})}else r.d.m(m)},nr.requestFormReset=function(m){r.d.r(m)},nr.unstable_batchedUpdates=function(m,f){return m(f)},nr.useFormState=function(m,f,h){return c.H.useFormState(m,f,h)},nr.useFormStatus=function(){return c.H.useHostTransitionStatus()},nr.version="19.2.4",nr}var Dy;function sw(){if(Dy)return rp.exports;Dy=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(),rp.exports=w7(),rp.exports}var Iy;function k7(){if(Iy)return Gl;Iy=1;var e=v7(),t=A0(),n=sw();function r(a){var i="https://react.dev/errors/"+a;if(1<arguments.length){i+="?args[]="+encodeURIComponent(arguments[1]);for(var u=2;u<arguments.length;u++)i+="&args[]="+encodeURIComponent(arguments[u])}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,u=a;if(a.alternate)for(;i.return;)i=i.return;else{a=i;do i=a,(i.flags&4098)!==0&&(u=i.return),a=i.return;while(a)}return i.tag===3?u:null}function c(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 f(a){var i=a.alternate;if(!i){if(i=l(a),i===null)throw Error(r(188));return i!==a?null:a}for(var u=a,p=i;;){var b=u.return;if(b===null)break;var v=b.alternate;if(v===null){if(p=b.return,p!==null){u=p;continue}break}if(b.child===v.child){for(v=b.child;v;){if(v===u)return m(b),a;if(v===p)return m(b),i;v=v.sibling}throw Error(r(188))}if(u.return!==p.return)u=b,p=v;else{for(var _=!1,D=b.child;D;){if(D===u){_=!0,u=b,p=v;break}if(D===p){_=!0,p=b,u=v;break}D=D.sibling}if(!_){for(D=v.child;D;){if(D===u){_=!0,u=v,p=b;break}if(D===p){_=!0,p=v,u=b;break}D=D.sibling}if(!_)throw Error(r(189))}}if(u.alternate!==p)throw Error(r(190))}if(u.tag!==3)throw Error(r(188));return u.stateNode.current===u?a:i}function h(a){var i=a.tag;if(i===5||i===26||i===27||i===6)return a;for(a=a.child;a!==null;){if(i=h(a),i!==null)return i;a=a.sibling}return null}var g=Object.assign,y=Symbol.for("react.element"),x=Symbol.for("react.transitional.element"),w=Symbol.for("react.portal"),C=Symbol.for("react.fragment"),T=Symbol.for("react.strict_mode"),S=Symbol.for("react.profiler"),E=Symbol.for("react.consumer"),j=Symbol.for("react.context"),L=Symbol.for("react.forward_ref"),I=Symbol.for("react.suspense"),O=Symbol.for("react.suspense_list"),F=Symbol.for("react.memo"),V=Symbol.for("react.lazy"),X=Symbol.for("react.activity"),z=Symbol.for("react.memo_cache_sentinel"),G=Symbol.iterator;function se(a){return a===null||typeof a!="object"?null:(a=G&&a[G]||a["@@iterator"],typeof a=="function"?a:null)}var ee=Symbol.for("react.client.reference");function q(a){if(a==null)return null;if(typeof a=="function")return a.$$typeof===ee?null:a.displayName||a.name||null;if(typeof a=="string")return a;switch(a){case C:return"Fragment";case S:return"Profiler";case T:return"StrictMode";case I:return"Suspense";case O:return"SuspenseList";case X:return"Activity"}if(typeof a=="object")switch(a.$$typeof){case w:return"Portal";case j:return a.displayName||"Context";case E:return(a._context.displayName||"Context")+".Consumer";case L:var i=a.render;return a=a.displayName,a||(a=i.displayName||i.name||"",a=a!==""?"ForwardRef("+a+")":"ForwardRef"),a;case F:return i=a.displayName||null,i!==null?i:q(a.type)||"Memo";case V:i=a._payload,a=a._init;try{return q(a(i))}catch{}}return null}var re=Array.isArray,B=t.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,J=n.__DOM_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,fe={pending:!1,data:null,method:null,action:null},Se=[],U=-1;function W(a){return{current:a}}function pe(a){0>U||(a.current=Se[U],Se[U]=null,U--)}function P(a,i){U++,Se[U]=a.current,a.current=i}var _e=W(null),He=W(null),Pe=W(null),Ge=W(null);function ct(a,i){switch(P(Pe,i),P(He,a),P(_e,null),i.nodeType){case 9:case 11:a=(a=i.documentElement)&&(a=a.namespaceURI)?Qx(a):0;break;default:if(a=i.tagName,i=i.namespaceURI)i=Qx(i),a=Zx(i,a);else switch(a){case"svg":a=1;break;case"math":a=2;break;default:a=0}}pe(_e),P(_e,a)}function mt(){pe(_e),pe(He),pe(Pe)}function Ct(a){a.memoizedState!==null&&P(Ge,a);var i=_e.current,u=Zx(i,a.type);i!==u&&(P(He,a),P(_e,u))}function Mt(a){He.current===a&&(pe(_e),pe(He)),Ge.current===a&&(pe(Ge),$l._currentValue=fe)}var Pt,Kt;function yt(a){if(Pt===void 0)try{throw Error()}catch(u){var i=u.stack.trim().match(/\n( *(at )?)/);Pt=i&&i[1]||"",Kt=-1<u.stack.indexOf(`
3
3
  at`)?" (<anonymous>)":-1<u.stack.indexOf("@")?"@unknown:0:0":""}return`
4
4
  `+Pt+a+Kt}var Ue=!1;function dt(a,i){if(!a||Ue)return"";Ue=!0;var u=Error.prepareStackTrace;Error.prepareStackTrace=void 0;try{var p={DetermineComponentFrameRoot:function(){try{if(i){var De=function(){throw Error()};if(Object.defineProperty(De.prototype,"props",{set:function(){throw Error()}}),typeof Reflect=="object"&&Reflect.construct){try{Reflect.construct(De,[])}catch(Ce){var ke=Ce}Reflect.construct(a,[],De)}else{try{De.call()}catch(Ce){ke=Ce}a.call(De.prototype)}}else{try{throw Error()}catch(Ce){ke=Ce}(De=a())&&typeof De.catch=="function"&&De.catch(function(){})}}catch(Ce){if(Ce&&ke&&typeof Ce.stack=="string")return[Ce.stack,ke.stack]}return[null,null]}};p.DetermineComponentFrameRoot.displayName="DetermineComponentFrameRoot";var b=Object.getOwnPropertyDescriptor(p.DetermineComponentFrameRoot,"name");b&&b.configurable&&Object.defineProperty(p.DetermineComponentFrameRoot,"name",{value:"DetermineComponentFrameRoot"});var v=p.DetermineComponentFrameRoot(),_=v[0],D=v[1];if(_&&D){var ie=_.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
  `},f]}}const eG=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_-]*/}}),tG=["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"],nG=["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"],rG=[...tG,...nG],aG=["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(),o3=["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(),l3=["after","backdrop","before","cue","cue-region","first-letter","first-line","grammar-error","marker","part","placeholder","selection","slotted","spelling-error"].sort().reverse(),sG=["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(),iG=o3.concat(l3).sort().reverse();function oG(e){const t=eG(e),n=iG,r="and or not only",o="[\\w-]+",l="("+o+"|@\\{"+o+"\\})",c=[],d=[],m=function(j){return{className:"string",begin:"~?"+j+".*?"+j}},f=function(j,L,I){return{className:j,begin:L,relevance:I}},h={$pattern:/[a-z-]+/,keyword:r,attribute:aG.join(" ")},g={begin:"\\(",end:"\\)",contains:d,keywords:h,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,f("variable","@@?"+o,10),f("variable","@\\{"+o+"\\}"),f("built_in","~?`[^`]*?`"),{className:"attribute",begin:o+"\\s*:",end:":",returnBegin:!0,excludeEnd:!0},t.IMPORTANT,{beginKeywords:"and not"},t.FUNCTION_DISPATCH);const y=d.concat({begin:/\{/,end:/\}/,contains:c}),x={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("+sG.join("|")+")\\b",end:/(?=:)/,starts:{endsWithParent:!0,illegal:"[<=$]",relevance:0,contains:d}}]},C={className:"keyword",begin:"@(import|media|charset|font-face|(-[a-z]+-)?keyframes|supports|document|namespace|page|viewport|host)\\b",starts:{end:"[;{}]",keywords:h,returnEnd:!0,contains:d,relevance:0}},T={className:"variable",variants:[{begin:"@"+o+"\\s*:",relevance:15},{begin:"@"+o}],starts:{end:"[;}]",returnEnd:!0,contains:y}},S={variants:[{begin:"[\\.#:&\\[>]",end:"[;{}]"},{begin:l,end:/\{/}],returnBegin:!0,returnEnd:!0,illegal:`[<='$"]`,relevance:0,contains:[e.C_LINE_COMMENT_MODE,e.C_BLOCK_COMMENT_MODE,x,f("keyword","all\\b"),f("variable","@\\{"+o+"\\}"),{begin:"\\b("+rG.join("|")+")\\b",className:"selector-tag"},t.CSS_NUMBER_MODE,f("selector-tag",l,0),f("selector-id","#"+l),f("selector-class","\\."+l,0),f("selector-tag","&",0),t.ATTRIBUTE_SELECTOR_MODE,{className:"selector-pseudo",begin:":("+o3.join("|")+")"},{className:"selector-pseudo",begin:":(:)?("+l3.join("|")+")"},{begin:/\(/,end:/\)/,relevance:0,contains:y},{begin:"!important"},t.FUNCTION_DISPATCH]},E={begin:o+`:(:)?(${n.join("|")})`,returnBegin:!0,contains:[S]};return c.push(e.C_LINE_COMMENT_MODE,e.C_BLOCK_COMMENT_MODE,C,T,E,w,S,x,t.FUNCTION_DISPATCH),{name:"Less",case_insensitive:!0,illegal:`[=>'/<($"]`,contains:c}}function lG(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 cG(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"}},c={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,c]}}function uG(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},c={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}]},f={className:"strong",contains:[],variants:[{begin:/_{2}(?!\s)/,end:/_{2}/},{begin:/\*{2}(?!\s)/,end:/\*{2}/}]},h={className:"emphasis",contains:[],variants:[{begin:/\*(?![*\s])/,end:/\*/},{begin:/_(?![_\s])/,end:/_/,relevance:0}]},g=e.inherit(f,{contains:[]}),y=e.inherit(h,{contains:[]});f.contains.push(y),h.contains.push(g);let x=[n,m];return[f,h,g,y].forEach(S=>{S.contains=S.contains.concat(x)}),x=x.concat(f,h),{name:"Markdown",aliases:["md","mkdown","mkd"],contains:[{className:"section",variants:[{begin:"^#{1,6}",end:"$",contains:x},{begin:"(?=^.+?\\n[=-]{2,}$)",contains:[{begin:"^[=-]*$"},{begin:"^",end:"\\n",contains:x}]}]},n,l,f,h,{className:"quote",begin:"^>\\s+",contains:x,end:"$"},o,r,m,c,{scope:"literal",match:/&([a-zA-Z0-9]+|#[0-9]{1,7}|#[Xx][0-9a-fA-F]{1,6});/}]}}function dG(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 mG(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},c={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]},f={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},h=[e.BACKSLASH_ESCAPE,l,m],g=[/!/,/\//,/\|/,/\?/,/'/,/"/,/#/],y=(C,T,S="\\1")=>{const E=S==="\\1"?S:t.concat(S,T);return t.concat(t.concat("(?:",C,")"),T,/(?:\\.|[^\\\/])*?/,E,/(?:\\.|[^\\\/])*?/,S,r)},x=(C,T,S)=>t.concat(t.concat("(?:",C,")"),T,/(?:\\.|[^\\\/])*?/,S,r),w=[m,e.HASH_COMMENT_MODE,e.COMMENT(/^=\w/,/=cut/,{endsWithParent:!0}),c,{className:"string",contains:h,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}]},f,{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:y("s|tr|y",t.either(...g,{capture:!0}))},{begin:y("s|tr|y","\\(","\\)")},{begin:y("s|tr|y","\\[","\\]")},{begin:y("s|tr|y","\\{","\\}")}],relevance:2},{className:"regexp",variants:[{begin:/(m|qr)\/\//,relevance:0},{begin:x("(?:m|qr)?",/\//,/\//)},{begin:x("m|qr",t.either(...g,{capture:!0}),/\1/)},{begin:x("m|qr",/\(/,/\)/)},{begin:x("m|qr",/\[/,/\]/)},{begin:x("m|qr",/\{/,/\}/)}]}]},{className:"function",beginKeywords:"sub method",end:"(\\s*\\(.*?\\))?[;{]",excludeEnd:!0,relevance:5,contains:[e.TITLE_MODE,d]},{className:"class",beginKeywords:"class",end:"[;{]",excludeEnd:!0,relevance:5,contains:[e.TITLE_MODE,d,f]},{begin:"-\\w\\b",relevance:0},{begin:"^__DATA__$",end:"^__END__$",subLanguage:"mojolicious",contains:[{begin:"^@@.*",end:"$",className:"comment"}]}];return l.contains=w,c.contains=w,{name:"Perl",aliases:["pl","pm"],keywords:o,contains:w}}function fG(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),c={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:/\}/}]},f=e.inherit(e.APOS_STRING_MODE,{illegal:null}),h=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":(q,re)=>{re.data._beginMatch=q[1]||q[2]},"on:end":(q,re)=>{re.data._beginMatch!==q[1]&&re.ignoreMatch()}},y=e.END_SAME_AS_BEGIN({begin:/<<<[ \t]*'(\w+)'\n/,end:/[ \t]*(\w+)\b/}),x=`[
646
646
  ]`,w={scope:"string",variants:[h,f,g,y]},C={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"],S=["__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"],E=["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"],L={keyword:S,literal:(q=>{const re=[];return q.forEach(B=>{re.push(B),B.toLowerCase()===B?re.push(B.toUpperCase()):re.push(B.toLowerCase())}),re})(T),built_in:E},I=q=>q.map(re=>re.replace(/\|\d+$/,"")),O={variants:[{match:[/new/,t.concat(x,"+"),t.concat("(?!",I(E).join("\\b|"),"\\b)"),o],scope:{1:"keyword",4:"title.class"}}]},F=t.concat(r,"\\b(?!\\()"),V={variants:[{match:[t.concat(/::/,t.lookahead(/(?!class\b)/)),F],scope:{2:"variable.constant"}},{match:[/::/,/class/],scope:{2:"variable.language"}},{match:[o,t.concat(/::/,t.lookahead(/(?!class\b)/)),F],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"}}]},X={scope:"attr",match:t.concat(r,t.lookahead(":"),t.lookahead(/(?!::)/))},z={relevance:0,begin:/\(/,end:/\)/,keywords:L,contains:[X,c,V,e.C_BLOCK_COMMENT_MODE,w,C,O]},G={relevance:0,match:[/\b/,t.concat("(?!fn\\b|function\\b|",I(S).join("\\b|"),"|",I(E).join("\\b|"),"\\b)"),r,t.concat(x,"*"),t.lookahead(/(?=\()/)],scope:{3:"title.function.invoke"},contains:[z]};z.contains.push(G);const se=[X,V,e.C_BLOCK_COMMENT_MODE,w,C,O],ee={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",...se]},...se,{scope:"meta",variants:[{match:o},{match:l}]}]};return{case_insensitive:!1,keywords:L,contains:[ee,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/},c,G,V,{match:[/const/,/\s/,r],scope:{1:"keyword",3:"variable.constant"}},O,{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:L,contains:["self",ee,c,V,e.C_BLOCK_COMMENT_MODE,w,C]}]},{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,C]}}function pG(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 hG(e){return{name:"Plain text",aliases:["text","txt"],disableAutodetect:!0}}function gG(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:/^(>>>|\.\.\.) /},f={className:"subst",begin:/\{/,end:/\}/,keywords:d,illegal:/#/},h={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,h,f]},{begin:/([fF][rR]|[rR][fF]|[fF])"""/,end:/"""/,contains:[e.BACKSLASH_ESCAPE,m,h,f]},{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,h,f]},{begin:/([fF][rR]|[rR][fF]|[fF])"/,end:/"/,contains:[e.BACKSLASH_ESCAPE,h,f]},e.APOS_STRING_MODE,e.QUOTE_STRING_MODE]},y="[0-9](_?[0-9])*",x=`(\\b(${y}))?\\.(${y})|\\b(${y})\\.`,w=`\\b|${r.join("|")}`,C={className:"number",relevance:0,variants:[{begin:`(\\b(${y})|(${x}))[eE][+-]?(${y})[jJ]?(?=${w})`},{begin:`(${x})[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(${y})[jJ](?=${w})`}]},T={className:"comment",begin:t.lookahead(/# type:/),end:/$/,keywords:d,contains:[{begin:/# type:/},{begin:/#/,end:/\b\B/,endsWithParent:!0}]},S={className:"params",variants:[{className:"",begin:/\(\s*\)/,skip:!0},{begin:/\(/,end:/\)/,excludeBegin:!0,excludeEnd:!0,keywords:d,contains:["self",m,C,g,e.HASH_COMMENT_MODE]}]};return f.contains=[g,C,m],{name:"Python",aliases:["py","gyp","ipython"],unicodeRegex:!0,keywords:d,illegal:/(<\/|\?)|=>/,contains:[m,C,{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:[S]},{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:[C,S,g]}]}}function bG(e){return{aliases:["pycon"],contains:[{className:"meta.prompt",starts:{end:/ |$/,starts:{end:"$",subLanguage:"python"}},variants:[{begin:/^>>>(?=[ ]|$)/},{begin:/^\.\.\.(?=[ ]|$)/}]}]}}function xG(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 yG(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+)*/),c={"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:">"},f=[e.COMMENT("#","$",{contains:[d]}),e.COMMENT("^=begin","^=end",{contains:[d],relevance:10}),e.COMMENT("^__END__",e.MATCH_NOTHING_RE)],h={className:"subst",begin:/#\{/,end:/\}/,keywords:c},g={className:"string",contains:[e.BACKSLASH_ESCAPE,h],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,h]})]}]},y="[1-9](_?[0-9])*|0",x="[0-9](_?[0-9])*",w={className:"number",relevance:0,variants:[{begin:`\\b(${y})(\\.(${x}))?([eE][+-]?(${x})|r)?i?\\b`},{begin:"\\b0[dD][0-9](_?[0-9])*r?i?\\b"},{begin:"\\b0[bB][0-1](_?[0-1])*r?i?\\b"},{begin:"\\b0[oO][0-7](_?[0-7])*r?i?\\b"},{begin:"\\b0[xX][0-9a-fA-F](_?[0-9a-fA-F])*r?i?\\b"},{begin:"\\b0(_?[0-7])+r?i?\\b"}]},C={variants:[{match:/\(\)/},{className:"params",begin:/\(/,end:/(?=\))/,excludeBegin:!0,endsParent:!0,keywords:c}]},O=[g,{variants:[{match:[/class\s+/,o,/\s+<\s+/,o]},{match:[/\b(class|module)\s+/,o]}],scope:{2:"title.class",4:"title.class.inherited"},keywords:c},{match:[/(include|extend)\s+/,o],scope:{2:"title.class"},keywords:c},{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:[C]},{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:c},{begin:"("+e.RE_STARTERS_RE+"|unless)\\s*",keywords:"unless",contains:[{className:"regexp",contains:[e.BACKSLASH_ESCAPE,h],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,f),relevance:0}].concat(m,f);h.contains=O,C.contains=O;const z=[{begin:/^\s*=>/,starts:{end:"$",contains:O}},{className:"meta.prompt",begin:"^("+"[>?]>"+"|"+"[\\w#]+\\(\\w+\\):\\d+:\\d+[>*]"+"|"+"(\\w+-)?\\d+\\.\\d+\\.\\d+(p\\d+)?[^\\d][^>]+>"+")(?=[ ])",starts:{end:"$",keywords:c,contains:O}}];return f.unshift(m),{name:"Ruby",aliases:["rb","gemspec","podspec","thor","irb"],keywords:c,illegal:/\/\*/,contains:[e.SHEBANG({binary:"ruby"})].concat(z).concat(f).concat(O)}}function vG(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*\(/))},c="([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"],f=["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!"],h=["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:h,keyword:d,literal:m,built_in:f},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_]+)"+c},{begin:"\\b0o([0-7_]+)"+c},{begin:"\\b0x([A-Fa-f0-9_]+)"+c},{begin:"\\b(\\d[\\d_]*(\\.[0-9_]+)?([eE][+-]?[0-9_]+)?)"+c}],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:f,type:h}},{className:"punctuation",begin:"->"},l]}}const wG=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_-]*/}}),kG=["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"],SG=["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"],NG=[...kG,...SG],CG=["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(),TG=["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(),AG=["after","backdrop","before","cue","cue-region","first-letter","first-line","grammar-error","marker","part","placeholder","selection","slotted","spelling-error"].sort().reverse(),EG=["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 _G(e){const t=wG(e),n=AG,r=TG,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("+NG.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("+EG.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:CG.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 jG(e){return{name:"Shell Session",aliases:["console","shellsession"],contains:[{className:"meta.prompt",begin:/^\s{0,3}[/~\w\d[\]()@-]*[>%$#][ ]?/,starts:{end:/[^\\](?=\s*$)/,subLanguage:"bash"}}]}}function MG(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"],c=["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"],f=["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"],h=["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"],y=["create table","insert into","primary key","foreign key","not null","alter table","add constraint","grouping sets","on overflow","character set","respect nulls","ignore nulls","nulls first","nulls last","depth first","breadth first"],x=h,w=[...f,...m].filter(I=>!h.includes(I)),C={scope:"variable",match:/@[a-z0-9][a-z0-9_]*/},T={scope:"operator",match:/[-+*/=%^~]|&&?|\|\|?|!=?|<(?:=>?|<|>)?|>[>=]?/,relevance:0},S={match:t.concat(/\b/,t.either(...x),/\s*\(/),relevance:0,keywords:{built_in:x}};function E(I){return t.concat(/\b/,t.either(...I.map(O=>O.replace(/\s+/,"\\s+"))),/\b/)}const j={scope:"keyword",match:E(y),relevance:0};function L(I,{exceptions:O,when:F}={}){const V=F;return O=O||[],I.map(X=>X.match(/\|\d+$/)||O.includes(X)?X:V(X)?`${X}|0`:X)}return{name:"SQL",case_insensitive:!0,illegal:/[{}]|<\//,keywords:{$pattern:/\b[\w\.]+/,keyword:L(w,{when:I=>I.length<3}),literal:l,type:d,built_in:g},contains:[{scope:"type",match:E(c)},j,S,C,r,o,e.C_NUMBER_MODE,e.C_BLOCK_COMMENT_MODE,n,T]}}function c3(e){return e?typeof e=="string"?e:e.source:null}function Ql(e){return dn("(?=",e,")")}function dn(...e){return e.map(n=>c3(n)).join("")}function RG(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"("+(RG(e).capture?"":"?:")+e.map(r=>c3(r)).join("|")+")"}const Gg=e=>dn(/\b/,e,/\w$/.test(e)?/\b/:/\B/),LG=["Protocol","Type"].map(Gg),W2=["init","self"].map(Gg),OG=["Any","Self"],Wp=["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"],Y2=["false","nil","true"],DG=["assignment","associativity","higherThan","left","lowerThan","none","right"],IG=["#colorLiteral","#column","#dsohandle","#else","#elseif","#endif","#error","#file","#fileID","#fileLiteral","#filePath","#function","#if","#imageLiteral","#keyPath","#line","#selector","#sourceLocation","#warning"],X2=["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"],u3=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]/),d3=cr(u3,/[\u0300-\u036F]/,/[\u1DC0-\u1DFF]/,/[\u20D0-\u20FF]/,/[\uFE00-\uFE0F]/,/[\uFE20-\uFE2F]/),Yp=dn(u3,d3,"*"),m3=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]/),h0=cr(m3,/\d/,/[\u0300-\u036F\u1DC0-\u1DFF\u20D0-\u20FF\uFE20-\uFE2F]/),ba=dn(m3,h0,"*"),vd=dn(/[A-Z]/,h0,"*"),PG=["attached","autoclosure",dn(/convention\(/,cr("swift","block","c"),/\)/),"discardableResult","dynamicCallable","dynamicMemberLookup","escaping","freestanding","frozen","GKInspectable","IBAction","IBDesignable","IBInspectable","IBOutlet","IBSegueAction","inlinable","main","nonobjc","NSApplicationMain","NSCopying","NSManaged",dn(/objc\(/,ba,/\)/),"objc","objcMembers","propertyWrapper","requires_stored_property_inits","resultBuilder","Sendable","testable","UIApplicationMain","unchecked","unknown","usableFromInline","warn_unqualified_access"],zG=["iOS","iOSApplicationExtension","macOS","macOSApplicationExtension","macCatalyst","macCatalystApplicationExtension","watchOS","watchOSApplicationExtension","tvOS","tvOSApplicationExtension","swift"];function BG(e){const t={match:/\s+/,relevance:0},n=e.COMMENT("/\\*","\\*/",{contains:["self"]}),r=[e.C_LINE_COMMENT_MODE,n],o={match:[/\./,cr(...LG,...W2)],className:{2:"keyword"}},l={match:dn(/\./,cr(...Wp)),relevance:0},c=Wp.filter(dt=>typeof dt=="string").concat(["_|0"]),d=Wp.filter(dt=>typeof dt!="string").concat(OG).map(Gg),m={variants:[{className:"keyword",match:cr(...d,...W2)}]},f={$pattern:cr(/\b\w+/,/#\w+/),keyword:c.concat(IG),literal:Y2},h=[o,l,m],g={match:dn(/\./,cr(...X2)),relevance:0},y={className:"built_in",match:dn(/\b/,cr(...X2),/(?=\()/)},x=[g,y],w={match:/->/,relevance:0},C={className:"operator",relevance:0,variants:[{match:Yp},{match:`\\.(\\.|${d3})+`}]},T=[w,C],S="([0-9]_*)+",E="([0-9a-fA-F]_*)+",j={className:"number",relevance:0,variants:[{match:`\\b(${S})(\\.(${S}))?([eE][+-]?(${S}))?\\b`},{match:`\\b0x(${E})(\\.(${E}))?([pP][+-]?(${S}))?\\b`},{match:/\b0o([0-7]_*)+\b/},{match:/\b0b([01]_*)+\b/}]},L=(dt="")=>({className:"subst",variants:[{match:dn(/\\/,dt,/[0\\tnr"']/)},{match:dn(/\\/,dt,/u\{[0-9a-fA-F]{1,8}\}/)}]}),I=(dt="")=>({className:"subst",match:dn(/\\/,dt,/[\t ]*(?:[\r\n]|\r\n)/)}),O=(dt="")=>({className:"subst",label:"interpol",begin:dn(/\\/,dt,/\(/),end:/\)/}),F=(dt="")=>({begin:dn(dt,/"""/),end:dn(/"""/,dt),contains:[L(dt),I(dt),O(dt)]}),V=(dt="")=>({begin:dn(dt,/"/),end:dn(/"/,dt),contains:[L(dt),O(dt)]}),X={className:"string",variants:[F(),F("#"),F("##"),F("###"),V(),V("#"),V("##"),V("###")]},z=[e.BACKSLASH_ESCAPE,{begin:/\[/,end:/\]/,relevance:0,contains:[e.BACKSLASH_ESCAPE]}],G={begin:/\/[^\s](?=[^/\n]*\/)/,end:/\//,contains:z},se=dt=>{const Nt=dn(dt,/\//),bt=dn(/\//,dt);return{begin:Nt,end:bt,contains:[...z,{scope:"comment",begin:`#(?!.*${bt})`,end:/$/}]}},ee={scope:"regexp",variants:[se("###"),se("##"),se("#"),G]},q={match:dn(/`/,ba,/`/)},re={className:"variable",match:/\$\d+/},B={className:"variable",match:`\\$${h0}+`},J=[q,re,B],fe={match:/(@|#(un)?)available/,scope:"keyword",starts:{contains:[{begin:/\(/,end:/\)/,keywords:zG,contains:[...T,j,X]}]}},Se={scope:"keyword",match:dn(/@/,cr(...PG),Ql(cr(/\(/,/\s+/)))},U={scope:"meta",match:dn(/@/,ba)},W=[fe,Se,U],pe={match:Ql(/\b[A-Z]/),relevance:0,contains:[{className:"type",match:dn(/(AV|CA|CF|CG|CI|CL|CM|CN|CT|MK|MP|MTK|MTL|NS|SCN|SK|UI|WK|XC)/,h0,"+")},{className:"type",match:vd,relevance:0},{match:/[?!]+/,relevance:0},{match:/\.\.\./,relevance:0},{match:dn(/\s+&\s+/,Ql(vd)),relevance:0}]},P={begin:/</,end:/>/,keywords:f,contains:[...r,...h,...W,w,pe]};pe.contains.push(P);const _e={match:dn(ba,/\s*:/),keywords:"_|0",relevance:0},He={begin:/\(/,end:/\)/,relevance:0,keywords:f,contains:["self",_e,...r,ee,...h,...x,...T,j,X,...J,...W,pe]},Pe={begin:/</,end:/>/,keywords:"repeat each",contains:[...r,pe]},Ge={begin:cr(Ql(dn(ba,/\s*:/)),Ql(dn(ba,/\s+/,ba,/\s*:/))),end:/:/,relevance:0,contains:[{className:"keyword",match:/\b_\b/},{className:"params",match:ba}]},ct={begin:/\(/,end:/\)/,keywords:f,contains:[Ge,...r,...h,...T,j,X,...W,pe,He],endsParent:!0,illegal:/["']/},mt={match:[/(func|macro)/,/\s+/,cr(q.match,ba,Yp)],className:{1:"keyword",3:"title.function"},contains:[Pe,ct,t],illegal:[/\[/,/%/]},Ct={match:[/\b(?:subscript|init[?!]?)/,/\s*(?=[<(])/],className:{1:"keyword"},contains:[Pe,ct,t],illegal:/\[|%/},Mt={match:[/operator/,/\s+/,Yp],className:{1:"keyword",3:"title"}},Pt={begin:[/precedencegroup/,/\s+/,vd],className:{1:"keyword",3:"title"},contains:[pe],keywords:[...DG,...Y2],end:/}/},Kt={match:[/class\b/,/\s+/,/func\b/,/\s+/,/\b[A-Za-z_][A-Za-z0-9_]*\b/],scope:{1:"keyword",3:"keyword",5:"title.function"}},yt={match:[/class\b/,/\s+/,/var\b/],scope:{1:"keyword",3:"keyword"}},Ue={begin:[/(struct|protocol|class|extension|enum|actor)/,/\s+/,ba,/\s*/],beginScope:{1:"keyword",3:"title.class"},keywords:f,contains:[Pe,...h,{begin:/:/,end:/\{/,keywords:f,contains:[{scope:"title.class.inherited",match:vd},...h],relevance:0}]};for(const dt of X.variants){const Nt=dt.contains.find(Lt=>Lt.label==="interpol");Nt.keywords=f;const bt=[...h,...x,...T,j,X,...J];Nt.contains=[...bt,{begin:/\(/,end:/\)/,contains:["self",...bt]}]}return{name:"Swift",keywords:f,contains:[...r,mt,Ct,Kt,yt,Ue,Mt,Pt,{beginKeywords:"import",end:/$/,contains:[...r],relevance:0},ee,...h,...x,...T,j,X,...J,...W,pe,He]}}const g0="[A-Za-z$_][0-9A-Za-z$_]*",f3=["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"],p3=["true","false","null","undefined","NaN","Infinity"],h3=["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"],g3=["Error","EvalError","InternalError","RangeError","ReferenceError","SyntaxError","TypeError","URIError"],b3=["setInterval","setTimeout","clearInterval","clearTimeout","require","exports","eval","isFinite","isNaN","parseFloat","parseInt","decodeURI","decodeURIComponent","encodeURI","encodeURIComponent","escape","unescape"],x3=["arguments","this","super","console","window","document","localStorage","sessionStorage","module","global"],y3=[].concat(b3,h3,g3);function $G(e){const t=e.regex,n=(fe,{after:Se})=>{const U="</"+fe[0].slice(1);return fe.input.indexOf(U,Se)!==-1},r=g0,o={begin:"<>",end:"</>"},l=/<[A-Za-z0-9\\._:-]+\s*\/>/,c={begin:/<[A-Za-z0-9\\._:-]+/,end:/\/[A-Za-z0-9\\._:-]+>|\/>/,isTrulyOpeningTag:(fe,Se)=>{const U=fe[0].length+fe.index,W=fe.input[U];if(W==="<"||W===","){Se.ignoreMatch();return}W===">"&&(n(fe,{after:U})||Se.ignoreMatch());let pe;const P=fe.input.substring(U);if(pe=P.match(/^\s*=/)){Se.ignoreMatch();return}if((pe=P.match(/^\s+extends\s+/))&&pe.index===0){Se.ignoreMatch();return}}},d={$pattern:g0,keyword:f3,literal:p3,built_in:y3,"variable.language":x3},m="[0-9](_?[0-9])*",f=`\\.(${m})`,h="0|[1-9](_?[0-9])*|0[0-7]*[89][0-9]*",g={className:"number",variants:[{begin:`(\\b(${h})((${f})|\\.)?|(${f}))[eE][+-]?(${m})\\b`},{begin:`\\b(${h})\\b((${f})\\b|\\.)?|(${f})\\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},y={className:"subst",begin:"\\$\\{",end:"\\}",keywords:d,contains:[]},x={begin:".?html`",end:"",starts:{end:"`",returnEnd:!1,contains:[e.BACKSLASH_ESCAPE,y],subLanguage:"xml"}},w={begin:".?css`",end:"",starts:{end:"`",returnEnd:!1,contains:[e.BACKSLASH_ESCAPE,y],subLanguage:"css"}},C={begin:".?gql`",end:"",starts:{end:"`",returnEnd:!1,contains:[e.BACKSLASH_ESCAPE,y],subLanguage:"graphql"}},T={className:"string",begin:"`",end:"`",contains:[e.BACKSLASH_ESCAPE,y]},E={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]},j=[e.APOS_STRING_MODE,e.QUOTE_STRING_MODE,x,w,C,T,{match:/\$\d+/},g];y.contains=j.concat({begin:/\{/,end:/\}/,keywords:d,contains:["self"].concat(j)});const L=[].concat(E,y.contains),I=L.concat([{begin:/(\s*)\(/,end:/\)/,keywords:d,contains:["self"].concat(L)}]),O={className:"params",begin:/(\s*)\(/,end:/\)/,excludeBegin:!0,excludeEnd:!0,keywords:d,contains:I},F={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"}}]},V={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:{_:[...h3,...g3]}},X={label:"use_strict",className:"meta",relevance:10,begin:/^\s*['"]use (strict|asm)['"]/},z={variants:[{match:[/function/,/\s+/,r,/(?=\s*\()/]},{match:[/function/,/\s*(?=\()/]}],className:{1:"keyword",3:"title.function"},label:"func.def",contains:[O],illegal:/%/},G={relevance:0,match:/\b[A-Z][A-Z_0-9]+\b/,className:"variable.constant"};function se(fe){return t.concat("(?!",fe.join("|"),")")}const ee={match:t.concat(/\b/,se([...b3,"super","import"].map(fe=>`${fe}\\s*\\(`)),r,t.lookahead(/\s*\(/)),className:"title.function",relevance:0},q={begin:t.concat(/\./,t.lookahead(t.concat(r,/(?![0-9A-Za-z$_(])/))),end:r,excludeBegin:!0,keywords:"prototype",className:"property",relevance:0},re={match:[/get|set/,/\s+/,r,/(?=\()/],className:{1:"keyword",3:"title.function"},contains:[{begin:/\(\)/},O]},B="(\\([^()]*(\\([^()]*(\\([^()]*\\)[^()]*)*\\)[^()]*)*\\)|"+e.UNDERSCORE_IDENT_RE+")\\s*=>",J={match:[/const|var|let/,/\s+/,r,/\s*/,/=\s*/,/(async\s*)?/,t.lookahead(B)],keywords:"async",className:{1:"keyword",3:"title.function"},contains:[O]};return{name:"JavaScript",aliases:["js","jsx","mjs","cjs"],keywords:d,exports:{PARAMS_CONTAINS:I,CLASS_REFERENCE:V},illegal:/#(?![$_A-z])/,contains:[e.SHEBANG({label:"shebang",binary:"node",relevance:5}),X,e.APOS_STRING_MODE,e.QUOTE_STRING_MODE,x,w,C,T,E,{match:/\$\d+/},g,V,{scope:"attr",match:r+t.lookahead(":"),relevance:0},J,{begin:"("+e.RE_STARTERS_RE+"|\\b(case|return|throw)\\b)\\s*",keywords:"return throw case",relevance:0,contains:[E,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:I}]}]},{begin:/,/,relevance:0},{match:/\s+/,relevance:0},{variants:[{begin:o.begin,end:o.end},{match:l},{begin:c.begin,"on:begin":c.isTrulyOpeningTag,end:c.end}],subLanguage:"xml",contains:[{begin:c.begin,end:c.end,skip:!0,contains:["self"]}]}]},z,{beginKeywords:"while if switch catch for"},{begin:"\\b(?!function)"+e.UNDERSCORE_IDENT_RE+"\\([^()]*(\\([^()]*(\\([^()]*\\)[^()]*)*\\)[^()]*)*\\)\\s*\\{",returnBegin:!0,label:"func.def",contains:[O,e.inherit(e.TITLE_MODE,{begin:r,className:"title.function"})]},{match:/\.\.\./,relevance:0},q,{match:"\\$"+r,relevance:0},{match:[/\bconstructor(?=\s*\()/],className:{1:"title.function"},contains:[O]},ee,G,F,re,{match:/\$[(.]/}]}}function HG(e){const t=e.regex,n=$G(e),r=g0,o=["any","void","number","boolean","string","object","never","symbol","bigint","unknown"],l={begin:[/namespace/,/\s+/,e.IDENT_RE],beginScope:{1:"keyword",3:"title.class"}},c={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"],f={$pattern:g0,keyword:f3.concat(m),literal:p3,built_in:y3.concat(o),"variable.language":x3},h={className:"meta",begin:"@"+r},g=(C,T,S)=>{const E=C.contains.findIndex(j=>j.label===T);if(E===-1)throw new Error("can not find mode to replace");C.contains.splice(E,1,S)};Object.assign(n.keywords,f),n.exports.PARAMS_CONTAINS.push(h);const y=n.contains.find(C=>C.scope==="attr"),x=Object.assign({},y,{match:t.concat(r,t.lookahead(/\s*\?:/))});n.exports.PARAMS_CONTAINS.push([n.exports.CLASS_REFERENCE,y,x]),n.contains=n.contains.concat([h,l,c,x]),g(n,"shebang",e.SHEBANG()),g(n,"use_strict",d);const w=n.contains.find(C=>C.label==="func.def");return w.relevance=0,Object.assign(n,{name:"TypeScript",aliases:["ts","tsx","mts","cts"]}),n}function UG(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}/,c=/(\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(/# */,c,/ *#/)},{begin:t.concat(/# */,t.either(l,o),/ +/,t.either(c,d),/ *#/)}]},f={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])|[%&])?/}]},h={className:"label",begin:/^\w+:/},g=e.COMMENT(/'''/,/$/,{contains:[{className:"doctag",begin:/<\/?/,end:/>/}]}),y=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,f,h,g,y,{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:[y]}]}}function FG(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_]+/},c={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"},f={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,c,o,e.QUOTE_STRING_MODE,m,f,d]}}function qG(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/}]},c=e.inherit(l,{begin:/\(/,end:/\)/}),d=e.inherit(e.APOS_STRING_MODE,{className:"string"}),m=e.inherit(e.QUOTE_STRING_MODE,{className:"string"}),f={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,c,{begin:/\[/,end:/\]/,contains:[{className:"meta",begin:/<![a-z]/,end:/>/,contains:[l,c,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:[f],starts:{end:/<\/style>/,returnEnd:!0,subLanguage:["css","xml"]}},{className:"tag",begin:/<script(?=\s|>)/,end:/>/,keywords:{name:"script"},contains:[f],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:f}]},{className:"tag",begin:t.concat(/<\//,t.lookahead(t.concat(n,/>/))),contains:[{className:"name",begin:n,relevance:0},{begin:/>/,relevance:0,endsParent:!0}]}]}}function GG(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}]},c={className:"string",relevance:0,variants:[{begin:/"/,end:/"/},{begin:/\S+/}],contains:[e.BACKSLASH_ESCAPE,o]},d=e.inherit(c,{variants:[{begin:/'/,end:/'/,contains:[{begin:/''/,relevance:0}]},{begin:/"/,end:/"/},{begin:/[^\s,{}[\]]+/}]}),y={className:"number",begin:"\\b"+"[0-9]{4}(-[0-9][0-9]){0,2}"+"([Tt \\t][0-9][0-9]?(:[0-9][0-9]){2})?"+"(\\.[0-9]*)?"+"([ \\t])*(Z|[-+][0-9][0-9]?(:[0-9][0-9])?)?"+"\\b"},x={end:",",endsWithParent:!0,excludeEnd:!0,keywords:t,relevance:0},w={begin:/\{/,end:/\}/,contains:[x],illegal:"\\n",relevance:0},C={begin:"\\[",end:"\\]",contains:[x],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}},y,{className:"number",begin:e.C_NUMBER_RE+"\\b",relevance:0},w,C,l,c],S=[...T];return S.pop(),S.push(d),x.contains=S,{name:"YAML",case_insensitive:!0,aliases:["yml"],contains:T}}const VG={arduino:Aq,bash:Eq,c:_q,cpp:jq,csharp:Mq,css:$q,diff:Hq,go:Uq,graphql:Fq,ini:qq,java:Gq,javascript:Xq,json:Qq,kotlin:Jq,less:oG,lua:lG,makefile:cG,markdown:uG,objectivec:dG,perl:mG,php:fG,"php-template":pG,plaintext:hG,python:gG,"python-repl":bG,r:xG,ruby:yG,rust:vG,scss:_G,shell:jG,sql:MG,swift:BG,typescript:HG,vbnet:UG,wasm:FG,xml:qG,yaml:GG};var Xp,Q2;function KG(){if(Q2)return Xp;Q2=1;function e(K){return K instanceof Map?K.clear=K.delete=K.set=function(){throw new Error("map is read-only")}:K instanceof Set&&(K.add=K.clear=K.delete=function(){throw new Error("set is read-only")}),Object.freeze(K),Object.getOwnPropertyNames(K).forEach(ce=>{const Te=K[ce],ze=typeof Te;(ze==="object"||ze==="function")&&!Object.isFrozen(Te)&&e(Te)}),K}class t{constructor(ce){ce.data===void 0&&(ce.data={}),this.data=ce.data,this.isMatchIgnored=!1}ignoreMatch(){this.isMatchIgnored=!0}}function n(K){return K.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&#x27;")}function r(K,...ce){const Te=Object.create(null);for(const ze in K)Te[ze]=K[ze];return ce.forEach(function(ze){for(const rt in ze)Te[rt]=ze[rt]}),Te}const o="</span>",l=K=>!!K.scope,c=(K,{prefix:ce})=>{if(K.startsWith("language:"))return K.replace("language:","language-");if(K.includes(".")){const Te=K.split(".");return[`${ce}${Te.shift()}`,...Te.map((ze,rt)=>`${ze}${"_".repeat(rt+1)}`)].join(" ")}return`${ce}${K}`};class d{constructor(ce,Te){this.buffer="",this.classPrefix=Te.classPrefix,ce.walk(this)}addText(ce){this.buffer+=n(ce)}openNode(ce){if(!l(ce))return;const Te=c(ce.scope,{prefix:this.classPrefix});this.span(Te)}closeNode(ce){l(ce)&&(this.buffer+=o)}value(){return this.buffer}span(ce){this.buffer+=`<span class="${ce}">`}}const m=(K={})=>{const ce={children:[]};return Object.assign(ce,K),ce};class f{constructor(){this.rootNode=m(),this.stack=[this.rootNode]}get top(){return this.stack[this.stack.length-1]}get root(){return this.rootNode}add(ce){this.top.children.push(ce)}openNode(ce){const Te=m({scope:ce});this.add(Te),this.stack.push(Te)}closeNode(){if(this.stack.length>1)return this.stack.pop()}closeAllNodes(){for(;this.closeNode(););}toJSON(){return JSON.stringify(this.rootNode,null,4)}walk(ce){return this.constructor._walk(ce,this.rootNode)}static _walk(ce,Te){return typeof Te=="string"?ce.addText(Te):Te.children&&(ce.openNode(Te),Te.children.forEach(ze=>this._walk(ce,ze)),ce.closeNode(Te)),ce}static _collapse(ce){typeof ce!="string"&&ce.children&&(ce.children.every(Te=>typeof Te=="string")?ce.children=[ce.children.join("")]:ce.children.forEach(Te=>{f._collapse(Te)}))}}class h extends f{constructor(ce){super(),this.options=ce}addText(ce){ce!==""&&this.add(ce)}startScope(ce){this.openNode(ce)}endScope(){this.closeNode()}__addSublanguage(ce,Te){const ze=ce.root;Te&&(ze.scope=`language:${Te}`),this.add(ze)}toHTML(){return new d(this,this.options).value()}finalize(){return this.closeAllNodes(),!0}}function g(K){return K?typeof K=="string"?K:K.source:null}function y(K){return C("(?=",K,")")}function x(K){return C("(?:",K,")*")}function w(K){return C("(?:",K,")?")}function C(...K){return K.map(Te=>g(Te)).join("")}function T(K){const ce=K[K.length-1];return typeof ce=="object"&&ce.constructor===Object?(K.splice(K.length-1,1),ce):{}}function S(...K){return"("+(T(K).capture?"":"?:")+K.map(ze=>g(ze)).join("|")+")"}function E(K){return new RegExp(K.toString()+"|").exec("").length-1}function j(K,ce){const Te=K&&K.exec(ce);return Te&&Te.index===0}const L=/\[(?:[^\\\]]|\\.)*\]|\(\??|\\([1-9][0-9]*)|\\./;function I(K,{joinWith:ce}){let Te=0;return K.map(ze=>{Te+=1;const rt=Te;let vt=g(ze),Fe="";for(;vt.length>0;){const at=L.exec(vt);if(!at){Fe+=vt;break}Fe+=vt.substring(0,at.index),vt=vt.substring(at.index+at[0].length),at[0][0]==="\\"&&at[1]?Fe+="\\"+String(Number(at[1])+rt):(Fe+=at[0],at[0]==="("&&Te++)}return Fe}).map(ze=>`(${ze})`).join(ce)}const O=/\b\B/,F="[a-zA-Z]\\w*",V="[a-zA-Z_]\\w*",X="\\b\\d+(\\.\\d+)?",z="(-?)(\\b0[xX][a-fA-F0-9]+|(\\b\\d+(\\.\\d*)?|\\.\\d+)([eE][-+]?\\d+)?)",G="\\b(0b[01]+)",se="!|!=|!==|%|%=|&|&&|&=|\\*|\\*=|\\+|\\+=|,|-|-=|/=|/|:|;|<<|<<=|<=|<|===|==|=|>>>=|>>=|>=|>>>|>>|>|\\?|\\[|\\{|\\(|\\^|\\^=|\\||\\|=|\\|\\||~",ee=(K={})=>{const ce=/^#![ ]*\//;return K.binary&&(K.begin=C(ce,/.*\b/,K.binary,/\b.*/)),r({scope:"meta",begin:ce,end:/$/,relevance:0,"on:begin":(Te,ze)=>{Te.index!==0&&ze.ignoreMatch()}},K)},q={begin:"\\\\[\\s\\S]",relevance:0},re={scope:"string",begin:"'",end:"'",illegal:"\\n",contains:[q]},B={scope:"string",begin:'"',end:'"',illegal:"\\n",contains:[q]},J={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/},fe=function(K,ce,Te={}){const ze=r({scope:"comment",begin:K,end:ce,contains:[]},Te);ze.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 rt=S("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 ze.contains.push({begin:C(/[ ]+/,"(",rt,/[.]?[:]?([.][ ]|[ ])/,"){3}")}),ze},Se=fe("//","$"),U=fe("/\\*","\\*/"),W=fe("#","$"),pe={scope:"number",begin:X,relevance:0},P={scope:"number",begin:z,relevance:0},_e={scope:"number",begin:G,relevance:0},He={scope:"regexp",begin:/\/(?=[^/\n]*\/)/,end:/\/[gimuy]*/,contains:[q,{begin:/\[/,end:/\]/,relevance:0,contains:[q]}]},Pe={scope:"title",begin:F,relevance:0},Ge={scope:"title",begin:V,relevance:0},ct={begin:"\\.\\s*"+V,relevance:0};var Ct=Object.freeze({__proto__:null,APOS_STRING_MODE:re,BACKSLASH_ESCAPE:q,BINARY_NUMBER_MODE:_e,BINARY_NUMBER_RE:G,COMMENT:fe,C_BLOCK_COMMENT_MODE:U,C_LINE_COMMENT_MODE:Se,C_NUMBER_MODE:P,C_NUMBER_RE:z,END_SAME_AS_BEGIN:function(K){return Object.assign(K,{"on:begin":(ce,Te)=>{Te.data._beginMatch=ce[1]},"on:end":(ce,Te)=>{Te.data._beginMatch!==ce[1]&&Te.ignoreMatch()}})},HASH_COMMENT_MODE:W,IDENT_RE:F,MATCH_NOTHING_RE:O,METHOD_GUARD:ct,NUMBER_MODE:pe,NUMBER_RE:X,PHRASAL_WORDS_MODE:J,QUOTE_STRING_MODE:B,REGEXP_MODE:He,RE_STARTERS_RE:se,SHEBANG:ee,TITLE_MODE:Pe,UNDERSCORE_IDENT_RE:V,UNDERSCORE_TITLE_MODE:Ge});function Mt(K,ce){K.input[K.index-1]==="."&&ce.ignoreMatch()}function Pt(K,ce){K.className!==void 0&&(K.scope=K.className,delete K.className)}function Kt(K,ce){ce&&K.beginKeywords&&(K.begin="\\b("+K.beginKeywords.split(" ").join("|")+")(?!\\.)(?=\\b|\\s)",K.__beforeBegin=Mt,K.keywords=K.keywords||K.beginKeywords,delete K.beginKeywords,K.relevance===void 0&&(K.relevance=0))}function yt(K,ce){Array.isArray(K.illegal)&&(K.illegal=S(...K.illegal))}function Ue(K,ce){if(K.match){if(K.begin||K.end)throw new Error("begin & end are not supported with match");K.begin=K.match,delete K.match}}function dt(K,ce){K.relevance===void 0&&(K.relevance=1)}const Nt=(K,ce)=>{if(!K.beforeMatch)return;if(K.starts)throw new Error("beforeMatch cannot be used with starts");const Te=Object.assign({},K);Object.keys(K).forEach(ze=>{delete K[ze]}),K.keywords=Te.keywords,K.begin=C(Te.beforeMatch,y(Te.begin)),K.starts={relevance:0,contains:[Object.assign(Te,{endsParent:!0})]},K.relevance=0,delete Te.beforeMatch},bt=["of","and","for","in","not","or","if","then","parent","list","value"],Lt="keyword";function ue(K,ce,Te=Lt){const ze=Object.create(null);return typeof K=="string"?rt(Te,K.split(" ")):Array.isArray(K)?rt(Te,K):Object.keys(K).forEach(function(vt){Object.assign(ze,ue(K[vt],ce,vt))}),ze;function rt(vt,Fe){ce&&(Fe=Fe.map(at=>at.toLowerCase())),Fe.forEach(function(at){const kt=at.split("|");ze[kt[0]]=[vt,tt(kt[0],kt[1])]})}}function tt(K,ce){return ce?Number(ce):st(K)?0:1}function st(K){return bt.includes(K.toLowerCase())}const ye={},je=K=>{console.error(K)},Ae=(K,...ce)=>{console.log(`WARN: ${K}`,...ce)},oe=(K,ce)=>{ye[`${K}/${ce}`]||(console.log(`Deprecated as of ${K}. ${ce}`),ye[`${K}/${ce}`]=!0)},H=new Error;function te(K,ce,{key:Te}){let ze=0;const rt=K[Te],vt={},Fe={};for(let at=1;at<=ce.length;at++)Fe[at+ze]=rt[at],vt[at+ze]=!0,ze+=E(ce[at-1]);K[Te]=Fe,K[Te]._emit=vt,K[Te]._multi=!0}function Ne(K){if(Array.isArray(K.begin)){if(K.skip||K.excludeBegin||K.returnBegin)throw je("skip, excludeBegin, returnBegin not compatible with beginScope: {}"),H;if(typeof K.beginScope!="object"||K.beginScope===null)throw je("beginScope must be object"),H;te(K,K.begin,{key:"beginScope"}),K.begin=I(K.begin,{joinWith:""})}}function Re(K){if(Array.isArray(K.end)){if(K.skip||K.excludeEnd||K.returnEnd)throw je("skip, excludeEnd, returnEnd not compatible with endScope: {}"),H;if(typeof K.endScope!="object"||K.endScope===null)throw je("endScope must be object"),H;te(K,K.end,{key:"endScope"}),K.end=I(K.end,{joinWith:""})}}function $e(K){K.scope&&typeof K.scope=="object"&&K.scope!==null&&(K.beginScope=K.scope,delete K.scope)}function Q(K){$e(K),typeof K.beginScope=="string"&&(K.beginScope={_wrap:K.beginScope}),typeof K.endScope=="string"&&(K.endScope={_wrap:K.endScope}),Ne(K),Re(K)}function Z(K){function ce(Fe,at){return new RegExp(g(Fe),"m"+(K.case_insensitive?"i":"")+(K.unicodeRegex?"u":"")+(at?"g":""))}class Te{constructor(){this.matchIndexes={},this.regexes=[],this.matchAt=1,this.position=0}addRule(at,kt){kt.position=this.position++,this.matchIndexes[this.matchAt]=kt,this.regexes.push([kt,at]),this.matchAt+=E(at)+1}compile(){this.regexes.length===0&&(this.exec=()=>null);const at=this.regexes.map(kt=>kt[1]);this.matcherRe=ce(I(at,{joinWith:"|"}),!0),this.lastIndex=0}exec(at){this.matcherRe.lastIndex=this.lastIndex;const kt=this.matcherRe.exec(at);if(!kt)return null;const xn=kt.findIndex((Ea,Di)=>Di>0&&Ea!==void 0),wn=this.matchIndexes[xn];return kt.splice(0,xn),Object.assign(kt,wn)}}class ze{constructor(){this.rules=[],this.multiRegexes=[],this.count=0,this.lastIndex=0,this.regexIndex=0}getMatcher(at){if(this.multiRegexes[at])return this.multiRegexes[at];const kt=new Te;return this.rules.slice(at).forEach(([xn,wn])=>kt.addRule(xn,wn)),kt.compile(),this.multiRegexes[at]=kt,kt}resumingScanAtSamePosition(){return this.regexIndex!==0}considerAll(){this.regexIndex=0}addRule(at,kt){this.rules.push([at,kt]),kt.type==="begin"&&this.count++}exec(at){const kt=this.getMatcher(this.regexIndex);kt.lastIndex=this.lastIndex;let xn=kt.exec(at);if(this.resumingScanAtSamePosition()&&!(xn&&xn.index===this.lastIndex)){const wn=this.getMatcher(0);wn.lastIndex=this.lastIndex+1,xn=wn.exec(at)}return xn&&(this.regexIndex+=xn.position+1,this.regexIndex===this.count&&this.considerAll()),xn}}function rt(Fe){const at=new ze;return Fe.contains.forEach(kt=>at.addRule(kt.begin,{rule:kt,type:"begin"})),Fe.terminatorEnd&&at.addRule(Fe.terminatorEnd,{type:"end"}),Fe.illegal&&at.addRule(Fe.illegal,{type:"illegal"}),at}function vt(Fe,at){const kt=Fe;if(Fe.isCompiled)return kt;[Pt,Ue,Q,Nt].forEach(wn=>wn(Fe,at)),K.compilerExtensions.forEach(wn=>wn(Fe,at)),Fe.__beforeBegin=null,[Kt,yt,dt].forEach(wn=>wn(Fe,at)),Fe.isCompiled=!0;let xn=null;return typeof Fe.keywords=="object"&&Fe.keywords.$pattern&&(Fe.keywords=Object.assign({},Fe.keywords),xn=Fe.keywords.$pattern,delete Fe.keywords.$pattern),xn=xn||/\w+/,Fe.keywords&&(Fe.keywords=ue(Fe.keywords,K.case_insensitive)),kt.keywordPatternRe=ce(xn,!0),at&&(Fe.begin||(Fe.begin=/\B|\b/),kt.beginRe=ce(kt.begin),!Fe.end&&!Fe.endsWithParent&&(Fe.end=/\B|\b/),Fe.end&&(kt.endRe=ce(kt.end)),kt.terminatorEnd=g(kt.end)||"",Fe.endsWithParent&&at.terminatorEnd&&(kt.terminatorEnd+=(Fe.end?"|":"")+at.terminatorEnd)),Fe.illegal&&(kt.illegalRe=ce(Fe.illegal)),Fe.contains||(Fe.contains=[]),Fe.contains=[].concat(...Fe.contains.map(function(wn){return Ke(wn==="self"?Fe:wn)})),Fe.contains.forEach(function(wn){vt(wn,kt)}),Fe.starts&&vt(Fe.starts,at),kt.matcher=rt(kt),kt}if(K.compilerExtensions||(K.compilerExtensions=[]),K.contains&&K.contains.includes("self"))throw new Error("ERR: contains `self` is not supported at the top-level of a language. See documentation.");return K.classNameAliases=r(K.classNameAliases||{}),vt(K)}function be(K){return K?K.endsWithParent||be(K.starts):!1}function Ke(K){return K.variants&&!K.cachedVariants&&(K.cachedVariants=K.variants.map(function(ce){return r(K,{variants:null},ce)})),K.cachedVariants?K.cachedVariants:be(K)?r(K,{starts:K.starts?r(K.starts):null}):Object.isFrozen(K)?r(K):K}var Ie="11.11.1";class Ye extends Error{constructor(ce,Te){super(ce),this.name="HTMLInjectionError",this.html=Te}}const M=n,le=r,Oe=Symbol("nomatch"),ge=7,Ve=function(K){const ce=Object.create(null),Te=Object.create(null),ze=[];let rt=!0;const vt="Could not find the language '{}', did you forget to load/include a language module?",Fe={disableAutodetect:!0,name:"Plain text",contains:[]};let at={ignoreUnescapedHTML:!1,throwUnescapedHTML:!1,noHighlightRe:/^(no-?highlight)$/i,languageDetectRe:/\blang(?:uage)?-([\w-]+)\b/i,classPrefix:"hljs-",cssSelector:"pre code",languages:null,__emitter:h};function kt(We){return at.noHighlightRe.test(We)}function xn(We){let wt=We.className+" ";wt+=We.parentNode?We.parentNode.className:"";const Ht=at.languageDetectRe.exec(wt);if(Ht){const rn=ir(Ht[1]);return rn||(Ae(vt.replace("{}",Ht[1])),Ae("Falling back to no-highlight mode for this block.",We)),rn?Ht[1]:"no-highlight"}return wt.split(/\s+/).find(rn=>kt(rn)||ir(rn))}function wn(We,wt,Ht){let rn="",Rn="";typeof wt=="object"?(rn=We,Ht=wt.ignoreIllegals,Rn=wt.language):(oe("10.7.0","highlight(lang, code, ...args) has been deprecated."),oe("10.7.0",`Please use highlight(code, options) instead.
647
647
  https://github.com/highlightjs/highlight.js/issues/2277`),Rn=We,rn=wt),Ht===void 0&&(Ht=!0);const tr={code:rn,language:Rn};Ys("before:highlight",tr);const Mr=tr.result?tr.result:Ea(tr.language,tr.code,Ht);return Mr.code=tr.code,Ys("after:highlight",Mr),Mr}function Ea(We,wt,Ht,rn){const Rn=Object.create(null);function tr(nt,ht){return nt.keywords[ht]}function Mr(){if(!Et.keywords){In.addText(an);return}let nt=0;Et.keywordPatternRe.lastIndex=0;let ht=Et.keywordPatternRe.exec(an),Dt="";for(;ht;){Dt+=an.substring(nt,ht.index);const Wt=Yn.case_insensitive?ht[0].toLowerCase():ht[0],Cn=tr(Et,Wt);if(Cn){const[Wr,nl]=Cn;if(In.addText(Dt),Dt="",Rn[Wt]=(Rn[Wt]||0)+1,Rn[Wt]<=ge&&(ls+=nl),Wr.startsWith("_"))Dt+=ht[0];else{const Hc=Yn.classNameAliases[Wr]||Wr;Rr(ht[0],Hc)}}else Dt+=ht[0];nt=Et.keywordPatternRe.lastIndex,ht=Et.keywordPatternRe.exec(an)}Dt+=an.substring(nt),In.addText(Dt)}function gr(){if(an==="")return;let nt=null;if(typeof Et.subLanguage=="string"){if(!ce[Et.subLanguage]){In.addText(an);return}nt=Ea(Et.subLanguage,an,!0,$c[Et.subLanguage]),$c[Et.subLanguage]=nt._top}else nt=Ii(an,Et.subLanguage.length?Et.subLanguage:null);Et.relevance>0&&(ls+=nt.relevance),In.__addSublanguage(nt._emitter,nt.language)}function hn(){Et.subLanguage!=null?gr():Mr(),an=""}function Rr(nt,ht){nt!==""&&(In.startScope(ht),In.addText(nt),In.endScope())}function zc(nt,ht){let Dt=1;const Wt=ht.length-1;for(;Dt<=Wt;){if(!nt._emit[Dt]){Dt++;continue}const Cn=Yn.classNameAliases[nt[Dt]]||nt[Dt],Wr=ht[Dt];Cn?Rr(Wr,Cn):(an=Wr,Mr(),an=""),Dt++}}function zi(nt,ht){return nt.scope&&typeof nt.scope=="string"&&In.openNode(Yn.classNameAliases[nt.scope]||nt.scope),nt.beginScope&&(nt.beginScope._wrap?(Rr(an,Yn.classNameAliases[nt.beginScope._wrap]||nt.beginScope._wrap),an=""):nt.beginScope._multi&&(zc(nt.beginScope,ht),an="")),Et=Object.create(nt,{parent:{value:Et}}),Et}function Jo(nt,ht,Dt){let Wt=j(nt.endRe,Dt);if(Wt){if(nt["on:end"]){const Cn=new t(nt);nt["on:end"](ht,Cn),Cn.isMatchIgnored&&(Wt=!1)}if(Wt){for(;nt.endsParent&&nt.parent;)nt=nt.parent;return nt}}if(nt.endsWithParent)return Jo(nt.parent,ht,Dt)}function Bi(nt){return Et.matcher.regexIndex===0?(an+=nt[0],1):(cs=!0,0)}function X0(nt){const ht=nt[0],Dt=nt.rule,Wt=new t(Dt),Cn=[Dt.__beforeBegin,Dt["on:begin"]];for(const Wr of Cn)if(Wr&&(Wr(nt,Wt),Wt.isMatchIgnored))return Bi(ht);return Dt.skip?an+=ht:(Dt.excludeBegin&&(an+=ht),hn(),!Dt.returnBegin&&!Dt.excludeBegin&&(an=ht)),zi(Dt,nt),Dt.returnBegin?0:ht.length}function br(nt){const ht=nt[0],Dt=wt.substring(nt.index),Wt=Jo(Et,nt,Dt);if(!Wt)return Oe;const Cn=Et;Et.endScope&&Et.endScope._wrap?(hn(),Rr(ht,Et.endScope._wrap)):Et.endScope&&Et.endScope._multi?(hn(),zc(Et.endScope,nt)):Cn.skip?an+=ht:(Cn.returnEnd||Cn.excludeEnd||(an+=ht),hn(),Cn.excludeEnd&&(an=ht));do Et.scope&&In.closeNode(),!Et.skip&&!Et.subLanguage&&(ls+=Et.relevance),Et=Et.parent;while(Et!==Wt.parent);return Wt.starts&&zi(Wt.starts,nt),Cn.returnEnd?0:ht.length}function el(){const nt=[];for(let ht=Et;ht!==Yn;ht=ht.parent)ht.scope&&nt.unshift(ht.scope);nt.forEach(ht=>In.openNode(ht))}let Xs={};function $i(nt,ht){const Dt=ht&&ht[0];if(an+=nt,Dt==null)return hn(),0;if(Xs.type==="begin"&&ht.type==="end"&&Xs.index===ht.index&&Dt===""){if(an+=wt.slice(ht.index,ht.index+1),!rt){const Wt=new Error(`0 width match regex (${We})`);throw Wt.languageName=We,Wt.badRule=Xs.rule,Wt}return 1}if(Xs=ht,ht.type==="begin")return X0(ht);if(ht.type==="illegal"&&!Ht){const Wt=new Error('Illegal lexeme "'+Dt+'" for mode "'+(Et.scope||"<unnamed>")+'"');throw Wt.mode=Et,Wt}else if(ht.type==="end"){const Wt=br(ht);if(Wt!==Oe)return Wt}if(ht.type==="illegal"&&Dt==="")return an+=`
648
- `,1;if(tl>1e5&&tl>ht.index*3)throw new Error("potential infinite loop, way more iterations than matches");return an+=Dt,Dt.length}const Yn=ir(We);if(!Yn)throw je(vt.replace("{}",We)),new Error('Unknown language: "'+We+'"');const Bc=Z(Yn);let Hi="",Et=rn||Bc;const $c={},In=new at.__emitter(at);el();let an="",ls=0,Ma=0,tl=0,cs=!1;try{if(Yn.__emitTokens)Yn.__emitTokens(wt,In);else{for(Et.matcher.considerAll();;){tl++,cs?cs=!1:Et.matcher.considerAll(),Et.matcher.lastIndex=Ma;const nt=Et.matcher.exec(wt);if(!nt)break;const ht=wt.substring(Ma,nt.index),Dt=$i(ht,nt);Ma=nt.index+Dt}$i(wt.substring(Ma))}return In.finalize(),Hi=In.toHTML(),{language:We,value:Hi,relevance:ls,illegal:!1,_emitter:In,_top:Et}}catch(nt){if(nt.message&&nt.message.includes("Illegal"))return{language:We,value:M(wt),illegal:!0,relevance:0,_illegalBy:{message:nt.message,index:Ma,context:wt.slice(Ma-100,Ma+100),mode:nt.mode,resultSoFar:Hi},_emitter:In};if(rt)return{language:We,value:M(wt),illegal:!1,relevance:0,errorRaised:nt,_emitter:In,_top:Et};throw nt}}function Di(We){const wt={value:M(We),illegal:!1,relevance:0,_top:Fe,_emitter:new at.__emitter(at)};return wt._emitter.addText(We),wt}function Ii(We,wt){wt=wt||at.languages||Object.keys(ce);const Ht=Di(We),rn=wt.filter(ir).filter(is).map(hn=>Ea(hn,We,!1));rn.unshift(Ht);const Rn=rn.sort((hn,Rr)=>{if(hn.relevance!==Rr.relevance)return Rr.relevance-hn.relevance;if(hn.language&&Rr.language){if(ir(hn.language).supersetOf===Rr.language)return 1;if(ir(Rr.language).supersetOf===hn.language)return-1}return 0}),[tr,Mr]=Rn,gr=tr;return gr.secondBest=Mr,gr}function ma(We,wt,Ht){const rn=wt&&Te[wt]||Ht;We.classList.add("hljs"),We.classList.add(`language-${rn}`)}function Mn(We){let wt=null;const Ht=xn(We);if(kt(Ht))return;if(Ys("before:highlightElement",{el:We,language:Ht}),We.dataset.highlighted){console.log("Element previously highlighted. To highlight again, first unset `dataset.highlighted`.",We);return}if(We.children.length>0&&(at.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(We)),at.throwUnescapedHTML))throw new Ye("One of your code blocks includes unescaped HTML.",We.innerHTML);wt=We;const rn=wt.textContent,Rn=Ht?wn(rn,{language:Ht,ignoreIllegals:!0}):Ii(rn);We.innerHTML=Rn.value,We.dataset.highlighted="yes",ma(We,Ht,Rn.language),We.result={language:Rn.language,re:Rn.relevance,relevance:Rn.relevance},Rn.secondBest&&(We.secondBest={language:Rn.secondBest.language,relevance:Rn.secondBest.relevance}),Ys("after:highlightElement",{el:We,result:Rn,text:rn})}function er(We){at=le(at,We)}const ss=()=>{Pi(),oe("10.6.0","initHighlighting() deprecated. Use highlightAll() now.")};function Qo(){Pi(),oe("10.6.0","initHighlightingOnLoad() deprecated. Use highlightAll() now.")}let Dc=!1;function Pi(){function We(){Pi()}if(document.readyState==="loading"){Dc||window.addEventListener("DOMContentLoaded",We,!1),Dc=!0;return}document.querySelectorAll(at.cssSelector).forEach(Mn)}function Ic(We,wt){let Ht=null;try{Ht=wt(K)}catch(rn){if(je("Language definition for '{}' could not be registered.".replace("{}",We)),rt)je(rn);else throw rn;Ht=Fe}Ht.name||(Ht.name=We),ce[We]=Ht,Ht.rawDefinition=wt.bind(null,K),Ht.aliases&&_a(Ht.aliases,{languageName:We})}function Ws(We){delete ce[We];for(const wt of Object.keys(Te))Te[wt]===We&&delete Te[wt]}function Zo(){return Object.keys(ce)}function ir(We){return We=(We||"").toLowerCase(),ce[We]||ce[Te[We]]}function _a(We,{languageName:wt}){typeof We=="string"&&(We=[We]),We.forEach(Ht=>{Te[Ht.toLowerCase()]=wt})}function is(We){const wt=ir(We);return wt&&!wt.disableAutodetect}function os(We){We["before:highlightBlock"]&&!We["before:highlightElement"]&&(We["before:highlightElement"]=wt=>{We["before:highlightBlock"](Object.assign({block:wt.el},wt))}),We["after:highlightBlock"]&&!We["after:highlightElement"]&&(We["after:highlightElement"]=wt=>{We["after:highlightBlock"](Object.assign({block:wt.el},wt))})}function Dn(We){os(We),ze.push(We)}function Pc(We){const wt=ze.indexOf(We);wt!==-1&&ze.splice(wt,1)}function Ys(We,wt){const Ht=We;ze.forEach(function(rn){rn[Ht]&&rn[Ht](wt)})}function ja(We){return oe("10.7.0","highlightBlock will be removed entirely in v12.0"),oe("10.7.0","Please use highlightElement now."),Mn(We)}Object.assign(K,{highlight:wn,highlightAuto:Ii,highlightAll:Pi,highlightElement:Mn,highlightBlock:ja,configure:er,initHighlighting:ss,initHighlightingOnLoad:Qo,registerLanguage:Ic,unregisterLanguage:Ws,listLanguages:Zo,getLanguage:ir,registerAliases:_a,autoDetection:is,inherit:le,addPlugin:Dn,removePlugin:Pc}),K.debugMode=function(){rt=!1},K.safeMode=function(){rt=!0},K.versionString=Ie,K.regex={concat:C,lookahead:y,either:S,optional:w,anyNumberOfTimes:x};for(const We in Ct)typeof Ct[We]=="object"&&e(Ct[We]);return Object.assign(K,Ct),K},Qe=Ve({});return Qe.newInstance=()=>Ve({}),Xp=Qe,Qe.HighlightJS=Qe,Qe.default=Qe,Xp}var WG=KG();const YG=Tc(WG),Z2={},XG="hljs-";function QG(e){const t=YG.newInstance();return e&&l(e),{highlight:n,highlightAuto:r,listLanguages:o,register:l,registerAlias:c,registered:d};function n(m,f,h){const g=h||Z2,y=typeof g.prefix=="string"?g.prefix:XG;if(!t.getLanguage(m))throw new Error("Unknown language: `"+m+"` is not registered");t.configure({__emitter:ZG,classPrefix:y});const x=t.highlight(f,{ignoreIllegals:!0,language:m});if(x.errorRaised)throw new Error("Could not highlight with `Highlight.js`",{cause:x.errorRaised});const w=x._emitter.root,C=w.data;return C.language=x.language,C.relevance=x.relevance,w}function r(m,f){const g=(f||Z2).subset||o();let y=-1,x=0,w;for(;++y<g.length;){const C=g[y];if(!t.getLanguage(C))continue;const T=n(C,m,f);T.data&&T.data.relevance!==void 0&&T.data.relevance>x&&(x=T.data.relevance,w=T)}return w||{type:"root",children:[],data:{language:void 0,relevance:x}}}function o(){return t.listLanguages()}function l(m,f){if(typeof m=="string")t.registerLanguage(m,f);else{let h;for(h in m)Object.hasOwn(m,h)&&t.registerLanguage(h,m[h])}}function c(m,f){if(typeof m=="string")t.registerAliases(typeof f=="string"?f:[...f],{languageName:m});else{let h;for(h in m)if(Object.hasOwn(m,h)){const g=m[h];t.registerAliases(typeof g=="string"?g:[...g],{languageName:h})}}}function d(m){return!!t.getLanguage(m)}}class ZG{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(c,d){return d?c+"_".repeat(d):n.options.classPrefix+c}),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 JG={};function v3(e){const t=e||JG,n=t.aliases,r=t.detect||!1,o=t.languages||VG,l=t.plainText,c=t.prefix,d=t.subset;let m="hljs";const f=QG(o);if(n&&f.registerAlias(n),c){const h=c.indexOf("-");m=h===-1?c:c.slice(0,h)}return function(h,g){D0(h,"element",function(y,x,w){if(y.tagName!=="code"||!w||w.type!=="element"||w.tagName!=="pre")return;const C=eV(y);if(C===!1||!C&&!r||C&&l&&l.includes(C))return;Array.isArray(y.properties.className)||(y.properties.className=[]),y.properties.className.includes(m)||y.properties.className.unshift(m);const T=Zk(y,{whitespace:"pre"});let S;try{S=C?f.highlight(C,T,{prefix:c}):f.highlightAuto(T,{prefix:c,subset:d})}catch(E){const j=E;if(C&&/Unknown language/.test(j.message)){g.message("Cannot highlight as `"+C+"`, it’s not registered",{ancestors:[w,y],cause:j,place:y.position,ruleId:"missing-language",source:"rehype-highlight"});return}throw j}!C&&S.data&&S.data.language&&y.properties.className.push("language-"+S.data.language),S.children.length>0&&(y.children=S.children)})}}function eV(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 Vg=new Set;function wi(e){e&&Vg.add(e)}function Vh(e){e&&Vg.delete(e)}const w3="markus_right_panel_v1",tV=10,Kh=new Map;function nV(e,t=3e3){Kh.set(e,Date.now()+t)}function rV(e){const t=Kh.get(e);return t==null?!1:Date.now()>t?(Kh.delete(e),!1):!0}function aV(e){return e.kind==="terminal"}function Zl(e){if(e.kind==="file")return`file:${e.path}`;if(e.kind==="url")return`url:${e.browserId||e.url}`;if(e.kind==="terminal")return`terminal:${e.terminalId}`;const t=e.deliverable;return`deliverable:${t.id||`${t.reference||""}|${t.title||""}|${t.summary?.slice(0,48)||""}`||"unknown"}`}function J2(e){return e.kind==="deliverable"?e.deliverable.title||e.deliverable.reference||"Deliverable":e.kind==="url"?e.title||e.url:e.kind==="terminal"?e.title||"Terminal":e.title||e.path.split(/[/\\]/).pop()||e.path}function Is(){return`tab_${Date.now().toString(36)}_${Math.random().toString(36).slice(2,7)}`}function wd(e){let t=e;for(;t.length>tV;){let n=-1;for(let o=t.length-1;o>=0;o--)if(!t[o].pinned){n=o;break}if(n<0)break;const r=t[n];r&&(Wh(r.payload),Yh(r.payload)),t=t.filter((o,l)=>l!==n)}return t}function Wh(e){e?.kind==="url"&&e.browserId&&(nV(e.browserId),window.markusDesktop?.browser?.destroy(e.browserId))}function Yh(e){e?.kind==="terminal"&&e.terminalId&&(Vh(e.terminalId),window.markusDesktop?.terminal?.destroy(e.terminalId))}function sV(e){const t=e.payload;return t.kind==="terminal"?null:t.kind==="url"?gc(t.url||"")||gc(t.title||"")?null:{id:e.id,title:e.title,pinned:e.pinned,payload:{kind:"url",url:t.url||"about:blank",title:t.title||e.title}}:t.kind==="file"?{id:e.id,title:e.title,pinned:e.pinned,payload:{kind:"file",path:t.path,title:t.title}}:{id:e.id,title:e.title,pinned:e.pinned,payload:{kind:"deliverable",deliverable:t.deliverable}}}function iV(e,t=0){if(e.payload.kind==="url"){const n=`eb_${Date.now().toString(36)}_${t.toString(36)}_${Math.random().toString(36).slice(2,7)}`;return{...e,payload:{kind:"url",url:e.payload.url||"about:blank",title:e.payload.title||e.title,browserId:n}}}return e}function oV(){try{const e=localStorage.getItem(w3);if(!e)return null;const t=JSON.parse(e);return!t||t.mode!=="browser"&&t.mode!=="terminal"||!Array.isArray(t.browserTabs)?null:t}catch{return null}}function lV(){const e={mode:"browser",browserTabs:[],browserActiveId:null,terminalTabs:[],terminalActiveId:null,stashedBrowserTabs:[],stashedBrowserActiveId:null,stashedTerminalTabs:[],stashedTerminalActiveId:null},t=oV();if(!t)return e;const n=t.browserTabs.map((x,w)=>{try{return iV(x,w)}catch{return null}}).filter(x=>!(!x||x.payload.kind==="terminal"||x.payload.kind==="url"&&gc(x.payload.url||""))),r=n.some(x=>x.id===t.browserActiveId)?t.browserActiveId:n[0]?.id??null,o=(t.terminalTabs||[]).map((x,w)=>{const C=`term_${Date.now().toString(36)}_${w.toString(36)}_${Math.random().toString(36).slice(2,7)}`;return wi(C),{id:x.id||Is(),title:x.title||"Terminal",payload:{kind:"terminal",terminalId:C,title:x.title||"Terminal",cwd:x.cwd}}}),l=o.some(x=>x.id===t.terminalActiveId)?t.terminalActiveId:o[0]?.id??null,c=!!t.browserCollapsed&&n.length>0,d=!!t.terminalCollapsed&&o.length>0,m=c?[]:n,f=c?null:r,h=d?[]:o,g=d?null:l;let y=t.mode;return y==="terminal"&&h.length===0&&!d&&(y="browser"),y==="browser"&&m.length===0&&h.length>0&&(y="terminal"),{mode:y,browserTabs:m,browserActiveId:f,terminalTabs:h,terminalActiveId:g,stashedBrowserTabs:n,stashedBrowserActiveId:r,stashedTerminalTabs:o,stashedTerminalActiveId:l}}const k3=k.createContext(null);function cV({children:e}){const[t,n]=k.useState(()=>{try{return localStorage.getItem("markus_sidebar_c")==="1"}catch{return!1}}),r=k.useMemo(()=>lV(),[]),[o,l]=k.useState(r.mode),[c,d]=k.useState(r.browserTabs),[m,f]=k.useState(r.terminalTabs),[h,g]=k.useState(r.browserActiveId),[y,x]=k.useState(r.terminalActiveId),[w,C]=k.useState(!1),[T,S]=k.useState(!1),[E,j]=k.useState("l0"),[L,I]=k.useState(null),O=k.useCallback(ye=>j(ye),[]),F=k.useCallback(ye=>I(ye),[]);k.useEffect(()=>{const ye=Ae=>{if(!(Ae instanceof HTMLElement))return!1;const oe=Ae.tagName;return oe==="INPUT"||oe==="TEXTAREA"||oe==="SELECT"?!0:Ae.isContentEditable},je=Ae=>{if(!(Ae.target instanceof Element))return;const oe=document.activeElement;if(ye(oe)){const Ne=oe===Ae.target||oe.contains(Ae.target),Re=!!Ae.target.closest("[data-keep-edit-focus]"),$e=ye(Ae.target)||!!Ae.target.closest('input, textarea, select, [contenteditable="true"]'),Q=!!Ae.target.closest(".xterm");!Ne&&!Re&&!$e&&!Q&&oe.blur()}const H=Ae.target.closest("[data-keyboard-pane]");if(!H)return;const te=H.getAttribute("data-keyboard-pane");if(!(te!=="l0"&&te!=="l1"&&te!=="l2"&&te!=="content")&&(j(te),te==="l0")){const Re=Ae.target.closest("[data-l0-page-id]")?.getAttribute("data-l0-page-id");Re&&I(Re)}};return document.addEventListener("pointerdown",je,!0),()=>document.removeEventListener("pointerdown",je,!0)},[]);const V=k.useRef(r.stashedBrowserTabs.length>0?r.stashedBrowserTabs:r.browserTabs),X=k.useRef(r.stashedBrowserActiveId??r.browserActiveId),z=k.useRef(r.stashedTerminalTabs.length>0?r.stashedTerminalTabs:r.terminalTabs),G=k.useRef(r.stashedTerminalActiveId??r.terminalActiveId),se=k.useRef(r.browserActiveId),ee=k.useRef(r.terminalActiveId),q=k.useRef(r.browserTabs),re=k.useRef(r.terminalTabs),B=k.useRef(r.mode);se.current=h,ee.current=y,q.current=c,re.current=m,B.current=o,k.useEffect(()=>{(r.mode==="terminal"||r.browserTabs.length===0)&&window.markusDesktop?.browser?.hideAll?.()},[]),k.useEffect(()=>{const ye=c.length===0&&V.current.length>0,je=m.length===0&&z.current.length>0,Ae=ye?V.current:c,oe=je?z.current:m,H=Ae.map(sV).filter(Re=>!!Re),te=oe.filter(Re=>Re.payload.kind==="terminal").map(Re=>({id:Re.id,title:Re.title,cwd:Re.payload.kind==="terminal"?Re.payload.cwd:void 0})),Ne={mode:o,browserTabs:H,browserActiveId:ye?X.current:h,terminalTabs:te,terminalActiveId:je?G.current:y,browserCollapsed:ye,terminalCollapsed:je};try{localStorage.setItem(w3,JSON.stringify(Ne))}catch{}},[o,c,h,m,y]);const J=k.useCallback(ye=>n(ye),[]),fe=k.useCallback(()=>n(ye=>!ye),[]),Se=k.useCallback(()=>{window.markusDesktop?.browser?.hideAll?.()},[]),U=k.useCallback(ye=>{l(je=>je===ye?je:(ye==="terminal"&&Se(),ye))},[Se]),W=k.useCallback(ye=>{if(ye==="terminal"){if(Se(),l("terminal"),n(!0),m.length>0)return;if(z.current.length>0){const Re=z.current,$e=G.current&&Re.some(Q=>Q.id===G.current)?G.current:Re[0].id;f(Re),x($e),G.current=$e;return}const H=Is(),te=`term_${Date.now().toString(36)}_${Math.random().toString(36).slice(2,7)}`;wi(te);const Ne={id:H,title:"Terminal",payload:{kind:"terminal",terminalId:te,title:"Terminal"}};z.current=[Ne],f([Ne]),x(Ne.id),G.current=Ne.id;return}if(l("browser"),n(!0),c.length>0)return;if(V.current.length>0){const H=V.current,te=X.current&&H.some(Ne=>Ne.id===X.current)?X.current:H[0].id;d(H),g(te),X.current=te;return}const je=Is(),Ae=`eb_${Date.now().toString(36)}_${Math.random().toString(36).slice(2,7)}`,oe={id:je,title:"New Tab",payload:{kind:"url",url:"about:blank",title:"New Tab",browserId:Ae}};V.current=[oe],d([oe]),g(oe.id),X.current=oe.id},[c.length,m.length,Se]),pe=k.useCallback(ye=>{const je=Zl(ye),Ae=Is();if(aV(ye)){ye.kind==="terminal"&&wi(ye.terminalId),l("terminal"),Se();const H=re.current,te=H.find($e=>Zl($e.payload)===je)??z.current.find($e=>Zl($e.payload)===je);let Ne,Re;if(te)Re=te.id,Ne=H.some($e=>$e.id===te.id)?H:wd([te,...H]);else{const $e={id:Ae,title:J2(ye),payload:ye};Ne=wd([$e,...H]),Re=Ae}z.current=Ne,re.current=Ne,f(Ne),x(Re),G.current=Re,ee.current=Re}else{l("browser");const H=q.current,te=H.find($e=>Zl($e.payload)===je)??V.current.find($e=>Zl($e.payload)===je);let Ne,Re;if(te)Re=te.id,Ne=H.some($e=>$e.id===te.id)?H:wd([te,...H]);else{const $e={id:Ae,title:J2(ye),payload:ye};Ne=wd([$e,...H]),Re=Ae}V.current=Ne,q.current=Ne,d(Ne),g(Re),X.current=Re,se.current=Re}n(!0)},[Se]),P=k.useCallback(ye=>{const je=q.current,Ae=je.findIndex(Z=>Z.id===ye);if(Ae>=0){const Z=je[Ae]?.payload,be=je.filter(M=>M.id!==ye),Ke=se.current,Ye=(je.some(M=>M.id===Ke)?Ke:je[0]?.id??null)===ye||be.length===0?be[Math.min(Ae,be.length-1)]?.id??null:void 0;V.current=be,q.current=be,d(be),be.length===0&&B.current==="browser"&&C(!1),Ye!==void 0&&(g(Ye),X.current=Ye,se.current=Ye),Wh(Z);return}const oe=re.current,H=oe.findIndex(Z=>Z.id===ye);if(H<0)return;const te=oe[H]?.payload,Ne=oe.filter(Z=>Z.id!==ye),Re=ee.current,Q=(oe.some(Z=>Z.id===Re)?Re:oe[0]?.id??null)===ye||Ne.length===0?Ne[Math.min(H,Ne.length-1)]?.id??null:void 0;z.current=Ne,re.current=Ne,f(Ne),Ne.length===0&&B.current==="terminal"&&C(!1),Q!==void 0&&(x(Q),G.current=Q,ee.current=Q),Yh(te)},[]),_e=k.useCallback(()=>{const ye=q.current.map(Ae=>Ae.payload),je=re.current.map(Ae=>Ae.payload);q.current=[],re.current=[],V.current=[],X.current=null,z.current=[],G.current=null,se.current=null,ee.current=null,d([]),f([]),g(null),x(null),C(!1);for(const Ae of ye)Wh(Ae);for(const Ae of je)Yh(Ae)},[]),He=k.useCallback(ye=>{B.current==="terminal"?(x(ye),G.current=ye):(g(ye),X.current=ye)},[]),Pe=k.useCallback((ye,je)=>{d(Ae=>{let oe=!1;const H=Ae.map(te=>{if(te.payload.kind!=="url"||te.payload.browserId!==ye)return te;const Ne=je.url??te.payload.url,Re=je.title||te.payload.title||Ne,$e=je.pageId??te.payload.pageId;return Ne===te.payload.url&&Re===(te.payload.title||te.title)&&$e===te.payload.pageId&&Re===te.title?te:(oe=!0,{...te,title:Re,payload:{...te.payload,url:Ne,title:Re,...$e!=null?{pageId:$e}:{}}})});return oe&&(V.current=H),oe?H:Ae})},[]),Ge=k.useCallback((ye,je)=>{f(Ae=>{let oe=!1;const H=Ae.map(te=>{if(te.payload.kind!=="terminal"||te.payload.terminalId!==ye)return te;const Ne=je.title||te.payload.title||te.title,Re=je.cwd??te.payload.cwd;return Ne===te.title&&Re===te.payload.cwd&&Ne===(te.payload.title||te.title)?te:(oe=!0,{...te,title:Ne,payload:{...te.payload,title:Ne,...Re!=null?{cwd:Re}:{}}})});return oe&&(z.current=H),oe?H:Ae})},[]),ct=k.useCallback(()=>{B.current==="terminal"?(f(ye=>ye.length===0?ye:(z.current=ye,ee.current&&(G.current=ee.current),[])),x(null)):(d(ye=>ye.length===0?ye:(V.current=ye,se.current&&(X.current=se.current),[])),g(null),Se()),C(!1)},[Se]),mt=k.useCallback(()=>{if(B.current==="terminal"&&m.length>0){if(l("browser"),c.length>0){n(!0);return}if(V.current.length>0){const $e=V.current,Q=X.current&&$e.some(Z=>Z.id===X.current)?X.current:$e[0].id;d($e),g(Q),X.current=Q,n(!0);return}const te=Is(),Ne=`eb_${Date.now().toString(36)}_${Math.random().toString(36).slice(2,7)}`,Re={id:te,title:"New Tab",payload:{kind:"url",url:"about:blank",title:"New Tab",browserId:Ne}};V.current=[Re],d([Re]),g(Re.id),X.current=Re.id,n(!0);return}const ye=Is(),je=`eb_${Date.now().toString(36)}_${Math.random().toString(36).slice(2,7)}`;let Ae,oe=!1,H=!1;l("browser"),d(te=>{if(te.length>0)return V.current=te,se.current&&(X.current=se.current),H=!0,Ae=null,[];if(V.current.length>0){oe=!0;const Re=V.current;return Ae=X.current&&Re.some(Q=>Q.id===X.current)?X.current:Re[0].id,Re}oe=!0;const Ne={id:ye,title:"New Tab",payload:{kind:"url",url:"about:blank",title:"New Tab",browserId:je}};return V.current=[Ne],Ae=Ne.id,[Ne]}),oe&&n(!0),H?(g(null),C(!1),Se()):Ae!=null&&(g(Ae),X.current=Ae)},[c.length,m.length,Se]),Ct=k.useCallback(()=>{if(B.current==="browser"&&c.length>0){if(l("terminal"),Se(),m.length>0){n(!0);return}if(z.current.length>0){const $e=z.current,Q=G.current&&$e.some(Z=>Z.id===G.current)?G.current:$e[0].id;f($e),x(Q),G.current=Q,n(!0);return}const te=Is(),Ne=`term_${Date.now().toString(36)}_${Math.random().toString(36).slice(2,7)}`;wi(Ne);const Re={id:te,title:"Terminal",payload:{kind:"terminal",terminalId:Ne,title:"Terminal"}};z.current=[Re],f([Re]),x(Re.id),G.current=Re.id,n(!0);return}const ye=Is(),je=`term_${Date.now().toString(36)}_${Math.random().toString(36).slice(2,7)}`;wi(je);let Ae,oe=!1,H=!1;l("terminal"),Se(),f(te=>{if(te.length>0)return z.current=te,ee.current&&(G.current=ee.current),H=!0,Ae=null,[];if(z.current.length>0){oe=!0;const Re=z.current;return Ae=G.current&&Re.some(Q=>Q.id===G.current)?G.current:Re[0].id,Re}oe=!0;const Ne={id:ye,title:"Terminal",payload:{kind:"terminal",terminalId:je,title:"Terminal"}};return z.current=[Ne],Ae=Ne.id,[Ne]}),oe&&n(!0),H?(x(null),C(!1)):Ae!=null&&(x(Ae),G.current=Ae)},[c.length,m.length,Se]),Mt=k.useCallback(ye=>{const je=B.current==="terminal"?m:c;if(je.length<2)return;const Ae=B.current==="terminal"?ee.current:se.current,H=(Math.max(0,je.findIndex(Ne=>Ne.id===Ae))+ye+je.length)%je.length,te=je[H].id;B.current==="terminal"?(x(te),G.current=te):(g(te),X.current=te)},[c,m]),Pt=k.useCallback(ye=>{const Ae=(B.current==="terminal"?m:c)[ye];Ae&&(B.current==="terminal"?(x(Ae.id),G.current=Ae.id):(g(Ae.id),X.current=Ae.id))},[c,m]),Kt=k.useCallback(()=>{if(B.current==="terminal"){const je=`term_${Date.now().toString(36)}_${Math.random().toString(36).slice(2,7)}`;pe({kind:"terminal",terminalId:je,title:"Terminal"});return}const ye=`eb_${Date.now().toString(36)}_${Math.random().toString(36).slice(2,7)}`;pe({kind:"url",url:"about:blank",title:"New Tab",browserId:ye})},[pe]),yt=k.useCallback(ye=>{const je=re.current,Ae=je.findIndex($e=>$e.payload.kind==="terminal"&&$e.payload.terminalId===ye);if(Ae<0){Vh(ye),window.markusDesktop?.terminal?.destroy(ye);return}const oe=je[Ae];if(je.length>1){P(oe.id);return}Vh(ye),window.markusDesktop?.terminal?.destroy(ye);const H=`term_${Date.now().toString(36)}_${Math.random().toString(36).slice(2,7)}`;wi(H);const te=oe.payload.kind==="terminal"&&(oe.payload.title||oe.title)||"Terminal",Ne=oe.payload.kind==="terminal"?oe.payload.cwd:void 0,Re={id:oe.id,title:te,payload:{kind:"terminal",terminalId:H,title:te,cwd:Ne}};z.current=[Re],f([Re]),x(Re.id),G.current=Re.id,B.current!=="terminal"&&l("terminal")},[P]),Ue=k.useCallback(ye=>C(ye),[]),dt=k.useCallback(()=>C(ye=>!ye),[]),Nt=o==="terminal"?m:c,bt=o==="terminal"?y:h,Lt=Nt.find(ye=>ye.id===bt)??Nt[0]??null,ue=Lt?.payload??null,tt=Nt.length>0,st=k.useMemo(()=>({leftCollapsed:t,setLeftCollapsed:J,toggleLeftCollapsed:fe,keyboardPane:E,setKeyboardPane:O,l0FocusPageId:L,setL0FocusPageId:F,rightPanelMode:o,setRightPanelMode:U,switchRightPanelMode:W,rightPanel:ue,rightPanelOpen:tt,rightPanelTabs:Nt,activeRightPanelTabId:Lt?.id??null,openRightPanel:pe,closeRightPanel:_e,closeRightPanelTab:P,setActiveRightPanelTab:He,updateRightPanelBrowserTab:Pe,updateRightPanelTerminalTab:Ge,toggleRightPanel:mt,toggleTerminalPanel:Ct,collapseRightPanelOnly:ct,cycleRightPanelTab:Mt,activateRightPanelTabAt:Pt,openNewRightPanelTab:Kt,handleTerminalExit:yt,rightPanelFullscreen:w,setRightPanelFullscreen:Ue,toggleRightPanelFullscreen:dt,hostAvailable:T,setHostAvailable:S}),[t,J,fe,E,O,L,F,o,U,W,ue,tt,Nt,Lt,pe,_e,P,He,Pe,Ge,mt,Ct,ct,Mt,Pt,Kt,yt,w,Ue,dt,T]);return s.jsx(k3.Provider,{value:st,children:e})}function Lc(){return k.useContext(k3)}function Jl(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 uV(e){let t=e.replace(/\\\[([\s\S]*?)\\\]/g,(n,r)=>`$$${r}$$`);return t=t.replace(/\\\((.+?)\\\)/g,(n,r)=>`$${r}$`),t}const kd="#mention:";function dV(e,t){if(!t||t.length===0)return e.replace(/@\[([^\]]+)\]|@([\w\p{L}\p{N}]+)/gu,(l,c,d)=>{const m=c??d;return`[@${m}](${kd}${encodeURIComponent(m)})`});const n=[...t].sort((l,c)=>c.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 h=e.indexOf("]",l+2);if(h>l+2){const g=e.slice(l+2,h);r+=`[@${g}](${kd}${encodeURIComponent(g)})`,o=h+1;continue}}const c=e.slice(l+1),d=c.toLowerCase(),m=n.find(h=>d.startsWith(h.toLowerCase()));if(m){const h=c.slice(0,m.length);r+=`[@${h}](${kd}${encodeURIComponent(h)})`,o=l+1+m.length;continue}const f=c.match(/^([\w\p{L}\p{N}]+)/u);if(f){const h=f[1];r+=`[@${h}](${kd}${encodeURIComponent(h)})`,o=l+1+h.length;continue}r+="@",o=l+1}return r}const S3="#entity:",mV=new RegExp("(?<!\\[)(?<!\\()(?<!:)(?<!\\/)(?<!\\\\)\\b(tsk|req|proj|dlv|agt|team)_[a-f0-9]{6,}\\b(?!\\]\\(#entity:)","gi"),fV=/`\[([^\]]+)\]\(#entity:((?:tsk|req|proj|dlv|agt|team)_[a-f0-9]{6,})\)`/gi;function pV(e,t){const n=e.slice(0,t),r=n.lastIndexOf("](");return r===-1?!1:n.indexOf(")",r+2)===-1}function hV(e){return e.replace(fV,(t,n,r)=>`[${n}](${S3}${r})`)}function gV(e){return e.replace(mV,(t,n,r)=>pV(e,r)?t:`[${t}](${S3}${t})`)}function bV(e){const t=e.trim();return t.startsWith("@startuml")&&t.endsWith("@enduml")}const xV=/^(graph\s|flowchart\s|sequenceDiagram|classDiagram|stateDiagram|erDiagram|gantt|pie|gitGraph|mindmap|timeline|journey)/m;function yV(e){return xV.test(e.trim())}const vV={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 wV(e){return vV[e.toLowerCase()]??e.charAt(0).toUpperCase()+e.slice(1)}function kV(e){const t=e.match(/language-(\S+)/);return t?t[1]:null}const N3=/^(?:\/|~\/|[A-Za-z]:[\\/]|\\\\)/,C3=/^\.{1,2}\//,SV=/\.[a-zA-Z0-9]{1,12}(?:$|[?#])/,T3=/^[A-Za-z]:[\\/]/,A3=/^\\\\[^\\]/;function E3(e){const t=e.trim();return t?!!(/^file:/i.test(t)||T3.test(t)||A3.test(t)||t.startsWith("~/")||t.startsWith("/")||C3.test(t)):!1}function Kg(e){let t=e.trim();if(/^file:/i.test(t)){try{t=decodeURIComponent(t.replace(/^file:\/\//i,""))}catch{t=t.replace(/^file:\/\//i,"")}/^\/[A-Za-z]:\//.test(t)&&(t=t.slice(1))}return t=t.replace(/\\+/g,"/"),t}function NV(e){return e.replace(/(!?\[[^\]]*]\()((?:[A-Za-z]:|\\\\)[^)\n]*)(\))/g,(t,n,r,o)=>`${n}${r.replace(/\\+/g,"/")}${o}`)}function _3(e){return e.trim().toLowerCase().replace(/[^\p{L}\p{N}\p{M}\s\-_]/gu,"").replace(/\s+/g,"-").replace(/-+/g,"-").replace(/^-|-$/g,"")}function Sd(e,t){if(!e)return e;if(N3.test(e))return e.startsWith("~/")?e:e.replace(/\\/g,"/");if(!t)return e;const r=`${t.replace(/\\/g,"/").replace(/\/+$/,"")}/${e.replace(/^\.\//,"")}`,o=r.split("/"),l=[];for(const d of o)!d||d==="."||(d===".."?l.pop():l.push(d));const c=l.join("/");return r.startsWith("/")?`/${c}`.replace(/^\/+/,"/"):c}function e4(e){const t=e.indexOf("#");return t<0?{path:e}:{path:e.slice(0,t),fragment:decodeURIComponent(e.slice(t+1))}}function t4(e,t){if(!e)return{kind:"passthrough"};const n=e.trim();if(!n||n==="#")return{kind:"passthrough"};if(n.startsWith("#")&&!n.startsWith("#mention:")&&!n.startsWith("#entity:"))return{kind:"fragment",id:decodeURIComponent(n.slice(1))};if(T3.test(n)||A3.test(n)){const{path:l,fragment:c}=e4(n);return{kind:"file",path:Sd(l,t),fragment:c}}if(/^[a-zA-Z][a-zA-Z0-9+.-]*:/.test(n))return/^https?:\/\//i.test(n)||/^mailto:/i.test(n)?{kind:"external",url:n}:/^file:\/\//i.test(n)?{kind:"file",path:Kg(n)}:{kind:"passthrough"};const{path:r,fragment:o}=e4(n);return N3.test(r)?{kind:"file",path:Sd(r,t),fragment:o}:C3.test(r)?{kind:"file",path:Sd(r,t),fragment:o}:r&&SV.test(r)&&!r.includes("://")?{kind:"file",path:Sd(r,t),fragment:o}:{kind:"passthrough"}}function CV(e,t){if(!e||!t)return!1;let n=null;try{n=e.querySelector(`#${CSS.escape(t)}`)}catch{n=null}if(n||(n=e.querySelector(`[id="${t.replace(/"/g,'\\"')}"]`)),!n){const r=e.querySelectorAll("h1,h2,h3,h4,h5,h6");for(const o of r)if(_3(o.textContent||"")===t||o.id===t){n=o;break}}return n?(n.scrollIntoView({behavior:"smooth",block:"start"}),!0):!1}function j3(e){return e.type==="text"?e.value??"":(e.children??[]).map(j3).join("")}function M3(){return e=>{const t=new Map,n=r=>{if(r.type==="element"&&r.tagName&&/^h[1-6]$/.test(r.tagName)){const o=j3(r).trim();let l=_3(o);if(l){const c=t.get(l)??0;t.set(l,c+1),c>0&&(l=`${l}-${c}`),r.properties={...r.properties??{},id:l}}}for(const o of r.children??[])n(o)};n(e)}}function TV(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",c=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:${c.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:${c.h2}em;font-weight:700;color:${d.heading};margin:18px 0 8px;line-height:1.3;`,h3:`font-size:${c.h3}em;font-weight:600;color:${d.heading};margin:14px 0 6px;line-height:1.3;`,h4:`font-size:${c.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 f(h){h.removeAttribute("class");const g=h.tagName.toLowerCase();if(g==="pre"){h.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 y=h.querySelector("code");y&&(y.removeAttribute("class"),y.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"?h.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]&&h.setAttribute("style",m[g]),Array.from(h.children).forEach(f)}return r.removeAttribute("class"),Array.from(r.children).forEach(h=>f(h)),`<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 Wg(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 AV(e,t,n,r){const o=TV(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 Wg(n),method:"text"}}}const R3="markus-copy-typography",n4={fontFamily:"default",fontSize:15,headingScale:"standard"};function L3(){try{const e=localStorage.getItem(R3);if(e)return{...n4,...JSON.parse(e)}}catch{}return n4}function EV(e){localStorage.setItem(R3,JSON.stringify(e))}function _V(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 jV({onClose:e}){const{t}=ft("common"),[n,r]=k.useState(L3);k.useEffect(()=>{EV(n)},[n]);const o=k.useCallback((l,c)=>{r(d=>({...d,[l]:c}))},[]);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))})]})]})}class MV extends k.Component{state={error:null};static getDerivedStateFromError(t){return{error:t}}componentDidUpdate(t){this.state.error&&this.props.resetKeys&&!RV(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 RV(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 LV=k.lazy(()=>Gr(()=>Promise.resolve().then(()=>G3),void 0).then(e=>({default:e.MarkdownMessage}))),OV={file:{icon:"📄",color:"bg-green-500/10 text-green-600"},directory:{icon:"📁",color:"bg-blue-500/10 text-blue-600"}},r4={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 DV({item:e,onClose:t,onOpenInPage:n}){const{t:r}=ft(["agent","common"]),o=OV[e.type]??{icon:"📎",color:"bg-surface-elevated text-fg-secondary"},l=r4[e.status]??r4.active,c=/^https?:\/\//i.test(e.reference??"");k.useEffect(()=>{const m=f=>{f.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(LV,{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}),c?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:()=>{Ee.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"?Sa.createPortal(d,document.body):d}const IV={tsk:"task",req:"requirement",proj:"project",dlv:"deliverable",agt:"agent",team:"team"};function O3(e){return{task:"task",requirement:"requirement",project:"project",deliverable:"deliverable",agent:"agent",team:"team"}[e]}const D3={task:"📋",requirement:"📝",project:"📁",deliverable:"📦",agent:"🤖",team:"👥"},I3={task:"Task",requirement:"Requirement",project:"Project",deliverable:"Deliverable",agent:"Agent",team:"Team"},PV=/^(tsk|req|proj|dlv|agt|team)_[a-f0-9]{6,}$/i;function b0(e){return PV.test(e.trim())}function zV(e){const t=e.split("_")[0]?.toLowerCase();return t?IV[t]:void 0}function P3(e){e.startsWith("tsk_")?it.navigate(de.WORK,{openTask:e}):e.startsWith("req_")?it.navigate(de.WORK,{openRequirement:e}):e.startsWith("proj_")?it.navigate(de.WORK,{projectId:e}):e.startsWith("dlv_")?it.navigate(de.DELIVERABLES,{openDeliverable:e}):e.startsWith("agt_")?it.navigate(de.TEAM,{agentId:e}):e.startsWith("team_")&&it.navigate(de.TEAM,{selectTeam:e})}const Qp=new Map,Nd=new Map;async function BV(e,t){const n={id:e,type:t,title:e,loading:!1};try{switch(t){case"task":{const r=await Ee.tasks.get(e);return{...n,title:r.task.title,status:r.task.status}}case"requirement":{const r=await Ee.requirements.get(e);return{...n,title:r.requirement.title,status:r.requirement.status}}case"project":{const r=await Ee.projects.get(e);return{...n,title:r.project.name,status:r.project.status,summary:r.project.description}}case"deliverable":{const r=await Ee.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 Ee.agents.get(e);return{...n,title:r.name,summary:r.role}}case"team":{const o=(await Ee.teams.list()).teams.find(l=>l.id===e);return{...n,title:o?.name??e,notFound:!o}}}}catch{}return{...n,notFound:!0}}function z3(e,t){const n=t??zV(e),[r,o]=k.useState(()=>Qp.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=Qp.get(e);if(l){o(l);return}o(m=>({...m,type:n,loading:!0}));let c=!0,d=Nd.get(e);return d||(d=BV(e,n),Nd.set(e,d)),d.then(m=>{Qp.set(e,m),Nd.delete(e),c&&o(m)}).catch(()=>{Nd.delete(e),c&&o({id:e,type:n,title:e,loading:!1,notFound:!0})}),()=>{c=!1}},[e,n]),r}function B3(e){const t=(e.split("_")[0]?.length??3)+1;return e.length>t+8?`${e.slice(0,t+8)}…`:e}function lc({id:e,type:t,label:n}){const r=z3(e,t),o=Lc(),l=D3[r.type]??"🔗",c=n??(r.loading||r.notFound?B3(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}P3(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:`${I3[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:c})]})}function $V({id:e,type:t,label:n}){const r=z3(e,t),[o,l]=k.useState(!1),c=Lc(),d=D3[r.type]??"🔗",m=()=>{if(r.type==="deliverable"&&r.deliverable){if(c?.hostAvailable){c.openRightPanel({kind:"deliverable",deliverable:r.deliverable});return}l(!0);return}P3(e)},f=r.loading?B3(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:I3[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:f}),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(DV,{item:r.deliverable,onClose:()=>l(!1),onOpenInPage:h=>{l(!1),it.navigate(de.DELIVERABLES,{openDeliverable:h})}})]})}k.lazy(()=>Gr(()=>Promise.resolve().then(()=>G3),void 0).then(e=>({default:e.MarkdownMessage})));const HV=k.lazy(()=>Gr(()=>import("./ContentRenderer-Bb_drUpO.js"),[]).then(e=>({default:e.ContentRenderer})));let No=[],a4=60;function UV(e){const t=k.useRef(e);t.current=e;const[n]=k.useState(()=>++a4);return k.useEffect(()=>{const r=()=>t.current();No.push(r);const o=l=>{l.key==="Escape"&&No[No.length-1]===r&&(l.preventDefault(),r())};return window.addEventListener("keydown",o,!0),()=>{window.removeEventListener("keydown",o,!0),No=No.filter(l=>l!==r),No.length===0&&(a4=60)}},[]),n}const s4=500,$s=new Map,x0=new Set,qd=new Map;let Gd=null;function FV(){if($s.size<=s4)return;const e=$s.size-s4,t=$s.keys();for(let n=0;n<e;n++){const{value:r,done:o}=t.next();if(o)break;$s.delete(r)}}function i4(e,t){$s.delete(e),$s.set(e,t),FV()}function o4(e){const t=qd.get(e);if(t)for(const n of t)n()}function qV(){Gd=null;const e=[...x0];x0.clear(),e.length!==0&&Ee.files.check(e).then(({results:t})=>{for(const[n,r]of Object.entries(t))i4(n,r),o4(n)}).catch(()=>{for(const t of e)i4(t,{exists:!1,isFile:!1,type:"unknown"}),o4(t)})}function GV(e){$s.has(e)||x0.has(e)||(x0.add(e),Gd&&clearTimeout(Gd),Gd=setTimeout(qV,30))}function VV(e,t){let n=qd.get(e);return n||(n=new Set,qd.set(e,n)),n.add(t),()=>{n.delete(t),n.size===0&&qd.delete(e)}}function KV(e){const t=k.useCallback(o=>VV(e,o),[e]),n=k.useCallback(()=>$s.get(e),[e]),r=k.useSyncExternalStore(t,n,n);return k.useEffect(()=>{GV(e)},[e]),r}const WV=/^(?:\/[\w.\-@+]+(?:\/[\w.\-@+ ]*)*|~\/[\w.\-@+]+(?:\/[\w.\-@+ ]*)*|[A-Za-z]:(?:\\|\/)[\w.\-@+ ]+(?:(?:\\|\/)[\w.\-@+ ]*)*|\.\.?\/[\w.\-@+]+(?:\/[\w.\-@+ ]*)*)$/;function YV(e){return e.length<2||e.length>500?!1:WV.test(e)}function XV({filePath:e,onClose:t}){const n=UV(t),[r,o]=k.useState(!0),[l,c]=k.useState(null),[d,m]=k.useState(""),[f,h]=k.useState(""),[g,y]=k.useState(""),[x,w]=k.useState(""),[C,T]=k.useState("");k.useEffect(()=>{o(!0),c(null),Ee.files.preview(e).then(E=>{m(typeof E.content=="string"?E.content:""),h(E.type),y(E.name),w(E.mimeType||""),T(E.streamUrl||(E.path?Ee.files.streamUrl(E.path):"")||(E.type==="audio"||E.type==="video"?Ee.files.streamUrl(e):""))}).catch(E=>{c(String(E?.message||E))}).finally(()=>{o(!1)})},[e]);const S=g||e.split(/[/\\]/).pop()||e;return Sa.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:E=>E.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:S}),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:()=>Ee.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&&f==="image"&&d&&s.jsx("div",{className:"flex justify-center",children:s.jsx("img",{src:`data:${x||"image/png"};base64,${d}`,alt:S,className:"max-w-full rounded"})}),!r&&!l&&f==="audio"&&C&&s.jsx("audio",{controls:!0,preload:"metadata",src:C,className:"w-full"}),!r&&!l&&f==="video"&&C&&s.jsx("video",{controls:!0,preload:"metadata",src:C,className:"w-full max-h-[60vh] rounded-lg bg-black"}),!r&&!l&&(f==="binary"||!d&&f!=="image"&&f!=="audio"&&f!=="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:()=>{Ee.files.reveal(e)},children:"Reveal in file explorer"})]}),!r&&!l&&d&&f!=="image"&&f!=="audio"&&f!=="video"&&f!=="binary"&&s.jsx(k.Suspense,{fallback:s.jsx("div",{className:"text-xs text-fg-tertiary",children:"Loading…"}),children:s.jsx(HV,{content:d,format:f==="text"?"text":f,className:"text-sm"})})]})]})}),document.body)}function QV({path:e}){const t=KV(e),[n,r]=k.useState(null),o=Lc(),l=t?.exists??!1,c=t?.type==="markdown"||t?.type==="html"||t?.type==="json"||t?.type==="text"||t?.type==="image"||t?.type==="audio"||t?.type==="video",d=k.useCallback(h=>{if(h.preventDefault(),h.stopPropagation(),!!l)if(c){if(o?.hostAvailable){o.openRightPanel({kind:"file",path:e});return}r(e)}else Ee.files.reveal(e)},[l,c,e,o]),m="inline w-3 h-3 align-[-0.125em]",f=c?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:c?"Click to preview":"Click to reveal in file explorer",role:"button",tabIndex:0,children:[s.jsxs("span",{className:"whitespace-nowrap",children:[f,e.charAt(0)]}),e.slice(1)]}),n&&s.jsx(XV,{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 Zp=null;function ZV(){return Zp||(Zp=Gr(()=>import("./mermaid.core-N5tL3hIv.js").then(e=>e.b9),__vite__mapDeps([0,1])).then(e=>(e.default.initialize({startOnLoad:!1,securityLevel:"loose",fontFamily:"inherit"}),e))),Zp}function JV(){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 eK(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 tK(){return JV()}function nK(){return k.useSyncExternalStore(eK,tK)}function $3({code:e}){const t=k.useRef(null),[n,r]=k.useState(null),[o,l]=k.useState(!0),c=k.useId(),d=k.useRef(0),m=k.useRef(null),f=nK();return k.useEffect(()=>{if(!e.trim()||m.current&&m.current.code===e&&m.current.dark===f)return;let h=!1;return l(!0),r(null),d.current+=1,(async()=>{try{const g=await ZV();if(h)return;g.default.initialize({startOnLoad:!1,theme:f?"dark":"default",securityLevel:"loose",fontFamily:"inherit"});const y=`mermaid-${c.replace(/:/g,"")}-${d.current}`,{svg:x}=await g.default.render(y,e.trim());if(h)return;t.current&&(t.current.innerHTML=x,m.current={code:e,dark:f})}catch(g){h||r(g instanceof Error?g.message:String(g))}finally{h||l(!1)}})(),()=>{h=!0}},[e,c,f]),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 rK="/assets/viz-global-C_AyN6D9.js";let Cd=!1,Jp=null;function aK(){return Cd?Promise.resolve():new Promise((e,t)=>{const n=document.querySelector("script[data-plantuml-viz]");if(n){globalThis.Viz?(Cd=!0,e()):(n.addEventListener("load",()=>{Cd=!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=rK,r.onload=()=>{Cd=!0,e()},r.onerror=()=>t(new Error("Failed to load viz-global.js")),document.head.appendChild(r)})}function sK(){return Jp||(Jp=aK().then(()=>Gr(()=>import("./plantuml-DezRDxd4.js"),[]))),Jp}let l4=Promise.resolve();function iK(e,t){const n=l4.then(()=>new Promise((r,o)=>{sK().then(({renderToString:l})=>{const c=e.split(/\r\n|\r|\n/);l(c,r,o,{dark:t})}).catch(o)}));return l4=n.then(()=>{},()=>{}),n}function oK(){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 lK(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 cK(){return k.useSyncExternalStore(lK,()=>oK())}function H3({code:e}){const[t,n]=k.useState(null),[r,o]=k.useState(null),[l,c]=k.useState(!0),d=k.useRef(null),m=cK();return k.useEffect(()=>{if(!e.trim()||d.current&&d.current.code===e&&d.current.dark===m)return;let f=!1;return c(!0),o(null),iK(e.trim(),m).then(h=>{f||(n(h),d.current={code:e,dark:m})}).catch(h=>{f||o(h instanceof Error?h.message:String(h))}).finally(()=>{f||c(!1)}),()=>{f=!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 Xh({code:e,language:t,children:n}){const{t:r}=ft("common"),[o,l]=k.useState("rendered"),[c,d]=k.useState(!1),m=k.useCallback(async()=>{await Wg(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:c?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 uK=[$3,H3];function dK(e){for(const t of k.Children.toArray(e))if(k.isValidElement(t)&&typeof t.props?.className=="string"){const n=t.props.className;return kV(n)}return null}function cc(e){if(typeof e=="string")return e;if(typeof e=="number")return String(e);if(!e)return"";if(Array.isArray(e))return e.map(cc).join("");if(k.isValidElement(e)){const t=e.props;return cc(t.children)}return""}function mK({children:e}){const{t}=ft("common"),n=dK(e),r=k.useRef(null),[o,l]=k.useState(!1),[c,d]=k.useState("rendered"),m=k.useCallback(async()=>{let h;c==="source"?h=cc(e):h=r.current?.querySelector("code")?.textContent??"";try{await navigator.clipboard.writeText(h),l(!0),setTimeout(()=>l(!1),1800)}catch{}},[c,e]);if(k.Children.toArray(e).some(h=>k.isValidElement(h)&&uK.includes(h.type))){const h=cc(e),g=n==="mermaid"||n==="plantuml"?n:"diagram";return s.jsx(Xh,{code:h,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:wV(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 ${c==="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 ${c==="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:[c==="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,h=>k.isValidElement(h)?k.cloneElement(h,{style:{background:"transparent",padding:0}}):h)}):s.jsx("pre",{className:"p-3 overflow-x-auto text-xs font-mono text-fg-secondary whitespace-pre-wrap break-words",children:cc(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 c4="#mention:",y0="#entity:",fK=/^\[([^\]]+)\]\(#entity:((tsk|req|proj|dlv|agt|team)_[a-f0-9]{6,})\)$/i,U3=/^(workflow|task|requirement|project|deliverable|agent|team):(.+)$/,Qh="text-brand-500 hover:text-brand-500 underline break-all cursor-pointer";function Zh(e){return e.type==="text"?e.value??"":(e.children??[]).map(Zh).join("")}function pK(e){return e.type==="text"&&(e.value??"").trim()===""}function hK(e){if(!e?.children)return null;const t=e.children.filter(r=>!pK(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=Zh(n);if(r.startsWith(y0))return{id:r.slice(y0.length)};const l=r.match(U3);return l&&l[1]!=="workflow"?{id:l[2],type:O3(l[1]),label:o}:null}if(n.type==="element"&&n.tagName==="code"){const r=Zh(n).trim();if(b0(r))return{id:r}}if(n.type==="text"){const r=(n.value??"").trim();if(b0(r))return{id:r}}return null}const gK={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")||bV(r))return s.jsx(Xh,{code:r,language:"plantuml",children:s.jsx(H3,{code:r})});if(t?.includes("language-mermaid")||!t&&yV(r))return s.jsx(Xh,{code:r,language:"mermaid",children:s.jsx($3,{code:r})});if(t?.includes("language-"))return s.jsx("code",{className:`${t} text-fg-secondary font-mono text-xs`,children:e});if(b0(n))return s.jsx(lc,{id:n.trim()});const o=n.match(fK);return o?s.jsx(lc,{id:o[2],label:o[1]}):YV(n)?s.jsx(QV,{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(mK,{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,className:Qh,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})},bK=/\.(png|jpe?g|gif|webp|svg|bmp|ico)$/i;function xK(e){const t=Kg(e);return E3(e)&&bK.test(t.split("?")[0]??t)}function yK(e,t){const n=Kg(e);if(n.startsWith("/")||n.startsWith("~/")||/^[A-Za-z]:\//.test(n)||n.startsWith("//"))return n;if((n.startsWith("./")||n.startsWith("../"))&&t){const o=((t.replace(/\\/g,"/").endsWith("/")?t.replace(/\\/g,"/"):`${t.replace(/\\/g,"/")}/`)+n).split("/"),l=[];for(const c of o)c===".."?l.pop():c!=="."&&c!==""&&l.push(c);return"/"+l.join("/")}return n}function vK(e){return`/api/files/image?path=${encodeURIComponent(e)}`}const Co=new Map;function wK({src:e,alt:t,onPreview:n,basePath:r}){const o=k.useMemo(()=>xK(e)?vK(yK(e,r)):e,[e,r]),l=o.startsWith("/api/files/image?"),c=Co.get(o),[d,m]=k.useState(c??(l?null:o)),[f,h]=k.useState(!!c),[g,y]=k.useState(!1),[x,w]=k.useState(null),[C,T]=k.useState(0),S=k.useRef(0),E=k.useCallback(()=>{Co.delete(o),y(!1),w(null),h(!1),m(l?null:`${o}${o.includes("?")?"&":"?"}retry=${Date.now()}`),T(j=>j+1)},[o,l]);return k.useEffect(()=>{if(!l)return;const j=Co.get(o);if(j){m(j),h(!0),y(!1),w(null);return}const L=++S.current;y(!1),w(null),h(!1),m(null),(async()=>{try{const I=await fetch(o,{credentials:"same-origin"});if(L!==S.current)return;if(!I.ok){let V=`HTTP ${I.status}`;try{const X=await I.json();X.error&&(V=X.error)}catch{}throw new Error(V)}const O=await I.blob();if(L!==S.current)return;if(O.size===0)throw new Error("Empty image response");if(O.type&&!O.type.startsWith("image/")&&!O.type.includes("octet-stream"))throw new Error(`Unexpected content-type: ${O.type}`);const F=URL.createObjectURL(O);Co.set(o,F),m(F),h(!0),y(!1),w(null)}catch(I){if(L!==S.current)return;const O=I instanceof Error?I.message:String(I);console.warn("[MarkdownImage] failed to load local image",o,I),w(O),y(!0),h(!1)}})()},[l,o,C]),k.useEffect(()=>{l||(m(o),h(!!Co.get(o)),y(!1),w(null))},[o,l,C]),g?s.jsxs("button",{type:"button",onClick:E,title:x??"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",x?` (${x})`:""]})]}):s.jsxs("span",{className:"inline-block align-middle max-w-full",children:[!f&&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||Co.set(o,o),h(!0)},onError:()=>{w("Image decode failed"),y(!0)},onClick:()=>n?.(d),className:`max-w-full h-auto rounded-lg cursor-pointer hover:opacity-90 transition-opacity my-1${f?"":" absolute opacity-0 pointer-events-none"}`,style:{maxHeight:"400px",objectFit:"contain"}}):null]})}async function u4(e){const t=await fetch(e);if(!t.ok)throw new Error(`Failed to fetch image (${t.status})`);return t.blob()}async function kK(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(c=>c?o(c):l(new Error("PNG encode failed")),"image/png")})}function SK(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 F3({src:e,onClose:t}){const{t:n}=ft("common"),[r,o]=k.useState(null),[l,c]=k.useState(null);Ho(!0),k.useEffect(()=>{const g=y=>{y.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){c("copy");try{const y=await u4(e),x=await kK(y);await navigator.clipboard.write([new ClipboardItem({"image/png":x})]),d(n("imageCopied"))}catch{d(n("imageCopyFailed"))}finally{c(null)}}},[l,d,e,n]),f=k.useCallback(async g=>{if(g.stopPropagation(),!l){c("download");try{const y=await u4(e),x=URL.createObjectURL(y),w=document.createElement("a");w.href=x,w.download=SK(e,y),document.body.appendChild(w),w.click(),w.remove(),URL.revokeObjectURL(x),d(n("imageDownloaded"))}catch{d(n("imageDownloadFailed"))}finally{c(null)}}},[l,d,e,n]),h="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 Sa.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:h,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:h,onClick:f,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 q3(e={}){const{onMentionClick:t,basePath:n,onImagePreview:r,contentRef:o,hostAvailable:l,openRightPanel:c}=e,d=k.useCallback((m,f)=>{const h=t4(f,n);if(h.kind!=="passthrough"){if(m.preventDefault(),m.stopPropagation(),h.kind==="fragment"){CV(o?.current??null,h.id);return}if(h.kind==="file"){l&&c?c({kind:"file",path:h.path,title:h.path.split(/[/\\]/).pop()}):Ee.files.reveal(h.path).catch(()=>{});return}if(h.kind==="external"){if(l&&c&&/^https?:\/\//i.test(h.url)){c({kind:"url",url:h.url,title:h.url});return}_i(h.url)}}},[n,o,l,c]);return k.useMemo(()=>({...gK,img:({src:m,alt:f})=>s.jsx(wK,{src:m??"",alt:f,onPreview:r,basePath:n},m??""),p:({children:m,node:f})=>{const h=hK(f);return h?s.jsx($V,{id:h.id,type:h.type,label:h.label}):s.jsx("p",{className:"mb-2 last:mb-0 leading-relaxed text-fg-secondary",children:m})},a:({href:m,children:f})=>{if(m?.startsWith(c4)){const g=decodeURIComponent(m.slice(c4.length));return s.jsx("span",{className:`text-brand-500 font-medium${t?" cursor-pointer hover:underline":""}`,onClick:t?y=>{y.preventDefault(),y.stopPropagation(),t(g,y)}:void 0,title:g,children:f})}if(m?.startsWith(y0))return s.jsx(lc,{id:m.slice(y0.length)});{const g=m?.match(U3);if(g){const[,y,x]=g;if(y==="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:C=>{C.preventDefault(),C.stopPropagation(),it.navigate(de.WORK,{boardType:"workflows"})},title:`workflow: ${x}`,children:[s.jsx("span",{className:"text-[10px]",children:"⚙️"}),s.jsx("span",{children:f})]});const w=O3(y);if(w)return s.jsx(lc,{id:x,type:w,label:f})}}if(m&&b0(m))return s.jsx(lc,{id:m.trim(),label:f});const h=t4(m,n);return h.kind==="fragment"||h.kind==="file"||h.kind==="external"?s.jsx("a",{href:m,className:Qh,onClick:g=>d(g,m),title:h.kind==="fragment"?`#${h.id}`:h.kind==="file"?h.path:h.url,children:f}):s.jsx("a",{href:m,className:Qh,onClick:g=>{yc()&&m&&!/^[a-zA-Z][a-zA-Z0-9+.-]*:/.test(m)&&g.preventDefault()},children:f})}}),[t,n,r,d])}const d4=[q5,Vk,Kk],m4=[M3,[n3,{strict:"ignore"}],[v3,{detect:!0,ignoreMissing:!0}]];function f4(e){return/^(deliverable|task|requirement|project|agent|team|workflow):/i.test(e)||E3(e)?e:x5(e)}const NK=/ thinking([\s\S]*?)(<\/think>|$)/g;function CK(e){const t=[];let n=e.replace(NK,(r,o)=>{const l=o.trim();return l&&t.push(l),""});return n=n.replace(/<\/think>/g,"").replace(/ thinking/g,""),{thinking:t,rest:n.trim()}}function TK(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 AK({content:e,contentRef:t}){const{t:n}=ft("common"),[r,o]=k.useState(!1),[l,c]=k.useState(!1),[d,m]=k.useState(!1),[f,h]=k.useState(null),g=k.useRef(null),y=TK();k.useEffect(()=>{if(!r)return;const T=S=>{g.current&&!g.current.contains(S.target)&&(o(!1),c(!1),m(!1))};return document.addEventListener("mousedown",T),()=>document.removeEventListener("mousedown",T)},[r]);const x=k.useCallback(T=>{h(T),setTimeout(()=>h(null),1500)},[]),w=async()=>{const T=await Wg(e);x(n(T?"markdown.copied":"markdown.failed")),o(!1)},C=async T=>{const S=t.current?.firstElementChild;if(!S)return;const E=L3(),j=_V(E),L=await AV(S,T,e,{fontFamily:j.fontFamily,fontSize:j.fontSize,headingScales:j.headingScales}),I=n(T==="light"?"markdown.themeLight":"markdown.themeDark");x(L.ok?L.method==="html"?n("markdown.htmlCopied",{theme:I}):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:[f&&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:f}),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(jV,{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:()=>c(!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:()=>c(!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(y?"markdown.copyMdSourceShort":"markdown.copyMdSource")]}),s.jsxs("button",{onClick:()=>C("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(y?"markdown.copyHtmlLightShort":"markdown.copyHtmlLight")]}),s.jsxs("button",{onClick:()=>C("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(y?"markdown.copyHtmlDarkShort":"markdown.copyHtmlDark")]})]})})]})}const Er=k.memo(function({content:t,className:n="",onMentionClick:r,knownNames:o,basePath:l}){const{thinking:c,rest:d}=CK(t),m=k.useRef(null),[f,h]=k.useState(null),g=Lc(),y=k.useCallback(C=>{let T=Jl(C,uV);return T=Jl(T,NV),T=Jl(T,hV),T=Jl(T,gV),T=Jl(T,S=>dV(S,o)),T},[o]),x=k.useMemo(()=>y(d),[d,y]),w=q3({onMentionClick:r,basePath:l,onImagePreview:h,contentRef:m,hostAvailable:g?.hostAvailable,openRightPanel:g?.openRightPanel});return s.jsxs("div",{className:"relative group/md",children:[s.jsx(AK,{content:t,contentRef:m}),s.jsx("div",{ref:m,children:s.jsx(MV,{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:[c.length>0&&(()=>{const C=c.join(`
648
+ `,1;if(tl>1e5&&tl>ht.index*3)throw new Error("potential infinite loop, way more iterations than matches");return an+=Dt,Dt.length}const Yn=ir(We);if(!Yn)throw je(vt.replace("{}",We)),new Error('Unknown language: "'+We+'"');const Bc=Z(Yn);let Hi="",Et=rn||Bc;const $c={},In=new at.__emitter(at);el();let an="",ls=0,Ma=0,tl=0,cs=!1;try{if(Yn.__emitTokens)Yn.__emitTokens(wt,In);else{for(Et.matcher.considerAll();;){tl++,cs?cs=!1:Et.matcher.considerAll(),Et.matcher.lastIndex=Ma;const nt=Et.matcher.exec(wt);if(!nt)break;const ht=wt.substring(Ma,nt.index),Dt=$i(ht,nt);Ma=nt.index+Dt}$i(wt.substring(Ma))}return In.finalize(),Hi=In.toHTML(),{language:We,value:Hi,relevance:ls,illegal:!1,_emitter:In,_top:Et}}catch(nt){if(nt.message&&nt.message.includes("Illegal"))return{language:We,value:M(wt),illegal:!0,relevance:0,_illegalBy:{message:nt.message,index:Ma,context:wt.slice(Ma-100,Ma+100),mode:nt.mode,resultSoFar:Hi},_emitter:In};if(rt)return{language:We,value:M(wt),illegal:!1,relevance:0,errorRaised:nt,_emitter:In,_top:Et};throw nt}}function Di(We){const wt={value:M(We),illegal:!1,relevance:0,_top:Fe,_emitter:new at.__emitter(at)};return wt._emitter.addText(We),wt}function Ii(We,wt){wt=wt||at.languages||Object.keys(ce);const Ht=Di(We),rn=wt.filter(ir).filter(is).map(hn=>Ea(hn,We,!1));rn.unshift(Ht);const Rn=rn.sort((hn,Rr)=>{if(hn.relevance!==Rr.relevance)return Rr.relevance-hn.relevance;if(hn.language&&Rr.language){if(ir(hn.language).supersetOf===Rr.language)return 1;if(ir(Rr.language).supersetOf===hn.language)return-1}return 0}),[tr,Mr]=Rn,gr=tr;return gr.secondBest=Mr,gr}function ma(We,wt,Ht){const rn=wt&&Te[wt]||Ht;We.classList.add("hljs"),We.classList.add(`language-${rn}`)}function Mn(We){let wt=null;const Ht=xn(We);if(kt(Ht))return;if(Ys("before:highlightElement",{el:We,language:Ht}),We.dataset.highlighted){console.log("Element previously highlighted. To highlight again, first unset `dataset.highlighted`.",We);return}if(We.children.length>0&&(at.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(We)),at.throwUnescapedHTML))throw new Ye("One of your code blocks includes unescaped HTML.",We.innerHTML);wt=We;const rn=wt.textContent,Rn=Ht?wn(rn,{language:Ht,ignoreIllegals:!0}):Ii(rn);We.innerHTML=Rn.value,We.dataset.highlighted="yes",ma(We,Ht,Rn.language),We.result={language:Rn.language,re:Rn.relevance,relevance:Rn.relevance},Rn.secondBest&&(We.secondBest={language:Rn.secondBest.language,relevance:Rn.secondBest.relevance}),Ys("after:highlightElement",{el:We,result:Rn,text:rn})}function er(We){at=le(at,We)}const ss=()=>{Pi(),oe("10.6.0","initHighlighting() deprecated. Use highlightAll() now.")};function Qo(){Pi(),oe("10.6.0","initHighlightingOnLoad() deprecated. Use highlightAll() now.")}let Dc=!1;function Pi(){function We(){Pi()}if(document.readyState==="loading"){Dc||window.addEventListener("DOMContentLoaded",We,!1),Dc=!0;return}document.querySelectorAll(at.cssSelector).forEach(Mn)}function Ic(We,wt){let Ht=null;try{Ht=wt(K)}catch(rn){if(je("Language definition for '{}' could not be registered.".replace("{}",We)),rt)je(rn);else throw rn;Ht=Fe}Ht.name||(Ht.name=We),ce[We]=Ht,Ht.rawDefinition=wt.bind(null,K),Ht.aliases&&_a(Ht.aliases,{languageName:We})}function Ws(We){delete ce[We];for(const wt of Object.keys(Te))Te[wt]===We&&delete Te[wt]}function Zo(){return Object.keys(ce)}function ir(We){return We=(We||"").toLowerCase(),ce[We]||ce[Te[We]]}function _a(We,{languageName:wt}){typeof We=="string"&&(We=[We]),We.forEach(Ht=>{Te[Ht.toLowerCase()]=wt})}function is(We){const wt=ir(We);return wt&&!wt.disableAutodetect}function os(We){We["before:highlightBlock"]&&!We["before:highlightElement"]&&(We["before:highlightElement"]=wt=>{We["before:highlightBlock"](Object.assign({block:wt.el},wt))}),We["after:highlightBlock"]&&!We["after:highlightElement"]&&(We["after:highlightElement"]=wt=>{We["after:highlightBlock"](Object.assign({block:wt.el},wt))})}function Dn(We){os(We),ze.push(We)}function Pc(We){const wt=ze.indexOf(We);wt!==-1&&ze.splice(wt,1)}function Ys(We,wt){const Ht=We;ze.forEach(function(rn){rn[Ht]&&rn[Ht](wt)})}function ja(We){return oe("10.7.0","highlightBlock will be removed entirely in v12.0"),oe("10.7.0","Please use highlightElement now."),Mn(We)}Object.assign(K,{highlight:wn,highlightAuto:Ii,highlightAll:Pi,highlightElement:Mn,highlightBlock:ja,configure:er,initHighlighting:ss,initHighlightingOnLoad:Qo,registerLanguage:Ic,unregisterLanguage:Ws,listLanguages:Zo,getLanguage:ir,registerAliases:_a,autoDetection:is,inherit:le,addPlugin:Dn,removePlugin:Pc}),K.debugMode=function(){rt=!1},K.safeMode=function(){rt=!0},K.versionString=Ie,K.regex={concat:C,lookahead:y,either:S,optional:w,anyNumberOfTimes:x};for(const We in Ct)typeof Ct[We]=="object"&&e(Ct[We]);return Object.assign(K,Ct),K},Qe=Ve({});return Qe.newInstance=()=>Ve({}),Xp=Qe,Qe.HighlightJS=Qe,Qe.default=Qe,Xp}var WG=KG();const YG=Tc(WG),Z2={},XG="hljs-";function QG(e){const t=YG.newInstance();return e&&l(e),{highlight:n,highlightAuto:r,listLanguages:o,register:l,registerAlias:c,registered:d};function n(m,f,h){const g=h||Z2,y=typeof g.prefix=="string"?g.prefix:XG;if(!t.getLanguage(m))throw new Error("Unknown language: `"+m+"` is not registered");t.configure({__emitter:ZG,classPrefix:y});const x=t.highlight(f,{ignoreIllegals:!0,language:m});if(x.errorRaised)throw new Error("Could not highlight with `Highlight.js`",{cause:x.errorRaised});const w=x._emitter.root,C=w.data;return C.language=x.language,C.relevance=x.relevance,w}function r(m,f){const g=(f||Z2).subset||o();let y=-1,x=0,w;for(;++y<g.length;){const C=g[y];if(!t.getLanguage(C))continue;const T=n(C,m,f);T.data&&T.data.relevance!==void 0&&T.data.relevance>x&&(x=T.data.relevance,w=T)}return w||{type:"root",children:[],data:{language:void 0,relevance:x}}}function o(){return t.listLanguages()}function l(m,f){if(typeof m=="string")t.registerLanguage(m,f);else{let h;for(h in m)Object.hasOwn(m,h)&&t.registerLanguage(h,m[h])}}function c(m,f){if(typeof m=="string")t.registerAliases(typeof f=="string"?f:[...f],{languageName:m});else{let h;for(h in m)if(Object.hasOwn(m,h)){const g=m[h];t.registerAliases(typeof g=="string"?g:[...g],{languageName:h})}}}function d(m){return!!t.getLanguage(m)}}class ZG{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(c,d){return d?c+"_".repeat(d):n.options.classPrefix+c}),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 JG={};function v3(e){const t=e||JG,n=t.aliases,r=t.detect||!1,o=t.languages||VG,l=t.plainText,c=t.prefix,d=t.subset;let m="hljs";const f=QG(o);if(n&&f.registerAlias(n),c){const h=c.indexOf("-");m=h===-1?c:c.slice(0,h)}return function(h,g){D0(h,"element",function(y,x,w){if(y.tagName!=="code"||!w||w.type!=="element"||w.tagName!=="pre")return;const C=eV(y);if(C===!1||!C&&!r||C&&l&&l.includes(C))return;Array.isArray(y.properties.className)||(y.properties.className=[]),y.properties.className.includes(m)||y.properties.className.unshift(m);const T=Zk(y,{whitespace:"pre"});let S;try{S=C?f.highlight(C,T,{prefix:c}):f.highlightAuto(T,{prefix:c,subset:d})}catch(E){const j=E;if(C&&/Unknown language/.test(j.message)){g.message("Cannot highlight as `"+C+"`, it’s not registered",{ancestors:[w,y],cause:j,place:y.position,ruleId:"missing-language",source:"rehype-highlight"});return}throw j}!C&&S.data&&S.data.language&&y.properties.className.push("language-"+S.data.language),S.children.length>0&&(y.children=S.children)})}}function eV(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 Vg=new Set;function wi(e){e&&Vg.add(e)}function Vh(e){e&&Vg.delete(e)}const w3="markus_right_panel_v1",tV=10,Kh=new Map;function nV(e,t=3e3){Kh.set(e,Date.now()+t)}function rV(e){const t=Kh.get(e);return t==null?!1:Date.now()>t?(Kh.delete(e),!1):!0}function aV(e){return e.kind==="terminal"}function Zl(e){if(e.kind==="file")return`file:${e.path}`;if(e.kind==="url")return`url:${e.browserId||e.url}`;if(e.kind==="terminal")return`terminal:${e.terminalId}`;const t=e.deliverable;return`deliverable:${t.id||`${t.reference||""}|${t.title||""}|${t.summary?.slice(0,48)||""}`||"unknown"}`}function J2(e){return e.kind==="deliverable"?e.deliverable.title||e.deliverable.reference||"Deliverable":e.kind==="url"?e.title||e.url:e.kind==="terminal"?e.title||"Terminal":e.title||e.path.split(/[/\\]/).pop()||e.path}function Is(){return`tab_${Date.now().toString(36)}_${Math.random().toString(36).slice(2,7)}`}function wd(e){let t=e;for(;t.length>tV;){let n=-1;for(let o=t.length-1;o>=0;o--)if(!t[o].pinned){n=o;break}if(n<0)break;const r=t[n];r&&(Wh(r.payload),Yh(r.payload)),t=t.filter((o,l)=>l!==n)}return t}function Wh(e){e?.kind==="url"&&e.browserId&&(nV(e.browserId),window.markusDesktop?.browser?.destroy(e.browserId))}function Yh(e){e?.kind==="terminal"&&e.terminalId&&(Vh(e.terminalId),window.markusDesktop?.terminal?.destroy(e.terminalId))}function sV(e){const t=e.payload;return t.kind==="terminal"?null:t.kind==="url"?gc(t.url||"")||gc(t.title||"")?null:{id:e.id,title:e.title,pinned:e.pinned,payload:{kind:"url",url:t.url||"about:blank",title:t.title||e.title}}:t.kind==="file"?{id:e.id,title:e.title,pinned:e.pinned,payload:{kind:"file",path:t.path,title:t.title}}:{id:e.id,title:e.title,pinned:e.pinned,payload:{kind:"deliverable",deliverable:t.deliverable}}}function iV(e,t=0){if(e.payload.kind==="url"){const n=`eb_${Date.now().toString(36)}_${t.toString(36)}_${Math.random().toString(36).slice(2,7)}`;return{...e,payload:{kind:"url",url:e.payload.url||"about:blank",title:e.payload.title||e.title,browserId:n}}}return e}function oV(){try{const e=localStorage.getItem(w3);if(!e)return null;const t=JSON.parse(e);return!t||t.mode!=="browser"&&t.mode!=="terminal"||!Array.isArray(t.browserTabs)?null:t}catch{return null}}function lV(){const e={mode:"browser",browserTabs:[],browserActiveId:null,terminalTabs:[],terminalActiveId:null,stashedBrowserTabs:[],stashedBrowserActiveId:null,stashedTerminalTabs:[],stashedTerminalActiveId:null},t=oV();if(!t)return e;const n=t.browserTabs.map((x,w)=>{try{return iV(x,w)}catch{return null}}).filter(x=>!(!x||x.payload.kind==="terminal"||x.payload.kind==="url"&&gc(x.payload.url||""))),r=n.some(x=>x.id===t.browserActiveId)?t.browserActiveId:n[0]?.id??null,o=(t.terminalTabs||[]).map((x,w)=>{const C=`term_${Date.now().toString(36)}_${w.toString(36)}_${Math.random().toString(36).slice(2,7)}`;return wi(C),{id:x.id||Is(),title:x.title||"Terminal",payload:{kind:"terminal",terminalId:C,title:x.title||"Terminal",cwd:x.cwd}}}),l=o.some(x=>x.id===t.terminalActiveId)?t.terminalActiveId:o[0]?.id??null,c=!!t.browserCollapsed&&n.length>0,d=!!t.terminalCollapsed&&o.length>0,m=c?[]:n,f=c?null:r,h=d?[]:o,g=d?null:l;let y=t.mode;return y==="terminal"&&h.length===0&&!d&&(y="browser"),y==="browser"&&m.length===0&&h.length>0&&(y="terminal"),{mode:y,browserTabs:m,browserActiveId:f,terminalTabs:h,terminalActiveId:g,stashedBrowserTabs:n,stashedBrowserActiveId:r,stashedTerminalTabs:o,stashedTerminalActiveId:l}}const k3=k.createContext(null);function cV({children:e}){const[t,n]=k.useState(()=>{try{return localStorage.getItem("markus_sidebar_c")==="1"}catch{return!1}}),r=k.useMemo(()=>lV(),[]),[o,l]=k.useState(r.mode),[c,d]=k.useState(r.browserTabs),[m,f]=k.useState(r.terminalTabs),[h,g]=k.useState(r.browserActiveId),[y,x]=k.useState(r.terminalActiveId),[w,C]=k.useState(!1),[T,S]=k.useState(!1),[E,j]=k.useState("l0"),[L,I]=k.useState(null),O=k.useCallback(ye=>j(ye),[]),F=k.useCallback(ye=>I(ye),[]);k.useEffect(()=>{const ye=Ae=>{if(!(Ae instanceof HTMLElement))return!1;const oe=Ae.tagName;return oe==="INPUT"||oe==="TEXTAREA"||oe==="SELECT"?!0:Ae.isContentEditable},je=Ae=>{if(!(Ae.target instanceof Element))return;const oe=document.activeElement;if(ye(oe)){const Ne=oe===Ae.target||oe.contains(Ae.target),Re=!!Ae.target.closest("[data-keep-edit-focus]"),$e=ye(Ae.target)||!!Ae.target.closest('input, textarea, select, [contenteditable="true"]'),Q=!!Ae.target.closest(".xterm");!Ne&&!Re&&!$e&&!Q&&oe.blur()}const H=Ae.target.closest("[data-keyboard-pane]");if(!H)return;const te=H.getAttribute("data-keyboard-pane");if(!(te!=="l0"&&te!=="l1"&&te!=="l2"&&te!=="content")&&(j(te),te==="l0")){const Re=Ae.target.closest("[data-l0-page-id]")?.getAttribute("data-l0-page-id");Re&&I(Re)}};return document.addEventListener("pointerdown",je,!0),()=>document.removeEventListener("pointerdown",je,!0)},[]);const V=k.useRef(r.stashedBrowserTabs.length>0?r.stashedBrowserTabs:r.browserTabs),X=k.useRef(r.stashedBrowserActiveId??r.browserActiveId),z=k.useRef(r.stashedTerminalTabs.length>0?r.stashedTerminalTabs:r.terminalTabs),G=k.useRef(r.stashedTerminalActiveId??r.terminalActiveId),se=k.useRef(r.browserActiveId),ee=k.useRef(r.terminalActiveId),q=k.useRef(r.browserTabs),re=k.useRef(r.terminalTabs),B=k.useRef(r.mode);se.current=h,ee.current=y,q.current=c,re.current=m,B.current=o,k.useEffect(()=>{(r.mode==="terminal"||r.browserTabs.length===0)&&window.markusDesktop?.browser?.hideAll?.()},[]),k.useEffect(()=>{const ye=c.length===0&&V.current.length>0,je=m.length===0&&z.current.length>0,Ae=ye?V.current:c,oe=je?z.current:m,H=Ae.map(sV).filter(Re=>!!Re),te=oe.filter(Re=>Re.payload.kind==="terminal").map(Re=>({id:Re.id,title:Re.title,cwd:Re.payload.kind==="terminal"?Re.payload.cwd:void 0})),Ne={mode:o,browserTabs:H,browserActiveId:ye?X.current:h,terminalTabs:te,terminalActiveId:je?G.current:y,browserCollapsed:ye,terminalCollapsed:je};try{localStorage.setItem(w3,JSON.stringify(Ne))}catch{}},[o,c,h,m,y]);const J=k.useCallback(ye=>n(ye),[]),fe=k.useCallback(()=>n(ye=>!ye),[]),Se=k.useCallback(()=>{window.markusDesktop?.browser?.hideAll?.()},[]),U=k.useCallback(ye=>{l(je=>je===ye?je:(ye==="terminal"&&Se(),ye))},[Se]),W=k.useCallback(ye=>{if(ye==="terminal"){if(Se(),l("terminal"),n(!0),m.length>0)return;if(z.current.length>0){const Re=z.current,$e=G.current&&Re.some(Q=>Q.id===G.current)?G.current:Re[0].id;f(Re),x($e),G.current=$e;return}const H=Is(),te=`term_${Date.now().toString(36)}_${Math.random().toString(36).slice(2,7)}`;wi(te);const Ne={id:H,title:"Terminal",payload:{kind:"terminal",terminalId:te,title:"Terminal"}};z.current=[Ne],f([Ne]),x(Ne.id),G.current=Ne.id;return}if(l("browser"),n(!0),c.length>0)return;if(V.current.length>0){const H=V.current,te=X.current&&H.some(Ne=>Ne.id===X.current)?X.current:H[0].id;d(H),g(te),X.current=te;return}const je=Is(),Ae=`eb_${Date.now().toString(36)}_${Math.random().toString(36).slice(2,7)}`,oe={id:je,title:"New Tab",payload:{kind:"url",url:"about:blank",title:"New Tab",browserId:Ae}};V.current=[oe],d([oe]),g(oe.id),X.current=oe.id},[c.length,m.length,Se]),pe=k.useCallback(ye=>{const je=Zl(ye),Ae=Is();if(aV(ye)){ye.kind==="terminal"&&wi(ye.terminalId),l("terminal"),Se();const H=re.current,te=H.find($e=>Zl($e.payload)===je)??z.current.find($e=>Zl($e.payload)===je);let Ne,Re;if(te)Re=te.id,Ne=H.some($e=>$e.id===te.id)?H:wd([te,...H]);else{const $e={id:Ae,title:J2(ye),payload:ye};Ne=wd([$e,...H]),Re=Ae}z.current=Ne,re.current=Ne,f(Ne),x(Re),G.current=Re,ee.current=Re}else{l("browser");const H=q.current,te=H.find($e=>Zl($e.payload)===je)??V.current.find($e=>Zl($e.payload)===je);let Ne,Re;if(te)Re=te.id,Ne=H.some($e=>$e.id===te.id)?H:wd([te,...H]);else{const $e={id:Ae,title:J2(ye),payload:ye};Ne=wd([$e,...H]),Re=Ae}V.current=Ne,q.current=Ne,d(Ne),g(Re),X.current=Re,se.current=Re}n(!0)},[Se]),P=k.useCallback(ye=>{const je=q.current,Ae=je.findIndex(Z=>Z.id===ye);if(Ae>=0){const Z=je[Ae]?.payload,be=je.filter(M=>M.id!==ye),Ke=se.current,Ye=(je.some(M=>M.id===Ke)?Ke:je[0]?.id??null)===ye||be.length===0?be[Math.min(Ae,be.length-1)]?.id??null:void 0;V.current=be,q.current=be,d(be),be.length===0&&B.current==="browser"&&C(!1),Ye!==void 0&&(g(Ye),X.current=Ye,se.current=Ye),Wh(Z);return}const oe=re.current,H=oe.findIndex(Z=>Z.id===ye);if(H<0)return;const te=oe[H]?.payload,Ne=oe.filter(Z=>Z.id!==ye),Re=ee.current,Q=(oe.some(Z=>Z.id===Re)?Re:oe[0]?.id??null)===ye||Ne.length===0?Ne[Math.min(H,Ne.length-1)]?.id??null:void 0;z.current=Ne,re.current=Ne,f(Ne),Ne.length===0&&B.current==="terminal"&&C(!1),Q!==void 0&&(x(Q),G.current=Q,ee.current=Q),Yh(te)},[]),_e=k.useCallback(()=>{const ye=q.current.map(Ae=>Ae.payload),je=re.current.map(Ae=>Ae.payload);q.current=[],re.current=[],V.current=[],X.current=null,z.current=[],G.current=null,se.current=null,ee.current=null,d([]),f([]),g(null),x(null),C(!1);for(const Ae of ye)Wh(Ae);for(const Ae of je)Yh(Ae)},[]),He=k.useCallback(ye=>{B.current==="terminal"?(x(ye),G.current=ye):(g(ye),X.current=ye)},[]),Pe=k.useCallback((ye,je)=>{d(Ae=>{let oe=!1;const H=Ae.map(te=>{if(te.payload.kind!=="url"||te.payload.browserId!==ye)return te;const Ne=je.url??te.payload.url,Re=je.title||te.payload.title||Ne,$e=je.pageId??te.payload.pageId;return Ne===te.payload.url&&Re===(te.payload.title||te.title)&&$e===te.payload.pageId&&Re===te.title?te:(oe=!0,{...te,title:Re,payload:{...te.payload,url:Ne,title:Re,...$e!=null?{pageId:$e}:{}}})});return oe&&(V.current=H),oe?H:Ae})},[]),Ge=k.useCallback((ye,je)=>{f(Ae=>{let oe=!1;const H=Ae.map(te=>{if(te.payload.kind!=="terminal"||te.payload.terminalId!==ye)return te;const Ne=je.title||te.payload.title||te.title,Re=je.cwd??te.payload.cwd;return Ne===te.title&&Re===te.payload.cwd&&Ne===(te.payload.title||te.title)?te:(oe=!0,{...te,title:Ne,payload:{...te.payload,title:Ne,...Re!=null?{cwd:Re}:{}}})});return oe&&(z.current=H),oe?H:Ae})},[]),ct=k.useCallback(()=>{B.current==="terminal"?(f(ye=>ye.length===0?ye:(z.current=ye,ee.current&&(G.current=ee.current),[])),x(null)):(d(ye=>ye.length===0?ye:(V.current=ye,se.current&&(X.current=se.current),[])),g(null),Se()),C(!1)},[Se]),mt=k.useCallback(()=>{if(B.current==="terminal"&&m.length>0){if(l("browser"),c.length>0){n(!0);return}if(V.current.length>0){const $e=V.current,Q=X.current&&$e.some(Z=>Z.id===X.current)?X.current:$e[0].id;d($e),g(Q),X.current=Q,n(!0);return}const te=Is(),Ne=`eb_${Date.now().toString(36)}_${Math.random().toString(36).slice(2,7)}`,Re={id:te,title:"New Tab",payload:{kind:"url",url:"about:blank",title:"New Tab",browserId:Ne}};V.current=[Re],d([Re]),g(Re.id),X.current=Re.id,n(!0);return}const ye=Is(),je=`eb_${Date.now().toString(36)}_${Math.random().toString(36).slice(2,7)}`;let Ae,oe=!1,H=!1;l("browser"),d(te=>{if(te.length>0)return V.current=te,se.current&&(X.current=se.current),H=!0,Ae=null,[];if(V.current.length>0){oe=!0;const Re=V.current;return Ae=X.current&&Re.some(Q=>Q.id===X.current)?X.current:Re[0].id,Re}oe=!0;const Ne={id:ye,title:"New Tab",payload:{kind:"url",url:"about:blank",title:"New Tab",browserId:je}};return V.current=[Ne],Ae=Ne.id,[Ne]}),oe&&n(!0),H?(g(null),C(!1),Se()):Ae!=null&&(g(Ae),X.current=Ae)},[c.length,m.length,Se]),Ct=k.useCallback(()=>{if(B.current==="browser"&&c.length>0){if(l("terminal"),Se(),m.length>0){n(!0);return}if(z.current.length>0){const $e=z.current,Q=G.current&&$e.some(Z=>Z.id===G.current)?G.current:$e[0].id;f($e),x(Q),G.current=Q,n(!0);return}const te=Is(),Ne=`term_${Date.now().toString(36)}_${Math.random().toString(36).slice(2,7)}`;wi(Ne);const Re={id:te,title:"Terminal",payload:{kind:"terminal",terminalId:Ne,title:"Terminal"}};z.current=[Re],f([Re]),x(Re.id),G.current=Re.id,n(!0);return}const ye=Is(),je=`term_${Date.now().toString(36)}_${Math.random().toString(36).slice(2,7)}`;wi(je);let Ae,oe=!1,H=!1;l("terminal"),Se(),f(te=>{if(te.length>0)return z.current=te,ee.current&&(G.current=ee.current),H=!0,Ae=null,[];if(z.current.length>0){oe=!0;const Re=z.current;return Ae=G.current&&Re.some(Q=>Q.id===G.current)?G.current:Re[0].id,Re}oe=!0;const Ne={id:ye,title:"Terminal",payload:{kind:"terminal",terminalId:je,title:"Terminal"}};return z.current=[Ne],Ae=Ne.id,[Ne]}),oe&&n(!0),H?(x(null),C(!1)):Ae!=null&&(x(Ae),G.current=Ae)},[c.length,m.length,Se]),Mt=k.useCallback(ye=>{const je=B.current==="terminal"?m:c;if(je.length<2)return;const Ae=B.current==="terminal"?ee.current:se.current,H=(Math.max(0,je.findIndex(Ne=>Ne.id===Ae))+ye+je.length)%je.length,te=je[H].id;B.current==="terminal"?(x(te),G.current=te):(g(te),X.current=te)},[c,m]),Pt=k.useCallback(ye=>{const Ae=(B.current==="terminal"?m:c)[ye];Ae&&(B.current==="terminal"?(x(Ae.id),G.current=Ae.id):(g(Ae.id),X.current=Ae.id))},[c,m]),Kt=k.useCallback(()=>{if(B.current==="terminal"){const je=`term_${Date.now().toString(36)}_${Math.random().toString(36).slice(2,7)}`;pe({kind:"terminal",terminalId:je,title:"Terminal"});return}const ye=`eb_${Date.now().toString(36)}_${Math.random().toString(36).slice(2,7)}`;pe({kind:"url",url:"about:blank",title:"New Tab",browserId:ye})},[pe]),yt=k.useCallback(ye=>{const je=re.current,Ae=je.findIndex($e=>$e.payload.kind==="terminal"&&$e.payload.terminalId===ye);if(Ae<0){Vh(ye),window.markusDesktop?.terminal?.destroy(ye);return}const oe=je[Ae];if(je.length>1){P(oe.id);return}Vh(ye),window.markusDesktop?.terminal?.destroy(ye);const H=`term_${Date.now().toString(36)}_${Math.random().toString(36).slice(2,7)}`;wi(H);const te=oe.payload.kind==="terminal"&&(oe.payload.title||oe.title)||"Terminal",Ne=oe.payload.kind==="terminal"?oe.payload.cwd:void 0,Re={id:oe.id,title:te,payload:{kind:"terminal",terminalId:H,title:te,cwd:Ne}};z.current=[Re],f([Re]),x(Re.id),G.current=Re.id,B.current!=="terminal"&&l("terminal")},[P]),Ue=k.useCallback(ye=>C(ye),[]),dt=k.useCallback(()=>C(ye=>!ye),[]),Nt=o==="terminal"?m:c,bt=o==="terminal"?y:h,Lt=Nt.find(ye=>ye.id===bt)??Nt[0]??null,ue=Lt?.payload??null,tt=Nt.length>0,st=k.useMemo(()=>({leftCollapsed:t,setLeftCollapsed:J,toggleLeftCollapsed:fe,keyboardPane:E,setKeyboardPane:O,l0FocusPageId:L,setL0FocusPageId:F,rightPanelMode:o,setRightPanelMode:U,switchRightPanelMode:W,rightPanel:ue,rightPanelOpen:tt,rightPanelTabs:Nt,activeRightPanelTabId:Lt?.id??null,openRightPanel:pe,closeRightPanel:_e,closeRightPanelTab:P,setActiveRightPanelTab:He,updateRightPanelBrowserTab:Pe,updateRightPanelTerminalTab:Ge,toggleRightPanel:mt,toggleTerminalPanel:Ct,collapseRightPanelOnly:ct,cycleRightPanelTab:Mt,activateRightPanelTabAt:Pt,openNewRightPanelTab:Kt,handleTerminalExit:yt,rightPanelFullscreen:w,setRightPanelFullscreen:Ue,toggleRightPanelFullscreen:dt,hostAvailable:T,setHostAvailable:S}),[t,J,fe,E,O,L,F,o,U,W,ue,tt,Nt,Lt,pe,_e,P,He,Pe,Ge,mt,Ct,ct,Mt,Pt,Kt,yt,w,Ue,dt,T]);return s.jsx(k3.Provider,{value:st,children:e})}function Lc(){return k.useContext(k3)}function Jl(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 uV(e){let t=e.replace(/\\\[([\s\S]*?)\\\]/g,(n,r)=>`$$${r}$$`);return t=t.replace(/\\\((.+?)\\\)/g,(n,r)=>`$${r}$`),t}const kd="#mention:";function dV(e,t){if(!t||t.length===0)return e.replace(/@\[([^\]]+)\]|@([\w\p{L}\p{N}]+)/gu,(l,c,d)=>{const m=c??d;return`[@${m}](${kd}${encodeURIComponent(m)})`});const n=[...t].sort((l,c)=>c.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 h=e.indexOf("]",l+2);if(h>l+2){const g=e.slice(l+2,h);r+=`[@${g}](${kd}${encodeURIComponent(g)})`,o=h+1;continue}}const c=e.slice(l+1),d=c.toLowerCase(),m=n.find(h=>d.startsWith(h.toLowerCase()));if(m){const h=c.slice(0,m.length);r+=`[@${h}](${kd}${encodeURIComponent(h)})`,o=l+1+m.length;continue}const f=c.match(/^([\w\p{L}\p{N}]+)/u);if(f){const h=f[1];r+=`[@${h}](${kd}${encodeURIComponent(h)})`,o=l+1+h.length;continue}r+="@",o=l+1}return r}const S3="#entity:",mV=new RegExp("(?<!\\[)(?<!\\()(?<!:)(?<!\\/)(?<!\\\\)\\b(tsk|req|proj|dlv|agt|team)_[a-f0-9]{6,}\\b(?!\\]\\(#entity:)","gi"),fV=/`\[([^\]]+)\]\(#entity:((?:tsk|req|proj|dlv|agt|team)_[a-f0-9]{6,})\)`/gi;function pV(e,t){const n=e.slice(0,t),r=n.lastIndexOf("](");return r===-1?!1:n.indexOf(")",r+2)===-1}function hV(e){return e.replace(fV,(t,n,r)=>`[${n}](${S3}${r})`)}function gV(e){return e.replace(mV,(t,n,r)=>pV(e,r)?t:`[${t}](${S3}${t})`)}function bV(e){const t=e.trim();return t.startsWith("@startuml")&&t.endsWith("@enduml")}const xV=/^(graph\s|flowchart\s|sequenceDiagram|classDiagram|stateDiagram|erDiagram|gantt|pie|gitGraph|mindmap|timeline|journey)/m;function yV(e){return xV.test(e.trim())}const vV={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 wV(e){return vV[e.toLowerCase()]??e.charAt(0).toUpperCase()+e.slice(1)}function kV(e){const t=e.match(/language-(\S+)/);return t?t[1]:null}const N3=/^(?:\/|~\/|[A-Za-z]:[\\/]|\\\\)/,C3=/^\.{1,2}\//,SV=/\.[a-zA-Z0-9]{1,12}(?:$|[?#])/,T3=/^[A-Za-z]:[\\/]/,A3=/^\\\\[^\\]/;function E3(e){const t=e.trim();return t?!!(/^file:/i.test(t)||T3.test(t)||A3.test(t)||t.startsWith("~/")||t.startsWith("/")||C3.test(t)):!1}function Kg(e){let t=e.trim();if(/^file:/i.test(t)){try{t=decodeURIComponent(t.replace(/^file:\/\//i,""))}catch{t=t.replace(/^file:\/\//i,"")}/^\/[A-Za-z]:\//.test(t)&&(t=t.slice(1))}return t=t.replace(/\\+/g,"/"),t}function NV(e){return e.replace(/(!?\[[^\]]*]\()((?:[A-Za-z]:|\\\\)[^)\n]*)(\))/g,(t,n,r,o)=>`${n}${r.replace(/\\+/g,"/")}${o}`)}function _3(e){return e.trim().toLowerCase().replace(/[^\p{L}\p{N}\p{M}\s\-_]/gu,"").replace(/\s+/g,"-").replace(/-+/g,"-").replace(/^-|-$/g,"")}function Sd(e,t){if(!e)return e;if(N3.test(e))return e.startsWith("~/")?e:e.replace(/\\/g,"/");if(!t)return e;const r=`${t.replace(/\\/g,"/").replace(/\/+$/,"")}/${e.replace(/^\.\//,"")}`,o=r.split("/"),l=[];for(const d of o)!d||d==="."||(d===".."?l.pop():l.push(d));const c=l.join("/");return r.startsWith("/")?`/${c}`.replace(/^\/+/,"/"):c}function e4(e){const t=e.indexOf("#");return t<0?{path:e}:{path:e.slice(0,t),fragment:decodeURIComponent(e.slice(t+1))}}function t4(e,t){if(!e)return{kind:"passthrough"};const n=e.trim();if(!n||n==="#")return{kind:"passthrough"};if(n.startsWith("#")&&!n.startsWith("#mention:")&&!n.startsWith("#entity:"))return{kind:"fragment",id:decodeURIComponent(n.slice(1))};if(T3.test(n)||A3.test(n)){const{path:l,fragment:c}=e4(n);return{kind:"file",path:Sd(l,t),fragment:c}}if(/^[a-zA-Z][a-zA-Z0-9+.-]*:/.test(n))return/^https?:\/\//i.test(n)||/^mailto:/i.test(n)?{kind:"external",url:n}:/^file:\/\//i.test(n)?{kind:"file",path:Kg(n)}:{kind:"passthrough"};const{path:r,fragment:o}=e4(n);return N3.test(r)?{kind:"file",path:Sd(r,t),fragment:o}:C3.test(r)?{kind:"file",path:Sd(r,t),fragment:o}:r&&SV.test(r)&&!r.includes("://")?{kind:"file",path:Sd(r,t),fragment:o}:{kind:"passthrough"}}function CV(e,t){if(!e||!t)return!1;let n=null;try{n=e.querySelector(`#${CSS.escape(t)}`)}catch{n=null}if(n||(n=e.querySelector(`[id="${t.replace(/"/g,'\\"')}"]`)),!n){const r=e.querySelectorAll("h1,h2,h3,h4,h5,h6");for(const o of r)if(_3(o.textContent||"")===t||o.id===t){n=o;break}}return n?(n.scrollIntoView({behavior:"smooth",block:"start"}),!0):!1}function j3(e){return e.type==="text"?e.value??"":(e.children??[]).map(j3).join("")}function M3(){return e=>{const t=new Map,n=r=>{if(r.type==="element"&&r.tagName&&/^h[1-6]$/.test(r.tagName)){const o=j3(r).trim();let l=_3(o);if(l){const c=t.get(l)??0;t.set(l,c+1),c>0&&(l=`${l}-${c}`),r.properties={...r.properties??{},id:l}}}for(const o of r.children??[])n(o)};n(e)}}function TV(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",c=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:${c.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:${c.h2}em;font-weight:700;color:${d.heading};margin:18px 0 8px;line-height:1.3;`,h3:`font-size:${c.h3}em;font-weight:600;color:${d.heading};margin:14px 0 6px;line-height:1.3;`,h4:`font-size:${c.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 f(h){h.removeAttribute("class");const g=h.tagName.toLowerCase();if(g==="pre"){h.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 y=h.querySelector("code");y&&(y.removeAttribute("class"),y.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"?h.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]&&h.setAttribute("style",m[g]),Array.from(h.children).forEach(f)}return r.removeAttribute("class"),Array.from(r.children).forEach(h=>f(h)),`<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 Wg(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 AV(e,t,n,r){const o=TV(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 Wg(n),method:"text"}}}const R3="markus-copy-typography",n4={fontFamily:"default",fontSize:15,headingScale:"standard"};function L3(){try{const e=localStorage.getItem(R3);if(e)return{...n4,...JSON.parse(e)}}catch{}return n4}function EV(e){localStorage.setItem(R3,JSON.stringify(e))}function _V(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 jV({onClose:e}){const{t}=ft("common"),[n,r]=k.useState(L3);k.useEffect(()=>{EV(n)},[n]);const o=k.useCallback((l,c)=>{r(d=>({...d,[l]:c}))},[]);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))})]})]})}class MV extends k.Component{state={error:null};static getDerivedStateFromError(t){return{error:t}}componentDidUpdate(t){this.state.error&&this.props.resetKeys&&!RV(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 RV(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 LV=k.lazy(()=>Gr(()=>Promise.resolve().then(()=>G3),void 0).then(e=>({default:e.MarkdownMessage}))),OV={file:{icon:"📄",color:"bg-green-500/10 text-green-600"},directory:{icon:"📁",color:"bg-blue-500/10 text-blue-600"}},r4={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 DV({item:e,onClose:t,onOpenInPage:n}){const{t:r}=ft(["agent","common"]),o=OV[e.type]??{icon:"📎",color:"bg-surface-elevated text-fg-secondary"},l=r4[e.status]??r4.active,c=/^https?:\/\//i.test(e.reference??"");k.useEffect(()=>{const m=f=>{f.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(LV,{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}),c?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:()=>{Ee.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"?Sa.createPortal(d,document.body):d}const IV={tsk:"task",req:"requirement",proj:"project",dlv:"deliverable",agt:"agent",team:"team"};function O3(e){return{task:"task",requirement:"requirement",project:"project",deliverable:"deliverable",agent:"agent",team:"team"}[e]}const D3={task:"📋",requirement:"📝",project:"📁",deliverable:"📦",agent:"🤖",team:"👥"},I3={task:"Task",requirement:"Requirement",project:"Project",deliverable:"Deliverable",agent:"Agent",team:"Team"},PV=/^(tsk|req|proj|dlv|agt|team)_[a-f0-9]{6,}$/i;function b0(e){return PV.test(e.trim())}function zV(e){const t=e.split("_")[0]?.toLowerCase();return t?IV[t]:void 0}function P3(e){e.startsWith("tsk_")?it.navigate(de.WORK,{openTask:e}):e.startsWith("req_")?it.navigate(de.WORK,{openRequirement:e}):e.startsWith("proj_")?it.navigate(de.WORK,{projectId:e}):e.startsWith("dlv_")?it.navigate(de.DELIVERABLES,{openDeliverable:e}):e.startsWith("agt_")?it.navigate(de.TEAM,{agentId:e}):e.startsWith("team_")&&it.navigate(de.TEAM,{selectTeam:e})}const Qp=new Map,Nd=new Map;async function BV(e,t){const n={id:e,type:t,title:e,loading:!1};try{switch(t){case"task":{const r=await Ee.tasks.get(e);return{...n,title:r.task.title,status:r.task.status}}case"requirement":{const r=await Ee.requirements.get(e);return{...n,title:r.requirement.title,status:r.requirement.status}}case"project":{const r=await Ee.projects.get(e);return{...n,title:r.project.name,status:r.project.status,summary:r.project.description}}case"deliverable":{const r=await Ee.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 Ee.agents.get(e);return{...n,title:r.name,summary:r.role}}case"team":{const o=(await Ee.teams.list()).teams.find(l=>l.id===e);return{...n,title:o?.name??e,notFound:!o}}}}catch{}return{...n,notFound:!0}}function z3(e,t){const n=t??zV(e),[r,o]=k.useState(()=>Qp.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=Qp.get(e);if(l){o(l);return}o(m=>({...m,type:n,loading:!0}));let c=!0,d=Nd.get(e);return d||(d=BV(e,n),Nd.set(e,d)),d.then(m=>{Qp.set(e,m),Nd.delete(e),c&&o(m)}).catch(()=>{Nd.delete(e),c&&o({id:e,type:n,title:e,loading:!1,notFound:!0})}),()=>{c=!1}},[e,n]),r}function B3(e){const t=(e.split("_")[0]?.length??3)+1;return e.length>t+8?`${e.slice(0,t+8)}…`:e}function lc({id:e,type:t,label:n}){const r=z3(e,t),o=Lc(),l=D3[r.type]??"🔗",c=n??(r.loading||r.notFound?B3(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}P3(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:`${I3[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:c})]})}function $V({id:e,type:t,label:n}){const r=z3(e,t),[o,l]=k.useState(!1),c=Lc(),d=D3[r.type]??"🔗",m=()=>{if(r.type==="deliverable"&&r.deliverable){if(c?.hostAvailable){c.openRightPanel({kind:"deliverable",deliverable:r.deliverable});return}l(!0);return}P3(e)},f=r.loading?B3(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:I3[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:f}),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(DV,{item:r.deliverable,onClose:()=>l(!1),onOpenInPage:h=>{l(!1),it.navigate(de.DELIVERABLES,{openDeliverable:h})}})]})}k.lazy(()=>Gr(()=>Promise.resolve().then(()=>G3),void 0).then(e=>({default:e.MarkdownMessage})));const HV=k.lazy(()=>Gr(()=>import("./ContentRenderer-gaxBn1N9.js"),[]).then(e=>({default:e.ContentRenderer})));let No=[],a4=60;function UV(e){const t=k.useRef(e);t.current=e;const[n]=k.useState(()=>++a4);return k.useEffect(()=>{const r=()=>t.current();No.push(r);const o=l=>{l.key==="Escape"&&No[No.length-1]===r&&(l.preventDefault(),r())};return window.addEventListener("keydown",o,!0),()=>{window.removeEventListener("keydown",o,!0),No=No.filter(l=>l!==r),No.length===0&&(a4=60)}},[]),n}const s4=500,$s=new Map,x0=new Set,qd=new Map;let Gd=null;function FV(){if($s.size<=s4)return;const e=$s.size-s4,t=$s.keys();for(let n=0;n<e;n++){const{value:r,done:o}=t.next();if(o)break;$s.delete(r)}}function i4(e,t){$s.delete(e),$s.set(e,t),FV()}function o4(e){const t=qd.get(e);if(t)for(const n of t)n()}function qV(){Gd=null;const e=[...x0];x0.clear(),e.length!==0&&Ee.files.check(e).then(({results:t})=>{for(const[n,r]of Object.entries(t))i4(n,r),o4(n)}).catch(()=>{for(const t of e)i4(t,{exists:!1,isFile:!1,type:"unknown"}),o4(t)})}function GV(e){$s.has(e)||x0.has(e)||(x0.add(e),Gd&&clearTimeout(Gd),Gd=setTimeout(qV,30))}function VV(e,t){let n=qd.get(e);return n||(n=new Set,qd.set(e,n)),n.add(t),()=>{n.delete(t),n.size===0&&qd.delete(e)}}function KV(e){const t=k.useCallback(o=>VV(e,o),[e]),n=k.useCallback(()=>$s.get(e),[e]),r=k.useSyncExternalStore(t,n,n);return k.useEffect(()=>{GV(e)},[e]),r}const WV=/^(?:\/[\w.\-@+]+(?:\/[\w.\-@+ ]*)*|~\/[\w.\-@+]+(?:\/[\w.\-@+ ]*)*|[A-Za-z]:(?:\\|\/)[\w.\-@+ ]+(?:(?:\\|\/)[\w.\-@+ ]*)*|\.\.?\/[\w.\-@+]+(?:\/[\w.\-@+ ]*)*)$/;function YV(e){return e.length<2||e.length>500?!1:WV.test(e)}function XV({filePath:e,onClose:t}){const n=UV(t),[r,o]=k.useState(!0),[l,c]=k.useState(null),[d,m]=k.useState(""),[f,h]=k.useState(""),[g,y]=k.useState(""),[x,w]=k.useState(""),[C,T]=k.useState("");k.useEffect(()=>{o(!0),c(null),Ee.files.preview(e).then(E=>{m(typeof E.content=="string"?E.content:""),h(E.type),y(E.name),w(E.mimeType||""),T(E.streamUrl||(E.path?Ee.files.streamUrl(E.path):"")||(E.type==="audio"||E.type==="video"?Ee.files.streamUrl(e):""))}).catch(E=>{c(String(E?.message||E))}).finally(()=>{o(!1)})},[e]);const S=g||e.split(/[/\\]/).pop()||e;return Sa.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:E=>E.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:S}),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:()=>Ee.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&&f==="image"&&d&&s.jsx("div",{className:"flex justify-center",children:s.jsx("img",{src:`data:${x||"image/png"};base64,${d}`,alt:S,className:"max-w-full rounded"})}),!r&&!l&&f==="audio"&&C&&s.jsx("audio",{controls:!0,preload:"metadata",src:C,className:"w-full"}),!r&&!l&&f==="video"&&C&&s.jsx("video",{controls:!0,preload:"metadata",src:C,className:"w-full max-h-[60vh] rounded-lg bg-black"}),!r&&!l&&(f==="binary"||!d&&f!=="image"&&f!=="audio"&&f!=="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:()=>{Ee.files.reveal(e)},children:"Reveal in file explorer"})]}),!r&&!l&&d&&f!=="image"&&f!=="audio"&&f!=="video"&&f!=="binary"&&s.jsx(k.Suspense,{fallback:s.jsx("div",{className:"text-xs text-fg-tertiary",children:"Loading…"}),children:s.jsx(HV,{content:d,format:f==="text"?"text":f,className:"text-sm"})})]})]})}),document.body)}function QV({path:e}){const t=KV(e),[n,r]=k.useState(null),o=Lc(),l=t?.exists??!1,c=t?.type==="markdown"||t?.type==="html"||t?.type==="json"||t?.type==="text"||t?.type==="image"||t?.type==="audio"||t?.type==="video",d=k.useCallback(h=>{if(h.preventDefault(),h.stopPropagation(),!!l)if(c){if(o?.hostAvailable){o.openRightPanel({kind:"file",path:e});return}r(e)}else Ee.files.reveal(e)},[l,c,e,o]),m="inline w-3 h-3 align-[-0.125em]",f=c?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:c?"Click to preview":"Click to reveal in file explorer",role:"button",tabIndex:0,children:[s.jsxs("span",{className:"whitespace-nowrap",children:[f,e.charAt(0)]}),e.slice(1)]}),n&&s.jsx(XV,{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 Zp=null;function ZV(){return Zp||(Zp=Gr(()=>import("./mermaid.core-B4fv65oQ.js").then(e=>e.b9),__vite__mapDeps([0,1])).then(e=>(e.default.initialize({startOnLoad:!1,securityLevel:"loose",fontFamily:"inherit"}),e))),Zp}function JV(){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 eK(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 tK(){return JV()}function nK(){return k.useSyncExternalStore(eK,tK)}function $3({code:e}){const t=k.useRef(null),[n,r]=k.useState(null),[o,l]=k.useState(!0),c=k.useId(),d=k.useRef(0),m=k.useRef(null),f=nK();return k.useEffect(()=>{if(!e.trim()||m.current&&m.current.code===e&&m.current.dark===f)return;let h=!1;return l(!0),r(null),d.current+=1,(async()=>{try{const g=await ZV();if(h)return;g.default.initialize({startOnLoad:!1,theme:f?"dark":"default",securityLevel:"loose",fontFamily:"inherit"});const y=`mermaid-${c.replace(/:/g,"")}-${d.current}`,{svg:x}=await g.default.render(y,e.trim());if(h)return;t.current&&(t.current.innerHTML=x,m.current={code:e,dark:f})}catch(g){h||r(g instanceof Error?g.message:String(g))}finally{h||l(!1)}})(),()=>{h=!0}},[e,c,f]),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 rK="/assets/viz-global-C_AyN6D9.js";let Cd=!1,Jp=null;function aK(){return Cd?Promise.resolve():new Promise((e,t)=>{const n=document.querySelector("script[data-plantuml-viz]");if(n){globalThis.Viz?(Cd=!0,e()):(n.addEventListener("load",()=>{Cd=!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=rK,r.onload=()=>{Cd=!0,e()},r.onerror=()=>t(new Error("Failed to load viz-global.js")),document.head.appendChild(r)})}function sK(){return Jp||(Jp=aK().then(()=>Gr(()=>import("./plantuml-DezRDxd4.js"),[]))),Jp}let l4=Promise.resolve();function iK(e,t){const n=l4.then(()=>new Promise((r,o)=>{sK().then(({renderToString:l})=>{const c=e.split(/\r\n|\r|\n/);l(c,r,o,{dark:t})}).catch(o)}));return l4=n.then(()=>{},()=>{}),n}function oK(){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 lK(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 cK(){return k.useSyncExternalStore(lK,()=>oK())}function H3({code:e}){const[t,n]=k.useState(null),[r,o]=k.useState(null),[l,c]=k.useState(!0),d=k.useRef(null),m=cK();return k.useEffect(()=>{if(!e.trim()||d.current&&d.current.code===e&&d.current.dark===m)return;let f=!1;return c(!0),o(null),iK(e.trim(),m).then(h=>{f||(n(h),d.current={code:e,dark:m})}).catch(h=>{f||o(h instanceof Error?h.message:String(h))}).finally(()=>{f||c(!1)}),()=>{f=!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 Xh({code:e,language:t,children:n}){const{t:r}=ft("common"),[o,l]=k.useState("rendered"),[c,d]=k.useState(!1),m=k.useCallback(async()=>{await Wg(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:c?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 uK=[$3,H3];function dK(e){for(const t of k.Children.toArray(e))if(k.isValidElement(t)&&typeof t.props?.className=="string"){const n=t.props.className;return kV(n)}return null}function cc(e){if(typeof e=="string")return e;if(typeof e=="number")return String(e);if(!e)return"";if(Array.isArray(e))return e.map(cc).join("");if(k.isValidElement(e)){const t=e.props;return cc(t.children)}return""}function mK({children:e}){const{t}=ft("common"),n=dK(e),r=k.useRef(null),[o,l]=k.useState(!1),[c,d]=k.useState("rendered"),m=k.useCallback(async()=>{let h;c==="source"?h=cc(e):h=r.current?.querySelector("code")?.textContent??"";try{await navigator.clipboard.writeText(h),l(!0),setTimeout(()=>l(!1),1800)}catch{}},[c,e]);if(k.Children.toArray(e).some(h=>k.isValidElement(h)&&uK.includes(h.type))){const h=cc(e),g=n==="mermaid"||n==="plantuml"?n:"diagram";return s.jsx(Xh,{code:h,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:wV(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 ${c==="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 ${c==="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:[c==="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,h=>k.isValidElement(h)?k.cloneElement(h,{style:{background:"transparent",padding:0}}):h)}):s.jsx("pre",{className:"p-3 overflow-x-auto text-xs font-mono text-fg-secondary whitespace-pre-wrap break-words",children:cc(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 c4="#mention:",y0="#entity:",fK=/^\[([^\]]+)\]\(#entity:((tsk|req|proj|dlv|agt|team)_[a-f0-9]{6,})\)$/i,U3=/^(workflow|task|requirement|project|deliverable|agent|team):(.+)$/,Qh="text-brand-500 hover:text-brand-500 underline break-all cursor-pointer";function Zh(e){return e.type==="text"?e.value??"":(e.children??[]).map(Zh).join("")}function pK(e){return e.type==="text"&&(e.value??"").trim()===""}function hK(e){if(!e?.children)return null;const t=e.children.filter(r=>!pK(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=Zh(n);if(r.startsWith(y0))return{id:r.slice(y0.length)};const l=r.match(U3);return l&&l[1]!=="workflow"?{id:l[2],type:O3(l[1]),label:o}:null}if(n.type==="element"&&n.tagName==="code"){const r=Zh(n).trim();if(b0(r))return{id:r}}if(n.type==="text"){const r=(n.value??"").trim();if(b0(r))return{id:r}}return null}const gK={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")||bV(r))return s.jsx(Xh,{code:r,language:"plantuml",children:s.jsx(H3,{code:r})});if(t?.includes("language-mermaid")||!t&&yV(r))return s.jsx(Xh,{code:r,language:"mermaid",children:s.jsx($3,{code:r})});if(t?.includes("language-"))return s.jsx("code",{className:`${t} text-fg-secondary font-mono text-xs`,children:e});if(b0(n))return s.jsx(lc,{id:n.trim()});const o=n.match(fK);return o?s.jsx(lc,{id:o[2],label:o[1]}):YV(n)?s.jsx(QV,{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(mK,{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,className:Qh,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})},bK=/\.(png|jpe?g|gif|webp|svg|bmp|ico)$/i;function xK(e){const t=Kg(e);return E3(e)&&bK.test(t.split("?")[0]??t)}function yK(e,t){const n=Kg(e);if(n.startsWith("/")||n.startsWith("~/")||/^[A-Za-z]:\//.test(n)||n.startsWith("//"))return n;if((n.startsWith("./")||n.startsWith("../"))&&t){const o=((t.replace(/\\/g,"/").endsWith("/")?t.replace(/\\/g,"/"):`${t.replace(/\\/g,"/")}/`)+n).split("/"),l=[];for(const c of o)c===".."?l.pop():c!=="."&&c!==""&&l.push(c);return"/"+l.join("/")}return n}function vK(e){return`/api/files/image?path=${encodeURIComponent(e)}`}const Co=new Map;function wK({src:e,alt:t,onPreview:n,basePath:r}){const o=k.useMemo(()=>xK(e)?vK(yK(e,r)):e,[e,r]),l=o.startsWith("/api/files/image?"),c=Co.get(o),[d,m]=k.useState(c??(l?null:o)),[f,h]=k.useState(!!c),[g,y]=k.useState(!1),[x,w]=k.useState(null),[C,T]=k.useState(0),S=k.useRef(0),E=k.useCallback(()=>{Co.delete(o),y(!1),w(null),h(!1),m(l?null:`${o}${o.includes("?")?"&":"?"}retry=${Date.now()}`),T(j=>j+1)},[o,l]);return k.useEffect(()=>{if(!l)return;const j=Co.get(o);if(j){m(j),h(!0),y(!1),w(null);return}const L=++S.current;y(!1),w(null),h(!1),m(null),(async()=>{try{const I=await fetch(o,{credentials:"same-origin"});if(L!==S.current)return;if(!I.ok){let V=`HTTP ${I.status}`;try{const X=await I.json();X.error&&(V=X.error)}catch{}throw new Error(V)}const O=await I.blob();if(L!==S.current)return;if(O.size===0)throw new Error("Empty image response");if(O.type&&!O.type.startsWith("image/")&&!O.type.includes("octet-stream"))throw new Error(`Unexpected content-type: ${O.type}`);const F=URL.createObjectURL(O);Co.set(o,F),m(F),h(!0),y(!1),w(null)}catch(I){if(L!==S.current)return;const O=I instanceof Error?I.message:String(I);console.warn("[MarkdownImage] failed to load local image",o,I),w(O),y(!0),h(!1)}})()},[l,o,C]),k.useEffect(()=>{l||(m(o),h(!!Co.get(o)),y(!1),w(null))},[o,l,C]),g?s.jsxs("button",{type:"button",onClick:E,title:x??"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",x?` (${x})`:""]})]}):s.jsxs("span",{className:"inline-block align-middle max-w-full",children:[!f&&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||Co.set(o,o),h(!0)},onError:()=>{w("Image decode failed"),y(!0)},onClick:()=>n?.(d),className:`max-w-full h-auto rounded-lg cursor-pointer hover:opacity-90 transition-opacity my-1${f?"":" absolute opacity-0 pointer-events-none"}`,style:{maxHeight:"400px",objectFit:"contain"}}):null]})}async function u4(e){const t=await fetch(e);if(!t.ok)throw new Error(`Failed to fetch image (${t.status})`);return t.blob()}async function kK(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(c=>c?o(c):l(new Error("PNG encode failed")),"image/png")})}function SK(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 F3({src:e,onClose:t}){const{t:n}=ft("common"),[r,o]=k.useState(null),[l,c]=k.useState(null);Ho(!0),k.useEffect(()=>{const g=y=>{y.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){c("copy");try{const y=await u4(e),x=await kK(y);await navigator.clipboard.write([new ClipboardItem({"image/png":x})]),d(n("imageCopied"))}catch{d(n("imageCopyFailed"))}finally{c(null)}}},[l,d,e,n]),f=k.useCallback(async g=>{if(g.stopPropagation(),!l){c("download");try{const y=await u4(e),x=URL.createObjectURL(y),w=document.createElement("a");w.href=x,w.download=SK(e,y),document.body.appendChild(w),w.click(),w.remove(),URL.revokeObjectURL(x),d(n("imageDownloaded"))}catch{d(n("imageDownloadFailed"))}finally{c(null)}}},[l,d,e,n]),h="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 Sa.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:h,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:h,onClick:f,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 q3(e={}){const{onMentionClick:t,basePath:n,onImagePreview:r,contentRef:o,hostAvailable:l,openRightPanel:c}=e,d=k.useCallback((m,f)=>{const h=t4(f,n);if(h.kind!=="passthrough"){if(m.preventDefault(),m.stopPropagation(),h.kind==="fragment"){CV(o?.current??null,h.id);return}if(h.kind==="file"){l&&c?c({kind:"file",path:h.path,title:h.path.split(/[/\\]/).pop()}):Ee.files.reveal(h.path).catch(()=>{});return}if(h.kind==="external"){if(l&&c&&/^https?:\/\//i.test(h.url)){c({kind:"url",url:h.url,title:h.url});return}_i(h.url)}}},[n,o,l,c]);return k.useMemo(()=>({...gK,img:({src:m,alt:f})=>s.jsx(wK,{src:m??"",alt:f,onPreview:r,basePath:n},m??""),p:({children:m,node:f})=>{const h=hK(f);return h?s.jsx($V,{id:h.id,type:h.type,label:h.label}):s.jsx("p",{className:"mb-2 last:mb-0 leading-relaxed text-fg-secondary",children:m})},a:({href:m,children:f})=>{if(m?.startsWith(c4)){const g=decodeURIComponent(m.slice(c4.length));return s.jsx("span",{className:`text-brand-500 font-medium${t?" cursor-pointer hover:underline":""}`,onClick:t?y=>{y.preventDefault(),y.stopPropagation(),t(g,y)}:void 0,title:g,children:f})}if(m?.startsWith(y0))return s.jsx(lc,{id:m.slice(y0.length)});{const g=m?.match(U3);if(g){const[,y,x]=g;if(y==="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:C=>{C.preventDefault(),C.stopPropagation(),it.navigate(de.WORK,{boardType:"workflows"})},title:`workflow: ${x}`,children:[s.jsx("span",{className:"text-[10px]",children:"⚙️"}),s.jsx("span",{children:f})]});const w=O3(y);if(w)return s.jsx(lc,{id:x,type:w,label:f})}}if(m&&b0(m))return s.jsx(lc,{id:m.trim(),label:f});const h=t4(m,n);return h.kind==="fragment"||h.kind==="file"||h.kind==="external"?s.jsx("a",{href:m,className:Qh,onClick:g=>d(g,m),title:h.kind==="fragment"?`#${h.id}`:h.kind==="file"?h.path:h.url,children:f}):s.jsx("a",{href:m,className:Qh,onClick:g=>{yc()&&m&&!/^[a-zA-Z][a-zA-Z0-9+.-]*:/.test(m)&&g.preventDefault()},children:f})}}),[t,n,r,d])}const d4=[q5,Vk,Kk],m4=[M3,[n3,{strict:"ignore"}],[v3,{detect:!0,ignoreMissing:!0}]];function f4(e){return/^(deliverable|task|requirement|project|agent|team|workflow):/i.test(e)||E3(e)?e:x5(e)}const NK=/ thinking([\s\S]*?)(<\/think>|$)/g;function CK(e){const t=[];let n=e.replace(NK,(r,o)=>{const l=o.trim();return l&&t.push(l),""});return n=n.replace(/<\/think>/g,"").replace(/ thinking/g,""),{thinking:t,rest:n.trim()}}function TK(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 AK({content:e,contentRef:t}){const{t:n}=ft("common"),[r,o]=k.useState(!1),[l,c]=k.useState(!1),[d,m]=k.useState(!1),[f,h]=k.useState(null),g=k.useRef(null),y=TK();k.useEffect(()=>{if(!r)return;const T=S=>{g.current&&!g.current.contains(S.target)&&(o(!1),c(!1),m(!1))};return document.addEventListener("mousedown",T),()=>document.removeEventListener("mousedown",T)},[r]);const x=k.useCallback(T=>{h(T),setTimeout(()=>h(null),1500)},[]),w=async()=>{const T=await Wg(e);x(n(T?"markdown.copied":"markdown.failed")),o(!1)},C=async T=>{const S=t.current?.firstElementChild;if(!S)return;const E=L3(),j=_V(E),L=await AV(S,T,e,{fontFamily:j.fontFamily,fontSize:j.fontSize,headingScales:j.headingScales}),I=n(T==="light"?"markdown.themeLight":"markdown.themeDark");x(L.ok?L.method==="html"?n("markdown.htmlCopied",{theme:I}):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:[f&&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:f}),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(jV,{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:()=>c(!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:()=>c(!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(y?"markdown.copyMdSourceShort":"markdown.copyMdSource")]}),s.jsxs("button",{onClick:()=>C("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(y?"markdown.copyHtmlLightShort":"markdown.copyHtmlLight")]}),s.jsxs("button",{onClick:()=>C("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(y?"markdown.copyHtmlDarkShort":"markdown.copyHtmlDark")]})]})})]})}const Er=k.memo(function({content:t,className:n="",onMentionClick:r,knownNames:o,basePath:l}){const{thinking:c,rest:d}=CK(t),m=k.useRef(null),[f,h]=k.useState(null),g=Lc(),y=k.useCallback(C=>{let T=Jl(C,uV);return T=Jl(T,NV),T=Jl(T,hV),T=Jl(T,gV),T=Jl(T,S=>dV(S,o)),T},[o]),x=k.useMemo(()=>y(d),[d,y]),w=q3({onMentionClick:r,basePath:l,onImagePreview:h,contentRef:m,hostAvailable:g?.hostAvailable,openRightPanel:g?.openRightPanel});return s.jsxs("div",{className:"relative group/md",children:[s.jsx(AK,{content:t,contentRef:m}),s.jsx("div",{ref:m,children:s.jsx(MV,{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:[c.length>0&&(()=>{const C=c.join(`
649
649
 
650
650
  `),T=C.split(`
651
651
  `)[0]??"",S=T.length>80?T.slice(0,80)+"…":T;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:S})]}),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(Eh,{remarkPlugins:d4,rehypePlugins:m4,components:w,urlTransform:f4,children:y(C)})})})]})})(),s.jsx(Eh,{remarkPlugins:d4,rehypePlugins:m4,components:w,urlTransform:f4,children:x})]})})}),f&&s.jsx(F3,{src:f,onClose:()=>h(null)})]})},(e,t)=>e.content===t.content&&e.className===t.className&&e.basePath===t.basePath&&e.onMentionClick===t.onMentionClick&&EK(e.knownNames,t.knownNames));function EK(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 G3=Object.freeze(Object.defineProperty({__proto__:null,ImagePreviewModal:F3,MarkdownMessage:Er},Symbol.toStringTag,{value:"Module"})),Jh={suppressAdjustUntil:0};function Cc(e=2500){const t=typeof performance<"u"?performance.now():Date.now();Jh.suppressAdjustUntil=Math.max(Jh.suppressAdjustUntil,t+e)}function GY(){return(typeof performance<"u"?performance.now():Date.now())<Jh.suppressAdjustUntil}const p4={shell_execute:{label:"Running command",icon:"⌨"},list_terminals:{label:"Listing terminals",icon:"⌨"},new_terminal:{label:"Opening terminal",icon:"⌨"},select_terminal:{label:"Selecting terminal",icon:"⌨"},close_terminal:{label:"Closing terminal",icon:"⌨"},read_terminal:{label:"Reading terminal",icon:"⌨"},write_terminal:{label:"Writing terminal",icon:"⌨"},exec_terminal:{label:"Running in terminal",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:"🔍"}},h4={shell_execute:"square-terminal",background_exec:"square-terminal",process:"settings",list_terminals:"square-terminal",new_terminal:"square-terminal",select_terminal:"square-terminal",close_terminal:"square-terminal",read_terminal:"square-terminal",write_terminal:"square-terminal",exec_terminal:"square-terminal",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 Ai(e){const t=e.includes("__")?e.split("__").pop():e,n=p4[t]??p4[e],r=h4[t]??h4[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 $o(e){return e==null?"":e<1e3?`${e}ms`:`${(e/1e3).toFixed(1)}s`}function _K(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"),c=String(t.getSeconds()).padStart(2,"0");return`${n}-${r} ${o}:${l}:${c}`}function eg(e,t){return e.length<=t?e:e.slice(0,t)+"…"}function g4(e){try{const t=JSON.parse(e);return JSON.stringify(t,null,2)}catch{return e}}function V3(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 jK(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 VY(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_",""),c=o.metadata;n.get(r)?.push({eventType:l,content:o.content,metadata:c})}return t.map(o=>{if(o.type!=="tool")return o;const l=o.key;if(!l)return o;const c=l.replace(/^(?:t[se]_|e[se]_)/,""),d=parseInt(c,10);if(isNaN(d))return o;const m=n.get(d);return!m||m.length===0?o:{...o,info:{...o.info,subagentLogs:m}}})}function b4(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 K3(e){const t=_K(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 W3(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 Y3(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 X3={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 MK(e){return!!e&&e in X3}function Yo({name:e,size:t=24,className:n=""}){const r=X3[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 x4={"coding-tools":"terminal",markitdown:"file-text","markus-admin-cli":"terminal",codex:"code","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"},y4={development:"code",开发工具:"code",devops:"server",data:"bar-chart",数据分析:"bar-chart",productivity:"zap",效率提升:"zap",communication:"message-square",通讯协作:"message-square",browser:"globe",内容创作:"edit","AI 智能":"sparkles"};function Vd(e,t){const n=(e||"").toLowerCase();return x4[n]?x4[n]:t&&y4[t]?y4[t]:"layers"}function RK(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 Q3(){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 LK(){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 v4({item:e}){const{t}=ft("common"),n=Ai(e.tool);return s.jsxs("div",{className:"flex items-center gap-1.5 py-0.5",children:[s.jsx(Yo,{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(Q3,{})]})}function OK({activities:e,isActive:t,persistent:n}){const{t:r}=ft("common"),o=RK(e),[l,c]=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,C=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:()=>c(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:C})}),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 S=Ai(T.tool);return s.jsx(Yo,{name:S.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,S)=>s.jsx(v4,{item:T,idx:S,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(LK,{})]});const f=o.filter(w=>w.status==="error").length;let h=null;for(let w=o.length-1;w>=0;w--)if(o[w].status==="running"){h=o[w];break}const g=o[o.length-1];let y;if(h){const w=Ai(h.tool);y=`${r(`execution.tools.${w.key}`,{defaultValue:w.label})}…`}else if(t&&m)y=r("activity.writingResponse");else{const w=Ai(g.tool);y=r(`execution.tools.${w.key}`,{defaultValue:w.label})}const x=!!h||t&&m;return s.jsxs("div",{className:"mb-1",children:[s.jsxs("button",{onClick:w=>{w.stopPropagation(),c(C=>!C)},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 ${x?"activity-text-shimmer":"text-fg-secondary"}`,children:y}),s.jsxs("span",{className:"shrink-0",children:["· ",r("activity.step",{count:o.length})]}),f>0&&s.jsxs("span",{className:"text-red-500 shrink-0",children:["· ",r("activity.failed",{count:f})]}),x&&s.jsx(Q3,{})]}),l&&s.jsx("div",{className:"mt-1 space-y-0.5",children:o.map((w,C)=>s.jsx(v4,{item:w,idx:C,total:o.length},w.key))})]})}const DK={"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"}},Do=["created","context_injected","running"],IK=new Set(["completed","failed","cancelled","timeout"]),w4={created:"Created",context_injected:"Context injected",running:"Running",completed:"Completed",failed:"Failed",cancelled:"Cancelled",timeout:"Timed out"};function PK(e){return DK[e]??{label:e.replace(/-/g," ").replace(/\b\w/g,t=>t.toUpperCase()),icon:"⚙",badgeClass:"bg-surface-elevated text-fg-tertiary"}}function zK(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 BK(e){if(e==="completed"||IK.has(e))return Do.length;const t=Do.indexOf(e);return t>=0?t:0}function $K({session:e,className:t}){const n=PK(e.tool),[r,o]=k.useState(!1),[l,c]=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,f=e.status==="completed"||e.result?.success===!0;k.useEffect(()=>{if(!d)return;const w=setInterval(()=>c(Date.now()),1e3);return()=>clearInterval(w)},[d]);const h=k.useMemo(()=>zK(e,l),[e,l]),g=BK(e.status),y=e.result?.rawOutput??(f||m?e.result?.summary:void 0),x=d?"border-brand-500/40 bg-brand-500/5":m?"border-red-500/30 bg-red-500/5":f?"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 ${x} 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":f?"text-green-500":"text-fg-tertiary"}`,children:w4[e.status]??e.status}),h!=null&&s.jsx("span",{className:"text-[10px] text-fg-tertiary tabular-nums",children:$o(h)}),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:[Do.map((w,C)=>{const T=g>C||g===C&&!d&&f,S=g===C&&d,E=m&&C===Do.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 ${E?"bg-red-500":T?"bg-green-500":S?"bg-brand-500 animate-pulse":"bg-gray-600"}`,title:w4[w]}),C<Do.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":f?"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"]})]})]}),y&&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:y})]})]})}function HK({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 k4=150;function UK({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>=k4?(o.current=d,r(e)):l.current||(l.current=setTimeout(()=>{o.current=Date.now(),l.current=null,r(e)},k4-m)),()=>{l.current&&(clearTimeout(l.current),l.current=null)}},[e]);const c=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(Er,{content:c,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 v0=8e3,Td=120;function eh({text:e,className:t}){const{t:n}=ft("common"),[r,o]=k.useState(!1),l=e.length>v0,c=!l||r?e:`${e.slice(0,v0)}
@@ -660,7 +660,7 @@ https://github.com/highlightjs/highlight.js/issues/2277`),Rn=We,rn=wt),Ht===void
660
660
  `)}),c.toolCalls?.length)for(let m=0;m<c.toolCalls.length;m++){const f=c.toolCalls[m];d.push({type:"tool",key:`${f.tool}_${m}`,tool:f.tool,status:f.status==="error"?"error":"done",args:f.arguments,result:f.result,durationMs:f.durationMs})}d.length>0&&(d.push({type:"text",content:e.text}),l.segments=d)}return l}function eX(e,t,n){const r=t?new Date(t):new Date;if(isNaN(r.getTime()))return e;const o=new Date,l=new Date(o.getFullYear(),o.getMonth(),o.getDate()).getTime(),c=r.getTime(),d=r.toLocaleTimeString(void 0,{hour:"2-digit",minute:"2-digit"});return c>=l?d:c>=l-864e5?`${n?.yesterday??"Yesterday"} ${d}`:r.toLocaleDateString(void 0,{month:"short",day:"numeric"})+" "+d}function tX(e){if(!e)return"";const t=new Date(e);return isNaN(t.getTime())?"":`${t.getFullYear()}-${t.getMonth()+1}-${t.getDate()}`}function nX(e,t){const n=new Date(e);if(isNaN(n.getTime()))return"";const r=new Date,o=new Date(r.getFullYear(),r.getMonth(),r.getDate()).getTime(),l=n.getTime();return l>=o?t?.today??"Today":l>=o-864e5?t?.yesterday??"Yesterday":n.toLocaleDateString(void 0,{weekday:"long",year:"numeric",month:"long",day:"numeric"})}function rX(e,t){let n=0,r=null;return((...o)=>{const l=Date.now(),c=t-(l-n);if(c<=0)return r&&(clearTimeout(r),r=null),n=l,e(...o);r||(r=setTimeout(()=>{n=Date.now(),r=null,e(...o)},c))})}function aX({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 sX({name:e,agentId:t,agents:n,onViewProfile:r}){const{t:o}=ft(["team","common"]),[l,c]=k.useState(!1),d=k.useRef(null),m=t?n.find(f=>f.id===t):n.find(f=>f.name===e);return k.useEffect(()=>{if(!l)return;const f=h=>{d.current&&!d.current.contains(h.target)&&c(!1)};return document.addEventListener("mousedown",f),()=>document.removeEventListener("mousedown",f)},[l]),m?s.jsxs("span",{ref:d,className:"relative inline-block",children:[s.jsx("button",{onClick:()=>c(!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(Hs,{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:()=>{c(!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 iX({agent:e,anchorRect:t,onClose:n,onViewProfile:r}){const{t:o}=ft(["common","team"]),l=k.useRef(null);k.useEffect(()=>{const f=h=>{l.current&&!l.current.contains(h.target)&&n()};return document.addEventListener("mousedown",f),()=>document.removeEventListener("mousedown",f)},[n]);const c=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(f=>{if(!f)return;l.current=f;const h=f.getBoundingClientRect(),g=window.innerWidth,y=window.innerHeight,x=8;h.right>g-x&&(f.style.left=`${Math.max(x,g-h.width-x)}px`),h.left<x&&(f.style.left=`${x}px`),h.bottom>y-x&&(f.style.top=`${Math.max(x,y-h.height-x)}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(Hs,{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 ${c}`}),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 sW(e){const t=String(e);return t.includes("MARKUS_UPSTREAM_ERROR")?!1:t.includes("CU_EXCEEDED")||t.includes("CU_MONTHLY_EXCEEDED")}const n6="markus:credit-notif-muted";let E4=0;function oX(){try{if(localStorage.getItem(n6))return}catch{}const e=Date.now();e-E4<5*6e4||(E4=e,window.dispatchEvent(new CustomEvent("markus:credit-exhausted")))}function iW(){try{localStorage.setItem(n6,"1")}catch{}}function lX(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(sW(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 c=(r||n).replace(/https?:\/\/[^\s]*openrouter\.ai[^\s]*/gi,"").trim();return l("aiGeneric",{detail:(c||n).slice(0,120)})}function cX({msg:e,onCopy:t,onRetry:n,onResume:r,onReply:o,onRemember:l,isCopied:c,isLastAgentMsg:d,showRemember:m}){const{t:f}=ft(["team","common"]),h=e.isError||e.sender==="agent"&&e.text.startsWith("⚠"),g=e.isStopped,y=!!e.emptyReply||e.sender==="agent"&&!e.text?.trim()&&!e.segments?.some(C=>C.type==="text"&&(C.content||C.thinking)||C.type==="tool"),x=d!==!1,w=JK(m,e.sender)&&!!l;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:f("common:copy"),children:[c?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"})]}),f(c?"common:copied":"common:copy")]}),x&&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:f("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"})}),f("page.messageActions.resumeTitle")]}),x&&g&&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:f("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"})]}),f("page.messageActions.reaskTitle")]}),x&&(h||y)&&!g&&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:f("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"})]}),f("page.messageActions.retryTitle")]}),x&&!h&&!y&&!g&&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:f("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"})]}),f("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:f("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"})]}),f("page.messageActions.replyTitle")]}),w&&s.jsxs("button",{type:"button",onClick:()=>l(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:f("page.messageActions.rememberTitle"),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",children:[s.jsx("path",{d:"M12 2a7 7 0 00-4 12.7V19a1 1 0 001 1h6a1 1 0 001-1v-4.3A7 7 0 0012 2z"}),s.jsx("path",{d:"M9 22h6"})]}),f("page.messageActions.rememberTitle")]}),e.sender==="agent"&&s.jsx("span",{className:"ml-1 px-1 text-[10px] leading-none text-fg-tertiary/70 select-none whitespace-nowrap",children:f("page.messageActions.aiGeneratedDisclaimer")})]})}function uX({busy:e,onConfirm:t,onCancel:n}){const{t:r}=ft(["team","common"]),[o,l]=k.useState("");return Sa.createPortal(s.jsx("div",{className:"fixed inset-0 bg-black/60 flex items-center justify-center z-[10050] p-4",onClick:n,children:s.jsxs("div",{className:"bg-surface-secondary border border-border-default rounded-xl p-6 w-[400px] max-w-[calc(100vw-2rem)] shadow-2xl",onClick:c=>c.stopPropagation(),children:[s.jsx("h3",{className:"font-semibold text-base text-fg-primary",children:r("page.messageActions.rememberModalTitle")}),s.jsx("p",{className:"text-sm text-fg-secondary mt-1.5 leading-relaxed",children:r("page.messageActions.rememberModalHint")}),s.jsx("textarea",{value:o,onChange:c=>l(c.target.value),placeholder:r("page.messageActions.rememberModalPlaceholder"),rows:3,disabled:e,className:"mt-3 w-full px-3 py-2 text-sm bg-surface-primary border border-border-default rounded-lg outline-none focus:border-brand-500/50 resize-y min-h-[72px]"}),s.jsxs("div",{className:"flex justify-end gap-2 mt-4",children:[s.jsx("button",{type:"button",onClick:n,disabled:e,className:"px-4 py-1.5 text-sm text-fg-secondary hover:text-fg-primary rounded-lg transition-colors",children:r("page.messageActions.rememberCancel")}),s.jsx("button",{type:"button",onClick:()=>t(o),disabled:e,className:"px-4 py-1.5 text-sm bg-brand-600 hover:bg-brand-500 disabled:opacity-60 text-white rounded-lg transition-colors",children:e?r("common:loading",{defaultValue:"…"}):r("page.messageActions.rememberConfirm")})]})]})}),document.body)}function _4(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(E=>E.createdAt),f=E=>{if(E.createdAt)return E.createdAt;if(m)return new Date(d).toISOString();const j=new Date(d).toISOString();return E.type==="tool"&&E.durationMs?d+=E.durationMs:d+=1e3,j};let h="",g="",y="";const x=()=>{const E=h.trim();if(E){const j=r[r.length-1];j&&j.type==="text"&&j.metadata?.isThinking?j.content+=(j.content?`
661
661
 
662
662
  `:"")+E:r.push({id:`cseg_${o}`,sourceType:"chat",sourceId:"",agentId:l,seq:o++,type:"text",content:E,createdAt:y,metadata:{isThinking:!0}})}h=""},w=()=>{const E=g.trim();E&&r.push({id:`cseg_${o}`,sourceType:"chat",sourceId:"",agentId:l,seq:o++,type:"text",content:E,createdAt:y}),g=""},C="<think>",T="</think>",S=E=>{let j=0,L=!1;for(;j<E.length;)if(L){const I=E.indexOf(T,j);I===-1?j=E.length:(L=!1,j=I+T.length)}else{const I=E.indexOf(C,j);I===-1?(g+=E.slice(j),j=E.length):(g+=E.slice(j,I),L=!0,j=I+C.length)}};for(const E of e)if(y=f(E),E.type==="tool"){w();const j=E.createdAt&&E.durationMs?new Date(new Date(E.createdAt).getTime()-E.durationMs).toISOString():y;r.push({id:`cseg_${o}`,sourceType:"chat",sourceId:"",agentId:l,seq:o++,type:"tool_start",content:E.tool,metadata:{arguments:E.args,...E.status==="running"&&E.subagentLogs?.length?{subagentLogs:E.subagentLogs}:{}},createdAt:j}),E.status!=="running"&&r.push({id:`cseg_${o}`,sourceType:"chat",sourceId:"",agentId:l,seq:o++,type:"tool_end",content:E.tool,metadata:{arguments:E.args,result:E.result,error:E.error,durationMs:E.durationMs,success:E.status!=="error",...E.subagentLogs?.length?{subagentLogs:E.subagentLogs}:{}},createdAt:y})}else E.thinking&&(w(),h+=E.thinking,x()),S(Yg(E.content).cleaned);return w(),r}const dX=k.memo(function({msg:t,isStreaming:n,liveActivities:r,onMentionClick:o,knownNames:l}){const{t:c}=ft(["team","common"]),d=t.segments,m=t.isStopped,f=j=>j.type==="text"?j.content.length+(j.thinking?.length??0):(j.result?.length??0)+(j.subagentLogs?.length??0)*1e3+(j.liveOutput?.length??0),h=d?d.length+":"+(d.length>0?f(d[d.length-1]):0):"",g=d?d.reduce((j,L)=>j+(L.type==="tool"?L.subagentLogs?.length??0:0),0):0,y=k.useMemo(()=>d&&d.length>0?_4(d,t.agentId,t.rawCreatedAt):[],[h,g,t.agentId,t.rawCreatedAt]),x=t.committedSegments,w=x?x.length+":"+(x.length>0?f(x[x.length-1]):0):"",C=x?x.reduce((j,L)=>j+(L.type==="tool"?L.subagentLogs?.length??0:0),0):0,T=k.useMemo(()=>n?y:x&&x.length>0?_4(x,t.agentId,t.rawCreatedAt):y,[n,w,C,t.agentId,t.rawCreatedAt,y]);if(d!==void 0&&d.length>0){const j=d.some(z=>z.type==="tool"),L=d.filter(z=>z.type==="text"),I=n?null:L.map(z=>z.content).join(""),O=z=>z.replace(/\n*<!--\s*notify_context:\s*[\s\S]*?-->/g,"").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,V=(I?O(I):null)||(!n&&t.text?O(t.text):null),X=[];for(const z of d){if(z.type!=="tool")continue;const G=W3(z.tool,z.result);if(G){X.push({key:`task-${G.taskId}`,kind:"task",info:G});continue}const se=Y3(z.tool,z.result);se&&X.push({key:`req-${se.requirementId}`,kind:"req",info:se})}return s.jsxs("div",{className:"space-y-2 min-h-[1em] min-w-0 overflow-x-hidden",children:[j||n?s.jsx(ZK,{entries:T,isActive:n,embedded:!0,hideApprovalCards:!0}):V&&s.jsx(Er,{content:V,onMentionClick:o,knownNames:l}),X.map(z=>z.kind==="task"?s.jsx(J3,{info:z.info},z.key):s.jsx(e6,{info:z.info},z.key)),!n&&!V&&!j&&X.length===0&&!m&&(t.emptyReply||!t.isError)&&s.jsx("div",{className:"flex items-start gap-1.5 text-[13px] text-fg-tertiary leading-relaxed",children:s.jsx("span",{children:c("page.emptyReply")})}),!n&&(t.isError||t.text.startsWith("⚠"))&&t.text&&!d?.some(z=>z.type==="text"&&z.content&&(z.content===t.text||z.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:c("page.stopped")})]})]})}const S=(t.activities?.length??0)>0,E=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||S)&&s.jsx(OK,{activities:n?r:t.activities??[],isActive:n,persistent:!n&&S}),E?t.isError||E.startsWith("⚠")?s.jsx("p",{className:"text-[13px] text-fg-tertiary leading-relaxed whitespace-pre-wrap",children:E.replace(/^⚠\s*/,"")}):s.jsx(Er,{content:E,onMentionClick:o,knownNames:l}):null,!n&&!E&&!S&&!m&&t.sender==="agent"&&(t.emptyReply||!t.isError)&&s.jsx("div",{className:"flex items-start gap-1.5 text-[13px] text-fg-tertiary leading-relaxed",children:s.jsx("span",{children:c("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:c("page.stopped")})]})]})});function oW(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 lW({approval:e,submitting:t,readOnly:n,onClose:r,onSubmit:o}){const{t:l}=ft(["team","common"]);Ho(!0);const c=k.useMemo(()=>oW(e),[e]),[d,m]=k.useState(0),[f,h]=k.useState(()=>{if(n&&e.answers&&e.answers.length>0){const I={};for(const O of e.answers)I[O.questionId]={selectedOptionIds:O.selectedOptionIds??[],text:O.text??""};return I}return{}}),g=c[d],y=d===c.length-1,x=c.length>1,w=I=>f[I]??{selectedOptionIds:[],text:""},C=(I,O)=>{h(F=>({...F,[I]:{...w(I),...O}}))},T=(I,O)=>{const F=w(I.id);if(I.allowMultiple){const V=F.selectedOptionIds.includes(O);C(I.id,{selectedOptionIds:V?F.selectedOptionIds.filter(X=>X!==O):[...F.selectedOptionIds,O],text:V?F.text:""})}else{const V=F.selectedOptionIds.includes(O);C(I.id,{selectedOptionIds:V?[]:[O],text:V?F.text:""})}},S=I=>{const O=w(I.id);return I.inputType==="choice"?O.selectedOptionIds.length>0?!0:!!(I.allowFreeform&&O.text.trim()):O.text.trim().length>0},E=c.every(S),j=()=>c.map(I=>{const O=w(I.id),F={questionId:I.id};return O.selectedOptionIds.length>0&&(F.selectedOptionIds=O.selectedOptionIds),O.text.trim()&&(F.text=O.text.trim()),F}),L=()=>{const I=j();let O=!0,F;if(!e.questions?.length&&e.options?.length){const X=I[0];F=X?.selectedOptionIds?.[0]??(X?.text?"custom":void 0),O=F!=="reject"&&F!=="request_changes"}const V=I.map(X=>X.text).filter(Boolean).join(`
663
- `)||void 0;o({approved:O,comment:V,selectedOption:F,answers:I})};return Sa.createPortal(s.jsx("div",{className:"fixed inset-0 z-[10000] flex items-center justify-center p-4 bg-black/50 backdrop-blur-sm",onMouseDown:I=>{I.target===I.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:[x&&s.jsx("div",{className:"flex items-center gap-2",children:c.map((I,O)=>s.jsx("button",{onClick:()=>m(O),className:`h-1.5 flex-1 rounded-full transition-colors ${O===d?"bg-brand-500":S(I)?"bg-green-500/60":"bg-border-default"}`,title:`${O+1}. ${I.prompt.slice(0,40)}`},I.id))}),x&&s.jsx("div",{className:"text-[11px] font-medium text-fg-tertiary",children:l("team:userInput.questionProgress",{current:d+1,total:c.length,defaultValue:`Question ${d+1} of ${c.length}`})}),s.jsx("div",{className:"text-sm text-fg-primary leading-relaxed",children:s.jsx(Er,{content:g.prompt})}),g.inputType==="choice"&&g.options&&s.jsx("div",{className:"space-y-2",children:g.options.map((I,O)=>{const F=w(g.id).selectedOptionIds.includes(I.id);return s.jsxs("button",{onClick:n?void 0:()=>T(g,I.id),disabled:n,className:`w-full px-4 py-3 text-left rounded-xl border transition-colors flex items-start gap-3 ${F?"border-brand-500 bg-brand-500/10":`border-border-default ${n?"":"hover:bg-surface-overlay"}`} ${n?"cursor-default":""} ${n&&!F?"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 ${F?"bg-brand-600 text-white":"bg-surface-overlay text-fg-tertiary"}`,children:F?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+O)}),s.jsxs("span",{className:"flex-1 min-w-0 text-sm text-fg-primary [&_p]:my-0 [&_p]:text-sm",children:[s.jsx(Er,{content:I.label}),I.description&&s.jsx("span",{className:"block text-xs text-fg-tertiary mt-1 [&_p]:my-0 [&_p]:text-xs",children:s.jsx(Er,{content:I.description})})]})]},I.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:I=>{const O=I.target.value;C(g.id,{text:O,selectedOptionIds:O.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:x&&d>0&&s.jsx("button",{onClick:()=>m(I=>Math.max(0,I-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:x&&!y?s.jsx("button",{disabled:!n&&!S(g),onClick:()=>m(I=>Math.min(c.length-1,I+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||!E,onClick:L,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 Ad(e){return Array.isArray(e.questions)&&e.questions.length>0}const Ed={urgent:"bg-red-500",high:"bg-amber-500",normal:"bg-blue-500",low:"bg-gray-400"},To={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"},j4={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 Ao(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 M4="markus:template-updates-ack";let th=!1,_d=null;function cW(e){return e.map(t=>`${t.name}@${t.availableVersion}`).sort().join(",")}function R4(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 jd(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 nh(){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 uW({collapsed:e,userId:t,embeddedMode:n,onClose:r,sidebarMode:o,isActive:l,label:c,iconPath:d}){const{t:m}=ft(["team","common"]),[f,h]=k.useState(!1),[g,y]=k.useState("approvals"),[x,w]=k.useState([]),[C,T]=k.useState([]),[S,E]=k.useState(null),[j,L]=k.useState(null),[I,O]=k.useState(null),[F,V]=k.useState({}),[X,z]=k.useState(0),G=k.useRef(null),se=k.useRef(null),[ee,q]=k.useState({top:0,left:0,width:448,maxHeight:576}),re=k.useRef(null),B=k.useRef(!1),[J,fe]=k.useState(!0),[Se,U]=k.useState(!1),W=k.useRef(null),pe=k.useRef("approvals"),[P,_e]=k.useState(!1),He=30,Pe=k.useCallback(async()=>{try{Ya("/approvals"),Ya("/notifications");const[M,le]=await Promise.all([Ee.notifications.list(t,!1,{limit:He,offset:0}),Ee.approvals.list()]);w(M.notifications);const Oe=M.unreadCount??M.notifications.filter(ge=>!ge.read).length;if(z(Oe),fe(M.totalCount!=null?M.notifications.length<M.totalCount:M.notifications.length>=He),T(le.approvals),!B.current){const ge=le.approvals.filter(Ve=>Ve.status==="pending").length;re.current=ge,B.current=!0}}catch{}},[t]),Ge=k.useCallback(async()=>{if(!(Se||!J)){U(!0);try{const M=await Ee.notifications.list(t,!1,{limit:He,offset:x.length});M.notifications.length>0&&w(le=>[...le,...M.notifications.filter(Oe=>!le.some(ge=>ge.id===Oe.id))]),fe(M.totalCount!=null?x.length+M.notifications.length<M.totalCount:M.notifications.length>=He)}catch{}U(!1)}},[t,x.length,Se,J]),ct=k.useCallback(M=>{const le=M.detail;if(!le)return;const{taskId:Oe,requirementId:ge}=le;!Oe&&!ge||w(Ve=>{const Qe=Ve.filter(K=>!K.read&&(Oe&&K.metadata?.taskId===Oe||ge&&K.metadata?.requirementId===ge));if(Qe.length===0)return Ve;for(const K of Qe)Ee.notifications.markRead(K.id).catch(()=>{});return z(K=>Math.max(0,K-Qe.length)),Ve.map(K=>Qe.some(ce=>ce.id===K.id)?{...K,read:!0}:K)})},[]),mt=k.useRef(x);mt.current=x;const Ct=k.useCallback(async()=>{if(!mt.current.some(le=>!le.read&&le.type==="system"&&le.metadata?.creditExhausted))try{await Ee.notifications.create({title:m("credits.notificationTitle",{ns:"common"}),body:m("credits.notificationBody",{ns:"common"}),type:"system",priority:"urgent",metadata:{creditExhausted:!0}}),Pe(),nh()}catch{}},[Pe,m]),Mt=k.useCallback(async()=>{if(!th){th=!0;try{const{updates:M}=await Ee.skills.updates();if(!M.length)return;const le=cW(M);try{if(localStorage.getItem(M4)===le)return}catch{}if(_d===le||mt.current.some(ge=>!ge.read&&R4(ge,le)))return;try{const Ve=(await Ee.notifications.list(t,!0,{limit:50,type:"system"})).notifications.filter(Qe=>R4(Qe,le)).sort((Qe,K)=>new Date(K.createdAt).getTime()-new Date(Qe.createdAt).getTime());if(Ve.length>0){for(const Qe of Ve.slice(1))Ee.notifications.markRead(Qe.id).catch(()=>{});Ve.length>1&&Pe(),_d=le;return}}catch{}_d=le,await Ee.notifications.create({title:m("templateUpdates.notificationTitle",{ns:"common"}),body:m("templateUpdates.notificationBody",{ns:"common",count:M.length}),type:"system",priority:"high",metadata:{templateUpdates:!0,templateUpdatesFingerprint:le,count:M.length,skills:M.map(ge=>ge.name)}}),Pe(),nh()}catch{_d=null}finally{th=!1}}},[Pe,m,t]);k.useEffect(()=>{Pe();const M=setInterval(Pe,6e4);let le=null;const Oe=()=>{le||(le=setTimeout(()=>{le=null,Pe()},400))},ge=()=>Oe(),Ve=()=>{h(!0),Pe()};window.addEventListener("markus:notifications-changed",ge),window.addEventListener("markus:mark-read-by-ref",ct),window.addEventListener("markus:open-notifications",Ve),window.addEventListener("markus:credit-exhausted",Ct);const Qe=va.on("notification",Oe),K=va.on("approval:requested",Oe);return()=>{clearInterval(M),le&&clearTimeout(le),window.removeEventListener("markus:notifications-changed",ge),window.removeEventListener("markus:mark-read-by-ref",ct),window.removeEventListener("markus:open-notifications",Ve),window.removeEventListener("markus:credit-exhausted",Ct),Qe(),K()}},[Pe,ct,Ct]),k.useEffect(()=>{Mt();const M=setInterval(()=>{Mt()},5*6e4),le=()=>{Mt()};return window.addEventListener("markus:data-changed",le),()=>{clearInterval(M),window.removeEventListener("markus:data-changed",le)}},[t]);const Pt=k.useCallback(()=>{if(!G.current)return;const M=G.current.getBoundingClientRect(),le=window.innerWidth,Oe=window.innerHeight,ge=Math.min(448,le-16),Ve=Math.min(576,Oe-16);let Qe=M.right+8,K=M.top;Qe+ge>le-8&&(Qe=Math.max(8,le-ge-8)),K+Ve>Oe-8&&(K=Math.max(8,Oe-Ve-8)),q({top:K,left:Qe,width:ge,maxHeight:Ve})},[]);k.useLayoutEffect(()=>{f&&Pt()},[f,Pt]),k.useEffect(()=>{if(f)return window.addEventListener("resize",Pt),()=>window.removeEventListener("resize",Pt)},[f,Pt]),k.useEffect(()=>{if(!f)return;const M=le=>{G.current?.contains(le.target)||se.current?.contains(le.target)||h(!1)};return document.addEventListener("mousedown",M),()=>document.removeEventListener("mousedown",M)},[f]),k.useEffect(()=>{if(!f)return;const M=C.some(Oe=>Oe.status==="pending"),le=x.some(Oe=>!Oe.read);y(M&&!le?"approvals":!M&&le?"notifications":pe.current)},[f]);const Kt=new Set(C.filter(M=>M.status==="pending").map(M=>M.id)),yt=new Set(C.map(M=>M.id)),Ue=x.filter(M=>!(M.type==="approval_request"&&M.metadata?.approvalId&&yt.has(M.metadata.approvalId))),dt=x.filter(M=>M.type==="approval_request"&&!M.read&&M.metadata?.approvalId&&Kt.has(M.metadata.approvalId)).length,Nt=Math.max(0,X-dt),bt=Kt.size,Lt=Nt+bt;k.useEffect(()=>{re.current!==null&&bt>re.current&&nh(),re.current=bt},[bt]);const ue=async M=>{await Ee.notifications.markRead(M),w(le=>le.map(Oe=>Oe.id===M?{...Oe,read:!0}:Oe)),z(le=>Math.max(0,le-1)),window.dispatchEvent(new CustomEvent("markus:notifications-changed"))},tt=M=>{const le=M.metadata??{},Oe=M.actionType,ge=M.actionTarget;if(Oe==="open_chat"&&ge)try{const Ve=typeof ge=="string"?JSON.parse(ge):ge;if(Ve.agentId){const Qe={agentId:Ve.agentId};Ve.sessionId&&(Qe.sessionId=Ve.sessionId),it.navigate(de.TEAM,Qe);return}}catch{}if(Oe==="navigate"&&ge)try{const Ve=typeof ge=="string"?JSON.parse(ge):ge;if(Ve.path){if(Ve.path.startsWith("/team")){const Qe={},K=new URLSearchParams(Ve.path.split("?")[1]||"");for(const[ce,Te]of K.entries())Qe[ce]=Te;it.navigate(de.TEAM,Qe);return}if(Ve.path.startsWith("/work")){const Qe={},K=new URLSearchParams(Ve.path.split("?")[1]||"");for(const[ce,Te]of K.entries())Qe[ce]=Te;it.navigate(de.WORK,Qe);return}}}catch{}switch(M.type){case"approval_request":{const Ve=le.approvalId,Qe=Ve?C.find(ze=>ze.id===Ve):void 0;if(Qe&&Ad(Qe)){L(Qe);break}const K=Qe?.details?.taskId??le.taskId,ce=Qe?.details?.requirementId??le.requirementId,Te=Qe?.details?.agentId??Qe?.agentId;K?it.navigate(de.WORK,{openTask:K}):ce?it.navigate(de.WORK,{openRequirement:ce}):Te?it.navigate(de.TEAM,{agentId:Te}):it.navigate(de.WORK);break}case"task_completed":case"task_created":case"task_review":case"task_failed":le.taskId?it.navigate(de.WORK,{openTask:le.taskId}):it.navigate(de.WORK);break;case"requirement_created":case"requirement_decision":le.requirementId?it.navigate(de.WORK,{openRequirement:le.requirementId}):it.navigate(de.WORK);break;case"agent_report":case"system":{if(le.creditExhausted){_e(!0);return}if(le.templateUpdates){const Ve=le.templateUpdatesFingerprint;if(Ve)try{localStorage.setItem(M4,Ve)}catch{}localStorage.setItem("markus_nav_storeTab","installed"),it.navigate(de.STORE);return}if(le.agentId){const Ve={agentId:le.agentId};le.sessionId&&(Ve.sessionId=le.sessionId),it.navigate(de.TEAM,Ve)}else it.navigate(de.TEAM);break}case"direct_message":{const Ve=le.senderId;Ve?it.navigate(de.TEAM,{dm:Ve}):it.navigate(de.TEAM);break}case"group_message":{const Ve=le.channel;Ve?it.navigate(de.TEAM,{channel:Ve}):it.navigate(de.TEAM);break}default:le.taskId?it.navigate(de.WORK,{openTask:le.taskId}):le.requirementId?it.navigate(de.WORK,{openRequirement:le.requirementId}):le.projectId?it.navigate(de.WORK,{projectId:le.projectId}):le.agentId&&it.navigate(de.TEAM,{agentId:le.agentId});break}},st=async M=>{const le=M.metadata??{},Oe=M.actionType,ge=M.type==="agent_report"&&!le.creditExhausted&&!le.templateUpdates&&(Oe==="open_chat"||!!le.agentId&&Oe!=="navigate");!M.read&&!ge&&ue(M.id);const Ve=le.taskId,Qe=le.requirementId;if(!ge&&(Ve||Qe)){const K=x.filter(ce=>ce.id!==M.id&&!ce.read&&(Ve&&ce.metadata?.taskId===Ve||Qe&&ce.metadata?.requirementId===Qe));for(const ce of K)ue(ce.id)}tt(M)},ye=async(M,le,Oe,ge,Ve)=>{E(M);try{const{approval:Qe}=await Ee.approvals.respond(M,le,t,Oe,ge,Ve);T(ze=>ze.map(rt=>rt.id===M?Qe:rt)),L(null),O(null),V(ze=>{const rt={...ze};return delete rt[M],rt});const K=Qe.details?.taskId,ce=Qe.details?.requirementId,Te=x.filter(ze=>!ze.read&&(ze.type==="approval_request"&&ze.metadata?.approvalId===M||K&&ze.metadata?.taskId===K||ce&&ze.metadata?.requirementId===ce));if(Te.length>0){for(const rt of Te)Ee.notifications.markRead(rt.id).catch(()=>{});const ze=new Set(Te.map(rt=>rt.id));w(rt=>rt.map(vt=>ze.has(vt.id)?{...vt,read:!0}:vt)),z(rt=>Math.max(0,rt-Te.length))}Ya("/approvals"),Ya("/notifications"),Ya("/tasks"),Ya("/taskboard"),Ya("/requirements"),window.dispatchEvent(new CustomEvent("markus:data-changed")),window.dispatchEvent(new CustomEvent("markus:notifications-changed")),setTimeout(()=>Pe(),800)}catch{}E(null)},je=async()=>{try{if(!t)return;await Ee.notifications.markAllRead(t),w(M=>M.map(le=>({...le,read:!0}))),z(0),Ya("/notifications"),window.dispatchEvent(new CustomEvent("markus:notifications-changed"))}catch{const M=Ue.filter(le=>!le.read);await Promise.all(M.map(le=>Ee.notifications.markRead(le.id))),w(le=>le.map(Oe=>({...Oe,read:!0}))),z(0),Ya("/notifications"),window.dispatchEvent(new CustomEvent("markus:notifications-changed"))}},Ae=M=>{const le=M.details?.subType;return le==="requirement_resubmit"?m("team:notifications.approvalType.requirementResubmit"):le==="requirement"||M.details?.requirementId?m("team:notifications.approvalType.requirement"):le==="task_review"?m("team:notifications.approvalType.taskReview"):le==="task"||M.details?.taskId?m("team:notifications.approvalType.task"):M.details?.toolName?m("team:notifications.approvalType.toolExecution"):null},oe=M=>{const le=[];le.push(M.agentName);const Oe=M.details?.taskTitle,ge=M.details?.taskId;Oe?le.push(Oe):ge&&le.push(`Task ${ge.slice(0,8)}`);const Ve=M.details?.requirementId;return Ve&&!ge&&le.push(`Req ${Ve.slice(0,8)}`),le.join(" · ")},H=[...C].sort((M,le)=>new Date(le.requestedAt).getTime()-new Date(M.requestedAt).getTime()),te=H.filter(M=>M.status==="pending"),Ne=H.filter(M=>M.status!=="pending"),Re=M=>{const le=M.details?.taskId,Oe=M.details?.requirementId,ge=M.details?.agentId??M.agentId;le?it.navigate(de.WORK,{openTask:le}):Oe?it.navigate(de.WORK,{openRequirement:Oe}):ge?it.navigate(de.TEAM,{agentId:ge}):it.navigate(de.WORK)},$e=()=>{h(!1),r?.()},Q=M=>s.jsxs("button",{disabled:S===M.id,onClick:()=>L(M),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"}),M.questions&&M.questions.length>1?` (${M.questions.length})`:""]}),Z=j?s.jsx(lW,{approval:j,submitting:S===j.id,readOnly:j.status!=="pending",onClose:()=>L(null),onSubmit:M=>ye(j.id,M.approved,M.comment,M.selectedOption,M.answers)}):null,be=s.jsxs(s.Fragment,{children:[s.jsxs("div",{className:"flex border-b border-border-default shrink-0",children:[s.jsxs("button",{onClick:()=>{y("approvals"),pe.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"),bt>0?` (${bt})`:""]}),s.jsxs("button",{onClick:()=>{y("notifications"),pe.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"),Nt>0?` (${Nt})`:""]}),s.jsx("button",{onClick:$e,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"&&X>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:je,className:"text-[10px] text-brand-500 hover:text-brand-400 transition-colors",children:m("team:notifications.markAllRead")})}),s.jsxs("div",{ref:W,className:"flex-1 overflow-y-auto",onScroll:M=>{if(g!=="notifications"||!J||Se)return;const le=M.currentTarget;le.scrollTop+le.clientHeight>=le.scrollHeight-80&&Ge()},children:[g==="approvals"&&(C.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:[te.map(M=>{const le=M.details?.command,Oe=le?M.description.replace(/\s*Command:.*$/,""):M.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:()=>Re(M),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:To.approval_request})}),s.jsxs("div",{className:"flex-1 min-w-0",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[Ae(M)&&s.jsx("span",{className:"text-[10px] text-amber-500 font-medium shrink-0",children:Ae(M)}),s.jsx("span",{className:"text-xs text-fg-primary font-medium truncate",children:M.title}),s.jsx("span",{className:"text-[10px] text-fg-tertiary shrink-0",children:Ao(M.requestedAt,m)})]}),s.jsx("div",{className:"text-[11px] text-fg-tertiary mt-0.5",children:M.agentName})]})]}),s.jsx("div",{className:"mt-2.5 text-[11px] text-fg-secondary leading-relaxed",children:s.jsx(Er,{content:Oe,className:"text-[11px] [&_h1]:text-xs [&_h2]:text-[11px] [&_h3]:text-[11px] [&_p]:text-[11px] [&_li]:text-[11px]"})}),le&&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:le})]}),(()=>{if(Ad(M))return Q(M);const ge=M.details?.subType,Ve=ge==="task"||ge==="requirement"||ge==="requirement_resubmit",Qe=M.options&&M.options.length>0,K=(F[M.id]??"").trim();return Qe?s.jsxs("div",{className:"space-y-1.5",children:[M.options.map((ce,Te)=>s.jsxs("button",{disabled:S===M.id,onClick:()=>ye(M.id,ce.id!=="reject",K||void 0,ce.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 ${ce.id==="reject"||ce.id==="request_changes"?"border border-border-default text-fg-secondary hover:bg-surface-overlay":"bg-brand-600 text-white hover:bg-brand-700"}`,title:ce.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+Te)}),ce.label]},ce.id)),s.jsxs("div",{className:"flex gap-1.5 mt-1",children:[s.jsx("input",{type:"text",placeholder:m("team:notifications.freeformPlaceholder"),value:F[M.id]??"",onChange:ce=>V(Te=>({...Te,[M.id]:ce.target.value})),onKeyDown:ce=>{ce.key==="Enter"&&(F[M.id]??"").trim()&&ye(M.id,!0,(F[M.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:S===M.id||!(F[M.id]??"").trim(),onClick:()=>ye(M.id,!0,(F[M.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")})]})]}):Ve?s.jsxs("div",{className:"space-y-1.5",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsxs("button",{disabled:S===M.id,onClick:()=>ye(M.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:S===M.id,onClick:()=>ye(M.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")]}),I!==M.id&&s.jsxs("button",{disabled:S===M.id,onClick:()=>O(M.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")]})]}),I===M.id&&s.jsxs("div",{className:"space-y-1.5",children:[s.jsx("input",{type:"text",autoFocus:!0,placeholder:m("team:notifications.adjustmentPlaceholder"),value:F[M.id]??"",onChange:ce=>V(Te=>({...Te,[M.id]:ce.target.value})),onKeyDown:ce=>{ce.key==="Enter"&&(F[M.id]??"").trim()&&ye(M.id,!1,(F[M.id]??"").trim(),"needs_adjustment"),ce.key==="Escape"&&O(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:S===M.id||!(F[M.id]??"").trim(),onClick:()=>ye(M.id,!1,(F[M.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:()=>O(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:F[M.id]??"",onChange:ce=>V(Te=>({...Te,[M.id]:ce.target.value})),onKeyDown:ce=>{ce.key==="Enter"&&ye(M.id,!0,K||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:S===M.id,onClick:()=>ye(M.id,!0,K||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:S===M.id,onClick:()=>ye(M.id,!1,K||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")})]})]})})()]},M.id)}),Ne.length>0&&s.jsxs(s.Fragment,{children:[te.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")}),Ne.slice(0,50).map(M=>s.jsxs("button",{onClick:()=>Ad(M)?L(M):Re(M),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 ${M.status==="approved"?"bg-green-500":M.status==="cancelled"||M.status==="expired"?"bg-gray-400":"bg-red-500"}`}),Ae(M)&&s.jsx("span",{className:"text-[10px] text-fg-tertiary font-medium shrink-0",children:Ae(M)}),s.jsx("span",{className:"text-xs text-fg-secondary truncate flex-1 group-hover:text-fg-primary",children:M.title}),s.jsx("span",{className:`text-[10px] font-medium shrink-0 ${M.status==="approved"?"text-green-500":M.status==="cancelled"||M.status==="expired"?"text-fg-muted":"text-red-500"}`,children:m(`common:status.${M.status}`,{defaultValue:M.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:oe(M)}),s.jsx("span",{className:"text-[10px] text-fg-muted shrink-0",children:"·"}),s.jsx("span",{className:"text-[10px] text-fg-muted shrink-0",children:Ao(M.respondedAt??M.requestedAt,m)})]}),M.responseComment&&s.jsxs("p",{className:"text-[10px] text-fg-muted mt-0.5 pl-3.5 truncate",children:["“",M.responseComment,"”"]})]},M.id))]})]})),g==="notifications"&&(Ue.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:[Ue.map(M=>{const le=j4[M.type]??"text-fg-tertiary";return s.jsxs("div",{role:"button",tabIndex:0,onClick:()=>st(M),onKeyDown:Oe=>{(Oe.key==="Enter"||Oe.key===" ")&&(Oe.preventDefault(),st(M))},className:`w-full text-left px-3 py-2.5 flex gap-2.5 transition-colors cursor-pointer ${M.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:le,children:s.jsx("path",{d:To[M.type]??To.system})})}),s.jsxs("div",{className:"flex-1 min-w-0",children:[s.jsxs("div",{className:"flex items-center gap-1.5",children:[!M.read&&s.jsx("span",{className:`w-1.5 h-1.5 rounded-full shrink-0 ${Ed[M.priority]??Ed.normal}`}),s.jsx("span",{className:"text-xs text-fg-primary font-medium truncate",children:M.title})]}),s.jsx("div",{className:"text-[11px] text-fg-tertiary mt-0.5 ",children:s.jsx(Er,{content:M.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:Ao(M.createdAt,m)}),jd(M,m)&&s.jsx("span",{className:`text-[10px] font-medium ${le}`,children:jd(M,m)})]})]})]},M.id)}),Se&&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"})]})})]}))]})]}),Ke=k.useCallback(M=>{M?.mute&&iW()},[]),Ie=k.useCallback(M=>{Ke(M),_e(!1)},[Ke]),Ye=P?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:()=>_e(!1),onCancelClick:M=>{Ie(M),it.navigate(de.SETTINGS),setTimeout(()=>{window.location.hash="settings/providers"},50)},onConfirm:M=>{const le=`${lt.getUrl().replace(/\/$/,"")}/settings?tab=billing`;Ie(M),_i(le)}}):null;if(n){const M=["approvals","notifications"],le=M.indexOf(g),Oe=(()=>{let ge=0,Ve=0;return{onTouchStart:Qe=>{ge=Qe.touches[0].clientX,Ve=Qe.touches[0].clientY},onTouchEnd:Qe=>{const K=Qe.changedTouches[0].clientX-ge,ce=Qe.changedTouches[0].clientY-Ve;Math.abs(K)>60&&Math.abs(K)>Math.abs(ce)*1.5&&(K<0&&le<M.length-1&&y(M[le+1]),K>0&&le>0&&y(M[le-1]))}}})();return s.jsxs(s.Fragment,{children:[Ye,s.jsxs("div",{className:"flex flex-col h-full overflow-hidden",children:[Z,s.jsx("div",{className:"flex border-b border-border-default shrink-0",children:M.map(ge=>s.jsx("button",{onClick:()=>y(ge),className:`flex-1 px-3 py-3 text-sm font-medium transition-colors ${g===ge?"text-fg-primary border-b-2 border-brand-500":"text-fg-tertiary"}`,children:ge==="approvals"?s.jsxs(s.Fragment,{children:[m("team:notifications.approvals"),bt>0?` (${bt})`:""]}):s.jsxs(s.Fragment,{children:[m("team:notifications.notifications"),Nt>0?` (${Nt})`:""]})},ge))}),g==="notifications"&&X>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:je,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",...Oe,children:s.jsxs("div",{className:"flex h-full transition-transform duration-300 ease-out",style:{transform:`translateX(-${le*100}%)`},children:[s.jsx("div",{className:"w-full shrink-0 h-full overflow-y-auto scrollbar-thin",children:C.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:[te.map(ge=>{const Ve=ge.details?.command,Qe=Ve?ge.description.replace(/\s*Command:.*$/,""):ge.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:()=>Re(ge),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:To.approval_request})}),s.jsxs("div",{className:"flex-1 min-w-0",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[Ae(ge)&&s.jsx("span",{className:"text-[10px] text-amber-500 font-medium shrink-0",children:Ae(ge)}),s.jsx("span",{className:"text-xs text-fg-primary font-medium truncate",children:ge.title}),s.jsx("span",{className:"text-[10px] text-fg-tertiary shrink-0",children:Ao(ge.requestedAt,m)})]}),s.jsx("div",{className:"text-[11px] text-fg-tertiary mt-0.5",children:ge.agentName})]})]}),s.jsx("div",{className:"mt-2.5 text-[11px] text-fg-secondary leading-relaxed",children:s.jsx(Er,{content:Qe,className:"text-[11px] [&_h1]:text-xs [&_h2]:text-[11px] [&_h3]:text-[11px] [&_p]:text-[11px] [&_li]:text-[11px]"})}),Ve&&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:Ve})]}),(()=>{if(Ad(ge))return Q(ge);const K=ge.details?.subType,ce=K==="task"||K==="requirement"||K==="requirement_resubmit",Te=ge.options&&ge.options.length>0,ze=(F[ge.id]??"").trim();return Te?s.jsxs("div",{className:"space-y-1.5",children:[ge.options.map((rt,vt)=>s.jsxs("button",{disabled:S===ge.id,onClick:()=>ye(ge.id,rt.id!=="reject",ze||void 0,rt.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 ${rt.id==="reject"||rt.id==="request_changes"?"border border-border-default text-fg-secondary hover:bg-surface-overlay":"bg-brand-600 text-white hover:bg-brand-700"}`,title:rt.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+vt)}),rt.label]},rt.id)),s.jsxs("div",{className:"flex gap-1.5 mt-1",children:[s.jsx("input",{type:"text",placeholder:m("team:notifications.freeformPlaceholder"),value:F[ge.id]??"",onChange:rt=>V(vt=>({...vt,[ge.id]:rt.target.value})),onKeyDown:rt=>{rt.key==="Enter"&&(F[ge.id]??"").trim()&&ye(ge.id,!0,(F[ge.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:S===ge.id||!(F[ge.id]??"").trim(),onClick:()=>ye(ge.id,!0,(F[ge.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")})]})]}):ce?s.jsxs("div",{className:"space-y-1.5",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsxs("button",{disabled:S===ge.id,onClick:()=>ye(ge.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:S===ge.id,onClick:()=>ye(ge.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")]}),I!==ge.id&&s.jsxs("button",{disabled:S===ge.id,onClick:()=>O(ge.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")]})]}),I===ge.id&&s.jsxs("div",{className:"space-y-1.5",children:[s.jsx("input",{type:"text",autoFocus:!0,placeholder:m("team:notifications.adjustmentPlaceholder"),value:F[ge.id]??"",onChange:rt=>V(vt=>({...vt,[ge.id]:rt.target.value})),onKeyDown:rt=>{rt.key==="Enter"&&(F[ge.id]??"").trim()&&ye(ge.id,!1,(F[ge.id]??"").trim(),"needs_adjustment"),rt.key==="Escape"&&O(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:S===ge.id||!(F[ge.id]??"").trim(),onClick:()=>ye(ge.id,!1,(F[ge.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:()=>O(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:F[ge.id]??"",onChange:rt=>V(vt=>({...vt,[ge.id]:rt.target.value})),onKeyDown:rt=>{rt.key==="Enter"&&ye(ge.id,!0,ze||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:S===ge.id,onClick:()=>ye(ge.id,!0,ze||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:S===ge.id,onClick:()=>ye(ge.id,!1,ze||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")})]})]})})()]},ge.id)}),Ne.length>0&&s.jsxs(s.Fragment,{children:[te.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")}),Ne.slice(0,50).map(ge=>s.jsxs("button",{onClick:()=>Re(ge),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 ${ge.status==="approved"?"bg-green-500":ge.status==="cancelled"||ge.status==="expired"?"bg-gray-400":"bg-red-500"}`}),s.jsx("span",{className:"text-xs text-fg-secondary truncate flex-1",children:ge.title}),s.jsx("span",{className:`text-[10px] font-medium shrink-0 ${ge.status==="approved"?"text-green-500":ge.status==="cancelled"||ge.status==="expired"?"text-fg-muted":"text-red-500"}`,children:m(`common:status.${ge.status}`,{defaultValue:ge.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:oe(ge)}),s.jsx("span",{className:"text-[10px] text-fg-muted shrink-0",children:"·"}),s.jsx("span",{className:"text-[10px] text-fg-muted shrink-0",children:Ao(ge.respondedAt??ge.requestedAt,m)})]})]},ge.id))]})]})}),s.jsx("div",{className:"w-full shrink-0 h-full overflow-y-auto scrollbar-thin",children:Ue.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:Ue.slice(0,50).map(ge=>{const Ve=j4[ge.type]??"text-fg-tertiary";return s.jsxs("button",{onClick:()=>st(ge),className:`w-full text-left px-3 py-2.5 flex gap-2.5 transition-colors ${ge.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:Ve,children:s.jsx("path",{d:To[ge.type]??To.system})})}),s.jsxs("div",{className:"flex-1 min-w-0",children:[s.jsxs("div",{className:"flex items-center gap-1.5",children:[!ge.read&&s.jsx("span",{className:`w-1.5 h-1.5 rounded-full shrink-0 ${Ed[ge.priority]??Ed.normal}`}),s.jsx("span",{className:"text-xs text-fg-primary font-medium truncate",children:ge.title})]}),s.jsx("div",{className:"text-[11px] text-fg-tertiary mt-0.5 ",children:s.jsx(Er,{content:ge.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:Ao(ge.createdAt,m)}),jd(ge,m)&&s.jsx("span",{className:`text-[10px] font-medium ${Ve}`,children:jd(ge,m)})]})]})]},ge.id)})})})]})})]})]})}if(o){const M=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:[Z,s.jsxs("button",{ref:G,onClick:()=>{h(!f),f||Pe()},title:e?c||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 ${f||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:M})}),e?s.jsx("span",{className:"text-[9px] leading-tight truncate w-full text-center",children:c}):s.jsx("span",{className:"truncate",children:c}),Lt>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:Lt>99?m("common:badgeOverLimit"):Lt})]}),f&&Sa.createPortal(s.jsx("div",{ref:se,className:"fixed bg-surface-secondary border border-border-default rounded-xl shadow-2xl z-[9999] flex flex-col overflow-hidden",style:{top:ee.top,left:ee.left,width:ee.width,maxHeight:ee.maxHeight},children:be}),document.body),Ye]})}return s.jsxs(s.Fragment,{children:[Z,s.jsxs("button",{ref:G,onClick:()=>{h(!f),f||Pe()},className:`relative flex items-center justify-center rounded-md transition-colors ${e?"w-8 h-8":"w-7 h-7"} ${f?"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"})]}),Lt>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:Lt>99?m("common:badgeOverLimit"):Lt})]}),f&&Sa.createPortal(s.jsx("div",{ref:se,className:"fixed bg-surface-secondary border border-border-default rounded-xl shadow-2xl z-[9999] flex flex-col overflow-hidden",style:{top:ee.top,left:ee.left,width:ee.width,maxHeight:ee.maxHeight},children:be}),document.body),Ye]})}function Md({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 rh=200;function dW({authUser:e,onLogout:t,onEditProfile:n,showSettingsLink:r=!1,collapsed:o=!1,showVersion:l=!1}){const{t:c}=ft(["nav","common"]),[d,m]=k.useState(!1),[f,h]=k.useState(!1),[g,y]=k.useState(()=>lt.isAuthenticated()),[x,w]=k.useState(()=>sa()),[C,T]=k.useState({top:0,left:0}),S=k.useRef(null),E=k.useRef(null),j=k.useCallback(ee=>{if(w(sa()),!lt.isAuthenticated()){y(!1);return}if(!ee?.validate){y(!0);return}Cw().then(q=>{y(q),w(sa())})},[]);k.useEffect(()=>{j({validate:!0});const ee=()=>j(),q=()=>j({validate:!0});return window.addEventListener("markus:hub-auth",ee),window.addEventListener("focus",q),()=>{window.removeEventListener("markus:hub-auth",ee),window.removeEventListener("focus",q)}},[j]);const L=k.useCallback(()=>{if(!S.current)return;const ee=S.current.getBoundingClientRect(),q=window.innerWidth,re=window.innerHeight,B=E.current?.offsetHeight??220;let J=ee.right+8;J+rh>q-8&&(J=Math.max(8,ee.left-rh-8));let fe=ee.top-B-8;fe<8&&(fe=Math.min(ee.bottom+8,re-B-8)),T({top:Math.max(8,fe),left:J})},[]);k.useLayoutEffect(()=>{if(!d)return;L();const ee=requestAnimationFrame(()=>L());return()=>cancelAnimationFrame(ee)},[d,L,o]),k.useEffect(()=>{if(!d)return;const ee=re=>{const B=re.target;S.current?.contains(B)||E.current?.contains(B)||m(!1)},q=()=>L();return document.addEventListener("mousedown",ee),window.addEventListener("resize",q),window.addEventListener("scroll",q,!0),()=>{document.removeEventListener("mousedown",ee),window.removeEventListener("resize",q),window.removeEventListener("scroll",q,!0)}},[d,L]);const I=e?.name||x?.displayName||x?.username||c("common:userPlaceholder"),O=e?.email||x?.email||"",F=Ew(e?.avatarUrl,x?.avatarUrl),V=g?"bg-emerald-500":"bg-fg-muted",X=g?x?.username?c("sidebar.hubConnectedAs",{username:x.username}):c("sidebar.hubConnected"):c("sidebar.hubDisconnected"),z=!!(g&&x?.username&&e?.name&&x.username.toLowerCase()!==e.name.toLowerCase()&&x.email?.toLowerCase()!==e.email?.toLowerCase()),G=()=>{m(!1),j({validate:!0}),it.navigate(de.SETTINGS,{tab:"account"})},se=d&&Sa.createPortal(s.jsxs("div",{ref:E,className:"fixed bg-surface-elevated border border-border-default rounded-xl shadow-xl z-[9999] overflow-hidden",style:{top:C.top,left:C.left,width:rh},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:I}),O&&s.jsx("div",{className:"text-xs text-fg-tertiary mt-0.5 truncate",children:O})]}),n&&s.jsx("button",{type:"button",onClick:()=>{m(!1),n()},title:c("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(Md,{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:G,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 ${V}`}),s.jsxs("span",{className:"min-w-0 flex-1",children:[s.jsx("span",{className:"text-xs text-fg-secondary block truncate",children:X}),z&&x?.username&&s.jsx("span",{className:"text-[10px] text-amber-500/90 block truncate mt-0.5",children:c("sidebar.hubAccountMismatch",{username:x.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),it.navigate(de.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(Md,{d:hc[de.SETTINGS]}),c("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(Md,{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"}),c("common:openInBrowser")]}),t&&s.jsxs("button",{type:"button",onClick:()=>{m(!1),h(!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(Md,{d:"M9 21H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h4M16 17l5-5-5-5M21 12H9"}),c("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:S,type:"button",onClick:()=>m(ee=>!ee),title:I,className:`relative inline-flex items-center justify-center rounded-full transition-opacity hover:opacity-90 ${o?"p-0.5":""}`,children:[s.jsx(Hs,{name:I,avatarUrl:F,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 ${V}`,title:X})]}),l&&!o&&s.jsxs("span",{className:"text-[10px] text-fg-muted select-none shrink-0",children:["v","0.9.7-rc.1"]}),se,f&&t&&s.jsx(dr,{title:c("common:signOutConfirmTitle"),message:c("common:signOutConfirmMessage"),confirmLabel:c("common:signOut"),variant:"primary",onConfirm:()=>{h(!1),t()},onCancel:()=>h(!1)})]})}function mW({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 fW({currentPage:e,onNavigate:t,authUser:n,collapsed:r,onToggleCollapse:o,onLogout:l,keyboardFocusPageId:c,keyboardPaneActive:d}){const{t:m}=ft(["nav","common"]);return s.jsxs("aside",{"data-keyboard-pane":"l0",className:"markus-app-sidebar h-dvh bg-surface-secondary flex flex-col shrink-0 overflow-hidden",children:[s.jsx("div",{"data-electron-drag":!0,className:`electron-mac-sidebar-header flex items-center ${r?"px-2 py-3.5 justify-center":"px-4 h-14 justify-between"}`,children:s.jsxs("button",{"data-no-drag":!0,onClick:o,title:m(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:YO.map((f,h)=>{const g=vw.filter(x=>x.section===f.key);if(g.length===0)return null;const y=m(`sections.${f.key}`);return s.jsx("div",{children:s.jsxs("div",{className:h>0?"mt-3":"",children:[!r&&y&&s.jsx("div",{className:"px-3 py-1.5 mb-1 text-[10px] font-semibold text-fg-muted uppercase tracking-[0.1em]",children:y}),r&&h>0&&s.jsx("div",{className:"my-3"}),g.map(x=>{if(x.id===de.NOTIFICATIONS)return s.jsx(uW,{sidebarMode:!0,collapsed:r,userId:n?.id,label:m(x.id),iconPath:hc[x.id],isActive:e===x.id},x.id);const w=e===x.id,C=d&&c===x.id;return s.jsxs("button",{"data-l0-page-id":x.id,onClick:()=>t(x.id),title:r?m(x.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 ${C?"bg-brand-500/25 ring-1 ring-inset ring-brand-500/40":w?"bg-surface-overlay":"hover:bg-surface-overlay/60"}`,children:[s.jsx(mW,{d:hc[x.id]??"",size:r?16:18}),r?s.jsx("span",{className:"text-[9px] leading-tight truncate w-full text-center",children:m(x.id)}):s.jsx("span",{className:"truncate",children:m(x.id)})]},x.id)})]})},f.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(dW,{authUser:n,onLogout:l,onEditProfile:()=>{window.dispatchEvent(new Event("markus:open-edit-profile"))},showSettingsLink:!1,collapsed:r,showVersion:!r})})]})}const pW=6e4;let zs={},xi={};const tg=new Set,ng=new Set;let r6=0,uc=null,Rd=0,Kd=null;function w0(){for(const e of tg)e()}async function rg(){try{const e=await Ee.unread.getCounts();zs=e.counts??{},xi=e.sessionAgentMap??{},w0()}catch{}}function hW(){uc||(rg(),uc=setInterval(rg,pW),Kd=va.on("chat:unread_update",e=>{const t=e.payload?.conversationKey;t&&!ng.has(t)&&Date.now()>r6&&(zs[t]=(zs[t]??0)+1,w0())}))}function gW(){uc&&(clearInterval(uc),uc=null),Kd&&(Kd(),Kd=null)}function bW(e){const t=e?.enabled??!0,[n,r]=k.useState(zs),[o,l]=k.useState(xi),c=k.useCallback(async()=>{await rg()},[]),d=k.useCallback(async w=>{const C=new Date().toISOString();delete zs[w],w0();try{await Ee.unread.markRead(w,C)}catch{}},[]),m=k.useCallback(async()=>{zs={},w0();try{await Ee.unread.markAllRead()}catch{}},[]),f=k.useCallback(w=>{ng.add(w)},[]),h=k.useCallback(w=>{ng.delete(w),r6=Date.now()+150},[]);k.useEffect(()=>{if(!t)return;Rd++,hW();let w=xi;const C=()=>{r({...zs}),w!==xi&&(w=xi,l({...xi}))};return tg.add(C),r({...zs}),l({...xi}),()=>{tg.delete(C),Rd--,Rd<=0&&(Rd=0,gW())}},[t]);const g=k.useMemo(()=>Object.values(n).reduce((w,C)=>w+C,0),[n]),y=k.useCallback(w=>n[`session:${w}`]??0,[n]),x=k.useCallback(w=>n[`channel:${w}`]??0,[n]);return{counts:n,totalUnread:g,sessionAgentMap:o,getSessionUnread:y,getChannelUnread:x,markRead:d,markAllRead:m,refresh:c,setActiveKey:f,clearActiveKey:h}}function mX(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),c=e[l];c&&n.set(c,(n.get(c)??0)+o)}return n},[e,t])}function xW({currentPage:e,onNavigate:t,userId:n}){const{t:r}=ft("nav"),[o,l]=k.useState(0),{counts:c}=bW({enabled:!0}),d=k.useMemo(()=>{let f=0;for(const h of Object.values(c))f+=h;return f},[c]),m=k.useCallback(async()=>{try{const f=await Ee.notifications.list(n,!1);l(f.unreadCount??f.notifications.filter(h=>!h.read).length)}catch{}},[n]);return k.useEffect(()=>{m();const f=setInterval(()=>{document.visibilityState==="visible"&&m()},3e4),h=()=>m();return window.addEventListener("markus:notifications-changed",h),()=>{clearInterval(f),window.removeEventListener("markus:notifications-changed",h)}},[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:QO.map(f=>{const h=f.group.includes(e),g=f.id===de.NOTIFICATIONS,y=f.id===de.TEAM;return s.jsxs("button",{onClick:()=>t(f.id),className:`flex-1 flex flex-col items-center justify-center gap-0.5 transition-colors ${h?"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:h?2:1.75,strokeLinecap:"round",strokeLinejoin:"round",className:"shrink-0",children:s.jsx("path",{d:hc[f.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}),y&&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 ${h?"font-semibold":""}`,children:r(f.id)})]},f.id)})})}const k0=new Map;function gi(e,t){k0.has(e)||k0.set(e,t().catch(()=>{}))}function Si(e){const t=k0.get(e);return k0.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"},Ei={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 Xo(e){const t=(e||"").toLowerCase();return t==="team"?"team":t==="skill"?"skill":t==="connector"||t==="mcp"?"connector":"agent"}function a6(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 yW={agent:258,team:205,skill:32,connector:162};function Xg(e,t){const n=yW[e],r=a6(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 L4=["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 s6(e){return L4[a6(e+"g")%L4.length]}function i6(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 vW(e){return!e||i6(e)?!1:[...e].length<=4&&new RegExp("\\p{Extended_Pictographic}","u").test(e)}function wW(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 Mo(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 O4(e,t="usd"){return!e||e<=0?"Free":`${t.toLowerCase()==="usd"?"$":""}${(e/100).toFixed(e%100===0?0:2)}`}const D4={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"}},kW=["development","devops","management","productivity","browser","custom","general"],SW=[{label:"Tech",emojis:["✦","◈","⬡","⚡","🤖","🧠","💡","🎯","🔧","📦","🚀","💻","🛠️","⭐","🔥","💎","⚙️","🧩","🔌","💾","🖥️","📡","🔬","🧪","🏗️","📱","🎮","🕹️","📟","💽","🖨️","⌨️"]},{label:"People",emojis:["👤","👥","🧑‍💻","👨‍💼","👩‍🔬","🧙","🦸","🤝","💪","🎓","👷","🕵️","🧑‍🎨","🧑‍🏫","👨‍🚀","🥷","🧑‍🏭","🧑‍⚕️","🧑‍🔧","🧑‍🍳","👨‍🎤","🦹","🧝","🧞","🧑‍✈️","💂","🤴","👸","🧛","🧟","🧜","🧚"]},{label:"Objects",emojis:["📝","📊","🗂️","📁","🔍","🔑","🌐","💬","🔒","🎨","📐","🗃️","📋","✏️","🖊️","📌","📎","🧲","🪝","🧰","🪜","🧬","🔭","💊","🩺","📕","📗","📘","📙","📓","🗒️","📰"]},{label:"Symbols",emojis:["❤️","🧡","💛","💚","💙","💜","🖤","🤍","♠️","♥️","♦️","♣️","🎵","🎶","💯","✅","❌","⭕","🔴","🟠","🟡","🟢","🔵","🟣","⚫","⚪","🟤","🔶","🔷","▶️","⏸️","⏹️"]},{label:"Nature",emojis:["🌟","🌈","🌊","🌿","🍀","🔮","💫","✨","🌙","☀️","🦋","🐉","🦊","🐺","🦅","🐙","🦁","🐯","🦄","🐲","🌸","🌺","🍄","🌵","🎄","🌴","🍁","🌻","🐝","🦎","🐍","🦈"]},{label:"Activity",emojis:["🎯","🏆","🥇","🎖️","🏅","🎪","🎭","🎬","🎤","🎧","🎼","🎹","🥁","🎸","🎺","🎻","⚽","🏀","🎾","🏐","🎲","🧸","🪁","🎰","🎳","🏹","🥊","🤺","⛷️","🏄","🚴","🧗"]}],NW={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 ah({value:e,onChange:t,renderAs:n="span",className:r,editClassName:o,placeholder:l,multiline:c,readOnly:d}){if(d){const j=e||l,I=`${r??""} ${!e?"text-fg-muted italic":""}`;return n==="h1"?s.jsx("h1",{className:I,children:j}):n==="p"?s.jsx("p",{className:I,children:j}):s.jsx("span",{className:I,children:j})}const[m,f]=k.useState(!1),[h,g]=k.useState(e),y=k.useRef(null);k.useEffect(()=>{g(e)},[e]),k.useEffect(()=>{m&&y.current?.focus()},[m]);const x=()=>{f(!1),h!==e&&t(h)},w=()=>{g(e),f(!1)},C=j=>{j.key==="Escape"&&w(),j.key==="Enter"&&!c&&x()};if(m){const j=`bg-transparent outline-none w-full ${o??r??""} ring-1 ring-brand-500/50 rounded px-1 -mx-1`;return c?s.jsx("textarea",{ref:y,value:h,onChange:L=>g(L.target.value),onBlur:x,onKeyDown:C,className:`${j} resize-y min-h-[60px]`,placeholder:l}):s.jsx("input",{ref:y,value:h,onChange:L=>g(L.target.value),onBlur:x,onKeyDown:C,className:j,placeholder:l})}const T=e||l,S=!e,E="cursor-text hover:ring-1 hover:ring-border-default rounded px-1 -mx-1 transition-all";return n==="h1"?s.jsx("h1",{onClick:()=>f(!0),className:`${r??""} ${E} ${S?"text-fg-muted italic":""}`,children:T}):n==="p"?s.jsx("p",{onClick:()=>f(!0),className:`${r??""} ${E} ${S?"text-fg-muted italic":""}`,children:T}):n==="badge"?s.jsx("span",{onClick:()=>f(!0),className:`${r??""} ${E} ${S?"text-fg-muted italic":""}`,children:T}):s.jsx("span",{onClick:()=>f(!0),className:`${r??""} ${E} ${S?"text-fg-muted italic":""}`,children:T})}function CW({value:e,options:t,onChange:n,className:r,readOnly:o}){if(o)return s.jsx("span",{className:r,children:e});const[l,c]=k.useState(!1),[d,m]=k.useState(e),f=k.useRef(null),h=k.useRef(null);k.useEffect(()=>{l&&(m(e),setTimeout(()=>f.current?.focus(),0))},[l,e]);const g=t.filter(x=>x.toLowerCase().includes(d.toLowerCase())),y=x=>{const w=x.trim();w&&w!==e&&n(w),c(!1)};return l?s.jsxs("div",{ref:h,className:"relative inline-block",children:[s.jsx("input",{ref:f,value:d,onChange:x=>m(x.target.value),onKeyDown:x=>{x.key==="Enter"?(x.preventDefault(),y(d)):x.key==="Escape"&&c(!1)},onBlur:x=>{h.current?.contains(x.relatedTarget)||y(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(x=>s.jsx("button",{onMouseDown:w=>{w.preventDefault(),y(x)},className:`block w-full text-left px-3 py-1.5 text-xs hover:bg-surface-secondary/80 transition-colors ${x===e?"text-brand-400 font-medium":"text-fg-secondary"}`,children:x},x))})]}):s.jsx("span",{onClick:()=>c(!0),className:`${r??""} cursor-pointer hover:ring-1 hover:ring-border-default rounded px-1 -mx-1 transition-all`,children:e})}function TW({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(h=>s.jsx("span",{className:"text-[10px] px-2 py-0.5 bg-surface-elevated text-fg-muted rounded-full border border-border-default",children:h},h))});const{t:r}=ft(["builder"]),[o,l]=k.useState(!1),[c,d]=k.useState(""),m=k.useRef(null);k.useEffect(()=>{o&&m.current?.focus()},[o]);const f=h=>{if((h.key==="Enter"||h.key===",")&&c.trim()){h.preventDefault();const g=c.trim().toLowerCase();e.includes(g)||t([...e,g]),d("")}else h.key==="Backspace"&&!c&&e.length>0?t(e.slice(0,-1)):h.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(h=>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:[h,s.jsx("button",{onClick:()=>t(e.filter(g=>g!==h)),className:"text-fg-muted hover:text-red-500",children:"×"})]},h)),s.jsx("input",{ref:m,value:c,onChange:h=>d(h.target.value),onKeyDown:f,onBlur:()=>{c||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(h=>s.jsx("span",{className:"text-[10px] px-2 py-0.5 bg-surface-elevated text-fg-muted rounded-full border border-border-default",children:h},h)):s.jsx("span",{className:"text-[10px] text-fg-muted italic",children:r("detail.typeTagAndEnter")})})}function ag({content:e}){const t=[q5,Vk,Kk],n=[M3,[n3,{strict:"ignore"}],[v3,{detect:!0,ignoreMissing:!0}]],r=q3({});return s.jsx("div",{className:`prose prose-invert prose-sm max-w-none
663
+ `)||void 0;o({approved:O,comment:V,selectedOption:F,answers:I})};return Sa.createPortal(s.jsx("div",{className:"fixed inset-0 z-[10000] flex items-center justify-center p-4 bg-black/50 backdrop-blur-sm",onMouseDown:I=>{I.target===I.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:[x&&s.jsx("div",{className:"flex items-center gap-2",children:c.map((I,O)=>s.jsx("button",{onClick:()=>m(O),className:`h-1.5 flex-1 rounded-full transition-colors ${O===d?"bg-brand-500":S(I)?"bg-green-500/60":"bg-border-default"}`,title:`${O+1}. ${I.prompt.slice(0,40)}`},I.id))}),x&&s.jsx("div",{className:"text-[11px] font-medium text-fg-tertiary",children:l("team:userInput.questionProgress",{current:d+1,total:c.length,defaultValue:`Question ${d+1} of ${c.length}`})}),s.jsx("div",{className:"text-sm text-fg-primary leading-relaxed",children:s.jsx(Er,{content:g.prompt})}),g.inputType==="choice"&&g.options&&s.jsx("div",{className:"space-y-2",children:g.options.map((I,O)=>{const F=w(g.id).selectedOptionIds.includes(I.id);return s.jsxs("button",{onClick:n?void 0:()=>T(g,I.id),disabled:n,className:`w-full px-4 py-3 text-left rounded-xl border transition-colors flex items-start gap-3 ${F?"border-brand-500 bg-brand-500/10":`border-border-default ${n?"":"hover:bg-surface-overlay"}`} ${n?"cursor-default":""} ${n&&!F?"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 ${F?"bg-brand-600 text-white":"bg-surface-overlay text-fg-tertiary"}`,children:F?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+O)}),s.jsxs("span",{className:"flex-1 min-w-0 text-sm text-fg-primary [&_p]:my-0 [&_p]:text-sm",children:[s.jsx(Er,{content:I.label}),I.description&&s.jsx("span",{className:"block text-xs text-fg-tertiary mt-1 [&_p]:my-0 [&_p]:text-xs",children:s.jsx(Er,{content:I.description})})]})]},I.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:I=>{const O=I.target.value;C(g.id,{text:O,selectedOptionIds:O.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:x&&d>0&&s.jsx("button",{onClick:()=>m(I=>Math.max(0,I-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:x&&!y?s.jsx("button",{disabled:!n&&!S(g),onClick:()=>m(I=>Math.min(c.length-1,I+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||!E,onClick:L,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 Ad(e){return Array.isArray(e.questions)&&e.questions.length>0}const Ed={urgent:"bg-red-500",high:"bg-amber-500",normal:"bg-blue-500",low:"bg-gray-400"},To={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"},j4={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 Ao(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 M4="markus:template-updates-ack";let th=!1,_d=null;function cW(e){return e.map(t=>`${t.name}@${t.availableVersion}`).sort().join(",")}function R4(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 jd(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 nh(){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 uW({collapsed:e,userId:t,embeddedMode:n,onClose:r,sidebarMode:o,isActive:l,label:c,iconPath:d}){const{t:m}=ft(["team","common"]),[f,h]=k.useState(!1),[g,y]=k.useState("approvals"),[x,w]=k.useState([]),[C,T]=k.useState([]),[S,E]=k.useState(null),[j,L]=k.useState(null),[I,O]=k.useState(null),[F,V]=k.useState({}),[X,z]=k.useState(0),G=k.useRef(null),se=k.useRef(null),[ee,q]=k.useState({top:0,left:0,width:448,maxHeight:576}),re=k.useRef(null),B=k.useRef(!1),[J,fe]=k.useState(!0),[Se,U]=k.useState(!1),W=k.useRef(null),pe=k.useRef("approvals"),[P,_e]=k.useState(!1),He=30,Pe=k.useCallback(async()=>{try{Ya("/approvals"),Ya("/notifications");const[M,le]=await Promise.all([Ee.notifications.list(t,!1,{limit:He,offset:0}),Ee.approvals.list()]);w(M.notifications);const Oe=M.unreadCount??M.notifications.filter(ge=>!ge.read).length;if(z(Oe),fe(M.totalCount!=null?M.notifications.length<M.totalCount:M.notifications.length>=He),T(le.approvals),!B.current){const ge=le.approvals.filter(Ve=>Ve.status==="pending").length;re.current=ge,B.current=!0}}catch{}},[t]),Ge=k.useCallback(async()=>{if(!(Se||!J)){U(!0);try{const M=await Ee.notifications.list(t,!1,{limit:He,offset:x.length});M.notifications.length>0&&w(le=>[...le,...M.notifications.filter(Oe=>!le.some(ge=>ge.id===Oe.id))]),fe(M.totalCount!=null?x.length+M.notifications.length<M.totalCount:M.notifications.length>=He)}catch{}U(!1)}},[t,x.length,Se,J]),ct=k.useCallback(M=>{const le=M.detail;if(!le)return;const{taskId:Oe,requirementId:ge}=le;!Oe&&!ge||w(Ve=>{const Qe=Ve.filter(K=>!K.read&&(Oe&&K.metadata?.taskId===Oe||ge&&K.metadata?.requirementId===ge));if(Qe.length===0)return Ve;for(const K of Qe)Ee.notifications.markRead(K.id).catch(()=>{});return z(K=>Math.max(0,K-Qe.length)),Ve.map(K=>Qe.some(ce=>ce.id===K.id)?{...K,read:!0}:K)})},[]),mt=k.useRef(x);mt.current=x;const Ct=k.useCallback(async()=>{if(!mt.current.some(le=>!le.read&&le.type==="system"&&le.metadata?.creditExhausted))try{await Ee.notifications.create({title:m("credits.notificationTitle",{ns:"common"}),body:m("credits.notificationBody",{ns:"common"}),type:"system",priority:"urgent",metadata:{creditExhausted:!0}}),Pe(),nh()}catch{}},[Pe,m]),Mt=k.useCallback(async()=>{if(!th){th=!0;try{const{updates:M}=await Ee.skills.updates();if(!M.length)return;const le=cW(M);try{if(localStorage.getItem(M4)===le)return}catch{}if(_d===le||mt.current.some(ge=>!ge.read&&R4(ge,le)))return;try{const Ve=(await Ee.notifications.list(t,!0,{limit:50,type:"system"})).notifications.filter(Qe=>R4(Qe,le)).sort((Qe,K)=>new Date(K.createdAt).getTime()-new Date(Qe.createdAt).getTime());if(Ve.length>0){for(const Qe of Ve.slice(1))Ee.notifications.markRead(Qe.id).catch(()=>{});Ve.length>1&&Pe(),_d=le;return}}catch{}_d=le,await Ee.notifications.create({title:m("templateUpdates.notificationTitle",{ns:"common"}),body:m("templateUpdates.notificationBody",{ns:"common",count:M.length}),type:"system",priority:"high",metadata:{templateUpdates:!0,templateUpdatesFingerprint:le,count:M.length,skills:M.map(ge=>ge.name)}}),Pe(),nh()}catch{_d=null}finally{th=!1}}},[Pe,m,t]);k.useEffect(()=>{Pe();const M=setInterval(Pe,6e4);let le=null;const Oe=()=>{le||(le=setTimeout(()=>{le=null,Pe()},400))},ge=()=>Oe(),Ve=()=>{h(!0),Pe()};window.addEventListener("markus:notifications-changed",ge),window.addEventListener("markus:mark-read-by-ref",ct),window.addEventListener("markus:open-notifications",Ve),window.addEventListener("markus:credit-exhausted",Ct);const Qe=va.on("notification",Oe),K=va.on("approval:requested",Oe);return()=>{clearInterval(M),le&&clearTimeout(le),window.removeEventListener("markus:notifications-changed",ge),window.removeEventListener("markus:mark-read-by-ref",ct),window.removeEventListener("markus:open-notifications",Ve),window.removeEventListener("markus:credit-exhausted",Ct),Qe(),K()}},[Pe,ct,Ct]),k.useEffect(()=>{Mt();const M=setInterval(()=>{Mt()},5*6e4),le=()=>{Mt()};return window.addEventListener("markus:data-changed",le),()=>{clearInterval(M),window.removeEventListener("markus:data-changed",le)}},[t]);const Pt=k.useCallback(()=>{if(!G.current)return;const M=G.current.getBoundingClientRect(),le=window.innerWidth,Oe=window.innerHeight,ge=Math.min(448,le-16),Ve=Math.min(576,Oe-16);let Qe=M.right+8,K=M.top;Qe+ge>le-8&&(Qe=Math.max(8,le-ge-8)),K+Ve>Oe-8&&(K=Math.max(8,Oe-Ve-8)),q({top:K,left:Qe,width:ge,maxHeight:Ve})},[]);k.useLayoutEffect(()=>{f&&Pt()},[f,Pt]),k.useEffect(()=>{if(f)return window.addEventListener("resize",Pt),()=>window.removeEventListener("resize",Pt)},[f,Pt]),k.useEffect(()=>{if(!f)return;const M=le=>{G.current?.contains(le.target)||se.current?.contains(le.target)||h(!1)};return document.addEventListener("mousedown",M),()=>document.removeEventListener("mousedown",M)},[f]),k.useEffect(()=>{if(!f)return;const M=C.some(Oe=>Oe.status==="pending"),le=x.some(Oe=>!Oe.read);y(M&&!le?"approvals":!M&&le?"notifications":pe.current)},[f]);const Kt=new Set(C.filter(M=>M.status==="pending").map(M=>M.id)),yt=new Set(C.map(M=>M.id)),Ue=x.filter(M=>!(M.type==="approval_request"&&M.metadata?.approvalId&&yt.has(M.metadata.approvalId))),dt=x.filter(M=>M.type==="approval_request"&&!M.read&&M.metadata?.approvalId&&Kt.has(M.metadata.approvalId)).length,Nt=Math.max(0,X-dt),bt=Kt.size,Lt=Nt+bt;k.useEffect(()=>{re.current!==null&&bt>re.current&&nh(),re.current=bt},[bt]);const ue=async M=>{await Ee.notifications.markRead(M),w(le=>le.map(Oe=>Oe.id===M?{...Oe,read:!0}:Oe)),z(le=>Math.max(0,le-1)),window.dispatchEvent(new CustomEvent("markus:notifications-changed"))},tt=M=>{const le=M.metadata??{},Oe=M.actionType,ge=M.actionTarget;if(Oe==="open_chat"&&ge)try{const Ve=typeof ge=="string"?JSON.parse(ge):ge;if(Ve.agentId){const Qe={agentId:Ve.agentId};Ve.sessionId&&(Qe.sessionId=Ve.sessionId),it.navigate(de.TEAM,Qe);return}}catch{}if(Oe==="navigate"&&ge)try{const Ve=typeof ge=="string"?JSON.parse(ge):ge;if(Ve.path){if(Ve.path.startsWith("/team")){const Qe={},K=new URLSearchParams(Ve.path.split("?")[1]||"");for(const[ce,Te]of K.entries())Qe[ce]=Te;it.navigate(de.TEAM,Qe);return}if(Ve.path.startsWith("/work")){const Qe={},K=new URLSearchParams(Ve.path.split("?")[1]||"");for(const[ce,Te]of K.entries())Qe[ce]=Te;it.navigate(de.WORK,Qe);return}}}catch{}switch(M.type){case"approval_request":{const Ve=le.approvalId,Qe=Ve?C.find(ze=>ze.id===Ve):void 0;if(Qe&&Ad(Qe)){L(Qe);break}const K=Qe?.details?.taskId??le.taskId,ce=Qe?.details?.requirementId??le.requirementId,Te=Qe?.details?.agentId??Qe?.agentId;K?it.navigate(de.WORK,{openTask:K}):ce?it.navigate(de.WORK,{openRequirement:ce}):Te?it.navigate(de.TEAM,{agentId:Te}):it.navigate(de.WORK);break}case"task_completed":case"task_created":case"task_review":case"task_failed":le.taskId?it.navigate(de.WORK,{openTask:le.taskId}):it.navigate(de.WORK);break;case"requirement_created":case"requirement_decision":le.requirementId?it.navigate(de.WORK,{openRequirement:le.requirementId}):it.navigate(de.WORK);break;case"agent_report":case"system":{if(le.creditExhausted){_e(!0);return}if(le.templateUpdates){const Ve=le.templateUpdatesFingerprint;if(Ve)try{localStorage.setItem(M4,Ve)}catch{}localStorage.setItem("markus_nav_storeTab","installed"),it.navigate(de.STORE);return}if(le.agentId){const Ve={agentId:le.agentId};le.sessionId&&(Ve.sessionId=le.sessionId),it.navigate(de.TEAM,Ve)}else it.navigate(de.TEAM);break}case"direct_message":{const Ve=le.senderId;Ve?it.navigate(de.TEAM,{dm:Ve}):it.navigate(de.TEAM);break}case"group_message":{const Ve=le.channel;Ve?it.navigate(de.TEAM,{channel:Ve}):it.navigate(de.TEAM);break}default:le.taskId?it.navigate(de.WORK,{openTask:le.taskId}):le.requirementId?it.navigate(de.WORK,{openRequirement:le.requirementId}):le.projectId?it.navigate(de.WORK,{projectId:le.projectId}):le.agentId&&it.navigate(de.TEAM,{agentId:le.agentId});break}},st=async M=>{const le=M.metadata??{},Oe=M.actionType,ge=M.type==="agent_report"&&!le.creditExhausted&&!le.templateUpdates&&(Oe==="open_chat"||!!le.agentId&&Oe!=="navigate");!M.read&&!ge&&ue(M.id);const Ve=le.taskId,Qe=le.requirementId;if(!ge&&(Ve||Qe)){const K=x.filter(ce=>ce.id!==M.id&&!ce.read&&(Ve&&ce.metadata?.taskId===Ve||Qe&&ce.metadata?.requirementId===Qe));for(const ce of K)ue(ce.id)}tt(M)},ye=async(M,le,Oe,ge,Ve)=>{E(M);try{const{approval:Qe}=await Ee.approvals.respond(M,le,t,Oe,ge,Ve);T(ze=>ze.map(rt=>rt.id===M?Qe:rt)),L(null),O(null),V(ze=>{const rt={...ze};return delete rt[M],rt});const K=Qe.details?.taskId,ce=Qe.details?.requirementId,Te=x.filter(ze=>!ze.read&&(ze.type==="approval_request"&&ze.metadata?.approvalId===M||K&&ze.metadata?.taskId===K||ce&&ze.metadata?.requirementId===ce));if(Te.length>0){for(const rt of Te)Ee.notifications.markRead(rt.id).catch(()=>{});const ze=new Set(Te.map(rt=>rt.id));w(rt=>rt.map(vt=>ze.has(vt.id)?{...vt,read:!0}:vt)),z(rt=>Math.max(0,rt-Te.length))}Ya("/approvals"),Ya("/notifications"),Ya("/tasks"),Ya("/taskboard"),Ya("/requirements"),window.dispatchEvent(new CustomEvent("markus:data-changed")),window.dispatchEvent(new CustomEvent("markus:notifications-changed")),setTimeout(()=>Pe(),800)}catch{}E(null)},je=async()=>{try{if(!t)return;await Ee.notifications.markAllRead(t),w(M=>M.map(le=>({...le,read:!0}))),z(0),Ya("/notifications"),window.dispatchEvent(new CustomEvent("markus:notifications-changed"))}catch{const M=Ue.filter(le=>!le.read);await Promise.all(M.map(le=>Ee.notifications.markRead(le.id))),w(le=>le.map(Oe=>({...Oe,read:!0}))),z(0),Ya("/notifications"),window.dispatchEvent(new CustomEvent("markus:notifications-changed"))}},Ae=M=>{const le=M.details?.subType;return le==="requirement_resubmit"?m("team:notifications.approvalType.requirementResubmit"):le==="requirement"||M.details?.requirementId?m("team:notifications.approvalType.requirement"):le==="task_review"?m("team:notifications.approvalType.taskReview"):le==="task"||M.details?.taskId?m("team:notifications.approvalType.task"):M.details?.toolName?m("team:notifications.approvalType.toolExecution"):null},oe=M=>{const le=[];le.push(M.agentName);const Oe=M.details?.taskTitle,ge=M.details?.taskId;Oe?le.push(Oe):ge&&le.push(`Task ${ge.slice(0,8)}`);const Ve=M.details?.requirementId;return Ve&&!ge&&le.push(`Req ${Ve.slice(0,8)}`),le.join(" · ")},H=[...C].sort((M,le)=>new Date(le.requestedAt).getTime()-new Date(M.requestedAt).getTime()),te=H.filter(M=>M.status==="pending"),Ne=H.filter(M=>M.status!=="pending"),Re=M=>{const le=M.details?.taskId,Oe=M.details?.requirementId,ge=M.details?.agentId??M.agentId;le?it.navigate(de.WORK,{openTask:le}):Oe?it.navigate(de.WORK,{openRequirement:Oe}):ge?it.navigate(de.TEAM,{agentId:ge}):it.navigate(de.WORK)},$e=()=>{h(!1),r?.()},Q=M=>s.jsxs("button",{disabled:S===M.id,onClick:()=>L(M),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"}),M.questions&&M.questions.length>1?` (${M.questions.length})`:""]}),Z=j?s.jsx(lW,{approval:j,submitting:S===j.id,readOnly:j.status!=="pending",onClose:()=>L(null),onSubmit:M=>ye(j.id,M.approved,M.comment,M.selectedOption,M.answers)}):null,be=s.jsxs(s.Fragment,{children:[s.jsxs("div",{className:"flex border-b border-border-default shrink-0",children:[s.jsxs("button",{onClick:()=>{y("approvals"),pe.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"),bt>0?` (${bt})`:""]}),s.jsxs("button",{onClick:()=>{y("notifications"),pe.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"),Nt>0?` (${Nt})`:""]}),s.jsx("button",{onClick:$e,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"&&X>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:je,className:"text-[10px] text-brand-500 hover:text-brand-400 transition-colors",children:m("team:notifications.markAllRead")})}),s.jsxs("div",{ref:W,className:"flex-1 overflow-y-auto",onScroll:M=>{if(g!=="notifications"||!J||Se)return;const le=M.currentTarget;le.scrollTop+le.clientHeight>=le.scrollHeight-80&&Ge()},children:[g==="approvals"&&(C.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:[te.map(M=>{const le=M.details?.command,Oe=le?M.description.replace(/\s*Command:.*$/,""):M.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:()=>Re(M),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:To.approval_request})}),s.jsxs("div",{className:"flex-1 min-w-0",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[Ae(M)&&s.jsx("span",{className:"text-[10px] text-amber-500 font-medium shrink-0",children:Ae(M)}),s.jsx("span",{className:"text-xs text-fg-primary font-medium truncate",children:M.title}),s.jsx("span",{className:"text-[10px] text-fg-tertiary shrink-0",children:Ao(M.requestedAt,m)})]}),s.jsx("div",{className:"text-[11px] text-fg-tertiary mt-0.5",children:M.agentName})]})]}),s.jsx("div",{className:"mt-2.5 text-[11px] text-fg-secondary leading-relaxed",children:s.jsx(Er,{content:Oe,className:"text-[11px] [&_h1]:text-xs [&_h2]:text-[11px] [&_h3]:text-[11px] [&_p]:text-[11px] [&_li]:text-[11px]"})}),le&&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:le})]}),(()=>{if(Ad(M))return Q(M);const ge=M.details?.subType,Ve=ge==="task"||ge==="requirement"||ge==="requirement_resubmit",Qe=M.options&&M.options.length>0,K=(F[M.id]??"").trim();return Qe?s.jsxs("div",{className:"space-y-1.5",children:[M.options.map((ce,Te)=>s.jsxs("button",{disabled:S===M.id,onClick:()=>ye(M.id,ce.id!=="reject",K||void 0,ce.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 ${ce.id==="reject"||ce.id==="request_changes"?"border border-border-default text-fg-secondary hover:bg-surface-overlay":"bg-brand-600 text-white hover:bg-brand-700"}`,title:ce.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+Te)}),ce.label]},ce.id)),s.jsxs("div",{className:"flex gap-1.5 mt-1",children:[s.jsx("input",{type:"text",placeholder:m("team:notifications.freeformPlaceholder"),value:F[M.id]??"",onChange:ce=>V(Te=>({...Te,[M.id]:ce.target.value})),onKeyDown:ce=>{ce.key==="Enter"&&(F[M.id]??"").trim()&&ye(M.id,!0,(F[M.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:S===M.id||!(F[M.id]??"").trim(),onClick:()=>ye(M.id,!0,(F[M.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")})]})]}):Ve?s.jsxs("div",{className:"space-y-1.5",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsxs("button",{disabled:S===M.id,onClick:()=>ye(M.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:S===M.id,onClick:()=>ye(M.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")]}),I!==M.id&&s.jsxs("button",{disabled:S===M.id,onClick:()=>O(M.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")]})]}),I===M.id&&s.jsxs("div",{className:"space-y-1.5",children:[s.jsx("input",{type:"text",autoFocus:!0,placeholder:m("team:notifications.adjustmentPlaceholder"),value:F[M.id]??"",onChange:ce=>V(Te=>({...Te,[M.id]:ce.target.value})),onKeyDown:ce=>{ce.key==="Enter"&&(F[M.id]??"").trim()&&ye(M.id,!1,(F[M.id]??"").trim(),"needs_adjustment"),ce.key==="Escape"&&O(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:S===M.id||!(F[M.id]??"").trim(),onClick:()=>ye(M.id,!1,(F[M.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:()=>O(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:F[M.id]??"",onChange:ce=>V(Te=>({...Te,[M.id]:ce.target.value})),onKeyDown:ce=>{ce.key==="Enter"&&ye(M.id,!0,K||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:S===M.id,onClick:()=>ye(M.id,!0,K||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:S===M.id,onClick:()=>ye(M.id,!1,K||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")})]})]})})()]},M.id)}),Ne.length>0&&s.jsxs(s.Fragment,{children:[te.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")}),Ne.slice(0,50).map(M=>s.jsxs("button",{onClick:()=>Ad(M)?L(M):Re(M),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 ${M.status==="approved"?"bg-green-500":M.status==="cancelled"||M.status==="expired"?"bg-gray-400":"bg-red-500"}`}),Ae(M)&&s.jsx("span",{className:"text-[10px] text-fg-tertiary font-medium shrink-0",children:Ae(M)}),s.jsx("span",{className:"text-xs text-fg-secondary truncate flex-1 group-hover:text-fg-primary",children:M.title}),s.jsx("span",{className:`text-[10px] font-medium shrink-0 ${M.status==="approved"?"text-green-500":M.status==="cancelled"||M.status==="expired"?"text-fg-muted":"text-red-500"}`,children:m(`common:status.${M.status}`,{defaultValue:M.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:oe(M)}),s.jsx("span",{className:"text-[10px] text-fg-muted shrink-0",children:"·"}),s.jsx("span",{className:"text-[10px] text-fg-muted shrink-0",children:Ao(M.respondedAt??M.requestedAt,m)})]}),M.responseComment&&s.jsxs("p",{className:"text-[10px] text-fg-muted mt-0.5 pl-3.5 truncate",children:["“",M.responseComment,"”"]})]},M.id))]})]})),g==="notifications"&&(Ue.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:[Ue.map(M=>{const le=j4[M.type]??"text-fg-tertiary";return s.jsxs("div",{role:"button",tabIndex:0,onClick:()=>st(M),onKeyDown:Oe=>{(Oe.key==="Enter"||Oe.key===" ")&&(Oe.preventDefault(),st(M))},className:`w-full text-left px-3 py-2.5 flex gap-2.5 transition-colors cursor-pointer ${M.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:le,children:s.jsx("path",{d:To[M.type]??To.system})})}),s.jsxs("div",{className:"flex-1 min-w-0",children:[s.jsxs("div",{className:"flex items-center gap-1.5",children:[!M.read&&s.jsx("span",{className:`w-1.5 h-1.5 rounded-full shrink-0 ${Ed[M.priority]??Ed.normal}`}),s.jsx("span",{className:"text-xs text-fg-primary font-medium truncate",children:M.title})]}),s.jsx("div",{className:"text-[11px] text-fg-tertiary mt-0.5 ",children:s.jsx(Er,{content:M.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:Ao(M.createdAt,m)}),jd(M,m)&&s.jsx("span",{className:`text-[10px] font-medium ${le}`,children:jd(M,m)})]})]})]},M.id)}),Se&&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"})]})})]}))]})]}),Ke=k.useCallback(M=>{M?.mute&&iW()},[]),Ie=k.useCallback(M=>{Ke(M),_e(!1)},[Ke]),Ye=P?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:()=>_e(!1),onCancelClick:M=>{Ie(M),it.navigate(de.SETTINGS),setTimeout(()=>{window.location.hash="settings/providers"},50)},onConfirm:M=>{const le=`${lt.getUrl().replace(/\/$/,"")}/settings?tab=billing`;Ie(M),_i(le)}}):null;if(n){const M=["approvals","notifications"],le=M.indexOf(g),Oe=(()=>{let ge=0,Ve=0;return{onTouchStart:Qe=>{ge=Qe.touches[0].clientX,Ve=Qe.touches[0].clientY},onTouchEnd:Qe=>{const K=Qe.changedTouches[0].clientX-ge,ce=Qe.changedTouches[0].clientY-Ve;Math.abs(K)>60&&Math.abs(K)>Math.abs(ce)*1.5&&(K<0&&le<M.length-1&&y(M[le+1]),K>0&&le>0&&y(M[le-1]))}}})();return s.jsxs(s.Fragment,{children:[Ye,s.jsxs("div",{className:"flex flex-col h-full overflow-hidden",children:[Z,s.jsx("div",{className:"flex border-b border-border-default shrink-0",children:M.map(ge=>s.jsx("button",{onClick:()=>y(ge),className:`flex-1 px-3 py-3 text-sm font-medium transition-colors ${g===ge?"text-fg-primary border-b-2 border-brand-500":"text-fg-tertiary"}`,children:ge==="approvals"?s.jsxs(s.Fragment,{children:[m("team:notifications.approvals"),bt>0?` (${bt})`:""]}):s.jsxs(s.Fragment,{children:[m("team:notifications.notifications"),Nt>0?` (${Nt})`:""]})},ge))}),g==="notifications"&&X>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:je,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",...Oe,children:s.jsxs("div",{className:"flex h-full transition-transform duration-300 ease-out",style:{transform:`translateX(-${le*100}%)`},children:[s.jsx("div",{className:"w-full shrink-0 h-full overflow-y-auto scrollbar-thin",children:C.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:[te.map(ge=>{const Ve=ge.details?.command,Qe=Ve?ge.description.replace(/\s*Command:.*$/,""):ge.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:()=>Re(ge),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:To.approval_request})}),s.jsxs("div",{className:"flex-1 min-w-0",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[Ae(ge)&&s.jsx("span",{className:"text-[10px] text-amber-500 font-medium shrink-0",children:Ae(ge)}),s.jsx("span",{className:"text-xs text-fg-primary font-medium truncate",children:ge.title}),s.jsx("span",{className:"text-[10px] text-fg-tertiary shrink-0",children:Ao(ge.requestedAt,m)})]}),s.jsx("div",{className:"text-[11px] text-fg-tertiary mt-0.5",children:ge.agentName})]})]}),s.jsx("div",{className:"mt-2.5 text-[11px] text-fg-secondary leading-relaxed",children:s.jsx(Er,{content:Qe,className:"text-[11px] [&_h1]:text-xs [&_h2]:text-[11px] [&_h3]:text-[11px] [&_p]:text-[11px] [&_li]:text-[11px]"})}),Ve&&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:Ve})]}),(()=>{if(Ad(ge))return Q(ge);const K=ge.details?.subType,ce=K==="task"||K==="requirement"||K==="requirement_resubmit",Te=ge.options&&ge.options.length>0,ze=(F[ge.id]??"").trim();return Te?s.jsxs("div",{className:"space-y-1.5",children:[ge.options.map((rt,vt)=>s.jsxs("button",{disabled:S===ge.id,onClick:()=>ye(ge.id,rt.id!=="reject",ze||void 0,rt.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 ${rt.id==="reject"||rt.id==="request_changes"?"border border-border-default text-fg-secondary hover:bg-surface-overlay":"bg-brand-600 text-white hover:bg-brand-700"}`,title:rt.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+vt)}),rt.label]},rt.id)),s.jsxs("div",{className:"flex gap-1.5 mt-1",children:[s.jsx("input",{type:"text",placeholder:m("team:notifications.freeformPlaceholder"),value:F[ge.id]??"",onChange:rt=>V(vt=>({...vt,[ge.id]:rt.target.value})),onKeyDown:rt=>{rt.key==="Enter"&&(F[ge.id]??"").trim()&&ye(ge.id,!0,(F[ge.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:S===ge.id||!(F[ge.id]??"").trim(),onClick:()=>ye(ge.id,!0,(F[ge.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")})]})]}):ce?s.jsxs("div",{className:"space-y-1.5",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsxs("button",{disabled:S===ge.id,onClick:()=>ye(ge.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:S===ge.id,onClick:()=>ye(ge.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")]}),I!==ge.id&&s.jsxs("button",{disabled:S===ge.id,onClick:()=>O(ge.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")]})]}),I===ge.id&&s.jsxs("div",{className:"space-y-1.5",children:[s.jsx("input",{type:"text",autoFocus:!0,placeholder:m("team:notifications.adjustmentPlaceholder"),value:F[ge.id]??"",onChange:rt=>V(vt=>({...vt,[ge.id]:rt.target.value})),onKeyDown:rt=>{rt.key==="Enter"&&(F[ge.id]??"").trim()&&ye(ge.id,!1,(F[ge.id]??"").trim(),"needs_adjustment"),rt.key==="Escape"&&O(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:S===ge.id||!(F[ge.id]??"").trim(),onClick:()=>ye(ge.id,!1,(F[ge.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:()=>O(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:F[ge.id]??"",onChange:rt=>V(vt=>({...vt,[ge.id]:rt.target.value})),onKeyDown:rt=>{rt.key==="Enter"&&ye(ge.id,!0,ze||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:S===ge.id,onClick:()=>ye(ge.id,!0,ze||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:S===ge.id,onClick:()=>ye(ge.id,!1,ze||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")})]})]})})()]},ge.id)}),Ne.length>0&&s.jsxs(s.Fragment,{children:[te.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")}),Ne.slice(0,50).map(ge=>s.jsxs("button",{onClick:()=>Re(ge),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 ${ge.status==="approved"?"bg-green-500":ge.status==="cancelled"||ge.status==="expired"?"bg-gray-400":"bg-red-500"}`}),s.jsx("span",{className:"text-xs text-fg-secondary truncate flex-1",children:ge.title}),s.jsx("span",{className:`text-[10px] font-medium shrink-0 ${ge.status==="approved"?"text-green-500":ge.status==="cancelled"||ge.status==="expired"?"text-fg-muted":"text-red-500"}`,children:m(`common:status.${ge.status}`,{defaultValue:ge.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:oe(ge)}),s.jsx("span",{className:"text-[10px] text-fg-muted shrink-0",children:"·"}),s.jsx("span",{className:"text-[10px] text-fg-muted shrink-0",children:Ao(ge.respondedAt??ge.requestedAt,m)})]})]},ge.id))]})]})}),s.jsx("div",{className:"w-full shrink-0 h-full overflow-y-auto scrollbar-thin",children:Ue.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:Ue.slice(0,50).map(ge=>{const Ve=j4[ge.type]??"text-fg-tertiary";return s.jsxs("button",{onClick:()=>st(ge),className:`w-full text-left px-3 py-2.5 flex gap-2.5 transition-colors ${ge.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:Ve,children:s.jsx("path",{d:To[ge.type]??To.system})})}),s.jsxs("div",{className:"flex-1 min-w-0",children:[s.jsxs("div",{className:"flex items-center gap-1.5",children:[!ge.read&&s.jsx("span",{className:`w-1.5 h-1.5 rounded-full shrink-0 ${Ed[ge.priority]??Ed.normal}`}),s.jsx("span",{className:"text-xs text-fg-primary font-medium truncate",children:ge.title})]}),s.jsx("div",{className:"text-[11px] text-fg-tertiary mt-0.5 ",children:s.jsx(Er,{content:ge.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:Ao(ge.createdAt,m)}),jd(ge,m)&&s.jsx("span",{className:`text-[10px] font-medium ${Ve}`,children:jd(ge,m)})]})]})]},ge.id)})})})]})})]})]})}if(o){const M=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:[Z,s.jsxs("button",{ref:G,onClick:()=>{h(!f),f||Pe()},title:e?c||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 ${f||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:M})}),e?s.jsx("span",{className:"text-[9px] leading-tight truncate w-full text-center",children:c}):s.jsx("span",{className:"truncate",children:c}),Lt>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:Lt>99?m("common:badgeOverLimit"):Lt})]}),f&&Sa.createPortal(s.jsx("div",{ref:se,className:"fixed bg-surface-secondary border border-border-default rounded-xl shadow-2xl z-[9999] flex flex-col overflow-hidden",style:{top:ee.top,left:ee.left,width:ee.width,maxHeight:ee.maxHeight},children:be}),document.body),Ye]})}return s.jsxs(s.Fragment,{children:[Z,s.jsxs("button",{ref:G,onClick:()=>{h(!f),f||Pe()},className:`relative flex items-center justify-center rounded-md transition-colors ${e?"w-8 h-8":"w-7 h-7"} ${f?"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"})]}),Lt>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:Lt>99?m("common:badgeOverLimit"):Lt})]}),f&&Sa.createPortal(s.jsx("div",{ref:se,className:"fixed bg-surface-secondary border border-border-default rounded-xl shadow-2xl z-[9999] flex flex-col overflow-hidden",style:{top:ee.top,left:ee.left,width:ee.width,maxHeight:ee.maxHeight},children:be}),document.body),Ye]})}function Md({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 rh=200;function dW({authUser:e,onLogout:t,onEditProfile:n,showSettingsLink:r=!1,collapsed:o=!1,showVersion:l=!1}){const{t:c}=ft(["nav","common"]),[d,m]=k.useState(!1),[f,h]=k.useState(!1),[g,y]=k.useState(()=>lt.isAuthenticated()),[x,w]=k.useState(()=>sa()),[C,T]=k.useState({top:0,left:0}),S=k.useRef(null),E=k.useRef(null),j=k.useCallback(ee=>{if(w(sa()),!lt.isAuthenticated()){y(!1);return}if(!ee?.validate){y(!0);return}Cw().then(q=>{y(q),w(sa())})},[]);k.useEffect(()=>{j({validate:!0});const ee=()=>j(),q=()=>j({validate:!0});return window.addEventListener("markus:hub-auth",ee),window.addEventListener("focus",q),()=>{window.removeEventListener("markus:hub-auth",ee),window.removeEventListener("focus",q)}},[j]);const L=k.useCallback(()=>{if(!S.current)return;const ee=S.current.getBoundingClientRect(),q=window.innerWidth,re=window.innerHeight,B=E.current?.offsetHeight??220;let J=ee.right+8;J+rh>q-8&&(J=Math.max(8,ee.left-rh-8));let fe=ee.top-B-8;fe<8&&(fe=Math.min(ee.bottom+8,re-B-8)),T({top:Math.max(8,fe),left:J})},[]);k.useLayoutEffect(()=>{if(!d)return;L();const ee=requestAnimationFrame(()=>L());return()=>cancelAnimationFrame(ee)},[d,L,o]),k.useEffect(()=>{if(!d)return;const ee=re=>{const B=re.target;S.current?.contains(B)||E.current?.contains(B)||m(!1)},q=()=>L();return document.addEventListener("mousedown",ee),window.addEventListener("resize",q),window.addEventListener("scroll",q,!0),()=>{document.removeEventListener("mousedown",ee),window.removeEventListener("resize",q),window.removeEventListener("scroll",q,!0)}},[d,L]);const I=e?.name||x?.displayName||x?.username||c("common:userPlaceholder"),O=e?.email||x?.email||"",F=Ew(e?.avatarUrl,x?.avatarUrl),V=g?"bg-emerald-500":"bg-fg-muted",X=g?x?.username?c("sidebar.hubConnectedAs",{username:x.username}):c("sidebar.hubConnected"):c("sidebar.hubDisconnected"),z=!!(g&&x?.username&&e?.name&&x.username.toLowerCase()!==e.name.toLowerCase()&&x.email?.toLowerCase()!==e.email?.toLowerCase()),G=()=>{m(!1),j({validate:!0}),it.navigate(de.SETTINGS,{tab:"account"})},se=d&&Sa.createPortal(s.jsxs("div",{ref:E,className:"fixed bg-surface-elevated border border-border-default rounded-xl shadow-xl z-[9999] overflow-hidden",style:{top:C.top,left:C.left,width:rh},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:I}),O&&s.jsx("div",{className:"text-xs text-fg-tertiary mt-0.5 truncate",children:O})]}),n&&s.jsx("button",{type:"button",onClick:()=>{m(!1),n()},title:c("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(Md,{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:G,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 ${V}`}),s.jsxs("span",{className:"min-w-0 flex-1",children:[s.jsx("span",{className:"text-xs text-fg-secondary block truncate",children:X}),z&&x?.username&&s.jsx("span",{className:"text-[10px] text-amber-500/90 block truncate mt-0.5",children:c("sidebar.hubAccountMismatch",{username:x.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),it.navigate(de.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(Md,{d:hc[de.SETTINGS]}),c("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(Md,{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"}),c("common:openInBrowser")]}),t&&s.jsxs("button",{type:"button",onClick:()=>{m(!1),h(!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(Md,{d:"M9 21H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h4M16 17l5-5-5-5M21 12H9"}),c("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:S,type:"button",onClick:()=>m(ee=>!ee),title:I,className:`relative inline-flex items-center justify-center rounded-full transition-opacity hover:opacity-90 ${o?"p-0.5":""}`,children:[s.jsx(Hs,{name:I,avatarUrl:F,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 ${V}`,title:X})]}),l&&!o&&s.jsxs("span",{className:"text-[10px] text-fg-muted select-none shrink-0",children:["v","0.9.7"]}),se,f&&t&&s.jsx(dr,{title:c("common:signOutConfirmTitle"),message:c("common:signOutConfirmMessage"),confirmLabel:c("common:signOut"),variant:"primary",onConfirm:()=>{h(!1),t()},onCancel:()=>h(!1)})]})}function mW({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 fW({currentPage:e,onNavigate:t,authUser:n,collapsed:r,onToggleCollapse:o,onLogout:l,keyboardFocusPageId:c,keyboardPaneActive:d}){const{t:m}=ft(["nav","common"]);return s.jsxs("aside",{"data-keyboard-pane":"l0",className:"markus-app-sidebar h-dvh bg-surface-secondary flex flex-col shrink-0 overflow-hidden",children:[s.jsx("div",{"data-electron-drag":!0,className:`electron-mac-sidebar-header flex items-center ${r?"px-2 py-3.5 justify-center":"px-4 h-14 justify-between"}`,children:s.jsxs("button",{"data-no-drag":!0,onClick:o,title:m(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:YO.map((f,h)=>{const g=vw.filter(x=>x.section===f.key);if(g.length===0)return null;const y=m(`sections.${f.key}`);return s.jsx("div",{children:s.jsxs("div",{className:h>0?"mt-3":"",children:[!r&&y&&s.jsx("div",{className:"px-3 py-1.5 mb-1 text-[10px] font-semibold text-fg-muted uppercase tracking-[0.1em]",children:y}),r&&h>0&&s.jsx("div",{className:"my-3"}),g.map(x=>{if(x.id===de.NOTIFICATIONS)return s.jsx(uW,{sidebarMode:!0,collapsed:r,userId:n?.id,label:m(x.id),iconPath:hc[x.id],isActive:e===x.id},x.id);const w=e===x.id,C=d&&c===x.id;return s.jsxs("button",{"data-l0-page-id":x.id,onClick:()=>t(x.id),title:r?m(x.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 ${C?"bg-brand-500/25 ring-1 ring-inset ring-brand-500/40":w?"bg-surface-overlay":"hover:bg-surface-overlay/60"}`,children:[s.jsx(mW,{d:hc[x.id]??"",size:r?16:18}),r?s.jsx("span",{className:"text-[9px] leading-tight truncate w-full text-center",children:m(x.id)}):s.jsx("span",{className:"truncate",children:m(x.id)})]},x.id)})]})},f.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(dW,{authUser:n,onLogout:l,onEditProfile:()=>{window.dispatchEvent(new Event("markus:open-edit-profile"))},showSettingsLink:!1,collapsed:r,showVersion:!r})})]})}const pW=6e4;let zs={},xi={};const tg=new Set,ng=new Set;let r6=0,uc=null,Rd=0,Kd=null;function w0(){for(const e of tg)e()}async function rg(){try{const e=await Ee.unread.getCounts();zs=e.counts??{},xi=e.sessionAgentMap??{},w0()}catch{}}function hW(){uc||(rg(),uc=setInterval(rg,pW),Kd=va.on("chat:unread_update",e=>{const t=e.payload?.conversationKey;t&&!ng.has(t)&&Date.now()>r6&&(zs[t]=(zs[t]??0)+1,w0())}))}function gW(){uc&&(clearInterval(uc),uc=null),Kd&&(Kd(),Kd=null)}function bW(e){const t=e?.enabled??!0,[n,r]=k.useState(zs),[o,l]=k.useState(xi),c=k.useCallback(async()=>{await rg()},[]),d=k.useCallback(async w=>{const C=new Date().toISOString();delete zs[w],w0();try{await Ee.unread.markRead(w,C)}catch{}},[]),m=k.useCallback(async()=>{zs={},w0();try{await Ee.unread.markAllRead()}catch{}},[]),f=k.useCallback(w=>{ng.add(w)},[]),h=k.useCallback(w=>{ng.delete(w),r6=Date.now()+150},[]);k.useEffect(()=>{if(!t)return;Rd++,hW();let w=xi;const C=()=>{r({...zs}),w!==xi&&(w=xi,l({...xi}))};return tg.add(C),r({...zs}),l({...xi}),()=>{tg.delete(C),Rd--,Rd<=0&&(Rd=0,gW())}},[t]);const g=k.useMemo(()=>Object.values(n).reduce((w,C)=>w+C,0),[n]),y=k.useCallback(w=>n[`session:${w}`]??0,[n]),x=k.useCallback(w=>n[`channel:${w}`]??0,[n]);return{counts:n,totalUnread:g,sessionAgentMap:o,getSessionUnread:y,getChannelUnread:x,markRead:d,markAllRead:m,refresh:c,setActiveKey:f,clearActiveKey:h}}function mX(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),c=e[l];c&&n.set(c,(n.get(c)??0)+o)}return n},[e,t])}function xW({currentPage:e,onNavigate:t,userId:n}){const{t:r}=ft("nav"),[o,l]=k.useState(0),{counts:c}=bW({enabled:!0}),d=k.useMemo(()=>{let f=0;for(const h of Object.values(c))f+=h;return f},[c]),m=k.useCallback(async()=>{try{const f=await Ee.notifications.list(n,!1);l(f.unreadCount??f.notifications.filter(h=>!h.read).length)}catch{}},[n]);return k.useEffect(()=>{m();const f=setInterval(()=>{document.visibilityState==="visible"&&m()},3e4),h=()=>m();return window.addEventListener("markus:notifications-changed",h),()=>{clearInterval(f),window.removeEventListener("markus:notifications-changed",h)}},[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:QO.map(f=>{const h=f.group.includes(e),g=f.id===de.NOTIFICATIONS,y=f.id===de.TEAM;return s.jsxs("button",{onClick:()=>t(f.id),className:`flex-1 flex flex-col items-center justify-center gap-0.5 transition-colors ${h?"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:h?2:1.75,strokeLinecap:"round",strokeLinejoin:"round",className:"shrink-0",children:s.jsx("path",{d:hc[f.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}),y&&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 ${h?"font-semibold":""}`,children:r(f.id)})]},f.id)})})}const k0=new Map;function gi(e,t){k0.has(e)||k0.set(e,t().catch(()=>{}))}function Si(e){const t=k0.get(e);return k0.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"},Ei={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 Xo(e){const t=(e||"").toLowerCase();return t==="team"?"team":t==="skill"?"skill":t==="connector"||t==="mcp"?"connector":"agent"}function a6(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 yW={agent:258,team:205,skill:32,connector:162};function Xg(e,t){const n=yW[e],r=a6(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 L4=["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 s6(e){return L4[a6(e+"g")%L4.length]}function i6(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 vW(e){return!e||i6(e)?!1:[...e].length<=4&&new RegExp("\\p{Extended_Pictographic}","u").test(e)}function wW(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 Mo(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 O4(e,t="usd"){return!e||e<=0?"Free":`${t.toLowerCase()==="usd"?"$":""}${(e/100).toFixed(e%100===0?0:2)}`}const D4={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"}},kW=["development","devops","management","productivity","browser","custom","general"],SW=[{label:"Tech",emojis:["✦","◈","⬡","⚡","🤖","🧠","💡","🎯","🔧","📦","🚀","💻","🛠️","⭐","🔥","💎","⚙️","🧩","🔌","💾","🖥️","📡","🔬","🧪","🏗️","📱","🎮","🕹️","📟","💽","🖨️","⌨️"]},{label:"People",emojis:["👤","👥","🧑‍💻","👨‍💼","👩‍🔬","🧙","🦸","🤝","💪","🎓","👷","🕵️","🧑‍🎨","🧑‍🏫","👨‍🚀","🥷","🧑‍🏭","🧑‍⚕️","🧑‍🔧","🧑‍🍳","👨‍🎤","🦹","🧝","🧞","🧑‍✈️","💂","🤴","👸","🧛","🧟","🧜","🧚"]},{label:"Objects",emojis:["📝","📊","🗂️","📁","🔍","🔑","🌐","💬","🔒","🎨","📐","🗃️","📋","✏️","🖊️","📌","📎","🧲","🪝","🧰","🪜","🧬","🔭","💊","🩺","📕","📗","📘","📙","📓","🗒️","📰"]},{label:"Symbols",emojis:["❤️","🧡","💛","💚","💙","💜","🖤","🤍","♠️","♥️","♦️","♣️","🎵","🎶","💯","✅","❌","⭕","🔴","🟠","🟡","🟢","🔵","🟣","⚫","⚪","🟤","🔶","🔷","▶️","⏸️","⏹️"]},{label:"Nature",emojis:["🌟","🌈","🌊","🌿","🍀","🔮","💫","✨","🌙","☀️","🦋","🐉","🦊","🐺","🦅","🐙","🦁","🐯","🦄","🐲","🌸","🌺","🍄","🌵","🎄","🌴","🍁","🌻","🐝","🦎","🐍","🦈"]},{label:"Activity",emojis:["🎯","🏆","🥇","🎖️","🏅","🎪","🎭","🎬","🎤","🎧","🎼","🎹","🥁","🎸","🎺","🎻","⚽","🏀","🎾","🏐","🎲","🧸","🪁","🎰","🎳","🏹","🥊","🤺","⛷️","🏄","🚴","🧗"]}],NW={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 ah({value:e,onChange:t,renderAs:n="span",className:r,editClassName:o,placeholder:l,multiline:c,readOnly:d}){if(d){const j=e||l,I=`${r??""} ${!e?"text-fg-muted italic":""}`;return n==="h1"?s.jsx("h1",{className:I,children:j}):n==="p"?s.jsx("p",{className:I,children:j}):s.jsx("span",{className:I,children:j})}const[m,f]=k.useState(!1),[h,g]=k.useState(e),y=k.useRef(null);k.useEffect(()=>{g(e)},[e]),k.useEffect(()=>{m&&y.current?.focus()},[m]);const x=()=>{f(!1),h!==e&&t(h)},w=()=>{g(e),f(!1)},C=j=>{j.key==="Escape"&&w(),j.key==="Enter"&&!c&&x()};if(m){const j=`bg-transparent outline-none w-full ${o??r??""} ring-1 ring-brand-500/50 rounded px-1 -mx-1`;return c?s.jsx("textarea",{ref:y,value:h,onChange:L=>g(L.target.value),onBlur:x,onKeyDown:C,className:`${j} resize-y min-h-[60px]`,placeholder:l}):s.jsx("input",{ref:y,value:h,onChange:L=>g(L.target.value),onBlur:x,onKeyDown:C,className:j,placeholder:l})}const T=e||l,S=!e,E="cursor-text hover:ring-1 hover:ring-border-default rounded px-1 -mx-1 transition-all";return n==="h1"?s.jsx("h1",{onClick:()=>f(!0),className:`${r??""} ${E} ${S?"text-fg-muted italic":""}`,children:T}):n==="p"?s.jsx("p",{onClick:()=>f(!0),className:`${r??""} ${E} ${S?"text-fg-muted italic":""}`,children:T}):n==="badge"?s.jsx("span",{onClick:()=>f(!0),className:`${r??""} ${E} ${S?"text-fg-muted italic":""}`,children:T}):s.jsx("span",{onClick:()=>f(!0),className:`${r??""} ${E} ${S?"text-fg-muted italic":""}`,children:T})}function CW({value:e,options:t,onChange:n,className:r,readOnly:o}){if(o)return s.jsx("span",{className:r,children:e});const[l,c]=k.useState(!1),[d,m]=k.useState(e),f=k.useRef(null),h=k.useRef(null);k.useEffect(()=>{l&&(m(e),setTimeout(()=>f.current?.focus(),0))},[l,e]);const g=t.filter(x=>x.toLowerCase().includes(d.toLowerCase())),y=x=>{const w=x.trim();w&&w!==e&&n(w),c(!1)};return l?s.jsxs("div",{ref:h,className:"relative inline-block",children:[s.jsx("input",{ref:f,value:d,onChange:x=>m(x.target.value),onKeyDown:x=>{x.key==="Enter"?(x.preventDefault(),y(d)):x.key==="Escape"&&c(!1)},onBlur:x=>{h.current?.contains(x.relatedTarget)||y(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(x=>s.jsx("button",{onMouseDown:w=>{w.preventDefault(),y(x)},className:`block w-full text-left px-3 py-1.5 text-xs hover:bg-surface-secondary/80 transition-colors ${x===e?"text-brand-400 font-medium":"text-fg-secondary"}`,children:x},x))})]}):s.jsx("span",{onClick:()=>c(!0),className:`${r??""} cursor-pointer hover:ring-1 hover:ring-border-default rounded px-1 -mx-1 transition-all`,children:e})}function TW({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(h=>s.jsx("span",{className:"text-[10px] px-2 py-0.5 bg-surface-elevated text-fg-muted rounded-full border border-border-default",children:h},h))});const{t:r}=ft(["builder"]),[o,l]=k.useState(!1),[c,d]=k.useState(""),m=k.useRef(null);k.useEffect(()=>{o&&m.current?.focus()},[o]);const f=h=>{if((h.key==="Enter"||h.key===",")&&c.trim()){h.preventDefault();const g=c.trim().toLowerCase();e.includes(g)||t([...e,g]),d("")}else h.key==="Backspace"&&!c&&e.length>0?t(e.slice(0,-1)):h.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(h=>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:[h,s.jsx("button",{onClick:()=>t(e.filter(g=>g!==h)),className:"text-fg-muted hover:text-red-500",children:"×"})]},h)),s.jsx("input",{ref:m,value:c,onChange:h=>d(h.target.value),onKeyDown:f,onBlur:()=>{c||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(h=>s.jsx("span",{className:"text-[10px] px-2 py-0.5 bg-surface-elevated text-fg-muted rounded-full border border-border-default",children:h},h)):s.jsx("span",{className:"text-[10px] text-fg-muted italic",children:r("detail.typeTagAndEnter")})})}function ag({content:e}){const t=[q5,Vk,Kk],n=[M3,[n3,{strict:"ignore"}],[v3,{detect:!0,ignoreMissing:!0}]],r=q3({});return s.jsx("div",{className:`prose prose-invert prose-sm max-w-none
664
664
  prose-headings:text-fg-primary prose-headings:font-semibold
665
665
  prose-p:text-fg-secondary prose-p:leading-relaxed
666
666
  prose-a:text-brand-400 prose-a:no-underline hover:prose-a:underline
@@ -669,4 +669,4 @@ https://github.com/highlightjs/highlight.js/issues/2277`),Rn=We,rn=wt),Ht===void
669
669
  prose-strong:text-fg-primary
670
670
  prose-li:text-fg-secondary
671
671
  prose-hr:border-border-default
672
- prose-blockquote:border-brand-500/40 prose-blockquote:text-fg-secondary`,children:s.jsx(Eh,{remarkPlugins:t,rehypePlugins:n,components:r,children:e})})}function sh({filename:e,content:t,onSave:n,embedded:r,readOnly:o}){const{t:l}=ft(["builder","common"]),[c,d]=k.useState(!1),[m,f]=k.useState(t),[h,g]=k.useState(!1),y=/\.(md|mdx|markdown)$/i.test(e),x=k.useRef(null);k.useEffect(()=>{f(t)},[t]),k.useEffect(()=>{if(c&&x.current){const T=x.current;T.style.height="auto",T.style.height=Math.max(200,T.scrollHeight)+"px"}},[c,m]);const w=async()=>{g(!0),await n(m),g(!1),d(!1)},C=o?null:s.jsx("div",{className:"flex items-center gap-2",children:c?s.jsxs(s.Fragment,{children:[s.jsx("button",{onClick:()=>{f(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:h,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(h?"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:C}),c?s.jsx("textarea",{ref:x,value:m,onChange:T=>f(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:y?s.jsx(ag,{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}),C]}),c?s.jsx("textarea",{ref:x,value:m,onChange:T=>f(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:y?s.jsx(ag,{content:t}):s.jsx("pre",{className:"text-xs leading-relaxed text-fg-secondary whitespace-pre-wrap font-mono",children:t})})]})}const I4={"README.md":0,"ROLE.md":1,"HEARTBEAT.md":2,"POLICIES.md":3,"CONTEXT.md":4,"ANNOUNCEMENT.md":0,"NORMS.md":1};function AW(e){return[...e].sort(([t],[n])=>{const r=I4[t]??99,o=I4[n]??99;return r!==o?r-o:t.localeCompare(n)})}function S0({files:e,onSave:t,noHeader:n,readOnly:r}){const o=k.useMemo(()=>AW(e),[e]),[l,c]=k.useState(0);if(o.length===1)return n?s.jsx(sh,{filename:o[0][0],content:o[0][1],onSave:h=>t(o[0][0],h),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(sh,{filename:o[0][0],content:o[0][1],onSave:h=>t(o[0][0],h),readOnly:r})]});const[d,m]=o[l]??o[0],f=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(([h],g)=>s.jsx("button",{onClick:()=>c(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:h},h))}),s.jsx(sh,{filename:d,content:m,onSave:h=>t(d,h),embedded:!0,readOnly:r},d)]});return n?f: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"}),f]})}function EW({images:e,artifactType:t,artifactName:n,onUpload:r,onRemove:o,readOnly:l,cacheBust:c}){const{t:d}=ft(["builder"]),m=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:()=>m.current?.click(),onDragOver:f=>f.preventDefault(),onDrop:f=>{f.preventDefault();const h=f.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:d("images.dropOrClick")}),s.jsx("span",{className:"block text-xs text-fg-muted/60 mt-1",children:d("images.hint")}),s.jsx("input",{ref:m,type:"file",accept:"image/*",className:"hidden",onChange:f=>{const h=f.target.files?.[0];h&&r(h),f.target.value=""}})]}):s.jsxs("div",{children:[s.jsxs("div",{className:"flex gap-3 overflow-x-auto pb-2",children:[e.map(f=>{const h=f.split("/").pop()??f;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)}${c!=null?`?v=${c}`:""}`,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:"×"})]},f)}),!l&&s.jsx("button",{onClick:()=>m.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:m,type:"file",accept:"image/*",className:"hidden",onChange:f=>{const h=f.target.files?.[0];h&&r(h),f.target.value=""}})]})}function _W({members:e,teamTopFiles:t,files:n,artifactName:r,onFileSave:o,readOnly:l}){const{t:c}=ft(["builder"]),[d,m]=k.useState(0),f=k.useMemo(()=>{const T=new Set;for(const S of Object.keys(n)){const E=S.match(/^members\/([^/]+)\//);E&&T.add(E[1])}return[...T]},[n]),h=k.useMemo(()=>{const T=new Map,S=new Set;for(let L=0;L<e.length;L++){const O=e[L].slug;O&&f.includes(O)&&!S.has(O)&&(T.set(L,O),S.add(O))}for(let L=0;L<e.length;L++){if(T.has(L))continue;const I=r0(e[L].name);I&&f.includes(I)&&!S.has(I)&&(T.set(L,I),S.add(I))}for(let L=0;L<e.length;L++){if(T.has(L))continue;const I=e[L].roleName;if(I){const O=r0(I);f.includes(O)&&!S.has(O)&&(T.set(L,O),S.add(O))}}for(let L=0;L<e.length;L++){if(T.has(L))continue;const I=e[L].name;for(const O of f){if(S.has(O))continue;const F=n[`members/${O}/ROLE.md`];if(!F)continue;const V=F.match(/^#\s+(.+)$/m)?.[1]?.trim();if(V&&(V.toLowerCase().includes(I.toLowerCase())||I.toLowerCase().includes(V.toLowerCase()))){T.set(L,O),S.add(O);break}}}const E=f.filter(L=>!S.has(L));let j=0;for(let L=0;L<e.length;L++)T.has(L)||j<E.length&&(T.set(L,E[j]),j++);return T},[e,f,n]),g=k.useCallback((T,S)=>{const E=h.get(S);return E?Object.entries(n).filter(([j])=>j.startsWith(`members/${E}/`)):[]},[n,h]),y=k.useMemo(()=>{const T=[{label:c("detail.overview")}];for(const S of e)T.push({label:S.name,role:S.role});return T},[e,c]),x=d>0?e[d-1]:null,w=d-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:y.map((T,S)=>{const E=S===d,j=T.role==="manager",L=S===0?E?"border-brand-500 text-brand-400":"border-transparent text-fg-tertiary hover:text-fg-secondary":j?E?"border-amber-500 text-amber-400":"border-transparent text-fg-tertiary hover:text-fg-secondary":E?"border-blue-500 text-blue-400":"border-transparent text-fg-tertiary hover:text-fg-secondary";return s.jsxs("button",{onClick:()=>m(S),className:`px-4 py-2.5 text-xs font-medium whitespace-nowrap border-b-2 transition-colors flex items-center gap-1.5 ${L} ${E?"bg-surface-secondary/50":"hover:bg-surface-elevated/50"}`,children:[S===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"})]}),S>0&&((()=>{const I=S-1,O=h.get(I),F=O?`/api/builder/artifacts/teams/${encodeURIComponent(r)}/members/${encodeURIComponent(O)}/images/avatar.jpg`:null;return F?s.jsx("img",{src:F,alt:T.label,className:`w-5 h-5 rounded-full object-cover shrink-0 ring-1 ${j?"ring-amber-500/40":"ring-blue-500/40"}`,onError:V=>{V.target.style.display="none",V.target.nextElementSibling?.classList.remove("hidden")}}):null})(),s.jsx("span",{className:`w-5 h-5 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"} ${(()=>{const I=S-1;return h.get(I)?"hidden":""})()}`,children:(T.label[0]??"?").toUpperCase()})),T.label]},S)})}),s.jsx("div",{className:"p-5",children:d===0?s.jsxs("div",{className:"space-y-6",children:[t.length>0&&s.jsx(S0,{noHeader:!0,files:t,onSave:C,readOnly:l}),s.jsxs("div",{children:[s.jsx("div",{className:"text-[10px] font-semibold text-fg-tertiary uppercase tracking-wider mb-3",children:c("sidebar.composition")}),s.jsx("div",{className:"grid gap-2 sm:grid-cols-2",children:e.map((T,S)=>{const E=T.role==="manager";return s.jsxs("button",{onClick:()=>m(S+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:[(()=>{const j=h.get(S),L=j?`/api/builder/artifacts/teams/${encodeURIComponent(r)}/members/${encodeURIComponent(j)}/images/avatar.jpg`:null;return L?s.jsx("img",{src:L,alt:T.name,className:`w-8 h-8 rounded-full object-cover shrink-0 ring-1 ${E?"ring-amber-500/30":"ring-blue-500/30"}`,onError:I=>{I.target.style.display="none",I.target.nextElementSibling?.classList.remove("hidden")}}):null})(),s.jsx("div",{className:`w-8 h-8 rounded-full flex items-center justify-center text-xs font-bold shrink-0 ${E?"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"} ${h.get(S)?"hidden":""}`,children:(T.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:T.name}),s.jsx("span",{className:`text-[9px] px-1.5 py-0.5 rounded-full font-medium ${E?"bg-amber-500/15 text-amber-400":"bg-blue-500/15 text-blue-400"}`,children:T.role}),T.count>1&&s.jsxs("span",{className:"text-[9px] text-fg-muted",children:["×",T.count]})]}),T.skills&&T.skills.length>0&&s.jsxs("div",{className:"flex flex-wrap gap-1 mt-1",children:[T.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)),T.skills.length>3&&s.jsxs("span",{className:"text-[9px] text-fg-muted",children:["+",T.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"})})]},S)})})]})]}):x?s.jsxs("div",{className:"space-y-4",children:[s.jsxs("div",{className:"flex items-center gap-4",children:[(()=>{const T=h.get(w),S=T?`/api/builder/artifacts/teams/${encodeURIComponent(r)}/members/${encodeURIComponent(T)}/images/avatar.jpg`:null;return S?s.jsx("img",{src:S,alt:x.name,className:`w-12 h-12 rounded-full object-cover shrink-0 ring-2 ${x.role==="manager"?"ring-amber-500/30":"ring-blue-500/30"}`,onError:E=>{E.target.style.display="none",E.target.nextElementSibling?.classList.remove("hidden")}}):null})(),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"} ${h.get(w)?"hidden":""}`,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(T=>s.jsx("span",{className:"text-[10px] px-2.5 py-1 bg-surface-elevated text-fg-muted rounded-full border border-border-default",children:T},T))}),(()=>{const T=g(x.name,w);return T.length===0?s.jsx("p",{className:"text-xs text-fg-muted italic",children:"No files for this member yet."}):s.jsx(S0,{noHeader:!0,readOnly:l,files:T.map(([S,E])=>[S.replace(/^members\/[^/]+\//,""),E]),onSave:(S,E)=>{const j=T.find(([L])=>L.endsWith(`/${S}`));j&&o(j[0],E)}})})()]}):null})]});function C(T,S){o(T,S)}}function Mi({type:e,name:t,onBack:n,authUser:r,readOnly:o,initialManifest:l,actionSlot:c,contentSlot:d}){const{t:m}=ft(["builder","common"]),f=Uo(),[h,g]=k.useState(!0),[y,x]=k.useState(t),[w,C]=k.useState({}),[T,S]=k.useState(null),[E,j]=k.useState(""),[L,I]=k.useState("idle"),[O,F]=k.useState({shared:!1}),[V,X]=k.useState(!1),[z,G]=k.useState(!1),[se,ee]=k.useState(!1),[q,re]=k.useState(!1),[B,J]=k.useState(!1),[fe,Se]=k.useState(!1),[U,W]=k.useState(null),[pe,P]=k.useState(0),[_e,He]=k.useState(""),[Pe,Ge]=k.useState(""),[ct,mt]=k.useState(""),[Ct,Mt]=k.useState(""),[Pt,Kt]=k.useState([]),[yt,Ue]=k.useState(""),dt=k.useRef(null),Nt=k.useRef(l);Nt.current=l,k.useEffect(()=>{x(t)},[t]);const bt=k.useCallback(async()=>{const Q=Nt.current;if(Q){S(Q),He(Q.displayName||Q.name||t),Ge(Q.description||""),mt(Q.version||"1.0.0"),Mt(Q.category||"general"),Kt(Q.tags||[]),Ue(Q.icon||""),C(Q.files??{}),g(!1);return}g(!0);try{let Z=t;try{const Ie=await Ee.builder.artifacts.ensureSlugSafe(e,t);Z=Ie.name,x(Z),Ie.converted&&(history.replaceState(null,"",Ti(de.BUILDER,`${e}/${encodeURIComponent(Z)}`)),window.dispatchEvent(new CustomEvent("markus:data-changed")))}catch{x(t)}const be=await Ee.builder.artifacts.get(e,Z);C(be.files??{}),j(be.path??"");const Ke=be.files[`${e}.json`]??be.files["agent.json"]??be.files["team.json"]??be.files["skill.json"];if(Ke){const Ie=JSON.parse(Ke);S(Ie),He(Ie.displayName||Ie.name||t),Ge(Ie.description||""),mt(Ie.version||"1.0.0"),Mt(Ie.category||"general"),Kt(Ie.tags||[]),Ue(Ie.icon||"")}}catch(Z){console.error("Failed to load artifact:",Z)}finally{g(!1)}},[e,t]);k.useEffect(()=>{bt()},[bt]),k.useEffect(()=>{l?.files&&C(l.files)},[l?.files]),k.useEffect(()=>{if(!o){try{const Q=localStorage.getItem("markus_builder_shared_map");if(Q){const Z=JSON.parse(Q),be=`${e}/${t}`;Z[be]&&F({shared:!0,id:Z[be].id,slug:Z[be].slug,version:Z[be].version,visibility:Z[be].visibility??"public"})}}catch{}lt.myItems().then(Q=>{const Z=Q?.items??[],be=e==="agent"?"agent":e==="team"?"team":"skill";for(const Ke of Z)if(Ke.itemType===be&&(Ke.slug===t||Ke.name===t)){F({shared:!0,id:Ke.id,slug:Ke.slug,version:Ke.version,visibility:Ke.visibility??"public",moderationStatus:Ke.moderationStatus,pendingReview:Ke.pendingReview});return}}).catch(()=>{})}},[e,t,o]);const Lt=k.useCallback(async Q=>{if(!(!T||o)){I("saving");try{const Z={...T,...Q};await Ee.builder.artifacts.save(e,Z),S(Z),I("saved"),setTimeout(()=>I(be=>be==="saved"?"idle":be),2e3)}catch{I("error"),setTimeout(()=>I("idle"),3e3)}}},[T,e]),ue=k.useCallback(Q=>{dt.current&&clearTimeout(dt.current),dt.current=setTimeout(()=>Lt(Q),800)},[Lt]),tt=k.useCallback((Q,Z)=>{const be={};Q==="displayName"?(He(Z),be.displayName=Z,G(!0)):Q==="description"?(Ge(Z),be.description=Z,G(!0)):Q==="version"?(mt(Z),be.version=Z,G(!1),ee(!1)):Q==="category"?(Mt(Z),be.category=Z,G(!0)):Q==="tags"?(Kt(Z),be.tags=Z,G(!0)):Q==="icon"&&(Ue(Z),be.icon=Z||void 0,G(!0)),ue({...T,...be})},[T,ue]),st=k.useCallback(async(Q,Z)=>{try{const be={...w,[Q]:Z};C(be);const Ke={...T,files:be};await Ee.builder.artifacts.save(e,Ke),I("saved"),G(!0),setTimeout(()=>I(Ie=>Ie==="saved"?"idle":Ie),2e3)}catch{I("error")}},[w,e,T]),ye=k.useCallback(async Q=>{if(T){X(!0);try{await lt.ensureAuth();const Z=await Ee.builder.artifacts.ensureSlugSafe(e,y,T.displayName||T.name||y),be=Z.name,Ke=Z.slug||xc(be);if(!Ke)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 Ie=Z.displayName||T.displayName||T.name||y;Z.converted&&(x(be),S(ze=>ze&&{...ze,name:Ke,displayName:Ie}),history.replaceState(null,"",Ti(de.BUILDER,`${e}/${encodeURIComponent(be)}`)),window.dispatchEvent(new CustomEvent("markus:data-changed")));const Ye={...T,name:Ke,displayName:Ie},M=Ye.description||"",le=Ye.category||"general",Oe=Ye.tags??[];let ge=Ye.icon||void 0;const Ve=Ye.version||"1.0.0";if(ge&&!ge.startsWith("http")&&/\.(png|jpe?g|gif|webp|svg)$/i.test(ge)){const ze=ge.split("/").pop()??ge;try{const rt=await fetch(`/api/builder/artifacts/${e}s/${encodeURIComponent(be)}/images/${encodeURIComponent(ze)}`,{cache:"no-store"});if(rt.ok){const vt=await rt.blob(),Fe=new File([vt],ze,{type:vt.type}),at=await lt.uploadImage(Fe);at?.url&&(ge=at.url)}}catch{}}let Qe;const K=[],ce=Ye.screenshots??[];for(let ze=0;ze<ce.length;ze++){const rt=ce[ze],vt=rt.split("/").pop()??rt;try{const Fe=await fetch(`/api/builder/artifacts/${e}s/${encodeURIComponent(be)}/images/${encodeURIComponent(vt)}`,{cache:"no-store"});if(Fe.ok){const at=await Fe.blob(),kt=new File([at],vt,{type:at.type}),xn=await lt.uploadImage(kt);xn?.url&&(K.push({url:xn.url,alt:vt,order:ze}),ze===0&&(Qe=xn.url))}}catch{}}const Te=await lt.publishViaProxy({itemType:e==="team"?"team":e==="skill"?"skill":"agent",name:Ie,slug:Ke,description:M,category:le,tags:Oe,icon:ge,version:Ve,config:Ye,files:Object.keys(w).length>0?w:void 0,thumbnailUrl:Qe,images:K.length>0?K:void 0,priceCents:Q?.priceCents,donationsEnabled:Q?.donationsEnabled,visibility:Q?.visibility,orgId:Q?.orgId});Te.id&&(F({shared:!0,id:Te.id,slug:Te.slug??Ke,version:Ve,visibility:Te.visibility??Q?.visibility??"public",moderationStatus:Te.moderationStatus,pendingReview:Te.pendingReview}),G(!1),(Te.visibility??Q?.visibility??"public")!=="org"&&(Te.moderationStatus==="pending"||Te.pendingReview)?W({title:m("common:share"),message:Z.converted?m("share.convertedAndSubmitted",{previous:t,slug:Ke}):Te.updated?m("share.updateSubmitted"):m("share.submittedForReview"),variant:"primary"}):Z.converted&&W({title:m("common:share"),message:m("share.convertedSlug",{previous:t,slug:Ke}),variant:"primary"}))}catch(Z){console.error("Share to Hub failed:",Z),W({title:m("common:share"),message:Z instanceof Error?Z.message:String(Z),variant:"danger"})}finally{X(!1)}}},[T,w,e,t,y,m]),je=async Q=>{const Z=new FormData;Z.append("image",Q);try{await fetch(`/api/builder/artifacts/${e}s/${encodeURIComponent(y)}/images`,{method:"POST",body:Z,credentials:"include"}),await bt(),G(!0),P(be=>be+1)}catch(be){console.error("Image upload failed:",be)}},Ae=async Q=>{try{await fetch(`/api/builder/artifacts/${e}s/${encodeURIComponent(y)}/images/${encodeURIComponent(Q)}`,{method:"DELETE",credentials:"include"}),await bt(),G(!0),P(Z=>Z+1)}catch(Z){console.error("Image remove failed:",Z)}},oe=D4[e]??D4.agent,H=T?.screenshots??[],te=T?.skill?.skillFile?w[T.skill.skillFile]:w["SKILL.md"]??w["README.md"],Ne=k.useMemo(()=>e!=="agent"?[]:Object.entries(w).filter(([Q])=>!Q.endsWith(".json")&&!Q.startsWith("images/")&&!Q.startsWith("members/")),[w,e]),Re=k.useMemo(()=>e!=="team"?[]:Object.entries(w).filter(([Q])=>!Q.endsWith(".json")&&!Q.startsWith("images/")&&!Q.startsWith("members/")),[w,e]),$e=k.useMemo(()=>{if(e==="agent"||e==="team")return[];const Q=new Set;if(e==="skill"){const Z=T?.skill?.skillFile;Z&&w[Z]&&Q.add(Z),!Z&&w["SKILL.md"]&&Q.add("SKILL.md"),!Z&&!w["SKILL.md"]&&w["README.md"]&&Q.add("README.md")}return Object.entries(w).filter(([Z])=>!Z.endsWith(".json")&&!Z.startsWith("images/")&&!Z.startsWith("members/")&&!Q.has(Z))},[w,e,T?.skill?.skillFile]);return h?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:`${f?"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&&L==="saving"&&s.jsx("span",{className:"text-[10px] text-fg-muted animate-pulse",children:m("detail.saving")}),!o&&L==="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&&L==="error"&&s.jsx("span",{className:"text-[10px] text-red-500",children:m("detail.saveFailed")}),c,!o&&O.shared&&(()=>{const Q=lt.getUser(),Z=Q&&O.slug?`${lt.getUrl()}/@${encodeURIComponent(Q.username)}/${encodeURIComponent(O.slug)}`:null,be=ct||T?.version||"1.0.0",Ke=O.version!==be;return s.jsxs(s.Fragment,{children:[O.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")]}):O.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")]}):O.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,Z&&s.jsxs("a",{href:Z,target:"_blank",rel:"noopener noreferrer",onClick:Ie=>{yc()&&(Ie.preventDefault(),_i(Z))},className:`text-xs px-3 py-1.5 rounded-lg border transition-colors inline-flex items-center gap-1.5 ${O.visibility==="org"?"border-blue-500/30 text-blue-500 hover:text-blue-400 hover:border-blue-400/50":O.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:[O.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"})]}):O.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"})]}),O.visibility==="org"?m("visibility.sharedOrg"):O.visibility==="unlisted"?m("visibility.sharedUnlisted"):m("share.viewOnHub")]}),Ke&&s.jsx("button",{onClick:()=>{ye({visibility:O.visibility})},disabled:V,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:V?m("share.updating"):m("share.updateVersion",{version:be})})]})})(),!o&&!O.shared&&s.jsx("button",{onClick:()=>J(!0),disabled:V,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(V?"share.sharing":"share.toHub")})]})]}),!o&&z&&!se&&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:()=>ee(!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&&se&&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 Q=(ct||"1.0.0").split(".");return Q[2]=String(Number(Q[2]??0)+1),Q.join(".")})(),className:"text-xs px-2 py-1 rounded bg-surface-elevated border border-border-default text-fg-primary w-24 font-mono",onKeyDown:Q=>{Q.key==="Enter"&&tt("version",Q.target.value)}}),s.jsx("button",{onClick:Q=>{const Z=Q.target.parentElement?.querySelector("input");Z&&tt("version",Z.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:()=>ee(!1),className:"text-xs text-fg-tertiary hover:text-fg-secondary",children:m("common:cancel")})]}),O.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 ${f?"flex-col":""}`,children:[s.jsxs("div",{className:`${f?"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&&Se(!fe),className:`w-16 h-16 rounded-xl ${oe.bg} flex items-center justify-center text-3xl shrink-0 ${o?"":"cursor-pointer hover:ring-2"} ${oe.ring} transition-all overflow-hidden`,children:yt&&yt.startsWith("images/")?s.jsx("img",{src:`/api/builder/artifacts/${e}s/${encodeURIComponent(y)}/images/${encodeURIComponent(yt.replace("images/",""))}?v=${pe}`,alt:"",className:"w-full h-full object-cover"}):yt&&(yt.startsWith("http")||yt.startsWith("/"))?s.jsx("img",{src:yt,alt:"",className:"w-full h-full object-cover"}):(()=>{const Q=yt||"";if(Q&&[...Q].length<=2&&new RegExp("\\p{Emoji}","u").test(Q))return Q;const be=Ei[Xo(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:s6(_e||t||e),fill:be})})})()}),!o&&fe&&s.jsxs(s.Fragment,{children:[s.jsx("div",{className:"fixed inset-0 z-40",onClick:()=>Se(!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:yt,onKeyDown:Q=>{Q.key==="Enter"&&(tt("icon",Q.target.value),Se(!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 Q=>{const Z=Q.target.files?.[0];if(!Z)return;const be=new FormData;be.append("image",Z);try{const Ke=await fetch(`/api/builder/artifacts/${e}s/${encodeURIComponent(y)}/images`,{method:"POST",body:be,credentials:"include"});if(Ke.ok){const Ye=(await Ke.json()).path;if(Ue(Ye),Se(!1),T){const M={...T,icon:Ye};S(M),await Ee.builder.artifacts.save(e,M)}G(!0)}}catch{}}})]}),yt&&s.jsx("button",{onClick:()=>{tt("icon",""),Se(!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:SW.map(Q=>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:Q.label}),s.jsx("div",{className:"flex flex-wrap gap-0.5",children:Q.emojis.map(Z=>s.jsx("button",{onClick:()=>{tt("icon",Z),Se(!1)},className:`w-7 h-7 rounded flex items-center justify-center text-base hover:bg-surface-elevated transition-colors ${yt===Z?"ring-1.5 ring-brand-500 bg-brand-500/10":""}`,children:Z},Z))})]},Q.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(ah,{value:_e,onChange:Q=>tt("displayName",Q),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 ${oe.bg} ${oe.color}`,children:oe.label}),s.jsx(ah,{value:ct,onChange:Q=>tt("version",Q),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(ah,{value:Pe,onChange:Q=>tt("description",Q),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(CW,{value:Ct,options:kW,onChange:Q=>tt("category",Q),className:"text-xs px-2 py-0.5 rounded bg-surface-elevated text-fg-tertiary",readOnly:o}),s.jsx(TW,{tags:Pt,onChange:Q=>tt("tags",Q),readOnly:o})]})]})]}),s.jsx("div",{className:"mb-8",children:s.jsx(EW,{images:H,artifactType:e,artifactName:t,onUpload:je,onRemove:Ae,readOnly:o,cacheBust:pe})}),d&&s.jsx("div",{className:"mb-8",children:d}),e==="team"&&T.team&&s.jsx("div",{className:"mb-8",children:s.jsx(_W,{members:T.team.members,teamTopFiles:Re,files:w,artifactName:y,onFileSave:st,readOnly:o})}),e==="agent"&&Ne.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(S0,{noHeader:!0,files:Ne,onSave:st,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(Q=>{const Z=NW[Q];return s.jsxs("span",{className:`inline-flex items-center gap-1.5 text-xs px-3 py-1.5 rounded-lg border font-medium ${Z?.color??"bg-surface-elevated text-fg-secondary border-border-default"}`,children:[s.jsx("span",{className:"font-mono text-[10px]",children:Z?.icon??"?"})," ",Q]},Q)})})]}),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(([Q,Z])=>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:Q}),s.jsx("div",{className:"text-[10px] text-fg-muted font-mono truncate",children:typeof Z=="object"?JSON.stringify(Z).slice(0,80):String(Z)})]})]},Q))})]}),te&&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(ag,{content:te})})]})]}),$e.length>0&&s.jsx(S0,{files:$e,onSave:st,readOnly:o})]}),s.jsx("div",{className:`${f?"w-full":"w-72 shrink-0"}`,children:s.jsxs("div",{className:`${f?"":"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 ${oe.color}`,children:oe.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:Ct})]}),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:ct})]}),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((Q,Z)=>Q+Z.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(Q=>Q.role==="manager").reduce((Q,Z)=>Q+Z.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(Q=>Q.role!=="manager").reduce((Q,Z)=>Q+Z.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(Q=>s.jsx("span",{className:"text-[10px] px-1.5 py-0.5 bg-surface-elevated text-fg-muted rounded border border-border-default",children:Q},Q))})]})]})]}),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(Q=>s.jsx("span",{className:"text-[10px] px-2 py-0.5 bg-surface-elevated text-fg-secondary rounded border border-border-default",children:Q},Q))})]}):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(Q=>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:Q},Q))})]}):null]}):null,!o&&E&&s.jsxs("button",{onClick:()=>Ee.system.openPath(E).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:E,children:[s.jsx("span",{className:"text-fg-tertiary block mb-0.5",children:m("sidebar.openInFinder")}),E.replace(/.*\.markus\//,"~/.markus/")]})]})})]})]}),!o&&q&&s.jsx(MW,{onClose:()=>re(!1),onConfirm:(Q,Z)=>{re(!1),ye({donationsEnabled:!1,priceCents:Q==="paid"?Z:void 0})},isUpdate:O.shared}),!o&&B&&s.jsx(jW,{onClose:()=>J(!1),onConfirm:(Q,Z,be,Ke)=>{J(!1),ye({visibility:Q,orgId:Z,priceCents:be,donationsEnabled:Ke})}}),U&&s.jsx(dr,{alertOnly:!0,variant:U.variant??"primary",title:U.title,message:U.message,onConfirm:()=>W(null),onCancel:()=>W(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 jW({onClose:e,onConfirm:t}){const{t:n}=ft(["builder","common"]),[r,o]=k.useState("public"),[l,c]=k.useState([]),[d,m]=k.useState(""),[f,h]=k.useState(!1),[g,y]=k.useState(0),[x,w]=k.useState(!1);k.useEffect(()=>{r==="org"&&l.length===0&&(h(!0),lt.myOrgs().then(S=>{c(S.memberships),S.memberships.length>0&&m(S.memberships[0].id)}).catch(()=>{}).finally(()=>h(!1)))},[r,l.length]);const C=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:S=>S.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(S=>s.jsxs("label",{className:`flex items-center gap-3 p-3 rounded-lg border cursor-pointer transition-colors ${r===S.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===S.value,onChange:()=>o(S.value),className:"accent-brand-500"}),s.jsx("div",{className:"flex items-center gap-2 text-fg-secondary",children:S.icon}),s.jsxs("div",{children:[s.jsx("div",{className:"text-sm font-medium text-fg-primary",children:S.label}),s.jsx("div",{className:"text-[11px] text-fg-tertiary",children:S.desc})]})]},S.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")}),f?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:S=>m(S.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(S=>s.jsx("option",{value:S.id,children:S.name},S.id))})]}),C&&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:o6.map(S=>s.jsx("button",{type:"button",onClick:()=>y(S.cents),className:`text-sm px-2 py-2 rounded-lg border transition-colors ${g===S.cents?"border-brand-500 bg-brand-500/10 text-fg-primary":"border-border-default text-fg-secondary hover:border-gray-600"}`,children:S.label},S.cents))}),s.jsxs("label",{className:"flex items-center gap-2 cursor-pointer",children:[s.jsx("input",{type:"checkbox",checked:x,onChange:S=>w(S.target.checked),className:"accent-brand-500"}),s.jsx("span",{className:"text-xs text-fg-secondary",children:n("pricing.enableTips")})]})]}),C&&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,C&&g>0?g:void 0,C?x: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 o6=[{cents:0,label:"Free"},{cents:100,label:"$1"},{cents:500,label:"$5"},{cents:1e3,label:"$10"}];function MW({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:c=>c.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:o6.map(c=>s.jsxs("label",{className:`flex items-center gap-3 p-3 rounded-lg border cursor-pointer transition-colors ${o===c.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===c.cents,onChange:()=>l(c.cents),className:"accent-brand-500"}),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.cents===0?r("shareMode.freeDesc"):r("shareMode.paidDesc")})]})]},c.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 N0(e,t){return!e||!i6(e)?null:e.startsWith("http")||e.startsWith("data:")?e:e.startsWith("/")&&t?`${t}${e}`:e}function RW({type:e,seed:t,icon:n,hubBase:r,size:o=44,className:l="",rounded:c="rounded-xl"}){const d=Xo(e),m=N0(n,r),f=k.useMemo(()=>Xg(d,t),[d,t]),h=k.useMemo(()=>s6(t),[t]),[g,y]=k.useState(!1);return m&&!g?s.jsx("img",{src:m,alt:"",onError:()=>y(!0),style:{width:o,height:o},className:`${c} object-cover shrink-0 ${l}`}):vW(n)?s.jsx("div",{style:{width:o,height:o,background:f,fontSize:o*.5},className:`${c} shrink-0 flex items-center justify-center shadow-inner ${l}`,children:s.jsx("span",{className:"drop-shadow-sm",children:n})}):n&&MK(n)?s.jsx("div",{style:{width:o,height:o,background:f},className:`${c} shrink-0 flex items-center justify-center text-white shadow-inner ${l}`,children:s.jsx(Yo,{name:n,size:o*.52,className:"drop-shadow-sm"})}):s.jsx("div",{style:{width:o,height:o,background:f},className:`${c} 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:h,fill:"rgba(255,255,255,0.92)"})})})}function C0({name:e,username:t,avatarUrl:n,hubBase:r,size:o=24,className:l="",verified:c}){const d=t||e||"markus",m=N0(n,r),[f,h]=k.useState(!1),g=m&&!f?m:wW(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:()=>h(!0),className:"w-full h-full rounded-full object-cover ring-1 ring-white/10 bg-surface-elevated"}),c&&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 LW({type:e,className:t=""}){const n=Xo(e),r=Ei[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 P4({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 ia(e){const{type:t,name:n,description:r,seed:o,icon:l,cover:c,hubBase:d,author:m,authorLabel:f,version:h,category:g,tags:y,rating:x=0,ratingCount:w=0,downloadCount:C=0,priceCents:T,currency:S="usd",installed:E,glowing:j,selected:L,showTypeBadge:I=!0,hideStats:O=!1,cornerLabel:F,actions:V,footerLeft:X,headerAction:z,onClick:G,className:se=""}=e,ee=Xo(t),q=Ei[ee],re=o||n,B=(T??0)>0,J=!!N0(c||void 0,d),fe=Xg(ee,re),Se=f??m?.displayName??m?.username??"",[U,W]=k.useState(null),pe=E?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"})})}):F?s.jsx("span",{className:"chip",children:F}):B?s.jsx("span",{className:"badge-paid",children:O4(T,S)}):null;if(J){const P=N0(c||void 0,d);return s.jsxs("div",{onClick:G,style:{aspectRatio:U??void 0},className:`group asset-card card-shine relative flex flex-col overflow-hidden min-h-[180px] ${G?"cursor-pointer":""} ${L?"ring-1 ring-brand-500/60":""} ${j?"ring-2 ring-brand-500 shadow-lg shadow-brand-500/20":""} ${se}`,children:[s.jsx("img",{src:P,alt:"",onLoad:_e=>{const He=_e.currentTarget;He.naturalWidth&&He.naturalHeight&&W(Math.min(1.9,Math.max(1,He.naturalWidth/He.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:I&&s.jsx(LW,{type:ee})}),s.jsxs("span",{className:"flex items-center gap-1.5",onClick:_e=>_e.stopPropagation(),children:[E?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"})})}):F?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:F}):z?null:s.jsx("span",{className:B?"badge-paid":"badge-free",children:O4(T,S)}),z]})]}),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}),h&&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",h]})]}),Se&&s.jsxs("div",{className:"flex items-center gap-1.5 text-[11px] text-white/85",children:[m&&s.jsx(C0,{name:m.displayName,username:m.username,avatarUrl:m.avatarUrl,hubBase:d,size:15}),s.jsx("span",{className:"truncate",children:Se})]}),r&&s.jsx("p",{className:"text-[12.5px] text-white/80 truncate leading-snug drop-shadow-sm",children:r}),(g||y&&y.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}),y?.slice(0,3).map(_e=>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:_e},_e))]}),(!O||V)&&s.jsxs("div",{className:"flex items-center justify-between gap-2 pt-1 shrink-0",children:[O?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(P4,{rating:x}),w>0&&s.jsxs("span",{className:"text-white/60",children:["(",Mo(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"})}),Mo(C)]})]}),V&&s.jsx("div",{className:"flex items-center gap-2",onClick:_e=>_e.stopPropagation(),children:V})]})]})]})}return s.jsxs("div",{onClick:G,className:`group asset-card card-shine relative flex flex-col ${G?"cursor-pointer":""} ${L?"ring-1 ring-brand-500/60":""} ${j?"ring-2 ring-brand-500 shadow-lg shadow-brand-500/20":""} ${se}`,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, ${q.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:fe}}),z&&s.jsx("div",{className:"absolute top-2.5 right-2.5 z-10",onClick:P=>P.stopPropagation(),children:z}),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(RW,{type:ee,seed:re,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 ${z?"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}),h&&s.jsxs("span",{className:"chip shrink-0",children:["v",h]}),pe&&s.jsx("span",{className:"ml-auto shrink-0",children:pe})]}),(Se||I)&&s.jsxs("div",{className:"mt-1 flex items-center gap-1.5 text-[11px] text-fg-tertiary min-w-0",children:[m&&s.jsx(C0,{name:m.displayName,username:m.username,avatarUrl:m.avatarUrl,hubBase:d,size:15}),Se&&s.jsx("span",{className:"truncate",children:Se}),I&&s.jsxs(s.Fragment,{children:[Se&&s.jsx("span",{className:"text-fg-muted",children:"·"}),s.jsx("span",{className:"font-semibold shrink-0",style:{color:q.accent},children:q.label})]})]})]})]}),r&&s.jsx("p",{className:"text-[13px] text-fg-secondary truncate leading-snug",children:r}),(g||y&&y.length>0)&&s.jsxs("div",{className:"flex flex-wrap gap-1.5",children:[g&&s.jsx("span",{className:"chip-accent capitalize",children:g}),y?.slice(0,3).map(P=>s.jsx("span",{className:"chip",children:P},P)),(y?.length??0)>3&&s.jsxs("span",{className:"text-[10px] text-fg-muted self-center",children:["+",(y?.length??0)-3]})]}),(()=>{const P=X??(O?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(P4,{rating:x}),s.jsx("span",{className:"text-fg-muted",children:w>0?`(${Mo(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"})}),Mo(C)]})]}));return!P&&!V?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:_e=>_e.stopPropagation(),children:[P&&s.jsx("div",{className:"min-w-0 flex items-center gap-2",children:P}),V&&s.jsx("div",{className:"flex flex-wrap items-center gap-2 justify-end",children:V})]})})()]})]})}function Ar({children:e,maxCardWidth:t=400,gap:n="1rem",className:r=""}){const o=k.useRef(null),[l,c]=k.useState(0);k.useEffect(()=>{const h=o.current;if(!h)return;c(h.clientWidth);const g=new ResizeObserver(y=>{for(const x of y)c(x.contentRect.width)});return g.observe(h),()=>g.disconnect()},[]);const d=Math.max(1,Math.ceil((l||t)/t)),m=k.Children.toArray(e),f=Array.from({length:d},()=>[]);return m.forEach((h,g)=>{f[g%d].push(h)}),s.jsx("div",{ref:o,className:`flex items-start ${r}`,style:{gap:n},children:f.map((h,g)=>s.jsx("div",{className:"flex flex-col flex-1 min-w-0",style:{gap:n,maxWidth:t},children:h},g))})}function OW(e){const t=e.indexOf(".markus/builder-artifacts/");return t>=0?"~/"+e.slice(t):e}const DW=[{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 IW(){const[e,t]=k.useState(()=>{const r=window.location.hash.slice(1).split("/");return fc(r[0])===de.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("/");fc(o[0])===de.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 l6="markus_builder_shared_map";function PW(){try{const e=localStorage.getItem(l6);if(!e)return new Map;const t=JSON.parse(e);return new Map(Object.entries(t))}catch{return new Map}}function Ld(e){try{localStorage.setItem(l6,JSON.stringify(Object.fromEntries(e)))}catch{}}function c6({authUser:e}={}){const{t}=ft(["builder","common"]),n=Uo(),r=IW(),[o,l]=k.useState([]),[c,d]=k.useState([]),[m,f]=k.useState(!1),[h,g]=k.useState("all"),[y,x]=k.useState(null),[w,C]=k.useState(new Map),[T,S]=k.useState(null),[E,j]=k.useState(null),[L,I]=k.useState(null),[O,F]=k.useState(PW),[V,X]=k.useState(null),[z,G]=k.useState(null),[se,ee]=k.useState(null),[q,re]=k.useState(null),[B,J]=k.useState(null),[fe,Se]=k.useState("creations"),[U,W]=k.useState([]),[pe,P]=k.useState(""),[_e,He]=k.useState([]),[Pe,Ge]=k.useState(!1),[ct,mt]=k.useState("all"),Ct=k.useCallback(()=>{f(!0),Promise.all([(Si(Tr.builderArtifacts)??Ee.builder.artifacts.list()).then(ue=>ue?.artifacts??[]).catch(()=>[]),(Si(Tr.builderAgents)??Ee.agents.list()).then(ue=>ue?.agents??[]).catch(()=>[]),(Si(Tr.builderHubMyItems)??lt.myItems()).then(ue=>ue?.items??[]).catch(()=>[]),(Si(Tr.builderInstalled)??Ee.builder.artifacts.installed()).then(ue=>ue?.installed??{}).catch(()=>({}))]).then(([ue,tt,st,ye])=>{if(d(ue),l(tt),st.length>0){const Ae=new Map;for(const oe of st){const H=oe.itemType==="agent"?"agent":oe.itemType==="team"?"team":"skill";for(const te of ue)te.type===H&&(oe.slug===te.name||oe.name===(te.meta.displayName||te.meta.name||te.name))&&Ae.set(`${te.type}/${te.name}`,{id:oe.id,name:oe.name,slug:oe.slug||te.name,version:oe.version||"1.0.0",visibility:oe.visibility??"public",moderationStatus:oe.moderationStatus,pendingReview:oe.pendingReview})}Ae.size>0&&F(oe=>{const H=new Map(oe);for(const[te,Ne]of Ae)H.set(te,Ne);return Ld(H),H})}const je=new Map;for(const Ae of ue){const oe=`${Ae.type}/${Ae.name}`,H=ye[oe];H&&je.set(oe,{agentId:H.agentId,agentIds:H.agentIds,teamId:H.teamId})}C(je)}).finally(()=>f(!1))},[]);k.useEffect(()=>{Ct();const ue=tt=>{tt.detail?.page===de.BUILDER&&Ct()};return window.addEventListener("markus:navigate",ue),()=>window.removeEventListener("markus:navigate",ue)},[Ct]);const Mt=ue=>{const tt=o.find(st=>st.role==="Secretary"||st.name==="Secretary");tt?it.navigate(de.TEAM,{agentId:tt.id,prefillMessage:ue}):it.navigate(de.TEAM,{prefillMessage:ue})},Pt=async ue=>{const tt=`${ue.type}/${ue.name}`;if(!w.has(tt)){x({key:tt,action:"install"});try{const st=await Ee.builder.artifacts.install(ue.type,ue.name),ye={};st.agent&&typeof st.agent=="object"&&(ye.agentId=st.agent.id),st.team&&typeof st.team=="object"&&(ye.teamId=st.team.id),Array.isArray(st.agents)&&(ye.agentIds=st.agents.map(je=>je.id)),C(je=>new Map(je).set(tt,ye)),window.dispatchEvent(new CustomEvent("markus:data-changed"))}catch(st){console.error("Install failed:",st),G({title:t("common:install"),message:t("installFailed",{error:String(st)}),variant:"danger"})}finally{x(null)}}},Kt=async ue=>{const tt=`${ue.type}/${ue.name}`;if(w.has(tt)){x({key:tt,action:"uninstall"});try{await Ee.builder.artifacts.uninstall(ue.type,ue.name),C(st=>{const ye=new Map(st);return ye.delete(tt),ye}),window.dispatchEvent(new CustomEvent("markus:data-changed"))}catch(st){console.error("Uninstall failed:",st),G({title:t("common:uninstall"),message:t("uninstallFailed",{error:String(st)}),variant:"danger"})}finally{x(null)}}},yt=async(ue,tt)=>{const st=`${ue.type}/${ue.name}`;x({key:st,action:"share"});try{const ye=await Ee.builder.artifacts.ensureSlugSafe(ue.type,ue.name,ue.meta.displayName||ue.meta.name||ue.name),je=ye.name,Ae=ye.slug||xc(je);if(!Ae)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 oe=`${ue.type}/${je}`;ye.converted&&(d(le=>le.map(Oe=>Oe.type===ue.type&&Oe.name===ue.name?{...Oe,name:je,path:ye.path,meta:{...Oe.meta,name:je,displayName:ye.displayName??Oe.meta.displayName??ue.name}}:Oe)),F(le=>{const Oe=new Map(le),ge=Oe.get(st);return ge&&(Oe.delete(st),Oe.set(oe,{...ge,slug:Ae,name:ye.displayName??ge.name})),Ld(Oe),Oe}),C(le=>{const Oe=new Map(le),ge=Oe.get(st);return ge&&(Oe.delete(st),Oe.set(oe,ge)),Oe}));const H=await Ee.builder.artifacts.get(ue.type,je);let te={...ue.meta,name:je,displayName:ye.displayName??ue.meta.displayName??ue.name};try{const le=H.files?.[`${ue.type}.json`]??H.files?.["agent.json"]??H.files?.["team.json"]??H.files?.["skill.json"];le&&(te={...JSON.parse(le),...te,name:je,displayName:te.displayName})}catch{}const Ne=te.displayName||te.name||je,Re=te.description||"",$e=te.category||"general",Q=Array.isArray(te.tags)?te.tags:[];let Z=te.icon||void 0;const be=te.version||"1.0.0";if(Z&&!Z.startsWith("http")&&/\.(png|jpe?g|gif|webp|svg)$/i.test(Z)){const le=Z.split("/").pop()??Z;try{const Oe=await fetch(`/api/builder/artifacts/${ue.type}s/${encodeURIComponent(je)}/images/${encodeURIComponent(le)}`);if(Oe.ok){const ge=await Oe.blob(),Ve=new File([ge],le,{type:ge.type}),Qe=await lt.uploadImage(Ve);Qe?.url&&(Z=Qe.url)}}catch{}}let Ke;const Ie=[],Ye=Array.isArray(te.screenshots)?te.screenshots:[];for(let le=0;le<Ye.length;le++){const Oe=Ye[le],ge=Oe.split("/").pop()??Oe;try{const Ve=await fetch(`/api/builder/artifacts/${ue.type}s/${encodeURIComponent(je)}/images/${encodeURIComponent(ge)}`);if(Ve.ok){const Qe=await Ve.blob(),K=new File([Qe],ge,{type:Qe.type}),ce=await lt.uploadImage(K);ce?.url&&(Ie.push({url:ce.url,alt:ge,order:le}),(le===0||te.thumbnail===Oe)&&(Ke=ce.url))}}catch{}}const M=await lt.publishViaProxy({itemType:ue.type==="team"?"team":ue.type==="skill"?"skill":"agent",name:Ne,slug:Ae,description:Re,category:$e,tags:Q,icon:Z,version:be,config:{...te,name:je,displayName:Ne},files:H.files&&Object.keys(H.files).length>0?H.files:void 0,thumbnailUrl:Ke,images:Ie.length>0?Ie:void 0,priceCents:tt?.priceCents,donationsEnabled:tt?.donationsEnabled,visibility:tt?.visibility,orgId:tt?.orgId});M.id&&(F(Oe=>{const ge=new Map(Oe);return ge.set(oe,{id:M.id,name:Ne,slug:M.slug??Ae,version:be,visibility:M.visibility??tt?.visibility??"public",moderationStatus:M.moderationStatus,pendingReview:M.pendingReview}),Ld(ge),ge}),(M.visibility??tt?.visibility??"public")!=="org"&&(M.moderationStatus==="pending"||M.pendingReview)?G({title:t("common:share"),message:ye.converted?t("share.convertedAndSubmitted",{previous:ue.name,slug:Ae}):M.updated?t("share.updateSubmitted"):t("share.submittedForReview"),variant:"primary"}):ye.converted&&G({title:t("common:share"),message:t("share.convertedSlug",{previous:ue.name,slug:Ae}),variant:"primary"}))}catch(ye){console.error("Share failed:",ye),G({title:t("common:share"),message:t("shareFailed",{error:ye instanceof Error?ye.message:String(ye)}),variant:"danger"})}finally{x(null)}},Ue=async()=>{if(!V)return;const{key:ue}=V,tt=O.get(ue);if(X(null),!tt)return;const st=tt.id;x({key:ue,action:"hubDelete"});try{await lt.deleteItem(st),F(ye=>{const je=new Map(ye);return je.delete(ue),Ld(je),je})}catch(ye){console.error("Hub delete failed:",ye),G({title:t("unshare"),message:t("hubDeleteFailed",{error:String(ye)}),variant:"danger"})}finally{x(null)}},dt=async()=>{if(!T)return;const ue=T,tt=`${ue.type}/${ue.name}`;S(null),x({key:tt,action:"delete"});try{await Ee.builder.artifacts.delete(ue.type,ue.name),d(st=>st.filter(ye=>!(ye.type===ue.type&&ye.name===ue.name))),C(st=>{const ye=new Map(st);return ye.delete(tt),ye}),window.dispatchEvent(new CustomEvent("markus:data-changed"))}catch(st){console.error("Delete failed:",st)}finally{x(null)}},Nt=h==="all"?c:c.filter(ue=>ue.type===h);k.useEffect(()=>{fe!=="orgAssets"||U.length>0||lt.myOrgs().then(ue=>{W(ue.memberships),ue.memberships.length>0&&!pe&&P(ue.memberships[0].id)}).catch(()=>{})},[fe,U.length,pe]),k.useEffect(()=>{fe!=="orgAssets"||!pe||(Ge(!0),lt.browseItems({orgId:pe,limit:100}).then(ue=>He(ue.items??[])).catch(()=>He([])).finally(()=>Ge(!1)))},[fe,pe]);const bt=ct==="all"?_e:_e.filter(ue=>ue.itemType===ct),Lt=ue=>{history.pushState(null,"",Ti(de.BUILDER,`${ue.type}/${encodeURIComponent(ue.name)}`)),window.dispatchEvent(new HashChangeEvent("hashchange"))};return r?s.jsx(Mi,{type:r.type,name:r.name,authUser:e,onBack:()=>{history.pushState(null,"",Ti(de.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:DW.map(ue=>{const tt=t(`prompts.${ue.id}Prompt`),st=t(`prompts.${ue.id}Examples`,{returnObjects:!0}),ye=Array.isArray(st)?st:[];return s.jsx("button",{onClick:()=>Mt(tt),className:`group text-left w-full rounded-xl border ${ue.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 ${ue.bgColor} flex items-center justify-center shrink-0`,children:ue.icon}),s.jsxs("div",{className:"flex-1 min-w-0",children:[s.jsx("h3",{className:`text-sm font-semibold bg-gradient-to-r ${ue.color} bg-clip-text text-transparent`,children:t(`prompts.${ue.id}`)}),s.jsx("p",{className:"text-[11px] text-fg-tertiary mt-1 leading-relaxed",children:t(`prompts.${ue.id}Desc`)}),ye.length>0&&s.jsx("div",{className:"mt-2 flex flex-wrap gap-1.5",children:ye.slice(0,2).map((je,Ae)=>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:oe=>{oe.stopPropagation(),Mt(tt+je)},children:["“",je,"”"]},Ae))})]})]})},ue.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:()=>Se("creations"),className:`text-sm font-semibold transition-colors ${fe==="creations"?"text-fg-primary":"text-fg-tertiary hover:text-fg-secondary"}`,children:t("myCreations.title")}),s.jsx("button",{onClick:()=>Se("orgAssets"),className:`text-sm font-semibold transition-colors ${fe==="orgAssets"?"text-fg-primary":"text-fg-tertiary hover:text-fg-secondary"}`,children:t("orgAssets.title")})]}),fe==="creations"&&s.jsx("div",{className:"flex gap-1.5",children:["all","agent","team","skill"].map(ue=>s.jsx("button",{onClick:()=>g(ue),className:`text-xs px-2.5 py-1 rounded-lg transition-colors ${h===ue?"bg-brand-600 text-white":"text-fg-tertiary hover:text-fg-secondary hover:bg-surface-elevated"}`,children:t(ue==="all"?"myCreations.filterAll":ue==="agent"?"myCreations.filterAgents":ue==="team"?"myCreations.filterTeams":"myCreations.filterSkills")},ue))}),fe==="orgAssets"&&s.jsx("div",{className:"flex gap-1.5",children:["all","agent","team","skill"].map(ue=>s.jsx("button",{onClick:()=>mt(ue),className:`text-xs px-2.5 py-1 rounded-lg transition-colors ${ct===ue?"bg-brand-600 text-white":"text-fg-tertiary hover:text-fg-secondary hover:bg-surface-elevated"}`,children:t(ue==="all"?"myCreations.filterAll":ue==="agent"?"myCreations.filterAgents":ue==="team"?"myCreations.filterTeams":"myCreations.filterSkills")},ue))})]})}),fe==="orgAssets"&&U.length>0&&s.jsx("div",{className:"flex gap-2 mb-3 overflow-x-auto pb-1",children:U.map(ue=>s.jsx("button",{onClick:()=>P(ue.id),className:`text-xs px-3 py-1.5 rounded-full whitespace-nowrap border transition-colors ${pe===ue.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:ue.name},ue.id))}),fe==="orgAssets"&&(U.length===0&&!Pe?s.jsx("div",{className:"text-center py-12",children:s.jsx("div",{className:"text-fg-tertiary text-sm",children:t("orgAssets.noOrgs")})}):Pe?s.jsx("div",{className:"text-center text-fg-tertiary py-12 text-sm",children:t("orgAssets.loading")}):bt.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(Ar,{children:bt.map(ue=>{const tt=ue.author?.username&&ue.slug?`${lt.getUrl()}/@${encodeURIComponent(ue.author.username)}/${encodeURIComponent(ue.slug)}`:null;return s.jsx(ia,{type:ue.itemType,name:ue.name,description:ue.description,seed:ue.slug||ue.id||ue.name,icon:ue.icon,cover:ue.thumbnailUrl,hubBase:lt.getUrl(),author:ue.author,version:ue.version,rating:parseFloat(ue.avgRating)||0,ratingCount:ue.ratingCount,downloadCount:ue.downloadCount,actions:tt?s.jsxs("a",{href:tt,target:"_blank",rel:"noopener noreferrer",onClick:st=>{st.stopPropagation(),yc()&&(st.preventDefault(),_i(tt))},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},ue.id)})})),fe==="creations"&&(m&&c.length===0?s.jsx("div",{className:"text-center text-fg-tertiary py-12 text-sm",children:t("myCreations.loadingArtifacts")}):Nt.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(Ar,{children:Nt.map(ue=>{const tt=ue.meta.displayName||ue.meta.name||ue.name,st=ue.meta.description||"",ye=`${ue.type}/${ue.name}`,je=y?.key===ye?y.action:null,Ae=O.get(ye),oe=ue.meta.version||"1.0.0",H=!!Ae,te=H&&Ae.version!==oe,Ne=()=>{const Ie=lt.getUser();return!Ae||!Ie?null:`${lt.getUrl()}/@${encodeURIComponent(Ie.username)}/${encodeURIComponent(Ae.slug)}`},Re=H&&(Ae?.moderationStatus==="pending"||Ae?.moderationStatus==="rejected"||!!Ae?.pendingReview),$e=s.jsxs("div",{className:"flex items-center gap-1.5 justify-end",onClick:Ie=>Ie.stopPropagation(),children:[w.has(ye)?s.jsxs("button",{onClick:()=>I(ue),disabled:!!je,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(je==="uninstall"?"common:uninstalling":"common:uninstall")]}):s.jsxs("button",{onClick:()=>j(ue),disabled:!!je,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(je==="install"?"common:installing":"common:install")]}),H&&Re?Ae?.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")]}):Ae?.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")]}):H?s.jsxs(s.Fragment,{children:[te&&s.jsxs("button",{onClick:()=>{const Ie=Ae?.visibility??"public";yt(ue,{visibility:Ie})},disabled:!!je,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"})]}),je==="share"?t("common:sharing"):t("share.updateVersion",{version:oe})]}),s.jsxs("a",{href:Ne()??"#",target:"_blank",rel:"noopener noreferrer",onClick:Ie=>{const Ye=Ne();yc()&&Ye&&(Ie.preventDefault(),_i(Ye))},className:`text-xs px-3 py-1.5 rounded-lg border transition-colors inline-flex items-center gap-1 ${Ae?.visibility==="org"?"border-blue-500/30 text-blue-500 hover:text-blue-400 hover:border-blue-400/40":Ae?.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:[Ae?.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"})]}):Ae?.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"})]}),Ae?.visibility==="org"?t("visibility.sharedOrg"):Ae?.visibility==="unlisted"?t("visibility.sharedUnlisted"):t("visibility.shared")]}),s.jsxs("button",{onClick:()=>X({key:ye,name:tt}),disabled:!!je,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(ue.meta.screenshots)&&ue.meta.screenshots.length>0?J(ue):ee(ue)},disabled:!!je,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(je==="share"?"common:sharing":"common:share")]})]}),Q=s.jsx("button",{onClick:()=>S(ue),disabled:!!je,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"})]})}),Z=ue.meta.icon,Ke=!!Z&&/\.(png|jpe?g|gif|webp|svg)$/i.test(Z)?Z.startsWith("http")||Z.startsWith("/")?Z:`/api/builder/artifacts/${ue.type}s/${encodeURIComponent(ue.name)}/images/${encodeURIComponent(Z.split("/").pop()??"")}?v=${ue.updatedAt??""}`:Z;return s.jsx(ia,{type:ue.type,name:tt,description:st,seed:ye,icon:Ke,version:oe,footerLeft:s.jsxs("span",{className:"flex items-center gap-2 text-[10px] text-fg-tertiary min-w-0",children:[s.jsx("button",{onClick:Ie=>{Ie.stopPropagation(),Ee.system.openPath(ue.path).catch(()=>{})},className:"hover:text-fg-secondary transition-colors truncate min-w-0",title:ue.path,children:OW(ue.path)}),s.jsx("span",{className:"shrink-0",children:"·"}),s.jsx("span",{className:"shrink-0",children:new Date(ue.updatedAt).toLocaleDateString()})]}),headerAction:Q,actions:$e,onClick:()=>Lt(ue)},ye)})})),E&&s.jsx(dr,{variant:"primary",title:t("confirmInstall"),message:t("confirmInstallMsg",{name:E.meta.displayName||E.meta.name||E.name}),confirmLabel:t("common:install"),onConfirm:()=>{const ue=E;j(null),Pt(ue)},onCancel:()=>j(null)}),L&&s.jsx(dr,{variant:"primary",title:t("confirmUninstall"),message:t("confirmUninstallMsg",{name:L.meta.displayName||L.meta.name||L.name}),confirmLabel:t("common:uninstall"),onConfirm:()=>{const ue=L;I(null),Kt(ue)},onCancel:()=>I(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:dt,onCancel:()=>S(null)}),V&&s.jsx(dr,{title:t("confirmUnshare"),message:t("removeFromHub",{name:V.name}),confirmLabel:t("unshare"),onConfirm:()=>{Ue()},onCancel:()=>X(null)}),z&&s.jsx(dr,{alertOnly:!0,variant:z.variant??"primary",title:z.title,message:z.message,onConfirm:()=>G(null),onCancel:()=>G(null)}),se&&s.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/60 backdrop-blur-sm",onClick:()=>ee(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:ue=>ue.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 ue=se;ee(null),J(ue)},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 ue=se;ee(null),Lt(ue)},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")})]})]})}),q&&s.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/60 backdrop-blur-sm",onClick:()=>re(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:ue=>ue.stopPropagation(),children:s.jsx(BW,{isUpdate:O.has(`${q.type}/${q.name}`),onCancel:()=>re(null),onConfirm:(ue,tt)=>{const st=q;re(null),yt(st,{priceCents:tt>0?tt:void 0})}})})}),B&&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:ue=>ue.stopPropagation(),children:s.jsx(zW,{onCancel:()=>J(null),onConfirm:(ue,tt,st,ye)=>{const je=B;J(null),yt(je,{visibility:ue,orgId:tt,priceCents:st,donationsEnabled:ye})}})})})]})})}function zW({onCancel:e,onConfirm:t}){const{t:n}=ft(["builder","common"]),[r,o]=k.useState("public"),[l,c]=k.useState([]),[d,m]=k.useState(""),[f,h]=k.useState(!1),[g,y]=k.useState(0),[x,w]=k.useState(!1);k.useEffect(()=>{r==="org"&&l.length===0&&(h(!0),lt.myOrgs().then(S=>{c(S.memberships),S.memberships.length>0&&m(S.memberships[0].id)}).catch(()=>{}).finally(()=>h(!1)))},[r,l.length]);const C=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(S=>s.jsxs("label",{className:`flex items-center gap-3 p-3 rounded-lg border cursor-pointer transition-colors ${r===S.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===S.value,onChange:()=>o(S.value),className:"accent-brand-500"}),s.jsx("div",{className:"flex items-center gap-2 text-fg-secondary",children:S.icon}),s.jsxs("div",{children:[s.jsx("div",{className:"text-sm font-medium text-fg-primary",children:S.label}),s.jsx("div",{className:"text-[11px] text-fg-tertiary",children:S.desc})]})]},S.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")}),f?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:S=>m(S.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(S=>s.jsx("option",{value:S.id,children:S.name},S.id))})]}),C&&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:u6.map(S=>s.jsx("button",{type:"button",onClick:()=>y(S.cents),className:`text-sm px-2 py-2 rounded-lg border transition-colors ${g===S.cents?"border-brand-500 bg-brand-500/10 text-fg-primary":"border-border-default text-fg-secondary hover:border-gray-600"}`,children:S.label},S.cents))}),s.jsxs("label",{className:"flex items-center gap-2 cursor-pointer",children:[s.jsx("input",{type:"checkbox",checked:x,onChange:S=>w(S.target.checked),className:"accent-brand-500"}),s.jsx("span",{className:"text-xs text-fg-secondary",children:n("pricing.enableTips")})]})]}),C&&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,C&&g>0?g:void 0,C?x: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 u6=[{cents:0,label:"Free"},{cents:100,label:"$1"},{cents:500,label:"$5"},{cents:1e3,label:"$10"}];function BW({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:u6.map(c=>s.jsxs("label",{className:`flex items-center gap-3 p-3 rounded-lg border cursor-pointer transition-colors ${o===c.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===c.cents,onChange:()=>l(c.cents),className:"accent-brand-500"}),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.cents===0?r("shareMode.freeDesc"):r("shareMode.paidDesc")})]})]},c.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 $W=Object.freeze(Object.defineProperty({__proto__:null,AgentBuilder:c6},Symbol.toStringTag,{value:"Module"}));async function d6(e,t){if(!t)return{items:e,highlighted:null,missing:!1};const n=e.find(r=>r.id===t);if(n)return{items:[n,...e.filter(r=>r.id!==t)],highlighted:n,missing:!1};try{const{item:r}=await lt.getItem(t);return r?{items:[r,...e],highlighted:r,missing:!1}:{items:e,highlighted:null,missing:!0}}catch{return{items:e,highlighted:null,missing:!0}}}function HW(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,c=r[o]??0;if(l>c)return!0;if(l<c)return!1}return!1}function T0(e,t){const n=e.i18n?.[t];return n?.displayName||n?.name||e.name}function z4(e,t){return e.i18n?.[t]?.description||e.description}const UW={manager:"bg-brand-500/15 text-brand-500",worker:"bg-blue-500/15 text-blue-600"};function FW({authUser:e,highlightItemId:t,onHighlightDone:n}={}){const{t:r,i18n:o}=ft(["store","common"]),l=o.language,[c,d]=k.useState(""),[m,f]=k.useState([]),[h,g]=k.useState([]),[y,x]=k.useState(null),[w,C]=k.useState({}),[T,S]=k.useState(!1),[E,j]=k.useState(!0),[L,I]=k.useState(new Map),[O,F]=k.useState(new Set),[V,X]=k.useState(null),[z,G]=k.useState(null),se=k.useCallback(async()=>{try{const[re,B]=await Promise.all([Ee.builder.artifacts.list().catch(()=>({artifacts:[]})),Ee.builder.artifacts.installed().catch(()=>({installed:{}}))]),J=new Map;for(const fe of re.artifacts){if(fe.type!=="agent")continue;const Se=!!B.installed[`agent/${fe.name}`];J.set(fe.name,{installed:Se,localVersion:fe.meta.version||void 0,localUpdatedAt:fe.updatedAt})}I(J)}catch{}},[]),ee=k.useCallback(async()=>{j(!0);try{const re=c?lt.search({type:"agent",q:c,limit:50}):Si(Tr.hubAgents)??lt.search({type:"agent",limit:50}),B=new URLSearchParams;c&&B.set("q",c);const J=fetch("/api/templates?"+B.toString()).then(W=>W.json()).catch(()=>({templates:[]})),[fe,Se]=await Promise.all([re.catch(()=>({items:[],total:0})),J,se(),lt.isAuthenticated()?lt.purchases.mine().then(W=>F(new Set(W.purchases.map(pe=>pe.itemId)))).catch(()=>{}):Promise.resolve()]),U=await d6(fe?.items??[],t);g(U.items),f(Array.isArray(Se.templates)?Se.templates:[]),U.missing&&n?.()}catch{f([]),g([])}finally{j(!1)}},[c,se,t,n]);k.useEffect(()=>{ee()},[ee]),k.useEffect(()=>{if(!y){C({});return}fetch(`/api/templates/${encodeURIComponent(y.id)}/files`,{credentials:"include"}).then(re=>re.json()).then(re=>C(re.files??{})).catch(()=>C({}))},[y]);const q=async(re,B,J)=>{try{const fe=await fetch("/api/templates/instantiate",{method:"POST",headers:{"Content-Type":"application/json"},credentials:"include",body:JSON.stringify({templateId:re,name:B,orgId:"default",teamId:J})});if(!fe.ok)throw new Error(`Failed: ${fe.status}`);S(!1),x(null)}catch(fe){G({title:r("common:create",{defaultValue:"Create"}),message:`Failed to create agent: ${fe}`,variant:"danger"})}};if(V)return s.jsx(Mi,{type:V.type,name:V.name,onBack:()=>X(null)});if(y){const re={type:"agent",name:y.id,displayName:T0(y,l),version:y.version,description:z4(y,l),author:y.author,category:y.category,tags:y.tags,icon:y.icon,files:w,agent:{roleName:y.roleId,agentRole:y.agentRole==="manager"?"manager":"worker"},dependencies:{skills:y.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:y.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 ${UW[y.agentRole]??""}`,children:y.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:[y.skills.map(J=>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:J},J)),y.skills.length===0&&s.jsx("span",{className:"text-xs text-fg-tertiary italic",children:r("agentStore.noSkills")})]})]})]}),y.starterTasks&&y.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:y.starterTasks.map((J,fe)=>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 ${J.priority==="high"?"bg-red-400":J.priority==="medium"?"bg-amber-400":"bg-green-400"}`}),s.jsxs("div",{children:[s.jsx("div",{className:"text-sm text-fg-primary",children:J.title}),J.description&&s.jsx("div",{className:"text-xs text-fg-tertiary mt-0.5",children:J.description})]})]},fe))})]})]});return s.jsxs(s.Fragment,{children:[s.jsx(Mi,{type:"agent",name:y.id,onBack:()=>x(null),readOnly:!0,initialManifest:re,actionSlot:s.jsx("button",{onClick:()=>S(!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(B4,{template:y,lang:l,onClose:()=>S(!1),onHire:q}),z&&s.jsx(dr,{alertOnly:!0,variant:z.variant??"danger",title:z.title,message:z.message,onConfirm:()=>G(null),onCancel:()=>G(null)})]})}return s.jsxs("div",{className:"flex-1 overflow-hidden flex flex-col",children:[s.jsxs("div",{"data-electron-drag":!0,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:c,onChange:re=>d(re.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:E?s.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-4",children:Array.from({length:6}).map((re,B)=>s.jsx("div",{className:"h-56 rounded-2xl skeleton"},B))}):m.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:c?r("agentStore.noResults",{search:c}):r("agentStore.noAgents")}),s.jsx("div",{className:"text-fg-tertiary text-sm",children:r(c?"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(Ar,{columns:3,children:m.map(re=>s.jsx(ia,{type:"agent",name:T0(re,l),description:z4(re,l),seed:re.id,icon:re.icon,version:re.version,category:re.category,tags:re.tags,authorLabel:re.author,hideStats:!0,showTypeBadge:!1,cornerLabel:r("agentStore.builtin"),onClick:()=>x(re)},re.id))})]}),h.length>0&&s.jsxs("section",{children:[s.jsx("h3",{className:"section-title mb-3",children:r("agentStore.markusHub")}),s.jsx(Ar,{columns:3,children:h.map(re=>s.jsx(qW,{item:re,localInfo:L.get(Oc(re)),purchased:e0(re,O),onStatusChange:se,highlight:re.id===t,onHighlightDone:n,onViewDetail:B=>X({type:"agent",name:B})},re.id))})]})]})}),T&&y&&s.jsx(B4,{template:y,lang:l,onClose:()=>S(!1),onHire:q}),z&&s.jsx(dr,{alertOnly:!0,variant:z.variant??"danger",title:z.title,message:z.message,onConfirm:()=>G(null),onCancel:()=>G(null)})]})}function Oc(e,t){if(e.slug&&e.slug.trim())return e.slug.trim();const n=t&&typeof t.name=="string"?t.name.trim():"";return r0(n||e.name,"hub-pkg")}function Ni(e){return(async()=>{const t=await lt.download(e.id),n=t.name||e.name,r=t.config??{},o=Oc(e,r),l=t.itemType==="team"?"team":t.itemType==="skill"?"skill":"agent",c={type:"hub",hubItemId:e.id},d=(t.version||e.version||(typeof r.version=="string"?r.version:"")||"").trim()||void 0;if(t.files&&Object.keys(t.files).length>0)await Ee.builder.artifacts.import(l,o,t.files,c,d);else{const m={...r,...d?{version:d}:{},name:o,displayName:r.displayName||n,description:e.description,source:c};await Ee.builder.artifacts.save(l,m)}return await Ee.builder.artifacts.install(l,o),window.dispatchEvent(new CustomEvent("markus:data-changed")),n})()}async function Qg(e,t){t("checking"),await lt.ensureAuth();const n=await lt.purchases.checkout(e.id);if(n.alreadyOwned)return t("installing"),await Ni(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 Ni(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 c=setInterval(async()=>{const d=r?r.closed:!1;try{if((await lt.purchases.checkout(e.id)).alreadyOwned){clearInterval(c),t("installing");try{await Ni(e),o("installed")}catch(f){l(f)}return}}catch{}if(d){clearInterval(c);try{if((await lt.purchases.checkout(e.id)).alreadyOwned){t("installing"),await Ni(e),o("installed");return}}catch{}o("cancelled")}},2e3)})}function qW({item:e,localInfo:t,purchased:n,onStatusChange:r,highlight:o,onHighlightDone:l,onViewDetail:c}){const{t:d}=ft(["store"]),[m,f]=k.useState(!1),[h,g]=k.useState(""),y=k.useRef(null),[x,w]=k.useState(!1);k.useEffect(()=>{if(o&&y.current){y.current.scrollIntoView({behavior:"smooth",block:"center"}),w(!0);const V=setTimeout(()=>{w(!1)},4e3);return()=>clearTimeout(V)}},[o,l]);const C=t?.installed??!1,T=C&&e.version&&t?.localVersion&&HW(e.version,t.localVersion),S=(e.priceCents??0)>0,E=async V=>{if(V.stopPropagation(),!m){f(!0),g("");try{await Ni(e),g(T?d("card.upgraded"):d("card.installed")+"!"),r()}catch(X){const z=X instanceof Error?X.message:"";z.includes("402")||z.includes("Purchase required")?g(d("card.purchaseRequired")):g(d("card.failed"))}finally{f(!1)}}},j=async V=>{if(V.stopPropagation(),!m){f(!0),g("");try{await Qg(e,z=>{z==="checkout_opened"?g(d("card.waitingPurchase","Waiting for purchase...")):z==="installing"&&g(d("card.installing"))})==="installed"?(g(d("card.installed")+"!"),r()):g("")}catch(X){g(X instanceof Error?X.message:d("card.failed"))}finally{f(!1)}}},L=S?`$${((e.priceCents??0)/100).toFixed(2)}`:null,I=e.slug&&e.author?.username?`${lt.getUrl()}/@${encodeURIComponent(e.author.username)}/${encodeURIComponent(e.slug)}`:null,O=()=>{C&&c?c(Oc(e)):I&&window.open(I,"_blank","noopener,noreferrer")},F=s.jsxs(s.Fragment,{children:[T?s.jsx("button",{onClick:V=>{E(V)},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})}):C?s.jsxs("button",{onClick:V=>{E(V)},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}`:""]}):S&&!n?s.jsx("button",{onClick:V=>{j(V)},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?h||d("card.installing"):s.jsxs(s.Fragment,{children:[d("card.buy","Buy")," ",L]})}):s.jsx("button",{onClick:V=>{E(V)},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")}),h&&!(S&&!n)&&s.jsx("span",{className:`text-[10px] ${h===d("card.failed")||h===d("card.purchaseRequired")?"text-red-500":"text-green-600"}`,children:h})]});return s.jsx("div",{ref:y,className:x?"animate-pulse":"",children:s.jsx(ia,{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:C,glowing:x,onClick:O,actions:F})})}function B4({template:e,lang:t,onClose:n,onHire:r}){const{t:o}=ft(["store"]),[l,c]=k.useState(`${T0(e,t)} Agent`),[d,m]=k.useState(""),[f,h]=k.useState([]),[g,y]=k.useState(!1);k.useEffect(()=>{fetch("/api/teams",{credentials:"include"}).then(w=>w.json()).then(w=>h(w.teams??[])).catch(()=>{})},[]);const x=async()=>{if(l.trim()){y(!0);try{await r(e.id,l.trim(),d||void 0)}finally{y(!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:T0(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=>c(w.target.value),className:"input-field",autoFocus:!0})]}),f.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")}),f.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:x,disabled:!l.trim()||g,className:"btn-primary",children:o(g?"hireModal.creating_progress":"hireModal.create")})]})]})})}function ih(e,t){const n=e.i18n?.[t];return n?.displayName||n?.name||e.name}function $4(e,t){return e.i18n?.[t]?.description||e.description}function H4(e,t,n){return e.i18n?.[n]?.members?.[t]||t}function GW(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,c=r[o]??0;if(l>c)return!0;if(l<c)return!1}return!1}function VW({highlightItemId:e,onHighlightDone:t}={}){const{t:n,i18n:r}=ft(["store","common"]),o=r.language,[l,c]=k.useState(""),[d,m]=k.useState([]),[f,h]=k.useState([]),[g,y]=k.useState(null),[x,w]=k.useState({}),[C,T]=k.useState(!0),[S,E]=k.useState(!1),[j,L]=k.useState(null),[I,O]=k.useState(new Map),[F,V]=k.useState(new Set),[X,z]=k.useState(null),G=k.useCallback(async()=>{try{const[q,re]=await Promise.all([Ee.builder.artifacts.list().catch(()=>({artifacts:[]})),Ee.builder.artifacts.installed().catch(()=>({installed:{}}))]),B=new Map;for(const J of q.artifacts){if(J.type!=="team")continue;const fe=!!re.installed[`team/${J.name}`];B.set(J.name,{installed:fe,localVersion:J.meta.version||void 0,localUpdatedAt:J.updatedAt})}O(B)}catch{}},[]),se=k.useCallback(async()=>{T(!0);try{const q=l?lt.search({type:"team",q:l,limit:50}):Si(Tr.hubTeams)??lt.search({type:"team",limit:50}),[re,B]=await Promise.all([q.catch(()=>({items:[],total:0})),Ee.teamTemplates.list(l||void 0).catch(()=>({templates:[]})),G(),lt.isAuthenticated()?lt.purchases.mine().then(fe=>V(new Set(fe.purchases.map(Se=>Se.itemId)))).catch(()=>{}):Promise.resolve()]),J=await d6(re?.items??[],e);h(J.items),m(B?.templates??[]),J.missing&&t?.()}catch{m([]),h([])}finally{T(!1)}},[l,G,e,t]);k.useEffect(()=>{se()},[se]),k.useEffect(()=>{if(!g){w({});return}fetch(`/api/team-templates/${encodeURIComponent(g.id)}/files`,{credentials:"include"}).then(q=>q.json()).then(q=>w(q.files??{})).catch(()=>w({}))},[g]);const ee=async q=>{E(!0),L(null);try{const B=(await Ee.teams.create(q.name,q.description)).team.id;let J,fe=0;const Se=[];for(const W of q.members){const pe=W.count??1;for(let P=0;P<pe;P++){const _e=W.name??`${q.name} Agent ${P+1}`,He=pe>1?`${_e} ${P+1}`:_e,Pe=W.roleName??W.templateId;try{const Ge=await fetch("/api/agents",{method:"POST",headers:{"Content-Type":"application/json"},credentials:"include",body:JSON.stringify({name:He,...Pe?{roleName:Pe}:{},orgId:"default",teamId:B,agentRole:W.role??"worker",skills:W.skills??[]})});if(Ge.ok){fe++;const ct=await Ge.json();W.role==="manager"&&!J&&(J=ct.agent?.id)}else{const ct=await Ge.json().catch(()=>({error:`HTTP ${Ge.status}`}));Se.push(`${He}: ${ct.error??Ge.statusText}`)}}catch(Ge){Se.push(`${He}: ${String(Ge)}`)}}}J&&await Ee.teams.update(B,{managerId:J,managerType:"agent"}).catch(()=>{});const U=Se.length>0?` (${Se.length} failed: ${Se[0]})`:"";L({ok:fe>0,message:`Team "${ih(q,o)}" deployed with ${fe} agent(s)${U}`})}catch(re){L({ok:!1,message:`Failed: ${re}`})}finally{E(!1)}};if(X)return s.jsx(Mi,{type:X.type,name:X.name,onBack:()=>z(null)});if(g){const q={...x};g.announcements&&(q["ANNOUNCEMENT.md"]=g.announcements),g.norms&&(q["NORMS.md"]=g.norms);const re={type:"team",name:g.id,displayName:ih(g,o),version:g.version,description:$4(g,o),author:g.author,category:g.category??"general",tags:g.tags??[],files:q,team:{members:g.members.map(J=>({name:H4(g,J.name??J.roleName??J.templateId??"Agent",o),role:J.role??"worker",roleName:J.roleName??J.templateId,count:J.count??1,skills:J.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((J,fe)=>{const Se=H4(g,J.name??J.roleName??J.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 ${J.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:(Se[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:Se}),s.jsx("span",{className:`px-1.5 py-0.5 rounded text-[10px] capitalize font-medium ${J.role==="manager"?"bg-amber-500/15 text-amber-400":"bg-blue-500/15 text-blue-400"}`,children:J.role??"worker"}),(J.count??1)>1&&s.jsxs("span",{className:"text-[10px] text-fg-muted",children:["×",J.count]})]}),(J.roleName||J.templateId)&&s.jsx("div",{className:"text-[10px] text-fg-tertiary font-mono mt-0.5",children:J.roleName??J.templateId})]}),J.skills&&J.skills.length>0&&s.jsxs("div",{className:"flex flex-wrap gap-1 shrink-0",children:[J.skills.slice(0,3).map(U=>s.jsx("span",{className:"px-1.5 py-0.5 text-[9px] bg-surface-elevated text-fg-muted rounded border border-border-default",children:U},U)),J.skills.length>3&&s.jsxs("span",{className:"text-[9px] text-fg-muted",children:["+",J.skills.length-3]})]})]},fe)})})]});return s.jsx(s.Fragment,{children:s.jsx(Mi,{type:"team",name:g.id,onBack:()=>{y(null),L(null)},readOnly:!0,initialManifest:re,contentSlot:B,actionSlot:s.jsxs(s.Fragment,{children:[j&&s.jsx("span",{className:`text-xs ${j.ok?"text-green-500":"text-red-500"}`,children:j.message}),s.jsx("button",{onClick:()=>{ee(g)},disabled:S,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(S?"teamStore.deploying":"teamStore.deployTeam")})]})})})}return s.jsxs("div",{className:"flex-1 overflow-hidden flex flex-col",children:[s.jsxs("div",{"data-electron-drag":!0,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:q=>c(q.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:C?s.jsx("div",{className:"grid grid-cols-1 lg:grid-cols-2 gap-4",children:Array.from({length:4}).map((q,re)=>s.jsx("div",{className:"h-56 rounded-2xl skeleton"},re))}):d.length===0&&f.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(Ar,{columns:2,children:d.map(q=>s.jsx(ia,{type:"team",name:ih(q,o),description:$4(q,o),seed:q.id,icon:q.icon||"users",version:q.version,category:q.category,tags:q.tags,authorLabel:q.author,hideStats:!0,showTypeBadge:!1,cornerLabel:n("teamStore.builtin"),onClick:()=>y(q)},q.id))})]}),f.length>0&&s.jsxs("section",{children:[s.jsx("h3",{className:"section-title mb-3",children:n("teamStore.markusHub")}),s.jsx(Ar,{columns:2,children:f.map(q=>s.jsx(KW,{item:q,localInfo:I.get(Oc(q)),purchased:e0(q,F),onStatusChange:G,highlight:q.id===e,onHighlightDone:t,onViewDetail:re=>z({type:"team",name:re})},q.id))})]})]})})]})}function KW({item:e,localInfo:t,purchased:n,onStatusChange:r,highlight:o,onHighlightDone:l,onViewDetail:c}){const{t:d}=ft(["store"]),[m,f]=k.useState(!1),[h,g]=k.useState(""),y=k.useRef(null),[x,w]=k.useState(!1);k.useEffect(()=>{if(o&&y.current){y.current.scrollIntoView({behavior:"smooth",block:"center"}),w(!0);const V=setTimeout(()=>{w(!1)},4e3);return()=>clearTimeout(V)}},[o,l]);const C=t?.installed??!1,T=C&&e.version&&t?.localVersion&&GW(e.version,t.localVersion),S=(e.priceCents??0)>0,E=S?`$${((e.priceCents??0)/100).toFixed(2)}`:null,j=async V=>{if(V.stopPropagation(),!m){f(!0),g("");try{await Ni(e),g(T?d("card.upgraded"):d("card.installed")+"!"),r()}catch(X){const z=X instanceof Error?X.message:"";z.includes("402")||z.includes("Purchase required")?g(d("card.purchaseRequired")):g(d("card.failed"))}finally{f(!1)}}},L=async V=>{if(V.stopPropagation(),!m){f(!0),g("");try{await Qg(e,z=>{z==="checkout_opened"?g(d("card.waitingPurchase","Waiting for purchase...")):z==="installing"&&g(d("card.installing"))})==="installed"?(g(d("card.installed")+"!"),r()):g("")}catch(X){g(X instanceof Error?X.message:d("card.failed"))}finally{f(!1)}}},I=e.slug&&e.author?.username?`${lt.getUrl()}/@${encodeURIComponent(e.author.username)}/${encodeURIComponent(e.slug)}`:null,O=()=>{C&&c?c(Oc(e)):I&&window.open(I,"_blank","noopener,noreferrer")},F=s.jsxs(s.Fragment,{children:[T?s.jsx("button",{onClick:V=>{j(V)},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})}):C?s.jsxs("button",{onClick:V=>{j(V)},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}`:""]}):S&&!n?s.jsx("button",{onClick:V=>{L(V)},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?h||d("card.installing"):s.jsxs(s.Fragment,{children:[d("card.buy","Buy")," ",E]})}):s.jsx("button",{onClick:V=>{j(V)},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")}),h&&s.jsx("span",{className:`text-[10px] ${h===d("card.failed")||h===d("card.purchaseRequired")?"text-red-500":"text-green-600"}`,children:h})]});return s.jsx("div",{ref:y,className:x?"animate-pulse":"",children:s.jsx(ia,{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:C,glowing:x,onClick:O,actions:F})})}function oh(e,t){return e.i18n?.[t]?.displayName||e.name}function lh(e,t){return e.i18n?.[t]?.description||e.description||""}function m6(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,c=r[o]??0;if(l>c)return!0;if(l<c)return!1}return!1}const WW={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 YW({item:e,installedSkills:t,purchased:n,onMsg:r,onRefresh:o}){const{t:l}=ft(["store"]),[c,d]=k.useState(!1),m=e.name.toLowerCase().trim().replace(/\s+/g,"-").replace(/[\/\\:*?"<>|]+/g,"").replace(/-{2,}/g,"-").replace(/^-|-$/g,"")||"unnamed",f=t.find(S=>S.name===e.name||S.name===m||!!e.slug&&S.name===e.slug),h=!!f,g=h&&e.version&&f?.version&&m6(e.version,f.version),y=(e.priceCents??0)>0,[x,w]=k.useState(""),C=async()=>{if(!c){d(!0),w("");try{await Ni(e),r(g?`Upgraded ${e.name}`:`Installed ${e.name}`,"success"),o()}catch(S){const E=S instanceof Error?S.message:"";E.includes("402")||E.includes("Purchase required")?r(l("card.purchaseRequired"),"error"):r(l("card.failed"),"error")}finally{d(!1)}}},T=async()=>{if(!c){d(!0),w("");try{await Qg(e,E=>{E==="checkout_opened"?w(l("card.waitingPurchase","Waiting for purchase...")):E==="installing"&&w(l("card.installing"))})==="installed"&&(r(`Purchased & installed ${e.name}`,"success"),o()),w("")}catch(S){r(S instanceof Error?S.message:l("card.failed"),"error"),w("")}finally{d(!1)}}};if(g)return s.jsx("button",{onClick:()=>{C()},disabled:c,className:"px-2.5 py-1 text-[10px] bg-amber-600 hover:bg-amber-500 text-white rounded-lg disabled:opacity-50",children:c?l("card.upgrading"):l("card.upgrade",{version:e.version})});if(h)return s.jsxs("span",{className:"px-2.5 py-1 text-[10px] bg-surface-overlay text-fg-secondary rounded-lg",children:[l("card.installed"),f?.version?` (v${f.version})`:""]});if(y&&!n){const S=`$${((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:c,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:c?x||l("card.installing"):s.jsxs(s.Fragment,{children:[l("card.buy","Buy")," ",S]})})})}return s.jsx("button",{onClick:()=>{C()},disabled:c,className:"px-2.5 py-1 text-[10px] bg-brand-600 hover:bg-brand-500 text-white rounded-lg disabled:opacity-50",children:l(c?"card.installing":"card.install")})}function U4({item:e,installedSkills:t,purchased:n,onMsg:r,onRefresh:o,highlight:l,onHighlightDone:c,type:d="skill"}){const m=k.useRef(null),[f,h]=k.useState(!1);k.useEffect(()=>{if(l&&m.current){m.current.scrollIntoView({behavior:"smooth",block:"center"}),h(!0);const x=setTimeout(()=>{h(!1)},4e3);return()=>clearTimeout(x)}},[l,c]);const g=e.slug&&e.author?.username?`${lt.getUrl()}/@${encodeURIComponent(e.author.username)}/${encodeURIComponent(e.slug)}`:null,y=()=>{g&&window.open(g,"_blank","noopener,noreferrer")};return s.jsx("div",{ref:m,className:f?"animate-pulse":"",children:s.jsx(ia,{type:d,showTypeBadge:d!=="skill",name:e.name,description:e.description,seed:e.slug||e.name,icon:e.icon||Vd(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:y,actions:s.jsx(YW,{item:e,installedSkills:t,purchased:n,onMsg:r,onRefresh:o})})})}function XW({highlightItemId:e,onHighlightDone:t}={}){const{t:n,i18n:r}=ft(["store","common"]),o=r.language,l=Uo(),[c,d]=k.useState("skills"),[m,f]=k.useState(null),[h,g]=k.useState(new Set),[y,x]=k.useState([]),[w,C]=k.useState(null),[T,S]=k.useState([]),[E,j]=k.useState(0),[L,I]=k.useState(1),[O,F]=k.useState([]),[V,X]=k.useState(""),[z,G]=k.useState("score"),[se,ee]=k.useState(""),[q,re]=k.useState(!1),[B,J]=k.useState([]),[fe,Se]=k.useState(!1),[U,W]=k.useState([]),[pe,P]=k.useState(""),[_e,He]=k.useState(!1),[Pe,Ge]=k.useState([]),[ct,mt]=k.useState([]),[Ct,Mt]=k.useState(new Set),[Pt,Kt]=k.useState(!1),[yt,Ue]=k.useState(""),dt=[{id:"skills",labelKey:"skillStore.tabs.all"},{id:"skillhub",labelKey:"skillStore.tabs.skillhub"},{id:"skillssh",labelKey:"skillStore.tabs.skillssh"}],Nt=(H,te="success")=>{f({text:H,type:te}),setTimeout(()=>f(null),te==="error"?1e4:4e3)},bt=k.useCallback(async()=>{try{const H=await Ee.skills.list();x(H.skills)}catch{}},[]),Lt=k.useCallback(async()=>{Se(!0);try{const H=await Ee.skills.builtin();J(H.skills)}catch{}Se(!1)},[]),ue=k.useCallback(async H=>{re(!0);try{const te=await Ee.skills.registrySkillhub({q:H?.q,category:H?.category,page:H?.page??1,limit:24,sort:H?.sort??z});S(te.skills),j(te.total),te.categories?.length&&F(te.categories)}catch{}re(!1)},[z]),tt=k.useCallback(async H=>{He(!0);try{const te=await Ee.skills.registrySkillssh(H);W(te.skills)}catch{}He(!1)},[]),st=k.useCallback(async H=>{Kt(!0);try{const te=H?lt.search({type:"skill",q:H,limit:50}):Si(Tr.hubSkills)??lt.search({type:"skill",limit:50}),Ne=lt.search({subtype:"connector",q:H||void 0,limit:50}).catch(()=>({items:[]})),[Re,$e]=await Promise.all([te,Ne,lt.isAuthenticated()?lt.purchases.mine().then(be=>Mt(new Set(be.purchases.map(Ke=>Ke.itemId)))).catch(()=>{}):Promise.resolve()]);let Q=Re?.items??[],Z=$e?.items??[];if(e){const be=Q.some(Ie=>Ie.id===e),Ke=Z.some(Ie=>Ie.id===e);if(!be&&!Ke)try{const{item:Ie}=await lt.getItem(e);Ie?.subtype==="connector"?Z=[Ie,...Z]:Ie?Q=[Ie,...Q]:t?.()}catch{t?.()}else be&&(Q=[Q.find(Ye=>Ye.id===e),...Q.filter(Ye=>Ye.id!==e)]),Ke&&(Z=[Z.find(Ye=>Ye.id===e),...Z.filter(Ye=>Ye.id!==e)])}Ge(Q),mt(Z)}catch{}Kt(!1)},[e,t]);k.useEffect(()=>{bt(),Lt(),ue(),tt()},[]),k.useEffect(()=>{c==="skills"&&st(yt)},[c,yt,st]);const ye=async H=>{g(te=>new Set(te).add(H.name));try{const te=await Ee.skills.install({name:H.name,source:"skillhub",slug:H.slug,sourceUrl:H.homepage,description:H.description_zh??H.description,category:"custom",version:H.version});await bt(),Nt(`"${H.name}" installed (${te.method}) → ${te.path}`),window.dispatchEvent(new CustomEvent("markus:data-changed"))}catch{Nt(`Download failed for "${H.name}". You can try manually from: ${H.homepage}`,"error")}g(te=>{const Ne=new Set(te);return Ne.delete(H.name),Ne})},je=async H=>{g(te=>new Set(te).add(H.name));try{const te=await Ee.skills.install({name:H.name,source:"skillssh",sourceUrl:H.url,githubRepo:`${H.author}/${H.repo}`,githubSkillPath:H.name});await bt(),Nt(`"${H.name}" installed (${te.method}) → ${te.path}`),window.dispatchEvent(new CustomEvent("markus:data-changed"))}catch{Nt(`Download failed for "${H.name}". You can try manually from: ${H.url}`,"error")}g(te=>{const Ne=new Set(te);return Ne.delete(H.name),Ne})},Ae=async H=>{g(te=>new Set(te).add(H.name));try{const te=await Ee.skills.install({name:H.name,source:"builtin"});await bt(),await Lt(),Nt(`"${H.name}" installed (${te.method}) → ${te.path}`),window.dispatchEvent(new CustomEvent("markus:data-changed"))}catch(te){Nt(`Install failed for "${H.name}": ${te}`,"error")}g(te=>{const Ne=new Set(te);return Ne.delete(H.name),Ne})},oe=U.filter(H=>{if(!pe)return!0;const te=pe.toLowerCase();return H.name.toLowerCase().includes(te)||H.repo.toLowerCase().includes(te)});if(w){const H=w,te={};H.instructions&&(te["SKILL.md"]=H.instructions);const Ne={type:"skill",name:H.name,displayName:oh(H,o),version:H.version,description:lh(H,o),author:H.author??"",category:H.category??"general",tags:H.tags,files:te,skill:{skillFile:H.instructions?"SKILL.md":"",requiredPermissions:H.requiredPermissions,mcpServers:void 0,alwaysOn:!1}},Re=H.installed&&H.installedVersion&&m6(H.version,H.installedVersion)?s.jsx("button",{onClick:()=>{Ae(H)},disabled:h.has(H.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:h.has(H.name)?n("card.upgrading"):n("card.upgrade",{version:H.version})}):H.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"),H.installedVersion?` v${H.installedVersion}`:""]}):s.jsx("button",{onClick:()=>{Ae(H)},disabled:h.has(H.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:h.has(H.name)?n("card.installing"):n("card.install")}),$e=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:[H.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 ${WW[H.category]??"bg-gray-500/15 text-fg-secondary"}`,children:H.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:H.version})]}),H.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"})]}),H.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:"✓"})]})]})]}),(H.requiredPermissions.length>0||H.tags.length>0)&&s.jsxs("div",{className:"space-y-4",children:[H.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:H.requiredPermissions.map(Q=>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:Q},Q))})]}),H.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:H.tags.map(Q=>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:Q},Q))})]})]})]});return s.jsxs(s.Fragment,{children:[s.jsx(Mi,{type:"skill",name:H.name,onBack:()=>C(null),readOnly:!0,initialManifest:Ne,actionSlot:Re,contentSlot:$e}),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",{"data-electron-drag":!0,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:dt.map(H=>s.jsx("button",{onClick:()=>d(H.id),className:`px-3 py-1.5 text-xs rounded-lg transition-colors shrink-0 ${c===H.id?"bg-brand-600 text-white":"text-fg-secondary hover:text-fg-primary hover:bg-surface-elevated"}`,children:n(H.labelKey)},H.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}),c==="skills"&&(()=>{const H=yt.trim().toLowerCase(),te=H?B.filter($e=>oh($e,o).toLowerCase().includes(H)||lh($e,o).toLowerCase().includes(H)):B,Ne=fe&&Pt,Re=te.length===0&&Pe.length===0&&ct.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:yt,onChange:$e=>Ue($e.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"}`})}),Ne&&Re?s.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-4",children:Array.from({length:6}).map(($e,Q)=>s.jsx("div",{className:"h-56 rounded-2xl skeleton"},Q))}):Re?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:[te.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:te.length})})]}),s.jsx(Ar,{columns:3,children:te.map($e=>s.jsx(ia,{type:"skill",name:oh($e,o),description:lh($e,o),seed:$e.name,icon:Vd($e.name,$e.category),version:$e.version,category:$e.category,tags:$e.tags,authorLabel:$e.author||void 0,installed:$e.installed,hideStats:!0,showTypeBadge:!1,cornerLabel:$e.installed?void 0:n("skillStore.tabs.builtin"),onClick:()=>C($e)},$e.name))})]}),Pe.length>0&&s.jsxs("section",{children:[s.jsx("h3",{className:"section-title mb-3",children:n("skillStore.tabs.markusHub")}),s.jsx(Ar,{columns:3,children:Pe.map($e=>s.jsx(U4,{item:$e,installedSkills:y,purchased:e0($e,Ct),onMsg:Nt,onRefresh:()=>{bt(),st(yt)},highlight:$e.id===e,onHighlightDone:t},$e.id))})]}),ct.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(Ar,{columns:3,children:ct.map($e=>s.jsx(U4,{item:$e,type:"connector",installedSkills:y,purchased:e0($e,Ct),onMsg:Nt,onRefresh:()=>{bt(),st(yt)},highlight:$e.id===e,onHighlightDone:t},$e.id))})]})]})]})})(),c==="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:V,onChange:H=>{X(H.target.value),I(1),ue({q:se||void 0,category:H.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")}),O.map(H=>s.jsx("option",{value:H,children:H},H))]}),s.jsxs("select",{value:z,onChange:H=>{G(H.target.value),I(1),ue({q:se||void 0,category:V||void 0,page:1,sort:H.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:se,onChange:H=>ee(H.target.value),onKeyDown:H=>{H.key==="Enter"&&(I(1),ue({q:se||void 0,category:V||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:()=>{I(1),ue({q:se||void 0,category:V||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"})]}),q?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:E.toLocaleString()})}),s.jsx(Ar,{columns:3,children:T.map(H=>{const te=y.some(Ne=>Ne.name===H.name||Ne.name===H.slug);return s.jsx(ia,{type:"skill",name:H.name,description:H.description_zh??H.description??"",seed:H.slug,icon:Vd(H.slug||H.name,H.tags?.[0]),version:H.version,authorLabel:"SkillHub",showTypeBadge:!1,tags:H.tags,installed:te,hideStats:!0,onClick:()=>window.open(H.homepage,"_blank","noopener,noreferrer"),footerLeft:s.jsxs("span",{className:"flex items-center gap-2 text-[10px] text-fg-tertiary",children:[H.stars>0&&s.jsxs("span",{className:"text-amber-600",children:["★ ",H.stars.toLocaleString()]}),H.downloads>0&&s.jsxs("span",{children:[H.downloads>=1e4?`${(H.downloads/1e4).toFixed(1)}万`:H.downloads.toLocaleString()," ",n("skillStore.downloads")]})]}),actions:te?void 0:s.jsx("button",{onClick:()=>{ye(H)},disabled:h.has(H.name),className:"px-2.5 py-1 text-[10px] bg-brand-600 hover:bg-brand-500 text-white rounded-lg disabled:opacity-50",children:h.has(H.name)?"...":n("card.install")})},H.slug)})}),E>24&&s.jsxs("div",{className:"flex items-center justify-center gap-2 mt-6",children:[s.jsx("button",{disabled:L<=1,onClick:()=>{const H=L-1;I(H),ue({q:se||void 0,category:V||void 0,page:H})},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:L,total:Math.ceil(E/24)})}),s.jsx("button",{disabled:L>=Math.ceil(E/24),onClick:()=>{const H=L+1;I(H),ue({q:se||void 0,category:V||void 0,page:H})},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")})]})]})]}),c==="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:pe,onChange:H=>P(H.target.value),onKeyDown:H=>{H.key==="Enter"&&pe.trim()&&tt(pe)},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:()=>{pe.trim()&&tt(pe)},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")})})]}),_e?s.jsx("div",{className:"text-center text-fg-tertiary py-20",children:s.jsx("div",{className:"animate-pulse",children:n("skillStore.loadingSkillssh")})}):oe.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(Ar,{columns:3,children:oe.map(H=>{const te=y.some(Ne=>Ne.name===H.name);return s.jsx(ia,{type:"skill",name:H.name,description:H.description||"",seed:`${H.author}-${H.name}`,icon:Vd(H.name),authorLabel:`${H.author}/${H.repo}`,showTypeBadge:!1,installed:te,hideStats:!0,cornerLabel:te?void 0:"skills.sh",onClick:()=>window.open(H.url,"_blank","noopener,noreferrer"),footerLeft:H.installs?s.jsxs("span",{className:"text-[10px] text-fg-tertiary",children:[H.installs," installs"]}):void 0,actions:te?void 0:s.jsx("button",{onClick:()=>{je(H)},disabled:h.has(H.name),className:"px-2.5 py-1 text-[10px] bg-brand-600 hover:bg-brand-500 text-white rounded-lg disabled:opacity-50",children:h.has(H.name)?"...":n("card.install")})},`${H.author}-${H.name}`)})})]})]})}const QW=["agent","team","skill","connector"];function ch({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 ZW({item:e,onOpen:t}){const n=Xo(e.subtype==="connector"?"connector":e.itemType),r=Xg(n,e.slug||e.name),o=Ei[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(C0,{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:["↓ ",Mo(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 F4({items:e,onOpen:t}){return s.jsx(Ar,{columns:3,children:e.map(n=>s.jsx(ia,{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 q4(){return s.jsx(Ar,{columns:3,children:Array.from({length:6}).map((e,t)=>s.jsx("div",{className:"h-64 rounded-2xl skeleton"},t))})}function JW({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 y=await lt.search({limit:60,sort:"popular"});g||r(y.items??[])}catch{g||r([])}finally{g||l(!1)}})(),()=>{g=!0}},[]);const c=k.useMemo(()=>{const g=n.filter(x=>x.featured);return(g.length>0?g:n).slice(0,3)},[n]),d=k.useMemo(()=>[...n].sort((g,y)=>(y.trendingScore??y.downloadCount)-(g.trendingScore??g.downloadCount)).slice(0,10),[n]),m=k.useMemo(()=>[...n].sort((g,y)=>(y.createdAt||"").localeCompare(g.createdAt||"")).slice(0,10),[n]),f=k.useMemo(()=>{const g=new Map;for(const y of n){const x=y.author?.username||y.author?.id;if(!x)continue;const w=g.get(x)??{author:y.author,downloads:0,count:0};w.downloads+=y.downloadCount||0,w.count+=1,g.set(x,w)}return[...g.values()].sort((y,x)=>x.downloads-y.downloads).slice(0,6)},[n]),h=g=>e(Xo(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:QW.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 ${Ei[g].gradient} hover:opacity-90 transition-opacity`,children:[Ei[g].labelZh,s.jsx("span",{className:"opacity-70",children:Ei[g].label})]},g))})]}),o?s.jsx("div",{className:"h-52 rounded-2xl skeleton"}):c.length>0?s.jsx("div",{className:"grid grid-cols-1 lg:grid-cols-3 gap-4",children:c.map(g=>s.jsx(ZW,{item:g,onOpen:()=>h(g)},g.id))}):null,s.jsxs("section",{children:[s.jsx(ch,{title:t("discover.trending","热门趋势"),subtitle:t("discover.trendingSub","社区中下载与评分增长最快的资产")}),o?s.jsx(q4,{}):d.length>0?s.jsx(F4,{items:d,onOpen:h}):s.jsx(eY,{})]}),s.jsxs("section",{children:[s.jsx(ch,{title:t("discover.fresh","新鲜上架"),subtitle:t("discover.freshSub","来自创作者的最新作品")}),o?s.jsx(q4,{}):m.length>0?s.jsx(F4,{items:m,onOpen:h}):null]}),f.length>0&&s.jsxs("section",{children:[s.jsx(ch,{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:f.map((g,y)=>s.jsxs("div",{className:"asset-card p-4 flex flex-col items-center text-center",children:[s.jsxs("div",{className:"relative",children:[s.jsx(C0,{name:g.author?.displayName,username:g.author?.username,avatarUrl:g.author?.avatarUrl,hubBase:lt.getUrl(),size:48,verified:y<3}),y<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:y+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," 作品 · ↓ ",Mo(g.downloads)]})]},g.author?.username||y))})]})]})}function eY(){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 Od(e,t,n){return e.i18n?.[n]?.[t]}function tY(){const{t:e,i18n:t}=ft(["store","common"]),n=Uo(),r=t.language,[o,l]=k.useState([]),[c,d]=k.useState({}),[m,f]=k.useState(new Set),[h,g]=k.useState(null),[y,x]=k.useState(!0),[w,C]=k.useState(""),[T,S]=k.useState("all"),[E,j]=k.useState(null),L=k.useCallback(async()=>{x(!0);try{const[F,V,X,z]=await Promise.all([Ee.builder.artifacts.list().catch(()=>({artifacts:[]})),Ee.builder.artifacts.installed().catch(()=>({installed:{}})),Ee.skills.updates().catch(()=>({updates:[],count:0})),Ee.skills.builtin().catch(()=>({skills:[]}))]),G={};for(const q of X.updates)G[q.name]={availableVersion:q.availableVersion,installedVersion:q.installedVersion,displayName:q.displayName,description:q.description};d(G);const se=F.artifacts.filter(q=>{const re=`${q.type}/${q.name}`;return!!V.installed[re]}),ee=new Set(se.filter(q=>q.type==="skill").map(q=>q.name));for(const q of z.skills)!q.installed||ee.has(q.name)||!(V.installed[`skill/${q.name}`]||G[q.name])&&!q.updateAvailable||!V.installed[`skill/${q.name}`]&&!G[q.name]||(se.push({type:"skill",name:q.name,meta:{displayName:q.i18n?.[r]?.displayName||q.name,description:q.i18n?.[r]?.description||q.description||"",version:q.installedVersion||q.version,author:q.author,category:q.category,tags:q.tags,i18n:q.i18n},path:"",updatedAt:""}),ee.add(q.name));for(const[q,re]of Object.entries(G))ee.has(q)||(se.push({type:"skill",name:q,meta:{displayName:re.displayName||q,description:re.description||"",version:re.installedVersion},path:"",updatedAt:""}),ee.add(q));l(se)}catch{}x(!1)},[r]);k.useEffect(()=>{L()},[L]),k.useEffect(()=>{const F=()=>{L()};return window.addEventListener("markus:data-changed",F),()=>window.removeEventListener("markus:data-changed",F)},[L]),k.useEffect(()=>{if(!h)return;const F=setTimeout(()=>g(null),3e3);return()=>clearTimeout(F)},[h]);const I=async(F,V)=>{if(!m.has(F)){f(X=>new Set(X).add(F));try{await Ee.skills.install({name:F,source:"builtin"});try{localStorage.removeItem("markus:template-updates-ack")}catch{}g({text:e("installedTab.updateSuccess",{name:F,version:V}),type:"success"}),window.dispatchEvent(new CustomEvent("markus:data-changed")),await L()}catch{g({text:e("installedTab.updateFailed",{name:F}),type:"error"})}f(X=>{const z=new Set(X);return z.delete(F),z})}},O=o.filter(F=>{if(T!=="all"&&F.type!==T)return!1;if(!w)return!0;const V=w.toLowerCase(),X=(Od(F.meta,"displayName",r)||F.meta.displayName||F.name).toLowerCase(),z=(Od(F.meta,"description",r)||F.meta.description||"").toLowerCase();return X.includes(V)||z.includes(V)}).sort((F,V)=>{const X=F.type==="skill"&&c[F.name]?1:0;return(V.type==="skill"&&c[V.name]?1:0)-X});return E?s.jsx(Mi,{type:E.type,name:E.name,onBack:()=>j(null)}):s.jsxs("div",{className:"flex-1 overflow-hidden flex flex-col",children:[s.jsxs("div",{"data-electron-drag":!0,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(c).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(c).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(F=>s.jsx("button",{onClick:()=>S(F),className:`px-3 py-1 text-xs rounded-md transition-colors ${T===F?"bg-brand-600 text-white":"text-fg-secondary hover:text-fg-primary hover:bg-surface-elevated"}`,children:e(`installedTab.filter${F==="all"?"All":F==="agent"?"Agents":F==="team"?"Teams":"Skills"}`)},F))}),s.jsx("div",{className:"flex-1 min-w-[120px]",children:s.jsx("input",{type:"text",placeholder:e("installedTab.searchPlaceholder"),value:w,onChange:F=>C(F.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:y?s.jsx("div",{className:"text-center text-fg-tertiary py-20 animate-pulse",children:e("installedTab.loading")}):O.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(Ar,{columns:3,children:O.map(F=>{const V=Od(F.meta,"displayName",r)||F.meta.displayName||F.name,X=Od(F.meta,"description",r)||F.meta.description||"",z=F.meta.version||"",G=F.meta.author||"",se=F.meta.tags??[],ee=F.meta.category||"",q=F.meta.icon,re=q&&/\.(png|jpe?g|gif|webp|svg)$/i.test(q)&&!q.startsWith("http")&&!q.startsWith("data:")&&!q.startsWith("/")?`/api/builder/artifacts/${F.type}s/${encodeURIComponent(F.name)}/${q}`:q,B=F.type==="skill"?c[F.name]:void 0;return s.jsx(ia,{type:F.type,name:V,description:X,seed:F.name,icon:re,author:null,authorLabel:G||void 0,version:B?B.installedVersion:z,category:ee,tags:se,installed:!B,hideStats:!0,cornerLabel:B?e("installedTab.updateAvailable"):void 0,onClick:()=>{F.path&&j({type:F.type,name:F.name})},actions:B?s.jsx("button",{type:"button",disabled:m.has(F.name),onClick:()=>{I(F.name,B.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(F.name)?e("installedTab.updating"):e("installedTab.updateTo",{version:B.availableVersion})}):void 0},`${F.type}/${F.name}`)})})}),h&&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 ${h.type==="success"?"bg-emerald-600 text-white":"bg-red-600 text-white"}`,children:h.text})]})}const nY=50,rY=30;function aY(e,t,n,r){const o=k.useRef(0),l=k.useRef(0),c=k.useCallback(m=>{o.current=m.touches[0].clientX,l.current=m.touches[0].clientY},[]),d=k.useCallback(m=>{const f=m.changedTouches[0].clientX-o.current,h=m.changedTouches[0].clientY-l.current,g=Math.abs(f),y=Math.abs(h);if(g<nY||Math.atan2(y,g)*(180/Math.PI)>rY)return;if(r?.scrollContainerRef?.current){const C=r.scrollContainerRef.current,T=C.scrollLeft<=1,S=C.scrollLeft+C.clientWidth>=C.scrollWidth-1;if(f>0&&!T||f<0&&!S)return}const w=e.findIndex(C=>C.id===t);f<0&&w<e.length-1?n(e[w+1].id):f>0&&w>0?n(e[w-1].id):f>0&&w===0&&r?.onSwipeOutLeft?r.onSwipeOutLeft():f<0&&w===e.length-1&&r?.onSwipeOutRight&&r.onSwipeOutRight()},[e,t,n,r]);return{onTouchStart:c,onTouchEnd:d}}const sY=["builder","discover","agents","teams","skills","installed"],iY={agent:"agents",team:"teams",skill:"skills",connector:"skills"};function sg(e){return!!e&&sY.includes(e)}function G4(){const e=localStorage.getItem("markus_nav_installItem"),t=localStorage.getItem("markus_nav_storeTab");return{tab:sg(t)?t:"builder",installId:e}}function oY({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(G4),[o,l]=k.useState(r.tab),[c,d]=k.useState(r.installId),m=aY(n,o,l);k.useEffect(()=>{const h=G4();h.installId&&(d(h.installId),sg(h.tab)&&l(h.tab),localStorage.removeItem("markus_nav_installItem"),localStorage.removeItem("markus_nav_storeTab"))},[]),k.useEffect(()=>{const h=g=>{const y=g.detail,x=y.params?.storeTab??localStorage.getItem("markus_nav_storeTab");sg(x)&&l(x);const w=y.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",h),()=>window.removeEventListener("markus:navigate",h)},[]);const f=(h,g)=>{g&&d(g),l(iY[h]??"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(Mw,{className:"ml-2"}),n.map(h=>s.jsx("button",{onClick:()=>l(h.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===h.id?"border-brand-500 text-brand-500":"border-transparent text-fg-tertiary"}`,children:h.label},h.id))]}),s.jsxs("div",{className:"flex-1 overflow-hidden flex flex-col",children:[o==="builder"&&s.jsx(c6,{authUser:e}),o==="discover"&&s.jsx(JW,{onOpenType:f}),o==="agents"&&s.jsx(FW,{authUser:e,highlightItemId:c,onHighlightDone:()=>d(null)}),o==="teams"&&s.jsx(VW,{highlightItemId:c,onHighlightDone:()=>d(null)}),o==="skills"&&s.jsx(XW,{highlightItemId:c,onHighlightDone:()=>d(null)}),o==="installed"&&s.jsx(tY,{})]})]})}const V4="usageType",uh="profile";function lY({onComplete:e,theme:t,onThemeChange:n,skipProfile:r,onProfileUpdated:o}){const{t:l}=ft(["onboarding","common"]),[c,d]=k.useState(0),[m,f]=k.useState(""),[h,g]=k.useState(""),[y,x]=k.useState(""),[w,C]=k.useState(""),[T,S]=k.useState(!1),[E,j]=k.useState(""),[L,I]=k.useState(!1),[O,F]=k.useState(null);k.useEffect(()=>{Ee.auth.me().then(({user:Ue})=>{Ue.name&&f(Ue.name),Ue.email&&g(Ue.email),Ue.avatarUrl&&F(Ue.avatarUrl);const dt=Ue.name||Ue.email?.split("@")[0]||"";dt&&G(Nt=>Nt||l("usageType.defaultOrgName",{name:dt}))}).catch(()=>{}),Ee.settings.getOrg().then(({org:Ue})=>{Ue?.name&&Ue.name!=="My Organization"&&G(Ue.name)}).catch(()=>{}),bn()&&Ee.hubOrgs.invitations().then(Ue=>{Ue.invitations?.length>0&&Se(Ue.invitations)}).catch(()=>{})},[]);const[V,X]=k.useState(null),[z,G]=k.useState(""),[se,ee]=k.useState(!1),[q,re]=k.useState(!1),[B,J]=k.useState(""),[fe,Se]=k.useState([]),[U,W]=k.useState(null),[pe,P]=k.useState(null),_e=async()=>{const Ue=z.trim();if(Ue){ee(!0),J("");try{if(await Ee.settings.updateOrg(Ue),bn()){const dt=await Ee.hubOrgs.mine(),Nt=dt.orgs?.find(bt=>bt.role==="owner")??dt.orgs?.[0];Nt?.id?await Ee.hubOrgs.update(Nt.id,{name:Ue}):await Ee.hubOrgs.create(Ue)}re(!0)}catch{J(l("usageType.orgNameSaveFailed"))}finally{ee(!1)}}},[He,Pe]=k.useState(!0),Ge=async()=>{if(j(""),!m.trim()){j(l("profile.errors.nameRequired"));return}if(!h.trim()){j(l("profile.errors.emailRequired"));return}if(!/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(h.trim())){j(l("profile.errors.emailInvalid"));return}if(y&&y.length<6){j(l("profile.errors.passwordTooShort"));return}if(y&&y!==w){j(l("profile.errors.passwordMismatch"));return}S(!0);try{const{user:Ue}=await Ee.auth.updateProfile(m.trim(),h.trim());y&&await Ee.auth.changePassword("",y),o?.(Ue),I(!0)}catch{j(l("profile.errors.saveFailed"))}finally{S(!1)}},ct=[{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(g8,{i18nKey:"welcome.description",ns:"onboarding",components:{strong:s.jsx("strong",{className:"text-fg-primary"})}})})},{id:V4,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:()=>{X("personal"),re(!0)},className:`flex flex-col items-center gap-3 rounded-xl border-2 p-5 transition-all text-left ${V==="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:()=>{X("organization"),re(!1)},className:`flex flex-col items-center gap-3 rounded-xl border-2 p-5 transition-all text-left ${V==="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."})})]})]})]}),V==="organization"&&s.jsxs("div",{className:"space-y-4 mt-4",children:[fe.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")}),fe.map(Ue=>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:Ue.orgName}),s.jsx("div",{className:"text-[11px] text-fg-tertiary",children:l("usageType.invitedBy",{name:Ue.invitedBy})})]}),s.jsx("button",{onClick:async()=>{W(Ue.orgId);try{await Ee.hubOrgs.acceptInvitation(Ue.orgId),P(Ue.orgId),re(!0)}catch{}finally{W(null)}},disabled:U===Ue.orgId||pe===Ue.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:pe===Ue.orgId?l("usageType.accepted"):U===Ue.orgId?l("usageType.accepting"):l("usageType.acceptAndJoin")})]},Ue.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:z,onChange:Ue=>{G(Ue.target.value),re(!1),J("")},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:()=>{_e()},disabled:se||!z.trim()||q,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(se?"common:saving":q?"usageType.orgNameSaved":"usageType.setOrgName")})]})]})},{id:uh,title:l("profile.title"),subtitle:l("profile.subtitle"),content:L?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," · ",h]})]})]}):s.jsxs("div",{className:"space-y-4",children:[s.jsx("div",{className:"flex justify-center",children:s.jsx(jw,{currentUrl:O,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:Ue=>f(Ue.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:h,onChange:Ue=>g(Ue.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:y,onChange:Ue=>x(Ue.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"})]}),y&&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:Ue=>C(Ue.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"})]}),E&&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:E}),s.jsx("button",{onClick:()=>{Ge()},disabled:T||!m.trim()||!h.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:ct.map(Ue=>s.jsxs("button",{onClick:()=>n(Ue.value),className:`flex flex-col items-center gap-2 rounded-xl border-2 p-5 transition-all ${t===Ue.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:Ue.icon}),s.jsx("span",{className:"text-sm font-medium text-fg-primary",children:Ue.label}),s.jsx("span",{className:"text-[11px] text-fg-tertiary leading-tight text-center",children:Ue.desc})]},Ue.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:He,onChange:Ue=>Pe(Ue.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(Ue=>Ue.id!==uh):mt,Mt=Ct.findIndex(Ue=>Ue.id===V4),Pt=Ct.findIndex(Ue=>Ue.id===uh),Kt=()=>{c===Mt&&Mt>=0&&!V||c===Mt&&V==="organization"&&!q||c===Pt&&Pt>=0&&!L||(c<Ct.length-1?d(c+1):(fetch("/api/settings/telemetry",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({enabled:He})}).catch(()=>{}),e()))},yt=Ct[c];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((Ue,dt)=>s.jsx("div",{className:`h-1 flex-1 rounded-full transition-colors ${dt<=c?"bg-brand-500":"bg-surface-elevated"}`},dt))}),s.jsx("h2",{className:"text-2xl font-bold text-fg-primary",children:yt.title}),s.jsx("p",{className:"text-sm text-fg-secondary mt-1 mb-6",children:yt.subtitle}),yt.content,s.jsxs("div",{className:"flex justify-between mt-8",children:[c>0?s.jsx("button",{onClick:()=>d(c-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:Kt,disabled:Pt>=0&&c===Pt&&!L||Mt>=0&&c===Mt&&(!V||V==="organization"&&!q),className:`px-6 py-2.5 text-white text-sm rounded-xl transition-colors ${Pt>=0&&c===Pt&&!L||Mt>=0&&c===Mt&&(!V||V==="organization"&&!q)?"bg-brand-600/40 cursor-not-allowed":"bg-brand-600 hover:bg-brand-500"}`,children:c===Ct.length-1?l("getStarted"):l("common:next")})]})]})})})}const K4="markus:legal-consent",cY="https://markus.global";function uY({onLogin:e,hasOwner:t}){const{t:n,i18n:r}=ft("auth"),[o,l]=k.useState(null),[c,d]=k.useState(""),[m,f]=k.useState(!1),[h,g]=k.useState(""),[y,x]=k.useState(""),[w,C]=k.useState(!1),[T,S]=k.useState(!1),E=G=>{const se=(r.language||"").toLowerCase().startsWith("zh")?"?lang=zh":"";return`${cY}${G}${se}`},j=()=>{try{localStorage.setItem(K4,JSON.stringify({acceptedAt:new Date().toISOString(),terms:!0,privacy:!0}))}catch{}},L=()=>T?(j(),!0):(C(!1),requestAnimationFrame(()=>C(!0)),!1),I=async()=>{const G=bn(),se=sa();if(!G||!se){d(n("login.hubUnavailable"));return}const ee=await Ee.auth.hubLogin(G,se);if(window.markusDesktop?.clearPendingDeepLinkAuth?.(),ee.cloudAiReady===!1)try{sessionStorage.setItem("markus:cloud-ai-warning",ee.cloudAiError?n("login.cloudAiNotReady",{error:ee.cloudAiError}):n("login.cloudAiNotReadyGeneric"))}catch{}e(ee.user,ee.needsOnboarding??!1,{fromHub:!0})},O=async(G,se=!1)=>{if(!(!se&&!L())){d(""),l(G??"hub");try{if(se&&bn()&&sa()){await I();return}await Hr(G),await I()}catch(ee){const q=ee instanceof Error?ee.message:"";if(!q.includes("cancelled")){if(!se&&bn())return O(G,!0);d(q||n("login.hubUnavailable"))}}finally{l(null)}}},F=()=>{iD(),l(null),d("")};k.useEffect(()=>{const G=window.markusDesktop;if(!G?.peekPendingDeepLinkAuth&&!G?.consumePendingDeepLinkAuth)return;let se=!1;return(async()=>{const ee=G.peekPendingDeepLinkAuth?await G.peekPendingDeepLinkAuth():null;if(se||!ee)return;let q=!1;try{q=!!localStorage.getItem(K4)}catch{}if(!T&&!q){d(n("login.consentRequired"));return}q&&!T&&S(!0),j();const re=G.consumePendingDeepLinkAuth?await G.consumePendingDeepLinkAuth():ee;if(!(se||!re)){d(""),l("hub");try{if(!await sD(re)||!bn()||!sa()){d(n("login.hubUnavailable"));return}await I()}catch{d(n("login.hubUnavailable"))}finally{se||l(null)}}})().catch(()=>{}),()=>{se=!0}},[T]);const V=async G=>{if(G.preventDefault(),!(!h.trim()||!y)&&L()){d(""),l("local");try{const{user:se,needsOnboarding:ee}=await Ee.auth.login(h.trim(),y);e(se,ee??!1)}catch{d(n("login.invalidCredentials"))}finally{l(null)}}},X=n(t?"login.welcomeBack":"login.getStarted"),z="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:X})]}),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:V,className:"space-y-3",children:[s.jsx("input",{type:"email",value:h,onChange:G=>g(G.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:y,onChange:G=>x(G.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}),c&&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:c}),!t&&s.jsx("p",{className:"text-[11px] text-fg-tertiary",children:n("login.defaultCredentials")}),s.jsx("button",{type:"submit",disabled:o==="local"||!h||!y,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:()=>{f(!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:()=>O("google"),disabled:!!o,className:z,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:()=>O("github"),disabled:!!o,className:z,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:()=>O("email"),disabled:!!o,className:z,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")]}),o&&(o==="google"||o==="github"||o==="email"||o==="hub")&&s.jsxs("div",{className:"px-3 py-2.5 bg-brand-500/10 border border-brand-500/30 rounded-lg text-xs text-fg-secondary space-y-2",children:[s.jsx("p",{children:n("login.browserOpened")}),s.jsx("button",{type:"button",onClick:F,className:"text-brand-500 hover:text-brand-400 underline font-medium",children:n("login.cancelWaiting")})]}),c&&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:c}),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:()=>{f(!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:()=>C(!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:G=>{S(G.target.checked),G.target.checked&&C(!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:E("/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:E("/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 dY({token:e,onComplete:t}){const{t:n}=ft("auth"),[r,o]=k.useState(null),[l,c]=k.useState(""),[d,m]=k.useState(""),[f,h]=k.useState(""),[g,y]=k.useState(!1),[x,w]=k.useState(!1),[C,T]=k.useState(!1);k.useEffect(()=>{Ee.auth.inviteInfo(e).then(E=>o(E)).catch(()=>T(!0))},[e]);const S=async E=>{if(E.preventDefault(),h(""),l.length<6){h(n("invite.passwordMinLength"));return}if(l!==d){h(n("invite.passwordsDoNotMatch"));return}y(!0);try{await Ee.auth.setup(e,l),w(!0),setTimeout(()=>{window.location.hash="",t()},2e3)}catch{h(n("invite.error"))}finally{y(!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:C?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")})]}):x?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:S,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:E=>c(E.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:E=>m(E.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})]}),f&&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:f}),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 mY({onComplete:e,isFirstTime:t}){const{t:n}=ft("auth"),[r,o]=k.useState(""),[l,c]=k.useState(""),[d,m]=k.useState(""),[f,h]=k.useState(""),[g,y]=k.useState(!1),x=async w=>{if(w.preventDefault(),h(""),l.length<6){h(n("changePassword.passwordMinLength"));return}if(l!==d){h(n("changePassword.passwordsDoNotMatch"));return}y(!0);try{await Ee.auth.changePassword(r,l),e()}catch{h(n("changePassword.failedToChange"))}finally{y(!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:x,className:"bg-surface-secondary/80 backdrop-blur-sm border border-border-default rounded-2xl p-8 space-y-5 shadow-2xl shadow-black/30",children:[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=>c(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})]}),f&&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:f}),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 fY({side:e,defaultWidth:t,minWidth:n,maxWidth:r,collapsedWidth:o=0,storageKey:l}){const[c,d]=k.useState(()=>{try{const C=localStorage.getItem(`${l}_w`);if(C)return Math.max(n,Math.min(r,parseInt(C,10)))}catch{}return t}),[m,f]=k.useState(()=>{try{return localStorage.getItem(`${l}_c`)==="1"}catch{return!1}}),h=k.useRef(!1),g=k.useRef(n),y=k.useRef(r);g.current=n,y.current=r,k.useEffect(()=>{try{localStorage.setItem(`${l}_w`,String(c))}catch{}},[c,l]),k.useEffect(()=>{try{localStorage.setItem(`${l}_c`,m?"1":"0")}catch{}},[m,l]),k.useEffect(()=>{d(C=>Math.max(n,Math.min(r,C)))},[n,r]);const x=k.useCallback(C=>{C.preventDefault(),h.current=!0;const T=C.clientX,S=c,E=L=>{if(!h.current)return;const I=L.clientX-T;d(Math.max(g.current,Math.min(y.current,S+I)))},j=()=>{h.current=!1,document.removeEventListener("mousemove",E),document.removeEventListener("mouseup",j),document.body.style.cursor="",document.body.style.userSelect=""};document.addEventListener("mousemove",E),document.addEventListener("mouseup",j),document.body.style.cursor="col-resize",document.body.style.userSelect="none"},[c,e]),w=k.useCallback(()=>f(C=>!C),[]);return{width:m?o:c,rawWidth:c,collapsed:m,toggle:w,setCollapsed:f,setWidth:d,onResizeStart:x}}const fX=[{value:"system",label:"System"},{value:"light",label:"Light"},{value:"dark",label:"Dark"},{value:"cyberpunk",label:"Cyberpunk"},{value:"mono",label:"Mono"}],ig="markus-theme";function W4(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 pY(){try{const e=localStorage.getItem(ig);if(e==="midnight")return localStorage.setItem(ig,"dark"),"dark";if(e==="light"||e==="dark"||e==="system"||e==="cyberpunk"||e==="mono")return e}catch{}return"system"}function hY(){const[e,t]=k.useState(pY),n=k.useCallback(r=>{t(r);try{localStorage.setItem(ig,r)}catch{}W4(r)},[]);return k.useEffect(()=>{W4(e)},[e]),{mode:e,setMode:n}}const Wd={agents:[],tasks:[],requirements:[],projects:[],deliverables:[],workflows:[]},gY={team:["agents","workflows","tasks","requirements","projects","deliverables"],work:["workflows","projects","requirements","tasks","agents","deliverables"],deliverables:["deliverables","agents","tasks","requirements","projects","workflows"]},bY=["agents","tasks","requirements","projects","deliverables","workflows"];let Y4="",X4="all",Q4=Wd,Z4=!1;function xY({onClose:e,currentPage:t}){const{t:n}=ft(["common","home","work"]);Ho(!0);const[r,o]=k.useState(Y4),[l,c]=k.useState(X4),[d,m]=k.useState(Q4),[f,h]=k.useState(!1),[g,y]=k.useState(Z4),[x,w]=k.useState(-1);k.useEffect(()=>{Y4=r},[r]),k.useEffect(()=>{X4=l},[l]),k.useEffect(()=>{Q4=d},[d]),k.useEffect(()=>{Z4=g},[g]);const C=k.useRef(null),T=k.useRef(void 0),S=k.useRef(null),E=k.useRef(null);k.useEffect(()=>{setTimeout(()=>{C.current?.focus(),C.current?.select()},100)},[]);const j=k.useCallback(async ee=>{if(!ee.trim()){m(Wd),y(!1),w(-1);return}h(!0),y(!0),w(-1);const q=ee.toLowerCase();try{const[re,B,J,fe,Se,U]=await Promise.allSettled([Ee.agents.list(),Ee.tasks.list({search:ee,pageSize:20}),Ee.requirements.list(),Ee.projects.list(),Ee.deliverables.search({q:ee,limit:20}),Ee.teams.list()]),W=re.status==="fulfilled"?re.value.agents.filter(Ge=>Ge.name?.toLowerCase().includes(q)||Ge.role?.toLowerCase().includes(q)):[],pe=B.status==="fulfilled"?B.value.tasks:[],P=J.status==="fulfilled"?J.value.requirements.filter(Ge=>Ge.title?.toLowerCase().includes(q)||Ge.description?.toLowerCase().includes(q)):[],_e=fe.status==="fulfilled"?fe.value.projects.filter(Ge=>Ge.name?.toLowerCase().includes(q)||Ge.description?.toLowerCase().includes(q)):[],He=Se.status==="fulfilled"?Se.value.results:[],Pe=[];if(U.status==="fulfilled"){const Ge=await Promise.allSettled(U.value.teams.map(ct=>Ee.workflows.list(ct.id)));for(const ct of Ge)if(ct.status==="fulfilled")for(const mt of ct.value.workflows)(mt.name.toLowerCase().includes(q)||(mt.displayName||"").toLowerCase().includes(q)||mt.description?.toLowerCase().includes(q))&&Pe.push(mt)}m({agents:W,tasks:pe,requirements:P,projects:_e,deliverables:He,workflows:Pe})}catch{m(Wd)}finally{h(!1)}},[]),L=ee=>{o(ee),T.current&&clearTimeout(T.current),T.current=setTimeout(()=>j(ee),400)},I=k.useCallback((ee,q)=>{e(),it.navigate(ee,q)},[e]),O=[{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:"工作流"})}],F=k.useMemo(()=>gY[t||""]||bY,[t]),V=k.useMemo(()=>{const ee=[],q=l==="all"?8:void 0,re=B=>{if(l!=="all"&&l!==B)return;const J=d[B].length;if(B==="workflows"){const fe=q?d.workflows.slice(0,q):d.workflows;for(const Se of fe)ee.push({id:Se.name,type:"workflow",page:de.WORK,params:{boardType:"workflows"}})}else{const fe=d[B],Se=q?fe.slice(0,q):fe;for(const U of Se)switch(B){case"agents":ee.push({id:U.id,type:"agent",page:de.TEAM,params:{agentId:U.id}});break;case"tasks":ee.push({id:U.id,type:"task",page:de.WORK,params:{openTask:U.id}});break;case"requirements":ee.push({id:U.id,type:"requirement",page:de.WORK,params:{openRequirement:U.id}});break;case"projects":ee.push({id:U.id,type:"project",page:de.WORK,params:{projectId:U.id}});break;case"deliverables":ee.push({id:U.id,type:"deliverable",page:de.DELIVERABLES,params:{openDeliverable:U.id}});break}}q&&J>q&&ee.push({id:`more_${B}`,type:"showMore",page:"",expandCategory:B,totalCount:J})};for(const B of F)re(B);return ee},[d,l,F]),X=k.useCallback(ee=>{if(ee.type==="showMore"&&ee.expandCategory){c(ee.expandCategory),w(-1);return}I(ee.page,ee.params)},[I]);k.useEffect(()=>{const ee=E.current;if(!ee||x<0)return;const q=ee.querySelector(`[data-idx="${x}"]`);q&&q.scrollIntoView({block:"nearest"})},[x]);const z=k.useCallback(ee=>{if(ee.key==="Escape"){e();return}if(ee.key==="Tab"){ee.preventDefault();const B=O.map(Se=>Se.id),J=B.indexOf(l),fe=ee.shiftKey?J<=0?B.length-1:J-1:J>=B.length-1?0:J+1;c(B[fe]),w(-1);return}const q=ee.ctrlKey&&ee.key==="n"||ee.key==="ArrowDown",re=ee.ctrlKey&&ee.key==="p"||ee.key==="ArrowUp";if(q||re){ee.preventDefault(),w(B=>{const J=V.length-1;return J<0?-1:q?B>=J?0:B+1:B<=0?J:B-1});return}ee.key==="Enter"&&(ee.preventDefault(),x>=0&&x<V.length&&X(V[x]))},[e,V,x,X,O,l]);k.useEffect(()=>(document.addEventListener("keydown",z),()=>document.removeEventListener("keydown",z)),[z]);const G=V.length>0;let se=0;return s.jsx("div",{ref:S,className:"fixed inset-0 bg-black/50 flex items-start justify-center z-50 pt-[8vh]",onClick:ee=>{ee.target===S.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:C,value:r,onChange:ee=>L(ee.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(Wd),y(!1),w(-1),C.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:O.map(ee=>s.jsx("button",{onClick:()=>{c(ee.id),w(-1)},className:`px-3 py-1.5 text-xs rounded-lg whitespace-nowrap transition-colors ${l===ee.id?"bg-brand-600 text-white":"bg-surface-elevated text-fg-secondary hover:text-fg-primary"}`,children:ee.label},ee.id))})]}),s.jsxs("div",{ref:E,className:"flex-1 overflow-y-auto px-5 py-3",children:[f&&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")})}),!f&&g&&!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:noResults",{defaultValue:"没有找到相关结果"})})]}),!f&&G&&s.jsx("div",{className:"space-y-4",children:F.map(ee=>{if(l!=="all"&&l!==ee)return null;const q=l==="all"?8:void 0,re=B=>{const J=se++,fe=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":J,onClick:()=>{c(B),w(-1)},className:`mt-1 w-full text-xs py-1.5 rounded-lg transition-colors ${J===x?"bg-brand-600/15 ring-1 ring-brand-500/40 text-brand-500":"text-brand-500 hover:text-brand-400 hover:bg-surface-overlay"}`,children:[n("common:showAll",{defaultValue:"查看全部"})," (",fe,")"]})};return ee==="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:(q?d.agents.slice(0,q):d.agents).map(B=>{const J=se++;return s.jsxs("button",{"data-idx":J,onClick:()=>I(de.TEAM,{agentId:B.id}),className:`w-full flex items-center gap-3 px-3 py-2 rounded-xl transition-colors text-left ${J===x?"bg-brand-600/15 ring-1 ring-brand-500/40":"hover:bg-surface-overlay"}`,children:[s.jsx(Hs,{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(yY,{status:B.status})]},B.id)})}),q&&d.agents.length>q&&re("agents")]},"agents"):ee==="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:(q?d.tasks.slice(0,q):d.tasks).map(B=>{const J=se++;return s.jsxs("button",{"data-idx":J,onClick:()=>I(de.WORK,{openTask:B.id}),className:`w-full flex items-center gap-3 px-3 py-2 rounded-xl transition-colors text-left ${J===x?"bg-brand-600/15 ring-1 ring-brand-500/40":"hover:bg-surface-overlay"}`,children:[s.jsx(vY,{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)})}),q&&d.tasks.length>q&&re("tasks")]},"tasks"):ee==="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:(q?d.requirements.slice(0,q):d.requirements).map(B=>{const J=se++;return s.jsxs("button",{"data-idx":J,onClick:()=>I(de.WORK,{openRequirement:B.id}),className:`w-full flex items-center gap-3 px-3 py-2 rounded-xl transition-colors text-left ${J===x?"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)})}),q&&d.requirements.length>q&&re("requirements")]},"requirements"):ee==="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:(q?d.projects.slice(0,q):d.projects).map(B=>{const J=se++;return s.jsxs("button",{"data-idx":J,onClick:()=>I(de.WORK,{projectId:B.id}),className:`w-full flex items-center gap-3 px-3 py-2 rounded-xl transition-colors text-left ${J===x?"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)})}),q&&d.projects.length>q&&re("projects")]},"projects"):ee==="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:(q?d.deliverables.slice(0,q):d.deliverables).map(B=>{const J=se++;return s.jsxs("button",{"data-idx":J,onClick:()=>I(de.DELIVERABLES,{openDeliverable:B.id}),className:`w-full flex items-center gap-3 px-3 py-2 rounded-xl transition-colors text-left ${J===x?"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)})}),q&&d.deliverables.length>q&&re("deliverables")]},"deliverables"):ee==="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:(q?d.workflows.slice(0,q):d.workflows).map(B=>{const J=se++;return s.jsxs("button",{"data-idx":J,onClick:()=>I(de.WORK,{boardType:"workflows"}),className:`w-full flex items-center gap-3 px-3 py-2 rounded-xl transition-colors text-left ${J===x?"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)})}),q&&d.workflows.length>q&&re("workflows")]},"workflows"):null})}),!f&&!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 yY({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 vY({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"})]})})}const wY=[{id:"toggle-left",group:"layout",keys:["B"],label:"Toggle left sidebar (L0 + page L1)",labelKey:"shortcuts.toggleLeft",page:"any"},{id:"help",group:"help",keys:["/"],label:"Show keyboard shortcuts",labelKey:"shortcuts.help",page:"any"},{id:"search",group:"search",keys:["P"],label:"Global search",labelKey:"shortcuts.search",page:"any"},{id:"nav-l0-jk",group:"navigation",keys:["J / K"],label:"L0: switch page up / down",labelKey:"shortcuts.navL0Jk",page:"any",bare:!0},{id:"nav-l0-l",group:"navigation",keys:["L"],label:"L0: enter page L1 (Team / Tasks / Output / Store / Settings)",labelKey:"shortcuts.navL0L",page:"any",bare:!0},{id:"nav-l0-h",group:"navigation",keys:["H"],label:"From page L1: focus app rail (L0)",labelKey:"shortcuts.navL0H",page:"any",bare:!0},{id:"settings-back",group:"navigation",keys:["H"],label:"Settings: go back to previous page",labelKey:"shortcuts.settingsBack",page:"any",bare:!0},{id:"nav-jk-settings",group:"navigation",keys:["J / K"],label:"Settings L1: switch settings tabs",labelKey:"shortcuts.navJkSettings",page:"any",bare:!0},{id:"nav-hl-work",group:"navigation",keys:["H / L"],label:"Tasks: item list ↔ project L1 ↔ app rail",labelKey:"shortcuts.navHlWork",page:"work",bare:!0},{id:"nav-jk-work",group:"navigation",keys:["J / K"],label:"Tasks: move project / item selection",labelKey:"shortcuts.navJkWork",page:"work",bare:!0},{id:"nav-hl-team",group:"navigation",keys:["H / L"],label:"Team: L0 ↔ L1 ↔ L2 (L ignored on deepest pane)",labelKey:"shortcuts.navHlTeam",page:"team",bare:!0},{id:"nav-jk-team",group:"navigation",keys:["J / K"],label:"Team L1: move roster selection",labelKey:"shortcuts.navJkTeam",page:"team",bare:!0},{id:"nav-jk-team-l2",group:"navigation",keys:["J / K"],label:"Team L2: move team member selection",labelKey:"shortcuts.navJkTeamL2",page:"team",bare:!0},{id:"nav-jk-deliverables",group:"navigation",keys:["J / K"],label:"Output L1: move deliverable selection",labelKey:"shortcuts.navJkDeliverables",page:"deliverables",bare:!0},{id:"nav-jk-store",group:"navigation",keys:["J / K"],label:"Store L1: switch store tabs",labelKey:"shortcuts.navJkStore",page:"store",bare:!0},{id:"toggle-project-detail",group:"tasks",keys:["J"],label:"Toggle project detail (Tasks)",labelKey:"shortcuts.toggleProjectDetail",page:"work"},{id:"toggle-item-detail",group:"tasks",keys:["L"],label:"Toggle task / requirement detail (Tasks)",labelKey:"shortcuts.toggleItemDetail",page:"work"},{id:"cycle-board",group:"tasks",keys:["Ctrl","Tab"],label:"Cycle Tasks views",labelKey:"shortcuts.cycleBoard",page:"work",bare:!0},{id:"toggle-browser",group:"team",keys:["L"],label:"Toggle right panel · Browser",labelKey:"shortcuts.toggleBrowser",page:"team"},{id:"toggle-terminal",group:"team",keys:["J"],label:"Toggle right panel · Terminal",labelKey:"shortcuts.toggleTerminal",page:"team"},{id:"next-tab",group:"rightPanel",keys:["Shift","]"],label:"Next right-panel tab",labelKey:"shortcuts.nextTab",page:"team"},{id:"prev-tab",group:"rightPanel",keys:["Shift","["],label:"Previous right-panel tab",labelKey:"shortcuts.prevTab",page:"team"},{id:"tab-n",group:"rightPanel",keys:["1…9"],label:"Jump to Nth right-panel tab",labelKey:"shortcuts.tabN",page:"team"},{id:"close-tab",group:"rightPanel",keys:["W"],label:"Close right-panel tab",labelKey:"shortcuts.closeTab",page:"team"},{id:"new-tab",group:"rightPanel",keys:["T"],label:"New browser tab / shell",labelKey:"shortcuts.newTab",page:"team"},{id:"term-search",group:"terminal",keys:["F"],label:"Search in terminal",labelKey:"shortcuts.termSearch",page:"team"},{id:"term-to-chat",group:"terminal",keys:["Shift","A"],label:"Add terminal selection to chat",labelKey:"shortcuts.termToChat",page:"team"}];function kY(e,t,n){return n||e[0]==="Ctrl"||e[0]==="Tab"||e[0]==="J / K"||e[0]==="H / L"?e.join(e[0]==="Ctrl"?"+":" "):e.length===1&&(e[0]==="H"||e[0]==="L"||e[0]==="J"||e[0]==="K")?e[0]:[t?"⌘":"Ctrl",...e].join(t?"":"+")}function SY(e){if(!(e instanceof HTMLElement))return!1;const t=e.tagName;return t==="INPUT"||t==="TEXTAREA"||t==="SELECT"||e.isContentEditable?!0:e.closest(".xterm")!==null}function J4(e){return e instanceof HTMLElement?e.closest(".xterm")!==null:!1}const NY=["layout","navigation","tasks","team","search","rightPanel","terminal","help"];function CY(e){return e===de.TEAM?"team":e===de.WORK?"work":e===de.DELIVERABLES?"deliverables":e===de.STORE?"store":"any"}function TY({open:e,onClose:t,page:n}){const{t:r}=ft("common"),o=typeof navigator<"u"&&navigator.platform.toUpperCase().includes("MAC"),l=CY(n);return k.useEffect(()=>{if(!e)return;const c=d=>{d.key==="Escape"&&(d.preventDefault(),d.stopPropagation(),t())};return window.addEventListener("keydown",c,!0),()=>window.removeEventListener("keydown",c,!0)},[e,t]),e?s.jsx("div",{className:"fixed inset-0 z-[100] flex items-center justify-center bg-black/45 backdrop-blur-[1px] p-4",onMouseDown:c=>{c.target===c.currentTarget&&t()},role:"dialog","aria-modal":"true","aria-label":r("shortcuts.title"),children:s.jsxs("div",{className:"w-full max-w-lg max-h-[80vh] overflow-auto rounded-xl border border-border-default bg-surface-primary shadow-2xl",children:[s.jsxs("div",{className:"sticky top-0 z-10 flex items-center justify-between gap-3 px-4 py-3 border-b border-border-default bg-surface-primary",children:[s.jsx("h2",{className:"text-sm font-semibold text-fg-primary",children:r("shortcuts.title")}),s.jsx("button",{type:"button",onClick:t,className:"w-7 h-7 flex items-center justify-center rounded-md text-fg-tertiary hover:text-fg-secondary hover:bg-surface-elevated","aria-label":r("shortcuts.close"),children:s.jsxs("svg",{width:"14",height:"14",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"})]})})]}),s.jsx("div",{className:"px-4 py-3 space-y-4",children:NY.map(c=>{const d=wY.filter(m=>{if(m.group!==c)return!1;const f=m.page??"any";return f==="any"?!0:f===l});return d.length===0?null:s.jsxs("section",{children:[s.jsx("h3",{className:"text-[11px] font-semibold uppercase tracking-wide text-fg-tertiary mb-2",children:r(`shortcuts.groups.${c}`)}),s.jsx("ul",{className:"space-y-1.5",children:d.map(m=>s.jsxs("li",{className:"flex items-center justify-between gap-3 text-sm",children:[s.jsx("span",{className:"text-fg-secondary min-w-0",children:r(m.labelKey??m.label,{defaultValue:m.label})}),s.jsx("kbd",{className:"shrink-0 px-1.5 py-0.5 rounded bg-surface-elevated border border-border-default text-[11px] font-medium text-fg-primary font-mono",children:kY(m.keys,o,m.bare)})]},m.id))})]},c)})})]})}):null}function AY({authUser:e,onClose:t,onSaved:n,onUserUpdated:r}){const{t:o}=ft("common");Ho(!0);const[l,c]=k.useState(e.name||""),[d,m]=k.useState(e.email||""),[f,h]=k.useState(!1),[g,y]=k.useState(""),[x,w]=k.useState(()=>Ew(e.avatarUrl,sa()?.avatarUrl)),C=async T=>{if(T.preventDefault(),!l.trim()){y(o("profile.nameRequired"));return}if(d&&!/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(d.trim())){y(o("profile.invalidEmail"));return}h(!0),y("");try{const{user:S}=await Ee.auth.updateProfile(l.trim(),d.trim());n({...S,avatarUrl:x??S.avatarUrl})}catch{y(o("profile.failedToSave"))}finally{h(!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:C,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(jw,{currentUrl:x,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=>c(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:f,className:"px-4 py-2 text-sm bg-brand-600 hover:bg-brand-500 disabled:opacity-50 text-white rounded-lg",children:o(f?"saving":"save")})]})]})})}const ew=k.lazy(()=>Gr(()=>import("./Team-NM2SsmjN.js"),__vite__mapDeps([2,3,4,5,6])).then(e=>({default:e.TeamPage}))),tw=k.lazy(()=>Gr(()=>import("./Settings-WAXEtxMR.js"),[]).then(e=>({default:e.Settings}))),EY=k.lazy(()=>Gr(()=>import("./Store-DOGCOxTK.js"),[]).then(e=>({default:e.StorePage}))),_Y=k.lazy(()=>Gr(()=>Promise.resolve().then(()=>$W),void 0).then(e=>({default:e.AgentBuilder}))),nw=k.lazy(()=>Gr(()=>import("./Work-ornw-1Zh.js"),__vite__mapDeps([7,4,1,8,3,9])).then(e=>({default:e.WorkPage}))),rw=k.lazy(()=>Gr(()=>import("./Deliverables-CJFzxbLw.js"),__vite__mapDeps([10,4,5])).then(e=>({default:e.DeliverablesPage}))),jY=k.lazy(()=>Gr(()=>import("./Notifications-Cz2LKhGE.js"),[]).then(e=>({default:e.NotificationsPage}))),MY=k.lazy(()=>Gr(()=>import("./Search-dq45wHQN.js"),[]).then(e=>({default:e.SearchPage}))),RY={visibility:"hidden",position:"absolute",inset:0,pointerEvents:"none",zIndex:-1};function LY(e){try{const t=navigator.language,n=Intl.DateTimeFormat().resolvedOptions().timeZone,r=e.preferences??{};if(r.locale===t&&r.timezone===n)return;Ee.auth.updatePreferences({locale:t,timezone:n}).catch(()=>{})}catch{}}function OY(){return s.jsx("div",{className:"flex-1 flex items-center justify-center text-fg-tertiary text-sm animate-pulse",children:"Loading..."})}const DY=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:RY,children:s.jsx(k.Suspense,{fallback:s.jsx(OY,{}),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}),Dd={};function f6(e){return typeof window<"u"&&window.matchMedia("(max-width: 767px)").matches?yw[e]??e:e}function aw(){return f6(pc())}function IY(){const{t:e}=ft("common"),[t,n]=k.useState(aw),[r,o]=k.useState(()=>!localStorage.getItem("markus_onboarded")),[l,c]=k.useState(!0),d=Uo(),m=hY(),f=fY({side:"left",defaultWidth:160,minWidth:140,maxWidth:400,collapsedWidth:64,storageKey:"markus_sidebar"}),[h,g]=k.useState(()=>new Set([aw()])),[y,x]=k.useState("loading"),[w,C]=k.useState(!1),[T,S]=k.useState(null),[E,j]=k.useState({hasOwner:!1,hasMultipleUsers:!1}),[L,I]=k.useState(!1),[O,F]=k.useState(!1),[V,X]=k.useState(null),[z,G]=k.useState(!1),[se,ee]=k.useState(null),[q,re]=k.useState(()=>{const Q=localStorage.getItem("markus_update_dismissed");return Q||null}),[B,J]=k.useState(!1),[fe,Se]=k.useState(!1),U=Lc(),W=U?.leftCollapsed??!1,pe=U?.toggleLeftCollapsed,P=U?.setLeftCollapsed,_e=U?.keyboardPane??"l0",He=U?.setKeyboardPane,Pe=U?.l0FocusPageId??null,Ge=U?.setL0FocusPageId,ct=k.useRef(t);ct.current=t;const mt=k.useRef(de.HOME),Ct=U?.toggleRightPanel,Mt=U?.toggleTerminalPanel,Pt=U?.cycleRightPanelTab,Kt=U?.activateRightPanelTabAt,yt=U?.openNewRightPanelTab,Ue=U?.rightPanelOpen??!1,dt=U?.activeRightPanelTabId??null,Nt=U?.openRightPanel,bt=U?.closeRightPanelTab,Lt=U?.updateRightPanelBrowserTab,ue=U?.updateRightPanelTerminalTab,tt=k.useRef(U?.rightPanelTabs);tt.current=U?.rightPanelTabs,k.useEffect(()=>{const Q=window.markusDesktop?.browser?.onPageEvent;if(!(!Q||!Nt))return Q(Z=>{if(Z.type==="closed"){const be=tt.current?.find(Ke=>Ke.payload.kind==="url"&&Ke.payload.browserId===Z.browserId);be&&bt&&bt(be.id);return}if(Z.type==="navigated"){if(Z.url&&gc(Z.url))return;Z.browserId&&Lt&&Lt(Z.browserId,{url:Z.url,title:Z.title||Z.url});return}if(Z.type==="opened"||Z.type==="selected"){if(!Z.url&&!Z.browserId||Z.browserId.startsWith("eb_")||rV(Z.browserId)||Z.url&&gc(Z.url))return;Nt({kind:"url",url:Z.url||"about:blank",title:Z.title||Z.url||"Browser",browserId:Z.browserId,pageId:Z.pageId})}})},[Nt,bt,Lt]),k.useEffect(()=>{const Q=window.markusDesktop?.terminal?.onEvent;if(!(!Q||!Nt))return Q(Z=>{if(Z.type==="closed"){const be=tt.current?.find(Ke=>Ke.payload.kind==="terminal"&&Ke.payload.terminalId===Z.id);be&&bt&&bt(be.id);return}if(Z.type==="cwd"){Z.cwd&&ue?.(Z.id,{cwd:Z.cwd});return}if(Z.type==="selected"){(Z.title||Z.cwd)&&ue?.(Z.id,{title:Z.title,cwd:Z.cwd});return}if(Z.type==="opened"){if(Vg.has(Z.id)){(Z.title||Z.cwd)&&ue?.(Z.id,{title:Z.title,cwd:Z.cwd});return}wi(Z.id),Nt({kind:"terminal",terminalId:Z.id,title:Z.title||"Terminal",cwd:Z.cwd})}})},[Nt,bt,ue]);const st=U?.handleTerminalExit;k.useEffect(()=>{const Q=window.markusDesktop?.terminal?.onExit;if(!(!Q||!st))return Q(Z=>{st(Z.id)})},[st]),k.useLayoutEffect(()=>{const Q=t===de.TEAM&&Ue&&U?.rightPanelMode==="browser";up(Q)},[t,Ue,U?.rightPanelMode]),k.useEffect(()=>{window.markusDesktop?.browser?.hideAll?.()},[]);const ye=k.useRef(!1);k.useEffect(()=>{if(!ye.current){ye.current=!0;return}f.setCollapsed(W)},[W,f.setCollapsed]),k.useEffect(()=>{if(d)return;const Q=navigator.platform.toUpperCase().includes("MAC"),Z=Ke=>{Q&&Ke.metaKey&&!Ke.ctrlKey&&Ke.key==="p"?(Ke.preventDefault(),J(Ie=>!Ie)):!Q&&Ke.ctrlKey&&!Ke.metaKey&&Ke.key==="p"&&(Ke.preventDefault(),J(Ie=>!Ie))},be=()=>J(!0);return document.addEventListener("keydown",Z),window.addEventListener("markus:open-search",be),()=>{document.removeEventListener("keydown",Z),window.removeEventListener("markus:open-search",be)}},[d]);const je=k.useCallback(()=>!Ue||!dt||!bt?!1:(bt(dt),!0),[Ue,dt,bt]);k.useEffect(()=>{const Q=window.markusDesktop?.onAppShortcut?.(Z=>{if(Z.type==="close-tab"){je();return}Z.type==="new-tab"&&yt?.()});return()=>{Q?.()}},[je,yt]),k.useEffect(()=>{if(d||!pe||!Ct)return;const Q=navigator.platform.toUpperCase().includes("MAC"),Z=be=>{if(!(Q?be.metaKey&&!be.ctrlKey:be.ctrlKey&&!be.metaKey)||be.altKey)return;if(!be.shiftKey&&(be.key==="/"||be.code==="Slash")){be.preventDefault(),Se(Ye=>!Ye);return}if(be.shiftKey&&(be.key==="?"||be.key==="/")){be.preventDefault(),Se(Ye=>!Ye);return}if(be.shiftKey&&Ue&&Pt){if(be.key==="]"||be.code==="BracketRight"){be.preventDefault(),Pt(1);return}if(be.key==="["||be.code==="BracketLeft"){be.preventDefault(),Pt(-1);return}}if(!be.shiftKey&&Ue&&Kt){const Ye=be.key>="1"&&be.key<="9"?Number(be.key):0;if(Ye>=1){be.preventDefault(),Kt(Ye-1);return}}if(be.shiftKey)return;const Ie=be.key.toLowerCase();if(Ie==="w"){be.preventDefault(),be.stopPropagation(),je();return}if(Ie==="t"){be.preventDefault(),yt?.();return}if(Ie==="b"){if(t===de.DELIVERABLES)return;be.preventDefault(),pe()}else if(t===de.TEAM&&Ie==="l"){if(!Q&&J4(be.target)||Q&&J4(be.target)&&be.ctrlKey)return;be.preventDefault(),Ct()}else t===de.TEAM&&Ie==="j"&&Mt&&(be.preventDefault(),Mt())};return document.addEventListener("keydown",Z,!0),()=>document.removeEventListener("keydown",Z,!0)},[d,t,pe,Ct,Mt,Pt,Kt,Ue,je,yt]);const Ae=k.useCallback((Q,Z)=>{let be=fc(Q);d?be=yw[be]??be:be===de.NOTIFICATIONS&&(be=de.HOME),be!==de.TEAM&&up(!1);const Ke=pc(),Ie=window.location.hash.slice(1);Ie!==hh(Ke)?Dd[Ke]=Ie:delete Dd[Ke];const Ye=ct.current;if(be===de.SETTINGS&&Ye!==de.SETTINGS&&(mt.current=Ye,it.setSettingsReturnPage(Ye),He?.("l1"),Ge?.(de.SETTINGS)),Ye===de.SETTINGS&&be!==de.SETTINGS&&(He?.("l0"),Ge?.(be)),be===de.SETTINGS&&Z?.tab){const le=`settings/${Z.tab}`;Dd[be]=le,history.pushState(null,"","#"+le),window.dispatchEvent(new HashChangeEvent("hashchange")),n(be),g(Oe=>Oe.has(be)?Oe:new Set([...Oe,be]));return}const M=be!==de.WORK?Dd[be]:void 0;M&&M!==hh(be)?(history.pushState(null,"",Ti(be)),history.pushState(null,"","#"+M)):history.pushState(null,"",Ti(be)),window.dispatchEvent(new HashChangeEvent("hashchange")),n(be),g(le=>le.has(be)?le:new Set([...le,be]))},[d,He,Ge]);k.useEffect(()=>{it.setHandler((Q,Z)=>Ae(Q,Z))},[Ae]),k.useEffect(()=>{_e==="l0"&&t!==de.SETTINGS&&Ge?.(t)},[_e,t,Ge]),k.useEffect(()=>{if(d||!He||!Ge)return;const Q=Z=>{if(Z.metaKey||Z.ctrlKey||Z.altKey||SY(Z.target))return;const be=Z.key.length===1?Z.key.toLowerCase():Z.key;if(t===de.SETTINGS&&(be==="h"||be==="ArrowLeft")){Z.preventDefault(),Z.stopImmediatePropagation(),it.leaveSettings();return}if(_e!=="l0"||t===de.SETTINGS)return;const Ke=Pe&&vo.includes(Pe)?Pe:t,Ie=Math.max(0,vo.indexOf(Ke));if(be==="j"||be==="ArrowDown"){Z.preventDefault(),Z.stopImmediatePropagation();const Ye=vo[Math.min(vo.length-1,Ie+1)];Ge(Ye),Ye!==t&&Ae(Ye),requestAnimationFrame(()=>{document.querySelector(`[data-l0-page-id="${Ye}"]`)?.scrollIntoView({block:"nearest"})});return}if(be==="k"||be==="ArrowUp"){Z.preventDefault(),Z.stopImmediatePropagation();const Ye=vo[Math.max(0,Ie-1)];Ge(Ye),Ye!==t&&Ae(Ye),requestAnimationFrame(()=>{document.querySelector(`[data-l0-page-id="${Ye}"]`)?.scrollIntoView({block:"nearest"})});return}if(be==="l"||be==="ArrowRight"||be==="Enter"){const Ye=Pe&&vo.includes(Pe)?Pe:t;if(!XO.has(Ye)){Z.preventDefault(),Z.stopImmediatePropagation();return}Z.preventDefault(),Z.stopImmediatePropagation(),Ye!==t&&Ae(Ye),P?.(!1),He("l1");return}(be==="h"||be==="ArrowLeft")&&(Z.preventDefault(),Z.stopImmediatePropagation())};return document.addEventListener("keydown",Q,!0),()=>document.removeEventListener("keydown",Q,!0)},[d,_e,Pe,t,Ae,He,Ge,P]),k.useEffect(()=>{const Q=()=>C(!0);return window.addEventListener("markus:open-edit-profile",Q),()=>window.removeEventListener("markus:open-edit-profile",Q)},[]),k.useEffect(()=>{if(!window.markusDesktop)return;!d&&t!==de.SETTINGS&&!f.collapsed?window.markusDesktop.setTrafficLightPosition(16,16):window.markusDesktop.setTrafficLightPosition(6,16)},[f.collapsed,t,d]),k.useEffect(()=>{window.markusDesktop&&window.markusDesktop.onNotificationClick(Q=>{if(Q.openNotifications&&window.dispatchEvent(new CustomEvent("markus:open-notifications")),Q.page){const Z=fc(Q.page);Q.params&&Object.entries(Q.params).forEach(([be,Ke])=>localStorage.setItem(`markus_nav_${be}`,Ke)),Ae(Z),window.dispatchEvent(new CustomEvent("markus:navigate",{detail:{page:Z,params:Q.params}}))}})},[Ae]);const oe=k.useCallback(()=>{fetch("/api/settings/llm").then(Q=>Q.ok?Q.json():null).then(Q=>{if(Q?.providers){const Z=Object.values(Q.providers).some(be=>be.configured);X(Z)}}).catch(()=>{})},[]),H=k.useCallback((Q,Z)=>{if(!Q)return;const Ke=Z&&{agent:"agents",team:"teams",skill:"skills"}[Z]||"agents";localStorage.setItem("markus_nav_installItem",Q),localStorage.setItem("markus_nav_storeTab",Ke);const Ie=new URLSearchParams(window.location.search);Ie.get("install")||(Ie.set("install",Q),Z&&Ie.set("type",Z));const Ye=Ie.toString();window.history.replaceState(null,"",`${window.location.pathname}?${Ye}${Ti(de.STORE)}`);const M=()=>it.navigate(de.STORE,{storeTab:Ke,installItem:Q});M(),setTimeout(M,500),setTimeout(M,1500)},[]);k.useEffect(()=>{const Q=new URLSearchParams(window.location.search),Z=Q.get("install");Z&&H(Z,Q.get("type"));const be=window.markusDesktop;be?.onDeepLinkInstall?.(({id:Ye,type:M})=>H(Ye,M)),be?.consumePendingDeepLinkInstall?.().then(Ye=>{Ye?.id&&H(Ye.id,Ye.type)}),Ee.auth.me().then(({user:Ye})=>{x(Ye),S(!0),LY(Ye),va.connect(Ye.id),oe(),Ee.health().then(le=>{le.updateAvailable&&le.latestVersion&&ee({latestVersion:le.latestVersion,currentVersion:le.version})}).catch(()=>{});const M=()=>{gi(Tr.builderArtifacts,()=>Ee.builder.artifacts.list()),gi(Tr.builderAgents,()=>Ee.agents.list()),gi(Tr.builderHubMyItems,()=>lt.myItems()),gi(Tr.builderInstalled,()=>Ee.builder.artifacts.installed()),gi(Tr.hubAgents,()=>lt.search({type:"agent",limit:50})),gi(Tr.hubTeams,()=>lt.search({type:"team",limit:50})),gi(Tr.hubSkills,()=>lt.search({type:"skill",limit:50}))};typeof requestIdleCallback=="function"?requestIdleCallback(M,{timeout:5e3}):setTimeout(M,3e3)}).catch(()=>{x(null),Ee.auth.status().then(({initialized:Ye,hasOwner:M,hasMultipleUsers:le})=>{S(Ye),j({hasOwner:M,hasMultipleUsers:le})}).catch(()=>S(!0))}),va.connect();const Ke=va.on("notification",()=>{window.dispatchEvent(new CustomEvent("markus:notifications-changed"))}),Ie=()=>{const Ye=f6(pc());Ye!==de.TEAM&&up(!1),n(Ye),g(M=>M.has(Ye)?M:new Set([...M,Ye]))};return window.addEventListener("hashchange",Ie),window.addEventListener("popstate",Ie),()=>{Ke(),va.disconnect(),window.removeEventListener("hashchange",Ie),window.removeEventListener("popstate",Ie)}},[]);const te=y!=="loading"&&y!==null?y:void 0,Ne=k.useMemo(()=>d?{[de.HOME]:s.jsx(dv,{authUser:te}),[de.TEAM]:s.jsx(ew,{authUser:te}),[de.BUILDER]:s.jsx(oY,{authUser:te}),[de.SETTINGS]:s.jsx(tw,{theme:m.mode,onThemeChange:m.setMode,authUser:te,onLogout:()=>{Ee.auth.logout().catch(()=>{}),Ro(),x(null)},onUserUpdated:Q=>x(Q)}),[de.WORK]:s.jsx(nw,{authUser:te}),[de.DELIVERABLES]:s.jsx(rw,{authUser:te}),[de.NOTIFICATIONS]:s.jsx(jY,{authUser:te}),[de.SEARCH]:s.jsx(MY,{})}:{[de.HOME]:s.jsx(dv,{authUser:te}),[de.TEAM]:s.jsx(ew,{authUser:te}),[de.SETTINGS]:s.jsx(tw,{theme:m.mode,onThemeChange:m.setMode,authUser:te,onLogout:()=>{Ee.auth.logout().catch(()=>{}),Ro(),x(null)},onUserUpdated:Q=>x(Q)}),[de.STORE]:s.jsx(EY,{authUser:te}),[de.BUILDER]:s.jsx(_Y,{authUser:te}),[de.WORK]:s.jsx(nw,{authUser:te}),[de.DELIVERABLES]:s.jsx(rw,{authUser:te})},[te?.id,te?.role,m.mode,d]);if(y==="loading"||y===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 $e=(typeof window<"u"?window.location.hash:"").match(/^#invite\?token=([a-f0-9]+)/);return $e?s.jsx(dY,{token:$e[1],onComplete:()=>{window.location.hash="",localStorage.removeItem("markus_onboarded"),o(!0),I(!0),x("loading"),Ee.auth.me().then(Q=>x(Q.user)).catch(()=>x(null))}}):y===null?s.jsx(uY,{hasOwner:E.hasOwner,hasMultipleUsers:E.hasMultipleUsers,onLogin:(Q,Z,be)=>{x(Q),va.connect(Q.id),Z?(localStorage.removeItem("markus_onboarded"),o(!0),be?.fromHub&&I(!0)):localStorage.getItem("markus_onboarded")||(localStorage.setItem("markus_onboarded","1"),o(!1))}}):O?s.jsx(mY,{onComplete:()=>F(!1),isFirstTime:!0}):r?s.jsx(lY,{theme:m.mode,onThemeChange:m.setMode,skipProfile:L,onProfileUpdated:Q=>{const Z={id:Q.id,name:Q.name,email:Q.email,role:Q.role,orgId:Q.orgId??"default",avatarUrl:Q.avatarUrl};x(Z)},onComplete:()=>{localStorage.setItem("markus_onboarded","1"),o(!1),I(!1),Ee.auth.me().then(Q=>x(Q.user)).catch(()=>{}),oe(),Ae(de.HOME)}}):s.jsxs("div",{className:`flex h-dvh bg-surface-primary text-fg-primary overflow-x-hidden ${d?"flex-col":""}`,children:[!d&&t!==de.SETTINGS&&s.jsxs(s.Fragment,{children:[s.jsx("div",{className:"relative z-40 shrink-0",style:{width:f.width},children:s.jsx(fW,{currentPage:t,onNavigate:Q=>{Ae(Q),c(!1),He?.("l0"),Ge?.(Q)},authUser:y,collapsed:f.collapsed,onToggleCollapse:f.toggle,onLogout:()=>{Ee.auth.logout().catch(()=>{}),Ro(),x(null)},keyboardFocusPageId:Pe,keyboardPaneActive:_e==="l0"})}),s.jsx("div",{className:`${f.collapsed?"w-0":"w-1.5 cursor-col-resize"} shrink-0 group relative z-10 flex items-center justify-center`,onMouseDown:f.collapsed?void 0:f.onResizeStart,children:!f.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!==de.SETTINGS&&t!==de.SEARCH?"pb-14":""}`,children:[V===!1&&!z&&t!==de.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:()=>G(!0),className:"text-amber-500 hover:text-amber-600 text-xs",children:e("dismiss")})]})]}),se&&q!==se.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:se.latestVersion,current:se.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:()=>{re(se.latestVersion),localStorage.setItem("markus_update_dismissed",se.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(Ne).map(Q=>h.has(Q)?s.jsx(DY,{id:Q,activePage:t,children:Ne[Q]},Q):null)})]}),d&&t!==de.SETTINGS&&t!==de.SEARCH&&s.jsx(xW,{currentPage:t,onNavigate:Ae,userId:te?.id}),d&&s.jsx(mD,{authUser:te,onNavigate:Ae}),!d&&B&&s.jsx(xY,{onClose:()=>J(!1),currentPage:t}),!d&&s.jsx(TY,{open:fe,onClose:()=>Se(!1),page:t}),w&&te&&s.jsx(AY,{authUser:te,onClose:()=>C(!1),onUserUpdated:Q=>x(Q),onSaved:Q=>{C(!1),x(Q)}})]})}N7.createRoot(document.getElementById("root")).render(s.jsx(k.StrictMode,{children:s.jsx(cV,{children:s.jsx(IY,{})})}));export{g8 as $,Hs as A,Ya as B,Ti as C,dr as D,JO as E,HY as F,K3 as G,VY as H,tY as I,b4 as J,A4 as K,UK as L,Mw as M,uW as N,HK as O,de as P,UY as Q,PY as R,JW as S,FW as T,ZK as U,KY as V,yc as W,fX as X,zY as Y,sa as Z,Gr as _,Uo as a,BY as a0,$Y as a1,wi as a2,Sd as a3,_i as a4,r0 as a5,lX as a6,XK as a7,OV as a8,r4 as a9,sW as aA,oX as aB,WY as aC,qY as aD,G3 as aE,DV as aa,Ai as ab,Yo as ac,JY as ad,bW as ae,mX as af,rX as ag,GY as ah,ZY as ai,QY as aj,YY as ak,aW as al,Yg as am,XY as an,tX as ao,nX as ap,sX as aq,eX as ar,MV as as,dX as at,aX as au,cX as av,iX as aw,lW as ax,uX as ay,F3 as az,dD as b,Lc as c,aY as d,VW as e,XW as f,Ni as g,lt as h,SY as i,s as j,Sa as k,Ee as l,fY as m,it as n,bn as o,fc as p,Er as q,k as r,Wg as s,Hr as t,ft as u,Tc as v,va as w,A0 as x,x8 as y,Ho as z};
672
+ prose-blockquote:border-brand-500/40 prose-blockquote:text-fg-secondary`,children:s.jsx(Eh,{remarkPlugins:t,rehypePlugins:n,components:r,children:e})})}function sh({filename:e,content:t,onSave:n,embedded:r,readOnly:o}){const{t:l}=ft(["builder","common"]),[c,d]=k.useState(!1),[m,f]=k.useState(t),[h,g]=k.useState(!1),y=/\.(md|mdx|markdown)$/i.test(e),x=k.useRef(null);k.useEffect(()=>{f(t)},[t]),k.useEffect(()=>{if(c&&x.current){const T=x.current;T.style.height="auto",T.style.height=Math.max(200,T.scrollHeight)+"px"}},[c,m]);const w=async()=>{g(!0),await n(m),g(!1),d(!1)},C=o?null:s.jsx("div",{className:"flex items-center gap-2",children:c?s.jsxs(s.Fragment,{children:[s.jsx("button",{onClick:()=>{f(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:h,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(h?"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:C}),c?s.jsx("textarea",{ref:x,value:m,onChange:T=>f(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:y?s.jsx(ag,{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}),C]}),c?s.jsx("textarea",{ref:x,value:m,onChange:T=>f(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:y?s.jsx(ag,{content:t}):s.jsx("pre",{className:"text-xs leading-relaxed text-fg-secondary whitespace-pre-wrap font-mono",children:t})})]})}const I4={"README.md":0,"ROLE.md":1,"HEARTBEAT.md":2,"POLICIES.md":3,"CONTEXT.md":4,"ANNOUNCEMENT.md":0,"NORMS.md":1};function AW(e){return[...e].sort(([t],[n])=>{const r=I4[t]??99,o=I4[n]??99;return r!==o?r-o:t.localeCompare(n)})}function S0({files:e,onSave:t,noHeader:n,readOnly:r}){const o=k.useMemo(()=>AW(e),[e]),[l,c]=k.useState(0);if(o.length===1)return n?s.jsx(sh,{filename:o[0][0],content:o[0][1],onSave:h=>t(o[0][0],h),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(sh,{filename:o[0][0],content:o[0][1],onSave:h=>t(o[0][0],h),readOnly:r})]});const[d,m]=o[l]??o[0],f=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(([h],g)=>s.jsx("button",{onClick:()=>c(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:h},h))}),s.jsx(sh,{filename:d,content:m,onSave:h=>t(d,h),embedded:!0,readOnly:r},d)]});return n?f: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"}),f]})}function EW({images:e,artifactType:t,artifactName:n,onUpload:r,onRemove:o,readOnly:l,cacheBust:c}){const{t:d}=ft(["builder"]),m=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:()=>m.current?.click(),onDragOver:f=>f.preventDefault(),onDrop:f=>{f.preventDefault();const h=f.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:d("images.dropOrClick")}),s.jsx("span",{className:"block text-xs text-fg-muted/60 mt-1",children:d("images.hint")}),s.jsx("input",{ref:m,type:"file",accept:"image/*",className:"hidden",onChange:f=>{const h=f.target.files?.[0];h&&r(h),f.target.value=""}})]}):s.jsxs("div",{children:[s.jsxs("div",{className:"flex gap-3 overflow-x-auto pb-2",children:[e.map(f=>{const h=f.split("/").pop()??f;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)}${c!=null?`?v=${c}`:""}`,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:"×"})]},f)}),!l&&s.jsx("button",{onClick:()=>m.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:m,type:"file",accept:"image/*",className:"hidden",onChange:f=>{const h=f.target.files?.[0];h&&r(h),f.target.value=""}})]})}function _W({members:e,teamTopFiles:t,files:n,artifactName:r,onFileSave:o,readOnly:l}){const{t:c}=ft(["builder"]),[d,m]=k.useState(0),f=k.useMemo(()=>{const T=new Set;for(const S of Object.keys(n)){const E=S.match(/^members\/([^/]+)\//);E&&T.add(E[1])}return[...T]},[n]),h=k.useMemo(()=>{const T=new Map,S=new Set;for(let L=0;L<e.length;L++){const O=e[L].slug;O&&f.includes(O)&&!S.has(O)&&(T.set(L,O),S.add(O))}for(let L=0;L<e.length;L++){if(T.has(L))continue;const I=r0(e[L].name);I&&f.includes(I)&&!S.has(I)&&(T.set(L,I),S.add(I))}for(let L=0;L<e.length;L++){if(T.has(L))continue;const I=e[L].roleName;if(I){const O=r0(I);f.includes(O)&&!S.has(O)&&(T.set(L,O),S.add(O))}}for(let L=0;L<e.length;L++){if(T.has(L))continue;const I=e[L].name;for(const O of f){if(S.has(O))continue;const F=n[`members/${O}/ROLE.md`];if(!F)continue;const V=F.match(/^#\s+(.+)$/m)?.[1]?.trim();if(V&&(V.toLowerCase().includes(I.toLowerCase())||I.toLowerCase().includes(V.toLowerCase()))){T.set(L,O),S.add(O);break}}}const E=f.filter(L=>!S.has(L));let j=0;for(let L=0;L<e.length;L++)T.has(L)||j<E.length&&(T.set(L,E[j]),j++);return T},[e,f,n]),g=k.useCallback((T,S)=>{const E=h.get(S);return E?Object.entries(n).filter(([j])=>j.startsWith(`members/${E}/`)):[]},[n,h]),y=k.useMemo(()=>{const T=[{label:c("detail.overview")}];for(const S of e)T.push({label:S.name,role:S.role});return T},[e,c]),x=d>0?e[d-1]:null,w=d-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:y.map((T,S)=>{const E=S===d,j=T.role==="manager",L=S===0?E?"border-brand-500 text-brand-400":"border-transparent text-fg-tertiary hover:text-fg-secondary":j?E?"border-amber-500 text-amber-400":"border-transparent text-fg-tertiary hover:text-fg-secondary":E?"border-blue-500 text-blue-400":"border-transparent text-fg-tertiary hover:text-fg-secondary";return s.jsxs("button",{onClick:()=>m(S),className:`px-4 py-2.5 text-xs font-medium whitespace-nowrap border-b-2 transition-colors flex items-center gap-1.5 ${L} ${E?"bg-surface-secondary/50":"hover:bg-surface-elevated/50"}`,children:[S===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"})]}),S>0&&((()=>{const I=S-1,O=h.get(I),F=O?`/api/builder/artifacts/teams/${encodeURIComponent(r)}/members/${encodeURIComponent(O)}/images/avatar.jpg`:null;return F?s.jsx("img",{src:F,alt:T.label,className:`w-5 h-5 rounded-full object-cover shrink-0 ring-1 ${j?"ring-amber-500/40":"ring-blue-500/40"}`,onError:V=>{V.target.style.display="none",V.target.nextElementSibling?.classList.remove("hidden")}}):null})(),s.jsx("span",{className:`w-5 h-5 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"} ${(()=>{const I=S-1;return h.get(I)?"hidden":""})()}`,children:(T.label[0]??"?").toUpperCase()})),T.label]},S)})}),s.jsx("div",{className:"p-5",children:d===0?s.jsxs("div",{className:"space-y-6",children:[t.length>0&&s.jsx(S0,{noHeader:!0,files:t,onSave:C,readOnly:l}),s.jsxs("div",{children:[s.jsx("div",{className:"text-[10px] font-semibold text-fg-tertiary uppercase tracking-wider mb-3",children:c("sidebar.composition")}),s.jsx("div",{className:"grid gap-2 sm:grid-cols-2",children:e.map((T,S)=>{const E=T.role==="manager";return s.jsxs("button",{onClick:()=>m(S+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:[(()=>{const j=h.get(S),L=j?`/api/builder/artifacts/teams/${encodeURIComponent(r)}/members/${encodeURIComponent(j)}/images/avatar.jpg`:null;return L?s.jsx("img",{src:L,alt:T.name,className:`w-8 h-8 rounded-full object-cover shrink-0 ring-1 ${E?"ring-amber-500/30":"ring-blue-500/30"}`,onError:I=>{I.target.style.display="none",I.target.nextElementSibling?.classList.remove("hidden")}}):null})(),s.jsx("div",{className:`w-8 h-8 rounded-full flex items-center justify-center text-xs font-bold shrink-0 ${E?"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"} ${h.get(S)?"hidden":""}`,children:(T.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:T.name}),s.jsx("span",{className:`text-[9px] px-1.5 py-0.5 rounded-full font-medium ${E?"bg-amber-500/15 text-amber-400":"bg-blue-500/15 text-blue-400"}`,children:T.role}),T.count>1&&s.jsxs("span",{className:"text-[9px] text-fg-muted",children:["×",T.count]})]}),T.skills&&T.skills.length>0&&s.jsxs("div",{className:"flex flex-wrap gap-1 mt-1",children:[T.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)),T.skills.length>3&&s.jsxs("span",{className:"text-[9px] text-fg-muted",children:["+",T.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"})})]},S)})})]})]}):x?s.jsxs("div",{className:"space-y-4",children:[s.jsxs("div",{className:"flex items-center gap-4",children:[(()=>{const T=h.get(w),S=T?`/api/builder/artifacts/teams/${encodeURIComponent(r)}/members/${encodeURIComponent(T)}/images/avatar.jpg`:null;return S?s.jsx("img",{src:S,alt:x.name,className:`w-12 h-12 rounded-full object-cover shrink-0 ring-2 ${x.role==="manager"?"ring-amber-500/30":"ring-blue-500/30"}`,onError:E=>{E.target.style.display="none",E.target.nextElementSibling?.classList.remove("hidden")}}):null})(),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"} ${h.get(w)?"hidden":""}`,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(T=>s.jsx("span",{className:"text-[10px] px-2.5 py-1 bg-surface-elevated text-fg-muted rounded-full border border-border-default",children:T},T))}),(()=>{const T=g(x.name,w);return T.length===0?s.jsx("p",{className:"text-xs text-fg-muted italic",children:"No files for this member yet."}):s.jsx(S0,{noHeader:!0,readOnly:l,files:T.map(([S,E])=>[S.replace(/^members\/[^/]+\//,""),E]),onSave:(S,E)=>{const j=T.find(([L])=>L.endsWith(`/${S}`));j&&o(j[0],E)}})})()]}):null})]});function C(T,S){o(T,S)}}function Mi({type:e,name:t,onBack:n,authUser:r,readOnly:o,initialManifest:l,actionSlot:c,contentSlot:d}){const{t:m}=ft(["builder","common"]),f=Uo(),[h,g]=k.useState(!0),[y,x]=k.useState(t),[w,C]=k.useState({}),[T,S]=k.useState(null),[E,j]=k.useState(""),[L,I]=k.useState("idle"),[O,F]=k.useState({shared:!1}),[V,X]=k.useState(!1),[z,G]=k.useState(!1),[se,ee]=k.useState(!1),[q,re]=k.useState(!1),[B,J]=k.useState(!1),[fe,Se]=k.useState(!1),[U,W]=k.useState(null),[pe,P]=k.useState(0),[_e,He]=k.useState(""),[Pe,Ge]=k.useState(""),[ct,mt]=k.useState(""),[Ct,Mt]=k.useState(""),[Pt,Kt]=k.useState([]),[yt,Ue]=k.useState(""),dt=k.useRef(null),Nt=k.useRef(l);Nt.current=l,k.useEffect(()=>{x(t)},[t]);const bt=k.useCallback(async()=>{const Q=Nt.current;if(Q){S(Q),He(Q.displayName||Q.name||t),Ge(Q.description||""),mt(Q.version||"1.0.0"),Mt(Q.category||"general"),Kt(Q.tags||[]),Ue(Q.icon||""),C(Q.files??{}),g(!1);return}g(!0);try{let Z=t;try{const Ie=await Ee.builder.artifacts.ensureSlugSafe(e,t);Z=Ie.name,x(Z),Ie.converted&&(history.replaceState(null,"",Ti(de.BUILDER,`${e}/${encodeURIComponent(Z)}`)),window.dispatchEvent(new CustomEvent("markus:data-changed")))}catch{x(t)}const be=await Ee.builder.artifacts.get(e,Z);C(be.files??{}),j(be.path??"");const Ke=be.files[`${e}.json`]??be.files["agent.json"]??be.files["team.json"]??be.files["skill.json"];if(Ke){const Ie=JSON.parse(Ke);S(Ie),He(Ie.displayName||Ie.name||t),Ge(Ie.description||""),mt(Ie.version||"1.0.0"),Mt(Ie.category||"general"),Kt(Ie.tags||[]),Ue(Ie.icon||"")}}catch(Z){console.error("Failed to load artifact:",Z)}finally{g(!1)}},[e,t]);k.useEffect(()=>{bt()},[bt]),k.useEffect(()=>{l?.files&&C(l.files)},[l?.files]),k.useEffect(()=>{if(!o){try{const Q=localStorage.getItem("markus_builder_shared_map");if(Q){const Z=JSON.parse(Q),be=`${e}/${t}`;Z[be]&&F({shared:!0,id:Z[be].id,slug:Z[be].slug,version:Z[be].version,visibility:Z[be].visibility??"public"})}}catch{}lt.myItems().then(Q=>{const Z=Q?.items??[],be=e==="agent"?"agent":e==="team"?"team":"skill";for(const Ke of Z)if(Ke.itemType===be&&(Ke.slug===t||Ke.name===t)){F({shared:!0,id:Ke.id,slug:Ke.slug,version:Ke.version,visibility:Ke.visibility??"public",moderationStatus:Ke.moderationStatus,pendingReview:Ke.pendingReview});return}}).catch(()=>{})}},[e,t,o]);const Lt=k.useCallback(async Q=>{if(!(!T||o)){I("saving");try{const Z={...T,...Q};await Ee.builder.artifacts.save(e,Z),S(Z),I("saved"),setTimeout(()=>I(be=>be==="saved"?"idle":be),2e3)}catch{I("error"),setTimeout(()=>I("idle"),3e3)}}},[T,e]),ue=k.useCallback(Q=>{dt.current&&clearTimeout(dt.current),dt.current=setTimeout(()=>Lt(Q),800)},[Lt]),tt=k.useCallback((Q,Z)=>{const be={};Q==="displayName"?(He(Z),be.displayName=Z,G(!0)):Q==="description"?(Ge(Z),be.description=Z,G(!0)):Q==="version"?(mt(Z),be.version=Z,G(!1),ee(!1)):Q==="category"?(Mt(Z),be.category=Z,G(!0)):Q==="tags"?(Kt(Z),be.tags=Z,G(!0)):Q==="icon"&&(Ue(Z),be.icon=Z||void 0,G(!0)),ue({...T,...be})},[T,ue]),st=k.useCallback(async(Q,Z)=>{try{const be={...w,[Q]:Z};C(be);const Ke={...T,files:be};await Ee.builder.artifacts.save(e,Ke),I("saved"),G(!0),setTimeout(()=>I(Ie=>Ie==="saved"?"idle":Ie),2e3)}catch{I("error")}},[w,e,T]),ye=k.useCallback(async Q=>{if(T){X(!0);try{await lt.ensureAuth();const Z=await Ee.builder.artifacts.ensureSlugSafe(e,y,T.displayName||T.name||y),be=Z.name,Ke=Z.slug||xc(be);if(!Ke)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 Ie=Z.displayName||T.displayName||T.name||y;Z.converted&&(x(be),S(ze=>ze&&{...ze,name:Ke,displayName:Ie}),history.replaceState(null,"",Ti(de.BUILDER,`${e}/${encodeURIComponent(be)}`)),window.dispatchEvent(new CustomEvent("markus:data-changed")));const Ye={...T,name:Ke,displayName:Ie},M=Ye.description||"",le=Ye.category||"general",Oe=Ye.tags??[];let ge=Ye.icon||void 0;const Ve=Ye.version||"1.0.0";if(ge&&!ge.startsWith("http")&&/\.(png|jpe?g|gif|webp|svg)$/i.test(ge)){const ze=ge.split("/").pop()??ge;try{const rt=await fetch(`/api/builder/artifacts/${e}s/${encodeURIComponent(be)}/images/${encodeURIComponent(ze)}`,{cache:"no-store"});if(rt.ok){const vt=await rt.blob(),Fe=new File([vt],ze,{type:vt.type}),at=await lt.uploadImage(Fe);at?.url&&(ge=at.url)}}catch{}}let Qe;const K=[],ce=Ye.screenshots??[];for(let ze=0;ze<ce.length;ze++){const rt=ce[ze],vt=rt.split("/").pop()??rt;try{const Fe=await fetch(`/api/builder/artifacts/${e}s/${encodeURIComponent(be)}/images/${encodeURIComponent(vt)}`,{cache:"no-store"});if(Fe.ok){const at=await Fe.blob(),kt=new File([at],vt,{type:at.type}),xn=await lt.uploadImage(kt);xn?.url&&(K.push({url:xn.url,alt:vt,order:ze}),ze===0&&(Qe=xn.url))}}catch{}}const Te=await lt.publishViaProxy({itemType:e==="team"?"team":e==="skill"?"skill":"agent",name:Ie,slug:Ke,description:M,category:le,tags:Oe,icon:ge,version:Ve,config:Ye,files:Object.keys(w).length>0?w:void 0,thumbnailUrl:Qe,images:K.length>0?K:void 0,priceCents:Q?.priceCents,donationsEnabled:Q?.donationsEnabled,visibility:Q?.visibility,orgId:Q?.orgId});Te.id&&(F({shared:!0,id:Te.id,slug:Te.slug??Ke,version:Ve,visibility:Te.visibility??Q?.visibility??"public",moderationStatus:Te.moderationStatus,pendingReview:Te.pendingReview}),G(!1),(Te.visibility??Q?.visibility??"public")!=="org"&&(Te.moderationStatus==="pending"||Te.pendingReview)?W({title:m("common:share"),message:Z.converted?m("share.convertedAndSubmitted",{previous:t,slug:Ke}):Te.updated?m("share.updateSubmitted"):m("share.submittedForReview"),variant:"primary"}):Z.converted&&W({title:m("common:share"),message:m("share.convertedSlug",{previous:t,slug:Ke}),variant:"primary"}))}catch(Z){console.error("Share to Hub failed:",Z),W({title:m("common:share"),message:Z instanceof Error?Z.message:String(Z),variant:"danger"})}finally{X(!1)}}},[T,w,e,t,y,m]),je=async Q=>{const Z=new FormData;Z.append("image",Q);try{await fetch(`/api/builder/artifacts/${e}s/${encodeURIComponent(y)}/images`,{method:"POST",body:Z,credentials:"include"}),await bt(),G(!0),P(be=>be+1)}catch(be){console.error("Image upload failed:",be)}},Ae=async Q=>{try{await fetch(`/api/builder/artifacts/${e}s/${encodeURIComponent(y)}/images/${encodeURIComponent(Q)}`,{method:"DELETE",credentials:"include"}),await bt(),G(!0),P(Z=>Z+1)}catch(Z){console.error("Image remove failed:",Z)}},oe=D4[e]??D4.agent,H=T?.screenshots??[],te=T?.skill?.skillFile?w[T.skill.skillFile]:w["SKILL.md"]??w["README.md"],Ne=k.useMemo(()=>e!=="agent"?[]:Object.entries(w).filter(([Q])=>!Q.endsWith(".json")&&!Q.startsWith("images/")&&!Q.startsWith("members/")),[w,e]),Re=k.useMemo(()=>e!=="team"?[]:Object.entries(w).filter(([Q])=>!Q.endsWith(".json")&&!Q.startsWith("images/")&&!Q.startsWith("members/")),[w,e]),$e=k.useMemo(()=>{if(e==="agent"||e==="team")return[];const Q=new Set;if(e==="skill"){const Z=T?.skill?.skillFile;Z&&w[Z]&&Q.add(Z),!Z&&w["SKILL.md"]&&Q.add("SKILL.md"),!Z&&!w["SKILL.md"]&&w["README.md"]&&Q.add("README.md")}return Object.entries(w).filter(([Z])=>!Z.endsWith(".json")&&!Z.startsWith("images/")&&!Z.startsWith("members/")&&!Q.has(Z))},[w,e,T?.skill?.skillFile]);return h?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:`${f?"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&&L==="saving"&&s.jsx("span",{className:"text-[10px] text-fg-muted animate-pulse",children:m("detail.saving")}),!o&&L==="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&&L==="error"&&s.jsx("span",{className:"text-[10px] text-red-500",children:m("detail.saveFailed")}),c,!o&&O.shared&&(()=>{const Q=lt.getUser(),Z=Q&&O.slug?`${lt.getUrl()}/@${encodeURIComponent(Q.username)}/${encodeURIComponent(O.slug)}`:null,be=ct||T?.version||"1.0.0",Ke=O.version!==be;return s.jsxs(s.Fragment,{children:[O.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")]}):O.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")]}):O.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,Z&&s.jsxs("a",{href:Z,target:"_blank",rel:"noopener noreferrer",onClick:Ie=>{yc()&&(Ie.preventDefault(),_i(Z))},className:`text-xs px-3 py-1.5 rounded-lg border transition-colors inline-flex items-center gap-1.5 ${O.visibility==="org"?"border-blue-500/30 text-blue-500 hover:text-blue-400 hover:border-blue-400/50":O.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:[O.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"})]}):O.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"})]}),O.visibility==="org"?m("visibility.sharedOrg"):O.visibility==="unlisted"?m("visibility.sharedUnlisted"):m("share.viewOnHub")]}),Ke&&s.jsx("button",{onClick:()=>{ye({visibility:O.visibility})},disabled:V,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:V?m("share.updating"):m("share.updateVersion",{version:be})})]})})(),!o&&!O.shared&&s.jsx("button",{onClick:()=>J(!0),disabled:V,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(V?"share.sharing":"share.toHub")})]})]}),!o&&z&&!se&&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:()=>ee(!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&&se&&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 Q=(ct||"1.0.0").split(".");return Q[2]=String(Number(Q[2]??0)+1),Q.join(".")})(),className:"text-xs px-2 py-1 rounded bg-surface-elevated border border-border-default text-fg-primary w-24 font-mono",onKeyDown:Q=>{Q.key==="Enter"&&tt("version",Q.target.value)}}),s.jsx("button",{onClick:Q=>{const Z=Q.target.parentElement?.querySelector("input");Z&&tt("version",Z.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:()=>ee(!1),className:"text-xs text-fg-tertiary hover:text-fg-secondary",children:m("common:cancel")})]}),O.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 ${f?"flex-col":""}`,children:[s.jsxs("div",{className:`${f?"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&&Se(!fe),className:`w-16 h-16 rounded-xl ${oe.bg} flex items-center justify-center text-3xl shrink-0 ${o?"":"cursor-pointer hover:ring-2"} ${oe.ring} transition-all overflow-hidden`,children:yt&&yt.startsWith("images/")?s.jsx("img",{src:`/api/builder/artifacts/${e}s/${encodeURIComponent(y)}/images/${encodeURIComponent(yt.replace("images/",""))}?v=${pe}`,alt:"",className:"w-full h-full object-cover"}):yt&&(yt.startsWith("http")||yt.startsWith("/"))?s.jsx("img",{src:yt,alt:"",className:"w-full h-full object-cover"}):(()=>{const Q=yt||"";if(Q&&[...Q].length<=2&&new RegExp("\\p{Emoji}","u").test(Q))return Q;const be=Ei[Xo(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:s6(_e||t||e),fill:be})})})()}),!o&&fe&&s.jsxs(s.Fragment,{children:[s.jsx("div",{className:"fixed inset-0 z-40",onClick:()=>Se(!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:yt,onKeyDown:Q=>{Q.key==="Enter"&&(tt("icon",Q.target.value),Se(!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 Q=>{const Z=Q.target.files?.[0];if(!Z)return;const be=new FormData;be.append("image",Z);try{const Ke=await fetch(`/api/builder/artifacts/${e}s/${encodeURIComponent(y)}/images`,{method:"POST",body:be,credentials:"include"});if(Ke.ok){const Ye=(await Ke.json()).path;if(Ue(Ye),Se(!1),T){const M={...T,icon:Ye};S(M),await Ee.builder.artifacts.save(e,M)}G(!0)}}catch{}}})]}),yt&&s.jsx("button",{onClick:()=>{tt("icon",""),Se(!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:SW.map(Q=>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:Q.label}),s.jsx("div",{className:"flex flex-wrap gap-0.5",children:Q.emojis.map(Z=>s.jsx("button",{onClick:()=>{tt("icon",Z),Se(!1)},className:`w-7 h-7 rounded flex items-center justify-center text-base hover:bg-surface-elevated transition-colors ${yt===Z?"ring-1.5 ring-brand-500 bg-brand-500/10":""}`,children:Z},Z))})]},Q.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(ah,{value:_e,onChange:Q=>tt("displayName",Q),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 ${oe.bg} ${oe.color}`,children:oe.label}),s.jsx(ah,{value:ct,onChange:Q=>tt("version",Q),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(ah,{value:Pe,onChange:Q=>tt("description",Q),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(CW,{value:Ct,options:kW,onChange:Q=>tt("category",Q),className:"text-xs px-2 py-0.5 rounded bg-surface-elevated text-fg-tertiary",readOnly:o}),s.jsx(TW,{tags:Pt,onChange:Q=>tt("tags",Q),readOnly:o})]})]})]}),s.jsx("div",{className:"mb-8",children:s.jsx(EW,{images:H,artifactType:e,artifactName:t,onUpload:je,onRemove:Ae,readOnly:o,cacheBust:pe})}),d&&s.jsx("div",{className:"mb-8",children:d}),e==="team"&&T.team&&s.jsx("div",{className:"mb-8",children:s.jsx(_W,{members:T.team.members,teamTopFiles:Re,files:w,artifactName:y,onFileSave:st,readOnly:o})}),e==="agent"&&Ne.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(S0,{noHeader:!0,files:Ne,onSave:st,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(Q=>{const Z=NW[Q];return s.jsxs("span",{className:`inline-flex items-center gap-1.5 text-xs px-3 py-1.5 rounded-lg border font-medium ${Z?.color??"bg-surface-elevated text-fg-secondary border-border-default"}`,children:[s.jsx("span",{className:"font-mono text-[10px]",children:Z?.icon??"?"})," ",Q]},Q)})})]}),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(([Q,Z])=>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:Q}),s.jsx("div",{className:"text-[10px] text-fg-muted font-mono truncate",children:typeof Z=="object"?JSON.stringify(Z).slice(0,80):String(Z)})]})]},Q))})]}),te&&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(ag,{content:te})})]})]}),$e.length>0&&s.jsx(S0,{files:$e,onSave:st,readOnly:o})]}),s.jsx("div",{className:`${f?"w-full":"w-72 shrink-0"}`,children:s.jsxs("div",{className:`${f?"":"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 ${oe.color}`,children:oe.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:Ct})]}),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:ct})]}),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((Q,Z)=>Q+Z.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(Q=>Q.role==="manager").reduce((Q,Z)=>Q+Z.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(Q=>Q.role!=="manager").reduce((Q,Z)=>Q+Z.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(Q=>s.jsx("span",{className:"text-[10px] px-1.5 py-0.5 bg-surface-elevated text-fg-muted rounded border border-border-default",children:Q},Q))})]})]})]}),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(Q=>s.jsx("span",{className:"text-[10px] px-2 py-0.5 bg-surface-elevated text-fg-secondary rounded border border-border-default",children:Q},Q))})]}):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(Q=>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:Q},Q))})]}):null]}):null,!o&&E&&s.jsxs("button",{onClick:()=>Ee.system.openPath(E).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:E,children:[s.jsx("span",{className:"text-fg-tertiary block mb-0.5",children:m("sidebar.openInFinder")}),E.replace(/.*\.markus\//,"~/.markus/")]})]})})]})]}),!o&&q&&s.jsx(MW,{onClose:()=>re(!1),onConfirm:(Q,Z)=>{re(!1),ye({donationsEnabled:!1,priceCents:Q==="paid"?Z:void 0})},isUpdate:O.shared}),!o&&B&&s.jsx(jW,{onClose:()=>J(!1),onConfirm:(Q,Z,be,Ke)=>{J(!1),ye({visibility:Q,orgId:Z,priceCents:be,donationsEnabled:Ke})}}),U&&s.jsx(dr,{alertOnly:!0,variant:U.variant??"primary",title:U.title,message:U.message,onConfirm:()=>W(null),onCancel:()=>W(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 jW({onClose:e,onConfirm:t}){const{t:n}=ft(["builder","common"]),[r,o]=k.useState("public"),[l,c]=k.useState([]),[d,m]=k.useState(""),[f,h]=k.useState(!1),[g,y]=k.useState(0),[x,w]=k.useState(!1);k.useEffect(()=>{r==="org"&&l.length===0&&(h(!0),lt.myOrgs().then(S=>{c(S.memberships),S.memberships.length>0&&m(S.memberships[0].id)}).catch(()=>{}).finally(()=>h(!1)))},[r,l.length]);const C=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:S=>S.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(S=>s.jsxs("label",{className:`flex items-center gap-3 p-3 rounded-lg border cursor-pointer transition-colors ${r===S.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===S.value,onChange:()=>o(S.value),className:"accent-brand-500"}),s.jsx("div",{className:"flex items-center gap-2 text-fg-secondary",children:S.icon}),s.jsxs("div",{children:[s.jsx("div",{className:"text-sm font-medium text-fg-primary",children:S.label}),s.jsx("div",{className:"text-[11px] text-fg-tertiary",children:S.desc})]})]},S.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")}),f?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:S=>m(S.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(S=>s.jsx("option",{value:S.id,children:S.name},S.id))})]}),C&&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:o6.map(S=>s.jsx("button",{type:"button",onClick:()=>y(S.cents),className:`text-sm px-2 py-2 rounded-lg border transition-colors ${g===S.cents?"border-brand-500 bg-brand-500/10 text-fg-primary":"border-border-default text-fg-secondary hover:border-gray-600"}`,children:S.label},S.cents))}),s.jsxs("label",{className:"flex items-center gap-2 cursor-pointer",children:[s.jsx("input",{type:"checkbox",checked:x,onChange:S=>w(S.target.checked),className:"accent-brand-500"}),s.jsx("span",{className:"text-xs text-fg-secondary",children:n("pricing.enableTips")})]})]}),C&&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,C&&g>0?g:void 0,C?x: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 o6=[{cents:0,label:"Free"},{cents:100,label:"$1"},{cents:500,label:"$5"},{cents:1e3,label:"$10"}];function MW({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:c=>c.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:o6.map(c=>s.jsxs("label",{className:`flex items-center gap-3 p-3 rounded-lg border cursor-pointer transition-colors ${o===c.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===c.cents,onChange:()=>l(c.cents),className:"accent-brand-500"}),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.cents===0?r("shareMode.freeDesc"):r("shareMode.paidDesc")})]})]},c.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 N0(e,t){return!e||!i6(e)?null:e.startsWith("http")||e.startsWith("data:")?e:e.startsWith("/")&&t?`${t}${e}`:e}function RW({type:e,seed:t,icon:n,hubBase:r,size:o=44,className:l="",rounded:c="rounded-xl"}){const d=Xo(e),m=N0(n,r),f=k.useMemo(()=>Xg(d,t),[d,t]),h=k.useMemo(()=>s6(t),[t]),[g,y]=k.useState(!1);return m&&!g?s.jsx("img",{src:m,alt:"",onError:()=>y(!0),style:{width:o,height:o},className:`${c} object-cover shrink-0 ${l}`}):vW(n)?s.jsx("div",{style:{width:o,height:o,background:f,fontSize:o*.5},className:`${c} shrink-0 flex items-center justify-center shadow-inner ${l}`,children:s.jsx("span",{className:"drop-shadow-sm",children:n})}):n&&MK(n)?s.jsx("div",{style:{width:o,height:o,background:f},className:`${c} shrink-0 flex items-center justify-center text-white shadow-inner ${l}`,children:s.jsx(Yo,{name:n,size:o*.52,className:"drop-shadow-sm"})}):s.jsx("div",{style:{width:o,height:o,background:f},className:`${c} 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:h,fill:"rgba(255,255,255,0.92)"})})})}function C0({name:e,username:t,avatarUrl:n,hubBase:r,size:o=24,className:l="",verified:c}){const d=t||e||"markus",m=N0(n,r),[f,h]=k.useState(!1),g=m&&!f?m:wW(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:()=>h(!0),className:"w-full h-full rounded-full object-cover ring-1 ring-white/10 bg-surface-elevated"}),c&&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 LW({type:e,className:t=""}){const n=Xo(e),r=Ei[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 P4({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 ia(e){const{type:t,name:n,description:r,seed:o,icon:l,cover:c,hubBase:d,author:m,authorLabel:f,version:h,category:g,tags:y,rating:x=0,ratingCount:w=0,downloadCount:C=0,priceCents:T,currency:S="usd",installed:E,glowing:j,selected:L,showTypeBadge:I=!0,hideStats:O=!1,cornerLabel:F,actions:V,footerLeft:X,headerAction:z,onClick:G,className:se=""}=e,ee=Xo(t),q=Ei[ee],re=o||n,B=(T??0)>0,J=!!N0(c||void 0,d),fe=Xg(ee,re),Se=f??m?.displayName??m?.username??"",[U,W]=k.useState(null),pe=E?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"})})}):F?s.jsx("span",{className:"chip",children:F}):B?s.jsx("span",{className:"badge-paid",children:O4(T,S)}):null;if(J){const P=N0(c||void 0,d);return s.jsxs("div",{onClick:G,style:{aspectRatio:U??void 0},className:`group asset-card card-shine relative flex flex-col overflow-hidden min-h-[180px] ${G?"cursor-pointer":""} ${L?"ring-1 ring-brand-500/60":""} ${j?"ring-2 ring-brand-500 shadow-lg shadow-brand-500/20":""} ${se}`,children:[s.jsx("img",{src:P,alt:"",onLoad:_e=>{const He=_e.currentTarget;He.naturalWidth&&He.naturalHeight&&W(Math.min(1.9,Math.max(1,He.naturalWidth/He.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:I&&s.jsx(LW,{type:ee})}),s.jsxs("span",{className:"flex items-center gap-1.5",onClick:_e=>_e.stopPropagation(),children:[E?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"})})}):F?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:F}):z?null:s.jsx("span",{className:B?"badge-paid":"badge-free",children:O4(T,S)}),z]})]}),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}),h&&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",h]})]}),Se&&s.jsxs("div",{className:"flex items-center gap-1.5 text-[11px] text-white/85",children:[m&&s.jsx(C0,{name:m.displayName,username:m.username,avatarUrl:m.avatarUrl,hubBase:d,size:15}),s.jsx("span",{className:"truncate",children:Se})]}),r&&s.jsx("p",{className:"text-[12.5px] text-white/80 truncate leading-snug drop-shadow-sm",children:r}),(g||y&&y.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}),y?.slice(0,3).map(_e=>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:_e},_e))]}),(!O||V)&&s.jsxs("div",{className:"flex items-center justify-between gap-2 pt-1 shrink-0",children:[O?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(P4,{rating:x}),w>0&&s.jsxs("span",{className:"text-white/60",children:["(",Mo(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"})}),Mo(C)]})]}),V&&s.jsx("div",{className:"flex items-center gap-2",onClick:_e=>_e.stopPropagation(),children:V})]})]})]})}return s.jsxs("div",{onClick:G,className:`group asset-card card-shine relative flex flex-col ${G?"cursor-pointer":""} ${L?"ring-1 ring-brand-500/60":""} ${j?"ring-2 ring-brand-500 shadow-lg shadow-brand-500/20":""} ${se}`,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, ${q.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:fe}}),z&&s.jsx("div",{className:"absolute top-2.5 right-2.5 z-10",onClick:P=>P.stopPropagation(),children:z}),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(RW,{type:ee,seed:re,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 ${z?"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}),h&&s.jsxs("span",{className:"chip shrink-0",children:["v",h]}),pe&&s.jsx("span",{className:"ml-auto shrink-0",children:pe})]}),(Se||I)&&s.jsxs("div",{className:"mt-1 flex items-center gap-1.5 text-[11px] text-fg-tertiary min-w-0",children:[m&&s.jsx(C0,{name:m.displayName,username:m.username,avatarUrl:m.avatarUrl,hubBase:d,size:15}),Se&&s.jsx("span",{className:"truncate",children:Se}),I&&s.jsxs(s.Fragment,{children:[Se&&s.jsx("span",{className:"text-fg-muted",children:"·"}),s.jsx("span",{className:"font-semibold shrink-0",style:{color:q.accent},children:q.label})]})]})]})]}),r&&s.jsx("p",{className:"text-[13px] text-fg-secondary truncate leading-snug",children:r}),(g||y&&y.length>0)&&s.jsxs("div",{className:"flex flex-wrap gap-1.5",children:[g&&s.jsx("span",{className:"chip-accent capitalize",children:g}),y?.slice(0,3).map(P=>s.jsx("span",{className:"chip",children:P},P)),(y?.length??0)>3&&s.jsxs("span",{className:"text-[10px] text-fg-muted self-center",children:["+",(y?.length??0)-3]})]}),(()=>{const P=X??(O?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(P4,{rating:x}),s.jsx("span",{className:"text-fg-muted",children:w>0?`(${Mo(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"})}),Mo(C)]})]}));return!P&&!V?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:_e=>_e.stopPropagation(),children:[P&&s.jsx("div",{className:"min-w-0 flex items-center gap-2",children:P}),V&&s.jsx("div",{className:"flex flex-wrap items-center gap-2 justify-end",children:V})]})})()]})]})}function Ar({children:e,maxCardWidth:t=400,gap:n="1rem",className:r=""}){const o=k.useRef(null),[l,c]=k.useState(0);k.useEffect(()=>{const h=o.current;if(!h)return;c(h.clientWidth);const g=new ResizeObserver(y=>{for(const x of y)c(x.contentRect.width)});return g.observe(h),()=>g.disconnect()},[]);const d=Math.max(1,Math.ceil((l||t)/t)),m=k.Children.toArray(e),f=Array.from({length:d},()=>[]);return m.forEach((h,g)=>{f[g%d].push(h)}),s.jsx("div",{ref:o,className:`flex items-start ${r}`,style:{gap:n},children:f.map((h,g)=>s.jsx("div",{className:"flex flex-col flex-1 min-w-0",style:{gap:n,maxWidth:t},children:h},g))})}function OW(e){const t=e.indexOf(".markus/builder-artifacts/");return t>=0?"~/"+e.slice(t):e}const DW=[{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 IW(){const[e,t]=k.useState(()=>{const r=window.location.hash.slice(1).split("/");return fc(r[0])===de.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("/");fc(o[0])===de.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 l6="markus_builder_shared_map";function PW(){try{const e=localStorage.getItem(l6);if(!e)return new Map;const t=JSON.parse(e);return new Map(Object.entries(t))}catch{return new Map}}function Ld(e){try{localStorage.setItem(l6,JSON.stringify(Object.fromEntries(e)))}catch{}}function c6({authUser:e}={}){const{t}=ft(["builder","common"]),n=Uo(),r=IW(),[o,l]=k.useState([]),[c,d]=k.useState([]),[m,f]=k.useState(!1),[h,g]=k.useState("all"),[y,x]=k.useState(null),[w,C]=k.useState(new Map),[T,S]=k.useState(null),[E,j]=k.useState(null),[L,I]=k.useState(null),[O,F]=k.useState(PW),[V,X]=k.useState(null),[z,G]=k.useState(null),[se,ee]=k.useState(null),[q,re]=k.useState(null),[B,J]=k.useState(null),[fe,Se]=k.useState("creations"),[U,W]=k.useState([]),[pe,P]=k.useState(""),[_e,He]=k.useState([]),[Pe,Ge]=k.useState(!1),[ct,mt]=k.useState("all"),Ct=k.useCallback(()=>{f(!0),Promise.all([(Si(Tr.builderArtifacts)??Ee.builder.artifacts.list()).then(ue=>ue?.artifacts??[]).catch(()=>[]),(Si(Tr.builderAgents)??Ee.agents.list()).then(ue=>ue?.agents??[]).catch(()=>[]),(Si(Tr.builderHubMyItems)??lt.myItems()).then(ue=>ue?.items??[]).catch(()=>[]),(Si(Tr.builderInstalled)??Ee.builder.artifacts.installed()).then(ue=>ue?.installed??{}).catch(()=>({}))]).then(([ue,tt,st,ye])=>{if(d(ue),l(tt),st.length>0){const Ae=new Map;for(const oe of st){const H=oe.itemType==="agent"?"agent":oe.itemType==="team"?"team":"skill";for(const te of ue)te.type===H&&(oe.slug===te.name||oe.name===(te.meta.displayName||te.meta.name||te.name))&&Ae.set(`${te.type}/${te.name}`,{id:oe.id,name:oe.name,slug:oe.slug||te.name,version:oe.version||"1.0.0",visibility:oe.visibility??"public",moderationStatus:oe.moderationStatus,pendingReview:oe.pendingReview})}Ae.size>0&&F(oe=>{const H=new Map(oe);for(const[te,Ne]of Ae)H.set(te,Ne);return Ld(H),H})}const je=new Map;for(const Ae of ue){const oe=`${Ae.type}/${Ae.name}`,H=ye[oe];H&&je.set(oe,{agentId:H.agentId,agentIds:H.agentIds,teamId:H.teamId})}C(je)}).finally(()=>f(!1))},[]);k.useEffect(()=>{Ct();const ue=tt=>{tt.detail?.page===de.BUILDER&&Ct()};return window.addEventListener("markus:navigate",ue),()=>window.removeEventListener("markus:navigate",ue)},[Ct]);const Mt=ue=>{const tt=o.find(st=>st.role==="Secretary"||st.name==="Secretary");tt?it.navigate(de.TEAM,{agentId:tt.id,prefillMessage:ue}):it.navigate(de.TEAM,{prefillMessage:ue})},Pt=async ue=>{const tt=`${ue.type}/${ue.name}`;if(!w.has(tt)){x({key:tt,action:"install"});try{const st=await Ee.builder.artifacts.install(ue.type,ue.name),ye={};st.agent&&typeof st.agent=="object"&&(ye.agentId=st.agent.id),st.team&&typeof st.team=="object"&&(ye.teamId=st.team.id),Array.isArray(st.agents)&&(ye.agentIds=st.agents.map(je=>je.id)),C(je=>new Map(je).set(tt,ye)),window.dispatchEvent(new CustomEvent("markus:data-changed"))}catch(st){console.error("Install failed:",st),G({title:t("common:install"),message:t("installFailed",{error:String(st)}),variant:"danger"})}finally{x(null)}}},Kt=async ue=>{const tt=`${ue.type}/${ue.name}`;if(w.has(tt)){x({key:tt,action:"uninstall"});try{await Ee.builder.artifacts.uninstall(ue.type,ue.name),C(st=>{const ye=new Map(st);return ye.delete(tt),ye}),window.dispatchEvent(new CustomEvent("markus:data-changed"))}catch(st){console.error("Uninstall failed:",st),G({title:t("common:uninstall"),message:t("uninstallFailed",{error:String(st)}),variant:"danger"})}finally{x(null)}}},yt=async(ue,tt)=>{const st=`${ue.type}/${ue.name}`;x({key:st,action:"share"});try{const ye=await Ee.builder.artifacts.ensureSlugSafe(ue.type,ue.name,ue.meta.displayName||ue.meta.name||ue.name),je=ye.name,Ae=ye.slug||xc(je);if(!Ae)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 oe=`${ue.type}/${je}`;ye.converted&&(d(le=>le.map(Oe=>Oe.type===ue.type&&Oe.name===ue.name?{...Oe,name:je,path:ye.path,meta:{...Oe.meta,name:je,displayName:ye.displayName??Oe.meta.displayName??ue.name}}:Oe)),F(le=>{const Oe=new Map(le),ge=Oe.get(st);return ge&&(Oe.delete(st),Oe.set(oe,{...ge,slug:Ae,name:ye.displayName??ge.name})),Ld(Oe),Oe}),C(le=>{const Oe=new Map(le),ge=Oe.get(st);return ge&&(Oe.delete(st),Oe.set(oe,ge)),Oe}));const H=await Ee.builder.artifacts.get(ue.type,je);let te={...ue.meta,name:je,displayName:ye.displayName??ue.meta.displayName??ue.name};try{const le=H.files?.[`${ue.type}.json`]??H.files?.["agent.json"]??H.files?.["team.json"]??H.files?.["skill.json"];le&&(te={...JSON.parse(le),...te,name:je,displayName:te.displayName})}catch{}const Ne=te.displayName||te.name||je,Re=te.description||"",$e=te.category||"general",Q=Array.isArray(te.tags)?te.tags:[];let Z=te.icon||void 0;const be=te.version||"1.0.0";if(Z&&!Z.startsWith("http")&&/\.(png|jpe?g|gif|webp|svg)$/i.test(Z)){const le=Z.split("/").pop()??Z;try{const Oe=await fetch(`/api/builder/artifacts/${ue.type}s/${encodeURIComponent(je)}/images/${encodeURIComponent(le)}`);if(Oe.ok){const ge=await Oe.blob(),Ve=new File([ge],le,{type:ge.type}),Qe=await lt.uploadImage(Ve);Qe?.url&&(Z=Qe.url)}}catch{}}let Ke;const Ie=[],Ye=Array.isArray(te.screenshots)?te.screenshots:[];for(let le=0;le<Ye.length;le++){const Oe=Ye[le],ge=Oe.split("/").pop()??Oe;try{const Ve=await fetch(`/api/builder/artifacts/${ue.type}s/${encodeURIComponent(je)}/images/${encodeURIComponent(ge)}`);if(Ve.ok){const Qe=await Ve.blob(),K=new File([Qe],ge,{type:Qe.type}),ce=await lt.uploadImage(K);ce?.url&&(Ie.push({url:ce.url,alt:ge,order:le}),(le===0||te.thumbnail===Oe)&&(Ke=ce.url))}}catch{}}const M=await lt.publishViaProxy({itemType:ue.type==="team"?"team":ue.type==="skill"?"skill":"agent",name:Ne,slug:Ae,description:Re,category:$e,tags:Q,icon:Z,version:be,config:{...te,name:je,displayName:Ne},files:H.files&&Object.keys(H.files).length>0?H.files:void 0,thumbnailUrl:Ke,images:Ie.length>0?Ie:void 0,priceCents:tt?.priceCents,donationsEnabled:tt?.donationsEnabled,visibility:tt?.visibility,orgId:tt?.orgId});M.id&&(F(Oe=>{const ge=new Map(Oe);return ge.set(oe,{id:M.id,name:Ne,slug:M.slug??Ae,version:be,visibility:M.visibility??tt?.visibility??"public",moderationStatus:M.moderationStatus,pendingReview:M.pendingReview}),Ld(ge),ge}),(M.visibility??tt?.visibility??"public")!=="org"&&(M.moderationStatus==="pending"||M.pendingReview)?G({title:t("common:share"),message:ye.converted?t("share.convertedAndSubmitted",{previous:ue.name,slug:Ae}):M.updated?t("share.updateSubmitted"):t("share.submittedForReview"),variant:"primary"}):ye.converted&&G({title:t("common:share"),message:t("share.convertedSlug",{previous:ue.name,slug:Ae}),variant:"primary"}))}catch(ye){console.error("Share failed:",ye),G({title:t("common:share"),message:t("shareFailed",{error:ye instanceof Error?ye.message:String(ye)}),variant:"danger"})}finally{x(null)}},Ue=async()=>{if(!V)return;const{key:ue}=V,tt=O.get(ue);if(X(null),!tt)return;const st=tt.id;x({key:ue,action:"hubDelete"});try{await lt.deleteItem(st),F(ye=>{const je=new Map(ye);return je.delete(ue),Ld(je),je})}catch(ye){console.error("Hub delete failed:",ye),G({title:t("unshare"),message:t("hubDeleteFailed",{error:String(ye)}),variant:"danger"})}finally{x(null)}},dt=async()=>{if(!T)return;const ue=T,tt=`${ue.type}/${ue.name}`;S(null),x({key:tt,action:"delete"});try{await Ee.builder.artifacts.delete(ue.type,ue.name),d(st=>st.filter(ye=>!(ye.type===ue.type&&ye.name===ue.name))),C(st=>{const ye=new Map(st);return ye.delete(tt),ye}),window.dispatchEvent(new CustomEvent("markus:data-changed"))}catch(st){console.error("Delete failed:",st)}finally{x(null)}},Nt=h==="all"?c:c.filter(ue=>ue.type===h);k.useEffect(()=>{fe!=="orgAssets"||U.length>0||lt.myOrgs().then(ue=>{W(ue.memberships),ue.memberships.length>0&&!pe&&P(ue.memberships[0].id)}).catch(()=>{})},[fe,U.length,pe]),k.useEffect(()=>{fe!=="orgAssets"||!pe||(Ge(!0),lt.browseItems({orgId:pe,limit:100}).then(ue=>He(ue.items??[])).catch(()=>He([])).finally(()=>Ge(!1)))},[fe,pe]);const bt=ct==="all"?_e:_e.filter(ue=>ue.itemType===ct),Lt=ue=>{history.pushState(null,"",Ti(de.BUILDER,`${ue.type}/${encodeURIComponent(ue.name)}`)),window.dispatchEvent(new HashChangeEvent("hashchange"))};return r?s.jsx(Mi,{type:r.type,name:r.name,authUser:e,onBack:()=>{history.pushState(null,"",Ti(de.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:DW.map(ue=>{const tt=t(`prompts.${ue.id}Prompt`),st=t(`prompts.${ue.id}Examples`,{returnObjects:!0}),ye=Array.isArray(st)?st:[];return s.jsx("button",{onClick:()=>Mt(tt),className:`group text-left w-full rounded-xl border ${ue.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 ${ue.bgColor} flex items-center justify-center shrink-0`,children:ue.icon}),s.jsxs("div",{className:"flex-1 min-w-0",children:[s.jsx("h3",{className:`text-sm font-semibold bg-gradient-to-r ${ue.color} bg-clip-text text-transparent`,children:t(`prompts.${ue.id}`)}),s.jsx("p",{className:"text-[11px] text-fg-tertiary mt-1 leading-relaxed",children:t(`prompts.${ue.id}Desc`)}),ye.length>0&&s.jsx("div",{className:"mt-2 flex flex-wrap gap-1.5",children:ye.slice(0,2).map((je,Ae)=>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:oe=>{oe.stopPropagation(),Mt(tt+je)},children:["“",je,"”"]},Ae))})]})]})},ue.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:()=>Se("creations"),className:`text-sm font-semibold transition-colors ${fe==="creations"?"text-fg-primary":"text-fg-tertiary hover:text-fg-secondary"}`,children:t("myCreations.title")}),s.jsx("button",{onClick:()=>Se("orgAssets"),className:`text-sm font-semibold transition-colors ${fe==="orgAssets"?"text-fg-primary":"text-fg-tertiary hover:text-fg-secondary"}`,children:t("orgAssets.title")})]}),fe==="creations"&&s.jsx("div",{className:"flex gap-1.5",children:["all","agent","team","skill"].map(ue=>s.jsx("button",{onClick:()=>g(ue),className:`text-xs px-2.5 py-1 rounded-lg transition-colors ${h===ue?"bg-brand-600 text-white":"text-fg-tertiary hover:text-fg-secondary hover:bg-surface-elevated"}`,children:t(ue==="all"?"myCreations.filterAll":ue==="agent"?"myCreations.filterAgents":ue==="team"?"myCreations.filterTeams":"myCreations.filterSkills")},ue))}),fe==="orgAssets"&&s.jsx("div",{className:"flex gap-1.5",children:["all","agent","team","skill"].map(ue=>s.jsx("button",{onClick:()=>mt(ue),className:`text-xs px-2.5 py-1 rounded-lg transition-colors ${ct===ue?"bg-brand-600 text-white":"text-fg-tertiary hover:text-fg-secondary hover:bg-surface-elevated"}`,children:t(ue==="all"?"myCreations.filterAll":ue==="agent"?"myCreations.filterAgents":ue==="team"?"myCreations.filterTeams":"myCreations.filterSkills")},ue))})]})}),fe==="orgAssets"&&U.length>0&&s.jsx("div",{className:"flex gap-2 mb-3 overflow-x-auto pb-1",children:U.map(ue=>s.jsx("button",{onClick:()=>P(ue.id),className:`text-xs px-3 py-1.5 rounded-full whitespace-nowrap border transition-colors ${pe===ue.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:ue.name},ue.id))}),fe==="orgAssets"&&(U.length===0&&!Pe?s.jsx("div",{className:"text-center py-12",children:s.jsx("div",{className:"text-fg-tertiary text-sm",children:t("orgAssets.noOrgs")})}):Pe?s.jsx("div",{className:"text-center text-fg-tertiary py-12 text-sm",children:t("orgAssets.loading")}):bt.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(Ar,{children:bt.map(ue=>{const tt=ue.author?.username&&ue.slug?`${lt.getUrl()}/@${encodeURIComponent(ue.author.username)}/${encodeURIComponent(ue.slug)}`:null;return s.jsx(ia,{type:ue.itemType,name:ue.name,description:ue.description,seed:ue.slug||ue.id||ue.name,icon:ue.icon,cover:ue.thumbnailUrl,hubBase:lt.getUrl(),author:ue.author,version:ue.version,rating:parseFloat(ue.avgRating)||0,ratingCount:ue.ratingCount,downloadCount:ue.downloadCount,actions:tt?s.jsxs("a",{href:tt,target:"_blank",rel:"noopener noreferrer",onClick:st=>{st.stopPropagation(),yc()&&(st.preventDefault(),_i(tt))},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},ue.id)})})),fe==="creations"&&(m&&c.length===0?s.jsx("div",{className:"text-center text-fg-tertiary py-12 text-sm",children:t("myCreations.loadingArtifacts")}):Nt.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(Ar,{children:Nt.map(ue=>{const tt=ue.meta.displayName||ue.meta.name||ue.name,st=ue.meta.description||"",ye=`${ue.type}/${ue.name}`,je=y?.key===ye?y.action:null,Ae=O.get(ye),oe=ue.meta.version||"1.0.0",H=!!Ae,te=H&&Ae.version!==oe,Ne=()=>{const Ie=lt.getUser();return!Ae||!Ie?null:`${lt.getUrl()}/@${encodeURIComponent(Ie.username)}/${encodeURIComponent(Ae.slug)}`},Re=H&&(Ae?.moderationStatus==="pending"||Ae?.moderationStatus==="rejected"||!!Ae?.pendingReview),$e=s.jsxs("div",{className:"flex items-center gap-1.5 justify-end",onClick:Ie=>Ie.stopPropagation(),children:[w.has(ye)?s.jsxs("button",{onClick:()=>I(ue),disabled:!!je,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(je==="uninstall"?"common:uninstalling":"common:uninstall")]}):s.jsxs("button",{onClick:()=>j(ue),disabled:!!je,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(je==="install"?"common:installing":"common:install")]}),H&&Re?Ae?.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")]}):Ae?.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")]}):H?s.jsxs(s.Fragment,{children:[te&&s.jsxs("button",{onClick:()=>{const Ie=Ae?.visibility??"public";yt(ue,{visibility:Ie})},disabled:!!je,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"})]}),je==="share"?t("common:sharing"):t("share.updateVersion",{version:oe})]}),s.jsxs("a",{href:Ne()??"#",target:"_blank",rel:"noopener noreferrer",onClick:Ie=>{const Ye=Ne();yc()&&Ye&&(Ie.preventDefault(),_i(Ye))},className:`text-xs px-3 py-1.5 rounded-lg border transition-colors inline-flex items-center gap-1 ${Ae?.visibility==="org"?"border-blue-500/30 text-blue-500 hover:text-blue-400 hover:border-blue-400/40":Ae?.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:[Ae?.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"})]}):Ae?.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"})]}),Ae?.visibility==="org"?t("visibility.sharedOrg"):Ae?.visibility==="unlisted"?t("visibility.sharedUnlisted"):t("visibility.shared")]}),s.jsxs("button",{onClick:()=>X({key:ye,name:tt}),disabled:!!je,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(ue.meta.screenshots)&&ue.meta.screenshots.length>0?J(ue):ee(ue)},disabled:!!je,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(je==="share"?"common:sharing":"common:share")]})]}),Q=s.jsx("button",{onClick:()=>S(ue),disabled:!!je,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"})]})}),Z=ue.meta.icon,Ke=!!Z&&/\.(png|jpe?g|gif|webp|svg)$/i.test(Z)?Z.startsWith("http")||Z.startsWith("/")?Z:`/api/builder/artifacts/${ue.type}s/${encodeURIComponent(ue.name)}/images/${encodeURIComponent(Z.split("/").pop()??"")}?v=${ue.updatedAt??""}`:Z;return s.jsx(ia,{type:ue.type,name:tt,description:st,seed:ye,icon:Ke,version:oe,footerLeft:s.jsxs("span",{className:"flex items-center gap-2 text-[10px] text-fg-tertiary min-w-0",children:[s.jsx("button",{onClick:Ie=>{Ie.stopPropagation(),Ee.system.openPath(ue.path).catch(()=>{})},className:"hover:text-fg-secondary transition-colors truncate min-w-0",title:ue.path,children:OW(ue.path)}),s.jsx("span",{className:"shrink-0",children:"·"}),s.jsx("span",{className:"shrink-0",children:new Date(ue.updatedAt).toLocaleDateString()})]}),headerAction:Q,actions:$e,onClick:()=>Lt(ue)},ye)})})),E&&s.jsx(dr,{variant:"primary",title:t("confirmInstall"),message:t("confirmInstallMsg",{name:E.meta.displayName||E.meta.name||E.name}),confirmLabel:t("common:install"),onConfirm:()=>{const ue=E;j(null),Pt(ue)},onCancel:()=>j(null)}),L&&s.jsx(dr,{variant:"primary",title:t("confirmUninstall"),message:t("confirmUninstallMsg",{name:L.meta.displayName||L.meta.name||L.name}),confirmLabel:t("common:uninstall"),onConfirm:()=>{const ue=L;I(null),Kt(ue)},onCancel:()=>I(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:dt,onCancel:()=>S(null)}),V&&s.jsx(dr,{title:t("confirmUnshare"),message:t("removeFromHub",{name:V.name}),confirmLabel:t("unshare"),onConfirm:()=>{Ue()},onCancel:()=>X(null)}),z&&s.jsx(dr,{alertOnly:!0,variant:z.variant??"primary",title:z.title,message:z.message,onConfirm:()=>G(null),onCancel:()=>G(null)}),se&&s.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/60 backdrop-blur-sm",onClick:()=>ee(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:ue=>ue.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 ue=se;ee(null),J(ue)},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 ue=se;ee(null),Lt(ue)},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")})]})]})}),q&&s.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/60 backdrop-blur-sm",onClick:()=>re(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:ue=>ue.stopPropagation(),children:s.jsx(BW,{isUpdate:O.has(`${q.type}/${q.name}`),onCancel:()=>re(null),onConfirm:(ue,tt)=>{const st=q;re(null),yt(st,{priceCents:tt>0?tt:void 0})}})})}),B&&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:ue=>ue.stopPropagation(),children:s.jsx(zW,{onCancel:()=>J(null),onConfirm:(ue,tt,st,ye)=>{const je=B;J(null),yt(je,{visibility:ue,orgId:tt,priceCents:st,donationsEnabled:ye})}})})})]})})}function zW({onCancel:e,onConfirm:t}){const{t:n}=ft(["builder","common"]),[r,o]=k.useState("public"),[l,c]=k.useState([]),[d,m]=k.useState(""),[f,h]=k.useState(!1),[g,y]=k.useState(0),[x,w]=k.useState(!1);k.useEffect(()=>{r==="org"&&l.length===0&&(h(!0),lt.myOrgs().then(S=>{c(S.memberships),S.memberships.length>0&&m(S.memberships[0].id)}).catch(()=>{}).finally(()=>h(!1)))},[r,l.length]);const C=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(S=>s.jsxs("label",{className:`flex items-center gap-3 p-3 rounded-lg border cursor-pointer transition-colors ${r===S.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===S.value,onChange:()=>o(S.value),className:"accent-brand-500"}),s.jsx("div",{className:"flex items-center gap-2 text-fg-secondary",children:S.icon}),s.jsxs("div",{children:[s.jsx("div",{className:"text-sm font-medium text-fg-primary",children:S.label}),s.jsx("div",{className:"text-[11px] text-fg-tertiary",children:S.desc})]})]},S.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")}),f?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:S=>m(S.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(S=>s.jsx("option",{value:S.id,children:S.name},S.id))})]}),C&&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:u6.map(S=>s.jsx("button",{type:"button",onClick:()=>y(S.cents),className:`text-sm px-2 py-2 rounded-lg border transition-colors ${g===S.cents?"border-brand-500 bg-brand-500/10 text-fg-primary":"border-border-default text-fg-secondary hover:border-gray-600"}`,children:S.label},S.cents))}),s.jsxs("label",{className:"flex items-center gap-2 cursor-pointer",children:[s.jsx("input",{type:"checkbox",checked:x,onChange:S=>w(S.target.checked),className:"accent-brand-500"}),s.jsx("span",{className:"text-xs text-fg-secondary",children:n("pricing.enableTips")})]})]}),C&&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,C&&g>0?g:void 0,C?x: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 u6=[{cents:0,label:"Free"},{cents:100,label:"$1"},{cents:500,label:"$5"},{cents:1e3,label:"$10"}];function BW({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:u6.map(c=>s.jsxs("label",{className:`flex items-center gap-3 p-3 rounded-lg border cursor-pointer transition-colors ${o===c.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===c.cents,onChange:()=>l(c.cents),className:"accent-brand-500"}),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.cents===0?r("shareMode.freeDesc"):r("shareMode.paidDesc")})]})]},c.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 $W=Object.freeze(Object.defineProperty({__proto__:null,AgentBuilder:c6},Symbol.toStringTag,{value:"Module"}));async function d6(e,t){if(!t)return{items:e,highlighted:null,missing:!1};const n=e.find(r=>r.id===t);if(n)return{items:[n,...e.filter(r=>r.id!==t)],highlighted:n,missing:!1};try{const{item:r}=await lt.getItem(t);return r?{items:[r,...e],highlighted:r,missing:!1}:{items:e,highlighted:null,missing:!0}}catch{return{items:e,highlighted:null,missing:!0}}}function HW(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,c=r[o]??0;if(l>c)return!0;if(l<c)return!1}return!1}function T0(e,t){const n=e.i18n?.[t];return n?.displayName||n?.name||e.name}function z4(e,t){return e.i18n?.[t]?.description||e.description}const UW={manager:"bg-brand-500/15 text-brand-500",worker:"bg-blue-500/15 text-blue-600"};function FW({authUser:e,highlightItemId:t,onHighlightDone:n}={}){const{t:r,i18n:o}=ft(["store","common"]),l=o.language,[c,d]=k.useState(""),[m,f]=k.useState([]),[h,g]=k.useState([]),[y,x]=k.useState(null),[w,C]=k.useState({}),[T,S]=k.useState(!1),[E,j]=k.useState(!0),[L,I]=k.useState(new Map),[O,F]=k.useState(new Set),[V,X]=k.useState(null),[z,G]=k.useState(null),se=k.useCallback(async()=>{try{const[re,B]=await Promise.all([Ee.builder.artifacts.list().catch(()=>({artifacts:[]})),Ee.builder.artifacts.installed().catch(()=>({installed:{}}))]),J=new Map;for(const fe of re.artifacts){if(fe.type!=="agent")continue;const Se=!!B.installed[`agent/${fe.name}`];J.set(fe.name,{installed:Se,localVersion:fe.meta.version||void 0,localUpdatedAt:fe.updatedAt})}I(J)}catch{}},[]),ee=k.useCallback(async()=>{j(!0);try{const re=c?lt.search({type:"agent",q:c,limit:50}):Si(Tr.hubAgents)??lt.search({type:"agent",limit:50}),B=new URLSearchParams;c&&B.set("q",c);const J=fetch("/api/templates?"+B.toString()).then(W=>W.json()).catch(()=>({templates:[]})),[fe,Se]=await Promise.all([re.catch(()=>({items:[],total:0})),J,se(),lt.isAuthenticated()?lt.purchases.mine().then(W=>F(new Set(W.purchases.map(pe=>pe.itemId)))).catch(()=>{}):Promise.resolve()]),U=await d6(fe?.items??[],t);g(U.items),f(Array.isArray(Se.templates)?Se.templates:[]),U.missing&&n?.()}catch{f([]),g([])}finally{j(!1)}},[c,se,t,n]);k.useEffect(()=>{ee()},[ee]),k.useEffect(()=>{if(!y){C({});return}fetch(`/api/templates/${encodeURIComponent(y.id)}/files`,{credentials:"include"}).then(re=>re.json()).then(re=>C(re.files??{})).catch(()=>C({}))},[y]);const q=async(re,B,J)=>{try{const fe=await fetch("/api/templates/instantiate",{method:"POST",headers:{"Content-Type":"application/json"},credentials:"include",body:JSON.stringify({templateId:re,name:B,orgId:"default",teamId:J})});if(!fe.ok)throw new Error(`Failed: ${fe.status}`);S(!1),x(null)}catch(fe){G({title:r("common:create",{defaultValue:"Create"}),message:`Failed to create agent: ${fe}`,variant:"danger"})}};if(V)return s.jsx(Mi,{type:V.type,name:V.name,onBack:()=>X(null)});if(y){const re={type:"agent",name:y.id,displayName:T0(y,l),version:y.version,description:z4(y,l),author:y.author,category:y.category,tags:y.tags,icon:y.icon,files:w,agent:{roleName:y.roleId,agentRole:y.agentRole==="manager"?"manager":"worker"},dependencies:{skills:y.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:y.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 ${UW[y.agentRole]??""}`,children:y.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:[y.skills.map(J=>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:J},J)),y.skills.length===0&&s.jsx("span",{className:"text-xs text-fg-tertiary italic",children:r("agentStore.noSkills")})]})]})]}),y.starterTasks&&y.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:y.starterTasks.map((J,fe)=>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 ${J.priority==="high"?"bg-red-400":J.priority==="medium"?"bg-amber-400":"bg-green-400"}`}),s.jsxs("div",{children:[s.jsx("div",{className:"text-sm text-fg-primary",children:J.title}),J.description&&s.jsx("div",{className:"text-xs text-fg-tertiary mt-0.5",children:J.description})]})]},fe))})]})]});return s.jsxs(s.Fragment,{children:[s.jsx(Mi,{type:"agent",name:y.id,onBack:()=>x(null),readOnly:!0,initialManifest:re,actionSlot:s.jsx("button",{onClick:()=>S(!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(B4,{template:y,lang:l,onClose:()=>S(!1),onHire:q}),z&&s.jsx(dr,{alertOnly:!0,variant:z.variant??"danger",title:z.title,message:z.message,onConfirm:()=>G(null),onCancel:()=>G(null)})]})}return s.jsxs("div",{className:"flex-1 overflow-hidden flex flex-col",children:[s.jsxs("div",{"data-electron-drag":!0,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:c,onChange:re=>d(re.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:E?s.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-4",children:Array.from({length:6}).map((re,B)=>s.jsx("div",{className:"h-56 rounded-2xl skeleton"},B))}):m.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:c?r("agentStore.noResults",{search:c}):r("agentStore.noAgents")}),s.jsx("div",{className:"text-fg-tertiary text-sm",children:r(c?"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(Ar,{columns:3,children:m.map(re=>s.jsx(ia,{type:"agent",name:T0(re,l),description:z4(re,l),seed:re.id,icon:re.icon,version:re.version,category:re.category,tags:re.tags,authorLabel:re.author,hideStats:!0,showTypeBadge:!1,cornerLabel:r("agentStore.builtin"),onClick:()=>x(re)},re.id))})]}),h.length>0&&s.jsxs("section",{children:[s.jsx("h3",{className:"section-title mb-3",children:r("agentStore.markusHub")}),s.jsx(Ar,{columns:3,children:h.map(re=>s.jsx(qW,{item:re,localInfo:L.get(Oc(re)),purchased:e0(re,O),onStatusChange:se,highlight:re.id===t,onHighlightDone:n,onViewDetail:B=>X({type:"agent",name:B})},re.id))})]})]})}),T&&y&&s.jsx(B4,{template:y,lang:l,onClose:()=>S(!1),onHire:q}),z&&s.jsx(dr,{alertOnly:!0,variant:z.variant??"danger",title:z.title,message:z.message,onConfirm:()=>G(null),onCancel:()=>G(null)})]})}function Oc(e,t){if(e.slug&&e.slug.trim())return e.slug.trim();const n=t&&typeof t.name=="string"?t.name.trim():"";return r0(n||e.name,"hub-pkg")}function Ni(e){return(async()=>{const t=await lt.download(e.id),n=t.name||e.name,r=t.config??{},o=Oc(e,r),l=t.itemType==="team"?"team":t.itemType==="skill"?"skill":"agent",c={type:"hub",hubItemId:e.id},d=(t.version||e.version||(typeof r.version=="string"?r.version:"")||"").trim()||void 0;if(t.files&&Object.keys(t.files).length>0)await Ee.builder.artifacts.import(l,o,t.files,c,d);else{const m={...r,...d?{version:d}:{},name:o,displayName:r.displayName||n,description:e.description,source:c};await Ee.builder.artifacts.save(l,m)}return await Ee.builder.artifacts.install(l,o),window.dispatchEvent(new CustomEvent("markus:data-changed")),n})()}async function Qg(e,t){t("checking"),await lt.ensureAuth();const n=await lt.purchases.checkout(e.id);if(n.alreadyOwned)return t("installing"),await Ni(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 Ni(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 c=setInterval(async()=>{const d=r?r.closed:!1;try{if((await lt.purchases.checkout(e.id)).alreadyOwned){clearInterval(c),t("installing");try{await Ni(e),o("installed")}catch(f){l(f)}return}}catch{}if(d){clearInterval(c);try{if((await lt.purchases.checkout(e.id)).alreadyOwned){t("installing"),await Ni(e),o("installed");return}}catch{}o("cancelled")}},2e3)})}function qW({item:e,localInfo:t,purchased:n,onStatusChange:r,highlight:o,onHighlightDone:l,onViewDetail:c}){const{t:d}=ft(["store"]),[m,f]=k.useState(!1),[h,g]=k.useState(""),y=k.useRef(null),[x,w]=k.useState(!1);k.useEffect(()=>{if(o&&y.current){y.current.scrollIntoView({behavior:"smooth",block:"center"}),w(!0);const V=setTimeout(()=>{w(!1)},4e3);return()=>clearTimeout(V)}},[o,l]);const C=t?.installed??!1,T=C&&e.version&&t?.localVersion&&HW(e.version,t.localVersion),S=(e.priceCents??0)>0,E=async V=>{if(V.stopPropagation(),!m){f(!0),g("");try{await Ni(e),g(T?d("card.upgraded"):d("card.installed")+"!"),r()}catch(X){const z=X instanceof Error?X.message:"";z.includes("402")||z.includes("Purchase required")?g(d("card.purchaseRequired")):g(d("card.failed"))}finally{f(!1)}}},j=async V=>{if(V.stopPropagation(),!m){f(!0),g("");try{await Qg(e,z=>{z==="checkout_opened"?g(d("card.waitingPurchase","Waiting for purchase...")):z==="installing"&&g(d("card.installing"))})==="installed"?(g(d("card.installed")+"!"),r()):g("")}catch(X){g(X instanceof Error?X.message:d("card.failed"))}finally{f(!1)}}},L=S?`$${((e.priceCents??0)/100).toFixed(2)}`:null,I=e.slug&&e.author?.username?`${lt.getUrl()}/@${encodeURIComponent(e.author.username)}/${encodeURIComponent(e.slug)}`:null,O=()=>{C&&c?c(Oc(e)):I&&window.open(I,"_blank","noopener,noreferrer")},F=s.jsxs(s.Fragment,{children:[T?s.jsx("button",{onClick:V=>{E(V)},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})}):C?s.jsxs("button",{onClick:V=>{E(V)},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}`:""]}):S&&!n?s.jsx("button",{onClick:V=>{j(V)},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?h||d("card.installing"):s.jsxs(s.Fragment,{children:[d("card.buy","Buy")," ",L]})}):s.jsx("button",{onClick:V=>{E(V)},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")}),h&&!(S&&!n)&&s.jsx("span",{className:`text-[10px] ${h===d("card.failed")||h===d("card.purchaseRequired")?"text-red-500":"text-green-600"}`,children:h})]});return s.jsx("div",{ref:y,className:x?"animate-pulse":"",children:s.jsx(ia,{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:C,glowing:x,onClick:O,actions:F})})}function B4({template:e,lang:t,onClose:n,onHire:r}){const{t:o}=ft(["store"]),[l,c]=k.useState(`${T0(e,t)} Agent`),[d,m]=k.useState(""),[f,h]=k.useState([]),[g,y]=k.useState(!1);k.useEffect(()=>{fetch("/api/teams",{credentials:"include"}).then(w=>w.json()).then(w=>h(w.teams??[])).catch(()=>{})},[]);const x=async()=>{if(l.trim()){y(!0);try{await r(e.id,l.trim(),d||void 0)}finally{y(!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:T0(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=>c(w.target.value),className:"input-field",autoFocus:!0})]}),f.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")}),f.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:x,disabled:!l.trim()||g,className:"btn-primary",children:o(g?"hireModal.creating_progress":"hireModal.create")})]})]})})}function ih(e,t){const n=e.i18n?.[t];return n?.displayName||n?.name||e.name}function $4(e,t){return e.i18n?.[t]?.description||e.description}function H4(e,t,n){return e.i18n?.[n]?.members?.[t]||t}function GW(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,c=r[o]??0;if(l>c)return!0;if(l<c)return!1}return!1}function VW({highlightItemId:e,onHighlightDone:t}={}){const{t:n,i18n:r}=ft(["store","common"]),o=r.language,[l,c]=k.useState(""),[d,m]=k.useState([]),[f,h]=k.useState([]),[g,y]=k.useState(null),[x,w]=k.useState({}),[C,T]=k.useState(!0),[S,E]=k.useState(!1),[j,L]=k.useState(null),[I,O]=k.useState(new Map),[F,V]=k.useState(new Set),[X,z]=k.useState(null),G=k.useCallback(async()=>{try{const[q,re]=await Promise.all([Ee.builder.artifacts.list().catch(()=>({artifacts:[]})),Ee.builder.artifacts.installed().catch(()=>({installed:{}}))]),B=new Map;for(const J of q.artifacts){if(J.type!=="team")continue;const fe=!!re.installed[`team/${J.name}`];B.set(J.name,{installed:fe,localVersion:J.meta.version||void 0,localUpdatedAt:J.updatedAt})}O(B)}catch{}},[]),se=k.useCallback(async()=>{T(!0);try{const q=l?lt.search({type:"team",q:l,limit:50}):Si(Tr.hubTeams)??lt.search({type:"team",limit:50}),[re,B]=await Promise.all([q.catch(()=>({items:[],total:0})),Ee.teamTemplates.list(l||void 0).catch(()=>({templates:[]})),G(),lt.isAuthenticated()?lt.purchases.mine().then(fe=>V(new Set(fe.purchases.map(Se=>Se.itemId)))).catch(()=>{}):Promise.resolve()]),J=await d6(re?.items??[],e);h(J.items),m(B?.templates??[]),J.missing&&t?.()}catch{m([]),h([])}finally{T(!1)}},[l,G,e,t]);k.useEffect(()=>{se()},[se]),k.useEffect(()=>{if(!g){w({});return}fetch(`/api/team-templates/${encodeURIComponent(g.id)}/files`,{credentials:"include"}).then(q=>q.json()).then(q=>w(q.files??{})).catch(()=>w({}))},[g]);const ee=async q=>{E(!0),L(null);try{const B=(await Ee.teams.create(q.name,q.description)).team.id;let J,fe=0;const Se=[];for(const W of q.members){const pe=W.count??1;for(let P=0;P<pe;P++){const _e=W.name??`${q.name} Agent ${P+1}`,He=pe>1?`${_e} ${P+1}`:_e,Pe=W.roleName??W.templateId;try{const Ge=await fetch("/api/agents",{method:"POST",headers:{"Content-Type":"application/json"},credentials:"include",body:JSON.stringify({name:He,...Pe?{roleName:Pe}:{},orgId:"default",teamId:B,agentRole:W.role??"worker",skills:W.skills??[]})});if(Ge.ok){fe++;const ct=await Ge.json();W.role==="manager"&&!J&&(J=ct.agent?.id)}else{const ct=await Ge.json().catch(()=>({error:`HTTP ${Ge.status}`}));Se.push(`${He}: ${ct.error??Ge.statusText}`)}}catch(Ge){Se.push(`${He}: ${String(Ge)}`)}}}J&&await Ee.teams.update(B,{managerId:J,managerType:"agent"}).catch(()=>{});const U=Se.length>0?` (${Se.length} failed: ${Se[0]})`:"";L({ok:fe>0,message:`Team "${ih(q,o)}" deployed with ${fe} agent(s)${U}`})}catch(re){L({ok:!1,message:`Failed: ${re}`})}finally{E(!1)}};if(X)return s.jsx(Mi,{type:X.type,name:X.name,onBack:()=>z(null)});if(g){const q={...x};g.announcements&&(q["ANNOUNCEMENT.md"]=g.announcements),g.norms&&(q["NORMS.md"]=g.norms);const re={type:"team",name:g.id,displayName:ih(g,o),version:g.version,description:$4(g,o),author:g.author,category:g.category??"general",tags:g.tags??[],files:q,team:{members:g.members.map(J=>({name:H4(g,J.name??J.roleName??J.templateId??"Agent",o),role:J.role??"worker",roleName:J.roleName??J.templateId,count:J.count??1,skills:J.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((J,fe)=>{const Se=H4(g,J.name??J.roleName??J.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 ${J.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:(Se[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:Se}),s.jsx("span",{className:`px-1.5 py-0.5 rounded text-[10px] capitalize font-medium ${J.role==="manager"?"bg-amber-500/15 text-amber-400":"bg-blue-500/15 text-blue-400"}`,children:J.role??"worker"}),(J.count??1)>1&&s.jsxs("span",{className:"text-[10px] text-fg-muted",children:["×",J.count]})]}),(J.roleName||J.templateId)&&s.jsx("div",{className:"text-[10px] text-fg-tertiary font-mono mt-0.5",children:J.roleName??J.templateId})]}),J.skills&&J.skills.length>0&&s.jsxs("div",{className:"flex flex-wrap gap-1 shrink-0",children:[J.skills.slice(0,3).map(U=>s.jsx("span",{className:"px-1.5 py-0.5 text-[9px] bg-surface-elevated text-fg-muted rounded border border-border-default",children:U},U)),J.skills.length>3&&s.jsxs("span",{className:"text-[9px] text-fg-muted",children:["+",J.skills.length-3]})]})]},fe)})})]});return s.jsx(s.Fragment,{children:s.jsx(Mi,{type:"team",name:g.id,onBack:()=>{y(null),L(null)},readOnly:!0,initialManifest:re,contentSlot:B,actionSlot:s.jsxs(s.Fragment,{children:[j&&s.jsx("span",{className:`text-xs ${j.ok?"text-green-500":"text-red-500"}`,children:j.message}),s.jsx("button",{onClick:()=>{ee(g)},disabled:S,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(S?"teamStore.deploying":"teamStore.deployTeam")})]})})})}return s.jsxs("div",{className:"flex-1 overflow-hidden flex flex-col",children:[s.jsxs("div",{"data-electron-drag":!0,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:q=>c(q.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:C?s.jsx("div",{className:"grid grid-cols-1 lg:grid-cols-2 gap-4",children:Array.from({length:4}).map((q,re)=>s.jsx("div",{className:"h-56 rounded-2xl skeleton"},re))}):d.length===0&&f.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(Ar,{columns:2,children:d.map(q=>s.jsx(ia,{type:"team",name:ih(q,o),description:$4(q,o),seed:q.id,icon:q.icon||"users",version:q.version,category:q.category,tags:q.tags,authorLabel:q.author,hideStats:!0,showTypeBadge:!1,cornerLabel:n("teamStore.builtin"),onClick:()=>y(q)},q.id))})]}),f.length>0&&s.jsxs("section",{children:[s.jsx("h3",{className:"section-title mb-3",children:n("teamStore.markusHub")}),s.jsx(Ar,{columns:2,children:f.map(q=>s.jsx(KW,{item:q,localInfo:I.get(Oc(q)),purchased:e0(q,F),onStatusChange:G,highlight:q.id===e,onHighlightDone:t,onViewDetail:re=>z({type:"team",name:re})},q.id))})]})]})})]})}function KW({item:e,localInfo:t,purchased:n,onStatusChange:r,highlight:o,onHighlightDone:l,onViewDetail:c}){const{t:d}=ft(["store"]),[m,f]=k.useState(!1),[h,g]=k.useState(""),y=k.useRef(null),[x,w]=k.useState(!1);k.useEffect(()=>{if(o&&y.current){y.current.scrollIntoView({behavior:"smooth",block:"center"}),w(!0);const V=setTimeout(()=>{w(!1)},4e3);return()=>clearTimeout(V)}},[o,l]);const C=t?.installed??!1,T=C&&e.version&&t?.localVersion&&GW(e.version,t.localVersion),S=(e.priceCents??0)>0,E=S?`$${((e.priceCents??0)/100).toFixed(2)}`:null,j=async V=>{if(V.stopPropagation(),!m){f(!0),g("");try{await Ni(e),g(T?d("card.upgraded"):d("card.installed")+"!"),r()}catch(X){const z=X instanceof Error?X.message:"";z.includes("402")||z.includes("Purchase required")?g(d("card.purchaseRequired")):g(d("card.failed"))}finally{f(!1)}}},L=async V=>{if(V.stopPropagation(),!m){f(!0),g("");try{await Qg(e,z=>{z==="checkout_opened"?g(d("card.waitingPurchase","Waiting for purchase...")):z==="installing"&&g(d("card.installing"))})==="installed"?(g(d("card.installed")+"!"),r()):g("")}catch(X){g(X instanceof Error?X.message:d("card.failed"))}finally{f(!1)}}},I=e.slug&&e.author?.username?`${lt.getUrl()}/@${encodeURIComponent(e.author.username)}/${encodeURIComponent(e.slug)}`:null,O=()=>{C&&c?c(Oc(e)):I&&window.open(I,"_blank","noopener,noreferrer")},F=s.jsxs(s.Fragment,{children:[T?s.jsx("button",{onClick:V=>{j(V)},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})}):C?s.jsxs("button",{onClick:V=>{j(V)},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}`:""]}):S&&!n?s.jsx("button",{onClick:V=>{L(V)},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?h||d("card.installing"):s.jsxs(s.Fragment,{children:[d("card.buy","Buy")," ",E]})}):s.jsx("button",{onClick:V=>{j(V)},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")}),h&&s.jsx("span",{className:`text-[10px] ${h===d("card.failed")||h===d("card.purchaseRequired")?"text-red-500":"text-green-600"}`,children:h})]});return s.jsx("div",{ref:y,className:x?"animate-pulse":"",children:s.jsx(ia,{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:C,glowing:x,onClick:O,actions:F})})}function oh(e,t){return e.i18n?.[t]?.displayName||e.name}function lh(e,t){return e.i18n?.[t]?.description||e.description||""}function m6(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,c=r[o]??0;if(l>c)return!0;if(l<c)return!1}return!1}const WW={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 YW({item:e,installedSkills:t,purchased:n,onMsg:r,onRefresh:o}){const{t:l}=ft(["store"]),[c,d]=k.useState(!1),m=e.name.toLowerCase().trim().replace(/\s+/g,"-").replace(/[\/\\:*?"<>|]+/g,"").replace(/-{2,}/g,"-").replace(/^-|-$/g,"")||"unnamed",f=t.find(S=>S.name===e.name||S.name===m||!!e.slug&&S.name===e.slug),h=!!f,g=h&&e.version&&f?.version&&m6(e.version,f.version),y=(e.priceCents??0)>0,[x,w]=k.useState(""),C=async()=>{if(!c){d(!0),w("");try{await Ni(e),r(g?`Upgraded ${e.name}`:`Installed ${e.name}`,"success"),o()}catch(S){const E=S instanceof Error?S.message:"";E.includes("402")||E.includes("Purchase required")?r(l("card.purchaseRequired"),"error"):r(l("card.failed"),"error")}finally{d(!1)}}},T=async()=>{if(!c){d(!0),w("");try{await Qg(e,E=>{E==="checkout_opened"?w(l("card.waitingPurchase","Waiting for purchase...")):E==="installing"&&w(l("card.installing"))})==="installed"&&(r(`Purchased & installed ${e.name}`,"success"),o()),w("")}catch(S){r(S instanceof Error?S.message:l("card.failed"),"error"),w("")}finally{d(!1)}}};if(g)return s.jsx("button",{onClick:()=>{C()},disabled:c,className:"px-2.5 py-1 text-[10px] bg-amber-600 hover:bg-amber-500 text-white rounded-lg disabled:opacity-50",children:c?l("card.upgrading"):l("card.upgrade",{version:e.version})});if(h)return s.jsxs("span",{className:"px-2.5 py-1 text-[10px] bg-surface-overlay text-fg-secondary rounded-lg",children:[l("card.installed"),f?.version?` (v${f.version})`:""]});if(y&&!n){const S=`$${((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:c,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:c?x||l("card.installing"):s.jsxs(s.Fragment,{children:[l("card.buy","Buy")," ",S]})})})}return s.jsx("button",{onClick:()=>{C()},disabled:c,className:"px-2.5 py-1 text-[10px] bg-brand-600 hover:bg-brand-500 text-white rounded-lg disabled:opacity-50",children:l(c?"card.installing":"card.install")})}function U4({item:e,installedSkills:t,purchased:n,onMsg:r,onRefresh:o,highlight:l,onHighlightDone:c,type:d="skill"}){const m=k.useRef(null),[f,h]=k.useState(!1);k.useEffect(()=>{if(l&&m.current){m.current.scrollIntoView({behavior:"smooth",block:"center"}),h(!0);const x=setTimeout(()=>{h(!1)},4e3);return()=>clearTimeout(x)}},[l,c]);const g=e.slug&&e.author?.username?`${lt.getUrl()}/@${encodeURIComponent(e.author.username)}/${encodeURIComponent(e.slug)}`:null,y=()=>{g&&window.open(g,"_blank","noopener,noreferrer")};return s.jsx("div",{ref:m,className:f?"animate-pulse":"",children:s.jsx(ia,{type:d,showTypeBadge:d!=="skill",name:e.name,description:e.description,seed:e.slug||e.name,icon:e.icon||Vd(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:y,actions:s.jsx(YW,{item:e,installedSkills:t,purchased:n,onMsg:r,onRefresh:o})})})}function XW({highlightItemId:e,onHighlightDone:t}={}){const{t:n,i18n:r}=ft(["store","common"]),o=r.language,l=Uo(),[c,d]=k.useState("skills"),[m,f]=k.useState(null),[h,g]=k.useState(new Set),[y,x]=k.useState([]),[w,C]=k.useState(null),[T,S]=k.useState([]),[E,j]=k.useState(0),[L,I]=k.useState(1),[O,F]=k.useState([]),[V,X]=k.useState(""),[z,G]=k.useState("score"),[se,ee]=k.useState(""),[q,re]=k.useState(!1),[B,J]=k.useState([]),[fe,Se]=k.useState(!1),[U,W]=k.useState([]),[pe,P]=k.useState(""),[_e,He]=k.useState(!1),[Pe,Ge]=k.useState([]),[ct,mt]=k.useState([]),[Ct,Mt]=k.useState(new Set),[Pt,Kt]=k.useState(!1),[yt,Ue]=k.useState(""),dt=[{id:"skills",labelKey:"skillStore.tabs.all"},{id:"skillhub",labelKey:"skillStore.tabs.skillhub"},{id:"skillssh",labelKey:"skillStore.tabs.skillssh"}],Nt=(H,te="success")=>{f({text:H,type:te}),setTimeout(()=>f(null),te==="error"?1e4:4e3)},bt=k.useCallback(async()=>{try{const H=await Ee.skills.list();x(H.skills)}catch{}},[]),Lt=k.useCallback(async()=>{Se(!0);try{const H=await Ee.skills.builtin();J(H.skills)}catch{}Se(!1)},[]),ue=k.useCallback(async H=>{re(!0);try{const te=await Ee.skills.registrySkillhub({q:H?.q,category:H?.category,page:H?.page??1,limit:24,sort:H?.sort??z});S(te.skills),j(te.total),te.categories?.length&&F(te.categories)}catch{}re(!1)},[z]),tt=k.useCallback(async H=>{He(!0);try{const te=await Ee.skills.registrySkillssh(H);W(te.skills)}catch{}He(!1)},[]),st=k.useCallback(async H=>{Kt(!0);try{const te=H?lt.search({type:"skill",q:H,limit:50}):Si(Tr.hubSkills)??lt.search({type:"skill",limit:50}),Ne=lt.search({subtype:"connector",q:H||void 0,limit:50}).catch(()=>({items:[]})),[Re,$e]=await Promise.all([te,Ne,lt.isAuthenticated()?lt.purchases.mine().then(be=>Mt(new Set(be.purchases.map(Ke=>Ke.itemId)))).catch(()=>{}):Promise.resolve()]);let Q=Re?.items??[],Z=$e?.items??[];if(e){const be=Q.some(Ie=>Ie.id===e),Ke=Z.some(Ie=>Ie.id===e);if(!be&&!Ke)try{const{item:Ie}=await lt.getItem(e);Ie?.subtype==="connector"?Z=[Ie,...Z]:Ie?Q=[Ie,...Q]:t?.()}catch{t?.()}else be&&(Q=[Q.find(Ye=>Ye.id===e),...Q.filter(Ye=>Ye.id!==e)]),Ke&&(Z=[Z.find(Ye=>Ye.id===e),...Z.filter(Ye=>Ye.id!==e)])}Ge(Q),mt(Z)}catch{}Kt(!1)},[e,t]);k.useEffect(()=>{bt(),Lt(),ue(),tt()},[]),k.useEffect(()=>{c==="skills"&&st(yt)},[c,yt,st]);const ye=async H=>{g(te=>new Set(te).add(H.name));try{const te=await Ee.skills.install({name:H.name,source:"skillhub",slug:H.slug,sourceUrl:H.homepage,description:H.description_zh??H.description,category:"custom",version:H.version});await bt(),Nt(`"${H.name}" installed (${te.method}) → ${te.path}`),window.dispatchEvent(new CustomEvent("markus:data-changed"))}catch{Nt(`Download failed for "${H.name}". You can try manually from: ${H.homepage}`,"error")}g(te=>{const Ne=new Set(te);return Ne.delete(H.name),Ne})},je=async H=>{g(te=>new Set(te).add(H.name));try{const te=await Ee.skills.install({name:H.name,source:"skillssh",sourceUrl:H.url,githubRepo:`${H.author}/${H.repo}`,githubSkillPath:H.name});await bt(),Nt(`"${H.name}" installed (${te.method}) → ${te.path}`),window.dispatchEvent(new CustomEvent("markus:data-changed"))}catch{Nt(`Download failed for "${H.name}". You can try manually from: ${H.url}`,"error")}g(te=>{const Ne=new Set(te);return Ne.delete(H.name),Ne})},Ae=async H=>{g(te=>new Set(te).add(H.name));try{const te=await Ee.skills.install({name:H.name,source:"builtin"});await bt(),await Lt(),Nt(`"${H.name}" installed (${te.method}) → ${te.path}`),window.dispatchEvent(new CustomEvent("markus:data-changed"))}catch(te){Nt(`Install failed for "${H.name}": ${te}`,"error")}g(te=>{const Ne=new Set(te);return Ne.delete(H.name),Ne})},oe=U.filter(H=>{if(!pe)return!0;const te=pe.toLowerCase();return H.name.toLowerCase().includes(te)||H.repo.toLowerCase().includes(te)});if(w){const H=w,te={};H.instructions&&(te["SKILL.md"]=H.instructions);const Ne={type:"skill",name:H.name,displayName:oh(H,o),version:H.version,description:lh(H,o),author:H.author??"",category:H.category??"general",tags:H.tags,files:te,skill:{skillFile:H.instructions?"SKILL.md":"",requiredPermissions:H.requiredPermissions,mcpServers:void 0,alwaysOn:!1}},Re=H.installed&&H.installedVersion&&m6(H.version,H.installedVersion)?s.jsx("button",{onClick:()=>{Ae(H)},disabled:h.has(H.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:h.has(H.name)?n("card.upgrading"):n("card.upgrade",{version:H.version})}):H.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"),H.installedVersion?` v${H.installedVersion}`:""]}):s.jsx("button",{onClick:()=>{Ae(H)},disabled:h.has(H.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:h.has(H.name)?n("card.installing"):n("card.install")}),$e=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:[H.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 ${WW[H.category]??"bg-gray-500/15 text-fg-secondary"}`,children:H.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:H.version})]}),H.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"})]}),H.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:"✓"})]})]})]}),(H.requiredPermissions.length>0||H.tags.length>0)&&s.jsxs("div",{className:"space-y-4",children:[H.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:H.requiredPermissions.map(Q=>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:Q},Q))})]}),H.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:H.tags.map(Q=>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:Q},Q))})]})]})]});return s.jsxs(s.Fragment,{children:[s.jsx(Mi,{type:"skill",name:H.name,onBack:()=>C(null),readOnly:!0,initialManifest:Ne,actionSlot:Re,contentSlot:$e}),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",{"data-electron-drag":!0,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:dt.map(H=>s.jsx("button",{onClick:()=>d(H.id),className:`px-3 py-1.5 text-xs rounded-lg transition-colors shrink-0 ${c===H.id?"bg-brand-600 text-white":"text-fg-secondary hover:text-fg-primary hover:bg-surface-elevated"}`,children:n(H.labelKey)},H.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}),c==="skills"&&(()=>{const H=yt.trim().toLowerCase(),te=H?B.filter($e=>oh($e,o).toLowerCase().includes(H)||lh($e,o).toLowerCase().includes(H)):B,Ne=fe&&Pt,Re=te.length===0&&Pe.length===0&&ct.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:yt,onChange:$e=>Ue($e.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"}`})}),Ne&&Re?s.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-4",children:Array.from({length:6}).map(($e,Q)=>s.jsx("div",{className:"h-56 rounded-2xl skeleton"},Q))}):Re?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:[te.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:te.length})})]}),s.jsx(Ar,{columns:3,children:te.map($e=>s.jsx(ia,{type:"skill",name:oh($e,o),description:lh($e,o),seed:$e.name,icon:Vd($e.name,$e.category),version:$e.version,category:$e.category,tags:$e.tags,authorLabel:$e.author||void 0,installed:$e.installed,hideStats:!0,showTypeBadge:!1,cornerLabel:$e.installed?void 0:n("skillStore.tabs.builtin"),onClick:()=>C($e)},$e.name))})]}),Pe.length>0&&s.jsxs("section",{children:[s.jsx("h3",{className:"section-title mb-3",children:n("skillStore.tabs.markusHub")}),s.jsx(Ar,{columns:3,children:Pe.map($e=>s.jsx(U4,{item:$e,installedSkills:y,purchased:e0($e,Ct),onMsg:Nt,onRefresh:()=>{bt(),st(yt)},highlight:$e.id===e,onHighlightDone:t},$e.id))})]}),ct.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(Ar,{columns:3,children:ct.map($e=>s.jsx(U4,{item:$e,type:"connector",installedSkills:y,purchased:e0($e,Ct),onMsg:Nt,onRefresh:()=>{bt(),st(yt)},highlight:$e.id===e,onHighlightDone:t},$e.id))})]})]})]})})(),c==="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:V,onChange:H=>{X(H.target.value),I(1),ue({q:se||void 0,category:H.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")}),O.map(H=>s.jsx("option",{value:H,children:H},H))]}),s.jsxs("select",{value:z,onChange:H=>{G(H.target.value),I(1),ue({q:se||void 0,category:V||void 0,page:1,sort:H.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:se,onChange:H=>ee(H.target.value),onKeyDown:H=>{H.key==="Enter"&&(I(1),ue({q:se||void 0,category:V||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:()=>{I(1),ue({q:se||void 0,category:V||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"})]}),q?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:E.toLocaleString()})}),s.jsx(Ar,{columns:3,children:T.map(H=>{const te=y.some(Ne=>Ne.name===H.name||Ne.name===H.slug);return s.jsx(ia,{type:"skill",name:H.name,description:H.description_zh??H.description??"",seed:H.slug,icon:Vd(H.slug||H.name,H.tags?.[0]),version:H.version,authorLabel:"SkillHub",showTypeBadge:!1,tags:H.tags,installed:te,hideStats:!0,onClick:()=>window.open(H.homepage,"_blank","noopener,noreferrer"),footerLeft:s.jsxs("span",{className:"flex items-center gap-2 text-[10px] text-fg-tertiary",children:[H.stars>0&&s.jsxs("span",{className:"text-amber-600",children:["★ ",H.stars.toLocaleString()]}),H.downloads>0&&s.jsxs("span",{children:[H.downloads>=1e4?`${(H.downloads/1e4).toFixed(1)}万`:H.downloads.toLocaleString()," ",n("skillStore.downloads")]})]}),actions:te?void 0:s.jsx("button",{onClick:()=>{ye(H)},disabled:h.has(H.name),className:"px-2.5 py-1 text-[10px] bg-brand-600 hover:bg-brand-500 text-white rounded-lg disabled:opacity-50",children:h.has(H.name)?"...":n("card.install")})},H.slug)})}),E>24&&s.jsxs("div",{className:"flex items-center justify-center gap-2 mt-6",children:[s.jsx("button",{disabled:L<=1,onClick:()=>{const H=L-1;I(H),ue({q:se||void 0,category:V||void 0,page:H})},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:L,total:Math.ceil(E/24)})}),s.jsx("button",{disabled:L>=Math.ceil(E/24),onClick:()=>{const H=L+1;I(H),ue({q:se||void 0,category:V||void 0,page:H})},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")})]})]})]}),c==="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:pe,onChange:H=>P(H.target.value),onKeyDown:H=>{H.key==="Enter"&&pe.trim()&&tt(pe)},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:()=>{pe.trim()&&tt(pe)},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")})})]}),_e?s.jsx("div",{className:"text-center text-fg-tertiary py-20",children:s.jsx("div",{className:"animate-pulse",children:n("skillStore.loadingSkillssh")})}):oe.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(Ar,{columns:3,children:oe.map(H=>{const te=y.some(Ne=>Ne.name===H.name);return s.jsx(ia,{type:"skill",name:H.name,description:H.description||"",seed:`${H.author}-${H.name}`,icon:Vd(H.name),authorLabel:`${H.author}/${H.repo}`,showTypeBadge:!1,installed:te,hideStats:!0,cornerLabel:te?void 0:"skills.sh",onClick:()=>window.open(H.url,"_blank","noopener,noreferrer"),footerLeft:H.installs?s.jsxs("span",{className:"text-[10px] text-fg-tertiary",children:[H.installs," installs"]}):void 0,actions:te?void 0:s.jsx("button",{onClick:()=>{je(H)},disabled:h.has(H.name),className:"px-2.5 py-1 text-[10px] bg-brand-600 hover:bg-brand-500 text-white rounded-lg disabled:opacity-50",children:h.has(H.name)?"...":n("card.install")})},`${H.author}-${H.name}`)})})]})]})}const QW=["agent","team","skill","connector"];function ch({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 ZW({item:e,onOpen:t}){const n=Xo(e.subtype==="connector"?"connector":e.itemType),r=Xg(n,e.slug||e.name),o=Ei[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(C0,{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:["↓ ",Mo(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 F4({items:e,onOpen:t}){return s.jsx(Ar,{columns:3,children:e.map(n=>s.jsx(ia,{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 q4(){return s.jsx(Ar,{columns:3,children:Array.from({length:6}).map((e,t)=>s.jsx("div",{className:"h-64 rounded-2xl skeleton"},t))})}function JW({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 y=await lt.search({limit:60,sort:"popular"});g||r(y.items??[])}catch{g||r([])}finally{g||l(!1)}})(),()=>{g=!0}},[]);const c=k.useMemo(()=>{const g=n.filter(x=>x.featured);return(g.length>0?g:n).slice(0,3)},[n]),d=k.useMemo(()=>[...n].sort((g,y)=>(y.trendingScore??y.downloadCount)-(g.trendingScore??g.downloadCount)).slice(0,10),[n]),m=k.useMemo(()=>[...n].sort((g,y)=>(y.createdAt||"").localeCompare(g.createdAt||"")).slice(0,10),[n]),f=k.useMemo(()=>{const g=new Map;for(const y of n){const x=y.author?.username||y.author?.id;if(!x)continue;const w=g.get(x)??{author:y.author,downloads:0,count:0};w.downloads+=y.downloadCount||0,w.count+=1,g.set(x,w)}return[...g.values()].sort((y,x)=>x.downloads-y.downloads).slice(0,6)},[n]),h=g=>e(Xo(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:QW.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 ${Ei[g].gradient} hover:opacity-90 transition-opacity`,children:[Ei[g].labelZh,s.jsx("span",{className:"opacity-70",children:Ei[g].label})]},g))})]}),o?s.jsx("div",{className:"h-52 rounded-2xl skeleton"}):c.length>0?s.jsx("div",{className:"grid grid-cols-1 lg:grid-cols-3 gap-4",children:c.map(g=>s.jsx(ZW,{item:g,onOpen:()=>h(g)},g.id))}):null,s.jsxs("section",{children:[s.jsx(ch,{title:t("discover.trending","热门趋势"),subtitle:t("discover.trendingSub","社区中下载与评分增长最快的资产")}),o?s.jsx(q4,{}):d.length>0?s.jsx(F4,{items:d,onOpen:h}):s.jsx(eY,{})]}),s.jsxs("section",{children:[s.jsx(ch,{title:t("discover.fresh","新鲜上架"),subtitle:t("discover.freshSub","来自创作者的最新作品")}),o?s.jsx(q4,{}):m.length>0?s.jsx(F4,{items:m,onOpen:h}):null]}),f.length>0&&s.jsxs("section",{children:[s.jsx(ch,{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:f.map((g,y)=>s.jsxs("div",{className:"asset-card p-4 flex flex-col items-center text-center",children:[s.jsxs("div",{className:"relative",children:[s.jsx(C0,{name:g.author?.displayName,username:g.author?.username,avatarUrl:g.author?.avatarUrl,hubBase:lt.getUrl(),size:48,verified:y<3}),y<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:y+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," 作品 · ↓ ",Mo(g.downloads)]})]},g.author?.username||y))})]})]})}function eY(){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 Od(e,t,n){return e.i18n?.[n]?.[t]}function tY(){const{t:e,i18n:t}=ft(["store","common"]),n=Uo(),r=t.language,[o,l]=k.useState([]),[c,d]=k.useState({}),[m,f]=k.useState(new Set),[h,g]=k.useState(null),[y,x]=k.useState(!0),[w,C]=k.useState(""),[T,S]=k.useState("all"),[E,j]=k.useState(null),L=k.useCallback(async()=>{x(!0);try{const[F,V,X,z]=await Promise.all([Ee.builder.artifacts.list().catch(()=>({artifacts:[]})),Ee.builder.artifacts.installed().catch(()=>({installed:{}})),Ee.skills.updates().catch(()=>({updates:[],count:0})),Ee.skills.builtin().catch(()=>({skills:[]}))]),G={};for(const q of X.updates)G[q.name]={availableVersion:q.availableVersion,installedVersion:q.installedVersion,displayName:q.displayName,description:q.description};d(G);const se=F.artifacts.filter(q=>{const re=`${q.type}/${q.name}`;return!!V.installed[re]}),ee=new Set(se.filter(q=>q.type==="skill").map(q=>q.name));for(const q of z.skills)!q.installed||ee.has(q.name)||!(V.installed[`skill/${q.name}`]||G[q.name])&&!q.updateAvailable||!V.installed[`skill/${q.name}`]&&!G[q.name]||(se.push({type:"skill",name:q.name,meta:{displayName:q.i18n?.[r]?.displayName||q.name,description:q.i18n?.[r]?.description||q.description||"",version:q.installedVersion||q.version,author:q.author,category:q.category,tags:q.tags,i18n:q.i18n},path:"",updatedAt:""}),ee.add(q.name));for(const[q,re]of Object.entries(G))ee.has(q)||(se.push({type:"skill",name:q,meta:{displayName:re.displayName||q,description:re.description||"",version:re.installedVersion},path:"",updatedAt:""}),ee.add(q));l(se)}catch{}x(!1)},[r]);k.useEffect(()=>{L()},[L]),k.useEffect(()=>{const F=()=>{L()};return window.addEventListener("markus:data-changed",F),()=>window.removeEventListener("markus:data-changed",F)},[L]),k.useEffect(()=>{if(!h)return;const F=setTimeout(()=>g(null),3e3);return()=>clearTimeout(F)},[h]);const I=async(F,V)=>{if(!m.has(F)){f(X=>new Set(X).add(F));try{await Ee.skills.install({name:F,source:"builtin"});try{localStorage.removeItem("markus:template-updates-ack")}catch{}g({text:e("installedTab.updateSuccess",{name:F,version:V}),type:"success"}),window.dispatchEvent(new CustomEvent("markus:data-changed")),await L()}catch{g({text:e("installedTab.updateFailed",{name:F}),type:"error"})}f(X=>{const z=new Set(X);return z.delete(F),z})}},O=o.filter(F=>{if(T!=="all"&&F.type!==T)return!1;if(!w)return!0;const V=w.toLowerCase(),X=(Od(F.meta,"displayName",r)||F.meta.displayName||F.name).toLowerCase(),z=(Od(F.meta,"description",r)||F.meta.description||"").toLowerCase();return X.includes(V)||z.includes(V)}).sort((F,V)=>{const X=F.type==="skill"&&c[F.name]?1:0;return(V.type==="skill"&&c[V.name]?1:0)-X});return E?s.jsx(Mi,{type:E.type,name:E.name,onBack:()=>j(null)}):s.jsxs("div",{className:"flex-1 overflow-hidden flex flex-col",children:[s.jsxs("div",{"data-electron-drag":!0,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(c).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(c).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(F=>s.jsx("button",{onClick:()=>S(F),className:`px-3 py-1 text-xs rounded-md transition-colors ${T===F?"bg-brand-600 text-white":"text-fg-secondary hover:text-fg-primary hover:bg-surface-elevated"}`,children:e(`installedTab.filter${F==="all"?"All":F==="agent"?"Agents":F==="team"?"Teams":"Skills"}`)},F))}),s.jsx("div",{className:"flex-1 min-w-[120px]",children:s.jsx("input",{type:"text",placeholder:e("installedTab.searchPlaceholder"),value:w,onChange:F=>C(F.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:y?s.jsx("div",{className:"text-center text-fg-tertiary py-20 animate-pulse",children:e("installedTab.loading")}):O.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(Ar,{columns:3,children:O.map(F=>{const V=Od(F.meta,"displayName",r)||F.meta.displayName||F.name,X=Od(F.meta,"description",r)||F.meta.description||"",z=F.meta.version||"",G=F.meta.author||"",se=F.meta.tags??[],ee=F.meta.category||"",q=F.meta.icon,re=q&&/\.(png|jpe?g|gif|webp|svg)$/i.test(q)&&!q.startsWith("http")&&!q.startsWith("data:")&&!q.startsWith("/")?`/api/builder/artifacts/${F.type}s/${encodeURIComponent(F.name)}/${q}`:q,B=F.type==="skill"?c[F.name]:void 0;return s.jsx(ia,{type:F.type,name:V,description:X,seed:F.name,icon:re,author:null,authorLabel:G||void 0,version:B?B.installedVersion:z,category:ee,tags:se,installed:!B,hideStats:!0,cornerLabel:B?e("installedTab.updateAvailable"):void 0,onClick:()=>{F.path&&j({type:F.type,name:F.name})},actions:B?s.jsx("button",{type:"button",disabled:m.has(F.name),onClick:()=>{I(F.name,B.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(F.name)?e("installedTab.updating"):e("installedTab.updateTo",{version:B.availableVersion})}):void 0},`${F.type}/${F.name}`)})})}),h&&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 ${h.type==="success"?"bg-emerald-600 text-white":"bg-red-600 text-white"}`,children:h.text})]})}const nY=50,rY=30;function aY(e,t,n,r){const o=k.useRef(0),l=k.useRef(0),c=k.useCallback(m=>{o.current=m.touches[0].clientX,l.current=m.touches[0].clientY},[]),d=k.useCallback(m=>{const f=m.changedTouches[0].clientX-o.current,h=m.changedTouches[0].clientY-l.current,g=Math.abs(f),y=Math.abs(h);if(g<nY||Math.atan2(y,g)*(180/Math.PI)>rY)return;if(r?.scrollContainerRef?.current){const C=r.scrollContainerRef.current,T=C.scrollLeft<=1,S=C.scrollLeft+C.clientWidth>=C.scrollWidth-1;if(f>0&&!T||f<0&&!S)return}const w=e.findIndex(C=>C.id===t);f<0&&w<e.length-1?n(e[w+1].id):f>0&&w>0?n(e[w-1].id):f>0&&w===0&&r?.onSwipeOutLeft?r.onSwipeOutLeft():f<0&&w===e.length-1&&r?.onSwipeOutRight&&r.onSwipeOutRight()},[e,t,n,r]);return{onTouchStart:c,onTouchEnd:d}}const sY=["builder","discover","agents","teams","skills","installed"],iY={agent:"agents",team:"teams",skill:"skills",connector:"skills"};function sg(e){return!!e&&sY.includes(e)}function G4(){const e=localStorage.getItem("markus_nav_installItem"),t=localStorage.getItem("markus_nav_storeTab");return{tab:sg(t)?t:"builder",installId:e}}function oY({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(G4),[o,l]=k.useState(r.tab),[c,d]=k.useState(r.installId),m=aY(n,o,l);k.useEffect(()=>{const h=G4();h.installId&&(d(h.installId),sg(h.tab)&&l(h.tab),localStorage.removeItem("markus_nav_installItem"),localStorage.removeItem("markus_nav_storeTab"))},[]),k.useEffect(()=>{const h=g=>{const y=g.detail,x=y.params?.storeTab??localStorage.getItem("markus_nav_storeTab");sg(x)&&l(x);const w=y.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",h),()=>window.removeEventListener("markus:navigate",h)},[]);const f=(h,g)=>{g&&d(g),l(iY[h]??"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(Mw,{className:"ml-2"}),n.map(h=>s.jsx("button",{onClick:()=>l(h.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===h.id?"border-brand-500 text-brand-500":"border-transparent text-fg-tertiary"}`,children:h.label},h.id))]}),s.jsxs("div",{className:"flex-1 overflow-hidden flex flex-col",children:[o==="builder"&&s.jsx(c6,{authUser:e}),o==="discover"&&s.jsx(JW,{onOpenType:f}),o==="agents"&&s.jsx(FW,{authUser:e,highlightItemId:c,onHighlightDone:()=>d(null)}),o==="teams"&&s.jsx(VW,{highlightItemId:c,onHighlightDone:()=>d(null)}),o==="skills"&&s.jsx(XW,{highlightItemId:c,onHighlightDone:()=>d(null)}),o==="installed"&&s.jsx(tY,{})]})]})}const V4="usageType",uh="profile";function lY({onComplete:e,theme:t,onThemeChange:n,skipProfile:r,onProfileUpdated:o}){const{t:l}=ft(["onboarding","common"]),[c,d]=k.useState(0),[m,f]=k.useState(""),[h,g]=k.useState(""),[y,x]=k.useState(""),[w,C]=k.useState(""),[T,S]=k.useState(!1),[E,j]=k.useState(""),[L,I]=k.useState(!1),[O,F]=k.useState(null);k.useEffect(()=>{Ee.auth.me().then(({user:Ue})=>{Ue.name&&f(Ue.name),Ue.email&&g(Ue.email),Ue.avatarUrl&&F(Ue.avatarUrl);const dt=Ue.name||Ue.email?.split("@")[0]||"";dt&&G(Nt=>Nt||l("usageType.defaultOrgName",{name:dt}))}).catch(()=>{}),Ee.settings.getOrg().then(({org:Ue})=>{Ue?.name&&Ue.name!=="My Organization"&&G(Ue.name)}).catch(()=>{}),bn()&&Ee.hubOrgs.invitations().then(Ue=>{Ue.invitations?.length>0&&Se(Ue.invitations)}).catch(()=>{})},[]);const[V,X]=k.useState(null),[z,G]=k.useState(""),[se,ee]=k.useState(!1),[q,re]=k.useState(!1),[B,J]=k.useState(""),[fe,Se]=k.useState([]),[U,W]=k.useState(null),[pe,P]=k.useState(null),_e=async()=>{const Ue=z.trim();if(Ue){ee(!0),J("");try{if(await Ee.settings.updateOrg(Ue),bn()){const dt=await Ee.hubOrgs.mine(),Nt=dt.orgs?.find(bt=>bt.role==="owner")??dt.orgs?.[0];Nt?.id?await Ee.hubOrgs.update(Nt.id,{name:Ue}):await Ee.hubOrgs.create(Ue)}re(!0)}catch{J(l("usageType.orgNameSaveFailed"))}finally{ee(!1)}}},[He,Pe]=k.useState(!0),Ge=async()=>{if(j(""),!m.trim()){j(l("profile.errors.nameRequired"));return}if(!h.trim()){j(l("profile.errors.emailRequired"));return}if(!/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(h.trim())){j(l("profile.errors.emailInvalid"));return}if(y&&y.length<6){j(l("profile.errors.passwordTooShort"));return}if(y&&y!==w){j(l("profile.errors.passwordMismatch"));return}S(!0);try{const{user:Ue}=await Ee.auth.updateProfile(m.trim(),h.trim());y&&await Ee.auth.changePassword("",y),o?.(Ue),I(!0)}catch{j(l("profile.errors.saveFailed"))}finally{S(!1)}},ct=[{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(g8,{i18nKey:"welcome.description",ns:"onboarding",components:{strong:s.jsx("strong",{className:"text-fg-primary"})}})})},{id:V4,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:()=>{X("personal"),re(!0)},className:`flex flex-col items-center gap-3 rounded-xl border-2 p-5 transition-all text-left ${V==="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:()=>{X("organization"),re(!1)},className:`flex flex-col items-center gap-3 rounded-xl border-2 p-5 transition-all text-left ${V==="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."})})]})]})]}),V==="organization"&&s.jsxs("div",{className:"space-y-4 mt-4",children:[fe.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")}),fe.map(Ue=>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:Ue.orgName}),s.jsx("div",{className:"text-[11px] text-fg-tertiary",children:l("usageType.invitedBy",{name:Ue.invitedBy})})]}),s.jsx("button",{onClick:async()=>{W(Ue.orgId);try{await Ee.hubOrgs.acceptInvitation(Ue.orgId),P(Ue.orgId),re(!0)}catch{}finally{W(null)}},disabled:U===Ue.orgId||pe===Ue.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:pe===Ue.orgId?l("usageType.accepted"):U===Ue.orgId?l("usageType.accepting"):l("usageType.acceptAndJoin")})]},Ue.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:z,onChange:Ue=>{G(Ue.target.value),re(!1),J("")},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:()=>{_e()},disabled:se||!z.trim()||q,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(se?"common:saving":q?"usageType.orgNameSaved":"usageType.setOrgName")})]})]})},{id:uh,title:l("profile.title"),subtitle:l("profile.subtitle"),content:L?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," · ",h]})]})]}):s.jsxs("div",{className:"space-y-4",children:[s.jsx("div",{className:"flex justify-center",children:s.jsx(jw,{currentUrl:O,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:Ue=>f(Ue.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:h,onChange:Ue=>g(Ue.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:y,onChange:Ue=>x(Ue.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"})]}),y&&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:Ue=>C(Ue.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"})]}),E&&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:E}),s.jsx("button",{onClick:()=>{Ge()},disabled:T||!m.trim()||!h.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:ct.map(Ue=>s.jsxs("button",{onClick:()=>n(Ue.value),className:`flex flex-col items-center gap-2 rounded-xl border-2 p-5 transition-all ${t===Ue.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:Ue.icon}),s.jsx("span",{className:"text-sm font-medium text-fg-primary",children:Ue.label}),s.jsx("span",{className:"text-[11px] text-fg-tertiary leading-tight text-center",children:Ue.desc})]},Ue.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:He,onChange:Ue=>Pe(Ue.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(Ue=>Ue.id!==uh):mt,Mt=Ct.findIndex(Ue=>Ue.id===V4),Pt=Ct.findIndex(Ue=>Ue.id===uh),Kt=()=>{c===Mt&&Mt>=0&&!V||c===Mt&&V==="organization"&&!q||c===Pt&&Pt>=0&&!L||(c<Ct.length-1?d(c+1):(fetch("/api/settings/telemetry",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({enabled:He})}).catch(()=>{}),e()))},yt=Ct[c];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((Ue,dt)=>s.jsx("div",{className:`h-1 flex-1 rounded-full transition-colors ${dt<=c?"bg-brand-500":"bg-surface-elevated"}`},dt))}),s.jsx("h2",{className:"text-2xl font-bold text-fg-primary",children:yt.title}),s.jsx("p",{className:"text-sm text-fg-secondary mt-1 mb-6",children:yt.subtitle}),yt.content,s.jsxs("div",{className:"flex justify-between mt-8",children:[c>0?s.jsx("button",{onClick:()=>d(c-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:Kt,disabled:Pt>=0&&c===Pt&&!L||Mt>=0&&c===Mt&&(!V||V==="organization"&&!q),className:`px-6 py-2.5 text-white text-sm rounded-xl transition-colors ${Pt>=0&&c===Pt&&!L||Mt>=0&&c===Mt&&(!V||V==="organization"&&!q)?"bg-brand-600/40 cursor-not-allowed":"bg-brand-600 hover:bg-brand-500"}`,children:c===Ct.length-1?l("getStarted"):l("common:next")})]})]})})})}const K4="markus:legal-consent",cY="https://markus.global";function uY({onLogin:e,hasOwner:t}){const{t:n,i18n:r}=ft("auth"),[o,l]=k.useState(null),[c,d]=k.useState(""),[m,f]=k.useState(!1),[h,g]=k.useState(""),[y,x]=k.useState(""),[w,C]=k.useState(!1),[T,S]=k.useState(!1),E=G=>{const se=(r.language||"").toLowerCase().startsWith("zh")?"?lang=zh":"";return`${cY}${G}${se}`},j=()=>{try{localStorage.setItem(K4,JSON.stringify({acceptedAt:new Date().toISOString(),terms:!0,privacy:!0}))}catch{}},L=()=>T?(j(),!0):(C(!1),requestAnimationFrame(()=>C(!0)),!1),I=async()=>{const G=bn(),se=sa();if(!G||!se){d(n("login.hubUnavailable"));return}const ee=await Ee.auth.hubLogin(G,se);if(window.markusDesktop?.clearPendingDeepLinkAuth?.(),ee.cloudAiReady===!1)try{sessionStorage.setItem("markus:cloud-ai-warning",ee.cloudAiError?n("login.cloudAiNotReady",{error:ee.cloudAiError}):n("login.cloudAiNotReadyGeneric"))}catch{}e(ee.user,ee.needsOnboarding??!1,{fromHub:!0})},O=async(G,se=!1)=>{if(!(!se&&!L())){d(""),l(G??"hub");try{if(se&&bn()&&sa()){await I();return}await Hr(G),await I()}catch(ee){const q=ee instanceof Error?ee.message:"";if(!q.includes("cancelled")){if(!se&&bn())return O(G,!0);d(q||n("login.hubUnavailable"))}}finally{l(null)}}},F=()=>{iD(),l(null),d("")};k.useEffect(()=>{const G=window.markusDesktop;if(!G?.peekPendingDeepLinkAuth&&!G?.consumePendingDeepLinkAuth)return;let se=!1;return(async()=>{const ee=G.peekPendingDeepLinkAuth?await G.peekPendingDeepLinkAuth():null;if(se||!ee)return;let q=!1;try{q=!!localStorage.getItem(K4)}catch{}if(!T&&!q){d(n("login.consentRequired"));return}q&&!T&&S(!0),j();const re=G.consumePendingDeepLinkAuth?await G.consumePendingDeepLinkAuth():ee;if(!(se||!re)){d(""),l("hub");try{if(!await sD(re)||!bn()||!sa()){d(n("login.hubUnavailable"));return}await I()}catch{d(n("login.hubUnavailable"))}finally{se||l(null)}}})().catch(()=>{}),()=>{se=!0}},[T]);const V=async G=>{if(G.preventDefault(),!(!h.trim()||!y)&&L()){d(""),l("local");try{const{user:se,needsOnboarding:ee}=await Ee.auth.login(h.trim(),y);e(se,ee??!1)}catch{d(n("login.invalidCredentials"))}finally{l(null)}}},X=n(t?"login.welcomeBack":"login.getStarted"),z="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:X})]}),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:V,className:"space-y-3",children:[s.jsx("input",{type:"email",value:h,onChange:G=>g(G.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:y,onChange:G=>x(G.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}),c&&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:c}),!t&&s.jsx("p",{className:"text-[11px] text-fg-tertiary",children:n("login.defaultCredentials")}),s.jsx("button",{type:"submit",disabled:o==="local"||!h||!y,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:()=>{f(!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:()=>O("google"),disabled:!!o,className:z,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:()=>O("github"),disabled:!!o,className:z,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:()=>O("email"),disabled:!!o,className:z,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")]}),o&&(o==="google"||o==="github"||o==="email"||o==="hub")&&s.jsxs("div",{className:"px-3 py-2.5 bg-brand-500/10 border border-brand-500/30 rounded-lg text-xs text-fg-secondary space-y-2",children:[s.jsx("p",{children:n("login.browserOpened")}),s.jsx("button",{type:"button",onClick:F,className:"text-brand-500 hover:text-brand-400 underline font-medium",children:n("login.cancelWaiting")})]}),c&&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:c}),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:()=>{f(!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:()=>C(!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:G=>{S(G.target.checked),G.target.checked&&C(!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:E("/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:E("/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 dY({token:e,onComplete:t}){const{t:n}=ft("auth"),[r,o]=k.useState(null),[l,c]=k.useState(""),[d,m]=k.useState(""),[f,h]=k.useState(""),[g,y]=k.useState(!1),[x,w]=k.useState(!1),[C,T]=k.useState(!1);k.useEffect(()=>{Ee.auth.inviteInfo(e).then(E=>o(E)).catch(()=>T(!0))},[e]);const S=async E=>{if(E.preventDefault(),h(""),l.length<6){h(n("invite.passwordMinLength"));return}if(l!==d){h(n("invite.passwordsDoNotMatch"));return}y(!0);try{await Ee.auth.setup(e,l),w(!0),setTimeout(()=>{window.location.hash="",t()},2e3)}catch{h(n("invite.error"))}finally{y(!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:C?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")})]}):x?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:S,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:E=>c(E.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:E=>m(E.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})]}),f&&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:f}),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 mY({onComplete:e,isFirstTime:t}){const{t:n}=ft("auth"),[r,o]=k.useState(""),[l,c]=k.useState(""),[d,m]=k.useState(""),[f,h]=k.useState(""),[g,y]=k.useState(!1),x=async w=>{if(w.preventDefault(),h(""),l.length<6){h(n("changePassword.passwordMinLength"));return}if(l!==d){h(n("changePassword.passwordsDoNotMatch"));return}y(!0);try{await Ee.auth.changePassword(r,l),e()}catch{h(n("changePassword.failedToChange"))}finally{y(!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:x,className:"bg-surface-secondary/80 backdrop-blur-sm border border-border-default rounded-2xl p-8 space-y-5 shadow-2xl shadow-black/30",children:[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=>c(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})]}),f&&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:f}),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 fY({side:e,defaultWidth:t,minWidth:n,maxWidth:r,collapsedWidth:o=0,storageKey:l}){const[c,d]=k.useState(()=>{try{const C=localStorage.getItem(`${l}_w`);if(C)return Math.max(n,Math.min(r,parseInt(C,10)))}catch{}return t}),[m,f]=k.useState(()=>{try{return localStorage.getItem(`${l}_c`)==="1"}catch{return!1}}),h=k.useRef(!1),g=k.useRef(n),y=k.useRef(r);g.current=n,y.current=r,k.useEffect(()=>{try{localStorage.setItem(`${l}_w`,String(c))}catch{}},[c,l]),k.useEffect(()=>{try{localStorage.setItem(`${l}_c`,m?"1":"0")}catch{}},[m,l]),k.useEffect(()=>{d(C=>Math.max(n,Math.min(r,C)))},[n,r]);const x=k.useCallback(C=>{C.preventDefault(),h.current=!0;const T=C.clientX,S=c,E=L=>{if(!h.current)return;const I=L.clientX-T;d(Math.max(g.current,Math.min(y.current,S+I)))},j=()=>{h.current=!1,document.removeEventListener("mousemove",E),document.removeEventListener("mouseup",j),document.body.style.cursor="",document.body.style.userSelect=""};document.addEventListener("mousemove",E),document.addEventListener("mouseup",j),document.body.style.cursor="col-resize",document.body.style.userSelect="none"},[c,e]),w=k.useCallback(()=>f(C=>!C),[]);return{width:m?o:c,rawWidth:c,collapsed:m,toggle:w,setCollapsed:f,setWidth:d,onResizeStart:x}}const fX=[{value:"system",label:"System"},{value:"light",label:"Light"},{value:"dark",label:"Dark"},{value:"cyberpunk",label:"Cyberpunk"},{value:"mono",label:"Mono"}],ig="markus-theme";function W4(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 pY(){try{const e=localStorage.getItem(ig);if(e==="midnight")return localStorage.setItem(ig,"dark"),"dark";if(e==="light"||e==="dark"||e==="system"||e==="cyberpunk"||e==="mono")return e}catch{}return"system"}function hY(){const[e,t]=k.useState(pY),n=k.useCallback(r=>{t(r);try{localStorage.setItem(ig,r)}catch{}W4(r)},[]);return k.useEffect(()=>{W4(e)},[e]),{mode:e,setMode:n}}const Wd={agents:[],tasks:[],requirements:[],projects:[],deliverables:[],workflows:[]},gY={team:["agents","workflows","tasks","requirements","projects","deliverables"],work:["workflows","projects","requirements","tasks","agents","deliverables"],deliverables:["deliverables","agents","tasks","requirements","projects","workflows"]},bY=["agents","tasks","requirements","projects","deliverables","workflows"];let Y4="",X4="all",Q4=Wd,Z4=!1;function xY({onClose:e,currentPage:t}){const{t:n}=ft(["common","home","work"]);Ho(!0);const[r,o]=k.useState(Y4),[l,c]=k.useState(X4),[d,m]=k.useState(Q4),[f,h]=k.useState(!1),[g,y]=k.useState(Z4),[x,w]=k.useState(-1);k.useEffect(()=>{Y4=r},[r]),k.useEffect(()=>{X4=l},[l]),k.useEffect(()=>{Q4=d},[d]),k.useEffect(()=>{Z4=g},[g]);const C=k.useRef(null),T=k.useRef(void 0),S=k.useRef(null),E=k.useRef(null);k.useEffect(()=>{setTimeout(()=>{C.current?.focus(),C.current?.select()},100)},[]);const j=k.useCallback(async ee=>{if(!ee.trim()){m(Wd),y(!1),w(-1);return}h(!0),y(!0),w(-1);const q=ee.toLowerCase();try{const[re,B,J,fe,Se,U]=await Promise.allSettled([Ee.agents.list(),Ee.tasks.list({search:ee,pageSize:20}),Ee.requirements.list(),Ee.projects.list(),Ee.deliverables.search({q:ee,limit:20}),Ee.teams.list()]),W=re.status==="fulfilled"?re.value.agents.filter(Ge=>Ge.name?.toLowerCase().includes(q)||Ge.role?.toLowerCase().includes(q)):[],pe=B.status==="fulfilled"?B.value.tasks:[],P=J.status==="fulfilled"?J.value.requirements.filter(Ge=>Ge.title?.toLowerCase().includes(q)||Ge.description?.toLowerCase().includes(q)):[],_e=fe.status==="fulfilled"?fe.value.projects.filter(Ge=>Ge.name?.toLowerCase().includes(q)||Ge.description?.toLowerCase().includes(q)):[],He=Se.status==="fulfilled"?Se.value.results:[],Pe=[];if(U.status==="fulfilled"){const Ge=await Promise.allSettled(U.value.teams.map(ct=>Ee.workflows.list(ct.id)));for(const ct of Ge)if(ct.status==="fulfilled")for(const mt of ct.value.workflows)(mt.name.toLowerCase().includes(q)||(mt.displayName||"").toLowerCase().includes(q)||mt.description?.toLowerCase().includes(q))&&Pe.push(mt)}m({agents:W,tasks:pe,requirements:P,projects:_e,deliverables:He,workflows:Pe})}catch{m(Wd)}finally{h(!1)}},[]),L=ee=>{o(ee),T.current&&clearTimeout(T.current),T.current=setTimeout(()=>j(ee),400)},I=k.useCallback((ee,q)=>{e(),it.navigate(ee,q)},[e]),O=[{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:"工作流"})}],F=k.useMemo(()=>gY[t||""]||bY,[t]),V=k.useMemo(()=>{const ee=[],q=l==="all"?8:void 0,re=B=>{if(l!=="all"&&l!==B)return;const J=d[B].length;if(B==="workflows"){const fe=q?d.workflows.slice(0,q):d.workflows;for(const Se of fe)ee.push({id:Se.name,type:"workflow",page:de.WORK,params:{boardType:"workflows"}})}else{const fe=d[B],Se=q?fe.slice(0,q):fe;for(const U of Se)switch(B){case"agents":ee.push({id:U.id,type:"agent",page:de.TEAM,params:{agentId:U.id}});break;case"tasks":ee.push({id:U.id,type:"task",page:de.WORK,params:{openTask:U.id}});break;case"requirements":ee.push({id:U.id,type:"requirement",page:de.WORK,params:{openRequirement:U.id}});break;case"projects":ee.push({id:U.id,type:"project",page:de.WORK,params:{projectId:U.id}});break;case"deliverables":ee.push({id:U.id,type:"deliverable",page:de.DELIVERABLES,params:{openDeliverable:U.id}});break}}q&&J>q&&ee.push({id:`more_${B}`,type:"showMore",page:"",expandCategory:B,totalCount:J})};for(const B of F)re(B);return ee},[d,l,F]),X=k.useCallback(ee=>{if(ee.type==="showMore"&&ee.expandCategory){c(ee.expandCategory),w(-1);return}I(ee.page,ee.params)},[I]);k.useEffect(()=>{const ee=E.current;if(!ee||x<0)return;const q=ee.querySelector(`[data-idx="${x}"]`);q&&q.scrollIntoView({block:"nearest"})},[x]);const z=k.useCallback(ee=>{if(ee.key==="Escape"){e();return}if(ee.key==="Tab"){ee.preventDefault();const B=O.map(Se=>Se.id),J=B.indexOf(l),fe=ee.shiftKey?J<=0?B.length-1:J-1:J>=B.length-1?0:J+1;c(B[fe]),w(-1);return}const q=ee.ctrlKey&&ee.key==="n"||ee.key==="ArrowDown",re=ee.ctrlKey&&ee.key==="p"||ee.key==="ArrowUp";if(q||re){ee.preventDefault(),w(B=>{const J=V.length-1;return J<0?-1:q?B>=J?0:B+1:B<=0?J:B-1});return}ee.key==="Enter"&&(ee.preventDefault(),x>=0&&x<V.length&&X(V[x]))},[e,V,x,X,O,l]);k.useEffect(()=>(document.addEventListener("keydown",z),()=>document.removeEventListener("keydown",z)),[z]);const G=V.length>0;let se=0;return s.jsx("div",{ref:S,className:"fixed inset-0 bg-black/50 flex items-start justify-center z-50 pt-[8vh]",onClick:ee=>{ee.target===S.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:C,value:r,onChange:ee=>L(ee.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(Wd),y(!1),w(-1),C.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:O.map(ee=>s.jsx("button",{onClick:()=>{c(ee.id),w(-1)},className:`px-3 py-1.5 text-xs rounded-lg whitespace-nowrap transition-colors ${l===ee.id?"bg-brand-600 text-white":"bg-surface-elevated text-fg-secondary hover:text-fg-primary"}`,children:ee.label},ee.id))})]}),s.jsxs("div",{ref:E,className:"flex-1 overflow-y-auto px-5 py-3",children:[f&&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")})}),!f&&g&&!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:noResults",{defaultValue:"没有找到相关结果"})})]}),!f&&G&&s.jsx("div",{className:"space-y-4",children:F.map(ee=>{if(l!=="all"&&l!==ee)return null;const q=l==="all"?8:void 0,re=B=>{const J=se++,fe=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":J,onClick:()=>{c(B),w(-1)},className:`mt-1 w-full text-xs py-1.5 rounded-lg transition-colors ${J===x?"bg-brand-600/15 ring-1 ring-brand-500/40 text-brand-500":"text-brand-500 hover:text-brand-400 hover:bg-surface-overlay"}`,children:[n("common:showAll",{defaultValue:"查看全部"})," (",fe,")"]})};return ee==="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:(q?d.agents.slice(0,q):d.agents).map(B=>{const J=se++;return s.jsxs("button",{"data-idx":J,onClick:()=>I(de.TEAM,{agentId:B.id}),className:`w-full flex items-center gap-3 px-3 py-2 rounded-xl transition-colors text-left ${J===x?"bg-brand-600/15 ring-1 ring-brand-500/40":"hover:bg-surface-overlay"}`,children:[s.jsx(Hs,{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(yY,{status:B.status})]},B.id)})}),q&&d.agents.length>q&&re("agents")]},"agents"):ee==="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:(q?d.tasks.slice(0,q):d.tasks).map(B=>{const J=se++;return s.jsxs("button",{"data-idx":J,onClick:()=>I(de.WORK,{openTask:B.id}),className:`w-full flex items-center gap-3 px-3 py-2 rounded-xl transition-colors text-left ${J===x?"bg-brand-600/15 ring-1 ring-brand-500/40":"hover:bg-surface-overlay"}`,children:[s.jsx(vY,{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)})}),q&&d.tasks.length>q&&re("tasks")]},"tasks"):ee==="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:(q?d.requirements.slice(0,q):d.requirements).map(B=>{const J=se++;return s.jsxs("button",{"data-idx":J,onClick:()=>I(de.WORK,{openRequirement:B.id}),className:`w-full flex items-center gap-3 px-3 py-2 rounded-xl transition-colors text-left ${J===x?"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)})}),q&&d.requirements.length>q&&re("requirements")]},"requirements"):ee==="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:(q?d.projects.slice(0,q):d.projects).map(B=>{const J=se++;return s.jsxs("button",{"data-idx":J,onClick:()=>I(de.WORK,{projectId:B.id}),className:`w-full flex items-center gap-3 px-3 py-2 rounded-xl transition-colors text-left ${J===x?"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)})}),q&&d.projects.length>q&&re("projects")]},"projects"):ee==="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:(q?d.deliverables.slice(0,q):d.deliverables).map(B=>{const J=se++;return s.jsxs("button",{"data-idx":J,onClick:()=>I(de.DELIVERABLES,{openDeliverable:B.id}),className:`w-full flex items-center gap-3 px-3 py-2 rounded-xl transition-colors text-left ${J===x?"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)})}),q&&d.deliverables.length>q&&re("deliverables")]},"deliverables"):ee==="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:(q?d.workflows.slice(0,q):d.workflows).map(B=>{const J=se++;return s.jsxs("button",{"data-idx":J,onClick:()=>I(de.WORK,{boardType:"workflows"}),className:`w-full flex items-center gap-3 px-3 py-2 rounded-xl transition-colors text-left ${J===x?"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)})}),q&&d.workflows.length>q&&re("workflows")]},"workflows"):null})}),!f&&!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 yY({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 vY({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"})]})})}const wY=[{id:"toggle-left",group:"layout",keys:["B"],label:"Toggle left sidebar (L0 + page L1)",labelKey:"shortcuts.toggleLeft",page:"any"},{id:"help",group:"help",keys:["/"],label:"Show keyboard shortcuts",labelKey:"shortcuts.help",page:"any"},{id:"search",group:"search",keys:["P"],label:"Global search",labelKey:"shortcuts.search",page:"any"},{id:"nav-l0-jk",group:"navigation",keys:["J / K"],label:"L0: switch page up / down",labelKey:"shortcuts.navL0Jk",page:"any",bare:!0},{id:"nav-l0-l",group:"navigation",keys:["L"],label:"L0: enter page L1 (Team / Tasks / Output / Store / Settings)",labelKey:"shortcuts.navL0L",page:"any",bare:!0},{id:"nav-l0-h",group:"navigation",keys:["H"],label:"From page L1: focus app rail (L0)",labelKey:"shortcuts.navL0H",page:"any",bare:!0},{id:"settings-back",group:"navigation",keys:["H"],label:"Settings: go back to previous page",labelKey:"shortcuts.settingsBack",page:"any",bare:!0},{id:"nav-jk-settings",group:"navigation",keys:["J / K"],label:"Settings L1: switch settings tabs",labelKey:"shortcuts.navJkSettings",page:"any",bare:!0},{id:"nav-hl-work",group:"navigation",keys:["H / L"],label:"Tasks: item list ↔ project L1 ↔ app rail",labelKey:"shortcuts.navHlWork",page:"work",bare:!0},{id:"nav-jk-work",group:"navigation",keys:["J / K"],label:"Tasks: move project / item selection",labelKey:"shortcuts.navJkWork",page:"work",bare:!0},{id:"nav-hl-team",group:"navigation",keys:["H / L"],label:"Team: L0 ↔ L1 ↔ L2 (L ignored on deepest pane)",labelKey:"shortcuts.navHlTeam",page:"team",bare:!0},{id:"nav-jk-team",group:"navigation",keys:["J / K"],label:"Team L1: move roster selection",labelKey:"shortcuts.navJkTeam",page:"team",bare:!0},{id:"nav-jk-team-l2",group:"navigation",keys:["J / K"],label:"Team L2: move team member selection",labelKey:"shortcuts.navJkTeamL2",page:"team",bare:!0},{id:"nav-jk-deliverables",group:"navigation",keys:["J / K"],label:"Output L1: move deliverable selection",labelKey:"shortcuts.navJkDeliverables",page:"deliverables",bare:!0},{id:"nav-jk-store",group:"navigation",keys:["J / K"],label:"Store L1: switch store tabs",labelKey:"shortcuts.navJkStore",page:"store",bare:!0},{id:"toggle-project-detail",group:"tasks",keys:["J"],label:"Toggle project detail (Tasks)",labelKey:"shortcuts.toggleProjectDetail",page:"work"},{id:"toggle-item-detail",group:"tasks",keys:["L"],label:"Toggle task / requirement detail (Tasks)",labelKey:"shortcuts.toggleItemDetail",page:"work"},{id:"cycle-board",group:"tasks",keys:["Ctrl","Tab"],label:"Cycle Tasks views",labelKey:"shortcuts.cycleBoard",page:"work",bare:!0},{id:"toggle-browser",group:"team",keys:["L"],label:"Toggle right panel · Browser",labelKey:"shortcuts.toggleBrowser",page:"team"},{id:"toggle-terminal",group:"team",keys:["J"],label:"Toggle right panel · Terminal",labelKey:"shortcuts.toggleTerminal",page:"team"},{id:"next-tab",group:"rightPanel",keys:["Shift","]"],label:"Next right-panel tab",labelKey:"shortcuts.nextTab",page:"team"},{id:"prev-tab",group:"rightPanel",keys:["Shift","["],label:"Previous right-panel tab",labelKey:"shortcuts.prevTab",page:"team"},{id:"tab-n",group:"rightPanel",keys:["1…9"],label:"Jump to Nth right-panel tab",labelKey:"shortcuts.tabN",page:"team"},{id:"close-tab",group:"rightPanel",keys:["W"],label:"Close right-panel tab",labelKey:"shortcuts.closeTab",page:"team"},{id:"new-tab",group:"rightPanel",keys:["T"],label:"New browser tab / shell",labelKey:"shortcuts.newTab",page:"team"},{id:"term-search",group:"terminal",keys:["F"],label:"Search in terminal",labelKey:"shortcuts.termSearch",page:"team"},{id:"term-to-chat",group:"terminal",keys:["Shift","A"],label:"Add terminal selection to chat",labelKey:"shortcuts.termToChat",page:"team"}];function kY(e,t,n){return n||e[0]==="Ctrl"||e[0]==="Tab"||e[0]==="J / K"||e[0]==="H / L"?e.join(e[0]==="Ctrl"?"+":" "):e.length===1&&(e[0]==="H"||e[0]==="L"||e[0]==="J"||e[0]==="K")?e[0]:[t?"⌘":"Ctrl",...e].join(t?"":"+")}function SY(e){if(!(e instanceof HTMLElement))return!1;const t=e.tagName;return t==="INPUT"||t==="TEXTAREA"||t==="SELECT"||e.isContentEditable?!0:e.closest(".xterm")!==null}function J4(e){return e instanceof HTMLElement?e.closest(".xterm")!==null:!1}const NY=["layout","navigation","tasks","team","search","rightPanel","terminal","help"];function CY(e){return e===de.TEAM?"team":e===de.WORK?"work":e===de.DELIVERABLES?"deliverables":e===de.STORE?"store":"any"}function TY({open:e,onClose:t,page:n}){const{t:r}=ft("common"),o=typeof navigator<"u"&&navigator.platform.toUpperCase().includes("MAC"),l=CY(n);return k.useEffect(()=>{if(!e)return;const c=d=>{d.key==="Escape"&&(d.preventDefault(),d.stopPropagation(),t())};return window.addEventListener("keydown",c,!0),()=>window.removeEventListener("keydown",c,!0)},[e,t]),e?s.jsx("div",{className:"fixed inset-0 z-[100] flex items-center justify-center bg-black/45 backdrop-blur-[1px] p-4",onMouseDown:c=>{c.target===c.currentTarget&&t()},role:"dialog","aria-modal":"true","aria-label":r("shortcuts.title"),children:s.jsxs("div",{className:"w-full max-w-lg max-h-[80vh] overflow-auto rounded-xl border border-border-default bg-surface-primary shadow-2xl",children:[s.jsxs("div",{className:"sticky top-0 z-10 flex items-center justify-between gap-3 px-4 py-3 border-b border-border-default bg-surface-primary",children:[s.jsx("h2",{className:"text-sm font-semibold text-fg-primary",children:r("shortcuts.title")}),s.jsx("button",{type:"button",onClick:t,className:"w-7 h-7 flex items-center justify-center rounded-md text-fg-tertiary hover:text-fg-secondary hover:bg-surface-elevated","aria-label":r("shortcuts.close"),children:s.jsxs("svg",{width:"14",height:"14",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"})]})})]}),s.jsx("div",{className:"px-4 py-3 space-y-4",children:NY.map(c=>{const d=wY.filter(m=>{if(m.group!==c)return!1;const f=m.page??"any";return f==="any"?!0:f===l});return d.length===0?null:s.jsxs("section",{children:[s.jsx("h3",{className:"text-[11px] font-semibold uppercase tracking-wide text-fg-tertiary mb-2",children:r(`shortcuts.groups.${c}`)}),s.jsx("ul",{className:"space-y-1.5",children:d.map(m=>s.jsxs("li",{className:"flex items-center justify-between gap-3 text-sm",children:[s.jsx("span",{className:"text-fg-secondary min-w-0",children:r(m.labelKey??m.label,{defaultValue:m.label})}),s.jsx("kbd",{className:"shrink-0 px-1.5 py-0.5 rounded bg-surface-elevated border border-border-default text-[11px] font-medium text-fg-primary font-mono",children:kY(m.keys,o,m.bare)})]},m.id))})]},c)})})]})}):null}function AY({authUser:e,onClose:t,onSaved:n,onUserUpdated:r}){const{t:o}=ft("common");Ho(!0);const[l,c]=k.useState(e.name||""),[d,m]=k.useState(e.email||""),[f,h]=k.useState(!1),[g,y]=k.useState(""),[x,w]=k.useState(()=>Ew(e.avatarUrl,sa()?.avatarUrl)),C=async T=>{if(T.preventDefault(),!l.trim()){y(o("profile.nameRequired"));return}if(d&&!/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(d.trim())){y(o("profile.invalidEmail"));return}h(!0),y("");try{const{user:S}=await Ee.auth.updateProfile(l.trim(),d.trim());n({...S,avatarUrl:x??S.avatarUrl})}catch{y(o("profile.failedToSave"))}finally{h(!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:C,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(jw,{currentUrl:x,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=>c(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:f,className:"px-4 py-2 text-sm bg-brand-600 hover:bg-brand-500 disabled:opacity-50 text-white rounded-lg",children:o(f?"saving":"save")})]})]})})}const ew=k.lazy(()=>Gr(()=>import("./Team-CWRLD5sM.js"),__vite__mapDeps([2,3,4,5,6])).then(e=>({default:e.TeamPage}))),tw=k.lazy(()=>Gr(()=>import("./Settings-Q87nTBy5.js"),[]).then(e=>({default:e.Settings}))),EY=k.lazy(()=>Gr(()=>import("./Store-BK54Nx60.js"),[]).then(e=>({default:e.StorePage}))),_Y=k.lazy(()=>Gr(()=>Promise.resolve().then(()=>$W),void 0).then(e=>({default:e.AgentBuilder}))),nw=k.lazy(()=>Gr(()=>import("./Work-xejZ7HCT.js"),__vite__mapDeps([7,4,1,8,3,9])).then(e=>({default:e.WorkPage}))),rw=k.lazy(()=>Gr(()=>import("./Deliverables-BUi9KGwf.js"),__vite__mapDeps([10,4,5])).then(e=>({default:e.DeliverablesPage}))),jY=k.lazy(()=>Gr(()=>import("./Notifications-W-Mx_v6q.js"),[]).then(e=>({default:e.NotificationsPage}))),MY=k.lazy(()=>Gr(()=>import("./Search-Cxtd9r1S.js"),[]).then(e=>({default:e.SearchPage}))),RY={visibility:"hidden",position:"absolute",inset:0,pointerEvents:"none",zIndex:-1};function LY(e){try{const t=navigator.language,n=Intl.DateTimeFormat().resolvedOptions().timeZone,r=e.preferences??{};if(r.locale===t&&r.timezone===n)return;Ee.auth.updatePreferences({locale:t,timezone:n}).catch(()=>{})}catch{}}function OY(){return s.jsx("div",{className:"flex-1 flex items-center justify-center text-fg-tertiary text-sm animate-pulse",children:"Loading..."})}const DY=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:RY,children:s.jsx(k.Suspense,{fallback:s.jsx(OY,{}),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}),Dd={};function f6(e){return typeof window<"u"&&window.matchMedia("(max-width: 767px)").matches?yw[e]??e:e}function aw(){return f6(pc())}function IY(){const{t:e}=ft("common"),[t,n]=k.useState(aw),[r,o]=k.useState(()=>!localStorage.getItem("markus_onboarded")),[l,c]=k.useState(!0),d=Uo(),m=hY(),f=fY({side:"left",defaultWidth:160,minWidth:140,maxWidth:400,collapsedWidth:64,storageKey:"markus_sidebar"}),[h,g]=k.useState(()=>new Set([aw()])),[y,x]=k.useState("loading"),[w,C]=k.useState(!1),[T,S]=k.useState(null),[E,j]=k.useState({hasOwner:!1,hasMultipleUsers:!1}),[L,I]=k.useState(!1),[O,F]=k.useState(!1),[V,X]=k.useState(null),[z,G]=k.useState(!1),[se,ee]=k.useState(null),[q,re]=k.useState(()=>{const Q=localStorage.getItem("markus_update_dismissed");return Q||null}),[B,J]=k.useState(!1),[fe,Se]=k.useState(!1),U=Lc(),W=U?.leftCollapsed??!1,pe=U?.toggleLeftCollapsed,P=U?.setLeftCollapsed,_e=U?.keyboardPane??"l0",He=U?.setKeyboardPane,Pe=U?.l0FocusPageId??null,Ge=U?.setL0FocusPageId,ct=k.useRef(t);ct.current=t;const mt=k.useRef(de.HOME),Ct=U?.toggleRightPanel,Mt=U?.toggleTerminalPanel,Pt=U?.cycleRightPanelTab,Kt=U?.activateRightPanelTabAt,yt=U?.openNewRightPanelTab,Ue=U?.rightPanelOpen??!1,dt=U?.activeRightPanelTabId??null,Nt=U?.openRightPanel,bt=U?.closeRightPanelTab,Lt=U?.updateRightPanelBrowserTab,ue=U?.updateRightPanelTerminalTab,tt=k.useRef(U?.rightPanelTabs);tt.current=U?.rightPanelTabs,k.useEffect(()=>{const Q=window.markusDesktop?.browser?.onPageEvent;if(!(!Q||!Nt))return Q(Z=>{if(Z.type==="closed"){const be=tt.current?.find(Ke=>Ke.payload.kind==="url"&&Ke.payload.browserId===Z.browserId);be&&bt&&bt(be.id);return}if(Z.type==="navigated"){if(Z.url&&gc(Z.url))return;Z.browserId&&Lt&&Lt(Z.browserId,{url:Z.url,title:Z.title||Z.url});return}if(Z.type==="opened"||Z.type==="selected"){if(!Z.url&&!Z.browserId||Z.browserId.startsWith("eb_")||rV(Z.browserId)||Z.url&&gc(Z.url))return;Nt({kind:"url",url:Z.url||"about:blank",title:Z.title||Z.url||"Browser",browserId:Z.browserId,pageId:Z.pageId})}})},[Nt,bt,Lt]),k.useEffect(()=>{const Q=window.markusDesktop?.terminal?.onEvent;if(!(!Q||!Nt))return Q(Z=>{if(Z.type==="closed"){const be=tt.current?.find(Ke=>Ke.payload.kind==="terminal"&&Ke.payload.terminalId===Z.id);be&&bt&&bt(be.id);return}if(Z.type==="cwd"){Z.cwd&&ue?.(Z.id,{cwd:Z.cwd});return}if(Z.type==="selected"){(Z.title||Z.cwd)&&ue?.(Z.id,{title:Z.title,cwd:Z.cwd});return}if(Z.type==="opened"){if(Vg.has(Z.id)){(Z.title||Z.cwd)&&ue?.(Z.id,{title:Z.title,cwd:Z.cwd});return}wi(Z.id),Nt({kind:"terminal",terminalId:Z.id,title:Z.title||"Terminal",cwd:Z.cwd})}})},[Nt,bt,ue]);const st=U?.handleTerminalExit;k.useEffect(()=>{const Q=window.markusDesktop?.terminal?.onExit;if(!(!Q||!st))return Q(Z=>{st(Z.id)})},[st]),k.useLayoutEffect(()=>{const Q=t===de.TEAM&&Ue&&U?.rightPanelMode==="browser";up(Q)},[t,Ue,U?.rightPanelMode]),k.useEffect(()=>{window.markusDesktop?.browser?.hideAll?.()},[]);const ye=k.useRef(!1);k.useEffect(()=>{if(!ye.current){ye.current=!0;return}f.setCollapsed(W)},[W,f.setCollapsed]),k.useEffect(()=>{if(d)return;const Q=navigator.platform.toUpperCase().includes("MAC"),Z=Ke=>{Q&&Ke.metaKey&&!Ke.ctrlKey&&Ke.key==="p"?(Ke.preventDefault(),J(Ie=>!Ie)):!Q&&Ke.ctrlKey&&!Ke.metaKey&&Ke.key==="p"&&(Ke.preventDefault(),J(Ie=>!Ie))},be=()=>J(!0);return document.addEventListener("keydown",Z),window.addEventListener("markus:open-search",be),()=>{document.removeEventListener("keydown",Z),window.removeEventListener("markus:open-search",be)}},[d]);const je=k.useCallback(()=>!Ue||!dt||!bt?!1:(bt(dt),!0),[Ue,dt,bt]);k.useEffect(()=>{const Q=window.markusDesktop?.onAppShortcut?.(Z=>{if(Z.type==="close-tab"){je();return}Z.type==="new-tab"&&yt?.()});return()=>{Q?.()}},[je,yt]),k.useEffect(()=>{if(d||!pe||!Ct)return;const Q=navigator.platform.toUpperCase().includes("MAC"),Z=be=>{if(!(Q?be.metaKey&&!be.ctrlKey:be.ctrlKey&&!be.metaKey)||be.altKey)return;if(!be.shiftKey&&(be.key==="/"||be.code==="Slash")){be.preventDefault(),Se(Ye=>!Ye);return}if(be.shiftKey&&(be.key==="?"||be.key==="/")){be.preventDefault(),Se(Ye=>!Ye);return}if(be.shiftKey&&Ue&&Pt){if(be.key==="]"||be.code==="BracketRight"){be.preventDefault(),Pt(1);return}if(be.key==="["||be.code==="BracketLeft"){be.preventDefault(),Pt(-1);return}}if(!be.shiftKey&&Ue&&Kt){const Ye=be.key>="1"&&be.key<="9"?Number(be.key):0;if(Ye>=1){be.preventDefault(),Kt(Ye-1);return}}if(be.shiftKey)return;const Ie=be.key.toLowerCase();if(Ie==="w"){be.preventDefault(),be.stopPropagation(),je();return}if(Ie==="t"){be.preventDefault(),yt?.();return}if(Ie==="b"){if(t===de.DELIVERABLES)return;be.preventDefault(),pe()}else if(t===de.TEAM&&Ie==="l"){if(!Q&&J4(be.target)||Q&&J4(be.target)&&be.ctrlKey)return;be.preventDefault(),Ct()}else t===de.TEAM&&Ie==="j"&&Mt&&(be.preventDefault(),Mt())};return document.addEventListener("keydown",Z,!0),()=>document.removeEventListener("keydown",Z,!0)},[d,t,pe,Ct,Mt,Pt,Kt,Ue,je,yt]);const Ae=k.useCallback((Q,Z)=>{let be=fc(Q);d?be=yw[be]??be:be===de.NOTIFICATIONS&&(be=de.HOME),be!==de.TEAM&&up(!1);const Ke=pc(),Ie=window.location.hash.slice(1);Ie!==hh(Ke)?Dd[Ke]=Ie:delete Dd[Ke];const Ye=ct.current;if(be===de.SETTINGS&&Ye!==de.SETTINGS&&(mt.current=Ye,it.setSettingsReturnPage(Ye),He?.("l1"),Ge?.(de.SETTINGS)),Ye===de.SETTINGS&&be!==de.SETTINGS&&(He?.("l0"),Ge?.(be)),be===de.SETTINGS&&Z?.tab){const le=`settings/${Z.tab}`;Dd[be]=le,history.pushState(null,"","#"+le),window.dispatchEvent(new HashChangeEvent("hashchange")),n(be),g(Oe=>Oe.has(be)?Oe:new Set([...Oe,be]));return}const M=be!==de.WORK?Dd[be]:void 0;M&&M!==hh(be)?(history.pushState(null,"",Ti(be)),history.pushState(null,"","#"+M)):history.pushState(null,"",Ti(be)),window.dispatchEvent(new HashChangeEvent("hashchange")),n(be),g(le=>le.has(be)?le:new Set([...le,be]))},[d,He,Ge]);k.useEffect(()=>{it.setHandler((Q,Z)=>Ae(Q,Z))},[Ae]),k.useEffect(()=>{_e==="l0"&&t!==de.SETTINGS&&Ge?.(t)},[_e,t,Ge]),k.useEffect(()=>{if(d||!He||!Ge)return;const Q=Z=>{if(Z.metaKey||Z.ctrlKey||Z.altKey||SY(Z.target))return;const be=Z.key.length===1?Z.key.toLowerCase():Z.key;if(t===de.SETTINGS&&(be==="h"||be==="ArrowLeft")){Z.preventDefault(),Z.stopImmediatePropagation(),it.leaveSettings();return}if(_e!=="l0"||t===de.SETTINGS)return;const Ke=Pe&&vo.includes(Pe)?Pe:t,Ie=Math.max(0,vo.indexOf(Ke));if(be==="j"||be==="ArrowDown"){Z.preventDefault(),Z.stopImmediatePropagation();const Ye=vo[Math.min(vo.length-1,Ie+1)];Ge(Ye),Ye!==t&&Ae(Ye),requestAnimationFrame(()=>{document.querySelector(`[data-l0-page-id="${Ye}"]`)?.scrollIntoView({block:"nearest"})});return}if(be==="k"||be==="ArrowUp"){Z.preventDefault(),Z.stopImmediatePropagation();const Ye=vo[Math.max(0,Ie-1)];Ge(Ye),Ye!==t&&Ae(Ye),requestAnimationFrame(()=>{document.querySelector(`[data-l0-page-id="${Ye}"]`)?.scrollIntoView({block:"nearest"})});return}if(be==="l"||be==="ArrowRight"||be==="Enter"){const Ye=Pe&&vo.includes(Pe)?Pe:t;if(!XO.has(Ye)){Z.preventDefault(),Z.stopImmediatePropagation();return}Z.preventDefault(),Z.stopImmediatePropagation(),Ye!==t&&Ae(Ye),P?.(!1),He("l1");return}(be==="h"||be==="ArrowLeft")&&(Z.preventDefault(),Z.stopImmediatePropagation())};return document.addEventListener("keydown",Q,!0),()=>document.removeEventListener("keydown",Q,!0)},[d,_e,Pe,t,Ae,He,Ge,P]),k.useEffect(()=>{const Q=()=>C(!0);return window.addEventListener("markus:open-edit-profile",Q),()=>window.removeEventListener("markus:open-edit-profile",Q)},[]),k.useEffect(()=>{if(!window.markusDesktop)return;!d&&t!==de.SETTINGS&&!f.collapsed?window.markusDesktop.setTrafficLightPosition(16,16):window.markusDesktop.setTrafficLightPosition(6,16)},[f.collapsed,t,d]),k.useEffect(()=>{window.markusDesktop&&window.markusDesktop.onNotificationClick(Q=>{if(Q.openNotifications&&window.dispatchEvent(new CustomEvent("markus:open-notifications")),Q.page){const Z=fc(Q.page);Q.params&&Object.entries(Q.params).forEach(([be,Ke])=>localStorage.setItem(`markus_nav_${be}`,Ke)),Ae(Z),window.dispatchEvent(new CustomEvent("markus:navigate",{detail:{page:Z,params:Q.params}}))}})},[Ae]);const oe=k.useCallback(()=>{fetch("/api/settings/llm").then(Q=>Q.ok?Q.json():null).then(Q=>{if(Q?.providers){const Z=Object.values(Q.providers).some(be=>be.configured);X(Z)}}).catch(()=>{})},[]),H=k.useCallback((Q,Z)=>{if(!Q)return;const Ke=Z&&{agent:"agents",team:"teams",skill:"skills"}[Z]||"agents";localStorage.setItem("markus_nav_installItem",Q),localStorage.setItem("markus_nav_storeTab",Ke);const Ie=new URLSearchParams(window.location.search);Ie.get("install")||(Ie.set("install",Q),Z&&Ie.set("type",Z));const Ye=Ie.toString();window.history.replaceState(null,"",`${window.location.pathname}?${Ye}${Ti(de.STORE)}`);const M=()=>it.navigate(de.STORE,{storeTab:Ke,installItem:Q});M(),setTimeout(M,500),setTimeout(M,1500)},[]);k.useEffect(()=>{const Q=new URLSearchParams(window.location.search),Z=Q.get("install");Z&&H(Z,Q.get("type"));const be=window.markusDesktop;be?.onDeepLinkInstall?.(({id:Ye,type:M})=>H(Ye,M)),be?.consumePendingDeepLinkInstall?.().then(Ye=>{Ye?.id&&H(Ye.id,Ye.type)}),Ee.auth.me().then(({user:Ye})=>{x(Ye),S(!0),LY(Ye),va.connect(Ye.id),oe(),Ee.health().then(le=>{le.updateAvailable&&le.latestVersion&&ee({latestVersion:le.latestVersion,currentVersion:le.version})}).catch(()=>{});const M=()=>{gi(Tr.builderArtifacts,()=>Ee.builder.artifacts.list()),gi(Tr.builderAgents,()=>Ee.agents.list()),gi(Tr.builderHubMyItems,()=>lt.myItems()),gi(Tr.builderInstalled,()=>Ee.builder.artifacts.installed()),gi(Tr.hubAgents,()=>lt.search({type:"agent",limit:50})),gi(Tr.hubTeams,()=>lt.search({type:"team",limit:50})),gi(Tr.hubSkills,()=>lt.search({type:"skill",limit:50}))};typeof requestIdleCallback=="function"?requestIdleCallback(M,{timeout:5e3}):setTimeout(M,3e3)}).catch(()=>{x(null),Ee.auth.status().then(({initialized:Ye,hasOwner:M,hasMultipleUsers:le})=>{S(Ye),j({hasOwner:M,hasMultipleUsers:le})}).catch(()=>S(!0))}),va.connect();const Ke=va.on("notification",()=>{window.dispatchEvent(new CustomEvent("markus:notifications-changed"))}),Ie=()=>{const Ye=f6(pc());Ye!==de.TEAM&&up(!1),n(Ye),g(M=>M.has(Ye)?M:new Set([...M,Ye]))};return window.addEventListener("hashchange",Ie),window.addEventListener("popstate",Ie),()=>{Ke(),va.disconnect(),window.removeEventListener("hashchange",Ie),window.removeEventListener("popstate",Ie)}},[]);const te=y!=="loading"&&y!==null?y:void 0,Ne=k.useMemo(()=>d?{[de.HOME]:s.jsx(dv,{authUser:te}),[de.TEAM]:s.jsx(ew,{authUser:te}),[de.BUILDER]:s.jsx(oY,{authUser:te}),[de.SETTINGS]:s.jsx(tw,{theme:m.mode,onThemeChange:m.setMode,authUser:te,onLogout:()=>{Ee.auth.logout().catch(()=>{}),Ro(),x(null)},onUserUpdated:Q=>x(Q)}),[de.WORK]:s.jsx(nw,{authUser:te}),[de.DELIVERABLES]:s.jsx(rw,{authUser:te}),[de.NOTIFICATIONS]:s.jsx(jY,{authUser:te}),[de.SEARCH]:s.jsx(MY,{})}:{[de.HOME]:s.jsx(dv,{authUser:te}),[de.TEAM]:s.jsx(ew,{authUser:te}),[de.SETTINGS]:s.jsx(tw,{theme:m.mode,onThemeChange:m.setMode,authUser:te,onLogout:()=>{Ee.auth.logout().catch(()=>{}),Ro(),x(null)},onUserUpdated:Q=>x(Q)}),[de.STORE]:s.jsx(EY,{authUser:te}),[de.BUILDER]:s.jsx(_Y,{authUser:te}),[de.WORK]:s.jsx(nw,{authUser:te}),[de.DELIVERABLES]:s.jsx(rw,{authUser:te})},[te?.id,te?.role,m.mode,d]);if(y==="loading"||y===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 $e=(typeof window<"u"?window.location.hash:"").match(/^#invite\?token=([a-f0-9]+)/);return $e?s.jsx(dY,{token:$e[1],onComplete:()=>{window.location.hash="",localStorage.removeItem("markus_onboarded"),o(!0),I(!0),x("loading"),Ee.auth.me().then(Q=>x(Q.user)).catch(()=>x(null))}}):y===null?s.jsx(uY,{hasOwner:E.hasOwner,hasMultipleUsers:E.hasMultipleUsers,onLogin:(Q,Z,be)=>{x(Q),va.connect(Q.id),Z?(localStorage.removeItem("markus_onboarded"),o(!0),be?.fromHub&&I(!0)):localStorage.getItem("markus_onboarded")||(localStorage.setItem("markus_onboarded","1"),o(!1))}}):O?s.jsx(mY,{onComplete:()=>F(!1),isFirstTime:!0}):r?s.jsx(lY,{theme:m.mode,onThemeChange:m.setMode,skipProfile:L,onProfileUpdated:Q=>{const Z={id:Q.id,name:Q.name,email:Q.email,role:Q.role,orgId:Q.orgId??"default",avatarUrl:Q.avatarUrl};x(Z)},onComplete:()=>{localStorage.setItem("markus_onboarded","1"),o(!1),I(!1),Ee.auth.me().then(Q=>x(Q.user)).catch(()=>{}),oe(),Ae(de.HOME)}}):s.jsxs("div",{className:`flex h-dvh bg-surface-primary text-fg-primary overflow-x-hidden ${d?"flex-col":""}`,children:[!d&&t!==de.SETTINGS&&s.jsxs(s.Fragment,{children:[s.jsx("div",{className:"relative z-40 shrink-0",style:{width:f.width},children:s.jsx(fW,{currentPage:t,onNavigate:Q=>{Ae(Q),c(!1),He?.("l0"),Ge?.(Q)},authUser:y,collapsed:f.collapsed,onToggleCollapse:f.toggle,onLogout:()=>{Ee.auth.logout().catch(()=>{}),Ro(),x(null)},keyboardFocusPageId:Pe,keyboardPaneActive:_e==="l0"})}),s.jsx("div",{className:`${f.collapsed?"w-0":"w-1.5 cursor-col-resize"} shrink-0 group relative z-10 flex items-center justify-center`,onMouseDown:f.collapsed?void 0:f.onResizeStart,children:!f.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!==de.SETTINGS&&t!==de.SEARCH?"pb-14":""}`,children:[V===!1&&!z&&t!==de.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:()=>G(!0),className:"text-amber-500 hover:text-amber-600 text-xs",children:e("dismiss")})]})]}),se&&q!==se.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:se.latestVersion,current:se.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:()=>{re(se.latestVersion),localStorage.setItem("markus_update_dismissed",se.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(Ne).map(Q=>h.has(Q)?s.jsx(DY,{id:Q,activePage:t,children:Ne[Q]},Q):null)})]}),d&&t!==de.SETTINGS&&t!==de.SEARCH&&s.jsx(xW,{currentPage:t,onNavigate:Ae,userId:te?.id}),d&&s.jsx(mD,{authUser:te,onNavigate:Ae}),!d&&B&&s.jsx(xY,{onClose:()=>J(!1),currentPage:t}),!d&&s.jsx(TY,{open:fe,onClose:()=>Se(!1),page:t}),w&&te&&s.jsx(AY,{authUser:te,onClose:()=>C(!1),onUserUpdated:Q=>x(Q),onSaved:Q=>{C(!1),x(Q)}})]})}N7.createRoot(document.getElementById("root")).render(s.jsx(k.StrictMode,{children:s.jsx(cV,{children:s.jsx(IY,{})})}));export{g8 as $,Hs as A,Ya as B,Ti as C,dr as D,JO as E,HY as F,K3 as G,VY as H,tY as I,b4 as J,A4 as K,UK as L,Mw as M,uW as N,HK as O,de as P,UY as Q,PY as R,JW as S,FW as T,ZK as U,KY as V,yc as W,fX as X,zY as Y,sa as Z,Gr as _,Uo as a,BY as a0,$Y as a1,wi as a2,Sd as a3,_i as a4,r0 as a5,lX as a6,XK as a7,OV as a8,r4 as a9,sW as aA,oX as aB,WY as aC,qY as aD,G3 as aE,DV as aa,Ai as ab,Yo as ac,JY as ad,bW as ae,mX as af,rX as ag,GY as ah,ZY as ai,QY as aj,YY as ak,aW as al,Yg as am,XY as an,tX as ao,nX as ap,sX as aq,eX as ar,MV as as,dX as at,aX as au,cX as av,iX as aw,lW as ax,uX as ay,F3 as az,dD as b,Lc as c,aY as d,VW as e,XW as f,Ni as g,lt as h,SY as i,s as j,Sa as k,Ee as l,fY as m,it as n,bn as o,fc as p,Er as q,k as r,Wg as s,Hr as t,ft as u,Tc as v,va as w,A0 as x,x8 as y,Ho as z};