@markus-global/cli 0.9.9-rc.2 → 0.9.9

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/web-ui/assets/{CommentInput-B_rgrhLD.js → CommentInput-B9QvgXRU.js} +1 -1
  2. package/dist/web-ui/assets/{ContentRenderer-DyQHyRET.js → ContentRenderer-BEWNNIbH.js} +2 -2
  3. package/dist/web-ui/assets/{DeliverableShareModal-BY5ez6nr.js → DeliverableShareModal-C4bKsQbU.js} +3 -3
  4. package/dist/web-ui/assets/{Deliverables-PJJKw5_I.js → Deliverables-Bx8nwOQ9.js} +1 -1
  5. package/dist/web-ui/assets/{Notifications-DqIUg4CJ.js → Notifications-CApxHk72.js} +1 -1
  6. package/dist/web-ui/assets/{Search-kas6fpbv.js → Search-Afkxd1a6.js} +1 -1
  7. package/dist/web-ui/assets/{Settings-DaeT2xjy.js → Settings-B90Lsxn1.js} +1 -1
  8. package/dist/web-ui/assets/{Store-BjE_14dA.js → Store-DOYqG495.js} +1 -1
  9. package/dist/web-ui/assets/{Team-ADpT-bid.js → Team-BLcZORSs.js} +4 -4
  10. package/dist/web-ui/assets/{Work-BjU-XvpG.js → Work-FiluoP3I.js} +1 -1
  11. package/dist/web-ui/assets/{arc-7GJS7CRG.js → arc-DaSSpFFZ.js} +1 -1
  12. package/dist/web-ui/assets/{architectureDiagram-3BPJPVTR-16h4REV_.js → architectureDiagram-3BPJPVTR-DLDEmNda.js} +1 -1
  13. package/dist/web-ui/assets/{blockDiagram-GPEHLZMM-D6t3zWC0.js → blockDiagram-GPEHLZMM-wjnnl7YH.js} +1 -1
  14. package/dist/web-ui/assets/{c4Diagram-AAUBKEIU-CzyobbUO.js → c4Diagram-AAUBKEIU-PlSSecfa.js} +1 -1
  15. package/dist/web-ui/assets/channel-eCnCx_6n.js +1 -0
  16. package/dist/web-ui/assets/{chunk-2J33WTMH-CvpDz6qL.js → chunk-2J33WTMH-DK9cA6te.js} +1 -1
  17. package/dist/web-ui/assets/{chunk-4BX2VUAB-Df6veiXG.js → chunk-4BX2VUAB-QfjEzeta.js} +1 -1
  18. package/dist/web-ui/assets/{chunk-55IACEB6-CoTtIHdH.js → chunk-55IACEB6-Baasjplz.js} +1 -1
  19. package/dist/web-ui/assets/{chunk-727SXJPM-CdgCVHFp.js → chunk-727SXJPM-ChZiZqSs.js} +1 -1
  20. package/dist/web-ui/assets/{chunk-AQP2D5EJ-D7eMOge4.js → chunk-AQP2D5EJ-CvnzN3BF.js} +1 -1
  21. package/dist/web-ui/assets/{chunk-FMBD7UC4-FzZRkS5y.js → chunk-FMBD7UC4-BnvdtniW.js} +1 -1
  22. package/dist/web-ui/assets/{chunk-ND2GUHAM-D48nYUwc.js → chunk-ND2GUHAM-Cya4BDdk.js} +1 -1
  23. package/dist/web-ui/assets/{chunk-QZHKN3VN-PNMJkmrK.js → chunk-QZHKN3VN-DWHJ4QkC.js} +1 -1
  24. package/dist/web-ui/assets/classDiagram-4FO5ZUOK-Bm-i2o0g.js +1 -0
  25. package/dist/web-ui/assets/classDiagram-v2-Q7XG4LA2-Bm-i2o0g.js +1 -0
  26. package/dist/web-ui/assets/{cose-bilkent-S5V4N54A-DABmt_Nn.js → cose-bilkent-S5V4N54A-CELyP0mw.js} +1 -1
  27. package/dist/web-ui/assets/{dagre-BM42HDAG-w0jd14q4.js → dagre-BM42HDAG-CDI3cyCz.js} +1 -1
  28. package/dist/web-ui/assets/{diagram-2AECGRRQ-ximFHjaP.js → diagram-2AECGRRQ-BsR5QcOg.js} +1 -1
  29. package/dist/web-ui/assets/{diagram-5GNKFQAL-gWFsRPpD.js → diagram-5GNKFQAL-qfBEt9Wm.js} +1 -1
  30. package/dist/web-ui/assets/{diagram-KO2AKTUF-BMzfhoWn.js → diagram-KO2AKTUF-DgV2-oUF.js} +1 -1
  31. package/dist/web-ui/assets/{diagram-LMA3HP47-B9e-0A0Z.js → diagram-LMA3HP47-D3G5wDy7.js} +1 -1
  32. package/dist/web-ui/assets/{diagram-OG6HWLK6-CLqQNd-r.js → diagram-OG6HWLK6-Did_RC7f.js} +1 -1
  33. package/dist/web-ui/assets/{docx-preview-BFPCRZPr.js → docx-preview-CaBnt7lQ.js} +1 -1
  34. package/dist/web-ui/assets/{erDiagram-TEJ5UH35-qUR4XmIX.js → erDiagram-TEJ5UH35-DkCfZBLl.js} +1 -1
  35. package/dist/web-ui/assets/{flowDiagram-I6XJVG4X-CjN2ub4S.js → flowDiagram-I6XJVG4X-CSExusvH.js} +1 -1
  36. package/dist/web-ui/assets/{ganttDiagram-6RSMTGT7-By-5cyGj.js → ganttDiagram-6RSMTGT7-BueFExNX.js} +1 -1
  37. package/dist/web-ui/assets/{gitGraphDiagram-PVQCEYII-Bs13DgJn.js → gitGraphDiagram-PVQCEYII-B6AA-uri.js} +1 -1
  38. package/dist/web-ui/assets/{index-nn4q01mt.js → index-DHzWBdt5.js} +4 -4
  39. package/dist/web-ui/assets/{infoDiagram-5YYISTIA-Pyb2VrTD.js → infoDiagram-5YYISTIA-pN1OECDX.js} +1 -1
  40. package/dist/web-ui/assets/{ishikawaDiagram-YF4QCWOH-jISGKv-9.js → ishikawaDiagram-YF4QCWOH-DYLLTDk5.js} +1 -1
  41. package/dist/web-ui/assets/{journeyDiagram-JHISSGLW-BXnkNg9b.js → journeyDiagram-JHISSGLW-Cvhifuv6.js} +1 -1
  42. package/dist/web-ui/assets/{kanban-definition-UN3LZRKU-BV4ynBuw.js → kanban-definition-UN3LZRKU-DQlM9G-1.js} +1 -1
  43. package/dist/web-ui/assets/{mermaid.core-DeC0XDN4.js → mermaid.core-DL-UboGV.js} +5 -5
  44. package/dist/web-ui/assets/{mindmap-definition-RKZ34NQL-CEPK_ZV-.js → mindmap-definition-RKZ34NQL-h2m6w0EF.js} +1 -1
  45. package/dist/web-ui/assets/{pieDiagram-4H26LBE5-DreL09eo.js → pieDiagram-4H26LBE5-eSVk7_C0.js} +1 -1
  46. package/dist/web-ui/assets/{quadrantDiagram-W4KKPZXB-Bh3oKDxD.js → quadrantDiagram-W4KKPZXB-DIryaeZl.js} +1 -1
  47. package/dist/web-ui/assets/{requirementDiagram-4Y6WPE33-DWn-QfAY.js → requirementDiagram-4Y6WPE33-BVjw_HOt.js} +1 -1
  48. package/dist/web-ui/assets/{sankeyDiagram-5OEKKPKP-BnzVNTOP.js → sankeyDiagram-5OEKKPKP-CBvvHuJW.js} +1 -1
  49. package/dist/web-ui/assets/{sequenceDiagram-3UESZ5HK-iUEb-afs.js → sequenceDiagram-3UESZ5HK-DrhK7vnS.js} +1 -1
  50. package/dist/web-ui/assets/{stateDiagram-AJRCARHV-COc-ItOe.js → stateDiagram-AJRCARHV-CwvoCJ1j.js} +1 -1
  51. package/dist/web-ui/assets/stateDiagram-v2-BHNVJYJU-BflH5xmz.js +1 -0
  52. package/dist/web-ui/assets/{timeline-definition-PNZ67QCA-C8rO-noK.js → timeline-definition-PNZ67QCA-DOet_7ho.js} +1 -1
  53. package/dist/web-ui/assets/{vennDiagram-CIIHVFJN-Cpnk-2oH.js → vennDiagram-CIIHVFJN-B6DiA4eK.js} +1 -1
  54. package/dist/web-ui/assets/{wardley-L42UT6IY-BG39VhSj.js → wardley-L42UT6IY-DgN-f4t8.js} +1 -1
  55. package/dist/web-ui/assets/{wardleyDiagram-YWT4CUSO-wpyKdMmG.js → wardleyDiagram-YWT4CUSO-66dcjCfX.js} +1 -1
  56. package/dist/web-ui/assets/{xychartDiagram-2RQKCTM6-CP0mGBV4.js → xychartDiagram-2RQKCTM6-D8EN-vdQ.js} +1 -1
  57. package/dist/web-ui/index.html +1 -1
  58. package/package.json +1 -1
  59. package/dist/web-ui/assets/channel-CSoBs8Wc.js +0 -1
  60. package/dist/web-ui/assets/classDiagram-4FO5ZUOK-B2TGJzph.js +0 -1
  61. package/dist/web-ui/assets/classDiagram-v2-Q7XG4LA2-B2TGJzph.js +0 -1
  62. package/dist/web-ui/assets/stateDiagram-v2-BHNVJYJU-DaMprGFB.js +0 -1
@@ -1,4 +1,4 @@
1
- const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/mermaid.core-DeC0XDN4.js","assets/transform-CpIVI4vC.js","assets/Team-ADpT-bid.js","assets/CommentInput-B_rgrhLD.js","assets/ContentRenderer-DyQHyRET.js","assets/DeliverableShareModal-BY5ez6nr.js","assets/Team-DFuMZ0ql.css","assets/Work-BjU-XvpG.js","assets/value-DIujSiJ7.js","assets/Work-BZV40eAE.css","assets/Deliverables-PJJKw5_I.js"])))=>i.map(i=>d[i]);
1
+ const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/mermaid.core-DL-UboGV.js","assets/transform-CpIVI4vC.js","assets/Team-BLcZORSs.js","assets/CommentInput-B9QvgXRU.js","assets/ContentRenderer-BEWNNIbH.js","assets/DeliverableShareModal-C4bKsQbU.js","assets/Team-DFuMZ0ql.css","assets/Work-FiluoP3I.js","assets/value-DIujSiJ7.js","assets/Work-BZV40eAE.css","assets/Deliverables-Bx8nwOQ9.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 i of document.querySelectorAll('link[rel="modulepreload"]'))r(i);new MutationObserver(i=>{for(const l of i)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(i){const l={};return i.integrity&&(l.integrity=i.integrity),i.referrerPolicy&&(l.referrerPolicy=i.referrerPolicy),i.crossOrigin==="use-credentials"?l.credentials="include":i.crossOrigin==="anonymous"?l.credentials="omit":l.credentials="same-origin",l}function r(i){if(i.ep)return;i.ep=!0;const l=n(i);fetch(i.href,l)}})();var qX=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function Ec(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var Zf={exports:{}},Wl={};var My;function T7(){if(My)return Wl;My=1;var e=Symbol.for("react.transitional.element"),t=Symbol.for("react.fragment");function n(r,i,l){var c=null;if(l!==void 0&&(c=""+l),i.key!==void 0&&(c=""+i.key),"key"in i){l={};for(var d in i)d!=="key"&&(l[d]=i[d])}else l=i;return i=l.ref,{$$typeof:e,type:r,key:c,ref:i!==void 0?i:null,props:l}}return Wl.Fragment=t,Wl.jsx=n,Wl.jsxs=n,Wl}var Ry;function A7(){return Ry||(Ry=1,Zf.exports=T7()),Zf.exports}var s=A7(),Jf={exports:{}},Ot={};var Dy;function E7(){if(Dy)return Ot;Dy=1;var e=Symbol.for("react.transitional.element"),t=Symbol.for("react.portal"),n=Symbol.for("react.fragment"),r=Symbol.for("react.strict_mode"),i=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(G){return G===null||typeof G!="object"?null:(G=y&&G[y]||G["@@iterator"],typeof G=="function"?G:null)}var w={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},T=Object.assign,C={};function S(G,me,P){this.props=G,this.context=me,this.refs=C,this.updater=P||w}S.prototype.isReactComponent={},S.prototype.setState=function(G,me){if(typeof G!="object"&&typeof G!="function"&&G!=null)throw Error("takes an object of state variables to update or a function which returns an object of state variables.");this.updater.enqueueSetState(this,G,me,"setState")},S.prototype.forceUpdate=function(G){this.updater.enqueueForceUpdate(this,G,"forceUpdate")};function E(){}E.prototype=S.prototype;function j(G,me,P){this.props=G,this.context=me,this.refs=C,this.updater=P||w}var M=j.prototype=new E;M.constructor=j,T(M,S.prototype),M.isPureReactComponent=!0;var O=Array.isArray;function D(){}var H={H:null,A:null,T:null,S:null},q=Object.prototype.hasOwnProperty;function Q(G,me,P){var _e=P.ref;return{$$typeof:e,type:G,key:me,ref:_e!==void 0?_e:null,props:P}}function B(G,me){return Q(G.type,me,G.props)}function J(G){return typeof G=="object"&&G!==null&&G.$$typeof===e}function W(G){var me={"=":"=0",":":"=2"};return"$"+G.replace(/[=:]/g,function(P){return me[P]})}var re=/\/+/g;function F(G,me){return typeof G=="object"&&G!==null&&G.key!=null?W(""+G.key):me.toString(36)}function te(G){switch(G.status){case"fulfilled":return G.value;case"rejected":throw G.reason;default:switch(typeof G.status=="string"?G.then(D,D):(G.status="pending",G.then(function(me){G.status==="pending"&&(G.status="fulfilled",G.value=me)},function(me){G.status==="pending"&&(G.status="rejected",G.reason=me)})),G.status){case"fulfilled":return G.value;case"rejected":throw G.reason}}throw G}function L(G,me,P,_e,He){var Pe=typeof G;(Pe==="undefined"||Pe==="boolean")&&(G=null);var Ge=!1;if(G===null)Ge=!0;else switch(Pe){case"bigint":case"string":case"number":Ge=!0;break;case"object":switch(G.$$typeof){case e:case t:Ge=!0;break;case h:return Ge=G._init,L(Ge(G._payload),me,P,_e,He)}}if(Ge)return He=He(G),Ge=_e===""?"."+F(G,0):_e,O(He)?(P="",Ge!=null&&(P=Ge.replace(re,"$&/")+"/"),L(He,me,P,"",function(ht){return ht})):He!=null&&(J(He)&&(He=B(He,P+(He.key==null||G&&G.key===He.key?"":(""+He.key).replace(re,"$&/")+"/")+Ge)),me.push(He)),1;Ge=0;var ut=_e===""?".":_e+":";if(O(G))for(var pt=0;pt<G.length;pt++)_e=G[pt],Pe=ut+F(_e,pt),Ge+=L(_e,me,P,Pe,He);else if(pt=x(G),typeof pt=="function")for(G=pt.call(G),pt=0;!(_e=G.next()).done;)_e=_e.value,Pe=ut+F(_e,pt++),Ge+=L(_e,me,P,Pe,He);else if(Pe==="object"){if(typeof G.then=="function")return L(te(G),me,P,_e,He);throw me=String(G),Error("Objects are not valid as a React child (found: "+(me==="[object Object]"?"object with keys {"+Object.keys(G).join(", ")+"}":me)+"). If you meant to render a collection of children, use an array instead.")}return Ge}function ee(G,me,P){if(G==null)return G;var _e=[],He=0;return L(G,_e,"","",function(Pe){return me.call(P,Pe,He++)}),_e}function ue(G){if(G._status===-1){var me=G._result;me=me(),me.then(function(P){(G._status===0||G._status===-1)&&(G._status=1,G._result=P)},function(P){(G._status===0||G._status===-1)&&(G._status=2,G._result=P)}),G._status===-1&&(G._status=0,G._result=me)}if(G._status===1)return G._result.default;throw G._result}var Se=typeof reportError=="function"?reportError:function(G){if(typeof window=="object"&&typeof window.ErrorEvent=="function"){var me=new window.ErrorEvent("error",{bubbles:!0,cancelable:!0,message:typeof G=="object"&&G!==null&&typeof G.message=="string"?String(G.message):String(G),error:G});if(!window.dispatchEvent(me))return}else if(typeof process=="object"&&typeof process.emit=="function"){process.emit("uncaughtException",G);return}console.error(G)},$={map:ee,forEach:function(G,me,P){ee(G,function(){me.apply(this,arguments)},P)},count:function(G){var me=0;return ee(G,function(){me++}),me},toArray:function(G){return ee(G,function(me){return me})||[]},only:function(G){if(!J(G))throw Error("React.Children.only expected to receive a single React element child.");return G}};return Ot.Activity=g,Ot.Children=$,Ot.Component=S,Ot.Fragment=n,Ot.Profiler=i,Ot.PureComponent=j,Ot.StrictMode=r,Ot.Suspense=m,Ot.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE=H,Ot.__COMPILER_RUNTIME={__proto__:null,c:function(G){return H.H.useMemoCache(G)}},Ot.cache=function(G){return function(){return G.apply(null,arguments)}},Ot.cacheSignal=function(){return null},Ot.cloneElement=function(G,me,P){if(G==null)throw Error("The argument must be a React element, but you passed "+G+".");var _e=T({},G.props),He=G.key;if(me!=null)for(Pe in me.key!==void 0&&(He=""+me.key),me)!q.call(me,Pe)||Pe==="key"||Pe==="__self"||Pe==="__source"||Pe==="ref"&&me.ref===void 0||(_e[Pe]=me[Pe]);var Pe=arguments.length-2;if(Pe===1)_e.children=P;else if(1<Pe){for(var Ge=Array(Pe),ut=0;ut<Pe;ut++)Ge[ut]=arguments[ut+2];_e.children=Ge}return Q(G.type,He,_e)},Ot.createContext=function(G){return G={$$typeof:c,_currentValue:G,_currentValue2:G,_threadCount:0,Provider:null,Consumer:null},G.Provider=G,G.Consumer={$$typeof:l,_context:G},G},Ot.createElement=function(G,me,P){var _e,He={},Pe=null;if(me!=null)for(_e in me.key!==void 0&&(Pe=""+me.key),me)q.call(me,_e)&&_e!=="key"&&_e!=="__self"&&_e!=="__source"&&(He[_e]=me[_e]);var Ge=arguments.length-2;if(Ge===1)He.children=P;else if(1<Ge){for(var ut=Array(Ge),pt=0;pt<Ge;pt++)ut[pt]=arguments[pt+2];He.children=ut}if(G&&G.defaultProps)for(_e in Ge=G.defaultProps,Ge)He[_e]===void 0&&(He[_e]=Ge[_e]);return Q(G,Pe,He)},Ot.createRef=function(){return{current:null}},Ot.forwardRef=function(G){return{$$typeof:d,render:G}},Ot.isValidElement=J,Ot.lazy=function(G){return{$$typeof:h,_payload:{_status:-1,_result:G},_init:ue}},Ot.memo=function(G,me){return{$$typeof:f,type:G,compare:me===void 0?null:me}},Ot.startTransition=function(G){var me=H.T,P={};H.T=P;try{var _e=G(),He=H.S;He!==null&&He(P,_e),typeof _e=="object"&&_e!==null&&typeof _e.then=="function"&&_e.then(D,Se)}catch(Pe){Se(Pe)}finally{me!==null&&P.types!==null&&(me.types=P.types),H.T=me}},Ot.unstable_useCacheRefresh=function(){return H.H.useCacheRefresh()},Ot.use=function(G){return H.H.use(G)},Ot.useActionState=function(G,me,P){return H.H.useActionState(G,me,P)},Ot.useCallback=function(G,me){return H.H.useCallback(G,me)},Ot.useContext=function(G){return H.H.useContext(G)},Ot.useDebugValue=function(){},Ot.useDeferredValue=function(G,me){return H.H.useDeferredValue(G,me)},Ot.useEffect=function(G,me){return H.H.useEffect(G,me)},Ot.useEffectEvent=function(G){return H.H.useEffectEvent(G)},Ot.useId=function(){return H.H.useId()},Ot.useImperativeHandle=function(G,me,P){return H.H.useImperativeHandle(G,me,P)},Ot.useInsertionEffect=function(G,me){return H.H.useInsertionEffect(G,me)},Ot.useLayoutEffect=function(G,me){return H.H.useLayoutEffect(G,me)},Ot.useMemo=function(G,me){return H.H.useMemo(G,me)},Ot.useOptimistic=function(G,me){return H.H.useOptimistic(G,me)},Ot.useReducer=function(G,me,P){return H.H.useReducer(G,me,P)},Ot.useRef=function(G){return H.H.useRef(G)},Ot.useState=function(G){return H.H.useState(G)},Ot.useSyncExternalStore=function(G,me,P){return H.H.useSyncExternalStore(G,me,P)},Ot.useTransition=function(){return H.H.useTransition()},Ot.version="19.2.4",Ot}var Ly;function A0(){return Ly||(Ly=1,Jf.exports=E7()),Jf.exports}var k=A0();const GX=Ec(k);var ep={exports:{}},Yl={},tp={exports:{}},np={};var Oy;function _7(){return Oy||(Oy=1,(function(e){function t(L,ee){var ue=L.length;L.push(ee);e:for(;0<ue;){var Se=ue-1>>>1,$=L[Se];if(0<i($,ee))L[Se]=ee,L[ue]=$,ue=Se;else break e}}function n(L){return L.length===0?null:L[0]}function r(L){if(L.length===0)return null;var ee=L[0],ue=L.pop();if(ue!==ee){L[0]=ue;e:for(var Se=0,$=L.length,G=$>>>1;Se<G;){var me=2*(Se+1)-1,P=L[me],_e=me+1,He=L[_e];if(0>i(P,ue))_e<$&&0>i(He,P)?(L[Se]=He,L[_e]=ue,Se=_e):(L[Se]=P,L[me]=ue,Se=me);else if(_e<$&&0>i(He,ue))L[Se]=He,L[_e]=ue,Se=_e;else break e}}return ee}function i(L,ee){var ue=L.sortIndex-ee.sortIndex;return ue!==0?ue:L.id-ee.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,T=!1,C=!1,S=typeof setTimeout=="function"?setTimeout:null,E=typeof clearTimeout=="function"?clearTimeout:null,j=typeof setImmediate<"u"?setImmediate:null;function M(L){for(var ee=n(f);ee!==null;){if(ee.callback===null)r(f);else if(ee.startTime<=L)r(f),ee.sortIndex=ee.expirationTime,t(m,ee);else break;ee=n(f)}}function O(L){if(T=!1,M(L),!w)if(n(m)!==null)w=!0,D||(D=!0,W());else{var ee=n(f);ee!==null&&te(O,ee.startTime-L)}}var D=!1,H=-1,q=5,Q=-1;function B(){return C?!0:!(e.unstable_now()-Q<q)}function J(){if(C=!1,D){var L=e.unstable_now();Q=L;var ee=!0;try{e:{w=!1,T&&(T=!1,E(H),H=-1),x=!0;var ue=y;try{t:{for(M(L),g=n(m);g!==null&&!(g.expirationTime>L&&B());){var Se=g.callback;if(typeof Se=="function"){g.callback=null,y=g.priorityLevel;var $=Se(g.expirationTime<=L);if(L=e.unstable_now(),typeof $=="function"){g.callback=$,M(L),ee=!0;break t}g===n(m)&&r(m),M(L)}else r(m);g=n(m)}if(g!==null)ee=!0;else{var G=n(f);G!==null&&te(O,G.startTime-L),ee=!1}}break e}finally{g=null,y=ue,x=!1}ee=void 0}}finally{ee?W():D=!1}}}var W;if(typeof j=="function")W=function(){j(J)};else if(typeof MessageChannel<"u"){var re=new MessageChannel,F=re.port2;re.port1.onmessage=J,W=function(){F.postMessage(null)}}else W=function(){S(J,0)};function te(L,ee){H=S(function(){L(e.unstable_now())},ee)}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(L){L.callback=null},e.unstable_forceFrameRate=function(L){0>L||125<L?console.error("forceFrameRate takes a positive int between 0 and 125, forcing frame rates higher than 125 fps is not supported"):q=0<L?Math.floor(1e3/L):5},e.unstable_getCurrentPriorityLevel=function(){return y},e.unstable_next=function(L){switch(y){case 1:case 2:case 3:var ee=3;break;default:ee=y}var ue=y;y=ee;try{return L()}finally{y=ue}},e.unstable_requestPaint=function(){C=!0},e.unstable_runWithPriority=function(L,ee){switch(L){case 1:case 2:case 3:case 4:case 5:break;default:L=3}var ue=y;y=L;try{return ee()}finally{y=ue}},e.unstable_scheduleCallback=function(L,ee,ue){var Se=e.unstable_now();switch(typeof ue=="object"&&ue!==null?(ue=ue.delay,ue=typeof ue=="number"&&0<ue?Se+ue:Se):ue=Se,L){case 1:var $=-1;break;case 2:$=250;break;case 5:$=1073741823;break;case 4:$=1e4;break;default:$=5e3}return $=ue+$,L={id:h++,callback:ee,priorityLevel:L,startTime:ue,expirationTime:$,sortIndex:-1},ue>Se?(L.sortIndex=ue,t(f,L),n(m)===null&&L===n(f)&&(T?(E(H),H=-1):T=!0,te(O,ue-Se))):(L.sortIndex=$,t(m,L),w||x||(w=!0,D||(D=!0,W()))),L},e.unstable_shouldYield=B,e.unstable_wrapCallback=function(L){var ee=y;return function(){var ue=y;y=ee;try{return L.apply(this,arguments)}finally{y=ue}}}})(np)),np}var Iy;function j7(){return Iy||(Iy=1,tp.exports=_7()),tp.exports}var rp={exports:{}},fr={};var Py;function M7(){if(Py)return fr;Py=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},i=Symbol.for("react.portal");function l(m,f,h){var g=3<arguments.length&&arguments[3]!==void 0?arguments[3]:null;return{$$typeof:i,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 fr.__DOM_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE=r,fr.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)},fr.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()}},fr.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))},fr.prefetchDNS=function(m){typeof m=="string"&&r.d.D(m)},fr.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})}},fr.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)},fr.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})}},fr.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)},fr.requestFormReset=function(m){r.d.r(m)},fr.unstable_batchedUpdates=function(m,f){return m(f)},fr.useFormState=function(m,f,h){return c.H.useFormState(m,f,h)},fr.useFormStatus=function(){return c.H.useHostTransitionStatus()},fr.version="19.2.4",fr}var By;function mw(){if(By)return rp.exports;By=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=M7(),rp.exports}var zy;function R7(){if(zy)return Yl;zy=1;var e=j7(),t=A0(),n=mw();function r(a){var o="https://react.dev/errors/"+a;if(1<arguments.length){o+="?args[]="+encodeURIComponent(arguments[1]);for(var u=2;u<arguments.length;u++)o+="&args[]="+encodeURIComponent(arguments[u])}return"Minified React error #"+a+"; visit "+o+" for the full message or use the non-minified dev environment for full errors and additional helpful warnings."}function i(a){return!(!a||a.nodeType!==1&&a.nodeType!==9&&a.nodeType!==11)}function l(a){var o=a,u=a;if(a.alternate)for(;o.return;)o=o.return;else{a=o;do o=a,(o.flags&4098)!==0&&(u=o.return),a=o.return;while(a)}return o.tag===3?u:null}function c(a){if(a.tag===13){var o=a.memoizedState;if(o===null&&(a=a.alternate,a!==null&&(o=a.memoizedState)),o!==null)return o.dehydrated}return null}function d(a){if(a.tag===31){var o=a.memoizedState;if(o===null&&(a=a.alternate,a!==null&&(o=a.memoizedState)),o!==null)return o.dehydrated}return null}function m(a){if(l(a)!==a)throw Error(r(188))}function f(a){var o=a.alternate;if(!o){if(o=l(a),o===null)throw Error(r(188));return o!==a?null:a}for(var u=a,p=o;;){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),o;v=v.sibling}throw Error(r(188))}if(u.return!==p.return)u=b,p=v;else{for(var _=!1,I=b.child;I;){if(I===u){_=!0,u=b,p=v;break}if(I===p){_=!0,p=b,u=v;break}I=I.sibling}if(!_){for(I=v.child;I;){if(I===u){_=!0,u=v,p=b;break}if(I===p){_=!0,p=v,u=b;break}I=I.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:o}function h(a){var o=a.tag;if(o===5||o===26||o===27||o===6)return a;for(a=a.child;a!==null;){if(o=h(a),o!==null)return o;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"),T=Symbol.for("react.fragment"),C=Symbol.for("react.strict_mode"),S=Symbol.for("react.profiler"),E=Symbol.for("react.consumer"),j=Symbol.for("react.context"),M=Symbol.for("react.forward_ref"),O=Symbol.for("react.suspense"),D=Symbol.for("react.suspense_list"),H=Symbol.for("react.memo"),q=Symbol.for("react.lazy"),Q=Symbol.for("react.activity"),B=Symbol.for("react.memo_cache_sentinel"),J=Symbol.iterator;function W(a){return a===null||typeof a!="object"?null:(a=J&&a[J]||a["@@iterator"],typeof a=="function"?a:null)}var re=Symbol.for("react.client.reference");function F(a){if(a==null)return null;if(typeof a=="function")return a.$$typeof===re?null:a.displayName||a.name||null;if(typeof a=="string")return a;switch(a){case T:return"Fragment";case S:return"Profiler";case C:return"StrictMode";case O:return"Suspense";case D:return"SuspenseList";case Q: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 M:var o=a.render;return a=a.displayName,a||(a=o.displayName||o.name||"",a=a!==""?"ForwardRef("+a+")":"ForwardRef"),a;case H:return o=a.displayName||null,o!==null?o:F(a.type)||"Memo";case q:o=a._payload,a=a._init;try{return F(a(o))}catch{}}return null}var te=Array.isArray,L=t.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,ee=n.__DOM_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,ue={pending:!1,data:null,method:null,action:null},Se=[],$=-1;function G(a){return{current:a}}function me(a){0>$||(a.current=Se[$],Se[$]=null,$--)}function P(a,o){$++,Se[$]=a.current,a.current=o}var _e=G(null),He=G(null),Pe=G(null),Ge=G(null);function ut(a,o){switch(P(Pe,o),P(He,a),P(_e,null),o.nodeType){case 9:case 11:a=(a=o.documentElement)&&(a=a.namespaceURI)?ey(a):0;break;default:if(a=o.tagName,o=o.namespaceURI)o=ey(o),a=ty(o,a);else switch(a){case"svg":a=1;break;case"math":a=2;break;default:a=0}}me(_e),P(_e,a)}function pt(){me(_e),me(He),me(Pe)}function ht(a){a.memoizedState!==null&&P(Ge,a);var o=_e.current,u=ty(o,a.type);o!==u&&(P(He,a),P(_e,u))}function Mt(a){He.current===a&&(me(_e),me(He)),Ge.current===a&&(me(Ge),ql._currentValue=ue)}var Bt,Qt;function wt(a){if(Bt===void 0)try{throw Error()}catch(u){var o=u.stack.trim().match(/\n( *(at )?)/);Bt=o&&o[1]||"",Qt=-1<u.stack.indexOf(`
3
3
  at`)?" (<anonymous>)":-1<u.stack.indexOf("@")?"@unknown:0:0":""}return`
4
4
  `+Bt+a+Qt}var Ue=!1;function ft(a,o){if(!a||Ue)return"";Ue=!0;var u=Error.prepareStackTrace;Error.prepareStackTrace=void 0;try{var p={DetermineComponentFrameRoot:function(){try{if(o){var Le=function(){throw Error()};if(Object.defineProperty(Le.prototype,"props",{set:function(){throw Error()}}),typeof Reflect=="object"&&Reflect.construct){try{Reflect.construct(Le,[])}catch(Te){var Ne=Te}Reflect.construct(a,[],Le)}else{try{Le.call()}catch(Te){Ne=Te}a.call(Le.prototype)}}else{try{throw Error()}catch(Te){Ne=Te}(Le=a())&&typeof Le.catch=="function"&&Le.catch(function(){})}}catch(Te){if(Te&&Ne&&typeof Te.stack=="string")return[Te.stack,Ne.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],I=v[1];if(_&&I){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 iK=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_-]*/}}),oK=["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"],lK=["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"],cK=[...oK,...lK],uK=["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(),h3=["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(),g3=["after","backdrop","before","cue","cue-region","first-letter","first-line","grammar-error","marker","part","placeholder","selection","slotted","spelling-error"].sort().reverse(),dK=["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(),mK=h3.concat(g3).sort().reverse();function fK(e){const t=iK(e),n=mK,r="and or not only",i="[\\w-]+",l="("+i+"|@\\{"+i+"\\})",c=[],d=[],m=function(j){return{className:"string",begin:"~?"+j+".*?"+j}},f=function(j,M,O){return{className:j,begin:M,relevance:O}},h={$pattern:/[a-z-]+/,keyword:r,attribute:uK.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","@@?"+i,10),f("variable","@\\{"+i+"\\}"),f("built_in","~?`[^`]*?`"),{className:"attribute",begin:i+"\\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("+dK.join("|")+")\\b",end:/(?=:)/,starts:{endsWithParent:!0,illegal:"[<=$]",relevance:0,contains:d}}]},T={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}},C={className:"variable",variants:[{begin:"@"+i+"\\s*:",relevance:15},{begin:"@"+i}],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","@\\{"+i+"\\}"),{begin:"\\b("+cK.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:":("+h3.join("|")+")"},{className:"selector-pseudo",begin:":(:)?("+g3.join("|")+")"},{begin:/\(/,end:/\)/,relevance:0,contains:y},{begin:"!important"},t.FUNCTION_DISPATCH]},E={begin:i+`:(:)?(${n.join("|")})`,returnBegin:!0,contains:[S]};return c.push(e.C_LINE_COMMENT_MODE,e.C_BLOCK_COMMENT_MODE,T,C,E,w,S,x,t.FUNCTION_DISPATCH),{name:"Less",case_insensitive:!0,illegal:`[=>'/<($"]`,contains:c}}function pK(e){const t="\\[=*\\[",n="\\]=*\\]",r={begin:t,end:n,contains:["self"]},i=[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:i.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:i}].concat(i)},e.C_NUMBER_MODE,e.APOS_STRING_MODE,e.QUOTE_STRING_MODE,{className:"string",begin:t,end:n,contains:[r],relevance:5}])}}function hK(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]},i={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,i,l,c]}}function gK(e){const t=e.regex,n={begin:/<\/?[A-Za-z_]/,end:">",subLanguage:"xml",relevance:0},r={begin:"^[-\\*]{3,}",end:"$"},i={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:"$"},i,r,m,c,{scope:"literal",match:/&([a-zA-Z0-9]+|#[0-9]{1,7}|#[Xx][0-9a-fA-F]{1,6});/}]}}function bK(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 xK(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}/,i={$pattern:/[\w.]+/,keyword:n.join(" ")},l={className:"subst",begin:"[$@]\\{",end:"\\}",keywords:i},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=(T,C,S="\\1")=>{const E=S==="\\1"?S:t.concat(S,C);return t.concat(t.concat("(?:",T,")"),C,/(?:\\.|[^\\\/])*?/,E,/(?:\\.|[^\\\/])*?/,S,r)},x=(T,C,S)=>t.concat(t.concat("(?:",T,")"),C,/(?:\\.|[^\\\/])*?/,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:i,contains:w}}function yK(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),i=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":(F,te)=>{te.data._beginMatch=F[1]||F[2]},"on:end":(F,te)=>{te.data._beginMatch!==F[1]&&te.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]},T={scope:"number",variants:[{begin:"\\b0[bB][01]+(?:_[01]+)*\\b"},{begin:"\\b0[oO][0-7]+(?:_[0-7]+)*\\b"},{begin:"\\b0[xX][\\da-fA-F]+(?:_[\\da-fA-F]+)*\\b"},{begin:"(?:\\b\\d+(?:_\\d+)*(\\.(?:\\d+(?:_\\d+)*))?|\\B\\.\\d+)(?:[eE][+-]?\\d+)?"}],relevance:0},C=["false","null","true"],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"],M={keyword:S,literal:(F=>{const te=[];return F.forEach(L=>{te.push(L),L.toLowerCase()===L?te.push(L.toUpperCase()):te.push(L.toLowerCase())}),te})(C),built_in:E},O=F=>F.map(te=>te.replace(/\|\d+$/,"")),D={variants:[{match:[/new/,t.concat(x,"+"),t.concat("(?!",O(E).join("\\b|"),"\\b)"),i],scope:{1:"keyword",4:"title.class"}}]},H=t.concat(r,"\\b(?!\\()"),q={variants:[{match:[t.concat(/::/,t.lookahead(/(?!class\b)/)),H],scope:{2:"variable.constant"}},{match:[/::/,/class/],scope:{2:"variable.language"}},{match:[i,t.concat(/::/,t.lookahead(/(?!class\b)/)),H],scope:{1:"title.class",3:"variable.constant"}},{match:[i,t.concat("::",t.lookahead(/(?!class\b)/))],scope:{1:"title.class"}},{match:[i,/::/,/class/],scope:{1:"title.class",3:"variable.language"}}]},Q={scope:"attr",match:t.concat(r,t.lookahead(":"),t.lookahead(/(?!::)/))},B={relevance:0,begin:/\(/,end:/\)/,keywords:M,contains:[Q,c,q,e.C_BLOCK_COMMENT_MODE,w,T,D]},J={relevance:0,match:[/\b/,t.concat("(?!fn\\b|function\\b|",O(S).join("\\b|"),"|",O(E).join("\\b|"),"\\b)"),r,t.concat(x,"*"),t.lookahead(/(?=\()/)],scope:{3:"title.function.invoke"},contains:[B]};B.contains.push(J);const W=[Q,q,e.C_BLOCK_COMMENT_MODE,w,T,D],re={begin:t.concat(/#\[\s*\\?/,t.either(i,l)),beginScope:"meta",end:/]/,endScope:"meta",keywords:{literal:C,keyword:["new","array"]},contains:[{begin:/\[/,end:/]/,keywords:{literal:C,keyword:["new","array"]},contains:["self",...W]},...W,{scope:"meta",variants:[{match:i},{match:l}]}]};return{case_insensitive:!1,keywords:M,contains:[re,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,J,q,{match:[/const/,/\s/,r],scope:{1:"keyword",3:"variable.constant"}},D,{scope:"function",relevance:0,beginKeywords:"fn function",end:/[;{]/,excludeEnd:!0,illegal:"[$%\\[]",contains:[{beginKeywords:"use"},e.UNDERSCORE_TITLE_MODE,{begin:"=>",endsParent:!0},{scope:"params",begin:"\\(",end:"\\)",excludeBegin:!0,excludeEnd:!0,keywords:M,contains:["self",re,c,q,e.C_BLOCK_COMMENT_MODE,w,T]}]},{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,T]}}function vK(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 wK(e){return{name:"Plain text",aliases:["text","txt"],disableAutodetect:!0}}function kK(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("|")}`,T={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})`}]},C={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,T,g,e.HASH_COMMENT_MODE]}]};return f.contains=[g,T,m],{name:"Python",aliases:["py","gyp","ipython"],unicodeRegex:!0,keywords:d,illegal:/(<\/|\?)|=>/,contains:[m,T,{scope:"variable.language",match:/\bself\b/},{beginKeywords:"if",relevance:0},{match:/\bor\b/,scope:"keyword"},g,C,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:[T,S,g]}]}}function SK(e){return{aliases:["pycon"],contains:[{className:"meta.prompt",starts:{end:/ |$/,starts:{end:"$",subLanguage:"python"}},variants:[{begin:/^>>>(?=[ ]|$)/},{begin:/^\.\.\.(?=[ ]|$)/}]}]}}function NK(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]?/),i=/[=!<>:]=|\|\||&&|:::?|<-|<<-|->>|->|\|>|[-+*\/?!$&|:<=>@^~]|\*\*/,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:[i,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:i},{match:/%[^%]*%/}]},{scope:"punctuation",relevance:0,match:l},{begin:"`",end:"`",contains:[{begin:/\\./}]}]}}function CK(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]+/),i=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"}]},T={variants:[{match:/\(\)/},{className:"params",begin:/\(/,end:/(?=\))/,excludeBegin:!0,endsParent:!0,keywords:c}]},D=[g,{variants:[{match:[/class\s+/,i,/\s+<\s+/,i]},{match:[/\b(class|module)\s+/,i]}],scope:{2:"title.class",4:"title.class.inherited"},keywords:c},{match:[/(include|extend)\s+/,i],scope:{2:"title.class"},keywords:c},{relevance:0,match:[i,/\.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:[T]},{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=D,T.contains=D;const B=[{begin:/^\s*=>/,starts:{end:"$",contains:D}},{className:"meta.prompt",begin:"^("+"[>?]>"+"|"+"[\\w#]+\\(\\w+\\):\\d+:\\d+[>*]"+"|"+"(\\w+-)?\\d+\\.\\d+\\.\\d+(p\\d+)?[^\\d][^>]+>"+")(?=[ ])",starts:{end:"$",keywords:c,contains:D}}];return f.unshift(m),{name:"Ruby",aliases:["rb","gemspec","podspec","thor","irb"],keywords:c,illegal:/\/\*/,contains:[e.SHEBANG({binary:"ruby"})].concat(B).concat(f).concat(D)}}function TK(e){const t=e.regex,n=/(r#)?/,r=t.concat(n,e.UNDERSCORE_IDENT_RE),i=t.concat(n,e.IDENT_RE),l={className:"title.function.invoke",relevance:0,begin:t.concat(/\b/,/(?!let|for|while|if|else|match\b)/,i,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 AK=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_-]*/}}),EK=["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"],_K=["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"],jK=[...EK,..._K],MK=["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(),RK=["active","any-link","blank","checked","current","default","defined","dir","disabled","drop","empty","enabled","first","first-child","first-of-type","fullscreen","future","focus","focus-visible","focus-within","has","host","host-context","hover","indeterminate","in-range","invalid","is","lang","last-child","last-of-type","left","link","local-link","not","nth-child","nth-col","nth-last-child","nth-last-col","nth-last-of-type","nth-of-type","only-child","only-of-type","optional","out-of-range","past","placeholder-shown","read-only","read-write","required","right","root","scope","target","target-within","user-invalid","valid","visited","where"].sort().reverse(),DK=["after","backdrop","before","cue","cue-region","first-letter","first-line","grammar-error","marker","part","placeholder","selection","slotted","spelling-error"].sort().reverse(),LK=["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 OK(e){const t=AK(e),n=DK,r=RK,i="@[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("+jK.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("+LK.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:i,keyword:"@page @font-face"}},{begin:"@",end:"[{;]",returnBegin:!0,keywords:{$pattern:/[a-z-]+/,keyword:l,attribute:MK.join(" ")},contains:[{begin:i,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 IK(e){return{name:"Shell Session",aliases:["console","shellsession"],contains:[{className:"meta.prompt",begin:/^\s{0,3}[/~\w\d[\]()@-]*[>%$#][ ]?/,starts:{end:/[^\\](?=\s*$)/,subLanguage:"bash"}}]}}function PK(e){const t=e.regex,n=e.COMMENT("--","$"),r={scope:"string",variants:[{begin:/'/,end:/'/,contains:[{match:/''/}]}]},i={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(O=>!h.includes(O)),T={scope:"variable",match:/@[a-z0-9][a-z0-9_]*/},C={scope:"operator",match:/[-+*/=%^~]|&&?|\|\|?|!=?|<(?:=>?|<|>)?|>[>=]?/,relevance:0},S={match:t.concat(/\b/,t.either(...x),/\s*\(/),relevance:0,keywords:{built_in:x}};function E(O){return t.concat(/\b/,t.either(...O.map(D=>D.replace(/\s+/,"\\s+"))),/\b/)}const j={scope:"keyword",match:E(y),relevance:0};function M(O,{exceptions:D,when:H}={}){const q=H;return D=D||[],O.map(Q=>Q.match(/\|\d+$/)||D.includes(Q)?Q:q(Q)?`${Q}|0`:Q)}return{name:"SQL",case_insensitive:!0,illegal:/[{}]|<\//,keywords:{$pattern:/\b[\w\.]+/,keyword:M(w,{when:O=>O.length<3}),literal:l,type:d,built_in:g},contains:[{scope:"type",match:E(c)},j,S,T,r,i,e.C_NUMBER_MODE,e.C_BLOCK_COMMENT_MODE,n,C]}}function b3(e){return e?typeof e=="string"?e:e.source:null}function tc(e){return wn("(?=",e,")")}function wn(...e){return e.map(n=>b3(n)).join("")}function BK(e){const t=e[e.length-1];return typeof t=="object"&&t.constructor===Object?(e.splice(e.length-1,1),t):{}}function yr(...e){return"("+(BK(e).capture?"":"?:")+e.map(r=>b3(r)).join("|")+")"}const Wg=e=>wn(/\b/,e,/\w$/.test(e)?/\b/:/\B/),zK=["Protocol","Type"].map(Wg),t4=["init","self"].map(Wg),$K=["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"],n4=["false","nil","true"],HK=["assignment","associativity","higherThan","left","lowerThan","none","right"],UK=["#colorLiteral","#column","#dsohandle","#else","#elseif","#endif","#error","#file","#fileID","#fileLiteral","#filePath","#function","#if","#imageLiteral","#keyPath","#line","#selector","#sourceLocation","#warning"],r4=["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"],x3=yr(/[/=\-+!*%<>&|^~?]/,/[\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]/),y3=yr(x3,/[\u0300-\u036F]/,/[\u1DC0-\u1DFF]/,/[\u20D0-\u20FF]/,/[\uFE00-\uFE0F]/,/[\uFE20-\uFE2F]/),Yp=wn(x3,y3,"*"),v3=yr(/[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=yr(v3,/\d/,/[\u0300-\u036F\u1DC0-\u1DFF\u20D0-\u20FF\uFE20-\uFE2F]/),Aa=wn(v3,h0,"*"),vd=wn(/[A-Z]/,h0,"*"),FK=["attached","autoclosure",wn(/convention\(/,yr("swift","block","c"),/\)/),"discardableResult","dynamicCallable","dynamicMemberLookup","escaping","freestanding","frozen","GKInspectable","IBAction","IBDesignable","IBInspectable","IBOutlet","IBSegueAction","inlinable","main","nonobjc","NSApplicationMain","NSCopying","NSManaged",wn(/objc\(/,Aa,/\)/),"objc","objcMembers","propertyWrapper","requires_stored_property_inits","resultBuilder","Sendable","testable","UIApplicationMain","unchecked","unknown","usableFromInline","warn_unqualified_access"],qK=["iOS","iOSApplicationExtension","macOS","macOSApplicationExtension","macCatalyst","macCatalystApplicationExtension","watchOS","watchOSApplicationExtension","tvOS","tvOSApplicationExtension","swift"];function GK(e){const t={match:/\s+/,relevance:0},n=e.COMMENT("/\\*","\\*/",{contains:["self"]}),r=[e.C_LINE_COMMENT_MODE,n],i={match:[/\./,yr(...zK,...t4)],className:{2:"keyword"}},l={match:wn(/\./,yr(...Wp)),relevance:0},c=Wp.filter(ft=>typeof ft=="string").concat(["_|0"]),d=Wp.filter(ft=>typeof ft!="string").concat($K).map(Wg),m={variants:[{className:"keyword",match:yr(...d,...t4)}]},f={$pattern:yr(/\b\w+/,/#\w+/),keyword:c.concat(UK),literal:n4},h=[i,l,m],g={match:wn(/\./,yr(...r4)),relevance:0},y={className:"built_in",match:wn(/\b/,yr(...r4),/(?=\()/)},x=[g,y],w={match:/->/,relevance:0},T={className:"operator",relevance:0,variants:[{match:Yp},{match:`\\.(\\.|${y3})+`}]},C=[w,T],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/}]},M=(ft="")=>({className:"subst",variants:[{match:wn(/\\/,ft,/[0\\tnr"']/)},{match:wn(/\\/,ft,/u\{[0-9a-fA-F]{1,8}\}/)}]}),O=(ft="")=>({className:"subst",match:wn(/\\/,ft,/[\t ]*(?:[\r\n]|\r\n)/)}),D=(ft="")=>({className:"subst",label:"interpol",begin:wn(/\\/,ft,/\(/),end:/\)/}),H=(ft="")=>({begin:wn(ft,/"""/),end:wn(/"""/,ft),contains:[M(ft),O(ft),D(ft)]}),q=(ft="")=>({begin:wn(ft,/"/),end:wn(/"/,ft),contains:[M(ft),D(ft)]}),Q={className:"string",variants:[H(),H("#"),H("##"),H("###"),q(),q("#"),q("##"),q("###")]},B=[e.BACKSLASH_ESCAPE,{begin:/\[/,end:/\]/,relevance:0,contains:[e.BACKSLASH_ESCAPE]}],J={begin:/\/[^\s](?=[^/\n]*\/)/,end:/\//,contains:B},W=ft=>{const kt=wn(ft,/\//),Nt=wn(/\//,ft);return{begin:kt,end:Nt,contains:[...B,{scope:"comment",begin:`#(?!.*${Nt})`,end:/$/}]}},re={scope:"regexp",variants:[W("###"),W("##"),W("#"),J]},F={match:wn(/`/,Aa,/`/)},te={className:"variable",match:/\$\d+/},L={className:"variable",match:`\\$${h0}+`},ee=[F,te,L],ue={match:/(@|#(un)?)available/,scope:"keyword",starts:{contains:[{begin:/\(/,end:/\)/,keywords:qK,contains:[...C,j,Q]}]}},Se={scope:"keyword",match:wn(/@/,yr(...FK),tc(yr(/\(/,/\s+/)))},$={scope:"meta",match:wn(/@/,Aa)},G=[ue,Se,$],me={match:tc(/\b[A-Z]/),relevance:0,contains:[{className:"type",match:wn(/(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:wn(/\s+&\s+/,tc(vd)),relevance:0}]},P={begin:/</,end:/>/,keywords:f,contains:[...r,...h,...G,w,me]};me.contains.push(P);const _e={match:wn(Aa,/\s*:/),keywords:"_|0",relevance:0},He={begin:/\(/,end:/\)/,relevance:0,keywords:f,contains:["self",_e,...r,re,...h,...x,...C,j,Q,...ee,...G,me]},Pe={begin:/</,end:/>/,keywords:"repeat each",contains:[...r,me]},Ge={begin:yr(tc(wn(Aa,/\s*:/)),tc(wn(Aa,/\s+/,Aa,/\s*:/))),end:/:/,relevance:0,contains:[{className:"keyword",match:/\b_\b/},{className:"params",match:Aa}]},ut={begin:/\(/,end:/\)/,keywords:f,contains:[Ge,...r,...h,...C,j,Q,...G,me,He],endsParent:!0,illegal:/["']/},pt={match:[/(func|macro)/,/\s+/,yr(F.match,Aa,Yp)],className:{1:"keyword",3:"title.function"},contains:[Pe,ut,t],illegal:[/\[/,/%/]},ht={match:[/\b(?:subscript|init[?!]?)/,/\s*(?=[<(])/],className:{1:"keyword"},contains:[Pe,ut,t],illegal:/\[|%/},Mt={match:[/operator/,/\s+/,Yp],className:{1:"keyword",3:"title"}},Bt={begin:[/precedencegroup/,/\s+/,vd],className:{1:"keyword",3:"title"},contains:[me],keywords:[...HK,...n4],end:/}/},Qt={match:[/class\b/,/\s+/,/func\b/,/\s+/,/\b[A-Za-z_][A-Za-z0-9_]*\b/],scope:{1:"keyword",3:"keyword",5:"title.function"}},wt={match:[/class\b/,/\s+/,/var\b/],scope:{1:"keyword",3:"keyword"}},Ue={begin:[/(struct|protocol|class|extension|enum|actor)/,/\s+/,Aa,/\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 ft of Q.variants){const kt=ft.contains.find(zt=>zt.label==="interpol");kt.keywords=f;const Nt=[...h,...x,...C,j,Q,...ee];kt.contains=[...Nt,{begin:/\(/,end:/\)/,contains:["self",...Nt]}]}return{name:"Swift",keywords:f,contains:[...r,pt,ht,Qt,wt,Ue,Mt,Bt,{beginKeywords:"import",end:/$/,contains:[...r],relevance:0},re,...h,...x,...C,j,Q,...ee,...G,me,He]}}const g0="[A-Za-z$_][0-9A-Za-z$_]*",w3=["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"],k3=["true","false","null","undefined","NaN","Infinity"],S3=["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"],N3=["Error","EvalError","InternalError","RangeError","ReferenceError","SyntaxError","TypeError","URIError"],C3=["setInterval","setTimeout","clearInterval","clearTimeout","require","exports","eval","isFinite","isNaN","parseFloat","parseInt","decodeURI","decodeURIComponent","encodeURI","encodeURIComponent","escape","unescape"],T3=["arguments","this","super","console","window","document","localStorage","sessionStorage","module","global"],A3=[].concat(C3,S3,N3);function KK(e){const t=e.regex,n=(ue,{after:Se})=>{const $="</"+ue[0].slice(1);return ue.input.indexOf($,Se)!==-1},r=g0,i={begin:"<>",end:"</>"},l=/<[A-Za-z0-9\\._:-]+\s*\/>/,c={begin:/<[A-Za-z0-9\\._:-]+/,end:/\/[A-Za-z0-9\\._:-]+>|\/>/,isTrulyOpeningTag:(ue,Se)=>{const $=ue[0].length+ue.index,G=ue.input[$];if(G==="<"||G===","){Se.ignoreMatch();return}G===">"&&(n(ue,{after:$})||Se.ignoreMatch());let me;const P=ue.input.substring($);if(me=P.match(/^\s*=/)){Se.ignoreMatch();return}if((me=P.match(/^\s+extends\s+/))&&me.index===0){Se.ignoreMatch();return}}},d={$pattern:g0,keyword:w3,literal:k3,built_in:A3,"variable.language":T3},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"}},T={begin:".?gql`",end:"",starts:{end:"`",returnEnd:!1,contains:[e.BACKSLASH_ESCAPE,y],subLanguage:"graphql"}},C={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,T,C,{match:/\$\d+/},g];y.contains=j.concat({begin:/\{/,end:/\}/,keywords:d,contains:["self"].concat(j)});const M=[].concat(E,y.contains),O=M.concat([{begin:/(\s*)\(/,end:/\)/,keywords:d,contains:["self"].concat(M)}]),D={className:"params",begin:/(\s*)\(/,end:/\)/,excludeBegin:!0,excludeEnd:!0,keywords:d,contains:O},H={variants:[{match:[/class/,/\s+/,r,/\s+/,/extends/,/\s+/,t.concat(r,"(",t.concat(/\./,r),")*")],scope:{1:"keyword",3:"title.class",5:"keyword",7:"title.class.inherited"}},{match:[/class/,/\s+/,r],scope:{1:"keyword",3:"title.class"}}]},q={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:{_:[...S3,...N3]}},Q={label:"use_strict",className:"meta",relevance:10,begin:/^\s*['"]use (strict|asm)['"]/},B={variants:[{match:[/function/,/\s+/,r,/(?=\s*\()/]},{match:[/function/,/\s*(?=\()/]}],className:{1:"keyword",3:"title.function"},label:"func.def",contains:[D],illegal:/%/},J={relevance:0,match:/\b[A-Z][A-Z_0-9]+\b/,className:"variable.constant"};function W(ue){return t.concat("(?!",ue.join("|"),")")}const re={match:t.concat(/\b/,W([...C3,"super","import"].map(ue=>`${ue}\\s*\\(`)),r,t.lookahead(/\s*\(/)),className:"title.function",relevance:0},F={begin:t.concat(/\./,t.lookahead(t.concat(r,/(?![0-9A-Za-z$_(])/))),end:r,excludeBegin:!0,keywords:"prototype",className:"property",relevance:0},te={match:[/get|set/,/\s+/,r,/(?=\()/],className:{1:"keyword",3:"title.function"},contains:[{begin:/\(\)/},D]},L="(\\([^()]*(\\([^()]*(\\([^()]*\\)[^()]*)*\\)[^()]*)*\\)|"+e.UNDERSCORE_IDENT_RE+")\\s*=>",ee={match:[/const|var|let/,/\s+/,r,/\s*/,/=\s*/,/(async\s*)?/,t.lookahead(L)],keywords:"async",className:{1:"keyword",3:"title.function"},contains:[D]};return{name:"JavaScript",aliases:["js","jsx","mjs","cjs"],keywords:d,exports:{PARAMS_CONTAINS:O,CLASS_REFERENCE:q},illegal:/#(?![$_A-z])/,contains:[e.SHEBANG({label:"shebang",binary:"node",relevance:5}),Q,e.APOS_STRING_MODE,e.QUOTE_STRING_MODE,x,w,T,C,E,{match:/\$\d+/},g,q,{scope:"attr",match:r+t.lookahead(":"),relevance:0},ee,{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:L,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:O}]}]},{begin:/,/,relevance:0},{match:/\s+/,relevance:0},{variants:[{begin:i.begin,end:i.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"]}]}]},B,{beginKeywords:"while if switch catch for"},{begin:"\\b(?!function)"+e.UNDERSCORE_IDENT_RE+"\\([^()]*(\\([^()]*(\\([^()]*\\)[^()]*)*\\)[^()]*)*\\)\\s*\\{",returnBegin:!0,label:"func.def",contains:[D,e.inherit(e.TITLE_MODE,{begin:r,className:"title.function"})]},{match:/\.\.\./,relevance:0},F,{match:"\\$"+r,relevance:0},{match:[/\bconstructor(?=\s*\()/],className:{1:"title.function"},contains:[D]},re,J,H,te,{match:/\$[(.]/}]}}function VK(e){const t=e.regex,n=KK(e),r=g0,i=["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:i},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:w3.concat(m),literal:k3,built_in:A3.concat(i),"variable.language":T3},h={className:"meta",begin:"@"+r},g=(T,C,S)=>{const E=T.contains.findIndex(j=>j.label===C);if(E===-1)throw new Error("can not find mode to replace");T.contains.splice(E,1,S)};Object.assign(n.keywords,f),n.exports.PARAMS_CONTAINS.push(h);const y=n.contains.find(T=>T.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(T=>T.label==="func.def");return w.relevance=0,Object.assign(n,{name:"TypeScript",aliases:["ts","tsx","mts","cts"]}),n}function WK(e){const t=e.regex,n={className:"string",begin:/"(""|[^/n])"C\b/},r={className:"string",begin:/"/,end:/"/,illegal:/\n/,contains:[{begin:/""/}]},i=/\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,i),/ *#/)},{begin:t.concat(/# */,d,/ *#/)},{begin:t.concat(/# */,c,/ *#/)},{begin:t.concat(/# */,t.either(l,i),/ +/,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 YK(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"],i={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,i,e.QUOTE_STRING_MODE,m,f,d]}}function XK(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,i={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:[i]},{begin:/'/,end:/'/,contains:[i]},{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},i,{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 QK(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]|$)/}]},i={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,i]},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},T={begin:"\\[",end:"\\]",contains:[x],illegal:"\\n",relevance:0},C=[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,T,l,c],S=[...C];return S.pop(),S.push(d),x.contains=S,{name:"YAML",case_insensitive:!0,aliases:["yml"],contains:C}}const ZK={arduino:DG,bash:LG,c:OG,cpp:IG,csharp:PG,css:KG,diff:VG,go:WG,graphql:YG,ini:XG,java:QG,javascript:nK,json:rK,kotlin:sK,less:fK,lua:pK,makefile:hK,markdown:gK,objectivec:bK,perl:xK,php:yK,"php-template":vK,plaintext:wK,python:kK,"python-repl":SK,r:NK,ruby:CK,rust:TK,scss:OK,shell:IK,sql:PK,swift:GK,typescript:VK,vbnet:WK,wasm:YK,xml:XK,yaml:QK};var Xp,a4;function JK(){if(a4)return Xp;a4=1;function e(V){return V instanceof Map?V.clear=V.delete=V.set=function(){throw new Error("map is read-only")}:V instanceof Set&&(V.add=V.clear=V.delete=function(){throw new Error("set is read-only")}),Object.freeze(V),Object.getOwnPropertyNames(V).forEach(he=>{const Ie=V[he],Je=typeof Ie;(Je==="object"||Je==="function")&&!Object.isFrozen(Ie)&&e(Ie)}),V}class t{constructor(he){he.data===void 0&&(he.data={}),this.data=he.data,this.isMatchIgnored=!1}ignoreMatch(){this.isMatchIgnored=!0}}function n(V){return V.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&#x27;")}function r(V,...he){const Ie=Object.create(null);for(const Je in V)Ie[Je]=V[Je];return he.forEach(function(Je){for(const dt in Je)Ie[dt]=Je[dt]}),Ie}const i="</span>",l=V=>!!V.scope,c=(V,{prefix:he})=>{if(V.startsWith("language:"))return V.replace("language:","language-");if(V.includes(".")){const Ie=V.split(".");return[`${he}${Ie.shift()}`,...Ie.map((Je,dt)=>`${Je}${"_".repeat(dt+1)}`)].join(" ")}return`${he}${V}`};class d{constructor(he,Ie){this.buffer="",this.classPrefix=Ie.classPrefix,he.walk(this)}addText(he){this.buffer+=n(he)}openNode(he){if(!l(he))return;const Ie=c(he.scope,{prefix:this.classPrefix});this.span(Ie)}closeNode(he){l(he)&&(this.buffer+=i)}value(){return this.buffer}span(he){this.buffer+=`<span class="${he}">`}}const m=(V={})=>{const he={children:[]};return Object.assign(he,V),he};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(he){this.top.children.push(he)}openNode(he){const Ie=m({scope:he});this.add(Ie),this.stack.push(Ie)}closeNode(){if(this.stack.length>1)return this.stack.pop()}closeAllNodes(){for(;this.closeNode(););}toJSON(){return JSON.stringify(this.rootNode,null,4)}walk(he){return this.constructor._walk(he,this.rootNode)}static _walk(he,Ie){return typeof Ie=="string"?he.addText(Ie):Ie.children&&(he.openNode(Ie),Ie.children.forEach(Je=>this._walk(he,Je)),he.closeNode(Ie)),he}static _collapse(he){typeof he!="string"&&he.children&&(he.children.every(Ie=>typeof Ie=="string")?he.children=[he.children.join("")]:he.children.forEach(Ie=>{f._collapse(Ie)}))}}class h extends f{constructor(he){super(),this.options=he}addText(he){he!==""&&this.add(he)}startScope(he){this.openNode(he)}endScope(){this.closeNode()}__addSublanguage(he,Ie){const Je=he.root;Ie&&(Je.scope=`language:${Ie}`),this.add(Je)}toHTML(){return new d(this,this.options).value()}finalize(){return this.closeAllNodes(),!0}}function g(V){return V?typeof V=="string"?V:V.source:null}function y(V){return T("(?=",V,")")}function x(V){return T("(?:",V,")*")}function w(V){return T("(?:",V,")?")}function T(...V){return V.map(Ie=>g(Ie)).join("")}function C(V){const he=V[V.length-1];return typeof he=="object"&&he.constructor===Object?(V.splice(V.length-1,1),he):{}}function S(...V){return"("+(C(V).capture?"":"?:")+V.map(Je=>g(Je)).join("|")+")"}function E(V){return new RegExp(V.toString()+"|").exec("").length-1}function j(V,he){const Ie=V&&V.exec(he);return Ie&&Ie.index===0}const M=/\[(?:[^\\\]]|\\.)*\]|\(\??|\\([1-9][0-9]*)|\\./;function O(V,{joinWith:he}){let Ie=0;return V.map(Je=>{Ie+=1;const dt=Ie;let _t=g(Je),ct="";for(;_t.length>0;){const st=M.exec(_t);if(!st){ct+=_t;break}ct+=_t.substring(0,st.index),_t=_t.substring(st.index+st[0].length),st[0][0]==="\\"&&st[1]?ct+="\\"+String(Number(st[1])+dt):(ct+=st[0],st[0]==="("&&Ie++)}return ct}).map(Je=>`(${Je})`).join(he)}const D=/\b\B/,H="[a-zA-Z]\\w*",q="[a-zA-Z_]\\w*",Q="\\b\\d+(\\.\\d+)?",B="(-?)(\\b0[xX][a-fA-F0-9]+|(\\b\\d+(\\.\\d*)?|\\.\\d+)([eE][-+]?\\d+)?)",J="\\b(0b[01]+)",W="!|!=|!==|%|%=|&|&&|&=|\\*|\\*=|\\+|\\+=|,|-|-=|/=|/|:|;|<<|<<=|<=|<|===|==|=|>>>=|>>=|>=|>>>|>>|>|\\?|\\[|\\{|\\(|\\^|\\^=|\\||\\|=|\\|\\||~",re=(V={})=>{const he=/^#![ ]*\//;return V.binary&&(V.begin=T(he,/.*\b/,V.binary,/\b.*/)),r({scope:"meta",begin:he,end:/$/,relevance:0,"on:begin":(Ie,Je)=>{Ie.index!==0&&Je.ignoreMatch()}},V)},F={begin:"\\\\[\\s\\S]",relevance:0},te={scope:"string",begin:"'",end:"'",illegal:"\\n",contains:[F]},L={scope:"string",begin:'"',end:'"',illegal:"\\n",contains:[F]},ee={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/},ue=function(V,he,Ie={}){const Je=r({scope:"comment",begin:V,end:he,contains:[]},Ie);Je.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 dt=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 Je.contains.push({begin:T(/[ ]+/,"(",dt,/[.]?[:]?([.][ ]|[ ])/,"){3}")}),Je},Se=ue("//","$"),$=ue("/\\*","\\*/"),G=ue("#","$"),me={scope:"number",begin:Q,relevance:0},P={scope:"number",begin:B,relevance:0},_e={scope:"number",begin:J,relevance:0},He={scope:"regexp",begin:/\/(?=[^/\n]*\/)/,end:/\/[gimuy]*/,contains:[F,{begin:/\[/,end:/\]/,relevance:0,contains:[F]}]},Pe={scope:"title",begin:H,relevance:0},Ge={scope:"title",begin:q,relevance:0},ut={begin:"\\.\\s*"+q,relevance:0};var ht=Object.freeze({__proto__:null,APOS_STRING_MODE:te,BACKSLASH_ESCAPE:F,BINARY_NUMBER_MODE:_e,BINARY_NUMBER_RE:J,COMMENT:ue,C_BLOCK_COMMENT_MODE:$,C_LINE_COMMENT_MODE:Se,C_NUMBER_MODE:P,C_NUMBER_RE:B,END_SAME_AS_BEGIN:function(V){return Object.assign(V,{"on:begin":(he,Ie)=>{Ie.data._beginMatch=he[1]},"on:end":(he,Ie)=>{Ie.data._beginMatch!==he[1]&&Ie.ignoreMatch()}})},HASH_COMMENT_MODE:G,IDENT_RE:H,MATCH_NOTHING_RE:D,METHOD_GUARD:ut,NUMBER_MODE:me,NUMBER_RE:Q,PHRASAL_WORDS_MODE:ee,QUOTE_STRING_MODE:L,REGEXP_MODE:He,RE_STARTERS_RE:W,SHEBANG:re,TITLE_MODE:Pe,UNDERSCORE_IDENT_RE:q,UNDERSCORE_TITLE_MODE:Ge});function Mt(V,he){V.input[V.index-1]==="."&&he.ignoreMatch()}function Bt(V,he){V.className!==void 0&&(V.scope=V.className,delete V.className)}function Qt(V,he){he&&V.beginKeywords&&(V.begin="\\b("+V.beginKeywords.split(" ").join("|")+")(?!\\.)(?=\\b|\\s)",V.__beforeBegin=Mt,V.keywords=V.keywords||V.beginKeywords,delete V.beginKeywords,V.relevance===void 0&&(V.relevance=0))}function wt(V,he){Array.isArray(V.illegal)&&(V.illegal=S(...V.illegal))}function Ue(V,he){if(V.match){if(V.begin||V.end)throw new Error("begin & end are not supported with match");V.begin=V.match,delete V.match}}function ft(V,he){V.relevance===void 0&&(V.relevance=1)}const kt=(V,he)=>{if(!V.beforeMatch)return;if(V.starts)throw new Error("beforeMatch cannot be used with starts");const Ie=Object.assign({},V);Object.keys(V).forEach(Je=>{delete V[Je]}),V.keywords=Ie.keywords,V.begin=T(Ie.beforeMatch,y(Ie.begin)),V.starts={relevance:0,contains:[Object.assign(Ie,{endsParent:!0})]},V.relevance=0,delete Ie.beforeMatch},Nt=["of","and","for","in","not","or","if","then","parent","list","value"],zt="keyword";function ce(V,he,Ie=zt){const Je=Object.create(null);return typeof V=="string"?dt(Ie,V.split(" ")):Array.isArray(V)?dt(Ie,V):Object.keys(V).forEach(function(_t){Object.assign(Je,ce(V[_t],he,_t))}),Je;function dt(_t,ct){he&&(ct=ct.map(st=>st.toLowerCase())),ct.forEach(function(st){const Tt=st.split("|");Je[Tt[0]]=[_t,tt(Tt[0],Tt[1])]})}}function tt(V,he){return he?Number(he):rt(V)?0:1}function rt(V){return Nt.includes(V.toLowerCase())}const be={},je=V=>{console.error(V)},Ae=(V,...he)=>{console.log(`WARN: ${V}`,...he)},oe=(V,he)=>{be[`${V}/${he}`]||(console.log(`Deprecated as of ${V}. ${he}`),be[`${V}/${he}`]=!0)},U=new Error;function ae(V,he,{key:Ie}){let Je=0;const dt=V[Ie],_t={},ct={};for(let st=1;st<=he.length;st++)ct[st+Je]=dt[st],_t[st+Je]=!0,Je+=E(he[st-1]);V[Ie]=ct,V[Ie]._emit=_t,V[Ie]._multi=!0}function Ce(V){if(Array.isArray(V.begin)){if(V.skip||V.excludeBegin||V.returnBegin)throw je("skip, excludeBegin, returnBegin not compatible with beginScope: {}"),U;if(typeof V.beginScope!="object"||V.beginScope===null)throw je("beginScope must be object"),U;ae(V,V.begin,{key:"beginScope"}),V.begin=O(V.begin,{joinWith:""})}}function Re(V){if(Array.isArray(V.end)){if(V.skip||V.excludeEnd||V.returnEnd)throw je("skip, excludeEnd, returnEnd not compatible with endScope: {}"),U;if(typeof V.endScope!="object"||V.endScope===null)throw je("endScope must be object"),U;ae(V,V.end,{key:"endScope"}),V.end=O(V.end,{joinWith:""})}}function ze(V){V.scope&&typeof V.scope=="object"&&V.scope!==null&&(V.beginScope=V.scope,delete V.scope)}function X(V){ze(V),typeof V.beginScope=="string"&&(V.beginScope={_wrap:V.beginScope}),typeof V.endScope=="string"&&(V.endScope={_wrap:V.endScope}),Ce(V),Re(V)}function Z(V){function he(ct,st){return new RegExp(g(ct),"m"+(V.case_insensitive?"i":"")+(V.unicodeRegex?"u":"")+(st?"g":""))}class Ie{constructor(){this.matchIndexes={},this.regexes=[],this.matchAt=1,this.position=0}addRule(st,Tt){Tt.position=this.position++,this.matchIndexes[this.matchAt]=Tt,this.regexes.push([Tt,st]),this.matchAt+=E(st)+1}compile(){this.regexes.length===0&&(this.exec=()=>null);const st=this.regexes.map(Tt=>Tt[1]);this.matcherRe=he(O(st,{joinWith:"|"}),!0),this.lastIndex=0}exec(st){this.matcherRe.lastIndex=this.lastIndex;const Tt=this.matcherRe.exec(st);if(!Tt)return null;const kn=Tt.findIndex((ve,Ke)=>Ke>0&&ve!==void 0),bn=this.matchIndexes[kn];return Tt.splice(0,kn),Object.assign(Tt,bn)}}class Je{constructor(){this.rules=[],this.multiRegexes=[],this.count=0,this.lastIndex=0,this.regexIndex=0}getMatcher(st){if(this.multiRegexes[st])return this.multiRegexes[st];const Tt=new Ie;return this.rules.slice(st).forEach(([kn,bn])=>Tt.addRule(kn,bn)),Tt.compile(),this.multiRegexes[st]=Tt,Tt}resumingScanAtSamePosition(){return this.regexIndex!==0}considerAll(){this.regexIndex=0}addRule(st,Tt){this.rules.push([st,Tt]),Tt.type==="begin"&&this.count++}exec(st){const Tt=this.getMatcher(this.regexIndex);Tt.lastIndex=this.lastIndex;let kn=Tt.exec(st);if(this.resumingScanAtSamePosition()&&!(kn&&kn.index===this.lastIndex)){const bn=this.getMatcher(0);bn.lastIndex=this.lastIndex+1,kn=bn.exec(st)}return kn&&(this.regexIndex+=kn.position+1,this.regexIndex===this.count&&this.considerAll()),kn}}function dt(ct){const st=new Je;return ct.contains.forEach(Tt=>st.addRule(Tt.begin,{rule:Tt,type:"begin"})),ct.terminatorEnd&&st.addRule(ct.terminatorEnd,{type:"end"}),ct.illegal&&st.addRule(ct.illegal,{type:"illegal"}),st}function _t(ct,st){const Tt=ct;if(ct.isCompiled)return Tt;[Bt,Ue,X,kt].forEach(bn=>bn(ct,st)),V.compilerExtensions.forEach(bn=>bn(ct,st)),ct.__beforeBegin=null,[Qt,wt,ft].forEach(bn=>bn(ct,st)),ct.isCompiled=!0;let kn=null;return typeof ct.keywords=="object"&&ct.keywords.$pattern&&(ct.keywords=Object.assign({},ct.keywords),kn=ct.keywords.$pattern,delete ct.keywords.$pattern),kn=kn||/\w+/,ct.keywords&&(ct.keywords=ce(ct.keywords,V.case_insensitive)),Tt.keywordPatternRe=he(kn,!0),st&&(ct.begin||(ct.begin=/\B|\b/),Tt.beginRe=he(Tt.begin),!ct.end&&!ct.endsWithParent&&(ct.end=/\B|\b/),ct.end&&(Tt.endRe=he(Tt.end)),Tt.terminatorEnd=g(Tt.end)||"",ct.endsWithParent&&st.terminatorEnd&&(Tt.terminatorEnd+=(ct.end?"|":"")+st.terminatorEnd)),ct.illegal&&(Tt.illegalRe=he(ct.illegal)),ct.contains||(ct.contains=[]),ct.contains=[].concat(...ct.contains.map(function(bn){return Fe(bn==="self"?ct:bn)})),ct.contains.forEach(function(bn){_t(bn,Tt)}),ct.starts&&_t(ct.starts,st),Tt.matcher=dt(Tt),Tt}if(V.compilerExtensions||(V.compilerExtensions=[]),V.contains&&V.contains.includes("self"))throw new Error("ERR: contains `self` is not supported at the top-level of a language. See documentation.");return V.classNameAliases=r(V.classNameAliases||{}),_t(V)}function pe(V){return V?V.endsWithParent||pe(V.starts):!1}function Fe(V){return V.variants&&!V.cachedVariants&&(V.cachedVariants=V.variants.map(function(he){return r(V,{variants:null},he)})),V.cachedVariants?V.cachedVariants:pe(V)?r(V,{starts:V.starts?r(V.starts):null}):Object.isFrozen(V)?r(V):V}var Oe="11.11.1";class $e extends Error{constructor(he,Ie){super(he),this.name="HTMLInjectionError",this.html=Ie}}const Y=n,ye=r,Ye=Symbol("nomatch"),xe=7,nt=function(V){const he=Object.create(null),Ie=Object.create(null),Je=[];let dt=!0;const _t="Could not find the language '{}', did you forget to load/include a language module?",ct={disableAutodetect:!0,name:"Plain text",contains:[]};let st={ignoreUnescapedHTML:!1,throwUnescapedHTML:!1,noHighlightRe:/^(no-?highlight)$/i,languageDetectRe:/\blang(?:uage)?-([\w-]+)\b/i,classPrefix:"hljs-",cssSelector:"pre code",languages:null,__emitter:h};function Tt(Ve){return st.noHighlightRe.test(Ve)}function kn(Ve){let St=Ve.className+" ";St+=Ve.parentNode?Ve.parentNode.className:"";const Gt=st.languageDetectRe.exec(St);if(Gt){const fn=tr(Gt[1]);return fn||(Ae(_t.replace("{}",Gt[1])),Ae("Falling back to no-highlight mode for this block.",Ve)),fn?Gt[1]:"no-highlight"}return St.split(/\s+/).find(fn=>Tt(fn)||tr(fn))}function bn(Ve,St,Gt){let fn="",Hn="";typeof St=="object"?(fn=Ve,Gt=St.ignoreIllegals,Hn=St.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`),Hn=Ve,fn=St),Gt===void 0&&(Gt=!0);const mr={code:fn,language:Hn};ri("before:highlight",mr);const Hr=mr.result?mr.result:ve(mr.language,mr.code,Gt);return Hr.code=mr.code,ri("after:highlight",Hr),Hr}function ve(Ve,St,Gt,fn){const Hn=Object.create(null);function mr(et,xt){return et.keywords[xt]}function Hr(){if(!jt.keywords){Gn.addText(pn);return}let et=0;jt.keywordPatternRe.lastIndex=0;let xt=jt.keywordPatternRe.exec(pn),It="";for(;xt;){It+=pn.substring(et,xt.index);const Jt=or.case_insensitive?xt[0].toLowerCase():xt[0],Ln=mr(jt,Jt);if(Ln){const[aa,il]=Ln;if(Gn.addText(It),It="",Hn[Jt]=(Hn[Jt]||0)+1,Hn[Jt]<=xe&&(gs+=il),aa.startsWith("_"))It+=xt[0];else{const Hc=or.classNameAliases[aa]||aa;Ur(xt[0],Hc)}}else It+=xt[0];et=jt.keywordPatternRe.lastIndex,xt=jt.keywordPatternRe.exec(pn)}It+=pn.substring(et),Gn.addText(It)}function Tr(){if(pn==="")return;let et=null;if(typeof jt.subLanguage=="string"){if(!he[jt.subLanguage]){Gn.addText(pn);return}et=ve(jt.subLanguage,pn,!0,$c[jt.subLanguage]),$c[jt.subLanguage]=et._top}else et=qt(pn,jt.subLanguage.length?jt.subLanguage:null);jt.relevance>0&&(gs+=et.relevance),Gn.__addSublanguage(et._emitter,et.language)}function Tn(){jt.subLanguage!=null?Tr():Hr(),pn=""}function Ur(et,xt){et!==""&&(Gn.startScope(xt),Gn.addText(et),Gn.endScope())}function Bc(et,xt){let It=1;const Jt=xt.length-1;for(;It<=Jt;){if(!et._emit[It]){It++;continue}const Ln=or.classNameAliases[et[It]]||et[It],aa=xt[It];Ln?Ur(aa,Ln):(pn=aa,Hr(),pn=""),It++}}function Fi(et,xt){return et.scope&&typeof et.scope=="string"&&Gn.openNode(or.classNameAliases[et.scope]||et.scope),et.beginScope&&(et.beginScope._wrap?(Ur(pn,or.classNameAliases[et.beginScope._wrap]||et.beginScope._wrap),pn=""):et.beginScope._multi&&(Bc(et.beginScope,xt),pn="")),jt=Object.create(et,{parent:{value:jt}}),jt}function rl(et,xt,It){let Jt=j(et.endRe,It);if(Jt){if(et["on:end"]){const Ln=new t(et);et["on:end"](xt,Ln),Ln.isMatchIgnored&&(Jt=!1)}if(Jt){for(;et.endsParent&&et.parent;)et=et.parent;return et}}if(et.endsWithParent)return rl(et.parent,xt,It)}function qi(et){return jt.matcher.regexIndex===0?(pn+=et[0],1):(bs=!0,0)}function X0(et){const xt=et[0],It=et.rule,Jt=new t(It),Ln=[It.__beforeBegin,It["on:begin"]];for(const aa of Ln)if(aa&&(aa(et,Jt),Jt.isMatchIgnored))return qi(xt);return It.skip?pn+=xt:(It.excludeBegin&&(pn+=xt),Tn(),!It.returnBegin&&!It.excludeBegin&&(pn=xt)),Fi(It,et),It.returnBegin?0:xt.length}function Ar(et){const xt=et[0],It=St.substring(et.index),Jt=rl(jt,et,It);if(!Jt)return Ye;const Ln=jt;jt.endScope&&jt.endScope._wrap?(Tn(),Ur(xt,jt.endScope._wrap)):jt.endScope&&jt.endScope._multi?(Tn(),Bc(jt.endScope,et)):Ln.skip?pn+=xt:(Ln.returnEnd||Ln.excludeEnd||(pn+=xt),Tn(),Ln.excludeEnd&&(pn=xt));do jt.scope&&Gn.closeNode(),!jt.skip&&!jt.subLanguage&&(gs+=jt.relevance),jt=jt.parent;while(jt!==Jt.parent);return Jt.starts&&Fi(Jt.starts,et),Ln.returnEnd?0:xt.length}function al(){const et=[];for(let xt=jt;xt!==or;xt=xt.parent)xt.scope&&et.unshift(xt.scope);et.forEach(xt=>Gn.openNode(xt))}let ai={};function Gi(et,xt){const It=xt&&xt[0];if(pn+=et,It==null)return Tn(),0;if(ai.type==="begin"&&xt.type==="end"&&ai.index===xt.index&&It===""){if(pn+=St.slice(xt.index,xt.index+1),!dt){const Jt=new Error(`0 width match regex (${Ve})`);throw Jt.languageName=Ve,Jt.badRule=ai.rule,Jt}return 1}if(ai=xt,xt.type==="begin")return X0(xt);if(xt.type==="illegal"&&!Gt){const Jt=new Error('Illegal lexeme "'+It+'" for mode "'+(jt.scope||"<unnamed>")+'"');throw Jt.mode=jt,Jt}else if(xt.type==="end"){const Jt=Ar(xt);if(Jt!==Ye)return Jt}if(xt.type==="illegal"&&It==="")return pn+=`
648
- `,1;if(sl>1e5&&sl>xt.index*3)throw new Error("potential infinite loop, way more iterations than matches");return pn+=It,It.length}const or=tr(Ve);if(!or)throw je(_t.replace("{}",Ve)),new Error('Unknown language: "'+Ve+'"');const zc=Z(or);let Ki="",jt=fn||zc;const $c={},Gn=new st.__emitter(st);al();let pn="",gs=0,$a=0,sl=0,bs=!1;try{if(or.__emitTokens)or.__emitTokens(St,Gn);else{for(jt.matcher.considerAll();;){sl++,bs?bs=!1:jt.matcher.considerAll(),jt.matcher.lastIndex=$a;const et=jt.matcher.exec(St);if(!et)break;const xt=St.substring($a,et.index),It=Gi(xt,et);$a=et.index+It}Gi(St.substring($a))}return Gn.finalize(),Ki=Gn.toHTML(),{language:Ve,value:Ki,relevance:gs,illegal:!1,_emitter:Gn,_top:jt}}catch(et){if(et.message&&et.message.includes("Illegal"))return{language:Ve,value:Y(St),illegal:!0,relevance:0,_illegalBy:{message:et.message,index:$a,context:St.slice($a-100,$a+100),mode:et.mode,resultSoFar:Ki},_emitter:Gn};if(dt)return{language:Ve,value:Y(St),illegal:!1,relevance:0,errorRaised:et,_emitter:Gn,_top:jt};throw et}}function Ke(Ve){const St={value:Y(Ve),illegal:!1,relevance:0,_top:ct,_emitter:new st.__emitter(st)};return St._emitter.addText(Ve),St}function qt(Ve,St){St=St||st.languages||Object.keys(he);const Gt=Ke(Ve),fn=St.filter(tr).filter(ps).map(Tn=>ve(Tn,Ve,!1));fn.unshift(Gt);const Hn=fn.sort((Tn,Ur)=>{if(Tn.relevance!==Ur.relevance)return Ur.relevance-Tn.relevance;if(Tn.language&&Ur.language){if(tr(Tn.language).supersetOf===Ur.language)return 1;if(tr(Ur.language).supersetOf===Tn.language)return-1}return 0}),[mr,Hr]=Hn,Tr=mr;return Tr.secondBest=Hr,Tr}function sn(Ve,St,Gt){const fn=St&&Ie[St]||Gt;Ve.classList.add("hljs"),Ve.classList.add(`language-${fn}`)}function Zt(Ve){let St=null;const Gt=kn(Ve);if(Tt(Gt))return;if(ri("before:highlightElement",{el:Ve,language:Gt}),Ve.dataset.highlighted){console.log("Element previously highlighted. To highlight again, first unset `dataset.highlighted`.",Ve);return}if(Ve.children.length>0&&(st.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(Ve)),st.throwUnescapedHTML))throw new $e("One of your code blocks includes unescaped HTML.",Ve.innerHTML);St=Ve;const fn=St.textContent,Hn=Gt?bn(fn,{language:Gt,ignoreIllegals:!0}):qt(fn);Ve.innerHTML=Hn.value,Ve.dataset.highlighted="yes",sn(Ve,Gt,Hn.language),Ve.result={language:Hn.language,re:Hn.relevance,relevance:Hn.relevance},Hn.secondBest&&(Ve.secondBest={language:Hn.secondBest.language,relevance:Hn.secondBest.relevance}),ri("after:highlightElement",{el:Ve,result:Hn,text:fn})}function un(Ve){st=ye(st,Ve)}const Pn=()=>{mn(),oe("10.6.0","initHighlighting() deprecated. Use highlightAll() now.")};function $t(){mn(),oe("10.6.0","initHighlightingOnLoad() deprecated. Use highlightAll() now.")}let dn=!1;function mn(){function Ve(){mn()}if(document.readyState==="loading"){dn||window.addEventListener("DOMContentLoaded",Ve,!1),dn=!0;return}document.querySelectorAll(st.cssSelector).forEach(Zt)}function er(Ve,St){let Gt=null;try{Gt=St(V)}catch(fn){if(je("Language definition for '{}' could not be registered.".replace("{}",Ve)),dt)je(fn);else throw fn;Gt=ct}Gt.name||(Gt.name=Ve),he[Ve]=Gt,Gt.rawDefinition=St.bind(null,V),Gt.aliases&&Ba(Gt.aliases,{languageName:Ve})}function ir(Ve){delete he[Ve];for(const St of Object.keys(Ie))Ie[St]===Ve&&delete Ie[St]}function ka(){return Object.keys(he)}function tr(Ve){return Ve=(Ve||"").toLowerCase(),he[Ve]||he[Ie[Ve]]}function Ba(Ve,{languageName:St}){typeof Ve=="string"&&(Ve=[Ve]),Ve.forEach(Gt=>{Ie[Gt.toLowerCase()]=St})}function ps(Ve){const St=tr(Ve);return St&&!St.disableAutodetect}function hs(Ve){Ve["before:highlightBlock"]&&!Ve["before:highlightElement"]&&(Ve["before:highlightElement"]=St=>{Ve["before:highlightBlock"](Object.assign({block:St.el},St))}),Ve["after:highlightBlock"]&&!Ve["after:highlightElement"]&&(Ve["after:highlightElement"]=St=>{Ve["after:highlightBlock"](Object.assign({block:St.el},St))})}function qn(Ve){hs(Ve),Je.push(Ve)}function Pc(Ve){const St=Je.indexOf(Ve);St!==-1&&Je.splice(St,1)}function ri(Ve,St){const Gt=Ve;Je.forEach(function(fn){fn[Gt]&&fn[Gt](St)})}function za(Ve){return oe("10.7.0","highlightBlock will be removed entirely in v12.0"),oe("10.7.0","Please use highlightElement now."),Zt(Ve)}Object.assign(V,{highlight:bn,highlightAuto:qt,highlightAll:mn,highlightElement:Zt,highlightBlock:za,configure:un,initHighlighting:Pn,initHighlightingOnLoad:$t,registerLanguage:er,unregisterLanguage:ir,listLanguages:ka,getLanguage:tr,registerAliases:Ba,autoDetection:ps,inherit:ye,addPlugin:qn,removePlugin:Pc}),V.debugMode=function(){dt=!1},V.safeMode=function(){dt=!0},V.versionString=Oe,V.regex={concat:T,lookahead:y,either:S,optional:w,anyNumberOfTimes:x};for(const Ve in ht)typeof ht[Ve]=="object"&&e(ht[Ve]);return Object.assign(V,ht),V},at=nt({});return at.newInstance=()=>nt({}),Xp=at,at.HighlightJS=at,at.default=at,Xp}var eV=JK();const tV=Ec(eV),s4={},nV="hljs-";function rV(e){const t=tV.newInstance();return e&&l(e),{highlight:n,highlightAuto:r,listLanguages:i,register:l,registerAlias:c,registered:d};function n(m,f,h){const g=h||s4,y=typeof g.prefix=="string"?g.prefix:nV;if(!t.getLanguage(m))throw new Error("Unknown language: `"+m+"` is not registered");t.configure({__emitter:aV,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,T=w.data;return T.language=x.language,T.relevance=x.relevance,w}function r(m,f){const g=(f||s4).subset||i();let y=-1,x=0,w;for(;++y<g.length;){const T=g[y];if(!t.getLanguage(T))continue;const C=n(T,m,f);C.data&&C.data.relevance!==void 0&&C.data.relevance>x&&(x=C.data.relevance,w=C)}return w||{type:"root",children:[],data:{language:void 0,relevance:x}}}function i(){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 aV{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],i=t.root.children;n?r.children.push({type:"element",tagName:"span",properties:{className:[n]},children:i}):r.children.push(...i)}openNode(t){const n=this,r=t.split(".").map(function(c,d){return d?c+"_".repeat(d):n.options.classPrefix+c}),i=this.stack[this.stack.length-1],l={type:"element",tagName:"span",properties:{className:r},children:[]};i.children.push(l),this.stack.push(l)}closeNode(){this.stack.pop()}finalize(){}toHTML(){return""}}const sV={};function E3(e){const t=e||sV,n=t.aliases,r=t.detect||!1,i=t.languages||ZK,l=t.plainText,c=t.prefix,d=t.subset;let m="hljs";const f=rV(i);if(n&&f.registerAlias(n),c){const h=c.indexOf("-");m=h===-1?c:c.slice(0,h)}return function(h,g){O0(h,"element",function(y,x,w){if(y.tagName!=="code"||!w||w.type!=="element"||w.tagName!=="pre")return;const T=iV(y);if(T===!1||!T&&!r||T&&l&&l.includes(T))return;Array.isArray(y.properties.className)||(y.properties.className=[]),y.properties.className.includes(m)||y.properties.className.unshift(m);const C=i3(y,{whitespace:"pre"});let S;try{S=T?f.highlight(T,C,{prefix:c}):f.highlightAuto(C,{prefix:c,subset:d})}catch(E){const j=E;if(T&&/Unknown language/.test(j.message)){g.message("Cannot highlight as `"+T+"`, it’s not registered",{ancestors:[w,y],cause:j,place:y.position,ruleId:"missing-language",source:"rehype-highlight"});return}throw j}!T&&S.data&&S.data.language&&y.properties.className.push("language-"+S.data.language),S.children.length>0&&(y.children=S.children)})}}function iV(e){const t=e.properties.className;let n=-1;if(!Array.isArray(t))return;let r;for(;++n<t.length;){const i=String(t[n]);if(i==="no-highlight"||i==="nohighlight")return!1;!r&&i.slice(0,5)==="lang-"&&(r=i.slice(5)),!r&&i.slice(0,9)==="language-"&&(r=i.slice(9))}return r}const Yg=new Set;function ji(e){e&&Yg.add(e)}function Wh(e){e&&Yg.delete(e)}const _3="markus_right_panel_v1",oV=10,Yh=new Map;function lV(e,t=3e3){Yh.set(e,Date.now()+t)}function cV(e){const t=Yh.get(e);return t==null?!1:Date.now()>t?(Yh.delete(e),!1):!0}function uV(e){return e.kind==="terminal"}function nc(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 i4(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 qs(){return`tab_${Date.now().toString(36)}_${Math.random().toString(36).slice(2,7)}`}function wd(e){let t=e;for(;t.length>oV;){let n=-1;for(let i=t.length-1;i>=0;i--)if(!t[i].pinned){n=i;break}if(n<0)break;const r=t[n];r&&(Xh(r.payload),Qh(r.payload)),t=t.filter((i,l)=>l!==n)}return t}function Xh(e){e?.kind==="url"&&e.browserId&&(lV(e.browserId),window.markusDesktop?.browser?.destroy(e.browserId))}function Qh(e){e?.kind==="terminal"&&e.terminalId&&(Wh(e.terminalId),window.markusDesktop?.terminal?.destroy(e.terminalId))}function dV(e){const t=e.payload;return t.kind==="terminal"?null:t.kind==="url"?yc(t.url||"")||yc(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 mV(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 fV(){try{const e=localStorage.getItem(_3);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 pV(){const e={mode:"browser",browserTabs:[],browserActiveId:null,terminalTabs:[],terminalActiveId:null,stashedBrowserTabs:[],stashedBrowserActiveId:null,stashedTerminalTabs:[],stashedTerminalActiveId:null},t=fV();if(!t)return e;const n=t.browserTabs.map((x,w)=>{try{return mV(x,w)}catch{return null}}).filter(x=>!(!x||x.payload.kind==="terminal"||x.payload.kind==="url"&&yc(x.payload.url||""))),r=n.some(x=>x.id===t.browserActiveId)?t.browserActiveId:n[0]?.id??null,i=(t.terminalTabs||[]).map((x,w)=>{const T=`term_${Date.now().toString(36)}_${w.toString(36)}_${Math.random().toString(36).slice(2,7)}`;return ji(T),{id:x.id||qs(),title:x.title||"Terminal",payload:{kind:"terminal",terminalId:T,title:x.title||"Terminal",cwd:x.cwd}}}),l=i.some(x=>x.id===t.terminalActiveId)?t.terminalActiveId:i[0]?.id??null,c=!!t.browserCollapsed&&n.length>0,d=!!t.terminalCollapsed&&i.length>0,m=c?[]:n,f=c?null:r,h=d?[]:i,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:i,stashedTerminalActiveId:l}}const j3=k.createContext(null);function hV({children:e}){const[t,n]=k.useState(()=>{try{return localStorage.getItem("markus_sidebar_c")==="1"}catch{return!1}}),r=k.useMemo(()=>pV(),[]),[i,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,T]=k.useState(!1),[C,S]=k.useState(!1),[E,j]=k.useState("l0"),[M,O]=k.useState(null),D=k.useCallback(be=>j(be),[]),H=k.useCallback(be=>O(be),[]);k.useEffect(()=>{const be=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(be(oe)){const Ce=oe===Ae.target||oe.contains(Ae.target),Re=!!Ae.target.closest("[data-keep-edit-focus]"),ze=be(Ae.target)||!!Ae.target.closest('input, textarea, select, [contenteditable="true"]'),X=!!Ae.target.closest(".xterm");!Ce&&!Re&&!ze&&!X&&oe.blur()}const U=Ae.target.closest("[data-keyboard-pane]");if(!U)return;const ae=U.getAttribute("data-keyboard-pane");if(!(ae!=="l0"&&ae!=="l1"&&ae!=="l2"&&ae!=="content")&&(j(ae),ae==="l0")){const Re=Ae.target.closest("[data-l0-page-id]")?.getAttribute("data-l0-page-id");Re&&O(Re)}};return document.addEventListener("pointerdown",je,!0),()=>document.removeEventListener("pointerdown",je,!0)},[]);const q=k.useRef(r.stashedBrowserTabs.length>0?r.stashedBrowserTabs:r.browserTabs),Q=k.useRef(r.stashedBrowserActiveId??r.browserActiveId),B=k.useRef(r.stashedTerminalTabs.length>0?r.stashedTerminalTabs:r.terminalTabs),J=k.useRef(r.stashedTerminalActiveId??r.terminalActiveId),W=k.useRef(r.browserActiveId),re=k.useRef(r.terminalActiveId),F=k.useRef(r.browserTabs),te=k.useRef(r.terminalTabs),L=k.useRef(r.mode);W.current=h,re.current=y,F.current=c,te.current=m,L.current=i,k.useEffect(()=>{(r.mode==="terminal"||r.browserTabs.length===0)&&window.markusDesktop?.browser?.hideAll?.()},[]),k.useEffect(()=>{const be=c.length===0&&q.current.length>0,je=m.length===0&&B.current.length>0,Ae=be?q.current:c,oe=je?B.current:m,U=Ae.map(dV).filter(Re=>!!Re),ae=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})),Ce={mode:i,browserTabs:U,browserActiveId:be?Q.current:h,terminalTabs:ae,terminalActiveId:je?J.current:y,browserCollapsed:be,terminalCollapsed:je};try{localStorage.setItem(_3,JSON.stringify(Ce))}catch{}},[i,c,h,m,y]);const ee=k.useCallback(be=>n(be),[]),ue=k.useCallback(()=>n(be=>!be),[]),Se=k.useCallback(()=>{window.markusDesktop?.browser?.hideAll?.()},[]),$=k.useCallback(be=>{l(je=>je===be?je:(be==="terminal"&&Se(),be))},[Se]),G=k.useCallback(be=>{if(be==="terminal"){if(Se(),l("terminal"),n(!0),m.length>0)return;if(B.current.length>0){const Re=B.current,ze=J.current&&Re.some(X=>X.id===J.current)?J.current:Re[0].id;f(Re),x(ze),J.current=ze;return}const U=qs(),ae=`term_${Date.now().toString(36)}_${Math.random().toString(36).slice(2,7)}`;ji(ae);const Ce={id:U,title:"Terminal",payload:{kind:"terminal",terminalId:ae,title:"Terminal"}};B.current=[Ce],f([Ce]),x(Ce.id),J.current=Ce.id;return}if(l("browser"),n(!0),c.length>0)return;if(q.current.length>0){const U=q.current,ae=Q.current&&U.some(Ce=>Ce.id===Q.current)?Q.current:U[0].id;d(U),g(ae),Q.current=ae;return}const je=qs(),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}};q.current=[oe],d([oe]),g(oe.id),Q.current=oe.id},[c.length,m.length,Se]),me=k.useCallback(be=>{const je=nc(be),Ae=qs();if(uV(be)){be.kind==="terminal"&&ji(be.terminalId),l("terminal"),Se();const U=te.current,ae=U.find(ze=>nc(ze.payload)===je)??B.current.find(ze=>nc(ze.payload)===je);let Ce,Re;if(ae)Re=ae.id,Ce=U.some(ze=>ze.id===ae.id)?U:wd([ae,...U]);else{const ze={id:Ae,title:i4(be),payload:be};Ce=wd([ze,...U]),Re=Ae}B.current=Ce,te.current=Ce,f(Ce),x(Re),J.current=Re,re.current=Re}else{l("browser");const U=F.current,ae=U.find(ze=>nc(ze.payload)===je)??q.current.find(ze=>nc(ze.payload)===je);let Ce,Re;if(ae)Re=ae.id,Ce=U.some(ze=>ze.id===ae.id)?U:wd([ae,...U]);else{const ze={id:Ae,title:i4(be),payload:be};Ce=wd([ze,...U]),Re=Ae}q.current=Ce,F.current=Ce,d(Ce),g(Re),Q.current=Re,W.current=Re}n(!0)},[Se]),P=k.useCallback(be=>{const je=F.current,Ae=je.findIndex(Z=>Z.id===be);if(Ae>=0){const Z=je[Ae]?.payload,pe=je.filter(Y=>Y.id!==be),Fe=W.current,$e=(je.some(Y=>Y.id===Fe)?Fe:je[0]?.id??null)===be||pe.length===0?pe[Math.min(Ae,pe.length-1)]?.id??null:void 0;q.current=pe,F.current=pe,d(pe),pe.length===0&&L.current==="browser"&&T(!1),$e!==void 0&&(g($e),Q.current=$e,W.current=$e),Xh(Z);return}const oe=te.current,U=oe.findIndex(Z=>Z.id===be);if(U<0)return;const ae=oe[U]?.payload,Ce=oe.filter(Z=>Z.id!==be),Re=re.current,X=(oe.some(Z=>Z.id===Re)?Re:oe[0]?.id??null)===be||Ce.length===0?Ce[Math.min(U,Ce.length-1)]?.id??null:void 0;B.current=Ce,te.current=Ce,f(Ce),Ce.length===0&&L.current==="terminal"&&T(!1),X!==void 0&&(x(X),J.current=X,re.current=X),Qh(ae)},[]),_e=k.useCallback(()=>{const be=F.current.map(Ae=>Ae.payload),je=te.current.map(Ae=>Ae.payload);F.current=[],te.current=[],q.current=[],Q.current=null,B.current=[],J.current=null,W.current=null,re.current=null,d([]),f([]),g(null),x(null),T(!1);for(const Ae of be)Xh(Ae);for(const Ae of je)Qh(Ae)},[]),He=k.useCallback(be=>{L.current==="terminal"?(x(be),J.current=be):(g(be),Q.current=be)},[]),Pe=k.useCallback((be,je)=>{d(Ae=>{let oe=!1;const U=Ae.map(ae=>{if(ae.payload.kind!=="url"||ae.payload.browserId!==be)return ae;const Ce=je.url??ae.payload.url,Re=je.title||ae.payload.title||Ce,ze=je.pageId??ae.payload.pageId;return Ce===ae.payload.url&&Re===(ae.payload.title||ae.title)&&ze===ae.payload.pageId&&Re===ae.title?ae:(oe=!0,{...ae,title:Re,payload:{...ae.payload,url:Ce,title:Re,...ze!=null?{pageId:ze}:{}}})});return oe&&(q.current=U),oe?U:Ae})},[]),Ge=k.useCallback((be,je)=>{f(Ae=>{let oe=!1;const U=Ae.map(ae=>{if(ae.payload.kind!=="terminal"||ae.payload.terminalId!==be)return ae;const Ce=je.title||ae.payload.title||ae.title,Re=je.cwd??ae.payload.cwd;return Ce===ae.title&&Re===ae.payload.cwd&&Ce===(ae.payload.title||ae.title)?ae:(oe=!0,{...ae,title:Ce,payload:{...ae.payload,title:Ce,...Re!=null?{cwd:Re}:{}}})});return oe&&(B.current=U),oe?U:Ae})},[]),ut=k.useCallback(()=>{L.current==="terminal"?(f(be=>be.length===0?be:(B.current=be,re.current&&(J.current=re.current),[])),x(null)):(d(be=>be.length===0?be:(q.current=be,W.current&&(Q.current=W.current),[])),g(null),Se()),T(!1)},[Se]),pt=k.useCallback(()=>{if(L.current==="terminal"&&m.length>0){if(l("browser"),c.length>0){n(!0);return}if(q.current.length>0){const ze=q.current,X=Q.current&&ze.some(Z=>Z.id===Q.current)?Q.current:ze[0].id;d(ze),g(X),Q.current=X,n(!0);return}const ae=qs(),Ce=`eb_${Date.now().toString(36)}_${Math.random().toString(36).slice(2,7)}`,Re={id:ae,title:"New Tab",payload:{kind:"url",url:"about:blank",title:"New Tab",browserId:Ce}};q.current=[Re],d([Re]),g(Re.id),Q.current=Re.id,n(!0);return}const be=qs(),je=`eb_${Date.now().toString(36)}_${Math.random().toString(36).slice(2,7)}`;let Ae,oe=!1,U=!1;l("browser"),d(ae=>{if(ae.length>0)return q.current=ae,W.current&&(Q.current=W.current),U=!0,Ae=null,[];if(q.current.length>0){oe=!0;const Re=q.current;return Ae=Q.current&&Re.some(X=>X.id===Q.current)?Q.current:Re[0].id,Re}oe=!0;const Ce={id:be,title:"New Tab",payload:{kind:"url",url:"about:blank",title:"New Tab",browserId:je}};return q.current=[Ce],Ae=Ce.id,[Ce]}),oe&&n(!0),U?(g(null),T(!1),Se()):Ae!=null&&(g(Ae),Q.current=Ae)},[c.length,m.length,Se]),ht=k.useCallback(()=>{if(L.current==="browser"&&c.length>0){if(l("terminal"),Se(),m.length>0){n(!0);return}if(B.current.length>0){const ze=B.current,X=J.current&&ze.some(Z=>Z.id===J.current)?J.current:ze[0].id;f(ze),x(X),J.current=X,n(!0);return}const ae=qs(),Ce=`term_${Date.now().toString(36)}_${Math.random().toString(36).slice(2,7)}`;ji(Ce);const Re={id:ae,title:"Terminal",payload:{kind:"terminal",terminalId:Ce,title:"Terminal"}};B.current=[Re],f([Re]),x(Re.id),J.current=Re.id,n(!0);return}const be=qs(),je=`term_${Date.now().toString(36)}_${Math.random().toString(36).slice(2,7)}`;ji(je);let Ae,oe=!1,U=!1;l("terminal"),Se(),f(ae=>{if(ae.length>0)return B.current=ae,re.current&&(J.current=re.current),U=!0,Ae=null,[];if(B.current.length>0){oe=!0;const Re=B.current;return Ae=J.current&&Re.some(X=>X.id===J.current)?J.current:Re[0].id,Re}oe=!0;const Ce={id:be,title:"Terminal",payload:{kind:"terminal",terminalId:je,title:"Terminal"}};return B.current=[Ce],Ae=Ce.id,[Ce]}),oe&&n(!0),U?(x(null),T(!1)):Ae!=null&&(x(Ae),J.current=Ae)},[c.length,m.length,Se]),Mt=k.useCallback(be=>{const je=L.current==="terminal"?m:c;if(je.length<2)return;const Ae=L.current==="terminal"?re.current:W.current,U=(Math.max(0,je.findIndex(Ce=>Ce.id===Ae))+be+je.length)%je.length,ae=je[U].id;L.current==="terminal"?(x(ae),J.current=ae):(g(ae),Q.current=ae)},[c,m]),Bt=k.useCallback(be=>{const Ae=(L.current==="terminal"?m:c)[be];Ae&&(L.current==="terminal"?(x(Ae.id),J.current=Ae.id):(g(Ae.id),Q.current=Ae.id))},[c,m]),Qt=k.useCallback(()=>{if(L.current==="terminal"){const je=`term_${Date.now().toString(36)}_${Math.random().toString(36).slice(2,7)}`;me({kind:"terminal",terminalId:je,title:"Terminal"});return}const be=`eb_${Date.now().toString(36)}_${Math.random().toString(36).slice(2,7)}`;me({kind:"url",url:"about:blank",title:"New Tab",browserId:be})},[me]),wt=k.useCallback(be=>{const je=te.current,Ae=je.findIndex(ze=>ze.payload.kind==="terminal"&&ze.payload.terminalId===be);if(Ae<0){Wh(be),window.markusDesktop?.terminal?.destroy(be);return}const oe=je[Ae];if(je.length>1){P(oe.id);return}Wh(be),window.markusDesktop?.terminal?.destroy(be);const U=`term_${Date.now().toString(36)}_${Math.random().toString(36).slice(2,7)}`;ji(U);const ae=oe.payload.kind==="terminal"&&(oe.payload.title||oe.title)||"Terminal",Ce=oe.payload.kind==="terminal"?oe.payload.cwd:void 0,Re={id:oe.id,title:ae,payload:{kind:"terminal",terminalId:U,title:ae,cwd:Ce}};B.current=[Re],f([Re]),x(Re.id),J.current=Re.id,L.current!=="terminal"&&l("terminal")},[P]),Ue=k.useCallback(be=>T(be),[]),ft=k.useCallback(()=>T(be=>!be),[]),kt=i==="terminal"?m:c,Nt=i==="terminal"?y:h,zt=kt.find(be=>be.id===Nt)??kt[0]??null,ce=zt?.payload??null,tt=kt.length>0,rt=k.useMemo(()=>({leftCollapsed:t,setLeftCollapsed:ee,toggleLeftCollapsed:ue,keyboardPane:E,setKeyboardPane:D,l0FocusPageId:M,setL0FocusPageId:H,rightPanelMode:i,setRightPanelMode:$,switchRightPanelMode:G,rightPanel:ce,rightPanelOpen:tt,rightPanelTabs:kt,activeRightPanelTabId:zt?.id??null,openRightPanel:me,closeRightPanel:_e,closeRightPanelTab:P,setActiveRightPanelTab:He,updateRightPanelBrowserTab:Pe,updateRightPanelTerminalTab:Ge,toggleRightPanel:pt,toggleTerminalPanel:ht,collapseRightPanelOnly:ut,cycleRightPanelTab:Mt,activateRightPanelTabAt:Bt,openNewRightPanelTab:Qt,handleTerminalExit:wt,rightPanelFullscreen:w,setRightPanelFullscreen:Ue,toggleRightPanelFullscreen:ft,hostAvailable:C,setHostAvailable:S}),[t,ee,ue,E,D,M,H,i,$,G,ce,tt,kt,zt,me,_e,P,He,Pe,Ge,pt,ht,ut,Mt,Bt,Qt,wt,w,Ue,ft,C]);return s.jsx(j3.Provider,{value:rt,children:e})}function Oc(){return k.useContext(j3)}function Ti(e,t){const n=/```[\s\S]*?```|`[^`\n]+`/g;let r=0,i="";for(const l of e.matchAll(n))i+=t(e.slice(r,l.index)),i+=l[0],r=l.index+l[0].length;return i+=t(e.slice(r)),i}function gV(e){let t=e.replace(/\\\[([\s\S]*?)\\\]/g,(n,r)=>`$$${r}$$`);return t=t.replace(/\\\((.+?)\\\)/g,(n,r)=>`$${r}$`),t}const kd="#mention:";function bV(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="",i=0;for(;i<e.length;){const l=e.indexOf("@",i);if(l<0){r+=e.slice(i);break}if(r+=e.slice(i,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)})`,i=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)})`,i=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)})`,i=l+1+h.length;continue}r+="@",i=l+1}return r}const M3="#entity:",xV=new RegExp("(?<!\\[)(?<!\\()(?<!:)(?<!\\/)(?<!\\\\)\\b(tsk|req|proj|dlv|agt|team)_[a-f0-9]{6,}\\b(?!\\]\\(#entity:)","gi"),yV=/`\[([^\]]+)\]\(#entity:((?:tsk|req|proj|dlv|agt|team)_[a-f0-9]{6,})\)`/gi;function R3(e,t){const n=e.slice(0,t),r=n.lastIndexOf("](");return r===-1?!1:n.indexOf(")",r+2)===-1}function vV(e){return e.replace(yV,(t,n,r)=>`[${n}](${M3}${r})`)}function wV(e){return e.replace(xV,(t,n,r)=>R3(e,r)?t:`[${t}](${M3}${t})`)}const kV=["\\s","<",">","`","\\u4e00-\\u9fff","\\u3000-\\u303f","\\uff00-\\uffef"].join(""),SV=new RegExp(`https?://[^${kV}]+`,"gi");function D3(e){return e.replace(SV,(t,n)=>{if(R3(e,n))return t;const r=t.replace(/[.,;:!?\]\)"']+$/,"");if(!r)return t;const i=t.slice(r.length);return/[()[\]]/.test(r)?t:`[${r}](${r})${i}`})}function NV(e){const t=e.trim();return t.startsWith("@startuml")&&t.endsWith("@enduml")}const CV=/^(graph\s|flowchart\s|sequenceDiagram|classDiagram|stateDiagram|erDiagram|gantt|pie|gitGraph|mindmap|timeline|journey)/m;function TV(e){return CV.test(e.trim())}const AV={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 EV(e){return AV[e.toLowerCase()]??e.charAt(0).toUpperCase()+e.slice(1)}function _V(e){const t=e.match(/language-(\S+)/);return t?t[1]:null}const L3=/^(?:\/|~\/|[A-Za-z]:[\\/]|\\\\)/,O3=/^\.{1,2}\//,jV=/\.[a-zA-Z0-9]{1,12}(?:$|[?#])/,I3=/^[A-Za-z]:[\\/]/,P3=/^\\\\[^\\]/;function B3(e){const t=e.trim();return t?!!(/^file:/i.test(t)||I3.test(t)||P3.test(t)||t.startsWith("~/")||t.startsWith("/")||O3.test(t)):!1}function Xg(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 MV(e){return e.replace(/(!?\[[^\]]*]\()((?:[A-Za-z]:|\\\\)[^)\n]*)(\))/g,(t,n,r,i)=>`${n}${r.replace(/\\+/g,"/")}${i}`)}function z3(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(L3.test(e))return e.startsWith("~/")?e:e.replace(/\\/g,"/");if(!t)return e;const r=`${t.replace(/\\/g,"/").replace(/\/+$/,"")}/${e.replace(/^\.\//,"")}`,i=r.split("/"),l=[];for(const d of i)!d||d==="."||(d===".."?l.pop():l.push(d));const c=l.join("/");return r.startsWith("/")?`/${c}`.replace(/^\/+/,"/"):c}function o4(e){const t=e.indexOf("#");return t<0?{path:e}:{path:e.slice(0,t),fragment:decodeURIComponent(e.slice(t+1))}}function l4(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(I3.test(n)||P3.test(n)){const{path:l,fragment:c}=o4(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:Xg(n)}:{kind:"passthrough"};const{path:r,fragment:i}=o4(n);return L3.test(r)?{kind:"file",path:Sd(r,t),fragment:i}:O3.test(r)?{kind:"file",path:Sd(r,t),fragment:i}:r&&jV.test(r)&&!r.includes("://")?{kind:"file",path:Sd(r,t),fragment:i}:{kind:"passthrough"}}function RV(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 i of r)if(z3(i.textContent||"")===t||i.id===t){n=i;break}}return n?(n.scrollIntoView({behavior:"smooth",block:"start"}),!0):!1}function $3(e){return e.type==="text"?e.value??"":(e.children??[]).map($3).join("")}function H3(){return e=>{const t=new Map,n=r=>{if(r.type==="element"&&r.tagName&&/^h[1-6]$/.test(r.tagName)){const i=$3(r).trim();let l=z3(i);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 i of r.children??[])n(i)};n(e)}}function DV(e,t,n){const r=e.cloneNode(!0),i=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:${i};font-size:${l};line-height:1.7;max-width:800px;">${r.innerHTML}</div>`}async function Qg(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 LV(e,t,n,r){const i=DV(e,t,r);try{return await navigator.clipboard.write([new ClipboardItem({"text/html":new Blob([i],{type:"text/html"}),"text/plain":new Blob([n],{type:"text/plain"})})]),{ok:!0,method:"html"}}catch{return{ok:await Qg(n),method:"text"}}}const U3="markus-copy-typography",c4={fontFamily:"default",fontSize:15,headingScale:"standard"};function F3(){try{const e=localStorage.getItem(U3);if(e)return{...c4,...JSON.parse(e)}}catch{}return c4}function OV(e){localStorage.setItem(U3,JSON.stringify(e))}function IV(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 PV({onClose:e}){const{t}=gt("common"),[n,r]=k.useState(F3);k.useEffect(()=>{OV(n)},[n]);const i=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=>i("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=>i("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:()=>i("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 BV extends k.Component{state={error:null};static getDerivedStateFromError(t){return{error:t}}componentDidUpdate(t){this.state.error&&this.props.resetKeys&&!zV(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 zV(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 $V=k.lazy(()=>ta(()=>Promise.resolve().then(()=>t6),void 0).then(e=>({default:e.MarkdownMessage}))),HV={file:{icon:"📄",color:"bg-green-500/10 text-green-600"},directory:{icon:"📁",color:"bg-blue-500/10 text-blue-600"}},u4={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 UV({item:e,onClose:t,onOpenInPage:n}){const{t:r}=gt(["agent","common"]),i=HV[e.type]??{icon:"📎",color:"bg-surface-elevated text-fg-secondary"},l=u4[e.status]??u4.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 ${i.color}`,children:i.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($V,{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"?Da.createPortal(d,document.body):d}const FV={tsk:"task",req:"requirement",proj:"project",dlv:"deliverable",agt:"agent",team:"team"};function q3(e){return{task:"task",requirement:"requirement",project:"project",deliverable:"deliverable",agent:"agent",team:"team"}[e]}const G3={task:"📋",requirement:"📝",project:"📁",deliverable:"📦",agent:"🤖",team:"👥"},K3={task:"Task",requirement:"Requirement",project:"Project",deliverable:"Deliverable",agent:"Agent",team:"Team"},qV=/^(tsk|req|proj|dlv|agt|team)_[a-f0-9]{6,}$/i;function b0(e){return qV.test(e.trim())}function GV(e){const t=e.split("_")[0]?.toLowerCase();return t?FV[t]:void 0}function V3(e){e.startsWith("tsk_")?it.navigate(le.WORK,{openTask:e}):e.startsWith("req_")?it.navigate(le.WORK,{openRequirement:e}):e.startsWith("proj_")?it.navigate(le.WORK,{projectId:e}):e.startsWith("dlv_")?it.navigate(le.DELIVERABLES,{openDeliverable:e}):e.startsWith("agt_")?it.navigate(le.TEAM,{agentId:e}):e.startsWith("team_")&&it.navigate(le.TEAM,{selectTeam:e})}const Qp=new Map,Nd=new Map;async function KV(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 i=(await Ee.teams.list()).teams.find(l=>l.id===e);return{...n,title:i?.name??e,notFound:!i}}}}catch{}return{...n,notFound:!0}}function W3(e,t){const n=t??GV(e),[r,i]=k.useState(()=>Qp.get(e)??{id:e,type:n??"task",title:e,loading:!!n});return k.useEffect(()=>{if(!n){i({id:e,type:"task",title:e,loading:!1,notFound:!0});return}const l=Qp.get(e);if(l){i(l);return}i(m=>({...m,type:n,loading:!0}));let c=!0,d=Nd.get(e);return d||(d=KV(e,n),Nd.set(e,d)),d.then(m=>{Qp.set(e,m),Nd.delete(e),c&&i(m)}).catch(()=>{Nd.delete(e),c&&i({id:e,type:n,title:e,loading:!1,notFound:!0})}),()=>{c=!1}},[e,n]),r}function Y3(e){const t=(e.split("_")[0]?.length??3)+1;return e.length>t+8?`${e.slice(0,t+8)}…`:e}function dc({id:e,type:t,label:n}){const r=W3(e,t),i=Oc(),l=G3[r.type]??"🔗",c=n??(r.loading||r.notFound?Y3(e):r.title),d=m=>{if(m.preventDefault(),m.stopPropagation(),r.type==="deliverable"&&r.deliverable&&i?.hostAvailable){i.openRightPanel({kind:"deliverable",deliverable:r.deliverable});return}V3(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:`${K3[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 VV({id:e,type:t,label:n}){const r=W3(e,t),[i,l]=k.useState(!1),c=Oc(),d=G3[r.type]??"🔗",m=()=>{if(r.type==="deliverable"&&r.deliverable){if(c?.hostAvailable){c.openRightPanel({kind:"deliverable",deliverable:r.deliverable});return}l(!0);return}V3(e)},f=r.loading?Y3(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:K3[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"})})]}),i&&r.deliverable&&s.jsx(UV,{item:r.deliverable,onClose:()=>l(!1),onOpenInPage:h=>{l(!1),it.navigate(le.DELIVERABLES,{openDeliverable:h})}})]})}k.lazy(()=>ta(()=>Promise.resolve().then(()=>t6),void 0).then(e=>({default:e.MarkdownMessage})));const WV=k.lazy(()=>ta(()=>import("./ContentRenderer-DyQHyRET.js"),[]).then(e=>({default:e.ContentRenderer})));let _o=[],d4=60;function YV(e){const t=k.useRef(e);t.current=e;const[n]=k.useState(()=>++d4);return k.useEffect(()=>{const r=()=>t.current();_o.push(r);const i=l=>{l.key==="Escape"&&_o[_o.length-1]===r&&(l.preventDefault(),r())};return window.addEventListener("keydown",i,!0),()=>{window.removeEventListener("keydown",i,!0),_o=_o.filter(l=>l!==r),_o.length===0&&(d4=60)}},[]),n}const m4=500,Ws=new Map,x0=new Set,qd=new Map;let Gd=null;function XV(){if(Ws.size<=m4)return;const e=Ws.size-m4,t=Ws.keys();for(let n=0;n<e;n++){const{value:r,done:i}=t.next();if(i)break;Ws.delete(r)}}function f4(e,t){Ws.delete(e),Ws.set(e,t),XV()}function p4(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))f4(n,r),p4(n)}).catch(()=>{for(const t of e)f4(t,{exists:!1,isFile:!1,type:"unknown"}),p4(t)})}function ZV(e){Ws.has(e)||x0.has(e)||(x0.add(e),Gd&&clearTimeout(Gd),Gd=setTimeout(QV,30))}function JV(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 eW(e){const t=k.useCallback(i=>JV(e,i),[e]),n=k.useCallback(()=>Ws.get(e),[e]),r=k.useSyncExternalStore(t,n,n);return k.useEffect(()=>{ZV(e)},[e]),r}const tW=/^(?:\/[\w.\-@+]+(?:\/[\w.\-@+ ]*)*|~\/[\w.\-@+]+(?:\/[\w.\-@+ ]*)*|[A-Za-z]:(?:\\|\/)[\w.\-@+ ]+(?:(?:\\|\/)[\w.\-@+ ]*)*|\.\.?\/[\w.\-@+]+(?:\/[\w.\-@+ ]*)*)$/;function nW(e){return e.length<2||e.length>500?!1:tW.test(e)}function rW({filePath:e,onClose:t}){const n=YV(t),[r,i]=k.useState(!0),[l,c]=k.useState(null),[d,m]=k.useState(""),[f,h]=k.useState(""),[g,y]=k.useState(""),[x,w]=k.useState(""),[T,C]=k.useState("");k.useEffect(()=>{i(!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||""),C(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(()=>{i(!1)})},[e]);const S=g||e.split(/[/\\]/).pop()||e;return Da.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"&&T&&s.jsx("audio",{controls:!0,preload:"metadata",src:T,className:"w-full"}),!r&&!l&&f==="video"&&T&&s.jsx("video",{controls:!0,preload:"metadata",src:T,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(WV,{content:d,format:f==="text"?"text":f,className:"text-sm"})})]})]})}),document.body)}function aW({path:e}){const t=eW(e),[n,r]=k.useState(null),i=Oc(),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(i?.hostAvailable){i.openRightPanel({kind:"file",path:e});return}r(e)}else Ee.files.reveal(e)},[l,c,e,i]),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(rW,{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 sW(){return Zp||(Zp=ta(()=>import("./mermaid.core-DeC0XDN4.js").then(e=>e.b9),__vite__mapDeps([0,1])).then(e=>(e.default.initialize({startOnLoad:!1,securityLevel:"loose",fontFamily:"inherit"}),e))),Zp}function iW(){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 oW(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 lW(){return iW()}function cW(){return k.useSyncExternalStore(oW,lW)}function X3({code:e}){const t=k.useRef(null),[n,r]=k.useState(null),[i,l]=k.useState(!0),c=k.useId(),d=k.useRef(0),m=k.useRef(null),f=cW();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 sW();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:[i&&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${i?" hidden":""}`})]})}const uW="/assets/viz-global-C_AyN6D9.js";let Cd=!1,Jp=null;function dW(){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=uW,r.onload=()=>{Cd=!0,e()},r.onerror=()=>t(new Error("Failed to load viz-global.js")),document.head.appendChild(r)})}function mW(){return Jp||(Jp=dW().then(()=>ta(()=>import("./plantuml-DezRDxd4.js"),[]))),Jp}let h4=Promise.resolve();function fW(e,t){const n=h4.then(()=>new Promise((r,i)=>{mW().then(({renderToString:l})=>{const c=e.split(/\r\n|\r|\n/);l(c,r,i,{dark:t})}).catch(i)}));return h4=n.then(()=>{},()=>{}),n}function pW(){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 hW(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 gW(){return k.useSyncExternalStore(hW,()=>pW())}function Q3({code:e}){const[t,n]=k.useState(null),[r,i]=k.useState(null),[l,c]=k.useState(!0),d=k.useRef(null),m=gW();return k.useEffect(()=>{if(!e.trim()||d.current&&d.current.code===e&&d.current.dark===m)return;let f=!1;return c(!0),i(null),fW(e.trim(),m).then(h=>{f||(n(h),d.current={code:e,dark:m})}).catch(h=>{f||i(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 Zh({code:e,language:t,children:n}){const{t:r}=gt("common"),[i,l]=k.useState("rendered"),[c,d]=k.useState(!1),m=k.useCallback(async()=>{await Qg(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 ${i==="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 ${i==="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")]})})]})]}),i==="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 bW=[X3,Q3];function xW(e){for(const t of k.Children.toArray(e))if(k.isValidElement(t)&&typeof t.props?.className=="string"){const n=t.props.className;return _V(n)}return null}function mc(e){if(typeof e=="string")return e;if(typeof e=="number")return String(e);if(!e)return"";if(Array.isArray(e))return e.map(mc).join("");if(k.isValidElement(e)){const t=e.props;return mc(t.children)}return""}function yW({children:e}){const{t}=gt("common"),n=xW(e),r=k.useRef(null),[i,l]=k.useState(!1),[c,d]=k.useState("rendered"),m=k.useCallback(async()=>{let h;c==="source"?h=mc(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)&&bW.includes(h.type))){const h=mc(e),g=n==="mermaid"||n==="plantuml"?n:"diagram";return s.jsx(Zh,{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:EV(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:mc(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:i?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 g4="#mention:",y0="#entity:",vW=/^\[([^\]]+)\]\(#entity:((tsk|req|proj|dlv|agt|team)_[a-f0-9]{6,})\)$/i,Z3=/^(workflow|task|requirement|project|deliverable|agent|team):(.+)$/,Jh="text-brand-500 hover:text-brand-500 underline break-all cursor-pointer";function eg(e){return e.type==="text"?e.value??"":(e.children??[]).map(eg).join("")}function wW(e){return e.type==="text"&&(e.value??"").trim()===""}function kW(e){if(!e?.children)return null;const t=e.children.filter(r=>!wW(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 i=eg(n);if(r.startsWith(y0))return{id:r.slice(y0.length)};const l=r.match(Z3);return l&&l[1]!=="workflow"?{id:l[2],type:q3(l[1]),label:i}:null}if(n.type==="element"&&n.tagName==="code"){const r=eg(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 SW={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")||NV(r))return s.jsx(Zh,{code:r,language:"plantuml",children:s.jsx(Q3,{code:r})});if(t?.includes("language-mermaid")||!t&&TV(r))return s.jsx(Zh,{code:r,language:"mermaid",children:s.jsx(X3,{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(dc,{id:n.trim()});const i=n.match(vW);return i?s.jsx(dc,{id:i[2],label:i[1]}):nW(n)?s.jsx(aW,{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(yW,{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:Jh,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})},NW=/\.(png|jpe?g|gif|webp|svg|bmp|ico)$/i;function CW(e){const t=Xg(e);return B3(e)&&NW.test(t.split("?")[0]??t)}function TW(e,t){const n=Xg(e);if(n.startsWith("/")||n.startsWith("~/")||/^[A-Za-z]:\//.test(n)||n.startsWith("//"))return n;if((n.startsWith("./")||n.startsWith("../"))&&t){const i=((t.replace(/\\/g,"/").endsWith("/")?t.replace(/\\/g,"/"):`${t.replace(/\\/g,"/")}/`)+n).split("/"),l=[];for(const c of i)c===".."?l.pop():c!=="."&&c!==""&&l.push(c);return"/"+l.join("/")}return n}function AW(e){return`/api/files/image?path=${encodeURIComponent(e)}`}const jo=new Map;function EW({src:e,alt:t,onPreview:n,basePath:r}){const i=k.useMemo(()=>CW(e)?AW(TW(e,r)):e,[e,r]),l=i.startsWith("/api/files/image?"),c=jo.get(i),[d,m]=k.useState(c??(l?null:i)),[f,h]=k.useState(!!c),[g,y]=k.useState(!1),[x,w]=k.useState(null),[T,C]=k.useState(0),S=k.useRef(0),E=k.useCallback(()=>{jo.delete(i),y(!1),w(null),h(!1),m(l?null:`${i}${i.includes("?")?"&":"?"}retry=${Date.now()}`),C(j=>j+1)},[i,l]);return k.useEffect(()=>{if(!l)return;const j=jo.get(i);if(j){m(j),h(!0),y(!1),w(null);return}const M=++S.current;y(!1),w(null),h(!1),m(null),(async()=>{try{const O=await fetch(i,{credentials:"same-origin"});if(M!==S.current)return;if(!O.ok){let q=`HTTP ${O.status}`;try{const Q=await O.json();Q.error&&(q=Q.error)}catch{}throw new Error(q)}const D=await O.blob();if(M!==S.current)return;if(D.size===0)throw new Error("Empty image response");if(D.type&&!D.type.startsWith("image/")&&!D.type.includes("octet-stream"))throw new Error(`Unexpected content-type: ${D.type}`);const H=URL.createObjectURL(D);jo.set(i,H),m(H),h(!0),y(!1),w(null)}catch(O){if(M!==S.current)return;const D=O instanceof Error?O.message:String(O);console.warn("[MarkdownImage] failed to load local image",i,O),w(D),y(!0),h(!1)}})()},[l,i,T]),k.useEffect(()=>{l||(m(i),h(!!jo.get(i)),y(!1),w(null))},[i,l,T]),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||jo.set(i,i),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 b4(e){const t=await fetch(e);if(!t.ok)throw new Error(`Failed to fetch image (${t.status})`);return t.blob()}async function _W(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((i,l)=>{n.toBlob(c=>c?i(c):l(new Error("PNG encode failed")),"image/png")})}function jW(e,t){try{const i=(e.startsWith("data:")?"":new URL(e,window.location.href).pathname).split("/").pop()||"";if(i&&/\.(png|jpe?g|gif|webp|svg|bmp)$/i.test(i))return decodeURIComponent(i)}catch{}return`image.${(t.type.split("/")[1]||"png").replace("jpeg","jpg")}`}function J3({src:e,onClose:t}){const{t:n}=gt("common"),[r,i]=k.useState(null),[l,c]=k.useState(null);Vo(!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=>{i(g),window.setTimeout(()=>i(null),1600)},[]),m=k.useCallback(async g=>{if(g.stopPropagation(),!l){c("copy");try{const y=await b4(e),x=await _W(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 b4(e),x=URL.createObjectURL(y),w=document.createElement("a");w.href=x,w.download=jW(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 Da.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 e6(e={}){const{onMentionClick:t,basePath:n,onImagePreview:r,contentRef:i,hostAvailable:l,openRightPanel:c}=e,d=k.useCallback((m,f)=>{const h=l4(f,n);if(h.kind!=="passthrough"){if(m.preventDefault(),m.stopPropagation(),h.kind==="fragment"){RV(i?.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}Xs(h.url)}}},[n,i,l,c]);return k.useMemo(()=>({...SW,img:({src:m,alt:f})=>s.jsx(EW,{src:m??"",alt:f,onPreview:r,basePath:n},m??""),p:({children:m,node:f})=>{const h=kW(f);return h?s.jsx(VV,{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(g4)){const g=decodeURIComponent(m.slice(g4.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(dc,{id:m.slice(y0.length)});{const g=m?.match(Z3);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:T=>{T.preventDefault(),T.stopPropagation(),it.navigate(le.WORK,{boardType:"workflows"})},title:`workflow: ${x}`,children:[s.jsx("span",{className:"text-[10px]",children:"⚙️"}),s.jsx("span",{children:f})]});const w=q3(y);if(w)return s.jsx(dc,{id:x,type:w,label:f})}}if(m&&b0(m))return s.jsx(dc,{id:m.trim(),label:f});const h=l4(m,n);return h.kind==="fragment"||h.kind==="file"||h.kind==="external"?s.jsx("a",{href:m,className:Jh,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:Jh,onClick:g=>{Ho()&&m&&!/^[a-zA-Z][a-zA-Z0-9+.-]*:/.test(m)&&g.preventDefault()},children:f})}}),[t,n,r,d])}const x4=[Z5,e3,t3],y4=[H3,[u3,{strict:"ignore"}],[E3,{detect:!0,ignoreMissing:!0}]];function v4(e){return/^(deliverable|task|requirement|project|agent|team|workflow):/i.test(e)||B3(e)?e:T5(e)}const MW=/ thinking([\s\S]*?)(<\/think>|$)/g;function RW(e){const t=[];let n=e.replace(MW,(r,i)=>{const l=i.trim();return l&&t.push(l),""});return n=n.replace(/<\/think>/g,"").replace(/ thinking/g,""),{thinking:t,rest:n.trim()}}function DW(e=640){const[t,n]=k.useState(()=>window.innerWidth<e);return k.useEffect(()=>{const r=window.matchMedia(`(max-width: ${e-1}px)`),i=l=>n(l.matches);return r.addEventListener("change",i),n(r.matches),()=>r.removeEventListener("change",i)},[e]),t}function LW({content:e,contentRef:t}){const{t:n}=gt("common"),[r,i]=k.useState(!1),[l,c]=k.useState(!1),[d,m]=k.useState(!1),[f,h]=k.useState(null),g=k.useRef(null),y=DW();k.useEffect(()=>{if(!r)return;const C=S=>{g.current&&!g.current.contains(S.target)&&(i(!1),c(!1),m(!1))};return document.addEventListener("mousedown",C),()=>document.removeEventListener("mousedown",C)},[r]);const x=k.useCallback(C=>{h(C),setTimeout(()=>h(null),1500)},[]),w=async()=>{const C=await Qg(e);x(n(C?"markdown.copied":"markdown.failed")),i(!1)},T=async C=>{const S=t.current?.firstElementChild;if(!S)return;const E=F3(),j=IV(E),M=await LV(S,C,e,{fontFamily:j.fontFamily,fontSize:j.fontSize,headingScales:j.headingScales}),O=n(C==="light"?"markdown.themeLight":"markdown.themeDark");x(M.ok?M.method==="html"?n("markdown.htmlCopied",{theme:O}):n("markdown.textCopied"):n("markdown.failed")),i(!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:()=>i(C=>!C),className:"p-1.5 rounded-lg bg-surface-elevated/80 hover:bg-surface-overlay text-fg-secondary hover:text-fg-primary backdrop-blur-sm border border-border-default/50 transition-all",title: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(PV,{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:()=>T("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:()=>T("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 Br=k.memo(function({content:t,className:n="",onMentionClick:r,knownNames:i,basePath:l}){const{thinking:c,rest:d}=RW(t),m=k.useRef(null),[f,h]=k.useState(null),g=Oc(),y=k.useCallback(T=>{let C=Ti(T,gV);return C=Ti(C,MV),C=Ti(C,vV),C=Ti(C,wV),C=Ti(C,S=>bV(S,i)),C=Ti(C,D3),C},[i]),x=k.useMemo(()=>y(d),[d,y]),w=e6({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(LW,{content:t,contentRef:m}),s.jsx("div",{ref:m,children:s.jsx(BV,{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 T=c.join(`
648
+ `,1;if(sl>1e5&&sl>xt.index*3)throw new Error("potential infinite loop, way more iterations than matches");return pn+=It,It.length}const or=tr(Ve);if(!or)throw je(_t.replace("{}",Ve)),new Error('Unknown language: "'+Ve+'"');const zc=Z(or);let Ki="",jt=fn||zc;const $c={},Gn=new st.__emitter(st);al();let pn="",gs=0,$a=0,sl=0,bs=!1;try{if(or.__emitTokens)or.__emitTokens(St,Gn);else{for(jt.matcher.considerAll();;){sl++,bs?bs=!1:jt.matcher.considerAll(),jt.matcher.lastIndex=$a;const et=jt.matcher.exec(St);if(!et)break;const xt=St.substring($a,et.index),It=Gi(xt,et);$a=et.index+It}Gi(St.substring($a))}return Gn.finalize(),Ki=Gn.toHTML(),{language:Ve,value:Ki,relevance:gs,illegal:!1,_emitter:Gn,_top:jt}}catch(et){if(et.message&&et.message.includes("Illegal"))return{language:Ve,value:Y(St),illegal:!0,relevance:0,_illegalBy:{message:et.message,index:$a,context:St.slice($a-100,$a+100),mode:et.mode,resultSoFar:Ki},_emitter:Gn};if(dt)return{language:Ve,value:Y(St),illegal:!1,relevance:0,errorRaised:et,_emitter:Gn,_top:jt};throw et}}function Ke(Ve){const St={value:Y(Ve),illegal:!1,relevance:0,_top:ct,_emitter:new st.__emitter(st)};return St._emitter.addText(Ve),St}function qt(Ve,St){St=St||st.languages||Object.keys(he);const Gt=Ke(Ve),fn=St.filter(tr).filter(ps).map(Tn=>ve(Tn,Ve,!1));fn.unshift(Gt);const Hn=fn.sort((Tn,Ur)=>{if(Tn.relevance!==Ur.relevance)return Ur.relevance-Tn.relevance;if(Tn.language&&Ur.language){if(tr(Tn.language).supersetOf===Ur.language)return 1;if(tr(Ur.language).supersetOf===Tn.language)return-1}return 0}),[mr,Hr]=Hn,Tr=mr;return Tr.secondBest=Hr,Tr}function sn(Ve,St,Gt){const fn=St&&Ie[St]||Gt;Ve.classList.add("hljs"),Ve.classList.add(`language-${fn}`)}function Zt(Ve){let St=null;const Gt=kn(Ve);if(Tt(Gt))return;if(ri("before:highlightElement",{el:Ve,language:Gt}),Ve.dataset.highlighted){console.log("Element previously highlighted. To highlight again, first unset `dataset.highlighted`.",Ve);return}if(Ve.children.length>0&&(st.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(Ve)),st.throwUnescapedHTML))throw new $e("One of your code blocks includes unescaped HTML.",Ve.innerHTML);St=Ve;const fn=St.textContent,Hn=Gt?bn(fn,{language:Gt,ignoreIllegals:!0}):qt(fn);Ve.innerHTML=Hn.value,Ve.dataset.highlighted="yes",sn(Ve,Gt,Hn.language),Ve.result={language:Hn.language,re:Hn.relevance,relevance:Hn.relevance},Hn.secondBest&&(Ve.secondBest={language:Hn.secondBest.language,relevance:Hn.secondBest.relevance}),ri("after:highlightElement",{el:Ve,result:Hn,text:fn})}function un(Ve){st=ye(st,Ve)}const Pn=()=>{mn(),oe("10.6.0","initHighlighting() deprecated. Use highlightAll() now.")};function $t(){mn(),oe("10.6.0","initHighlightingOnLoad() deprecated. Use highlightAll() now.")}let dn=!1;function mn(){function Ve(){mn()}if(document.readyState==="loading"){dn||window.addEventListener("DOMContentLoaded",Ve,!1),dn=!0;return}document.querySelectorAll(st.cssSelector).forEach(Zt)}function er(Ve,St){let Gt=null;try{Gt=St(V)}catch(fn){if(je("Language definition for '{}' could not be registered.".replace("{}",Ve)),dt)je(fn);else throw fn;Gt=ct}Gt.name||(Gt.name=Ve),he[Ve]=Gt,Gt.rawDefinition=St.bind(null,V),Gt.aliases&&Ba(Gt.aliases,{languageName:Ve})}function ir(Ve){delete he[Ve];for(const St of Object.keys(Ie))Ie[St]===Ve&&delete Ie[St]}function ka(){return Object.keys(he)}function tr(Ve){return Ve=(Ve||"").toLowerCase(),he[Ve]||he[Ie[Ve]]}function Ba(Ve,{languageName:St}){typeof Ve=="string"&&(Ve=[Ve]),Ve.forEach(Gt=>{Ie[Gt.toLowerCase()]=St})}function ps(Ve){const St=tr(Ve);return St&&!St.disableAutodetect}function hs(Ve){Ve["before:highlightBlock"]&&!Ve["before:highlightElement"]&&(Ve["before:highlightElement"]=St=>{Ve["before:highlightBlock"](Object.assign({block:St.el},St))}),Ve["after:highlightBlock"]&&!Ve["after:highlightElement"]&&(Ve["after:highlightElement"]=St=>{Ve["after:highlightBlock"](Object.assign({block:St.el},St))})}function qn(Ve){hs(Ve),Je.push(Ve)}function Pc(Ve){const St=Je.indexOf(Ve);St!==-1&&Je.splice(St,1)}function ri(Ve,St){const Gt=Ve;Je.forEach(function(fn){fn[Gt]&&fn[Gt](St)})}function za(Ve){return oe("10.7.0","highlightBlock will be removed entirely in v12.0"),oe("10.7.0","Please use highlightElement now."),Zt(Ve)}Object.assign(V,{highlight:bn,highlightAuto:qt,highlightAll:mn,highlightElement:Zt,highlightBlock:za,configure:un,initHighlighting:Pn,initHighlightingOnLoad:$t,registerLanguage:er,unregisterLanguage:ir,listLanguages:ka,getLanguage:tr,registerAliases:Ba,autoDetection:ps,inherit:ye,addPlugin:qn,removePlugin:Pc}),V.debugMode=function(){dt=!1},V.safeMode=function(){dt=!0},V.versionString=Oe,V.regex={concat:T,lookahead:y,either:S,optional:w,anyNumberOfTimes:x};for(const Ve in ht)typeof ht[Ve]=="object"&&e(ht[Ve]);return Object.assign(V,ht),V},at=nt({});return at.newInstance=()=>nt({}),Xp=at,at.HighlightJS=at,at.default=at,Xp}var eV=JK();const tV=Ec(eV),s4={},nV="hljs-";function rV(e){const t=tV.newInstance();return e&&l(e),{highlight:n,highlightAuto:r,listLanguages:i,register:l,registerAlias:c,registered:d};function n(m,f,h){const g=h||s4,y=typeof g.prefix=="string"?g.prefix:nV;if(!t.getLanguage(m))throw new Error("Unknown language: `"+m+"` is not registered");t.configure({__emitter:aV,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,T=w.data;return T.language=x.language,T.relevance=x.relevance,w}function r(m,f){const g=(f||s4).subset||i();let y=-1,x=0,w;for(;++y<g.length;){const T=g[y];if(!t.getLanguage(T))continue;const C=n(T,m,f);C.data&&C.data.relevance!==void 0&&C.data.relevance>x&&(x=C.data.relevance,w=C)}return w||{type:"root",children:[],data:{language:void 0,relevance:x}}}function i(){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 aV{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],i=t.root.children;n?r.children.push({type:"element",tagName:"span",properties:{className:[n]},children:i}):r.children.push(...i)}openNode(t){const n=this,r=t.split(".").map(function(c,d){return d?c+"_".repeat(d):n.options.classPrefix+c}),i=this.stack[this.stack.length-1],l={type:"element",tagName:"span",properties:{className:r},children:[]};i.children.push(l),this.stack.push(l)}closeNode(){this.stack.pop()}finalize(){}toHTML(){return""}}const sV={};function E3(e){const t=e||sV,n=t.aliases,r=t.detect||!1,i=t.languages||ZK,l=t.plainText,c=t.prefix,d=t.subset;let m="hljs";const f=rV(i);if(n&&f.registerAlias(n),c){const h=c.indexOf("-");m=h===-1?c:c.slice(0,h)}return function(h,g){O0(h,"element",function(y,x,w){if(y.tagName!=="code"||!w||w.type!=="element"||w.tagName!=="pre")return;const T=iV(y);if(T===!1||!T&&!r||T&&l&&l.includes(T))return;Array.isArray(y.properties.className)||(y.properties.className=[]),y.properties.className.includes(m)||y.properties.className.unshift(m);const C=i3(y,{whitespace:"pre"});let S;try{S=T?f.highlight(T,C,{prefix:c}):f.highlightAuto(C,{prefix:c,subset:d})}catch(E){const j=E;if(T&&/Unknown language/.test(j.message)){g.message("Cannot highlight as `"+T+"`, it’s not registered",{ancestors:[w,y],cause:j,place:y.position,ruleId:"missing-language",source:"rehype-highlight"});return}throw j}!T&&S.data&&S.data.language&&y.properties.className.push("language-"+S.data.language),S.children.length>0&&(y.children=S.children)})}}function iV(e){const t=e.properties.className;let n=-1;if(!Array.isArray(t))return;let r;for(;++n<t.length;){const i=String(t[n]);if(i==="no-highlight"||i==="nohighlight")return!1;!r&&i.slice(0,5)==="lang-"&&(r=i.slice(5)),!r&&i.slice(0,9)==="language-"&&(r=i.slice(9))}return r}const Yg=new Set;function ji(e){e&&Yg.add(e)}function Wh(e){e&&Yg.delete(e)}const _3="markus_right_panel_v1",oV=10,Yh=new Map;function lV(e,t=3e3){Yh.set(e,Date.now()+t)}function cV(e){const t=Yh.get(e);return t==null?!1:Date.now()>t?(Yh.delete(e),!1):!0}function uV(e){return e.kind==="terminal"}function nc(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 i4(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 qs(){return`tab_${Date.now().toString(36)}_${Math.random().toString(36).slice(2,7)}`}function wd(e){let t=e;for(;t.length>oV;){let n=-1;for(let i=t.length-1;i>=0;i--)if(!t[i].pinned){n=i;break}if(n<0)break;const r=t[n];r&&(Xh(r.payload),Qh(r.payload)),t=t.filter((i,l)=>l!==n)}return t}function Xh(e){e?.kind==="url"&&e.browserId&&(lV(e.browserId),window.markusDesktop?.browser?.destroy(e.browserId))}function Qh(e){e?.kind==="terminal"&&e.terminalId&&(Wh(e.terminalId),window.markusDesktop?.terminal?.destroy(e.terminalId))}function dV(e){const t=e.payload;return t.kind==="terminal"?null:t.kind==="url"?yc(t.url||"")||yc(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 mV(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 fV(){try{const e=localStorage.getItem(_3);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 pV(){const e={mode:"browser",browserTabs:[],browserActiveId:null,terminalTabs:[],terminalActiveId:null,stashedBrowserTabs:[],stashedBrowserActiveId:null,stashedTerminalTabs:[],stashedTerminalActiveId:null},t=fV();if(!t)return e;const n=t.browserTabs.map((x,w)=>{try{return mV(x,w)}catch{return null}}).filter(x=>!(!x||x.payload.kind==="terminal"||x.payload.kind==="url"&&yc(x.payload.url||""))),r=n.some(x=>x.id===t.browserActiveId)?t.browserActiveId:n[0]?.id??null,i=(t.terminalTabs||[]).map((x,w)=>{const T=`term_${Date.now().toString(36)}_${w.toString(36)}_${Math.random().toString(36).slice(2,7)}`;return ji(T),{id:x.id||qs(),title:x.title||"Terminal",payload:{kind:"terminal",terminalId:T,title:x.title||"Terminal",cwd:x.cwd}}}),l=i.some(x=>x.id===t.terminalActiveId)?t.terminalActiveId:i[0]?.id??null,c=!!t.browserCollapsed&&n.length>0,d=!!t.terminalCollapsed&&i.length>0,m=c?[]:n,f=c?null:r,h=d?[]:i,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:i,stashedTerminalActiveId:l}}const j3=k.createContext(null);function hV({children:e}){const[t,n]=k.useState(()=>{try{return localStorage.getItem("markus_sidebar_c")==="1"}catch{return!1}}),r=k.useMemo(()=>pV(),[]),[i,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,T]=k.useState(!1),[C,S]=k.useState(!1),[E,j]=k.useState("l0"),[M,O]=k.useState(null),D=k.useCallback(be=>j(be),[]),H=k.useCallback(be=>O(be),[]);k.useEffect(()=>{const be=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(be(oe)){const Ce=oe===Ae.target||oe.contains(Ae.target),Re=!!Ae.target.closest("[data-keep-edit-focus]"),ze=be(Ae.target)||!!Ae.target.closest('input, textarea, select, [contenteditable="true"]'),X=!!Ae.target.closest(".xterm");!Ce&&!Re&&!ze&&!X&&oe.blur()}const U=Ae.target.closest("[data-keyboard-pane]");if(!U)return;const ae=U.getAttribute("data-keyboard-pane");if(!(ae!=="l0"&&ae!=="l1"&&ae!=="l2"&&ae!=="content")&&(j(ae),ae==="l0")){const Re=Ae.target.closest("[data-l0-page-id]")?.getAttribute("data-l0-page-id");Re&&O(Re)}};return document.addEventListener("pointerdown",je,!0),()=>document.removeEventListener("pointerdown",je,!0)},[]);const q=k.useRef(r.stashedBrowserTabs.length>0?r.stashedBrowserTabs:r.browserTabs),Q=k.useRef(r.stashedBrowserActiveId??r.browserActiveId),B=k.useRef(r.stashedTerminalTabs.length>0?r.stashedTerminalTabs:r.terminalTabs),J=k.useRef(r.stashedTerminalActiveId??r.terminalActiveId),W=k.useRef(r.browserActiveId),re=k.useRef(r.terminalActiveId),F=k.useRef(r.browserTabs),te=k.useRef(r.terminalTabs),L=k.useRef(r.mode);W.current=h,re.current=y,F.current=c,te.current=m,L.current=i,k.useEffect(()=>{(r.mode==="terminal"||r.browserTabs.length===0)&&window.markusDesktop?.browser?.hideAll?.()},[]),k.useEffect(()=>{const be=c.length===0&&q.current.length>0,je=m.length===0&&B.current.length>0,Ae=be?q.current:c,oe=je?B.current:m,U=Ae.map(dV).filter(Re=>!!Re),ae=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})),Ce={mode:i,browserTabs:U,browserActiveId:be?Q.current:h,terminalTabs:ae,terminalActiveId:je?J.current:y,browserCollapsed:be,terminalCollapsed:je};try{localStorage.setItem(_3,JSON.stringify(Ce))}catch{}},[i,c,h,m,y]);const ee=k.useCallback(be=>n(be),[]),ue=k.useCallback(()=>n(be=>!be),[]),Se=k.useCallback(()=>{window.markusDesktop?.browser?.hideAll?.()},[]),$=k.useCallback(be=>{l(je=>je===be?je:(be==="terminal"&&Se(),be))},[Se]),G=k.useCallback(be=>{if(be==="terminal"){if(Se(),l("terminal"),n(!0),m.length>0)return;if(B.current.length>0){const Re=B.current,ze=J.current&&Re.some(X=>X.id===J.current)?J.current:Re[0].id;f(Re),x(ze),J.current=ze;return}const U=qs(),ae=`term_${Date.now().toString(36)}_${Math.random().toString(36).slice(2,7)}`;ji(ae);const Ce={id:U,title:"Terminal",payload:{kind:"terminal",terminalId:ae,title:"Terminal"}};B.current=[Ce],f([Ce]),x(Ce.id),J.current=Ce.id;return}if(l("browser"),n(!0),c.length>0)return;if(q.current.length>0){const U=q.current,ae=Q.current&&U.some(Ce=>Ce.id===Q.current)?Q.current:U[0].id;d(U),g(ae),Q.current=ae;return}const je=qs(),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}};q.current=[oe],d([oe]),g(oe.id),Q.current=oe.id},[c.length,m.length,Se]),me=k.useCallback(be=>{const je=nc(be),Ae=qs();if(uV(be)){be.kind==="terminal"&&ji(be.terminalId),l("terminal"),Se();const U=te.current,ae=U.find(ze=>nc(ze.payload)===je)??B.current.find(ze=>nc(ze.payload)===je);let Ce,Re;if(ae)Re=ae.id,Ce=U.some(ze=>ze.id===ae.id)?U:wd([ae,...U]);else{const ze={id:Ae,title:i4(be),payload:be};Ce=wd([ze,...U]),Re=Ae}B.current=Ce,te.current=Ce,f(Ce),x(Re),J.current=Re,re.current=Re}else{l("browser");const U=F.current,ae=U.find(ze=>nc(ze.payload)===je)??q.current.find(ze=>nc(ze.payload)===je);let Ce,Re;if(ae)Re=ae.id,Ce=U.some(ze=>ze.id===ae.id)?U:wd([ae,...U]);else{const ze={id:Ae,title:i4(be),payload:be};Ce=wd([ze,...U]),Re=Ae}q.current=Ce,F.current=Ce,d(Ce),g(Re),Q.current=Re,W.current=Re}n(!0)},[Se]),P=k.useCallback(be=>{const je=F.current,Ae=je.findIndex(Z=>Z.id===be);if(Ae>=0){const Z=je[Ae]?.payload,pe=je.filter(Y=>Y.id!==be),Fe=W.current,$e=(je.some(Y=>Y.id===Fe)?Fe:je[0]?.id??null)===be||pe.length===0?pe[Math.min(Ae,pe.length-1)]?.id??null:void 0;q.current=pe,F.current=pe,d(pe),pe.length===0&&L.current==="browser"&&T(!1),$e!==void 0&&(g($e),Q.current=$e,W.current=$e),Xh(Z);return}const oe=te.current,U=oe.findIndex(Z=>Z.id===be);if(U<0)return;const ae=oe[U]?.payload,Ce=oe.filter(Z=>Z.id!==be),Re=re.current,X=(oe.some(Z=>Z.id===Re)?Re:oe[0]?.id??null)===be||Ce.length===0?Ce[Math.min(U,Ce.length-1)]?.id??null:void 0;B.current=Ce,te.current=Ce,f(Ce),Ce.length===0&&L.current==="terminal"&&T(!1),X!==void 0&&(x(X),J.current=X,re.current=X),Qh(ae)},[]),_e=k.useCallback(()=>{const be=F.current.map(Ae=>Ae.payload),je=te.current.map(Ae=>Ae.payload);F.current=[],te.current=[],q.current=[],Q.current=null,B.current=[],J.current=null,W.current=null,re.current=null,d([]),f([]),g(null),x(null),T(!1);for(const Ae of be)Xh(Ae);for(const Ae of je)Qh(Ae)},[]),He=k.useCallback(be=>{L.current==="terminal"?(x(be),J.current=be):(g(be),Q.current=be)},[]),Pe=k.useCallback((be,je)=>{d(Ae=>{let oe=!1;const U=Ae.map(ae=>{if(ae.payload.kind!=="url"||ae.payload.browserId!==be)return ae;const Ce=je.url??ae.payload.url,Re=je.title||ae.payload.title||Ce,ze=je.pageId??ae.payload.pageId;return Ce===ae.payload.url&&Re===(ae.payload.title||ae.title)&&ze===ae.payload.pageId&&Re===ae.title?ae:(oe=!0,{...ae,title:Re,payload:{...ae.payload,url:Ce,title:Re,...ze!=null?{pageId:ze}:{}}})});return oe&&(q.current=U),oe?U:Ae})},[]),Ge=k.useCallback((be,je)=>{f(Ae=>{let oe=!1;const U=Ae.map(ae=>{if(ae.payload.kind!=="terminal"||ae.payload.terminalId!==be)return ae;const Ce=je.title||ae.payload.title||ae.title,Re=je.cwd??ae.payload.cwd;return Ce===ae.title&&Re===ae.payload.cwd&&Ce===(ae.payload.title||ae.title)?ae:(oe=!0,{...ae,title:Ce,payload:{...ae.payload,title:Ce,...Re!=null?{cwd:Re}:{}}})});return oe&&(B.current=U),oe?U:Ae})},[]),ut=k.useCallback(()=>{L.current==="terminal"?(f(be=>be.length===0?be:(B.current=be,re.current&&(J.current=re.current),[])),x(null)):(d(be=>be.length===0?be:(q.current=be,W.current&&(Q.current=W.current),[])),g(null),Se()),T(!1)},[Se]),pt=k.useCallback(()=>{if(L.current==="terminal"&&m.length>0){if(l("browser"),c.length>0){n(!0);return}if(q.current.length>0){const ze=q.current,X=Q.current&&ze.some(Z=>Z.id===Q.current)?Q.current:ze[0].id;d(ze),g(X),Q.current=X,n(!0);return}const ae=qs(),Ce=`eb_${Date.now().toString(36)}_${Math.random().toString(36).slice(2,7)}`,Re={id:ae,title:"New Tab",payload:{kind:"url",url:"about:blank",title:"New Tab",browserId:Ce}};q.current=[Re],d([Re]),g(Re.id),Q.current=Re.id,n(!0);return}const be=qs(),je=`eb_${Date.now().toString(36)}_${Math.random().toString(36).slice(2,7)}`;let Ae,oe=!1,U=!1;l("browser"),d(ae=>{if(ae.length>0)return q.current=ae,W.current&&(Q.current=W.current),U=!0,Ae=null,[];if(q.current.length>0){oe=!0;const Re=q.current;return Ae=Q.current&&Re.some(X=>X.id===Q.current)?Q.current:Re[0].id,Re}oe=!0;const Ce={id:be,title:"New Tab",payload:{kind:"url",url:"about:blank",title:"New Tab",browserId:je}};return q.current=[Ce],Ae=Ce.id,[Ce]}),oe&&n(!0),U?(g(null),T(!1),Se()):Ae!=null&&(g(Ae),Q.current=Ae)},[c.length,m.length,Se]),ht=k.useCallback(()=>{if(L.current==="browser"&&c.length>0){if(l("terminal"),Se(),m.length>0){n(!0);return}if(B.current.length>0){const ze=B.current,X=J.current&&ze.some(Z=>Z.id===J.current)?J.current:ze[0].id;f(ze),x(X),J.current=X,n(!0);return}const ae=qs(),Ce=`term_${Date.now().toString(36)}_${Math.random().toString(36).slice(2,7)}`;ji(Ce);const Re={id:ae,title:"Terminal",payload:{kind:"terminal",terminalId:Ce,title:"Terminal"}};B.current=[Re],f([Re]),x(Re.id),J.current=Re.id,n(!0);return}const be=qs(),je=`term_${Date.now().toString(36)}_${Math.random().toString(36).slice(2,7)}`;ji(je);let Ae,oe=!1,U=!1;l("terminal"),Se(),f(ae=>{if(ae.length>0)return B.current=ae,re.current&&(J.current=re.current),U=!0,Ae=null,[];if(B.current.length>0){oe=!0;const Re=B.current;return Ae=J.current&&Re.some(X=>X.id===J.current)?J.current:Re[0].id,Re}oe=!0;const Ce={id:be,title:"Terminal",payload:{kind:"terminal",terminalId:je,title:"Terminal"}};return B.current=[Ce],Ae=Ce.id,[Ce]}),oe&&n(!0),U?(x(null),T(!1)):Ae!=null&&(x(Ae),J.current=Ae)},[c.length,m.length,Se]),Mt=k.useCallback(be=>{const je=L.current==="terminal"?m:c;if(je.length<2)return;const Ae=L.current==="terminal"?re.current:W.current,U=(Math.max(0,je.findIndex(Ce=>Ce.id===Ae))+be+je.length)%je.length,ae=je[U].id;L.current==="terminal"?(x(ae),J.current=ae):(g(ae),Q.current=ae)},[c,m]),Bt=k.useCallback(be=>{const Ae=(L.current==="terminal"?m:c)[be];Ae&&(L.current==="terminal"?(x(Ae.id),J.current=Ae.id):(g(Ae.id),Q.current=Ae.id))},[c,m]),Qt=k.useCallback(()=>{if(L.current==="terminal"){const je=`term_${Date.now().toString(36)}_${Math.random().toString(36).slice(2,7)}`;me({kind:"terminal",terminalId:je,title:"Terminal"});return}const be=`eb_${Date.now().toString(36)}_${Math.random().toString(36).slice(2,7)}`;me({kind:"url",url:"about:blank",title:"New Tab",browserId:be})},[me]),wt=k.useCallback(be=>{const je=te.current,Ae=je.findIndex(ze=>ze.payload.kind==="terminal"&&ze.payload.terminalId===be);if(Ae<0){Wh(be),window.markusDesktop?.terminal?.destroy(be);return}const oe=je[Ae];if(je.length>1){P(oe.id);return}Wh(be),window.markusDesktop?.terminal?.destroy(be);const U=`term_${Date.now().toString(36)}_${Math.random().toString(36).slice(2,7)}`;ji(U);const ae=oe.payload.kind==="terminal"&&(oe.payload.title||oe.title)||"Terminal",Ce=oe.payload.kind==="terminal"?oe.payload.cwd:void 0,Re={id:oe.id,title:ae,payload:{kind:"terminal",terminalId:U,title:ae,cwd:Ce}};B.current=[Re],f([Re]),x(Re.id),J.current=Re.id,L.current!=="terminal"&&l("terminal")},[P]),Ue=k.useCallback(be=>T(be),[]),ft=k.useCallback(()=>T(be=>!be),[]),kt=i==="terminal"?m:c,Nt=i==="terminal"?y:h,zt=kt.find(be=>be.id===Nt)??kt[0]??null,ce=zt?.payload??null,tt=kt.length>0,rt=k.useMemo(()=>({leftCollapsed:t,setLeftCollapsed:ee,toggleLeftCollapsed:ue,keyboardPane:E,setKeyboardPane:D,l0FocusPageId:M,setL0FocusPageId:H,rightPanelMode:i,setRightPanelMode:$,switchRightPanelMode:G,rightPanel:ce,rightPanelOpen:tt,rightPanelTabs:kt,activeRightPanelTabId:zt?.id??null,openRightPanel:me,closeRightPanel:_e,closeRightPanelTab:P,setActiveRightPanelTab:He,updateRightPanelBrowserTab:Pe,updateRightPanelTerminalTab:Ge,toggleRightPanel:pt,toggleTerminalPanel:ht,collapseRightPanelOnly:ut,cycleRightPanelTab:Mt,activateRightPanelTabAt:Bt,openNewRightPanelTab:Qt,handleTerminalExit:wt,rightPanelFullscreen:w,setRightPanelFullscreen:Ue,toggleRightPanelFullscreen:ft,hostAvailable:C,setHostAvailable:S}),[t,ee,ue,E,D,M,H,i,$,G,ce,tt,kt,zt,me,_e,P,He,Pe,Ge,pt,ht,ut,Mt,Bt,Qt,wt,w,Ue,ft,C]);return s.jsx(j3.Provider,{value:rt,children:e})}function Oc(){return k.useContext(j3)}function Ti(e,t){const n=/```[\s\S]*?```|`[^`\n]+`/g;let r=0,i="";for(const l of e.matchAll(n))i+=t(e.slice(r,l.index)),i+=l[0],r=l.index+l[0].length;return i+=t(e.slice(r)),i}function gV(e){let t=e.replace(/\\\[([\s\S]*?)\\\]/g,(n,r)=>`$$${r}$$`);return t=t.replace(/\\\((.+?)\\\)/g,(n,r)=>`$${r}$`),t}const kd="#mention:";function bV(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="",i=0;for(;i<e.length;){const l=e.indexOf("@",i);if(l<0){r+=e.slice(i);break}if(r+=e.slice(i,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)})`,i=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)})`,i=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)})`,i=l+1+h.length;continue}r+="@",i=l+1}return r}const M3="#entity:",xV=new RegExp("(?<!\\[)(?<!\\()(?<!:)(?<!\\/)(?<!\\\\)\\b(tsk|req|proj|dlv|agt|team)_[a-f0-9]{6,}\\b(?!\\]\\(#entity:)","gi"),yV=/`\[([^\]]+)\]\(#entity:((?:tsk|req|proj|dlv|agt|team)_[a-f0-9]{6,})\)`/gi;function R3(e,t){const n=e.slice(0,t),r=n.lastIndexOf("](");return r===-1?!1:n.indexOf(")",r+2)===-1}function vV(e){return e.replace(yV,(t,n,r)=>`[${n}](${M3}${r})`)}function wV(e){return e.replace(xV,(t,n,r)=>R3(e,r)?t:`[${t}](${M3}${t})`)}const kV=["\\s","<",">","`","\\u4e00-\\u9fff","\\u3000-\\u303f","\\uff00-\\uffef"].join(""),SV=new RegExp(`https?://[^${kV}]+`,"gi");function D3(e){return e.replace(SV,(t,n)=>{if(R3(e,n))return t;const r=t.replace(/[.,;:!?\]\)"']+$/,"");if(!r)return t;const i=t.slice(r.length);return/[()[\]]/.test(r)?t:`[${r}](${r})${i}`})}function NV(e){const t=e.trim();return t.startsWith("@startuml")&&t.endsWith("@enduml")}const CV=/^(graph\s|flowchart\s|sequenceDiagram|classDiagram|stateDiagram|erDiagram|gantt|pie|gitGraph|mindmap|timeline|journey)/m;function TV(e){return CV.test(e.trim())}const AV={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 EV(e){return AV[e.toLowerCase()]??e.charAt(0).toUpperCase()+e.slice(1)}function _V(e){const t=e.match(/language-(\S+)/);return t?t[1]:null}const L3=/^(?:\/|~\/|[A-Za-z]:[\\/]|\\\\)/,O3=/^\.{1,2}\//,jV=/\.[a-zA-Z0-9]{1,12}(?:$|[?#])/,I3=/^[A-Za-z]:[\\/]/,P3=/^\\\\[^\\]/;function B3(e){const t=e.trim();return t?!!(/^file:/i.test(t)||I3.test(t)||P3.test(t)||t.startsWith("~/")||t.startsWith("/")||O3.test(t)):!1}function Xg(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 MV(e){return e.replace(/(!?\[[^\]]*]\()((?:[A-Za-z]:|\\\\)[^)\n]*)(\))/g,(t,n,r,i)=>`${n}${r.replace(/\\+/g,"/")}${i}`)}function z3(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(L3.test(e))return e.startsWith("~/")?e:e.replace(/\\/g,"/");if(!t)return e;const r=`${t.replace(/\\/g,"/").replace(/\/+$/,"")}/${e.replace(/^\.\//,"")}`,i=r.split("/"),l=[];for(const d of i)!d||d==="."||(d===".."?l.pop():l.push(d));const c=l.join("/");return r.startsWith("/")?`/${c}`.replace(/^\/+/,"/"):c}function o4(e){const t=e.indexOf("#");return t<0?{path:e}:{path:e.slice(0,t),fragment:decodeURIComponent(e.slice(t+1))}}function l4(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(I3.test(n)||P3.test(n)){const{path:l,fragment:c}=o4(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:Xg(n)}:{kind:"passthrough"};const{path:r,fragment:i}=o4(n);return L3.test(r)?{kind:"file",path:Sd(r,t),fragment:i}:O3.test(r)?{kind:"file",path:Sd(r,t),fragment:i}:r&&jV.test(r)&&!r.includes("://")?{kind:"file",path:Sd(r,t),fragment:i}:{kind:"passthrough"}}function RV(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 i of r)if(z3(i.textContent||"")===t||i.id===t){n=i;break}}return n?(n.scrollIntoView({behavior:"smooth",block:"start"}),!0):!1}function $3(e){return e.type==="text"?e.value??"":(e.children??[]).map($3).join("")}function H3(){return e=>{const t=new Map,n=r=>{if(r.type==="element"&&r.tagName&&/^h[1-6]$/.test(r.tagName)){const i=$3(r).trim();let l=z3(i);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 i of r.children??[])n(i)};n(e)}}function DV(e,t,n){const r=e.cloneNode(!0),i=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:${i};font-size:${l};line-height:1.7;max-width:800px;">${r.innerHTML}</div>`}async function Qg(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 LV(e,t,n,r){const i=DV(e,t,r);try{return await navigator.clipboard.write([new ClipboardItem({"text/html":new Blob([i],{type:"text/html"}),"text/plain":new Blob([n],{type:"text/plain"})})]),{ok:!0,method:"html"}}catch{return{ok:await Qg(n),method:"text"}}}const U3="markus-copy-typography",c4={fontFamily:"default",fontSize:15,headingScale:"standard"};function F3(){try{const e=localStorage.getItem(U3);if(e)return{...c4,...JSON.parse(e)}}catch{}return c4}function OV(e){localStorage.setItem(U3,JSON.stringify(e))}function IV(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 PV({onClose:e}){const{t}=gt("common"),[n,r]=k.useState(F3);k.useEffect(()=>{OV(n)},[n]);const i=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=>i("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=>i("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:()=>i("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 BV extends k.Component{state={error:null};static getDerivedStateFromError(t){return{error:t}}componentDidUpdate(t){this.state.error&&this.props.resetKeys&&!zV(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 zV(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 $V=k.lazy(()=>ta(()=>Promise.resolve().then(()=>t6),void 0).then(e=>({default:e.MarkdownMessage}))),HV={file:{icon:"📄",color:"bg-green-500/10 text-green-600"},directory:{icon:"📁",color:"bg-blue-500/10 text-blue-600"}},u4={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 UV({item:e,onClose:t,onOpenInPage:n}){const{t:r}=gt(["agent","common"]),i=HV[e.type]??{icon:"📎",color:"bg-surface-elevated text-fg-secondary"},l=u4[e.status]??u4.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 ${i.color}`,children:i.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($V,{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"?Da.createPortal(d,document.body):d}const FV={tsk:"task",req:"requirement",proj:"project",dlv:"deliverable",agt:"agent",team:"team"};function q3(e){return{task:"task",requirement:"requirement",project:"project",deliverable:"deliverable",agent:"agent",team:"team"}[e]}const G3={task:"📋",requirement:"📝",project:"📁",deliverable:"📦",agent:"🤖",team:"👥"},K3={task:"Task",requirement:"Requirement",project:"Project",deliverable:"Deliverable",agent:"Agent",team:"Team"},qV=/^(tsk|req|proj|dlv|agt|team)_[a-f0-9]{6,}$/i;function b0(e){return qV.test(e.trim())}function GV(e){const t=e.split("_")[0]?.toLowerCase();return t?FV[t]:void 0}function V3(e){e.startsWith("tsk_")?it.navigate(le.WORK,{openTask:e}):e.startsWith("req_")?it.navigate(le.WORK,{openRequirement:e}):e.startsWith("proj_")?it.navigate(le.WORK,{projectId:e}):e.startsWith("dlv_")?it.navigate(le.DELIVERABLES,{openDeliverable:e}):e.startsWith("agt_")?it.navigate(le.TEAM,{agentId:e}):e.startsWith("team_")&&it.navigate(le.TEAM,{selectTeam:e})}const Qp=new Map,Nd=new Map;async function KV(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 i=(await Ee.teams.list()).teams.find(l=>l.id===e);return{...n,title:i?.name??e,notFound:!i}}}}catch{}return{...n,notFound:!0}}function W3(e,t){const n=t??GV(e),[r,i]=k.useState(()=>Qp.get(e)??{id:e,type:n??"task",title:e,loading:!!n});return k.useEffect(()=>{if(!n){i({id:e,type:"task",title:e,loading:!1,notFound:!0});return}const l=Qp.get(e);if(l){i(l);return}i(m=>({...m,type:n,loading:!0}));let c=!0,d=Nd.get(e);return d||(d=KV(e,n),Nd.set(e,d)),d.then(m=>{Qp.set(e,m),Nd.delete(e),c&&i(m)}).catch(()=>{Nd.delete(e),c&&i({id:e,type:n,title:e,loading:!1,notFound:!0})}),()=>{c=!1}},[e,n]),r}function Y3(e){const t=(e.split("_")[0]?.length??3)+1;return e.length>t+8?`${e.slice(0,t+8)}…`:e}function dc({id:e,type:t,label:n}){const r=W3(e,t),i=Oc(),l=G3[r.type]??"🔗",c=n??(r.loading||r.notFound?Y3(e):r.title),d=m=>{if(m.preventDefault(),m.stopPropagation(),r.type==="deliverable"&&r.deliverable&&i?.hostAvailable){i.openRightPanel({kind:"deliverable",deliverable:r.deliverable});return}V3(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:`${K3[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 VV({id:e,type:t,label:n}){const r=W3(e,t),[i,l]=k.useState(!1),c=Oc(),d=G3[r.type]??"🔗",m=()=>{if(r.type==="deliverable"&&r.deliverable){if(c?.hostAvailable){c.openRightPanel({kind:"deliverable",deliverable:r.deliverable});return}l(!0);return}V3(e)},f=r.loading?Y3(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:K3[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"})})]}),i&&r.deliverable&&s.jsx(UV,{item:r.deliverable,onClose:()=>l(!1),onOpenInPage:h=>{l(!1),it.navigate(le.DELIVERABLES,{openDeliverable:h})}})]})}k.lazy(()=>ta(()=>Promise.resolve().then(()=>t6),void 0).then(e=>({default:e.MarkdownMessage})));const WV=k.lazy(()=>ta(()=>import("./ContentRenderer-BEWNNIbH.js"),[]).then(e=>({default:e.ContentRenderer})));let _o=[],d4=60;function YV(e){const t=k.useRef(e);t.current=e;const[n]=k.useState(()=>++d4);return k.useEffect(()=>{const r=()=>t.current();_o.push(r);const i=l=>{l.key==="Escape"&&_o[_o.length-1]===r&&(l.preventDefault(),r())};return window.addEventListener("keydown",i,!0),()=>{window.removeEventListener("keydown",i,!0),_o=_o.filter(l=>l!==r),_o.length===0&&(d4=60)}},[]),n}const m4=500,Ws=new Map,x0=new Set,qd=new Map;let Gd=null;function XV(){if(Ws.size<=m4)return;const e=Ws.size-m4,t=Ws.keys();for(let n=0;n<e;n++){const{value:r,done:i}=t.next();if(i)break;Ws.delete(r)}}function f4(e,t){Ws.delete(e),Ws.set(e,t),XV()}function p4(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))f4(n,r),p4(n)}).catch(()=>{for(const t of e)f4(t,{exists:!1,isFile:!1,type:"unknown"}),p4(t)})}function ZV(e){Ws.has(e)||x0.has(e)||(x0.add(e),Gd&&clearTimeout(Gd),Gd=setTimeout(QV,30))}function JV(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 eW(e){const t=k.useCallback(i=>JV(e,i),[e]),n=k.useCallback(()=>Ws.get(e),[e]),r=k.useSyncExternalStore(t,n,n);return k.useEffect(()=>{ZV(e)},[e]),r}const tW=/^(?:\/[\w.\-@+]+(?:\/[\w.\-@+ ]*)*|~\/[\w.\-@+]+(?:\/[\w.\-@+ ]*)*|[A-Za-z]:(?:\\|\/)[\w.\-@+ ]+(?:(?:\\|\/)[\w.\-@+ ]*)*|\.\.?\/[\w.\-@+]+(?:\/[\w.\-@+ ]*)*)$/;function nW(e){return e.length<2||e.length>500?!1:tW.test(e)}function rW({filePath:e,onClose:t}){const n=YV(t),[r,i]=k.useState(!0),[l,c]=k.useState(null),[d,m]=k.useState(""),[f,h]=k.useState(""),[g,y]=k.useState(""),[x,w]=k.useState(""),[T,C]=k.useState("");k.useEffect(()=>{i(!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||""),C(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(()=>{i(!1)})},[e]);const S=g||e.split(/[/\\]/).pop()||e;return Da.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"&&T&&s.jsx("audio",{controls:!0,preload:"metadata",src:T,className:"w-full"}),!r&&!l&&f==="video"&&T&&s.jsx("video",{controls:!0,preload:"metadata",src:T,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(WV,{content:d,format:f==="text"?"text":f,className:"text-sm"})})]})]})}),document.body)}function aW({path:e}){const t=eW(e),[n,r]=k.useState(null),i=Oc(),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(i?.hostAvailable){i.openRightPanel({kind:"file",path:e});return}r(e)}else Ee.files.reveal(e)},[l,c,e,i]),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(rW,{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 sW(){return Zp||(Zp=ta(()=>import("./mermaid.core-DL-UboGV.js").then(e=>e.b9),__vite__mapDeps([0,1])).then(e=>(e.default.initialize({startOnLoad:!1,securityLevel:"loose",fontFamily:"inherit"}),e))),Zp}function iW(){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 oW(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 lW(){return iW()}function cW(){return k.useSyncExternalStore(oW,lW)}function X3({code:e}){const t=k.useRef(null),[n,r]=k.useState(null),[i,l]=k.useState(!0),c=k.useId(),d=k.useRef(0),m=k.useRef(null),f=cW();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 sW();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:[i&&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${i?" hidden":""}`})]})}const uW="/assets/viz-global-C_AyN6D9.js";let Cd=!1,Jp=null;function dW(){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=uW,r.onload=()=>{Cd=!0,e()},r.onerror=()=>t(new Error("Failed to load viz-global.js")),document.head.appendChild(r)})}function mW(){return Jp||(Jp=dW().then(()=>ta(()=>import("./plantuml-DezRDxd4.js"),[]))),Jp}let h4=Promise.resolve();function fW(e,t){const n=h4.then(()=>new Promise((r,i)=>{mW().then(({renderToString:l})=>{const c=e.split(/\r\n|\r|\n/);l(c,r,i,{dark:t})}).catch(i)}));return h4=n.then(()=>{},()=>{}),n}function pW(){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 hW(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 gW(){return k.useSyncExternalStore(hW,()=>pW())}function Q3({code:e}){const[t,n]=k.useState(null),[r,i]=k.useState(null),[l,c]=k.useState(!0),d=k.useRef(null),m=gW();return k.useEffect(()=>{if(!e.trim()||d.current&&d.current.code===e&&d.current.dark===m)return;let f=!1;return c(!0),i(null),fW(e.trim(),m).then(h=>{f||(n(h),d.current={code:e,dark:m})}).catch(h=>{f||i(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 Zh({code:e,language:t,children:n}){const{t:r}=gt("common"),[i,l]=k.useState("rendered"),[c,d]=k.useState(!1),m=k.useCallback(async()=>{await Qg(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 ${i==="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 ${i==="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")]})})]})]}),i==="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 bW=[X3,Q3];function xW(e){for(const t of k.Children.toArray(e))if(k.isValidElement(t)&&typeof t.props?.className=="string"){const n=t.props.className;return _V(n)}return null}function mc(e){if(typeof e=="string")return e;if(typeof e=="number")return String(e);if(!e)return"";if(Array.isArray(e))return e.map(mc).join("");if(k.isValidElement(e)){const t=e.props;return mc(t.children)}return""}function yW({children:e}){const{t}=gt("common"),n=xW(e),r=k.useRef(null),[i,l]=k.useState(!1),[c,d]=k.useState("rendered"),m=k.useCallback(async()=>{let h;c==="source"?h=mc(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)&&bW.includes(h.type))){const h=mc(e),g=n==="mermaid"||n==="plantuml"?n:"diagram";return s.jsx(Zh,{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:EV(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:mc(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:i?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 g4="#mention:",y0="#entity:",vW=/^\[([^\]]+)\]\(#entity:((tsk|req|proj|dlv|agt|team)_[a-f0-9]{6,})\)$/i,Z3=/^(workflow|task|requirement|project|deliverable|agent|team):(.+)$/,Jh="text-brand-500 hover:text-brand-500 underline break-all cursor-pointer";function eg(e){return e.type==="text"?e.value??"":(e.children??[]).map(eg).join("")}function wW(e){return e.type==="text"&&(e.value??"").trim()===""}function kW(e){if(!e?.children)return null;const t=e.children.filter(r=>!wW(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 i=eg(n);if(r.startsWith(y0))return{id:r.slice(y0.length)};const l=r.match(Z3);return l&&l[1]!=="workflow"?{id:l[2],type:q3(l[1]),label:i}:null}if(n.type==="element"&&n.tagName==="code"){const r=eg(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 SW={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")||NV(r))return s.jsx(Zh,{code:r,language:"plantuml",children:s.jsx(Q3,{code:r})});if(t?.includes("language-mermaid")||!t&&TV(r))return s.jsx(Zh,{code:r,language:"mermaid",children:s.jsx(X3,{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(dc,{id:n.trim()});const i=n.match(vW);return i?s.jsx(dc,{id:i[2],label:i[1]}):nW(n)?s.jsx(aW,{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(yW,{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:Jh,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})},NW=/\.(png|jpe?g|gif|webp|svg|bmp|ico)$/i;function CW(e){const t=Xg(e);return B3(e)&&NW.test(t.split("?")[0]??t)}function TW(e,t){const n=Xg(e);if(n.startsWith("/")||n.startsWith("~/")||/^[A-Za-z]:\//.test(n)||n.startsWith("//"))return n;if((n.startsWith("./")||n.startsWith("../"))&&t){const i=((t.replace(/\\/g,"/").endsWith("/")?t.replace(/\\/g,"/"):`${t.replace(/\\/g,"/")}/`)+n).split("/"),l=[];for(const c of i)c===".."?l.pop():c!=="."&&c!==""&&l.push(c);return"/"+l.join("/")}return n}function AW(e){return`/api/files/image?path=${encodeURIComponent(e)}`}const jo=new Map;function EW({src:e,alt:t,onPreview:n,basePath:r}){const i=k.useMemo(()=>CW(e)?AW(TW(e,r)):e,[e,r]),l=i.startsWith("/api/files/image?"),c=jo.get(i),[d,m]=k.useState(c??(l?null:i)),[f,h]=k.useState(!!c),[g,y]=k.useState(!1),[x,w]=k.useState(null),[T,C]=k.useState(0),S=k.useRef(0),E=k.useCallback(()=>{jo.delete(i),y(!1),w(null),h(!1),m(l?null:`${i}${i.includes("?")?"&":"?"}retry=${Date.now()}`),C(j=>j+1)},[i,l]);return k.useEffect(()=>{if(!l)return;const j=jo.get(i);if(j){m(j),h(!0),y(!1),w(null);return}const M=++S.current;y(!1),w(null),h(!1),m(null),(async()=>{try{const O=await fetch(i,{credentials:"same-origin"});if(M!==S.current)return;if(!O.ok){let q=`HTTP ${O.status}`;try{const Q=await O.json();Q.error&&(q=Q.error)}catch{}throw new Error(q)}const D=await O.blob();if(M!==S.current)return;if(D.size===0)throw new Error("Empty image response");if(D.type&&!D.type.startsWith("image/")&&!D.type.includes("octet-stream"))throw new Error(`Unexpected content-type: ${D.type}`);const H=URL.createObjectURL(D);jo.set(i,H),m(H),h(!0),y(!1),w(null)}catch(O){if(M!==S.current)return;const D=O instanceof Error?O.message:String(O);console.warn("[MarkdownImage] failed to load local image",i,O),w(D),y(!0),h(!1)}})()},[l,i,T]),k.useEffect(()=>{l||(m(i),h(!!jo.get(i)),y(!1),w(null))},[i,l,T]),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||jo.set(i,i),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 b4(e){const t=await fetch(e);if(!t.ok)throw new Error(`Failed to fetch image (${t.status})`);return t.blob()}async function _W(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((i,l)=>{n.toBlob(c=>c?i(c):l(new Error("PNG encode failed")),"image/png")})}function jW(e,t){try{const i=(e.startsWith("data:")?"":new URL(e,window.location.href).pathname).split("/").pop()||"";if(i&&/\.(png|jpe?g|gif|webp|svg|bmp)$/i.test(i))return decodeURIComponent(i)}catch{}return`image.${(t.type.split("/")[1]||"png").replace("jpeg","jpg")}`}function J3({src:e,onClose:t}){const{t:n}=gt("common"),[r,i]=k.useState(null),[l,c]=k.useState(null);Vo(!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=>{i(g),window.setTimeout(()=>i(null),1600)},[]),m=k.useCallback(async g=>{if(g.stopPropagation(),!l){c("copy");try{const y=await b4(e),x=await _W(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 b4(e),x=URL.createObjectURL(y),w=document.createElement("a");w.href=x,w.download=jW(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 Da.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 e6(e={}){const{onMentionClick:t,basePath:n,onImagePreview:r,contentRef:i,hostAvailable:l,openRightPanel:c}=e,d=k.useCallback((m,f)=>{const h=l4(f,n);if(h.kind!=="passthrough"){if(m.preventDefault(),m.stopPropagation(),h.kind==="fragment"){RV(i?.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}Xs(h.url)}}},[n,i,l,c]);return k.useMemo(()=>({...SW,img:({src:m,alt:f})=>s.jsx(EW,{src:m??"",alt:f,onPreview:r,basePath:n},m??""),p:({children:m,node:f})=>{const h=kW(f);return h?s.jsx(VV,{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(g4)){const g=decodeURIComponent(m.slice(g4.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(dc,{id:m.slice(y0.length)});{const g=m?.match(Z3);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:T=>{T.preventDefault(),T.stopPropagation(),it.navigate(le.WORK,{boardType:"workflows"})},title:`workflow: ${x}`,children:[s.jsx("span",{className:"text-[10px]",children:"⚙️"}),s.jsx("span",{children:f})]});const w=q3(y);if(w)return s.jsx(dc,{id:x,type:w,label:f})}}if(m&&b0(m))return s.jsx(dc,{id:m.trim(),label:f});const h=l4(m,n);return h.kind==="fragment"||h.kind==="file"||h.kind==="external"?s.jsx("a",{href:m,className:Jh,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:Jh,onClick:g=>{Ho()&&m&&!/^[a-zA-Z][a-zA-Z0-9+.-]*:/.test(m)&&g.preventDefault()},children:f})}}),[t,n,r,d])}const x4=[Z5,e3,t3],y4=[H3,[u3,{strict:"ignore"}],[E3,{detect:!0,ignoreMissing:!0}]];function v4(e){return/^(deliverable|task|requirement|project|agent|team|workflow):/i.test(e)||B3(e)?e:T5(e)}const MW=/ thinking([\s\S]*?)(<\/think>|$)/g;function RW(e){const t=[];let n=e.replace(MW,(r,i)=>{const l=i.trim();return l&&t.push(l),""});return n=n.replace(/<\/think>/g,"").replace(/ thinking/g,""),{thinking:t,rest:n.trim()}}function DW(e=640){const[t,n]=k.useState(()=>window.innerWidth<e);return k.useEffect(()=>{const r=window.matchMedia(`(max-width: ${e-1}px)`),i=l=>n(l.matches);return r.addEventListener("change",i),n(r.matches),()=>r.removeEventListener("change",i)},[e]),t}function LW({content:e,contentRef:t}){const{t:n}=gt("common"),[r,i]=k.useState(!1),[l,c]=k.useState(!1),[d,m]=k.useState(!1),[f,h]=k.useState(null),g=k.useRef(null),y=DW();k.useEffect(()=>{if(!r)return;const C=S=>{g.current&&!g.current.contains(S.target)&&(i(!1),c(!1),m(!1))};return document.addEventListener("mousedown",C),()=>document.removeEventListener("mousedown",C)},[r]);const x=k.useCallback(C=>{h(C),setTimeout(()=>h(null),1500)},[]),w=async()=>{const C=await Qg(e);x(n(C?"markdown.copied":"markdown.failed")),i(!1)},T=async C=>{const S=t.current?.firstElementChild;if(!S)return;const E=F3(),j=IV(E),M=await LV(S,C,e,{fontFamily:j.fontFamily,fontSize:j.fontSize,headingScales:j.headingScales}),O=n(C==="light"?"markdown.themeLight":"markdown.themeDark");x(M.ok?M.method==="html"?n("markdown.htmlCopied",{theme:O}):n("markdown.textCopied"):n("markdown.failed")),i(!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:()=>i(C=>!C),className:"p-1.5 rounded-lg bg-surface-elevated/80 hover:bg-surface-overlay text-fg-secondary hover:text-fg-primary backdrop-blur-sm border border-border-default/50 transition-all",title: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(PV,{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:()=>T("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:()=>T("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 Br=k.memo(function({content:t,className:n="",onMentionClick:r,knownNames:i,basePath:l}){const{thinking:c,rest:d}=RW(t),m=k.useRef(null),[f,h]=k.useState(null),g=Oc(),y=k.useCallback(T=>{let C=Ti(T,gV);return C=Ti(C,MV),C=Ti(C,vV),C=Ti(C,wV),C=Ti(C,S=>bV(S,i)),C=Ti(C,D3),C},[i]),x=k.useMemo(()=>y(d),[d,y]),w=e6({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(LW,{content:t,contentRef:m}),s.jsx("div",{ref:m,children:s.jsx(BV,{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 T=c.join(`
649
649
 
650
650
  `),C=T.split(`
651
651
  `)[0]??"",S=C.length>80?C.slice(0,80)+"…":C;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(jh,{remarkPlugins:x4,rehypePlugins:y4,components:w,urlTransform:v4,children:y(T)})})})]})})(),s.jsx(jh,{remarkPlugins:x4,rehypePlugins:y4,components:w,urlTransform:v4,children:x})]})})}),f&&s.jsx(J3,{src:f,onClose:()=>h(null)})]})},(e,t)=>e.content===t.content&&e.className===t.className&&e.basePath===t.basePath&&e.onMentionClick===t.onMentionClick&&OW(e.knownNames,t.knownNames));function OW(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 t6=Object.freeze(Object.defineProperty({__proto__:null,ImagePreviewModal:J3,MarkdownMessage:Br},Symbol.toStringTag,{value:"Module"})),tg={suppressAdjustUntil:0};function Ac(e=2500){const t=typeof performance<"u"?performance.now():Date.now();tg.suppressAdjustUntil=Math.max(tg.suppressAdjustUntil,t+e)}function eQ(){return(typeof performance<"u"?performance.now():Date.now())<tg.suppressAdjustUntil}const w4={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:"🔍"}},k4={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 Ii(e){const t=e.includes("__")?e.split("__").pop():e,n=w4[t]??w4[e],r=k4[t]??k4[e]??"settings";return n?{...n,iconName:r,key:t}:{label:t.replace(/_/g," ").replace(/\b\w/g,i=>i.toUpperCase()),icon:"⚙",iconName:r,key:t}}function Ko(e){return e==null?"":e<1e3?`${e}ms`:`${(e/1e3).toFixed(1)}s`}function IW(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"),i=String(t.getHours()).padStart(2,"0"),l=String(t.getMinutes()).padStart(2,"0"),c=String(t.getSeconds()).padStart(2,"0");return`${n}-${r} ${i}:${l}:${c}`}function ng(e,t){return e.length<=t?e:e.slice(0,t)+"…"}function S4(e){try{const t=JSON.parse(e);return JSON.stringify(t,null,2)}catch{return e}}function n6(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 PW(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 tQ(e,t){const n=new Map;let r=null;for(const i of e)if(i.type==="tool_start"&&(i.content==="spawn_subagent"||i.content==="spawn_subagents"))r=i.seq,n.set(i.seq,[]);else if(i.type==="tool_end"&&(i.content==="spawn_subagent"||i.content==="spawn_subagents")){if(r!==null){const l=n.get(r);l&&n.set(i.seq,l)}r=null}else if(r!==null&&i.type.startsWith("subagent_")){const l=i.type.replace("subagent_",""),c=i.metadata;n.get(r)?.push({eventType:l,content:i.content,metadata:c})}return t.map(i=>{if(i.type!=="tool")return i;const l=i.key;if(!l)return i;const c=l.replace(/^(?:t[se]_|e[se]_)/,""),d=parseInt(c,10);if(isNaN(d))return i;const m=n.get(d);return!m||m.length===0?i:{...i,info:{...i.info,subagentLogs:m}}})}function N4(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 i=n-1;i>=0;i--){const l=e[i];if(l.type==="tool"&&l.info.status==="running"&&l.info.tool===r.info.tool&&!t.has(i)){t.add(i);break}}}return e.filter((n,r)=>!t.has(r))}function r6(e){const t=IW(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 i=r?.action;return i&&["chat","chat_stream","task_execution","respond_in_session"].includes(i)?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 a6(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 s6(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 i6={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 BW(e){return!!e&&e in i6}function tl({name:e,size:t=24,className:n=""}){const r=i6[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 C4={"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"},T4={development:"code",开发工具:"code",devops:"server",data:"bar-chart",数据分析:"bar-chart",productivity:"zap",效率提升:"zap",communication:"message-square",通讯协作:"message-square",browser:"globe",内容创作:"edit","AI 智能":"sparkles"};function Kd(e,t){const n=(e||"").toLowerCase();return C4[n]?C4[n]:t&&T4[t]?T4[t]:"layers"}function zW(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 o6(){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 $W(){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 A4({item:e}){const{t}=gt("common"),n=Ii(e.tool);return s.jsxs("div",{className:"flex items-center gap-1.5 py-0.5",children:[s.jsx(tl,{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(o6,{})]})}function HW({activities:e,isActive:t,persistent:n}){const{t:r}=gt("common"),i=zW(e),[l,c]=k.useState(!1),d=i.length>0,m=d&&i.every(w=>w.status!=="running");if(n&&m){const w=i.filter(C=>C.status==="error").length,T=i.filter(C=>C.status==="done").length;return s.jsxs("div",{className:"mb-3 border-b border-border-default/50 pb-2",children:[s.jsxs("button",{onClick:()=>c(C=>!C),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:T})}),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:[i.slice(0,5).map(C=>{const S=Ii(C.tool);return s.jsx(tl,{name:S.iconName,size:13,className:`shrink-0 ${C.status==="error"?"text-red-500":"text-green-500"}`},C.key)}),i.length>5&&s.jsxs("span",{className:"text-[10px] text-fg-tertiary",children:["+",i.length-5]})]})]}),l&&s.jsx("div",{className:"mt-2 space-y-0.5",children:i.map((C,S)=>s.jsx(A4,{item:C,idx:S,total:i.length},C.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($W,{})]});const f=i.filter(w=>w.status==="error").length;let h=null;for(let w=i.length-1;w>=0;w--)if(i[w].status==="running"){h=i[w];break}const g=i[i.length-1];let y;if(h){const w=Ii(h.tool);y=`${r(`execution.tools.${w.key}`,{defaultValue:w.label})}…`}else if(t&&m)y=r("activity.writingResponse");else{const w=Ii(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(T=>!T)},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:i.length})]}),f>0&&s.jsxs("span",{className:"text-red-500 shrink-0",children:["· ",r("activity.failed",{count:f})]}),x&&s.jsx(o6,{})]}),l&&s.jsx("div",{className:"mt-1 space-y-0.5",children:i.map((w,T)=>s.jsx(A4,{item:w,idx:T,total:i.length},w.key))})]})}const UW={"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"}},$o=["created","context_injected","running"],FW=new Set(["completed","failed","cancelled","timeout"]),E4={created:"Created",context_injected:"Context injected",running:"Running",completed:"Completed",failed:"Failed",cancelled:"Cancelled",timeout:"Timed out"};function qW(e){return UW[e]??{label:e.replace(/-/g," ").replace(/\b\w/g,t=>t.toUpperCase()),icon:"⚙",badgeClass:"bg-surface-elevated text-fg-tertiary"}}function GW(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 i=new Date(e.completedAt).getTime();return Number.isNaN(i)?void 0:Math.max(0,i-r)}if(e.status==="running"||e.status==="context_injected")return Math.max(0,t-r)}}function KW(e){if(e==="completed"||FW.has(e))return $o.length;const t=$o.indexOf(e);return t>=0?t:0}function VW({session:e,className:t}){const n=qW(e.tool),[r,i]=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(()=>GW(e,l),[e,l]),g=KW(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:E4[e.status]??e.status}),h!=null&&s.jsx("span",{className:"text-[10px] text-fg-tertiary tabular-nums",children:Ko(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:[$o.map((w,T)=>{const C=g>T||g===T&&!d&&f,S=g===T&&d,E=m&&T===$o.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":C?"bg-green-500":S?"bg-brand-500 animate-pulse":"bg-gray-600"}`,title:E4[w]}),T<$o.length-1&&s.jsx("div",{className:`h-px flex-1 ${C?"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:()=>i(!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 WW({label:e}){const{t}=gt("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 _4=150;function YW({content:e,className:t}){const[n,r]=k.useState(e),i=k.useRef(0),l=k.useRef(null);k.useEffect(()=>{const d=Date.now(),m=d-i.current;return m>=_4?(i.current=d,r(e)):l.current||(l.current=setTimeout(()=>{i.current=Date.now(),l.current=null,r(e)},_4-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(Br,{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}=gt("common"),[r,i]=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`),Hn=Ve,fn=St),Gt===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 uQ(e,t,n){const r=t?new Date(t):new Date;if(isNaN(r.getTime()))return e;const i=new Date,l=new Date(i.getFullYear(),i.getMonth(),i.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 dQ(e){if(!e)return"";const t=new Date(e);return isNaN(t.getTime())?"":`${t.getFullYear()}-${t.getMonth()+1}-${t.getDate()}`}function mQ(e,t){const n=new Date(e);if(isNaN(n.getTime()))return"";const r=new Date,i=new Date(r.getFullYear(),r.getMonth(),r.getDate()).getTime(),l=n.getTime();return l>=i?t?.today??"Today":l>=i-864e5?t?.yesterday??"Yesterday":n.toLocaleDateString(void 0,{weekday:"long",year:"numeric",month:"long",day:"numeric"})}function fQ(e,t){let n=0,r=null;return((...i)=>{const l=Date.now(),c=t-(l-n);if(c<=0)return r&&(clearTimeout(r),r=null),n=l,e(...i);r||(r=setTimeout(()=>{n=Date.now(),r=null,e(...i)},c))})}function pQ({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 hQ({name:e,agentId:t,agents:n,onViewProfile:r}){const{t:i}=gt(["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(Ys,{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??i("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:i("page.viewProfileArrow")})]})]}):s.jsx("span",{children:e})}function gQ({agent:e,anchorRect:t,onClose:n,onViewProfile:r}){const{t:i}=gt(["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"?i("common:status.online"):e.status==="working"?i("common:status.working"):e.status==="error"?i("common:status.error"):i("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(Ys,{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:i("team:page.viewProfileArrow")})]})}function mY(e){const t=String(e);return t.includes("MARKUS_UPSTREAM_ERROR")?!1:t.includes("CU_EXCEEDED")||t.includes("CU_MONTHLY_EXCEEDED")}const m6="markus:credit-notif-muted";let O4=0;function bQ(){try{if(localStorage.getItem(m6))return}catch{}const e=Date.now();e-O4<5*6e4||(O4=e,window.dispatchEvent(new CustomEvent("markus:credit-exhausted")))}function fY(){try{localStorage.setItem(m6,"1")}catch{}}function xQ(e,t){const n=String(e);if(n.includes("AbortError")||n.includes("abort"))return"";let r="";const i=n.match(/\{[\s\S]*\}/);if(i)try{const d=JSON.parse(i[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(mY(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 yQ({msg:e,onCopy:t,onRetry:n,onResume:r,onReply:i,onRemember:l,isCopied:c,isLastAgentMsg:d,showRemember:m}){const{t:f}=gt(["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(T=>T.type==="text"&&(T.content||T.thinking)||T.type==="tool"),x=d!==!1,w=iY(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")]}),i&&s.jsxs("button",{onClick:()=>i(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 vQ({busy:e,onConfirm:t,onCancel:n}){const{t:r}=gt(["team","common"]),[i,l]=k.useState("");return Da.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:i,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(i),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 I4(e,t,n){if(!e)return[];const r=[];let i=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_${i}`,sourceType:"chat",sourceId:"",agentId:l,seq:i++,type:"text",content:E,createdAt:y,metadata:{isThinking:!0}})}h=""},w=()=>{const E=g.trim();E&&r.push({id:`cseg_${i}`,sourceType:"chat",sourceId:"",agentId:l,seq:i++,type:"text",content:E,createdAt:y}),g=""},T="<think>",C="</think>",S=E=>{let j=0,M=!1;for(;j<E.length;)if(M){const O=E.indexOf(C,j);O===-1?j=E.length:(M=!1,j=O+C.length)}else{const O=E.indexOf(T,j);O===-1?(g+=E.slice(j),j=E.length):(g+=E.slice(j,O),M=!0,j=O+T.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_${i}`,sourceType:"chat",sourceId:"",agentId:l,seq:i++,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_${i}`,sourceType:"chat",sourceId:"",agentId:l,seq:i++,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(Zg(E.content).cleaned);return w(),r}const wQ=k.memo(function({msg:t,isStreaming:n,liveActivities:r,onMentionClick:i,knownNames:l}){const{t:c}=gt(["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,M)=>j+(M.type==="tool"?M.subagentLogs?.length??0:0),0):0,y=k.useMemo(()=>d&&d.length>0?I4(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):"",T=x?x.reduce((j,M)=>j+(M.type==="tool"?M.subagentLogs?.length??0:0),0):0,C=k.useMemo(()=>n?y:x&&x.length>0?I4(x,t.agentId,t.rawCreatedAt):y,[n,w,T,t.agentId,t.rawCreatedAt,y]);if(d!==void 0&&d.length>0){const j=d.some(B=>B.type==="tool"),M=d.filter(B=>B.type==="text"),O=n?null:M.map(B=>B.content).join(""),D=B=>B.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,q=(O?D(O):null)||(!n&&t.text?D(t.text):null),Q=[];for(const B of d){if(B.type!=="tool")continue;const J=a6(B.tool,B.result);if(J){Q.push({key:`task-${J.taskId}`,kind:"task",info:J});continue}const W=s6(B.tool,B.result);W&&Q.push({key:`req-${W.requirementId}`,kind:"req",info:W})}return s.jsxs("div",{className:"space-y-2 min-h-[1em] min-w-0 overflow-x-hidden",children:[j||n?s.jsx(sY,{entries:C,isActive:n,embedded:!0,hideApprovalCards:!0}):q&&s.jsx(Br,{content:q,onMentionClick:i,knownNames:l}),Q.map(B=>B.kind==="task"?s.jsx(c6,{info:B.info},B.key):s.jsx(u6,{info:B.info},B.key)),!n&&!q&&!j&&Q.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(B=>B.type==="text"&&B.content&&(B.content===t.text||B.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(HW,{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(Br,{content:E,onMentionClick:i,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 pY(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 hY({approval:e,submitting:t,readOnly:n,onClose:r,onSubmit:i}){const{t:l}=gt(["team","common"]);Vo(!0);const c=k.useMemo(()=>pY(e),[e]),[d,m]=k.useState(0),[f,h]=k.useState(()=>{if(n&&e.answers&&e.answers.length>0){const O={};for(const D of e.answers)O[D.questionId]={selectedOptionIds:D.selectedOptionIds??[],text:D.text??""};return O}return{}}),g=c[d],y=d===c.length-1,x=c.length>1,w=O=>f[O]??{selectedOptionIds:[],text:""},T=(O,D)=>{h(H=>({...H,[O]:{...w(O),...D}}))},C=(O,D)=>{const H=w(O.id);if(O.allowMultiple){const q=H.selectedOptionIds.includes(D);T(O.id,{selectedOptionIds:q?H.selectedOptionIds.filter(Q=>Q!==D):[...H.selectedOptionIds,D],text:q?H.text:""})}else{const q=H.selectedOptionIds.includes(D);T(O.id,{selectedOptionIds:q?[]:[D],text:q?H.text:""})}},S=O=>{const D=w(O.id);return O.inputType==="choice"?D.selectedOptionIds.length>0?!0:!!(O.allowFreeform&&D.text.trim()):D.text.trim().length>0},E=c.every(S),j=()=>c.map(O=>{const D=w(O.id),H={questionId:O.id};return D.selectedOptionIds.length>0&&(H.selectedOptionIds=D.selectedOptionIds),D.text.trim()&&(H.text=D.text.trim()),H}),M=()=>{const O=j();let D=!0,H;if(!e.questions?.length&&e.options?.length){const Q=O[0];H=Q?.selectedOptionIds?.[0]??(Q?.text?"custom":void 0),D=H!=="reject"&&H!=="request_changes"}const q=O.map(Q=>Q.text).filter(Boolean).join(`
663
- `)||void 0;i({approved:D,comment:q,selectedOption:H,answers:O})};return Da.createPortal(s.jsx("div",{className:"fixed inset-0 z-[10000] flex items-center justify-center p-4 bg-black/50 backdrop-blur-sm",onMouseDown:O=>{O.target===O.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((O,D)=>s.jsx("button",{onClick:()=>m(D),className:`h-1.5 flex-1 rounded-full transition-colors ${D===d?"bg-brand-500":S(O)?"bg-green-500/60":"bg-border-default"}`,title:`${D+1}. ${O.prompt.slice(0,40)}`},O.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(Br,{content:g.prompt})}),g.inputType==="choice"&&g.options&&s.jsx("div",{className:"space-y-2",children:g.options.map((O,D)=>{const H=w(g.id).selectedOptionIds.includes(O.id);return s.jsxs("button",{onClick:n?void 0:()=>C(g,O.id),disabled:n,className:`w-full px-4 py-3 text-left rounded-xl border transition-colors flex items-start gap-3 ${H?"border-brand-500 bg-brand-500/10":`border-border-default ${n?"":"hover:bg-surface-overlay"}`} ${n?"cursor-default":""} ${n&&!H?"opacity-50":""}`,children:[s.jsx("span",{className:`w-6 h-6 rounded-full flex items-center justify-center text-[11px] font-bold shrink-0 mt-0.5 ${H?"bg-brand-600 text-white":"bg-surface-overlay text-fg-tertiary"}`,children:H?s.jsx("svg",{width:"13",height:"13",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"3",strokeLinecap:"round",strokeLinejoin:"round",children:s.jsx("path",{d:"M20 6L9 17l-5-5"})}):String.fromCharCode(65+D)}),s.jsxs("span",{className:"flex-1 min-w-0 text-sm text-fg-primary [&_p]:my-0 [&_p]:text-sm",children:[s.jsx(Br,{content:O.label}),O.description&&s.jsx("span",{className:"block text-xs text-fg-tertiary mt-1 [&_p]:my-0 [&_p]:text-xs",children:s.jsx(Br,{content:O.description})})]})]},O.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:O=>{const D=O.target.value;T(g.id,{text:D,selectedOptionIds:D.trim()&&g.inputType==="choice"?[]:w(g.id).selectedOptionIds})},className:`w-full px-3.5 py-2.5 text-sm bg-surface-overlay border border-border-default rounded-xl text-fg-primary placeholder:text-fg-tertiary focus:outline-none resize-y ${n?"cursor-default opacity-80":"focus:ring-1 focus:ring-brand-500/50"}`})]}),s.jsxs("div",{className:"flex items-center justify-between gap-2 px-6 py-4 border-t border-border-default shrink-0",children:[s.jsx("div",{children:x&&d>0&&s.jsx("button",{onClick:()=>m(O=>Math.max(0,O-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(O=>Math.min(c.length-1,O+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:M,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"},Mo={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"},P4={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 Ro(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 i=Math.floor(r/60);return i<24?t("common:time.hoursAgo",{count:i}):t("common:time.daysAgo",{count:Math.floor(i/24)})}const B4="markus:template-updates-ack";let th=!1,_d=null;function gY(e){return e.map(t=>`${t.name}@${t.availableVersion}`).sort().join(",")}function z4(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 bY({collapsed:e,userId:t,embeddedMode:n,onClose:r,sidebarMode:i,isActive:l,label:c,iconPath:d}){const{t:m}=gt(["team","common"]),[f,h]=k.useState(!1),[g,y]=k.useState("approvals"),[x,w]=k.useState([]),[T,C]=k.useState([]),[S,E]=k.useState(null),[j,M]=k.useState(null),[O,D]=k.useState(null),[H,q]=k.useState({}),[Q,B]=k.useState(0),J=k.useRef(null),W=k.useRef(null),[re,F]=k.useState({top:0,left:0,width:448,maxHeight:576}),te=k.useRef(null),L=k.useRef(!1),[ee,ue]=k.useState(!0),[Se,$]=k.useState(!1),G=k.useRef(null),me=k.useRef("approvals"),[P,_e]=k.useState(!1),He=30,Pe=k.useCallback(async()=>{try{as("/approvals"),as("/notifications");const[Y,ye]=await Promise.all([Ee.notifications.list(t,!1,{limit:He,offset:0}),Ee.approvals.list()]);w(Y.notifications);const Ye=Y.unreadCount??Y.notifications.filter(xe=>!xe.read).length;if(B(Ye),ue(Y.totalCount!=null?Y.notifications.length<Y.totalCount:Y.notifications.length>=He),C(ye.approvals),!L.current){const xe=ye.approvals.filter(nt=>nt.status==="pending").length;te.current=xe,L.current=!0}}catch{}},[t]),Ge=k.useCallback(async()=>{if(!(Se||!ee)){$(!0);try{const Y=await Ee.notifications.list(t,!1,{limit:He,offset:x.length});Y.notifications.length>0&&w(ye=>[...ye,...Y.notifications.filter(Ye=>!ye.some(xe=>xe.id===Ye.id))]),ue(Y.totalCount!=null?x.length+Y.notifications.length<Y.totalCount:Y.notifications.length>=He)}catch{}$(!1)}},[t,x.length,Se,ee]),ut=k.useCallback(Y=>{const ye=Y.detail;if(!ye)return;const{taskId:Ye,requirementId:xe}=ye;!Ye&&!xe||w(nt=>{const at=nt.filter(V=>!V.read&&(Ye&&V.metadata?.taskId===Ye||xe&&V.metadata?.requirementId===xe));if(at.length===0)return nt;for(const V of at)Ee.notifications.markRead(V.id).catch(()=>{});return B(V=>Math.max(0,V-at.length)),nt.map(V=>at.some(he=>he.id===V.id)?{...V,read:!0}:V)})},[]),pt=k.useRef(x);pt.current=x;const ht=k.useCallback(async()=>{if(!pt.current.some(ye=>!ye.read&&ye.type==="system"&&ye.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:Y}=await Ee.skills.updates();if(!Y.length)return;const ye=gY(Y);try{if(localStorage.getItem(B4)===ye)return}catch{}if(_d===ye||pt.current.some(xe=>!xe.read&&z4(xe,ye)))return;try{const nt=(await Ee.notifications.list(t,!0,{limit:50,type:"system"})).notifications.filter(at=>z4(at,ye)).sort((at,V)=>new Date(V.createdAt).getTime()-new Date(at.createdAt).getTime());if(nt.length>0){for(const at of nt.slice(1))Ee.notifications.markRead(at.id).catch(()=>{});nt.length>1&&Pe(),_d=ye;return}}catch{}_d=ye,await Ee.notifications.create({title:m("templateUpdates.notificationTitle",{ns:"common"}),body:m("templateUpdates.notificationBody",{ns:"common",count:Y.length}),type:"system",priority:"high",metadata:{templateUpdates:!0,templateUpdatesFingerprint:ye,count:Y.length,skills:Y.map(xe=>xe.name)}}),Pe(),nh()}catch{_d=null}finally{th=!1}}},[Pe,m,t]);k.useEffect(()=>{Pe();const Y=setInterval(Pe,6e4);let ye=null;const Ye=()=>{ye||(ye=setTimeout(()=>{ye=null,Pe()},400))},xe=()=>Ye(),nt=()=>{h(!0),Pe()};window.addEventListener("markus:notifications-changed",xe),window.addEventListener("markus:mark-read-by-ref",ut),window.addEventListener("markus:open-notifications",nt),window.addEventListener("markus:credit-exhausted",ht);const at=ja.on("notification",Ye),V=ja.on("approval:requested",Ye);return()=>{clearInterval(Y),ye&&clearTimeout(ye),window.removeEventListener("markus:notifications-changed",xe),window.removeEventListener("markus:mark-read-by-ref",ut),window.removeEventListener("markus:open-notifications",nt),window.removeEventListener("markus:credit-exhausted",ht),at(),V()}},[Pe,ut,ht]),k.useEffect(()=>{Mt();const Y=setInterval(()=>{Mt()},5*6e4),ye=()=>{Mt()};return window.addEventListener("markus:data-changed",ye),()=>{clearInterval(Y),window.removeEventListener("markus:data-changed",ye)}},[t]);const Bt=k.useCallback(()=>{if(!J.current)return;const Y=J.current.getBoundingClientRect(),ye=window.innerWidth,Ye=window.innerHeight,xe=Math.min(448,ye-16),nt=Math.min(576,Ye-16);let at=Y.right+8,V=Y.top;at+xe>ye-8&&(at=Math.max(8,ye-xe-8)),V+nt>Ye-8&&(V=Math.max(8,Ye-nt-8)),F({top:V,left:at,width:xe,maxHeight:nt})},[]);k.useLayoutEffect(()=>{f&&Bt()},[f,Bt]),k.useEffect(()=>{if(f)return window.addEventListener("resize",Bt),()=>window.removeEventListener("resize",Bt)},[f,Bt]),k.useEffect(()=>{if(!f)return;const Y=ye=>{J.current?.contains(ye.target)||W.current?.contains(ye.target)||h(!1)};return document.addEventListener("mousedown",Y),()=>document.removeEventListener("mousedown",Y)},[f]),k.useEffect(()=>{if(!f)return;const Y=T.some(Ye=>Ye.status==="pending"),ye=x.some(Ye=>!Ye.read);y(Y&&!ye?"approvals":!Y&&ye?"notifications":me.current)},[f]);const Qt=new Set(T.filter(Y=>Y.status==="pending").map(Y=>Y.id)),wt=new Set(T.map(Y=>Y.id)),Ue=x.filter(Y=>!(Y.type==="approval_request"&&Y.metadata?.approvalId&&wt.has(Y.metadata.approvalId))),ft=x.filter(Y=>Y.type==="approval_request"&&!Y.read&&Y.metadata?.approvalId&&Qt.has(Y.metadata.approvalId)).length,kt=Math.max(0,Q-ft),Nt=Qt.size,zt=kt+Nt;k.useEffect(()=>{te.current!==null&&Nt>te.current&&nh(),te.current=Nt},[Nt]);const ce=async Y=>{await Ee.notifications.markRead(Y),w(ye=>ye.map(Ye=>Ye.id===Y?{...Ye,read:!0}:Ye)),B(ye=>Math.max(0,ye-1)),window.dispatchEvent(new CustomEvent("markus:notifications-changed"))},tt=Y=>{const ye=Y.metadata??{},Ye=Y.actionType,xe=Y.actionTarget;if(Ye==="open_chat"&&xe)try{const nt=typeof xe=="string"?JSON.parse(xe):xe;if(nt.agentId){const at={agentId:nt.agentId};nt.sessionId&&(at.sessionId=nt.sessionId),it.navigate(le.TEAM,at);return}}catch{}if(Ye==="navigate"&&xe)try{const nt=typeof xe=="string"?JSON.parse(xe):xe;if(nt.path){if(nt.path.startsWith("/team")){const at={},V=new URLSearchParams(nt.path.split("?")[1]||"");for(const[he,Ie]of V.entries())at[he]=Ie;it.navigate(le.TEAM,at);return}if(nt.path.startsWith("/work")){const at={},V=new URLSearchParams(nt.path.split("?")[1]||"");for(const[he,Ie]of V.entries())at[he]=Ie;it.navigate(le.WORK,at);return}}}catch{}switch(Y.type){case"approval_request":{const nt=ye.approvalId,at=nt?T.find(Je=>Je.id===nt):void 0;if(at&&Ad(at)){M(at);break}const V=at?.details?.taskId??ye.taskId,he=at?.details?.requirementId??ye.requirementId,Ie=at?.details?.agentId??at?.agentId;V?it.navigate(le.WORK,{openTask:V}):he?it.navigate(le.WORK,{openRequirement:he}):Ie?it.navigate(le.TEAM,{agentId:Ie}):it.navigate(le.WORK);break}case"task_completed":case"task_created":case"task_review":case"task_failed":ye.taskId?it.navigate(le.WORK,{openTask:ye.taskId}):it.navigate(le.WORK);break;case"requirement_created":case"requirement_decision":ye.requirementId?it.navigate(le.WORK,{openRequirement:ye.requirementId}):it.navigate(le.WORK);break;case"agent_report":case"system":{if(ye.creditExhausted){_e(!0);return}if(ye.templateUpdates){const nt=ye.templateUpdatesFingerprint;if(nt)try{localStorage.setItem(B4,nt)}catch{}localStorage.setItem("markus_nav_storeTab","installed"),it.navigate(le.STORE);return}if(ye.agentId){const nt={agentId:ye.agentId};ye.sessionId&&(nt.sessionId=ye.sessionId),it.navigate(le.TEAM,nt)}else it.navigate(le.TEAM);break}case"direct_message":{const nt=ye.senderId;nt?it.navigate(le.TEAM,{dm:nt}):it.navigate(le.TEAM);break}case"group_message":{const nt=ye.channel;nt?it.navigate(le.TEAM,{channel:nt}):it.navigate(le.TEAM);break}default:ye.taskId?it.navigate(le.WORK,{openTask:ye.taskId}):ye.requirementId?it.navigate(le.WORK,{openRequirement:ye.requirementId}):ye.projectId?it.navigate(le.WORK,{projectId:ye.projectId}):ye.agentId&&it.navigate(le.TEAM,{agentId:ye.agentId});break}},rt=async Y=>{const ye=Y.metadata??{},Ye=Y.actionType,xe=Y.type==="agent_report"&&!ye.creditExhausted&&!ye.templateUpdates&&(Ye==="open_chat"||!!ye.agentId&&Ye!=="navigate");!Y.read&&!xe&&ce(Y.id);const nt=ye.taskId,at=ye.requirementId;if(!xe&&(nt||at)){const V=x.filter(he=>he.id!==Y.id&&!he.read&&(nt&&he.metadata?.taskId===nt||at&&he.metadata?.requirementId===at));for(const he of V)ce(he.id)}tt(Y)},be=async(Y,ye,Ye,xe,nt)=>{E(Y);try{const{approval:at}=await Ee.approvals.respond(Y,ye,t,Ye,xe,nt);C(Je=>Je.map(dt=>dt.id===Y?at:dt)),M(null),D(null),q(Je=>{const dt={...Je};return delete dt[Y],dt});const V=at.details?.taskId,he=at.details?.requirementId,Ie=x.filter(Je=>!Je.read&&(Je.type==="approval_request"&&Je.metadata?.approvalId===Y||V&&Je.metadata?.taskId===V||he&&Je.metadata?.requirementId===he));if(Ie.length>0){for(const dt of Ie)Ee.notifications.markRead(dt.id).catch(()=>{});const Je=new Set(Ie.map(dt=>dt.id));w(dt=>dt.map(_t=>Je.has(_t.id)?{..._t,read:!0}:_t)),B(dt=>Math.max(0,dt-Ie.length))}as("/approvals"),as("/notifications"),as("/tasks"),as("/taskboard"),as("/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(Y=>Y.map(ye=>({...ye,read:!0}))),B(0),as("/notifications"),window.dispatchEvent(new CustomEvent("markus:notifications-changed"))}catch{const Y=Ue.filter(ye=>!ye.read);await Promise.all(Y.map(ye=>Ee.notifications.markRead(ye.id))),w(ye=>ye.map(Ye=>({...Ye,read:!0}))),B(0),as("/notifications"),window.dispatchEvent(new CustomEvent("markus:notifications-changed"))}},Ae=Y=>{const ye=Y.details?.subType;return ye==="requirement_resubmit"?m("team:notifications.approvalType.requirementResubmit"):ye==="requirement"||Y.details?.requirementId?m("team:notifications.approvalType.requirement"):ye==="task_review"?m("team:notifications.approvalType.taskReview"):ye==="task"||Y.details?.taskId?m("team:notifications.approvalType.task"):Y.details?.toolName?m("team:notifications.approvalType.toolExecution"):null},oe=Y=>{const ye=[];ye.push(Y.agentName);const Ye=Y.details?.taskTitle,xe=Y.details?.taskId;Ye?ye.push(Ye):xe&&ye.push(`Task ${xe.slice(0,8)}`);const nt=Y.details?.requirementId;return nt&&!xe&&ye.push(`Req ${nt.slice(0,8)}`),ye.join(" · ")},U=[...T].sort((Y,ye)=>new Date(ye.requestedAt).getTime()-new Date(Y.requestedAt).getTime()),ae=U.filter(Y=>Y.status==="pending"),Ce=U.filter(Y=>Y.status!=="pending"),Re=Y=>{const ye=Y.details?.taskId,Ye=Y.details?.requirementId,xe=Y.details?.agentId??Y.agentId;ye?it.navigate(le.WORK,{openTask:ye}):Ye?it.navigate(le.WORK,{openRequirement:Ye}):xe?it.navigate(le.TEAM,{agentId:xe}):it.navigate(le.WORK)},ze=()=>{h(!1),r?.()},X=Y=>s.jsxs("button",{disabled:S===Y.id,onClick:()=>M(Y),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"}),Y.questions&&Y.questions.length>1?` (${Y.questions.length})`:""]}),Z=j?s.jsx(hY,{approval:j,submitting:S===j.id,readOnly:j.status!=="pending",onClose:()=>M(null),onSubmit:Y=>be(j.id,Y.approved,Y.comment,Y.selectedOption,Y.answers)}):null,pe=s.jsxs(s.Fragment,{children:[s.jsxs("div",{className:"flex border-b border-border-default shrink-0",children:[s.jsxs("button",{onClick:()=>{y("approvals"),me.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"),Nt>0?` (${Nt})`:""]}),s.jsxs("button",{onClick:()=>{y("notifications"),me.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"),kt>0?` (${kt})`:""]}),s.jsx("button",{onClick:ze,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"&&Q>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:G,className:"flex-1 overflow-y-auto",onScroll:Y=>{if(g!=="notifications"||!ee||Se)return;const ye=Y.currentTarget;ye.scrollTop+ye.clientHeight>=ye.scrollHeight-80&&Ge()},children:[g==="approvals"&&(T.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:[ae.map(Y=>{const ye=Y.details?.command,Ye=ye?Y.description.replace(/\s*Command:.*$/,""):Y.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(Y),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:Mo.approval_request})}),s.jsxs("div",{className:"flex-1 min-w-0",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[Ae(Y)&&s.jsx("span",{className:"text-[10px] text-amber-500 font-medium shrink-0",children:Ae(Y)}),s.jsx("span",{className:"text-xs text-fg-primary font-medium truncate",children:Y.title}),s.jsx("span",{className:"text-[10px] text-fg-tertiary shrink-0",children:Ro(Y.requestedAt,m)})]}),s.jsx("div",{className:"text-[11px] text-fg-tertiary mt-0.5",children:Y.agentName})]})]}),s.jsx("div",{className:"mt-2.5 text-[11px] text-fg-secondary leading-relaxed",children:s.jsx(Br,{content:Ye,className:"text-[11px] [&_h1]:text-xs [&_h2]:text-[11px] [&_h3]:text-[11px] [&_p]:text-[11px] [&_li]:text-[11px]"})}),ye&&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:ye})]}),(()=>{if(Ad(Y))return X(Y);const xe=Y.details?.subType,nt=xe==="task"||xe==="requirement"||xe==="requirement_resubmit",at=Y.options&&Y.options.length>0,V=(H[Y.id]??"").trim();return at?s.jsxs("div",{className:"space-y-1.5",children:[Y.options.map((he,Ie)=>s.jsxs("button",{disabled:S===Y.id,onClick:()=>be(Y.id,he.id!=="reject",V||void 0,he.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 ${he.id==="reject"||he.id==="request_changes"?"border border-border-default text-fg-secondary hover:bg-surface-overlay":"bg-brand-600 text-white hover:bg-brand-700"}`,title:he.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+Ie)}),he.label]},he.id)),s.jsxs("div",{className:"flex gap-1.5 mt-1",children:[s.jsx("input",{type:"text",placeholder:m("team:notifications.freeformPlaceholder"),value:H[Y.id]??"",onChange:he=>q(Ie=>({...Ie,[Y.id]:he.target.value})),onKeyDown:he=>{he.key==="Enter"&&(H[Y.id]??"").trim()&&be(Y.id,!0,(H[Y.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===Y.id||!(H[Y.id]??"").trim(),onClick:()=>be(Y.id,!0,(H[Y.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")})]})]}):nt?s.jsxs("div",{className:"space-y-1.5",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsxs("button",{disabled:S===Y.id,onClick:()=>be(Y.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===Y.id,onClick:()=>be(Y.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")]}),O!==Y.id&&s.jsxs("button",{disabled:S===Y.id,onClick:()=>D(Y.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")]})]}),O===Y.id&&s.jsxs("div",{className:"space-y-1.5",children:[s.jsx("input",{type:"text",autoFocus:!0,placeholder:m("team:notifications.adjustmentPlaceholder"),value:H[Y.id]??"",onChange:he=>q(Ie=>({...Ie,[Y.id]:he.target.value})),onKeyDown:he=>{he.key==="Enter"&&(H[Y.id]??"").trim()&&be(Y.id,!1,(H[Y.id]??"").trim(),"needs_adjustment"),he.key==="Escape"&&D(null)},className:"w-full px-2.5 py-1.5 text-[11px] bg-surface-overlay border border-border-default rounded-md text-fg-primary placeholder:text-fg-tertiary focus:outline-none focus:ring-1 focus:ring-amber-500/50"}),s.jsxs("div",{className:"flex gap-2",children:[s.jsx("button",{disabled:S===Y.id||!(H[Y.id]??"").trim(),onClick:()=>be(Y.id,!1,(H[Y.id]??"").trim(),"needs_adjustment"),className:"px-2.5 py-1.5 text-[11px] font-medium bg-amber-600 text-white rounded-md hover:bg-amber-700 disabled:opacity-50 transition-colors",children:m("team:notifications.confirmAdjustment")}),s.jsx("button",{onClick:()=>D(null),className:"px-2.5 py-1.5 text-[11px] font-medium border border-border-default text-fg-secondary rounded-md hover:bg-surface-overlay transition-colors",children:m("common:cancel")})]})]})]}):s.jsxs("div",{className:"space-y-1.5",children:[s.jsx("input",{type:"text",placeholder:m("team:notifications.commentPlaceholder"),value:H[Y.id]??"",onChange:he=>q(Ie=>({...Ie,[Y.id]:he.target.value})),onKeyDown:he=>{he.key==="Enter"&&be(Y.id,!0,V||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===Y.id,onClick:()=>be(Y.id,!0,V||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===Y.id,onClick:()=>be(Y.id,!1,V||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")})]})]})})()]},Y.id)}),Ce.length>0&&s.jsxs(s.Fragment,{children:[ae.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")}),Ce.slice(0,50).map(Y=>s.jsxs("button",{onClick:()=>Ad(Y)?M(Y):Re(Y),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 ${Y.status==="approved"?"bg-green-500":Y.status==="cancelled"||Y.status==="expired"?"bg-gray-400":"bg-red-500"}`}),Ae(Y)&&s.jsx("span",{className:"text-[10px] text-fg-tertiary font-medium shrink-0",children:Ae(Y)}),s.jsx("span",{className:"text-xs text-fg-secondary truncate flex-1 group-hover:text-fg-primary",children:Y.title}),s.jsx("span",{className:`text-[10px] font-medium shrink-0 ${Y.status==="approved"?"text-green-500":Y.status==="cancelled"||Y.status==="expired"?"text-fg-muted":"text-red-500"}`,children:m(`common:status.${Y.status}`,{defaultValue:Y.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(Y)}),s.jsx("span",{className:"text-[10px] text-fg-muted shrink-0",children:"·"}),s.jsx("span",{className:"text-[10px] text-fg-muted shrink-0",children:Ro(Y.respondedAt??Y.requestedAt,m)})]}),Y.responseComment&&s.jsxs("p",{className:"text-[10px] text-fg-muted mt-0.5 pl-3.5 truncate",children:["“",Y.responseComment,"”"]})]},Y.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(Y=>{const ye=P4[Y.type]??"text-fg-tertiary";return s.jsxs("div",{role:"button",tabIndex:0,onClick:()=>rt(Y),onKeyDown:Ye=>{(Ye.key==="Enter"||Ye.key===" ")&&(Ye.preventDefault(),rt(Y))},className:`w-full text-left px-3 py-2.5 flex gap-2.5 transition-colors cursor-pointer ${Y.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:ye,children:s.jsx("path",{d:Mo[Y.type]??Mo.system})})}),s.jsxs("div",{className:"flex-1 min-w-0",children:[s.jsxs("div",{className:"flex items-center gap-1.5",children:[!Y.read&&s.jsx("span",{className:`w-1.5 h-1.5 rounded-full shrink-0 ${Ed[Y.priority]??Ed.normal}`}),s.jsx("span",{className:"text-xs text-fg-primary font-medium truncate",children:Y.title})]}),s.jsx("div",{className:"text-[11px] text-fg-tertiary mt-0.5 ",children:s.jsx(Br,{content:Y.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:Ro(Y.createdAt,m)}),jd(Y,m)&&s.jsx("span",{className:`text-[10px] font-medium ${ye}`,children:jd(Y,m)})]})]})]},Y.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"})]})})]}))]})]}),Fe=k.useCallback(Y=>{Y?.mute&&fY()},[]),Oe=k.useCallback(Y=>{Fe(Y),_e(!1)},[Fe]),$e=P?s.jsx(wr,{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:Y=>{Oe(Y),it.navigate(le.SETTINGS),setTimeout(()=>{window.location.hash="settings/providers"},50)},onConfirm:Y=>{const ye=`${lt.getUrl().replace(/\/$/,"")}/settings?tab=billing`;Oe(Y),Xs(ye)}}):null;if(n){const Y=["approvals","notifications"],ye=Y.indexOf(g),Ye=(()=>{let xe=0,nt=0;return{onTouchStart:at=>{xe=at.touches[0].clientX,nt=at.touches[0].clientY},onTouchEnd:at=>{const V=at.changedTouches[0].clientX-xe,he=at.changedTouches[0].clientY-nt;Math.abs(V)>60&&Math.abs(V)>Math.abs(he)*1.5&&(V<0&&ye<Y.length-1&&y(Y[ye+1]),V>0&&ye>0&&y(Y[ye-1]))}}})();return s.jsxs(s.Fragment,{children:[$e,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:Y.map(xe=>s.jsx("button",{onClick:()=>y(xe),className:`flex-1 px-3 py-3 text-sm font-medium transition-colors ${g===xe?"text-fg-primary border-b-2 border-brand-500":"text-fg-tertiary"}`,children:xe==="approvals"?s.jsxs(s.Fragment,{children:[m("team:notifications.approvals"),Nt>0?` (${Nt})`:""]}):s.jsxs(s.Fragment,{children:[m("team:notifications.notifications"),kt>0?` (${kt})`:""]})},xe))}),g==="notifications"&&Q>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",...Ye,children:s.jsxs("div",{className:"flex h-full transition-transform duration-300 ease-out",style:{transform:`translateX(-${ye*100}%)`},children:[s.jsx("div",{className:"w-full shrink-0 h-full overflow-y-auto scrollbar-thin",children:T.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:[ae.map(xe=>{const nt=xe.details?.command,at=nt?xe.description.replace(/\s*Command:.*$/,""):xe.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(xe),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:Mo.approval_request})}),s.jsxs("div",{className:"flex-1 min-w-0",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[Ae(xe)&&s.jsx("span",{className:"text-[10px] text-amber-500 font-medium shrink-0",children:Ae(xe)}),s.jsx("span",{className:"text-xs text-fg-primary font-medium truncate",children:xe.title}),s.jsx("span",{className:"text-[10px] text-fg-tertiary shrink-0",children:Ro(xe.requestedAt,m)})]}),s.jsx("div",{className:"text-[11px] text-fg-tertiary mt-0.5",children:xe.agentName})]})]}),s.jsx("div",{className:"mt-2.5 text-[11px] text-fg-secondary leading-relaxed",children:s.jsx(Br,{content:at,className:"text-[11px] [&_h1]:text-xs [&_h2]:text-[11px] [&_h3]:text-[11px] [&_p]:text-[11px] [&_li]:text-[11px]"})}),nt&&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:nt})]}),(()=>{if(Ad(xe))return X(xe);const V=xe.details?.subType,he=V==="task"||V==="requirement"||V==="requirement_resubmit",Ie=xe.options&&xe.options.length>0,Je=(H[xe.id]??"").trim();return Ie?s.jsxs("div",{className:"space-y-1.5",children:[xe.options.map((dt,_t)=>s.jsxs("button",{disabled:S===xe.id,onClick:()=>be(xe.id,dt.id!=="reject",Je||void 0,dt.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 ${dt.id==="reject"||dt.id==="request_changes"?"border border-border-default text-fg-secondary hover:bg-surface-overlay":"bg-brand-600 text-white hover:bg-brand-700"}`,title:dt.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+_t)}),dt.label]},dt.id)),s.jsxs("div",{className:"flex gap-1.5 mt-1",children:[s.jsx("input",{type:"text",placeholder:m("team:notifications.freeformPlaceholder"),value:H[xe.id]??"",onChange:dt=>q(_t=>({..._t,[xe.id]:dt.target.value})),onKeyDown:dt=>{dt.key==="Enter"&&(H[xe.id]??"").trim()&&be(xe.id,!0,(H[xe.id]??"").trim(),"custom")},className:"flex-1 px-2.5 py-1.5 text-[11px] bg-surface-overlay border border-border-default rounded-md text-fg-primary placeholder:text-fg-tertiary focus:outline-none focus:ring-1 focus:ring-brand-500/50"}),s.jsx("button",{disabled:S===xe.id||!(H[xe.id]??"").trim(),onClick:()=>be(xe.id,!0,(H[xe.id]??"").trim(),"custom"),className:"px-2.5 py-1.5 text-[11px] font-medium bg-brand-600 text-white rounded-md hover:bg-brand-700 disabled:opacity-50 transition-colors",children:m("common:send")})]})]}):he?s.jsxs("div",{className:"space-y-1.5",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsxs("button",{disabled:S===xe.id,onClick:()=>be(xe.id,!0,void 0,"approve"),className:"px-3 py-1.5 text-[11px] font-medium bg-green-600 text-white rounded-md hover:bg-green-700 disabled:opacity-50 transition-colors inline-flex items-center gap-1.5",children:[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===xe.id,onClick:()=>be(xe.id,!1,void 0,"reject"),className:"px-3 py-1.5 text-[11px] font-medium bg-red-600/80 text-white rounded-md hover:bg-red-700 disabled:opacity-50 transition-colors inline-flex items-center gap-1.5",children:[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")]}),O!==xe.id&&s.jsxs("button",{disabled:S===xe.id,onClick:()=>D(xe.id),className:"px-3 py-1.5 text-[11px] font-medium border border-amber-500/50 text-amber-500 rounded-md hover:bg-amber-500/10 disabled:opacity-50 transition-colors inline-flex items-center gap-1.5",children:[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")]})]}),O===xe.id&&s.jsxs("div",{className:"space-y-1.5",children:[s.jsx("input",{type:"text",autoFocus:!0,placeholder:m("team:notifications.adjustmentPlaceholder"),value:H[xe.id]??"",onChange:dt=>q(_t=>({..._t,[xe.id]:dt.target.value})),onKeyDown:dt=>{dt.key==="Enter"&&(H[xe.id]??"").trim()&&be(xe.id,!1,(H[xe.id]??"").trim(),"needs_adjustment"),dt.key==="Escape"&&D(null)},className:"w-full px-2.5 py-1.5 text-[11px] bg-surface-overlay border border-border-default rounded-md text-fg-primary placeholder:text-fg-tertiary focus:outline-none focus:ring-1 focus:ring-amber-500/50"}),s.jsxs("div",{className:"flex gap-2",children:[s.jsx("button",{disabled:S===xe.id||!(H[xe.id]??"").trim(),onClick:()=>be(xe.id,!1,(H[xe.id]??"").trim(),"needs_adjustment"),className:"px-2.5 py-1.5 text-[11px] font-medium bg-amber-600 text-white rounded-md hover:bg-amber-700 disabled:opacity-50 transition-colors",children:m("team:notifications.confirmAdjustment")}),s.jsx("button",{onClick:()=>D(null),className:"px-2.5 py-1.5 text-[11px] font-medium border border-border-default text-fg-secondary rounded-md hover:bg-surface-overlay transition-colors",children:m("common:cancel")})]})]})]}):s.jsxs("div",{className:"space-y-1.5",children:[s.jsx("input",{type:"text",placeholder:m("team:notifications.commentPlaceholder"),value:H[xe.id]??"",onChange:dt=>q(_t=>({..._t,[xe.id]:dt.target.value})),onKeyDown:dt=>{dt.key==="Enter"&&be(xe.id,!0,Je||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===xe.id,onClick:()=>be(xe.id,!0,Je||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===xe.id,onClick:()=>be(xe.id,!1,Je||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")})]})]})})()]},xe.id)}),Ce.length>0&&s.jsxs(s.Fragment,{children:[ae.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")}),Ce.slice(0,50).map(xe=>s.jsxs("button",{onClick:()=>Re(xe),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 ${xe.status==="approved"?"bg-green-500":xe.status==="cancelled"||xe.status==="expired"?"bg-gray-400":"bg-red-500"}`}),s.jsx("span",{className:"text-xs text-fg-secondary truncate flex-1",children:xe.title}),s.jsx("span",{className:`text-[10px] font-medium shrink-0 ${xe.status==="approved"?"text-green-500":xe.status==="cancelled"||xe.status==="expired"?"text-fg-muted":"text-red-500"}`,children:m(`common:status.${xe.status}`,{defaultValue:xe.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(xe)}),s.jsx("span",{className:"text-[10px] text-fg-muted shrink-0",children:"·"}),s.jsx("span",{className:"text-[10px] text-fg-muted shrink-0",children:Ro(xe.respondedAt??xe.requestedAt,m)})]})]},xe.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(xe=>{const nt=P4[xe.type]??"text-fg-tertiary";return s.jsxs("button",{onClick:()=>rt(xe),className:`w-full text-left px-3 py-2.5 flex gap-2.5 transition-colors ${xe.read?"opacity-50 hover:opacity-70":"hover:bg-surface-overlay"}`,children:[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:nt,children:s.jsx("path",{d:Mo[xe.type]??Mo.system})})}),s.jsxs("div",{className:"flex-1 min-w-0",children:[s.jsxs("div",{className:"flex items-center gap-1.5",children:[!xe.read&&s.jsx("span",{className:`w-1.5 h-1.5 rounded-full shrink-0 ${Ed[xe.priority]??Ed.normal}`}),s.jsx("span",{className:"text-xs text-fg-primary font-medium truncate",children:xe.title})]}),s.jsx("div",{className:"text-[11px] text-fg-tertiary mt-0.5 ",children:s.jsx(Br,{content:xe.body,className:"text-[11px] [&_h1]:text-xs [&_h2]:text-[11px] [&_h3]:text-[11px] [&_p]:text-[11px] [&_li]:text-[11px] [&_p]:text-fg-tertiary"})}),s.jsxs("div",{className:"flex items-center gap-2 mt-0.5",children:[s.jsx("span",{className:"text-[10px] text-fg-muted",children:Ro(xe.createdAt,m)}),jd(xe,m)&&s.jsx("span",{className:`text-[10px] font-medium ${nt}`,children:jd(xe,m)})]})]})]},xe.id)})})})]})})]})]})}if(i){const Y=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:J,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:Y})}),e?s.jsx("span",{className:"text-[9px] leading-tight truncate w-full text-center",children:c}):s.jsx("span",{className:"truncate",children:c}),zt>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:zt>99?m("common:badgeOverLimit"):zt})]}),f&&Da.createPortal(s.jsx("div",{ref:W,className:"fixed bg-surface-secondary border border-border-default rounded-xl shadow-2xl z-[9999] flex flex-col overflow-hidden",style:{top:re.top,left:re.left,width:re.width,maxHeight:re.maxHeight},children:pe}),document.body),$e]})}return s.jsxs(s.Fragment,{children:[Z,s.jsxs("button",{ref:J,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"})]}),zt>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:zt>99?m("common:badgeOverLimit"):zt})]}),f&&Da.createPortal(s.jsx("div",{ref:W,className:"fixed bg-surface-secondary border border-border-default rounded-xl shadow-2xl z-[9999] flex flex-col overflow-hidden",style:{top:re.top,left:re.left,width:re.width,maxHeight:re.maxHeight},children:pe}),document.body),$e]})}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 xY({authUser:e,onLogout:t,onEditProfile:n,showSettingsLink:r=!1,collapsed:i=!1,showVersion:l=!1}){const{t:c}=gt(["nav","common"]),[d,m]=k.useState(!1),[f,h]=k.useState(!1),[g,y]=k.useState(()=>lt.isAuthenticated()),[x,w]=k.useState(()=>ha()),[T,C]=k.useState(null),[S,E]=k.useState({top:0,left:0}),j=k.useRef(null),M=k.useRef(null),O=k.useCallback(te=>{if(w(ha()),!lt.isAuthenticated()){y(!1),C(null);return}if(!te?.validate){y(!0);return}Rw().then(L=>{y(L),w(ha())})},[]);k.useEffect(()=>{O({validate:!0});const te=()=>O(),L=()=>O({validate:!0});return window.addEventListener("markus:hub-auth",te),window.addEventListener("focus",L),()=>{window.removeEventListener("markus:hub-auth",te),window.removeEventListener("focus",L)}},[O]),k.useEffect(()=>{if(!d||!lt.isAuthenticated())return;let te=!1;return lt.user.plan().then(L=>{if(te)return;const ee=(L.monthlyQuotaCu??0)+(L.bonusCu??0)+(L.purchasedCu??0);C(Math.max(0,ee-(L.cuUsed??0)))}).catch(()=>{te||C(null)}),()=>{te=!0}},[d,g]);const D=k.useCallback(()=>{if(!j.current)return;const te=j.current.getBoundingClientRect(),L=window.innerWidth,ee=window.innerHeight,ue=M.current?.offsetHeight??220;let Se=te.right+8;Se+rh>L-8&&(Se=Math.max(8,te.left-rh-8));let $=te.top-ue-8;$<8&&($=Math.min(te.bottom+8,ee-ue-8)),E({top:Math.max(8,$),left:Se})},[]);k.useLayoutEffect(()=>{if(!d)return;D();const te=requestAnimationFrame(()=>D());return()=>cancelAnimationFrame(te)},[d,D,i]),k.useEffect(()=>{if(!d)return;const te=ee=>{const ue=ee.target;j.current?.contains(ue)||M.current?.contains(ue)||m(!1)},L=()=>D();return document.addEventListener("mousedown",te),window.addEventListener("resize",L),window.addEventListener("scroll",L,!0),()=>{document.removeEventListener("mousedown",te),window.removeEventListener("resize",L),window.removeEventListener("scroll",L,!0)}},[d,D]);const H=e?.name||x?.displayName||x?.username||c("common:userPlaceholder"),q=e?.email||x?.email||"",Q=Ow(e?.avatarUrl,x?.avatarUrl),B=g?"bg-emerald-500":"bg-fg-muted",J=g?x?.username?c("sidebar.hubConnectedAs",{username:x.username}):c("sidebar.hubConnected"):c("sidebar.hubDisconnected"),W=!!(g&&x?.username&&e?.name&&x.username.toLowerCase()!==e.name.toLowerCase()&&x.email?.toLowerCase()!==e.email?.toLowerCase()),re=()=>{m(!1),O({validate:!0}),it.navigate(le.SETTINGS,{tab:"account"})},F=d&&Da.createPortal(s.jsxs("div",{ref:M,className:"fixed bg-surface-elevated border border-border-default rounded-xl shadow-xl z-[9999] overflow-hidden",style:{top:S.top,left:S.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:H}),q&&s.jsx("div",{className:"text-xs text-fg-tertiary mt-0.5 truncate",children:q}),T!==null&&s.jsxs("div",{className:"text-xs text-fg-secondary mt-0.5 flex items-center gap-1",children:[s.jsx("svg",{width:"11",height:"11",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",className:"shrink-0",children:s.jsx("polyline",{points:"13 2 3 14 12 14 18 22 6 22 12 17"})}),s.jsxs("span",{className:"truncate",children:[c("common:creditBalance"),": ",T.toLocaleString()]})]})]}),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:re,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 ${B}`}),s.jsxs("span",{className:"min-w-0 flex-1",children:[s.jsx("span",{className:"text-xs text-fg-secondary block truncate",children:J}),W&&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(le.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:xc[le.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 ${i?"flex justify-center":"flex items-center justify-between gap-2 w-full"}`,children:[s.jsxs("button",{ref:j,type:"button",onClick:()=>m(te=>!te),title:H,className:`relative inline-flex items-center justify-center rounded-full transition-opacity hover:opacity-90 ${i?"p-0.5":""}`,children:[s.jsx(Ys,{name:H,avatarUrl:Q,size:i?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 ${B}`,title:J})]}),l&&!i&&s.jsxs("span",{className:"text-[10px] text-fg-muted select-none shrink-0",children:["v","0.9.9-rc.2"]}),F,f&&t&&s.jsx(wr,{title:c("common:signOutConfirmTitle"),message:c("common:signOutConfirmMessage"),confirmLabel:c("common:signOut"),variant:"primary",onConfirm:()=>{h(!1),t()},onCancel:()=>h(!1)})]})}function yY({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 vY({currentPage:e,onNavigate:t,authUser:n,collapsed:r,onToggleCollapse:i,onLogout:l,keyboardFocusPageId:c,keyboardPaneActive:d}){const{t:m}=gt(["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:i,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=Aw.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===le.NOTIFICATIONS)return s.jsx(bY,{sidebarMode:!0,collapsed:r,userId:n?.id,label:m(x.id),iconPath:xc[x.id],isActive:e===x.id},x.id);const w=e===x.id,T=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 ${T?"bg-brand-500/25 ring-1 ring-inset ring-brand-500/40":w?"bg-surface-overlay":"hover:bg-surface-overlay/60"}`,children:[s.jsx(yY,{d:xc[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(xY,{authUser:n,onLogout:l,onEditProfile:()=>{window.dispatchEvent(new Event("markus:open-edit-profile"))},showSettingsLink:!1,collapsed:r,showVersion:!r})})]})}const wY=6e4;let Ks={},Ai={};const rg=new Set,ag=new Set;let f6=0,fc=null,Rd=0,Vd=null;function w0(){for(const e of rg)e()}async function sg(){try{const e=await Ee.unread.getCounts();Ks=e.counts??{},Ai=e.sessionAgentMap??{},w0()}catch{}}function kY(){fc||(sg(),fc=setInterval(sg,wY),Vd=ja.on("chat:unread_update",e=>{const t=e.payload?.conversationKey;t&&!ag.has(t)&&Date.now()>f6&&(Ks[t]=(Ks[t]??0)+1,w0())}))}function SY(){fc&&(clearInterval(fc),fc=null),Vd&&(Vd(),Vd=null)}function NY(e){const t=e?.enabled??!0,[n,r]=k.useState(Ks),[i,l]=k.useState(Ai),c=k.useCallback(async()=>{await sg()},[]),d=k.useCallback(async w=>{const T=new Date().toISOString();delete Ks[w],w0();try{await Ee.unread.markRead(w,T)}catch{}},[]),m=k.useCallback(async()=>{Ks={},w0();try{await Ee.unread.markAllRead()}catch{}},[]),f=k.useCallback(w=>{ag.add(w)},[]),h=k.useCallback(w=>{ag.delete(w),f6=Date.now()+150},[]);k.useEffect(()=>{if(!t)return;Rd++,kY();let w=Ai;const T=()=>{r({...Ks}),w!==Ai&&(w=Ai,l({...Ai}))};return rg.add(T),r({...Ks}),l({...Ai}),()=>{rg.delete(T),Rd--,Rd<=0&&(Rd=0,SY())}},[t]);const g=k.useMemo(()=>Object.values(n).reduce((w,T)=>w+T,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:i,getSessionUnread:y,getChannelUnread:x,markRead:d,markAllRead:m,refresh:c,setActiveKey:f,clearActiveKey:h}}function kQ(e,t){return k.useMemo(()=>{const n=new Map;for(const[r,i]of Object.entries(t))if(r.startsWith("session:")){const l=r.slice(8),c=e[l];c&&n.set(c,(n.get(c)??0)+i)}return n},[e,t])}function CY({currentPage:e,onNavigate:t,userId:n}){const{t:r}=gt("nav"),[i,l]=k.useState(0),{counts:c}=NY({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===le.NOTIFICATIONS,y=f.id===le.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:xc[f.id]})}),g&&i>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:i>99?"99+":i}),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 Ni(e,t){k0.has(e)||k0.set(e,t().catch(()=>{}))}function Ri(e){const t=k0.get(e);return k0.delete(e),t}const Ir={builderArtifacts:"builder.artifacts",builderAgents:"builder.agents",builderHubMyItems:"builder.hubMyItems",builderInstalled:"builder.installed",hubAgents:"hub.agents",hubTeams:"hub.teams",hubSkills:"hub.skills"},Pi={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 nl(e){const t=(e||"").toLowerCase();return t==="team"?"team":t==="skill"?"skill":t==="connector"||t==="mcp"?"connector":"agent"}function p6(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 TY={agent:258,team:205,skill:32,connector:162};function Jg(e,t){const n=TY[e],r=p6(t),i=((n+(r%68-34))%360+360)%360,l=(i+22+(r>>>8)%24)%360;return`linear-gradient(${120+r%44}deg, hsl(${i} 72% 56%), hsl(${l} 66% 43%))`}const $4=["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 h6(e){return $4[p6(e+"g")%$4.length]}function g6(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 AY(e){return!e||g6(e)?!1:[...e].length<=4&&new RegExp("\\p{Extended_Pictographic}","u").test(e)}function EY(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 Io(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 H4(e,t="usd"){return!e||e<=0?"Free":`${t.toLowerCase()==="usd"?"$":""}${(e/100).toFixed(e%100===0?0:2)}`}const U4={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"}},_Y=["development","devops","management","productivity","browser","custom","general"],jY=[{label:"Tech",emojis:["✦","◈","⬡","⚡","🤖","🧠","💡","🎯","🔧","📦","🚀","💻","🛠️","⭐","🔥","💎","⚙️","🧩","🔌","💾","🖥️","📡","🔬","🧪","🏗️","📱","🎮","🕹️","📟","💽","🖨️","⌨️"]},{label:"People",emojis:["👤","👥","🧑‍💻","👨‍💼","👩‍🔬","🧙","🦸","🤝","💪","🎓","👷","🕵️","🧑‍🎨","🧑‍🏫","👨‍🚀","🥷","🧑‍🏭","🧑‍⚕️","🧑‍🔧","🧑‍🍳","👨‍🎤","🦹","🧝","🧞","🧑‍✈️","💂","🤴","👸","🧛","🧟","🧜","🧚"]},{label:"Objects",emojis:["📝","📊","🗂️","📁","🔍","🔑","🌐","💬","🔒","🎨","📐","🗃️","📋","✏️","🖊️","📌","📎","🧲","🪝","🧰","🪜","🧬","🔭","💊","🩺","📕","📗","📘","📙","📓","🗒️","📰"]},{label:"Symbols",emojis:["❤️","🧡","💛","💚","💙","💜","🖤","🤍","♠️","♥️","♦️","♣️","🎵","🎶","💯","✅","❌","⭕","🔴","🟠","🟡","🟢","🔵","🟣","⚫","⚪","🟤","🔶","🔷","▶️","⏸️","⏹️"]},{label:"Nature",emojis:["🌟","🌈","🌊","🌿","🍀","🔮","💫","✨","🌙","☀️","🦋","🐉","🦊","🐺","🦅","🐙","🦁","🐯","🦄","🐲","🌸","🌺","🍄","🌵","🎄","🌴","🍁","🌻","🐝","🦎","🐍","🦈"]},{label:"Activity",emojis:["🎯","🏆","🥇","🎖️","🏅","🎪","🎭","🎬","🎤","🎧","🎼","🎹","🥁","🎸","🎺","🎻","⚽","🏀","🎾","🏐","🎲","🧸","🪁","🎰","🎳","🏹","🥊","🤺","⛷️","🏄","🚴","🧗"]}],MY={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:i,placeholder:l,multiline:c,readOnly:d}){if(d){const j=e||l,O=`${r??""} ${!e?"text-fg-muted italic":""}`;return n==="h1"?s.jsx("h1",{className:O,children:j}):n==="p"?s.jsx("p",{className:O,children:j}):s.jsx("span",{className:O,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)},T=j=>{j.key==="Escape"&&w(),j.key==="Enter"&&!c&&x()};if(m){const j=`bg-transparent outline-none w-full ${i??r??""} ring-1 ring-brand-500/50 rounded px-1 -mx-1`;return c?s.jsx("textarea",{ref:y,value:h,onChange:M=>g(M.target.value),onBlur:x,onKeyDown:T,className:`${j} resize-y min-h-[60px]`,placeholder:l}):s.jsx("input",{ref:y,value:h,onChange:M=>g(M.target.value),onBlur:x,onKeyDown:T,className:j,placeholder:l})}const C=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:C}):n==="p"?s.jsx("p",{onClick:()=>f(!0),className:`${r??""} ${E} ${S?"text-fg-muted italic":""}`,children:C}):n==="badge"?s.jsx("span",{onClick:()=>f(!0),className:`${r??""} ${E} ${S?"text-fg-muted italic":""}`,children:C}):s.jsx("span",{onClick:()=>f(!0),className:`${r??""} ${E} ${S?"text-fg-muted italic":""}`,children:C})}function RY({value:e,options:t,onChange:n,className:r,readOnly:i}){if(i)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 DY({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}=gt(["builder"]),[i,l]=k.useState(!1),[c,d]=k.useState(""),m=k.useRef(null);k.useEffect(()=>{i&&m.current?.focus()},[i]);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 i?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 ig({content:e}){const t=[Z5,e3,t3],n=[H3,[u3,{strict:"ignore"}],[E3,{detect:!0,ignoreMissing:!0}]],r=e6({}),i=k.useMemo(()=>Ti(e,D3),[e]);return s.jsx("div",{className:`prose prose-invert prose-sm max-w-none
663
+ `)||void 0;i({approved:D,comment:q,selectedOption:H,answers:O})};return Da.createPortal(s.jsx("div",{className:"fixed inset-0 z-[10000] flex items-center justify-center p-4 bg-black/50 backdrop-blur-sm",onMouseDown:O=>{O.target===O.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((O,D)=>s.jsx("button",{onClick:()=>m(D),className:`h-1.5 flex-1 rounded-full transition-colors ${D===d?"bg-brand-500":S(O)?"bg-green-500/60":"bg-border-default"}`,title:`${D+1}. ${O.prompt.slice(0,40)}`},O.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(Br,{content:g.prompt})}),g.inputType==="choice"&&g.options&&s.jsx("div",{className:"space-y-2",children:g.options.map((O,D)=>{const H=w(g.id).selectedOptionIds.includes(O.id);return s.jsxs("button",{onClick:n?void 0:()=>C(g,O.id),disabled:n,className:`w-full px-4 py-3 text-left rounded-xl border transition-colors flex items-start gap-3 ${H?"border-brand-500 bg-brand-500/10":`border-border-default ${n?"":"hover:bg-surface-overlay"}`} ${n?"cursor-default":""} ${n&&!H?"opacity-50":""}`,children:[s.jsx("span",{className:`w-6 h-6 rounded-full flex items-center justify-center text-[11px] font-bold shrink-0 mt-0.5 ${H?"bg-brand-600 text-white":"bg-surface-overlay text-fg-tertiary"}`,children:H?s.jsx("svg",{width:"13",height:"13",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"3",strokeLinecap:"round",strokeLinejoin:"round",children:s.jsx("path",{d:"M20 6L9 17l-5-5"})}):String.fromCharCode(65+D)}),s.jsxs("span",{className:"flex-1 min-w-0 text-sm text-fg-primary [&_p]:my-0 [&_p]:text-sm",children:[s.jsx(Br,{content:O.label}),O.description&&s.jsx("span",{className:"block text-xs text-fg-tertiary mt-1 [&_p]:my-0 [&_p]:text-xs",children:s.jsx(Br,{content:O.description})})]})]},O.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:O=>{const D=O.target.value;T(g.id,{text:D,selectedOptionIds:D.trim()&&g.inputType==="choice"?[]:w(g.id).selectedOptionIds})},className:`w-full px-3.5 py-2.5 text-sm bg-surface-overlay border border-border-default rounded-xl text-fg-primary placeholder:text-fg-tertiary focus:outline-none resize-y ${n?"cursor-default opacity-80":"focus:ring-1 focus:ring-brand-500/50"}`})]}),s.jsxs("div",{className:"flex items-center justify-between gap-2 px-6 py-4 border-t border-border-default shrink-0",children:[s.jsx("div",{children:x&&d>0&&s.jsx("button",{onClick:()=>m(O=>Math.max(0,O-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(O=>Math.min(c.length-1,O+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:M,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"},Mo={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"},P4={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 Ro(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 i=Math.floor(r/60);return i<24?t("common:time.hoursAgo",{count:i}):t("common:time.daysAgo",{count:Math.floor(i/24)})}const B4="markus:template-updates-ack";let th=!1,_d=null;function gY(e){return e.map(t=>`${t.name}@${t.availableVersion}`).sort().join(",")}function z4(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 bY({collapsed:e,userId:t,embeddedMode:n,onClose:r,sidebarMode:i,isActive:l,label:c,iconPath:d}){const{t:m}=gt(["team","common"]),[f,h]=k.useState(!1),[g,y]=k.useState("approvals"),[x,w]=k.useState([]),[T,C]=k.useState([]),[S,E]=k.useState(null),[j,M]=k.useState(null),[O,D]=k.useState(null),[H,q]=k.useState({}),[Q,B]=k.useState(0),J=k.useRef(null),W=k.useRef(null),[re,F]=k.useState({top:0,left:0,width:448,maxHeight:576}),te=k.useRef(null),L=k.useRef(!1),[ee,ue]=k.useState(!0),[Se,$]=k.useState(!1),G=k.useRef(null),me=k.useRef("approvals"),[P,_e]=k.useState(!1),He=30,Pe=k.useCallback(async()=>{try{as("/approvals"),as("/notifications");const[Y,ye]=await Promise.all([Ee.notifications.list(t,!1,{limit:He,offset:0}),Ee.approvals.list()]);w(Y.notifications);const Ye=Y.unreadCount??Y.notifications.filter(xe=>!xe.read).length;if(B(Ye),ue(Y.totalCount!=null?Y.notifications.length<Y.totalCount:Y.notifications.length>=He),C(ye.approvals),!L.current){const xe=ye.approvals.filter(nt=>nt.status==="pending").length;te.current=xe,L.current=!0}}catch{}},[t]),Ge=k.useCallback(async()=>{if(!(Se||!ee)){$(!0);try{const Y=await Ee.notifications.list(t,!1,{limit:He,offset:x.length});Y.notifications.length>0&&w(ye=>[...ye,...Y.notifications.filter(Ye=>!ye.some(xe=>xe.id===Ye.id))]),ue(Y.totalCount!=null?x.length+Y.notifications.length<Y.totalCount:Y.notifications.length>=He)}catch{}$(!1)}},[t,x.length,Se,ee]),ut=k.useCallback(Y=>{const ye=Y.detail;if(!ye)return;const{taskId:Ye,requirementId:xe}=ye;!Ye&&!xe||w(nt=>{const at=nt.filter(V=>!V.read&&(Ye&&V.metadata?.taskId===Ye||xe&&V.metadata?.requirementId===xe));if(at.length===0)return nt;for(const V of at)Ee.notifications.markRead(V.id).catch(()=>{});return B(V=>Math.max(0,V-at.length)),nt.map(V=>at.some(he=>he.id===V.id)?{...V,read:!0}:V)})},[]),pt=k.useRef(x);pt.current=x;const ht=k.useCallback(async()=>{if(!pt.current.some(ye=>!ye.read&&ye.type==="system"&&ye.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:Y}=await Ee.skills.updates();if(!Y.length)return;const ye=gY(Y);try{if(localStorage.getItem(B4)===ye)return}catch{}if(_d===ye||pt.current.some(xe=>!xe.read&&z4(xe,ye)))return;try{const nt=(await Ee.notifications.list(t,!0,{limit:50,type:"system"})).notifications.filter(at=>z4(at,ye)).sort((at,V)=>new Date(V.createdAt).getTime()-new Date(at.createdAt).getTime());if(nt.length>0){for(const at of nt.slice(1))Ee.notifications.markRead(at.id).catch(()=>{});nt.length>1&&Pe(),_d=ye;return}}catch{}_d=ye,await Ee.notifications.create({title:m("templateUpdates.notificationTitle",{ns:"common"}),body:m("templateUpdates.notificationBody",{ns:"common",count:Y.length}),type:"system",priority:"high",metadata:{templateUpdates:!0,templateUpdatesFingerprint:ye,count:Y.length,skills:Y.map(xe=>xe.name)}}),Pe(),nh()}catch{_d=null}finally{th=!1}}},[Pe,m,t]);k.useEffect(()=>{Pe();const Y=setInterval(Pe,6e4);let ye=null;const Ye=()=>{ye||(ye=setTimeout(()=>{ye=null,Pe()},400))},xe=()=>Ye(),nt=()=>{h(!0),Pe()};window.addEventListener("markus:notifications-changed",xe),window.addEventListener("markus:mark-read-by-ref",ut),window.addEventListener("markus:open-notifications",nt),window.addEventListener("markus:credit-exhausted",ht);const at=ja.on("notification",Ye),V=ja.on("approval:requested",Ye);return()=>{clearInterval(Y),ye&&clearTimeout(ye),window.removeEventListener("markus:notifications-changed",xe),window.removeEventListener("markus:mark-read-by-ref",ut),window.removeEventListener("markus:open-notifications",nt),window.removeEventListener("markus:credit-exhausted",ht),at(),V()}},[Pe,ut,ht]),k.useEffect(()=>{Mt();const Y=setInterval(()=>{Mt()},5*6e4),ye=()=>{Mt()};return window.addEventListener("markus:data-changed",ye),()=>{clearInterval(Y),window.removeEventListener("markus:data-changed",ye)}},[t]);const Bt=k.useCallback(()=>{if(!J.current)return;const Y=J.current.getBoundingClientRect(),ye=window.innerWidth,Ye=window.innerHeight,xe=Math.min(448,ye-16),nt=Math.min(576,Ye-16);let at=Y.right+8,V=Y.top;at+xe>ye-8&&(at=Math.max(8,ye-xe-8)),V+nt>Ye-8&&(V=Math.max(8,Ye-nt-8)),F({top:V,left:at,width:xe,maxHeight:nt})},[]);k.useLayoutEffect(()=>{f&&Bt()},[f,Bt]),k.useEffect(()=>{if(f)return window.addEventListener("resize",Bt),()=>window.removeEventListener("resize",Bt)},[f,Bt]),k.useEffect(()=>{if(!f)return;const Y=ye=>{J.current?.contains(ye.target)||W.current?.contains(ye.target)||h(!1)};return document.addEventListener("mousedown",Y),()=>document.removeEventListener("mousedown",Y)},[f]),k.useEffect(()=>{if(!f)return;const Y=T.some(Ye=>Ye.status==="pending"),ye=x.some(Ye=>!Ye.read);y(Y&&!ye?"approvals":!Y&&ye?"notifications":me.current)},[f]);const Qt=new Set(T.filter(Y=>Y.status==="pending").map(Y=>Y.id)),wt=new Set(T.map(Y=>Y.id)),Ue=x.filter(Y=>!(Y.type==="approval_request"&&Y.metadata?.approvalId&&wt.has(Y.metadata.approvalId))),ft=x.filter(Y=>Y.type==="approval_request"&&!Y.read&&Y.metadata?.approvalId&&Qt.has(Y.metadata.approvalId)).length,kt=Math.max(0,Q-ft),Nt=Qt.size,zt=kt+Nt;k.useEffect(()=>{te.current!==null&&Nt>te.current&&nh(),te.current=Nt},[Nt]);const ce=async Y=>{await Ee.notifications.markRead(Y),w(ye=>ye.map(Ye=>Ye.id===Y?{...Ye,read:!0}:Ye)),B(ye=>Math.max(0,ye-1)),window.dispatchEvent(new CustomEvent("markus:notifications-changed"))},tt=Y=>{const ye=Y.metadata??{},Ye=Y.actionType,xe=Y.actionTarget;if(Ye==="open_chat"&&xe)try{const nt=typeof xe=="string"?JSON.parse(xe):xe;if(nt.agentId){const at={agentId:nt.agentId};nt.sessionId&&(at.sessionId=nt.sessionId),it.navigate(le.TEAM,at);return}}catch{}if(Ye==="navigate"&&xe)try{const nt=typeof xe=="string"?JSON.parse(xe):xe;if(nt.path){if(nt.path.startsWith("/team")){const at={},V=new URLSearchParams(nt.path.split("?")[1]||"");for(const[he,Ie]of V.entries())at[he]=Ie;it.navigate(le.TEAM,at);return}if(nt.path.startsWith("/work")){const at={},V=new URLSearchParams(nt.path.split("?")[1]||"");for(const[he,Ie]of V.entries())at[he]=Ie;it.navigate(le.WORK,at);return}}}catch{}switch(Y.type){case"approval_request":{const nt=ye.approvalId,at=nt?T.find(Je=>Je.id===nt):void 0;if(at&&Ad(at)){M(at);break}const V=at?.details?.taskId??ye.taskId,he=at?.details?.requirementId??ye.requirementId,Ie=at?.details?.agentId??at?.agentId;V?it.navigate(le.WORK,{openTask:V}):he?it.navigate(le.WORK,{openRequirement:he}):Ie?it.navigate(le.TEAM,{agentId:Ie}):it.navigate(le.WORK);break}case"task_completed":case"task_created":case"task_review":case"task_failed":ye.taskId?it.navigate(le.WORK,{openTask:ye.taskId}):it.navigate(le.WORK);break;case"requirement_created":case"requirement_decision":ye.requirementId?it.navigate(le.WORK,{openRequirement:ye.requirementId}):it.navigate(le.WORK);break;case"agent_report":case"system":{if(ye.creditExhausted){_e(!0);return}if(ye.templateUpdates){const nt=ye.templateUpdatesFingerprint;if(nt)try{localStorage.setItem(B4,nt)}catch{}localStorage.setItem("markus_nav_storeTab","installed"),it.navigate(le.STORE);return}if(ye.agentId){const nt={agentId:ye.agentId};ye.sessionId&&(nt.sessionId=ye.sessionId),it.navigate(le.TEAM,nt)}else it.navigate(le.TEAM);break}case"direct_message":{const nt=ye.senderId;nt?it.navigate(le.TEAM,{dm:nt}):it.navigate(le.TEAM);break}case"group_message":{const nt=ye.channel;nt?it.navigate(le.TEAM,{channel:nt}):it.navigate(le.TEAM);break}default:ye.taskId?it.navigate(le.WORK,{openTask:ye.taskId}):ye.requirementId?it.navigate(le.WORK,{openRequirement:ye.requirementId}):ye.projectId?it.navigate(le.WORK,{projectId:ye.projectId}):ye.agentId&&it.navigate(le.TEAM,{agentId:ye.agentId});break}},rt=async Y=>{const ye=Y.metadata??{},Ye=Y.actionType,xe=Y.type==="agent_report"&&!ye.creditExhausted&&!ye.templateUpdates&&(Ye==="open_chat"||!!ye.agentId&&Ye!=="navigate");!Y.read&&!xe&&ce(Y.id);const nt=ye.taskId,at=ye.requirementId;if(!xe&&(nt||at)){const V=x.filter(he=>he.id!==Y.id&&!he.read&&(nt&&he.metadata?.taskId===nt||at&&he.metadata?.requirementId===at));for(const he of V)ce(he.id)}tt(Y)},be=async(Y,ye,Ye,xe,nt)=>{E(Y);try{const{approval:at}=await Ee.approvals.respond(Y,ye,t,Ye,xe,nt);C(Je=>Je.map(dt=>dt.id===Y?at:dt)),M(null),D(null),q(Je=>{const dt={...Je};return delete dt[Y],dt});const V=at.details?.taskId,he=at.details?.requirementId,Ie=x.filter(Je=>!Je.read&&(Je.type==="approval_request"&&Je.metadata?.approvalId===Y||V&&Je.metadata?.taskId===V||he&&Je.metadata?.requirementId===he));if(Ie.length>0){for(const dt of Ie)Ee.notifications.markRead(dt.id).catch(()=>{});const Je=new Set(Ie.map(dt=>dt.id));w(dt=>dt.map(_t=>Je.has(_t.id)?{..._t,read:!0}:_t)),B(dt=>Math.max(0,dt-Ie.length))}as("/approvals"),as("/notifications"),as("/tasks"),as("/taskboard"),as("/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(Y=>Y.map(ye=>({...ye,read:!0}))),B(0),as("/notifications"),window.dispatchEvent(new CustomEvent("markus:notifications-changed"))}catch{const Y=Ue.filter(ye=>!ye.read);await Promise.all(Y.map(ye=>Ee.notifications.markRead(ye.id))),w(ye=>ye.map(Ye=>({...Ye,read:!0}))),B(0),as("/notifications"),window.dispatchEvent(new CustomEvent("markus:notifications-changed"))}},Ae=Y=>{const ye=Y.details?.subType;return ye==="requirement_resubmit"?m("team:notifications.approvalType.requirementResubmit"):ye==="requirement"||Y.details?.requirementId?m("team:notifications.approvalType.requirement"):ye==="task_review"?m("team:notifications.approvalType.taskReview"):ye==="task"||Y.details?.taskId?m("team:notifications.approvalType.task"):Y.details?.toolName?m("team:notifications.approvalType.toolExecution"):null},oe=Y=>{const ye=[];ye.push(Y.agentName);const Ye=Y.details?.taskTitle,xe=Y.details?.taskId;Ye?ye.push(Ye):xe&&ye.push(`Task ${xe.slice(0,8)}`);const nt=Y.details?.requirementId;return nt&&!xe&&ye.push(`Req ${nt.slice(0,8)}`),ye.join(" · ")},U=[...T].sort((Y,ye)=>new Date(ye.requestedAt).getTime()-new Date(Y.requestedAt).getTime()),ae=U.filter(Y=>Y.status==="pending"),Ce=U.filter(Y=>Y.status!=="pending"),Re=Y=>{const ye=Y.details?.taskId,Ye=Y.details?.requirementId,xe=Y.details?.agentId??Y.agentId;ye?it.navigate(le.WORK,{openTask:ye}):Ye?it.navigate(le.WORK,{openRequirement:Ye}):xe?it.navigate(le.TEAM,{agentId:xe}):it.navigate(le.WORK)},ze=()=>{h(!1),r?.()},X=Y=>s.jsxs("button",{disabled:S===Y.id,onClick:()=>M(Y),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"}),Y.questions&&Y.questions.length>1?` (${Y.questions.length})`:""]}),Z=j?s.jsx(hY,{approval:j,submitting:S===j.id,readOnly:j.status!=="pending",onClose:()=>M(null),onSubmit:Y=>be(j.id,Y.approved,Y.comment,Y.selectedOption,Y.answers)}):null,pe=s.jsxs(s.Fragment,{children:[s.jsxs("div",{className:"flex border-b border-border-default shrink-0",children:[s.jsxs("button",{onClick:()=>{y("approvals"),me.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"),Nt>0?` (${Nt})`:""]}),s.jsxs("button",{onClick:()=>{y("notifications"),me.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"),kt>0?` (${kt})`:""]}),s.jsx("button",{onClick:ze,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"&&Q>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:G,className:"flex-1 overflow-y-auto",onScroll:Y=>{if(g!=="notifications"||!ee||Se)return;const ye=Y.currentTarget;ye.scrollTop+ye.clientHeight>=ye.scrollHeight-80&&Ge()},children:[g==="approvals"&&(T.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:[ae.map(Y=>{const ye=Y.details?.command,Ye=ye?Y.description.replace(/\s*Command:.*$/,""):Y.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(Y),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:Mo.approval_request})}),s.jsxs("div",{className:"flex-1 min-w-0",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[Ae(Y)&&s.jsx("span",{className:"text-[10px] text-amber-500 font-medium shrink-0",children:Ae(Y)}),s.jsx("span",{className:"text-xs text-fg-primary font-medium truncate",children:Y.title}),s.jsx("span",{className:"text-[10px] text-fg-tertiary shrink-0",children:Ro(Y.requestedAt,m)})]}),s.jsx("div",{className:"text-[11px] text-fg-tertiary mt-0.5",children:Y.agentName})]})]}),s.jsx("div",{className:"mt-2.5 text-[11px] text-fg-secondary leading-relaxed",children:s.jsx(Br,{content:Ye,className:"text-[11px] [&_h1]:text-xs [&_h2]:text-[11px] [&_h3]:text-[11px] [&_p]:text-[11px] [&_li]:text-[11px]"})}),ye&&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:ye})]}),(()=>{if(Ad(Y))return X(Y);const xe=Y.details?.subType,nt=xe==="task"||xe==="requirement"||xe==="requirement_resubmit",at=Y.options&&Y.options.length>0,V=(H[Y.id]??"").trim();return at?s.jsxs("div",{className:"space-y-1.5",children:[Y.options.map((he,Ie)=>s.jsxs("button",{disabled:S===Y.id,onClick:()=>be(Y.id,he.id!=="reject",V||void 0,he.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 ${he.id==="reject"||he.id==="request_changes"?"border border-border-default text-fg-secondary hover:bg-surface-overlay":"bg-brand-600 text-white hover:bg-brand-700"}`,title:he.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+Ie)}),he.label]},he.id)),s.jsxs("div",{className:"flex gap-1.5 mt-1",children:[s.jsx("input",{type:"text",placeholder:m("team:notifications.freeformPlaceholder"),value:H[Y.id]??"",onChange:he=>q(Ie=>({...Ie,[Y.id]:he.target.value})),onKeyDown:he=>{he.key==="Enter"&&(H[Y.id]??"").trim()&&be(Y.id,!0,(H[Y.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===Y.id||!(H[Y.id]??"").trim(),onClick:()=>be(Y.id,!0,(H[Y.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")})]})]}):nt?s.jsxs("div",{className:"space-y-1.5",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsxs("button",{disabled:S===Y.id,onClick:()=>be(Y.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===Y.id,onClick:()=>be(Y.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")]}),O!==Y.id&&s.jsxs("button",{disabled:S===Y.id,onClick:()=>D(Y.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")]})]}),O===Y.id&&s.jsxs("div",{className:"space-y-1.5",children:[s.jsx("input",{type:"text",autoFocus:!0,placeholder:m("team:notifications.adjustmentPlaceholder"),value:H[Y.id]??"",onChange:he=>q(Ie=>({...Ie,[Y.id]:he.target.value})),onKeyDown:he=>{he.key==="Enter"&&(H[Y.id]??"").trim()&&be(Y.id,!1,(H[Y.id]??"").trim(),"needs_adjustment"),he.key==="Escape"&&D(null)},className:"w-full px-2.5 py-1.5 text-[11px] bg-surface-overlay border border-border-default rounded-md text-fg-primary placeholder:text-fg-tertiary focus:outline-none focus:ring-1 focus:ring-amber-500/50"}),s.jsxs("div",{className:"flex gap-2",children:[s.jsx("button",{disabled:S===Y.id||!(H[Y.id]??"").trim(),onClick:()=>be(Y.id,!1,(H[Y.id]??"").trim(),"needs_adjustment"),className:"px-2.5 py-1.5 text-[11px] font-medium bg-amber-600 text-white rounded-md hover:bg-amber-700 disabled:opacity-50 transition-colors",children:m("team:notifications.confirmAdjustment")}),s.jsx("button",{onClick:()=>D(null),className:"px-2.5 py-1.5 text-[11px] font-medium border border-border-default text-fg-secondary rounded-md hover:bg-surface-overlay transition-colors",children:m("common:cancel")})]})]})]}):s.jsxs("div",{className:"space-y-1.5",children:[s.jsx("input",{type:"text",placeholder:m("team:notifications.commentPlaceholder"),value:H[Y.id]??"",onChange:he=>q(Ie=>({...Ie,[Y.id]:he.target.value})),onKeyDown:he=>{he.key==="Enter"&&be(Y.id,!0,V||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===Y.id,onClick:()=>be(Y.id,!0,V||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===Y.id,onClick:()=>be(Y.id,!1,V||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")})]})]})})()]},Y.id)}),Ce.length>0&&s.jsxs(s.Fragment,{children:[ae.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")}),Ce.slice(0,50).map(Y=>s.jsxs("button",{onClick:()=>Ad(Y)?M(Y):Re(Y),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 ${Y.status==="approved"?"bg-green-500":Y.status==="cancelled"||Y.status==="expired"?"bg-gray-400":"bg-red-500"}`}),Ae(Y)&&s.jsx("span",{className:"text-[10px] text-fg-tertiary font-medium shrink-0",children:Ae(Y)}),s.jsx("span",{className:"text-xs text-fg-secondary truncate flex-1 group-hover:text-fg-primary",children:Y.title}),s.jsx("span",{className:`text-[10px] font-medium shrink-0 ${Y.status==="approved"?"text-green-500":Y.status==="cancelled"||Y.status==="expired"?"text-fg-muted":"text-red-500"}`,children:m(`common:status.${Y.status}`,{defaultValue:Y.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(Y)}),s.jsx("span",{className:"text-[10px] text-fg-muted shrink-0",children:"·"}),s.jsx("span",{className:"text-[10px] text-fg-muted shrink-0",children:Ro(Y.respondedAt??Y.requestedAt,m)})]}),Y.responseComment&&s.jsxs("p",{className:"text-[10px] text-fg-muted mt-0.5 pl-3.5 truncate",children:["“",Y.responseComment,"”"]})]},Y.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(Y=>{const ye=P4[Y.type]??"text-fg-tertiary";return s.jsxs("div",{role:"button",tabIndex:0,onClick:()=>rt(Y),onKeyDown:Ye=>{(Ye.key==="Enter"||Ye.key===" ")&&(Ye.preventDefault(),rt(Y))},className:`w-full text-left px-3 py-2.5 flex gap-2.5 transition-colors cursor-pointer ${Y.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:ye,children:s.jsx("path",{d:Mo[Y.type]??Mo.system})})}),s.jsxs("div",{className:"flex-1 min-w-0",children:[s.jsxs("div",{className:"flex items-center gap-1.5",children:[!Y.read&&s.jsx("span",{className:`w-1.5 h-1.5 rounded-full shrink-0 ${Ed[Y.priority]??Ed.normal}`}),s.jsx("span",{className:"text-xs text-fg-primary font-medium truncate",children:Y.title})]}),s.jsx("div",{className:"text-[11px] text-fg-tertiary mt-0.5 ",children:s.jsx(Br,{content:Y.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:Ro(Y.createdAt,m)}),jd(Y,m)&&s.jsx("span",{className:`text-[10px] font-medium ${ye}`,children:jd(Y,m)})]})]})]},Y.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"})]})})]}))]})]}),Fe=k.useCallback(Y=>{Y?.mute&&fY()},[]),Oe=k.useCallback(Y=>{Fe(Y),_e(!1)},[Fe]),$e=P?s.jsx(wr,{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:Y=>{Oe(Y),it.navigate(le.SETTINGS),setTimeout(()=>{window.location.hash="settings/providers"},50)},onConfirm:Y=>{const ye=`${lt.getUrl().replace(/\/$/,"")}/settings?tab=billing`;Oe(Y),Xs(ye)}}):null;if(n){const Y=["approvals","notifications"],ye=Y.indexOf(g),Ye=(()=>{let xe=0,nt=0;return{onTouchStart:at=>{xe=at.touches[0].clientX,nt=at.touches[0].clientY},onTouchEnd:at=>{const V=at.changedTouches[0].clientX-xe,he=at.changedTouches[0].clientY-nt;Math.abs(V)>60&&Math.abs(V)>Math.abs(he)*1.5&&(V<0&&ye<Y.length-1&&y(Y[ye+1]),V>0&&ye>0&&y(Y[ye-1]))}}})();return s.jsxs(s.Fragment,{children:[$e,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:Y.map(xe=>s.jsx("button",{onClick:()=>y(xe),className:`flex-1 px-3 py-3 text-sm font-medium transition-colors ${g===xe?"text-fg-primary border-b-2 border-brand-500":"text-fg-tertiary"}`,children:xe==="approvals"?s.jsxs(s.Fragment,{children:[m("team:notifications.approvals"),Nt>0?` (${Nt})`:""]}):s.jsxs(s.Fragment,{children:[m("team:notifications.notifications"),kt>0?` (${kt})`:""]})},xe))}),g==="notifications"&&Q>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",...Ye,children:s.jsxs("div",{className:"flex h-full transition-transform duration-300 ease-out",style:{transform:`translateX(-${ye*100}%)`},children:[s.jsx("div",{className:"w-full shrink-0 h-full overflow-y-auto scrollbar-thin",children:T.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:[ae.map(xe=>{const nt=xe.details?.command,at=nt?xe.description.replace(/\s*Command:.*$/,""):xe.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(xe),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:Mo.approval_request})}),s.jsxs("div",{className:"flex-1 min-w-0",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[Ae(xe)&&s.jsx("span",{className:"text-[10px] text-amber-500 font-medium shrink-0",children:Ae(xe)}),s.jsx("span",{className:"text-xs text-fg-primary font-medium truncate",children:xe.title}),s.jsx("span",{className:"text-[10px] text-fg-tertiary shrink-0",children:Ro(xe.requestedAt,m)})]}),s.jsx("div",{className:"text-[11px] text-fg-tertiary mt-0.5",children:xe.agentName})]})]}),s.jsx("div",{className:"mt-2.5 text-[11px] text-fg-secondary leading-relaxed",children:s.jsx(Br,{content:at,className:"text-[11px] [&_h1]:text-xs [&_h2]:text-[11px] [&_h3]:text-[11px] [&_p]:text-[11px] [&_li]:text-[11px]"})}),nt&&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:nt})]}),(()=>{if(Ad(xe))return X(xe);const V=xe.details?.subType,he=V==="task"||V==="requirement"||V==="requirement_resubmit",Ie=xe.options&&xe.options.length>0,Je=(H[xe.id]??"").trim();return Ie?s.jsxs("div",{className:"space-y-1.5",children:[xe.options.map((dt,_t)=>s.jsxs("button",{disabled:S===xe.id,onClick:()=>be(xe.id,dt.id!=="reject",Je||void 0,dt.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 ${dt.id==="reject"||dt.id==="request_changes"?"border border-border-default text-fg-secondary hover:bg-surface-overlay":"bg-brand-600 text-white hover:bg-brand-700"}`,title:dt.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+_t)}),dt.label]},dt.id)),s.jsxs("div",{className:"flex gap-1.5 mt-1",children:[s.jsx("input",{type:"text",placeholder:m("team:notifications.freeformPlaceholder"),value:H[xe.id]??"",onChange:dt=>q(_t=>({..._t,[xe.id]:dt.target.value})),onKeyDown:dt=>{dt.key==="Enter"&&(H[xe.id]??"").trim()&&be(xe.id,!0,(H[xe.id]??"").trim(),"custom")},className:"flex-1 px-2.5 py-1.5 text-[11px] bg-surface-overlay border border-border-default rounded-md text-fg-primary placeholder:text-fg-tertiary focus:outline-none focus:ring-1 focus:ring-brand-500/50"}),s.jsx("button",{disabled:S===xe.id||!(H[xe.id]??"").trim(),onClick:()=>be(xe.id,!0,(H[xe.id]??"").trim(),"custom"),className:"px-2.5 py-1.5 text-[11px] font-medium bg-brand-600 text-white rounded-md hover:bg-brand-700 disabled:opacity-50 transition-colors",children:m("common:send")})]})]}):he?s.jsxs("div",{className:"space-y-1.5",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsxs("button",{disabled:S===xe.id,onClick:()=>be(xe.id,!0,void 0,"approve"),className:"px-3 py-1.5 text-[11px] font-medium bg-green-600 text-white rounded-md hover:bg-green-700 disabled:opacity-50 transition-colors inline-flex items-center gap-1.5",children:[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===xe.id,onClick:()=>be(xe.id,!1,void 0,"reject"),className:"px-3 py-1.5 text-[11px] font-medium bg-red-600/80 text-white rounded-md hover:bg-red-700 disabled:opacity-50 transition-colors inline-flex items-center gap-1.5",children:[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")]}),O!==xe.id&&s.jsxs("button",{disabled:S===xe.id,onClick:()=>D(xe.id),className:"px-3 py-1.5 text-[11px] font-medium border border-amber-500/50 text-amber-500 rounded-md hover:bg-amber-500/10 disabled:opacity-50 transition-colors inline-flex items-center gap-1.5",children:[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")]})]}),O===xe.id&&s.jsxs("div",{className:"space-y-1.5",children:[s.jsx("input",{type:"text",autoFocus:!0,placeholder:m("team:notifications.adjustmentPlaceholder"),value:H[xe.id]??"",onChange:dt=>q(_t=>({..._t,[xe.id]:dt.target.value})),onKeyDown:dt=>{dt.key==="Enter"&&(H[xe.id]??"").trim()&&be(xe.id,!1,(H[xe.id]??"").trim(),"needs_adjustment"),dt.key==="Escape"&&D(null)},className:"w-full px-2.5 py-1.5 text-[11px] bg-surface-overlay border border-border-default rounded-md text-fg-primary placeholder:text-fg-tertiary focus:outline-none focus:ring-1 focus:ring-amber-500/50"}),s.jsxs("div",{className:"flex gap-2",children:[s.jsx("button",{disabled:S===xe.id||!(H[xe.id]??"").trim(),onClick:()=>be(xe.id,!1,(H[xe.id]??"").trim(),"needs_adjustment"),className:"px-2.5 py-1.5 text-[11px] font-medium bg-amber-600 text-white rounded-md hover:bg-amber-700 disabled:opacity-50 transition-colors",children:m("team:notifications.confirmAdjustment")}),s.jsx("button",{onClick:()=>D(null),className:"px-2.5 py-1.5 text-[11px] font-medium border border-border-default text-fg-secondary rounded-md hover:bg-surface-overlay transition-colors",children:m("common:cancel")})]})]})]}):s.jsxs("div",{className:"space-y-1.5",children:[s.jsx("input",{type:"text",placeholder:m("team:notifications.commentPlaceholder"),value:H[xe.id]??"",onChange:dt=>q(_t=>({..._t,[xe.id]:dt.target.value})),onKeyDown:dt=>{dt.key==="Enter"&&be(xe.id,!0,Je||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===xe.id,onClick:()=>be(xe.id,!0,Je||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===xe.id,onClick:()=>be(xe.id,!1,Je||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")})]})]})})()]},xe.id)}),Ce.length>0&&s.jsxs(s.Fragment,{children:[ae.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")}),Ce.slice(0,50).map(xe=>s.jsxs("button",{onClick:()=>Re(xe),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 ${xe.status==="approved"?"bg-green-500":xe.status==="cancelled"||xe.status==="expired"?"bg-gray-400":"bg-red-500"}`}),s.jsx("span",{className:"text-xs text-fg-secondary truncate flex-1",children:xe.title}),s.jsx("span",{className:`text-[10px] font-medium shrink-0 ${xe.status==="approved"?"text-green-500":xe.status==="cancelled"||xe.status==="expired"?"text-fg-muted":"text-red-500"}`,children:m(`common:status.${xe.status}`,{defaultValue:xe.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(xe)}),s.jsx("span",{className:"text-[10px] text-fg-muted shrink-0",children:"·"}),s.jsx("span",{className:"text-[10px] text-fg-muted shrink-0",children:Ro(xe.respondedAt??xe.requestedAt,m)})]})]},xe.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(xe=>{const nt=P4[xe.type]??"text-fg-tertiary";return s.jsxs("button",{onClick:()=>rt(xe),className:`w-full text-left px-3 py-2.5 flex gap-2.5 transition-colors ${xe.read?"opacity-50 hover:opacity-70":"hover:bg-surface-overlay"}`,children:[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:nt,children:s.jsx("path",{d:Mo[xe.type]??Mo.system})})}),s.jsxs("div",{className:"flex-1 min-w-0",children:[s.jsxs("div",{className:"flex items-center gap-1.5",children:[!xe.read&&s.jsx("span",{className:`w-1.5 h-1.5 rounded-full shrink-0 ${Ed[xe.priority]??Ed.normal}`}),s.jsx("span",{className:"text-xs text-fg-primary font-medium truncate",children:xe.title})]}),s.jsx("div",{className:"text-[11px] text-fg-tertiary mt-0.5 ",children:s.jsx(Br,{content:xe.body,className:"text-[11px] [&_h1]:text-xs [&_h2]:text-[11px] [&_h3]:text-[11px] [&_p]:text-[11px] [&_li]:text-[11px] [&_p]:text-fg-tertiary"})}),s.jsxs("div",{className:"flex items-center gap-2 mt-0.5",children:[s.jsx("span",{className:"text-[10px] text-fg-muted",children:Ro(xe.createdAt,m)}),jd(xe,m)&&s.jsx("span",{className:`text-[10px] font-medium ${nt}`,children:jd(xe,m)})]})]})]},xe.id)})})})]})})]})]})}if(i){const Y=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:J,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:Y})}),e?s.jsx("span",{className:"text-[9px] leading-tight truncate w-full text-center",children:c}):s.jsx("span",{className:"truncate",children:c}),zt>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:zt>99?m("common:badgeOverLimit"):zt})]}),f&&Da.createPortal(s.jsx("div",{ref:W,className:"fixed bg-surface-secondary border border-border-default rounded-xl shadow-2xl z-[9999] flex flex-col overflow-hidden",style:{top:re.top,left:re.left,width:re.width,maxHeight:re.maxHeight},children:pe}),document.body),$e]})}return s.jsxs(s.Fragment,{children:[Z,s.jsxs("button",{ref:J,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"})]}),zt>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:zt>99?m("common:badgeOverLimit"):zt})]}),f&&Da.createPortal(s.jsx("div",{ref:W,className:"fixed bg-surface-secondary border border-border-default rounded-xl shadow-2xl z-[9999] flex flex-col overflow-hidden",style:{top:re.top,left:re.left,width:re.width,maxHeight:re.maxHeight},children:pe}),document.body),$e]})}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 xY({authUser:e,onLogout:t,onEditProfile:n,showSettingsLink:r=!1,collapsed:i=!1,showVersion:l=!1}){const{t:c}=gt(["nav","common"]),[d,m]=k.useState(!1),[f,h]=k.useState(!1),[g,y]=k.useState(()=>lt.isAuthenticated()),[x,w]=k.useState(()=>ha()),[T,C]=k.useState(null),[S,E]=k.useState({top:0,left:0}),j=k.useRef(null),M=k.useRef(null),O=k.useCallback(te=>{if(w(ha()),!lt.isAuthenticated()){y(!1),C(null);return}if(!te?.validate){y(!0);return}Rw().then(L=>{y(L),w(ha())})},[]);k.useEffect(()=>{O({validate:!0});const te=()=>O(),L=()=>O({validate:!0});return window.addEventListener("markus:hub-auth",te),window.addEventListener("focus",L),()=>{window.removeEventListener("markus:hub-auth",te),window.removeEventListener("focus",L)}},[O]),k.useEffect(()=>{if(!d||!lt.isAuthenticated())return;let te=!1;return lt.user.plan().then(L=>{if(te)return;const ee=(L.monthlyQuotaCu??0)+(L.bonusCu??0)+(L.purchasedCu??0);C(Math.max(0,ee-(L.cuUsed??0)))}).catch(()=>{te||C(null)}),()=>{te=!0}},[d,g]);const D=k.useCallback(()=>{if(!j.current)return;const te=j.current.getBoundingClientRect(),L=window.innerWidth,ee=window.innerHeight,ue=M.current?.offsetHeight??220;let Se=te.right+8;Se+rh>L-8&&(Se=Math.max(8,te.left-rh-8));let $=te.top-ue-8;$<8&&($=Math.min(te.bottom+8,ee-ue-8)),E({top:Math.max(8,$),left:Se})},[]);k.useLayoutEffect(()=>{if(!d)return;D();const te=requestAnimationFrame(()=>D());return()=>cancelAnimationFrame(te)},[d,D,i]),k.useEffect(()=>{if(!d)return;const te=ee=>{const ue=ee.target;j.current?.contains(ue)||M.current?.contains(ue)||m(!1)},L=()=>D();return document.addEventListener("mousedown",te),window.addEventListener("resize",L),window.addEventListener("scroll",L,!0),()=>{document.removeEventListener("mousedown",te),window.removeEventListener("resize",L),window.removeEventListener("scroll",L,!0)}},[d,D]);const H=e?.name||x?.displayName||x?.username||c("common:userPlaceholder"),q=e?.email||x?.email||"",Q=Ow(e?.avatarUrl,x?.avatarUrl),B=g?"bg-emerald-500":"bg-fg-muted",J=g?x?.username?c("sidebar.hubConnectedAs",{username:x.username}):c("sidebar.hubConnected"):c("sidebar.hubDisconnected"),W=!!(g&&x?.username&&e?.name&&x.username.toLowerCase()!==e.name.toLowerCase()&&x.email?.toLowerCase()!==e.email?.toLowerCase()),re=()=>{m(!1),O({validate:!0}),it.navigate(le.SETTINGS,{tab:"account"})},F=d&&Da.createPortal(s.jsxs("div",{ref:M,className:"fixed bg-surface-elevated border border-border-default rounded-xl shadow-xl z-[9999] overflow-hidden",style:{top:S.top,left:S.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:H}),q&&s.jsx("div",{className:"text-xs text-fg-tertiary mt-0.5 truncate",children:q}),T!==null&&s.jsxs("div",{className:"text-xs text-fg-secondary mt-0.5 flex items-center gap-1",children:[s.jsx("svg",{width:"11",height:"11",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",className:"shrink-0",children:s.jsx("polyline",{points:"13 2 3 14 12 14 18 22 6 22 12 17"})}),s.jsxs("span",{className:"truncate",children:[c("common:creditBalance"),": ",T.toLocaleString()]})]})]}),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:re,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 ${B}`}),s.jsxs("span",{className:"min-w-0 flex-1",children:[s.jsx("span",{className:"text-xs text-fg-secondary block truncate",children:J}),W&&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(le.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:xc[le.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 ${i?"flex justify-center":"flex items-center justify-between gap-2 w-full"}`,children:[s.jsxs("button",{ref:j,type:"button",onClick:()=>m(te=>!te),title:H,className:`relative inline-flex items-center justify-center rounded-full transition-opacity hover:opacity-90 ${i?"p-0.5":""}`,children:[s.jsx(Ys,{name:H,avatarUrl:Q,size:i?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 ${B}`,title:J})]}),l&&!i&&s.jsxs("span",{className:"text-[10px] text-fg-muted select-none shrink-0",children:["v","0.9.9"]}),F,f&&t&&s.jsx(wr,{title:c("common:signOutConfirmTitle"),message:c("common:signOutConfirmMessage"),confirmLabel:c("common:signOut"),variant:"primary",onConfirm:()=>{h(!1),t()},onCancel:()=>h(!1)})]})}function yY({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 vY({currentPage:e,onNavigate:t,authUser:n,collapsed:r,onToggleCollapse:i,onLogout:l,keyboardFocusPageId:c,keyboardPaneActive:d}){const{t:m}=gt(["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:i,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=Aw.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===le.NOTIFICATIONS)return s.jsx(bY,{sidebarMode:!0,collapsed:r,userId:n?.id,label:m(x.id),iconPath:xc[x.id],isActive:e===x.id},x.id);const w=e===x.id,T=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 ${T?"bg-brand-500/25 ring-1 ring-inset ring-brand-500/40":w?"bg-surface-overlay":"hover:bg-surface-overlay/60"}`,children:[s.jsx(yY,{d:xc[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(xY,{authUser:n,onLogout:l,onEditProfile:()=>{window.dispatchEvent(new Event("markus:open-edit-profile"))},showSettingsLink:!1,collapsed:r,showVersion:!r})})]})}const wY=6e4;let Ks={},Ai={};const rg=new Set,ag=new Set;let f6=0,fc=null,Rd=0,Vd=null;function w0(){for(const e of rg)e()}async function sg(){try{const e=await Ee.unread.getCounts();Ks=e.counts??{},Ai=e.sessionAgentMap??{},w0()}catch{}}function kY(){fc||(sg(),fc=setInterval(sg,wY),Vd=ja.on("chat:unread_update",e=>{const t=e.payload?.conversationKey;t&&!ag.has(t)&&Date.now()>f6&&(Ks[t]=(Ks[t]??0)+1,w0())}))}function SY(){fc&&(clearInterval(fc),fc=null),Vd&&(Vd(),Vd=null)}function NY(e){const t=e?.enabled??!0,[n,r]=k.useState(Ks),[i,l]=k.useState(Ai),c=k.useCallback(async()=>{await sg()},[]),d=k.useCallback(async w=>{const T=new Date().toISOString();delete Ks[w],w0();try{await Ee.unread.markRead(w,T)}catch{}},[]),m=k.useCallback(async()=>{Ks={},w0();try{await Ee.unread.markAllRead()}catch{}},[]),f=k.useCallback(w=>{ag.add(w)},[]),h=k.useCallback(w=>{ag.delete(w),f6=Date.now()+150},[]);k.useEffect(()=>{if(!t)return;Rd++,kY();let w=Ai;const T=()=>{r({...Ks}),w!==Ai&&(w=Ai,l({...Ai}))};return rg.add(T),r({...Ks}),l({...Ai}),()=>{rg.delete(T),Rd--,Rd<=0&&(Rd=0,SY())}},[t]);const g=k.useMemo(()=>Object.values(n).reduce((w,T)=>w+T,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:i,getSessionUnread:y,getChannelUnread:x,markRead:d,markAllRead:m,refresh:c,setActiveKey:f,clearActiveKey:h}}function kQ(e,t){return k.useMemo(()=>{const n=new Map;for(const[r,i]of Object.entries(t))if(r.startsWith("session:")){const l=r.slice(8),c=e[l];c&&n.set(c,(n.get(c)??0)+i)}return n},[e,t])}function CY({currentPage:e,onNavigate:t,userId:n}){const{t:r}=gt("nav"),[i,l]=k.useState(0),{counts:c}=NY({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===le.NOTIFICATIONS,y=f.id===le.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:xc[f.id]})}),g&&i>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:i>99?"99+":i}),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 Ni(e,t){k0.has(e)||k0.set(e,t().catch(()=>{}))}function Ri(e){const t=k0.get(e);return k0.delete(e),t}const Ir={builderArtifacts:"builder.artifacts",builderAgents:"builder.agents",builderHubMyItems:"builder.hubMyItems",builderInstalled:"builder.installed",hubAgents:"hub.agents",hubTeams:"hub.teams",hubSkills:"hub.skills"},Pi={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 nl(e){const t=(e||"").toLowerCase();return t==="team"?"team":t==="skill"?"skill":t==="connector"||t==="mcp"?"connector":"agent"}function p6(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 TY={agent:258,team:205,skill:32,connector:162};function Jg(e,t){const n=TY[e],r=p6(t),i=((n+(r%68-34))%360+360)%360,l=(i+22+(r>>>8)%24)%360;return`linear-gradient(${120+r%44}deg, hsl(${i} 72% 56%), hsl(${l} 66% 43%))`}const $4=["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 h6(e){return $4[p6(e+"g")%$4.length]}function g6(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 AY(e){return!e||g6(e)?!1:[...e].length<=4&&new RegExp("\\p{Extended_Pictographic}","u").test(e)}function EY(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 Io(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 H4(e,t="usd"){return!e||e<=0?"Free":`${t.toLowerCase()==="usd"?"$":""}${(e/100).toFixed(e%100===0?0:2)}`}const U4={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"}},_Y=["development","devops","management","productivity","browser","custom","general"],jY=[{label:"Tech",emojis:["✦","◈","⬡","⚡","🤖","🧠","💡","🎯","🔧","📦","🚀","💻","🛠️","⭐","🔥","💎","⚙️","🧩","🔌","💾","🖥️","📡","🔬","🧪","🏗️","📱","🎮","🕹️","📟","💽","🖨️","⌨️"]},{label:"People",emojis:["👤","👥","🧑‍💻","👨‍💼","👩‍🔬","🧙","🦸","🤝","💪","🎓","👷","🕵️","🧑‍🎨","🧑‍🏫","👨‍🚀","🥷","🧑‍🏭","🧑‍⚕️","🧑‍🔧","🧑‍🍳","👨‍🎤","🦹","🧝","🧞","🧑‍✈️","💂","🤴","👸","🧛","🧟","🧜","🧚"]},{label:"Objects",emojis:["📝","📊","🗂️","📁","🔍","🔑","🌐","💬","🔒","🎨","📐","🗃️","📋","✏️","🖊️","📌","📎","🧲","🪝","🧰","🪜","🧬","🔭","💊","🩺","📕","📗","📘","📙","📓","🗒️","📰"]},{label:"Symbols",emojis:["❤️","🧡","💛","💚","💙","💜","🖤","🤍","♠️","♥️","♦️","♣️","🎵","🎶","💯","✅","❌","⭕","🔴","🟠","🟡","🟢","🔵","🟣","⚫","⚪","🟤","🔶","🔷","▶️","⏸️","⏹️"]},{label:"Nature",emojis:["🌟","🌈","🌊","🌿","🍀","🔮","💫","✨","🌙","☀️","🦋","🐉","🦊","🐺","🦅","🐙","🦁","🐯","🦄","🐲","🌸","🌺","🍄","🌵","🎄","🌴","🍁","🌻","🐝","🦎","🐍","🦈"]},{label:"Activity",emojis:["🎯","🏆","🥇","🎖️","🏅","🎪","🎭","🎬","🎤","🎧","🎼","🎹","🥁","🎸","🎺","🎻","⚽","🏀","🎾","🏐","🎲","🧸","🪁","🎰","🎳","🏹","🥊","🤺","⛷️","🏄","🚴","🧗"]}],MY={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:i,placeholder:l,multiline:c,readOnly:d}){if(d){const j=e||l,O=`${r??""} ${!e?"text-fg-muted italic":""}`;return n==="h1"?s.jsx("h1",{className:O,children:j}):n==="p"?s.jsx("p",{className:O,children:j}):s.jsx("span",{className:O,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)},T=j=>{j.key==="Escape"&&w(),j.key==="Enter"&&!c&&x()};if(m){const j=`bg-transparent outline-none w-full ${i??r??""} ring-1 ring-brand-500/50 rounded px-1 -mx-1`;return c?s.jsx("textarea",{ref:y,value:h,onChange:M=>g(M.target.value),onBlur:x,onKeyDown:T,className:`${j} resize-y min-h-[60px]`,placeholder:l}):s.jsx("input",{ref:y,value:h,onChange:M=>g(M.target.value),onBlur:x,onKeyDown:T,className:j,placeholder:l})}const C=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:C}):n==="p"?s.jsx("p",{onClick:()=>f(!0),className:`${r??""} ${E} ${S?"text-fg-muted italic":""}`,children:C}):n==="badge"?s.jsx("span",{onClick:()=>f(!0),className:`${r??""} ${E} ${S?"text-fg-muted italic":""}`,children:C}):s.jsx("span",{onClick:()=>f(!0),className:`${r??""} ${E} ${S?"text-fg-muted italic":""}`,children:C})}function RY({value:e,options:t,onChange:n,className:r,readOnly:i}){if(i)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 DY({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}=gt(["builder"]),[i,l]=k.useState(!1),[c,d]=k.useState(""),m=k.useRef(null);k.useEffect(()=>{i&&m.current?.focus()},[i]);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 i?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 ig({content:e}){const t=[Z5,e3,t3],n=[H3,[u3,{strict:"ignore"}],[E3,{detect:!0,ignoreMissing:!0}]],r=e6({}),i=k.useMemo(()=>Ti(e,D3),[e]);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`),Hn=Ve,fn=St),Gt===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(jh,{remarkPlugins:t,rehypePlugins:n,components:r,children:i})})}function sh({filename:e,content:t,onSave:n,embedded:r,readOnly:i}){const{t:l}=gt(["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 C=x.current;C.style.height="auto",C.style.height=Math.max(200,C.scrollHeight)+"px"}},[c,m]);const w=async()=>{g(!0),await n(m),g(!1),d(!1)},T=i?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:T}),c?s.jsx("textarea",{ref:x,value:m,onChange:C=>f(C.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(ig,{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}),T]}),c?s.jsx("textarea",{ref:x,value:m,onChange:C=>f(C.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(ig,{content:t}):s.jsx("pre",{className:"text-xs leading-relaxed text-fg-secondary whitespace-pre-wrap font-mono",children:t})})]})}const F4={"README.md":0,"ROLE.md":1,"HEARTBEAT.md":2,"POLICIES.md":3,"CONTEXT.md":4,"ANNOUNCEMENT.md":0,"NORMS.md":1};function LY(e){return[...e].sort(([t],[n])=>{const r=F4[t]??99,i=F4[n]??99;return r!==i?r-i:t.localeCompare(n)})}function S0({files:e,onSave:t,noHeader:n,readOnly:r}){const i=k.useMemo(()=>LY(e),[e]),[l,c]=k.useState(0);if(i.length===1)return n?s.jsx(sh,{filename:i[0][0],content:i[0][1],onSave:h=>t(i[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:i[0][0],content:i[0][1],onSave:h=>t(i[0][0],h),readOnly:r})]});const[d,m]=i[l]??i[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:i.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 OY({images:e,artifactType:t,artifactName:n,onUpload:r,onRemove:i,readOnly:l,cacheBust:c}){const{t:d}=gt(["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:()=>i(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 IY({members:e,teamTopFiles:t,files:n,artifactName:r,onFileSave:i,readOnly:l}){const{t:c}=gt(["builder"]),[d,m]=k.useState(0),f=k.useMemo(()=>{const C=new Set;for(const S of Object.keys(n)){const E=S.match(/^members\/([^/]+)\//);E&&C.add(E[1])}return[...C]},[n]),h=k.useMemo(()=>{const C=new Map,S=new Set;for(let M=0;M<e.length;M++){const D=e[M].slug;D&&f.includes(D)&&!S.has(D)&&(C.set(M,D),S.add(D))}for(let M=0;M<e.length;M++){if(C.has(M))continue;const O=r0(e[M].name);O&&f.includes(O)&&!S.has(O)&&(C.set(M,O),S.add(O))}for(let M=0;M<e.length;M++){if(C.has(M))continue;const O=e[M].roleName;if(O){const D=r0(O);f.includes(D)&&!S.has(D)&&(C.set(M,D),S.add(D))}}for(let M=0;M<e.length;M++){if(C.has(M))continue;const O=e[M].name;for(const D of f){if(S.has(D))continue;const H=n[`members/${D}/ROLE.md`];if(!H)continue;const q=H.match(/^#\s+(.+)$/m)?.[1]?.trim();if(q&&(q.toLowerCase().includes(O.toLowerCase())||O.toLowerCase().includes(q.toLowerCase()))){C.set(M,D),S.add(D);break}}}const E=f.filter(M=>!S.has(M));let j=0;for(let M=0;M<e.length;M++)C.has(M)||j<E.length&&(C.set(M,E[j]),j++);return C},[e,f,n]),g=k.useCallback((C,S)=>{const E=h.get(S);return E?Object.entries(n).filter(([j])=>j.startsWith(`members/${E}/`)):[]},[n,h]),y=k.useMemo(()=>{const C=[{label:c("detail.overview")}];for(const S of e)C.push({label:S.name,role:S.role});return C},[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((C,S)=>{const E=S===d,j=C.role==="manager",M=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 ${M} ${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 O=S-1,D=h.get(O),H=D?`/api/builder/artifacts/teams/${encodeURIComponent(r)}/members/${encodeURIComponent(D)}/images/avatar.jpg`:null;return H?s.jsx("img",{src:H,alt:C.label,className:`w-5 h-5 rounded-full object-cover shrink-0 ring-1 ${j?"ring-amber-500/40":"ring-blue-500/40"}`,onError:q=>{q.target.style.display="none",q.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 O=S-1;return h.get(O)?"hidden":""})()}`,children:(C.label[0]??"?").toUpperCase()})),C.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:T,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((C,S)=>{const E=C.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),M=j?`/api/builder/artifacts/teams/${encodeURIComponent(r)}/members/${encodeURIComponent(j)}/images/avatar.jpg`:null;return M?s.jsx("img",{src:M,alt:C.name,className:`w-8 h-8 rounded-full object-cover shrink-0 ring-1 ${E?"ring-amber-500/30":"ring-blue-500/30"}`,onError:O=>{O.target.style.display="none",O.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:(C.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:C.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:C.role}),C.count>1&&s.jsxs("span",{className:"text-[9px] text-fg-muted",children:["×",C.count]})]}),C.skills&&C.skills.length>0&&s.jsxs("div",{className:"flex flex-wrap gap-1 mt-1",children:[C.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)),C.skills.length>3&&s.jsxs("span",{className:"text-[9px] text-fg-muted",children:["+",C.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 C=h.get(w),S=C?`/api/builder/artifacts/teams/${encodeURIComponent(r)}/members/${encodeURIComponent(C)}/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(C=>s.jsx("span",{className:"text-[10px] px-2.5 py-1 bg-surface-elevated text-fg-muted rounded-full border border-border-default",children:C},C))}),(()=>{const C=g(x.name,w);return C.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:C.map(([S,E])=>[S.replace(/^members\/[^/]+\//,""),E]),onSave:(S,E)=>{const j=C.find(([M])=>M.endsWith(`/${S}`));j&&i(j[0],E)}})})()]}):null})]});function T(C,S){i(C,S)}}function zi({type:e,name:t,onBack:n,authUser:r,readOnly:i,initialManifest:l,actionSlot:c,contentSlot:d}){const{t:m}=gt(["builder","common"]),f=Wo(),[h,g]=k.useState(!0),[y,x]=k.useState(t),[w,T]=k.useState({}),[C,S]=k.useState(null),[E,j]=k.useState(""),[M,O]=k.useState("idle"),[D,H]=k.useState({shared:!1}),[q,Q]=k.useState(!1),[B,J]=k.useState(!1),[W,re]=k.useState(!1),[F,te]=k.useState(!1),[L,ee]=k.useState(!1),[ue,Se]=k.useState(!1),[$,G]=k.useState(null),[me,P]=k.useState(0),[_e,He]=k.useState(""),[Pe,Ge]=k.useState(""),[ut,pt]=k.useState(""),[ht,Mt]=k.useState(""),[Bt,Qt]=k.useState([]),[wt,Ue]=k.useState(""),ft=k.useRef(null),kt=k.useRef(l);kt.current=l,k.useEffect(()=>{x(t)},[t]);const Nt=k.useCallback(async()=>{const X=kt.current;if(X){S(X),He(X.displayName||X.name||t),Ge(X.description||""),pt(X.version||"1.0.0"),Mt(X.category||"general"),Qt(X.tags||[]),Ue(X.icon||""),T(X.files??{}),g(!1);return}g(!0);try{let Z=t;try{const Oe=await Ee.builder.artifacts.ensureSlugSafe(e,t);Z=Oe.name,x(Z),Oe.converted&&(history.replaceState(null,"",Oi(le.BUILDER,`${e}/${encodeURIComponent(Z)}`)),window.dispatchEvent(new CustomEvent("markus:data-changed")))}catch{x(t)}const pe=await Ee.builder.artifacts.get(e,Z);T(pe.files??{}),j(pe.path??"");const Fe=pe.files[`${e}.json`]??pe.files["agent.json"]??pe.files["team.json"]??pe.files["skill.json"];if(Fe){const Oe=JSON.parse(Fe);S(Oe),He(Oe.displayName||Oe.name||t),Ge(Oe.description||""),pt(Oe.version||"1.0.0"),Mt(Oe.category||"general"),Qt(Oe.tags||[]),Ue(Oe.icon||"")}}catch(Z){console.error("Failed to load artifact:",Z)}finally{g(!1)}},[e,t]);k.useEffect(()=>{Nt()},[Nt]),k.useEffect(()=>{l?.files&&T(l.files)},[l?.files]),k.useEffect(()=>{if(!i){try{const X=localStorage.getItem("markus_builder_shared_map");if(X){const Z=JSON.parse(X),pe=`${e}/${t}`;Z[pe]&&H({shared:!0,id:Z[pe].id,slug:Z[pe].slug,version:Z[pe].version,visibility:Z[pe].visibility??"public"})}}catch{}lt.myItems().then(X=>{const Z=X?.items??[],pe=e==="agent"?"agent":e==="team"?"team":"skill";for(const Fe of Z)if(Fe.itemType===pe&&(Fe.slug===t||Fe.name===t)){H({shared:!0,id:Fe.id,slug:Fe.slug,version:Fe.version,visibility:Fe.visibility??"public",moderationStatus:Fe.moderationStatus,pendingReview:Fe.pendingReview});return}}).catch(()=>{})}},[e,t,i]);const zt=k.useCallback(async X=>{if(!(!C||i)){O("saving");try{const Z={...C,...X};await Ee.builder.artifacts.save(e,Z),S(Z),O("saved"),setTimeout(()=>O(pe=>pe==="saved"?"idle":pe),2e3)}catch{O("error"),setTimeout(()=>O("idle"),3e3)}}},[C,e]),ce=k.useCallback(X=>{ft.current&&clearTimeout(ft.current),ft.current=setTimeout(()=>zt(X),800)},[zt]),tt=k.useCallback((X,Z)=>{const pe={};X==="displayName"?(He(Z),pe.displayName=Z,J(!0)):X==="description"?(Ge(Z),pe.description=Z,J(!0)):X==="version"?(pt(Z),pe.version=Z,J(!1),re(!1)):X==="category"?(Mt(Z),pe.category=Z,J(!0)):X==="tags"?(Qt(Z),pe.tags=Z,J(!0)):X==="icon"&&(Ue(Z),pe.icon=Z||void 0,J(!0)),ce({...C,...pe})},[C,ce]),rt=k.useCallback(async(X,Z)=>{try{const pe={...w,[X]:Z};T(pe);const Fe={...C,files:pe};await Ee.builder.artifacts.save(e,Fe),O("saved"),J(!0),setTimeout(()=>O(Oe=>Oe==="saved"?"idle":Oe),2e3)}catch{O("error")}},[w,e,C]),be=k.useCallback(async X=>{if(C){Q(!0);try{await lt.ensureAuth();const Z=await Ee.builder.artifacts.ensureSlugSafe(e,y,C.displayName||C.name||y),pe=Z.name,Fe=Z.slug||wc(pe);if(!Fe)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=Z.displayName||C.displayName||C.name||y;Z.converted&&(x(pe),S(Je=>Je&&{...Je,name:Fe,displayName:Oe}),history.replaceState(null,"",Oi(le.BUILDER,`${e}/${encodeURIComponent(pe)}`)),window.dispatchEvent(new CustomEvent("markus:data-changed")));const $e={...C,name:Fe,displayName:Oe},Y=$e.description||"",ye=$e.category||"general",Ye=$e.tags??[];let xe=$e.icon||void 0;const nt=$e.version||"1.0.0";if(xe&&!xe.startsWith("http")&&/\.(png|jpe?g|gif|webp|svg)$/i.test(xe)){const Je=xe.split("/").pop()??xe;try{const dt=await fetch(`/api/builder/artifacts/${e}s/${encodeURIComponent(pe)}/images/${encodeURIComponent(Je)}`,{cache:"no-store"});if(dt.ok){const _t=await dt.blob(),ct=new File([_t],Je,{type:_t.type}),st=await lt.uploadImage(ct);st?.url&&(xe=st.url)}}catch{}}let at;const V=[],he=$e.screenshots??[];for(let Je=0;Je<he.length;Je++){const dt=he[Je],_t=dt.split("/").pop()??dt;try{const ct=await fetch(`/api/builder/artifacts/${e}s/${encodeURIComponent(pe)}/images/${encodeURIComponent(_t)}`,{cache:"no-store"});if(ct.ok){const st=await ct.blob(),Tt=new File([st],_t,{type:st.type}),kn=await lt.uploadImage(Tt);kn?.url&&(V.push({url:kn.url,alt:_t,order:Je}),Je===0&&(at=kn.url))}}catch{}}const Ie=await lt.publishViaProxy({itemType:e==="team"?"team":e==="skill"?"skill":"agent",name:Oe,slug:Fe,description:Y,category:ye,tags:Ye,icon:xe,version:nt,config:$e,files:Object.keys(w).length>0?w:void 0,thumbnailUrl:at,images:V.length>0?V:void 0,priceCents:X?.priceCents,donationsEnabled:X?.donationsEnabled,visibility:X?.visibility,orgId:X?.orgId});Ie.id&&(H({shared:!0,id:Ie.id,slug:Ie.slug??Fe,version:nt,visibility:Ie.visibility??X?.visibility??"public",moderationStatus:Ie.moderationStatus,pendingReview:Ie.pendingReview}),J(!1),(Ie.visibility??X?.visibility??"public")!=="org"&&(Ie.moderationStatus==="pending"||Ie.pendingReview)?G({title:m("common:share"),message:Z.converted?m("share.convertedAndSubmitted",{previous:t,slug:Fe}):Ie.updated?m("share.updateSubmitted"):m("share.submittedForReview"),variant:"primary"}):Z.converted&&G({title:m("common:share"),message:m("share.convertedSlug",{previous:t,slug:Fe}),variant:"primary"}))}catch(Z){console.error("Share to Hub failed:",Z),G({title:m("common:share"),message:Z instanceof Error?Z.message:String(Z),variant:"danger"})}finally{Q(!1)}}},[C,w,e,t,y,m]),je=async X=>{const Z=new FormData;Z.append("image",X);try{await fetch(`/api/builder/artifacts/${e}s/${encodeURIComponent(y)}/images`,{method:"POST",body:Z,credentials:"include"}),await Nt(),J(!0),P(pe=>pe+1)}catch(pe){console.error("Image upload failed:",pe)}},Ae=async X=>{try{await fetch(`/api/builder/artifacts/${e}s/${encodeURIComponent(y)}/images/${encodeURIComponent(X)}`,{method:"DELETE",credentials:"include"}),await Nt(),J(!0),P(Z=>Z+1)}catch(Z){console.error("Image remove failed:",Z)}},oe=U4[e]??U4.agent,U=C?.screenshots??[],ae=C?.skill?.skillFile?w[C.skill.skillFile]:w["SKILL.md"]??w["README.md"],Ce=k.useMemo(()=>e!=="agent"?[]:Object.entries(w).filter(([X])=>!X.endsWith(".json")&&!X.startsWith("images/")&&!X.startsWith("members/")),[w,e]),Re=k.useMemo(()=>e!=="team"?[]:Object.entries(w).filter(([X])=>!X.endsWith(".json")&&!X.startsWith("images/")&&!X.startsWith("members/")),[w,e]),ze=k.useMemo(()=>{if(e==="agent"||e==="team")return[];const X=new Set;if(e==="skill"){const Z=C?.skill?.skillFile;Z&&w[Z]&&X.add(Z),!Z&&w["SKILL.md"]&&X.add("SKILL.md"),!Z&&!w["SKILL.md"]&&w["README.md"]&&X.add("README.md")}return Object.entries(w).filter(([Z])=>!Z.endsWith(".json")&&!Z.startsWith("images/")&&!Z.startsWith("members/")&&!X.has(Z))},[w,e,C?.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")})]})}):C?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(i?"common:back":"detail.backToBuilder")]}),s.jsxs("div",{className:"flex items-center gap-2",children:[!i&&M==="saving"&&s.jsx("span",{className:"text-[10px] text-fg-muted animate-pulse",children:m("detail.saving")}),!i&&M==="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")]}),!i&&M==="error"&&s.jsx("span",{className:"text-[10px] text-red-500",children:m("detail.saveFailed")}),c,!i&&D.shared&&(()=>{const X=lt.getUser(),Z=X&&D.slug?`${lt.getUrl()}/@${encodeURIComponent(X.username)}/${encodeURIComponent(D.slug)}`:null,pe=ut||C?.version||"1.0.0",Fe=D.version!==pe;return s.jsxs(s.Fragment,{children:[D.moderationStatus==="pending"?s.jsxs("span",{className:"text-xs px-2 py-1.5 rounded-lg border border-amber-500/30 text-amber-400 inline-flex items-center gap-1",title:m("share.underReviewTip"),children:[s.jsxs("svg",{className:"w-3 h-3",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[s.jsx("circle",{cx:"12",cy:"12",r:"10"}),s.jsx("polyline",{points:"12 6 12 12 16 14"})]}),m("share.underReview")]}):D.moderationStatus==="rejected"?s.jsxs("span",{className:"text-xs px-2 py-1.5 rounded-lg border border-red-500/30 text-red-400 inline-flex items-center gap-1",title:m("share.rejectedTip"),children:[s.jsxs("svg",{className:"w-3 h-3",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[s.jsx("circle",{cx:"12",cy:"12",r:"10"}),s.jsx("line",{x1:"15",y1:"9",x2:"9",y2:"15"}),s.jsx("line",{x1:"9",y1:"9",x2:"15",y2:"15"})]}),m("share.rejected")]}):D.pendingReview?s.jsxs("span",{className:"text-xs px-2 py-1.5 rounded-lg border border-amber-500/30 text-amber-400 inline-flex items-center gap-1",title:m("share.updateUnderReviewTip"),children:[s.jsxs("svg",{className:"w-3 h-3",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[s.jsx("circle",{cx:"12",cy:"12",r:"10"}),s.jsx("polyline",{points:"12 6 12 12 16 14"})]}),m("share.updateUnderReview")]}):null,Z&&s.jsxs("a",{href:Z,target:"_blank",rel:"noopener noreferrer",onClick:Oe=>{Ho()&&(Oe.preventDefault(),Xs(Z))},className:`text-xs px-3 py-1.5 rounded-lg border transition-colors inline-flex items-center gap-1.5 ${D.visibility==="org"?"border-blue-500/30 text-blue-500 hover:text-blue-400 hover:border-blue-400/50":D.visibility==="unlisted"?"border-gray-500/30 text-fg-tertiary hover:text-fg-secondary hover:border-gray-400/50":"border-green-600/30 text-green-600 hover:text-green-500 hover:border-green-500/50"}`,children:[D.visibility==="org"?s.jsxs("svg",{className:"w-3 h-3",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[s.jsx("path",{d:"M3 21h18"}),s.jsx("path",{d:"M9 8h1"}),s.jsx("path",{d:"M9 12h1"}),s.jsx("path",{d:"M9 16h1"}),s.jsx("path",{d:"M14 8h1"}),s.jsx("path",{d:"M14 12h1"}),s.jsx("path",{d:"M14 16h1"}),s.jsx("path",{d:"M5 21V5a2 2 0 0 1 2-2h10a2 2 0 0 1 2 2v16"})]}):D.visibility==="unlisted"?s.jsxs("svg",{className:"w-3 h-3",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[s.jsx("path",{d:"M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71"}),s.jsx("path",{d:"M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71"})]}):s.jsxs("svg",{className:"w-3 h-3",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[s.jsx("path",{d:"M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6"}),s.jsx("polyline",{points:"15 3 21 3 21 9"}),s.jsx("line",{x1:"10",y1:"14",x2:"21",y2:"3"})]}),D.visibility==="org"?m("visibility.sharedOrg"):D.visibility==="unlisted"?m("visibility.sharedUnlisted"):m("share.viewOnHub")]}),Fe&&s.jsx("button",{onClick:()=>{be({visibility:D.visibility})},disabled:q,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:q?m("share.updating"):m("share.updateVersion",{version:pe})})]})})(),!i&&!D.shared&&s.jsx("button",{onClick:()=>ee(!0),disabled:q,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(q?"share.sharing":"share.toHub")})]})]}),!i&&B&&!W&&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:()=>re(!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")})]}),!i&&W&&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 X=(ut||"1.0.0").split(".");return X[2]=String(Number(X[2]??0)+1),X.join(".")})(),className:"text-xs px-2 py-1 rounded bg-surface-elevated border border-border-default text-fg-primary w-24 font-mono",onKeyDown:X=>{X.key==="Enter"&&tt("version",X.target.value)}}),s.jsx("button",{onClick:X=>{const Z=X.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:()=>re(!1),className:"text-xs text-fg-tertiary hover:text-fg-secondary",children:m("common:cancel")})]}),D.shared&&s.jsx("p",{className:"text-[10px] text-fg-tertiary mt-2",children:"After bumping the version, you can share the new version to Hub."})]}),s.jsxs("div",{className:`flex gap-8 ${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:()=>!i&&Se(!ue),className:`w-16 h-16 rounded-xl ${oe.bg} flex items-center justify-center text-3xl shrink-0 ${i?"":"cursor-pointer hover:ring-2"} ${oe.ring} transition-all overflow-hidden`,children:wt&&wt.startsWith("images/")?s.jsx("img",{src:`/api/builder/artifacts/${e}s/${encodeURIComponent(y)}/images/${encodeURIComponent(wt.replace("images/",""))}?v=${me}`,alt:"",className:"w-full h-full object-cover"}):wt&&(wt.startsWith("http")||wt.startsWith("/"))?s.jsx("img",{src:wt,alt:"",className:"w-full h-full object-cover"}):(()=>{const X=wt||"";if(X&&[...X].length<=2&&new RegExp("\\p{Emoji}","u").test(X))return X;const pe=Pi[nl(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:h6(_e||t||e),fill:pe})})})()}),!i&&ue&&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:wt,onKeyDown:X=>{X.key==="Enter"&&(tt("icon",X.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 X=>{const Z=X.target.files?.[0];if(!Z)return;const pe=new FormData;pe.append("image",Z);try{const Fe=await fetch(`/api/builder/artifacts/${e}s/${encodeURIComponent(y)}/images`,{method:"POST",body:pe,credentials:"include"});if(Fe.ok){const $e=(await Fe.json()).path;if(Ue($e),Se(!1),C){const Y={...C,icon:$e};S(Y),await Ee.builder.artifacts.save(e,Y)}J(!0)}}catch{}}})]}),wt&&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:jY.map(X=>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:X.label}),s.jsx("div",{className:"flex flex-wrap gap-0.5",children:X.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 ${wt===Z?"ring-1.5 ring-brand-500 bg-brand-500/10":""}`,children:Z},Z))})]},X.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:X=>tt("displayName",X),renderAs:"h1",className:"text-xl font-bold text-fg-primary",placeholder:m("detail.untitled"),readOnly:i}),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:ut,onChange:X=>tt("version",X),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:i})]}),s.jsx(ah,{value:Pe,onChange:X=>tt("description",X),renderAs:"p",className:"text-sm text-fg-secondary mt-1.5 leading-relaxed",placeholder:m("detail.addDescription"),multiline:!0,readOnly:i}),s.jsxs("div",{className:"flex items-center gap-2 mt-2 flex-wrap",children:[s.jsx(RY,{value:ht,options:_Y,onChange:X=>tt("category",X),className:"text-xs px-2 py-0.5 rounded bg-surface-elevated text-fg-tertiary",readOnly:i}),s.jsx(DY,{tags:Bt,onChange:X=>tt("tags",X),readOnly:i})]})]})]}),s.jsx("div",{className:"mb-8",children:s.jsx(OY,{images:U,artifactType:e,artifactName:t,onUpload:je,onRemove:Ae,readOnly:i,cacheBust:me})}),d&&s.jsx("div",{className:"mb-8",children:d}),e==="team"&&C.team&&s.jsx("div",{className:"mb-8",children:s.jsx(IY,{members:C.team.members,teamTopFiles:Re,files:w,artifactName:y,onFileSave:rt,readOnly:i})}),e==="agent"&&Ce.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:Ce,onSave:rt,readOnly:i})]}),e==="skill"&&s.jsxs("div",{className:"mb-8",children:[C.skill?.requiredPermissions&&C.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:C.skill.requiredPermissions.map(X=>{const Z=MY[X];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??"?"})," ",X]},X)})})]}),C.skill?.mcpServers&&Object.keys(C.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(C.skill.mcpServers).map(([X,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:X}),s.jsx("div",{className:"text-[10px] text-fg-muted font-mono truncate",children:typeof Z=="object"?JSON.stringify(Z).slice(0,80):String(Z)})]})]},X))})]}),ae&&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(ig,{content:ae})})]})]}),ze.length>0&&s.jsx(S0,{files:ze,onSave:rt,readOnly:i})]}),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:ht})]}),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:ut})]}),C.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 C.author=="string"?C.author:C.author?.name??""})]})]})]}),e==="agent"&&C.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:[C.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:C.agent.roleName})]}),C.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:C.agent.llmProvider})]}),C.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:C.agent.llmModel})]}),C.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:C.agent.temperature})]})]})]}),e==="team"&&C.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:C.team.members.reduce((X,Z)=>X+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:C.team.members.filter(X=>X.role==="manager").reduce((X,Z)=>X+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:C.team.members.filter(X=>X.role!=="manager").reduce((X,Z)=>X+Z.count,0)})]})]})]}),e==="skill"&&C.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:[C.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:C.skill.alwaysOn?"text-green-400":"text-fg-secondary",children:C.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:C.skill.skillFile})]}),C.skill.requiredPermissions&&C.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:C.skill.requiredPermissions.map(X=>s.jsx("span",{className:"text-[10px] px-1.5 py-0.5 bg-surface-elevated text-fg-muted rounded border border-border-default",children:X},X))})]})]})]}),C.dependencies&&(C.dependencies.skills?.length||C.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")}),C.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:C.dependencies.skills.map(X=>s.jsx("span",{className:"text-[10px] px-2 py-0.5 bg-surface-elevated text-fg-secondary rounded border border-border-default",children:X},X))})]}):null,C.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:C.dependencies.env.map(X=>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:X},X))})]}):null]}):null,!i&&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/")]})]})})]})]}),!i&&F&&s.jsx(BY,{onClose:()=>te(!1),onConfirm:(X,Z)=>{te(!1),be({donationsEnabled:!1,priceCents:X==="paid"?Z:void 0})},isUpdate:D.shared}),!i&&L&&s.jsx(PY,{onClose:()=>ee(!1),onConfirm:(X,Z,pe,Fe)=>{ee(!1),be({visibility:X,orgId:Z,priceCents:pe,donationsEnabled:Fe})}}),$&&s.jsx(wr,{alertOnly:!0,variant:$.variant??"primary",title:$.title,message:$.message,onConfirm:()=>G(null),onCancel:()=>G(null)})]}):s.jsx("div",{className:"flex-1 overflow-y-auto",children:s.jsxs("div",{className:"px-6 py-8",children:[s.jsxs("button",{onClick:n,className:"text-xs text-brand-400 hover:text-brand-300 mb-4 inline-flex items-center gap-1",children:[s.jsx("svg",{className:"w-3.5 h-3.5",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:s.jsx("polyline",{points:"15 18 9 12 15 6"})}),m("detail.backToBuilder")]}),s.jsx("div",{className:"text-fg-tertiary text-sm py-20 text-center",children:m("detail.notFound")})]})})}function PY({onClose:e,onConfirm:t}){const{t:n}=gt(["builder","common"]),[r,i]=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 T=r==="public"||r==="unlisted",C=[{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:C.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:()=>i(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))})]}),T&&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:b6.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")})]})]}),T&&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,T&&g>0?g:void 0,T?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 b6=[{cents:0,label:"Free"},{cents:100,label:"$1"},{cents:500,label:"$5"},{cents:1e3,label:"$10"}];function BY({onClose:e,onConfirm:t,isUpdate:n}){const{t:r}=gt(["builder","common"]),[i,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:b6.map(c=>s.jsxs("label",{className:`flex items-center gap-3 p-3 rounded-lg border cursor-pointer transition-colors ${i===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:i===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(i>0?"paid":"free",i),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||!g6(e)?null:e.startsWith("http")||e.startsWith("data:")?e:e.startsWith("/")&&t?`${t}${e}`:e}function zY({type:e,seed:t,icon:n,hubBase:r,size:i=44,className:l="",rounded:c="rounded-xl"}){const d=nl(e),m=N0(n,r),f=k.useMemo(()=>Jg(d,t),[d,t]),h=k.useMemo(()=>h6(t),[t]),[g,y]=k.useState(!1);return m&&!g?s.jsx("img",{src:m,alt:"",onError:()=>y(!0),style:{width:i,height:i},className:`${c} object-cover shrink-0 ${l}`}):AY(n)?s.jsx("div",{style:{width:i,height:i,background:f,fontSize:i*.5},className:`${c} shrink-0 flex items-center justify-center shadow-inner ${l}`,children:s.jsx("span",{className:"drop-shadow-sm",children:n})}):n&&BW(n)?s.jsx("div",{style:{width:i,height:i,background:f},className:`${c} shrink-0 flex items-center justify-center text-white shadow-inner ${l}`,children:s.jsx(tl,{name:n,size:i*.52,className:"drop-shadow-sm"})}):s.jsx("div",{style:{width:i,height:i,background:f},className:`${c} shrink-0 flex items-center justify-center shadow-inner ${l}`,children:s.jsx("svg",{width:i*.55,height:i*.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:i=24,className:l="",verified:c}){const d=t||e||"markus",m=N0(n,r),[f,h]=k.useState(!1),g=m&&!f?m:EY(d);return s.jsxs("span",{className:`relative inline-flex shrink-0 ${l}`,style:{width:i,height:i},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:i*.42,height:i*.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 $Y({type:e,className:t=""}){const n=nl(e),r=Pi[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 q4({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 ga(e){const{type:t,name:n,description:r,seed:i,icon:l,cover:c,hubBase:d,author:m,authorLabel:f,version:h,category:g,tags:y,rating:x=0,ratingCount:w=0,downloadCount:T=0,priceCents:C,currency:S="usd",installed:E,glowing:j,selected:M,showTypeBadge:O=!0,hideStats:D=!1,cornerLabel:H,actions:q,footerLeft:Q,headerAction:B,onClick:J,className:W=""}=e,re=nl(t),F=Pi[re],te=i||n,L=(C??0)>0,ee=!!N0(c||void 0,d),ue=Jg(re,te),Se=f??m?.displayName??m?.username??"",[$,G]=k.useState(null),me=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"})})}):H?s.jsx("span",{className:"chip",children:H}):L?s.jsx("span",{className:"badge-paid",children:H4(C,S)}):null;if(ee){const P=N0(c||void 0,d);return s.jsxs("div",{onClick:J,style:{aspectRatio:$??void 0},className:`group asset-card card-shine relative flex flex-col overflow-hidden min-h-[180px] ${J?"cursor-pointer":""} ${M?"ring-1 ring-brand-500/60":""} ${j?"ring-2 ring-brand-500 shadow-lg shadow-brand-500/20":""} ${W}`,children:[s.jsx("img",{src:P,alt:"",onLoad:_e=>{const He=_e.currentTarget;He.naturalWidth&&He.naturalHeight&&G(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:O&&s.jsx($Y,{type:re})}),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"})})}):H?s.jsx("span",{className:"inline-flex items-center rounded-full bg-white/15 text-white border border-white/25 px-2 py-0.5 text-[10px] font-medium backdrop-blur-md",children:H}):B?null:s.jsx("span",{className:L?"badge-paid":"badge-free",children:H4(C,S)}),B]})]}),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))]}),(!D||q)&&s.jsxs("div",{className:"flex items-center justify-between gap-2 pt-1 shrink-0",children:[D?s.jsx("span",{}):s.jsxs("div",{className:"flex items-center gap-3 text-[11px] text-white/80",children:[s.jsxs("span",{className:"inline-flex items-center gap-1",children:[s.jsx(q4,{rating:x}),w>0&&s.jsxs("span",{className:"text-white/60",children:["(",Io(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"})}),Io(T)]})]}),q&&s.jsx("div",{className:"flex items-center gap-2",onClick:_e=>_e.stopPropagation(),children:q})]})]})]})}return s.jsxs("div",{onClick:J,className:`group asset-card card-shine relative flex flex-col ${J?"cursor-pointer":""} ${M?"ring-1 ring-brand-500/60":""} ${j?"ring-2 ring-brand-500 shadow-lg shadow-brand-500/20":""} ${W}`,children:[s.jsx("div",{className:"pointer-events-none absolute inset-x-0 top-0 h-[2px] opacity-0 group-hover:opacity-100 transition-opacity duration-300",style:{background:`linear-gradient(90deg, transparent, ${F.accent}, transparent)`}}),s.jsx("div",{className:"pointer-events-none absolute -top-10 -left-10 w-36 h-36 rounded-full blur-2xl opacity-[0.12] group-hover:opacity-20 transition-opacity duration-300",style:{background:ue}}),B&&s.jsx("div",{className:"absolute top-2.5 right-2.5 z-10",onClick:P=>P.stopPropagation(),children:B}),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(zY,{type:re,seed:te,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 ${B?"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]}),me&&s.jsx("span",{className:"ml-auto shrink-0",children:me})]}),(Se||O)&&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}),O&&s.jsxs(s.Fragment,{children:[Se&&s.jsx("span",{className:"text-fg-muted",children:"·"}),s.jsx("span",{className:"font-semibold shrink-0",style:{color:F.accent},children:F.label})]})]})]})]}),r&&s.jsx("p",{className:"text-[13px] text-fg-secondary truncate leading-snug",children:r}),(g||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=Q??(D?null:s.jsxs("span",{className:"flex items-center gap-3 text-[11px] text-fg-tertiary",children:[s.jsxs("span",{className:"inline-flex items-center gap-1",children:[s.jsx(q4,{rating:x}),s.jsx("span",{className:"text-fg-muted",children:w>0?`(${Io(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"})}),Io(T)]})]}));return!P&&!q?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}),q&&s.jsx("div",{className:"flex flex-wrap items-center gap-2 justify-end",children:q})]})})()]})]})}function Pr({children:e,maxCardWidth:t=400,gap:n="1rem",className:r=""}){const i=k.useRef(null),[l,c]=k.useState(0);k.useEffect(()=>{const h=i.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:i,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 HY(e){const t=e.indexOf(".markus/builder-artifacts/");return t>=0?"~/"+e.slice(t):e}const UY=[{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 FY(){const[e,t]=k.useState(()=>{const r=window.location.hash.slice(1).split("/");return gc(r[0])===le.BUILDER&&r[1]&&r[2]?{type:r[1],name:decodeURIComponent(r[2])}:null});return k.useEffect(()=>{const n=()=>{const i=window.location.hash.slice(1).split("/");gc(i[0])===le.BUILDER&&i[1]&&i[2]?t({type:i[1],name:decodeURIComponent(i[2])}):t(null)};return window.addEventListener("hashchange",n),()=>window.removeEventListener("hashchange",n)},[]),e}const x6="markus_builder_shared_map";function qY(){try{const e=localStorage.getItem(x6);if(!e)return new Map;const t=JSON.parse(e);return new Map(Object.entries(t))}catch{return new Map}}function Dd(e){try{localStorage.setItem(x6,JSON.stringify(Object.fromEntries(e)))}catch{}}function y6({authUser:e}={}){const{t}=gt(["builder","common"]),n=Wo(),r=FY(),[i,l]=k.useState([]),[c,d]=k.useState([]),[m,f]=k.useState(!1),[h,g]=k.useState("all"),[y,x]=k.useState(null),[w,T]=k.useState(new Map),[C,S]=k.useState(null),[E,j]=k.useState(null),[M,O]=k.useState(null),[D,H]=k.useState(qY),[q,Q]=k.useState(null),[B,J]=k.useState(null),[W,re]=k.useState(null),[F,te]=k.useState(null),[L,ee]=k.useState(null),[ue,Se]=k.useState("creations"),[$,G]=k.useState([]),[me,P]=k.useState(""),[_e,He]=k.useState([]),[Pe,Ge]=k.useState(!1),[ut,pt]=k.useState("all"),ht=k.useCallback(()=>{f(!0),Promise.all([(Ri(Ir.builderArtifacts)??Ee.builder.artifacts.list()).then(ce=>ce?.artifacts??[]).catch(()=>[]),(Ri(Ir.builderAgents)??Ee.agents.list()).then(ce=>ce?.agents??[]).catch(()=>[]),(Ri(Ir.builderHubMyItems)??lt.myItems()).then(ce=>ce?.items??[]).catch(()=>[]),(Ri(Ir.builderInstalled)??Ee.builder.artifacts.installed()).then(ce=>ce?.installed??{}).catch(()=>({}))]).then(([ce,tt,rt,be])=>{if(d(ce),l(tt),rt.length>0){const Ae=new Map;for(const oe of rt){const U=oe.itemType==="agent"?"agent":oe.itemType==="team"?"team":"skill";for(const ae of ce)ae.type===U&&(oe.slug===ae.name||oe.name===(ae.meta.displayName||ae.meta.name||ae.name))&&Ae.set(`${ae.type}/${ae.name}`,{id:oe.id,name:oe.name,slug:oe.slug||ae.name,version:oe.version||"1.0.0",visibility:oe.visibility??"public",moderationStatus:oe.moderationStatus,pendingReview:oe.pendingReview})}Ae.size>0&&H(oe=>{const U=new Map(oe);for(const[ae,Ce]of Ae)U.set(ae,Ce);return Dd(U),U})}const je=new Map;for(const Ae of ce){const oe=`${Ae.type}/${Ae.name}`,U=be[oe];U&&je.set(oe,{agentId:U.agentId,agentIds:U.agentIds,teamId:U.teamId})}T(je)}).finally(()=>f(!1))},[]);k.useEffect(()=>{ht();const ce=tt=>{tt.detail?.page===le.BUILDER&&ht()};return window.addEventListener("markus:navigate",ce),()=>window.removeEventListener("markus:navigate",ce)},[ht]);const Mt=ce=>{const tt=i.find(rt=>rt.role==="Secretary"||rt.name==="Secretary");tt?it.navigate(le.TEAM,{agentId:tt.id,prefillMessage:ce}):it.navigate(le.TEAM,{prefillMessage:ce})},Bt=async ce=>{const tt=`${ce.type}/${ce.name}`;if(!w.has(tt)){x({key:tt,action:"install"});try{const rt=await Ee.builder.artifacts.install(ce.type,ce.name),be={};rt.agent&&typeof rt.agent=="object"&&(be.agentId=rt.agent.id),rt.team&&typeof rt.team=="object"&&(be.teamId=rt.team.id),Array.isArray(rt.agents)&&(be.agentIds=rt.agents.map(je=>je.id)),T(je=>new Map(je).set(tt,be)),window.dispatchEvent(new CustomEvent("markus:data-changed"))}catch(rt){console.error("Install failed:",rt),J({title:t("common:install"),message:t("installFailed",{error:String(rt)}),variant:"danger"})}finally{x(null)}}},Qt=async ce=>{const tt=`${ce.type}/${ce.name}`;if(w.has(tt)){x({key:tt,action:"uninstall"});try{await Ee.builder.artifacts.uninstall(ce.type,ce.name),T(rt=>{const be=new Map(rt);return be.delete(tt),be}),window.dispatchEvent(new CustomEvent("markus:data-changed"))}catch(rt){console.error("Uninstall failed:",rt),J({title:t("common:uninstall"),message:t("uninstallFailed",{error:String(rt)}),variant:"danger"})}finally{x(null)}}},wt=async(ce,tt)=>{const rt=`${ce.type}/${ce.name}`;x({key:rt,action:"share"});try{const be=await Ee.builder.artifacts.ensureSlugSafe(ce.type,ce.name,ce.meta.displayName||ce.meta.name||ce.name),je=be.name,Ae=be.slug||wc(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=`${ce.type}/${je}`;be.converted&&(d(ye=>ye.map(Ye=>Ye.type===ce.type&&Ye.name===ce.name?{...Ye,name:je,path:be.path,meta:{...Ye.meta,name:je,displayName:be.displayName??Ye.meta.displayName??ce.name}}:Ye)),H(ye=>{const Ye=new Map(ye),xe=Ye.get(rt);return xe&&(Ye.delete(rt),Ye.set(oe,{...xe,slug:Ae,name:be.displayName??xe.name})),Dd(Ye),Ye}),T(ye=>{const Ye=new Map(ye),xe=Ye.get(rt);return xe&&(Ye.delete(rt),Ye.set(oe,xe)),Ye}));const U=await Ee.builder.artifacts.get(ce.type,je);let ae={...ce.meta,name:je,displayName:be.displayName??ce.meta.displayName??ce.name};try{const ye=U.files?.[`${ce.type}.json`]??U.files?.["agent.json"]??U.files?.["team.json"]??U.files?.["skill.json"];ye&&(ae={...JSON.parse(ye),...ae,name:je,displayName:ae.displayName})}catch{}const Ce=ae.displayName||ae.name||je,Re=ae.description||"",ze=ae.category||"general",X=Array.isArray(ae.tags)?ae.tags:[];let Z=ae.icon||void 0;const pe=ae.version||"1.0.0";if(Z&&!Z.startsWith("http")&&/\.(png|jpe?g|gif|webp|svg)$/i.test(Z)){const ye=Z.split("/").pop()??Z;try{const Ye=await fetch(`/api/builder/artifacts/${ce.type}s/${encodeURIComponent(je)}/images/${encodeURIComponent(ye)}`);if(Ye.ok){const xe=await Ye.blob(),nt=new File([xe],ye,{type:xe.type}),at=await lt.uploadImage(nt);at?.url&&(Z=at.url)}}catch{}}let Fe;const Oe=[],$e=Array.isArray(ae.screenshots)?ae.screenshots:[];for(let ye=0;ye<$e.length;ye++){const Ye=$e[ye],xe=Ye.split("/").pop()??Ye;try{const nt=await fetch(`/api/builder/artifacts/${ce.type}s/${encodeURIComponent(je)}/images/${encodeURIComponent(xe)}`);if(nt.ok){const at=await nt.blob(),V=new File([at],xe,{type:at.type}),he=await lt.uploadImage(V);he?.url&&(Oe.push({url:he.url,alt:xe,order:ye}),(ye===0||ae.thumbnail===Ye)&&(Fe=he.url))}}catch{}}const Y=await lt.publishViaProxy({itemType:ce.type==="team"?"team":ce.type==="skill"?"skill":"agent",name:Ce,slug:Ae,description:Re,category:ze,tags:X,icon:Z,version:pe,config:{...ae,name:je,displayName:Ce},files:U.files&&Object.keys(U.files).length>0?U.files:void 0,thumbnailUrl:Fe,images:Oe.length>0?Oe:void 0,priceCents:tt?.priceCents,donationsEnabled:tt?.donationsEnabled,visibility:tt?.visibility,orgId:tt?.orgId});Y.id&&(H(Ye=>{const xe=new Map(Ye);return xe.set(oe,{id:Y.id,name:Ce,slug:Y.slug??Ae,version:pe,visibility:Y.visibility??tt?.visibility??"public",moderationStatus:Y.moderationStatus,pendingReview:Y.pendingReview}),Dd(xe),xe}),(Y.visibility??tt?.visibility??"public")!=="org"&&(Y.moderationStatus==="pending"||Y.pendingReview)?J({title:t("common:share"),message:be.converted?t("share.convertedAndSubmitted",{previous:ce.name,slug:Ae}):Y.updated?t("share.updateSubmitted"):t("share.submittedForReview"),variant:"primary"}):be.converted&&J({title:t("common:share"),message:t("share.convertedSlug",{previous:ce.name,slug:Ae}),variant:"primary"}))}catch(be){console.error("Share failed:",be),J({title:t("common:share"),message:t("shareFailed",{error:be instanceof Error?be.message:String(be)}),variant:"danger"})}finally{x(null)}},Ue=async()=>{if(!q)return;const{key:ce}=q,tt=D.get(ce);if(Q(null),!tt)return;const rt=tt.id;x({key:ce,action:"hubDelete"});try{await lt.deleteItem(rt),H(be=>{const je=new Map(be);return je.delete(ce),Dd(je),je})}catch(be){console.error("Hub delete failed:",be),J({title:t("unshare"),message:t("hubDeleteFailed",{error:String(be)}),variant:"danger"})}finally{x(null)}},ft=async()=>{if(!C)return;const ce=C,tt=`${ce.type}/${ce.name}`;S(null),x({key:tt,action:"delete"});try{await Ee.builder.artifacts.delete(ce.type,ce.name),d(rt=>rt.filter(be=>!(be.type===ce.type&&be.name===ce.name))),T(rt=>{const be=new Map(rt);return be.delete(tt),be}),window.dispatchEvent(new CustomEvent("markus:data-changed"))}catch(rt){console.error("Delete failed:",rt)}finally{x(null)}},kt=h==="all"?c:c.filter(ce=>ce.type===h);k.useEffect(()=>{ue!=="orgAssets"||$.length>0||lt.myOrgs().then(ce=>{G(ce.memberships),ce.memberships.length>0&&!me&&P(ce.memberships[0].id)}).catch(()=>{})},[ue,$.length,me]),k.useEffect(()=>{ue!=="orgAssets"||!me||(Ge(!0),lt.browseItems({orgId:me,limit:100}).then(ce=>He(ce.items??[])).catch(()=>He([])).finally(()=>Ge(!1)))},[ue,me]);const Nt=ut==="all"?_e:_e.filter(ce=>ce.itemType===ut),zt=ce=>{history.pushState(null,"",Oi(le.BUILDER,`${ce.type}/${encodeURIComponent(ce.name)}`)),window.dispatchEvent(new HashChangeEvent("hashchange"))};return r?s.jsx(zi,{type:r.type,name:r.name,authUser:e,onBack:()=>{history.pushState(null,"",Oi(le.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:ht,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:UY.map(ce=>{const tt=t(`prompts.${ce.id}Prompt`),rt=t(`prompts.${ce.id}Examples`,{returnObjects:!0}),be=Array.isArray(rt)?rt:[];return s.jsx("button",{onClick:()=>Mt(tt),className:`group text-left w-full rounded-xl border ${ce.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 ${ce.bgColor} flex items-center justify-center shrink-0`,children:ce.icon}),s.jsxs("div",{className:"flex-1 min-w-0",children:[s.jsx("h3",{className:`text-sm font-semibold bg-gradient-to-r ${ce.color} bg-clip-text text-transparent`,children:t(`prompts.${ce.id}`)}),s.jsx("p",{className:"text-[11px] text-fg-tertiary mt-1 leading-relaxed",children:t(`prompts.${ce.id}Desc`)}),be.length>0&&s.jsx("div",{className:"mt-2 flex flex-wrap gap-1.5",children:be.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))})]})]})},ce.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 ${ue==="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 ${ue==="orgAssets"?"text-fg-primary":"text-fg-tertiary hover:text-fg-secondary"}`,children:t("orgAssets.title")})]}),ue==="creations"&&s.jsx("div",{className:"flex gap-1.5",children:["all","agent","team","skill"].map(ce=>s.jsx("button",{onClick:()=>g(ce),className:`text-xs px-2.5 py-1 rounded-lg transition-colors ${h===ce?"bg-brand-600 text-white":"text-fg-tertiary hover:text-fg-secondary hover:bg-surface-elevated"}`,children:t(ce==="all"?"myCreations.filterAll":ce==="agent"?"myCreations.filterAgents":ce==="team"?"myCreations.filterTeams":"myCreations.filterSkills")},ce))}),ue==="orgAssets"&&s.jsx("div",{className:"flex gap-1.5",children:["all","agent","team","skill"].map(ce=>s.jsx("button",{onClick:()=>pt(ce),className:`text-xs px-2.5 py-1 rounded-lg transition-colors ${ut===ce?"bg-brand-600 text-white":"text-fg-tertiary hover:text-fg-secondary hover:bg-surface-elevated"}`,children:t(ce==="all"?"myCreations.filterAll":ce==="agent"?"myCreations.filterAgents":ce==="team"?"myCreations.filterTeams":"myCreations.filterSkills")},ce))})]})}),ue==="orgAssets"&&$.length>0&&s.jsx("div",{className:"flex gap-2 mb-3 overflow-x-auto pb-1",children:$.map(ce=>s.jsx("button",{onClick:()=>P(ce.id),className:`text-xs px-3 py-1.5 rounded-full whitespace-nowrap border transition-colors ${me===ce.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:ce.name},ce.id))}),ue==="orgAssets"&&($.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")}):Nt.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(Pr,{children:Nt.map(ce=>{const tt=ce.author?.username&&ce.slug?`${lt.getUrl()}/@${encodeURIComponent(ce.author.username)}/${encodeURIComponent(ce.slug)}`:null;return s.jsx(ga,{type:ce.itemType,name:ce.name,description:ce.description,seed:ce.slug||ce.id||ce.name,icon:ce.icon,cover:ce.thumbnailUrl,hubBase:lt.getUrl(),author:ce.author,version:ce.version,rating:parseFloat(ce.avgRating)||0,ratingCount:ce.ratingCount,downloadCount:ce.downloadCount,actions:tt?s.jsxs("a",{href:tt,target:"_blank",rel:"noopener noreferrer",onClick:rt=>{rt.stopPropagation(),Ho()&&(rt.preventDefault(),Xs(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},ce.id)})})),ue==="creations"&&(m&&c.length===0?s.jsx("div",{className:"text-center text-fg-tertiary py-12 text-sm",children:t("myCreations.loadingArtifacts")}):kt.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(Pr,{children:kt.map(ce=>{const tt=ce.meta.displayName||ce.meta.name||ce.name,rt=ce.meta.description||"",be=`${ce.type}/${ce.name}`,je=y?.key===be?y.action:null,Ae=D.get(be),oe=ce.meta.version||"1.0.0",U=!!Ae,ae=U&&Ae.version!==oe,Ce=()=>{const Oe=lt.getUser();return!Ae||!Oe?null:`${lt.getUrl()}/@${encodeURIComponent(Oe.username)}/${encodeURIComponent(Ae.slug)}`},Re=U&&(Ae?.moderationStatus==="pending"||Ae?.moderationStatus==="rejected"||!!Ae?.pendingReview),ze=s.jsxs("div",{className:"flex items-center gap-1.5 justify-end",onClick:Oe=>Oe.stopPropagation(),children:[w.has(be)?s.jsxs("button",{onClick:()=>O(ce),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(ce),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")]}),U&&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")]}):U?s.jsxs(s.Fragment,{children:[ae&&s.jsxs("button",{onClick:()=>{const Oe=Ae?.visibility??"public";wt(ce,{visibility:Oe})},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:Ce()??"#",target:"_blank",rel:"noopener noreferrer",onClick:Oe=>{const $e=Ce();Ho()&&$e&&(Oe.preventDefault(),Xs($e))},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:()=>Q({key:be,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(ce.meta.screenshots)&&ce.meta.screenshots.length>0?ee(ce):re(ce)},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")]})]}),X=s.jsx("button",{onClick:()=>S(ce),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=ce.meta.icon,Fe=!!Z&&/\.(png|jpe?g|gif|webp|svg)$/i.test(Z)?Z.startsWith("http")||Z.startsWith("/")?Z:`/api/builder/artifacts/${ce.type}s/${encodeURIComponent(ce.name)}/images/${encodeURIComponent(Z.split("/").pop()??"")}?v=${ce.updatedAt??""}`:Z;return s.jsx(ga,{type:ce.type,name:tt,description:rt,seed:be,icon:Fe,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:Oe=>{Oe.stopPropagation(),Ee.system.openPath(ce.path).catch(()=>{})},className:"hover:text-fg-secondary transition-colors truncate min-w-0",title:ce.path,children:HY(ce.path)}),s.jsx("span",{className:"shrink-0",children:"·"}),s.jsx("span",{className:"shrink-0",children:new Date(ce.updatedAt).toLocaleDateString()})]}),headerAction:X,actions:ze,onClick:()=>zt(ce)},be)})})),E&&s.jsx(wr,{variant:"primary",title:t("confirmInstall"),message:t("confirmInstallMsg",{name:E.meta.displayName||E.meta.name||E.name}),confirmLabel:t("common:install"),onConfirm:()=>{const ce=E;j(null),Bt(ce)},onCancel:()=>j(null)}),M&&s.jsx(wr,{variant:"primary",title:t("confirmUninstall"),message:t("confirmUninstallMsg",{name:M.meta.displayName||M.meta.name||M.name}),confirmLabel:t("common:uninstall"),onConfirm:()=>{const ce=M;O(null),Qt(ce)},onCancel:()=>O(null)}),C&&s.jsx(wr,{title:t("confirmDeleteLocal"),message:t("deleteCannotUndo",{name:C.meta.displayName||C.meta.name||C.name}),confirmLabel:t("common:delete"),onConfirm:ft,onCancel:()=>S(null)}),q&&s.jsx(wr,{title:t("confirmUnshare"),message:t("removeFromHub",{name:q.name}),confirmLabel:t("unshare"),onConfirm:()=>{Ue()},onCancel:()=>Q(null)}),B&&s.jsx(wr,{alertOnly:!0,variant:B.variant??"primary",title:B.title,message:B.message,onConfirm:()=>J(null),onCancel:()=>J(null)}),W&&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.jsxs("div",{className:"bg-surface-secondary border border-border-default rounded-xl max-w-sm w-full mx-4 p-6 shadow-2xl",onClick:ce=>ce.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 ce=W;re(null),ee(ce)},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 ce=W;re(null),zt(ce)},className:"flex-1 text-sm px-4 py-2 rounded-lg bg-brand-600 hover:bg-brand-500 text-white transition-colors",children:t("share.addImagesFirst")})]})]})}),F&&s.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/60 backdrop-blur-sm",onClick:()=>te(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:ce=>ce.stopPropagation(),children:s.jsx(KY,{isUpdate:D.has(`${F.type}/${F.name}`),onCancel:()=>te(null),onConfirm:(ce,tt)=>{const rt=F;te(null),wt(rt,{priceCents:tt>0?tt:void 0})}})})}),L&&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.jsx("div",{className:"bg-surface-secondary border border-border-default rounded-xl max-w-sm w-full mx-4 p-6 shadow-2xl",onClick:ce=>ce.stopPropagation(),children:s.jsx(GY,{onCancel:()=>ee(null),onConfirm:(ce,tt,rt,be)=>{const je=L;ee(null),wt(je,{visibility:ce,orgId:tt,priceCents:rt,donationsEnabled:be})}})})})]})})}function GY({onCancel:e,onConfirm:t}){const{t:n}=gt(["builder","common"]),[r,i]=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 T=r==="public"||r==="unlisted",C=[{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:C.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:()=>i(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))})]}),T&&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:v6.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")})]})]}),T&&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,T&&g>0?g:void 0,T?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 v6=[{cents:0,label:"Free"},{cents:100,label:"$1"},{cents:500,label:"$5"},{cents:1e3,label:"$10"}];function KY({isUpdate:e,onCancel:t,onConfirm:n}){const{t:r}=gt(["builder","common"]),[i,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:v6.map(c=>s.jsxs("label",{className:`flex items-center gap-3 p-3 rounded-lg border cursor-pointer transition-colors ${i===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:i===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(i>0?"paid":"free",i),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 VY=Object.freeze(Object.defineProperty({__proto__:null,AgentBuilder:y6},Symbol.toStringTag,{value:"Module"}));async function w6(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 WY(e,t){const n=e.split(".").map(Number),r=t.split(".").map(Number);for(let i=0;i<Math.max(n.length,r.length);i++){const l=n[i]??0,c=r[i]??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 G4(e,t){return e.i18n?.[t]?.description||e.description}const YY={manager:"bg-brand-500/15 text-brand-500",worker:"bg-blue-500/15 text-blue-600"};function XY({authUser:e,highlightItemId:t,onHighlightDone:n}={}){const{t:r,i18n:i}=gt(["store","common"]),l=i.language,[c,d]=k.useState(""),[m,f]=k.useState([]),[h,g]=k.useState([]),[y,x]=k.useState(null),[w,T]=k.useState({}),[C,S]=k.useState(!1),[E,j]=k.useState(!0),[M,O]=k.useState(new Map),[D,H]=k.useState(new Set),[q,Q]=k.useState(null),[B,J]=k.useState(null),W=k.useCallback(async()=>{try{const[te,L]=await Promise.all([Ee.builder.artifacts.list().catch(()=>({artifacts:[]})),Ee.builder.artifacts.installed().catch(()=>({installed:{}}))]),ee=new Map;for(const ue of te.artifacts){if(ue.type!=="agent")continue;const Se=!!L.installed[`agent/${ue.name}`];ee.set(ue.name,{installed:Se,localVersion:ue.meta.version||void 0,localUpdatedAt:ue.updatedAt})}O(ee)}catch{}},[]),re=k.useCallback(async()=>{j(!0);try{const te=c?lt.search({type:"agent",q:c,limit:50}):Ri(Ir.hubAgents)??lt.search({type:"agent",limit:50}),L=new URLSearchParams;c&&L.set("q",c);const ee=fetch("/api/templates?"+L.toString()).then(G=>G.json()).catch(()=>({templates:[]})),[ue,Se]=await Promise.all([te.catch(()=>({items:[],total:0})),ee,W(),lt.isAuthenticated()?lt.purchases.mine().then(G=>H(new Set(G.purchases.map(me=>me.itemId)))).catch(()=>{}):Promise.resolve()]),$=await w6(ue?.items??[],t);g($.items),f(Array.isArray(Se.templates)?Se.templates:[]),$.missing&&n?.()}catch{f([]),g([])}finally{j(!1)}},[c,W,t,n]);k.useEffect(()=>{re()},[re]),k.useEffect(()=>{if(!y){T({});return}fetch(`/api/templates/${encodeURIComponent(y.id)}/files`,{credentials:"include"}).then(te=>te.json()).then(te=>T(te.files??{})).catch(()=>T({}))},[y]);const F=async(te,L,ee)=>{try{const ue=await fetch("/api/templates/instantiate",{method:"POST",headers:{"Content-Type":"application/json"},credentials:"include",body:JSON.stringify({templateId:te,name:L,orgId:"default",teamId:ee})});if(!ue.ok)throw new Error(`Failed: ${ue.status}`);S(!1),x(null)}catch(ue){J({title:r("common:create",{defaultValue:"Create"}),message:`Failed to create agent: ${ue}`,variant:"danger"})}};if(q)return s.jsx(zi,{type:q.type,name:q.name,onBack:()=>Q(null)});if(y){const te={type:"agent",name:y.id,displayName:T0(y,l),version:y.version,description:G4(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}},L=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 ${YY[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(ee=>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:ee},ee)),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((ee,ue)=>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 ${ee.priority==="high"?"bg-red-400":ee.priority==="medium"?"bg-amber-400":"bg-green-400"}`}),s.jsxs("div",{children:[s.jsx("div",{className:"text-sm text-fg-primary",children:ee.title}),ee.description&&s.jsx("div",{className:"text-xs text-fg-tertiary mt-0.5",children:ee.description})]})]},ue))})]})]});return s.jsxs(s.Fragment,{children:[s.jsx(zi,{type:"agent",name:y.id,onBack:()=>x(null),readOnly:!0,initialManifest:te,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:L}),C&&s.jsx(K4,{template:y,lang:l,onClose:()=>S(!1),onHire:F}),B&&s.jsx(wr,{alertOnly:!0,variant:B.variant??"danger",title:B.title,message:B.message,onConfirm:()=>J(null),onCancel:()=>J(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:te=>d(te.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((te,L)=>s.jsx("div",{className:"h-56 rounded-2xl skeleton"},L))}):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(Pr,{columns:3,children:m.map(te=>s.jsx(ga,{type:"agent",name:T0(te,l),description:G4(te,l),seed:te.id,icon:te.icon,version:te.version,category:te.category,tags:te.tags,authorLabel:te.author,hideStats:!0,showTypeBadge:!1,cornerLabel:r("agentStore.builtin"),onClick:()=>x(te)},te.id))})]}),h.length>0&&s.jsxs("section",{children:[s.jsx("h3",{className:"section-title mb-3",children:r("agentStore.markusHub")}),s.jsx(Pr,{columns:3,children:h.map(te=>s.jsx(QY,{item:te,localInfo:M.get(Ic(te)),purchased:e0(te,D),onStatusChange:W,highlight:te.id===t,onHighlightDone:n,onViewDetail:L=>Q({type:"agent",name:L})},te.id))})]})]})}),C&&y&&s.jsx(K4,{template:y,lang:l,onClose:()=>S(!1),onHire:F}),B&&s.jsx(wr,{alertOnly:!0,variant:B.variant??"danger",title:B.title,message:B.message,onConfirm:()=>J(null),onCancel:()=>J(null)})]})}function Ic(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 Di(e){return(async()=>{const t=await lt.download(e.id),n=t.name||e.name,r=t.config??{},i=Ic(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,i,t.files,c,d);else{const m={...r,...d?{version:d}:{},name:i,displayName:r.displayName||n,description:e.description,source:c};await Ee.builder.artifacts.save(l,m)}return await Ee.builder.artifacts.install(l,i),window.dispatchEvent(new CustomEvent("markus:data-changed")),n})()}async function eb(e,t){t("checking"),await lt.ensureAuth();const n=await lt.purchases.checkout(e.id);if(n.alreadyOwned)return t("installing"),await Di(e),"installed";try{if((await lt.creator.getBalance()).availableBalance>=(e.priceCents??0)){const c=await lt.purchases.payWithEarnings(e.id);if(c.ok||c.alreadyOwned)return t("installing"),await Di(e),"installed"}}catch{}if(!n.checkoutUrl)throw new Error("No checkout URL");t("checkout_opened");const r=Ho();let i=null;return r?Xs(n.checkoutUrl):i=window.open(n.checkoutUrl,"_blank","noopener"),new Promise((l,c)=>{const d=Date.now(),m=300*1e3,f=setInterval(async()=>{if(Date.now()-d>m){clearInterval(f),l("cancelled");return}const g=!r&&i?i.closed:!1;try{if((await lt.purchases.checkout(e.id)).alreadyOwned){clearInterval(f),t("installing");try{await Di(e),l("installed")}catch(x){c(x)}return}}catch{}if(g){clearInterval(f);try{if((await lt.purchases.checkout(e.id)).alreadyOwned){t("installing"),await Di(e),l("installed");return}}catch{}l("cancelled")}},2e3)})}function QY({item:e,localInfo:t,purchased:n,onStatusChange:r,highlight:i,onHighlightDone:l,onViewDetail:c}){const{t:d}=gt(["store"]),[m,f]=k.useState(!1),[h,g]=k.useState(""),y=k.useRef(null),[x,w]=k.useState(!1);k.useEffect(()=>{if(i&&y.current){y.current.scrollIntoView({behavior:"smooth",block:"center"}),w(!0);const q=setTimeout(()=>{w(!1)},4e3);return()=>clearTimeout(q)}},[i,l]);const T=t?.installed??!1,C=T&&e.version&&t?.localVersion&&WY(e.version,t.localVersion),S=(e.priceCents??0)>0,E=async q=>{if(q.stopPropagation(),!m){f(!0),g("");try{await Di(e),g(C?d("card.upgraded"):d("card.installed")+"!"),r()}catch(Q){const B=Q instanceof Error?Q.message:"";B.includes("402")||B.includes("Purchase required")?g(d("card.purchaseRequired")):g(d("card.failed"))}finally{f(!1)}}},j=async q=>{if(q.stopPropagation(),!m){f(!0),g("");try{await eb(e,B=>{B==="checkout_opened"?g(d("card.waitingPurchase","Waiting for purchase...")):B==="installing"&&g(d("card.installing"))})==="installed"?(g(d("card.installed")+"!"),r()):g("")}catch(Q){g(Q instanceof Error?Q.message:d("card.failed"))}finally{f(!1)}}},M=S?`$${((e.priceCents??0)/100).toFixed(2)}`:null,O=e.slug&&e.author?.username?`${lt.getUrl()}/@${encodeURIComponent(e.author.username)}/${encodeURIComponent(e.slug)}`:null,D=()=>{T&&c?c(Ic(e)):O&&window.open(O,"_blank","noopener,noreferrer")},H=s.jsxs(s.Fragment,{children:[C?s.jsx("button",{onClick:q=>{E(q)},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})}):T?s.jsxs("button",{onClick:q=>{E(q)},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:q=>{j(q)},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")," ",M]})}):s.jsx("button",{onClick:q=>{E(q)},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(ga,{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:T,glowing:x,onClick:D,actions:H})})}function K4({template:e,lang:t,onClose:n,onHire:r}){const{t:i}=gt(["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:i("hireModal.title")}),s.jsx("p",{className:"text-xs text-fg-tertiary",children:i("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:i("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:i("hireModal.assignTeam")}),s.jsxs("select",{value:d,onChange:w=>m(w.target.value),className:"input-field",children:[s.jsx("option",{value:"",children:i("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:i("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:i("hireModal.role")}),s.jsx("div",{className:"text-fg-secondary font-mono",children:e.roleId}),s.jsx("div",{className:"text-fg-tertiary",children:i("hireModal.position")}),s.jsx("div",{className:"text-fg-secondary capitalize",children:e.agentRole}),s.jsx("div",{className:"text-fg-tertiary",children:i("hireModal.skills")}),s.jsx("div",{className:"text-fg-secondary",children:e.skills.join(", ")||i("hireModal.none")})]})]})]}),s.jsxs("div",{className:"flex justify-end gap-3 mt-6",children:[s.jsx("button",{onClick:n,className:"btn-secondary",children:i("hireModal.cancel")}),s.jsx("button",{onClick:x,disabled:!l.trim()||g,className:"btn-primary",children:i(g?"hireModal.creating_progress":"hireModal.create")})]})]})})}function ih(e,t){const n=e.i18n?.[t];return n?.displayName||n?.name||e.name}function V4(e,t){return e.i18n?.[t]?.description||e.description}function W4(e,t,n){return e.i18n?.[n]?.members?.[t]||t}function ZY(e,t){const n=e.split(".").map(Number),r=t.split(".").map(Number);for(let i=0;i<Math.max(n.length,r.length);i++){const l=n[i]??0,c=r[i]??0;if(l>c)return!0;if(l<c)return!1}return!1}function JY({highlightItemId:e,onHighlightDone:t}={}){const{t:n,i18n:r}=gt(["store","common"]),i=r.language,[l,c]=k.useState(""),[d,m]=k.useState([]),[f,h]=k.useState([]),[g,y]=k.useState(null),[x,w]=k.useState({}),[T,C]=k.useState(!0),[S,E]=k.useState(!1),[j,M]=k.useState(null),[O,D]=k.useState(new Map),[H,q]=k.useState(new Set),[Q,B]=k.useState(null),J=k.useCallback(async()=>{try{const[F,te]=await Promise.all([Ee.builder.artifacts.list().catch(()=>({artifacts:[]})),Ee.builder.artifacts.installed().catch(()=>({installed:{}}))]),L=new Map;for(const ee of F.artifacts){if(ee.type!=="team")continue;const ue=!!te.installed[`team/${ee.name}`];L.set(ee.name,{installed:ue,localVersion:ee.meta.version||void 0,localUpdatedAt:ee.updatedAt})}D(L)}catch{}},[]),W=k.useCallback(async()=>{C(!0);try{const F=l?lt.search({type:"team",q:l,limit:50}):Ri(Ir.hubTeams)??lt.search({type:"team",limit:50}),[te,L]=await Promise.all([F.catch(()=>({items:[],total:0})),Ee.teamTemplates.list(l||void 0).catch(()=>({templates:[]})),J(),lt.isAuthenticated()?lt.purchases.mine().then(ue=>q(new Set(ue.purchases.map(Se=>Se.itemId)))).catch(()=>{}):Promise.resolve()]),ee=await w6(te?.items??[],e);h(ee.items),m(L?.templates??[]),ee.missing&&t?.()}catch{m([]),h([])}finally{C(!1)}},[l,J,e,t]);k.useEffect(()=>{W()},[W]),k.useEffect(()=>{if(!g){w({});return}fetch(`/api/team-templates/${encodeURIComponent(g.id)}/files`,{credentials:"include"}).then(F=>F.json()).then(F=>w(F.files??{})).catch(()=>w({}))},[g]);const re=async F=>{E(!0),M(null);try{const L=(await Ee.teams.create(F.name,F.description)).team.id;let ee,ue=0;const Se=[];for(const G of F.members){const me=G.count??1;for(let P=0;P<me;P++){const _e=G.name??`${F.name} Agent ${P+1}`,He=me>1?`${_e} ${P+1}`:_e,Pe=G.roleName??G.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:L,agentRole:G.role??"worker",skills:G.skills??[]})});if(Ge.ok){ue++;const ut=await Ge.json();G.role==="manager"&&!ee&&(ee=ut.agent?.id)}else{const ut=await Ge.json().catch(()=>({error:`HTTP ${Ge.status}`}));Se.push(`${He}: ${ut.error??Ge.statusText}`)}}catch(Ge){Se.push(`${He}: ${String(Ge)}`)}}}ee&&await Ee.teams.update(L,{managerId:ee,managerType:"agent"}).catch(()=>{});const $=Se.length>0?` (${Se.length} failed: ${Se[0]})`:"";M({ok:ue>0,message:`Team "${ih(F,i)}" deployed with ${ue} agent(s)${$}`})}catch(te){M({ok:!1,message:`Failed: ${te}`})}finally{E(!1)}};if(Q)return s.jsx(zi,{type:Q.type,name:Q.name,onBack:()=>B(null)});if(g){const F={...x};g.announcements&&(F["ANNOUNCEMENT.md"]=g.announcements),g.norms&&(F["NORMS.md"]=g.norms);const te={type:"team",name:g.id,displayName:ih(g,i),version:g.version,description:V4(g,i),author:g.author,category:g.category??"general",tags:g.tags??[],files:F,team:{members:g.members.map(ee=>({name:W4(g,ee.name??ee.roleName??ee.templateId??"Agent",i),role:ee.role??"worker",roleName:ee.roleName??ee.templateId,count:ee.count??1,skills:ee.skills??[]}))}},L=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((ee,ue)=>{const Se=W4(g,ee.name??ee.roleName??ee.templateId??"Agent",i);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 ${ee.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 ${ee.role==="manager"?"bg-amber-500/15 text-amber-400":"bg-blue-500/15 text-blue-400"}`,children:ee.role??"worker"}),(ee.count??1)>1&&s.jsxs("span",{className:"text-[10px] text-fg-muted",children:["×",ee.count]})]}),(ee.roleName||ee.templateId)&&s.jsx("div",{className:"text-[10px] text-fg-tertiary font-mono mt-0.5",children:ee.roleName??ee.templateId})]}),ee.skills&&ee.skills.length>0&&s.jsxs("div",{className:"flex flex-wrap gap-1 shrink-0",children:[ee.skills.slice(0,3).map($=>s.jsx("span",{className:"px-1.5 py-0.5 text-[9px] bg-surface-elevated text-fg-muted rounded border border-border-default",children:$},$)),ee.skills.length>3&&s.jsxs("span",{className:"text-[9px] text-fg-muted",children:["+",ee.skills.length-3]})]})]},ue)})})]});return s.jsx(s.Fragment,{children:s.jsx(zi,{type:"team",name:g.id,onBack:()=>{y(null),M(null)},readOnly:!0,initialManifest:te,contentSlot:L,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:()=>{re(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:F=>c(F.target.value),className:"px-3 py-1.5 bg-surface-elevated border border-border-default rounded-lg text-sm max-w-xs w-full focus:border-brand-500 focus:outline-none"})]}),s.jsx("div",{className:"flex-1 overflow-y-auto p-7 space-y-8",children:T?s.jsx("div",{className:"grid grid-cols-1 lg:grid-cols-2 gap-4",children:Array.from({length:4}).map((F,te)=>s.jsx("div",{className:"h-56 rounded-2xl skeleton"},te))}):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(Pr,{columns:2,children:d.map(F=>s.jsx(ga,{type:"team",name:ih(F,i),description:V4(F,i),seed:F.id,icon:F.icon||"users",version:F.version,category:F.category,tags:F.tags,authorLabel:F.author,hideStats:!0,showTypeBadge:!1,cornerLabel:n("teamStore.builtin"),onClick:()=>y(F)},F.id))})]}),f.length>0&&s.jsxs("section",{children:[s.jsx("h3",{className:"section-title mb-3",children:n("teamStore.markusHub")}),s.jsx(Pr,{columns:2,children:f.map(F=>s.jsx(eX,{item:F,localInfo:O.get(Ic(F)),purchased:e0(F,H),onStatusChange:J,highlight:F.id===e,onHighlightDone:t,onViewDetail:te=>B({type:"team",name:te})},F.id))})]})]})})]})}function eX({item:e,localInfo:t,purchased:n,onStatusChange:r,highlight:i,onHighlightDone:l,onViewDetail:c}){const{t:d}=gt(["store"]),[m,f]=k.useState(!1),[h,g]=k.useState(""),y=k.useRef(null),[x,w]=k.useState(!1);k.useEffect(()=>{if(i&&y.current){y.current.scrollIntoView({behavior:"smooth",block:"center"}),w(!0);const q=setTimeout(()=>{w(!1)},4e3);return()=>clearTimeout(q)}},[i,l]);const T=t?.installed??!1,C=T&&e.version&&t?.localVersion&&ZY(e.version,t.localVersion),S=(e.priceCents??0)>0,E=S?`$${((e.priceCents??0)/100).toFixed(2)}`:null,j=async q=>{if(q.stopPropagation(),!m){f(!0),g("");try{await Di(e),g(C?d("card.upgraded"):d("card.installed")+"!"),r()}catch(Q){const B=Q instanceof Error?Q.message:"";B.includes("402")||B.includes("Purchase required")?g(d("card.purchaseRequired")):g(d("card.failed"))}finally{f(!1)}}},M=async q=>{if(q.stopPropagation(),!m){f(!0),g("");try{await eb(e,B=>{B==="checkout_opened"?g(d("card.waitingPurchase","Waiting for purchase...")):B==="installing"&&g(d("card.installing"))})==="installed"?(g(d("card.installed")+"!"),r()):g("")}catch(Q){g(Q instanceof Error?Q.message:d("card.failed"))}finally{f(!1)}}},O=e.slug&&e.author?.username?`${lt.getUrl()}/@${encodeURIComponent(e.author.username)}/${encodeURIComponent(e.slug)}`:null,D=()=>{T&&c?c(Ic(e)):O&&window.open(O,"_blank","noopener,noreferrer")},H=s.jsxs(s.Fragment,{children:[C?s.jsx("button",{onClick:q=>{j(q)},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})}):T?s.jsxs("button",{onClick:q=>{j(q)},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:q=>{M(q)},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:q=>{j(q)},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(ga,{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:T,glowing:x,onClick:D,actions:H})})}function oh(e,t){return e.i18n?.[t]?.displayName||e.name}function lh(e,t){return e.i18n?.[t]?.description||e.description||""}function k6(e,t){const n=e.split(".").map(Number),r=t.split(".").map(Number);for(let i=0;i<Math.max(n.length,r.length);i++){const l=n[i]??0,c=r[i]??0;if(l>c)return!0;if(l<c)return!1}return!1}const tX={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 nX({item:e,installedSkills:t,purchased:n,onMsg:r,onRefresh:i}){const{t:l}=gt(["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&&k6(e.version,f.version),y=(e.priceCents??0)>0,[x,w]=k.useState(""),T=async()=>{if(!c){d(!0),w("");try{await Di(e),r(g?`Upgraded ${e.name}`:`Installed ${e.name}`,"success"),i()}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)}}},C=async()=>{if(!c){d(!0),w("");try{await eb(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"),i()),w("")}catch(S){r(S instanceof Error?S.message:l("card.failed"),"error"),w("")}finally{d(!1)}}};if(g)return 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",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:()=>{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 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:()=>{T()},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 Y4({item:e,installedSkills:t,purchased:n,onMsg:r,onRefresh:i,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(ga,{type:d,showTypeBadge:d!=="skill",name:e.name,description:e.description,seed:e.slug||e.name,icon:e.icon||Kd(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(nX,{item:e,installedSkills:t,purchased:n,onMsg:r,onRefresh:i})})})}function rX({highlightItemId:e,onHighlightDone:t}={}){const{t:n,i18n:r}=gt(["store","common"]),i=r.language,l=Wo(),[c,d]=k.useState("skills"),[m,f]=k.useState(null),[h,g]=k.useState(new Set),[y,x]=k.useState([]),[w,T]=k.useState(null),[C,S]=k.useState([]),[E,j]=k.useState(0),[M,O]=k.useState(1),[D,H]=k.useState([]),[q,Q]=k.useState(""),[B,J]=k.useState("score"),[W,re]=k.useState(""),[F,te]=k.useState(!1),[L,ee]=k.useState([]),[ue,Se]=k.useState(!1),[$,G]=k.useState([]),[me,P]=k.useState(""),[_e,He]=k.useState(!1),[Pe,Ge]=k.useState([]),[ut,pt]=k.useState([]),[ht,Mt]=k.useState(new Set),[Bt,Qt]=k.useState(!1),[wt,Ue]=k.useState(""),ft=[{id:"skills",labelKey:"skillStore.tabs.all"},{id:"skillhub",labelKey:"skillStore.tabs.skillhub"},{id:"skillssh",labelKey:"skillStore.tabs.skillssh"}],kt=(U,ae="success")=>{f({text:U,type:ae}),setTimeout(()=>f(null),ae==="error"?1e4:4e3)},Nt=k.useCallback(async()=>{try{const U=await Ee.skills.list();x(U.skills)}catch{}},[]),zt=k.useCallback(async()=>{Se(!0);try{const U=await Ee.skills.builtin();ee(U.skills)}catch{}Se(!1)},[]),ce=k.useCallback(async U=>{te(!0);try{const ae=await Ee.skills.registrySkillhub({q:U?.q,category:U?.category,page:U?.page??1,limit:24,sort:U?.sort??B});S(ae.skills),j(ae.total),ae.categories?.length&&H(ae.categories)}catch{}te(!1)},[B]),tt=k.useCallback(async U=>{He(!0);try{const ae=await Ee.skills.registrySkillssh(U);G(ae.skills)}catch{}He(!1)},[]),rt=k.useCallback(async U=>{Qt(!0);try{const ae=U?lt.search({type:"skill",q:U,limit:50}):Ri(Ir.hubSkills)??lt.search({type:"skill",limit:50}),Ce=lt.search({subtype:"connector",q:U||void 0,limit:50}).catch(()=>({items:[]})),[Re,ze]=await Promise.all([ae,Ce,lt.isAuthenticated()?lt.purchases.mine().then(pe=>Mt(new Set(pe.purchases.map(Fe=>Fe.itemId)))).catch(()=>{}):Promise.resolve()]);let X=Re?.items??[],Z=ze?.items??[];if(e){const pe=X.some(Oe=>Oe.id===e),Fe=Z.some(Oe=>Oe.id===e);if(!pe&&!Fe)try{const{item:Oe}=await lt.getItem(e);Oe?.subtype==="connector"?Z=[Oe,...Z]:Oe?X=[Oe,...X]:t?.()}catch{t?.()}else pe&&(X=[X.find($e=>$e.id===e),...X.filter($e=>$e.id!==e)]),Fe&&(Z=[Z.find($e=>$e.id===e),...Z.filter($e=>$e.id!==e)])}Ge(X),pt(Z)}catch{}Qt(!1)},[e,t]);k.useEffect(()=>{Nt(),zt(),ce(),tt()},[]),k.useEffect(()=>{c==="skills"&&rt(wt)},[c,wt,rt]);const be=async U=>{g(ae=>new Set(ae).add(U.name));try{const ae=await Ee.skills.install({name:U.name,source:"skillhub",slug:U.slug,sourceUrl:U.homepage,description:U.description_zh??U.description,category:"custom",version:U.version});await Nt(),kt(`"${U.name}" installed (${ae.method}) → ${ae.path}`),window.dispatchEvent(new CustomEvent("markus:data-changed"))}catch{kt(`Download failed for "${U.name}". You can try manually from: ${U.homepage}`,"error")}g(ae=>{const Ce=new Set(ae);return Ce.delete(U.name),Ce})},je=async U=>{g(ae=>new Set(ae).add(U.name));try{const ae=await Ee.skills.install({name:U.name,source:"skillssh",sourceUrl:U.url,githubRepo:`${U.author}/${U.repo}`,githubSkillPath:U.name});await Nt(),kt(`"${U.name}" installed (${ae.method}) → ${ae.path}`),window.dispatchEvent(new CustomEvent("markus:data-changed"))}catch{kt(`Download failed for "${U.name}". You can try manually from: ${U.url}`,"error")}g(ae=>{const Ce=new Set(ae);return Ce.delete(U.name),Ce})},Ae=async U=>{g(ae=>new Set(ae).add(U.name));try{const ae=await Ee.skills.install({name:U.name,source:"builtin"});await Nt(),await zt(),kt(`"${U.name}" installed (${ae.method}) → ${ae.path}`),window.dispatchEvent(new CustomEvent("markus:data-changed"))}catch(ae){kt(`Install failed for "${U.name}": ${ae}`,"error")}g(ae=>{const Ce=new Set(ae);return Ce.delete(U.name),Ce})},oe=$.filter(U=>{if(!me)return!0;const ae=me.toLowerCase();return U.name.toLowerCase().includes(ae)||U.repo.toLowerCase().includes(ae)});if(w){const U=w,ae={};U.instructions&&(ae["SKILL.md"]=U.instructions);const Ce={type:"skill",name:U.name,displayName:oh(U,i),version:U.version,description:lh(U,i),author:U.author??"",category:U.category??"general",tags:U.tags,files:ae,skill:{skillFile:U.instructions?"SKILL.md":"",requiredPermissions:U.requiredPermissions,mcpServers:void 0,alwaysOn:!1}},Re=U.installed&&U.installedVersion&&k6(U.version,U.installedVersion)?s.jsx("button",{onClick:()=>{Ae(U)},disabled:h.has(U.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(U.name)?n("card.upgrading"):n("card.upgrade",{version:U.version})}):U.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"),U.installedVersion?` v${U.installedVersion}`:""]}):s.jsx("button",{onClick:()=>{Ae(U)},disabled:h.has(U.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(U.name)?n("card.installing"):n("card.install")}),ze=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:[U.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 ${tX[U.category]??"bg-gray-500/15 text-fg-secondary"}`,children:U.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:U.version})]}),U.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"})]}),U.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:"✓"})]})]})]}),(U.requiredPermissions.length>0||U.tags.length>0)&&s.jsxs("div",{className:"space-y-4",children:[U.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:U.requiredPermissions.map(X=>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:X},X))})]}),U.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:U.tags.map(X=>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:X},X))})]})]})]});return s.jsxs(s.Fragment,{children:[s.jsx(zi,{type:"skill",name:U.name,onBack:()=>T(null),readOnly:!0,initialManifest:Ce,actionSlot:Re,contentSlot:ze}),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:ft.map(U=>s.jsx("button",{onClick:()=>d(U.id),className:`px-3 py-1.5 text-xs rounded-lg transition-colors shrink-0 ${c===U.id?"bg-brand-600 text-white":"text-fg-secondary hover:text-fg-primary hover:bg-surface-elevated"}`,children:n(U.labelKey)},U.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 U=wt.trim().toLowerCase(),ae=U?L.filter(ze=>oh(ze,i).toLowerCase().includes(U)||lh(ze,i).toLowerCase().includes(U)):L,Ce=ue&&Bt,Re=ae.length===0&&Pe.length===0&&ut.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:wt,onChange:ze=>Ue(ze.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"}`})}),Ce&&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((ze,X)=>s.jsx("div",{className:"h-56 rounded-2xl skeleton"},X))}):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:[ae.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:ae.length})})]}),s.jsx(Pr,{columns:3,children:ae.map(ze=>s.jsx(ga,{type:"skill",name:oh(ze,i),description:lh(ze,i),seed:ze.name,icon:Kd(ze.name,ze.category),version:ze.version,category:ze.category,tags:ze.tags,authorLabel:ze.author||void 0,installed:ze.installed,hideStats:!0,showTypeBadge:!1,cornerLabel:ze.installed?void 0:n("skillStore.tabs.builtin"),onClick:()=>T(ze)},ze.name))})]}),Pe.length>0&&s.jsxs("section",{children:[s.jsx("h3",{className:"section-title mb-3",children:n("skillStore.tabs.markusHub")}),s.jsx(Pr,{columns:3,children:Pe.map(ze=>s.jsx(Y4,{item:ze,installedSkills:y,purchased:e0(ze,ht),onMsg:kt,onRefresh:()=>{Nt(),rt(wt)},highlight:ze.id===e,onHighlightDone:t},ze.id))})]}),ut.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(Pr,{columns:3,children:ut.map(ze=>s.jsx(Y4,{item:ze,type:"connector",installedSkills:y,purchased:e0(ze,ht),onMsg:kt,onRefresh:()=>{Nt(),rt(wt)},highlight:ze.id===e,onHighlightDone:t},ze.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:q,onChange:U=>{Q(U.target.value),O(1),ce({q:W||void 0,category:U.target.value||void 0,page:1})},className:"px-2 py-1.5 bg-surface-elevated border border-border-default rounded-lg text-xs text-fg-secondary outline-none",children:[s.jsx("option",{value:"",children:n("skillStore.allCategories")}),D.map(U=>s.jsx("option",{value:U,children:U},U))]}),s.jsxs("select",{value:B,onChange:U=>{J(U.target.value),O(1),ce({q:W||void 0,category:q||void 0,page:1,sort:U.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:W,onChange:U=>re(U.target.value),onKeyDown:U=>{U.key==="Enter"&&(O(1),ce({q:W||void 0,category:q||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:()=>{O(1),ce({q:W||void 0,category:q||void 0,page:1})},className:"px-3 py-1.5 bg-brand-600 hover:bg-brand-500 text-white text-xs rounded-lg shrink-0",children:"Search"})]}),F?s.jsx("div",{className:"text-center text-fg-tertiary py-20",children:s.jsx("div",{className:"animate-pulse",children:n("skillStore.loadingSkillhub")})}):C.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(Pr,{columns:3,children:C.map(U=>{const ae=y.some(Ce=>Ce.name===U.name||Ce.name===U.slug);return s.jsx(ga,{type:"skill",name:U.name,description:U.description_zh??U.description??"",seed:U.slug,icon:Kd(U.slug||U.name,U.tags?.[0]),version:U.version,authorLabel:"SkillHub",showTypeBadge:!1,tags:U.tags,installed:ae,hideStats:!0,onClick:()=>window.open(U.homepage,"_blank","noopener,noreferrer"),footerLeft:s.jsxs("span",{className:"flex items-center gap-2 text-[10px] text-fg-tertiary",children:[U.stars>0&&s.jsxs("span",{className:"text-amber-600",children:["★ ",U.stars.toLocaleString()]}),U.downloads>0&&s.jsxs("span",{children:[U.downloads>=1e4?`${(U.downloads/1e4).toFixed(1)}万`:U.downloads.toLocaleString()," ",n("skillStore.downloads")]})]}),actions:ae?void 0:s.jsx("button",{onClick:()=>{be(U)},disabled:h.has(U.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(U.name)?"...":n("card.install")})},U.slug)})}),E>24&&s.jsxs("div",{className:"flex items-center justify-center gap-2 mt-6",children:[s.jsx("button",{disabled:M<=1,onClick:()=>{const U=M-1;O(U),ce({q:W||void 0,category:q||void 0,page:U})},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:M,total:Math.ceil(E/24)})}),s.jsx("button",{disabled:M>=Math.ceil(E/24),onClick:()=>{const U=M+1;O(U),ce({q:W||void 0,category:q||void 0,page:U})},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:me,onChange:U=>P(U.target.value),onKeyDown:U=>{U.key==="Enter"&&me.trim()&&tt(me)},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:()=>{me.trim()&&tt(me)},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(Pr,{columns:3,children:oe.map(U=>{const ae=y.some(Ce=>Ce.name===U.name);return s.jsx(ga,{type:"skill",name:U.name,description:U.description||"",seed:`${U.author}-${U.name}`,icon:Kd(U.name),authorLabel:`${U.author}/${U.repo}`,showTypeBadge:!1,installed:ae,hideStats:!0,cornerLabel:ae?void 0:"skills.sh",onClick:()=>window.open(U.url,"_blank","noopener,noreferrer"),footerLeft:U.installs?s.jsxs("span",{className:"text-[10px] text-fg-tertiary",children:[U.installs," installs"]}):void 0,actions:ae?void 0:s.jsx("button",{onClick:()=>{je(U)},disabled:h.has(U.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(U.name)?"...":n("card.install")})},`${U.author}-${U.name}`)})})]})]})}const aX=["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 sX({item:e,onOpen:t}){const n=nl(e.subtype==="connector"?"connector":e.itemType),r=Jg(n,e.slug||e.name),i=Pi[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 · ",i.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:["↓ ",Io(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 X4({items:e,onOpen:t}){return s.jsx(Pr,{columns:3,children:e.map(n=>s.jsx(ga,{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(Pr,{columns:3,children:Array.from({length:6}).map((e,t)=>s.jsx("div",{className:"h-64 rounded-2xl skeleton"},t))})}function iX({onOpenType:e}){const{t}=gt(["store","common"]),[n,r]=k.useState([]),[i,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(nl(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:aX.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 ${Pi[g].gradient} hover:opacity-90 transition-opacity`,children:[Pi[g].labelZh,s.jsx("span",{className:"opacity-70",children:Pi[g].label})]},g))})]}),i?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(sX,{item:g,onOpen:()=>h(g)},g.id))}):null,s.jsxs("section",{children:[s.jsx(ch,{title:t("discover.trending","热门趋势"),subtitle:t("discover.trendingSub","社区中下载与评分增长最快的资产")}),i?s.jsx(Q4,{}):d.length>0?s.jsx(X4,{items:d,onOpen:h}):s.jsx(oX,{})]}),s.jsxs("section",{children:[s.jsx(ch,{title:t("discover.fresh","新鲜上架"),subtitle:t("discover.freshSub","来自创作者的最新作品")}),i?s.jsx(Q4,{}):m.length>0?s.jsx(X4,{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," 作品 · ↓ ",Io(g.downloads)]})]},g.author?.username||y))})]})]})}function oX(){const{t:e}=gt(["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 Ld(e,t,n){return e.i18n?.[n]?.[t]}function lX(){const{t:e,i18n:t}=gt(["store","common"]),n=Wo(),r=t.language,[i,l]=k.useState([]),[c,d]=k.useState({}),[m,f]=k.useState(new Set),[h,g]=k.useState(null),[y,x]=k.useState(!0),[w,T]=k.useState(""),[C,S]=k.useState("all"),[E,j]=k.useState(null),M=k.useCallback(async()=>{x(!0);try{const[H,q,Q,B]=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:[]}))]),J={};for(const F of Q.updates)J[F.name]={availableVersion:F.availableVersion,installedVersion:F.installedVersion,displayName:F.displayName,description:F.description};d(J);const W=H.artifacts.filter(F=>{const te=`${F.type}/${F.name}`;return!!q.installed[te]}),re=new Set(W.filter(F=>F.type==="skill").map(F=>F.name));for(const F of B.skills)!F.installed||re.has(F.name)||!(q.installed[`skill/${F.name}`]||J[F.name])&&!F.updateAvailable||!q.installed[`skill/${F.name}`]&&!J[F.name]||(W.push({type:"skill",name:F.name,meta:{displayName:F.i18n?.[r]?.displayName||F.name,description:F.i18n?.[r]?.description||F.description||"",version:F.installedVersion||F.version,author:F.author,category:F.category,tags:F.tags,i18n:F.i18n},path:"",updatedAt:""}),re.add(F.name));for(const[F,te]of Object.entries(J))re.has(F)||(W.push({type:"skill",name:F,meta:{displayName:te.displayName||F,description:te.description||"",version:te.installedVersion},path:"",updatedAt:""}),re.add(F));l(W)}catch{}x(!1)},[r]);k.useEffect(()=>{M()},[M]),k.useEffect(()=>{const H=()=>{M()};return window.addEventListener("markus:data-changed",H),()=>window.removeEventListener("markus:data-changed",H)},[M]),k.useEffect(()=>{if(!h)return;const H=setTimeout(()=>g(null),3e3);return()=>clearTimeout(H)},[h]);const O=async(H,q)=>{if(!m.has(H)){f(Q=>new Set(Q).add(H));try{await Ee.skills.install({name:H,source:"builtin"});try{localStorage.removeItem("markus:template-updates-ack")}catch{}g({text:e("installedTab.updateSuccess",{name:H,version:q}),type:"success"}),window.dispatchEvent(new CustomEvent("markus:data-changed")),await M()}catch{g({text:e("installedTab.updateFailed",{name:H}),type:"error"})}f(Q=>{const B=new Set(Q);return B.delete(H),B})}},D=i.filter(H=>{if(C!=="all"&&H.type!==C)return!1;if(!w)return!0;const q=w.toLowerCase(),Q=(Ld(H.meta,"displayName",r)||H.meta.displayName||H.name).toLowerCase(),B=(Ld(H.meta,"description",r)||H.meta.description||"").toLowerCase();return Q.includes(q)||B.includes(q)}).sort((H,q)=>{const Q=H.type==="skill"&&c[H.name]?1:0;return(q.type==="skill"&&c[q.name]?1:0)-Q});return E?s.jsx(zi,{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(H=>s.jsx("button",{onClick:()=>S(H),className:`px-3 py-1 text-xs rounded-md transition-colors ${C===H?"bg-brand-600 text-white":"text-fg-secondary hover:text-fg-primary hover:bg-surface-elevated"}`,children:e(`installedTab.filter${H==="all"?"All":H==="agent"?"Agents":H==="team"?"Teams":"Skills"}`)},H))}),s.jsx("div",{className:"flex-1 min-w-[120px]",children:s.jsx("input",{type:"text",placeholder:e("installedTab.searchPlaceholder"),value:w,onChange:H=>T(H.target.value),className:"px-3 py-1.5 bg-surface-elevated border border-border-default rounded-lg text-sm w-full focus:border-brand-500 focus:outline-none"})})]}),s.jsx("div",{className:`flex-1 overflow-y-auto ${n?"p-4":"p-7"}`,children:y?s.jsx("div",{className:"text-center text-fg-tertiary py-20 animate-pulse",children:e("installedTab.loading")}):D.length===0?s.jsxs("div",{className:"text-center py-20",children:[s.jsx("div",{className:"text-4xl mb-4 opacity-30",children:"⧉"}),s.jsx("div",{className:"text-fg-secondary font-medium mb-1",children:e("installedTab.noItems")}),s.jsx("div",{className:"text-fg-tertiary text-sm",children:e("installedTab.noItemsHint")})]}):s.jsx(Pr,{columns:3,children:D.map(H=>{const q=Ld(H.meta,"displayName",r)||H.meta.displayName||H.name,Q=Ld(H.meta,"description",r)||H.meta.description||"",B=H.meta.version||"",J=H.meta.author||"",W=H.meta.tags??[],re=H.meta.category||"",F=H.meta.icon,te=F&&/\.(png|jpe?g|gif|webp|svg)$/i.test(F)&&!F.startsWith("http")&&!F.startsWith("data:")&&!F.startsWith("/")?`/api/builder/artifacts/${H.type}s/${encodeURIComponent(H.name)}/${F}`:F,L=H.type==="skill"?c[H.name]:void 0;return s.jsx(ga,{type:H.type,name:q,description:Q,seed:H.name,icon:te,author:null,authorLabel:J||void 0,version:L?L.installedVersion:B,category:re,tags:W,installed:!L,hideStats:!0,cornerLabel:L?e("installedTab.updateAvailable"):void 0,onClick:()=>{H.path&&j({type:H.type,name:H.name})},actions:L?s.jsx("button",{type:"button",disabled:m.has(H.name),onClick:()=>{O(H.name,L.availableVersion)},className:"px-3 py-1.5 text-xs font-medium bg-amber-600 hover:bg-amber-500 text-white rounded-lg disabled:opacity-50 transition-colors",children:m.has(H.name)?e("installedTab.updating"):e("installedTab.updateTo",{version:L.availableVersion})}):void 0},`${H.type}/${H.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 cX=50,uX=30;function dX(e,t,n,r){const i=k.useRef(0),l=k.useRef(0),c=k.useCallback(m=>{i.current=m.touches[0].clientX,l.current=m.touches[0].clientY},[]),d=k.useCallback(m=>{const f=m.changedTouches[0].clientX-i.current,h=m.changedTouches[0].clientY-l.current,g=Math.abs(f),y=Math.abs(h);if(g<cX||Math.atan2(y,g)*(180/Math.PI)>uX)return;if(r?.scrollContainerRef?.current){const T=r.scrollContainerRef.current,C=T.scrollLeft<=1,S=T.scrollLeft+T.clientWidth>=T.scrollWidth-1;if(f>0&&!C||f<0&&!S)return}const w=e.findIndex(T=>T.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 mX=["builder","discover","agents","teams","skills","installed"],fX={agent:"agents",team:"teams",skill:"skills",connector:"skills"};function og(e){return!!e&&mX.includes(e)}function Z4(){const e=localStorage.getItem("markus_nav_installItem"),t=localStorage.getItem("markus_nav_storeTab");return{tab:og(t)?t:"builder",installId:e}}function pX({authUser:e}){const{t}=gt(["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(Z4),[i,l]=k.useState(r.tab),[c,d]=k.useState(r.installId),m=dX(n,i,l);k.useEffect(()=>{const h=Z4();h.installId&&(d(h.installId),og(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");og(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(fX[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(Bw,{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 ${i===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:[i==="builder"&&s.jsx(y6,{authUser:e}),i==="discover"&&s.jsx(iX,{onOpenType:f}),i==="agents"&&s.jsx(XY,{authUser:e,highlightItemId:c,onHighlightDone:()=>d(null)}),i==="teams"&&s.jsx(JY,{highlightItemId:c,onHighlightDone:()=>d(null)}),i==="skills"&&s.jsx(rX,{highlightItemId:c,onHighlightDone:()=>d(null)}),i==="installed"&&s.jsx(lX,{})]})]})}const J4="usageType",uh="profile";function hX({onComplete:e,theme:t,onThemeChange:n,skipProfile:r,onProfileUpdated:i}){const{t:l}=gt(["onboarding","common"]),[c,d]=k.useState(0),[m,f]=k.useState(""),[h,g]=k.useState(""),[y,x]=k.useState(""),[w,T]=k.useState(""),[C,S]=k.useState(!1),[E,j]=k.useState(""),[M,O]=k.useState(!1),[D,H]=k.useState(null);k.useEffect(()=>{Ee.auth.me().then(({user:Ue})=>{Ue.name&&f(Ue.name),Ue.email&&g(Ue.email),Ue.avatarUrl&&H(Ue.avatarUrl);const ft=Ue.name||Ue.email?.split("@")[0]||"";ft&&J(kt=>kt||l("usageType.defaultOrgName",{name:ft}))}).catch(()=>{}),Ee.settings.getOrg().then(({org:Ue})=>{Ue?.name&&Ue.name!=="My Organization"&&J(Ue.name)}).catch(()=>{}),En()&&Ee.hubOrgs.invitations().then(Ue=>{Ue.invitations?.length>0&&Se(Ue.invitations)}).catch(()=>{})},[]);const[q,Q]=k.useState(null),[B,J]=k.useState(""),[W,re]=k.useState(!1),[F,te]=k.useState(!1),[L,ee]=k.useState(""),[ue,Se]=k.useState([]),[$,G]=k.useState(null),[me,P]=k.useState(null),_e=async()=>{const Ue=B.trim();if(Ue){re(!0),ee("");try{if(await Ee.settings.updateOrg(Ue),En()){const ft=await Ee.hubOrgs.mine(),kt=ft.orgs?.find(Nt=>Nt.role==="owner")??ft.orgs?.[0];kt?.id?await Ee.hubOrgs.update(kt.id,{name:Ue}):await Ee.hubOrgs.create(Ue)}te(!0)}catch{ee(l("usageType.orgNameSaveFailed"))}finally{re(!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),i?.(Ue),O(!0)}catch{j(l("profile.errors.saveFailed"))}finally{S(!1)}},ut=[{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")}],pt=[{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(T8,{i18nKey:"welcome.description",ns:"onboarding",components:{strong:s.jsx("strong",{className:"text-fg-primary"})}})})},{id:J4,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:()=>{Q("personal"),te(!0)},className:`flex flex-col items-center gap-3 rounded-xl border-2 p-5 transition-all text-left ${q==="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:()=>{Q("organization"),te(!1)},className:`flex flex-col items-center gap-3 rounded-xl border-2 p-5 transition-all text-left ${q==="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."})})]})]})]}),q==="organization"&&s.jsxs("div",{className:"space-y-4 mt-4",children:[ue.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")}),ue.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()=>{G(Ue.orgId);try{await Ee.hubOrgs.acceptInvitation(Ue.orgId),P(Ue.orgId),te(!0)}catch{}finally{G(null)}},disabled:$===Ue.orgId||me===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:me===Ue.orgId?l("usageType.accepted"):$===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:B,onChange:Ue=>{J(Ue.target.value),te(!1),ee("")},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"})]}),L&&s.jsx("p",{className:"text-xs text-red-500",children:L}),s.jsx("button",{onClick:()=>{_e()},disabled:W||!B.trim()||F,className:"w-full px-4 py-2.5 bg-brand-600 hover:bg-brand-500 disabled:opacity-40 text-white text-sm rounded-xl transition-colors",children:l(W?"common:saving":F?"usageType.orgNameSaved":"usageType.setOrgName")})]})]})},{id:uh,title:l("profile.title"),subtitle:l("profile.subtitle"),content:M?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(Pw,{currentUrl:D,name:m,size:64,targetType:"user"})}),s.jsxs("div",{className:"space-y-1",children:[s.jsxs("label",{className:"text-xs text-fg-tertiary font-medium",children:[l("profile.nameLabel")," ",s.jsx("span",{className:"text-red-500",children:"*"})]}),s.jsx("input",{type:"text",value:m,onChange: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=>T(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:C||!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(C?"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:ut.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")})]})]})}],ht=r?pt.filter(Ue=>Ue.id!==uh):pt,Mt=ht.findIndex(Ue=>Ue.id===J4),Bt=ht.findIndex(Ue=>Ue.id===uh),Qt=()=>{c===Mt&&Mt>=0&&!q||c===Mt&&q==="organization"&&!F||c===Bt&&Bt>=0&&!M||(c<ht.length-1?d(c+1):(fetch("/api/settings/telemetry",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({enabled:He})}).catch(()=>{}),e()))},wt=ht[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:ht.map((Ue,ft)=>s.jsx("div",{className:`h-1 flex-1 rounded-full transition-colors ${ft<=c?"bg-brand-500":"bg-surface-elevated"}`},ft))}),s.jsx("h2",{className:"text-2xl font-bold text-fg-primary",children:wt.title}),s.jsx("p",{className:"text-sm text-fg-secondary mt-1 mb-6",children:wt.subtitle}),wt.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:Qt,disabled:Bt>=0&&c===Bt&&!M||Mt>=0&&c===Mt&&(!q||q==="organization"&&!F),className:`px-6 py-2.5 text-white text-sm rounded-xl transition-colors ${Bt>=0&&c===Bt&&!M||Mt>=0&&c===Mt&&(!q||q==="organization"&&!F)?"bg-brand-600/40 cursor-not-allowed":"bg-brand-600 hover:bg-brand-500"}`,children:c===ht.length-1?l("getStarted"):l("common:next")})]})]})})})}const ew="markus:legal-consent",gX="https://markus.global";function bX({onLogin:e,hasOwner:t}){const{t:n,i18n:r}=gt("auth"),[i,l]=k.useState(null),[c,d]=k.useState(""),[m,f]=k.useState(!1),[h,g]=k.useState(""),[y,x]=k.useState(""),[w,T]=k.useState(!1),[C,S]=k.useState(!1),E=J=>{const W=(r.language||"").toLowerCase().startsWith("zh")?"?lang=zh":"";return`${gX}${J}${W}`},j=()=>{try{localStorage.setItem(ew,JSON.stringify({acceptedAt:new Date().toISOString(),terms:!0,privacy:!0}))}catch{}},M=()=>C?(j(),!0):(T(!1),requestAnimationFrame(()=>T(!0)),!1),O=async()=>{const J=En(),W=ha();if(!J||!W){d(n("login.hubUnavailable"));return}const re=await Ee.auth.hubLogin(J,W);if(window.markusDesktop?.clearPendingDeepLinkAuth?.(),re.cloudAiReady===!1)try{sessionStorage.setItem("markus:cloud-ai-warning",re.cloudAiError?n("login.cloudAiNotReady",{error:re.cloudAiError}):n("login.cloudAiNotReadyGeneric"))}catch{}e(re.user,re.needsOnboarding??!1,{fromHub:!0})},D=async(J,W=!1)=>{if(!(!W&&!M())){d(""),l(J??"hub");try{if(W&&En()&&ha()){await O();return}await Qr(J),await O()}catch(re){const F=re instanceof Error?re.message:"";if(!F.includes("cancelled")){if(!W&&En())return D(J,!0);d(F||n("login.hubUnavailable"))}}finally{l(null)}}},H=()=>{oI(),l(null),d("")};k.useEffect(()=>{const J=window.markusDesktop;if(!J?.peekPendingDeepLinkAuth&&!J?.consumePendingDeepLinkAuth)return;let W=!1;return(async()=>{const re=J.peekPendingDeepLinkAuth?await J.peekPendingDeepLinkAuth():null;if(W||!re)return;let F=!1;try{F=!!localStorage.getItem(ew)}catch{}if(!C&&!F){d(n("login.consentRequired"));return}F&&!C&&S(!0),j();const te=J.consumePendingDeepLinkAuth?await J.consumePendingDeepLinkAuth():re;if(!(W||!te)){d(""),l("hub");try{if(!await iI(te)||!En()||!ha()){d(n("login.hubUnavailable"));return}await O()}catch{d(n("login.hubUnavailable"))}finally{W||l(null)}}})().catch(()=>{}),()=>{W=!0}},[C]);const q=async J=>{if(J.preventDefault(),!(!h.trim()||!y)&&M()){d(""),l("local");try{const{user:W,needsOnboarding:re}=await Ee.auth.login(h.trim(),y);e(W,re??!1)}catch{d(n("login.invalidCredentials"))}finally{l(null)}}},Q=n(t?"login.welcomeBack":"login.getStarted"),B="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:Q})]}),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:q,className:"space-y-3",children:[s.jsx("input",{type:"email",value:h,onChange:J=>g(J.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:J=>x(J.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:i==="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(i==="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:()=>D("google"),disabled:!!i,className:B,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(i==="google"?"login.connectingHub":"login.withGoogle")]}),s.jsxs("button",{onClick:()=>D("github"),disabled:!!i,className:B,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(i==="github"?"login.connectingHub":"login.withGithub")]}),s.jsxs("button",{onClick:()=>D("email"),disabled:!!i,className:B,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(i==="email"?"login.connectingHub":"login.withEmail")]}),i&&(i==="google"||i==="github"||i==="email"||i==="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:H,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:!!i,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:()=>T(!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:C,onChange:J=>{S(J.target.checked),J.target.checked&&T(!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 xX({token:e,onComplete:t}){const{t:n}=gt("auth"),[r,i]=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),[T,C]=k.useState(!1);k.useEffect(()=>{Ee.auth.inviteInfo(e).then(E=>i(E)).catch(()=>C(!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:T?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 yX({onComplete:e,isFirstTime:t}){const{t:n}=gt("auth"),[r,i]=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=>i(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 vX({side:e,defaultWidth:t,minWidth:n,maxWidth:r,collapsedWidth:i=0,storageKey:l}){const[c,d]=k.useState(()=>{try{const T=localStorage.getItem(`${l}_w`);if(T)return Math.max(n,Math.min(r,parseInt(T,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(T=>Math.max(n,Math.min(r,T)))},[n,r]);const x=k.useCallback(T=>{T.preventDefault(),h.current=!0;const C=T.clientX,S=c,E=M=>{if(!h.current)return;const O=M.clientX-C;d(Math.max(g.current,Math.min(y.current,S+O)))},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(T=>!T),[]);return{width:m?i:c,rawWidth:c,collapsed:m,toggle:w,setCollapsed:f,setWidth:d,onResizeStart:x}}const SQ=[{value:"system",label:"System"},{value:"light",label:"Light"},{value:"dark",label:"Dark"},{value:"cyberpunk",label:"Cyberpunk"},{value:"mono",label:"Mono"}],lg="markus-theme";function tw(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 wX(){try{const e=localStorage.getItem(lg);if(e==="midnight")return localStorage.setItem(lg,"dark"),"dark";if(e==="light"||e==="dark"||e==="system"||e==="cyberpunk"||e==="mono")return e}catch{}return"system"}function kX(){const[e,t]=k.useState(wX),n=k.useCallback(r=>{t(r);try{localStorage.setItem(lg,r)}catch{}tw(r)},[]);return k.useEffect(()=>{tw(e)},[e]),{mode:e,setMode:n}}const Wd={agents:[],tasks:[],requirements:[],projects:[],deliverables:[],workflows:[]},SX={team:["agents","workflows","tasks","requirements","projects","deliverables"],work:["workflows","projects","requirements","tasks","agents","deliverables"],deliverables:["deliverables","agents","tasks","requirements","projects","workflows"]},NX=["agents","tasks","requirements","projects","deliverables","workflows"];let nw="",rw="all",aw=Wd,sw=!1;function CX({onClose:e,currentPage:t}){const{t:n}=gt(["common","home","work"]);Vo(!0);const[r,i]=k.useState(nw),[l,c]=k.useState(rw),[d,m]=k.useState(aw),[f,h]=k.useState(!1),[g,y]=k.useState(sw),[x,w]=k.useState(-1);k.useEffect(()=>{nw=r},[r]),k.useEffect(()=>{rw=l},[l]),k.useEffect(()=>{aw=d},[d]),k.useEffect(()=>{sw=g},[g]);const T=k.useRef(null),C=k.useRef(void 0),S=k.useRef(null),E=k.useRef(null);k.useEffect(()=>{setTimeout(()=>{T.current?.focus(),T.current?.select()},100)},[]);const j=k.useCallback(async re=>{if(!re.trim()){m(Wd),y(!1),w(-1);return}h(!0),y(!0),w(-1);const F=re.toLowerCase();try{const[te,L,ee,ue,Se,$]=await Promise.allSettled([Ee.agents.list(),Ee.tasks.list({search:re,pageSize:20}),Ee.requirements.list(),Ee.projects.list(),Ee.deliverables.search({q:re,limit:20}),Ee.teams.list()]),G=te.status==="fulfilled"?te.value.agents.filter(Ge=>Ge.name?.toLowerCase().includes(F)||Ge.role?.toLowerCase().includes(F)):[],me=L.status==="fulfilled"?L.value.tasks:[],P=ee.status==="fulfilled"?ee.value.requirements.filter(Ge=>Ge.title?.toLowerCase().includes(F)||Ge.description?.toLowerCase().includes(F)):[],_e=ue.status==="fulfilled"?ue.value.projects.filter(Ge=>Ge.name?.toLowerCase().includes(F)||Ge.description?.toLowerCase().includes(F)):[],He=Se.status==="fulfilled"?Se.value.results:[],Pe=[];if($.status==="fulfilled"){const Ge=await Promise.allSettled($.value.teams.map(ut=>Ee.workflows.list(ut.id)));for(const ut of Ge)if(ut.status==="fulfilled")for(const pt of ut.value.workflows)(pt.name.toLowerCase().includes(F)||(pt.displayName||"").toLowerCase().includes(F)||pt.description?.toLowerCase().includes(F))&&Pe.push(pt)}m({agents:G,tasks:me,requirements:P,projects:_e,deliverables:He,workflows:Pe})}catch{m(Wd)}finally{h(!1)}},[]),M=re=>{i(re),C.current&&clearTimeout(C.current),C.current=setTimeout(()=>j(re),400)},O=k.useCallback((re,F)=>{e(),it.navigate(re,F)},[e]),D=[{id:"all",label:n("common:all",{defaultValue:"全部"})},{id:"agents",label:n("common:agents",{defaultValue:"智能体"})},{id:"tasks",label:n("common:tasks",{defaultValue:"任务"})},{id:"requirements",label:n("common:requirements",{defaultValue:"需求"})},{id:"projects",label:n("common:projects",{defaultValue:"项目"})},{id:"deliverables",label:n("common:deliverables",{defaultValue:"交付物"})},{id:"workflows",label:n("common:workflows",{defaultValue:"工作流"})}],H=k.useMemo(()=>SX[t||""]||NX,[t]),q=k.useMemo(()=>{const re=[],F=l==="all"?8:void 0,te=L=>{if(l!=="all"&&l!==L)return;const ee=d[L].length;if(L==="workflows"){const ue=F?d.workflows.slice(0,F):d.workflows;for(const Se of ue)re.push({id:Se.name,type:"workflow",page:le.WORK,params:{boardType:"workflows"}})}else{const ue=d[L],Se=F?ue.slice(0,F):ue;for(const $ of Se)switch(L){case"agents":re.push({id:$.id,type:"agent",page:le.TEAM,params:{agentId:$.id}});break;case"tasks":re.push({id:$.id,type:"task",page:le.WORK,params:{openTask:$.id}});break;case"requirements":re.push({id:$.id,type:"requirement",page:le.WORK,params:{openRequirement:$.id}});break;case"projects":re.push({id:$.id,type:"project",page:le.WORK,params:{projectId:$.id}});break;case"deliverables":re.push({id:$.id,type:"deliverable",page:le.DELIVERABLES,params:{openDeliverable:$.id}});break}}F&&ee>F&&re.push({id:`more_${L}`,type:"showMore",page:"",expandCategory:L,totalCount:ee})};for(const L of H)te(L);return re},[d,l,H]),Q=k.useCallback(re=>{if(re.type==="showMore"&&re.expandCategory){c(re.expandCategory),w(-1);return}O(re.page,re.params)},[O]);k.useEffect(()=>{const re=E.current;if(!re||x<0)return;const F=re.querySelector(`[data-idx="${x}"]`);F&&F.scrollIntoView({block:"nearest"})},[x]);const B=k.useCallback(re=>{if(re.key==="Escape"){e();return}if(re.key==="Tab"){re.preventDefault();const L=D.map(Se=>Se.id),ee=L.indexOf(l),ue=re.shiftKey?ee<=0?L.length-1:ee-1:ee>=L.length-1?0:ee+1;c(L[ue]),w(-1);return}const F=re.ctrlKey&&re.key==="n"||re.key==="ArrowDown",te=re.ctrlKey&&re.key==="p"||re.key==="ArrowUp";if(F||te){re.preventDefault(),w(L=>{const ee=q.length-1;return ee<0?-1:F?L>=ee?0:L+1:L<=0?ee:L-1});return}re.key==="Enter"&&(re.preventDefault(),x>=0&&x<q.length&&Q(q[x]))},[e,q,x,Q,D,l]);k.useEffect(()=>(document.addEventListener("keydown",B),()=>document.removeEventListener("keydown",B)),[B]);const J=q.length>0;let W=0;return s.jsx("div",{ref:S,className:"fixed inset-0 bg-black/50 flex items-start justify-center z-50 pt-[8vh]",onClick:re=>{re.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:T,value:r,onChange:re=>M(re.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:()=>{i(""),m(Wd),y(!1),w(-1),T.current?.focus()},className:"absolute right-3 top-1/2 -translate-y-1/2 text-fg-tertiary hover:text-fg-secondary",children:s.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[s.jsx("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),s.jsx("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]})})]}),s.jsx("div",{className:"flex gap-1 overflow-x-auto scrollbar-hide",children:D.map(re=>s.jsx("button",{onClick:()=>{c(re.id),w(-1)},className:`px-3 py-1.5 text-xs rounded-lg whitespace-nowrap transition-colors ${l===re.id?"bg-brand-600 text-white":"bg-surface-elevated text-fg-secondary hover:text-fg-primary"}`,children:re.label},re.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&&!J&&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&&J&&s.jsx("div",{className:"space-y-4",children:H.map(re=>{if(l!=="all"&&l!==re)return null;const F=l==="all"?8:void 0,te=L=>{const ee=W++,ue=L==="agents"?d.agents.length:L==="tasks"?d.tasks.length:L==="requirements"?d.requirements.length:L==="projects"?d.projects.length:L==="workflows"?d.workflows.length:d.deliverables.length;return s.jsxs("button",{"data-idx":ee,onClick:()=>{c(L),w(-1)},className:`mt-1 w-full text-xs py-1.5 rounded-lg transition-colors ${ee===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:"查看全部"})," (",ue,")"]})};return re==="agents"&&d.agents.length>0?s.jsxs("section",{children:[s.jsx("h3",{className:"text-xs font-medium text-fg-tertiary uppercase mb-2",children:n("common:agents",{defaultValue:"智能体"})}),s.jsx("div",{className:"space-y-0.5",children:(F?d.agents.slice(0,F):d.agents).map(L=>{const ee=W++;return s.jsxs("button",{"data-idx":ee,onClick:()=>O(le.TEAM,{agentId:L.id}),className:`w-full flex items-center gap-3 px-3 py-2 rounded-xl transition-colors text-left ${ee===x?"bg-brand-600/15 ring-1 ring-brand-500/40":"hover:bg-surface-overlay"}`,children:[s.jsx(Ys,{name:L.name||"Agent",avatarUrl:L.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:L.name}),s.jsx("div",{className:"text-xs text-fg-tertiary truncate",children:L.role||L.status})]}),s.jsx(TX,{status:L.status})]},L.id)})}),F&&d.agents.length>F&&te("agents")]},"agents"):re==="tasks"&&d.tasks.length>0?s.jsxs("section",{children:[s.jsx("h3",{className:"text-xs font-medium text-fg-tertiary uppercase mb-2",children:n("common:tasks",{defaultValue:"任务"})}),s.jsx("div",{className:"space-y-0.5",children:(F?d.tasks.slice(0,F):d.tasks).map(L=>{const ee=W++;return s.jsxs("button",{"data-idx":ee,onClick:()=>O(le.WORK,{openTask:L.id}),className:`w-full flex items-center gap-3 px-3 py-2 rounded-xl transition-colors text-left ${ee===x?"bg-brand-600/15 ring-1 ring-brand-500/40":"hover:bg-surface-overlay"}`,children:[s.jsx(AX,{status:L.status}),s.jsxs("div",{className:"flex-1 min-w-0",children:[s.jsx("div",{className:"text-sm text-fg-primary truncate",children:L.title}),s.jsxs("div",{className:"text-xs text-fg-tertiary truncate",children:[L.status," · ",L.priority||""]})]})]},L.id)})}),F&&d.tasks.length>F&&te("tasks")]},"tasks"):re==="requirements"&&d.requirements.length>0?s.jsxs("section",{children:[s.jsx("h3",{className:"text-xs font-medium text-fg-tertiary uppercase mb-2",children:n("common:requirements",{defaultValue:"需求"})}),s.jsx("div",{className:"space-y-0.5",children:(F?d.requirements.slice(0,F):d.requirements).map(L=>{const ee=W++;return s.jsxs("button",{"data-idx":ee,onClick:()=>O(le.WORK,{openRequirement:L.id}),className:`w-full flex items-center gap-3 px-3 py-2 rounded-xl transition-colors text-left ${ee===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 ${L.status==="approved"?"text-green-500 bg-green-500/15":L.status==="pending"?"text-amber-500 bg-amber-500/15":L.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:L.title}),s.jsxs("div",{className:"text-xs text-fg-tertiary truncate",children:[L.status," · ",L.priority||""]})]})]},L.id)})}),F&&d.requirements.length>F&&te("requirements")]},"requirements"):re==="projects"&&d.projects.length>0?s.jsxs("section",{children:[s.jsx("h3",{className:"text-xs font-medium text-fg-tertiary uppercase mb-2",children:n("common:projects",{defaultValue:"项目"})}),s.jsx("div",{className:"space-y-0.5",children:(F?d.projects.slice(0,F):d.projects).map(L=>{const ee=W++;return s.jsxs("button",{"data-idx":ee,onClick:()=>O(le.WORK,{projectId:L.id}),className:`w-full flex items-center gap-3 px-3 py-2 rounded-xl transition-colors text-left ${ee===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:L.name}),L.description&&s.jsx("div",{className:"text-xs text-fg-tertiary truncate",children:L.description})]})]},L.id)})}),F&&d.projects.length>F&&te("projects")]},"projects"):re==="deliverables"&&d.deliverables.length>0?s.jsxs("section",{children:[s.jsx("h3",{className:"text-xs font-medium text-fg-tertiary uppercase mb-2",children:n("common:deliverables",{defaultValue:"交付物"})}),s.jsx("div",{className:"space-y-0.5",children:(F?d.deliverables.slice(0,F):d.deliverables).map(L=>{const ee=W++;return s.jsxs("button",{"data-idx":ee,onClick:()=>O(le.DELIVERABLES,{openDeliverable:L.id}),className:`w-full flex items-center gap-3 px-3 py-2 rounded-xl transition-colors text-left ${ee===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:L.title}),s.jsxs("div",{className:"text-xs text-fg-tertiary truncate",children:[L.type," · ",L.status]})]})]},L.id)})}),F&&d.deliverables.length>F&&te("deliverables")]},"deliverables"):re==="workflows"&&d.workflows.length>0?s.jsxs("section",{children:[s.jsx("h3",{className:"text-xs font-medium text-fg-tertiary uppercase mb-2",children:n("common:workflows",{defaultValue:"工作流"})}),s.jsx("div",{className:"space-y-0.5",children:(F?d.workflows.slice(0,F):d.workflows).map(L=>{const ee=W++;return s.jsxs("button",{"data-idx":ee,onClick:()=>O(le.WORK,{boardType:"workflows"}),className:`w-full flex items-center gap-3 px-3 py-2 rounded-xl transition-colors text-left ${ee===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:L.displayName||L.name}),s.jsxs("div",{className:"text-xs text-fg-tertiary truncate",children:[L.stepCount," steps · v",L.version]})]})]},L.name)})}),F&&d.workflows.length>F&&te("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 TX({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 AX({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 EX=[{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 _X(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 jX(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 iw(e){return e instanceof HTMLElement?e.closest(".xterm")!==null:!1}const MX=["layout","navigation","tasks","team","search","rightPanel","terminal","help"];function RX(e){return e===le.TEAM?"team":e===le.WORK?"work":e===le.DELIVERABLES?"deliverables":e===le.STORE?"store":"any"}function DX({open:e,onClose:t,page:n}){const{t:r}=gt("common"),i=typeof navigator<"u"&&navigator.platform.toUpperCase().includes("MAC"),l=RX(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:MX.map(c=>{const d=EX.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:_X(m.keys,i,m.bare)})]},m.id))})]},c)})})]})}):null}function LX({authUser:e,onClose:t,onSaved:n,onUserUpdated:r}){const{t:i}=gt("common");Vo(!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(()=>Ow(e.avatarUrl,ha()?.avatarUrl)),T=async C=>{if(C.preventDefault(),!l.trim()){y(i("profile.nameRequired"));return}if(d&&!/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(d.trim())){y(i("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(i("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:T,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:"text-base font-semibold mb-5",children:i("profile.editProfile")}),s.jsx("div",{className:"flex justify-center mb-5",children:s.jsx(Pw,{currentUrl:x,name:l,size:72,targetType:"user",targetId:e.id,onUploaded:C=>{w(C),r?.({...e,avatarUrl:C})}})}),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:i("profile.name")}),s.jsx("input",{value:l,onChange:C=>c(C.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:i("profile.email")}),s.jsx("input",{value:d,onChange:C=>m(C.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:i("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:i(f?"saving":"save")})]})]})})}const ow=k.lazy(()=>ta(()=>import("./Team-ADpT-bid.js"),__vite__mapDeps([2,3,4,5,6])).then(e=>({default:e.TeamPage}))),lw=k.lazy(()=>ta(()=>import("./Settings-DaeT2xjy.js"),[]).then(e=>({default:e.Settings}))),OX=k.lazy(()=>ta(()=>import("./Store-BjE_14dA.js"),[]).then(e=>({default:e.StorePage}))),IX=k.lazy(()=>ta(()=>Promise.resolve().then(()=>VY),void 0).then(e=>({default:e.AgentBuilder}))),cw=k.lazy(()=>ta(()=>import("./Work-BjU-XvpG.js"),__vite__mapDeps([7,4,1,8,3,9])).then(e=>({default:e.WorkPage}))),uw=k.lazy(()=>ta(()=>import("./Deliverables-PJJKw5_I.js"),__vite__mapDeps([10,4,5])).then(e=>({default:e.DeliverablesPage}))),PX=k.lazy(()=>ta(()=>import("./Notifications-DqIUg4CJ.js"),[]).then(e=>({default:e.NotificationsPage}))),BX=k.lazy(()=>ta(()=>import("./Search-kas6fpbv.js"),[]).then(e=>({default:e.SearchPage}))),zX={visibility:"hidden",position:"absolute",inset:0,pointerEvents:"none",zIndex:-1};function $X(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 HX(){return s.jsx("div",{className:"flex-1 flex items-center justify-center text-fg-tertiary text-sm animate-pulse",children:"Loading..."})}const UX=k.memo(function({id:t,activePage:n,children:r}){const i=t===n;return s.jsx("div",{className:"flex-1 overflow-hidden flex flex-col",style:i?void 0:zX,children:s.jsx(k.Suspense,{fallback:s.jsx(HX,{}),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}),Od={};function S6(e){return typeof window<"u"&&window.matchMedia("(max-width: 767px)").matches?Tw[e]??e:e}function dw(){return S6(bc())}function FX(){const{t:e}=gt("common"),[t,n]=k.useState(dw),[r,i]=k.useState(!1),[l,c]=k.useState(!0),d=Wo(),m=kX(),f=vX({side:"left",defaultWidth:160,minWidth:140,maxWidth:400,collapsedWidth:64,storageKey:"markus_sidebar"}),[h,g]=k.useState(()=>new Set([dw()])),[y,x]=k.useState("loading"),[w,T]=k.useState(!1),[C,S]=k.useState(null),[E,j]=k.useState({hasOwner:!1,hasMultipleUsers:!1}),[M,O]=k.useState(!1),[D,H]=k.useState(!1),[q,Q]=k.useState(null),[B,J]=k.useState(!1),[W,re]=k.useState(null),[F,te]=k.useState(()=>{const X=localStorage.getItem("markus_update_dismissed");return X||null}),[L,ee]=k.useState(!1),[ue,Se]=k.useState(!1),$=Oc(),G=$?.leftCollapsed??!1,me=$?.toggleLeftCollapsed,P=$?.setLeftCollapsed,_e=$?.keyboardPane??"l0",He=$?.setKeyboardPane,Pe=$?.l0FocusPageId??null,Ge=$?.setL0FocusPageId,ut=k.useRef(t);ut.current=t;const pt=k.useRef(le.HOME),ht=$?.toggleRightPanel,Mt=$?.toggleTerminalPanel,Bt=$?.cycleRightPanelTab,Qt=$?.activateRightPanelTabAt,wt=$?.openNewRightPanelTab,Ue=$?.rightPanelOpen??!1,ft=$?.activeRightPanelTabId??null,kt=$?.openRightPanel,Nt=$?.closeRightPanelTab,zt=$?.updateRightPanelBrowserTab,ce=$?.updateRightPanelTerminalTab,tt=k.useRef($?.rightPanelTabs);tt.current=$?.rightPanelTabs,k.useEffect(()=>{const X=window.markusDesktop?.browser?.onPageEvent;if(!(!X||!kt))return X(Z=>{if(Z.type==="closed"){const pe=tt.current?.find(Fe=>Fe.payload.kind==="url"&&Fe.payload.browserId===Z.browserId);pe&&Nt&&Nt(pe.id);return}if(Z.type==="navigated"){if(Z.url&&yc(Z.url))return;Z.browserId&&zt&&zt(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_")||cV(Z.browserId)||Z.url&&yc(Z.url))return;kt({kind:"url",url:Z.url||"about:blank",title:Z.title||Z.url||"Browser",browserId:Z.browserId,pageId:Z.pageId})}})},[kt,Nt,zt]),k.useEffect(()=>{const X=window.markusDesktop?.terminal?.onEvent;if(!(!X||!kt))return X(Z=>{if(Z.type==="closed"){const pe=tt.current?.find(Fe=>Fe.payload.kind==="terminal"&&Fe.payload.terminalId===Z.id);pe&&Nt&&Nt(pe.id);return}if(Z.type==="cwd"){Z.cwd&&ce?.(Z.id,{cwd:Z.cwd});return}if(Z.type==="selected"){(Z.title||Z.cwd)&&ce?.(Z.id,{title:Z.title,cwd:Z.cwd});return}if(Z.type==="opened"){if(Yg.has(Z.id)){(Z.title||Z.cwd)&&ce?.(Z.id,{title:Z.title,cwd:Z.cwd});return}ji(Z.id),kt({kind:"terminal",terminalId:Z.id,title:Z.title||"Terminal",cwd:Z.cwd})}})},[kt,Nt,ce]);const rt=$?.handleTerminalExit;k.useEffect(()=>{const X=window.markusDesktop?.terminal?.onExit;if(!(!X||!rt))return X(Z=>{rt(Z.id)})},[rt]),k.useLayoutEffect(()=>{const X=t===le.TEAM&&Ue&&$?.rightPanelMode==="browser";up(X)},[t,Ue,$?.rightPanelMode]),k.useEffect(()=>{window.markusDesktop?.browser?.hideAll?.()},[]);const be=k.useRef(!1);k.useEffect(()=>{if(!be.current){be.current=!0;return}f.setCollapsed(G)},[G,f.setCollapsed]),k.useEffect(()=>{if(d)return;const X=navigator.platform.toUpperCase().includes("MAC"),Z=Fe=>{X&&Fe.metaKey&&!Fe.ctrlKey&&Fe.key==="p"?(Fe.preventDefault(),ee(Oe=>!Oe)):!X&&Fe.ctrlKey&&!Fe.metaKey&&Fe.key==="p"&&(Fe.preventDefault(),ee(Oe=>!Oe))},pe=()=>ee(!0);return document.addEventListener("keydown",Z),window.addEventListener("markus:open-search",pe),()=>{document.removeEventListener("keydown",Z),window.removeEventListener("markus:open-search",pe)}},[d]);const je=k.useCallback(()=>!Ue||!ft||!Nt?!1:(Nt(ft),!0),[Ue,ft,Nt]);k.useEffect(()=>{const X=window.markusDesktop?.onAppShortcut?.(Z=>{if(Z.type==="close-tab"){je();return}Z.type==="new-tab"&&wt?.()});return()=>{X?.()}},[je,wt]),k.useEffect(()=>{if(d||!me||!ht)return;const X=navigator.platform.toUpperCase().includes("MAC"),Z=pe=>{if(!(X?pe.metaKey&&!pe.ctrlKey:pe.ctrlKey&&!pe.metaKey)||pe.altKey)return;if(!pe.shiftKey&&(pe.key==="/"||pe.code==="Slash")){pe.preventDefault(),Se($e=>!$e);return}if(pe.shiftKey&&(pe.key==="?"||pe.key==="/")){pe.preventDefault(),Se($e=>!$e);return}if(pe.shiftKey&&Ue&&Bt){if(pe.key==="]"||pe.code==="BracketRight"){pe.preventDefault(),Bt(1);return}if(pe.key==="["||pe.code==="BracketLeft"){pe.preventDefault(),Bt(-1);return}}if(!pe.shiftKey&&Ue&&Qt){const $e=pe.key>="1"&&pe.key<="9"?Number(pe.key):0;if($e>=1){pe.preventDefault(),Qt($e-1);return}}if(pe.shiftKey)return;const Oe=pe.key.toLowerCase();if(Oe==="w"){pe.preventDefault(),pe.stopPropagation(),je();return}if(Oe==="t"){pe.preventDefault(),wt?.();return}if(Oe==="b"){if(t===le.DELIVERABLES)return;pe.preventDefault(),me()}else if(t===le.TEAM&&Oe==="l"){if(!X&&iw(pe.target)||X&&iw(pe.target)&&pe.ctrlKey)return;pe.preventDefault(),ht()}else t===le.TEAM&&Oe==="j"&&Mt&&(pe.preventDefault(),Mt())};return document.addEventListener("keydown",Z,!0),()=>document.removeEventListener("keydown",Z,!0)},[d,t,me,ht,Mt,Bt,Qt,Ue,je,wt]);const Ae=k.useCallback((X,Z)=>{let pe=gc(X);d?pe=Tw[pe]??pe:pe===le.NOTIFICATIONS&&(pe=le.HOME),pe!==le.TEAM&&up(!1);const Fe=bc(),Oe=window.location.hash.slice(1);Oe!==hh(Fe)?Od[Fe]=Oe:delete Od[Fe];const $e=ut.current;if(pe===le.SETTINGS&&$e!==le.SETTINGS&&(pt.current=$e,it.setSettingsReturnPage($e),He?.("l1"),Ge?.(le.SETTINGS)),$e===le.SETTINGS&&pe!==le.SETTINGS&&(He?.("l0"),Ge?.(pe)),pe===le.SETTINGS&&Z?.tab){const ye=`settings/${Z.tab}`;Od[pe]=ye,history.pushState(null,"","#"+ye),window.dispatchEvent(new HashChangeEvent("hashchange")),n(pe),g(Ye=>Ye.has(pe)?Ye:new Set([...Ye,pe]));return}const Y=pe!==le.WORK?Od[pe]:void 0;Y&&Y!==hh(pe)?(history.pushState(null,"",Oi(pe)),history.pushState(null,"","#"+Y)):history.pushState(null,"",Oi(pe)),window.dispatchEvent(new HashChangeEvent("hashchange")),n(pe),g(ye=>ye.has(pe)?ye:new Set([...ye,pe]))},[d,He,Ge]);k.useEffect(()=>{it.setHandler((X,Z)=>Ae(X,Z))},[Ae]),k.useEffect(()=>{_e==="l0"&&t!==le.SETTINGS&&Ge?.(t)},[_e,t,Ge]),k.useEffect(()=>{if(d||!He||!Ge)return;const X=Z=>{if(Z.metaKey||Z.ctrlKey||Z.altKey||jX(Z.target))return;const pe=Z.key.length===1?Z.key.toLowerCase():Z.key;if(t===le.SETTINGS&&(pe==="h"||pe==="ArrowLeft")){Z.preventDefault(),Z.stopImmediatePropagation(),it.leaveSettings();return}if(_e!=="l0"||t===le.SETTINGS)return;const Fe=Pe&&Co.includes(Pe)?Pe:t,Oe=Math.max(0,Co.indexOf(Fe));if(pe==="j"||pe==="ArrowDown"){Z.preventDefault(),Z.stopImmediatePropagation();const $e=Co[Math.min(Co.length-1,Oe+1)];Ge($e),$e!==t&&Ae($e),requestAnimationFrame(()=>{document.querySelector(`[data-l0-page-id="${$e}"]`)?.scrollIntoView({block:"nearest"})});return}if(pe==="k"||pe==="ArrowUp"){Z.preventDefault(),Z.stopImmediatePropagation();const $e=Co[Math.max(0,Oe-1)];Ge($e),$e!==t&&Ae($e),requestAnimationFrame(()=>{document.querySelector(`[data-l0-page-id="${$e}"]`)?.scrollIntoView({block:"nearest"})});return}if(pe==="l"||pe==="ArrowRight"||pe==="Enter"){const $e=Pe&&Co.includes(Pe)?Pe:t;if(!XO.has($e)){Z.preventDefault(),Z.stopImmediatePropagation();return}Z.preventDefault(),Z.stopImmediatePropagation(),$e!==t&&Ae($e),P?.(!1),He("l1");return}(pe==="h"||pe==="ArrowLeft")&&(Z.preventDefault(),Z.stopImmediatePropagation())};return document.addEventListener("keydown",X,!0),()=>document.removeEventListener("keydown",X,!0)},[d,_e,Pe,t,Ae,He,Ge,P]),k.useEffect(()=>{const X=()=>T(!0);return window.addEventListener("markus:open-edit-profile",X),()=>window.removeEventListener("markus:open-edit-profile",X)},[]),k.useEffect(()=>{if(!window.markusDesktop)return;!d&&t!==le.SETTINGS&&!f.collapsed?window.markusDesktop.setTrafficLightPosition(16,16):window.markusDesktop.setTrafficLightPosition(6,16)},[f.collapsed,t,d]),k.useEffect(()=>{window.markusDesktop&&window.markusDesktop.onNotificationClick(X=>{if(X.openNotifications&&window.dispatchEvent(new CustomEvent("markus:open-notifications")),X.page){const Z=gc(X.page);X.params&&Object.entries(X.params).forEach(([pe,Fe])=>localStorage.setItem(`markus_nav_${pe}`,Fe)),Ae(Z),window.dispatchEvent(new CustomEvent("markus:navigate",{detail:{page:Z,params:X.params}}))}})},[Ae]);const oe=k.useCallback(()=>{fetch("/api/settings/llm").then(X=>X.ok?X.json():null).then(X=>{if(X?.providers){const Z=Object.values(X.providers).some(pe=>pe.configured);Q(Z)}}).catch(()=>{})},[]),U=k.useCallback((X,Z)=>{if(!X)return;const Fe=Z&&{agent:"agents",team:"teams",skill:"skills"}[Z]||"agents";localStorage.setItem("markus_nav_installItem",X),localStorage.setItem("markus_nav_storeTab",Fe);const Oe=new URLSearchParams(window.location.search);Oe.get("install")||(Oe.set("install",X),Z&&Oe.set("type",Z));const $e=Oe.toString();window.history.replaceState(null,"",`${window.location.pathname}?${$e}${Oi(le.STORE)}`);const Y=()=>it.navigate(le.STORE,{storeTab:Fe,installItem:X});Y(),setTimeout(Y,500),setTimeout(Y,1500)},[]);k.useEffect(()=>{const X=new URLSearchParams(window.location.search),Z=X.get("install");Z&&U(Z,X.get("type"));const pe=window.markusDesktop;pe?.onDeepLinkInstall?.(({id:$e,type:Y})=>U($e,Y)),pe?.consumePendingDeepLinkInstall?.().then($e=>{$e?.id&&U($e.id,$e.type)}),Ee.auth.me().then(({user:$e})=>{x($e),S(!0),i(!1),$e.preferences?.guideHidden===!0&&!yh($e.id)&&vh($e.id),$X($e),ja.connect($e.id),oe(),Ee.health().then(ye=>{ye.updateAvailable&&ye.latestVersion&&re({latestVersion:ye.latestVersion,currentVersion:ye.version})}).catch(()=>{});const Y=()=>{Ni(Ir.builderArtifacts,()=>Ee.builder.artifacts.list()),Ni(Ir.builderAgents,()=>Ee.agents.list()),Ni(Ir.builderHubMyItems,()=>lt.myItems()),Ni(Ir.builderInstalled,()=>Ee.builder.artifacts.installed()),Ni(Ir.hubAgents,()=>lt.search({type:"agent",limit:50})),Ni(Ir.hubTeams,()=>lt.search({type:"team",limit:50})),Ni(Ir.hubSkills,()=>lt.search({type:"skill",limit:50}))};typeof requestIdleCallback=="function"?requestIdleCallback(Y,{timeout:5e3}):setTimeout(Y,3e3)}).catch(()=>{x(null),Ee.auth.status().then(({initialized:$e,hasOwner:Y,hasMultipleUsers:ye})=>{S($e),j({hasOwner:Y,hasMultipleUsers:ye})}).catch(()=>S(!0))}),ja.connect();const Fe=ja.on("notification",()=>{window.dispatchEvent(new CustomEvent("markus:notifications-changed"))}),Oe=()=>{const $e=S6(bc());$e!==le.TEAM&&up(!1),n($e),g(Y=>Y.has($e)?Y:new Set([...Y,$e]))};return window.addEventListener("hashchange",Oe),window.addEventListener("popstate",Oe),()=>{Fe(),ja.disconnect(),window.removeEventListener("hashchange",Oe),window.removeEventListener("popstate",Oe)}},[]);const ae=y!=="loading"&&y!==null?y:void 0,Ce=k.useMemo(()=>d?{[le.HOME]:s.jsx(bv,{authUser:ae}),[le.TEAM]:s.jsx(ow,{authUser:ae}),[le.BUILDER]:s.jsx(pX,{authUser:ae}),[le.SETTINGS]:s.jsx(lw,{theme:m.mode,onThemeChange:m.setMode,authUser:ae,onLogout:()=>{Ee.auth.logout().catch(()=>{}),Po(),x(null)},onUserUpdated:X=>x(X)}),[le.WORK]:s.jsx(cw,{authUser:ae}),[le.DELIVERABLES]:s.jsx(uw,{authUser:ae}),[le.NOTIFICATIONS]:s.jsx(PX,{authUser:ae}),[le.SEARCH]:s.jsx(BX,{})}:{[le.HOME]:s.jsx(bv,{authUser:ae}),[le.TEAM]:s.jsx(ow,{authUser:ae}),[le.SETTINGS]:s.jsx(lw,{theme:m.mode,onThemeChange:m.setMode,authUser:ae,onLogout:()=>{Ee.auth.logout().catch(()=>{}),Po(),x(null)},onUserUpdated:X=>x(X)}),[le.STORE]:s.jsx(OX,{authUser:ae}),[le.BUILDER]:s.jsx(IX,{authUser:ae}),[le.WORK]:s.jsx(cw,{authUser:ae}),[le.DELIVERABLES]:s.jsx(uw,{authUser:ae})},[ae?.id,ae?.role,m.mode,d]);if(y==="loading"||y===null&&C===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 ze=(typeof window<"u"?window.location.hash:"").match(/^#invite\?token=([a-f0-9]+)/);return ze?s.jsx(xX,{token:ze[1],onComplete:()=>{window.location.hash="",localStorage.removeItem("markus_onboarded"),i(!0),O(!0),x("loading"),Ee.auth.me().then(X=>{pv(X.user.id),x(X.user)}).catch(()=>x(null))}}):y===null?s.jsx(bX,{hasOwner:E.hasOwner,hasMultipleUsers:E.hasMultipleUsers,onLogin:(X,Z,pe)=>{x(X),ja.connect(X.id),Z?(pv(X.id),i(!0),pe?.fromHub&&O(!0)):(i(!1),yh(X.id)?(vh(X.id),Ee.auth.updatePreferences({guideHidden:!0}).catch(()=>{}),x({...X,preferences:{...X.preferences,guideHidden:!0}})):x(X))}}):D?s.jsx(yX,{onComplete:()=>H(!1),isFirstTime:!0}):r?s.jsx(hX,{theme:m.mode,onThemeChange:m.setMode,skipProfile:M,onProfileUpdated:X=>{const Z={id:X.id,name:X.name,email:X.email,role:X.role,orgId:X.orgId??"default",avatarUrl:X.avatarUrl};x(Z)},onComplete:()=>{localStorage.removeItem("markus_onboarded"),i(!1),O(!1),Ee.auth.me().then(X=>x(X.user)).catch(()=>{}),oe(),Ae(le.HOME)}}):s.jsxs("div",{className:`flex h-dvh bg-surface-primary text-fg-primary overflow-x-hidden ${d?"flex-col":""}`,children:[!d&&t!==le.SETTINGS&&s.jsxs(s.Fragment,{children:[s.jsx("div",{className:"relative z-40 shrink-0",style:{width:f.width},children:s.jsx(vY,{currentPage:t,onNavigate:X=>{Ae(X),c(!1),He?.("l0"),Ge?.(X)},authUser:y,collapsed:f.collapsed,onToggleCollapse:f.toggle,onLogout:()=>{Ee.auth.logout().catch(()=>{}),Po(),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!==le.SETTINGS&&t!==le.SEARCH?"pb-14":""}`,children:[q===!1&&!B&&t!==le.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:()=>J(!0),className:"text-amber-500 hover:text-amber-600 text-xs",children:e("dismiss")})]})]}),W&&F!==W.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:W.latestVersion,current:W.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:()=>{te(W.latestVersion),localStorage.setItem("markus_update_dismissed",W.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(Ce).map(X=>h.has(X)?s.jsx(UX,{id:X,activePage:t,children:Ce[X]},X):null)})]}),d&&t!==le.SETTINGS&&t!==le.SEARCH&&s.jsx(CY,{currentPage:t,onNavigate:Ae,userId:ae?.id}),d&&s.jsx(fI,{authUser:ae,onNavigate:Ae}),!d&&L&&s.jsx(CX,{onClose:()=>ee(!1),currentPage:t}),!d&&s.jsx(DX,{open:ue,onClose:()=>Se(!1),page:t}),w&&ae&&s.jsx(LX,{authUser:ae,onClose:()=>T(!1),onUserUpdated:X=>x(X),onSaved:X=>{T(!1),x(X)}})]})}L7.createRoot(document.getElementById("root")).render(s.jsx(k.StrictMode,{children:s.jsx(hV,{children:s.jsx(FX,{})})}));export{ha as $,Ys as A,Vo as B,as as C,Oi as D,wr as E,eI as F,XX as G,r6 as H,lX as I,tQ as J,N4 as K,L4 as L,Bw as M,bY as N,YW as O,le as P,WW as Q,GX as R,iX as S,XY as T,QX as U,sY as V,nQ as W,Ho as X,SQ as Y,KX as Z,ta as _,Wo as a,T8 as a0,VX as a1,WX as a2,ji as a3,Sd as a4,Xs as a5,r0 as a6,xQ as a7,rY as a8,HV as a9,vQ as aA,J3 as aB,mY as aC,bQ as aD,rQ as aE,YX as aF,JX as aG,t6 as aH,u4 as aa,UV as ab,Ii as ac,tl as ad,cQ as ae,NY as af,kQ as ag,fQ as ah,eQ as ai,lQ as aj,iQ as ak,oQ as al,aQ as am,dY as an,Zg as ao,sQ as ap,dQ as aq,mQ as ar,hQ as as,uQ as at,BV as au,wQ as av,pQ as aw,yQ as ax,gQ as ay,hY as az,mI as b,Oc as c,dX as d,JY as e,rX as f,Di as g,lt as h,jX as i,s as j,Da as k,Ee as l,vX as m,it as n,En as o,gc as p,Br as q,k as r,Qg as s,Qr as t,gt as u,qX as v,ja as w,Ec as x,A0 as y,E8 as z};
672
+ prose-blockquote:border-brand-500/40 prose-blockquote:text-fg-secondary`,children:s.jsx(jh,{remarkPlugins:t,rehypePlugins:n,components:r,children:i})})}function sh({filename:e,content:t,onSave:n,embedded:r,readOnly:i}){const{t:l}=gt(["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 C=x.current;C.style.height="auto",C.style.height=Math.max(200,C.scrollHeight)+"px"}},[c,m]);const w=async()=>{g(!0),await n(m),g(!1),d(!1)},T=i?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:T}),c?s.jsx("textarea",{ref:x,value:m,onChange:C=>f(C.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(ig,{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}),T]}),c?s.jsx("textarea",{ref:x,value:m,onChange:C=>f(C.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(ig,{content:t}):s.jsx("pre",{className:"text-xs leading-relaxed text-fg-secondary whitespace-pre-wrap font-mono",children:t})})]})}const F4={"README.md":0,"ROLE.md":1,"HEARTBEAT.md":2,"POLICIES.md":3,"CONTEXT.md":4,"ANNOUNCEMENT.md":0,"NORMS.md":1};function LY(e){return[...e].sort(([t],[n])=>{const r=F4[t]??99,i=F4[n]??99;return r!==i?r-i:t.localeCompare(n)})}function S0({files:e,onSave:t,noHeader:n,readOnly:r}){const i=k.useMemo(()=>LY(e),[e]),[l,c]=k.useState(0);if(i.length===1)return n?s.jsx(sh,{filename:i[0][0],content:i[0][1],onSave:h=>t(i[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:i[0][0],content:i[0][1],onSave:h=>t(i[0][0],h),readOnly:r})]});const[d,m]=i[l]??i[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:i.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 OY({images:e,artifactType:t,artifactName:n,onUpload:r,onRemove:i,readOnly:l,cacheBust:c}){const{t:d}=gt(["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:()=>i(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 IY({members:e,teamTopFiles:t,files:n,artifactName:r,onFileSave:i,readOnly:l}){const{t:c}=gt(["builder"]),[d,m]=k.useState(0),f=k.useMemo(()=>{const C=new Set;for(const S of Object.keys(n)){const E=S.match(/^members\/([^/]+)\//);E&&C.add(E[1])}return[...C]},[n]),h=k.useMemo(()=>{const C=new Map,S=new Set;for(let M=0;M<e.length;M++){const D=e[M].slug;D&&f.includes(D)&&!S.has(D)&&(C.set(M,D),S.add(D))}for(let M=0;M<e.length;M++){if(C.has(M))continue;const O=r0(e[M].name);O&&f.includes(O)&&!S.has(O)&&(C.set(M,O),S.add(O))}for(let M=0;M<e.length;M++){if(C.has(M))continue;const O=e[M].roleName;if(O){const D=r0(O);f.includes(D)&&!S.has(D)&&(C.set(M,D),S.add(D))}}for(let M=0;M<e.length;M++){if(C.has(M))continue;const O=e[M].name;for(const D of f){if(S.has(D))continue;const H=n[`members/${D}/ROLE.md`];if(!H)continue;const q=H.match(/^#\s+(.+)$/m)?.[1]?.trim();if(q&&(q.toLowerCase().includes(O.toLowerCase())||O.toLowerCase().includes(q.toLowerCase()))){C.set(M,D),S.add(D);break}}}const E=f.filter(M=>!S.has(M));let j=0;for(let M=0;M<e.length;M++)C.has(M)||j<E.length&&(C.set(M,E[j]),j++);return C},[e,f,n]),g=k.useCallback((C,S)=>{const E=h.get(S);return E?Object.entries(n).filter(([j])=>j.startsWith(`members/${E}/`)):[]},[n,h]),y=k.useMemo(()=>{const C=[{label:c("detail.overview")}];for(const S of e)C.push({label:S.name,role:S.role});return C},[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((C,S)=>{const E=S===d,j=C.role==="manager",M=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 ${M} ${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 O=S-1,D=h.get(O),H=D?`/api/builder/artifacts/teams/${encodeURIComponent(r)}/members/${encodeURIComponent(D)}/images/avatar.jpg`:null;return H?s.jsx("img",{src:H,alt:C.label,className:`w-5 h-5 rounded-full object-cover shrink-0 ring-1 ${j?"ring-amber-500/40":"ring-blue-500/40"}`,onError:q=>{q.target.style.display="none",q.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 O=S-1;return h.get(O)?"hidden":""})()}`,children:(C.label[0]??"?").toUpperCase()})),C.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:T,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((C,S)=>{const E=C.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),M=j?`/api/builder/artifacts/teams/${encodeURIComponent(r)}/members/${encodeURIComponent(j)}/images/avatar.jpg`:null;return M?s.jsx("img",{src:M,alt:C.name,className:`w-8 h-8 rounded-full object-cover shrink-0 ring-1 ${E?"ring-amber-500/30":"ring-blue-500/30"}`,onError:O=>{O.target.style.display="none",O.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:(C.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:C.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:C.role}),C.count>1&&s.jsxs("span",{className:"text-[9px] text-fg-muted",children:["×",C.count]})]}),C.skills&&C.skills.length>0&&s.jsxs("div",{className:"flex flex-wrap gap-1 mt-1",children:[C.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)),C.skills.length>3&&s.jsxs("span",{className:"text-[9px] text-fg-muted",children:["+",C.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 C=h.get(w),S=C?`/api/builder/artifacts/teams/${encodeURIComponent(r)}/members/${encodeURIComponent(C)}/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(C=>s.jsx("span",{className:"text-[10px] px-2.5 py-1 bg-surface-elevated text-fg-muted rounded-full border border-border-default",children:C},C))}),(()=>{const C=g(x.name,w);return C.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:C.map(([S,E])=>[S.replace(/^members\/[^/]+\//,""),E]),onSave:(S,E)=>{const j=C.find(([M])=>M.endsWith(`/${S}`));j&&i(j[0],E)}})})()]}):null})]});function T(C,S){i(C,S)}}function zi({type:e,name:t,onBack:n,authUser:r,readOnly:i,initialManifest:l,actionSlot:c,contentSlot:d}){const{t:m}=gt(["builder","common"]),f=Wo(),[h,g]=k.useState(!0),[y,x]=k.useState(t),[w,T]=k.useState({}),[C,S]=k.useState(null),[E,j]=k.useState(""),[M,O]=k.useState("idle"),[D,H]=k.useState({shared:!1}),[q,Q]=k.useState(!1),[B,J]=k.useState(!1),[W,re]=k.useState(!1),[F,te]=k.useState(!1),[L,ee]=k.useState(!1),[ue,Se]=k.useState(!1),[$,G]=k.useState(null),[me,P]=k.useState(0),[_e,He]=k.useState(""),[Pe,Ge]=k.useState(""),[ut,pt]=k.useState(""),[ht,Mt]=k.useState(""),[Bt,Qt]=k.useState([]),[wt,Ue]=k.useState(""),ft=k.useRef(null),kt=k.useRef(l);kt.current=l,k.useEffect(()=>{x(t)},[t]);const Nt=k.useCallback(async()=>{const X=kt.current;if(X){S(X),He(X.displayName||X.name||t),Ge(X.description||""),pt(X.version||"1.0.0"),Mt(X.category||"general"),Qt(X.tags||[]),Ue(X.icon||""),T(X.files??{}),g(!1);return}g(!0);try{let Z=t;try{const Oe=await Ee.builder.artifacts.ensureSlugSafe(e,t);Z=Oe.name,x(Z),Oe.converted&&(history.replaceState(null,"",Oi(le.BUILDER,`${e}/${encodeURIComponent(Z)}`)),window.dispatchEvent(new CustomEvent("markus:data-changed")))}catch{x(t)}const pe=await Ee.builder.artifacts.get(e,Z);T(pe.files??{}),j(pe.path??"");const Fe=pe.files[`${e}.json`]??pe.files["agent.json"]??pe.files["team.json"]??pe.files["skill.json"];if(Fe){const Oe=JSON.parse(Fe);S(Oe),He(Oe.displayName||Oe.name||t),Ge(Oe.description||""),pt(Oe.version||"1.0.0"),Mt(Oe.category||"general"),Qt(Oe.tags||[]),Ue(Oe.icon||"")}}catch(Z){console.error("Failed to load artifact:",Z)}finally{g(!1)}},[e,t]);k.useEffect(()=>{Nt()},[Nt]),k.useEffect(()=>{l?.files&&T(l.files)},[l?.files]),k.useEffect(()=>{if(!i){try{const X=localStorage.getItem("markus_builder_shared_map");if(X){const Z=JSON.parse(X),pe=`${e}/${t}`;Z[pe]&&H({shared:!0,id:Z[pe].id,slug:Z[pe].slug,version:Z[pe].version,visibility:Z[pe].visibility??"public"})}}catch{}lt.myItems().then(X=>{const Z=X?.items??[],pe=e==="agent"?"agent":e==="team"?"team":"skill";for(const Fe of Z)if(Fe.itemType===pe&&(Fe.slug===t||Fe.name===t)){H({shared:!0,id:Fe.id,slug:Fe.slug,version:Fe.version,visibility:Fe.visibility??"public",moderationStatus:Fe.moderationStatus,pendingReview:Fe.pendingReview});return}}).catch(()=>{})}},[e,t,i]);const zt=k.useCallback(async X=>{if(!(!C||i)){O("saving");try{const Z={...C,...X};await Ee.builder.artifacts.save(e,Z),S(Z),O("saved"),setTimeout(()=>O(pe=>pe==="saved"?"idle":pe),2e3)}catch{O("error"),setTimeout(()=>O("idle"),3e3)}}},[C,e]),ce=k.useCallback(X=>{ft.current&&clearTimeout(ft.current),ft.current=setTimeout(()=>zt(X),800)},[zt]),tt=k.useCallback((X,Z)=>{const pe={};X==="displayName"?(He(Z),pe.displayName=Z,J(!0)):X==="description"?(Ge(Z),pe.description=Z,J(!0)):X==="version"?(pt(Z),pe.version=Z,J(!1),re(!1)):X==="category"?(Mt(Z),pe.category=Z,J(!0)):X==="tags"?(Qt(Z),pe.tags=Z,J(!0)):X==="icon"&&(Ue(Z),pe.icon=Z||void 0,J(!0)),ce({...C,...pe})},[C,ce]),rt=k.useCallback(async(X,Z)=>{try{const pe={...w,[X]:Z};T(pe);const Fe={...C,files:pe};await Ee.builder.artifacts.save(e,Fe),O("saved"),J(!0),setTimeout(()=>O(Oe=>Oe==="saved"?"idle":Oe),2e3)}catch{O("error")}},[w,e,C]),be=k.useCallback(async X=>{if(C){Q(!0);try{await lt.ensureAuth();const Z=await Ee.builder.artifacts.ensureSlugSafe(e,y,C.displayName||C.name||y),pe=Z.name,Fe=Z.slug||wc(pe);if(!Fe)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=Z.displayName||C.displayName||C.name||y;Z.converted&&(x(pe),S(Je=>Je&&{...Je,name:Fe,displayName:Oe}),history.replaceState(null,"",Oi(le.BUILDER,`${e}/${encodeURIComponent(pe)}`)),window.dispatchEvent(new CustomEvent("markus:data-changed")));const $e={...C,name:Fe,displayName:Oe},Y=$e.description||"",ye=$e.category||"general",Ye=$e.tags??[];let xe=$e.icon||void 0;const nt=$e.version||"1.0.0";if(xe&&!xe.startsWith("http")&&/\.(png|jpe?g|gif|webp|svg)$/i.test(xe)){const Je=xe.split("/").pop()??xe;try{const dt=await fetch(`/api/builder/artifacts/${e}s/${encodeURIComponent(pe)}/images/${encodeURIComponent(Je)}`,{cache:"no-store"});if(dt.ok){const _t=await dt.blob(),ct=new File([_t],Je,{type:_t.type}),st=await lt.uploadImage(ct);st?.url&&(xe=st.url)}}catch{}}let at;const V=[],he=$e.screenshots??[];for(let Je=0;Je<he.length;Je++){const dt=he[Je],_t=dt.split("/").pop()??dt;try{const ct=await fetch(`/api/builder/artifacts/${e}s/${encodeURIComponent(pe)}/images/${encodeURIComponent(_t)}`,{cache:"no-store"});if(ct.ok){const st=await ct.blob(),Tt=new File([st],_t,{type:st.type}),kn=await lt.uploadImage(Tt);kn?.url&&(V.push({url:kn.url,alt:_t,order:Je}),Je===0&&(at=kn.url))}}catch{}}const Ie=await lt.publishViaProxy({itemType:e==="team"?"team":e==="skill"?"skill":"agent",name:Oe,slug:Fe,description:Y,category:ye,tags:Ye,icon:xe,version:nt,config:$e,files:Object.keys(w).length>0?w:void 0,thumbnailUrl:at,images:V.length>0?V:void 0,priceCents:X?.priceCents,donationsEnabled:X?.donationsEnabled,visibility:X?.visibility,orgId:X?.orgId});Ie.id&&(H({shared:!0,id:Ie.id,slug:Ie.slug??Fe,version:nt,visibility:Ie.visibility??X?.visibility??"public",moderationStatus:Ie.moderationStatus,pendingReview:Ie.pendingReview}),J(!1),(Ie.visibility??X?.visibility??"public")!=="org"&&(Ie.moderationStatus==="pending"||Ie.pendingReview)?G({title:m("common:share"),message:Z.converted?m("share.convertedAndSubmitted",{previous:t,slug:Fe}):Ie.updated?m("share.updateSubmitted"):m("share.submittedForReview"),variant:"primary"}):Z.converted&&G({title:m("common:share"),message:m("share.convertedSlug",{previous:t,slug:Fe}),variant:"primary"}))}catch(Z){console.error("Share to Hub failed:",Z),G({title:m("common:share"),message:Z instanceof Error?Z.message:String(Z),variant:"danger"})}finally{Q(!1)}}},[C,w,e,t,y,m]),je=async X=>{const Z=new FormData;Z.append("image",X);try{await fetch(`/api/builder/artifacts/${e}s/${encodeURIComponent(y)}/images`,{method:"POST",body:Z,credentials:"include"}),await Nt(),J(!0),P(pe=>pe+1)}catch(pe){console.error("Image upload failed:",pe)}},Ae=async X=>{try{await fetch(`/api/builder/artifacts/${e}s/${encodeURIComponent(y)}/images/${encodeURIComponent(X)}`,{method:"DELETE",credentials:"include"}),await Nt(),J(!0),P(Z=>Z+1)}catch(Z){console.error("Image remove failed:",Z)}},oe=U4[e]??U4.agent,U=C?.screenshots??[],ae=C?.skill?.skillFile?w[C.skill.skillFile]:w["SKILL.md"]??w["README.md"],Ce=k.useMemo(()=>e!=="agent"?[]:Object.entries(w).filter(([X])=>!X.endsWith(".json")&&!X.startsWith("images/")&&!X.startsWith("members/")),[w,e]),Re=k.useMemo(()=>e!=="team"?[]:Object.entries(w).filter(([X])=>!X.endsWith(".json")&&!X.startsWith("images/")&&!X.startsWith("members/")),[w,e]),ze=k.useMemo(()=>{if(e==="agent"||e==="team")return[];const X=new Set;if(e==="skill"){const Z=C?.skill?.skillFile;Z&&w[Z]&&X.add(Z),!Z&&w["SKILL.md"]&&X.add("SKILL.md"),!Z&&!w["SKILL.md"]&&w["README.md"]&&X.add("README.md")}return Object.entries(w).filter(([Z])=>!Z.endsWith(".json")&&!Z.startsWith("images/")&&!Z.startsWith("members/")&&!X.has(Z))},[w,e,C?.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")})]})}):C?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(i?"common:back":"detail.backToBuilder")]}),s.jsxs("div",{className:"flex items-center gap-2",children:[!i&&M==="saving"&&s.jsx("span",{className:"text-[10px] text-fg-muted animate-pulse",children:m("detail.saving")}),!i&&M==="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")]}),!i&&M==="error"&&s.jsx("span",{className:"text-[10px] text-red-500",children:m("detail.saveFailed")}),c,!i&&D.shared&&(()=>{const X=lt.getUser(),Z=X&&D.slug?`${lt.getUrl()}/@${encodeURIComponent(X.username)}/${encodeURIComponent(D.slug)}`:null,pe=ut||C?.version||"1.0.0",Fe=D.version!==pe;return s.jsxs(s.Fragment,{children:[D.moderationStatus==="pending"?s.jsxs("span",{className:"text-xs px-2 py-1.5 rounded-lg border border-amber-500/30 text-amber-400 inline-flex items-center gap-1",title:m("share.underReviewTip"),children:[s.jsxs("svg",{className:"w-3 h-3",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[s.jsx("circle",{cx:"12",cy:"12",r:"10"}),s.jsx("polyline",{points:"12 6 12 12 16 14"})]}),m("share.underReview")]}):D.moderationStatus==="rejected"?s.jsxs("span",{className:"text-xs px-2 py-1.5 rounded-lg border border-red-500/30 text-red-400 inline-flex items-center gap-1",title:m("share.rejectedTip"),children:[s.jsxs("svg",{className:"w-3 h-3",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[s.jsx("circle",{cx:"12",cy:"12",r:"10"}),s.jsx("line",{x1:"15",y1:"9",x2:"9",y2:"15"}),s.jsx("line",{x1:"9",y1:"9",x2:"15",y2:"15"})]}),m("share.rejected")]}):D.pendingReview?s.jsxs("span",{className:"text-xs px-2 py-1.5 rounded-lg border border-amber-500/30 text-amber-400 inline-flex items-center gap-1",title:m("share.updateUnderReviewTip"),children:[s.jsxs("svg",{className:"w-3 h-3",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[s.jsx("circle",{cx:"12",cy:"12",r:"10"}),s.jsx("polyline",{points:"12 6 12 12 16 14"})]}),m("share.updateUnderReview")]}):null,Z&&s.jsxs("a",{href:Z,target:"_blank",rel:"noopener noreferrer",onClick:Oe=>{Ho()&&(Oe.preventDefault(),Xs(Z))},className:`text-xs px-3 py-1.5 rounded-lg border transition-colors inline-flex items-center gap-1.5 ${D.visibility==="org"?"border-blue-500/30 text-blue-500 hover:text-blue-400 hover:border-blue-400/50":D.visibility==="unlisted"?"border-gray-500/30 text-fg-tertiary hover:text-fg-secondary hover:border-gray-400/50":"border-green-600/30 text-green-600 hover:text-green-500 hover:border-green-500/50"}`,children:[D.visibility==="org"?s.jsxs("svg",{className:"w-3 h-3",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[s.jsx("path",{d:"M3 21h18"}),s.jsx("path",{d:"M9 8h1"}),s.jsx("path",{d:"M9 12h1"}),s.jsx("path",{d:"M9 16h1"}),s.jsx("path",{d:"M14 8h1"}),s.jsx("path",{d:"M14 12h1"}),s.jsx("path",{d:"M14 16h1"}),s.jsx("path",{d:"M5 21V5a2 2 0 0 1 2-2h10a2 2 0 0 1 2 2v16"})]}):D.visibility==="unlisted"?s.jsxs("svg",{className:"w-3 h-3",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[s.jsx("path",{d:"M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71"}),s.jsx("path",{d:"M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71"})]}):s.jsxs("svg",{className:"w-3 h-3",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[s.jsx("path",{d:"M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6"}),s.jsx("polyline",{points:"15 3 21 3 21 9"}),s.jsx("line",{x1:"10",y1:"14",x2:"21",y2:"3"})]}),D.visibility==="org"?m("visibility.sharedOrg"):D.visibility==="unlisted"?m("visibility.sharedUnlisted"):m("share.viewOnHub")]}),Fe&&s.jsx("button",{onClick:()=>{be({visibility:D.visibility})},disabled:q,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:q?m("share.updating"):m("share.updateVersion",{version:pe})})]})})(),!i&&!D.shared&&s.jsx("button",{onClick:()=>ee(!0),disabled:q,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(q?"share.sharing":"share.toHub")})]})]}),!i&&B&&!W&&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:()=>re(!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")})]}),!i&&W&&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 X=(ut||"1.0.0").split(".");return X[2]=String(Number(X[2]??0)+1),X.join(".")})(),className:"text-xs px-2 py-1 rounded bg-surface-elevated border border-border-default text-fg-primary w-24 font-mono",onKeyDown:X=>{X.key==="Enter"&&tt("version",X.target.value)}}),s.jsx("button",{onClick:X=>{const Z=X.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:()=>re(!1),className:"text-xs text-fg-tertiary hover:text-fg-secondary",children:m("common:cancel")})]}),D.shared&&s.jsx("p",{className:"text-[10px] text-fg-tertiary mt-2",children:"After bumping the version, you can share the new version to Hub."})]}),s.jsxs("div",{className:`flex gap-8 ${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:()=>!i&&Se(!ue),className:`w-16 h-16 rounded-xl ${oe.bg} flex items-center justify-center text-3xl shrink-0 ${i?"":"cursor-pointer hover:ring-2"} ${oe.ring} transition-all overflow-hidden`,children:wt&&wt.startsWith("images/")?s.jsx("img",{src:`/api/builder/artifacts/${e}s/${encodeURIComponent(y)}/images/${encodeURIComponent(wt.replace("images/",""))}?v=${me}`,alt:"",className:"w-full h-full object-cover"}):wt&&(wt.startsWith("http")||wt.startsWith("/"))?s.jsx("img",{src:wt,alt:"",className:"w-full h-full object-cover"}):(()=>{const X=wt||"";if(X&&[...X].length<=2&&new RegExp("\\p{Emoji}","u").test(X))return X;const pe=Pi[nl(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:h6(_e||t||e),fill:pe})})})()}),!i&&ue&&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:wt,onKeyDown:X=>{X.key==="Enter"&&(tt("icon",X.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 X=>{const Z=X.target.files?.[0];if(!Z)return;const pe=new FormData;pe.append("image",Z);try{const Fe=await fetch(`/api/builder/artifacts/${e}s/${encodeURIComponent(y)}/images`,{method:"POST",body:pe,credentials:"include"});if(Fe.ok){const $e=(await Fe.json()).path;if(Ue($e),Se(!1),C){const Y={...C,icon:$e};S(Y),await Ee.builder.artifacts.save(e,Y)}J(!0)}}catch{}}})]}),wt&&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:jY.map(X=>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:X.label}),s.jsx("div",{className:"flex flex-wrap gap-0.5",children:X.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 ${wt===Z?"ring-1.5 ring-brand-500 bg-brand-500/10":""}`,children:Z},Z))})]},X.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:X=>tt("displayName",X),renderAs:"h1",className:"text-xl font-bold text-fg-primary",placeholder:m("detail.untitled"),readOnly:i}),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:ut,onChange:X=>tt("version",X),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:i})]}),s.jsx(ah,{value:Pe,onChange:X=>tt("description",X),renderAs:"p",className:"text-sm text-fg-secondary mt-1.5 leading-relaxed",placeholder:m("detail.addDescription"),multiline:!0,readOnly:i}),s.jsxs("div",{className:"flex items-center gap-2 mt-2 flex-wrap",children:[s.jsx(RY,{value:ht,options:_Y,onChange:X=>tt("category",X),className:"text-xs px-2 py-0.5 rounded bg-surface-elevated text-fg-tertiary",readOnly:i}),s.jsx(DY,{tags:Bt,onChange:X=>tt("tags",X),readOnly:i})]})]})]}),s.jsx("div",{className:"mb-8",children:s.jsx(OY,{images:U,artifactType:e,artifactName:t,onUpload:je,onRemove:Ae,readOnly:i,cacheBust:me})}),d&&s.jsx("div",{className:"mb-8",children:d}),e==="team"&&C.team&&s.jsx("div",{className:"mb-8",children:s.jsx(IY,{members:C.team.members,teamTopFiles:Re,files:w,artifactName:y,onFileSave:rt,readOnly:i})}),e==="agent"&&Ce.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:Ce,onSave:rt,readOnly:i})]}),e==="skill"&&s.jsxs("div",{className:"mb-8",children:[C.skill?.requiredPermissions&&C.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:C.skill.requiredPermissions.map(X=>{const Z=MY[X];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??"?"})," ",X]},X)})})]}),C.skill?.mcpServers&&Object.keys(C.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(C.skill.mcpServers).map(([X,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:X}),s.jsx("div",{className:"text-[10px] text-fg-muted font-mono truncate",children:typeof Z=="object"?JSON.stringify(Z).slice(0,80):String(Z)})]})]},X))})]}),ae&&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(ig,{content:ae})})]})]}),ze.length>0&&s.jsx(S0,{files:ze,onSave:rt,readOnly:i})]}),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:ht})]}),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:ut})]}),C.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 C.author=="string"?C.author:C.author?.name??""})]})]})]}),e==="agent"&&C.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:[C.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:C.agent.roleName})]}),C.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:C.agent.llmProvider})]}),C.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:C.agent.llmModel})]}),C.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:C.agent.temperature})]})]})]}),e==="team"&&C.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:C.team.members.reduce((X,Z)=>X+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:C.team.members.filter(X=>X.role==="manager").reduce((X,Z)=>X+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:C.team.members.filter(X=>X.role!=="manager").reduce((X,Z)=>X+Z.count,0)})]})]})]}),e==="skill"&&C.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:[C.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:C.skill.alwaysOn?"text-green-400":"text-fg-secondary",children:C.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:C.skill.skillFile})]}),C.skill.requiredPermissions&&C.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:C.skill.requiredPermissions.map(X=>s.jsx("span",{className:"text-[10px] px-1.5 py-0.5 bg-surface-elevated text-fg-muted rounded border border-border-default",children:X},X))})]})]})]}),C.dependencies&&(C.dependencies.skills?.length||C.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")}),C.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:C.dependencies.skills.map(X=>s.jsx("span",{className:"text-[10px] px-2 py-0.5 bg-surface-elevated text-fg-secondary rounded border border-border-default",children:X},X))})]}):null,C.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:C.dependencies.env.map(X=>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:X},X))})]}):null]}):null,!i&&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/")]})]})})]})]}),!i&&F&&s.jsx(BY,{onClose:()=>te(!1),onConfirm:(X,Z)=>{te(!1),be({donationsEnabled:!1,priceCents:X==="paid"?Z:void 0})},isUpdate:D.shared}),!i&&L&&s.jsx(PY,{onClose:()=>ee(!1),onConfirm:(X,Z,pe,Fe)=>{ee(!1),be({visibility:X,orgId:Z,priceCents:pe,donationsEnabled:Fe})}}),$&&s.jsx(wr,{alertOnly:!0,variant:$.variant??"primary",title:$.title,message:$.message,onConfirm:()=>G(null),onCancel:()=>G(null)})]}):s.jsx("div",{className:"flex-1 overflow-y-auto",children:s.jsxs("div",{className:"px-6 py-8",children:[s.jsxs("button",{onClick:n,className:"text-xs text-brand-400 hover:text-brand-300 mb-4 inline-flex items-center gap-1",children:[s.jsx("svg",{className:"w-3.5 h-3.5",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:s.jsx("polyline",{points:"15 18 9 12 15 6"})}),m("detail.backToBuilder")]}),s.jsx("div",{className:"text-fg-tertiary text-sm py-20 text-center",children:m("detail.notFound")})]})})}function PY({onClose:e,onConfirm:t}){const{t:n}=gt(["builder","common"]),[r,i]=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 T=r==="public"||r==="unlisted",C=[{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:C.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:()=>i(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))})]}),T&&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:b6.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")})]})]}),T&&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,T&&g>0?g:void 0,T?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 b6=[{cents:0,label:"Free"},{cents:100,label:"$1"},{cents:500,label:"$5"},{cents:1e3,label:"$10"}];function BY({onClose:e,onConfirm:t,isUpdate:n}){const{t:r}=gt(["builder","common"]),[i,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:b6.map(c=>s.jsxs("label",{className:`flex items-center gap-3 p-3 rounded-lg border cursor-pointer transition-colors ${i===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:i===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(i>0?"paid":"free",i),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||!g6(e)?null:e.startsWith("http")||e.startsWith("data:")?e:e.startsWith("/")&&t?`${t}${e}`:e}function zY({type:e,seed:t,icon:n,hubBase:r,size:i=44,className:l="",rounded:c="rounded-xl"}){const d=nl(e),m=N0(n,r),f=k.useMemo(()=>Jg(d,t),[d,t]),h=k.useMemo(()=>h6(t),[t]),[g,y]=k.useState(!1);return m&&!g?s.jsx("img",{src:m,alt:"",onError:()=>y(!0),style:{width:i,height:i},className:`${c} object-cover shrink-0 ${l}`}):AY(n)?s.jsx("div",{style:{width:i,height:i,background:f,fontSize:i*.5},className:`${c} shrink-0 flex items-center justify-center shadow-inner ${l}`,children:s.jsx("span",{className:"drop-shadow-sm",children:n})}):n&&BW(n)?s.jsx("div",{style:{width:i,height:i,background:f},className:`${c} shrink-0 flex items-center justify-center text-white shadow-inner ${l}`,children:s.jsx(tl,{name:n,size:i*.52,className:"drop-shadow-sm"})}):s.jsx("div",{style:{width:i,height:i,background:f},className:`${c} shrink-0 flex items-center justify-center shadow-inner ${l}`,children:s.jsx("svg",{width:i*.55,height:i*.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:i=24,className:l="",verified:c}){const d=t||e||"markus",m=N0(n,r),[f,h]=k.useState(!1),g=m&&!f?m:EY(d);return s.jsxs("span",{className:`relative inline-flex shrink-0 ${l}`,style:{width:i,height:i},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:i*.42,height:i*.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 $Y({type:e,className:t=""}){const n=nl(e),r=Pi[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 q4({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 ga(e){const{type:t,name:n,description:r,seed:i,icon:l,cover:c,hubBase:d,author:m,authorLabel:f,version:h,category:g,tags:y,rating:x=0,ratingCount:w=0,downloadCount:T=0,priceCents:C,currency:S="usd",installed:E,glowing:j,selected:M,showTypeBadge:O=!0,hideStats:D=!1,cornerLabel:H,actions:q,footerLeft:Q,headerAction:B,onClick:J,className:W=""}=e,re=nl(t),F=Pi[re],te=i||n,L=(C??0)>0,ee=!!N0(c||void 0,d),ue=Jg(re,te),Se=f??m?.displayName??m?.username??"",[$,G]=k.useState(null),me=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"})})}):H?s.jsx("span",{className:"chip",children:H}):L?s.jsx("span",{className:"badge-paid",children:H4(C,S)}):null;if(ee){const P=N0(c||void 0,d);return s.jsxs("div",{onClick:J,style:{aspectRatio:$??void 0},className:`group asset-card card-shine relative flex flex-col overflow-hidden min-h-[180px] ${J?"cursor-pointer":""} ${M?"ring-1 ring-brand-500/60":""} ${j?"ring-2 ring-brand-500 shadow-lg shadow-brand-500/20":""} ${W}`,children:[s.jsx("img",{src:P,alt:"",onLoad:_e=>{const He=_e.currentTarget;He.naturalWidth&&He.naturalHeight&&G(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:O&&s.jsx($Y,{type:re})}),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"})})}):H?s.jsx("span",{className:"inline-flex items-center rounded-full bg-white/15 text-white border border-white/25 px-2 py-0.5 text-[10px] font-medium backdrop-blur-md",children:H}):B?null:s.jsx("span",{className:L?"badge-paid":"badge-free",children:H4(C,S)}),B]})]}),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))]}),(!D||q)&&s.jsxs("div",{className:"flex items-center justify-between gap-2 pt-1 shrink-0",children:[D?s.jsx("span",{}):s.jsxs("div",{className:"flex items-center gap-3 text-[11px] text-white/80",children:[s.jsxs("span",{className:"inline-flex items-center gap-1",children:[s.jsx(q4,{rating:x}),w>0&&s.jsxs("span",{className:"text-white/60",children:["(",Io(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"})}),Io(T)]})]}),q&&s.jsx("div",{className:"flex items-center gap-2",onClick:_e=>_e.stopPropagation(),children:q})]})]})]})}return s.jsxs("div",{onClick:J,className:`group asset-card card-shine relative flex flex-col ${J?"cursor-pointer":""} ${M?"ring-1 ring-brand-500/60":""} ${j?"ring-2 ring-brand-500 shadow-lg shadow-brand-500/20":""} ${W}`,children:[s.jsx("div",{className:"pointer-events-none absolute inset-x-0 top-0 h-[2px] opacity-0 group-hover:opacity-100 transition-opacity duration-300",style:{background:`linear-gradient(90deg, transparent, ${F.accent}, transparent)`}}),s.jsx("div",{className:"pointer-events-none absolute -top-10 -left-10 w-36 h-36 rounded-full blur-2xl opacity-[0.12] group-hover:opacity-20 transition-opacity duration-300",style:{background:ue}}),B&&s.jsx("div",{className:"absolute top-2.5 right-2.5 z-10",onClick:P=>P.stopPropagation(),children:B}),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(zY,{type:re,seed:te,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 ${B?"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]}),me&&s.jsx("span",{className:"ml-auto shrink-0",children:me})]}),(Se||O)&&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}),O&&s.jsxs(s.Fragment,{children:[Se&&s.jsx("span",{className:"text-fg-muted",children:"·"}),s.jsx("span",{className:"font-semibold shrink-0",style:{color:F.accent},children:F.label})]})]})]})]}),r&&s.jsx("p",{className:"text-[13px] text-fg-secondary truncate leading-snug",children:r}),(g||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=Q??(D?null:s.jsxs("span",{className:"flex items-center gap-3 text-[11px] text-fg-tertiary",children:[s.jsxs("span",{className:"inline-flex items-center gap-1",children:[s.jsx(q4,{rating:x}),s.jsx("span",{className:"text-fg-muted",children:w>0?`(${Io(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"})}),Io(T)]})]}));return!P&&!q?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}),q&&s.jsx("div",{className:"flex flex-wrap items-center gap-2 justify-end",children:q})]})})()]})]})}function Pr({children:e,maxCardWidth:t=400,gap:n="1rem",className:r=""}){const i=k.useRef(null),[l,c]=k.useState(0);k.useEffect(()=>{const h=i.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:i,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 HY(e){const t=e.indexOf(".markus/builder-artifacts/");return t>=0?"~/"+e.slice(t):e}const UY=[{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 FY(){const[e,t]=k.useState(()=>{const r=window.location.hash.slice(1).split("/");return gc(r[0])===le.BUILDER&&r[1]&&r[2]?{type:r[1],name:decodeURIComponent(r[2])}:null});return k.useEffect(()=>{const n=()=>{const i=window.location.hash.slice(1).split("/");gc(i[0])===le.BUILDER&&i[1]&&i[2]?t({type:i[1],name:decodeURIComponent(i[2])}):t(null)};return window.addEventListener("hashchange",n),()=>window.removeEventListener("hashchange",n)},[]),e}const x6="markus_builder_shared_map";function qY(){try{const e=localStorage.getItem(x6);if(!e)return new Map;const t=JSON.parse(e);return new Map(Object.entries(t))}catch{return new Map}}function Dd(e){try{localStorage.setItem(x6,JSON.stringify(Object.fromEntries(e)))}catch{}}function y6({authUser:e}={}){const{t}=gt(["builder","common"]),n=Wo(),r=FY(),[i,l]=k.useState([]),[c,d]=k.useState([]),[m,f]=k.useState(!1),[h,g]=k.useState("all"),[y,x]=k.useState(null),[w,T]=k.useState(new Map),[C,S]=k.useState(null),[E,j]=k.useState(null),[M,O]=k.useState(null),[D,H]=k.useState(qY),[q,Q]=k.useState(null),[B,J]=k.useState(null),[W,re]=k.useState(null),[F,te]=k.useState(null),[L,ee]=k.useState(null),[ue,Se]=k.useState("creations"),[$,G]=k.useState([]),[me,P]=k.useState(""),[_e,He]=k.useState([]),[Pe,Ge]=k.useState(!1),[ut,pt]=k.useState("all"),ht=k.useCallback(()=>{f(!0),Promise.all([(Ri(Ir.builderArtifacts)??Ee.builder.artifacts.list()).then(ce=>ce?.artifacts??[]).catch(()=>[]),(Ri(Ir.builderAgents)??Ee.agents.list()).then(ce=>ce?.agents??[]).catch(()=>[]),(Ri(Ir.builderHubMyItems)??lt.myItems()).then(ce=>ce?.items??[]).catch(()=>[]),(Ri(Ir.builderInstalled)??Ee.builder.artifacts.installed()).then(ce=>ce?.installed??{}).catch(()=>({}))]).then(([ce,tt,rt,be])=>{if(d(ce),l(tt),rt.length>0){const Ae=new Map;for(const oe of rt){const U=oe.itemType==="agent"?"agent":oe.itemType==="team"?"team":"skill";for(const ae of ce)ae.type===U&&(oe.slug===ae.name||oe.name===(ae.meta.displayName||ae.meta.name||ae.name))&&Ae.set(`${ae.type}/${ae.name}`,{id:oe.id,name:oe.name,slug:oe.slug||ae.name,version:oe.version||"1.0.0",visibility:oe.visibility??"public",moderationStatus:oe.moderationStatus,pendingReview:oe.pendingReview})}Ae.size>0&&H(oe=>{const U=new Map(oe);for(const[ae,Ce]of Ae)U.set(ae,Ce);return Dd(U),U})}const je=new Map;for(const Ae of ce){const oe=`${Ae.type}/${Ae.name}`,U=be[oe];U&&je.set(oe,{agentId:U.agentId,agentIds:U.agentIds,teamId:U.teamId})}T(je)}).finally(()=>f(!1))},[]);k.useEffect(()=>{ht();const ce=tt=>{tt.detail?.page===le.BUILDER&&ht()};return window.addEventListener("markus:navigate",ce),()=>window.removeEventListener("markus:navigate",ce)},[ht]);const Mt=ce=>{const tt=i.find(rt=>rt.role==="Secretary"||rt.name==="Secretary");tt?it.navigate(le.TEAM,{agentId:tt.id,prefillMessage:ce}):it.navigate(le.TEAM,{prefillMessage:ce})},Bt=async ce=>{const tt=`${ce.type}/${ce.name}`;if(!w.has(tt)){x({key:tt,action:"install"});try{const rt=await Ee.builder.artifacts.install(ce.type,ce.name),be={};rt.agent&&typeof rt.agent=="object"&&(be.agentId=rt.agent.id),rt.team&&typeof rt.team=="object"&&(be.teamId=rt.team.id),Array.isArray(rt.agents)&&(be.agentIds=rt.agents.map(je=>je.id)),T(je=>new Map(je).set(tt,be)),window.dispatchEvent(new CustomEvent("markus:data-changed"))}catch(rt){console.error("Install failed:",rt),J({title:t("common:install"),message:t("installFailed",{error:String(rt)}),variant:"danger"})}finally{x(null)}}},Qt=async ce=>{const tt=`${ce.type}/${ce.name}`;if(w.has(tt)){x({key:tt,action:"uninstall"});try{await Ee.builder.artifacts.uninstall(ce.type,ce.name),T(rt=>{const be=new Map(rt);return be.delete(tt),be}),window.dispatchEvent(new CustomEvent("markus:data-changed"))}catch(rt){console.error("Uninstall failed:",rt),J({title:t("common:uninstall"),message:t("uninstallFailed",{error:String(rt)}),variant:"danger"})}finally{x(null)}}},wt=async(ce,tt)=>{const rt=`${ce.type}/${ce.name}`;x({key:rt,action:"share"});try{const be=await Ee.builder.artifacts.ensureSlugSafe(ce.type,ce.name,ce.meta.displayName||ce.meta.name||ce.name),je=be.name,Ae=be.slug||wc(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=`${ce.type}/${je}`;be.converted&&(d(ye=>ye.map(Ye=>Ye.type===ce.type&&Ye.name===ce.name?{...Ye,name:je,path:be.path,meta:{...Ye.meta,name:je,displayName:be.displayName??Ye.meta.displayName??ce.name}}:Ye)),H(ye=>{const Ye=new Map(ye),xe=Ye.get(rt);return xe&&(Ye.delete(rt),Ye.set(oe,{...xe,slug:Ae,name:be.displayName??xe.name})),Dd(Ye),Ye}),T(ye=>{const Ye=new Map(ye),xe=Ye.get(rt);return xe&&(Ye.delete(rt),Ye.set(oe,xe)),Ye}));const U=await Ee.builder.artifacts.get(ce.type,je);let ae={...ce.meta,name:je,displayName:be.displayName??ce.meta.displayName??ce.name};try{const ye=U.files?.[`${ce.type}.json`]??U.files?.["agent.json"]??U.files?.["team.json"]??U.files?.["skill.json"];ye&&(ae={...JSON.parse(ye),...ae,name:je,displayName:ae.displayName})}catch{}const Ce=ae.displayName||ae.name||je,Re=ae.description||"",ze=ae.category||"general",X=Array.isArray(ae.tags)?ae.tags:[];let Z=ae.icon||void 0;const pe=ae.version||"1.0.0";if(Z&&!Z.startsWith("http")&&/\.(png|jpe?g|gif|webp|svg)$/i.test(Z)){const ye=Z.split("/").pop()??Z;try{const Ye=await fetch(`/api/builder/artifacts/${ce.type}s/${encodeURIComponent(je)}/images/${encodeURIComponent(ye)}`);if(Ye.ok){const xe=await Ye.blob(),nt=new File([xe],ye,{type:xe.type}),at=await lt.uploadImage(nt);at?.url&&(Z=at.url)}}catch{}}let Fe;const Oe=[],$e=Array.isArray(ae.screenshots)?ae.screenshots:[];for(let ye=0;ye<$e.length;ye++){const Ye=$e[ye],xe=Ye.split("/").pop()??Ye;try{const nt=await fetch(`/api/builder/artifacts/${ce.type}s/${encodeURIComponent(je)}/images/${encodeURIComponent(xe)}`);if(nt.ok){const at=await nt.blob(),V=new File([at],xe,{type:at.type}),he=await lt.uploadImage(V);he?.url&&(Oe.push({url:he.url,alt:xe,order:ye}),(ye===0||ae.thumbnail===Ye)&&(Fe=he.url))}}catch{}}const Y=await lt.publishViaProxy({itemType:ce.type==="team"?"team":ce.type==="skill"?"skill":"agent",name:Ce,slug:Ae,description:Re,category:ze,tags:X,icon:Z,version:pe,config:{...ae,name:je,displayName:Ce},files:U.files&&Object.keys(U.files).length>0?U.files:void 0,thumbnailUrl:Fe,images:Oe.length>0?Oe:void 0,priceCents:tt?.priceCents,donationsEnabled:tt?.donationsEnabled,visibility:tt?.visibility,orgId:tt?.orgId});Y.id&&(H(Ye=>{const xe=new Map(Ye);return xe.set(oe,{id:Y.id,name:Ce,slug:Y.slug??Ae,version:pe,visibility:Y.visibility??tt?.visibility??"public",moderationStatus:Y.moderationStatus,pendingReview:Y.pendingReview}),Dd(xe),xe}),(Y.visibility??tt?.visibility??"public")!=="org"&&(Y.moderationStatus==="pending"||Y.pendingReview)?J({title:t("common:share"),message:be.converted?t("share.convertedAndSubmitted",{previous:ce.name,slug:Ae}):Y.updated?t("share.updateSubmitted"):t("share.submittedForReview"),variant:"primary"}):be.converted&&J({title:t("common:share"),message:t("share.convertedSlug",{previous:ce.name,slug:Ae}),variant:"primary"}))}catch(be){console.error("Share failed:",be),J({title:t("common:share"),message:t("shareFailed",{error:be instanceof Error?be.message:String(be)}),variant:"danger"})}finally{x(null)}},Ue=async()=>{if(!q)return;const{key:ce}=q,tt=D.get(ce);if(Q(null),!tt)return;const rt=tt.id;x({key:ce,action:"hubDelete"});try{await lt.deleteItem(rt),H(be=>{const je=new Map(be);return je.delete(ce),Dd(je),je})}catch(be){console.error("Hub delete failed:",be),J({title:t("unshare"),message:t("hubDeleteFailed",{error:String(be)}),variant:"danger"})}finally{x(null)}},ft=async()=>{if(!C)return;const ce=C,tt=`${ce.type}/${ce.name}`;S(null),x({key:tt,action:"delete"});try{await Ee.builder.artifacts.delete(ce.type,ce.name),d(rt=>rt.filter(be=>!(be.type===ce.type&&be.name===ce.name))),T(rt=>{const be=new Map(rt);return be.delete(tt),be}),window.dispatchEvent(new CustomEvent("markus:data-changed"))}catch(rt){console.error("Delete failed:",rt)}finally{x(null)}},kt=h==="all"?c:c.filter(ce=>ce.type===h);k.useEffect(()=>{ue!=="orgAssets"||$.length>0||lt.myOrgs().then(ce=>{G(ce.memberships),ce.memberships.length>0&&!me&&P(ce.memberships[0].id)}).catch(()=>{})},[ue,$.length,me]),k.useEffect(()=>{ue!=="orgAssets"||!me||(Ge(!0),lt.browseItems({orgId:me,limit:100}).then(ce=>He(ce.items??[])).catch(()=>He([])).finally(()=>Ge(!1)))},[ue,me]);const Nt=ut==="all"?_e:_e.filter(ce=>ce.itemType===ut),zt=ce=>{history.pushState(null,"",Oi(le.BUILDER,`${ce.type}/${encodeURIComponent(ce.name)}`)),window.dispatchEvent(new HashChangeEvent("hashchange"))};return r?s.jsx(zi,{type:r.type,name:r.name,authUser:e,onBack:()=>{history.pushState(null,"",Oi(le.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:ht,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:UY.map(ce=>{const tt=t(`prompts.${ce.id}Prompt`),rt=t(`prompts.${ce.id}Examples`,{returnObjects:!0}),be=Array.isArray(rt)?rt:[];return s.jsx("button",{onClick:()=>Mt(tt),className:`group text-left w-full rounded-xl border ${ce.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 ${ce.bgColor} flex items-center justify-center shrink-0`,children:ce.icon}),s.jsxs("div",{className:"flex-1 min-w-0",children:[s.jsx("h3",{className:`text-sm font-semibold bg-gradient-to-r ${ce.color} bg-clip-text text-transparent`,children:t(`prompts.${ce.id}`)}),s.jsx("p",{className:"text-[11px] text-fg-tertiary mt-1 leading-relaxed",children:t(`prompts.${ce.id}Desc`)}),be.length>0&&s.jsx("div",{className:"mt-2 flex flex-wrap gap-1.5",children:be.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))})]})]})},ce.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 ${ue==="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 ${ue==="orgAssets"?"text-fg-primary":"text-fg-tertiary hover:text-fg-secondary"}`,children:t("orgAssets.title")})]}),ue==="creations"&&s.jsx("div",{className:"flex gap-1.5",children:["all","agent","team","skill"].map(ce=>s.jsx("button",{onClick:()=>g(ce),className:`text-xs px-2.5 py-1 rounded-lg transition-colors ${h===ce?"bg-brand-600 text-white":"text-fg-tertiary hover:text-fg-secondary hover:bg-surface-elevated"}`,children:t(ce==="all"?"myCreations.filterAll":ce==="agent"?"myCreations.filterAgents":ce==="team"?"myCreations.filterTeams":"myCreations.filterSkills")},ce))}),ue==="orgAssets"&&s.jsx("div",{className:"flex gap-1.5",children:["all","agent","team","skill"].map(ce=>s.jsx("button",{onClick:()=>pt(ce),className:`text-xs px-2.5 py-1 rounded-lg transition-colors ${ut===ce?"bg-brand-600 text-white":"text-fg-tertiary hover:text-fg-secondary hover:bg-surface-elevated"}`,children:t(ce==="all"?"myCreations.filterAll":ce==="agent"?"myCreations.filterAgents":ce==="team"?"myCreations.filterTeams":"myCreations.filterSkills")},ce))})]})}),ue==="orgAssets"&&$.length>0&&s.jsx("div",{className:"flex gap-2 mb-3 overflow-x-auto pb-1",children:$.map(ce=>s.jsx("button",{onClick:()=>P(ce.id),className:`text-xs px-3 py-1.5 rounded-full whitespace-nowrap border transition-colors ${me===ce.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:ce.name},ce.id))}),ue==="orgAssets"&&($.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")}):Nt.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(Pr,{children:Nt.map(ce=>{const tt=ce.author?.username&&ce.slug?`${lt.getUrl()}/@${encodeURIComponent(ce.author.username)}/${encodeURIComponent(ce.slug)}`:null;return s.jsx(ga,{type:ce.itemType,name:ce.name,description:ce.description,seed:ce.slug||ce.id||ce.name,icon:ce.icon,cover:ce.thumbnailUrl,hubBase:lt.getUrl(),author:ce.author,version:ce.version,rating:parseFloat(ce.avgRating)||0,ratingCount:ce.ratingCount,downloadCount:ce.downloadCount,actions:tt?s.jsxs("a",{href:tt,target:"_blank",rel:"noopener noreferrer",onClick:rt=>{rt.stopPropagation(),Ho()&&(rt.preventDefault(),Xs(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},ce.id)})})),ue==="creations"&&(m&&c.length===0?s.jsx("div",{className:"text-center text-fg-tertiary py-12 text-sm",children:t("myCreations.loadingArtifacts")}):kt.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(Pr,{children:kt.map(ce=>{const tt=ce.meta.displayName||ce.meta.name||ce.name,rt=ce.meta.description||"",be=`${ce.type}/${ce.name}`,je=y?.key===be?y.action:null,Ae=D.get(be),oe=ce.meta.version||"1.0.0",U=!!Ae,ae=U&&Ae.version!==oe,Ce=()=>{const Oe=lt.getUser();return!Ae||!Oe?null:`${lt.getUrl()}/@${encodeURIComponent(Oe.username)}/${encodeURIComponent(Ae.slug)}`},Re=U&&(Ae?.moderationStatus==="pending"||Ae?.moderationStatus==="rejected"||!!Ae?.pendingReview),ze=s.jsxs("div",{className:"flex items-center gap-1.5 justify-end",onClick:Oe=>Oe.stopPropagation(),children:[w.has(be)?s.jsxs("button",{onClick:()=>O(ce),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(ce),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")]}),U&&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")]}):U?s.jsxs(s.Fragment,{children:[ae&&s.jsxs("button",{onClick:()=>{const Oe=Ae?.visibility??"public";wt(ce,{visibility:Oe})},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:Ce()??"#",target:"_blank",rel:"noopener noreferrer",onClick:Oe=>{const $e=Ce();Ho()&&$e&&(Oe.preventDefault(),Xs($e))},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:()=>Q({key:be,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(ce.meta.screenshots)&&ce.meta.screenshots.length>0?ee(ce):re(ce)},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")]})]}),X=s.jsx("button",{onClick:()=>S(ce),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=ce.meta.icon,Fe=!!Z&&/\.(png|jpe?g|gif|webp|svg)$/i.test(Z)?Z.startsWith("http")||Z.startsWith("/")?Z:`/api/builder/artifacts/${ce.type}s/${encodeURIComponent(ce.name)}/images/${encodeURIComponent(Z.split("/").pop()??"")}?v=${ce.updatedAt??""}`:Z;return s.jsx(ga,{type:ce.type,name:tt,description:rt,seed:be,icon:Fe,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:Oe=>{Oe.stopPropagation(),Ee.system.openPath(ce.path).catch(()=>{})},className:"hover:text-fg-secondary transition-colors truncate min-w-0",title:ce.path,children:HY(ce.path)}),s.jsx("span",{className:"shrink-0",children:"·"}),s.jsx("span",{className:"shrink-0",children:new Date(ce.updatedAt).toLocaleDateString()})]}),headerAction:X,actions:ze,onClick:()=>zt(ce)},be)})})),E&&s.jsx(wr,{variant:"primary",title:t("confirmInstall"),message:t("confirmInstallMsg",{name:E.meta.displayName||E.meta.name||E.name}),confirmLabel:t("common:install"),onConfirm:()=>{const ce=E;j(null),Bt(ce)},onCancel:()=>j(null)}),M&&s.jsx(wr,{variant:"primary",title:t("confirmUninstall"),message:t("confirmUninstallMsg",{name:M.meta.displayName||M.meta.name||M.name}),confirmLabel:t("common:uninstall"),onConfirm:()=>{const ce=M;O(null),Qt(ce)},onCancel:()=>O(null)}),C&&s.jsx(wr,{title:t("confirmDeleteLocal"),message:t("deleteCannotUndo",{name:C.meta.displayName||C.meta.name||C.name}),confirmLabel:t("common:delete"),onConfirm:ft,onCancel:()=>S(null)}),q&&s.jsx(wr,{title:t("confirmUnshare"),message:t("removeFromHub",{name:q.name}),confirmLabel:t("unshare"),onConfirm:()=>{Ue()},onCancel:()=>Q(null)}),B&&s.jsx(wr,{alertOnly:!0,variant:B.variant??"primary",title:B.title,message:B.message,onConfirm:()=>J(null),onCancel:()=>J(null)}),W&&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.jsxs("div",{className:"bg-surface-secondary border border-border-default rounded-xl max-w-sm w-full mx-4 p-6 shadow-2xl",onClick:ce=>ce.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 ce=W;re(null),ee(ce)},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 ce=W;re(null),zt(ce)},className:"flex-1 text-sm px-4 py-2 rounded-lg bg-brand-600 hover:bg-brand-500 text-white transition-colors",children:t("share.addImagesFirst")})]})]})}),F&&s.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/60 backdrop-blur-sm",onClick:()=>te(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:ce=>ce.stopPropagation(),children:s.jsx(KY,{isUpdate:D.has(`${F.type}/${F.name}`),onCancel:()=>te(null),onConfirm:(ce,tt)=>{const rt=F;te(null),wt(rt,{priceCents:tt>0?tt:void 0})}})})}),L&&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.jsx("div",{className:"bg-surface-secondary border border-border-default rounded-xl max-w-sm w-full mx-4 p-6 shadow-2xl",onClick:ce=>ce.stopPropagation(),children:s.jsx(GY,{onCancel:()=>ee(null),onConfirm:(ce,tt,rt,be)=>{const je=L;ee(null),wt(je,{visibility:ce,orgId:tt,priceCents:rt,donationsEnabled:be})}})})})]})})}function GY({onCancel:e,onConfirm:t}){const{t:n}=gt(["builder","common"]),[r,i]=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 T=r==="public"||r==="unlisted",C=[{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:C.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:()=>i(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))})]}),T&&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:v6.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")})]})]}),T&&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,T&&g>0?g:void 0,T?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 v6=[{cents:0,label:"Free"},{cents:100,label:"$1"},{cents:500,label:"$5"},{cents:1e3,label:"$10"}];function KY({isUpdate:e,onCancel:t,onConfirm:n}){const{t:r}=gt(["builder","common"]),[i,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:v6.map(c=>s.jsxs("label",{className:`flex items-center gap-3 p-3 rounded-lg border cursor-pointer transition-colors ${i===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:i===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(i>0?"paid":"free",i),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 VY=Object.freeze(Object.defineProperty({__proto__:null,AgentBuilder:y6},Symbol.toStringTag,{value:"Module"}));async function w6(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 WY(e,t){const n=e.split(".").map(Number),r=t.split(".").map(Number);for(let i=0;i<Math.max(n.length,r.length);i++){const l=n[i]??0,c=r[i]??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 G4(e,t){return e.i18n?.[t]?.description||e.description}const YY={manager:"bg-brand-500/15 text-brand-500",worker:"bg-blue-500/15 text-blue-600"};function XY({authUser:e,highlightItemId:t,onHighlightDone:n}={}){const{t:r,i18n:i}=gt(["store","common"]),l=i.language,[c,d]=k.useState(""),[m,f]=k.useState([]),[h,g]=k.useState([]),[y,x]=k.useState(null),[w,T]=k.useState({}),[C,S]=k.useState(!1),[E,j]=k.useState(!0),[M,O]=k.useState(new Map),[D,H]=k.useState(new Set),[q,Q]=k.useState(null),[B,J]=k.useState(null),W=k.useCallback(async()=>{try{const[te,L]=await Promise.all([Ee.builder.artifacts.list().catch(()=>({artifacts:[]})),Ee.builder.artifacts.installed().catch(()=>({installed:{}}))]),ee=new Map;for(const ue of te.artifacts){if(ue.type!=="agent")continue;const Se=!!L.installed[`agent/${ue.name}`];ee.set(ue.name,{installed:Se,localVersion:ue.meta.version||void 0,localUpdatedAt:ue.updatedAt})}O(ee)}catch{}},[]),re=k.useCallback(async()=>{j(!0);try{const te=c?lt.search({type:"agent",q:c,limit:50}):Ri(Ir.hubAgents)??lt.search({type:"agent",limit:50}),L=new URLSearchParams;c&&L.set("q",c);const ee=fetch("/api/templates?"+L.toString()).then(G=>G.json()).catch(()=>({templates:[]})),[ue,Se]=await Promise.all([te.catch(()=>({items:[],total:0})),ee,W(),lt.isAuthenticated()?lt.purchases.mine().then(G=>H(new Set(G.purchases.map(me=>me.itemId)))).catch(()=>{}):Promise.resolve()]),$=await w6(ue?.items??[],t);g($.items),f(Array.isArray(Se.templates)?Se.templates:[]),$.missing&&n?.()}catch{f([]),g([])}finally{j(!1)}},[c,W,t,n]);k.useEffect(()=>{re()},[re]),k.useEffect(()=>{if(!y){T({});return}fetch(`/api/templates/${encodeURIComponent(y.id)}/files`,{credentials:"include"}).then(te=>te.json()).then(te=>T(te.files??{})).catch(()=>T({}))},[y]);const F=async(te,L,ee)=>{try{const ue=await fetch("/api/templates/instantiate",{method:"POST",headers:{"Content-Type":"application/json"},credentials:"include",body:JSON.stringify({templateId:te,name:L,orgId:"default",teamId:ee})});if(!ue.ok)throw new Error(`Failed: ${ue.status}`);S(!1),x(null)}catch(ue){J({title:r("common:create",{defaultValue:"Create"}),message:`Failed to create agent: ${ue}`,variant:"danger"})}};if(q)return s.jsx(zi,{type:q.type,name:q.name,onBack:()=>Q(null)});if(y){const te={type:"agent",name:y.id,displayName:T0(y,l),version:y.version,description:G4(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}},L=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 ${YY[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(ee=>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:ee},ee)),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((ee,ue)=>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 ${ee.priority==="high"?"bg-red-400":ee.priority==="medium"?"bg-amber-400":"bg-green-400"}`}),s.jsxs("div",{children:[s.jsx("div",{className:"text-sm text-fg-primary",children:ee.title}),ee.description&&s.jsx("div",{className:"text-xs text-fg-tertiary mt-0.5",children:ee.description})]})]},ue))})]})]});return s.jsxs(s.Fragment,{children:[s.jsx(zi,{type:"agent",name:y.id,onBack:()=>x(null),readOnly:!0,initialManifest:te,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:L}),C&&s.jsx(K4,{template:y,lang:l,onClose:()=>S(!1),onHire:F}),B&&s.jsx(wr,{alertOnly:!0,variant:B.variant??"danger",title:B.title,message:B.message,onConfirm:()=>J(null),onCancel:()=>J(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:te=>d(te.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((te,L)=>s.jsx("div",{className:"h-56 rounded-2xl skeleton"},L))}):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(Pr,{columns:3,children:m.map(te=>s.jsx(ga,{type:"agent",name:T0(te,l),description:G4(te,l),seed:te.id,icon:te.icon,version:te.version,category:te.category,tags:te.tags,authorLabel:te.author,hideStats:!0,showTypeBadge:!1,cornerLabel:r("agentStore.builtin"),onClick:()=>x(te)},te.id))})]}),h.length>0&&s.jsxs("section",{children:[s.jsx("h3",{className:"section-title mb-3",children:r("agentStore.markusHub")}),s.jsx(Pr,{columns:3,children:h.map(te=>s.jsx(QY,{item:te,localInfo:M.get(Ic(te)),purchased:e0(te,D),onStatusChange:W,highlight:te.id===t,onHighlightDone:n,onViewDetail:L=>Q({type:"agent",name:L})},te.id))})]})]})}),C&&y&&s.jsx(K4,{template:y,lang:l,onClose:()=>S(!1),onHire:F}),B&&s.jsx(wr,{alertOnly:!0,variant:B.variant??"danger",title:B.title,message:B.message,onConfirm:()=>J(null),onCancel:()=>J(null)})]})}function Ic(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 Di(e){return(async()=>{const t=await lt.download(e.id),n=t.name||e.name,r=t.config??{},i=Ic(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,i,t.files,c,d);else{const m={...r,...d?{version:d}:{},name:i,displayName:r.displayName||n,description:e.description,source:c};await Ee.builder.artifacts.save(l,m)}return await Ee.builder.artifacts.install(l,i),window.dispatchEvent(new CustomEvent("markus:data-changed")),n})()}async function eb(e,t){t("checking"),await lt.ensureAuth();const n=await lt.purchases.checkout(e.id);if(n.alreadyOwned)return t("installing"),await Di(e),"installed";try{if((await lt.creator.getBalance()).availableBalance>=(e.priceCents??0)){const c=await lt.purchases.payWithEarnings(e.id);if(c.ok||c.alreadyOwned)return t("installing"),await Di(e),"installed"}}catch{}if(!n.checkoutUrl)throw new Error("No checkout URL");t("checkout_opened");const r=Ho();let i=null;return r?Xs(n.checkoutUrl):i=window.open(n.checkoutUrl,"_blank","noopener"),new Promise((l,c)=>{const d=Date.now(),m=300*1e3,f=setInterval(async()=>{if(Date.now()-d>m){clearInterval(f),l("cancelled");return}const g=!r&&i?i.closed:!1;try{if((await lt.purchases.checkout(e.id)).alreadyOwned){clearInterval(f),t("installing");try{await Di(e),l("installed")}catch(x){c(x)}return}}catch{}if(g){clearInterval(f);try{if((await lt.purchases.checkout(e.id)).alreadyOwned){t("installing"),await Di(e),l("installed");return}}catch{}l("cancelled")}},2e3)})}function QY({item:e,localInfo:t,purchased:n,onStatusChange:r,highlight:i,onHighlightDone:l,onViewDetail:c}){const{t:d}=gt(["store"]),[m,f]=k.useState(!1),[h,g]=k.useState(""),y=k.useRef(null),[x,w]=k.useState(!1);k.useEffect(()=>{if(i&&y.current){y.current.scrollIntoView({behavior:"smooth",block:"center"}),w(!0);const q=setTimeout(()=>{w(!1)},4e3);return()=>clearTimeout(q)}},[i,l]);const T=t?.installed??!1,C=T&&e.version&&t?.localVersion&&WY(e.version,t.localVersion),S=(e.priceCents??0)>0,E=async q=>{if(q.stopPropagation(),!m){f(!0),g("");try{await Di(e),g(C?d("card.upgraded"):d("card.installed")+"!"),r()}catch(Q){const B=Q instanceof Error?Q.message:"";B.includes("402")||B.includes("Purchase required")?g(d("card.purchaseRequired")):g(d("card.failed"))}finally{f(!1)}}},j=async q=>{if(q.stopPropagation(),!m){f(!0),g("");try{await eb(e,B=>{B==="checkout_opened"?g(d("card.waitingPurchase","Waiting for purchase...")):B==="installing"&&g(d("card.installing"))})==="installed"?(g(d("card.installed")+"!"),r()):g("")}catch(Q){g(Q instanceof Error?Q.message:d("card.failed"))}finally{f(!1)}}},M=S?`$${((e.priceCents??0)/100).toFixed(2)}`:null,O=e.slug&&e.author?.username?`${lt.getUrl()}/@${encodeURIComponent(e.author.username)}/${encodeURIComponent(e.slug)}`:null,D=()=>{T&&c?c(Ic(e)):O&&window.open(O,"_blank","noopener,noreferrer")},H=s.jsxs(s.Fragment,{children:[C?s.jsx("button",{onClick:q=>{E(q)},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})}):T?s.jsxs("button",{onClick:q=>{E(q)},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:q=>{j(q)},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")," ",M]})}):s.jsx("button",{onClick:q=>{E(q)},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(ga,{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:T,glowing:x,onClick:D,actions:H})})}function K4({template:e,lang:t,onClose:n,onHire:r}){const{t:i}=gt(["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:i("hireModal.title")}),s.jsx("p",{className:"text-xs text-fg-tertiary",children:i("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:i("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:i("hireModal.assignTeam")}),s.jsxs("select",{value:d,onChange:w=>m(w.target.value),className:"input-field",children:[s.jsx("option",{value:"",children:i("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:i("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:i("hireModal.role")}),s.jsx("div",{className:"text-fg-secondary font-mono",children:e.roleId}),s.jsx("div",{className:"text-fg-tertiary",children:i("hireModal.position")}),s.jsx("div",{className:"text-fg-secondary capitalize",children:e.agentRole}),s.jsx("div",{className:"text-fg-tertiary",children:i("hireModal.skills")}),s.jsx("div",{className:"text-fg-secondary",children:e.skills.join(", ")||i("hireModal.none")})]})]})]}),s.jsxs("div",{className:"flex justify-end gap-3 mt-6",children:[s.jsx("button",{onClick:n,className:"btn-secondary",children:i("hireModal.cancel")}),s.jsx("button",{onClick:x,disabled:!l.trim()||g,className:"btn-primary",children:i(g?"hireModal.creating_progress":"hireModal.create")})]})]})})}function ih(e,t){const n=e.i18n?.[t];return n?.displayName||n?.name||e.name}function V4(e,t){return e.i18n?.[t]?.description||e.description}function W4(e,t,n){return e.i18n?.[n]?.members?.[t]||t}function ZY(e,t){const n=e.split(".").map(Number),r=t.split(".").map(Number);for(let i=0;i<Math.max(n.length,r.length);i++){const l=n[i]??0,c=r[i]??0;if(l>c)return!0;if(l<c)return!1}return!1}function JY({highlightItemId:e,onHighlightDone:t}={}){const{t:n,i18n:r}=gt(["store","common"]),i=r.language,[l,c]=k.useState(""),[d,m]=k.useState([]),[f,h]=k.useState([]),[g,y]=k.useState(null),[x,w]=k.useState({}),[T,C]=k.useState(!0),[S,E]=k.useState(!1),[j,M]=k.useState(null),[O,D]=k.useState(new Map),[H,q]=k.useState(new Set),[Q,B]=k.useState(null),J=k.useCallback(async()=>{try{const[F,te]=await Promise.all([Ee.builder.artifacts.list().catch(()=>({artifacts:[]})),Ee.builder.artifacts.installed().catch(()=>({installed:{}}))]),L=new Map;for(const ee of F.artifacts){if(ee.type!=="team")continue;const ue=!!te.installed[`team/${ee.name}`];L.set(ee.name,{installed:ue,localVersion:ee.meta.version||void 0,localUpdatedAt:ee.updatedAt})}D(L)}catch{}},[]),W=k.useCallback(async()=>{C(!0);try{const F=l?lt.search({type:"team",q:l,limit:50}):Ri(Ir.hubTeams)??lt.search({type:"team",limit:50}),[te,L]=await Promise.all([F.catch(()=>({items:[],total:0})),Ee.teamTemplates.list(l||void 0).catch(()=>({templates:[]})),J(),lt.isAuthenticated()?lt.purchases.mine().then(ue=>q(new Set(ue.purchases.map(Se=>Se.itemId)))).catch(()=>{}):Promise.resolve()]),ee=await w6(te?.items??[],e);h(ee.items),m(L?.templates??[]),ee.missing&&t?.()}catch{m([]),h([])}finally{C(!1)}},[l,J,e,t]);k.useEffect(()=>{W()},[W]),k.useEffect(()=>{if(!g){w({});return}fetch(`/api/team-templates/${encodeURIComponent(g.id)}/files`,{credentials:"include"}).then(F=>F.json()).then(F=>w(F.files??{})).catch(()=>w({}))},[g]);const re=async F=>{E(!0),M(null);try{const L=(await Ee.teams.create(F.name,F.description)).team.id;let ee,ue=0;const Se=[];for(const G of F.members){const me=G.count??1;for(let P=0;P<me;P++){const _e=G.name??`${F.name} Agent ${P+1}`,He=me>1?`${_e} ${P+1}`:_e,Pe=G.roleName??G.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:L,agentRole:G.role??"worker",skills:G.skills??[]})});if(Ge.ok){ue++;const ut=await Ge.json();G.role==="manager"&&!ee&&(ee=ut.agent?.id)}else{const ut=await Ge.json().catch(()=>({error:`HTTP ${Ge.status}`}));Se.push(`${He}: ${ut.error??Ge.statusText}`)}}catch(Ge){Se.push(`${He}: ${String(Ge)}`)}}}ee&&await Ee.teams.update(L,{managerId:ee,managerType:"agent"}).catch(()=>{});const $=Se.length>0?` (${Se.length} failed: ${Se[0]})`:"";M({ok:ue>0,message:`Team "${ih(F,i)}" deployed with ${ue} agent(s)${$}`})}catch(te){M({ok:!1,message:`Failed: ${te}`})}finally{E(!1)}};if(Q)return s.jsx(zi,{type:Q.type,name:Q.name,onBack:()=>B(null)});if(g){const F={...x};g.announcements&&(F["ANNOUNCEMENT.md"]=g.announcements),g.norms&&(F["NORMS.md"]=g.norms);const te={type:"team",name:g.id,displayName:ih(g,i),version:g.version,description:V4(g,i),author:g.author,category:g.category??"general",tags:g.tags??[],files:F,team:{members:g.members.map(ee=>({name:W4(g,ee.name??ee.roleName??ee.templateId??"Agent",i),role:ee.role??"worker",roleName:ee.roleName??ee.templateId,count:ee.count??1,skills:ee.skills??[]}))}},L=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((ee,ue)=>{const Se=W4(g,ee.name??ee.roleName??ee.templateId??"Agent",i);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 ${ee.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 ${ee.role==="manager"?"bg-amber-500/15 text-amber-400":"bg-blue-500/15 text-blue-400"}`,children:ee.role??"worker"}),(ee.count??1)>1&&s.jsxs("span",{className:"text-[10px] text-fg-muted",children:["×",ee.count]})]}),(ee.roleName||ee.templateId)&&s.jsx("div",{className:"text-[10px] text-fg-tertiary font-mono mt-0.5",children:ee.roleName??ee.templateId})]}),ee.skills&&ee.skills.length>0&&s.jsxs("div",{className:"flex flex-wrap gap-1 shrink-0",children:[ee.skills.slice(0,3).map($=>s.jsx("span",{className:"px-1.5 py-0.5 text-[9px] bg-surface-elevated text-fg-muted rounded border border-border-default",children:$},$)),ee.skills.length>3&&s.jsxs("span",{className:"text-[9px] text-fg-muted",children:["+",ee.skills.length-3]})]})]},ue)})})]});return s.jsx(s.Fragment,{children:s.jsx(zi,{type:"team",name:g.id,onBack:()=>{y(null),M(null)},readOnly:!0,initialManifest:te,contentSlot:L,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:()=>{re(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:F=>c(F.target.value),className:"px-3 py-1.5 bg-surface-elevated border border-border-default rounded-lg text-sm max-w-xs w-full focus:border-brand-500 focus:outline-none"})]}),s.jsx("div",{className:"flex-1 overflow-y-auto p-7 space-y-8",children:T?s.jsx("div",{className:"grid grid-cols-1 lg:grid-cols-2 gap-4",children:Array.from({length:4}).map((F,te)=>s.jsx("div",{className:"h-56 rounded-2xl skeleton"},te))}):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(Pr,{columns:2,children:d.map(F=>s.jsx(ga,{type:"team",name:ih(F,i),description:V4(F,i),seed:F.id,icon:F.icon||"users",version:F.version,category:F.category,tags:F.tags,authorLabel:F.author,hideStats:!0,showTypeBadge:!1,cornerLabel:n("teamStore.builtin"),onClick:()=>y(F)},F.id))})]}),f.length>0&&s.jsxs("section",{children:[s.jsx("h3",{className:"section-title mb-3",children:n("teamStore.markusHub")}),s.jsx(Pr,{columns:2,children:f.map(F=>s.jsx(eX,{item:F,localInfo:O.get(Ic(F)),purchased:e0(F,H),onStatusChange:J,highlight:F.id===e,onHighlightDone:t,onViewDetail:te=>B({type:"team",name:te})},F.id))})]})]})})]})}function eX({item:e,localInfo:t,purchased:n,onStatusChange:r,highlight:i,onHighlightDone:l,onViewDetail:c}){const{t:d}=gt(["store"]),[m,f]=k.useState(!1),[h,g]=k.useState(""),y=k.useRef(null),[x,w]=k.useState(!1);k.useEffect(()=>{if(i&&y.current){y.current.scrollIntoView({behavior:"smooth",block:"center"}),w(!0);const q=setTimeout(()=>{w(!1)},4e3);return()=>clearTimeout(q)}},[i,l]);const T=t?.installed??!1,C=T&&e.version&&t?.localVersion&&ZY(e.version,t.localVersion),S=(e.priceCents??0)>0,E=S?`$${((e.priceCents??0)/100).toFixed(2)}`:null,j=async q=>{if(q.stopPropagation(),!m){f(!0),g("");try{await Di(e),g(C?d("card.upgraded"):d("card.installed")+"!"),r()}catch(Q){const B=Q instanceof Error?Q.message:"";B.includes("402")||B.includes("Purchase required")?g(d("card.purchaseRequired")):g(d("card.failed"))}finally{f(!1)}}},M=async q=>{if(q.stopPropagation(),!m){f(!0),g("");try{await eb(e,B=>{B==="checkout_opened"?g(d("card.waitingPurchase","Waiting for purchase...")):B==="installing"&&g(d("card.installing"))})==="installed"?(g(d("card.installed")+"!"),r()):g("")}catch(Q){g(Q instanceof Error?Q.message:d("card.failed"))}finally{f(!1)}}},O=e.slug&&e.author?.username?`${lt.getUrl()}/@${encodeURIComponent(e.author.username)}/${encodeURIComponent(e.slug)}`:null,D=()=>{T&&c?c(Ic(e)):O&&window.open(O,"_blank","noopener,noreferrer")},H=s.jsxs(s.Fragment,{children:[C?s.jsx("button",{onClick:q=>{j(q)},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})}):T?s.jsxs("button",{onClick:q=>{j(q)},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:q=>{M(q)},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:q=>{j(q)},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(ga,{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:T,glowing:x,onClick:D,actions:H})})}function oh(e,t){return e.i18n?.[t]?.displayName||e.name}function lh(e,t){return e.i18n?.[t]?.description||e.description||""}function k6(e,t){const n=e.split(".").map(Number),r=t.split(".").map(Number);for(let i=0;i<Math.max(n.length,r.length);i++){const l=n[i]??0,c=r[i]??0;if(l>c)return!0;if(l<c)return!1}return!1}const tX={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 nX({item:e,installedSkills:t,purchased:n,onMsg:r,onRefresh:i}){const{t:l}=gt(["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&&k6(e.version,f.version),y=(e.priceCents??0)>0,[x,w]=k.useState(""),T=async()=>{if(!c){d(!0),w("");try{await Di(e),r(g?`Upgraded ${e.name}`:`Installed ${e.name}`,"success"),i()}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)}}},C=async()=>{if(!c){d(!0),w("");try{await eb(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"),i()),w("")}catch(S){r(S instanceof Error?S.message:l("card.failed"),"error"),w("")}finally{d(!1)}}};if(g)return 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",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:()=>{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 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:()=>{T()},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 Y4({item:e,installedSkills:t,purchased:n,onMsg:r,onRefresh:i,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(ga,{type:d,showTypeBadge:d!=="skill",name:e.name,description:e.description,seed:e.slug||e.name,icon:e.icon||Kd(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(nX,{item:e,installedSkills:t,purchased:n,onMsg:r,onRefresh:i})})})}function rX({highlightItemId:e,onHighlightDone:t}={}){const{t:n,i18n:r}=gt(["store","common"]),i=r.language,l=Wo(),[c,d]=k.useState("skills"),[m,f]=k.useState(null),[h,g]=k.useState(new Set),[y,x]=k.useState([]),[w,T]=k.useState(null),[C,S]=k.useState([]),[E,j]=k.useState(0),[M,O]=k.useState(1),[D,H]=k.useState([]),[q,Q]=k.useState(""),[B,J]=k.useState("score"),[W,re]=k.useState(""),[F,te]=k.useState(!1),[L,ee]=k.useState([]),[ue,Se]=k.useState(!1),[$,G]=k.useState([]),[me,P]=k.useState(""),[_e,He]=k.useState(!1),[Pe,Ge]=k.useState([]),[ut,pt]=k.useState([]),[ht,Mt]=k.useState(new Set),[Bt,Qt]=k.useState(!1),[wt,Ue]=k.useState(""),ft=[{id:"skills",labelKey:"skillStore.tabs.all"},{id:"skillhub",labelKey:"skillStore.tabs.skillhub"},{id:"skillssh",labelKey:"skillStore.tabs.skillssh"}],kt=(U,ae="success")=>{f({text:U,type:ae}),setTimeout(()=>f(null),ae==="error"?1e4:4e3)},Nt=k.useCallback(async()=>{try{const U=await Ee.skills.list();x(U.skills)}catch{}},[]),zt=k.useCallback(async()=>{Se(!0);try{const U=await Ee.skills.builtin();ee(U.skills)}catch{}Se(!1)},[]),ce=k.useCallback(async U=>{te(!0);try{const ae=await Ee.skills.registrySkillhub({q:U?.q,category:U?.category,page:U?.page??1,limit:24,sort:U?.sort??B});S(ae.skills),j(ae.total),ae.categories?.length&&H(ae.categories)}catch{}te(!1)},[B]),tt=k.useCallback(async U=>{He(!0);try{const ae=await Ee.skills.registrySkillssh(U);G(ae.skills)}catch{}He(!1)},[]),rt=k.useCallback(async U=>{Qt(!0);try{const ae=U?lt.search({type:"skill",q:U,limit:50}):Ri(Ir.hubSkills)??lt.search({type:"skill",limit:50}),Ce=lt.search({subtype:"connector",q:U||void 0,limit:50}).catch(()=>({items:[]})),[Re,ze]=await Promise.all([ae,Ce,lt.isAuthenticated()?lt.purchases.mine().then(pe=>Mt(new Set(pe.purchases.map(Fe=>Fe.itemId)))).catch(()=>{}):Promise.resolve()]);let X=Re?.items??[],Z=ze?.items??[];if(e){const pe=X.some(Oe=>Oe.id===e),Fe=Z.some(Oe=>Oe.id===e);if(!pe&&!Fe)try{const{item:Oe}=await lt.getItem(e);Oe?.subtype==="connector"?Z=[Oe,...Z]:Oe?X=[Oe,...X]:t?.()}catch{t?.()}else pe&&(X=[X.find($e=>$e.id===e),...X.filter($e=>$e.id!==e)]),Fe&&(Z=[Z.find($e=>$e.id===e),...Z.filter($e=>$e.id!==e)])}Ge(X),pt(Z)}catch{}Qt(!1)},[e,t]);k.useEffect(()=>{Nt(),zt(),ce(),tt()},[]),k.useEffect(()=>{c==="skills"&&rt(wt)},[c,wt,rt]);const be=async U=>{g(ae=>new Set(ae).add(U.name));try{const ae=await Ee.skills.install({name:U.name,source:"skillhub",slug:U.slug,sourceUrl:U.homepage,description:U.description_zh??U.description,category:"custom",version:U.version});await Nt(),kt(`"${U.name}" installed (${ae.method}) → ${ae.path}`),window.dispatchEvent(new CustomEvent("markus:data-changed"))}catch{kt(`Download failed for "${U.name}". You can try manually from: ${U.homepage}`,"error")}g(ae=>{const Ce=new Set(ae);return Ce.delete(U.name),Ce})},je=async U=>{g(ae=>new Set(ae).add(U.name));try{const ae=await Ee.skills.install({name:U.name,source:"skillssh",sourceUrl:U.url,githubRepo:`${U.author}/${U.repo}`,githubSkillPath:U.name});await Nt(),kt(`"${U.name}" installed (${ae.method}) → ${ae.path}`),window.dispatchEvent(new CustomEvent("markus:data-changed"))}catch{kt(`Download failed for "${U.name}". You can try manually from: ${U.url}`,"error")}g(ae=>{const Ce=new Set(ae);return Ce.delete(U.name),Ce})},Ae=async U=>{g(ae=>new Set(ae).add(U.name));try{const ae=await Ee.skills.install({name:U.name,source:"builtin"});await Nt(),await zt(),kt(`"${U.name}" installed (${ae.method}) → ${ae.path}`),window.dispatchEvent(new CustomEvent("markus:data-changed"))}catch(ae){kt(`Install failed for "${U.name}": ${ae}`,"error")}g(ae=>{const Ce=new Set(ae);return Ce.delete(U.name),Ce})},oe=$.filter(U=>{if(!me)return!0;const ae=me.toLowerCase();return U.name.toLowerCase().includes(ae)||U.repo.toLowerCase().includes(ae)});if(w){const U=w,ae={};U.instructions&&(ae["SKILL.md"]=U.instructions);const Ce={type:"skill",name:U.name,displayName:oh(U,i),version:U.version,description:lh(U,i),author:U.author??"",category:U.category??"general",tags:U.tags,files:ae,skill:{skillFile:U.instructions?"SKILL.md":"",requiredPermissions:U.requiredPermissions,mcpServers:void 0,alwaysOn:!1}},Re=U.installed&&U.installedVersion&&k6(U.version,U.installedVersion)?s.jsx("button",{onClick:()=>{Ae(U)},disabled:h.has(U.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(U.name)?n("card.upgrading"):n("card.upgrade",{version:U.version})}):U.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"),U.installedVersion?` v${U.installedVersion}`:""]}):s.jsx("button",{onClick:()=>{Ae(U)},disabled:h.has(U.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(U.name)?n("card.installing"):n("card.install")}),ze=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:[U.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 ${tX[U.category]??"bg-gray-500/15 text-fg-secondary"}`,children:U.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:U.version})]}),U.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"})]}),U.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:"✓"})]})]})]}),(U.requiredPermissions.length>0||U.tags.length>0)&&s.jsxs("div",{className:"space-y-4",children:[U.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:U.requiredPermissions.map(X=>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:X},X))})]}),U.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:U.tags.map(X=>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:X},X))})]})]})]});return s.jsxs(s.Fragment,{children:[s.jsx(zi,{type:"skill",name:U.name,onBack:()=>T(null),readOnly:!0,initialManifest:Ce,actionSlot:Re,contentSlot:ze}),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:ft.map(U=>s.jsx("button",{onClick:()=>d(U.id),className:`px-3 py-1.5 text-xs rounded-lg transition-colors shrink-0 ${c===U.id?"bg-brand-600 text-white":"text-fg-secondary hover:text-fg-primary hover:bg-surface-elevated"}`,children:n(U.labelKey)},U.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 U=wt.trim().toLowerCase(),ae=U?L.filter(ze=>oh(ze,i).toLowerCase().includes(U)||lh(ze,i).toLowerCase().includes(U)):L,Ce=ue&&Bt,Re=ae.length===0&&Pe.length===0&&ut.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:wt,onChange:ze=>Ue(ze.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"}`})}),Ce&&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((ze,X)=>s.jsx("div",{className:"h-56 rounded-2xl skeleton"},X))}):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:[ae.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:ae.length})})]}),s.jsx(Pr,{columns:3,children:ae.map(ze=>s.jsx(ga,{type:"skill",name:oh(ze,i),description:lh(ze,i),seed:ze.name,icon:Kd(ze.name,ze.category),version:ze.version,category:ze.category,tags:ze.tags,authorLabel:ze.author||void 0,installed:ze.installed,hideStats:!0,showTypeBadge:!1,cornerLabel:ze.installed?void 0:n("skillStore.tabs.builtin"),onClick:()=>T(ze)},ze.name))})]}),Pe.length>0&&s.jsxs("section",{children:[s.jsx("h3",{className:"section-title mb-3",children:n("skillStore.tabs.markusHub")}),s.jsx(Pr,{columns:3,children:Pe.map(ze=>s.jsx(Y4,{item:ze,installedSkills:y,purchased:e0(ze,ht),onMsg:kt,onRefresh:()=>{Nt(),rt(wt)},highlight:ze.id===e,onHighlightDone:t},ze.id))})]}),ut.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(Pr,{columns:3,children:ut.map(ze=>s.jsx(Y4,{item:ze,type:"connector",installedSkills:y,purchased:e0(ze,ht),onMsg:kt,onRefresh:()=>{Nt(),rt(wt)},highlight:ze.id===e,onHighlightDone:t},ze.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:q,onChange:U=>{Q(U.target.value),O(1),ce({q:W||void 0,category:U.target.value||void 0,page:1})},className:"px-2 py-1.5 bg-surface-elevated border border-border-default rounded-lg text-xs text-fg-secondary outline-none",children:[s.jsx("option",{value:"",children:n("skillStore.allCategories")}),D.map(U=>s.jsx("option",{value:U,children:U},U))]}),s.jsxs("select",{value:B,onChange:U=>{J(U.target.value),O(1),ce({q:W||void 0,category:q||void 0,page:1,sort:U.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:W,onChange:U=>re(U.target.value),onKeyDown:U=>{U.key==="Enter"&&(O(1),ce({q:W||void 0,category:q||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:()=>{O(1),ce({q:W||void 0,category:q||void 0,page:1})},className:"px-3 py-1.5 bg-brand-600 hover:bg-brand-500 text-white text-xs rounded-lg shrink-0",children:"Search"})]}),F?s.jsx("div",{className:"text-center text-fg-tertiary py-20",children:s.jsx("div",{className:"animate-pulse",children:n("skillStore.loadingSkillhub")})}):C.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(Pr,{columns:3,children:C.map(U=>{const ae=y.some(Ce=>Ce.name===U.name||Ce.name===U.slug);return s.jsx(ga,{type:"skill",name:U.name,description:U.description_zh??U.description??"",seed:U.slug,icon:Kd(U.slug||U.name,U.tags?.[0]),version:U.version,authorLabel:"SkillHub",showTypeBadge:!1,tags:U.tags,installed:ae,hideStats:!0,onClick:()=>window.open(U.homepage,"_blank","noopener,noreferrer"),footerLeft:s.jsxs("span",{className:"flex items-center gap-2 text-[10px] text-fg-tertiary",children:[U.stars>0&&s.jsxs("span",{className:"text-amber-600",children:["★ ",U.stars.toLocaleString()]}),U.downloads>0&&s.jsxs("span",{children:[U.downloads>=1e4?`${(U.downloads/1e4).toFixed(1)}万`:U.downloads.toLocaleString()," ",n("skillStore.downloads")]})]}),actions:ae?void 0:s.jsx("button",{onClick:()=>{be(U)},disabled:h.has(U.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(U.name)?"...":n("card.install")})},U.slug)})}),E>24&&s.jsxs("div",{className:"flex items-center justify-center gap-2 mt-6",children:[s.jsx("button",{disabled:M<=1,onClick:()=>{const U=M-1;O(U),ce({q:W||void 0,category:q||void 0,page:U})},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:M,total:Math.ceil(E/24)})}),s.jsx("button",{disabled:M>=Math.ceil(E/24),onClick:()=>{const U=M+1;O(U),ce({q:W||void 0,category:q||void 0,page:U})},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:me,onChange:U=>P(U.target.value),onKeyDown:U=>{U.key==="Enter"&&me.trim()&&tt(me)},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:()=>{me.trim()&&tt(me)},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(Pr,{columns:3,children:oe.map(U=>{const ae=y.some(Ce=>Ce.name===U.name);return s.jsx(ga,{type:"skill",name:U.name,description:U.description||"",seed:`${U.author}-${U.name}`,icon:Kd(U.name),authorLabel:`${U.author}/${U.repo}`,showTypeBadge:!1,installed:ae,hideStats:!0,cornerLabel:ae?void 0:"skills.sh",onClick:()=>window.open(U.url,"_blank","noopener,noreferrer"),footerLeft:U.installs?s.jsxs("span",{className:"text-[10px] text-fg-tertiary",children:[U.installs," installs"]}):void 0,actions:ae?void 0:s.jsx("button",{onClick:()=>{je(U)},disabled:h.has(U.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(U.name)?"...":n("card.install")})},`${U.author}-${U.name}`)})})]})]})}const aX=["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 sX({item:e,onOpen:t}){const n=nl(e.subtype==="connector"?"connector":e.itemType),r=Jg(n,e.slug||e.name),i=Pi[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 · ",i.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:["↓ ",Io(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 X4({items:e,onOpen:t}){return s.jsx(Pr,{columns:3,children:e.map(n=>s.jsx(ga,{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(Pr,{columns:3,children:Array.from({length:6}).map((e,t)=>s.jsx("div",{className:"h-64 rounded-2xl skeleton"},t))})}function iX({onOpenType:e}){const{t}=gt(["store","common"]),[n,r]=k.useState([]),[i,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(nl(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:aX.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 ${Pi[g].gradient} hover:opacity-90 transition-opacity`,children:[Pi[g].labelZh,s.jsx("span",{className:"opacity-70",children:Pi[g].label})]},g))})]}),i?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(sX,{item:g,onOpen:()=>h(g)},g.id))}):null,s.jsxs("section",{children:[s.jsx(ch,{title:t("discover.trending","热门趋势"),subtitle:t("discover.trendingSub","社区中下载与评分增长最快的资产")}),i?s.jsx(Q4,{}):d.length>0?s.jsx(X4,{items:d,onOpen:h}):s.jsx(oX,{})]}),s.jsxs("section",{children:[s.jsx(ch,{title:t("discover.fresh","新鲜上架"),subtitle:t("discover.freshSub","来自创作者的最新作品")}),i?s.jsx(Q4,{}):m.length>0?s.jsx(X4,{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," 作品 · ↓ ",Io(g.downloads)]})]},g.author?.username||y))})]})]})}function oX(){const{t:e}=gt(["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 Ld(e,t,n){return e.i18n?.[n]?.[t]}function lX(){const{t:e,i18n:t}=gt(["store","common"]),n=Wo(),r=t.language,[i,l]=k.useState([]),[c,d]=k.useState({}),[m,f]=k.useState(new Set),[h,g]=k.useState(null),[y,x]=k.useState(!0),[w,T]=k.useState(""),[C,S]=k.useState("all"),[E,j]=k.useState(null),M=k.useCallback(async()=>{x(!0);try{const[H,q,Q,B]=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:[]}))]),J={};for(const F of Q.updates)J[F.name]={availableVersion:F.availableVersion,installedVersion:F.installedVersion,displayName:F.displayName,description:F.description};d(J);const W=H.artifacts.filter(F=>{const te=`${F.type}/${F.name}`;return!!q.installed[te]}),re=new Set(W.filter(F=>F.type==="skill").map(F=>F.name));for(const F of B.skills)!F.installed||re.has(F.name)||!(q.installed[`skill/${F.name}`]||J[F.name])&&!F.updateAvailable||!q.installed[`skill/${F.name}`]&&!J[F.name]||(W.push({type:"skill",name:F.name,meta:{displayName:F.i18n?.[r]?.displayName||F.name,description:F.i18n?.[r]?.description||F.description||"",version:F.installedVersion||F.version,author:F.author,category:F.category,tags:F.tags,i18n:F.i18n},path:"",updatedAt:""}),re.add(F.name));for(const[F,te]of Object.entries(J))re.has(F)||(W.push({type:"skill",name:F,meta:{displayName:te.displayName||F,description:te.description||"",version:te.installedVersion},path:"",updatedAt:""}),re.add(F));l(W)}catch{}x(!1)},[r]);k.useEffect(()=>{M()},[M]),k.useEffect(()=>{const H=()=>{M()};return window.addEventListener("markus:data-changed",H),()=>window.removeEventListener("markus:data-changed",H)},[M]),k.useEffect(()=>{if(!h)return;const H=setTimeout(()=>g(null),3e3);return()=>clearTimeout(H)},[h]);const O=async(H,q)=>{if(!m.has(H)){f(Q=>new Set(Q).add(H));try{await Ee.skills.install({name:H,source:"builtin"});try{localStorage.removeItem("markus:template-updates-ack")}catch{}g({text:e("installedTab.updateSuccess",{name:H,version:q}),type:"success"}),window.dispatchEvent(new CustomEvent("markus:data-changed")),await M()}catch{g({text:e("installedTab.updateFailed",{name:H}),type:"error"})}f(Q=>{const B=new Set(Q);return B.delete(H),B})}},D=i.filter(H=>{if(C!=="all"&&H.type!==C)return!1;if(!w)return!0;const q=w.toLowerCase(),Q=(Ld(H.meta,"displayName",r)||H.meta.displayName||H.name).toLowerCase(),B=(Ld(H.meta,"description",r)||H.meta.description||"").toLowerCase();return Q.includes(q)||B.includes(q)}).sort((H,q)=>{const Q=H.type==="skill"&&c[H.name]?1:0;return(q.type==="skill"&&c[q.name]?1:0)-Q});return E?s.jsx(zi,{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(H=>s.jsx("button",{onClick:()=>S(H),className:`px-3 py-1 text-xs rounded-md transition-colors ${C===H?"bg-brand-600 text-white":"text-fg-secondary hover:text-fg-primary hover:bg-surface-elevated"}`,children:e(`installedTab.filter${H==="all"?"All":H==="agent"?"Agents":H==="team"?"Teams":"Skills"}`)},H))}),s.jsx("div",{className:"flex-1 min-w-[120px]",children:s.jsx("input",{type:"text",placeholder:e("installedTab.searchPlaceholder"),value:w,onChange:H=>T(H.target.value),className:"px-3 py-1.5 bg-surface-elevated border border-border-default rounded-lg text-sm w-full focus:border-brand-500 focus:outline-none"})})]}),s.jsx("div",{className:`flex-1 overflow-y-auto ${n?"p-4":"p-7"}`,children:y?s.jsx("div",{className:"text-center text-fg-tertiary py-20 animate-pulse",children:e("installedTab.loading")}):D.length===0?s.jsxs("div",{className:"text-center py-20",children:[s.jsx("div",{className:"text-4xl mb-4 opacity-30",children:"⧉"}),s.jsx("div",{className:"text-fg-secondary font-medium mb-1",children:e("installedTab.noItems")}),s.jsx("div",{className:"text-fg-tertiary text-sm",children:e("installedTab.noItemsHint")})]}):s.jsx(Pr,{columns:3,children:D.map(H=>{const q=Ld(H.meta,"displayName",r)||H.meta.displayName||H.name,Q=Ld(H.meta,"description",r)||H.meta.description||"",B=H.meta.version||"",J=H.meta.author||"",W=H.meta.tags??[],re=H.meta.category||"",F=H.meta.icon,te=F&&/\.(png|jpe?g|gif|webp|svg)$/i.test(F)&&!F.startsWith("http")&&!F.startsWith("data:")&&!F.startsWith("/")?`/api/builder/artifacts/${H.type}s/${encodeURIComponent(H.name)}/${F}`:F,L=H.type==="skill"?c[H.name]:void 0;return s.jsx(ga,{type:H.type,name:q,description:Q,seed:H.name,icon:te,author:null,authorLabel:J||void 0,version:L?L.installedVersion:B,category:re,tags:W,installed:!L,hideStats:!0,cornerLabel:L?e("installedTab.updateAvailable"):void 0,onClick:()=>{H.path&&j({type:H.type,name:H.name})},actions:L?s.jsx("button",{type:"button",disabled:m.has(H.name),onClick:()=>{O(H.name,L.availableVersion)},className:"px-3 py-1.5 text-xs font-medium bg-amber-600 hover:bg-amber-500 text-white rounded-lg disabled:opacity-50 transition-colors",children:m.has(H.name)?e("installedTab.updating"):e("installedTab.updateTo",{version:L.availableVersion})}):void 0},`${H.type}/${H.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 cX=50,uX=30;function dX(e,t,n,r){const i=k.useRef(0),l=k.useRef(0),c=k.useCallback(m=>{i.current=m.touches[0].clientX,l.current=m.touches[0].clientY},[]),d=k.useCallback(m=>{const f=m.changedTouches[0].clientX-i.current,h=m.changedTouches[0].clientY-l.current,g=Math.abs(f),y=Math.abs(h);if(g<cX||Math.atan2(y,g)*(180/Math.PI)>uX)return;if(r?.scrollContainerRef?.current){const T=r.scrollContainerRef.current,C=T.scrollLeft<=1,S=T.scrollLeft+T.clientWidth>=T.scrollWidth-1;if(f>0&&!C||f<0&&!S)return}const w=e.findIndex(T=>T.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 mX=["builder","discover","agents","teams","skills","installed"],fX={agent:"agents",team:"teams",skill:"skills",connector:"skills"};function og(e){return!!e&&mX.includes(e)}function Z4(){const e=localStorage.getItem("markus_nav_installItem"),t=localStorage.getItem("markus_nav_storeTab");return{tab:og(t)?t:"builder",installId:e}}function pX({authUser:e}){const{t}=gt(["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(Z4),[i,l]=k.useState(r.tab),[c,d]=k.useState(r.installId),m=dX(n,i,l);k.useEffect(()=>{const h=Z4();h.installId&&(d(h.installId),og(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");og(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(fX[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(Bw,{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 ${i===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:[i==="builder"&&s.jsx(y6,{authUser:e}),i==="discover"&&s.jsx(iX,{onOpenType:f}),i==="agents"&&s.jsx(XY,{authUser:e,highlightItemId:c,onHighlightDone:()=>d(null)}),i==="teams"&&s.jsx(JY,{highlightItemId:c,onHighlightDone:()=>d(null)}),i==="skills"&&s.jsx(rX,{highlightItemId:c,onHighlightDone:()=>d(null)}),i==="installed"&&s.jsx(lX,{})]})]})}const J4="usageType",uh="profile";function hX({onComplete:e,theme:t,onThemeChange:n,skipProfile:r,onProfileUpdated:i}){const{t:l}=gt(["onboarding","common"]),[c,d]=k.useState(0),[m,f]=k.useState(""),[h,g]=k.useState(""),[y,x]=k.useState(""),[w,T]=k.useState(""),[C,S]=k.useState(!1),[E,j]=k.useState(""),[M,O]=k.useState(!1),[D,H]=k.useState(null);k.useEffect(()=>{Ee.auth.me().then(({user:Ue})=>{Ue.name&&f(Ue.name),Ue.email&&g(Ue.email),Ue.avatarUrl&&H(Ue.avatarUrl);const ft=Ue.name||Ue.email?.split("@")[0]||"";ft&&J(kt=>kt||l("usageType.defaultOrgName",{name:ft}))}).catch(()=>{}),Ee.settings.getOrg().then(({org:Ue})=>{Ue?.name&&Ue.name!=="My Organization"&&J(Ue.name)}).catch(()=>{}),En()&&Ee.hubOrgs.invitations().then(Ue=>{Ue.invitations?.length>0&&Se(Ue.invitations)}).catch(()=>{})},[]);const[q,Q]=k.useState(null),[B,J]=k.useState(""),[W,re]=k.useState(!1),[F,te]=k.useState(!1),[L,ee]=k.useState(""),[ue,Se]=k.useState([]),[$,G]=k.useState(null),[me,P]=k.useState(null),_e=async()=>{const Ue=B.trim();if(Ue){re(!0),ee("");try{if(await Ee.settings.updateOrg(Ue),En()){const ft=await Ee.hubOrgs.mine(),kt=ft.orgs?.find(Nt=>Nt.role==="owner")??ft.orgs?.[0];kt?.id?await Ee.hubOrgs.update(kt.id,{name:Ue}):await Ee.hubOrgs.create(Ue)}te(!0)}catch{ee(l("usageType.orgNameSaveFailed"))}finally{re(!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),i?.(Ue),O(!0)}catch{j(l("profile.errors.saveFailed"))}finally{S(!1)}},ut=[{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")}],pt=[{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(T8,{i18nKey:"welcome.description",ns:"onboarding",components:{strong:s.jsx("strong",{className:"text-fg-primary"})}})})},{id:J4,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:()=>{Q("personal"),te(!0)},className:`flex flex-col items-center gap-3 rounded-xl border-2 p-5 transition-all text-left ${q==="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:()=>{Q("organization"),te(!1)},className:`flex flex-col items-center gap-3 rounded-xl border-2 p-5 transition-all text-left ${q==="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."})})]})]})]}),q==="organization"&&s.jsxs("div",{className:"space-y-4 mt-4",children:[ue.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")}),ue.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()=>{G(Ue.orgId);try{await Ee.hubOrgs.acceptInvitation(Ue.orgId),P(Ue.orgId),te(!0)}catch{}finally{G(null)}},disabled:$===Ue.orgId||me===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:me===Ue.orgId?l("usageType.accepted"):$===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:B,onChange:Ue=>{J(Ue.target.value),te(!1),ee("")},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"})]}),L&&s.jsx("p",{className:"text-xs text-red-500",children:L}),s.jsx("button",{onClick:()=>{_e()},disabled:W||!B.trim()||F,className:"w-full px-4 py-2.5 bg-brand-600 hover:bg-brand-500 disabled:opacity-40 text-white text-sm rounded-xl transition-colors",children:l(W?"common:saving":F?"usageType.orgNameSaved":"usageType.setOrgName")})]})]})},{id:uh,title:l("profile.title"),subtitle:l("profile.subtitle"),content:M?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(Pw,{currentUrl:D,name:m,size:64,targetType:"user"})}),s.jsxs("div",{className:"space-y-1",children:[s.jsxs("label",{className:"text-xs text-fg-tertiary font-medium",children:[l("profile.nameLabel")," ",s.jsx("span",{className:"text-red-500",children:"*"})]}),s.jsx("input",{type:"text",value:m,onChange: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=>T(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:C||!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(C?"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:ut.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")})]})]})}],ht=r?pt.filter(Ue=>Ue.id!==uh):pt,Mt=ht.findIndex(Ue=>Ue.id===J4),Bt=ht.findIndex(Ue=>Ue.id===uh),Qt=()=>{c===Mt&&Mt>=0&&!q||c===Mt&&q==="organization"&&!F||c===Bt&&Bt>=0&&!M||(c<ht.length-1?d(c+1):(fetch("/api/settings/telemetry",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({enabled:He})}).catch(()=>{}),e()))},wt=ht[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:ht.map((Ue,ft)=>s.jsx("div",{className:`h-1 flex-1 rounded-full transition-colors ${ft<=c?"bg-brand-500":"bg-surface-elevated"}`},ft))}),s.jsx("h2",{className:"text-2xl font-bold text-fg-primary",children:wt.title}),s.jsx("p",{className:"text-sm text-fg-secondary mt-1 mb-6",children:wt.subtitle}),wt.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:Qt,disabled:Bt>=0&&c===Bt&&!M||Mt>=0&&c===Mt&&(!q||q==="organization"&&!F),className:`px-6 py-2.5 text-white text-sm rounded-xl transition-colors ${Bt>=0&&c===Bt&&!M||Mt>=0&&c===Mt&&(!q||q==="organization"&&!F)?"bg-brand-600/40 cursor-not-allowed":"bg-brand-600 hover:bg-brand-500"}`,children:c===ht.length-1?l("getStarted"):l("common:next")})]})]})})})}const ew="markus:legal-consent",gX="https://markus.global";function bX({onLogin:e,hasOwner:t}){const{t:n,i18n:r}=gt("auth"),[i,l]=k.useState(null),[c,d]=k.useState(""),[m,f]=k.useState(!1),[h,g]=k.useState(""),[y,x]=k.useState(""),[w,T]=k.useState(!1),[C,S]=k.useState(!1),E=J=>{const W=(r.language||"").toLowerCase().startsWith("zh")?"?lang=zh":"";return`${gX}${J}${W}`},j=()=>{try{localStorage.setItem(ew,JSON.stringify({acceptedAt:new Date().toISOString(),terms:!0,privacy:!0}))}catch{}},M=()=>C?(j(),!0):(T(!1),requestAnimationFrame(()=>T(!0)),!1),O=async()=>{const J=En(),W=ha();if(!J||!W){d(n("login.hubUnavailable"));return}const re=await Ee.auth.hubLogin(J,W);if(window.markusDesktop?.clearPendingDeepLinkAuth?.(),re.cloudAiReady===!1)try{sessionStorage.setItem("markus:cloud-ai-warning",re.cloudAiError?n("login.cloudAiNotReady",{error:re.cloudAiError}):n("login.cloudAiNotReadyGeneric"))}catch{}e(re.user,re.needsOnboarding??!1,{fromHub:!0})},D=async(J,W=!1)=>{if(!(!W&&!M())){d(""),l(J??"hub");try{if(W&&En()&&ha()){await O();return}await Qr(J),await O()}catch(re){const F=re instanceof Error?re.message:"";if(!F.includes("cancelled")){if(!W&&En())return D(J,!0);d(F||n("login.hubUnavailable"))}}finally{l(null)}}},H=()=>{oI(),l(null),d("")};k.useEffect(()=>{const J=window.markusDesktop;if(!J?.peekPendingDeepLinkAuth&&!J?.consumePendingDeepLinkAuth)return;let W=!1;return(async()=>{const re=J.peekPendingDeepLinkAuth?await J.peekPendingDeepLinkAuth():null;if(W||!re)return;let F=!1;try{F=!!localStorage.getItem(ew)}catch{}if(!C&&!F){d(n("login.consentRequired"));return}F&&!C&&S(!0),j();const te=J.consumePendingDeepLinkAuth?await J.consumePendingDeepLinkAuth():re;if(!(W||!te)){d(""),l("hub");try{if(!await iI(te)||!En()||!ha()){d(n("login.hubUnavailable"));return}await O()}catch{d(n("login.hubUnavailable"))}finally{W||l(null)}}})().catch(()=>{}),()=>{W=!0}},[C]);const q=async J=>{if(J.preventDefault(),!(!h.trim()||!y)&&M()){d(""),l("local");try{const{user:W,needsOnboarding:re}=await Ee.auth.login(h.trim(),y);e(W,re??!1)}catch{d(n("login.invalidCredentials"))}finally{l(null)}}},Q=n(t?"login.welcomeBack":"login.getStarted"),B="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:Q})]}),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:q,className:"space-y-3",children:[s.jsx("input",{type:"email",value:h,onChange:J=>g(J.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:J=>x(J.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:i==="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(i==="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:()=>D("google"),disabled:!!i,className:B,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(i==="google"?"login.connectingHub":"login.withGoogle")]}),s.jsxs("button",{onClick:()=>D("github"),disabled:!!i,className:B,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(i==="github"?"login.connectingHub":"login.withGithub")]}),s.jsxs("button",{onClick:()=>D("email"),disabled:!!i,className:B,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(i==="email"?"login.connectingHub":"login.withEmail")]}),i&&(i==="google"||i==="github"||i==="email"||i==="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:H,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:!!i,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:()=>T(!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:C,onChange:J=>{S(J.target.checked),J.target.checked&&T(!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 xX({token:e,onComplete:t}){const{t:n}=gt("auth"),[r,i]=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),[T,C]=k.useState(!1);k.useEffect(()=>{Ee.auth.inviteInfo(e).then(E=>i(E)).catch(()=>C(!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:T?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 yX({onComplete:e,isFirstTime:t}){const{t:n}=gt("auth"),[r,i]=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=>i(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 vX({side:e,defaultWidth:t,minWidth:n,maxWidth:r,collapsedWidth:i=0,storageKey:l}){const[c,d]=k.useState(()=>{try{const T=localStorage.getItem(`${l}_w`);if(T)return Math.max(n,Math.min(r,parseInt(T,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(T=>Math.max(n,Math.min(r,T)))},[n,r]);const x=k.useCallback(T=>{T.preventDefault(),h.current=!0;const C=T.clientX,S=c,E=M=>{if(!h.current)return;const O=M.clientX-C;d(Math.max(g.current,Math.min(y.current,S+O)))},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(T=>!T),[]);return{width:m?i:c,rawWidth:c,collapsed:m,toggle:w,setCollapsed:f,setWidth:d,onResizeStart:x}}const SQ=[{value:"system",label:"System"},{value:"light",label:"Light"},{value:"dark",label:"Dark"},{value:"cyberpunk",label:"Cyberpunk"},{value:"mono",label:"Mono"}],lg="markus-theme";function tw(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 wX(){try{const e=localStorage.getItem(lg);if(e==="midnight")return localStorage.setItem(lg,"dark"),"dark";if(e==="light"||e==="dark"||e==="system"||e==="cyberpunk"||e==="mono")return e}catch{}return"system"}function kX(){const[e,t]=k.useState(wX),n=k.useCallback(r=>{t(r);try{localStorage.setItem(lg,r)}catch{}tw(r)},[]);return k.useEffect(()=>{tw(e)},[e]),{mode:e,setMode:n}}const Wd={agents:[],tasks:[],requirements:[],projects:[],deliverables:[],workflows:[]},SX={team:["agents","workflows","tasks","requirements","projects","deliverables"],work:["workflows","projects","requirements","tasks","agents","deliverables"],deliverables:["deliverables","agents","tasks","requirements","projects","workflows"]},NX=["agents","tasks","requirements","projects","deliverables","workflows"];let nw="",rw="all",aw=Wd,sw=!1;function CX({onClose:e,currentPage:t}){const{t:n}=gt(["common","home","work"]);Vo(!0);const[r,i]=k.useState(nw),[l,c]=k.useState(rw),[d,m]=k.useState(aw),[f,h]=k.useState(!1),[g,y]=k.useState(sw),[x,w]=k.useState(-1);k.useEffect(()=>{nw=r},[r]),k.useEffect(()=>{rw=l},[l]),k.useEffect(()=>{aw=d},[d]),k.useEffect(()=>{sw=g},[g]);const T=k.useRef(null),C=k.useRef(void 0),S=k.useRef(null),E=k.useRef(null);k.useEffect(()=>{setTimeout(()=>{T.current?.focus(),T.current?.select()},100)},[]);const j=k.useCallback(async re=>{if(!re.trim()){m(Wd),y(!1),w(-1);return}h(!0),y(!0),w(-1);const F=re.toLowerCase();try{const[te,L,ee,ue,Se,$]=await Promise.allSettled([Ee.agents.list(),Ee.tasks.list({search:re,pageSize:20}),Ee.requirements.list(),Ee.projects.list(),Ee.deliverables.search({q:re,limit:20}),Ee.teams.list()]),G=te.status==="fulfilled"?te.value.agents.filter(Ge=>Ge.name?.toLowerCase().includes(F)||Ge.role?.toLowerCase().includes(F)):[],me=L.status==="fulfilled"?L.value.tasks:[],P=ee.status==="fulfilled"?ee.value.requirements.filter(Ge=>Ge.title?.toLowerCase().includes(F)||Ge.description?.toLowerCase().includes(F)):[],_e=ue.status==="fulfilled"?ue.value.projects.filter(Ge=>Ge.name?.toLowerCase().includes(F)||Ge.description?.toLowerCase().includes(F)):[],He=Se.status==="fulfilled"?Se.value.results:[],Pe=[];if($.status==="fulfilled"){const Ge=await Promise.allSettled($.value.teams.map(ut=>Ee.workflows.list(ut.id)));for(const ut of Ge)if(ut.status==="fulfilled")for(const pt of ut.value.workflows)(pt.name.toLowerCase().includes(F)||(pt.displayName||"").toLowerCase().includes(F)||pt.description?.toLowerCase().includes(F))&&Pe.push(pt)}m({agents:G,tasks:me,requirements:P,projects:_e,deliverables:He,workflows:Pe})}catch{m(Wd)}finally{h(!1)}},[]),M=re=>{i(re),C.current&&clearTimeout(C.current),C.current=setTimeout(()=>j(re),400)},O=k.useCallback((re,F)=>{e(),it.navigate(re,F)},[e]),D=[{id:"all",label:n("common:all",{defaultValue:"全部"})},{id:"agents",label:n("common:agents",{defaultValue:"智能体"})},{id:"tasks",label:n("common:tasks",{defaultValue:"任务"})},{id:"requirements",label:n("common:requirements",{defaultValue:"需求"})},{id:"projects",label:n("common:projects",{defaultValue:"项目"})},{id:"deliverables",label:n("common:deliverables",{defaultValue:"交付物"})},{id:"workflows",label:n("common:workflows",{defaultValue:"工作流"})}],H=k.useMemo(()=>SX[t||""]||NX,[t]),q=k.useMemo(()=>{const re=[],F=l==="all"?8:void 0,te=L=>{if(l!=="all"&&l!==L)return;const ee=d[L].length;if(L==="workflows"){const ue=F?d.workflows.slice(0,F):d.workflows;for(const Se of ue)re.push({id:Se.name,type:"workflow",page:le.WORK,params:{boardType:"workflows"}})}else{const ue=d[L],Se=F?ue.slice(0,F):ue;for(const $ of Se)switch(L){case"agents":re.push({id:$.id,type:"agent",page:le.TEAM,params:{agentId:$.id}});break;case"tasks":re.push({id:$.id,type:"task",page:le.WORK,params:{openTask:$.id}});break;case"requirements":re.push({id:$.id,type:"requirement",page:le.WORK,params:{openRequirement:$.id}});break;case"projects":re.push({id:$.id,type:"project",page:le.WORK,params:{projectId:$.id}});break;case"deliverables":re.push({id:$.id,type:"deliverable",page:le.DELIVERABLES,params:{openDeliverable:$.id}});break}}F&&ee>F&&re.push({id:`more_${L}`,type:"showMore",page:"",expandCategory:L,totalCount:ee})};for(const L of H)te(L);return re},[d,l,H]),Q=k.useCallback(re=>{if(re.type==="showMore"&&re.expandCategory){c(re.expandCategory),w(-1);return}O(re.page,re.params)},[O]);k.useEffect(()=>{const re=E.current;if(!re||x<0)return;const F=re.querySelector(`[data-idx="${x}"]`);F&&F.scrollIntoView({block:"nearest"})},[x]);const B=k.useCallback(re=>{if(re.key==="Escape"){e();return}if(re.key==="Tab"){re.preventDefault();const L=D.map(Se=>Se.id),ee=L.indexOf(l),ue=re.shiftKey?ee<=0?L.length-1:ee-1:ee>=L.length-1?0:ee+1;c(L[ue]),w(-1);return}const F=re.ctrlKey&&re.key==="n"||re.key==="ArrowDown",te=re.ctrlKey&&re.key==="p"||re.key==="ArrowUp";if(F||te){re.preventDefault(),w(L=>{const ee=q.length-1;return ee<0?-1:F?L>=ee?0:L+1:L<=0?ee:L-1});return}re.key==="Enter"&&(re.preventDefault(),x>=0&&x<q.length&&Q(q[x]))},[e,q,x,Q,D,l]);k.useEffect(()=>(document.addEventListener("keydown",B),()=>document.removeEventListener("keydown",B)),[B]);const J=q.length>0;let W=0;return s.jsx("div",{ref:S,className:"fixed inset-0 bg-black/50 flex items-start justify-center z-50 pt-[8vh]",onClick:re=>{re.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:T,value:r,onChange:re=>M(re.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:()=>{i(""),m(Wd),y(!1),w(-1),T.current?.focus()},className:"absolute right-3 top-1/2 -translate-y-1/2 text-fg-tertiary hover:text-fg-secondary",children:s.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[s.jsx("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),s.jsx("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]})})]}),s.jsx("div",{className:"flex gap-1 overflow-x-auto scrollbar-hide",children:D.map(re=>s.jsx("button",{onClick:()=>{c(re.id),w(-1)},className:`px-3 py-1.5 text-xs rounded-lg whitespace-nowrap transition-colors ${l===re.id?"bg-brand-600 text-white":"bg-surface-elevated text-fg-secondary hover:text-fg-primary"}`,children:re.label},re.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&&!J&&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&&J&&s.jsx("div",{className:"space-y-4",children:H.map(re=>{if(l!=="all"&&l!==re)return null;const F=l==="all"?8:void 0,te=L=>{const ee=W++,ue=L==="agents"?d.agents.length:L==="tasks"?d.tasks.length:L==="requirements"?d.requirements.length:L==="projects"?d.projects.length:L==="workflows"?d.workflows.length:d.deliverables.length;return s.jsxs("button",{"data-idx":ee,onClick:()=>{c(L),w(-1)},className:`mt-1 w-full text-xs py-1.5 rounded-lg transition-colors ${ee===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:"查看全部"})," (",ue,")"]})};return re==="agents"&&d.agents.length>0?s.jsxs("section",{children:[s.jsx("h3",{className:"text-xs font-medium text-fg-tertiary uppercase mb-2",children:n("common:agents",{defaultValue:"智能体"})}),s.jsx("div",{className:"space-y-0.5",children:(F?d.agents.slice(0,F):d.agents).map(L=>{const ee=W++;return s.jsxs("button",{"data-idx":ee,onClick:()=>O(le.TEAM,{agentId:L.id}),className:`w-full flex items-center gap-3 px-3 py-2 rounded-xl transition-colors text-left ${ee===x?"bg-brand-600/15 ring-1 ring-brand-500/40":"hover:bg-surface-overlay"}`,children:[s.jsx(Ys,{name:L.name||"Agent",avatarUrl:L.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:L.name}),s.jsx("div",{className:"text-xs text-fg-tertiary truncate",children:L.role||L.status})]}),s.jsx(TX,{status:L.status})]},L.id)})}),F&&d.agents.length>F&&te("agents")]},"agents"):re==="tasks"&&d.tasks.length>0?s.jsxs("section",{children:[s.jsx("h3",{className:"text-xs font-medium text-fg-tertiary uppercase mb-2",children:n("common:tasks",{defaultValue:"任务"})}),s.jsx("div",{className:"space-y-0.5",children:(F?d.tasks.slice(0,F):d.tasks).map(L=>{const ee=W++;return s.jsxs("button",{"data-idx":ee,onClick:()=>O(le.WORK,{openTask:L.id}),className:`w-full flex items-center gap-3 px-3 py-2 rounded-xl transition-colors text-left ${ee===x?"bg-brand-600/15 ring-1 ring-brand-500/40":"hover:bg-surface-overlay"}`,children:[s.jsx(AX,{status:L.status}),s.jsxs("div",{className:"flex-1 min-w-0",children:[s.jsx("div",{className:"text-sm text-fg-primary truncate",children:L.title}),s.jsxs("div",{className:"text-xs text-fg-tertiary truncate",children:[L.status," · ",L.priority||""]})]})]},L.id)})}),F&&d.tasks.length>F&&te("tasks")]},"tasks"):re==="requirements"&&d.requirements.length>0?s.jsxs("section",{children:[s.jsx("h3",{className:"text-xs font-medium text-fg-tertiary uppercase mb-2",children:n("common:requirements",{defaultValue:"需求"})}),s.jsx("div",{className:"space-y-0.5",children:(F?d.requirements.slice(0,F):d.requirements).map(L=>{const ee=W++;return s.jsxs("button",{"data-idx":ee,onClick:()=>O(le.WORK,{openRequirement:L.id}),className:`w-full flex items-center gap-3 px-3 py-2 rounded-xl transition-colors text-left ${ee===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 ${L.status==="approved"?"text-green-500 bg-green-500/15":L.status==="pending"?"text-amber-500 bg-amber-500/15":L.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:L.title}),s.jsxs("div",{className:"text-xs text-fg-tertiary truncate",children:[L.status," · ",L.priority||""]})]})]},L.id)})}),F&&d.requirements.length>F&&te("requirements")]},"requirements"):re==="projects"&&d.projects.length>0?s.jsxs("section",{children:[s.jsx("h3",{className:"text-xs font-medium text-fg-tertiary uppercase mb-2",children:n("common:projects",{defaultValue:"项目"})}),s.jsx("div",{className:"space-y-0.5",children:(F?d.projects.slice(0,F):d.projects).map(L=>{const ee=W++;return s.jsxs("button",{"data-idx":ee,onClick:()=>O(le.WORK,{projectId:L.id}),className:`w-full flex items-center gap-3 px-3 py-2 rounded-xl transition-colors text-left ${ee===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:L.name}),L.description&&s.jsx("div",{className:"text-xs text-fg-tertiary truncate",children:L.description})]})]},L.id)})}),F&&d.projects.length>F&&te("projects")]},"projects"):re==="deliverables"&&d.deliverables.length>0?s.jsxs("section",{children:[s.jsx("h3",{className:"text-xs font-medium text-fg-tertiary uppercase mb-2",children:n("common:deliverables",{defaultValue:"交付物"})}),s.jsx("div",{className:"space-y-0.5",children:(F?d.deliverables.slice(0,F):d.deliverables).map(L=>{const ee=W++;return s.jsxs("button",{"data-idx":ee,onClick:()=>O(le.DELIVERABLES,{openDeliverable:L.id}),className:`w-full flex items-center gap-3 px-3 py-2 rounded-xl transition-colors text-left ${ee===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:L.title}),s.jsxs("div",{className:"text-xs text-fg-tertiary truncate",children:[L.type," · ",L.status]})]})]},L.id)})}),F&&d.deliverables.length>F&&te("deliverables")]},"deliverables"):re==="workflows"&&d.workflows.length>0?s.jsxs("section",{children:[s.jsx("h3",{className:"text-xs font-medium text-fg-tertiary uppercase mb-2",children:n("common:workflows",{defaultValue:"工作流"})}),s.jsx("div",{className:"space-y-0.5",children:(F?d.workflows.slice(0,F):d.workflows).map(L=>{const ee=W++;return s.jsxs("button",{"data-idx":ee,onClick:()=>O(le.WORK,{boardType:"workflows"}),className:`w-full flex items-center gap-3 px-3 py-2 rounded-xl transition-colors text-left ${ee===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:L.displayName||L.name}),s.jsxs("div",{className:"text-xs text-fg-tertiary truncate",children:[L.stepCount," steps · v",L.version]})]})]},L.name)})}),F&&d.workflows.length>F&&te("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 TX({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 AX({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 EX=[{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 _X(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 jX(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 iw(e){return e instanceof HTMLElement?e.closest(".xterm")!==null:!1}const MX=["layout","navigation","tasks","team","search","rightPanel","terminal","help"];function RX(e){return e===le.TEAM?"team":e===le.WORK?"work":e===le.DELIVERABLES?"deliverables":e===le.STORE?"store":"any"}function DX({open:e,onClose:t,page:n}){const{t:r}=gt("common"),i=typeof navigator<"u"&&navigator.platform.toUpperCase().includes("MAC"),l=RX(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:MX.map(c=>{const d=EX.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:_X(m.keys,i,m.bare)})]},m.id))})]},c)})})]})}):null}function LX({authUser:e,onClose:t,onSaved:n,onUserUpdated:r}){const{t:i}=gt("common");Vo(!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(()=>Ow(e.avatarUrl,ha()?.avatarUrl)),T=async C=>{if(C.preventDefault(),!l.trim()){y(i("profile.nameRequired"));return}if(d&&!/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(d.trim())){y(i("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(i("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:T,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:"text-base font-semibold mb-5",children:i("profile.editProfile")}),s.jsx("div",{className:"flex justify-center mb-5",children:s.jsx(Pw,{currentUrl:x,name:l,size:72,targetType:"user",targetId:e.id,onUploaded:C=>{w(C),r?.({...e,avatarUrl:C})}})}),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:i("profile.name")}),s.jsx("input",{value:l,onChange:C=>c(C.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:i("profile.email")}),s.jsx("input",{value:d,onChange:C=>m(C.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:i("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:i(f?"saving":"save")})]})]})})}const ow=k.lazy(()=>ta(()=>import("./Team-BLcZORSs.js"),__vite__mapDeps([2,3,4,5,6])).then(e=>({default:e.TeamPage}))),lw=k.lazy(()=>ta(()=>import("./Settings-B90Lsxn1.js"),[]).then(e=>({default:e.Settings}))),OX=k.lazy(()=>ta(()=>import("./Store-DOYqG495.js"),[]).then(e=>({default:e.StorePage}))),IX=k.lazy(()=>ta(()=>Promise.resolve().then(()=>VY),void 0).then(e=>({default:e.AgentBuilder}))),cw=k.lazy(()=>ta(()=>import("./Work-FiluoP3I.js"),__vite__mapDeps([7,4,1,8,3,9])).then(e=>({default:e.WorkPage}))),uw=k.lazy(()=>ta(()=>import("./Deliverables-Bx8nwOQ9.js"),__vite__mapDeps([10,4,5])).then(e=>({default:e.DeliverablesPage}))),PX=k.lazy(()=>ta(()=>import("./Notifications-CApxHk72.js"),[]).then(e=>({default:e.NotificationsPage}))),BX=k.lazy(()=>ta(()=>import("./Search-Afkxd1a6.js"),[]).then(e=>({default:e.SearchPage}))),zX={visibility:"hidden",position:"absolute",inset:0,pointerEvents:"none",zIndex:-1};function $X(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 HX(){return s.jsx("div",{className:"flex-1 flex items-center justify-center text-fg-tertiary text-sm animate-pulse",children:"Loading..."})}const UX=k.memo(function({id:t,activePage:n,children:r}){const i=t===n;return s.jsx("div",{className:"flex-1 overflow-hidden flex flex-col",style:i?void 0:zX,children:s.jsx(k.Suspense,{fallback:s.jsx(HX,{}),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}),Od={};function S6(e){return typeof window<"u"&&window.matchMedia("(max-width: 767px)").matches?Tw[e]??e:e}function dw(){return S6(bc())}function FX(){const{t:e}=gt("common"),[t,n]=k.useState(dw),[r,i]=k.useState(!1),[l,c]=k.useState(!0),d=Wo(),m=kX(),f=vX({side:"left",defaultWidth:160,minWidth:140,maxWidth:400,collapsedWidth:64,storageKey:"markus_sidebar"}),[h,g]=k.useState(()=>new Set([dw()])),[y,x]=k.useState("loading"),[w,T]=k.useState(!1),[C,S]=k.useState(null),[E,j]=k.useState({hasOwner:!1,hasMultipleUsers:!1}),[M,O]=k.useState(!1),[D,H]=k.useState(!1),[q,Q]=k.useState(null),[B,J]=k.useState(!1),[W,re]=k.useState(null),[F,te]=k.useState(()=>{const X=localStorage.getItem("markus_update_dismissed");return X||null}),[L,ee]=k.useState(!1),[ue,Se]=k.useState(!1),$=Oc(),G=$?.leftCollapsed??!1,me=$?.toggleLeftCollapsed,P=$?.setLeftCollapsed,_e=$?.keyboardPane??"l0",He=$?.setKeyboardPane,Pe=$?.l0FocusPageId??null,Ge=$?.setL0FocusPageId,ut=k.useRef(t);ut.current=t;const pt=k.useRef(le.HOME),ht=$?.toggleRightPanel,Mt=$?.toggleTerminalPanel,Bt=$?.cycleRightPanelTab,Qt=$?.activateRightPanelTabAt,wt=$?.openNewRightPanelTab,Ue=$?.rightPanelOpen??!1,ft=$?.activeRightPanelTabId??null,kt=$?.openRightPanel,Nt=$?.closeRightPanelTab,zt=$?.updateRightPanelBrowserTab,ce=$?.updateRightPanelTerminalTab,tt=k.useRef($?.rightPanelTabs);tt.current=$?.rightPanelTabs,k.useEffect(()=>{const X=window.markusDesktop?.browser?.onPageEvent;if(!(!X||!kt))return X(Z=>{if(Z.type==="closed"){const pe=tt.current?.find(Fe=>Fe.payload.kind==="url"&&Fe.payload.browserId===Z.browserId);pe&&Nt&&Nt(pe.id);return}if(Z.type==="navigated"){if(Z.url&&yc(Z.url))return;Z.browserId&&zt&&zt(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_")||cV(Z.browserId)||Z.url&&yc(Z.url))return;kt({kind:"url",url:Z.url||"about:blank",title:Z.title||Z.url||"Browser",browserId:Z.browserId,pageId:Z.pageId})}})},[kt,Nt,zt]),k.useEffect(()=>{const X=window.markusDesktop?.terminal?.onEvent;if(!(!X||!kt))return X(Z=>{if(Z.type==="closed"){const pe=tt.current?.find(Fe=>Fe.payload.kind==="terminal"&&Fe.payload.terminalId===Z.id);pe&&Nt&&Nt(pe.id);return}if(Z.type==="cwd"){Z.cwd&&ce?.(Z.id,{cwd:Z.cwd});return}if(Z.type==="selected"){(Z.title||Z.cwd)&&ce?.(Z.id,{title:Z.title,cwd:Z.cwd});return}if(Z.type==="opened"){if(Yg.has(Z.id)){(Z.title||Z.cwd)&&ce?.(Z.id,{title:Z.title,cwd:Z.cwd});return}ji(Z.id),kt({kind:"terminal",terminalId:Z.id,title:Z.title||"Terminal",cwd:Z.cwd})}})},[kt,Nt,ce]);const rt=$?.handleTerminalExit;k.useEffect(()=>{const X=window.markusDesktop?.terminal?.onExit;if(!(!X||!rt))return X(Z=>{rt(Z.id)})},[rt]),k.useLayoutEffect(()=>{const X=t===le.TEAM&&Ue&&$?.rightPanelMode==="browser";up(X)},[t,Ue,$?.rightPanelMode]),k.useEffect(()=>{window.markusDesktop?.browser?.hideAll?.()},[]);const be=k.useRef(!1);k.useEffect(()=>{if(!be.current){be.current=!0;return}f.setCollapsed(G)},[G,f.setCollapsed]),k.useEffect(()=>{if(d)return;const X=navigator.platform.toUpperCase().includes("MAC"),Z=Fe=>{X&&Fe.metaKey&&!Fe.ctrlKey&&Fe.key==="p"?(Fe.preventDefault(),ee(Oe=>!Oe)):!X&&Fe.ctrlKey&&!Fe.metaKey&&Fe.key==="p"&&(Fe.preventDefault(),ee(Oe=>!Oe))},pe=()=>ee(!0);return document.addEventListener("keydown",Z),window.addEventListener("markus:open-search",pe),()=>{document.removeEventListener("keydown",Z),window.removeEventListener("markus:open-search",pe)}},[d]);const je=k.useCallback(()=>!Ue||!ft||!Nt?!1:(Nt(ft),!0),[Ue,ft,Nt]);k.useEffect(()=>{const X=window.markusDesktop?.onAppShortcut?.(Z=>{if(Z.type==="close-tab"){je();return}Z.type==="new-tab"&&wt?.()});return()=>{X?.()}},[je,wt]),k.useEffect(()=>{if(d||!me||!ht)return;const X=navigator.platform.toUpperCase().includes("MAC"),Z=pe=>{if(!(X?pe.metaKey&&!pe.ctrlKey:pe.ctrlKey&&!pe.metaKey)||pe.altKey)return;if(!pe.shiftKey&&(pe.key==="/"||pe.code==="Slash")){pe.preventDefault(),Se($e=>!$e);return}if(pe.shiftKey&&(pe.key==="?"||pe.key==="/")){pe.preventDefault(),Se($e=>!$e);return}if(pe.shiftKey&&Ue&&Bt){if(pe.key==="]"||pe.code==="BracketRight"){pe.preventDefault(),Bt(1);return}if(pe.key==="["||pe.code==="BracketLeft"){pe.preventDefault(),Bt(-1);return}}if(!pe.shiftKey&&Ue&&Qt){const $e=pe.key>="1"&&pe.key<="9"?Number(pe.key):0;if($e>=1){pe.preventDefault(),Qt($e-1);return}}if(pe.shiftKey)return;const Oe=pe.key.toLowerCase();if(Oe==="w"){pe.preventDefault(),pe.stopPropagation(),je();return}if(Oe==="t"){pe.preventDefault(),wt?.();return}if(Oe==="b"){if(t===le.DELIVERABLES)return;pe.preventDefault(),me()}else if(t===le.TEAM&&Oe==="l"){if(!X&&iw(pe.target)||X&&iw(pe.target)&&pe.ctrlKey)return;pe.preventDefault(),ht()}else t===le.TEAM&&Oe==="j"&&Mt&&(pe.preventDefault(),Mt())};return document.addEventListener("keydown",Z,!0),()=>document.removeEventListener("keydown",Z,!0)},[d,t,me,ht,Mt,Bt,Qt,Ue,je,wt]);const Ae=k.useCallback((X,Z)=>{let pe=gc(X);d?pe=Tw[pe]??pe:pe===le.NOTIFICATIONS&&(pe=le.HOME),pe!==le.TEAM&&up(!1);const Fe=bc(),Oe=window.location.hash.slice(1);Oe!==hh(Fe)?Od[Fe]=Oe:delete Od[Fe];const $e=ut.current;if(pe===le.SETTINGS&&$e!==le.SETTINGS&&(pt.current=$e,it.setSettingsReturnPage($e),He?.("l1"),Ge?.(le.SETTINGS)),$e===le.SETTINGS&&pe!==le.SETTINGS&&(He?.("l0"),Ge?.(pe)),pe===le.SETTINGS&&Z?.tab){const ye=`settings/${Z.tab}`;Od[pe]=ye,history.pushState(null,"","#"+ye),window.dispatchEvent(new HashChangeEvent("hashchange")),n(pe),g(Ye=>Ye.has(pe)?Ye:new Set([...Ye,pe]));return}const Y=pe!==le.WORK?Od[pe]:void 0;Y&&Y!==hh(pe)?(history.pushState(null,"",Oi(pe)),history.pushState(null,"","#"+Y)):history.pushState(null,"",Oi(pe)),window.dispatchEvent(new HashChangeEvent("hashchange")),n(pe),g(ye=>ye.has(pe)?ye:new Set([...ye,pe]))},[d,He,Ge]);k.useEffect(()=>{it.setHandler((X,Z)=>Ae(X,Z))},[Ae]),k.useEffect(()=>{_e==="l0"&&t!==le.SETTINGS&&Ge?.(t)},[_e,t,Ge]),k.useEffect(()=>{if(d||!He||!Ge)return;const X=Z=>{if(Z.metaKey||Z.ctrlKey||Z.altKey||jX(Z.target))return;const pe=Z.key.length===1?Z.key.toLowerCase():Z.key;if(t===le.SETTINGS&&(pe==="h"||pe==="ArrowLeft")){Z.preventDefault(),Z.stopImmediatePropagation(),it.leaveSettings();return}if(_e!=="l0"||t===le.SETTINGS)return;const Fe=Pe&&Co.includes(Pe)?Pe:t,Oe=Math.max(0,Co.indexOf(Fe));if(pe==="j"||pe==="ArrowDown"){Z.preventDefault(),Z.stopImmediatePropagation();const $e=Co[Math.min(Co.length-1,Oe+1)];Ge($e),$e!==t&&Ae($e),requestAnimationFrame(()=>{document.querySelector(`[data-l0-page-id="${$e}"]`)?.scrollIntoView({block:"nearest"})});return}if(pe==="k"||pe==="ArrowUp"){Z.preventDefault(),Z.stopImmediatePropagation();const $e=Co[Math.max(0,Oe-1)];Ge($e),$e!==t&&Ae($e),requestAnimationFrame(()=>{document.querySelector(`[data-l0-page-id="${$e}"]`)?.scrollIntoView({block:"nearest"})});return}if(pe==="l"||pe==="ArrowRight"||pe==="Enter"){const $e=Pe&&Co.includes(Pe)?Pe:t;if(!XO.has($e)){Z.preventDefault(),Z.stopImmediatePropagation();return}Z.preventDefault(),Z.stopImmediatePropagation(),$e!==t&&Ae($e),P?.(!1),He("l1");return}(pe==="h"||pe==="ArrowLeft")&&(Z.preventDefault(),Z.stopImmediatePropagation())};return document.addEventListener("keydown",X,!0),()=>document.removeEventListener("keydown",X,!0)},[d,_e,Pe,t,Ae,He,Ge,P]),k.useEffect(()=>{const X=()=>T(!0);return window.addEventListener("markus:open-edit-profile",X),()=>window.removeEventListener("markus:open-edit-profile",X)},[]),k.useEffect(()=>{if(!window.markusDesktop)return;!d&&t!==le.SETTINGS&&!f.collapsed?window.markusDesktop.setTrafficLightPosition(16,16):window.markusDesktop.setTrafficLightPosition(6,16)},[f.collapsed,t,d]),k.useEffect(()=>{window.markusDesktop&&window.markusDesktop.onNotificationClick(X=>{if(X.openNotifications&&window.dispatchEvent(new CustomEvent("markus:open-notifications")),X.page){const Z=gc(X.page);X.params&&Object.entries(X.params).forEach(([pe,Fe])=>localStorage.setItem(`markus_nav_${pe}`,Fe)),Ae(Z),window.dispatchEvent(new CustomEvent("markus:navigate",{detail:{page:Z,params:X.params}}))}})},[Ae]);const oe=k.useCallback(()=>{fetch("/api/settings/llm").then(X=>X.ok?X.json():null).then(X=>{if(X?.providers){const Z=Object.values(X.providers).some(pe=>pe.configured);Q(Z)}}).catch(()=>{})},[]),U=k.useCallback((X,Z)=>{if(!X)return;const Fe=Z&&{agent:"agents",team:"teams",skill:"skills"}[Z]||"agents";localStorage.setItem("markus_nav_installItem",X),localStorage.setItem("markus_nav_storeTab",Fe);const Oe=new URLSearchParams(window.location.search);Oe.get("install")||(Oe.set("install",X),Z&&Oe.set("type",Z));const $e=Oe.toString();window.history.replaceState(null,"",`${window.location.pathname}?${$e}${Oi(le.STORE)}`);const Y=()=>it.navigate(le.STORE,{storeTab:Fe,installItem:X});Y(),setTimeout(Y,500),setTimeout(Y,1500)},[]);k.useEffect(()=>{const X=new URLSearchParams(window.location.search),Z=X.get("install");Z&&U(Z,X.get("type"));const pe=window.markusDesktop;pe?.onDeepLinkInstall?.(({id:$e,type:Y})=>U($e,Y)),pe?.consumePendingDeepLinkInstall?.().then($e=>{$e?.id&&U($e.id,$e.type)}),Ee.auth.me().then(({user:$e})=>{x($e),S(!0),i(!1),$e.preferences?.guideHidden===!0&&!yh($e.id)&&vh($e.id),$X($e),ja.connect($e.id),oe(),Ee.health().then(ye=>{ye.updateAvailable&&ye.latestVersion&&re({latestVersion:ye.latestVersion,currentVersion:ye.version})}).catch(()=>{});const Y=()=>{Ni(Ir.builderArtifacts,()=>Ee.builder.artifacts.list()),Ni(Ir.builderAgents,()=>Ee.agents.list()),Ni(Ir.builderHubMyItems,()=>lt.myItems()),Ni(Ir.builderInstalled,()=>Ee.builder.artifacts.installed()),Ni(Ir.hubAgents,()=>lt.search({type:"agent",limit:50})),Ni(Ir.hubTeams,()=>lt.search({type:"team",limit:50})),Ni(Ir.hubSkills,()=>lt.search({type:"skill",limit:50}))};typeof requestIdleCallback=="function"?requestIdleCallback(Y,{timeout:5e3}):setTimeout(Y,3e3)}).catch(()=>{x(null),Ee.auth.status().then(({initialized:$e,hasOwner:Y,hasMultipleUsers:ye})=>{S($e),j({hasOwner:Y,hasMultipleUsers:ye})}).catch(()=>S(!0))}),ja.connect();const Fe=ja.on("notification",()=>{window.dispatchEvent(new CustomEvent("markus:notifications-changed"))}),Oe=()=>{const $e=S6(bc());$e!==le.TEAM&&up(!1),n($e),g(Y=>Y.has($e)?Y:new Set([...Y,$e]))};return window.addEventListener("hashchange",Oe),window.addEventListener("popstate",Oe),()=>{Fe(),ja.disconnect(),window.removeEventListener("hashchange",Oe),window.removeEventListener("popstate",Oe)}},[]);const ae=y!=="loading"&&y!==null?y:void 0,Ce=k.useMemo(()=>d?{[le.HOME]:s.jsx(bv,{authUser:ae}),[le.TEAM]:s.jsx(ow,{authUser:ae}),[le.BUILDER]:s.jsx(pX,{authUser:ae}),[le.SETTINGS]:s.jsx(lw,{theme:m.mode,onThemeChange:m.setMode,authUser:ae,onLogout:()=>{Ee.auth.logout().catch(()=>{}),Po(),x(null)},onUserUpdated:X=>x(X)}),[le.WORK]:s.jsx(cw,{authUser:ae}),[le.DELIVERABLES]:s.jsx(uw,{authUser:ae}),[le.NOTIFICATIONS]:s.jsx(PX,{authUser:ae}),[le.SEARCH]:s.jsx(BX,{})}:{[le.HOME]:s.jsx(bv,{authUser:ae}),[le.TEAM]:s.jsx(ow,{authUser:ae}),[le.SETTINGS]:s.jsx(lw,{theme:m.mode,onThemeChange:m.setMode,authUser:ae,onLogout:()=>{Ee.auth.logout().catch(()=>{}),Po(),x(null)},onUserUpdated:X=>x(X)}),[le.STORE]:s.jsx(OX,{authUser:ae}),[le.BUILDER]:s.jsx(IX,{authUser:ae}),[le.WORK]:s.jsx(cw,{authUser:ae}),[le.DELIVERABLES]:s.jsx(uw,{authUser:ae})},[ae?.id,ae?.role,m.mode,d]);if(y==="loading"||y===null&&C===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 ze=(typeof window<"u"?window.location.hash:"").match(/^#invite\?token=([a-f0-9]+)/);return ze?s.jsx(xX,{token:ze[1],onComplete:()=>{window.location.hash="",localStorage.removeItem("markus_onboarded"),i(!0),O(!0),x("loading"),Ee.auth.me().then(X=>{pv(X.user.id),x(X.user)}).catch(()=>x(null))}}):y===null?s.jsx(bX,{hasOwner:E.hasOwner,hasMultipleUsers:E.hasMultipleUsers,onLogin:(X,Z,pe)=>{x(X),ja.connect(X.id),Z?(pv(X.id),i(!0),pe?.fromHub&&O(!0)):(i(!1),yh(X.id)?(vh(X.id),Ee.auth.updatePreferences({guideHidden:!0}).catch(()=>{}),x({...X,preferences:{...X.preferences,guideHidden:!0}})):x(X))}}):D?s.jsx(yX,{onComplete:()=>H(!1),isFirstTime:!0}):r?s.jsx(hX,{theme:m.mode,onThemeChange:m.setMode,skipProfile:M,onProfileUpdated:X=>{const Z={id:X.id,name:X.name,email:X.email,role:X.role,orgId:X.orgId??"default",avatarUrl:X.avatarUrl};x(Z)},onComplete:()=>{localStorage.removeItem("markus_onboarded"),i(!1),O(!1),Ee.auth.me().then(X=>x(X.user)).catch(()=>{}),oe(),Ae(le.HOME)}}):s.jsxs("div",{className:`flex h-dvh bg-surface-primary text-fg-primary overflow-x-hidden ${d?"flex-col":""}`,children:[!d&&t!==le.SETTINGS&&s.jsxs(s.Fragment,{children:[s.jsx("div",{className:"relative z-40 shrink-0",style:{width:f.width},children:s.jsx(vY,{currentPage:t,onNavigate:X=>{Ae(X),c(!1),He?.("l0"),Ge?.(X)},authUser:y,collapsed:f.collapsed,onToggleCollapse:f.toggle,onLogout:()=>{Ee.auth.logout().catch(()=>{}),Po(),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!==le.SETTINGS&&t!==le.SEARCH?"pb-14":""}`,children:[q===!1&&!B&&t!==le.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:()=>J(!0),className:"text-amber-500 hover:text-amber-600 text-xs",children:e("dismiss")})]})]}),W&&F!==W.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:W.latestVersion,current:W.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:()=>{te(W.latestVersion),localStorage.setItem("markus_update_dismissed",W.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(Ce).map(X=>h.has(X)?s.jsx(UX,{id:X,activePage:t,children:Ce[X]},X):null)})]}),d&&t!==le.SETTINGS&&t!==le.SEARCH&&s.jsx(CY,{currentPage:t,onNavigate:Ae,userId:ae?.id}),d&&s.jsx(fI,{authUser:ae,onNavigate:Ae}),!d&&L&&s.jsx(CX,{onClose:()=>ee(!1),currentPage:t}),!d&&s.jsx(DX,{open:ue,onClose:()=>Se(!1),page:t}),w&&ae&&s.jsx(LX,{authUser:ae,onClose:()=>T(!1),onUserUpdated:X=>x(X),onSaved:X=>{T(!1),x(X)}})]})}L7.createRoot(document.getElementById("root")).render(s.jsx(k.StrictMode,{children:s.jsx(hV,{children:s.jsx(FX,{})})}));export{ha as $,Ys as A,Vo as B,as as C,Oi as D,wr as E,eI as F,XX as G,r6 as H,lX as I,tQ as J,N4 as K,L4 as L,Bw as M,bY as N,YW as O,le as P,WW as Q,GX as R,iX as S,XY as T,QX as U,sY as V,nQ as W,Ho as X,SQ as Y,KX as Z,ta as _,Wo as a,T8 as a0,VX as a1,WX as a2,ji as a3,Sd as a4,Xs as a5,r0 as a6,xQ as a7,rY as a8,HV as a9,vQ as aA,J3 as aB,mY as aC,bQ as aD,rQ as aE,YX as aF,JX as aG,t6 as aH,u4 as aa,UV as ab,Ii as ac,tl as ad,cQ as ae,NY as af,kQ as ag,fQ as ah,eQ as ai,lQ as aj,iQ as ak,oQ as al,aQ as am,dY as an,Zg as ao,sQ as ap,dQ as aq,mQ as ar,hQ as as,uQ as at,BV as au,wQ as av,pQ as aw,yQ as ax,gQ as ay,hY as az,mI as b,Oc as c,dX as d,JY as e,rX as f,Di as g,lt as h,jX as i,s as j,Da as k,Ee as l,vX as m,it as n,En as o,gc as p,Br as q,k as r,Qg as s,Qr as t,gt as u,qX as v,ja as w,Ec as x,A0 as y,E8 as z};