@markus-global/cli 0.10.1-rc.0 → 0.10.1

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 (64) hide show
  1. package/dist/markus.mjs +37 -10
  2. package/dist/web-ui/assets/{CommentInput-C745UDMQ.js → CommentInput-C3h-Yzay.js} +1 -1
  3. package/dist/web-ui/assets/{ContentRenderer-BL3f4UN5.js → ContentRenderer-zASgOqkn.js} +2 -2
  4. package/dist/web-ui/assets/{DeliverableShareModal-o1pbK67c.js → DeliverableShareModal-Dbnn1New.js} +1 -1
  5. package/dist/web-ui/assets/{Deliverables-D4ugAcBA.js → Deliverables-DJAIrKO-.js} +1 -1
  6. package/dist/web-ui/assets/{Notifications-DA8vJKEr.js → Notifications-Yg4YtKfK.js} +1 -1
  7. package/dist/web-ui/assets/{Search-xvm7dGkp.js → Search-BxrbCVbt.js} +1 -1
  8. package/dist/web-ui/assets/{Settings-x1XJ8_4m.js → Settings-D3Sk4wo8.js} +3 -3
  9. package/dist/web-ui/assets/{Store-CcHbeFLa.js → Store-_qnw3ukN.js} +1 -1
  10. package/dist/web-ui/assets/{Team-YUOVSMYB.js → Team-DJ1rMsS3.js} +29 -29
  11. package/dist/web-ui/assets/{Work-CWfGwHiq.js → Work-CB0n0sCV.js} +1 -1
  12. package/dist/web-ui/assets/{arc-De0cSzJU.js → arc-BjnJOOw9.js} +1 -1
  13. package/dist/web-ui/assets/{architectureDiagram-3BPJPVTR-BdWCyUwY.js → architectureDiagram-3BPJPVTR-CNCZskCC.js} +1 -1
  14. package/dist/web-ui/assets/{blockDiagram-GPEHLZMM-Cl6FrDyx.js → blockDiagram-GPEHLZMM-tvgynQ_P.js} +1 -1
  15. package/dist/web-ui/assets/{c4Diagram-AAUBKEIU-DoleWwBp.js → c4Diagram-AAUBKEIU-VjR6PhyJ.js} +1 -1
  16. package/dist/web-ui/assets/channel-CmOq1ZYv.js +1 -0
  17. package/dist/web-ui/assets/{chunk-2J33WTMH-CS1slQfm.js → chunk-2J33WTMH-ZF0vS7Am.js} +1 -1
  18. package/dist/web-ui/assets/{chunk-4BX2VUAB-BWcch029.js → chunk-4BX2VUAB-DIc3vKk2.js} +1 -1
  19. package/dist/web-ui/assets/{chunk-55IACEB6-DSbMTTT3.js → chunk-55IACEB6-DaYrbGjR.js} +1 -1
  20. package/dist/web-ui/assets/{chunk-727SXJPM-CqJoKpmq.js → chunk-727SXJPM-CLEluTgG.js} +1 -1
  21. package/dist/web-ui/assets/{chunk-AQP2D5EJ-pqcLwNvB.js → chunk-AQP2D5EJ-CvnOAGKW.js} +1 -1
  22. package/dist/web-ui/assets/{chunk-FMBD7UC4-vTCMHNNd.js → chunk-FMBD7UC4-B-08R9l2.js} +1 -1
  23. package/dist/web-ui/assets/{chunk-ND2GUHAM-CiYrvIJ7.js → chunk-ND2GUHAM-KSpUjU1U.js} +1 -1
  24. package/dist/web-ui/assets/{chunk-QZHKN3VN-s1fyx_zY.js → chunk-QZHKN3VN-d3Lb3-2g.js} +1 -1
  25. package/dist/web-ui/assets/classDiagram-4FO5ZUOK-DzFj83Mn.js +1 -0
  26. package/dist/web-ui/assets/classDiagram-v2-Q7XG4LA2-DzFj83Mn.js +1 -0
  27. package/dist/web-ui/assets/{cose-bilkent-S5V4N54A-CoLgGvvR.js → cose-bilkent-S5V4N54A-DfhCvOY4.js} +1 -1
  28. package/dist/web-ui/assets/{dagre-BM42HDAG-B5HqSIjs.js → dagre-BM42HDAG-DsnRWNK6.js} +1 -1
  29. package/dist/web-ui/assets/{diagram-2AECGRRQ-XvD9iWFV.js → diagram-2AECGRRQ-BWQQTl0l.js} +1 -1
  30. package/dist/web-ui/assets/{diagram-5GNKFQAL-C_RwD4mX.js → diagram-5GNKFQAL-CBk0iWkF.js} +1 -1
  31. package/dist/web-ui/assets/{diagram-KO2AKTUF-ooulajaZ.js → diagram-KO2AKTUF-DzzA482R.js} +1 -1
  32. package/dist/web-ui/assets/{diagram-LMA3HP47-DPrVAE1l.js → diagram-LMA3HP47-D2kcYGlo.js} +1 -1
  33. package/dist/web-ui/assets/{diagram-OG6HWLK6-DtGUL9Ar.js → diagram-OG6HWLK6-AbGNmLXr.js} +1 -1
  34. package/dist/web-ui/assets/{docx-preview-Bbv-to1F.js → docx-preview--1ncczOI.js} +1 -1
  35. package/dist/web-ui/assets/{erDiagram-TEJ5UH35-Dt1LIcRW.js → erDiagram-TEJ5UH35-CBFv7tRL.js} +1 -1
  36. package/dist/web-ui/assets/{flowDiagram-I6XJVG4X-BGkeNe73.js → flowDiagram-I6XJVG4X-DpXrThuu.js} +1 -1
  37. package/dist/web-ui/assets/{ganttDiagram-6RSMTGT7-BBFM37Si.js → ganttDiagram-6RSMTGT7-CupAuc9R.js} +1 -1
  38. package/dist/web-ui/assets/{gitGraphDiagram-PVQCEYII-DDZslnia.js → gitGraphDiagram-PVQCEYII-BJCAOb-p.js} +1 -1
  39. package/dist/web-ui/assets/{index-CtvWAPSx.js → index-BhgfBFXX.js} +5 -5
  40. package/dist/web-ui/assets/{infoDiagram-5YYISTIA-CCeNBOcz.js → infoDiagram-5YYISTIA-DaNJu9kK.js} +1 -1
  41. package/dist/web-ui/assets/{ishikawaDiagram-YF4QCWOH-Dzz-ZwGx.js → ishikawaDiagram-YF4QCWOH-BmgExWtv.js} +1 -1
  42. package/dist/web-ui/assets/{journeyDiagram-JHISSGLW-Bf1MpoEJ.js → journeyDiagram-JHISSGLW-BGNYie65.js} +1 -1
  43. package/dist/web-ui/assets/{kanban-definition-UN3LZRKU-Cct3iwex.js → kanban-definition-UN3LZRKU-BFJ79pHV.js} +1 -1
  44. package/dist/web-ui/assets/{mermaid.core-SSIWILrc.js → mermaid.core-Des6lIh7.js} +5 -5
  45. package/dist/web-ui/assets/{mindmap-definition-RKZ34NQL-905mFjP0.js → mindmap-definition-RKZ34NQL-Dh8lPNzf.js} +1 -1
  46. package/dist/web-ui/assets/modelCapabilities-DDtCBZ6o.js +1 -0
  47. package/dist/web-ui/assets/{pieDiagram-4H26LBE5-ByZUSYyz.js → pieDiagram-4H26LBE5-D00jFAPE.js} +1 -1
  48. package/dist/web-ui/assets/{quadrantDiagram-W4KKPZXB-CaV2JZmU.js → quadrantDiagram-W4KKPZXB-Bb76wY4G.js} +1 -1
  49. package/dist/web-ui/assets/{requirementDiagram-4Y6WPE33-BwZH9jjo.js → requirementDiagram-4Y6WPE33-Bp_uC7mF.js} +1 -1
  50. package/dist/web-ui/assets/{sankeyDiagram-5OEKKPKP-BS5G0r-a.js → sankeyDiagram-5OEKKPKP-f9suZ_m2.js} +1 -1
  51. package/dist/web-ui/assets/{sequenceDiagram-3UESZ5HK-C39toITa.js → sequenceDiagram-3UESZ5HK-CdbTYw2a.js} +1 -1
  52. package/dist/web-ui/assets/{stateDiagram-AJRCARHV-B8kaqqlT.js → stateDiagram-AJRCARHV-CcK2OMSf.js} +1 -1
  53. package/dist/web-ui/assets/stateDiagram-v2-BHNVJYJU-0jXPoaYs.js +1 -0
  54. package/dist/web-ui/assets/{timeline-definition-PNZ67QCA-CJ0-XG2F.js → timeline-definition-PNZ67QCA-CXP-5wIX.js} +1 -1
  55. package/dist/web-ui/assets/{vennDiagram-CIIHVFJN-eeoPYmS4.js → vennDiagram-CIIHVFJN-DpIWugKQ.js} +1 -1
  56. package/dist/web-ui/assets/{wardley-L42UT6IY-Cd0jXy6w.js → wardley-L42UT6IY-BLjAic-S.js} +1 -1
  57. package/dist/web-ui/assets/{wardleyDiagram-YWT4CUSO-Bsm8d7ET.js → wardleyDiagram-YWT4CUSO-B1M1hx57.js} +1 -1
  58. package/dist/web-ui/assets/{xychartDiagram-2RQKCTM6-COj4Y_b2.js → xychartDiagram-2RQKCTM6-a4RO5hTM.js} +1 -1
  59. package/dist/web-ui/index.html +1 -1
  60. package/package.json +1 -1
  61. package/dist/web-ui/assets/channel-DZexGcNx.js +0 -1
  62. package/dist/web-ui/assets/classDiagram-4FO5ZUOK-Ba64yqov.js +0 -1
  63. package/dist/web-ui/assets/classDiagram-v2-Q7XG4LA2-Ba64yqov.js +0 -1
  64. package/dist/web-ui/assets/stateDiagram-v2-BHNVJYJU-W2oTLuaB.js +0 -1
@@ -1,4 +1,4 @@
1
- const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/mermaid.core-SSIWILrc.js","assets/transform-CpIVI4vC.js","assets/Team-YUOVSMYB.js","assets/CommentInput-C745UDMQ.js","assets/ContentRenderer-BL3f4UN5.js","assets/DeliverableShareModal-o1pbK67c.js","assets/Team-DFuMZ0ql.css","assets/Work-CWfGwHiq.js","assets/value-DIujSiJ7.js","assets/Work-BZV40eAE.css","assets/Deliverables-D4ugAcBA.js"])))=>i.map(i=>d[i]);
1
+ const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/mermaid.core-Des6lIh7.js","assets/transform-CpIVI4vC.js","assets/Team-DJ1rMsS3.js","assets/CommentInput-C3h-Yzay.js","assets/ContentRenderer-zASgOqkn.js","assets/DeliverableShareModal-Dbnn1New.js","assets/modelCapabilities-DDtCBZ6o.js","assets/Team-DFuMZ0ql.css","assets/Settings-D3Sk4wo8.js","assets/Work-CB0n0sCV.js","assets/value-DIujSiJ7.js","assets/Work-BZV40eAE.css","assets/Deliverables-DJAIrKO-.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 s of document.querySelectorAll('link[rel="modulepreload"]'))a(s);new MutationObserver(s=>{for(const l of s)if(l.type==="childList")for(const c of l.addedNodes)c.tagName==="LINK"&&c.rel==="modulepreload"&&a(c)}).observe(document,{childList:!0,subtree:!0});function n(s){const l={};return s.integrity&&(l.integrity=s.integrity),s.referrerPolicy&&(l.referrerPolicy=s.referrerPolicy),s.crossOrigin==="use-credentials"?l.credentials="include":s.crossOrigin==="anonymous"?l.credentials="omit":l.credentials="same-origin",l}function a(s){if(s.ep)return;s.ep=!0;const l=n(s);fetch(s.href,l)}})();var Hie=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function Ic(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var cf={exports:{}},Xl={};var Xx;function dA(){if(Xx)return Xl;Xx=1;var e=Symbol.for("react.transitional.element"),t=Symbol.for("react.fragment");function n(a,s,l){var c=null;if(l!==void 0&&(c=""+l),s.key!==void 0&&(c=""+s.key),"key"in s){l={};for(var d in s)d!=="key"&&(l[d]=s[d])}else l=s;return s=l.ref,{$$typeof:e,type:a,key:c,ref:s!==void 0?s:null,props:l}}return Xl.Fragment=t,Xl.jsx=n,Xl.jsxs=n,Xl}var Jx;function mA(){return Jx||(Jx=1,cf.exports=dA()),cf.exports}var i=mA(),uf={exports:{}},$t={};var Zx;function pA(){if(Zx)return $t;Zx=1;var e=Symbol.for("react.transitional.element"),t=Symbol.for("react.portal"),n=Symbol.for("react.fragment"),a=Symbol.for("react.strict_mode"),s=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"),p=Symbol.for("react.memo"),h=Symbol.for("react.lazy"),g=Symbol.for("react.activity"),x=Symbol.iterator;function y(V){return V===null||typeof V!="object"?null:(V=x&&V[x]||V["@@iterator"],typeof V=="function"?V:null)}var w={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},T=Object.assign,C={};function S(V,pe,z){this.props=V,this.context=pe,this.refs=C,this.updater=z||w}S.prototype.isReactComponent={},S.prototype.setState=function(V,pe){if(typeof V!="object"&&typeof V!="function"&&V!=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,V,pe,"setState")},S.prototype.forceUpdate=function(V){this.updater.enqueueForceUpdate(this,V,"forceUpdate")};function E(){}E.prototype=S.prototype;function _(V,pe,z){this.props=V,this.context=pe,this.refs=C,this.updater=z||w}var M=_.prototype=new E;M.constructor=_,T(M,S.prototype),M.isPureReactComponent=!0;var P=Array.isArray;function R(){}var I={H:null,A:null,T:null,S:null},K=Object.prototype.hasOwnProperty;function Y(V,pe,z){var je=z.ref;return{$$typeof:e,type:V,key:pe,ref:je!==void 0?je:null,props:z}}function L(V,pe){return Y(V.type,pe,V.props)}function F(V){return typeof V=="object"&&V!==null&&V.$$typeof===e}function ne(V){var pe={"=":"=0",":":"=2"};return"$"+V.replace(/[=:]/g,function(z){return pe[z]})}var ee=/\/+/g;function G(V,pe){return typeof V=="object"&&V!==null&&V.key!=null?ne(""+V.key):pe.toString(36)}function ae(V){switch(V.status){case"fulfilled":return V.value;case"rejected":throw V.reason;default:switch(typeof V.status=="string"?V.then(R,R):(V.status="pending",V.then(function(pe){V.status==="pending"&&(V.status="fulfilled",V.value=pe)},function(pe){V.status==="pending"&&(V.status="rejected",V.reason=pe)})),V.status){case"fulfilled":return V.value;case"rejected":throw V.reason}}throw V}function H(V,pe,z,je,Ue){var qe=typeof V;(qe==="undefined"||qe==="boolean")&&(V=null);var He=!1;if(V===null)He=!0;else switch(qe){case"bigint":case"string":case"number":He=!0;break;case"object":switch(V.$$typeof){case e:case t:He=!0;break;case h:return He=V._init,H(He(V._payload),pe,z,je,Ue)}}if(He)return Ue=Ue(V),He=je===""?"."+G(V,0):je,P(Ue)?(z="",He!=null&&(z=He.replace(ee,"$&/")+"/"),H(Ue,pe,z,"",function(Nt){return Nt})):Ue!=null&&(F(Ue)&&(Ue=L(Ue,z+(Ue.key==null||V&&V.key===Ue.key?"":(""+Ue.key).replace(ee,"$&/")+"/")+He)),pe.push(Ue)),1;He=0;var ut=je===""?".":je+":";if(P(V))for(var dt=0;dt<V.length;dt++)je=V[dt],qe=ut+G(je,dt),He+=H(je,pe,z,qe,Ue);else if(dt=y(V),typeof dt=="function")for(V=dt.call(V),dt=0;!(je=V.next()).done;)je=je.value,qe=ut+G(je,dt++),He+=H(je,pe,z,qe,Ue);else if(qe==="object"){if(typeof V.then=="function")return H(ae(V),pe,z,je,Ue);throw pe=String(V),Error("Objects are not valid as a React child (found: "+(pe==="[object Object]"?"object with keys {"+Object.keys(V).join(", ")+"}":pe)+"). If you meant to render a collection of children, use an array instead.")}return He}function J(V,pe,z){if(V==null)return V;var je=[],Ue=0;return H(V,je,"","",function(qe){return pe.call(z,qe,Ue++)}),je}function fe(V){if(V._status===-1){var pe=V._result;pe=pe(),pe.then(function(z){(V._status===0||V._status===-1)&&(V._status=1,V._result=z)},function(z){(V._status===0||V._status===-1)&&(V._status=2,V._result=z)}),V._status===-1&&(V._status=0,V._result=pe)}if(V._status===1)return V._result.default;throw V._result}var Ce=typeof reportError=="function"?reportError:function(V){if(typeof window=="object"&&typeof window.ErrorEvent=="function"){var pe=new window.ErrorEvent("error",{bubbles:!0,cancelable:!0,message:typeof V=="object"&&V!==null&&typeof V.message=="string"?String(V.message):String(V),error:V});if(!window.dispatchEvent(pe))return}else if(typeof process=="object"&&typeof process.emit=="function"){process.emit("uncaughtException",V);return}console.error(V)},$={map:J,forEach:function(V,pe,z){J(V,function(){pe.apply(this,arguments)},z)},count:function(V){var pe=0;return J(V,function(){pe++}),pe},toArray:function(V){return J(V,function(pe){return pe})||[]},only:function(V){if(!F(V))throw Error("React.Children.only expected to receive a single React element child.");return V}};return $t.Activity=g,$t.Children=$,$t.Component=S,$t.Fragment=n,$t.Profiler=s,$t.PureComponent=_,$t.StrictMode=a,$t.Suspense=m,$t.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE=I,$t.__COMPILER_RUNTIME={__proto__:null,c:function(V){return I.H.useMemoCache(V)}},$t.cache=function(V){return function(){return V.apply(null,arguments)}},$t.cacheSignal=function(){return null},$t.cloneElement=function(V,pe,z){if(V==null)throw Error("The argument must be a React element, but you passed "+V+".");var je=T({},V.props),Ue=V.key;if(pe!=null)for(qe in pe.key!==void 0&&(Ue=""+pe.key),pe)!K.call(pe,qe)||qe==="key"||qe==="__self"||qe==="__source"||qe==="ref"&&pe.ref===void 0||(je[qe]=pe[qe]);var qe=arguments.length-2;if(qe===1)je.children=z;else if(1<qe){for(var He=Array(qe),ut=0;ut<qe;ut++)He[ut]=arguments[ut+2];je.children=He}return Y(V.type,Ue,je)},$t.createContext=function(V){return V={$$typeof:c,_currentValue:V,_currentValue2:V,_threadCount:0,Provider:null,Consumer:null},V.Provider=V,V.Consumer={$$typeof:l,_context:V},V},$t.createElement=function(V,pe,z){var je,Ue={},qe=null;if(pe!=null)for(je in pe.key!==void 0&&(qe=""+pe.key),pe)K.call(pe,je)&&je!=="key"&&je!=="__self"&&je!=="__source"&&(Ue[je]=pe[je]);var He=arguments.length-2;if(He===1)Ue.children=z;else if(1<He){for(var ut=Array(He),dt=0;dt<He;dt++)ut[dt]=arguments[dt+2];Ue.children=ut}if(V&&V.defaultProps)for(je in He=V.defaultProps,He)Ue[je]===void 0&&(Ue[je]=He[je]);return Y(V,qe,Ue)},$t.createRef=function(){return{current:null}},$t.forwardRef=function(V){return{$$typeof:d,render:V}},$t.isValidElement=F,$t.lazy=function(V){return{$$typeof:h,_payload:{_status:-1,_result:V},_init:fe}},$t.memo=function(V,pe){return{$$typeof:p,type:V,compare:pe===void 0?null:pe}},$t.startTransition=function(V){var pe=I.T,z={};I.T=z;try{var je=V(),Ue=I.S;Ue!==null&&Ue(z,je),typeof je=="object"&&je!==null&&typeof je.then=="function"&&je.then(R,Ce)}catch(qe){Ce(qe)}finally{pe!==null&&z.types!==null&&(pe.types=z.types),I.T=pe}},$t.unstable_useCacheRefresh=function(){return I.H.useCacheRefresh()},$t.use=function(V){return I.H.use(V)},$t.useActionState=function(V,pe,z){return I.H.useActionState(V,pe,z)},$t.useCallback=function(V,pe){return I.H.useCallback(V,pe)},$t.useContext=function(V){return I.H.useContext(V)},$t.useDebugValue=function(){},$t.useDeferredValue=function(V,pe){return I.H.useDeferredValue(V,pe)},$t.useEffect=function(V,pe){return I.H.useEffect(V,pe)},$t.useEffectEvent=function(V){return I.H.useEffectEvent(V)},$t.useId=function(){return I.H.useId()},$t.useImperativeHandle=function(V,pe,z){return I.H.useImperativeHandle(V,pe,z)},$t.useInsertionEffect=function(V,pe){return I.H.useInsertionEffect(V,pe)},$t.useLayoutEffect=function(V,pe){return I.H.useLayoutEffect(V,pe)},$t.useMemo=function(V,pe){return I.H.useMemo(V,pe)},$t.useOptimistic=function(V,pe){return I.H.useOptimistic(V,pe)},$t.useReducer=function(V,pe,z){return I.H.useReducer(V,pe,z)},$t.useRef=function(V){return I.H.useRef(V)},$t.useState=function(V){return I.H.useState(V)},$t.useSyncExternalStore=function(V,pe,z){return I.H.useSyncExternalStore(V,pe,z)},$t.useTransition=function(){return I.H.useTransition()},$t.version="19.2.4",$t}var ev;function zm(){return ev||(ev=1,uf.exports=pA()),uf.exports}var k=zm();const $ie=Ic(k);var df={exports:{}},Jl={},mf={exports:{}},pf={};var tv;function fA(){return tv||(tv=1,(function(e){function t(H,J){var fe=H.length;H.push(J);e:for(;0<fe;){var Ce=fe-1>>>1,$=H[Ce];if(0<s($,J))H[Ce]=J,H[fe]=$,fe=Ce;else break e}}function n(H){return H.length===0?null:H[0]}function a(H){if(H.length===0)return null;var J=H[0],fe=H.pop();if(fe!==J){H[0]=fe;e:for(var Ce=0,$=H.length,V=$>>>1;Ce<V;){var pe=2*(Ce+1)-1,z=H[pe],je=pe+1,Ue=H[je];if(0>s(z,fe))je<$&&0>s(Ue,z)?(H[Ce]=Ue,H[je]=fe,Ce=je):(H[Ce]=z,H[pe]=fe,Ce=pe);else if(je<$&&0>s(Ue,fe))H[Ce]=Ue,H[je]=fe,Ce=je;else break e}}return J}function s(H,J){var fe=H.sortIndex-J.sortIndex;return fe!==0?fe:H.id-J.id}if(e.unstable_now=void 0,typeof performance=="object"&&typeof performance.now=="function"){var l=performance;e.unstable_now=function(){return l.now()}}else{var c=Date,d=c.now();e.unstable_now=function(){return c.now()-d}}var m=[],p=[],h=1,g=null,x=3,y=!1,w=!1,T=!1,C=!1,S=typeof setTimeout=="function"?setTimeout:null,E=typeof clearTimeout=="function"?clearTimeout:null,_=typeof setImmediate<"u"?setImmediate:null;function M(H){for(var J=n(p);J!==null;){if(J.callback===null)a(p);else if(J.startTime<=H)a(p),J.sortIndex=J.expirationTime,t(m,J);else break;J=n(p)}}function P(H){if(T=!1,M(H),!w)if(n(m)!==null)w=!0,R||(R=!0,ne());else{var J=n(p);J!==null&&ae(P,J.startTime-H)}}var R=!1,I=-1,K=5,Y=-1;function L(){return C?!0:!(e.unstable_now()-Y<K)}function F(){if(C=!1,R){var H=e.unstable_now();Y=H;var J=!0;try{e:{w=!1,T&&(T=!1,E(I),I=-1),y=!0;var fe=x;try{t:{for(M(H),g=n(m);g!==null&&!(g.expirationTime>H&&L());){var Ce=g.callback;if(typeof Ce=="function"){g.callback=null,x=g.priorityLevel;var $=Ce(g.expirationTime<=H);if(H=e.unstable_now(),typeof $=="function"){g.callback=$,M(H),J=!0;break t}g===n(m)&&a(m),M(H)}else a(m);g=n(m)}if(g!==null)J=!0;else{var V=n(p);V!==null&&ae(P,V.startTime-H),J=!1}}break e}finally{g=null,x=fe,y=!1}J=void 0}}finally{J?ne():R=!1}}}var ne;if(typeof _=="function")ne=function(){_(F)};else if(typeof MessageChannel<"u"){var ee=new MessageChannel,G=ee.port2;ee.port1.onmessage=F,ne=function(){G.postMessage(null)}}else ne=function(){S(F,0)};function ae(H,J){I=S(function(){H(e.unstable_now())},J)}e.unstable_IdlePriority=5,e.unstable_ImmediatePriority=1,e.unstable_LowPriority=4,e.unstable_NormalPriority=3,e.unstable_Profiling=null,e.unstable_UserBlockingPriority=2,e.unstable_cancelCallback=function(H){H.callback=null},e.unstable_forceFrameRate=function(H){0>H||125<H?console.error("forceFrameRate takes a positive int between 0 and 125, forcing frame rates higher than 125 fps is not supported"):K=0<H?Math.floor(1e3/H):5},e.unstable_getCurrentPriorityLevel=function(){return x},e.unstable_next=function(H){switch(x){case 1:case 2:case 3:var J=3;break;default:J=x}var fe=x;x=J;try{return H()}finally{x=fe}},e.unstable_requestPaint=function(){C=!0},e.unstable_runWithPriority=function(H,J){switch(H){case 1:case 2:case 3:case 4:case 5:break;default:H=3}var fe=x;x=H;try{return J()}finally{x=fe}},e.unstable_scheduleCallback=function(H,J,fe){var Ce=e.unstable_now();switch(typeof fe=="object"&&fe!==null?(fe=fe.delay,fe=typeof fe=="number"&&0<fe?Ce+fe:Ce):fe=Ce,H){case 1:var $=-1;break;case 2:$=250;break;case 5:$=1073741823;break;case 4:$=1e4;break;default:$=5e3}return $=fe+$,H={id:h++,callback:J,priorityLevel:H,startTime:fe,expirationTime:$,sortIndex:-1},fe>Ce?(H.sortIndex=fe,t(p,H),n(m)===null&&H===n(p)&&(T?(E(I),I=-1):T=!0,ae(P,fe-Ce))):(H.sortIndex=$,t(m,H),w||y||(w=!0,R||(R=!0,ne()))),H},e.unstable_shouldYield=L,e.unstable_wrapCallback=function(H){var J=x;return function(){var fe=x;x=J;try{return H.apply(this,arguments)}finally{x=fe}}}})(pf)),pf}var nv;function hA(){return nv||(nv=1,mf.exports=fA()),mf.exports}var ff={exports:{}},ga={};var av;function gA(){if(av)return ga;av=1;var e=zm();function t(m){var p="https://react.dev/errors/"+m;if(1<arguments.length){p+="?args[]="+encodeURIComponent(arguments[1]);for(var h=2;h<arguments.length;h++)p+="&args[]="+encodeURIComponent(arguments[h])}return"Minified React error #"+m+"; visit "+p+" for the full message or use the non-minified dev environment for full errors and additional helpful warnings."}function n(){}var a={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},s=Symbol.for("react.portal");function l(m,p,h){var g=3<arguments.length&&arguments[3]!==void 0?arguments[3]:null;return{$$typeof:s,key:g==null?null:""+g,children:m,containerInfo:p,implementation:h}}var c=e.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE;function d(m,p){if(m==="font")return"";if(typeof p=="string")return p==="use-credentials"?p:""}return ga.__DOM_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE=a,ga.createPortal=function(m,p){var h=2<arguments.length&&arguments[2]!==void 0?arguments[2]:null;if(!p||p.nodeType!==1&&p.nodeType!==9&&p.nodeType!==11)throw Error(t(299));return l(m,p,null,h)},ga.flushSync=function(m){var p=c.T,h=a.p;try{if(c.T=null,a.p=2,m)return m()}finally{c.T=p,a.p=h,a.d.f()}},ga.preconnect=function(m,p){typeof m=="string"&&(p?(p=p.crossOrigin,p=typeof p=="string"?p==="use-credentials"?p:"":void 0):p=null,a.d.C(m,p))},ga.prefetchDNS=function(m){typeof m=="string"&&a.d.D(m)},ga.preinit=function(m,p){if(typeof m=="string"&&p&&typeof p.as=="string"){var h=p.as,g=d(h,p.crossOrigin),x=typeof p.integrity=="string"?p.integrity:void 0,y=typeof p.fetchPriority=="string"?p.fetchPriority:void 0;h==="style"?a.d.S(m,typeof p.precedence=="string"?p.precedence:void 0,{crossOrigin:g,integrity:x,fetchPriority:y}):h==="script"&&a.d.X(m,{crossOrigin:g,integrity:x,fetchPriority:y,nonce:typeof p.nonce=="string"?p.nonce:void 0})}},ga.preinitModule=function(m,p){if(typeof m=="string")if(typeof p=="object"&&p!==null){if(p.as==null||p.as==="script"){var h=d(p.as,p.crossOrigin);a.d.M(m,{crossOrigin:h,integrity:typeof p.integrity=="string"?p.integrity:void 0,nonce:typeof p.nonce=="string"?p.nonce:void 0})}}else p==null&&a.d.M(m)},ga.preload=function(m,p){if(typeof m=="string"&&typeof p=="object"&&p!==null&&typeof p.as=="string"){var h=p.as,g=d(h,p.crossOrigin);a.d.L(m,h,{crossOrigin:g,integrity:typeof p.integrity=="string"?p.integrity:void 0,nonce:typeof p.nonce=="string"?p.nonce:void 0,type:typeof p.type=="string"?p.type:void 0,fetchPriority:typeof p.fetchPriority=="string"?p.fetchPriority:void 0,referrerPolicy:typeof p.referrerPolicy=="string"?p.referrerPolicy:void 0,imageSrcSet:typeof p.imageSrcSet=="string"?p.imageSrcSet:void 0,imageSizes:typeof p.imageSizes=="string"?p.imageSizes:void 0,media:typeof p.media=="string"?p.media:void 0})}},ga.preloadModule=function(m,p){if(typeof m=="string")if(p){var h=d(p.as,p.crossOrigin);a.d.m(m,{as:typeof p.as=="string"&&p.as!=="script"?p.as:void 0,crossOrigin:h,integrity:typeof p.integrity=="string"?p.integrity:void 0})}else a.d.m(m)},ga.requestFormReset=function(m){a.d.r(m)},ga.unstable_batchedUpdates=function(m,p){return m(p)},ga.useFormState=function(m,p,h){return c.H.useFormState(m,p,h)},ga.useFormStatus=function(){return c.H.useHostTransitionStatus()},ga.version="19.2.4",ga}var rv;function Fk(){if(rv)return ff.exports;rv=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(),ff.exports=gA(),ff.exports}var iv;function bA(){if(iv)return Jl;iv=1;var e=hA(),t=zm(),n=Fk();function a(r){var o="https://react.dev/errors/"+r;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 #"+r+"; visit "+o+" for the full message or use the non-minified dev environment for full errors and additional helpful warnings."}function s(r){return!(!r||r.nodeType!==1&&r.nodeType!==9&&r.nodeType!==11)}function l(r){var o=r,u=r;if(r.alternate)for(;o.return;)o=o.return;else{r=o;do o=r,(o.flags&4098)!==0&&(u=o.return),r=o.return;while(r)}return o.tag===3?u:null}function c(r){if(r.tag===13){var o=r.memoizedState;if(o===null&&(r=r.alternate,r!==null&&(o=r.memoizedState)),o!==null)return o.dehydrated}return null}function d(r){if(r.tag===31){var o=r.memoizedState;if(o===null&&(r=r.alternate,r!==null&&(o=r.memoizedState)),o!==null)return o.dehydrated}return null}function m(r){if(l(r)!==r)throw Error(a(188))}function p(r){var o=r.alternate;if(!o){if(o=l(r),o===null)throw Error(a(188));return o!==r?null:r}for(var u=r,f=o;;){var b=u.return;if(b===null)break;var v=b.alternate;if(v===null){if(f=b.return,f!==null){u=f;continue}break}if(b.child===v.child){for(v=b.child;v;){if(v===u)return m(b),r;if(v===f)return m(b),o;v=v.sibling}throw Error(a(188))}if(u.return!==f.return)u=b,f=v;else{for(var j=!1,O=b.child;O;){if(O===u){j=!0,u=b,f=v;break}if(O===f){j=!0,f=b,u=v;break}O=O.sibling}if(!j){for(O=v.child;O;){if(O===u){j=!0,u=v,f=b;break}if(O===f){j=!0,f=v,u=b;break}O=O.sibling}if(!j)throw Error(a(189))}}if(u.alternate!==f)throw Error(a(190))}if(u.tag!==3)throw Error(a(188));return u.stateNode.current===u?r:o}function h(r){var o=r.tag;if(o===5||o===26||o===27||o===6)return r;for(r=r.child;r!==null;){if(o=h(r),o!==null)return o;r=r.sibling}return null}var g=Object.assign,x=Symbol.for("react.element"),y=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"),_=Symbol.for("react.context"),M=Symbol.for("react.forward_ref"),P=Symbol.for("react.suspense"),R=Symbol.for("react.suspense_list"),I=Symbol.for("react.memo"),K=Symbol.for("react.lazy"),Y=Symbol.for("react.activity"),L=Symbol.for("react.memo_cache_sentinel"),F=Symbol.iterator;function ne(r){return r===null||typeof r!="object"?null:(r=F&&r[F]||r["@@iterator"],typeof r=="function"?r:null)}var ee=Symbol.for("react.client.reference");function G(r){if(r==null)return null;if(typeof r=="function")return r.$$typeof===ee?null:r.displayName||r.name||null;if(typeof r=="string")return r;switch(r){case T:return"Fragment";case S:return"Profiler";case C:return"StrictMode";case P:return"Suspense";case R:return"SuspenseList";case Y:return"Activity"}if(typeof r=="object")switch(r.$$typeof){case w:return"Portal";case _:return r.displayName||"Context";case E:return(r._context.displayName||"Context")+".Consumer";case M:var o=r.render;return r=r.displayName,r||(r=o.displayName||o.name||"",r=r!==""?"ForwardRef("+r+")":"ForwardRef"),r;case I:return o=r.displayName||null,o!==null?o:G(r.type)||"Memo";case K:o=r._payload,r=r._init;try{return G(r(o))}catch{}}return null}var ae=Array.isArray,H=t.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,J=n.__DOM_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,fe={pending:!1,data:null,method:null,action:null},Ce=[],$=-1;function V(r){return{current:r}}function pe(r){0>$||(r.current=Ce[$],Ce[$]=null,$--)}function z(r,o){$++,Ce[$]=r.current,r.current=o}var je=V(null),Ue=V(null),qe=V(null),He=V(null);function ut(r,o){switch(z(qe,o),z(Ue,r),z(je,null),o.nodeType){case 9:case 11:r=(r=o.documentElement)&&(r=r.namespaceURI)?vx(r):0;break;default:if(r=o.tagName,o=o.namespaceURI)o=vx(o),r=wx(o,r);else switch(r){case"svg":r=1;break;case"math":r=2;break;default:r=0}}pe(je),z(je,r)}function dt(){pe(je),pe(Ue),pe(qe)}function Nt(r){r.memoizedState!==null&&z(He,r);var o=je.current,u=wx(o,r.type);o!==u&&(z(Ue,r),z(je,u))}function wt(r){Ue.current===r&&(pe(je),pe(Ue)),He.current===r&&(pe(He),Vl._currentValue=fe)}var Zt,Wt;function rt(r){if(Zt===void 0)try{throw Error()}catch(u){var o=u.stack.trim().match(/\n( *(at )?)/);Zt=o&&o[1]||"",Wt=-1<u.stack.indexOf(`
3
3
  at`)?" (<anonymous>)":-1<u.stack.indexOf("@")?"@unknown:0:0":""}return`
4
4
  `+Zt+r+Wt}var $e=!1;function mt(r,o){if(!r||$e)return"";$e=!0;var u=Error.prepareStackTrace;Error.prepareStackTrace=void 0;try{var f={DetermineComponentFrameRoot:function(){try{if(o){var Oe=function(){throw Error()};if(Object.defineProperty(Oe.prototype,"props",{set:function(){throw Error()}}),typeof Reflect=="object"&&Reflect.construct){try{Reflect.construct(Oe,[])}catch(Te){var ke=Te}Reflect.construct(r,[],Oe)}else{try{Oe.call()}catch(Te){ke=Te}r.call(Oe.prototype)}}else{try{throw Error()}catch(Te){ke=Te}(Oe=r())&&typeof Oe.catch=="function"&&Oe.catch(function(){})}}catch(Te){if(Te&&ke&&typeof Te.stack=="string")return[Te.stack,ke.stack]}return[null,null]}};f.DetermineComponentFrameRoot.displayName="DetermineComponentFrameRoot";var b=Object.getOwnPropertyDescriptor(f.DetermineComponentFrameRoot,"name");b&&b.configurable&&Object.defineProperty(f.DetermineComponentFrameRoot,"name",{value:"DetermineComponentFrameRoot"});var v=f.DetermineComponentFrameRoot(),j=v[0],O=v[1];if(j&&O){var oe=j.split(`
@@ -844,14 +844,14 @@ if (ip && typeof ip.join !== 'function') {
844
844
  };
845
845
  }
846
846
  await import("${new URL("/assets/pdf.worker.min-CHFwMXne.mjs",import.meta.url).toString()}");
847
- `;ch=URL.createObjectURL(new Blob([t],{type:"text/javascript"}))}return ch}async function vne(e,t,n){const a=await va(()=>import("./pdf-DMRcuM1e.js"),[]);a.GlobalWorkerOptions.workerSrc=xne();const s=await a.getDocument({url:e}).promise,l=[];for(let c=1;c<=s.numPages;c++){const d=await s.getPage(c),m=d.getViewport({scale:1.5*n.zoom}),p=document.createElement("canvas");p.width=Math.floor(m.width),p.height=Math.floor(m.height),p.style.width=`${Math.floor(m.width)}px`,p.style.height=`${Math.floor(m.height)}px`,p.style.marginBottom="8px",p.style.boxShadow="0 1px 4px rgba(0,0,0,0.15)",p.style.borderRadius="2px";const h=p.getContext("2d");if(!h)throw new Error("canvas 2d context unavailable");await d.render({canvas:p,canvasContext:h,viewport:m}).promise,p.dataset.page=String(c),t.appendChild(p),l.push(p)}return n.onReady(s.numPages),()=>{for(const c of l)c.remove();s.cleanup()}}async function wne(e,t){const{renderAsync:n}=await va(async()=>{const{renderAsync:s}=await import("./docx-preview-Bbv-to1F.js");return{renderAsync:s}},[]),a=await fetch(e).then(s=>{if(!s.ok)throw new Error(`HTTP ${s.status}`);return s.blob()});if(a.size===0)throw new Error("empty docx");return await n(a,t,void 0,{inWrapper:!0,ignoreWidth:!0,ignoreHeight:!1,breakPages:!0,className:"office-docx"}),()=>{t.innerHTML=""}}async function kne(e,t){const n=await va(()=>import("./xlsx-CNerDvZX.js"),[]),a=await fetch(e).then(d=>{if(!d.ok)throw new Error(`HTTP ${d.status}`);return d.arrayBuffer()});if(a.byteLength===0)throw new Error("empty xlsx");const s=n.read(a,{type:"array"});if(!s.SheetNames||s.SheetNames.length===0)throw new Error("no sheets");const l=n.utils.sheet_to_html(s.Sheets[s.SheetNames[0]],{id:"office-xlsx-sheet",editable:!1});t.innerHTML=l;const c=document.createElement("style");return c.textContent=`
847
+ `;ch=URL.createObjectURL(new Blob([t],{type:"text/javascript"}))}return ch}async function vne(e,t,n){const a=await va(()=>import("./pdf-DMRcuM1e.js"),[]);a.GlobalWorkerOptions.workerSrc=xne();const s=await a.getDocument({url:e}).promise,l=[];for(let c=1;c<=s.numPages;c++){const d=await s.getPage(c),m=d.getViewport({scale:1.5*n.zoom}),p=document.createElement("canvas");p.width=Math.floor(m.width),p.height=Math.floor(m.height),p.style.width=`${Math.floor(m.width)}px`,p.style.height=`${Math.floor(m.height)}px`,p.style.marginBottom="8px",p.style.boxShadow="0 1px 4px rgba(0,0,0,0.15)",p.style.borderRadius="2px";const h=p.getContext("2d");if(!h)throw new Error("canvas 2d context unavailable");await d.render({canvas:p,canvasContext:h,viewport:m}).promise,p.dataset.page=String(c),t.appendChild(p),l.push(p)}return n.onReady(s.numPages),()=>{for(const c of l)c.remove();s.cleanup()}}async function wne(e,t){const{renderAsync:n}=await va(async()=>{const{renderAsync:s}=await import("./docx-preview--1ncczOI.js");return{renderAsync:s}},[]),a=await fetch(e).then(s=>{if(!s.ok)throw new Error(`HTTP ${s.status}`);return s.blob()});if(a.size===0)throw new Error("empty docx");return await n(a,t,void 0,{inWrapper:!0,ignoreWidth:!0,ignoreHeight:!1,breakPages:!0,className:"office-docx"}),()=>{t.innerHTML=""}}async function kne(e,t){const n=await va(()=>import("./xlsx-CNerDvZX.js"),[]),a=await fetch(e).then(d=>{if(!d.ok)throw new Error(`HTTP ${d.status}`);return d.arrayBuffer()});if(a.byteLength===0)throw new Error("empty xlsx");const s=n.read(a,{type:"array"});if(!s.SheetNames||s.SheetNames.length===0)throw new Error("no sheets");const l=n.utils.sheet_to_html(s.Sheets[s.SheetNames[0]],{id:"office-xlsx-sheet",editable:!1});t.innerHTML=l;const c=document.createElement("style");return c.textContent=`
848
848
  #office-xlsx-sheet { border-collapse: collapse; font-size: 12px; color: var(--fg-primary, #333); }
849
849
  #office-xlsx-sheet td, #office-xlsx-sheet th {
850
850
  border: 1px solid var(--border-default, #ddd); padding: 4px 8px; white-space: nowrap;
851
851
  background: var(--surface-primary, #fff);
852
852
  }
853
853
  #office-xlsx-sheet th { background: var(--surface-elevated, #f3f4f6); font-weight: 600; }
854
- `,t.prepend(c),()=>{t.innerHTML=""}}k.lazy(()=>va(()=>Promise.resolve().then(()=>PS),void 0).then(e=>({default:e.MarkdownMessage})));const Sne=k.lazy(()=>va(()=>import("./ContentRenderer-BL3f4UN5.js"),[]).then(e=>({default:e.ContentRenderer})));let Do=[],Pw=60;function Cne(e){const t=k.useRef(e);t.current=e;const[n]=k.useState(()=>++Pw);return k.useEffect(()=>{const a=()=>t.current();Do.push(a);const s=l=>{l.key==="Escape"&&Do[Do.length-1]===a&&(l.preventDefault(),a())};return window.addEventListener("keydown",s,!0),()=>{window.removeEventListener("keydown",s,!0),Do=Do.filter(l=>l!==a),Do.length===0&&(Pw=60)}},[]),n}const zw=500,Ji=new Map,jm=new Set,Zd=new Map;let em=null;function Ane(){if(Ji.size<=zw)return;const e=Ji.size-zw,t=Ji.keys();for(let n=0;n<e;n++){const{value:a,done:s}=t.next();if(s)break;Ji.delete(a)}}function Bw(e,t){Ji.delete(e),Ji.set(e,t),Ane()}function Hw(e){const t=Zd.get(e);if(t)for(const n of t)n()}function Tne(){em=null;const e=[...jm];jm.clear(),e.length!==0&&Ae.files.check(e).then(({results:t})=>{for(const[n,a]of Object.entries(t))Bw(n,a),Hw(n)}).catch(()=>{for(const t of e)Bw(t,{exists:!1,isFile:!1,type:"unknown"}),Hw(t)})}function Nne(e){Ji.has(e)||jm.has(e)||(jm.add(e),em&&clearTimeout(em),em=setTimeout(Tne,30))}function Ene(e,t){let n=Zd.get(e);return n||(n=new Set,Zd.set(e,n)),n.add(t),()=>{n.delete(t),n.size===0&&Zd.delete(e)}}function jne(e){const t=k.useCallback(s=>Ene(e,s),[e]),n=k.useCallback(()=>Ji.get(e),[e]),a=k.useSyncExternalStore(t,n,n);return k.useEffect(()=>{Nne(e)},[e]),a}function Mne(e){const t=e.includes("\\")?"\\":"/",n=e.lastIndexOf(t);return n<=0?t==="/"?"/":e.slice(0,2):e.slice(0,n)}function _ne({filePath:e,onClose:t}){const n=Cne(t),[a,s]=k.useState(e),[l,c]=k.useState(!0),[d,m]=k.useState(null),[p,h]=k.useState(""),[g,x]=k.useState(""),[y,w]=k.useState(""),[T,C]=k.useState(""),[S,E]=k.useState(""),[_,M]=k.useState(null),[P,R]=k.useState(!1);k.useEffect(()=>{c(!0),m(null),h(""),M(null),Ae.files.preview(a).then(F=>{if(F.type==="directory"&&Array.isArray(F.entries)){x("directory"),w(F.name),M(F.entries);return}x(F.type),w(F.name),C(F.mimeType||""),h(typeof F.content=="string"?F.content:""),E(F.streamUrl||(F.path?Ae.files.streamUrl(F.path):"")||(F.type==="audio"||F.type==="video"?Ae.files.streamUrl(a):""))}).catch(F=>{m(String(F?.message||F))}).finally(()=>{c(!1)})},[a]);const I=y||a.split(/[/\\]/).pop()||a,K=g==="directory"||a!==e,Y=()=>s(F=>Mne(F)),L=()=>{navigator.clipboard?.writeText(a).then(()=>{R(!0),setTimeout(()=>R(!1),1500)}).catch(()=>{})};return zr.createPortal(i.jsx("div",{className:"fixed inset-0 bg-black/40 flex items-center justify-center",style:{zIndex:n},onClick:t,children:i.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:F=>F.stopPropagation(),children:[i.jsxs("div",{className:"flex items-center justify-between px-4 py-3 border-b border-border-default bg-surface-elevated/50 shrink-0",children:[i.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[g==="directory"&&i.jsx("svg",{className:"w-4 h-4 shrink-0 text-blue-400",viewBox:"0 0 20 20",fill:"currentColor",children:i.jsx("path",{d:"M3.5 3A1.5 1.5 0 002 4.5v11A1.5 1.5 0 003.5 17h13a1.5 1.5 0 001.5-1.5v-8A1.5 1.5 0 0016.5 6h-6.53a.5.5 0 01-.354-.146L8.706 4.854A1.5 1.5 0 007.586 4H3.5z"})}),g!=="directory"&&i.jsx("svg",{className:"w-4 h-4 shrink-0 text-fg-secondary",viewBox:"0 0 20 20",fill:"currentColor",children:i.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"})}),i.jsx("span",{className:"text-sm font-medium text-fg-primary truncate",children:I}),i.jsx("span",{className:"text-xs text-fg-tertiary truncate hidden sm:inline",children:a})]}),i.jsxs("div",{className:"flex items-center gap-2 shrink-0",children:[K&&i.jsx("button",{className:"text-xs text-fg-secondary hover:text-fg-primary px-2 py-1 rounded hover:bg-surface-elevated transition-colors",onClick:Y,title:"返回上级目录",children:"← 上级"}),i.jsx("button",{className:"text-xs text-fg-secondary hover:text-fg-primary px-2 py-1 rounded hover:bg-surface-elevated transition-colors",onClick:L,title:"复制路径",children:P?"✓ 已复制":"复制路径"}),i.jsx("button",{className:"text-xs text-fg-secondary hover:text-fg-primary px-2 py-1 rounded hover:bg-surface-elevated transition-colors",onClick:()=>Ae.files.reveal(a),title:"Reveal in file explorer",children:i.jsx("svg",{className:"w-4 h-4",viewBox:"0 0 20 20",fill:"currentColor",children:i.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"})})}),i.jsx("button",{className:"text-fg-secondary hover:text-fg-primary p-1 rounded hover:bg-surface-elevated transition-colors",onClick:t,children:i.jsx("svg",{className:"w-4 h-4",viewBox:"0 0 20 20",fill:"currentColor",children:i.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"})})})]})]}),i.jsxs("div",{className:"flex-1 overflow-y-auto p-5",children:[l&&i.jsx("div",{className:"flex items-center justify-center py-12",children:i.jsx("div",{className:"w-5 h-5 border-2 border-brand-500/30 border-t-brand-500 rounded-full animate-spin"})}),d&&i.jsxs("div",{className:"text-center py-12 text-fg-secondary text-sm",children:[i.jsx("p",{className:"text-red-400 mb-1",children:"Failed to load file"}),i.jsx("p",{className:"text-xs text-fg-tertiary",children:d})]}),!l&&!d&&g==="directory"&&_&&i.jsx(pne,{path:a,entries:_,onNavigate:F=>s(F),onOpenFile:F=>s(F),onReveal:F=>Ae.files.reveal(F),onCopyPath:F=>{navigator.clipboard?.writeText(F).then(()=>{R(!0),setTimeout(()=>R(!1),1500)}).catch(()=>{})}}),!l&&!d&&g==="office"&&S&&i.jsx(hne,{data:{format:(a.split(".").pop()||"pdf").toLowerCase(),streamUrl:S,name:I},reference:a,onFallback:()=>{Ae.files.reveal(a)}}),!l&&!d&&g==="image"&&p&&i.jsx("div",{className:"flex justify-center",children:i.jsx("img",{src:`data:${T||"image/png"};base64,${p}`,alt:I,className:"max-w-full rounded"})}),!l&&!d&&g==="audio"&&S&&i.jsx("audio",{controls:!0,preload:"metadata",src:S,className:"w-full"}),!l&&!d&&g==="video"&&S&&i.jsx("video",{controls:!0,preload:"metadata",src:S,className:"w-full max-h-[60vh] rounded-lg bg-black"}),!l&&!d&&(g==="binary"||!p&&g!=="image"&&g!=="audio"&&g!=="video"&&g!=="directory")&&i.jsxs("div",{className:"text-center py-8 space-y-3",children:[i.jsx("p",{className:"text-sm text-fg-secondary",children:"This file type cannot be previewed."}),i.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:()=>{Ae.files.reveal(a)},children:"Reveal in file explorer"})]}),!l&&!d&&p&&g!=="image"&&g!=="audio"&&g!=="video"&&g!=="binary"&&g!=="directory"&&i.jsx(k.Suspense,{fallback:i.jsx("div",{className:"text-xs text-fg-tertiary",children:"Loading…"}),children:i.jsx(Sne,{content:p,format:g==="text"?"text":g,className:"text-sm"})})]})]})}),document.body)}function Rne({path:e}){const t=jne(e),[n,a]=k.useState(null),s=qc(),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"||t?.type==="office"||t?.type==="directory",d=k.useCallback(h=>{if(h.preventDefault(),h.stopPropagation(),!!l)if(c){if(s?.hostAvailable){s.openRightPanel({kind:"file",path:e});return}a(e)}else Ae.files.reveal(e)},[l,c,e,s]),m="inline w-3 h-3 align-[-0.125em]",p=c?i.jsx("svg",{className:m,viewBox:"0 0 20 20",fill:"currentColor",children:i.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"})}):i.jsx("svg",{className:m,viewBox:"0 0 20 20",fill:"currentColor",children:i.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?i.jsxs(i.Fragment,{children:[i.jsxs("code",{"data-file-path-link":"ready",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:[i.jsxs("span",{className:"whitespace-nowrap",children:[p,e.charAt(0)]}),e.slice(1)]}),n&&i.jsx(_ne,{filePath:n,onClose:()=>a(null)})]}):i.jsx("code",{"data-file-path-link":"missing",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}):i.jsx("code",{"data-file-path-link":"loading",className:"bg-surface-secondary px-1.5 py-0.5 rounded text-xs font-mono text-fg-secondary break-all",children:e})}let uh=null;function Dne(){return uh||(uh=va(()=>import("./mermaid.core-SSIWILrc.js").then(e=>e.b9),__vite__mapDeps([0,1])).then(e=>(e.default.initialize({startOnLoad:!1,securityLevel:"loose",fontFamily:"inherit"}),e))),uh}function Lne(){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 Ine(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 One(){return Lne()}function Pne(){return k.useSyncExternalStore(Ine,One)}function RS({code:e}){const{t}=ot("common"),n=k.useRef(null),[a,s]=k.useState(null),[l,c]=k.useState(!0),d=k.useId(),m=k.useRef(0),p=k.useRef(null),h=Pne();return k.useEffect(()=>{if(!e.trim()||p.current&&p.current.code===e&&p.current.dark===h)return;let g=!1;return c(!0),s(null),m.current+=1,(async()=>{try{const x=await Dne();if(g)return;x.default.initialize({startOnLoad:!1,theme:h?"dark":"default",securityLevel:"loose",fontFamily:"inherit"});const y=`mermaid-${d.replace(/:/g,"")}-${m.current}`,{svg:w}=await x.default.render(y,e.trim());if(g)return;n.current&&(n.current.innerHTML=w,p.current={code:e,dark:h})}catch(x){g||s(x instanceof Error?x.message:String(x))}finally{g||c(!1)}})(),()=>{g=!0}},[e,d,h]),a?i.jsxs("div",{className:"my-2 rounded-lg overflow-hidden border border-red-500/30",children:[i.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:[i.jsx("svg",{className:"w-3.5 h-3.5 text-red-400",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:i.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"})}),i.jsx("span",{className:"text-[10px] font-medium text-red-400",children:t("markdown.mermaidRenderError")})]}),a&&i.jsx("div",{className:"px-3 py-2 bg-surface-secondary/60 text-[11px] font-mono text-red-300/90 whitespace-pre-wrap break-words border-b border-red-500/10 max-h-40 overflow-y-auto",children:a}),i.jsx("pre",{className:"p-3 bg-surface-secondary text-xs text-fg-secondary overflow-x-auto font-mono",children:e})]}):i.jsxs("div",{className:"not-prose my-2 rounded-lg bg-surface-secondary border border-border-subtle p-4 overflow-x-auto",children:[l&&i.jsxs("div",{className:"flex items-center gap-2 text-xs text-fg-tertiary",children:[i.jsx("div",{className:"w-4 h-4 border-2 border-fg-tertiary/30 border-t-fg-tertiary rounded-full animate-spin"}),t("markdown.renderingDiagram")]}),i.jsx("div",{ref:n,className:`flex justify-center [&>svg]:max-w-full${l?" hidden":""}`})]})}const zne="/assets/viz-global-C_AyN6D9.js";let Rd=!1,dh=null;function Bne(){return Rd?Promise.resolve():new Promise((e,t)=>{const n=document.querySelector("script[data-plantuml-viz]");if(n){globalThis.Viz?(Rd=!0,e()):(n.addEventListener("load",()=>{Rd=!0,e()}),n.addEventListener("error",()=>t(new Error("Failed to load viz-global.js"))));return}const a=document.createElement("script");a.setAttribute("data-plantuml-viz",""),a.src=zne,a.onload=()=>{Rd=!0,e()},a.onerror=()=>t(new Error("Failed to load viz-global.js")),document.head.appendChild(a)})}function Hne(){return dh||(dh=Bne().then(()=>va(()=>import("./plantuml-DezRDxd4.js"),[]))),dh}let $w=Promise.resolve();function $ne(e,t){const n=$w.then(()=>new Promise((a,s)=>{Hne().then(({renderToString:l})=>{const c=e.split(/\r\n|\r|\n/);l(c,a,s,{dark:t})}).catch(s)}));return $w=n.then(()=>{},()=>{}),n}function qne(){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 Fne(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 Une(){return k.useSyncExternalStore(Fne,()=>qne())}function DS({code:e}){const{t}=ot("common"),[n,a]=k.useState(null),[s,l]=k.useState(null),[c,d]=k.useState(!0),m=k.useRef(null),p=Une();return k.useEffect(()=>{if(!e.trim()||m.current&&m.current.code===e&&m.current.dark===p)return;let h=!1;return d(!0),l(null),$ne(e.trim(),p).then(g=>{h||(a(g),m.current={code:e,dark:p})}).catch(g=>{h||l(g instanceof Error?g.message:String(g))}).finally(()=>{h||d(!1)}),()=>{h=!0}},[e,p]),s?i.jsxs("div",{className:"my-2 rounded-lg overflow-hidden border border-red-500/30",children:[i.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:[i.jsx("svg",{className:"w-3.5 h-3.5 text-red-400",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:i.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"})}),i.jsx("span",{className:"text-[10px] font-medium text-red-400",children:t("markdown.plantumlRenderError")})]}),s&&i.jsx("div",{className:"px-3 py-2 bg-surface-secondary/60 text-[11px] font-mono text-red-300/90 whitespace-pre-wrap break-words border-b border-red-500/10 max-h-40 overflow-y-auto",children:s}),i.jsx("pre",{className:"p-3 bg-surface-secondary text-xs text-fg-secondary overflow-x-auto font-mono",children:e})]}):i.jsxs("div",{className:"not-prose my-2 rounded-lg bg-surface-secondary border border-border-subtle p-4 overflow-x-auto",children:[c&&i.jsxs("div",{className:"flex items-center gap-2 text-xs text-fg-tertiary",children:[i.jsx("div",{className:"w-4 h-4 border-2 border-fg-tertiary/30 border-t-fg-tertiary rounded-full animate-spin"}),t("markdown.renderingDiagram")]}),n&&i.jsx("div",{className:`flex justify-center [&>svg]:max-w-full${c?" hidden":""}`,dangerouslySetInnerHTML:{__html:n}})]})}function dg({code:e,language:t,children:n}){const{t:a}=ot("common"),[s,l]=k.useState("rendered"),[c,d]=k.useState(!1),m=k.useCallback(async()=>{await hb(e)&&(d(!0),setTimeout(()=>d(!1),1800))},[e]);return i.jsxs("div",{className:"not-prose my-2 rounded-lg overflow-hidden border border-border-subtle",children:[i.jsxs("div",{className:"flex items-center justify-between px-3 py-1.5 border-b border-border-subtle bg-surface-secondary",children:[i.jsx("span",{className:"text-[10px] font-medium text-fg-tertiary uppercase tracking-wider select-none",children:t}),i.jsxs("div",{className:"flex items-center gap-1",children:[i.jsx("button",{onClick:()=>l("rendered"),className:`px-2 py-0.5 rounded text-[10px] font-medium transition-colors ${s==="rendered"?"bg-brand-600/20 text-brand-500":"text-fg-tertiary hover:text-fg-secondary"}`,children:i.jsxs("span",{className:"flex items-center gap-1",children:[i.jsxs("svg",{className:"w-3 h-3",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:[i.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M15 12a3 3 0 11-6 0 3 3 0 016 0z"}),i.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"})]}),a("markdown.viewRendered")]})}),i.jsx("button",{onClick:()=>l("source"),className:`px-2 py-0.5 rounded text-[10px] font-medium transition-colors ${s==="source"?"bg-brand-600/20 text-brand-500":"text-fg-tertiary hover:text-fg-secondary"}`,children:i.jsxs("span",{className:"flex items-center gap-1",children:[i.jsx("svg",{className:"w-3 h-3",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:i.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M10 20l4-16m4 4l4 4-4 4M6 16l-4-4 4-4"})}),a("markdown.viewSource")]})})]})]}),s==="rendered"?i.jsx("div",{children:n}):i.jsxs("div",{className:"relative group/source",children:[i.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}),i.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:a("markdown.copyContent"),children:c?i.jsx("svg",{className:"w-3.5 h-3.5 text-green-400",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:i.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M5 13l4 4L19 7"})}):i.jsx("svg",{className:"w-3.5 h-3.5",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:i.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 Gne=[RS,DS];function Kne(e){for(const t of k.Children.toArray(e))if(k.isValidElement(t)&&typeof t.props?.className=="string"){const n=t.props.className;return $te(n)}return null}function bc(e){if(typeof e=="string")return e;if(typeof e=="number")return String(e);if(!e)return"";if(Array.isArray(e))return e.map(bc).join("");if(k.isValidElement(e)){const t=e.props;return bc(t.children)}return""}function Vne({children:e}){const{t}=ot("common"),n=Kne(e),a=k.useRef(null),[s,l]=k.useState(!1),[c,d]=k.useState("rendered"),m=k.useCallback(async()=>{let h;c==="source"?h=bc(e):h=a.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)&&Gne.includes(h.type))){const h=bc(e),g=n==="mermaid"||n==="plantuml"?n:"diagram";return i.jsx(dg,{code:h,language:g,children:e})}return n==="mermaid"||n==="plantuml"?i.jsx(i.Fragment,{children:e}):i.jsxs("div",{className:"not-prose relative group/code my-2 rounded-lg overflow-hidden bg-surface-secondary border border-border-subtle",children:[n&&i.jsxs("div",{className:"flex items-center justify-between px-3 py-1.5 border-b border-border-subtle",children:[i.jsx("span",{className:"text-[10px] font-medium text-fg-tertiary uppercase tracking-wider select-none",children:Hte(n)}),i.jsxs("div",{className:"flex items-center gap-1",children:[i.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")}),i.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")})]})]}),i.jsxs("div",{className:"relative",children:[c==="rendered"?i.jsx("pre",{ref:a,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)}):i.jsx("pre",{className:"p-3 overflow-x-auto text-xs font-mono text-fg-secondary whitespace-pre-wrap break-words",children:bc(e)}),i.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:s?i.jsx("svg",{className:"w-3.5 h-3.5 text-green-400",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:i.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M5 13l4 4L19 7"})}):i.jsx("svg",{className:"w-3.5 h-3.5",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:i.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 qw="#mention:",Mm="#entity:",Wne=/^\[([^\]]+)\]\(#entity:((tsk|req|proj|dlv|agt|team)_[a-f0-9]{6,})\)$/i,LS=/^(workflow|task|requirement|project|deliverable|agent|team):(.+)$/,mg="text-brand-500 hover:text-brand-500 underline break-all cursor-pointer";function pg(e){return e.type==="text"?e.value??"":(e.children??[]).map(pg).join("")}function Yne(e){return e.type==="text"&&(e.value??"").trim()===""}function Qne(e){if(!e?.children)return null;const t=e.children.filter(a=>!Yne(a));if(t.length!==1)return null;const n=t[0];if(n.type==="element"&&n.tagName==="a"){const a=n.properties?.href;if(!a)return null;const s=pg(n);if(a.startsWith(Mm))return{id:a.slice(Mm.length)};const l=a.match(LS);return l&&l[1]!=="workflow"?{id:l[2],type:TS(l[1]),label:s}:null}if(n.type==="element"&&n.tagName==="code"){const a=pg(n).trim();if(Em(a))return{id:a}}if(n.type==="text"){const a=(n.value??"").trim();if(Em(a))return{id:a}}return null}const Xne={p:({children:e})=>i.jsx("p",{className:"mb-2 last:mb-0 leading-relaxed text-fg-secondary",children:e}),h1:({children:e})=>i.jsx("h1",{className:"text-base font-bold mb-2 mt-3 first:mt-0 text-fg-primary",children:e}),h2:({children:e})=>i.jsx("h2",{className:"text-sm font-bold mb-2 mt-3 first:mt-0 text-fg-primary",children:e}),h3:({children:e})=>i.jsx("h3",{className:"text-sm font-semibold mb-1 mt-2 first:mt-0 text-fg-primary",children:e}),h4:({children:e})=>i.jsx("h4",{className:"text-sm font-semibold mb-1 mt-2 first:mt-0 text-fg-primary",children:e}),h5:({children:e})=>i.jsx("h5",{className:"text-xs font-semibold mb-1 mt-2 first:mt-0 text-fg-primary",children:e}),h6:({children:e})=>i.jsx("h6",{className:"text-xs font-medium mb-1 mt-2 first:mt-0 text-fg-primary",children:e}),ul:({children:e})=>i.jsx("ul",{className:"list-disc pl-4 mb-2 space-y-0.5",children:e}),ol:({children:e,start:t})=>i.jsx("ol",{start:t,className:"list-decimal pl-7 mb-2 space-y-0.5",children:e}),li:({children:e,value:t})=>i.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??""),a=n.trim();if(t?.includes("language-plantuml")||zte(a))return i.jsx(dg,{code:a,language:"plantuml",children:i.jsx(DS,{code:a})});if(t?.includes("language-mermaid"))return i.jsx(dg,{code:a,language:"mermaid",children:i.jsx(RS,{code:a})});if(t?.includes("language-"))return i.jsx("code",{className:`${t} text-fg-secondary font-mono text-xs`,children:e});if(Em(n))return i.jsx(gc,{id:n.trim()});const s=n.match(Wne);return s?i.jsx(gc,{id:s[2],label:s[1]}):Kte(n)?i.jsx(Rne,{path:n}):i.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})=>i.jsx(Vne,{children:e}),strong:({children:e})=>i.jsx("strong",{className:"font-bold text-fg-primary",children:e}),em:({children:e})=>i.jsx("em",{className:"italic text-fg-secondary",children:e}),del:({children:e})=>i.jsx("del",{className:"line-through text-fg-tertiary",children:e}),blockquote:({children:e})=>i.jsx("blockquote",{className:"border-l-2 border-brand-500 pl-3 my-2 text-fg-secondary italic",children:e}),a:({href:e,children:t})=>i.jsx("a",{href:e,className:mg,children:t}),hr:()=>i.jsx("hr",{className:"border-border-default my-3"}),table:({children:e})=>i.jsx("div",{className:"overflow-x-auto my-2",children:i.jsx("table",{className:"min-w-full text-sm border-collapse border border-border-default",children:e})}),thead:({children:e})=>i.jsx("thead",{className:"bg-surface-secondary",children:e}),tbody:({children:e})=>i.jsx("tbody",{className:"divide-y divide-border-default",children:e}),tr:({children:e})=>i.jsx("tr",{className:"hover:bg-surface-elevated/50 transition-colors",children:e}),th:({children:e})=>i.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})=>i.jsx("td",{className:"px-3 py-2 text-sm text-fg-primary border border-border-default",children:e})},Jne=/\.(png|jpe?g|gif|webp|svg|bmp|ico)$/i;function Zne(e){const t=fb(e);return vS(e)&&Jne.test(t.split("?")[0]??t)}function eae(e,t){const n=fb(e);if(n.startsWith("/")||n.startsWith("~/")||/^[A-Za-z]:\//.test(n)||n.startsWith("//"))return n;if((n.startsWith("./")||n.startsWith("../"))&&t){const s=((t.replace(/\\/g,"/").endsWith("/")?t.replace(/\\/g,"/"):`${t.replace(/\\/g,"/")}/`)+n).split("/"),l=[];for(const c of s)c===".."?l.pop():c!=="."&&c!==""&&l.push(c);return"/"+l.join("/")}return n}function tae(e){return`/api/files/image?path=${encodeURIComponent(e)}`}function nae(e,t){return Zne(e)?tae(eae(e,t)):null}const Lo=new Map,sc=new Map,aae=k.memo(function({src:t,alt:n,onPreview:a,basePath:s}){const l=k.useMemo(()=>nae(t,s)??t,[t,s]),c=l.startsWith("/api/files/image?"),d=Lo.get(l),m=sc.get(l),[p,h]=k.useState(d??(c?null:l)),[g,x]=k.useState(!!d),[y,w]=k.useState(!!m),[T,C]=k.useState(m??null),[S,E]=k.useState(0),_=k.useRef(0),M=k.useCallback(R=>{sc.set(l,R),C(R),w(!0),x(!1)},[l]),P=k.useCallback(()=>{Lo.delete(l),sc.delete(l),w(!1),C(null),x(!1),h(c?null:`${l}${l.includes("?")?"&":"?"}retry=${Date.now()}`),E(R=>R+1)},[l,c]);return k.useEffect(()=>{if(!c)return;const R=Lo.get(l);if(R){h(R),x(!0),w(!1),C(null);return}const I=sc.get(l);if(I!==void 0){w(!0),C(I),x(!1);return}const K=++_.current;w(!1),C(null),x(!1),h(null),(async()=>{try{const Y=await fetch(l,{credentials:"same-origin"});if(K!==_.current)return;if(!Y.ok){let ne=`HTTP ${Y.status}`;try{const ee=await Y.json();ee.error&&(ne=ee.error)}catch{}throw new Error(ne)}const L=await Y.blob();if(K!==_.current)return;if(L.size===0)throw new Error("Empty image response");if(L.type&&!L.type.startsWith("image/")&&!L.type.includes("octet-stream"))throw new Error(`Unexpected content-type: ${L.type}`);const F=URL.createObjectURL(L);Lo.set(l,F),h(F),x(!0),w(!1),C(null)}catch(Y){if(K!==_.current)return;const L=Y instanceof Error?Y.message:String(Y);console.warn("[MarkdownImage] failed to load local image",l,Y),M(L)}})()},[c,l,S]),k.useEffect(()=>{if(c)return;const R=sc.get(l);if(R!==void 0){w(!0),C(R),x(!1);return}h(l),x(!!Lo.get(l)),w(!1),C(null)},[l,c,S]),y?i.jsxs("button",{type:"button",onClick:P,title:T??"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:[i.jsxs("svg",{className:"w-4 h-4 shrink-0",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:1.5,children:[i.jsx("rect",{x:"3",y:"3",width:"18",height:"18",rx:"2",ry:"2"}),i.jsx("circle",{cx:"8.5",cy:"8.5",r:"1.5"}),i.jsx("polyline",{points:"21 15 16 10 5 21"})]}),i.jsxs("span",{className:"truncate",children:["Failed to load image — click to retry",T?` (${T})`:""]})]}):i.jsxs("span",{className:"inline-block align-middle max-w-full",children:[!g&&i.jsx("span",{className:"block w-full min-h-[80px] max-w-[400px] bg-surface-elevated rounded-lg animate-pulse"}),p?i.jsx("img",{src:p,alt:n??"",onLoad:()=>{c||Lo.set(l,l),x(!0)},onError:()=>{M("Image decode failed")},onClick:()=>a?.(p),className:`max-w-full h-auto rounded-lg cursor-pointer hover:opacity-90 transition-opacity my-1${g?"":" absolute opacity-0 pointer-events-none"}`,style:{maxHeight:"400px",objectFit:"contain"}}):null]})});async function Fw(e){const t=await fetch(e);if(!t.ok)throw new Error(`Failed to fetch image (${t.status})`);return t.blob()}async function rae(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 a=n.getContext("2d");if(!a)throw new Error("Canvas unavailable");return a.drawImage(t,0,0),t.close(),new Promise((s,l)=>{n.toBlob(c=>c?s(c):l(new Error("PNG encode failed")),"image/png")})}function iae(e,t){try{const s=(e.startsWith("data:")?"":new URL(e,window.location.href).pathname).split("/").pop()||"";if(s&&/\.(png|jpe?g|gif|webp|svg|bmp)$/i.test(s))return decodeURIComponent(s)}catch{}return`image.${(t.type.split("/")[1]||"png").replace("jpeg","jpg")}`}function IS({src:e,onClose:t}){const{t:n}=ot("common"),[a,s]=k.useState(null),[l,c]=k.useState(null);Qo(!0),k.useEffect(()=>{const g=x=>{x.key==="Escape"&&t()};return document.addEventListener("keydown",g),()=>document.removeEventListener("keydown",g)},[t]);const d=k.useCallback(g=>{s(g),window.setTimeout(()=>s(null),1600)},[]),m=k.useCallback(async g=>{if(g.stopPropagation(),!l){c("copy");try{const x=await Fw(e),y=await rae(x);await navigator.clipboard.write([new ClipboardItem({"image/png":y})]),d(n("imageCopied"))}catch{d(n("imageCopyFailed"))}finally{c(null)}}},[l,d,e,n]),p=k.useCallback(async g=>{if(g.stopPropagation(),!l){c("download");try{const x=await Fw(e),y=URL.createObjectURL(x),w=document.createElement("a");w.href=y,w.download=iae(e,x),document.body.appendChild(w),w.click(),w.remove(),URL.revokeObjectURL(y),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 zr.createPortal(i.jsxs("div",{className:"fixed inset-0 z-[9999] bg-black/80 flex items-center justify-center p-4",onClick:t,children:[i.jsxs("div",{className:"absolute top-4 right-4 z-10 flex items-center gap-2",onClick:g=>g.stopPropagation(),children:[i.jsxs("button",{type:"button",className:h,onClick:m,disabled:!!l,title:n("copyImage"),children:[i.jsxs("svg",{className:"w-4 h-4",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[i.jsx("rect",{x:"9",y:"9",width:"13",height:"13",rx:"2"}),i.jsx("path",{d:"M5 15H4a2 2 0 01-2-2V4a2 2 0 012-2h9a2 2 0 012 2v1"})]}),n("copy")]}),i.jsxs("button",{type:"button",className:h,onClick:p,disabled:!!l,title:n("downloadImage"),children:[i.jsxs("svg",{className:"w-4 h-4",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[i.jsx("path",{d:"M21 15v4a2 2 0 01-2 2H5a2 2 0 01-2-2v-4"}),i.jsx("polyline",{points:"7 10 12 15 17 10"}),i.jsx("line",{x1:"12",y1:"15",x2:"12",y2:"3"})]}),n("downloadImage")]}),i.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:i.jsxs("svg",{className:"w-6 h-6 text-white",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2,children:[i.jsx("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),i.jsx("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]})})]}),a&&i.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:a}),i.jsx("img",{src:e,alt:"Preview",className:"max-w-full max-h-[90vh] object-contain rounded-lg",onClick:g=>g.stopPropagation()})]}),document.body)}function OS(e={}){const{onMentionClick:t,basePath:n,onImagePreview:a,contentRef:s,hostAvailable:l,openRightPanel:c}=e,d=k.useCallback((m,p)=>{const h=Rw(p,n);if(h.kind!=="passthrough"){if(m.preventDefault(),m.stopPropagation(),h.kind==="fragment"){Vte(s?.current??null,h.id);return}if(h.kind==="file"){l&&c?c({kind:"file",path:h.path,title:h.path.split(/[/\\]/).pop()}):Ae.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}fi(h.url)}}},[n,s,l,c]);return k.useMemo(()=>({...Xne,img:({src:m,alt:p})=>i.jsx(aae,{src:m??"",alt:p,onPreview:a,basePath:n},m??""),p:({children:m,node:p})=>{const h=Qne(p);return h?i.jsx(lne,{id:h.id,type:h.type,label:h.label}):i.jsx("p",{className:"mb-2 last:mb-0 leading-relaxed text-fg-secondary",children:m})},a:({href:m,children:p})=>{if(m?.startsWith(qw)){const g=decodeURIComponent(m.slice(qw.length));return i.jsx("span",{className:`text-brand-500 font-medium${t?" cursor-pointer hover:underline":""}`,onClick:t?x=>{x.preventDefault(),x.stopPropagation(),t(g,x)}:void 0,title:g,children:p})}if(m?.startsWith(Mm))return i.jsx(gc,{id:m.slice(Mm.length)});{const g=m?.match(LS);if(g){const[,x,y]=g;if(x==="workflow")return i.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(),at.navigate(de.WORK,{boardType:"workflows"})},title:`workflow: ${y}`,children:[i.jsx("span",{className:"text-[10px]",children:"⚙️"}),i.jsx("span",{children:p})]});const w=TS(x);if(w)return i.jsx(gc,{id:y,type:w,label:p})}}if(m&&Em(m))return i.jsx(gc,{id:m.trim(),label:p});const h=Rw(m,n);return h.kind==="fragment"||h.kind==="file"||h.kind==="external"?i.jsx("a",{href:m,className:mg,onClick:g=>d(g,m),title:h.kind==="fragment"?`#${h.id}`:h.kind==="file"?h.path:h.url,children:p}):i.jsx("a",{href:m,className:mg,onClick:g=>{Go()&&m&&!/^[a-zA-Z][a-zA-Z0-9+.-]*:/.test(m)&&g.preventDefault()},children:p})}}),[t,n,a,d])}const Uw=[D5,I3,O3],Gw=[SS,[G3,{strict:"ignore"}],[cS,{detect:!0,ignoreMissing:!0}]];function fg(e){if(/^(deliverable|task|requirement|project|agent|team|workflow):/i.test(e))return e;const n=pb(e);return vS(n)?n:o5(e)}const sae=/(?:<thinking>| thinking)([\s\S]*?)<\/thinking>/g;function oae(e){const t=[];let n=e.replace(sae,(a,s)=>{const l=s.trim();return l&&t.push(l),""});return n=n.replace(/<thinking>/gi,"").replace(/<\/thinking>/gi,""),{thinking:t,rest:n.trim()}}function lae(e=640){const[t,n]=k.useState(()=>window.innerWidth<e);return k.useEffect(()=>{const a=window.matchMedia(`(max-width: ${e-1}px)`),s=l=>n(l.matches);return a.addEventListener("change",s),n(a.matches),()=>a.removeEventListener("change",s)},[e]),t}function cae({content:e,contentRef:t}){const{t:n}=ot("common"),[a,s]=k.useState(!1),[l,c]=k.useState(!1),[d,m]=k.useState(!1),[p,h]=k.useState(null),g=k.useRef(null),x=lae();k.useEffect(()=>{if(!a)return;const C=S=>{g.current&&!g.current.contains(S.target)&&(s(!1),c(!1),m(!1))};return document.addEventListener("mousedown",C),()=>document.removeEventListener("mousedown",C)},[a]);const y=k.useCallback(C=>{h(C),setTimeout(()=>h(null),1500)},[]),w=async()=>{const C=await hb(e);y(n(C?"markdown.copied":"markdown.failed")),s(!1)},T=async C=>{const S=t.current?.firstElementChild;if(!S)return;const E=AS(),_=Xte(E),M=await Yte(S,C,e,{fontFamily:_.fontFamily,fontSize:_.fontSize,headingScales:_.headingScales}),P=n(C==="light"?"markdown.themeLight":"markdown.themeDark");y(M.ok?M.method==="html"?n("markdown.htmlCopied",{theme:P}):n("markdown.textCopied"):n("markdown.failed")),s(!1)};return i.jsxs("div",{className:"absolute top-1 right-1 z-10 opacity-0 group-hover/md:opacity-100 transition-opacity",ref:g,children:[p&&i.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:p}),i.jsx("button",{onClick:()=>s(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:i.jsx("svg",{className:"w-3.5 h-3.5",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:i.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"})})}),a&&i.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?i.jsx(Jte,{onClose:()=>m(!1)}):l?i.jsxs("div",{className:"px-3 py-2 text-[11px] text-fg-secondary space-y-2 max-w-[260px]",children:[i.jsxs("div",{className:"flex items-center justify-between mb-1",children:[i.jsx("span",{className:"font-medium text-fg-primary text-xs",children:n("markdown.infoTitle")}),i.jsx("button",{onClick:()=>c(!1),className:"text-fg-tertiary hover:text-fg-primary p-0.5",children:i.jsx("svg",{className:"w-3 h-3",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:i.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M6 18L18 6M6 6l12 12"})})})]}),i.jsxs("div",{children:[i.jsx("span",{className:"font-medium text-fg-primary",children:n("markdown.mdAbbrev")})," — ",n("markdown.infoMdDesc")]}),i.jsxs("div",{children:[i.jsx("span",{className:"font-medium text-fg-primary",children:"☀️"})," — ",n("markdown.infoHtmlLightDesc")]}),i.jsxs("div",{children:[i.jsx("span",{className:"font-medium text-fg-primary",children:"🌙"})," — ",n("markdown.infoHtmlDarkDesc")]})]}):i.jsxs(i.Fragment,{children:[i.jsxs("div",{className:"flex items-center justify-between px-3 py-1 border-b border-border-subtle mb-1",children:[i.jsx("span",{className:"text-[10px] text-fg-tertiary font-medium",children:n("markdown.copyContent")}),i.jsxs("div",{className:"flex items-center gap-1",children:[i.jsx("button",{onClick:()=>m(!0),className:"p-0.5 rounded text-fg-tertiary hover:text-fg-primary transition-colors",title:n("markdown.typographySettings"),children:i.jsxs("svg",{className:"w-3.5 h-3.5",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:[i.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"}),i.jsx("circle",{cx:"12",cy:"12",r:"3"})]})}),i.jsx("button",{onClick:()=>c(!0),className:"p-0.5 rounded text-fg-tertiary hover:text-fg-primary transition-colors",title:n("markdown.infoTitle"),children:i.jsxs("svg",{className:"w-3.5 h-3.5",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:[i.jsx("circle",{cx:"12",cy:"12",r:"10"}),i.jsx("path",{strokeLinecap:"round",d:"M12 16v-4m0-4h.01"})]})})]})]}),i.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:[i.jsx("span",{className:"w-4 text-center text-fg-tertiary shrink-0 font-mono text-[10px]",children:n("markdown.mdAbbrev")}),n(x?"markdown.copyMdSourceShort":"markdown.copyMdSource")]}),i.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:[i.jsx("span",{className:"w-4 text-center shrink-0 text-[10px]",children:"☀️"}),n(x?"markdown.copyHtmlLightShort":"markdown.copyHtmlLight")]}),i.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:[i.jsx("span",{className:"w-4 text-center shrink-0 text-[10px]",children:"🌙"}),n(x?"markdown.copyHtmlDarkShort":"markdown.copyHtmlDark")]})]})})]})}const Ea=k.memo(function({content:t,className:n="",onMentionClick:a,knownNames:s,basePath:l}){const{thinking:c,rest:d}=oae(t),m=k.useRef(null),[p,h]=k.useState(null),g=qc(),x=k.useCallback(T=>{let C=ui(T,mS);return C=ui(C,Mte),C=ui(C,Ute),C=ui(C,Lte),C=ui(C,Ite),C=ui(C,S=>_te(S,s)),C=ui(C,hS),C},[s]),y=k.useMemo(()=>x(d),[d,x]),w=OS({onMentionClick:a,basePath:l,onImagePreview:h,contentRef:m,hostAvailable:g?.hostAvailable,openRightPanel:g?.openRightPanel});return i.jsxs("div",{className:"relative group/md",children:[i.jsx(cae,{content:t,contentRef:m}),i.jsx("div",{ref:m,children:i.jsx(Zte,{resetKeys:[y],fallback:i.jsx("div",{className:`prose prose-sm max-w-none break-words whitespace-pre-wrap pr-8 text-fg-secondary ${n}`,children:d}),children:i.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(`
854
+ `,t.prepend(c),()=>{t.innerHTML=""}}k.lazy(()=>va(()=>Promise.resolve().then(()=>PS),void 0).then(e=>({default:e.MarkdownMessage})));const Sne=k.lazy(()=>va(()=>import("./ContentRenderer-zASgOqkn.js"),[]).then(e=>({default:e.ContentRenderer})));let Do=[],Pw=60;function Cne(e){const t=k.useRef(e);t.current=e;const[n]=k.useState(()=>++Pw);return k.useEffect(()=>{const a=()=>t.current();Do.push(a);const s=l=>{l.key==="Escape"&&Do[Do.length-1]===a&&(l.preventDefault(),a())};return window.addEventListener("keydown",s,!0),()=>{window.removeEventListener("keydown",s,!0),Do=Do.filter(l=>l!==a),Do.length===0&&(Pw=60)}},[]),n}const zw=500,Ji=new Map,jm=new Set,Zd=new Map;let em=null;function Ane(){if(Ji.size<=zw)return;const e=Ji.size-zw,t=Ji.keys();for(let n=0;n<e;n++){const{value:a,done:s}=t.next();if(s)break;Ji.delete(a)}}function Bw(e,t){Ji.delete(e),Ji.set(e,t),Ane()}function Hw(e){const t=Zd.get(e);if(t)for(const n of t)n()}function Tne(){em=null;const e=[...jm];jm.clear(),e.length!==0&&Ae.files.check(e).then(({results:t})=>{for(const[n,a]of Object.entries(t))Bw(n,a),Hw(n)}).catch(()=>{for(const t of e)Bw(t,{exists:!1,isFile:!1,type:"unknown"}),Hw(t)})}function Nne(e){Ji.has(e)||jm.has(e)||(jm.add(e),em&&clearTimeout(em),em=setTimeout(Tne,30))}function Ene(e,t){let n=Zd.get(e);return n||(n=new Set,Zd.set(e,n)),n.add(t),()=>{n.delete(t),n.size===0&&Zd.delete(e)}}function jne(e){const t=k.useCallback(s=>Ene(e,s),[e]),n=k.useCallback(()=>Ji.get(e),[e]),a=k.useSyncExternalStore(t,n,n);return k.useEffect(()=>{Nne(e)},[e]),a}function Mne(e){const t=e.includes("\\")?"\\":"/",n=e.lastIndexOf(t);return n<=0?t==="/"?"/":e.slice(0,2):e.slice(0,n)}function _ne({filePath:e,onClose:t}){const n=Cne(t),[a,s]=k.useState(e),[l,c]=k.useState(!0),[d,m]=k.useState(null),[p,h]=k.useState(""),[g,x]=k.useState(""),[y,w]=k.useState(""),[T,C]=k.useState(""),[S,E]=k.useState(""),[_,M]=k.useState(null),[P,R]=k.useState(!1);k.useEffect(()=>{c(!0),m(null),h(""),M(null),Ae.files.preview(a).then(F=>{if(F.type==="directory"&&Array.isArray(F.entries)){x("directory"),w(F.name),M(F.entries);return}x(F.type),w(F.name),C(F.mimeType||""),h(typeof F.content=="string"?F.content:""),E(F.streamUrl||(F.path?Ae.files.streamUrl(F.path):"")||(F.type==="audio"||F.type==="video"?Ae.files.streamUrl(a):""))}).catch(F=>{m(String(F?.message||F))}).finally(()=>{c(!1)})},[a]);const I=y||a.split(/[/\\]/).pop()||a,K=g==="directory"||a!==e,Y=()=>s(F=>Mne(F)),L=()=>{navigator.clipboard?.writeText(a).then(()=>{R(!0),setTimeout(()=>R(!1),1500)}).catch(()=>{})};return zr.createPortal(i.jsx("div",{className:"fixed inset-0 bg-black/40 flex items-center justify-center",style:{zIndex:n},onClick:t,children:i.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:F=>F.stopPropagation(),children:[i.jsxs("div",{className:"flex items-center justify-between px-4 py-3 border-b border-border-default bg-surface-elevated/50 shrink-0",children:[i.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[g==="directory"&&i.jsx("svg",{className:"w-4 h-4 shrink-0 text-blue-400",viewBox:"0 0 20 20",fill:"currentColor",children:i.jsx("path",{d:"M3.5 3A1.5 1.5 0 002 4.5v11A1.5 1.5 0 003.5 17h13a1.5 1.5 0 001.5-1.5v-8A1.5 1.5 0 0016.5 6h-6.53a.5.5 0 01-.354-.146L8.706 4.854A1.5 1.5 0 007.586 4H3.5z"})}),g!=="directory"&&i.jsx("svg",{className:"w-4 h-4 shrink-0 text-fg-secondary",viewBox:"0 0 20 20",fill:"currentColor",children:i.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"})}),i.jsx("span",{className:"text-sm font-medium text-fg-primary truncate",children:I}),i.jsx("span",{className:"text-xs text-fg-tertiary truncate hidden sm:inline",children:a})]}),i.jsxs("div",{className:"flex items-center gap-2 shrink-0",children:[K&&i.jsx("button",{className:"text-xs text-fg-secondary hover:text-fg-primary px-2 py-1 rounded hover:bg-surface-elevated transition-colors",onClick:Y,title:"返回上级目录",children:"← 上级"}),i.jsx("button",{className:"text-xs text-fg-secondary hover:text-fg-primary px-2 py-1 rounded hover:bg-surface-elevated transition-colors",onClick:L,title:"复制路径",children:P?"✓ 已复制":"复制路径"}),i.jsx("button",{className:"text-xs text-fg-secondary hover:text-fg-primary px-2 py-1 rounded hover:bg-surface-elevated transition-colors",onClick:()=>Ae.files.reveal(a),title:"Reveal in file explorer",children:i.jsx("svg",{className:"w-4 h-4",viewBox:"0 0 20 20",fill:"currentColor",children:i.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"})})}),i.jsx("button",{className:"text-fg-secondary hover:text-fg-primary p-1 rounded hover:bg-surface-elevated transition-colors",onClick:t,children:i.jsx("svg",{className:"w-4 h-4",viewBox:"0 0 20 20",fill:"currentColor",children:i.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"})})})]})]}),i.jsxs("div",{className:"flex-1 overflow-y-auto p-5",children:[l&&i.jsx("div",{className:"flex items-center justify-center py-12",children:i.jsx("div",{className:"w-5 h-5 border-2 border-brand-500/30 border-t-brand-500 rounded-full animate-spin"})}),d&&i.jsxs("div",{className:"text-center py-12 text-fg-secondary text-sm",children:[i.jsx("p",{className:"text-red-400 mb-1",children:"Failed to load file"}),i.jsx("p",{className:"text-xs text-fg-tertiary",children:d})]}),!l&&!d&&g==="directory"&&_&&i.jsx(pne,{path:a,entries:_,onNavigate:F=>s(F),onOpenFile:F=>s(F),onReveal:F=>Ae.files.reveal(F),onCopyPath:F=>{navigator.clipboard?.writeText(F).then(()=>{R(!0),setTimeout(()=>R(!1),1500)}).catch(()=>{})}}),!l&&!d&&g==="office"&&S&&i.jsx(hne,{data:{format:(a.split(".").pop()||"pdf").toLowerCase(),streamUrl:S,name:I},reference:a,onFallback:()=>{Ae.files.reveal(a)}}),!l&&!d&&g==="image"&&p&&i.jsx("div",{className:"flex justify-center",children:i.jsx("img",{src:`data:${T||"image/png"};base64,${p}`,alt:I,className:"max-w-full rounded"})}),!l&&!d&&g==="audio"&&S&&i.jsx("audio",{controls:!0,preload:"metadata",src:S,className:"w-full"}),!l&&!d&&g==="video"&&S&&i.jsx("video",{controls:!0,preload:"metadata",src:S,className:"w-full max-h-[60vh] rounded-lg bg-black"}),!l&&!d&&(g==="binary"||!p&&g!=="image"&&g!=="audio"&&g!=="video"&&g!=="directory")&&i.jsxs("div",{className:"text-center py-8 space-y-3",children:[i.jsx("p",{className:"text-sm text-fg-secondary",children:"This file type cannot be previewed."}),i.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:()=>{Ae.files.reveal(a)},children:"Reveal in file explorer"})]}),!l&&!d&&p&&g!=="image"&&g!=="audio"&&g!=="video"&&g!=="binary"&&g!=="directory"&&i.jsx(k.Suspense,{fallback:i.jsx("div",{className:"text-xs text-fg-tertiary",children:"Loading…"}),children:i.jsx(Sne,{content:p,format:g==="text"?"text":g,className:"text-sm"})})]})]})}),document.body)}function Rne({path:e}){const t=jne(e),[n,a]=k.useState(null),s=qc(),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"||t?.type==="office"||t?.type==="directory",d=k.useCallback(h=>{if(h.preventDefault(),h.stopPropagation(),!!l)if(c){if(s?.hostAvailable){s.openRightPanel({kind:"file",path:e});return}a(e)}else Ae.files.reveal(e)},[l,c,e,s]),m="inline w-3 h-3 align-[-0.125em]",p=c?i.jsx("svg",{className:m,viewBox:"0 0 20 20",fill:"currentColor",children:i.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"})}):i.jsx("svg",{className:m,viewBox:"0 0 20 20",fill:"currentColor",children:i.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?i.jsxs(i.Fragment,{children:[i.jsxs("code",{"data-file-path-link":"ready",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:[i.jsxs("span",{className:"whitespace-nowrap",children:[p,e.charAt(0)]}),e.slice(1)]}),n&&i.jsx(_ne,{filePath:n,onClose:()=>a(null)})]}):i.jsx("code",{"data-file-path-link":"missing",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}):i.jsx("code",{"data-file-path-link":"loading",className:"bg-surface-secondary px-1.5 py-0.5 rounded text-xs font-mono text-fg-secondary break-all",children:e})}let uh=null;function Dne(){return uh||(uh=va(()=>import("./mermaid.core-Des6lIh7.js").then(e=>e.b9),__vite__mapDeps([0,1])).then(e=>(e.default.initialize({startOnLoad:!1,securityLevel:"loose",fontFamily:"inherit"}),e))),uh}function Lne(){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 Ine(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 One(){return Lne()}function Pne(){return k.useSyncExternalStore(Ine,One)}function RS({code:e}){const{t}=ot("common"),n=k.useRef(null),[a,s]=k.useState(null),[l,c]=k.useState(!0),d=k.useId(),m=k.useRef(0),p=k.useRef(null),h=Pne();return k.useEffect(()=>{if(!e.trim()||p.current&&p.current.code===e&&p.current.dark===h)return;let g=!1;return c(!0),s(null),m.current+=1,(async()=>{try{const x=await Dne();if(g)return;x.default.initialize({startOnLoad:!1,theme:h?"dark":"default",securityLevel:"loose",fontFamily:"inherit"});const y=`mermaid-${d.replace(/:/g,"")}-${m.current}`,{svg:w}=await x.default.render(y,e.trim());if(g)return;n.current&&(n.current.innerHTML=w,p.current={code:e,dark:h})}catch(x){g||s(x instanceof Error?x.message:String(x))}finally{g||c(!1)}})(),()=>{g=!0}},[e,d,h]),a?i.jsxs("div",{className:"my-2 rounded-lg overflow-hidden border border-red-500/30",children:[i.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:[i.jsx("svg",{className:"w-3.5 h-3.5 text-red-400",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:i.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"})}),i.jsx("span",{className:"text-[10px] font-medium text-red-400",children:t("markdown.mermaidRenderError")})]}),a&&i.jsx("div",{className:"px-3 py-2 bg-surface-secondary/60 text-[11px] font-mono text-red-300/90 whitespace-pre-wrap break-words border-b border-red-500/10 max-h-40 overflow-y-auto",children:a}),i.jsx("pre",{className:"p-3 bg-surface-secondary text-xs text-fg-secondary overflow-x-auto font-mono",children:e})]}):i.jsxs("div",{className:"not-prose my-2 rounded-lg bg-surface-secondary border border-border-subtle p-4 overflow-x-auto",children:[l&&i.jsxs("div",{className:"flex items-center gap-2 text-xs text-fg-tertiary",children:[i.jsx("div",{className:"w-4 h-4 border-2 border-fg-tertiary/30 border-t-fg-tertiary rounded-full animate-spin"}),t("markdown.renderingDiagram")]}),i.jsx("div",{ref:n,className:`flex justify-center [&>svg]:max-w-full${l?" hidden":""}`})]})}const zne="/assets/viz-global-C_AyN6D9.js";let Rd=!1,dh=null;function Bne(){return Rd?Promise.resolve():new Promise((e,t)=>{const n=document.querySelector("script[data-plantuml-viz]");if(n){globalThis.Viz?(Rd=!0,e()):(n.addEventListener("load",()=>{Rd=!0,e()}),n.addEventListener("error",()=>t(new Error("Failed to load viz-global.js"))));return}const a=document.createElement("script");a.setAttribute("data-plantuml-viz",""),a.src=zne,a.onload=()=>{Rd=!0,e()},a.onerror=()=>t(new Error("Failed to load viz-global.js")),document.head.appendChild(a)})}function Hne(){return dh||(dh=Bne().then(()=>va(()=>import("./plantuml-DezRDxd4.js"),[]))),dh}let $w=Promise.resolve();function $ne(e,t){const n=$w.then(()=>new Promise((a,s)=>{Hne().then(({renderToString:l})=>{const c=e.split(/\r\n|\r|\n/);l(c,a,s,{dark:t})}).catch(s)}));return $w=n.then(()=>{},()=>{}),n}function qne(){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 Fne(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 Une(){return k.useSyncExternalStore(Fne,()=>qne())}function DS({code:e}){const{t}=ot("common"),[n,a]=k.useState(null),[s,l]=k.useState(null),[c,d]=k.useState(!0),m=k.useRef(null),p=Une();return k.useEffect(()=>{if(!e.trim()||m.current&&m.current.code===e&&m.current.dark===p)return;let h=!1;return d(!0),l(null),$ne(e.trim(),p).then(g=>{h||(a(g),m.current={code:e,dark:p})}).catch(g=>{h||l(g instanceof Error?g.message:String(g))}).finally(()=>{h||d(!1)}),()=>{h=!0}},[e,p]),s?i.jsxs("div",{className:"my-2 rounded-lg overflow-hidden border border-red-500/30",children:[i.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:[i.jsx("svg",{className:"w-3.5 h-3.5 text-red-400",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:i.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"})}),i.jsx("span",{className:"text-[10px] font-medium text-red-400",children:t("markdown.plantumlRenderError")})]}),s&&i.jsx("div",{className:"px-3 py-2 bg-surface-secondary/60 text-[11px] font-mono text-red-300/90 whitespace-pre-wrap break-words border-b border-red-500/10 max-h-40 overflow-y-auto",children:s}),i.jsx("pre",{className:"p-3 bg-surface-secondary text-xs text-fg-secondary overflow-x-auto font-mono",children:e})]}):i.jsxs("div",{className:"not-prose my-2 rounded-lg bg-surface-secondary border border-border-subtle p-4 overflow-x-auto",children:[c&&i.jsxs("div",{className:"flex items-center gap-2 text-xs text-fg-tertiary",children:[i.jsx("div",{className:"w-4 h-4 border-2 border-fg-tertiary/30 border-t-fg-tertiary rounded-full animate-spin"}),t("markdown.renderingDiagram")]}),n&&i.jsx("div",{className:`flex justify-center [&>svg]:max-w-full${c?" hidden":""}`,dangerouslySetInnerHTML:{__html:n}})]})}function dg({code:e,language:t,children:n}){const{t:a}=ot("common"),[s,l]=k.useState("rendered"),[c,d]=k.useState(!1),m=k.useCallback(async()=>{await hb(e)&&(d(!0),setTimeout(()=>d(!1),1800))},[e]);return i.jsxs("div",{className:"not-prose my-2 rounded-lg overflow-hidden border border-border-subtle",children:[i.jsxs("div",{className:"flex items-center justify-between px-3 py-1.5 border-b border-border-subtle bg-surface-secondary",children:[i.jsx("span",{className:"text-[10px] font-medium text-fg-tertiary uppercase tracking-wider select-none",children:t}),i.jsxs("div",{className:"flex items-center gap-1",children:[i.jsx("button",{onClick:()=>l("rendered"),className:`px-2 py-0.5 rounded text-[10px] font-medium transition-colors ${s==="rendered"?"bg-brand-600/20 text-brand-500":"text-fg-tertiary hover:text-fg-secondary"}`,children:i.jsxs("span",{className:"flex items-center gap-1",children:[i.jsxs("svg",{className:"w-3 h-3",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:[i.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M15 12a3 3 0 11-6 0 3 3 0 016 0z"}),i.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"})]}),a("markdown.viewRendered")]})}),i.jsx("button",{onClick:()=>l("source"),className:`px-2 py-0.5 rounded text-[10px] font-medium transition-colors ${s==="source"?"bg-brand-600/20 text-brand-500":"text-fg-tertiary hover:text-fg-secondary"}`,children:i.jsxs("span",{className:"flex items-center gap-1",children:[i.jsx("svg",{className:"w-3 h-3",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:i.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M10 20l4-16m4 4l4 4-4 4M6 16l-4-4 4-4"})}),a("markdown.viewSource")]})})]})]}),s==="rendered"?i.jsx("div",{children:n}):i.jsxs("div",{className:"relative group/source",children:[i.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}),i.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:a("markdown.copyContent"),children:c?i.jsx("svg",{className:"w-3.5 h-3.5 text-green-400",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:i.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M5 13l4 4L19 7"})}):i.jsx("svg",{className:"w-3.5 h-3.5",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:i.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 Gne=[RS,DS];function Kne(e){for(const t of k.Children.toArray(e))if(k.isValidElement(t)&&typeof t.props?.className=="string"){const n=t.props.className;return $te(n)}return null}function bc(e){if(typeof e=="string")return e;if(typeof e=="number")return String(e);if(!e)return"";if(Array.isArray(e))return e.map(bc).join("");if(k.isValidElement(e)){const t=e.props;return bc(t.children)}return""}function Vne({children:e}){const{t}=ot("common"),n=Kne(e),a=k.useRef(null),[s,l]=k.useState(!1),[c,d]=k.useState("rendered"),m=k.useCallback(async()=>{let h;c==="source"?h=bc(e):h=a.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)&&Gne.includes(h.type))){const h=bc(e),g=n==="mermaid"||n==="plantuml"?n:"diagram";return i.jsx(dg,{code:h,language:g,children:e})}return n==="mermaid"||n==="plantuml"?i.jsx(i.Fragment,{children:e}):i.jsxs("div",{className:"not-prose relative group/code my-2 rounded-lg overflow-hidden bg-surface-secondary border border-border-subtle",children:[n&&i.jsxs("div",{className:"flex items-center justify-between px-3 py-1.5 border-b border-border-subtle",children:[i.jsx("span",{className:"text-[10px] font-medium text-fg-tertiary uppercase tracking-wider select-none",children:Hte(n)}),i.jsxs("div",{className:"flex items-center gap-1",children:[i.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")}),i.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")})]})]}),i.jsxs("div",{className:"relative",children:[c==="rendered"?i.jsx("pre",{ref:a,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)}):i.jsx("pre",{className:"p-3 overflow-x-auto text-xs font-mono text-fg-secondary whitespace-pre-wrap break-words",children:bc(e)}),i.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:s?i.jsx("svg",{className:"w-3.5 h-3.5 text-green-400",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:i.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M5 13l4 4L19 7"})}):i.jsx("svg",{className:"w-3.5 h-3.5",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:i.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 qw="#mention:",Mm="#entity:",Wne=/^\[([^\]]+)\]\(#entity:((tsk|req|proj|dlv|agt|team)_[a-f0-9]{6,})\)$/i,LS=/^(workflow|task|requirement|project|deliverable|agent|team):(.+)$/,mg="text-brand-500 hover:text-brand-500 underline break-all cursor-pointer";function pg(e){return e.type==="text"?e.value??"":(e.children??[]).map(pg).join("")}function Yne(e){return e.type==="text"&&(e.value??"").trim()===""}function Qne(e){if(!e?.children)return null;const t=e.children.filter(a=>!Yne(a));if(t.length!==1)return null;const n=t[0];if(n.type==="element"&&n.tagName==="a"){const a=n.properties?.href;if(!a)return null;const s=pg(n);if(a.startsWith(Mm))return{id:a.slice(Mm.length)};const l=a.match(LS);return l&&l[1]!=="workflow"?{id:l[2],type:TS(l[1]),label:s}:null}if(n.type==="element"&&n.tagName==="code"){const a=pg(n).trim();if(Em(a))return{id:a}}if(n.type==="text"){const a=(n.value??"").trim();if(Em(a))return{id:a}}return null}const Xne={p:({children:e})=>i.jsx("p",{className:"mb-2 last:mb-0 leading-relaxed text-fg-secondary",children:e}),h1:({children:e})=>i.jsx("h1",{className:"text-base font-bold mb-2 mt-3 first:mt-0 text-fg-primary",children:e}),h2:({children:e})=>i.jsx("h2",{className:"text-sm font-bold mb-2 mt-3 first:mt-0 text-fg-primary",children:e}),h3:({children:e})=>i.jsx("h3",{className:"text-sm font-semibold mb-1 mt-2 first:mt-0 text-fg-primary",children:e}),h4:({children:e})=>i.jsx("h4",{className:"text-sm font-semibold mb-1 mt-2 first:mt-0 text-fg-primary",children:e}),h5:({children:e})=>i.jsx("h5",{className:"text-xs font-semibold mb-1 mt-2 first:mt-0 text-fg-primary",children:e}),h6:({children:e})=>i.jsx("h6",{className:"text-xs font-medium mb-1 mt-2 first:mt-0 text-fg-primary",children:e}),ul:({children:e})=>i.jsx("ul",{className:"list-disc pl-4 mb-2 space-y-0.5",children:e}),ol:({children:e,start:t})=>i.jsx("ol",{start:t,className:"list-decimal pl-7 mb-2 space-y-0.5",children:e}),li:({children:e,value:t})=>i.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??""),a=n.trim();if(t?.includes("language-plantuml")||zte(a))return i.jsx(dg,{code:a,language:"plantuml",children:i.jsx(DS,{code:a})});if(t?.includes("language-mermaid"))return i.jsx(dg,{code:a,language:"mermaid",children:i.jsx(RS,{code:a})});if(t?.includes("language-"))return i.jsx("code",{className:`${t} text-fg-secondary font-mono text-xs`,children:e});if(Em(n))return i.jsx(gc,{id:n.trim()});const s=n.match(Wne);return s?i.jsx(gc,{id:s[2],label:s[1]}):Kte(n)?i.jsx(Rne,{path:n}):i.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})=>i.jsx(Vne,{children:e}),strong:({children:e})=>i.jsx("strong",{className:"font-bold text-fg-primary",children:e}),em:({children:e})=>i.jsx("em",{className:"italic text-fg-secondary",children:e}),del:({children:e})=>i.jsx("del",{className:"line-through text-fg-tertiary",children:e}),blockquote:({children:e})=>i.jsx("blockquote",{className:"border-l-2 border-brand-500 pl-3 my-2 text-fg-secondary italic",children:e}),a:({href:e,children:t})=>i.jsx("a",{href:e,className:mg,children:t}),hr:()=>i.jsx("hr",{className:"border-border-default my-3"}),table:({children:e})=>i.jsx("div",{className:"overflow-x-auto my-2",children:i.jsx("table",{className:"min-w-full text-sm border-collapse border border-border-default",children:e})}),thead:({children:e})=>i.jsx("thead",{className:"bg-surface-secondary",children:e}),tbody:({children:e})=>i.jsx("tbody",{className:"divide-y divide-border-default",children:e}),tr:({children:e})=>i.jsx("tr",{className:"hover:bg-surface-elevated/50 transition-colors",children:e}),th:({children:e})=>i.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})=>i.jsx("td",{className:"px-3 py-2 text-sm text-fg-primary border border-border-default",children:e})},Jne=/\.(png|jpe?g|gif|webp|svg|bmp|ico)$/i;function Zne(e){const t=fb(e);return vS(e)&&Jne.test(t.split("?")[0]??t)}function eae(e,t){const n=fb(e);if(n.startsWith("/")||n.startsWith("~/")||/^[A-Za-z]:\//.test(n)||n.startsWith("//"))return n;if((n.startsWith("./")||n.startsWith("../"))&&t){const s=((t.replace(/\\/g,"/").endsWith("/")?t.replace(/\\/g,"/"):`${t.replace(/\\/g,"/")}/`)+n).split("/"),l=[];for(const c of s)c===".."?l.pop():c!=="."&&c!==""&&l.push(c);return"/"+l.join("/")}return n}function tae(e){return`/api/files/image?path=${encodeURIComponent(e)}`}function nae(e,t){return Zne(e)?tae(eae(e,t)):null}const Lo=new Map,sc=new Map,aae=k.memo(function({src:t,alt:n,onPreview:a,basePath:s}){const l=k.useMemo(()=>nae(t,s)??t,[t,s]),c=l.startsWith("/api/files/image?"),d=Lo.get(l),m=sc.get(l),[p,h]=k.useState(d??(c?null:l)),[g,x]=k.useState(!!d),[y,w]=k.useState(!!m),[T,C]=k.useState(m??null),[S,E]=k.useState(0),_=k.useRef(0),M=k.useCallback(R=>{sc.set(l,R),C(R),w(!0),x(!1)},[l]),P=k.useCallback(()=>{Lo.delete(l),sc.delete(l),w(!1),C(null),x(!1),h(c?null:`${l}${l.includes("?")?"&":"?"}retry=${Date.now()}`),E(R=>R+1)},[l,c]);return k.useEffect(()=>{if(!c)return;const R=Lo.get(l);if(R){h(R),x(!0),w(!1),C(null);return}const I=sc.get(l);if(I!==void 0){w(!0),C(I),x(!1);return}const K=++_.current;w(!1),C(null),x(!1),h(null),(async()=>{try{const Y=await fetch(l,{credentials:"same-origin"});if(K!==_.current)return;if(!Y.ok){let ne=`HTTP ${Y.status}`;try{const ee=await Y.json();ee.error&&(ne=ee.error)}catch{}throw new Error(ne)}const L=await Y.blob();if(K!==_.current)return;if(L.size===0)throw new Error("Empty image response");if(L.type&&!L.type.startsWith("image/")&&!L.type.includes("octet-stream"))throw new Error(`Unexpected content-type: ${L.type}`);const F=URL.createObjectURL(L);Lo.set(l,F),h(F),x(!0),w(!1),C(null)}catch(Y){if(K!==_.current)return;const L=Y instanceof Error?Y.message:String(Y);console.warn("[MarkdownImage] failed to load local image",l,Y),M(L)}})()},[c,l,S]),k.useEffect(()=>{if(c)return;const R=sc.get(l);if(R!==void 0){w(!0),C(R),x(!1);return}h(l),x(!!Lo.get(l)),w(!1),C(null)},[l,c,S]),y?i.jsxs("button",{type:"button",onClick:P,title:T??"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:[i.jsxs("svg",{className:"w-4 h-4 shrink-0",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:1.5,children:[i.jsx("rect",{x:"3",y:"3",width:"18",height:"18",rx:"2",ry:"2"}),i.jsx("circle",{cx:"8.5",cy:"8.5",r:"1.5"}),i.jsx("polyline",{points:"21 15 16 10 5 21"})]}),i.jsxs("span",{className:"truncate",children:["Failed to load image — click to retry",T?` (${T})`:""]})]}):i.jsxs("span",{className:"inline-block align-middle max-w-full",children:[!g&&i.jsx("span",{className:"block w-full min-h-[80px] max-w-[400px] bg-surface-elevated rounded-lg animate-pulse"}),p?i.jsx("img",{src:p,alt:n??"",onLoad:()=>{c||Lo.set(l,l),x(!0)},onError:()=>{M("Image decode failed")},onClick:()=>a?.(p),className:`max-w-full h-auto rounded-lg cursor-pointer hover:opacity-90 transition-opacity my-1${g?"":" absolute opacity-0 pointer-events-none"}`,style:{maxHeight:"400px",objectFit:"contain"}}):null]})});async function Fw(e){const t=await fetch(e);if(!t.ok)throw new Error(`Failed to fetch image (${t.status})`);return t.blob()}async function rae(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 a=n.getContext("2d");if(!a)throw new Error("Canvas unavailable");return a.drawImage(t,0,0),t.close(),new Promise((s,l)=>{n.toBlob(c=>c?s(c):l(new Error("PNG encode failed")),"image/png")})}function iae(e,t){try{const s=(e.startsWith("data:")?"":new URL(e,window.location.href).pathname).split("/").pop()||"";if(s&&/\.(png|jpe?g|gif|webp|svg|bmp)$/i.test(s))return decodeURIComponent(s)}catch{}return`image.${(t.type.split("/")[1]||"png").replace("jpeg","jpg")}`}function IS({src:e,onClose:t}){const{t:n}=ot("common"),[a,s]=k.useState(null),[l,c]=k.useState(null);Qo(!0),k.useEffect(()=>{const g=x=>{x.key==="Escape"&&t()};return document.addEventListener("keydown",g),()=>document.removeEventListener("keydown",g)},[t]);const d=k.useCallback(g=>{s(g),window.setTimeout(()=>s(null),1600)},[]),m=k.useCallback(async g=>{if(g.stopPropagation(),!l){c("copy");try{const x=await Fw(e),y=await rae(x);await navigator.clipboard.write([new ClipboardItem({"image/png":y})]),d(n("imageCopied"))}catch{d(n("imageCopyFailed"))}finally{c(null)}}},[l,d,e,n]),p=k.useCallback(async g=>{if(g.stopPropagation(),!l){c("download");try{const x=await Fw(e),y=URL.createObjectURL(x),w=document.createElement("a");w.href=y,w.download=iae(e,x),document.body.appendChild(w),w.click(),w.remove(),URL.revokeObjectURL(y),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 zr.createPortal(i.jsxs("div",{className:"fixed inset-0 z-[9999] bg-black/80 flex items-center justify-center p-4",onClick:t,children:[i.jsxs("div",{className:"absolute top-4 right-4 z-10 flex items-center gap-2",onClick:g=>g.stopPropagation(),children:[i.jsxs("button",{type:"button",className:h,onClick:m,disabled:!!l,title:n("copyImage"),children:[i.jsxs("svg",{className:"w-4 h-4",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[i.jsx("rect",{x:"9",y:"9",width:"13",height:"13",rx:"2"}),i.jsx("path",{d:"M5 15H4a2 2 0 01-2-2V4a2 2 0 012-2h9a2 2 0 012 2v1"})]}),n("copy")]}),i.jsxs("button",{type:"button",className:h,onClick:p,disabled:!!l,title:n("downloadImage"),children:[i.jsxs("svg",{className:"w-4 h-4",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[i.jsx("path",{d:"M21 15v4a2 2 0 01-2 2H5a2 2 0 01-2-2v-4"}),i.jsx("polyline",{points:"7 10 12 15 17 10"}),i.jsx("line",{x1:"12",y1:"15",x2:"12",y2:"3"})]}),n("downloadImage")]}),i.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:i.jsxs("svg",{className:"w-6 h-6 text-white",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2,children:[i.jsx("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),i.jsx("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]})})]}),a&&i.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:a}),i.jsx("img",{src:e,alt:"Preview",className:"max-w-full max-h-[90vh] object-contain rounded-lg",onClick:g=>g.stopPropagation()})]}),document.body)}function OS(e={}){const{onMentionClick:t,basePath:n,onImagePreview:a,contentRef:s,hostAvailable:l,openRightPanel:c}=e,d=k.useCallback((m,p)=>{const h=Rw(p,n);if(h.kind!=="passthrough"){if(m.preventDefault(),m.stopPropagation(),h.kind==="fragment"){Vte(s?.current??null,h.id);return}if(h.kind==="file"){l&&c?c({kind:"file",path:h.path,title:h.path.split(/[/\\]/).pop()}):Ae.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}fi(h.url)}}},[n,s,l,c]);return k.useMemo(()=>({...Xne,img:({src:m,alt:p})=>i.jsx(aae,{src:m??"",alt:p,onPreview:a,basePath:n},m??""),p:({children:m,node:p})=>{const h=Qne(p);return h?i.jsx(lne,{id:h.id,type:h.type,label:h.label}):i.jsx("p",{className:"mb-2 last:mb-0 leading-relaxed text-fg-secondary",children:m})},a:({href:m,children:p})=>{if(m?.startsWith(qw)){const g=decodeURIComponent(m.slice(qw.length));return i.jsx("span",{className:`text-brand-500 font-medium${t?" cursor-pointer hover:underline":""}`,onClick:t?x=>{x.preventDefault(),x.stopPropagation(),t(g,x)}:void 0,title:g,children:p})}if(m?.startsWith(Mm))return i.jsx(gc,{id:m.slice(Mm.length)});{const g=m?.match(LS);if(g){const[,x,y]=g;if(x==="workflow")return i.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(),at.navigate(de.WORK,{boardType:"workflows"})},title:`workflow: ${y}`,children:[i.jsx("span",{className:"text-[10px]",children:"⚙️"}),i.jsx("span",{children:p})]});const w=TS(x);if(w)return i.jsx(gc,{id:y,type:w,label:p})}}if(m&&Em(m))return i.jsx(gc,{id:m.trim(),label:p});const h=Rw(m,n);return h.kind==="fragment"||h.kind==="file"||h.kind==="external"?i.jsx("a",{href:m,className:mg,onClick:g=>d(g,m),title:h.kind==="fragment"?`#${h.id}`:h.kind==="file"?h.path:h.url,children:p}):i.jsx("a",{href:m,className:mg,onClick:g=>{Go()&&m&&!/^[a-zA-Z][a-zA-Z0-9+.-]*:/.test(m)&&g.preventDefault()},children:p})}}),[t,n,a,d])}const Uw=[D5,I3,O3],Gw=[SS,[G3,{strict:"ignore"}],[cS,{detect:!0,ignoreMissing:!0}]];function fg(e){if(/^(deliverable|task|requirement|project|agent|team|workflow):/i.test(e))return e;const n=pb(e);return vS(n)?n:o5(e)}const sae=/(?:<thinking>| thinking)([\s\S]*?)<\/thinking>/g;function oae(e){const t=[];let n=e.replace(sae,(a,s)=>{const l=s.trim();return l&&t.push(l),""});return n=n.replace(/<thinking>/gi,"").replace(/<\/thinking>/gi,""),{thinking:t,rest:n.trim()}}function lae(e=640){const[t,n]=k.useState(()=>window.innerWidth<e);return k.useEffect(()=>{const a=window.matchMedia(`(max-width: ${e-1}px)`),s=l=>n(l.matches);return a.addEventListener("change",s),n(a.matches),()=>a.removeEventListener("change",s)},[e]),t}function cae({content:e,contentRef:t}){const{t:n}=ot("common"),[a,s]=k.useState(!1),[l,c]=k.useState(!1),[d,m]=k.useState(!1),[p,h]=k.useState(null),g=k.useRef(null),x=lae();k.useEffect(()=>{if(!a)return;const C=S=>{g.current&&!g.current.contains(S.target)&&(s(!1),c(!1),m(!1))};return document.addEventListener("mousedown",C),()=>document.removeEventListener("mousedown",C)},[a]);const y=k.useCallback(C=>{h(C),setTimeout(()=>h(null),1500)},[]),w=async()=>{const C=await hb(e);y(n(C?"markdown.copied":"markdown.failed")),s(!1)},T=async C=>{const S=t.current?.firstElementChild;if(!S)return;const E=AS(),_=Xte(E),M=await Yte(S,C,e,{fontFamily:_.fontFamily,fontSize:_.fontSize,headingScales:_.headingScales}),P=n(C==="light"?"markdown.themeLight":"markdown.themeDark");y(M.ok?M.method==="html"?n("markdown.htmlCopied",{theme:P}):n("markdown.textCopied"):n("markdown.failed")),s(!1)};return i.jsxs("div",{className:"absolute top-1 right-1 z-10 opacity-0 group-hover/md:opacity-100 transition-opacity",ref:g,children:[p&&i.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:p}),i.jsx("button",{onClick:()=>s(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:i.jsx("svg",{className:"w-3.5 h-3.5",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:i.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"})})}),a&&i.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?i.jsx(Jte,{onClose:()=>m(!1)}):l?i.jsxs("div",{className:"px-3 py-2 text-[11px] text-fg-secondary space-y-2 max-w-[260px]",children:[i.jsxs("div",{className:"flex items-center justify-between mb-1",children:[i.jsx("span",{className:"font-medium text-fg-primary text-xs",children:n("markdown.infoTitle")}),i.jsx("button",{onClick:()=>c(!1),className:"text-fg-tertiary hover:text-fg-primary p-0.5",children:i.jsx("svg",{className:"w-3 h-3",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:i.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M6 18L18 6M6 6l12 12"})})})]}),i.jsxs("div",{children:[i.jsx("span",{className:"font-medium text-fg-primary",children:n("markdown.mdAbbrev")})," — ",n("markdown.infoMdDesc")]}),i.jsxs("div",{children:[i.jsx("span",{className:"font-medium text-fg-primary",children:"☀️"})," — ",n("markdown.infoHtmlLightDesc")]}),i.jsxs("div",{children:[i.jsx("span",{className:"font-medium text-fg-primary",children:"🌙"})," — ",n("markdown.infoHtmlDarkDesc")]})]}):i.jsxs(i.Fragment,{children:[i.jsxs("div",{className:"flex items-center justify-between px-3 py-1 border-b border-border-subtle mb-1",children:[i.jsx("span",{className:"text-[10px] text-fg-tertiary font-medium",children:n("markdown.copyContent")}),i.jsxs("div",{className:"flex items-center gap-1",children:[i.jsx("button",{onClick:()=>m(!0),className:"p-0.5 rounded text-fg-tertiary hover:text-fg-primary transition-colors",title:n("markdown.typographySettings"),children:i.jsxs("svg",{className:"w-3.5 h-3.5",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:[i.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"}),i.jsx("circle",{cx:"12",cy:"12",r:"3"})]})}),i.jsx("button",{onClick:()=>c(!0),className:"p-0.5 rounded text-fg-tertiary hover:text-fg-primary transition-colors",title:n("markdown.infoTitle"),children:i.jsxs("svg",{className:"w-3.5 h-3.5",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:[i.jsx("circle",{cx:"12",cy:"12",r:"10"}),i.jsx("path",{strokeLinecap:"round",d:"M12 16v-4m0-4h.01"})]})})]})]}),i.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:[i.jsx("span",{className:"w-4 text-center text-fg-tertiary shrink-0 font-mono text-[10px]",children:n("markdown.mdAbbrev")}),n(x?"markdown.copyMdSourceShort":"markdown.copyMdSource")]}),i.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:[i.jsx("span",{className:"w-4 text-center shrink-0 text-[10px]",children:"☀️"}),n(x?"markdown.copyHtmlLightShort":"markdown.copyHtmlLight")]}),i.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:[i.jsx("span",{className:"w-4 text-center shrink-0 text-[10px]",children:"🌙"}),n(x?"markdown.copyHtmlDarkShort":"markdown.copyHtmlDark")]})]})})]})}const Ea=k.memo(function({content:t,className:n="",onMentionClick:a,knownNames:s,basePath:l}){const{thinking:c,rest:d}=oae(t),m=k.useRef(null),[p,h]=k.useState(null),g=qc(),x=k.useCallback(T=>{let C=ui(T,mS);return C=ui(C,Mte),C=ui(C,Ute),C=ui(C,Lte),C=ui(C,Ite),C=ui(C,S=>_te(S,s)),C=ui(C,hS),C},[s]),y=k.useMemo(()=>x(d),[d,x]),w=OS({onMentionClick:a,basePath:l,onImagePreview:h,contentRef:m,hostAvailable:g?.hostAvailable,openRightPanel:g?.openRightPanel});return i.jsxs("div",{className:"relative group/md",children:[i.jsx(cae,{content:t,contentRef:m}),i.jsx("div",{ref:m,children:i.jsx(Zte,{resetKeys:[y],fallback:i.jsx("div",{className:`prose prose-sm max-w-none break-words whitespace-pre-wrap pr-8 text-fg-secondary ${n}`,children:d}),children:i.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(`
855
855
 
856
856
  `),C=T.split(`
857
857
  `)[0]??"",S=C.length>80?C.slice(0,80)+"…":C;return i.jsxs("details",{className:"mb-3 rounded-lg bg-surface-elevated/60 border border-border-default/50 overflow-hidden group/think",children:[i.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:[i.jsx("svg",{className:"w-3 h-3 shrink-0 transition-transform group-open/think:rotate-90",viewBox:"0 0 20 20",fill:"currentColor",children:i.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"})}),i.jsx("span",{className:"shrink-0",children:"Thinking"}),i.jsx("span",{className:"truncate text-fg-tertiary ml-1 group-open/think:hidden",children:S})]}),i.jsx("div",{className:"px-3 pb-3 border-t border-border-default/50",children:i.jsx("div",{className:"mt-2 pl-3 border-l-2 border-brand-500/40 text-xs text-fg-secondary leading-relaxed",children:i.jsx(qh,{remarkPlugins:Uw,rehypePlugins:Gw,components:w,urlTransform:fg,children:x(T)})})})]})})(),i.jsx(qh,{remarkPlugins:Uw,rehypePlugins:Gw,components:w,urlTransform:fg,children:y})]})})}),p&&i.jsx(IS,{src:p,onClose:()=>h(null)})]})},(e,t)=>e.content===t.content&&e.className===t.className&&e.basePath===t.basePath&&e.onMentionClick===t.onMentionClick&&uae(e.knownNames,t.knownNames));function uae(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 PS=Object.freeze(Object.defineProperty({__proto__:null,ImagePreviewModal:IS,MarkdownMessage:Ea,chatUrlTransform:fg},Symbol.toStringTag,{value:"Module"})),hg={suppressAdjustUntil:0};function Dc(e=2500){const t=typeof performance<"u"?performance.now():Date.now();hg.suppressAdjustUntil=Math.max(hg.suppressAdjustUntil,t+e)}function Qie(){return(typeof performance<"u"?performance.now():Date.now())<hg.suppressAdjustUntil}const Kw={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:"🔍"}},Vw={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 zs(e){const t=e.includes("__")?e.split("__").pop():e,n=Kw[t]??Kw[e],a=Vw[t]??Vw[e]??"settings";return n?{...n,iconName:a,key:t}:{label:t.replace(/_/g," ").replace(/\b\w/g,s=>s.toUpperCase()),icon:"⚙",iconName:a,key:t}}function $s(e){return e==null?"":e<1e3?`${e}ms`:`${(e/1e3).toFixed(1)}s`}function dae(e){const t=new Date(e);if(isNaN(t.getTime()))return e;const n=String(t.getMonth()+1).padStart(2,"0"),a=String(t.getDate()).padStart(2,"0"),s=String(t.getHours()).padStart(2,"0"),l=String(t.getMinutes()).padStart(2,"0"),c=String(t.getSeconds()).padStart(2,"0");return`${n}-${a} ${s}:${l}:${c}`}function gg(e,t){return e.length<=t?e:e.slice(0,t)+"…"}function Ww(e){try{const t=JSON.parse(e);return JSON.stringify(t,null,2)}catch{return e}}function zS(e){return!e||typeof e!="object"?[]:Object.entries(e).filter(([,n])=>n!=null).map(([n,a])=>({key:n,value:typeof a=="string"?a:JSON.stringify(a,null,2)}))}function mae(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 Xie(e,t){const n=new Map;let a=null;for(const s of e)if(s.type==="tool_start"&&(s.content==="spawn_subagent"||s.content==="spawn_subagents"))a=s.seq,n.set(s.seq,[]);else if(s.type==="tool_end"&&(s.content==="spawn_subagent"||s.content==="spawn_subagents")){if(a!==null){const l=n.get(a);l&&n.set(s.seq,l)}a=null}else if(a!==null&&s.type.startsWith("subagent_")){const l=s.type.replace("subagent_",""),c=s.metadata;n.get(a)?.push({eventType:l,content:s.content,metadata:c})}return t.map(s=>{if(s.type!=="tool")return s;const l=s.key;if(!l)return s;const c=l.replace(/^(?:t[se]_|e[se]_)/,""),d=parseInt(c,10);if(isNaN(d))return s;const m=n.get(d);return!m||m.length===0?s:{...s,info:{...s.info,subagentLogs:m}}})}function bg(e){const t=new Set;for(let n=0;n<e.length;n++){const a=e[n];if(a.type==="tool"&&(a.info.status==="done"||a.info.status==="error"))for(let s=n-1;s>=0;s--){const l=e[s];if(l.type==="tool"&&l.info.status==="running"&&l.info.tool===a.info.tool&&!t.has(s)){t.add(s);break}}}return e.filter((n,a)=>!t.has(a))}function gb(e){const t=dae(e.createdAt),n=e.createdAt,a=e.metadata;switch(e.type){case"text":return a?.isThinking?{type:"thinking",content:e.content,time:t,timestamp:n}:{type:"text",content:e.content,time:t,timestamp:n};case"status":{const s=a?.action;return s&&["chat","chat_stream","task_execution","respond_in_session"].includes(s)?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:a?.arguments,subagentLogs:a?.subagentLogs}};case"tool_end":return{type:"tool",time:t,timestamp:n,key:`ee_${e.seq}`,info:{tool:e.content,status:a?.success===!1?"error":"done",args:a?.arguments,result:a?.result,error:a?.error,durationMs:a?.durationMs,subagentLogs:a?.subagentLogs}};default:return null}}function BS(e,t){if(e!=="task_create"&&e!=="create_task"||!t)return null;try{const n=JSON.parse(t);if(!n.task)return null;const a=n.task;return{taskId:a.id,title:a.title,description:a.description,assignedAgentId:a.assignedAgentId,priority:a.priority}}catch{return null}}function HS(e,t){if(e!=="requirement_propose"||!t)return null;try{const n=JSON.parse(t);if(n.status!=="success"||!n.requirement)return null;const a=n.requirement;return a.status!=="pending"?null:{requirementId:a.id,title:a.title,description:a.description,priority:a.priority}}catch{return null}}const $S={code:i.jsxs(i.Fragment,{children:[i.jsx("polyline",{points:"16 18 22 12 16 6"}),i.jsx("polyline",{points:"8 6 2 12 8 18"})]}),search:i.jsxs(i.Fragment,{children:[i.jsx("circle",{cx:"11",cy:"11",r:"8"}),i.jsx("path",{d:"m21 21-4.3-4.3"})]}),clipboard:i.jsxs(i.Fragment,{children:[i.jsx("rect",{width:"8",height:"4",x:"8",y:"2",rx:"1",ry:"1"}),i.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":i.jsxs(i.Fragment,{children:[i.jsx("circle",{cx:"12",cy:"12",r:"10"}),i.jsx("path",{d:"m9 12 2 2 4-4"})]}),server:i.jsxs(i.Fragment,{children:[i.jsx("rect",{width:"20",height:"8",x:"2",y:"2",rx:"2",ry:"2"}),i.jsx("rect",{width:"20",height:"8",x:"2",y:"14",rx:"2",ry:"2"}),i.jsx("line",{x1:"6",x2:"6.01",y1:"6",y2:"6"}),i.jsx("line",{x1:"6",x2:"6.01",y1:"18",y2:"18"})]}),"file-text":i.jsxs(i.Fragment,{children:[i.jsx("path",{d:"M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7Z"}),i.jsx("path",{d:"M14 2v4a2 2 0 0 0 2 2h4"}),i.jsx("path",{d:"M10 9H8"}),i.jsx("path",{d:"M16 13H8"}),i.jsx("path",{d:"M16 17H8"})]}),"book-open":i.jsxs(i.Fragment,{children:[i.jsx("path",{d:"M12 7v14"}),i.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:i.jsxs(i.Fragment,{children:[i.jsx("path",{d:"M16 21v-2a4 4 0 0 0-4-4H6a4 4 0 0 0-4 4v2"}),i.jsx("circle",{cx:"9",cy:"7",r:"4"}),i.jsx("path",{d:"M22 21v-2a4 4 0 0 0-3-3.87"}),i.jsx("path",{d:"M16 3.13a4 4 0 0 1 0 7.75"})]}),"dollar-sign":i.jsxs(i.Fragment,{children:[i.jsx("line",{x1:"12",x2:"12",y1:"2",y2:"22"}),i.jsx("path",{d:"M17 5H9.5a3.5 3.5 0 0 0 0 7h5a3.5 3.5 0 0 1 0 7H6"})]}),megaphone:i.jsxs(i.Fragment,{children:[i.jsx("path",{d:"m3 11 18-5v12L3 14v-3z"}),i.jsx("path",{d:"M11.6 16.8a3 3 0 1 1-5.8-1.6"})]}),edit:i.jsxs(i.Fragment,{children:[i.jsx("path",{d:"M12 20h9"}),i.jsx("path",{d:"M16.5 3.5a2.121 2.121 0 0 1 3 3L7 19l-4 1 1-4Z"})]}),headphones:i.jsx(i.Fragment,{children:i.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:i.jsxs(i.Fragment,{children:[i.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"}),i.jsx("circle",{cx:"12",cy:"12",r:"3"})]}),target:i.jsxs(i.Fragment,{children:[i.jsx("circle",{cx:"12",cy:"12",r:"10"}),i.jsx("circle",{cx:"12",cy:"12",r:"6"}),i.jsx("circle",{cx:"12",cy:"12",r:"2"})]}),zap:i.jsx(i.Fragment,{children:i.jsx("polygon",{points:"13 2 3 14 12 14 11 22 21 10 12 10 13 2"})}),terminal:i.jsxs(i.Fragment,{children:[i.jsx("polyline",{points:"4 17 10 11 4 5"}),i.jsx("line",{x1:"12",x2:"20",y1:"19",y2:"19"})]}),sparkles:i.jsxs(i.Fragment,{children:[i.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"}),i.jsx("path",{d:"M20 3v4"}),i.jsx("path",{d:"M22 5h-4"})]}),wrench:i.jsx(i.Fragment,{children:i.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:i.jsxs(i.Fragment,{children:[i.jsx("circle",{cx:"12",cy:"12",r:"10"}),i.jsx("path",{d:"M12 2a14.5 14.5 0 0 0 0 20 14.5 14.5 0 0 0 0-20"}),i.jsx("path",{d:"M2 12h20"})]}),link:i.jsxs(i.Fragment,{children:[i.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"}),i.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:i.jsxs(i.Fragment,{children:[i.jsx("path",{d:"M12 8V4H8"}),i.jsx("rect",{width:"16",height:"12",x:"4",y:"8",rx:"2"}),i.jsx("path",{d:"M2 14h2"}),i.jsx("path",{d:"M20 14h2"}),i.jsx("path",{d:"M15 13v2"}),i.jsx("path",{d:"M9 13v2"})]}),"message-square":i.jsx(i.Fragment,{children:i.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:i.jsxs(i.Fragment,{children:[i.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"}),i.jsx("path",{d:"M18 14h-8"}),i.jsx("path",{d:"M15 18h-5"}),i.jsx("path",{d:"M10 6h8v4h-8V6Z"})]}),layers:i.jsxs(i.Fragment,{children:[i.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"}),i.jsx("path",{d:"m22 17.65-9.17 4.16a2 2 0 0 1-1.66 0L2 17.65"}),i.jsx("path",{d:"m22 12.65-9.17 4.16a2 2 0 0 1-1.66 0L2 12.65"})]}),"bar-chart":i.jsxs(i.Fragment,{children:[i.jsx("line",{x1:"12",x2:"12",y1:"20",y2:"10"}),i.jsx("line",{x1:"18",x2:"18",y1:"20",y2:"4"}),i.jsx("line",{x1:"6",x2:"6",y1:"20",y2:"16"})]}),folder:i.jsx(i.Fragment,{children:i.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":i.jsxs(i.Fragment,{children:[i.jsx("line",{x1:"6",x2:"6",y1:"3",y2:"15"}),i.jsx("circle",{cx:"18",cy:"6",r:"3"}),i.jsx("circle",{cx:"6",cy:"18",r:"3"}),i.jsx("path",{d:"M18 9a9 9 0 0 1-9 9"})]}),save:i.jsxs(i.Fragment,{children:[i.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"}),i.jsx("path",{d:"M17 21v-7a1 1 0 0 0-1-1H8a1 1 0 0 0-1 1v7"}),i.jsx("path",{d:"M7 3v4a1 1 0 0 0 1 1h7"})]}),camera:i.jsxs(i.Fragment,{children:[i.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"}),i.jsx("circle",{cx:"12",cy:"13",r:"3"})]}),clock:i.jsxs(i.Fragment,{children:[i.jsx("circle",{cx:"12",cy:"12",r:"10"}),i.jsx("polyline",{points:"12 6 12 12 16 14"})]}),database:i.jsxs(i.Fragment,{children:[i.jsx("ellipse",{cx:"12",cy:"5",rx:"9",ry:"3"}),i.jsx("path",{d:"M3 5v14a9 3 0 0 0 18 0V5"}),i.jsx("path",{d:"M3 12a9 3 0 0 0 18 0"})]}),lightbulb:i.jsxs(i.Fragment,{children:[i.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"}),i.jsx("path",{d:"M9 18h6"}),i.jsx("path",{d:"M10 22h4"})]}),"alert-circle":i.jsxs(i.Fragment,{children:[i.jsx("circle",{cx:"12",cy:"12",r:"10"}),i.jsx("line",{x1:"12",x2:"12",y1:"8",y2:"12"}),i.jsx("line",{x1:"12",x2:"12.01",y1:"16",y2:"16"})]}),"square-terminal":i.jsxs(i.Fragment,{children:[i.jsx("path",{d:"m7 11 2-2-2-2"}),i.jsx("path",{d:"M11 13h4"}),i.jsx("rect",{width:"18",height:"18",x:"3",y:"3",rx:"2"})]}),package:i.jsxs(i.Fragment,{children:[i.jsx("path",{d:"m7.5 4.27 9 5.15"}),i.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"}),i.jsx("path",{d:"m3.3 7 8.7 5 8.7-5"}),i.jsx("path",{d:"M12 22V12"})]})};function pae(e){return!!e&&e in $S}function rl({name:e,size:t=24,className:n=""}){const a=$S[e];return a?i.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:a}):null}const Yw={"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"},Qw={development:"code",开发工具:"code",devops:"server",data:"bar-chart",数据分析:"bar-chart",productivity:"zap",效率提升:"zap",communication:"message-square",通讯协作:"message-square",browser:"globe",内容创作:"edit","AI 智能":"sparkles"};function tm(e,t){const n=(e||"").toLowerCase();return Yw[n]?Yw[n]:t&&Qw[t]?Qw[t]:"layers"}function fae(e){const t=[];for(const n of e)if(n.phase!=="output"){if(n.phase==="start"){const a=`${n.tool}_${n.ts}`;t.push({key:a,tool:n.tool,status:"running"})}else for(let a=t.length-1;a>=0;a--)if(t[a].tool===n.tool&&t[a].status==="running"){t[a]={...t[a],status:n.success===!1?"error":"done"};break}}return t}function qS(){return i.jsxs("svg",{className:"w-3 h-3 animate-spin text-brand-500 shrink-0",viewBox:"0 0 24 24",fill:"none",children:[i.jsx("circle",{className:"opacity-25",cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"4"}),i.jsx("path",{className:"opacity-75",fill:"currentColor",d:"M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4z"})]})}function hae(){return i.jsx("span",{className:"flex items-center gap-0.5",children:[0,150,300].map(e=>i.jsx("span",{className:"w-1 h-1 rounded-full bg-brand-400 animate-bounce",style:{animationDelay:`${e}ms`,animationDuration:"1s"}},e))})}function Xw({item:e}){const{t}=ot("common"),n=zs(e.tool);return i.jsxs("div",{className:"flex items-center gap-1.5 py-0.5",children:[i.jsx(rl,{name:n.iconName,size:15,className:`shrink-0 ${e.status==="running"?"text-brand-500":e.status==="error"?"text-red-500":"text-green-500"}`}),i.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"&&i.jsx(qS,{})]})}function Jw({activities:e,isActive:t,persistent:n}){const{t:a}=ot("common"),s=fae(e),[l,c]=k.useState(!1),d=s.length>0,m=d&&s.every(w=>w.status!=="running");if(n&&m){const w=s.filter(C=>C.status==="error").length,T=s.filter(C=>C.status==="done").length;return i.jsxs("div",{className:"mb-3 border-b border-border-default/50 pb-2",children:[i.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:[i.jsx("span",{className:`transition-transform duration-150 ${l?"rotate-90":""}`,children:"▶"}),i.jsx("span",{className:"font-medium",children:a("activity.step",{count:T})}),w>0&&i.jsxs("span",{className:"text-red-500 ml-0.5",children:["· ",a("activity.failed",{count:w})]}),!l&&i.jsxs("span",{className:"ml-1 flex items-center gap-1",children:[s.slice(0,5).map(C=>{const S=zs(C.tool);return i.jsx(rl,{name:S.iconName,size:13,className:`shrink-0 ${C.status==="error"?"text-red-500":"text-green-500"}`},C.key)}),s.length>5&&i.jsxs("span",{className:"text-[10px] text-fg-tertiary",children:["+",s.length-5]})]})]}),l&&i.jsx("div",{className:"mt-2 space-y-0.5",children:s.map((C,S)=>i.jsx(Xw,{item:C,idx:S,total:s.length},C.key))})]})}if(!d)return i.jsxs("div",{className:"flex items-center gap-1.5 text-xs py-0.5",children:[i.jsx("span",{className:"mr-0.5 activity-text-shimmer",children:a("activity.thinking")}),i.jsx(hae,{})]});const p=s.filter(w=>w.status==="error").length;let h=null;for(let w=s.length-1;w>=0;w--)if(s[w].status==="running"){h=s[w];break}const g=s[s.length-1];let x;if(h){const w=zs(h.tool);x=`${a(`execution.tools.${w.key}`,{defaultValue:w.label})}…`}else if(t&&m)x=a("activity.writingResponse");else{const w=zs(g.tool);x=a(`execution.tools.${w.key}`,{defaultValue:w.label})}const y=!!h||t&&m;return i.jsxs("div",{className:"mb-1",children:[i.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:[i.jsx("span",{className:`shrink-0 transition-transform duration-150 ${l?"rotate-90":""}`,children:"▶"}),i.jsx("span",{className:`truncate font-medium ${y?"activity-text-shimmer":"text-fg-secondary"}`,children:x}),i.jsxs("span",{className:"shrink-0",children:["· ",a("activity.step",{count:s.length})]}),p>0&&i.jsxs("span",{className:"text-red-500 shrink-0",children:["· ",a("activity.failed",{count:p})]}),y&&i.jsx(qS,{})]}),l&&i.jsx("div",{className:"mt-1 space-y-0.5",children:s.map((w,T)=>i.jsx(Xw,{item:w,idx:T,total:s.length},w.key))})]})}const gae={"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"}},Uo=["created","context_injected","running"],bae=new Set(["completed","failed","cancelled","timeout"]),Zw={created:"Created",context_injected:"Context injected",running:"Running",completed:"Completed",failed:"Failed",cancelled:"Cancelled",timeout:"Timed out"};function yae(e){return gae[e]??{label:e.replace(/-/g," ").replace(/\b\w/g,t=>t.toUpperCase()),icon:"⚙",badgeClass:"bg-surface-elevated text-fg-tertiary"}}function xae(e,t){if(e.cost?.durationMs!=null)return e.cost.durationMs;const n=e.startedAt??e.createdAt,a=new Date(n).getTime();if(!Number.isNaN(a)){if(e.completedAt){const s=new Date(e.completedAt).getTime();return Number.isNaN(s)?void 0:Math.max(0,s-a)}if(e.status==="running"||e.status==="context_injected")return Math.max(0,t-a)}}function vae(e){if(e==="completed"||bae.has(e))return Uo.length;const t=Uo.indexOf(e);return t>=0?t:0}function wae({session:e,className:t}){const n=yae(e.tool),[a,s]=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,p=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(()=>xae(e,l),[e,l]),g=vae(e.status),x=e.result?.rawOutput??(p||m?e.result?.summary:void 0),y=d?"border-brand-500/40 bg-brand-500/5":m?"border-red-500/30 bg-red-500/5":p?"border-green-500/30 bg-green-500/5":"border-border-default bg-surface-secondary/30";return i.jsxs("div",{className:`my-2 rounded-lg border ${y} p-3 max-w-2xl transition-colors ${t??""}`,children:[i.jsxs("div",{className:"flex items-start gap-2",children:[i.jsx("span",{className:"text-sm mt-0.5",children:n.icon}),i.jsxs("div",{className:"flex-1 min-w-0",children:[i.jsxs("div",{className:"flex items-center gap-1.5 flex-wrap",children:[i.jsx("span",{className:`text-[10px] px-1.5 py-0.5 rounded font-medium ${n.badgeClass}`,children:n.label}),i.jsx("span",{className:`text-[10px] font-medium ${d?"text-brand-500":m?"text-red-500":p?"text-green-500":"text-fg-tertiary"}`,children:Zw[e.status]??e.status}),h!=null&&i.jsx("span",{className:"text-[10px] text-fg-tertiary tabular-nums",children:$s(h)}),e.cost?.estimatedCostUsd!=null&&i.jsxs("span",{className:"text-[10px] text-fg-tertiary tabular-nums",children:["$",e.cost.estimatedCostUsd.toFixed(4)]})]}),i.jsx("div",{className:"text-xs text-fg-secondary mt-1 line-clamp-2",children:e.prompt})]}),d&&i.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:[i.jsx("circle",{className:"opacity-25",cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"4"}),i.jsx("path",{className:"opacity-75",fill:"currentColor",d:"M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4z"})]})]}),i.jsxs("div",{className:"flex items-center gap-1 mt-3 ml-6",children:[Uo.map((w,T)=>{const C=g>T||g===T&&!d&&p,S=g===T&&d,E=m&&T===Uo.length-1&&e.status!=="completed";return i.jsxs("div",{className:"flex items-center gap-1 flex-1 min-w-0",children:[i.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:Zw[w]}),T<Uo.length-1&&i.jsx("div",{className:`h-px flex-1 ${C?"bg-green-500/50":"bg-border-default/60"}`})]},w)}),i.jsx("div",{className:`w-2 h-2 rounded-full shrink-0 ${m?"bg-red-500":p?"bg-green-500":"bg-gray-600"}`,title:m?"Failed":"Done"})]}),(e.progressMessage||e.progressPercent!=null)&&d&&i.jsxs("div",{className:"mt-2 ml-6 space-y-1",children:[e.progressPercent!=null&&i.jsx("div",{className:"h-1 bg-surface-elevated rounded-full overflow-hidden",children:i.jsx("div",{className:"h-full bg-brand-500 transition-all duration-300",style:{width:`${Math.min(100,Math.max(0,e.progressPercent))}%`}})}),e.progressMessage&&i.jsx("div",{className:"text-[11px] text-fg-tertiary font-mono truncate",children:e.progressMessage})]}),e.result&&!d&&i.jsxs("div",{className:"mt-2 ml-6 space-y-1.5",children:[e.result.summary&&i.jsx("div",{className:"text-xs text-fg-secondary",children:e.result.summary}),e.result.diffStats&&i.jsxs("div",{className:"flex items-center gap-3 text-[10px] font-mono",children:[i.jsxs("span",{className:"text-fg-tertiary",children:[e.result.diffStats.filesChanged," files"]}),i.jsxs("span",{className:"text-green-500",children:["+",e.result.diffStats.additions]}),i.jsxs("span",{className:"text-red-500",children:["−",e.result.diffStats.deletions]})]}),e.cost&&(e.cost.inputTokens!=null||e.cost.outputTokens!=null)&&i.jsxs("div",{className:"text-[10px] text-fg-tertiary",children:[e.cost.inputTokens!=null&&i.jsxs("span",{children:[e.cost.inputTokens.toLocaleString()," in"]}),e.cost.inputTokens!=null&&e.cost.outputTokens!=null&&i.jsx("span",{className:"mx-1",children:"·"}),e.cost.outputTokens!=null&&i.jsxs("span",{children:[e.cost.outputTokens.toLocaleString()," out"]})]})]}),x&&i.jsxs("div",{className:"mt-2 ml-6 border-t border-border-default/30 pt-2",children:[i.jsxs("button",{type:"button",onClick:()=>s(!a),className:"flex items-center gap-1.5 text-[10px] text-fg-tertiary hover:text-fg-secondary transition-colors",children:[i.jsx("svg",{className:`w-3 h-3 transition-transform ${a?"rotate-90":""}`,fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:i.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M9 5l7 7-7 7"})}),i.jsx("span",{className:"font-medium uppercase tracking-wider",children:"Raw output"})]}),a&&i.jsx("pre",{className:"mt-2 text-[11px] text-fg-tertiary bg-surface-elevated/70 rounded-lg px-3 py-2 overflow-x-auto max-h-48 overflow-y-auto whitespace-pre-wrap break-all font-mono",children:x})]})]})}function kae({label:e}){const{t}=ot("common");return i.jsxs("div",{className:"flex items-center gap-1.5 text-xs py-0.5",children:[i.jsx("span",{className:"activity-text-shimmer",children:e??t("execution.thinking")}),i.jsx("span",{className:"flex gap-0.5",children:[0,150,300].map(n=>i.jsx("span",{className:"w-1 h-1 rounded-full bg-brand-400 animate-bounce",style:{animationDelay:`${n}ms`,animationDuration:"1s"}},n))})]})}const ek=150;function Sae({content:e,className:t}){const[n,a]=k.useState(e),s=k.useRef(0),l=k.useRef(null);k.useEffect(()=>{const d=Date.now(),m=d-s.current;return m>=ek?(s.current=d,a(e)):l.current||(l.current=setTimeout(()=>{s.current=Date.now(),l.current=null,a(e)},ek-m)),()=>{l.current&&(clearTimeout(l.current),l.current=null)}},[e]);const c=k.useMemo(()=>n,[n]);return i.jsxs("div",{className:"bg-surface-elevated/50 rounded-lg px-3 py-2.5 my-1 min-w-0 overflow-hidden",children:[i.jsx(Ea,{content:c,className:t??"text-sm text-fg-secondary break-words"}),i.jsx("span",{className:"inline-block w-0.5 h-4 bg-brand-400 animate-pulse ml-0.5 align-middle"})]})}const _m=8e3,Dd=120;function mh({text:e,className:t}){const{t:n}=ot("common"),[a,s]=k.useState(!1),l=e.length>_m,c=!l||a?e:`${e.slice(0,_m)}
@@ -866,7 +866,7 @@ await import("${new URL("/assets/pdf.worker.min-CHFwMXne.mjs",import.meta.url).t
866
866
  `)}),c.toolCalls?.length)for(let m=0;m<c.toolCalls.length;m++){const p=c.toolCalls[m];d.push({type:"tool",key:`${p.tool}_${m}`,tool:p.tool,status:p.status==="error"?"error":"done",args:p.arguments,result:p.result,durationMs:p.durationMs})}d.length>0&&(d.push({type:"text",content:e.text}),l.segments=d)}return l}const Id=new Map,Fae=2e3;function fse(e,t,n){const a=new Date,s=new Date(a.getFullYear(),a.getMonth(),a.getDate()).getTime(),l=t?`${t}|${s}|${e}|${n?.yesterday??""}`:null;if(l){const h=Id.get(l);if(h!==void 0)return h}const c=t?new Date(t):a;if(isNaN(c.getTime()))return e;const d=c.getTime(),m=c.toLocaleTimeString(void 0,{hour:"2-digit",minute:"2-digit",second:"2-digit",hour12:!1});let p;return d>=s?p=m:d>=s-864e5?p=`${n?.yesterday??"Yesterday"} ${m}`:p=c.toLocaleDateString(void 0,{month:"short",day:"numeric"})+" "+m,l&&(Id.size>=Fae&&Id.clear(),Id.set(l,p)),p}function hse(e){if(!e)return"";const t=new Date(e);return isNaN(t.getTime())?"":`${t.getFullYear()}-${t.getMonth()+1}-${t.getDate()}`}function gse(e,t){const n=new Date(e);if(isNaN(n.getTime()))return"";const a=new Date,s=new Date(a.getFullYear(),a.getMonth(),a.getDate()).getTime(),l=n.getTime();return l>=s?t?.today??"Today":l>=s-864e5?t?.yesterday??"Yesterday":n.toLocaleDateString(void 0,{weekday:"long",year:"numeric",month:"long",day:"numeric"})}function bse(e,t){return(t?e.metaKey&&!e.ctrlKey:e.ctrlKey&&!e.metaKey)&&!e.altKey&&!e.shiftKey&&e.key.toLowerCase()==="n"?"new-conversation":e.ctrlKey&&!e.metaKey&&!e.altKey&&e.key==="Tab"?e.shiftKey?"cycle-session-prev":"cycle-session-next":null}function yse(e,t,n){if(e.length<=1)return null;const a=t===null?-1:e.indexOf(t),l=((a>=0?a:n===1?-1:0)+n+e.length)%e.length;return e[l]??null}function xse(e,t){let n=0,a=null;return((...s)=>{const l=Date.now(),c=t-(l-n);if(c<=0)return a&&(clearTimeout(a),a=null),n=l,e(...s);a||(a=setTimeout(()=>{n=Date.now(),a=null,e(...s)},c))})}const Uae=10,Gae=23,ik={expanded:24,compact:12};function vse(e){const t=e?ik.compact:ik.expanded;return Uae*Gae+t}function wse(e,t){return e||t}function kse(e){return e?"justify-end":""}function Sse(e,t,n){return e?t.includes(e)?"detail":n?"missing":"loading":"missing"}function Cse({priority:e}){const{t}=ot(["common","team"]),n=e==="high"||e==="critical",a=e&&e!=="normal"?` · ${t(`common:priority.${e}`,{defaultValue:e})}`:"";return i.jsxs("div",{className:`inline-flex items-center gap-1 mt-1.5 px-2 py-0.5 rounded-full text-[10px] font-medium ${n?"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:[i.jsxs("svg",{className:"w-3 h-3",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[i.jsx("path",{d:"M18 8A6 6 0 0 0 6 8c0 7-3 9-3 9h18s-3-2-3-9"}),i.jsx("path",{d:"M13.73 21a2 2 0 0 1-3.46 0"})]}),i.jsxs("span",{children:[t("team:notifications.badgeLabel"),a]})]})}function Ase({name:e,agentId:t,agents:n,onViewProfile:a}){const{t:s}=ot(["team","common"]),[l,c]=k.useState(!1),d=k.useRef(null),m=t?n.find(p=>p.id===t):n.find(p=>p.name===e);return k.useEffect(()=>{if(!l)return;const p=h=>{d.current&&!d.current.contains(h.target)&&c(!1)};return document.addEventListener("mousedown",p),()=>document.removeEventListener("mousedown",p)},[l]),m?i.jsxs("span",{ref:d,className:"relative inline-block",children:[i.jsx("button",{onClick:()=>c(!l),className:"text-fg-tertiary hover:text-brand-500 cursor-pointer transition-colors",children:e}),l&&i.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:[i.jsxs("div",{className:"flex items-center gap-2",children:[i.jsx(Zi,{name:m.name,avatarUrl:m.avatarUrl,size:28,bgClass:"bg-brand-500/15 text-brand-600"}),i.jsxs("div",{className:"flex-1 min-w-0",children:[i.jsx("div",{className:"text-xs text-fg-primary font-medium truncate",children:m.name}),i.jsxs("div",{className:"text-[10px] text-fg-tertiary",children:[m.role," · ",m.agentRole??s("page.workerRole")]})]}),i.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"}`})]}),i.jsx("button",{onClick:()=>{c(!1),a?.(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:s("page.viewProfileArrow")})]})]}):i.jsx("span",{children:e})}function Tse({agent:e,anchorRect:t,onClose:n,onViewProfile:a}){const{t:s}=ot(["common","team"]),l=k.useRef(null);k.useEffect(()=>{const p=h=>{l.current&&!l.current.contains(h.target)&&n()};return document.addEventListener("mousedown",p),()=>document.removeEventListener("mousedown",p)},[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"?s("common:status.online"):e.status==="working"?s("common:status.working"):e.status==="error"?s("common:status.error"):s("common:status.offline"),m=k.useCallback(p=>{if(!p)return;l.current=p;const h=p.getBoundingClientRect(),g=window.innerWidth,x=window.innerHeight,y=8;h.right>g-y&&(p.style.left=`${Math.max(y,g-h.width-y)}px`),h.left<y&&(p.style.left=`${y}px`),h.bottom>x-y&&(p.style.top=`${Math.max(y,x-h.height-y)}px`)},[]);return i.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:[i.jsxs("div",{className:"flex items-center gap-3",children:[i.jsx(Zi,{name:e.name,avatarUrl:e.avatarUrl,size:40,bgClass:"bg-brand-500/15 text-brand-600"}),i.jsxs("div",{className:"flex-1 min-w-0",children:[i.jsx("div",{className:"text-sm text-fg-primary font-medium truncate",children:e.name}),i.jsx("div",{className:"text-[11px] text-fg-tertiary",children:e.role}),i.jsxs("div",{className:"flex items-center gap-1.5 mt-0.5",children:[i.jsx("span",{className:`w-1.5 h-1.5 rounded-full ${c}`}),i.jsx("span",{className:"text-[10px] text-fg-secondary",children:d}),e.agentRole&&i.jsxs("span",{className:"text-[10px] text-fg-tertiary",children:["· ",e.agentRole]})]})]})]}),i.jsx("button",{onClick:()=>{n(),a(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:s("team:page.viewProfileArrow")})]})}function Kae(e){const t=String(e);return t.includes("MARKUS_UPSTREAM_ERROR")?!1:t.includes("CU_EXCEEDED")||t.includes("CU_MONTHLY_EXCEEDED")}const QS="markus:credit-notif-muted";let sk=0;function Nse(){try{if(localStorage.getItem(QS))return}catch{}const e=Date.now();e-sk<5*6e4||(sk=e,window.dispatchEvent(new CustomEvent("markus:credit-exhausted")))}function Vae(){try{localStorage.setItem(QS,"1")}catch{}}function Ese(e,t){const n=String(e);if(n.includes("AbortError")||n.includes("abort"))return"";let a="";const s=n.match(/\{[\s\S]*\}/);if(s)try{const d=JSON.parse(s[0]);a=d.error?.message??d.message??""}catch{}if(!a){const d=n.lastIndexOf(": ");d>=0&&(a=n.slice(d+2).trim())}const l=(d,m)=>t(`team:errors.${d}`,m);if(n.includes("MARKUS_UPSTREAM_ERROR"))return l("aiUpstreamBillingMismatch",{detail:a||l("defaultUpstreamBillingMismatch")});if(Kae(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:a||l("defaultInvalidApiKey")});if(n.includes("429")||/rate.?limit/i.test(n))return l("ai429",{detail:a||l("defaultTooManyRequests")});if(/\b409\b/.test(n)||/conflict/i.test(n))return l("ai409",{detail:a||l("defaultConflict")});if(n.includes("502")||/bad.?gateway/i.test(n))return l("ai502",{detail:a||l("defaultUpstreamDown")});if(n.includes("503")||/service.?unavailable/i.test(n))return l("ai503",{detail:a||l("defaultServiceDown")});const c=(a||n).replace(/https?:\/\/[^\s]*openrouter\.ai[^\s]*/gi,"").trim();return l("aiGeneric",{detail:(c||n).slice(0,120)})}function jse({msg:e,onCopy:t,onRetry:n,onResume:a,onReply:s,onRemember:l,isCopied:c,isLastAgentMsg:d,showRemember:m}){const{t:p}=ot(["team","common"]),h=e.isError||e.sender==="agent"&&e.text.startsWith("⚠"),g=e.isStopped,x=!!e.emptyReply||e.sender==="agent"&&!e.text?.trim()&&!e.segments?.some(T=>T.type==="text"&&(T.content||T.thinking)||T.type==="tool"),y=d!==!1,w=Dae(m,e.sender)&&!!l;return i.jsxs("div",{className:"flex items-center flex-wrap gap-0.5 mt-1",children:[i.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:p("common:copy"),children:[c?i.jsx("svg",{className:"w-3.5 h-3.5",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:i.jsx("polyline",{points:"20 6 9 17 4 12"})}):i.jsxs("svg",{className:"w-3.5 h-3.5",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[i.jsx("rect",{x:"9",y:"9",width:"13",height:"13",rx:"2"}),i.jsx("path",{d:"M5 15H4a2 2 0 01-2-2V4a2 2 0 012-2h9a2 2 0 012 2v1"})]}),p(c?"common:copied":"common:copy")]}),y&&a&&i.jsxs("button",{onClick:()=>a(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:p("page.messageActions.resumeTitle"),children:[i.jsx("svg",{className:"w-3.5 h-3.5",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:i.jsx("polygon",{points:"5 3 19 12 5 21 5 3"})}),p("page.messageActions.resumeTitle")]}),y&&g&&n&&i.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:p("page.messageActions.reaskTitle"),children:[i.jsxs("svg",{className:"w-3.5 h-3.5",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[i.jsx("polyline",{points:"23 4 23 10 17 10"}),i.jsx("path",{d:"M20.49 15a9 9 0 11-2.12-9.36L23 10"})]}),p("page.messageActions.reaskTitle")]}),y&&(h||x)&&!g&&n&&i.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:p("page.messageActions.retryTitle"),children:[i.jsxs("svg",{className:"w-3.5 h-3.5",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[i.jsx("polyline",{points:"23 4 23 10 17 10"}),i.jsx("path",{d:"M20.49 15a9 9 0 11-2.12-9.36L23 10"})]}),p("page.messageActions.retryTitle")]}),y&&!h&&!x&&!g&&e.sender==="agent"&&n&&i.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:p("page.messageActions.retryTitle"),children:[i.jsxs("svg",{className:"w-3.5 h-3.5",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[i.jsx("polyline",{points:"23 4 23 10 17 10"}),i.jsx("path",{d:"M20.49 15a9 9 0 11-2.12-9.36L23 10"})]}),p("page.messageActions.retryTitle")]}),s&&i.jsxs("button",{onClick:()=>s(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:p("page.messageActions.replyTitle"),children:[i.jsxs("svg",{className:"w-3.5 h-3.5",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[i.jsx("polyline",{points:"9 17 4 12 9 7"}),i.jsx("path",{d:"M20 18v-2a4 4 0 00-4-4H4"})]}),p("page.messageActions.replyTitle")]}),w&&i.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:p("page.messageActions.rememberTitle"),children:[i.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:[i.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"}),i.jsx("path",{d:"M9 22h6"})]}),p("page.messageActions.rememberTitle")]}),e.sender==="agent"&&i.jsx("span",{className:"ml-1 px-1 text-[10px] leading-none text-fg-tertiary/70 select-none whitespace-nowrap",children:p("page.messageActions.aiGeneratedDisclaimer")})]})}function Mse({busy:e,onConfirm:t,onCancel:n}){const{t:a}=ot(["team","common"]),[s,l]=k.useState("");return zr.createPortal(i.jsx("div",{className:"fixed inset-0 bg-black/60 flex items-center justify-center z-[10050] p-4",onClick:n,children:i.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:[i.jsx("h3",{className:"font-semibold text-base text-fg-primary",children:a("page.messageActions.rememberModalTitle")}),i.jsx("p",{className:"text-sm text-fg-secondary mt-1.5 leading-relaxed",children:a("page.messageActions.rememberModalHint")}),i.jsx("textarea",{value:s,onChange:c=>l(c.target.value),placeholder:a("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]"}),i.jsxs("div",{className:"flex justify-end gap-2 mt-4",children:[i.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:a("page.messageActions.rememberCancel")}),i.jsx("button",{type:"button",onClick:()=>t(s),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?a("common:loading",{defaultValue:"…"}):a("page.messageActions.rememberConfirm")})]})]})}),document.body)}const Wae=/[.!?。!?…::]\s*$|["'”’)\]}】》]\s*$|\n\s*$/,Yae=/^(?:\n|#{1,6}[ \t]|[-*+][ \t]|\d+[.)][ \t]|>|\||```|~~~|---)/;function Qae(e,t){return!(!e.replace(/\s+$/,"")||Wae.test(e)||!t.trim()||Yae.test(t))}function Xae(e,t,n){return/\s$/.test(e)||/^\s/.test(t)?e+t:n?.spaceNeeded?`${e} ${t}`:e+t}function Jae(e){const t=l=>l.type!=="text"||l.metadata?.isThinking===!0,n=[];let a=[],s=-1;for(const l of e){if(t(l)){a.push(l);continue}const c=s>=0?n[s]:void 0;if(c&&a.length>0&&l.metadata?.paragraphBreak!==!0&&c.metadata?.paragraphAfter!==!0&&Qae(c.content,l.content)){c.content=Xae(c.content,l.content,{spaceNeeded:c.metadata?.trailingSpace===!0||l.metadata?.leadingSpace===!0}),n.push(...a),a=[];continue}a.length>0&&(n.push(...a),a=[]),n.push(l),s=n.length-1}return a.length>0&&n.push(...a),n}function Zae(e){return e.type!=="text"||e.metadata?.isThinking===!0}function ere(e){let t=0,n=0,a=0,s=null,l=0;for(const p of e){if(p.type==="text"&&p.metadata?.isThinking===!0){t++;continue}if(p.type==="tool_start"){n++,s=p.content;continue}if(p.type==="tool_end"){p.metadata?.success===!1&&l++,s=null;continue}p.type==="subagent_start"&&a++,p.type==="error"&&l++}const c=Date.parse(e[0]?.createdAt??""),d=Date.parse(e[e.length-1]?.createdAt??""),m=Number.isFinite(c)&&Number.isFinite(d)&&d>c?d-c:0;return{thinkingCount:t,toolCount:n,subagentCount:a,running:s!==null,...s?{runningTool:s}:{},tailIsThinking:e[e.length-1]?.type==="text"&&e[e.length-1]?.metadata?.isThinking===!0,elapsedMs:m,errorCount:l}}function tre(e){const t=[];let n=[],a=0;const s=()=>{n.length!==0&&(t.push({kind:"process",key:`proc_${a}`,entries:n,summary:ere(n)}),n=[])};return e.forEach((l,c)=>{if(Zae(l)){n.length===0&&(a=c),n.push(l);return}s(),t.push({kind:"text",key:`text_${c}`,entry:l})}),s(),t}function nre({state:e}){return e==="running"?i.jsx("span",{className:"animate-spin inline-flex",children:i.jsx("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round","aria-hidden":"true",children:i.jsx("path",{d:"M12 3a9 9 0 1 0 9 9"})})}):e==="error"?i.jsxs("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:[i.jsx("path",{d:"M10.29 3.86 1.82 18a2 2 0 0 0 1.71 3h16.94a2 2 0 0 0 1.71-3L13.71 3.86a2 2 0 0 0-3.42 0z"}),i.jsx("path",{d:"M12 9.5v4"}),i.jsx("path",{d:"M12 17.5h.01"})]}):i.jsx("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:i.jsx("path",{d:"M20 6.5 9.5 17 4 11.5"})})}function are({entries:e,summary:t,isStreaming:n,isLastBlock:a,hideApprovalCards:s}){const{t:l}=ot("common"),[c,d]=k.useState(!1),m=k.useMemo(()=>bg(e.map(gb).filter(T=>T!==null)),[e]),p=n&&(t.running||a&&t.tailIsThinking),h=p?"running":t.errorCount>0?"error":"done",g=p&&t.runningTool?l("execution.processRun.runningTool",{tool:l(`execution.tools.${t.runningTool}`,{defaultValue:t.runningTool})}):null,x=[];t.thinkingCount>0&&x.push(l("execution.processRun.thinking")),t.toolCount>0&&x.push(l("execution.processRun.tools",{count:t.toolCount})),t.subagentCount>0&&x.push(l("execution.processRun.subagents",{count:t.subagentCount})),t.errorCount>0&&x.push(l("execution.processRun.errors",{count:t.errorCount})),t.elapsedMs>=1e3&&x.push($s(t.elapsedMs));const y=p?g??l("execution.thinkingEllipsis"):x.join(" · ")||l("execution.processRun.label"),w=l(`execution.processRun.state.${h}`);return i.jsxs("div",{className:"min-w-0",children:[i.jsxs("button",{type:"button",onClick:()=>d(T=>!T),"aria-expanded":c,"data-process-state":h,title:y,className:"group relative w-full flex items-center gap-2 px-2 py-1 rounded-lg text-left text-[11px] leading-tight text-fg-tertiary bg-surface-elevated/25 hover:bg-surface-elevated/45 border border-border-default/40 hover:border-border-default/70 overflow-hidden transition-colors cursor-pointer select-none",children:[p&&i.jsx("span",{className:"process-run-sweep","aria-hidden":"true"}),i.jsx("span",{className:`relative shrink-0 flex items-center justify-center w-3 h-3 ${h==="running"?"text-brand-400":""}`,children:i.jsx(nre,{state:h})}),i.jsx("span",{className:"sr-only",children:w}),i.jsx("span",{className:`relative min-w-0 truncate ${p&&!g?"activity-text-shimmer":""}`,children:p||x.length===0?y:x.map((T,C)=>i.jsxs("span",{children:[C>0?" · ":"",T]},T+C))}),i.jsx("svg",{className:`relative ml-auto w-3 h-3 shrink-0 transition-transform ${c?"rotate-180":""}`,viewBox:"0 0 20 20",fill:"currentColor","aria-hidden":"true",children:i.jsx("path",{fillRule:"evenodd",d:"M5.23 7.21a.75.75 0 011.06.02L10 11.168l3.71-3.938a.75.75 0 111.08 1.04l-4.25 4.5a.75.75 0 01-1.08 0l-4.25-4.5a.75.75 0 01.02-1.06z",clipRule:"evenodd"})})]}),c&&i.jsx("div",{className:"mt-1 ml-[7px] pl-3 border-l-2 border-border-default/50 space-y-2 min-w-0 overflow-hidden",children:m.length>0?m.map((T,C)=>i.jsx(yg,{entry:T,showTime:!1,hideApprovalCards:s},C)):i.jsx("div",{className:"py-1 text-[11px] text-fg-tertiary",children:l("execution.noToolDetail")})})]})}function ok(e,t,n){if(!e)return[];const a=[];let s=0;const l=t??"";let d=n?new Date(n).getTime():Date.now();const m=e.some(E=>E.createdAt),p=E=>{if(E.createdAt)return E.createdAt;if(m)return new Date(d).toISOString();const _=new Date(d).toISOString();return E.type==="tool"&&E.durationMs?d+=E.durationMs:d+=1e3,_};let h="",g="",x="";const y=()=>{const E=h.trim();if(E){const _=a[a.length-1];_&&_.type==="text"&&_.metadata?.isThinking?_.content+=(_.content?`
867
867
 
868
868
  `:"")+E:a.push({id:`cseg_${s}`,sourceType:"chat",sourceId:"",agentId:l,seq:s++,type:"text",content:E,createdAt:x,metadata:{isThinking:!0}})}h=""},w=()=>{const E=g,_=E.trim();if(_){const M={};/^\s*\n/.test(E)&&(M.paragraphBreak=!0),/\n\s*\n\s*$/.test(E)&&(M.paragraphAfter=!0),/\s$/.test(E)&&(M.trailingSpace=!0),/^\s/.test(E)&&(M.leadingSpace=!0),a.push({id:`cseg_${s}`,sourceType:"chat",sourceId:"",agentId:l,seq:s++,type:"text",content:_,createdAt:x,...Object.keys(M).length>0?{metadata:M}:{}})}g=""},T="<think>",C="</think>",S=E=>{let _=0,M=!1;for(;_<E.length;)if(M){const P=E.indexOf(C,_);P===-1?_=E.length:(M=!1,_=P+C.length)}else{const P=E.indexOf(T,_);P===-1?(g+=E.slice(_),_=E.length):(g+=E.slice(_,P),M=!0,_=P+T.length)}};for(const E of e)if(x=p(E),E.type==="tool"){w();const _=E.createdAt&&E.durationMs?new Date(new Date(E.createdAt).getTime()-E.durationMs).toISOString():x;a.push({id:`cseg_${s}`,sourceType:"chat",sourceId:"",agentId:l,seq:s++,type:"tool_start",content:E.tool,metadata:{arguments:E.args,...E.status==="running"&&E.subagentLogs?.length?{subagentLogs:E.subagentLogs}:{}},createdAt:_}),E.status!=="running"&&a.push({id:`cseg_${s}`,sourceType:"chat",sourceId:"",agentId:l,seq:s++,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:x})}else E.thinking&&(w(),h+=E.thinking,y()),S(bb(E.content).cleaned);return w(),Jae(a)}const _se=k.memo(function({msg:t,isStreaming:n,liveActivities:a,onMentionClick:s,knownNames:l}){const{t:c}=ot(["team","common"]),d=t.segments,m=t.isStopped,p=_=>_.type==="text"?_.content.length+(_.thinking?.length??0):(_.result?.length??0)+(_.subagentLogs?.length??0)*1e3+(_.liveOutput?.length??0),h=d?d.length+":"+(d.length>0?p(d[d.length-1]):0):"",g=d?d.reduce((_,M)=>_+(M.type==="tool"?M.subagentLogs?.length??0:0),0):0,x=k.useMemo(()=>d&&d.length>0?ok(d,t.agentId,t.rawCreatedAt):[],[h,g,t.agentId,t.rawCreatedAt]),y=t.committedSegments,w=y?y.length+":"+(y.length>0?p(y[y.length-1]):0):"",T=y?y.reduce((_,M)=>_+(M.type==="tool"?M.subagentLogs?.length??0:0),0):0,C=k.useMemo(()=>n?x:y&&y.length>0?ok(y,t.agentId,t.rawCreatedAt):x,[n,w,T,t.agentId,t.rawCreatedAt,x]);if(d!==void 0&&d.length>0){const M=d.filter(F=>F.type==="text").map(F=>F.content).join(""),P=F=>F.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,I=(M?P(M):null)||(t.text?P(t.text):null),K=tre(C),Y=K.some(F=>F.kind==="text"),L=[];for(const F of d){if(F.type!=="tool")continue;const ne=BS(F.tool,F.result);if(ne){L.push({key:`task-${ne.taskId}`,kind:"task",info:ne});continue}const ee=HS(F.tool,F.result);ee&&L.push({key:`req-${ee.requirementId}`,kind:"req",info:ee})}return i.jsxs("div",{className:"space-y-2 min-h-[1em] min-w-0 overflow-x-hidden",children:[K.map((F,ne)=>F.kind==="text"?i.jsx(Ea,{content:F.entry.content,onMentionClick:s,knownNames:l},F.key):i.jsx(are,{entries:F.entries,summary:F.summary,isStreaming:n,isLastBlock:ne===K.length-1,hideApprovalCards:!0},F.key)),K.length===0&&n&&i.jsx(Jw,{activities:a,isActive:!0}),!Y&&I&&i.jsx(Ea,{content:I,onMentionClick:s,knownNames:l}),L.map(F=>F.kind==="task"?i.jsx(US,{info:F.info},F.key):i.jsx(GS,{info:F.info},F.key)),!n&&!I&&K.length===0&&L.length===0&&!m&&(t.emptyReply||!t.isError)&&i.jsx("div",{className:"flex items-start gap-1.5 text-[13px] text-fg-tertiary leading-relaxed",children:i.jsx("span",{children:c("page.emptyReply")})}),!n&&(t.isError||t.text.startsWith("⚠"))&&t.text&&!d?.some(F=>F.type==="text"&&F.content&&(F.content===t.text||F.content.startsWith("⚠")))&&i.jsx("p",{className:"mt-1.5 text-[13px] text-fg-tertiary leading-relaxed whitespace-pre-wrap",children:t.text.replace(/^⚠\s*/,"")}),m&&i.jsxs("div",{className:"flex items-center gap-1.5 mt-1.5 text-[11px] text-fg-tertiary",children:[i.jsx("svg",{className:"w-3 h-3 shrink-0",viewBox:"0 0 24 24",fill:"currentColor",children:i.jsx("rect",{x:"4",y:"4",width:"16",height:"16",rx:"2"})}),i.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 i.jsxs(i.Fragment,{children:[(n||S)&&i.jsx(Jw,{activities:n?a:t.activities??[],isActive:n,persistent:!n&&S}),E?t.isError||E.startsWith("⚠")?i.jsx("p",{className:"text-[13px] text-fg-tertiary leading-relaxed whitespace-pre-wrap",children:E.replace(/^⚠\s*/,"")}):i.jsx(Ea,{content:E,onMentionClick:s,knownNames:l}):null,!n&&!E&&!S&&!m&&t.sender==="agent"&&(t.emptyReply||!t.isError)&&i.jsx("div",{className:"flex items-start gap-1.5 text-[13px] text-fg-tertiary leading-relaxed",children:i.jsx("span",{children:c("page.emptyReply")})}),m&&i.jsxs("div",{className:"flex items-center gap-1.5 mt-1.5 text-[11px] text-fg-tertiary",children:[i.jsx("svg",{className:"w-3 h-3 shrink-0",viewBox:"0 0 24 24",fill:"currentColor",children:i.jsx("rect",{x:"4",y:"4",width:"16",height:"16",rx:"2"})}),i.jsx("span",{children:c("page.stopped")})]})]})});function rre(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 ire({approval:e,submitting:t,readOnly:n,onClose:a,onSubmit:s}){const{t:l}=ot(["team","common"]);Qo(!0);const c=k.useMemo(()=>rre(e),[e]),[d,m]=k.useState(0),[p,h]=k.useState(()=>{if(n&&e.answers&&e.answers.length>0){const P={};for(const R of e.answers)P[R.questionId]={selectedOptionIds:R.selectedOptionIds??[],text:R.text??""};return P}return{}}),g=c[d],x=d===c.length-1,y=c.length>1,w=P=>p[P]??{selectedOptionIds:[],text:""},T=(P,R)=>{h(I=>({...I,[P]:{...w(P),...R}}))},C=(P,R)=>{const I=w(P.id);if(P.allowMultiple){const K=I.selectedOptionIds.includes(R);T(P.id,{selectedOptionIds:K?I.selectedOptionIds.filter(Y=>Y!==R):[...I.selectedOptionIds,R],text:K?I.text:""})}else{const K=I.selectedOptionIds.includes(R);T(P.id,{selectedOptionIds:K?[]:[R],text:K?I.text:""})}},S=P=>{const R=w(P.id);return P.inputType==="choice"?R.selectedOptionIds.length>0?!0:!!(P.allowFreeform&&R.text.trim()):R.text.trim().length>0},E=c.every(S),_=()=>c.map(P=>{const R=w(P.id),I={questionId:P.id};return R.selectedOptionIds.length>0&&(I.selectedOptionIds=R.selectedOptionIds),R.text.trim()&&(I.text=R.text.trim()),I}),M=()=>{const P=_();let R=!0,I;if(!e.questions?.length&&e.options?.length){const Y=P[0];I=Y?.selectedOptionIds?.[0]??(Y?.text?"custom":void 0),R=I!=="reject"&&I!=="request_changes"}const K=P.map(Y=>Y.text).filter(Boolean).join(`
869
- `)||void 0;s({approved:R,comment:K,selectedOption:I,answers:P})};return zr.createPortal(i.jsx("div",{className:"fixed inset-0 z-[10000] flex items-center justify-center p-4 bg-black/50 backdrop-blur-sm",onMouseDown:P=>{P.target===P.currentTarget&&a()},children:i.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:[i.jsxs("div",{className:"flex items-start gap-3 px-6 py-4 border-b border-border-default shrink-0",children:[i.jsx("div",{className:"w-9 h-9 rounded-lg bg-amber-500/15 text-amber-500 flex items-center justify-center shrink-0",children:i.jsxs("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[i.jsx("path",{d:"M12 2a10 10 0 1 0 0 20 10 10 0 0 0 0-20z"}),i.jsx("path",{d:"M12 8v4"}),i.jsx("path",{d:"M12 16h.01"})]})}),i.jsxs("div",{className:"flex-1 min-w-0",children:[i.jsx("h2",{className:"text-base font-semibold text-fg-primary leading-snug",children:e.title}),i.jsxs("div",{className:"flex items-center gap-2 mt-0.5",children:[i.jsx("p",{className:"text-xs text-fg-tertiary",children:e.agentName}),n&&i.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:[i.jsx("svg",{width:"10",height:"10",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"3",strokeLinecap:"round",strokeLinejoin:"round",children:i.jsx("path",{d:"M20 6L9 17l-5-5"})}),l("team:userInput.submitted",{defaultValue:"Submitted"})]})]})]}),i.jsx("button",{onClick:a,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:i.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[i.jsx("path",{d:"M18 6L6 18"}),i.jsx("path",{d:"M6 6l12 12"})]})})]}),i.jsxs("div",{className:"flex-1 overflow-y-auto px-6 py-5 space-y-4",children:[y&&i.jsx("div",{className:"flex items-center gap-2",children:c.map((P,R)=>i.jsx("button",{onClick:()=>m(R),className:`h-1.5 flex-1 rounded-full transition-colors ${R===d?"bg-brand-500":S(P)?"bg-green-500/60":"bg-border-default"}`,title:`${R+1}. ${P.prompt.slice(0,40)}`},P.id))}),y&&i.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}`})}),i.jsx("div",{className:"text-sm text-fg-primary leading-relaxed",children:i.jsx(Ea,{content:g.prompt})}),g.inputType==="choice"&&g.options&&i.jsx("div",{className:"space-y-2",children:g.options.map((P,R)=>{const I=w(g.id).selectedOptionIds.includes(P.id);return i.jsxs("button",{onClick:n?void 0:()=>C(g,P.id),disabled:n,className:`w-full px-4 py-3 text-left rounded-xl border transition-colors flex items-start gap-3 ${I?"border-brand-500 bg-brand-500/10":`border-border-default ${n?"":"hover:bg-surface-overlay"}`} ${n?"cursor-default":""} ${n&&!I?"opacity-50":""}`,children:[i.jsx("span",{className:`w-6 h-6 rounded-full flex items-center justify-center text-[11px] font-bold shrink-0 mt-0.5 ${I?"bg-brand-600 text-white":"bg-surface-overlay text-fg-tertiary"}`,children:I?i.jsx("svg",{width:"13",height:"13",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"3",strokeLinecap:"round",strokeLinejoin:"round",children:i.jsx("path",{d:"M20 6L9 17l-5-5"})}):String.fromCharCode(65+R)}),i.jsxs("span",{className:"flex-1 min-w-0 text-sm text-fg-primary [&_p]:my-0 [&_p]:text-sm",children:[i.jsx(Ea,{content:P.label}),P.description&&i.jsx("span",{className:"block text-xs text-fg-tertiary mt-1 [&_p]:my-0 [&_p]:text-xs",children:i.jsx(Ea,{content:P.description})})]})]},P.id)})}),(g.inputType==="text"||g.allowFreeform)&&(!n||w(g.id).text)&&i.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:P=>{const R=P.target.value;T(g.id,{text:R,selectedOptionIds:R.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"}`})]}),i.jsxs("div",{className:"flex items-center justify-between gap-2 px-6 py-4 border-t border-border-default shrink-0",children:[i.jsx("div",{children:y&&d>0&&i.jsx("button",{onClick:()=>m(P=>Math.max(0,P-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"})})}),i.jsx("div",{className:"flex items-center gap-2",children:y&&!x?i.jsx("button",{disabled:!n&&!S(g),onClick:()=>m(P=>Math.min(c.length-1,P+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?i.jsx("button",{onClick:a,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"})}):i.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&&i.jsxs("svg",{className:"animate-spin h-4 w-4",viewBox:"0 0 24 24",fill:"none",children:[i.jsx("circle",{className:"opacity-25",cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"4"}),i.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 Od(e){return Array.isArray(e.questions)&&e.questions.length>0}const Pd={urgent:"bg-red-500",high:"bg-amber-500",normal:"bg-blue-500",low:"bg-gray-400"},Io={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"},lk={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 Oo(e,t){const n=Date.now()-new Date(e).getTime(),a=Math.floor(n/6e4);if(a<1)return t("common:time.now");if(a<60)return t("common:time.minutesAgo",{count:a});const s=Math.floor(a/60);return s<24?t("common:time.hoursAgo",{count:s}):t("common:time.daysAgo",{count:Math.floor(s/24)})}const ck="markus:template-updates-ack";let ph=!1,zd=null;function sre(e){return e.map(t=>`${t.name}@${t.availableVersion}`).sort().join(",")}function uk(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 Bd(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 a=e.metadata??{};switch(e.type){case"task_completed":case"task_created":case"task_review":case"task_failed":return a.taskId?t("team:notifications.actionHints.viewTask"):null;case"requirement_created":case"requirement_decision":return a.requirementId?t("team:notifications.actionHints.viewRequirement"):null;case"agent_report":return a.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 a.templateUpdates?t("common:templateUpdates.actionHint"):null;default:return a.taskId?t("team:notifications.actionHints.viewTask"):a.requirementId?t("team:notifications.actionHints.viewRequirement"):a.agentId?t("team:notifications.actionHints.viewAgent"):null}}function XS(e){const t=e.metadata;if(!(!t||typeof t.i18n!="object"||!t.i18n))return t.i18n}function dk(e,t){const n=XS(e);if(!n?.titleKey)return e.title;const a={...n.titleParams??{}};return t(`team:${n.titleKey}`,{...a,defaultValue:e.title})}function mk(e,t){const n=XS(e);if(!n?.bodyKey)return e.body;const a={};for(const[s,l]of Object.entries(n.bodyParams??{}))a[s]=s==="status"||s==="statusKey"?t(`common:status.${l}`,{defaultValue:l}):l;return t(`team:${n.bodyKey}`,{...a,defaultValue:e.body})}function fh(){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 a=e.createOscillator();a.type="sine",a.frequency.setValueAtTime(880,t),a.frequency.setValueAtTime(1174.66,t+.15),a.connect(n),a.start(t),a.stop(t+.6),a.onended=()=>e.close()}catch{}}function ore({collapsed:e,userId:t,embeddedMode:n,onClose:a,sidebarMode:s,isActive:l,label:c,iconPath:d}){const{t:m}=ot(["team","common"]),[p,h]=k.useState(!1),[g,x]=k.useState("approvals"),[y,w]=k.useState([]),[T,C]=k.useState([]),[S,E]=k.useState(null),[_,M]=k.useState(null),[P,R]=k.useState(null),[I,K]=k.useState({}),[Y,L]=k.useState(0),[F,ne]=k.useState([]),ee=k.useRef(null),G=k.useRef(null),[ae,H]=k.useState({top:0,left:0,width:448,maxHeight:576}),J=k.useRef(null),fe=k.useRef(!1),[Ce,$]=k.useState(!0),[V,pe]=k.useState(!1),z=k.useRef(null),je=k.useRef("approvals"),[Ue,qe]=k.useState(!1),[He,ut]=k.useState("unread"),dt=30,Nt=100,wt=k.useCallback(async()=>{try{li("/approvals"),li("/notifications");const[U,ge,Xe]=await Promise.all([Ae.notifications.list(t,!1,{limit:dt,offset:0}),Ae.approvals.list(),Ae.notifications.list(t,!0,{limit:Nt,offset:0})]);w(U.notifications),ne(Xe.notifications);const ye=U.unreadCount??U.notifications.filter(tt=>!tt.read).length;if(L(ye),$(U.totalCount!=null?U.notifications.length<U.totalCount:U.notifications.length>=dt),C(ge.approvals),!fe.current){const tt=ge.approvals.filter(ft=>ft.status==="pending").length;J.current=tt,fe.current=!0}}catch{}},[t]),Zt=k.useCallback(async()=>{if(!(V||!Ce)){pe(!0);try{const U=await Ae.notifications.list(t,!1,{limit:dt,offset:y.length});U.notifications.length>0&&w(ge=>[...ge,...U.notifications.filter(Xe=>!ge.some(ye=>ye.id===Xe.id))]),$(U.totalCount!=null?y.length+U.notifications.length<U.totalCount:U.notifications.length>=dt)}catch{}pe(!1)}},[t,y.length,V,Ce]),Wt=k.useCallback(U=>{const ge=U.detail;if(!ge)return;const{taskId:Xe,requirementId:ye}=ge;!Xe&&!ye||w(tt=>{const ft=tt.filter(bt=>!bt.read&&(Xe&&bt.metadata?.taskId===Xe||ye&&bt.metadata?.requirementId===ye));if(ft.length===0)return tt;for(const bt of ft)Ae.notifications.markRead(bt.id).catch(()=>{});L(bt=>Math.max(0,bt-ft.length));const Ht=new Set(ft.map(bt=>bt.id));return ne(bt=>bt.filter(le=>!Ht.has(le.id))),tt.map(bt=>ft.some(le=>le.id===bt.id)?{...bt,read:!0}:bt)})},[]),rt=k.useRef(y);rt.current=y;const $e=k.useCallback(async()=>{if(!rt.current.some(ge=>!ge.read&&ge.type==="system"&&ge.metadata?.creditExhausted))try{await Ae.notifications.create({title:m("credits.notificationTitle",{ns:"common"}),body:m("credits.notificationBody",{ns:"common"}),type:"system",priority:"urgent",metadata:{creditExhausted:!0}}),wt(),fh()}catch{}},[wt,m]),mt=k.useCallback(async()=>{if(!ph){ph=!0;try{const{updates:U}=await Ae.skills.updates();if(!U.length)return;const ge=sre(U);try{if(localStorage.getItem(ck)===ge)return}catch{}if(zd===ge||rt.current.some(ye=>!ye.read&&uk(ye,ge)))return;try{const tt=(await Ae.notifications.list(t,!0,{limit:50,type:"system"})).notifications.filter(ft=>uk(ft,ge)).sort((ft,Ht)=>new Date(Ht.createdAt).getTime()-new Date(ft.createdAt).getTime());if(tt.length>0){for(const ft of tt.slice(1))Ae.notifications.markRead(ft.id).catch(()=>{});tt.length>1&&wt(),zd=ge;return}}catch{}zd=ge,await Ae.notifications.create({title:m("templateUpdates.notificationTitle",{ns:"common"}),body:m("templateUpdates.notificationBody",{ns:"common",count:U.length}),type:"system",priority:"high",metadata:{templateUpdates:!0,templateUpdatesFingerprint:ge,count:U.length,skills:U.map(ye=>ye.name)}}),wt(),fh()}catch{zd=null}finally{ph=!1}}},[wt,m,t]);k.useEffect(()=>{wt();const U=setInterval(wt,6e4);let ge=null;const Xe=()=>{ge||(ge=setTimeout(()=>{ge=null,wt()},400))},ye=()=>Xe(),tt=()=>{h(!0),wt()};window.addEventListener("markus:notifications-changed",ye),window.addEventListener("markus:mark-read-by-ref",Wt),window.addEventListener("markus:open-notifications",tt),window.addEventListener("markus:credit-exhausted",$e);const ft=Ir.on("notification",Xe),Ht=Ir.on("approval:requested",Xe);return()=>{clearInterval(U),ge&&clearTimeout(ge),window.removeEventListener("markus:notifications-changed",ye),window.removeEventListener("markus:mark-read-by-ref",Wt),window.removeEventListener("markus:open-notifications",tt),window.removeEventListener("markus:credit-exhausted",$e),ft(),Ht()}},[wt,Wt,$e]),k.useEffect(()=>{mt();const U=setInterval(()=>{mt()},5*6e4),ge=()=>{mt()};return window.addEventListener("markus:data-changed",ge),()=>{clearInterval(U),window.removeEventListener("markus:data-changed",ge)}},[t]);const At=k.useCallback(()=>{if(!ee.current)return;const U=ee.current.getBoundingClientRect(),ge=window.innerWidth,Xe=window.innerHeight,ye=Math.min(448,ge-16),tt=Math.min(576,Xe-16);let ft=U.right+8,Ht=U.top;ft+ye>ge-8&&(ft=Math.max(8,ge-ye-8)),Ht+tt>Xe-8&&(Ht=Math.max(8,Xe-tt-8)),H({top:Ht,left:ft,width:ye,maxHeight:tt})},[]);k.useLayoutEffect(()=>{p&&At()},[p,At]),k.useEffect(()=>{if(p)return window.addEventListener("resize",At),()=>window.removeEventListener("resize",At)},[p,At]),k.useEffect(()=>{if(!p)return;const U=ge=>{ee.current?.contains(ge.target)||G.current?.contains(ge.target)||h(!1)};return document.addEventListener("mousedown",U),()=>document.removeEventListener("mousedown",U)},[p]),k.useEffect(()=>{if(!p)return;ut("unread");const U=T.some(Xe=>Xe.status==="pending"),ge=y.some(Xe=>!Xe.read);x(U&&!ge?"approvals":!U&&ge?"notifications":je.current)},[p]);const Dt=new Set(T.filter(U=>U.status==="pending").map(U=>U.id)),ln=new Set(T.map(U=>U.id)),ce=U=>U.type==="approval_request"&&!!U.metadata?.approvalId&&ln.has(U.metadata.approvalId),et=U=>[...U].sort((ge,Xe)=>new Date(Xe.createdAt).getTime()-new Date(ge.createdAt).getTime()),nt=y.filter(U=>!ce(U)),we=F.filter(U=>!ce(U)),Me=et(nt),Ne=et(we),se=He==="all"?Me:Ne,q=m(He==="unread"?"team:notifications.noUnread":"team:notifications.noNotifications"),te=Ne.length,Se=Dt.size,De=te+Se;k.useEffect(()=>{J.current!==null&&Se>J.current&&fh(),J.current=Se},[Se]);const Pe=async U=>{await Ae.notifications.markRead(U),w(ge=>ge.map(Xe=>Xe.id===U?{...Xe,read:!0}:Xe)),ne(ge=>ge.filter(Xe=>Xe.id!==U)),L(ge=>Math.max(0,ge-1)),window.dispatchEvent(new CustomEvent("markus:notifications-changed"))},Q=U=>{const ge=U.metadata??{},Xe=U.actionType,ye=U.actionTarget;if(Xe==="open_chat"&&ye)try{const tt=typeof ye=="string"?JSON.parse(ye):ye;if(tt.agentId){const ft={agentId:tt.agentId};tt.sessionId&&(ft.sessionId=tt.sessionId),at.navigate(de.TEAM,ft);return}}catch{}if(Xe==="navigate"&&ye)try{const tt=typeof ye=="string"?JSON.parse(ye):ye;if(tt.path){if(tt.path.startsWith("/team")){const ft={},Ht=new URLSearchParams(tt.path.split("?")[1]||"");for(const[bt,le]of Ht.entries())ft[bt]=le;at.navigate(de.TEAM,ft);return}if(tt.path.startsWith("/work")){const ft={},Ht=new URLSearchParams(tt.path.split("?")[1]||"");for(const[bt,le]of Ht.entries())ft[bt]=le;at.navigate(de.WORK,ft);return}}}catch{}switch(U.type){case"approval_request":{const tt=ge.approvalId,ft=tt?T.find(_e=>_e.id===tt):void 0;if(ft&&Od(ft)){M(ft);break}const Ht=ft?.details?.taskId??ge.taskId,bt=ft?.details?.requirementId??ge.requirementId,le=ft?.details?.agentId??ft?.agentId;Ht?at.navigate(de.WORK,{openTask:Ht}):bt?at.navigate(de.WORK,{openRequirement:bt}):le?at.navigate(de.TEAM,{agentId:le}):at.navigate(de.WORK);break}case"task_completed":case"task_created":case"task_review":case"task_failed":ge.taskId?at.navigate(de.WORK,{openTask:ge.taskId}):at.navigate(de.WORK);break;case"requirement_created":case"requirement_decision":ge.requirementId?at.navigate(de.WORK,{openRequirement:ge.requirementId}):at.navigate(de.WORK);break;case"agent_report":case"system":{if(ge.creditExhausted){qe(!0);return}if(ge.templateUpdates){const tt=ge.templateUpdatesFingerprint;if(tt)try{localStorage.setItem(ck,tt)}catch{}localStorage.setItem("markus_nav_storeTab","installed"),at.navigate(de.STORE);return}if(ge.agentId){const tt={agentId:ge.agentId};ge.sessionId&&(tt.sessionId=ge.sessionId),at.navigate(de.TEAM,tt)}else at.navigate(de.TEAM);break}case"direct_message":{const tt=ge.senderId;tt?at.navigate(de.TEAM,{dm:tt}):at.navigate(de.TEAM);break}case"group_message":{const tt=ge.channel;tt?at.navigate(de.TEAM,{channel:tt}):at.navigate(de.TEAM);break}default:ge.taskId?at.navigate(de.WORK,{openTask:ge.taskId}):ge.requirementId?at.navigate(de.WORK,{openRequirement:ge.requirementId}):ge.projectId?at.navigate(de.WORK,{projectId:ge.projectId}):ge.agentId&&at.navigate(de.TEAM,{agentId:ge.agentId});break}},X=async U=>{const ge=U.metadata??{},Xe=U.actionType,ye=U.type==="agent_report"&&!ge.creditExhausted&&!ge.templateUpdates&&(Xe==="open_chat"||!!ge.agentId&&Xe!=="navigate");!U.read&&!ye&&Pe(U.id);const tt=ge.taskId,ft=ge.requirementId;if(!ye&&(tt||ft)){const Ht=y.filter(bt=>bt.id!==U.id&&!bt.read&&(tt&&bt.metadata?.taskId===tt||ft&&bt.metadata?.requirementId===ft));for(const bt of Ht)Pe(bt.id)}Q(U)},ue=async(U,ge,Xe,ye,tt)=>{E(U);try{const{approval:ft}=await Ae.approvals.respond(U,ge,t,Xe,ye,tt);C(_e=>_e.map(ht=>ht.id===U?ft:ht)),M(null),R(null),K(_e=>{const ht={..._e};return delete ht[U],ht});const Ht=ft.details?.taskId,bt=ft.details?.requirementId,le=y.filter(_e=>!_e.read&&(_e.type==="approval_request"&&_e.metadata?.approvalId===U||Ht&&_e.metadata?.taskId===Ht||bt&&_e.metadata?.requirementId===bt));if(le.length>0){for(const ht of le)Ae.notifications.markRead(ht.id).catch(()=>{});const _e=new Set(le.map(ht=>ht.id));w(ht=>ht.map(Tt=>_e.has(Tt.id)?{...Tt,read:!0}:Tt)),L(ht=>Math.max(0,ht-le.length))}li("/approvals"),li("/notifications"),li("/tasks"),li("/taskboard"),li("/requirements"),window.dispatchEvent(new CustomEvent("markus:data-changed")),window.dispatchEvent(new CustomEvent("markus:notifications-changed")),setTimeout(()=>wt(),800)}catch{}E(null)},Be=async()=>{try{if(!t)return;await Ae.notifications.markAllRead(t),w(U=>U.map(ge=>({...ge,read:!0}))),ne([]),L(0),li("/notifications"),window.dispatchEvent(new CustomEvent("markus:notifications-changed"))}catch{const U=nt.filter(ge=>!ge.read);await Promise.all(U.map(ge=>Ae.notifications.markRead(ge.id))),w(ge=>ge.map(Xe=>({...Xe,read:!0}))),ne([]),L(0),li("/notifications"),window.dispatchEvent(new CustomEvent("markus:notifications-changed"))}},Ie=U=>{const ge=U.details?.subType;return ge==="requirement_resubmit"?m("team:notifications.approvalType.requirementResubmit"):ge==="requirement"||U.details?.requirementId?m("team:notifications.approvalType.requirement"):ge==="task_review"?m("team:notifications.approvalType.taskReview"):ge==="task"||U.details?.taskId?m("team:notifications.approvalType.task"):U.details?.toolName?m("team:notifications.approvalType.toolExecution"):null},Ge=U=>{const ge=U.details??{},Xe=ge.subType,ye=ge.priority,tt=ye?m(`common:priority.${ye}`,{defaultValue:ye}):"";if(Xe==="requirement")return m("team:notifications.approvalDesc.requirementProposed",{agentName:U.agentName,title:U.title,priority:tt,defaultValue:U.description});if(Xe==="requirement_resubmit")return m("team:notifications.approvalDesc.requirementResubmitted",{agentName:U.agentName,title:U.title,priority:tt,defaultValue:U.description});if(Xe==="task")return m("team:notifications.approvalDesc.taskCreate",{agentName:U.agentName,title:U.title,priority:tt,defaultValue:U.description});if(Xe==="task_review"){const ft=`Task "${U.title}" has been submitted for your review.`;if(U.description.startsWith(ft))return m("team:notifications.approvalDesc.taskReview",{title:U.title})+U.description.slice(ft.length)}return U.description},kt=U=>{const ge=[];ge.push(U.agentName);const Xe=U.details?.taskTitle,ye=U.details?.taskId;Xe?ge.push(Xe):ye&&ge.push(`${m("team:notifications.approvalType.task")} ${ye.slice(0,8)}`);const tt=U.details?.requirementId;return tt&&!ye&&ge.push(`${m("team:notifications.approvalType.requirement")} ${tt.slice(0,8)}`),ge.join(" · ")},Rt=[...T].sort((U,ge)=>new Date(ge.requestedAt).getTime()-new Date(U.requestedAt).getTime()),Mt=Rt.filter(U=>U.status==="pending"),Ot=Rt.filter(U=>U.status!=="pending"),Un=U=>{const ge=U.details?.taskId,Xe=U.details?.requirementId,ye=U.details?.agentId??U.agentId;ge?at.navigate(de.WORK,{openTask:ge}):Xe?at.navigate(de.WORK,{openRequirement:Xe}):ye?at.navigate(de.TEAM,{agentId:ye}):at.navigate(de.WORK)},hn=()=>{h(!1),a?.()},ie=U=>i.jsxs("button",{disabled:S===U.id,onClick:()=>M(U),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:[i.jsx("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:i.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"}),U.questions&&U.questions.length>1?` (${U.questions.length})`:""]}),Ee=_?i.jsx(ire,{approval:_,submitting:S===_.id,readOnly:_.status!=="pending",onClose:()=>M(null),onSubmit:U=>ue(_.id,U.approved,U.comment,U.selectedOption,U.answers)}):null,We=i.jsxs("div",{className:"flex items-center justify-between gap-2 px-3 py-1.5 border-b border-border-default/50 shrink-0",children:[i.jsx("div",{className:"flex items-center gap-0.5 rounded-md bg-surface-overlay/60 p-0.5",children:["unread","all"].map(U=>i.jsx("button",{onClick:()=>ut(U),"aria-pressed":He===U,title:U==="unread"?m("team:notifications.noUnread"):void 0,className:`px-2 py-0.5 rounded text-[10px] font-medium transition-colors ${He===U?"bg-surface-base text-fg-primary shadow-sm":"text-fg-tertiary hover:text-fg-secondary"}`,children:U==="unread"?m("team:notifications.filterUnread")+(te>0?` (${te})`:""):m("team:notifications.filterAll")},U))}),Y>0&&i.jsx("button",{onClick:Be,className:"text-[10px] text-brand-500 hover:text-brand-400 transition-colors shrink-0",children:m("team:notifications.markAllRead")})]}),pt=i.jsxs(i.Fragment,{children:[i.jsxs("div",{className:"flex border-b border-border-default shrink-0",children:[i.jsxs("button",{onClick:()=>{x("approvals"),je.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"),Se>0?` (${Se})`:""]}),i.jsxs("button",{onClick:()=>{x("notifications"),je.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"),te>0?` (${te})`:""]}),i.jsx("button",{onClick:hn,className:"px-2 py-2 text-fg-tertiary hover:text-fg-primary transition-colors shrink-0",title:m("common:close"),children:i.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[i.jsx("path",{d:"M18 6L6 18"}),i.jsx("path",{d:"M6 6l12 12"})]})})]}),g==="notifications"&&We,i.jsxs("div",{ref:z,className:"flex-1 overflow-y-auto",onScroll:U=>{if(g!=="notifications"||!Ce||V)return;const ge=U.currentTarget;ge.scrollTop+ge.clientHeight>=ge.scrollHeight-80&&Zt()},children:[g==="approvals"&&(T.length===0?i.jsx("div",{className:"p-6 text-center text-xs text-fg-tertiary",children:m("team:notifications.noApprovals")}):i.jsxs("div",{className:"divide-y divide-border-default/50",children:[Mt.map(U=>{const ge=U.details?.command,Xe=ge?Ge(U).replace(/\s*Command:.*$/,""):Ge(U);return i.jsxs("div",{className:"px-3 py-3 space-y-2.5",children:[i.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:()=>Un(U),children:[i.jsxs("div",{className:"flex items-start gap-2",children:[i.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:i.jsx("path",{d:Io.approval_request})}),i.jsxs("div",{className:"flex-1 min-w-0",children:[i.jsxs("div",{className:"flex items-center gap-2",children:[Ie(U)&&i.jsx("span",{className:"text-[10px] text-amber-500 font-medium shrink-0",children:Ie(U)}),i.jsx("span",{className:"text-xs text-fg-primary font-medium truncate",children:U.title}),i.jsx("span",{className:"text-[10px] text-fg-tertiary shrink-0",children:Oo(U.requestedAt,m)})]}),i.jsx("div",{className:"text-[11px] text-fg-tertiary mt-0.5",children:U.agentName})]})]}),i.jsx("div",{className:"mt-2.5 text-[11px] text-fg-secondary leading-relaxed",children:i.jsx(Ea,{content:Xe,className:"text-[11px] [&_h1]:text-xs [&_h2]:text-[11px] [&_h3]:text-[11px] [&_p]:text-[11px] [&_li]:text-[11px]"})}),ge&&i.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:ge})]}),(()=>{if(Od(U))return ie(U);const ye=U.details?.subType,tt=ye==="task"||ye==="requirement"||ye==="requirement_resubmit",ft=U.options&&U.options.length>0,Ht=(I[U.id]??"").trim();if(ft){const bt=le=>le.id==="approve"?m("common:approve",{defaultValue:le.label}):le.id==="reject"||le.id==="request_changes"?m("team:notifications.optionLabels.requestChanges",{defaultValue:le.label}):le.label;return i.jsxs("div",{className:"space-y-1.5",children:[U.options.map((le,_e)=>i.jsxs("button",{disabled:S===U.id,onClick:()=>ue(U.id,le.id!=="reject",Ht||void 0,le.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 ${le.id==="reject"||le.id==="request_changes"?"border border-border-default text-fg-secondary hover:bg-surface-overlay":"bg-brand-600 text-white hover:bg-brand-700"}`,title:le.description,children:[i.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+_e)}),bt(le)]},le.id)),i.jsxs("div",{className:"flex gap-1.5 mt-1",children:[i.jsx("input",{type:"text",placeholder:m("team:notifications.freeformPlaceholder"),value:I[U.id]??"",onChange:le=>K(_e=>({..._e,[U.id]:le.target.value})),onKeyDown:le=>{le.key==="Enter"&&(I[U.id]??"").trim()&&ue(U.id,!0,(I[U.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"}),i.jsx("button",{disabled:S===U.id||!(I[U.id]??"").trim(),onClick:()=>ue(U.id,!0,(I[U.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")})]})]})}return tt?i.jsxs("div",{className:"space-y-1.5",children:[i.jsxs("div",{className:"flex items-center gap-2",children:[i.jsxs("button",{disabled:S===U.id,onClick:()=>ue(U.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:[i.jsx("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round",children:i.jsx("path",{d:"M20 6L9 17l-5-5"})}),m("common:approve")]}),i.jsxs("button",{disabled:S===U.id,onClick:()=>ue(U.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:[i.jsxs("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round",children:[i.jsx("path",{d:"M18 6L6 18"}),i.jsx("path",{d:"M6 6l12 12"})]}),m("common:reject")]}),P!==U.id&&i.jsxs("button",{disabled:S===U.id,onClick:()=>R(U.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:[i.jsxs("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[i.jsx("path",{d:"M11 4H4a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2v-7"}),i.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")]})]}),P===U.id&&i.jsxs("div",{className:"space-y-1.5",children:[i.jsx("input",{type:"text",autoFocus:!0,placeholder:m("team:notifications.adjustmentPlaceholder"),value:I[U.id]??"",onChange:bt=>K(le=>({...le,[U.id]:bt.target.value})),onKeyDown:bt=>{bt.key==="Enter"&&(I[U.id]??"").trim()&&ue(U.id,!1,(I[U.id]??"").trim(),"needs_adjustment"),bt.key==="Escape"&&R(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"}),i.jsxs("div",{className:"flex gap-2",children:[i.jsx("button",{disabled:S===U.id||!(I[U.id]??"").trim(),onClick:()=>ue(U.id,!1,(I[U.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")}),i.jsx("button",{onClick:()=>R(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")})]})]})]}):i.jsxs("div",{className:"space-y-1.5",children:[i.jsx("input",{type:"text",placeholder:m("team:notifications.commentPlaceholder"),value:I[U.id]??"",onChange:bt=>K(le=>({...le,[U.id]:bt.target.value})),onKeyDown:bt=>{bt.key==="Enter"&&ue(U.id,!0,Ht||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"}),i.jsxs("div",{className:"flex gap-2",children:[i.jsx("button",{disabled:S===U.id,onClick:()=>ue(U.id,!0,Ht||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")}),i.jsx("button",{disabled:S===U.id,onClick:()=>ue(U.id,!1,Ht||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")})]})]})})()]},U.id)}),Ot.length>0&&i.jsxs(i.Fragment,{children:[Mt.length>0&&i.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")}),Ot.slice(0,50).map(U=>i.jsxs("button",{onClick:()=>Od(U)?M(U):Un(U),className:"w-full text-left px-3 py-2.5 hover:bg-surface-overlay/50 transition-colors group",children:[i.jsxs("div",{className:"flex items-center gap-2",children:[i.jsx("span",{className:`w-1.5 h-1.5 rounded-full shrink-0 ${U.status==="approved"?"bg-green-500":U.status==="cancelled"||U.status==="expired"?"bg-gray-400":"bg-red-500"}`}),Ie(U)&&i.jsx("span",{className:"text-[10px] text-fg-tertiary font-medium shrink-0",children:Ie(U)}),i.jsx("span",{className:"text-xs text-fg-secondary truncate flex-1 group-hover:text-fg-primary",children:U.title}),i.jsx("span",{className:`text-[10px] font-medium shrink-0 ${U.status==="approved"?"text-green-500":U.status==="cancelled"||U.status==="expired"?"text-fg-muted":"text-red-500"}`,children:m(`common:status.${U.status}`,{defaultValue:U.status})})]}),i.jsxs("div",{className:"flex items-center gap-1.5 mt-0.5 pl-3.5",children:[i.jsx("span",{className:"text-[10px] text-fg-muted truncate",children:kt(U)}),i.jsx("span",{className:"text-[10px] text-fg-muted shrink-0",children:"·"}),i.jsx("span",{className:"text-[10px] text-fg-muted shrink-0",children:Oo(U.respondedAt??U.requestedAt,m)})]}),U.responseComment&&i.jsxs("p",{className:"text-[10px] text-fg-muted mt-0.5 pl-3.5 truncate",children:["“",U.responseComment,"”"]})]},U.id))]})]})),g==="notifications"&&(se.length===0?i.jsx("div",{className:"p-6 text-center text-xs text-fg-tertiary",children:q}):i.jsxs("div",{className:"divide-y divide-border-default/50",children:[se.map(U=>{const ge=lk[U.type]??"text-fg-tertiary";return i.jsxs("div",{role:"button",tabIndex:0,onClick:()=>X(U),onKeyDown:Xe=>{(Xe.key==="Enter"||Xe.key===" ")&&(Xe.preventDefault(),X(U))},className:`w-full text-left px-3 py-2.5 flex gap-2.5 transition-colors cursor-pointer ${U.read?"opacity-50 hover:opacity-70":"hover:bg-surface-overlay"}`,children:[i.jsx("div",{className:"shrink-0 mt-0.5",children:i.jsx("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",className:ge,children:i.jsx("path",{d:Io[U.type]??Io.system})})}),i.jsxs("div",{className:"flex-1 min-w-0",children:[i.jsxs("div",{className:"flex items-center gap-1.5",children:[!U.read&&i.jsx("span",{className:`w-1.5 h-1.5 rounded-full shrink-0 ${Pd[U.priority]??Pd.normal}`}),i.jsx("span",{className:"text-xs text-fg-primary font-medium truncate",children:dk(U,m)})]}),i.jsx("div",{className:"text-[11px] text-fg-tertiary mt-0.5 ",children:i.jsx(Ea,{content:mk(U,m),className:"text-[11px] [&_h1]:text-xs [&_h2]:text-[11px] [&_h3]:text-[11px] [&_p]:text-[11px] [&_li]:text-[11px] [&_p]:text-fg-tertiary"})}),i.jsxs("div",{className:"flex items-center gap-2 mt-0.5",children:[i.jsx("span",{className:"text-[10px] text-fg-muted",children:Oo(U.createdAt,m)}),Bd(U,m)&&i.jsx("span",{className:`text-[10px] font-medium ${ge}`,children:Bd(U,m)})]})]})]},U.id)}),V&&i.jsx("div",{className:"py-3 text-center",children:i.jsxs("svg",{className:"animate-spin h-4 w-4 text-fg-tertiary mx-auto",viewBox:"0 0 24 24",fill:"none",children:[i.jsx("circle",{className:"opacity-25",cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"4"}),i.jsx("path",{className:"opacity-75",fill:"currentColor",d:"M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4z"})]})})]}))]})]}),Bt=k.useCallback(U=>{U?.mute&&Vae()},[]),Pt=k.useCallback(U=>{Bt(U),qe(!1)},[Bt]),it=Ue?i.jsx(ba,{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:()=>qe(!1),onCancelClick:U=>{Pt(U),at.navigate(de.SETTINGS),setTimeout(()=>{window.location.hash="settings/providers"},50)},onConfirm:U=>{const ge=`${st.getUrl().replace(/\/$/,"")}/settings?tab=billing`;Pt(U),fi(ge)}}):null;if(n){const U=["approvals","notifications"],ge=U.indexOf(g),Xe=(()=>{let ye=0,tt=0;return{onTouchStart:ft=>{ye=ft.touches[0].clientX,tt=ft.touches[0].clientY},onTouchEnd:ft=>{const Ht=ft.changedTouches[0].clientX-ye,bt=ft.changedTouches[0].clientY-tt;Math.abs(Ht)>60&&Math.abs(Ht)>Math.abs(bt)*1.5&&(Ht<0&&ge<U.length-1&&x(U[ge+1]),Ht>0&&ge>0&&x(U[ge-1]))}}})();return i.jsxs(i.Fragment,{children:[it,i.jsxs("div",{className:"flex flex-col h-full overflow-hidden",children:[Ee,i.jsx("div",{className:"flex border-b border-border-default shrink-0",children:U.map(ye=>i.jsx("button",{onClick:()=>x(ye),className:`flex-1 px-3 py-3 text-sm font-medium transition-colors ${g===ye?"text-fg-primary border-b-2 border-brand-500":"text-fg-tertiary"}`,children:ye==="approvals"?i.jsxs(i.Fragment,{children:[m("team:notifications.approvals"),Se>0?` (${Se})`:""]}):i.jsxs(i.Fragment,{children:[m("team:notifications.notifications"),te>0?` (${te})`:""]})},ye))}),g==="notifications"&&We,i.jsx("div",{className:"flex-1 overflow-hidden relative",...Xe,children:i.jsxs("div",{className:"flex h-full transition-transform duration-300 ease-out",style:{transform:`translateX(-${ge*100}%)`},children:[i.jsx("div",{className:"w-full shrink-0 h-full overflow-y-auto scrollbar-thin",children:T.length===0?i.jsx("div",{className:"p-6 text-center text-xs text-fg-tertiary",children:m("team:notifications.noApprovals")}):i.jsxs("div",{className:"divide-y divide-border-default/50",children:[Mt.map(ye=>{const tt=ye.details?.command,ft=tt?Ge(ye).replace(/\s*Command:.*$/,""):Ge(ye);return i.jsxs("div",{className:"px-3 py-3 space-y-2.5",children:[i.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:()=>Un(ye),children:[i.jsxs("div",{className:"flex items-start gap-2",children:[i.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:i.jsx("path",{d:Io.approval_request})}),i.jsxs("div",{className:"flex-1 min-w-0",children:[i.jsxs("div",{className:"flex items-center gap-2",children:[Ie(ye)&&i.jsx("span",{className:"text-[10px] text-amber-500 font-medium shrink-0",children:Ie(ye)}),i.jsx("span",{className:"text-xs text-fg-primary font-medium truncate",children:ye.title}),i.jsx("span",{className:"text-[10px] text-fg-tertiary shrink-0",children:Oo(ye.requestedAt,m)})]}),i.jsx("div",{className:"text-[11px] text-fg-tertiary mt-0.5",children:ye.agentName})]})]}),i.jsx("div",{className:"mt-2.5 text-[11px] text-fg-secondary leading-relaxed",children:i.jsx(Ea,{content:ft,className:"text-[11px] [&_h1]:text-xs [&_h2]:text-[11px] [&_h3]:text-[11px] [&_p]:text-[11px] [&_li]:text-[11px]"})}),tt&&i.jsx("pre",{className:"text-[11px] text-fg-primary bg-surface-overlay border border-border-default rounded-md px-2.5 py-2 overflow-x-auto whitespace-pre-wrap break-all font-mono leading-relaxed mt-2",children:tt})]}),(()=>{if(Od(ye))return ie(ye);const Ht=ye.details?.subType,bt=Ht==="task"||Ht==="requirement"||Ht==="requirement_resubmit",le=ye.options&&ye.options.length>0,_e=(I[ye.id]??"").trim();if(le){const ht=Tt=>Tt.id==="approve"?m("common:approve",{defaultValue:Tt.label}):Tt.id==="reject"||Tt.id==="request_changes"?m("team:notifications.optionLabels.requestChanges",{defaultValue:Tt.label}):Tt.label;return i.jsxs("div",{className:"space-y-1.5",children:[ye.options.map((Tt,Pn)=>i.jsxs("button",{disabled:S===ye.id,onClick:()=>ue(ye.id,Tt.id!=="reject",_e||void 0,Tt.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 ${Tt.id==="reject"||Tt.id==="request_changes"?"border border-border-default text-fg-secondary hover:bg-surface-overlay":"bg-brand-600 text-white hover:bg-brand-700"}`,title:Tt.description,children:[i.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+Pn)}),ht(Tt)]},Tt.id)),i.jsxs("div",{className:"flex gap-1.5 mt-1",children:[i.jsx("input",{type:"text",placeholder:m("team:notifications.freeformPlaceholder"),value:I[ye.id]??"",onChange:Tt=>K(Pn=>({...Pn,[ye.id]:Tt.target.value})),onKeyDown:Tt=>{Tt.key==="Enter"&&(I[ye.id]??"").trim()&&ue(ye.id,!0,(I[ye.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"}),i.jsx("button",{disabled:S===ye.id||!(I[ye.id]??"").trim(),onClick:()=>ue(ye.id,!0,(I[ye.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")})]})]})}return bt?i.jsxs("div",{className:"space-y-1.5",children:[i.jsxs("div",{className:"flex items-center gap-2",children:[i.jsxs("button",{disabled:S===ye.id,onClick:()=>ue(ye.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:[i.jsx("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round",children:i.jsx("path",{d:"M20 6L9 17l-5-5"})}),m("common:approve")]}),i.jsxs("button",{disabled:S===ye.id,onClick:()=>ue(ye.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:[i.jsxs("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round",children:[i.jsx("path",{d:"M18 6L6 18"}),i.jsx("path",{d:"M6 6l12 12"})]}),m("common:reject")]}),P!==ye.id&&i.jsxs("button",{disabled:S===ye.id,onClick:()=>R(ye.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:[i.jsxs("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[i.jsx("path",{d:"M11 4H4a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2v-7"}),i.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")]})]}),P===ye.id&&i.jsxs("div",{className:"space-y-1.5",children:[i.jsx("input",{type:"text",autoFocus:!0,placeholder:m("team:notifications.adjustmentPlaceholder"),value:I[ye.id]??"",onChange:ht=>K(Tt=>({...Tt,[ye.id]:ht.target.value})),onKeyDown:ht=>{ht.key==="Enter"&&(I[ye.id]??"").trim()&&ue(ye.id,!1,(I[ye.id]??"").trim(),"needs_adjustment"),ht.key==="Escape"&&R(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"}),i.jsxs("div",{className:"flex gap-2",children:[i.jsx("button",{disabled:S===ye.id||!(I[ye.id]??"").trim(),onClick:()=>ue(ye.id,!1,(I[ye.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")}),i.jsx("button",{onClick:()=>R(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")})]})]})]}):i.jsxs("div",{className:"space-y-1.5",children:[i.jsx("input",{type:"text",placeholder:m("team:notifications.commentPlaceholder"),value:I[ye.id]??"",onChange:ht=>K(Tt=>({...Tt,[ye.id]:ht.target.value})),onKeyDown:ht=>{ht.key==="Enter"&&ue(ye.id,!0,_e||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"}),i.jsxs("div",{className:"flex gap-2",children:[i.jsx("button",{disabled:S===ye.id,onClick:()=>ue(ye.id,!0,_e||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")}),i.jsx("button",{disabled:S===ye.id,onClick:()=>ue(ye.id,!1,_e||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")})]})]})})()]},ye.id)}),Ot.length>0&&i.jsxs(i.Fragment,{children:[Mt.length>0&&i.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")}),Ot.slice(0,50).map(ye=>i.jsxs("button",{onClick:()=>Un(ye),className:"w-full text-left px-3 py-2.5 hover:bg-surface-overlay/50 transition-colors",children:[i.jsxs("div",{className:"flex items-center gap-2",children:[i.jsx("span",{className:`w-1.5 h-1.5 rounded-full shrink-0 ${ye.status==="approved"?"bg-green-500":ye.status==="cancelled"||ye.status==="expired"?"bg-gray-400":"bg-red-500"}`}),i.jsx("span",{className:"text-xs text-fg-secondary truncate flex-1",children:ye.title}),i.jsx("span",{className:`text-[10px] font-medium shrink-0 ${ye.status==="approved"?"text-green-500":ye.status==="cancelled"||ye.status==="expired"?"text-fg-muted":"text-red-500"}`,children:m(`common:status.${ye.status}`,{defaultValue:ye.status})})]}),i.jsxs("div",{className:"flex items-center gap-1.5 mt-0.5 pl-3.5",children:[i.jsx("span",{className:"text-[10px] text-fg-muted truncate",children:kt(ye)}),i.jsx("span",{className:"text-[10px] text-fg-muted shrink-0",children:"·"}),i.jsx("span",{className:"text-[10px] text-fg-muted shrink-0",children:Oo(ye.respondedAt??ye.requestedAt,m)})]})]},ye.id))]})]})}),i.jsx("div",{className:"w-full shrink-0 h-full overflow-y-auto scrollbar-thin",children:se.length===0?i.jsx("div",{className:"p-6 text-center text-xs text-fg-tertiary",children:q}):i.jsx("div",{className:"divide-y divide-border-default/50",children:se.slice(0,He==="unread"?Nt:50).map(ye=>{const tt=lk[ye.type]??"text-fg-tertiary";return i.jsxs("button",{onClick:()=>X(ye),className:`w-full text-left px-3 py-2.5 flex gap-2.5 transition-colors ${ye.read?"opacity-50 hover:opacity-70":"hover:bg-surface-overlay"}`,children:[i.jsx("div",{className:"shrink-0 mt-0.5",children:i.jsx("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",className:tt,children:i.jsx("path",{d:Io[ye.type]??Io.system})})}),i.jsxs("div",{className:"flex-1 min-w-0",children:[i.jsxs("div",{className:"flex items-center gap-1.5",children:[!ye.read&&i.jsx("span",{className:`w-1.5 h-1.5 rounded-full shrink-0 ${Pd[ye.priority]??Pd.normal}`}),i.jsx("span",{className:"text-xs text-fg-primary font-medium truncate",children:dk(ye,m)})]}),i.jsx("div",{className:"text-[11px] text-fg-tertiary mt-0.5 ",children:i.jsx(Ea,{content:mk(ye,m),className:"text-[11px] [&_h1]:text-xs [&_h2]:text-[11px] [&_h3]:text-[11px] [&_p]:text-[11px] [&_li]:text-[11px] [&_p]:text-fg-tertiary"})}),i.jsxs("div",{className:"flex items-center gap-2 mt-0.5",children:[i.jsx("span",{className:"text-[10px] text-fg-muted",children:Oo(ye.createdAt,m)}),Bd(ye,m)&&i.jsx("span",{className:`text-[10px] font-medium ${tt}`,children:Bd(ye,m)})]})]})]},ye.id)})})})]})})]})]})}if(s){const U=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 i.jsxs(i.Fragment,{children:[Ee,i.jsxs("button",{ref:ee,onClick:()=>{h(!p),p||wt()},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 ${p||l?"bg-surface-overlay":"hover:bg-surface-overlay/60"}`,children:[i.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:i.jsx("path",{d:U})}),e?i.jsx("span",{className:"text-[9px] leading-tight truncate w-full text-center",children:c}):i.jsx("span",{className:"truncate",children:c}),De>0&&i.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:De>99?m("common:badgeOverLimit"):De})]}),p&&zr.createPortal(i.jsx("div",{ref:G,className:"fixed bg-surface-secondary border border-border-default rounded-xl shadow-2xl z-[9999] flex flex-col overflow-hidden",style:{top:ae.top,left:ae.left,width:ae.width,maxHeight:ae.maxHeight},children:pt}),document.body),it]})}return i.jsxs(i.Fragment,{children:[Ee,i.jsxs("button",{ref:ee,onClick:()=>{h(!p),p||wt()},className:`relative flex items-center justify-center rounded-md transition-colors ${e?"w-8 h-8":"w-7 h-7"} ${p?"bg-surface-overlay text-fg-primary":"text-fg-tertiary hover:text-fg-secondary hover:bg-surface-overlay"}`,title:m("team:notifications.bellTitle"),children:[i.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[i.jsx("path",{d:"M18 8A6 6 0 0 0 6 8c0 7-3 9-3 9h18s-3-2-3-9"}),i.jsx("path",{d:"M13.73 21a2 2 0 0 1-3.46 0"})]}),De>0&&i.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:De>99?m("common:badgeOverLimit"):De})]}),p&&zr.createPortal(i.jsx("div",{ref:G,className:"fixed bg-surface-secondary border border-border-default rounded-xl shadow-2xl z-[9999] flex flex-col overflow-hidden",style:{top:ae.top,left:ae.left,width:ae.width,maxHeight:ae.maxHeight},children:pt}),document.body),it]})}function Hd({d:e,size:t=14}){return i.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:i.jsx("path",{d:e})})}const hh=200;function lre({authUser:e,onLogout:t,onEditProfile:n,showSettingsLink:a=!1,collapsed:s=!1,showVersion:l=!1}){const{t:c}=ot(["nav","common"]),[d,m]=k.useState(!1),[p,h]=k.useState(!1),[g,x]=k.useState({top:0,left:0}),y=k.useRef(null),w=k.useRef(null),{connected:T,user:C,credits:S,refresh:E}=h4(d),_=k.useCallback(()=>{if(!y.current)return;const ne=y.current.getBoundingClientRect(),ee=window.innerWidth,G=window.innerHeight,ae=w.current?.offsetHeight??220;let H=ne.right+8;H+hh>ee-8&&(H=Math.max(8,ne.left-hh-8));let J=ne.top-ae-8;J<8&&(J=Math.min(ne.bottom+8,G-ae-8)),x({top:Math.max(8,J),left:H})},[]);k.useLayoutEffect(()=>{if(!d)return;_();const ne=requestAnimationFrame(()=>_());return()=>cancelAnimationFrame(ne)},[d,_,s]),k.useEffect(()=>{if(!d)return;const ne=G=>{const ae=G.target;y.current?.contains(ae)||w.current?.contains(ae)||m(!1)},ee=()=>_();return document.addEventListener("mousedown",ne),window.addEventListener("resize",ee),window.addEventListener("scroll",ee,!0),()=>{document.removeEventListener("mousedown",ne),window.removeEventListener("resize",ee),window.removeEventListener("scroll",ee,!0)}},[d,_]);const M=e?.name||C?.displayName||C?.username||c("common:userPlaceholder"),P=e?.email||C?.email||"",R=m4(e?.avatarUrl,C?.avatarUrl),I=T?"bg-emerald-500":"bg-fg-muted",K=T?C?.username?c("sidebar.hubConnectedAs",{username:C.username}):c("sidebar.hubConnected"):c("sidebar.hubDisconnected"),Y=!!(T&&C?.username&&e?.name&&C.username.toLowerCase()!==e.name.toLowerCase()&&C.email?.toLowerCase()!==e.email?.toLowerCase()),L=()=>{m(!1),E({validate:!0}),at.navigate(de.SETTINGS,{tab:"account"})},F=d&&zr.createPortal(i.jsxs("div",{ref:w,className:"fixed bg-surface-elevated border border-border-default rounded-xl shadow-xl z-[9999] overflow-hidden",style:{top:g.top,left:g.left,width:hh},children:[i.jsxs("div",{className:"px-3.5 py-3 border-b border-border-default flex items-start gap-2",children:[i.jsxs("div",{className:"min-w-0 flex-1",children:[i.jsx("div",{className:"text-sm font-medium text-fg-primary truncate",children:M}),P&&i.jsx("div",{className:"text-xs text-fg-tertiary mt-0.5 truncate",children:P}),S!==null&&i.jsxs("div",{className:"text-xs text-fg-secondary mt-0.5 flex items-center gap-1",children:[i.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:i.jsx("polyline",{points:"13 2 3 14 12 14 18 22 6 22 12 17"})}),i.jsxs("span",{className:"truncate",children:[c("common:creditBalance"),": ",S.remaining.toLocaleString()]})]})]}),n&&i.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:i.jsx(Hd,{d:"M12 20h9M16.5 3.5a2.12 2.12 0 0 1 3 3L7 19l-4 1 1-4Z",size:14})})]}),i.jsxs("button",{type:"button",onClick:L,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:[i.jsx("span",{className:`w-2 h-2 rounded-full shrink-0 ${I}`}),i.jsxs("span",{className:"min-w-0 flex-1",children:[i.jsx("span",{className:"text-xs text-fg-secondary block truncate",children:K}),Y&&C?.username&&i.jsx("span",{className:"text-[10px] text-amber-500/90 block truncate mt-0.5",children:c("sidebar.hubAccountMismatch",{username:C.username})})]}),i.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:i.jsx("path",{d:"m9 18 6-6-6-6"})})]}),i.jsxs("div",{className:"py-1",children:[a&&i.jsxs("button",{type:"button",onClick:()=>{m(!1),at.navigate(de.SETTINGS)},className:"w-full flex items-center gap-2.5 px-3.5 py-2 text-sm text-fg-secondary hover:bg-surface-overlay transition-colors",children:[i.jsx(Hd,{d:Cc[de.SETTINGS]}),c("settings")]}),window.markusDesktop&&i.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:[i.jsx(Hd,{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&&i.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:[i.jsx(Hd,{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 i.jsxs("div",{className:`relative ${s?"flex justify-center":"flex items-center justify-between gap-2 w-full"}`,children:[i.jsxs("button",{ref:y,type:"button",onClick:()=>m(ne=>!ne),title:M,className:`relative inline-flex items-center justify-center rounded-full transition-opacity hover:opacity-90 ${s?"p-0.5":""}`,children:[i.jsx(Zi,{name:M,avatarUrl:R,size:s?28:32,fallback:"icon"}),i.jsx("span",{className:`absolute bottom-0 right-0 w-2.5 h-2.5 rounded-full border-2 border-surface-secondary ${I}`,title:K})]}),l&&!s&&i.jsxs("span",{className:"text-[10px] text-fg-muted select-none shrink-0",children:["v","0.10.1-rc.0"]}),F,p&&t&&i.jsx(ba,{title:c("common:signOutConfirmTitle"),message:c("common:signOutConfirmMessage"),confirmLabel:c("common:signOut"),variant:"primary",onConfirm:()=>{h(!1),t()},onCancel:()=>h(!1)})]})}function cre({d:e,size:t=18}){return i.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:i.jsx("path",{d:e})})}function ure({currentPage:e,onNavigate:t,authUser:n,collapsed:a,onToggleCollapse:s,onLogout:l,keyboardFocusPageId:c,keyboardPaneActive:d}){const{t:m}=ot(["nav","common"]);return i.jsxs("aside",{"data-keyboard-pane":"l0",className:"markus-app-sidebar h-dvh bg-surface-secondary flex flex-col shrink-0 overflow-hidden",children:[i.jsx("div",{"data-electron-drag":!0,className:`electron-mac-sidebar-header flex items-center ${a?"px-2 py-3.5 justify-center":"px-4 h-14 justify-between"}`,children:i.jsxs("button",{"data-no-drag":!0,onClick:s,title:m(a?"sidebar.expandSidebar":"sidebar.collapseSidebar"),className:"flex items-center gap-2.5 min-w-0 group",children:[i.jsx("img",{src:"/logo.png",alt:"Markus",className:"w-8 h-8 rounded-lg shrink-0"}),!a&&i.jsx("span",{className:"text-[15px] font-bold tracking-tight text-fg-primary whitespace-nowrap",children:"Markus"})]})}),i.jsx("nav",{className:`${a?"p-1":"px-3 py-2"} flex-1 overflow-y-auto scrollbar-thin`,children:JF.map((p,h)=>{const g=r4.filter(y=>y.section===p.key);if(g.length===0)return null;const x=m(`sections.${p.key}`);return i.jsx("div",{children:i.jsxs("div",{className:h>0?"mt-3":"",children:[!a&&x&&i.jsx("div",{className:"px-3 py-1.5 mb-1 text-[10px] font-semibold text-fg-muted uppercase tracking-[0.1em]",children:x}),a&&h>0&&i.jsx("div",{className:"my-3"}),g.map(y=>{if(y.id===de.NOTIFICATIONS)return i.jsx(ore,{sidebarMode:!0,collapsed:a,userId:n?.id,label:m(y.id),iconPath:Cc[y.id],isActive:e===y.id},y.id);const w=e===y.id,T=d&&c===y.id;return i.jsxs("button",{"data-l0-page-id":y.id,onClick:()=>t(y.id),title:a?m(y.id):void 0,className:`w-full flex items-center ${a?"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:[i.jsx(cre,{d:Cc[y.id]??"",size:a?16:18}),a?i.jsx("span",{className:"text-[9px] leading-tight truncate w-full text-center",children:m(y.id)}):i.jsx("span",{className:"truncate",children:m(y.id)})]},y.id)})]})},p.key)})}),i.jsx("div",{className:`shrink-0 border-t border-border-subtle ${a?"p-1.5 flex justify-center":"px-3 py-2.5"}`,children:i.jsx(lre,{authUser:n,onLogout:l,onEditProfile:()=>{window.dispatchEvent(new Event("markus:open-edit-profile"))},showSettingsLink:!1,collapsed:a,showVersion:!a})})]})}const dre=6e4,mre=2e3;let Ar={},Yi={};const xg=new Set,Rm=new Set;let JS=0;const vg=new Map;let yc=null,$d=0,nm=null;function Lc(){for(const e of xg)e()}function pk(e,t){const n=Object.keys(e);if(n.length!==Object.keys(t).length)return!1;for(const a of n)if(e[a]!==t[a])return!1;return!0}function pre(e,t){const n={},a=[];for(const[s,l]of Object.entries(e)){if(t.has(s)){l>0&&a.push(s);continue}n[s]=l}return{counts:n,staleActiveKeys:a}}function yb(e,t){const n=Date.now(),a=vg.get(e)??0;!t?.force&&n-a<mre||(vg.set(e,n),e in Ar&&(delete Ar[e],Lc()),Ae.unread.markRead(e,new Date().toISOString()).catch(()=>{}))}async function wg(){try{const e=await Ae.unread.getCounts(),{counts:t,staleActiveKeys:n}=pre(e.counts??{},Rm);Ar=t,Yi=e.sessionAgentMap??{},Lc();for(const a of n)yb(a)}catch{}}function fre(){yc||(wg(),yc=setInterval(wg,dre),nm=Ir.on("chat:unread_update",e=>{const t=e.payload?.conversationKey;if(t){if(Rm.has(t)){yb(t);return}Date.now()>JS&&(Ar[t]=(Ar[t]??0)+1,Lc())}}))}function hre(){yc&&(clearInterval(yc),yc=null),nm&&(nm(),nm=null)}function gre(e){const t=e?.enabled??!0,[n,a]=k.useState(Ar),[s,l]=k.useState(Yi),c=k.useCallback(async()=>{await wg()},[]),d=k.useCallback(async w=>{const T=new Date().toISOString();delete Ar[w],Lc();try{await Ae.unread.markRead(w,T)}catch{}},[]),m=k.useCallback(async()=>{Ar={},Lc();try{await Ae.unread.markAllRead()}catch{}},[]),p=k.useCallback(w=>{Rm.add(w)},[]),h=k.useCallback(w=>{Rm.delete(w),JS=Date.now()+150,vg.delete(w),yb(w,{force:!0})},[]);k.useEffect(()=>{if(!t)return;$d++,fre();let w=Yi;const T=()=>{a(C=>pk(C,Ar)?C:{...Ar}),w!==Yi&&(w=Yi,l(C=>pk(C,Yi)?C:{...Yi}))};return xg.add(T),a({...Ar}),l({...Yi}),()=>{xg.delete(T),$d--,$d<=0&&($d=0,hre())}},[t]);const g=k.useMemo(()=>Object.values(n).reduce((w,T)=>w+T,0),[n]),x=k.useCallback(w=>n[`session:${w}`]??0,[n]),y=k.useCallback(w=>n[`channel:${w}`]??0,[n]);return{counts:n,totalUnread:g,sessionAgentMap:s,getSessionUnread:x,getChannelUnread:y,markRead:d,markAllRead:m,refresh:c,setActiveKey:p,clearActiveKey:h}}function Rse(e,t){return k.useMemo(()=>{const n=new Map;for(const[a,s]of Object.entries(t))if(a.startsWith("session:")){const l=a.slice(8),c=e[l];c&&n.set(c,(n.get(c)??0)+s)}return n},[e,t])}function bre(e){return e.startsWith("channel:dm:a2a:")}function yre(e,t){let n=0;for(const[a,s]of Object.entries(e))if(a.startsWith("session:")){const l=a.slice(8);t[l]&&(n+=s)}else if(a.startsWith("channel:")){if(bre(a))continue;n+=s}return n}function xre({currentPage:e,onNavigate:t,userId:n}){const{t:a}=ot("nav"),[s,l]=k.useState(0),{counts:c,sessionAgentMap:d}=gre({enabled:!0}),m=k.useMemo(()=>yre(c,d),[c,d]),p=k.useCallback(async()=>{try{const h=await Ae.notifications.list(n,!1);l(h.unreadCount??h.notifications.filter(g=>!g.read).length)}catch{}},[n]);return k.useEffect(()=>{p();const h=setInterval(()=>{document.visibilityState==="visible"&&p()},3e4),g=()=>p();return window.addEventListener("markus:notifications-changed",g),()=>{clearInterval(h),window.removeEventListener("markus:notifications-changed",g)}},[p]),i.jsx("nav",{className:"fixed bottom-0 left-0 right-0 z-50 bg-surface-secondary flex items-stretch h-14 safe-area-bottom",children:eU.map(h=>{const g=h.group.includes(e),x=h.id===de.NOTIFICATIONS,y=h.id===de.TEAM;return i.jsxs("button",{onClick:()=>t(h.id),className:`flex-1 flex flex-col items-center justify-center gap-0.5 transition-colors ${g?"text-fg-primary":"text-fg-tertiary active:text-fg-secondary"}`,children:[i.jsxs("div",{className:"relative",children:[i.jsx("svg",{width:20,height:20,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:g?2:1.75,strokeLinecap:"round",strokeLinejoin:"round",className:"shrink-0",children:i.jsx("path",{d:Cc[h.id]})}),x&&s>0&&i.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:s>99?"99+":s}),y&&m>0&&i.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:m>99?"99+":m})]}),i.jsx("span",{className:`text-[10px] leading-tight ${g?"font-semibold":""}`,children:a(h.id)})]},h.id)})})}const Dm=new Map;function Ns(e,t){Dm.has(e)||Dm.set(e,t().catch(()=>{}))}function Ls(e){const t=Dm.get(e);return Dm.delete(e),t}const qa={builderArtifacts:"builder.artifacts",builderAgents:"builder.agents",builderHubMyItems:"builder.hubMyItems",builderInstalled:"builder.installed",hubAgents:"hub.agents",hubTeams:"hub.teams",hubSkills:"hub.skills"},Bs={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 il(e){const t=(e||"").toLowerCase();return t==="team"?"team":t==="skill"?"skill":t==="connector"||t==="mcp"?"connector":"agent"}function ZS(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 vre={agent:258,team:205,skill:32,connector:162};function xb(e,t){const n=vre[e],a=ZS(t),s=((n+(a%68-34))%360+360)%360,l=(s+22+(a>>>8)%24)%360;return`linear-gradient(${120+a%44}deg, hsl(${s} 72% 56%), hsl(${l} 66% 43%))`}const fk=["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 e6(e){return fk[ZS(e+"g")%fk.length]}function t6(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 wre(e){return!e||t6(e)?!1:[...e].length<=4&&new RegExp("\\p{Extended_Pictographic}","u").test(e)}function kre(e,t="user"){const n=t==="org"?"shapes":"thumbs",a=encodeURIComponent(e);return`https://api.dicebear.com/9.x/${n}/svg?seed=${a}&radius=50&backgroundType=gradientLinear`}function $o(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 hk(e,t="usd"){return!e||e<=0?"Free":`${t.toLowerCase()==="usd"?"$":""}${(e/100).toFixed(e%100===0?0:2)}`}const gk={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"}},Sre=["development","devops","management","productivity","browser","custom","general"],Cre=[{label:"Tech",emojis:["✦","◈","⬡","⚡","🤖","🧠","💡","🎯","🔧","📦","🚀","💻","🛠️","⭐","🔥","💎","⚙️","🧩","🔌","💾","🖥️","📡","🔬","🧪","🏗️","📱","🎮","🕹️","📟","💽","🖨️","⌨️"]},{label:"People",emojis:["👤","👥","🧑‍💻","👨‍💼","👩‍🔬","🧙","🦸","🤝","💪","🎓","👷","🕵️","🧑‍🎨","🧑‍🏫","👨‍🚀","🥷","🧑‍🏭","🧑‍⚕️","🧑‍🔧","🧑‍🍳","👨‍🎤","🦹","🧝","🧞","🧑‍✈️","💂","🤴","👸","🧛","🧟","🧜","🧚"]},{label:"Objects",emojis:["📝","📊","🗂️","📁","🔍","🔑","🌐","💬","🔒","🎨","📐","🗃️","📋","✏️","🖊️","📌","📎","🧲","🪝","🧰","🪜","🧬","🔭","💊","🩺","📕","📗","📘","📙","📓","🗒️","📰"]},{label:"Symbols",emojis:["❤️","🧡","💛","💚","💙","💜","🖤","🤍","♠️","♥️","♦️","♣️","🎵","🎶","💯","✅","❌","⭕","🔴","🟠","🟡","🟢","🔵","🟣","⚫","⚪","🟤","🔶","🔷","▶️","⏸️","⏹️"]},{label:"Nature",emojis:["🌟","🌈","🌊","🌿","🍀","🔮","💫","✨","🌙","☀️","🦋","🐉","🦊","🐺","🦅","🐙","🦁","🐯","🦄","🐲","🌸","🌺","🍄","🌵","🎄","🌴","🍁","🌻","🐝","🦎","🐍","🦈"]},{label:"Activity",emojis:["🎯","🏆","🥇","🎖️","🏅","🎪","🎭","🎬","🎤","🎧","🎼","🎹","🥁","🎸","🎺","🎻","⚽","🏀","🎾","🏐","🎲","🧸","🪁","🎰","🎳","🏹","🥊","🤺","⛷️","🏄","🚴","🧗"]}],Are={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 gh({value:e,onChange:t,renderAs:n="span",className:a,editClassName:s,placeholder:l,multiline:c,readOnly:d}){const[m,p]=k.useState(!1),[h,g]=k.useState(e),x=k.useRef(null);if(k.useEffect(()=>{g(e)},[e]),k.useEffect(()=>{m&&x.current?.focus()},[m]),d){const _=e||l,P=`${a??""} ${!e?"text-fg-muted italic":""}`;return n==="h1"?i.jsx("h1",{className:P,children:_}):n==="p"?i.jsx("p",{className:P,children:_}):i.jsx("span",{className:P,children:_})}const y=()=>{p(!1),h!==e&&t(h)},w=()=>{g(e),p(!1)},T=_=>{_.key==="Escape"&&w(),_.key==="Enter"&&!c&&y()};if(m){const _=`bg-transparent outline-none w-full ${s??a??""} ring-1 ring-brand-500/50 rounded px-1 -mx-1`;return c?i.jsx("textarea",{ref:x,value:h,onChange:M=>g(M.target.value),onBlur:y,onKeyDown:T,className:`${_} resize-y min-h-[60px]`,placeholder:l}):i.jsx("input",{ref:x,value:h,onChange:M=>g(M.target.value),onBlur:y,onKeyDown:T,className:_,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"?i.jsx("h1",{onClick:()=>p(!0),className:`${a??""} ${E} ${S?"text-fg-muted italic":""}`,children:C}):n==="p"?i.jsx("p",{onClick:()=>p(!0),className:`${a??""} ${E} ${S?"text-fg-muted italic":""}`,children:C}):n==="badge"?i.jsx("span",{onClick:()=>p(!0),className:`${a??""} ${E} ${S?"text-fg-muted italic":""}`,children:C}):i.jsx("span",{onClick:()=>p(!0),className:`${a??""} ${E} ${S?"text-fg-muted italic":""}`,children:C})}function Tre({value:e,options:t,onChange:n,className:a,readOnly:s}){const[l,c]=k.useState(!1),[d,m]=k.useState(e),p=k.useRef(null),h=k.useRef(null);if(k.useEffect(()=>{l&&(m(e),setTimeout(()=>p.current?.focus(),0))},[l,e]),s)return i.jsx("span",{className:a,children:e});const g=t.filter(y=>y.toLowerCase().includes(d.toLowerCase())),x=y=>{const w=y.trim();w&&w!==e&&n(w),c(!1)};return l?i.jsxs("div",{ref:h,className:"relative inline-block",children:[i.jsx("input",{ref:p,value:d,onChange:y=>m(y.target.value),onKeyDown:y=>{y.key==="Enter"?(y.preventDefault(),x(d)):y.key==="Escape"&&c(!1)},onBlur:y=>{h.current?.contains(y.relatedTarget)||x(d)},className:`${a??""} bg-transparent outline-none ring-1 ring-brand-500/50 rounded w-28`}),g.length>0&&i.jsx("div",{className:"absolute top-full left-0 mt-1 z-50 bg-surface-elevated border border-border-default rounded-lg shadow-xl py-1 min-w-[120px] max-h-40 overflow-y-auto",children:g.map(y=>i.jsx("button",{onMouseDown:w=>{w.preventDefault(),x(y)},className:`block w-full text-left px-3 py-1.5 text-xs hover:bg-surface-secondary/80 transition-colors ${y===e?"text-brand-400 font-medium":"text-fg-secondary"}`,children:y},y))})]}):i.jsx("span",{onClick:()=>c(!0),className:`${a??""} cursor-pointer hover:ring-1 hover:ring-border-default rounded px-1 -mx-1 transition-all`,children:e})}function Nre({tags:e,onChange:t,readOnly:n}){const{t:a}=ot(["builder"]),[s,l]=k.useState(!1),[c,d]=k.useState(""),m=k.useRef(null);if(k.useEffect(()=>{s&&m.current?.focus()},[s]),n)return i.jsx("div",{className:"flex flex-wrap items-center gap-1.5 min-h-[24px]",children:e.map(h=>i.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 p=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 s?i.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=>i.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,i.jsx("button",{onClick:()=>t(e.filter(g=>g!==h)),className:"text-fg-muted hover:text-red-500",children:"×"})]},h)),i.jsx("input",{ref:m,value:c,onChange:h=>d(h.target.value),onKeyDown:p,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:a("detail.typeTagAndEnter")})]}):i.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=>i.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)):i.jsx("span",{className:"text-[10px] text-fg-muted italic",children:a("detail.typeTagAndEnter")})})}function kg({content:e}){const t=[D5,I3,O3],n=[SS,[G3,{strict:"ignore"}],[cS,{detect:!0,ignoreMissing:!0}]],a=OS({}),s=k.useMemo(()=>{let l=ui(e,mS);return l=ui(l,hS),l},[e]);return i.jsx("div",{className:`prose prose-invert prose-sm max-w-none
869
+ `)||void 0;s({approved:R,comment:K,selectedOption:I,answers:P})};return zr.createPortal(i.jsx("div",{className:"fixed inset-0 z-[10000] flex items-center justify-center p-4 bg-black/50 backdrop-blur-sm",onMouseDown:P=>{P.target===P.currentTarget&&a()},children:i.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:[i.jsxs("div",{className:"flex items-start gap-3 px-6 py-4 border-b border-border-default shrink-0",children:[i.jsx("div",{className:"w-9 h-9 rounded-lg bg-amber-500/15 text-amber-500 flex items-center justify-center shrink-0",children:i.jsxs("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[i.jsx("path",{d:"M12 2a10 10 0 1 0 0 20 10 10 0 0 0 0-20z"}),i.jsx("path",{d:"M12 8v4"}),i.jsx("path",{d:"M12 16h.01"})]})}),i.jsxs("div",{className:"flex-1 min-w-0",children:[i.jsx("h2",{className:"text-base font-semibold text-fg-primary leading-snug",children:e.title}),i.jsxs("div",{className:"flex items-center gap-2 mt-0.5",children:[i.jsx("p",{className:"text-xs text-fg-tertiary",children:e.agentName}),n&&i.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:[i.jsx("svg",{width:"10",height:"10",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"3",strokeLinecap:"round",strokeLinejoin:"round",children:i.jsx("path",{d:"M20 6L9 17l-5-5"})}),l("team:userInput.submitted",{defaultValue:"Submitted"})]})]})]}),i.jsx("button",{onClick:a,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:i.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[i.jsx("path",{d:"M18 6L6 18"}),i.jsx("path",{d:"M6 6l12 12"})]})})]}),i.jsxs("div",{className:"flex-1 overflow-y-auto px-6 py-5 space-y-4",children:[y&&i.jsx("div",{className:"flex items-center gap-2",children:c.map((P,R)=>i.jsx("button",{onClick:()=>m(R),className:`h-1.5 flex-1 rounded-full transition-colors ${R===d?"bg-brand-500":S(P)?"bg-green-500/60":"bg-border-default"}`,title:`${R+1}. ${P.prompt.slice(0,40)}`},P.id))}),y&&i.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}`})}),i.jsx("div",{className:"text-sm text-fg-primary leading-relaxed",children:i.jsx(Ea,{content:g.prompt})}),g.inputType==="choice"&&g.options&&i.jsx("div",{className:"space-y-2",children:g.options.map((P,R)=>{const I=w(g.id).selectedOptionIds.includes(P.id);return i.jsxs("button",{onClick:n?void 0:()=>C(g,P.id),disabled:n,className:`w-full px-4 py-3 text-left rounded-xl border transition-colors flex items-start gap-3 ${I?"border-brand-500 bg-brand-500/10":`border-border-default ${n?"":"hover:bg-surface-overlay"}`} ${n?"cursor-default":""} ${n&&!I?"opacity-50":""}`,children:[i.jsx("span",{className:`w-6 h-6 rounded-full flex items-center justify-center text-[11px] font-bold shrink-0 mt-0.5 ${I?"bg-brand-600 text-white":"bg-surface-overlay text-fg-tertiary"}`,children:I?i.jsx("svg",{width:"13",height:"13",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"3",strokeLinecap:"round",strokeLinejoin:"round",children:i.jsx("path",{d:"M20 6L9 17l-5-5"})}):String.fromCharCode(65+R)}),i.jsxs("span",{className:"flex-1 min-w-0 text-sm text-fg-primary [&_p]:my-0 [&_p]:text-sm",children:[i.jsx(Ea,{content:P.label}),P.description&&i.jsx("span",{className:"block text-xs text-fg-tertiary mt-1 [&_p]:my-0 [&_p]:text-xs",children:i.jsx(Ea,{content:P.description})})]})]},P.id)})}),(g.inputType==="text"||g.allowFreeform)&&(!n||w(g.id).text)&&i.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:P=>{const R=P.target.value;T(g.id,{text:R,selectedOptionIds:R.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"}`})]}),i.jsxs("div",{className:"flex items-center justify-between gap-2 px-6 py-4 border-t border-border-default shrink-0",children:[i.jsx("div",{children:y&&d>0&&i.jsx("button",{onClick:()=>m(P=>Math.max(0,P-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"})})}),i.jsx("div",{className:"flex items-center gap-2",children:y&&!x?i.jsx("button",{disabled:!n&&!S(g),onClick:()=>m(P=>Math.min(c.length-1,P+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?i.jsx("button",{onClick:a,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"})}):i.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&&i.jsxs("svg",{className:"animate-spin h-4 w-4",viewBox:"0 0 24 24",fill:"none",children:[i.jsx("circle",{className:"opacity-25",cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"4"}),i.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 Od(e){return Array.isArray(e.questions)&&e.questions.length>0}const Pd={urgent:"bg-red-500",high:"bg-amber-500",normal:"bg-blue-500",low:"bg-gray-400"},Io={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"},lk={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 Oo(e,t){const n=Date.now()-new Date(e).getTime(),a=Math.floor(n/6e4);if(a<1)return t("common:time.now");if(a<60)return t("common:time.minutesAgo",{count:a});const s=Math.floor(a/60);return s<24?t("common:time.hoursAgo",{count:s}):t("common:time.daysAgo",{count:Math.floor(s/24)})}const ck="markus:template-updates-ack";let ph=!1,zd=null;function sre(e){return e.map(t=>`${t.name}@${t.availableVersion}`).sort().join(",")}function uk(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 Bd(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 a=e.metadata??{};switch(e.type){case"task_completed":case"task_created":case"task_review":case"task_failed":return a.taskId?t("team:notifications.actionHints.viewTask"):null;case"requirement_created":case"requirement_decision":return a.requirementId?t("team:notifications.actionHints.viewRequirement"):null;case"agent_report":return a.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 a.templateUpdates?t("common:templateUpdates.actionHint"):null;default:return a.taskId?t("team:notifications.actionHints.viewTask"):a.requirementId?t("team:notifications.actionHints.viewRequirement"):a.agentId?t("team:notifications.actionHints.viewAgent"):null}}function XS(e){const t=e.metadata;if(!(!t||typeof t.i18n!="object"||!t.i18n))return t.i18n}function dk(e,t){const n=XS(e);if(!n?.titleKey)return e.title;const a={...n.titleParams??{}};return t(`team:${n.titleKey}`,{...a,defaultValue:e.title})}function mk(e,t){const n=XS(e);if(!n?.bodyKey)return e.body;const a={};for(const[s,l]of Object.entries(n.bodyParams??{}))a[s]=s==="status"||s==="statusKey"?t(`common:status.${l}`,{defaultValue:l}):l;return t(`team:${n.bodyKey}`,{...a,defaultValue:e.body})}function fh(){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 a=e.createOscillator();a.type="sine",a.frequency.setValueAtTime(880,t),a.frequency.setValueAtTime(1174.66,t+.15),a.connect(n),a.start(t),a.stop(t+.6),a.onended=()=>e.close()}catch{}}function ore({collapsed:e,userId:t,embeddedMode:n,onClose:a,sidebarMode:s,isActive:l,label:c,iconPath:d}){const{t:m}=ot(["team","common"]),[p,h]=k.useState(!1),[g,x]=k.useState("approvals"),[y,w]=k.useState([]),[T,C]=k.useState([]),[S,E]=k.useState(null),[_,M]=k.useState(null),[P,R]=k.useState(null),[I,K]=k.useState({}),[Y,L]=k.useState(0),[F,ne]=k.useState([]),ee=k.useRef(null),G=k.useRef(null),[ae,H]=k.useState({top:0,left:0,width:448,maxHeight:576}),J=k.useRef(null),fe=k.useRef(!1),[Ce,$]=k.useState(!0),[V,pe]=k.useState(!1),z=k.useRef(null),je=k.useRef("approvals"),[Ue,qe]=k.useState(!1),[He,ut]=k.useState("unread"),dt=30,Nt=100,wt=k.useCallback(async()=>{try{li("/approvals"),li("/notifications");const[U,ge,Xe]=await Promise.all([Ae.notifications.list(t,!1,{limit:dt,offset:0}),Ae.approvals.list(),Ae.notifications.list(t,!0,{limit:Nt,offset:0})]);w(U.notifications),ne(Xe.notifications);const ye=U.unreadCount??U.notifications.filter(tt=>!tt.read).length;if(L(ye),$(U.totalCount!=null?U.notifications.length<U.totalCount:U.notifications.length>=dt),C(ge.approvals),!fe.current){const tt=ge.approvals.filter(ft=>ft.status==="pending").length;J.current=tt,fe.current=!0}}catch{}},[t]),Zt=k.useCallback(async()=>{if(!(V||!Ce)){pe(!0);try{const U=await Ae.notifications.list(t,!1,{limit:dt,offset:y.length});U.notifications.length>0&&w(ge=>[...ge,...U.notifications.filter(Xe=>!ge.some(ye=>ye.id===Xe.id))]),$(U.totalCount!=null?y.length+U.notifications.length<U.totalCount:U.notifications.length>=dt)}catch{}pe(!1)}},[t,y.length,V,Ce]),Wt=k.useCallback(U=>{const ge=U.detail;if(!ge)return;const{taskId:Xe,requirementId:ye}=ge;!Xe&&!ye||w(tt=>{const ft=tt.filter(bt=>!bt.read&&(Xe&&bt.metadata?.taskId===Xe||ye&&bt.metadata?.requirementId===ye));if(ft.length===0)return tt;for(const bt of ft)Ae.notifications.markRead(bt.id).catch(()=>{});L(bt=>Math.max(0,bt-ft.length));const Ht=new Set(ft.map(bt=>bt.id));return ne(bt=>bt.filter(le=>!Ht.has(le.id))),tt.map(bt=>ft.some(le=>le.id===bt.id)?{...bt,read:!0}:bt)})},[]),rt=k.useRef(y);rt.current=y;const $e=k.useCallback(async()=>{if(!rt.current.some(ge=>!ge.read&&ge.type==="system"&&ge.metadata?.creditExhausted))try{await Ae.notifications.create({title:m("credits.notificationTitle",{ns:"common"}),body:m("credits.notificationBody",{ns:"common"}),type:"system",priority:"urgent",metadata:{creditExhausted:!0}}),wt(),fh()}catch{}},[wt,m]),mt=k.useCallback(async()=>{if(!ph){ph=!0;try{const{updates:U}=await Ae.skills.updates();if(!U.length)return;const ge=sre(U);try{if(localStorage.getItem(ck)===ge)return}catch{}if(zd===ge||rt.current.some(ye=>!ye.read&&uk(ye,ge)))return;try{const tt=(await Ae.notifications.list(t,!0,{limit:50,type:"system"})).notifications.filter(ft=>uk(ft,ge)).sort((ft,Ht)=>new Date(Ht.createdAt).getTime()-new Date(ft.createdAt).getTime());if(tt.length>0){for(const ft of tt.slice(1))Ae.notifications.markRead(ft.id).catch(()=>{});tt.length>1&&wt(),zd=ge;return}}catch{}zd=ge,await Ae.notifications.create({title:m("templateUpdates.notificationTitle",{ns:"common"}),body:m("templateUpdates.notificationBody",{ns:"common",count:U.length}),type:"system",priority:"high",metadata:{templateUpdates:!0,templateUpdatesFingerprint:ge,count:U.length,skills:U.map(ye=>ye.name)}}),wt(),fh()}catch{zd=null}finally{ph=!1}}},[wt,m,t]);k.useEffect(()=>{wt();const U=setInterval(wt,6e4);let ge=null;const Xe=()=>{ge||(ge=setTimeout(()=>{ge=null,wt()},400))},ye=()=>Xe(),tt=()=>{h(!0),wt()};window.addEventListener("markus:notifications-changed",ye),window.addEventListener("markus:mark-read-by-ref",Wt),window.addEventListener("markus:open-notifications",tt),window.addEventListener("markus:credit-exhausted",$e);const ft=Ir.on("notification",Xe),Ht=Ir.on("approval:requested",Xe);return()=>{clearInterval(U),ge&&clearTimeout(ge),window.removeEventListener("markus:notifications-changed",ye),window.removeEventListener("markus:mark-read-by-ref",Wt),window.removeEventListener("markus:open-notifications",tt),window.removeEventListener("markus:credit-exhausted",$e),ft(),Ht()}},[wt,Wt,$e]),k.useEffect(()=>{mt();const U=setInterval(()=>{mt()},5*6e4),ge=()=>{mt()};return window.addEventListener("markus:data-changed",ge),()=>{clearInterval(U),window.removeEventListener("markus:data-changed",ge)}},[t]);const At=k.useCallback(()=>{if(!ee.current)return;const U=ee.current.getBoundingClientRect(),ge=window.innerWidth,Xe=window.innerHeight,ye=Math.min(448,ge-16),tt=Math.min(576,Xe-16);let ft=U.right+8,Ht=U.top;ft+ye>ge-8&&(ft=Math.max(8,ge-ye-8)),Ht+tt>Xe-8&&(Ht=Math.max(8,Xe-tt-8)),H({top:Ht,left:ft,width:ye,maxHeight:tt})},[]);k.useLayoutEffect(()=>{p&&At()},[p,At]),k.useEffect(()=>{if(p)return window.addEventListener("resize",At),()=>window.removeEventListener("resize",At)},[p,At]),k.useEffect(()=>{if(!p)return;const U=ge=>{ee.current?.contains(ge.target)||G.current?.contains(ge.target)||h(!1)};return document.addEventListener("mousedown",U),()=>document.removeEventListener("mousedown",U)},[p]),k.useEffect(()=>{if(!p)return;ut("unread");const U=T.some(Xe=>Xe.status==="pending"),ge=y.some(Xe=>!Xe.read);x(U&&!ge?"approvals":!U&&ge?"notifications":je.current)},[p]);const Dt=new Set(T.filter(U=>U.status==="pending").map(U=>U.id)),ln=new Set(T.map(U=>U.id)),ce=U=>U.type==="approval_request"&&!!U.metadata?.approvalId&&ln.has(U.metadata.approvalId),et=U=>[...U].sort((ge,Xe)=>new Date(Xe.createdAt).getTime()-new Date(ge.createdAt).getTime()),nt=y.filter(U=>!ce(U)),we=F.filter(U=>!ce(U)),Me=et(nt),Ne=et(we),se=He==="all"?Me:Ne,q=m(He==="unread"?"team:notifications.noUnread":"team:notifications.noNotifications"),te=Ne.length,Se=Dt.size,De=te+Se;k.useEffect(()=>{J.current!==null&&Se>J.current&&fh(),J.current=Se},[Se]);const Pe=async U=>{await Ae.notifications.markRead(U),w(ge=>ge.map(Xe=>Xe.id===U?{...Xe,read:!0}:Xe)),ne(ge=>ge.filter(Xe=>Xe.id!==U)),L(ge=>Math.max(0,ge-1)),window.dispatchEvent(new CustomEvent("markus:notifications-changed"))},Q=U=>{const ge=U.metadata??{},Xe=U.actionType,ye=U.actionTarget;if(Xe==="open_chat"&&ye)try{const tt=typeof ye=="string"?JSON.parse(ye):ye;if(tt.agentId){const ft={agentId:tt.agentId};tt.sessionId&&(ft.sessionId=tt.sessionId),at.navigate(de.TEAM,ft);return}}catch{}if(Xe==="navigate"&&ye)try{const tt=typeof ye=="string"?JSON.parse(ye):ye;if(tt.path){if(tt.path.startsWith("/team")){const ft={},Ht=new URLSearchParams(tt.path.split("?")[1]||"");for(const[bt,le]of Ht.entries())ft[bt]=le;at.navigate(de.TEAM,ft);return}if(tt.path.startsWith("/work")){const ft={},Ht=new URLSearchParams(tt.path.split("?")[1]||"");for(const[bt,le]of Ht.entries())ft[bt]=le;at.navigate(de.WORK,ft);return}}}catch{}switch(U.type){case"approval_request":{const tt=ge.approvalId,ft=tt?T.find(_e=>_e.id===tt):void 0;if(ft&&Od(ft)){M(ft);break}const Ht=ft?.details?.taskId??ge.taskId,bt=ft?.details?.requirementId??ge.requirementId,le=ft?.details?.agentId??ft?.agentId;Ht?at.navigate(de.WORK,{openTask:Ht}):bt?at.navigate(de.WORK,{openRequirement:bt}):le?at.navigate(de.TEAM,{agentId:le}):at.navigate(de.WORK);break}case"task_completed":case"task_created":case"task_review":case"task_failed":ge.taskId?at.navigate(de.WORK,{openTask:ge.taskId}):at.navigate(de.WORK);break;case"requirement_created":case"requirement_decision":ge.requirementId?at.navigate(de.WORK,{openRequirement:ge.requirementId}):at.navigate(de.WORK);break;case"agent_report":case"system":{if(ge.creditExhausted){qe(!0);return}if(ge.templateUpdates){const tt=ge.templateUpdatesFingerprint;if(tt)try{localStorage.setItem(ck,tt)}catch{}localStorage.setItem("markus_nav_storeTab","installed"),at.navigate(de.STORE);return}if(ge.agentId){const tt={agentId:ge.agentId};ge.sessionId&&(tt.sessionId=ge.sessionId),at.navigate(de.TEAM,tt)}else at.navigate(de.TEAM);break}case"direct_message":{const tt=ge.senderId;tt?at.navigate(de.TEAM,{dm:tt}):at.navigate(de.TEAM);break}case"group_message":{const tt=ge.channel;tt?at.navigate(de.TEAM,{channel:tt}):at.navigate(de.TEAM);break}default:ge.taskId?at.navigate(de.WORK,{openTask:ge.taskId}):ge.requirementId?at.navigate(de.WORK,{openRequirement:ge.requirementId}):ge.projectId?at.navigate(de.WORK,{projectId:ge.projectId}):ge.agentId&&at.navigate(de.TEAM,{agentId:ge.agentId});break}},X=async U=>{const ge=U.metadata??{},Xe=U.actionType,ye=U.type==="agent_report"&&!ge.creditExhausted&&!ge.templateUpdates&&(Xe==="open_chat"||!!ge.agentId&&Xe!=="navigate");!U.read&&!ye&&Pe(U.id);const tt=ge.taskId,ft=ge.requirementId;if(!ye&&(tt||ft)){const Ht=y.filter(bt=>bt.id!==U.id&&!bt.read&&(tt&&bt.metadata?.taskId===tt||ft&&bt.metadata?.requirementId===ft));for(const bt of Ht)Pe(bt.id)}Q(U)},ue=async(U,ge,Xe,ye,tt)=>{E(U);try{const{approval:ft}=await Ae.approvals.respond(U,ge,t,Xe,ye,tt);C(_e=>_e.map(ht=>ht.id===U?ft:ht)),M(null),R(null),K(_e=>{const ht={..._e};return delete ht[U],ht});const Ht=ft.details?.taskId,bt=ft.details?.requirementId,le=y.filter(_e=>!_e.read&&(_e.type==="approval_request"&&_e.metadata?.approvalId===U||Ht&&_e.metadata?.taskId===Ht||bt&&_e.metadata?.requirementId===bt));if(le.length>0){for(const ht of le)Ae.notifications.markRead(ht.id).catch(()=>{});const _e=new Set(le.map(ht=>ht.id));w(ht=>ht.map(Tt=>_e.has(Tt.id)?{...Tt,read:!0}:Tt)),L(ht=>Math.max(0,ht-le.length))}li("/approvals"),li("/notifications"),li("/tasks"),li("/taskboard"),li("/requirements"),window.dispatchEvent(new CustomEvent("markus:data-changed")),window.dispatchEvent(new CustomEvent("markus:notifications-changed")),setTimeout(()=>wt(),800)}catch{}E(null)},Be=async()=>{try{if(!t)return;await Ae.notifications.markAllRead(t),w(U=>U.map(ge=>({...ge,read:!0}))),ne([]),L(0),li("/notifications"),window.dispatchEvent(new CustomEvent("markus:notifications-changed"))}catch{const U=nt.filter(ge=>!ge.read);await Promise.all(U.map(ge=>Ae.notifications.markRead(ge.id))),w(ge=>ge.map(Xe=>({...Xe,read:!0}))),ne([]),L(0),li("/notifications"),window.dispatchEvent(new CustomEvent("markus:notifications-changed"))}},Ie=U=>{const ge=U.details?.subType;return ge==="requirement_resubmit"?m("team:notifications.approvalType.requirementResubmit"):ge==="requirement"||U.details?.requirementId?m("team:notifications.approvalType.requirement"):ge==="task_review"?m("team:notifications.approvalType.taskReview"):ge==="task"||U.details?.taskId?m("team:notifications.approvalType.task"):U.details?.toolName?m("team:notifications.approvalType.toolExecution"):null},Ge=U=>{const ge=U.details??{},Xe=ge.subType,ye=ge.priority,tt=ye?m(`common:priority.${ye}`,{defaultValue:ye}):"";if(Xe==="requirement")return m("team:notifications.approvalDesc.requirementProposed",{agentName:U.agentName,title:U.title,priority:tt,defaultValue:U.description});if(Xe==="requirement_resubmit")return m("team:notifications.approvalDesc.requirementResubmitted",{agentName:U.agentName,title:U.title,priority:tt,defaultValue:U.description});if(Xe==="task")return m("team:notifications.approvalDesc.taskCreate",{agentName:U.agentName,title:U.title,priority:tt,defaultValue:U.description});if(Xe==="task_review"){const ft=`Task "${U.title}" has been submitted for your review.`;if(U.description.startsWith(ft))return m("team:notifications.approvalDesc.taskReview",{title:U.title})+U.description.slice(ft.length)}return U.description},kt=U=>{const ge=[];ge.push(U.agentName);const Xe=U.details?.taskTitle,ye=U.details?.taskId;Xe?ge.push(Xe):ye&&ge.push(`${m("team:notifications.approvalType.task")} ${ye.slice(0,8)}`);const tt=U.details?.requirementId;return tt&&!ye&&ge.push(`${m("team:notifications.approvalType.requirement")} ${tt.slice(0,8)}`),ge.join(" · ")},Rt=[...T].sort((U,ge)=>new Date(ge.requestedAt).getTime()-new Date(U.requestedAt).getTime()),Mt=Rt.filter(U=>U.status==="pending"),Ot=Rt.filter(U=>U.status!=="pending"),Un=U=>{const ge=U.details?.taskId,Xe=U.details?.requirementId,ye=U.details?.agentId??U.agentId;ge?at.navigate(de.WORK,{openTask:ge}):Xe?at.navigate(de.WORK,{openRequirement:Xe}):ye?at.navigate(de.TEAM,{agentId:ye}):at.navigate(de.WORK)},hn=()=>{h(!1),a?.()},ie=U=>i.jsxs("button",{disabled:S===U.id,onClick:()=>M(U),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:[i.jsx("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:i.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"}),U.questions&&U.questions.length>1?` (${U.questions.length})`:""]}),Ee=_?i.jsx(ire,{approval:_,submitting:S===_.id,readOnly:_.status!=="pending",onClose:()=>M(null),onSubmit:U=>ue(_.id,U.approved,U.comment,U.selectedOption,U.answers)}):null,We=i.jsxs("div",{className:"flex items-center justify-between gap-2 px-3 py-1.5 border-b border-border-default/50 shrink-0",children:[i.jsx("div",{className:"flex items-center gap-0.5 rounded-md bg-surface-overlay/60 p-0.5",children:["unread","all"].map(U=>i.jsx("button",{onClick:()=>ut(U),"aria-pressed":He===U,title:U==="unread"?m("team:notifications.noUnread"):void 0,className:`px-2 py-0.5 rounded text-[10px] font-medium transition-colors ${He===U?"bg-surface-base text-fg-primary shadow-sm":"text-fg-tertiary hover:text-fg-secondary"}`,children:U==="unread"?m("team:notifications.filterUnread")+(te>0?` (${te})`:""):m("team:notifications.filterAll")},U))}),Y>0&&i.jsx("button",{onClick:Be,className:"text-[10px] text-brand-500 hover:text-brand-400 transition-colors shrink-0",children:m("team:notifications.markAllRead")})]}),pt=i.jsxs(i.Fragment,{children:[i.jsxs("div",{className:"flex border-b border-border-default shrink-0",children:[i.jsxs("button",{onClick:()=>{x("approvals"),je.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"),Se>0?` (${Se})`:""]}),i.jsxs("button",{onClick:()=>{x("notifications"),je.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"),te>0?` (${te})`:""]}),i.jsx("button",{onClick:hn,className:"px-2 py-2 text-fg-tertiary hover:text-fg-primary transition-colors shrink-0",title:m("common:close"),children:i.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[i.jsx("path",{d:"M18 6L6 18"}),i.jsx("path",{d:"M6 6l12 12"})]})})]}),g==="notifications"&&We,i.jsxs("div",{ref:z,className:"flex-1 overflow-y-auto",onScroll:U=>{if(g!=="notifications"||!Ce||V)return;const ge=U.currentTarget;ge.scrollTop+ge.clientHeight>=ge.scrollHeight-80&&Zt()},children:[g==="approvals"&&(T.length===0?i.jsx("div",{className:"p-6 text-center text-xs text-fg-tertiary",children:m("team:notifications.noApprovals")}):i.jsxs("div",{className:"divide-y divide-border-default/50",children:[Mt.map(U=>{const ge=U.details?.command,Xe=ge?Ge(U).replace(/\s*Command:.*$/,""):Ge(U);return i.jsxs("div",{className:"px-3 py-3 space-y-2.5",children:[i.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:()=>Un(U),children:[i.jsxs("div",{className:"flex items-start gap-2",children:[i.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:i.jsx("path",{d:Io.approval_request})}),i.jsxs("div",{className:"flex-1 min-w-0",children:[i.jsxs("div",{className:"flex items-center gap-2",children:[Ie(U)&&i.jsx("span",{className:"text-[10px] text-amber-500 font-medium shrink-0",children:Ie(U)}),i.jsx("span",{className:"text-xs text-fg-primary font-medium truncate",children:U.title}),i.jsx("span",{className:"text-[10px] text-fg-tertiary shrink-0",children:Oo(U.requestedAt,m)})]}),i.jsx("div",{className:"text-[11px] text-fg-tertiary mt-0.5",children:U.agentName})]})]}),i.jsx("div",{className:"mt-2.5 text-[11px] text-fg-secondary leading-relaxed",children:i.jsx(Ea,{content:Xe,className:"text-[11px] [&_h1]:text-xs [&_h2]:text-[11px] [&_h3]:text-[11px] [&_p]:text-[11px] [&_li]:text-[11px]"})}),ge&&i.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:ge})]}),(()=>{if(Od(U))return ie(U);const ye=U.details?.subType,tt=ye==="task"||ye==="requirement"||ye==="requirement_resubmit",ft=U.options&&U.options.length>0,Ht=(I[U.id]??"").trim();if(ft){const bt=le=>le.id==="approve"?m("common:approve",{defaultValue:le.label}):le.id==="reject"||le.id==="request_changes"?m("team:notifications.optionLabels.requestChanges",{defaultValue:le.label}):le.label;return i.jsxs("div",{className:"space-y-1.5",children:[U.options.map((le,_e)=>i.jsxs("button",{disabled:S===U.id,onClick:()=>ue(U.id,le.id!=="reject",Ht||void 0,le.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 ${le.id==="reject"||le.id==="request_changes"?"border border-border-default text-fg-secondary hover:bg-surface-overlay":"bg-brand-600 text-white hover:bg-brand-700"}`,title:le.description,children:[i.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+_e)}),bt(le)]},le.id)),i.jsxs("div",{className:"flex gap-1.5 mt-1",children:[i.jsx("input",{type:"text",placeholder:m("team:notifications.freeformPlaceholder"),value:I[U.id]??"",onChange:le=>K(_e=>({..._e,[U.id]:le.target.value})),onKeyDown:le=>{le.key==="Enter"&&(I[U.id]??"").trim()&&ue(U.id,!0,(I[U.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"}),i.jsx("button",{disabled:S===U.id||!(I[U.id]??"").trim(),onClick:()=>ue(U.id,!0,(I[U.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")})]})]})}return tt?i.jsxs("div",{className:"space-y-1.5",children:[i.jsxs("div",{className:"flex items-center gap-2",children:[i.jsxs("button",{disabled:S===U.id,onClick:()=>ue(U.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:[i.jsx("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round",children:i.jsx("path",{d:"M20 6L9 17l-5-5"})}),m("common:approve")]}),i.jsxs("button",{disabled:S===U.id,onClick:()=>ue(U.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:[i.jsxs("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round",children:[i.jsx("path",{d:"M18 6L6 18"}),i.jsx("path",{d:"M6 6l12 12"})]}),m("common:reject")]}),P!==U.id&&i.jsxs("button",{disabled:S===U.id,onClick:()=>R(U.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:[i.jsxs("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[i.jsx("path",{d:"M11 4H4a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2v-7"}),i.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")]})]}),P===U.id&&i.jsxs("div",{className:"space-y-1.5",children:[i.jsx("input",{type:"text",autoFocus:!0,placeholder:m("team:notifications.adjustmentPlaceholder"),value:I[U.id]??"",onChange:bt=>K(le=>({...le,[U.id]:bt.target.value})),onKeyDown:bt=>{bt.key==="Enter"&&(I[U.id]??"").trim()&&ue(U.id,!1,(I[U.id]??"").trim(),"needs_adjustment"),bt.key==="Escape"&&R(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"}),i.jsxs("div",{className:"flex gap-2",children:[i.jsx("button",{disabled:S===U.id||!(I[U.id]??"").trim(),onClick:()=>ue(U.id,!1,(I[U.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")}),i.jsx("button",{onClick:()=>R(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")})]})]})]}):i.jsxs("div",{className:"space-y-1.5",children:[i.jsx("input",{type:"text",placeholder:m("team:notifications.commentPlaceholder"),value:I[U.id]??"",onChange:bt=>K(le=>({...le,[U.id]:bt.target.value})),onKeyDown:bt=>{bt.key==="Enter"&&ue(U.id,!0,Ht||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"}),i.jsxs("div",{className:"flex gap-2",children:[i.jsx("button",{disabled:S===U.id,onClick:()=>ue(U.id,!0,Ht||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")}),i.jsx("button",{disabled:S===U.id,onClick:()=>ue(U.id,!1,Ht||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")})]})]})})()]},U.id)}),Ot.length>0&&i.jsxs(i.Fragment,{children:[Mt.length>0&&i.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")}),Ot.slice(0,50).map(U=>i.jsxs("button",{onClick:()=>Od(U)?M(U):Un(U),className:"w-full text-left px-3 py-2.5 hover:bg-surface-overlay/50 transition-colors group",children:[i.jsxs("div",{className:"flex items-center gap-2",children:[i.jsx("span",{className:`w-1.5 h-1.5 rounded-full shrink-0 ${U.status==="approved"?"bg-green-500":U.status==="cancelled"||U.status==="expired"?"bg-gray-400":"bg-red-500"}`}),Ie(U)&&i.jsx("span",{className:"text-[10px] text-fg-tertiary font-medium shrink-0",children:Ie(U)}),i.jsx("span",{className:"text-xs text-fg-secondary truncate flex-1 group-hover:text-fg-primary",children:U.title}),i.jsx("span",{className:`text-[10px] font-medium shrink-0 ${U.status==="approved"?"text-green-500":U.status==="cancelled"||U.status==="expired"?"text-fg-muted":"text-red-500"}`,children:m(`common:status.${U.status}`,{defaultValue:U.status})})]}),i.jsxs("div",{className:"flex items-center gap-1.5 mt-0.5 pl-3.5",children:[i.jsx("span",{className:"text-[10px] text-fg-muted truncate",children:kt(U)}),i.jsx("span",{className:"text-[10px] text-fg-muted shrink-0",children:"·"}),i.jsx("span",{className:"text-[10px] text-fg-muted shrink-0",children:Oo(U.respondedAt??U.requestedAt,m)})]}),U.responseComment&&i.jsxs("p",{className:"text-[10px] text-fg-muted mt-0.5 pl-3.5 truncate",children:["“",U.responseComment,"”"]})]},U.id))]})]})),g==="notifications"&&(se.length===0?i.jsx("div",{className:"p-6 text-center text-xs text-fg-tertiary",children:q}):i.jsxs("div",{className:"divide-y divide-border-default/50",children:[se.map(U=>{const ge=lk[U.type]??"text-fg-tertiary";return i.jsxs("div",{role:"button",tabIndex:0,onClick:()=>X(U),onKeyDown:Xe=>{(Xe.key==="Enter"||Xe.key===" ")&&(Xe.preventDefault(),X(U))},className:`w-full text-left px-3 py-2.5 flex gap-2.5 transition-colors cursor-pointer ${U.read?"opacity-50 hover:opacity-70":"hover:bg-surface-overlay"}`,children:[i.jsx("div",{className:"shrink-0 mt-0.5",children:i.jsx("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",className:ge,children:i.jsx("path",{d:Io[U.type]??Io.system})})}),i.jsxs("div",{className:"flex-1 min-w-0",children:[i.jsxs("div",{className:"flex items-center gap-1.5",children:[!U.read&&i.jsx("span",{className:`w-1.5 h-1.5 rounded-full shrink-0 ${Pd[U.priority]??Pd.normal}`}),i.jsx("span",{className:"text-xs text-fg-primary font-medium truncate",children:dk(U,m)})]}),i.jsx("div",{className:"text-[11px] text-fg-tertiary mt-0.5 ",children:i.jsx(Ea,{content:mk(U,m),className:"text-[11px] [&_h1]:text-xs [&_h2]:text-[11px] [&_h3]:text-[11px] [&_p]:text-[11px] [&_li]:text-[11px] [&_p]:text-fg-tertiary"})}),i.jsxs("div",{className:"flex items-center gap-2 mt-0.5",children:[i.jsx("span",{className:"text-[10px] text-fg-muted",children:Oo(U.createdAt,m)}),Bd(U,m)&&i.jsx("span",{className:`text-[10px] font-medium ${ge}`,children:Bd(U,m)})]})]})]},U.id)}),V&&i.jsx("div",{className:"py-3 text-center",children:i.jsxs("svg",{className:"animate-spin h-4 w-4 text-fg-tertiary mx-auto",viewBox:"0 0 24 24",fill:"none",children:[i.jsx("circle",{className:"opacity-25",cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"4"}),i.jsx("path",{className:"opacity-75",fill:"currentColor",d:"M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4z"})]})})]}))]})]}),Bt=k.useCallback(U=>{U?.mute&&Vae()},[]),Pt=k.useCallback(U=>{Bt(U),qe(!1)},[Bt]),it=Ue?i.jsx(ba,{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:()=>qe(!1),onCancelClick:U=>{Pt(U),at.navigate(de.SETTINGS),setTimeout(()=>{window.location.hash="settings/providers"},50)},onConfirm:U=>{const ge=`${st.getUrl().replace(/\/$/,"")}/settings?tab=billing`;Pt(U),fi(ge)}}):null;if(n){const U=["approvals","notifications"],ge=U.indexOf(g),Xe=(()=>{let ye=0,tt=0;return{onTouchStart:ft=>{ye=ft.touches[0].clientX,tt=ft.touches[0].clientY},onTouchEnd:ft=>{const Ht=ft.changedTouches[0].clientX-ye,bt=ft.changedTouches[0].clientY-tt;Math.abs(Ht)>60&&Math.abs(Ht)>Math.abs(bt)*1.5&&(Ht<0&&ge<U.length-1&&x(U[ge+1]),Ht>0&&ge>0&&x(U[ge-1]))}}})();return i.jsxs(i.Fragment,{children:[it,i.jsxs("div",{className:"flex flex-col h-full overflow-hidden",children:[Ee,i.jsx("div",{className:"flex border-b border-border-default shrink-0",children:U.map(ye=>i.jsx("button",{onClick:()=>x(ye),className:`flex-1 px-3 py-3 text-sm font-medium transition-colors ${g===ye?"text-fg-primary border-b-2 border-brand-500":"text-fg-tertiary"}`,children:ye==="approvals"?i.jsxs(i.Fragment,{children:[m("team:notifications.approvals"),Se>0?` (${Se})`:""]}):i.jsxs(i.Fragment,{children:[m("team:notifications.notifications"),te>0?` (${te})`:""]})},ye))}),g==="notifications"&&We,i.jsx("div",{className:"flex-1 overflow-hidden relative",...Xe,children:i.jsxs("div",{className:"flex h-full transition-transform duration-300 ease-out",style:{transform:`translateX(-${ge*100}%)`},children:[i.jsx("div",{className:"w-full shrink-0 h-full overflow-y-auto scrollbar-thin",children:T.length===0?i.jsx("div",{className:"p-6 text-center text-xs text-fg-tertiary",children:m("team:notifications.noApprovals")}):i.jsxs("div",{className:"divide-y divide-border-default/50",children:[Mt.map(ye=>{const tt=ye.details?.command,ft=tt?Ge(ye).replace(/\s*Command:.*$/,""):Ge(ye);return i.jsxs("div",{className:"px-3 py-3 space-y-2.5",children:[i.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:()=>Un(ye),children:[i.jsxs("div",{className:"flex items-start gap-2",children:[i.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:i.jsx("path",{d:Io.approval_request})}),i.jsxs("div",{className:"flex-1 min-w-0",children:[i.jsxs("div",{className:"flex items-center gap-2",children:[Ie(ye)&&i.jsx("span",{className:"text-[10px] text-amber-500 font-medium shrink-0",children:Ie(ye)}),i.jsx("span",{className:"text-xs text-fg-primary font-medium truncate",children:ye.title}),i.jsx("span",{className:"text-[10px] text-fg-tertiary shrink-0",children:Oo(ye.requestedAt,m)})]}),i.jsx("div",{className:"text-[11px] text-fg-tertiary mt-0.5",children:ye.agentName})]})]}),i.jsx("div",{className:"mt-2.5 text-[11px] text-fg-secondary leading-relaxed",children:i.jsx(Ea,{content:ft,className:"text-[11px] [&_h1]:text-xs [&_h2]:text-[11px] [&_h3]:text-[11px] [&_p]:text-[11px] [&_li]:text-[11px]"})}),tt&&i.jsx("pre",{className:"text-[11px] text-fg-primary bg-surface-overlay border border-border-default rounded-md px-2.5 py-2 overflow-x-auto whitespace-pre-wrap break-all font-mono leading-relaxed mt-2",children:tt})]}),(()=>{if(Od(ye))return ie(ye);const Ht=ye.details?.subType,bt=Ht==="task"||Ht==="requirement"||Ht==="requirement_resubmit",le=ye.options&&ye.options.length>0,_e=(I[ye.id]??"").trim();if(le){const ht=Tt=>Tt.id==="approve"?m("common:approve",{defaultValue:Tt.label}):Tt.id==="reject"||Tt.id==="request_changes"?m("team:notifications.optionLabels.requestChanges",{defaultValue:Tt.label}):Tt.label;return i.jsxs("div",{className:"space-y-1.5",children:[ye.options.map((Tt,Pn)=>i.jsxs("button",{disabled:S===ye.id,onClick:()=>ue(ye.id,Tt.id!=="reject",_e||void 0,Tt.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 ${Tt.id==="reject"||Tt.id==="request_changes"?"border border-border-default text-fg-secondary hover:bg-surface-overlay":"bg-brand-600 text-white hover:bg-brand-700"}`,title:Tt.description,children:[i.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+Pn)}),ht(Tt)]},Tt.id)),i.jsxs("div",{className:"flex gap-1.5 mt-1",children:[i.jsx("input",{type:"text",placeholder:m("team:notifications.freeformPlaceholder"),value:I[ye.id]??"",onChange:Tt=>K(Pn=>({...Pn,[ye.id]:Tt.target.value})),onKeyDown:Tt=>{Tt.key==="Enter"&&(I[ye.id]??"").trim()&&ue(ye.id,!0,(I[ye.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"}),i.jsx("button",{disabled:S===ye.id||!(I[ye.id]??"").trim(),onClick:()=>ue(ye.id,!0,(I[ye.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")})]})]})}return bt?i.jsxs("div",{className:"space-y-1.5",children:[i.jsxs("div",{className:"flex items-center gap-2",children:[i.jsxs("button",{disabled:S===ye.id,onClick:()=>ue(ye.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:[i.jsx("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round",children:i.jsx("path",{d:"M20 6L9 17l-5-5"})}),m("common:approve")]}),i.jsxs("button",{disabled:S===ye.id,onClick:()=>ue(ye.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:[i.jsxs("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round",children:[i.jsx("path",{d:"M18 6L6 18"}),i.jsx("path",{d:"M6 6l12 12"})]}),m("common:reject")]}),P!==ye.id&&i.jsxs("button",{disabled:S===ye.id,onClick:()=>R(ye.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:[i.jsxs("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[i.jsx("path",{d:"M11 4H4a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2v-7"}),i.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")]})]}),P===ye.id&&i.jsxs("div",{className:"space-y-1.5",children:[i.jsx("input",{type:"text",autoFocus:!0,placeholder:m("team:notifications.adjustmentPlaceholder"),value:I[ye.id]??"",onChange:ht=>K(Tt=>({...Tt,[ye.id]:ht.target.value})),onKeyDown:ht=>{ht.key==="Enter"&&(I[ye.id]??"").trim()&&ue(ye.id,!1,(I[ye.id]??"").trim(),"needs_adjustment"),ht.key==="Escape"&&R(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"}),i.jsxs("div",{className:"flex gap-2",children:[i.jsx("button",{disabled:S===ye.id||!(I[ye.id]??"").trim(),onClick:()=>ue(ye.id,!1,(I[ye.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")}),i.jsx("button",{onClick:()=>R(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")})]})]})]}):i.jsxs("div",{className:"space-y-1.5",children:[i.jsx("input",{type:"text",placeholder:m("team:notifications.commentPlaceholder"),value:I[ye.id]??"",onChange:ht=>K(Tt=>({...Tt,[ye.id]:ht.target.value})),onKeyDown:ht=>{ht.key==="Enter"&&ue(ye.id,!0,_e||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"}),i.jsxs("div",{className:"flex gap-2",children:[i.jsx("button",{disabled:S===ye.id,onClick:()=>ue(ye.id,!0,_e||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")}),i.jsx("button",{disabled:S===ye.id,onClick:()=>ue(ye.id,!1,_e||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")})]})]})})()]},ye.id)}),Ot.length>0&&i.jsxs(i.Fragment,{children:[Mt.length>0&&i.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")}),Ot.slice(0,50).map(ye=>i.jsxs("button",{onClick:()=>Un(ye),className:"w-full text-left px-3 py-2.5 hover:bg-surface-overlay/50 transition-colors",children:[i.jsxs("div",{className:"flex items-center gap-2",children:[i.jsx("span",{className:`w-1.5 h-1.5 rounded-full shrink-0 ${ye.status==="approved"?"bg-green-500":ye.status==="cancelled"||ye.status==="expired"?"bg-gray-400":"bg-red-500"}`}),i.jsx("span",{className:"text-xs text-fg-secondary truncate flex-1",children:ye.title}),i.jsx("span",{className:`text-[10px] font-medium shrink-0 ${ye.status==="approved"?"text-green-500":ye.status==="cancelled"||ye.status==="expired"?"text-fg-muted":"text-red-500"}`,children:m(`common:status.${ye.status}`,{defaultValue:ye.status})})]}),i.jsxs("div",{className:"flex items-center gap-1.5 mt-0.5 pl-3.5",children:[i.jsx("span",{className:"text-[10px] text-fg-muted truncate",children:kt(ye)}),i.jsx("span",{className:"text-[10px] text-fg-muted shrink-0",children:"·"}),i.jsx("span",{className:"text-[10px] text-fg-muted shrink-0",children:Oo(ye.respondedAt??ye.requestedAt,m)})]})]},ye.id))]})]})}),i.jsx("div",{className:"w-full shrink-0 h-full overflow-y-auto scrollbar-thin",children:se.length===0?i.jsx("div",{className:"p-6 text-center text-xs text-fg-tertiary",children:q}):i.jsx("div",{className:"divide-y divide-border-default/50",children:se.slice(0,He==="unread"?Nt:50).map(ye=>{const tt=lk[ye.type]??"text-fg-tertiary";return i.jsxs("button",{onClick:()=>X(ye),className:`w-full text-left px-3 py-2.5 flex gap-2.5 transition-colors ${ye.read?"opacity-50 hover:opacity-70":"hover:bg-surface-overlay"}`,children:[i.jsx("div",{className:"shrink-0 mt-0.5",children:i.jsx("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",className:tt,children:i.jsx("path",{d:Io[ye.type]??Io.system})})}),i.jsxs("div",{className:"flex-1 min-w-0",children:[i.jsxs("div",{className:"flex items-center gap-1.5",children:[!ye.read&&i.jsx("span",{className:`w-1.5 h-1.5 rounded-full shrink-0 ${Pd[ye.priority]??Pd.normal}`}),i.jsx("span",{className:"text-xs text-fg-primary font-medium truncate",children:dk(ye,m)})]}),i.jsx("div",{className:"text-[11px] text-fg-tertiary mt-0.5 ",children:i.jsx(Ea,{content:mk(ye,m),className:"text-[11px] [&_h1]:text-xs [&_h2]:text-[11px] [&_h3]:text-[11px] [&_p]:text-[11px] [&_li]:text-[11px] [&_p]:text-fg-tertiary"})}),i.jsxs("div",{className:"flex items-center gap-2 mt-0.5",children:[i.jsx("span",{className:"text-[10px] text-fg-muted",children:Oo(ye.createdAt,m)}),Bd(ye,m)&&i.jsx("span",{className:`text-[10px] font-medium ${tt}`,children:Bd(ye,m)})]})]})]},ye.id)})})})]})})]})]})}if(s){const U=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 i.jsxs(i.Fragment,{children:[Ee,i.jsxs("button",{ref:ee,onClick:()=>{h(!p),p||wt()},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 ${p||l?"bg-surface-overlay":"hover:bg-surface-overlay/60"}`,children:[i.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:i.jsx("path",{d:U})}),e?i.jsx("span",{className:"text-[9px] leading-tight truncate w-full text-center",children:c}):i.jsx("span",{className:"truncate",children:c}),De>0&&i.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:De>99?m("common:badgeOverLimit"):De})]}),p&&zr.createPortal(i.jsx("div",{ref:G,className:"fixed bg-surface-secondary border border-border-default rounded-xl shadow-2xl z-[9999] flex flex-col overflow-hidden",style:{top:ae.top,left:ae.left,width:ae.width,maxHeight:ae.maxHeight},children:pt}),document.body),it]})}return i.jsxs(i.Fragment,{children:[Ee,i.jsxs("button",{ref:ee,onClick:()=>{h(!p),p||wt()},className:`relative flex items-center justify-center rounded-md transition-colors ${e?"w-8 h-8":"w-7 h-7"} ${p?"bg-surface-overlay text-fg-primary":"text-fg-tertiary hover:text-fg-secondary hover:bg-surface-overlay"}`,title:m("team:notifications.bellTitle"),children:[i.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[i.jsx("path",{d:"M18 8A6 6 0 0 0 6 8c0 7-3 9-3 9h18s-3-2-3-9"}),i.jsx("path",{d:"M13.73 21a2 2 0 0 1-3.46 0"})]}),De>0&&i.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:De>99?m("common:badgeOverLimit"):De})]}),p&&zr.createPortal(i.jsx("div",{ref:G,className:"fixed bg-surface-secondary border border-border-default rounded-xl shadow-2xl z-[9999] flex flex-col overflow-hidden",style:{top:ae.top,left:ae.left,width:ae.width,maxHeight:ae.maxHeight},children:pt}),document.body),it]})}function Hd({d:e,size:t=14}){return i.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:i.jsx("path",{d:e})})}const hh=200;function lre({authUser:e,onLogout:t,onEditProfile:n,showSettingsLink:a=!1,collapsed:s=!1,showVersion:l=!1}){const{t:c}=ot(["nav","common"]),[d,m]=k.useState(!1),[p,h]=k.useState(!1),[g,x]=k.useState({top:0,left:0}),y=k.useRef(null),w=k.useRef(null),{connected:T,user:C,credits:S,refresh:E}=h4(d),_=k.useCallback(()=>{if(!y.current)return;const ne=y.current.getBoundingClientRect(),ee=window.innerWidth,G=window.innerHeight,ae=w.current?.offsetHeight??220;let H=ne.right+8;H+hh>ee-8&&(H=Math.max(8,ne.left-hh-8));let J=ne.top-ae-8;J<8&&(J=Math.min(ne.bottom+8,G-ae-8)),x({top:Math.max(8,J),left:H})},[]);k.useLayoutEffect(()=>{if(!d)return;_();const ne=requestAnimationFrame(()=>_());return()=>cancelAnimationFrame(ne)},[d,_,s]),k.useEffect(()=>{if(!d)return;const ne=G=>{const ae=G.target;y.current?.contains(ae)||w.current?.contains(ae)||m(!1)},ee=()=>_();return document.addEventListener("mousedown",ne),window.addEventListener("resize",ee),window.addEventListener("scroll",ee,!0),()=>{document.removeEventListener("mousedown",ne),window.removeEventListener("resize",ee),window.removeEventListener("scroll",ee,!0)}},[d,_]);const M=e?.name||C?.displayName||C?.username||c("common:userPlaceholder"),P=e?.email||C?.email||"",R=m4(e?.avatarUrl,C?.avatarUrl),I=T?"bg-emerald-500":"bg-fg-muted",K=T?C?.username?c("sidebar.hubConnectedAs",{username:C.username}):c("sidebar.hubConnected"):c("sidebar.hubDisconnected"),Y=!!(T&&C?.username&&e?.name&&C.username.toLowerCase()!==e.name.toLowerCase()&&C.email?.toLowerCase()!==e.email?.toLowerCase()),L=()=>{m(!1),E({validate:!0}),at.navigate(de.SETTINGS,{tab:"account"})},F=d&&zr.createPortal(i.jsxs("div",{ref:w,className:"fixed bg-surface-elevated border border-border-default rounded-xl shadow-xl z-[9999] overflow-hidden",style:{top:g.top,left:g.left,width:hh},children:[i.jsxs("div",{className:"px-3.5 py-3 border-b border-border-default flex items-start gap-2",children:[i.jsxs("div",{className:"min-w-0 flex-1",children:[i.jsx("div",{className:"text-sm font-medium text-fg-primary truncate",children:M}),P&&i.jsx("div",{className:"text-xs text-fg-tertiary mt-0.5 truncate",children:P}),S!==null&&i.jsxs("div",{className:"text-xs text-fg-secondary mt-0.5 flex items-center gap-1",children:[i.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:i.jsx("polyline",{points:"13 2 3 14 12 14 18 22 6 22 12 17"})}),i.jsxs("span",{className:"truncate",children:[c("common:creditBalance"),": ",S.remaining.toLocaleString()]})]})]}),n&&i.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:i.jsx(Hd,{d:"M12 20h9M16.5 3.5a2.12 2.12 0 0 1 3 3L7 19l-4 1 1-4Z",size:14})})]}),i.jsxs("button",{type:"button",onClick:L,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:[i.jsx("span",{className:`w-2 h-2 rounded-full shrink-0 ${I}`}),i.jsxs("span",{className:"min-w-0 flex-1",children:[i.jsx("span",{className:"text-xs text-fg-secondary block truncate",children:K}),Y&&C?.username&&i.jsx("span",{className:"text-[10px] text-amber-500/90 block truncate mt-0.5",children:c("sidebar.hubAccountMismatch",{username:C.username})})]}),i.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:i.jsx("path",{d:"m9 18 6-6-6-6"})})]}),i.jsxs("div",{className:"py-1",children:[a&&i.jsxs("button",{type:"button",onClick:()=>{m(!1),at.navigate(de.SETTINGS)},className:"w-full flex items-center gap-2.5 px-3.5 py-2 text-sm text-fg-secondary hover:bg-surface-overlay transition-colors",children:[i.jsx(Hd,{d:Cc[de.SETTINGS]}),c("settings")]}),window.markusDesktop&&i.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:[i.jsx(Hd,{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&&i.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:[i.jsx(Hd,{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 i.jsxs("div",{className:`relative ${s?"flex justify-center":"flex items-center justify-between gap-2 w-full"}`,children:[i.jsxs("button",{ref:y,type:"button",onClick:()=>m(ne=>!ne),title:M,className:`relative inline-flex items-center justify-center rounded-full transition-opacity hover:opacity-90 ${s?"p-0.5":""}`,children:[i.jsx(Zi,{name:M,avatarUrl:R,size:s?28:32,fallback:"icon"}),i.jsx("span",{className:`absolute bottom-0 right-0 w-2.5 h-2.5 rounded-full border-2 border-surface-secondary ${I}`,title:K})]}),l&&!s&&i.jsxs("span",{className:"text-[10px] text-fg-muted select-none shrink-0",children:["v","0.10.1"]}),F,p&&t&&i.jsx(ba,{title:c("common:signOutConfirmTitle"),message:c("common:signOutConfirmMessage"),confirmLabel:c("common:signOut"),variant:"primary",onConfirm:()=>{h(!1),t()},onCancel:()=>h(!1)})]})}function cre({d:e,size:t=18}){return i.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:i.jsx("path",{d:e})})}function ure({currentPage:e,onNavigate:t,authUser:n,collapsed:a,onToggleCollapse:s,onLogout:l,keyboardFocusPageId:c,keyboardPaneActive:d}){const{t:m}=ot(["nav","common"]);return i.jsxs("aside",{"data-keyboard-pane":"l0",className:"markus-app-sidebar h-dvh bg-surface-secondary flex flex-col shrink-0 overflow-hidden",children:[i.jsx("div",{"data-electron-drag":!0,className:`electron-mac-sidebar-header flex items-center ${a?"px-2 py-3.5 justify-center":"px-4 h-14 justify-between"}`,children:i.jsxs("button",{"data-no-drag":!0,onClick:s,title:m(a?"sidebar.expandSidebar":"sidebar.collapseSidebar"),className:"flex items-center gap-2.5 min-w-0 group",children:[i.jsx("img",{src:"/logo.png",alt:"Markus",className:"w-8 h-8 rounded-lg shrink-0"}),!a&&i.jsx("span",{className:"text-[15px] font-bold tracking-tight text-fg-primary whitespace-nowrap",children:"Markus"})]})}),i.jsx("nav",{className:`${a?"p-1":"px-3 py-2"} flex-1 overflow-y-auto scrollbar-thin`,children:JF.map((p,h)=>{const g=r4.filter(y=>y.section===p.key);if(g.length===0)return null;const x=m(`sections.${p.key}`);return i.jsx("div",{children:i.jsxs("div",{className:h>0?"mt-3":"",children:[!a&&x&&i.jsx("div",{className:"px-3 py-1.5 mb-1 text-[10px] font-semibold text-fg-muted uppercase tracking-[0.1em]",children:x}),a&&h>0&&i.jsx("div",{className:"my-3"}),g.map(y=>{if(y.id===de.NOTIFICATIONS)return i.jsx(ore,{sidebarMode:!0,collapsed:a,userId:n?.id,label:m(y.id),iconPath:Cc[y.id],isActive:e===y.id},y.id);const w=e===y.id,T=d&&c===y.id;return i.jsxs("button",{"data-l0-page-id":y.id,onClick:()=>t(y.id),title:a?m(y.id):void 0,className:`w-full flex items-center ${a?"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:[i.jsx(cre,{d:Cc[y.id]??"",size:a?16:18}),a?i.jsx("span",{className:"text-[9px] leading-tight truncate w-full text-center",children:m(y.id)}):i.jsx("span",{className:"truncate",children:m(y.id)})]},y.id)})]})},p.key)})}),i.jsx("div",{className:`shrink-0 border-t border-border-subtle ${a?"p-1.5 flex justify-center":"px-3 py-2.5"}`,children:i.jsx(lre,{authUser:n,onLogout:l,onEditProfile:()=>{window.dispatchEvent(new Event("markus:open-edit-profile"))},showSettingsLink:!1,collapsed:a,showVersion:!a})})]})}const dre=6e4,mre=2e3;let Ar={},Yi={};const xg=new Set,Rm=new Set;let JS=0;const vg=new Map;let yc=null,$d=0,nm=null;function Lc(){for(const e of xg)e()}function pk(e,t){const n=Object.keys(e);if(n.length!==Object.keys(t).length)return!1;for(const a of n)if(e[a]!==t[a])return!1;return!0}function pre(e,t){const n={},a=[];for(const[s,l]of Object.entries(e)){if(t.has(s)){l>0&&a.push(s);continue}n[s]=l}return{counts:n,staleActiveKeys:a}}function yb(e,t){const n=Date.now(),a=vg.get(e)??0;!t?.force&&n-a<mre||(vg.set(e,n),e in Ar&&(delete Ar[e],Lc()),Ae.unread.markRead(e,new Date().toISOString()).catch(()=>{}))}async function wg(){try{const e=await Ae.unread.getCounts(),{counts:t,staleActiveKeys:n}=pre(e.counts??{},Rm);Ar=t,Yi=e.sessionAgentMap??{},Lc();for(const a of n)yb(a)}catch{}}function fre(){yc||(wg(),yc=setInterval(wg,dre),nm=Ir.on("chat:unread_update",e=>{const t=e.payload?.conversationKey;if(t){if(Rm.has(t)){yb(t);return}Date.now()>JS&&(Ar[t]=(Ar[t]??0)+1,Lc())}}))}function hre(){yc&&(clearInterval(yc),yc=null),nm&&(nm(),nm=null)}function gre(e){const t=e?.enabled??!0,[n,a]=k.useState(Ar),[s,l]=k.useState(Yi),c=k.useCallback(async()=>{await wg()},[]),d=k.useCallback(async w=>{const T=new Date().toISOString();delete Ar[w],Lc();try{await Ae.unread.markRead(w,T)}catch{}},[]),m=k.useCallback(async()=>{Ar={},Lc();try{await Ae.unread.markAllRead()}catch{}},[]),p=k.useCallback(w=>{Rm.add(w)},[]),h=k.useCallback(w=>{Rm.delete(w),JS=Date.now()+150,vg.delete(w),yb(w,{force:!0})},[]);k.useEffect(()=>{if(!t)return;$d++,fre();let w=Yi;const T=()=>{a(C=>pk(C,Ar)?C:{...Ar}),w!==Yi&&(w=Yi,l(C=>pk(C,Yi)?C:{...Yi}))};return xg.add(T),a({...Ar}),l({...Yi}),()=>{xg.delete(T),$d--,$d<=0&&($d=0,hre())}},[t]);const g=k.useMemo(()=>Object.values(n).reduce((w,T)=>w+T,0),[n]),x=k.useCallback(w=>n[`session:${w}`]??0,[n]),y=k.useCallback(w=>n[`channel:${w}`]??0,[n]);return{counts:n,totalUnread:g,sessionAgentMap:s,getSessionUnread:x,getChannelUnread:y,markRead:d,markAllRead:m,refresh:c,setActiveKey:p,clearActiveKey:h}}function Rse(e,t){return k.useMemo(()=>{const n=new Map;for(const[a,s]of Object.entries(t))if(a.startsWith("session:")){const l=a.slice(8),c=e[l];c&&n.set(c,(n.get(c)??0)+s)}return n},[e,t])}function bre(e){return e.startsWith("channel:dm:a2a:")}function yre(e,t){let n=0;for(const[a,s]of Object.entries(e))if(a.startsWith("session:")){const l=a.slice(8);t[l]&&(n+=s)}else if(a.startsWith("channel:")){if(bre(a))continue;n+=s}return n}function xre({currentPage:e,onNavigate:t,userId:n}){const{t:a}=ot("nav"),[s,l]=k.useState(0),{counts:c,sessionAgentMap:d}=gre({enabled:!0}),m=k.useMemo(()=>yre(c,d),[c,d]),p=k.useCallback(async()=>{try{const h=await Ae.notifications.list(n,!1);l(h.unreadCount??h.notifications.filter(g=>!g.read).length)}catch{}},[n]);return k.useEffect(()=>{p();const h=setInterval(()=>{document.visibilityState==="visible"&&p()},3e4),g=()=>p();return window.addEventListener("markus:notifications-changed",g),()=>{clearInterval(h),window.removeEventListener("markus:notifications-changed",g)}},[p]),i.jsx("nav",{className:"fixed bottom-0 left-0 right-0 z-50 bg-surface-secondary flex items-stretch h-14 safe-area-bottom",children:eU.map(h=>{const g=h.group.includes(e),x=h.id===de.NOTIFICATIONS,y=h.id===de.TEAM;return i.jsxs("button",{onClick:()=>t(h.id),className:`flex-1 flex flex-col items-center justify-center gap-0.5 transition-colors ${g?"text-fg-primary":"text-fg-tertiary active:text-fg-secondary"}`,children:[i.jsxs("div",{className:"relative",children:[i.jsx("svg",{width:20,height:20,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:g?2:1.75,strokeLinecap:"round",strokeLinejoin:"round",className:"shrink-0",children:i.jsx("path",{d:Cc[h.id]})}),x&&s>0&&i.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:s>99?"99+":s}),y&&m>0&&i.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:m>99?"99+":m})]}),i.jsx("span",{className:`text-[10px] leading-tight ${g?"font-semibold":""}`,children:a(h.id)})]},h.id)})})}const Dm=new Map;function Ns(e,t){Dm.has(e)||Dm.set(e,t().catch(()=>{}))}function Ls(e){const t=Dm.get(e);return Dm.delete(e),t}const qa={builderArtifacts:"builder.artifacts",builderAgents:"builder.agents",builderHubMyItems:"builder.hubMyItems",builderInstalled:"builder.installed",hubAgents:"hub.agents",hubTeams:"hub.teams",hubSkills:"hub.skills"},Bs={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 il(e){const t=(e||"").toLowerCase();return t==="team"?"team":t==="skill"?"skill":t==="connector"||t==="mcp"?"connector":"agent"}function ZS(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 vre={agent:258,team:205,skill:32,connector:162};function xb(e,t){const n=vre[e],a=ZS(t),s=((n+(a%68-34))%360+360)%360,l=(s+22+(a>>>8)%24)%360;return`linear-gradient(${120+a%44}deg, hsl(${s} 72% 56%), hsl(${l} 66% 43%))`}const fk=["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 e6(e){return fk[ZS(e+"g")%fk.length]}function t6(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 wre(e){return!e||t6(e)?!1:[...e].length<=4&&new RegExp("\\p{Extended_Pictographic}","u").test(e)}function kre(e,t="user"){const n=t==="org"?"shapes":"thumbs",a=encodeURIComponent(e);return`https://api.dicebear.com/9.x/${n}/svg?seed=${a}&radius=50&backgroundType=gradientLinear`}function $o(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 hk(e,t="usd"){return!e||e<=0?"Free":`${t.toLowerCase()==="usd"?"$":""}${(e/100).toFixed(e%100===0?0:2)}`}const gk={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"}},Sre=["development","devops","management","productivity","browser","custom","general"],Cre=[{label:"Tech",emojis:["✦","◈","⬡","⚡","🤖","🧠","💡","🎯","🔧","📦","🚀","💻","🛠️","⭐","🔥","💎","⚙️","🧩","🔌","💾","🖥️","📡","🔬","🧪","🏗️","📱","🎮","🕹️","📟","💽","🖨️","⌨️"]},{label:"People",emojis:["👤","👥","🧑‍💻","👨‍💼","👩‍🔬","🧙","🦸","🤝","💪","🎓","👷","🕵️","🧑‍🎨","🧑‍🏫","👨‍🚀","🥷","🧑‍🏭","🧑‍⚕️","🧑‍🔧","🧑‍🍳","👨‍🎤","🦹","🧝","🧞","🧑‍✈️","💂","🤴","👸","🧛","🧟","🧜","🧚"]},{label:"Objects",emojis:["📝","📊","🗂️","📁","🔍","🔑","🌐","💬","🔒","🎨","📐","🗃️","📋","✏️","🖊️","📌","📎","🧲","🪝","🧰","🪜","🧬","🔭","💊","🩺","📕","📗","📘","📙","📓","🗒️","📰"]},{label:"Symbols",emojis:["❤️","🧡","💛","💚","💙","💜","🖤","🤍","♠️","♥️","♦️","♣️","🎵","🎶","💯","✅","❌","⭕","🔴","🟠","🟡","🟢","🔵","🟣","⚫","⚪","🟤","🔶","🔷","▶️","⏸️","⏹️"]},{label:"Nature",emojis:["🌟","🌈","🌊","🌿","🍀","🔮","💫","✨","🌙","☀️","🦋","🐉","🦊","🐺","🦅","🐙","🦁","🐯","🦄","🐲","🌸","🌺","🍄","🌵","🎄","🌴","🍁","🌻","🐝","🦎","🐍","🦈"]},{label:"Activity",emojis:["🎯","🏆","🥇","🎖️","🏅","🎪","🎭","🎬","🎤","🎧","🎼","🎹","🥁","🎸","🎺","🎻","⚽","🏀","🎾","🏐","🎲","🧸","🪁","🎰","🎳","🏹","🥊","🤺","⛷️","🏄","🚴","🧗"]}],Are={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 gh({value:e,onChange:t,renderAs:n="span",className:a,editClassName:s,placeholder:l,multiline:c,readOnly:d}){const[m,p]=k.useState(!1),[h,g]=k.useState(e),x=k.useRef(null);if(k.useEffect(()=>{g(e)},[e]),k.useEffect(()=>{m&&x.current?.focus()},[m]),d){const _=e||l,P=`${a??""} ${!e?"text-fg-muted italic":""}`;return n==="h1"?i.jsx("h1",{className:P,children:_}):n==="p"?i.jsx("p",{className:P,children:_}):i.jsx("span",{className:P,children:_})}const y=()=>{p(!1),h!==e&&t(h)},w=()=>{g(e),p(!1)},T=_=>{_.key==="Escape"&&w(),_.key==="Enter"&&!c&&y()};if(m){const _=`bg-transparent outline-none w-full ${s??a??""} ring-1 ring-brand-500/50 rounded px-1 -mx-1`;return c?i.jsx("textarea",{ref:x,value:h,onChange:M=>g(M.target.value),onBlur:y,onKeyDown:T,className:`${_} resize-y min-h-[60px]`,placeholder:l}):i.jsx("input",{ref:x,value:h,onChange:M=>g(M.target.value),onBlur:y,onKeyDown:T,className:_,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"?i.jsx("h1",{onClick:()=>p(!0),className:`${a??""} ${E} ${S?"text-fg-muted italic":""}`,children:C}):n==="p"?i.jsx("p",{onClick:()=>p(!0),className:`${a??""} ${E} ${S?"text-fg-muted italic":""}`,children:C}):n==="badge"?i.jsx("span",{onClick:()=>p(!0),className:`${a??""} ${E} ${S?"text-fg-muted italic":""}`,children:C}):i.jsx("span",{onClick:()=>p(!0),className:`${a??""} ${E} ${S?"text-fg-muted italic":""}`,children:C})}function Tre({value:e,options:t,onChange:n,className:a,readOnly:s}){const[l,c]=k.useState(!1),[d,m]=k.useState(e),p=k.useRef(null),h=k.useRef(null);if(k.useEffect(()=>{l&&(m(e),setTimeout(()=>p.current?.focus(),0))},[l,e]),s)return i.jsx("span",{className:a,children:e});const g=t.filter(y=>y.toLowerCase().includes(d.toLowerCase())),x=y=>{const w=y.trim();w&&w!==e&&n(w),c(!1)};return l?i.jsxs("div",{ref:h,className:"relative inline-block",children:[i.jsx("input",{ref:p,value:d,onChange:y=>m(y.target.value),onKeyDown:y=>{y.key==="Enter"?(y.preventDefault(),x(d)):y.key==="Escape"&&c(!1)},onBlur:y=>{h.current?.contains(y.relatedTarget)||x(d)},className:`${a??""} bg-transparent outline-none ring-1 ring-brand-500/50 rounded w-28`}),g.length>0&&i.jsx("div",{className:"absolute top-full left-0 mt-1 z-50 bg-surface-elevated border border-border-default rounded-lg shadow-xl py-1 min-w-[120px] max-h-40 overflow-y-auto",children:g.map(y=>i.jsx("button",{onMouseDown:w=>{w.preventDefault(),x(y)},className:`block w-full text-left px-3 py-1.5 text-xs hover:bg-surface-secondary/80 transition-colors ${y===e?"text-brand-400 font-medium":"text-fg-secondary"}`,children:y},y))})]}):i.jsx("span",{onClick:()=>c(!0),className:`${a??""} cursor-pointer hover:ring-1 hover:ring-border-default rounded px-1 -mx-1 transition-all`,children:e})}function Nre({tags:e,onChange:t,readOnly:n}){const{t:a}=ot(["builder"]),[s,l]=k.useState(!1),[c,d]=k.useState(""),m=k.useRef(null);if(k.useEffect(()=>{s&&m.current?.focus()},[s]),n)return i.jsx("div",{className:"flex flex-wrap items-center gap-1.5 min-h-[24px]",children:e.map(h=>i.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 p=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 s?i.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=>i.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,i.jsx("button",{onClick:()=>t(e.filter(g=>g!==h)),className:"text-fg-muted hover:text-red-500",children:"×"})]},h)),i.jsx("input",{ref:m,value:c,onChange:h=>d(h.target.value),onKeyDown:p,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:a("detail.typeTagAndEnter")})]}):i.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=>i.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)):i.jsx("span",{className:"text-[10px] text-fg-muted italic",children:a("detail.typeTagAndEnter")})})}function kg({content:e}){const t=[D5,I3,O3],n=[SS,[G3,{strict:"ignore"}],[cS,{detect:!0,ignoreMissing:!0}]],a=OS({}),s=k.useMemo(()=>{let l=ui(e,mS);return l=ui(l,hS),l},[e]);return i.jsx("div",{className:`prose prose-invert prose-sm max-w-none
870
870
  prose-headings:text-fg-primary prose-headings:font-semibold
871
871
  prose-p:text-fg-secondary prose-p:leading-relaxed
872
872
  prose-a:text-brand-400 prose-a:no-underline hover:prose-a:underline
@@ -879,4 +879,4 @@ await import("${new URL("/assets/pdf.worker.min-CHFwMXne.mjs",import.meta.url).t
879
879
 
880
880
  ${m("share.rejectedEncourage")}`})},className:"text-xs px-2 py-1.5 rounded-lg border border-red-500/30 text-red-400 hover:bg-red-500/10 transition-colors inline-flex items-center gap-1 cursor-pointer",title:m("share.rejectedTip"),children:[i.jsxs("svg",{className:"w-3 h-3",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[i.jsx("circle",{cx:"12",cy:"12",r:"10"}),i.jsx("line",{x1:"15",y1:"9",x2:"9",y2:"15"}),i.jsx("line",{x1:"9",y1:"9",x2:"15",y2:"15"})]}),m("share.rejected")]}),i.jsxs("button",{onClick:()=>{we({visibility:R.visibility})},disabled:K,className:"text-xs px-3 py-1.5 rounded-lg border border-brand-500/40 text-brand-400 hover:bg-brand-500/10 hover:border-brand-500/60 transition-colors disabled:opacity-50 inline-flex items-center gap-1",children:[i.jsxs("svg",{className:"w-3 h-3",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[i.jsx("polyline",{points:"23 4 23 10 17 10"}),i.jsx("polyline",{points:"1 20 1 14 7 14"}),i.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"})]}),m(K?"share.updating":"share.resubmit")]})]}),!R.moderationStatus&&R.pendingReview&&i.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:[i.jsxs("svg",{className:"w-3 h-3",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[i.jsx("circle",{cx:"12",cy:"12",r:"10"}),i.jsx("polyline",{points:"12 6 12 12 16 14"})]}),m("share.updateUnderReview")]}),X&&i.jsxs("a",{href:X,target:"_blank",rel:"noopener noreferrer",onClick:Ie=>{Go()&&(Ie.preventDefault(),fi(X))},className:`text-xs px-3 py-1.5 rounded-lg border transition-colors inline-flex items-center gap-1.5 ${R.visibility==="org"?"border-blue-500/30 text-blue-500 hover:text-blue-400 hover:border-blue-400/50":R.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:[R.visibility==="org"?i.jsxs("svg",{className:"w-3 h-3",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[i.jsx("path",{d:"M3 21h18"}),i.jsx("path",{d:"M9 8h1"}),i.jsx("path",{d:"M9 12h1"}),i.jsx("path",{d:"M9 16h1"}),i.jsx("path",{d:"M14 8h1"}),i.jsx("path",{d:"M14 12h1"}),i.jsx("path",{d:"M14 16h1"}),i.jsx("path",{d:"M5 21V5a2 2 0 0 1 2-2h10a2 2 0 0 1 2 2v16"})]}):R.visibility==="unlisted"?i.jsxs("svg",{className:"w-3 h-3",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[i.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"}),i.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"})]}):i.jsxs("svg",{className:"w-3 h-3",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[i.jsx("path",{d:"M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6"}),i.jsx("polyline",{points:"15 3 21 3 21 9"}),i.jsx("line",{x1:"10",y1:"14",x2:"21",y2:"3"})]}),R.visibility==="org"?m("visibility.sharedOrg"):R.visibility==="unlisted"?m("visibility.sharedUnlisted"):m("share.viewOnHub")]}),Be&&i.jsx("button",{onClick:()=>{we({visibility:R.visibility})},disabled:K,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:K?m("share.updating"):m("share.updateVersion",{version:ue})})]})})(),!s&&!R.shared&&i.jsx("button",{onClick:()=>J(!0),disabled:K,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(K?"share.sharing":"share.toHub")})]})]}),!s&&L&&!ne&&i.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:[i.jsx("span",{className:"text-xs text-amber-800 dark:text-amber-300",children:m("versionBump.contentModified")}),i.jsx("button",{onClick:()=>ee(!0),className:"text-xs px-3 py-1 rounded bg-amber-200 dark:bg-amber-500/20 text-amber-800 dark:text-amber-300 hover:bg-amber-300 dark:hover:bg-amber-500/30 transition-colors",children:m("versionBump.bumpVersion")})]}),!s&&ne&&i.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:[i.jsxs("div",{className:"flex items-center gap-3",children:[i.jsx("span",{className:"text-xs text-amber-800 dark:text-amber-300",children:m("versionBump.newVersion")}),i.jsx("input",{type:"text",defaultValue:(()=>{const Q=(ut||"1.0.0").split(".");return Q[2]=String(Number(Q[2]??0)+1),Q.join(".")})(),className:"text-xs px-2 py-1 rounded bg-surface-elevated border border-border-default text-fg-primary w-24 font-mono",onKeyDown:Q=>{Q.key==="Enter"&&et("version",Q.target.value)}}),i.jsx("button",{onClick:Q=>{const X=Q.target.parentElement?.querySelector("input");X&&et("version",X.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")}),i.jsx("button",{onClick:()=>ee(!1),className:"text-xs text-fg-tertiary hover:text-fg-secondary",children:m("common:cancel")})]}),R.shared&&i.jsx("p",{className:"text-[10px] text-fg-tertiary mt-2",children:"After bumping the version, you can share the new version to Hub."})]}),i.jsxs("div",{className:`flex gap-8 ${p?"flex-col":""}`,children:[i.jsxs("div",{className:`${p?"w-full":"flex-1 min-w-0"}`,children:[i.jsxs("div",{className:"flex items-start gap-4 mb-6",children:[i.jsxs("div",{className:"relative",children:[i.jsx("div",{onClick:()=>!s&&Ce(!fe),className:`w-16 h-16 rounded-xl ${se.bg} flex items-center justify-center text-3xl shrink-0 ${s?"":"cursor-pointer hover:ring-2"} ${se.ring} transition-all overflow-hidden`,children:rt&&rt.startsWith("images/")?i.jsx("img",{src:`/api/builder/artifacts/${e}s/${encodeURIComponent(x)}/images/${encodeURIComponent(rt.replace("images/",""))}?v=${pe}`,alt:"",className:"w-full h-full object-cover"}):rt&&(rt.startsWith("http")||rt.startsWith("/"))?i.jsx("img",{src:rt,alt:"",className:"w-full h-full object-cover"}):(()=>{const Q=rt||"";if(Q&&[...Q].length<=2&&new RegExp("\\p{Emoji}","u").test(Q))return Q;const ue=Bs[il(e)].accent;return i.jsx("svg",{width:"36",height:"36",viewBox:"0 0 24 24",fill:"none","aria-hidden":!0,children:i.jsx("path",{d:e6(je||t||e),fill:ue})})})()}),!s&&fe&&i.jsxs(i.Fragment,{children:[i.jsx("div",{className:"fixed inset-0 z-40",onClick:()=>Ce(!1)}),i.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:[i.jsxs("div",{className:"flex items-center gap-2 mb-3",children:[i.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:rt,onKeyDown:Q=>{Q.key==="Enter"&&(et("icon",Q.target.value),Ce(!1))}}),i.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"),i.jsx("input",{type:"file",accept:"image/*",className:"hidden",onChange:async Q=>{const X=Q.target.files?.[0];if(!X)return;const ue=new FormData;ue.append("image",X);try{const Be=await fetch(`/api/builder/artifacts/${e}s/${encodeURIComponent(x)}/images`,{method:"POST",body:ue,credentials:"include"});if(Be.ok){const Ge=(await Be.json()).path;if($e(Ge),Ce(!1),C){const kt={...C,icon:Ge};S(kt),await Ae.builder.artifacts.save(e,kt)}F(!0)}}catch{}}})]}),rt&&i.jsx("button",{onClick:()=>{et("icon",""),Ce(!1)},className:"text-[10px] text-fg-tertiary hover:text-red-400 px-1",children:"✕"})]}),i.jsx("div",{className:"max-h-64 overflow-y-auto",children:Cre.map(Q=>i.jsxs("div",{className:"mb-2.5",children:[i.jsx("div",{className:"text-[10px] text-fg-tertiary mb-1 sticky top-0 bg-surface-secondary py-0.5",children:Q.label}),i.jsx("div",{className:"flex flex-wrap gap-0.5",children:Q.emojis.map(X=>i.jsx("button",{onClick:()=>{et("icon",X),Ce(!1)},className:`w-7 h-7 rounded flex items-center justify-center text-base hover:bg-surface-elevated transition-colors ${rt===X?"ring-1.5 ring-brand-500 bg-brand-500/10":""}`,children:X},X))})]},Q.label))})]})]})]}),i.jsxs("div",{className:"flex-1 min-w-0",children:[i.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[i.jsx(gh,{value:je,onChange:Q=>et("displayName",Q),renderAs:"h1",className:"text-xl font-bold text-fg-primary",placeholder:m("detail.untitled"),readOnly:s}),i.jsx("span",{className:`text-[10px] font-medium uppercase tracking-wider px-2 py-0.5 rounded-full ${se.bg} ${se.color}`,children:se.label}),i.jsx(gh,{value:ut,onChange:Q=>et("version",Q),renderAs:"badge",className:"text-[10px] px-2 py-0.5 rounded-full bg-surface-elevated text-fg-tertiary border border-border-default font-mono",placeholder:"1.0.0",readOnly:s})]}),i.jsx(gh,{value:qe,onChange:Q=>et("description",Q),renderAs:"p",className:"text-sm text-fg-secondary mt-1.5 leading-relaxed",placeholder:m("detail.addDescription"),multiline:!0,readOnly:s}),i.jsxs("div",{className:"flex items-center gap-2 mt-2 flex-wrap",children:[i.jsx(Tre,{value:Nt,options:Sre,onChange:Q=>et("category",Q),className:"text-xs px-2 py-0.5 rounded bg-surface-elevated text-fg-tertiary",readOnly:s}),i.jsx(Nre,{tags:Zt,onChange:Q=>et("tags",Q),readOnly:s})]})]})]}),i.jsx("div",{className:"mb-8",children:i.jsx(jre,{images:q,artifactType:e,artifactName:t,onUpload:Me,onRemove:Ne,readOnly:s,cacheBust:pe})}),d&&i.jsx("div",{className:"mb-8",children:d}),e==="team"&&C.team&&i.jsx("div",{className:"mb-8",children:i.jsx(Mre,{members:C.team.members,teamTopFiles:De,files:w,artifactName:x,onFileSave:nt,readOnly:s})}),e==="agent"&&Se.length>0&&i.jsxs("div",{className:"mb-8",children:[i.jsx("h2",{className:"text-sm font-semibold text-fg-primary mb-4 uppercase tracking-wider",children:"About This Agent"}),i.jsx(Lm,{noHeader:!0,files:Se,onSave:nt,readOnly:s})]}),e==="skill"&&i.jsxs("div",{className:"mb-8",children:[C.skill?.requiredPermissions&&C.skill.requiredPermissions.length>0&&i.jsxs("div",{className:"mb-6",children:[i.jsx("h2",{className:"text-sm font-semibold text-fg-primary mb-3 uppercase tracking-wider",children:m("sidebar.permissions")}),i.jsx("div",{className:"flex flex-wrap gap-2",children:C.skill.requiredPermissions.map(Q=>{const X=Are[Q];return i.jsxs("span",{className:`inline-flex items-center gap-1.5 text-xs px-3 py-1.5 rounded-lg border font-medium ${X?.color??"bg-surface-elevated text-fg-secondary border-border-default"}`,children:[i.jsx("span",{className:"font-mono text-[10px]",children:X?.icon??"?"})," ",Q]},Q)})})]}),C.skill?.mcpServers&&Object.keys(C.skill.mcpServers).length>0&&i.jsxs("div",{className:"mb-6",children:[i.jsx("h2",{className:"text-sm font-semibold text-fg-primary mb-3 uppercase tracking-wider",children:"Integrations"}),i.jsx("div",{className:"grid gap-2",children:Object.entries(C.skill.mcpServers).map(([Q,X])=>i.jsxs("div",{className:"rounded-lg border border-border-default bg-surface-secondary/40 px-4 py-3 flex items-center gap-3",children:[i.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:"◎"}),i.jsxs("div",{children:[i.jsx("div",{className:"text-xs font-medium text-fg-primary",children:Q}),i.jsx("div",{className:"text-[10px] text-fg-muted font-mono truncate",children:typeof X=="object"?JSON.stringify(X).slice(0,80):String(X)})]})]},Q))})]}),te&&i.jsxs("div",{children:[i.jsx("h2",{className:"text-sm font-semibold text-fg-primary mb-3 uppercase tracking-wider",children:"Instructions"}),i.jsx("div",{className:"rounded-xl border border-border-default bg-surface-secondary/40 p-5",children:i.jsx(kg,{content:te})})]})]}),Pe.length>0&&i.jsx(Lm,{files:Pe,onSave:nt,readOnly:s})]}),i.jsx("div",{className:`${p?"w-full":"w-72 shrink-0"}`,children:i.jsxs("div",{className:`${p?"":"sticky top-6"} space-y-4`,children:[i.jsxs("div",{className:"rounded-xl border border-border-default bg-surface-secondary/60 p-4 space-y-3",children:[i.jsx("div",{className:"text-xs font-medium text-fg-tertiary uppercase tracking-wider",children:m("sidebar.info")}),i.jsxs("div",{className:"space-y-2 text-xs",children:[i.jsxs("div",{className:"flex justify-between",children:[i.jsx("span",{className:"text-fg-muted",children:m("sidebar.type")}),i.jsx("span",{className:`font-medium ${se.color}`,children:se.label})]}),i.jsxs("div",{className:"flex justify-between",children:[i.jsx("span",{className:"text-fg-muted",children:m("sidebar.category")}),i.jsx("span",{className:"text-fg-secondary",children:Nt})]}),i.jsxs("div",{className:"flex justify-between",children:[i.jsx("span",{className:"text-fg-muted",children:m("sidebar.version")}),i.jsx("span",{className:"text-fg-secondary font-mono",children:ut})]}),C.author&&i.jsxs("div",{className:"flex justify-between",children:[i.jsx("span",{className:"text-fg-muted",children:m("sidebar.author")}),i.jsx("span",{className:"text-fg-secondary",children:typeof C.author=="string"?C.author:C.author?.name??""})]})]})]}),e==="agent"&&C.agent&&i.jsxs("div",{className:"rounded-xl border border-border-default bg-surface-secondary/60 p-4 space-y-3",children:[i.jsx("div",{className:"text-xs font-medium text-fg-tertiary uppercase tracking-wider",children:m("sidebar.agentSpecs")}),i.jsxs("div",{className:"space-y-2 text-xs",children:[C.agent.roleName&&i.jsxs("div",{className:"flex justify-between",children:[i.jsx("span",{className:"text-fg-muted",children:m("sidebar.role")}),i.jsx("span",{className:"text-fg-secondary",children:C.agent.roleName})]}),C.agent.llmProvider&&i.jsxs("div",{className:"flex justify-between",children:[i.jsx("span",{className:"text-fg-muted",children:m("sidebar.provider")}),i.jsx("span",{className:"text-fg-secondary",children:C.agent.llmProvider})]}),C.agent.llmModel&&i.jsxs("div",{className:"flex justify-between",children:[i.jsx("span",{className:"text-fg-muted",children:m("sidebar.model")}),i.jsx("span",{className:"text-fg-secondary font-mono",children:C.agent.llmModel})]}),C.agent.temperature!==void 0&&i.jsxs("div",{className:"flex justify-between",children:[i.jsx("span",{className:"text-fg-muted",children:m("sidebar.temperature")}),i.jsx("span",{className:"text-fg-secondary",children:C.agent.temperature})]})]})]}),e==="team"&&C.team&&i.jsxs("div",{className:"rounded-xl border border-border-default bg-surface-secondary/60 p-4 space-y-3",children:[i.jsx("div",{className:"text-xs font-medium text-fg-tertiary uppercase tracking-wider",children:m("sidebar.composition")}),i.jsxs("div",{className:"space-y-2 text-xs",children:[i.jsxs("div",{className:"flex justify-between",children:[i.jsx("span",{className:"text-fg-muted",children:m("sidebar.totalMembers")}),i.jsx("span",{className:"text-fg-secondary",children:C.team.members.reduce((Q,X)=>Q+X.count,0)})]}),i.jsxs("div",{className:"flex justify-between",children:[i.jsx("span",{className:"text-fg-muted",children:m("sidebar.managers")}),i.jsx("span",{className:"text-amber-400",children:C.team.members.filter(Q=>Q.role==="manager").reduce((Q,X)=>Q+X.count,0)})]}),i.jsxs("div",{className:"flex justify-between",children:[i.jsx("span",{className:"text-fg-muted",children:m("sidebar.workers")}),i.jsx("span",{className:"text-blue-400",children:C.team.members.filter(Q=>Q.role!=="manager").reduce((Q,X)=>Q+X.count,0)})]})]})]}),e==="skill"&&C.skill&&i.jsxs("div",{className:"rounded-xl border border-border-default bg-surface-secondary/60 p-4 space-y-3",children:[i.jsx("div",{className:"text-xs font-medium text-fg-tertiary uppercase tracking-wider",children:m("sidebar.skillInfo")}),i.jsxs("div",{className:"space-y-2 text-xs",children:[C.skill.alwaysOn!==void 0&&i.jsxs("div",{className:"flex justify-between",children:[i.jsx("span",{className:"text-fg-muted",children:m("sidebar.alwaysOn")}),i.jsx("span",{className:C.skill.alwaysOn?"text-green-400":"text-fg-secondary",children:C.skill.alwaysOn?m("sidebar.yes"):m("sidebar.no")})]}),i.jsxs("div",{className:"flex justify-between",children:[i.jsx("span",{className:"text-fg-muted",children:m("sidebar.skillFile")}),i.jsx("span",{className:"text-fg-secondary font-mono truncate ml-2",children:C.skill.skillFile})]}),C.skill.requiredPermissions&&C.skill.requiredPermissions.length>0&&i.jsxs("div",{children:[i.jsx("span",{className:"text-fg-muted",children:m("sidebar.permissions")}),i.jsx("div",{className:"flex flex-wrap gap-1 mt-1",children:C.skill.requiredPermissions.map(Q=>i.jsx("span",{className:"text-[10px] px-1.5 py-0.5 bg-surface-elevated text-fg-muted rounded border border-border-default",children:Q},Q))})]})]})]}),C.dependencies&&(C.dependencies.skills?.length||C.dependencies.env?.length)?i.jsxs("div",{className:"rounded-xl border border-border-default bg-surface-secondary/60 p-4 space-y-3",children:[i.jsx("div",{className:"text-xs font-medium text-fg-tertiary uppercase tracking-wider",children:m("sidebar.dependencies")}),C.dependencies.skills?.length?i.jsxs("div",{children:[i.jsx("div",{className:"text-[10px] text-fg-muted mb-1",children:m("sidebar.skills")}),i.jsx("div",{className:"flex flex-wrap gap-1",children:C.dependencies.skills.map(Q=>i.jsx("span",{className:"text-[10px] px-2 py-0.5 bg-surface-elevated text-fg-secondary rounded border border-border-default",children:Q},Q))})]}):null,C.dependencies.env?.length?i.jsxs("div",{children:[i.jsx("div",{className:"text-[10px] text-fg-muted mb-1",children:m("sidebar.environment")}),i.jsx("div",{className:"flex flex-wrap gap-1",children:C.dependencies.env.map(Q=>i.jsx("span",{className:"text-[10px] px-2 py-0.5 bg-surface-elevated text-fg-secondary rounded font-mono border border-border-default",children:Q},Q))})]}):null]}):null,!s&&E&&i.jsxs("button",{onClick:()=>Ae.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:[i.jsx("span",{className:"text-fg-tertiary block mb-0.5",children:m("sidebar.openInFinder")}),E.replace(/.*\.markus\//,"~/.markus/")]})]})})]})]}),!s&&G&&i.jsx(Rre,{onClose:()=>ae(!1),onConfirm:(Q,X)=>{ae(!1),we({donationsEnabled:!1,priceCents:Q==="paid"?X:void 0})},isUpdate:R.shared}),!s&&H&&i.jsx(_re,{onClose:()=>J(!1),onConfirm:(Q,X,ue,Be)=>{J(!1),we({visibility:Q,orgId:X,priceCents:ue,donationsEnabled:Be})}}),$&&i.jsx(ba,{alertOnly:!0,variant:$.variant??"primary",title:$.title,message:$.message,onConfirm:()=>V(null),onCancel:()=>V(null)})]}):i.jsx("div",{className:"flex-1 overflow-y-auto",children:i.jsxs("div",{className:"px-6 py-8",children:[i.jsxs("button",{onClick:n,className:"text-xs text-brand-400 hover:text-brand-300 mb-4 inline-flex items-center gap-1",children:[i.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:i.jsx("polyline",{points:"15 18 9 12 15 6"})}),m("detail.backToBuilder")]}),i.jsx("div",{className:"text-fg-tertiary text-sm py-20 text-center",children:m("detail.notFound")})]})})}function _re({onClose:e,onConfirm:t}){const{t:n}=ot(["builder","common"]),[a,s]=k.useState("public"),[l,c]=k.useState([]),[d,m]=k.useState(""),[p,h]=k.useState(!1),[g,x]=k.useState(0),[y,w]=k.useState(!1);k.useEffect(()=>{a==="org"&&l.length===0&&(h(!0),st.myOrgs().then(S=>{c(S.memberships),S.memberships.length>0&&m(S.memberships[0].id)}).catch(()=>{}).finally(()=>h(!1)))},[a,l.length]);const T=a==="public"||a==="unlisted",C=[{value:"public",icon:i.jsxs("svg",{className:"w-4 h-4",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[i.jsx("circle",{cx:"12",cy:"12",r:"10"}),i.jsx("line",{x1:"2",y1:"12",x2:"22",y2:"12"}),i.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:i.jsxs("svg",{className:"w-4 h-4",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[i.jsx("path",{d:"M3 21h18"}),i.jsx("path",{d:"M9 8h1"}),i.jsx("path",{d:"M9 12h1"}),i.jsx("path",{d:"M9 16h1"}),i.jsx("path",{d:"M14 8h1"}),i.jsx("path",{d:"M14 12h1"}),i.jsx("path",{d:"M14 16h1"}),i.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:i.jsxs("svg",{className:"w-4 h-4",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[i.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"}),i.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 i.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/60 backdrop-blur-sm",onClick:e,children:i.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:[i.jsx("h3",{className:"text-base font-semibold text-fg-primary mb-1",children:n("visibility.label")}),i.jsx("p",{className:"text-[11px] text-fg-tertiary mb-4 leading-relaxed",children:n("visibility.subtitle")}),i.jsxs("div",{className:"text-[10px] uppercase tracking-wider text-fg-tertiary font-semibold mb-2",children:["1 · ",n("visibility.public")," / ",n("visibility.org")]}),i.jsx("div",{className:"space-y-2 mb-5",children:C.map(S=>i.jsxs("label",{className:`flex items-center gap-3 p-3 rounded-lg border cursor-pointer transition-colors ${a===S.value?"border-brand-500 bg-brand-500/10":"border-border-default hover:border-gray-600"}`,children:[i.jsx("input",{type:"radio",name:"visibility",checked:a===S.value,onChange:()=>s(S.value),className:"accent-brand-500"}),i.jsx("div",{className:"flex items-center gap-2 text-fg-secondary",children:S.icon}),i.jsxs("div",{children:[i.jsx("div",{className:"text-sm font-medium text-fg-primary",children:S.label}),i.jsx("div",{className:"text-[11px] text-fg-tertiary",children:S.desc})]})]},S.value))}),a==="org"&&i.jsxs("div",{className:"mb-5",children:[i.jsx("label",{className:"text-xs text-fg-secondary block mb-1.5",children:n("visibility.orgSelect")}),p?i.jsx("div",{className:"text-xs text-fg-tertiary py-2",children:"Loading..."}):l.length===0?i.jsx("div",{className:"text-xs text-fg-tertiary py-2",children:n("visibility.orgNone")}):i.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=>i.jsx("option",{value:S.id,children:S.name},S.id))})]}),T&&i.jsxs("div",{className:"mb-5",children:[i.jsxs("div",{className:"text-[10px] uppercase tracking-wider text-fg-tertiary font-semibold mb-2",children:["2 · ",n("pricing.label")]}),i.jsx("label",{className:"text-xs text-fg-secondary block mb-1.5",children:n("pricing.label")}),i.jsx("div",{className:"grid grid-cols-4 gap-2 mb-3",children:n6.map(S=>i.jsx("button",{type:"button",onClick:()=>x(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))}),i.jsxs("label",{className:"flex items-center gap-2 cursor-pointer",children:[i.jsx("input",{type:"checkbox",checked:y,onChange:S=>w(S.target.checked),className:"accent-brand-500"}),i.jsx("span",{className:"text-xs text-fg-secondary",children:n("pricing.enableTips")})]})]}),T&&i.jsx("div",{className:"mb-4 text-[11px] text-fg-tertiary rounded-lg border border-border-default px-3 py-2",children:n("pricing.reviewNote")}),i.jsxs("div",{className:"flex gap-3",children:[i.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")}),i.jsx("button",{onClick:()=>t(a,a==="org"?d:void 0,T&&g>0?g:void 0,T?y:void 0),disabled:a==="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 n6=[{cents:0,label:"Free"},{cents:100,label:"$1"},{cents:500,label:"$5"},{cents:1e3,label:"$10"}];function Rre({onClose:e,onConfirm:t,isUpdate:n}){const{t:a}=ot(["builder","common"]),[s,l]=k.useState(0);return i.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/60 backdrop-blur-sm",onClick:e,children:i.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:[i.jsx("h3",{className:"text-base font-semibold text-fg-primary mb-4",children:a(n?"shareMode.titleUpdate":"share.toHub")}),i.jsx("div",{className:"space-y-2 mb-5",children:n6.map(c=>i.jsxs("label",{className:`flex items-center gap-3 p-3 rounded-lg border cursor-pointer transition-colors ${s===c.cents?"border-brand-500 bg-brand-500/10":"border-border-default hover:border-gray-600"}`,children:[i.jsx("input",{type:"radio",name:"sharePrice",checked:s===c.cents,onChange:()=>l(c.cents),className:"accent-brand-500"}),i.jsxs("div",{children:[i.jsx("div",{className:"text-sm font-medium text-fg-primary",children:c.label}),i.jsx("div",{className:"text-[11px] text-fg-tertiary",children:c.cents===0?a("shareMode.freeDesc"):a("shareMode.paidDesc")})]})]},c.cents))}),i.jsxs("div",{className:"flex gap-3",children:[i.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:a("common:cancel")}),i.jsx("button",{onClick:()=>t(s>0?"paid":"free",s),className:"flex-1 text-sm px-4 py-2 rounded-lg bg-brand-600 hover:bg-brand-500 text-white transition-colors",children:a(n?"shareMode.update":"shareMode.share")})]})]})})}function Im(e,t){return!e||!t6(e)?null:e.startsWith("http")||e.startsWith("data:")?e:e.startsWith("/")&&t?`${t}${e}`:e}function Dre({type:e,seed:t,icon:n,hubBase:a,size:s=44,className:l="",rounded:c="rounded-xl"}){const d=il(e),m=Im(n,a),p=k.useMemo(()=>xb(d,t),[d,t]),h=k.useMemo(()=>e6(t),[t]),[g,x]=k.useState(!1);return m&&!g?i.jsx("img",{src:m,alt:"",onError:()=>x(!0),style:{width:s,height:s},className:`${c} object-cover shrink-0 ${l}`}):wre(n)?i.jsx("div",{style:{width:s,height:s,background:p,fontSize:s*.5},className:`${c} shrink-0 flex items-center justify-center shadow-inner ${l}`,children:i.jsx("span",{className:"drop-shadow-sm",children:n})}):n&&pae(n)?i.jsx("div",{style:{width:s,height:s,background:p},className:`${c} shrink-0 flex items-center justify-center text-white shadow-inner ${l}`,children:i.jsx(rl,{name:n,size:s*.52,className:"drop-shadow-sm"})}):i.jsx("div",{style:{width:s,height:s,background:p},className:`${c} shrink-0 flex items-center justify-center shadow-inner ${l}`,children:i.jsx("svg",{width:s*.55,height:s*.55,viewBox:"0 0 24 24",fill:"none","aria-hidden":!0,children:i.jsx("path",{d:h,fill:"rgba(255,255,255,0.92)"})})})}function Om({name:e,username:t,avatarUrl:n,hubBase:a,size:s=24,className:l="",verified:c}){const d=t||e||"markus",m=Im(n,a),[p,h]=k.useState(!1),g=m&&!p?m:kre(d);return i.jsxs("span",{className:`relative inline-flex shrink-0 ${l}`,style:{width:s,height:s},children:[i.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&&i.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:s*.42,height:s*.42},children:i.jsx("svg",{viewBox:"0 0 24 24",width:"60%",height:"60%",fill:"white","aria-hidden":!0,children:i.jsx("path",{d:"M9 16.2l-3.5-3.5 1.4-1.4L9 13.4l7.1-7.1 1.4 1.4z"})})})]})}function Lre({type:e,className:t=""}){const n=il(e),a=Bs[n];return i.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 ${a.gradient} ${t}`,children:a.label})}function yk({rating:e=0}){const t=Math.round(e);return i.jsx("span",{className:"inline-flex items-center","aria-label":`${e} out of 5`,children:[0,1,2,3,4].map(n=>i.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:i.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 vr(e){const{type:t,name:n,description:a,seed:s,icon:l,cover:c,hubBase:d,author:m,authorLabel:p,version:h,category:g,tags:x,rating:y=0,ratingCount:w=0,downloadCount:T=0,priceCents:C,currency:S="usd",installed:E,glowing:_,selected:M,showTypeBadge:P=!0,hideStats:R=!1,cornerLabel:I,actions:K,footerLeft:Y,headerAction:L,onClick:F,className:ne=""}=e,ee=il(t),G=Bs[ee],ae=s||n,H=(C??0)>0,J=!!Im(c||void 0,d),fe=xb(ee,ae),Ce=p??m?.displayName??m?.username??"",[$,V]=k.useState(null),pe=E?i.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:i.jsx("svg",{className:"w-2.5 h-2.5",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"3.5",children:i.jsx("polyline",{points:"20 6 9 17 4 12"})})}):I?i.jsx("span",{className:"chip",children:I}):H?i.jsx("span",{className:"badge-paid",children:hk(C,S)}):null;if(J){const z=Im(c||void 0,d);return i.jsxs("div",{onClick:F,style:{aspectRatio:$??void 0},className:`group asset-card card-shine relative flex flex-col overflow-hidden min-h-[180px] ${F?"cursor-pointer":""} ${M?"ring-1 ring-brand-500/60":""} ${_?"ring-2 ring-brand-500 shadow-lg shadow-brand-500/20":""} ${ne}`,children:[i.jsx("img",{src:z,alt:"",onLoad:je=>{const Ue=je.currentTarget;Ue.naturalWidth&&Ue.naturalHeight&&V(Math.min(1.9,Math.max(1,Ue.naturalWidth/Ue.naturalHeight)))},className:"absolute inset-0 w-full h-full object-cover transition-transform duration-[600ms] group-hover:scale-[1.05]"}),i.jsx("div",{className:"absolute inset-0 bg-gradient-to-t from-black/90 via-black/50 to-black/5"}),i.jsx("div",{className:"absolute inset-x-0 top-0 h-20 bg-gradient-to-b from-black/50 to-transparent"}),i.jsxs("div",{className:"relative flex items-start justify-between gap-2 p-3",children:[i.jsx("span",{children:P&&i.jsx(Lre,{type:ee})}),i.jsxs("span",{className:"flex items-center gap-1.5",onClick:je=>je.stopPropagation(),children:[E?i.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:i.jsx("svg",{className:"w-3 h-3",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"3",children:i.jsx("polyline",{points:"20 6 9 17 4 12"})})}):I?i.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:I}):L?null:i.jsx("span",{className:H?"badge-paid":"badge-free",children:hk(C,S)}),L]})]}),i.jsxs("div",{className:"relative mt-auto p-4 pt-10 flex flex-col gap-2 text-white",children:[i.jsxs("div",{className:"flex items-center gap-2",children:[i.jsx("h3",{className:"text-[15px] font-semibold truncate drop-shadow-md",children:n}),h&&i.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]})]}),Ce&&i.jsxs("div",{className:"flex items-center gap-1.5 text-[11px] text-white/85",children:[m&&i.jsx(Om,{name:m.displayName,username:m.username,avatarUrl:m.avatarUrl,hubBase:d,size:15}),i.jsx("span",{className:"truncate",children:Ce})]}),a&&i.jsx("p",{className:"text-[12.5px] text-white/80 truncate leading-snug drop-shadow-sm",children:a}),(g||x&&x.length>0)&&i.jsxs("div",{className:"flex flex-nowrap gap-1.5 overflow-hidden",children:[g&&i.jsx("span",{className:"shrink-0 rounded-full bg-white/15 border border-white/20 text-white/95 px-2 py-0.5 text-[10px] font-semibold capitalize backdrop-blur-md",children:g}),x?.slice(0,3).map(je=>i.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:je},je))]}),(!R||K)&&i.jsxs("div",{className:"flex items-center justify-between gap-2 pt-1 shrink-0",children:[R?i.jsx("span",{}):i.jsxs("div",{className:"flex items-center gap-3 text-[11px] text-white/80",children:[i.jsxs("span",{className:"inline-flex items-center gap-1",children:[i.jsx(yk,{rating:y}),w>0&&i.jsxs("span",{className:"text-white/60",children:["(",$o(w),")"]})]}),i.jsxs("span",{className:"inline-flex items-center gap-1",children:[i.jsx("svg",{viewBox:"0 0 24 24",width:"12",height:"12",fill:"none",stroke:"currentColor",strokeWidth:"2","aria-hidden":!0,children:i.jsx("path",{d:"M12 3v12m0 0l-4-4m4 4l4-4M5 21h14"})}),$o(T)]})]}),K&&i.jsx("div",{className:"flex items-center gap-2",onClick:je=>je.stopPropagation(),children:K})]})]})]})}return i.jsxs("div",{onClick:F,className:`group asset-card card-shine relative flex flex-col ${F?"cursor-pointer":""} ${M?"ring-1 ring-brand-500/60":""} ${_?"ring-2 ring-brand-500 shadow-lg shadow-brand-500/20":""} ${ne}`,children:[i.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, ${G.accent}, transparent)`}}),i.jsx("div",{className:"pointer-events-none absolute -top-10 -left-10 w-36 h-36 rounded-full blur-2xl opacity-[0.12] group-hover:opacity-20 transition-opacity duration-300",style:{background:fe}}),L&&i.jsx("div",{className:"absolute top-2.5 right-2.5 z-10",onClick:z=>z.stopPropagation(),children:L}),i.jsxs("div",{className:"relative p-4 flex flex-col flex-1 gap-2.5",children:[i.jsxs("div",{className:"flex items-start gap-3",children:[i.jsx(Dre,{type:ee,seed:ae,icon:l,hubBase:d,size:46,rounded:"rounded-2xl",className:"ring-1 ring-white/10 shadow-sm shadow-black/20"}),i.jsxs("div",{className:`min-w-0 flex-1 ${L?"pr-7":""}`,children:[i.jsxs("div",{className:"flex items-center gap-2",children:[i.jsx("h3",{className:"text-sm font-semibold text-fg-primary truncate group-hover:text-brand-300 transition-colors",children:n}),h&&i.jsxs("span",{className:"chip shrink-0",children:["v",h]}),pe&&i.jsx("span",{className:"ml-auto shrink-0",children:pe})]}),(Ce||P)&&i.jsxs("div",{className:"mt-1 flex items-center gap-1.5 text-[11px] text-fg-tertiary min-w-0",children:[m&&i.jsx(Om,{name:m.displayName,username:m.username,avatarUrl:m.avatarUrl,hubBase:d,size:15}),Ce&&i.jsx("span",{className:"truncate",children:Ce}),P&&i.jsxs(i.Fragment,{children:[Ce&&i.jsx("span",{className:"text-fg-muted",children:"·"}),i.jsx("span",{className:"font-semibold shrink-0",style:{color:G.accent},children:G.label})]})]})]})]}),a&&i.jsx("p",{className:"text-[13px] text-fg-secondary truncate leading-snug",children:a}),(g||x&&x.length>0)&&i.jsxs("div",{className:"flex flex-wrap gap-1.5",children:[g&&i.jsx("span",{className:"chip-accent capitalize",children:g}),x?.slice(0,3).map(z=>i.jsx("span",{className:"chip",children:z},z)),(x?.length??0)>3&&i.jsxs("span",{className:"text-[10px] text-fg-muted self-center",children:["+",(x?.length??0)-3]})]}),(()=>{const z=Y??(R?null:i.jsxs("span",{className:"flex items-center gap-3 text-[11px] text-fg-tertiary",children:[i.jsxs("span",{className:"inline-flex items-center gap-1",children:[i.jsx(yk,{rating:y}),i.jsx("span",{className:"text-fg-muted",children:w>0?`(${$o(w)})`:""})]}),i.jsxs("span",{className:"inline-flex items-center gap-1",children:[i.jsx("svg",{viewBox:"0 0 24 24",width:"12",height:"12",fill:"none",stroke:"currentColor",strokeWidth:"2","aria-hidden":!0,children:i.jsx("path",{d:"M12 3v12m0 0l-4-4m4 4l4-4M5 21h14"})}),$o(T)]})]}));return!z&&!K?null:i.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-2 pt-2 mt-auto border-t border-border-subtle/60",onClick:je=>je.stopPropagation(),children:[z&&i.jsx("div",{className:"min-w-0 flex items-center gap-2",children:z}),K&&i.jsx("div",{className:"flex flex-wrap items-center gap-2 justify-end",children:K})]})})()]})]})}function Fa({children:e,maxCardWidth:t=400,gap:n="1rem",className:a=""}){const s=k.useRef(null),[l,c]=k.useState(0);k.useEffect(()=>{const h=s.current;if(!h)return;c(h.clientWidth);const g=new ResizeObserver(x=>{for(const y of x)c(y.contentRect.width)});return g.observe(h),()=>g.disconnect()},[]);const d=Math.max(1,Math.ceil((l||t)/t)),m=k.Children.toArray(e),p=Array.from({length:d},()=>[]);return m.forEach((h,g)=>{p[g%d].push(h)}),i.jsx("div",{ref:s,className:`flex items-start ${a}`,style:{gap:n},children:p.map((h,g)=>i.jsx("div",{className:"flex flex-col flex-1 min-w-0",style:{gap:n,maxWidth:t},children:h},g))})}function Ire(e){const t=e.indexOf(".markus/builder-artifacts/");return t>=0?"~/"+e.slice(t):e}const Ore=[{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 Pre(){const[e,t]=k.useState(()=>{const a=window.location.hash.slice(1).split("/");return kc(a[0])===de.BUILDER&&a[1]&&a[2]?{type:a[1],name:decodeURIComponent(a[2])}:null});return k.useEffect(()=>{const n=()=>{const s=window.location.hash.slice(1).split("/");kc(s[0])===de.BUILDER&&s[1]&&s[2]?t({type:s[1],name:decodeURIComponent(s[2])}):t(null)};return window.addEventListener("hashchange",n),()=>window.removeEventListener("hashchange",n)},[]),e}const a6="markus_builder_shared_map";function zre(){try{const e=localStorage.getItem(a6);if(!e)return new Map;const t=JSON.parse(e);return new Map(Object.entries(t))}catch{return new Map}}function qd(e){try{localStorage.setItem(a6,JSON.stringify(Object.fromEntries(e)))}catch{}}function r6({authUser:e}={}){const{t}=ot(["builder","common"]),n=Xo(),a=Pre(),[s,l]=k.useState([]),[c,d]=k.useState([]),[m,p]=k.useState(!1),[h,g]=k.useState("all"),[x,y]=k.useState(null),[w,T]=k.useState(new Map),[C,S]=k.useState(null),[E,_]=k.useState(null),[M,P]=k.useState(null),[R,I]=k.useState(zre),[K,Y]=k.useState(null),[L,F]=k.useState(null),[ne,ee]=k.useState(null),[G,ae]=k.useState(null),[H,J]=k.useState(null),[fe,Ce]=k.useState("creations"),[$,V]=k.useState([]),[pe,z]=k.useState(""),[je,Ue]=k.useState([]),[qe,He]=k.useState(!1),[ut,dt]=k.useState("all"),Nt=k.useCallback(()=>{p(!0),Promise.all([(Ls(qa.builderArtifacts)??Ae.builder.artifacts.list()).then(ce=>ce?.artifacts??[]).catch(()=>[]),(Ls(qa.builderAgents)??Ae.agents.list()).then(ce=>ce?.agents??[]).catch(()=>[]),(Ls(qa.builderHubMyItems)??st.myItems()).then(ce=>ce?.items??[]).catch(()=>[]),(Ls(qa.builderInstalled)??Ae.builder.artifacts.installed()).then(ce=>ce?.installed??{}).catch(()=>({}))]).then(([ce,et,nt,we])=>{if(d(ce),l(et),nt.length>0){const Ne=new Map;for(const se of nt){const q=se.itemType==="agent"?"agent":se.itemType==="team"?"team":"skill";for(const te of ce)te.type===q&&(se.slug===te.name||se.name===(te.meta.displayName||te.meta.name||te.name))&&Ne.set(`${te.type}/${te.name}`,{id:se.id,name:se.name,slug:se.slug||te.name,version:se.version||"1.0.0",visibility:se.visibility??"public",moderationStatus:se.moderationStatus,moderationNote:se.moderationNote,pendingReview:se.pendingReview})}Ne.size>0&&I(se=>{const q=new Map(se);for(const[te,Se]of Ne)q.set(te,Se);return qd(q),q})}const Me=new Map;for(const Ne of ce){const se=`${Ne.type}/${Ne.name}`,q=we[se];q&&Me.set(se,{agentId:q.agentId,agentIds:q.agentIds,teamId:q.teamId})}T(Me)}).finally(()=>p(!1))},[]);k.useEffect(()=>{Nt();const ce=et=>{et.detail?.page===de.BUILDER&&Nt()};return window.addEventListener("markus:navigate",ce),()=>window.removeEventListener("markus:navigate",ce)},[Nt]);const wt=ce=>{const et=s.find(nt=>nt.role==="Secretary"||nt.name==="Secretary");et?at.navigate(de.TEAM,{agentId:et.id,prefillMessage:ce}):at.navigate(de.TEAM,{prefillMessage:ce})},Zt=async ce=>{const et=`${ce.type}/${ce.name}`;if(!w.has(et)){y({key:et,action:"install"});try{const nt=await Ae.builder.artifacts.install(ce.type,ce.name),we={};nt.agent&&typeof nt.agent=="object"&&(we.agentId=nt.agent.id),nt.team&&typeof nt.team=="object"&&(we.teamId=nt.team.id),Array.isArray(nt.agents)&&(we.agentIds=nt.agents.map(Me=>Me.id)),T(Me=>new Map(Me).set(et,we)),window.dispatchEvent(new CustomEvent("markus:data-changed"))}catch(nt){console.error("Install failed:",nt),F({title:t("common:install"),message:t("installFailed",{error:String(nt)}),variant:"danger"})}finally{y(null)}}},Wt=async ce=>{const et=`${ce.type}/${ce.name}`;if(w.has(et)){y({key:et,action:"uninstall"});try{await Ae.builder.artifacts.uninstall(ce.type,ce.name),T(nt=>{const we=new Map(nt);return we.delete(et),we}),window.dispatchEvent(new CustomEvent("markus:data-changed"))}catch(nt){console.error("Uninstall failed:",nt),F({title:t("common:uninstall"),message:t("uninstallFailed",{error:String(nt)}),variant:"danger"})}finally{y(null)}}},rt=async(ce,et)=>{const nt=`${ce.type}/${ce.name}`;y({key:nt,action:"share"});try{const we=await Ae.builder.artifacts.ensureSlugSafe(ce.type,ce.name,ce.meta.displayName||ce.meta.name||ce.name),Me=we.name,Ne=we.slug||Nc(Me);if(!Ne)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 se=`${ce.type}/${Me}`;we.converted&&(d(Rt=>Rt.map(Mt=>Mt.type===ce.type&&Mt.name===ce.name?{...Mt,name:Me,path:we.path,meta:{...Mt.meta,name:Me,displayName:we.displayName??Mt.meta.displayName??ce.name}}:Mt)),I(Rt=>{const Mt=new Map(Rt),Ot=Mt.get(nt);return Ot&&(Mt.delete(nt),Mt.set(se,{...Ot,slug:Ne,name:we.displayName??Ot.name})),qd(Mt),Mt}),T(Rt=>{const Mt=new Map(Rt),Ot=Mt.get(nt);return Ot&&(Mt.delete(nt),Mt.set(se,Ot)),Mt}));const q=await Ae.builder.artifacts.get(ce.type,Me);let te={...ce.meta,name:Me,displayName:we.displayName??ce.meta.displayName??ce.name};try{const Rt=q.files?.[`${ce.type}.json`]??q.files?.["agent.json"]??q.files?.["team.json"]??q.files?.["skill.json"];Rt&&(te={...JSON.parse(Rt),...te,name:Me,displayName:te.displayName})}catch{}const Se=te.displayName||te.name||Me,De=te.description||"",Pe=te.category||"general",Q=Array.isArray(te.tags)?te.tags:[];let X=te.icon||void 0;const ue=te.version||"1.0.0";if(X&&!X.startsWith("http")&&/\.(png|jpe?g|gif|webp|svg)$/i.test(X)){const Rt=X.split("/").pop()??X;try{const Mt=await fetch(`/api/builder/artifacts/${ce.type}s/${encodeURIComponent(Me)}/images/${encodeURIComponent(Rt)}`);if(Mt.ok){const Ot=await Mt.blob(),Un=new File([Ot],Rt,{type:Ot.type}),hn=await st.uploadImage(Un);hn?.url&&(X=hn.url)}}catch{}}let Be;const Ie=[],Ge=Array.isArray(te.screenshots)?te.screenshots:[];for(let Rt=0;Rt<Ge.length;Rt++){const Mt=Ge[Rt],Ot=Mt.split("/").pop()??Mt;try{const Un=await fetch(`/api/builder/artifacts/${ce.type}s/${encodeURIComponent(Me)}/images/${encodeURIComponent(Ot)}`);if(Un.ok){const hn=await Un.blob(),ie=new File([hn],Ot,{type:hn.type}),Ee=await st.uploadImage(ie);Ee?.url&&(Ie.push({url:Ee.url,alt:Ot,order:Rt}),(Rt===0||te.thumbnail===Mt)&&(Be=Ee.url))}}catch{}}const kt=await st.publishViaProxy({itemType:ce.type==="team"?"team":ce.type==="skill"?"skill":"agent",name:Se,slug:Ne,description:De,category:Pe,tags:Q,icon:X,version:ue,config:{...te,name:Me,displayName:Se},files:q.files&&Object.keys(q.files).length>0?q.files:void 0,thumbnailUrl:Be,images:Ie.length>0?Ie:void 0,priceCents:et?.priceCents,donationsEnabled:et?.donationsEnabled,visibility:et?.visibility,orgId:et?.orgId});kt.id&&(I(Mt=>{const Ot=new Map(Mt);return Ot.set(se,{id:kt.id,name:Se,slug:kt.slug??Ne,version:ue,visibility:kt.visibility??et?.visibility??"public",moderationStatus:kt.moderationStatus,pendingReview:kt.pendingReview}),qd(Ot),Ot}),(kt.visibility??et?.visibility??"public")!=="org"?F({title:t("common:share"),message:we.converted?t("share.convertedAndSubmitted",{previous:ce.name,slug:Ne}):kt.updated?t("share.updateSubmitted"):t("share.submittedForReview"),variant:"primary"}):we.converted&&F({title:t("common:share"),message:t("share.convertedSlug",{previous:ce.name,slug:Ne}),variant:"primary"}))}catch(we){console.error("Share failed:",we),F({title:t("common:share"),message:t("shareFailed",{error:we instanceof Error?we.message:String(we)}),variant:"danger"})}finally{y(null)}},$e=async()=>{if(!K)return;const{key:ce}=K,et=R.get(ce);if(Y(null),!et)return;const nt=et.id;y({key:ce,action:"hubDelete"});try{await st.deleteItem(nt),I(we=>{const Me=new Map(we);return Me.delete(ce),qd(Me),Me})}catch(we){console.error("Hub delete failed:",we),F({title:t("unshare"),message:t("hubDeleteFailed",{error:String(we)}),variant:"danger"})}finally{y(null)}},mt=async()=>{if(!C)return;const ce=C,et=`${ce.type}/${ce.name}`;S(null),y({key:et,action:"delete"});try{await Ae.builder.artifacts.delete(ce.type,ce.name),d(nt=>nt.filter(we=>!(we.type===ce.type&&we.name===ce.name))),T(nt=>{const we=new Map(nt);return we.delete(et),we}),window.dispatchEvent(new CustomEvent("markus:data-changed"))}catch(nt){console.error("Delete failed:",nt)}finally{y(null)}},At=h==="all"?c:c.filter(ce=>ce.type===h);k.useEffect(()=>{fe!=="orgAssets"||$.length>0||st.myOrgs().then(ce=>{V(ce.memberships),ce.memberships.length>0&&!pe&&z(ce.memberships[0].id)}).catch(()=>{})},[fe,$.length,pe]),k.useEffect(()=>{fe!=="orgAssets"||!pe||(He(!0),st.browseItems({orgId:pe,limit:100}).then(ce=>Ue(ce.items??[])).catch(()=>Ue([])).finally(()=>He(!1)))},[fe,pe]);const Dt=ut==="all"?je:je.filter(ce=>ce.itemType===ut),ln=ce=>{history.pushState(null,"",Ps(de.BUILDER,`${ce.type}/${encodeURIComponent(ce.name)}`)),window.dispatchEvent(new HashChangeEvent("hashchange"))};return a?i.jsx(qs,{type:a.type,name:a.name,authUser:e,onBack:()=>{history.pushState(null,"",Ps(de.BUILDER)),window.dispatchEvent(new HashChangeEvent("hashchange"))}}):i.jsx("div",{className:"flex-1 overflow-y-auto",children:i.jsxs("div",{className:`max-w-5xl mx-auto w-full ${n?"px-4 py-5":"px-6 py-6"}`,children:[i.jsxs("div",{className:"mb-6",children:[i.jsxs("div",{className:"flex items-center justify-between mb-4",children:[i.jsxs("div",{children:[i.jsx("h1",{className:"text-xl font-bold text-fg-primary",children:t("title")}),i.jsx("p",{className:"text-xs text-fg-tertiary mt-1",children:t("subtitle")})]}),i.jsx("button",{onClick:Nt,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")})]}),i.jsx("div",{className:`grid ${n?"grid-cols-1 gap-2":"grid-cols-3 gap-3"}`,children:Ore.map(ce=>{const et=t(`prompts.${ce.id}Prompt`),nt=t(`prompts.${ce.id}Examples`,{returnObjects:!0}),we=Array.isArray(nt)?nt:[];return i.jsx("button",{onClick:()=>wt(et),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:i.jsxs("div",{className:"flex items-start gap-3",children:[i.jsx("div",{className:`w-10 h-10 text-xl rounded-lg ${ce.bgColor} flex items-center justify-center shrink-0`,children:ce.icon}),i.jsxs("div",{className:"flex-1 min-w-0",children:[i.jsx("h3",{className:`text-sm font-semibold bg-gradient-to-r ${ce.color} bg-clip-text text-transparent`,children:t(`prompts.${ce.id}`)}),i.jsx("p",{className:"text-[11px] text-fg-tertiary mt-1 leading-relaxed",children:t(`prompts.${ce.id}Desc`)}),we.length>0&&i.jsx("div",{className:"mt-2 flex flex-wrap gap-1.5",children:we.slice(0,2).map((Me,Ne)=>i.jsxs("span",{className:"text-[10px] text-fg-muted bg-surface-elevated/60 rounded-full px-2 py-0.5 border border-border-default",onClick:se=>{se.stopPropagation(),wt(et+Me)},children:["“",Me,"”"]},Ne))})]})]})},ce.id)})})]}),i.jsx("div",{className:"mb-3",children:i.jsxs("div",{className:"flex items-center justify-between",children:[i.jsxs("div",{className:"flex items-center gap-3",children:[i.jsx("button",{onClick:()=>Ce("creations"),className:`text-sm font-semibold transition-colors ${fe==="creations"?"text-fg-primary":"text-fg-tertiary hover:text-fg-secondary"}`,children:t("myCreations.title")}),i.jsx("button",{onClick:()=>Ce("orgAssets"),className:`text-sm font-semibold transition-colors ${fe==="orgAssets"?"text-fg-primary":"text-fg-tertiary hover:text-fg-secondary"}`,children:t("orgAssets.title")})]}),fe==="creations"&&i.jsx("div",{className:"flex gap-1.5",children:["all","agent","team","skill"].map(ce=>i.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))}),fe==="orgAssets"&&i.jsx("div",{className:"flex gap-1.5",children:["all","agent","team","skill"].map(ce=>i.jsx("button",{onClick:()=>dt(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))})]})}),fe==="orgAssets"&&$.length>0&&i.jsx("div",{className:"flex gap-2 mb-3 overflow-x-auto pb-1",children:$.map(ce=>i.jsx("button",{onClick:()=>z(ce.id),className:`text-xs px-3 py-1.5 rounded-full whitespace-nowrap border transition-colors ${pe===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))}),fe==="orgAssets"&&($.length===0&&!qe?i.jsx("div",{className:"text-center py-12",children:i.jsx("div",{className:"text-fg-tertiary text-sm",children:t("orgAssets.noOrgs")})}):qe?i.jsx("div",{className:"text-center text-fg-tertiary py-12 text-sm",children:t("orgAssets.loading")}):Dt.length===0?i.jsx("div",{className:"text-center py-12",children:i.jsx("div",{className:"text-fg-tertiary text-sm",children:t("orgAssets.noItems")})}):i.jsx(Fa,{children:Dt.map(ce=>{const et=ce.author?.username&&ce.slug?`${st.getUrl()}/@${encodeURIComponent(ce.author.username)}/${encodeURIComponent(ce.slug)}`:null;return i.jsx(vr,{type:ce.itemType,name:ce.name,description:ce.description,seed:ce.slug||ce.id||ce.name,icon:ce.icon,cover:ce.thumbnailUrl,hubBase:st.getUrl(),author:ce.author,version:ce.version,rating:parseFloat(ce.avgRating)||0,ratingCount:ce.ratingCount,downloadCount:ce.downloadCount,actions:et?i.jsxs("a",{href:et,target:"_blank",rel:"noopener noreferrer",onClick:nt=>{nt.stopPropagation(),Go()&&(nt.preventDefault(),fi(et))},className:"text-xs px-3 py-1.5 rounded-lg border border-border-default text-fg-secondary hover:text-fg-primary hover:border-gray-600 transition-colors inline-flex items-center gap-1",children:[i.jsxs("svg",{className:"w-3 h-3",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[i.jsx("path",{d:"M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6"}),i.jsx("polyline",{points:"15 3 21 3 21 9"}),i.jsx("line",{x1:"10",y1:"14",x2:"21",y2:"3"})]}),"Hub"]}):void 0},ce.id)})})),fe==="creations"&&(m&&c.length===0?i.jsx("div",{className:"text-center text-fg-tertiary py-12 text-sm",children:t("myCreations.loadingArtifacts")}):At.length===0?i.jsxs("div",{className:"text-center py-12",children:[i.jsx("div",{className:"text-fg-tertiary text-sm",children:t("myCreations.noArtifacts")}),i.jsx("div",{className:"text-fg-muted text-xs mt-1",children:t("myCreations.noArtifactsHint")})]}):i.jsx(Fa,{children:At.map(ce=>{const et=ce.meta.displayName||ce.meta.name||ce.name,nt=ce.meta.description||"",we=`${ce.type}/${ce.name}`,Me=x?.key===we?x.action:null,Ne=R.get(we),se=ce.meta.version||"1.0.0",q=!!Ne,te=q&&Ne.version!==se,Se=()=>{const Ie=st.getUser();return!Ne||!Ie?null:`${st.getUrl()}/@${encodeURIComponent(Ie.username)}/${encodeURIComponent(Ne.slug)}`},De=q&&Ne?.moderationStatus==="rejected",Pe=i.jsxs("div",{className:"flex items-center gap-1.5 justify-end",onClick:Ie=>Ie.stopPropagation(),children:[w.has(we)?i.jsxs("button",{onClick:()=>P(ce),disabled:!!Me,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:[i.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:[i.jsx("path",{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4"}),i.jsx("polyline",{points:"17 8 12 3 7 8"}),i.jsx("line",{x1:"12",y1:"3",x2:"12",y2:"15"})]}),t(Me==="uninstall"?"common:uninstalling":"common:uninstall")]}):i.jsxs("button",{onClick:()=>_(ce),disabled:!!Me,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:[i.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:[i.jsx("path",{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4"}),i.jsx("polyline",{points:"7 10 12 15 17 10"}),i.jsx("line",{x1:"12",y1:"15",x2:"12",y2:"3"})]}),t(Me==="install"?"common:installing":"common:install")]}),q&&De?i.jsxs(i.Fragment,{children:[i.jsxs("button",{onClick:()=>{F({title:t("share.rejectedDetailTitle"),variant:"danger",message:`${t("share.rejectedReasonLabel")}${Ne?.moderationNote?Ne.moderationNote:t("share.rejectedNoReason")}
881
881
 
882
- ${t("share.rejectedEncourage")}`})},className:"text-xs px-2 py-1.5 rounded-lg border border-red-500/30 text-red-400 hover:bg-red-500/10 transition-colors inline-flex items-center gap-1 cursor-pointer",title:t("share.rejectedTip"),children:[i.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:[i.jsx("circle",{cx:"12",cy:"12",r:"10"}),i.jsx("line",{x1:"15",y1:"9",x2:"9",y2:"15"}),i.jsx("line",{x1:"9",y1:"9",x2:"15",y2:"15"})]}),t("share.rejected")]}),i.jsxs("button",{onClick:()=>{rt(ce,{visibility:Ne?.visibility??"public"})},disabled:!!Me,className:"text-xs px-3 py-1.5 rounded-lg border border-brand-500/40 text-brand-400 hover:bg-brand-500/10 hover:border-brand-500/60 transition-colors disabled:opacity-50 inline-flex items-center gap-1",title:t("share.rejectedTip"),children:[i.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:[i.jsx("polyline",{points:"23 4 23 10 17 10"}),i.jsx("polyline",{points:"1 20 1 14 7 14"}),i.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"})]}),t(Me==="share"?"common:sharing":"share.resubmit")]})]}):q?i.jsxs(i.Fragment,{children:[te&&i.jsxs("button",{onClick:()=>{const Ie=Ne?.visibility??"public";rt(ce,{visibility:Ie})},disabled:!!Me,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:[i.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:[i.jsx("polyline",{points:"23 4 23 10 17 10"}),i.jsx("polyline",{points:"1 20 1 14 7 14"}),i.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"})]}),Me==="share"?t("common:sharing"):t("share.updateVersion",{version:se})]}),i.jsxs("a",{href:Se()??"#",target:"_blank",rel:"noopener noreferrer",onClick:Ie=>{const Ge=Se();Go()&&Ge&&(Ie.preventDefault(),fi(Ge))},className:`text-xs px-3 py-1.5 rounded-lg border transition-colors inline-flex items-center gap-1 ${Ne?.visibility==="org"?"border-blue-500/30 text-blue-500 hover:text-blue-400 hover:border-blue-400/40":Ne?.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:[Ne?.visibility==="org"?i.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:[i.jsx("path",{d:"M3 21h18"}),i.jsx("path",{d:"M9 8h1"}),i.jsx("path",{d:"M9 12h1"}),i.jsx("path",{d:"M9 16h1"}),i.jsx("path",{d:"M14 8h1"}),i.jsx("path",{d:"M14 12h1"}),i.jsx("path",{d:"M14 16h1"}),i.jsx("path",{d:"M5 21V5a2 2 0 0 1 2-2h10a2 2 0 0 1 2 2v16"})]}):Ne?.visibility==="unlisted"?i.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:[i.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"}),i.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"})]}):i.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:[i.jsx("path",{d:"M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6"}),i.jsx("polyline",{points:"15 3 21 3 21 9"}),i.jsx("line",{x1:"10",y1:"14",x2:"21",y2:"3"})]}),Ne?.visibility==="org"?t("visibility.sharedOrg"):Ne?.visibility==="unlisted"?t("visibility.sharedUnlisted"):t("visibility.shared")]}),i.jsxs("button",{onClick:()=>Y({key:we,name:et}),disabled:!!Me,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:[i.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:[i.jsx("path",{d:"M18.84 12.25l1.72-1.71a5 5 0 0 0-7.07-7.07l-1.72 1.71"}),i.jsx("path",{d:"M5.17 11.75l-1.71 1.71a5 5 0 0 0 7.07 7.07l1.71-1.71"}),i.jsx("line",{x1:"2",y1:"2",x2:"22",y2:"22"})]}),t("unshare")]})]}):i.jsxs("button",{onClick:async()=>{await st.ensureAuth(),Array.isArray(ce.meta.screenshots)&&ce.meta.screenshots.length>0?J(ce):ee(ce)},disabled:!!Me,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:[i.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:[i.jsx("circle",{cx:"18",cy:"5",r:"3"}),i.jsx("circle",{cx:"6",cy:"12",r:"3"}),i.jsx("circle",{cx:"18",cy:"19",r:"3"}),i.jsx("line",{x1:"8.59",y1:"13.51",x2:"15.42",y2:"17.49"}),i.jsx("line",{x1:"15.41",y1:"6.51",x2:"8.59",y2:"10.49"})]}),t(Me==="share"?"common:sharing":"common:share")]})]}),Q=i.jsx("button",{onClick:()=>S(ce),disabled:!!Me,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:i.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:[i.jsx("polyline",{points:"3 6 5 6 21 6"}),i.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"})]})}),X=ce.meta.icon,Be=!!X&&/\.(png|jpe?g|gif|webp|svg)$/i.test(X)?X.startsWith("http")||X.startsWith("/")?X:`/api/builder/artifacts/${ce.type}s/${encodeURIComponent(ce.name)}/images/${encodeURIComponent(X.split("/").pop()??"")}?v=${ce.updatedAt??""}`:X;return i.jsx(vr,{type:ce.type,name:et,description:nt,seed:we,icon:Be,version:se,footerLeft:i.jsxs("span",{className:"flex items-center gap-2 text-[10px] text-fg-tertiary min-w-0",children:[i.jsx("button",{onClick:Ie=>{Ie.stopPropagation(),Ae.system.openPath(ce.path).catch(()=>{})},className:"hover:text-fg-secondary transition-colors truncate min-w-0",title:ce.path,children:Ire(ce.path)}),i.jsx("span",{className:"shrink-0",children:"·"}),i.jsx("span",{className:"shrink-0",children:new Date(ce.updatedAt).toLocaleDateString()})]}),headerAction:Q,actions:Pe,onClick:()=>ln(ce)},we)})})),E&&i.jsx(ba,{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;_(null),Zt(ce)},onCancel:()=>_(null)}),M&&i.jsx(ba,{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;P(null),Wt(ce)},onCancel:()=>P(null)}),C&&i.jsx(ba,{title:t("confirmDeleteLocal"),message:t("deleteCannotUndo",{name:C.meta.displayName||C.meta.name||C.name}),confirmLabel:t("common:delete"),onConfirm:mt,onCancel:()=>S(null)}),K&&i.jsx(ba,{title:t("confirmUnshare"),message:t("removeFromHub",{name:K.name}),confirmLabel:t("unshare"),onConfirm:()=>{$e()},onCancel:()=>Y(null)}),L&&i.jsx(ba,{alertOnly:!0,variant:L.variant??"primary",title:L.title,message:L.message,onConfirm:()=>F(null),onCancel:()=>F(null)}),ne&&i.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/60 backdrop-blur-sm",onClick:()=>ee(null),children:i.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:[i.jsx("h3",{className:"text-base font-semibold text-fg-primary mb-2",children:t("common:share")}),i.jsx("p",{className:"text-sm text-fg-secondary mb-5",children:t("share.imagePrompt")}),i.jsxs("div",{className:"flex gap-3",children:[i.jsx("button",{onClick:()=>{const ce=ne;ee(null),J(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")}),i.jsx("button",{onClick:()=>{const ce=ne;ee(null),ln(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")})]})]})}),G&&i.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/60 backdrop-blur-sm",onClick:()=>ae(null),children:i.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:i.jsx(Hre,{isUpdate:R.has(`${G.type}/${G.name}`),onCancel:()=>ae(null),onConfirm:(ce,et)=>{const nt=G;ae(null),rt(nt,{priceCents:et>0?et:void 0})}})})}),H&&i.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/60 backdrop-blur-sm",onClick:()=>J(null),children:i.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:i.jsx(Bre,{onCancel:()=>J(null),onConfirm:(ce,et,nt,we)=>{const Me=H;J(null),rt(Me,{visibility:ce,orgId:et,priceCents:nt,donationsEnabled:we})}})})})]})})}function Bre({onCancel:e,onConfirm:t}){const{t:n}=ot(["builder","common"]),[a,s]=k.useState("public"),[l,c]=k.useState([]),[d,m]=k.useState(""),[p,h]=k.useState(!1),[g,x]=k.useState(0),[y,w]=k.useState(!1);k.useEffect(()=>{a==="org"&&l.length===0&&(h(!0),st.myOrgs().then(S=>{c(S.memberships),S.memberships.length>0&&m(S.memberships[0].id)}).catch(()=>{}).finally(()=>h(!1)))},[a,l.length]);const T=a==="public"||a==="unlisted",C=[{value:"public",icon:i.jsxs("svg",{className:"w-4 h-4",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[i.jsx("circle",{cx:"12",cy:"12",r:"10"}),i.jsx("line",{x1:"2",y1:"12",x2:"22",y2:"12"}),i.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:i.jsxs("svg",{className:"w-4 h-4",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[i.jsx("path",{d:"M3 21h18"}),i.jsx("path",{d:"M9 8h1"}),i.jsx("path",{d:"M9 12h1"}),i.jsx("path",{d:"M9 16h1"}),i.jsx("path",{d:"M14 8h1"}),i.jsx("path",{d:"M14 12h1"}),i.jsx("path",{d:"M14 16h1"}),i.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:i.jsxs("svg",{className:"w-4 h-4",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[i.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"}),i.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 i.jsxs(i.Fragment,{children:[i.jsx("h3",{className:"text-base font-semibold text-fg-primary mb-4",children:n("visibility.label")}),i.jsx("div",{className:"space-y-2 mb-5",children:C.map(S=>i.jsxs("label",{className:`flex items-center gap-3 p-3 rounded-lg border cursor-pointer transition-colors ${a===S.value?"border-brand-500 bg-brand-500/10":"border-border-default hover:border-gray-600"}`,children:[i.jsx("input",{type:"radio",name:"visibility",checked:a===S.value,onChange:()=>s(S.value),className:"accent-brand-500"}),i.jsx("div",{className:"flex items-center gap-2 text-fg-secondary",children:S.icon}),i.jsxs("div",{children:[i.jsx("div",{className:"text-sm font-medium text-fg-primary",children:S.label}),i.jsx("div",{className:"text-[11px] text-fg-tertiary",children:S.desc})]})]},S.value))}),a==="org"&&i.jsxs("div",{className:"mb-5",children:[i.jsx("label",{className:"text-xs text-fg-secondary block mb-1.5",children:n("visibility.orgSelect")}),p?i.jsx("div",{className:"text-xs text-fg-tertiary py-2",children:"Loading..."}):l.length===0?i.jsx("div",{className:"text-xs text-fg-tertiary py-2",children:n("visibility.orgNone")}):i.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=>i.jsx("option",{value:S.id,children:S.name},S.id))})]}),T&&i.jsxs("div",{className:"mb-5",children:[i.jsx("label",{className:"text-xs text-fg-secondary block mb-1.5",children:n("pricing.label")}),i.jsx("div",{className:"grid grid-cols-4 gap-2 mb-3",children:i6.map(S=>i.jsx("button",{type:"button",onClick:()=>x(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))}),i.jsxs("label",{className:"flex items-center gap-2 cursor-pointer",children:[i.jsx("input",{type:"checkbox",checked:y,onChange:S=>w(S.target.checked),className:"accent-brand-500"}),i.jsx("span",{className:"text-xs text-fg-secondary",children:n("pricing.enableTips")})]})]}),T&&i.jsx("div",{className:"mb-4 text-[11px] text-fg-tertiary rounded-lg border border-border-default px-3 py-2",children:n("pricing.reviewNote")}),i.jsxs("div",{className:"flex gap-3",children:[i.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")}),i.jsx("button",{onClick:()=>t(a,a==="org"?d:void 0,T&&g>0?g:void 0,T?y:void 0),disabled:a==="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 i6=[{cents:0,label:"Free"},{cents:100,label:"$1"},{cents:500,label:"$5"},{cents:1e3,label:"$10"}];function Hre({isUpdate:e,onCancel:t,onConfirm:n}){const{t:a}=ot(["builder","common"]),[s,l]=k.useState(0);return i.jsxs(i.Fragment,{children:[i.jsx("h3",{className:"text-base font-semibold text-fg-primary mb-4",children:a(e?"shareMode.titleUpdate":"shareMode.title")}),i.jsx("div",{className:"space-y-2 mb-5",children:i6.map(c=>i.jsxs("label",{className:`flex items-center gap-3 p-3 rounded-lg border cursor-pointer transition-colors ${s===c.cents?"border-brand-500 bg-brand-500/10":"border-border-default hover:border-gray-600"}`,children:[i.jsx("input",{type:"radio",name:"sharePrice",checked:s===c.cents,onChange:()=>l(c.cents),className:"accent-brand-500"}),i.jsxs("div",{children:[i.jsx("div",{className:"text-sm font-medium text-fg-primary",children:c.label}),i.jsx("div",{className:"text-[11px] text-fg-tertiary",children:c.cents===0?a("shareMode.freeDesc"):a("shareMode.paidDesc")})]})]},c.cents))}),i.jsxs("div",{className:"flex gap-3",children:[i.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:a("common:cancel")}),i.jsx("button",{onClick:()=>n(s>0?"paid":"free",s),className:"flex-1 text-sm px-4 py-2 rounded-lg bg-brand-600 hover:bg-brand-500 text-white transition-colors",children:a(e?"shareMode.update":"shareMode.share")})]})]})}const $re=Object.freeze(Object.defineProperty({__proto__:null,AgentBuilder:r6},Symbol.toStringTag,{value:"Module"}));async function s6(e,t){if(!t)return{items:e,highlighted:null,missing:!1};const n=e.find(a=>a.id===t);if(n)return{items:[n,...e.filter(a=>a.id!==t)],highlighted:n,missing:!1};try{const{item:a}=await st.getItem(t);return a?{items:[a,...e],highlighted:a,missing:!1}:{items:e,highlighted:null,missing:!0}}catch{return{items:e,highlighted:null,missing:!0}}}function qre(e,t){const n=e.split(".").map(Number),a=t.split(".").map(Number);for(let s=0;s<Math.max(n.length,a.length);s++){const l=n[s]??0,c=a[s]??0;if(l>c)return!0;if(l<c)return!1}return!1}function Pm(e,t){const n=e.i18n?.[t];return n?.displayName||n?.name||e.name}function xk(e,t){return e.i18n?.[t]?.description||e.description}const Fre={manager:"bg-brand-500/15 text-brand-500",worker:"bg-blue-500/15 text-blue-600"};function Ure({authUser:e,highlightItemId:t,onHighlightDone:n}={}){const{t:a,i18n:s}=ot(["store","common"]),l=s.language,[c,d]=k.useState(""),[m,p]=k.useState([]),[h,g]=k.useState([]),[x,y]=k.useState(null),[w,T]=k.useState({}),[C,S]=k.useState(!1),[E,_]=k.useState(!0),[M,P]=k.useState(new Map),[R,I]=k.useState(new Set),[K,Y]=k.useState(null),[L,F]=k.useState(null),ne=k.useCallback(async()=>{try{const[ae,H]=await Promise.all([Ae.builder.artifacts.list().catch(()=>({artifacts:[]})),Ae.builder.artifacts.installed().catch(()=>({installed:{}}))]),J=new Map;for(const fe of ae.artifacts){if(fe.type!=="agent")continue;const Ce=!!H.installed[`agent/${fe.name}`];J.set(fe.name,{installed:Ce,localVersion:fe.meta.version||void 0,localUpdatedAt:fe.updatedAt})}P(J)}catch{}},[]),ee=k.useCallback(async()=>{_(!0);try{const ae=c?st.search({type:"agent",q:c,limit:50}):Ls(qa.hubAgents)??st.search({type:"agent",limit:50}),H=new URLSearchParams;c&&H.set("q",c);const J=fetch("/api/templates?"+H.toString()).then(V=>V.json()).catch(()=>({templates:[]})),[fe,Ce]=await Promise.all([ae.catch(()=>({items:[],total:0})),J,ne(),st.isAuthenticated()?st.purchases.mine().then(V=>I(new Set(V.purchases.map(pe=>pe.itemId)))).catch(()=>{}):Promise.resolve()]),$=await s6(fe?.items??[],t);g($.items),p(Array.isArray(Ce.templates)?Ce.templates:[]),$.missing&&n?.()}catch{p([]),g([])}finally{_(!1)}},[c,ne,t,n]);k.useEffect(()=>{ee()},[ee]),k.useEffect(()=>{if(!x){T({});return}fetch(`/api/templates/${encodeURIComponent(x.id)}/files`,{credentials:"include"}).then(ae=>ae.json()).then(ae=>T(ae.files??{})).catch(()=>T({}))},[x]);const G=async(ae,H,J)=>{try{const fe=await fetch("/api/templates/instantiate",{method:"POST",headers:{"Content-Type":"application/json"},credentials:"include",body:JSON.stringify({templateId:ae,name:H,orgId:"default",teamId:J})});if(!fe.ok)throw new Error(`Failed: ${fe.status}`);S(!1),y(null)}catch(fe){F({title:a("common:create",{defaultValue:"Create"}),message:`Failed to create agent: ${fe}`,variant:"danger"})}};if(K)return i.jsx(qs,{type:K.type,name:K.name,onBack:()=>Y(null)});if(x){const ae={type:"agent",name:x.id,displayName:Pm(x,l),version:x.version,description:xk(x,l),author:x.author,category:x.category,tags:x.tags,icon:x.icon,files:w,agent:{roleName:x.roleId,agentRole:x.agentRole==="manager"?"manager":"worker"},dependencies:{skills:x.skills}},H=i.jsxs("div",{className:"space-y-6",children:[i.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[i.jsxs("div",{className:"rounded-xl border border-border-default bg-surface-secondary/40 p-5",children:[i.jsx("h3",{className:"text-xs text-fg-tertiary uppercase tracking-wider mb-3",children:a("agentStore.roleConfig")}),i.jsxs("div",{className:"space-y-2.5 text-sm",children:[i.jsxs("div",{className:"flex items-center gap-2",children:[i.jsx("span",{className:"text-fg-tertiary w-20",children:a("agentStore.role")}),i.jsx("span",{className:"text-fg-secondary font-mono text-xs bg-surface-elevated px-2 py-0.5 rounded",children:x.roleId})]}),i.jsxs("div",{className:"flex items-center gap-2",children:[i.jsx("span",{className:"text-fg-tertiary w-20",children:a("agentStore.position")}),i.jsx("span",{className:`px-2 py-0.5 rounded text-xs capitalize ${Fre[x.agentRole]??""}`,children:x.agentRole})]})]})]}),i.jsxs("div",{className:"rounded-xl border border-border-default bg-surface-secondary/40 p-5",children:[i.jsx("h3",{className:"text-xs text-fg-tertiary uppercase tracking-wider mb-3",children:a("agentStore.skills")}),i.jsxs("div",{className:"flex flex-wrap gap-1.5",children:[x.skills.map(J=>i.jsx("span",{className:"px-2.5 py-1 text-xs bg-brand-500/10 text-brand-500 rounded-lg border border-brand-500/20",children:J},J)),x.skills.length===0&&i.jsx("span",{className:"text-xs text-fg-tertiary italic",children:a("agentStore.noSkills")})]})]})]}),x.starterTasks&&x.starterTasks.length>0&&i.jsxs("div",{className:"rounded-xl border border-border-default bg-surface-secondary/40 p-5",children:[i.jsx("h3",{className:"text-xs text-fg-tertiary uppercase tracking-wider mb-3",children:a("agentStore.starterTasks")}),i.jsx("div",{className:"space-y-2",children:x.starterTasks.map((J,fe)=>i.jsxs("div",{className:"flex items-start gap-3 bg-surface-elevated/50 rounded-lg p-3",children:[i.jsx("span",{className:`inline-block w-2 h-2 rounded-full shrink-0 mt-1 ${J.priority==="high"?"bg-red-400":J.priority==="medium"?"bg-amber-400":"bg-green-400"}`}),i.jsxs("div",{children:[i.jsx("div",{className:"text-sm text-fg-primary",children:J.title}),J.description&&i.jsx("div",{className:"text-xs text-fg-tertiary mt-0.5",children:J.description})]})]},fe))})]})]});return i.jsxs(i.Fragment,{children:[i.jsx(qs,{type:"agent",name:x.id,onBack:()=>y(null),readOnly:!0,initialManifest:ae,actionSlot:i.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:a("agentStore.hireAgent")}),contentSlot:H}),C&&i.jsx(vk,{template:x,lang:l,onClose:()=>S(!1),onHire:G}),L&&i.jsx(ba,{alertOnly:!0,variant:L.variant??"danger",title:L.title,message:L.message,onConfirm:()=>F(null),onCancel:()=>F(null)})]})}return i.jsxs("div",{className:"flex-1 overflow-hidden flex flex-col",children:[i.jsxs("div",{"data-electron-drag":!0,className:"px-6 h-14 flex items-center justify-between shrink-0 gap-3",children:[i.jsx("h2",{className:"text-lg font-semibold",children:a("agentStore.title")}),i.jsx("input",{type:"text",placeholder:a("agentStore.searchPlaceholder"),value:c,onChange:ae=>d(ae.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"})]}),i.jsx("div",{className:"flex-1 overflow-y-auto p-7 space-y-8",children:E?i.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-4",children:Array.from({length:6}).map((ae,H)=>i.jsx("div",{className:"h-56 rounded-2xl skeleton"},H))}):m.length===0&&h.length===0?i.jsxs("div",{className:"text-center py-20",children:[i.jsx("div",{className:"text-4xl mb-4 opacity-30",children:"⧉"}),i.jsx("div",{className:"text-fg-secondary font-medium mb-1",children:c?a("agentStore.noResults",{search:c}):a("agentStore.noAgents")}),i.jsx("div",{className:"text-fg-tertiary text-sm",children:a(c?"agentStore.noResultsHint":"agentStore.noAgentsHint")})]}):i.jsxs(i.Fragment,{children:[m.length>0&&i.jsxs("section",{children:[i.jsxs("div",{className:"flex items-baseline gap-2 mb-3",children:[i.jsx("h3",{className:"section-title",children:a("agentStore.builtin")}),i.jsx("span",{className:"text-xs text-fg-tertiary",children:a("agentStore.available",{count:m.length})})]}),i.jsx(Fa,{columns:3,children:m.map(ae=>i.jsx(vr,{type:"agent",name:Pm(ae,l),description:xk(ae,l),seed:ae.id,icon:ae.icon,version:ae.version,category:ae.category,tags:ae.tags,authorLabel:ae.author,hideStats:!0,showTypeBadge:!1,cornerLabel:a("agentStore.builtin"),onClick:()=>y(ae)},ae.id))})]}),h.length>0&&i.jsxs("section",{children:[i.jsx("h3",{className:"section-title mb-3",children:a("agentStore.markusHub")}),i.jsx(Fa,{columns:3,children:h.map(ae=>i.jsx(Gre,{item:ae,localInfo:M.get(Fc(ae)),purchased:cm(ae,R),onStatusChange:ne,highlight:ae.id===t,onHighlightDone:n,onViewDetail:H=>Y({type:"agent",name:H})},ae.id))})]})]})}),C&&x&&i.jsx(vk,{template:x,lang:l,onClose:()=>S(!1),onHire:G}),L&&i.jsx(ba,{alertOnly:!0,variant:L.variant??"danger",title:L.title,message:L.message,onConfirm:()=>F(null),onCancel:()=>F(null)})]})}function Fc(e,t){if(e.slug&&e.slug.trim())return e.slug.trim();const n=t&&typeof t.name=="string"?t.name.trim():"";return mm(n||e.name,"hub-pkg")}function Is(e){return(async()=>{const t=await st.download(e.id),n=t.name||e.name,a=t.config??{},s=Fc(e,a),l=t.itemType==="team"?"team":t.itemType==="skill"?"skill":"agent",c={type:"hub",hubItemId:e.id},d=(t.version||e.version||(typeof a.version=="string"?a.version:"")||"").trim()||void 0;if(t.files&&Object.keys(t.files).length>0)await Ae.builder.artifacts.import(l,s,t.files,c,d);else{const m={...a,...d?{version:d}:{},name:s,displayName:a.displayName||n,description:e.description,source:c};await Ae.builder.artifacts.save(l,m)}return await Ae.builder.artifacts.install(l,s),window.dispatchEvent(new CustomEvent("markus:data-changed")),n})()}async function vb(e,t){t("checking"),await st.ensureAuth();const n=await st.purchases.checkout(e.id);if(n.alreadyOwned)return t("installing"),await Is(e),"installed";try{if((await st.creator.getBalance()).availableBalance>=(e.priceCents??0)){const c=await st.purchases.payWithEarnings(e.id);if(c.ok||c.alreadyOwned)return t("installing"),await Is(e),"installed"}}catch{}if(!n.checkoutUrl)throw new Error("No checkout URL");t("checkout_opened");const a=Go();let s=null;return a?fi(n.checkoutUrl):s=window.open(n.checkoutUrl,"_blank","noopener"),new Promise((l,c)=>{const d=Date.now(),m=300*1e3,p=setInterval(async()=>{if(Date.now()-d>m){clearInterval(p),l("cancelled");return}const g=!a&&s?s.closed:!1;try{if((await st.purchases.checkout(e.id)).alreadyOwned){clearInterval(p),t("installing");try{await Is(e),l("installed")}catch(y){c(y)}return}}catch{}if(g){clearInterval(p);try{if((await st.purchases.checkout(e.id)).alreadyOwned){t("installing"),await Is(e),l("installed");return}}catch{}l("cancelled")}},2e3)})}function Gre({item:e,localInfo:t,purchased:n,onStatusChange:a,highlight:s,onHighlightDone:l,onViewDetail:c}){const{t:d}=ot(["store"]),[m,p]=k.useState(!1),[h,g]=k.useState(""),x=k.useRef(null),[y,w]=k.useState(!1);k.useEffect(()=>{if(s&&x.current){x.current.scrollIntoView({behavior:"smooth",block:"center"}),w(!0);const K=setTimeout(()=>{w(!1)},4e3);return()=>clearTimeout(K)}},[s,l]);const T=t?.installed??!1,C=T&&e.version&&t?.localVersion&&qre(e.version,t.localVersion),S=(e.priceCents??0)>0,E=async K=>{if(K.stopPropagation(),!m){p(!0),g("");try{await Is(e),g(C?d("card.upgraded"):d("card.installed")+"!"),a()}catch(Y){const L=Y instanceof Error?Y.message:"";L.includes("402")||L.includes("Purchase required")?g(d("card.purchaseRequired")):g(d("card.failed"))}finally{p(!1)}}},_=async K=>{if(K.stopPropagation(),!m){p(!0),g("");try{await vb(e,L=>{L==="checkout_opened"?g(d("card.waitingPurchase","Waiting for purchase...")):L==="installing"&&g(d("card.installing"))})==="installed"?(g(d("card.installed")+"!"),a()):g("")}catch(Y){g(Y instanceof Error?Y.message:d("card.failed"))}finally{p(!1)}}},M=S?`$${((e.priceCents??0)/100).toFixed(2)}`:null,P=e.slug&&e.author?.username?`${st.getUrl()}/@${encodeURIComponent(e.author.username)}/${encodeURIComponent(e.slug)}`:null,R=()=>{T&&c?c(Fc(e)):P&&window.open(P,"_blank","noopener,noreferrer")},I=i.jsxs(i.Fragment,{children:[C?i.jsx("button",{onClick:K=>{E(K)},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?i.jsxs("button",{onClick:K=>{E(K)},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?i.jsx("button",{onClick:K=>{_(K)},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"):i.jsxs(i.Fragment,{children:[d("card.buy","Buy")," ",M]})}):i.jsx("button",{onClick:K=>{E(K)},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)&&i.jsx("span",{className:`text-[10px] ${h===d("card.failed")||h===d("card.purchaseRequired")?"text-red-500":"text-green-600"}`,children:h})]});return i.jsx("div",{ref:x,className:y?"animate-pulse":"",children:i.jsx(vr,{type:"agent",showTypeBadge:!1,name:e.name,description:e.description,seed:e.slug||e.name,icon:e.icon||"bot",cover:e.thumbnailUrl,hubBase:st.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:y,onClick:R,actions:I})})}function vk({template:e,lang:t,onClose:n,onHire:a}){const{t:s}=ot(["store"]),[l,c]=k.useState(`${Pm(e,t)} Agent`),[d,m]=k.useState(""),[p,h]=k.useState([]),[g,x]=k.useState(!1);k.useEffect(()=>{fetch("/api/teams",{credentials:"include"}).then(w=>w.json()).then(w=>h(w.teams??[])).catch(()=>{})},[]);const y=async()=>{if(l.trim()){x(!0);try{await a(e.id,l.trim(),d||void 0)}finally{x(!1)}}};return i.jsx("div",{className:"fixed inset-0 bg-black/60 flex items-center justify-center z-50",onClick:n,children:i.jsxs("div",{className:"bg-surface-secondary border border-border-default rounded-xl p-6 w-[440px] shadow-2xl",onClick:w=>w.stopPropagation(),children:[i.jsx("div",{className:"flex items-center gap-3 mb-5",children:i.jsxs("div",{children:[i.jsx("h3",{className:"text-base font-semibold",children:s("hireModal.title")}),i.jsx("p",{className:"text-xs text-fg-tertiary",children:s("hireModal.creating",{name:Pm(e,t)})})]})}),i.jsxs("div",{className:"space-y-4",children:[i.jsxs("div",{children:[i.jsx("label",{className:"block text-xs text-fg-tertiary mb-1.5",children:s("hireModal.agentName")}),i.jsx("input",{type:"text",value:l,onChange:w=>c(w.target.value),className:"input-field",autoFocus:!0})]}),p.length>0&&i.jsxs("div",{children:[i.jsx("label",{className:"block text-xs text-fg-tertiary mb-1.5",children:s("hireModal.assignTeam")}),i.jsxs("select",{value:d,onChange:w=>m(w.target.value),className:"input-field",children:[i.jsx("option",{value:"",children:s("hireModal.noTeam")}),p.map(w=>i.jsx("option",{value:w.id,children:w.name},w.id))]})]}),i.jsxs("div",{className:"bg-surface-elevated/50 rounded-lg p-3",children:[i.jsx("div",{className:"text-xs text-fg-tertiary mb-2 font-medium",children:s("hireModal.agentConfig")}),i.jsxs("div",{className:"grid grid-cols-2 gap-y-1.5 gap-x-4 text-xs",children:[i.jsx("div",{className:"text-fg-tertiary",children:s("hireModal.role")}),i.jsx("div",{className:"text-fg-secondary font-mono",children:e.roleId}),i.jsx("div",{className:"text-fg-tertiary",children:s("hireModal.position")}),i.jsx("div",{className:"text-fg-secondary capitalize",children:e.agentRole}),i.jsx("div",{className:"text-fg-tertiary",children:s("hireModal.skills")}),i.jsx("div",{className:"text-fg-secondary",children:e.skills.join(", ")||s("hireModal.none")})]})]})]}),i.jsxs("div",{className:"flex justify-end gap-3 mt-6",children:[i.jsx("button",{onClick:n,className:"btn-secondary",children:s("hireModal.cancel")}),i.jsx("button",{onClick:y,disabled:!l.trim()||g,className:"btn-primary",children:s(g?"hireModal.creating_progress":"hireModal.create")})]})]})})}function yh(e,t){const n=e.i18n?.[t];return n?.displayName||n?.name||e.name}function wk(e,t){return e.i18n?.[t]?.description||e.description}function kk(e,t,n){return e.i18n?.[n]?.members?.[t]||t}function Kre(e,t){const n=e.split(".").map(Number),a=t.split(".").map(Number);for(let s=0;s<Math.max(n.length,a.length);s++){const l=n[s]??0,c=a[s]??0;if(l>c)return!0;if(l<c)return!1}return!1}function Vre({highlightItemId:e,onHighlightDone:t}={}){const{t:n,i18n:a}=ot(["store","common"]),s=a.language,[l,c]=k.useState(""),[d,m]=k.useState([]),[p,h]=k.useState([]),[g,x]=k.useState(null),[y,w]=k.useState({}),[T,C]=k.useState(!0),[S,E]=k.useState(!1),[_,M]=k.useState(null),[P,R]=k.useState(new Map),[I,K]=k.useState(new Set),[Y,L]=k.useState(null),F=k.useCallback(async()=>{try{const[G,ae]=await Promise.all([Ae.builder.artifacts.list().catch(()=>({artifacts:[]})),Ae.builder.artifacts.installed().catch(()=>({installed:{}}))]),H=new Map;for(const J of G.artifacts){if(J.type!=="team")continue;const fe=!!ae.installed[`team/${J.name}`];H.set(J.name,{installed:fe,localVersion:J.meta.version||void 0,localUpdatedAt:J.updatedAt})}R(H)}catch{}},[]),ne=k.useCallback(async()=>{C(!0);try{const G=l?st.search({type:"team",q:l,limit:50}):Ls(qa.hubTeams)??st.search({type:"team",limit:50}),[ae,H]=await Promise.all([G.catch(()=>({items:[],total:0})),Ae.teamTemplates.list(l||void 0).catch(()=>({templates:[]})),F(),st.isAuthenticated()?st.purchases.mine().then(fe=>K(new Set(fe.purchases.map(Ce=>Ce.itemId)))).catch(()=>{}):Promise.resolve()]),J=await s6(ae?.items??[],e);h(J.items),m(H?.templates??[]),J.missing&&t?.()}catch{m([]),h([])}finally{C(!1)}},[l,F,e,t]);k.useEffect(()=>{ne()},[ne]),k.useEffect(()=>{if(!g){w({});return}fetch(`/api/team-templates/${encodeURIComponent(g.id)}/files`,{credentials:"include"}).then(G=>G.json()).then(G=>w(G.files??{})).catch(()=>w({}))},[g]);const ee=async G=>{E(!0),M(null);try{const H=(await Ae.teams.create(G.name,G.description)).team.id;let J,fe=0;const Ce=[];for(const V of G.members){const pe=V.count??1;for(let z=0;z<pe;z++){const je=V.name??`${G.name} Agent ${z+1}`,Ue=pe>1?`${je} ${z+1}`:je,qe=V.roleName??V.templateId;try{const He=await fetch("/api/agents",{method:"POST",headers:{"Content-Type":"application/json"},credentials:"include",body:JSON.stringify({name:Ue,...qe?{roleName:qe}:{},orgId:"default",teamId:H,agentRole:V.role??"worker",skills:V.skills??[]})});if(He.ok){fe++;const ut=await He.json();V.role==="manager"&&!J&&(J=ut.agent?.id)}else{const ut=await He.json().catch(()=>({error:`HTTP ${He.status}`}));Ce.push(`${Ue}: ${ut.error??He.statusText}`)}}catch(He){Ce.push(`${Ue}: ${String(He)}`)}}}J&&await Ae.teams.update(H,{managerId:J,managerType:"agent"}).catch(()=>{});const $=Ce.length>0?` (${Ce.length} failed: ${Ce[0]})`:"";M({ok:fe>0,message:`Team "${yh(G,s)}" deployed with ${fe} agent(s)${$}`})}catch(ae){M({ok:!1,message:`Failed: ${ae}`})}finally{E(!1)}};if(Y)return i.jsx(qs,{type:Y.type,name:Y.name,onBack:()=>L(null)});if(g){const G={...y};g.announcements&&(G["ANNOUNCEMENT.md"]=g.announcements),g.norms&&(G["NORMS.md"]=g.norms);const ae={type:"team",name:g.id,displayName:yh(g,s),version:g.version,description:wk(g,s),author:g.author,category:g.category??"general",tags:g.tags??[],files:G,team:{members:g.members.map(J=>({name:kk(g,J.name??J.roleName??J.templateId??"Agent",s),role:J.role??"worker",roleName:J.roleName??J.templateId,count:J.count??1,skills:J.skills??[]}))}},H=i.jsxs("div",{className:"rounded-xl border border-border-default bg-surface-secondary/40 overflow-hidden",children:[i.jsx("div",{className:"px-5 py-3 border-b border-border-default bg-surface-elevated/30",children:i.jsx("h3",{className:"text-xs text-fg-tertiary uppercase tracking-wider",children:n("teamStore.teamComposition")})}),i.jsx("div",{className:"p-5 space-y-2",children:g.members.map((J,fe)=>{const Ce=kk(g,J.name??J.roleName??J.templateId??"Agent",s);return i.jsxs("div",{className:"flex items-center gap-3 bg-surface-elevated/50 rounded-lg p-3",children:[i.jsx("div",{className:`w-9 h-9 rounded-lg flex items-center justify-center text-sm font-bold shrink-0 ${J.role==="manager"?"bg-amber-500/15 text-amber-400 ring-1 ring-amber-500/30":"bg-blue-500/15 text-blue-400 ring-1 ring-blue-500/30"}`,children:(Ce[0]??"?").toUpperCase()}),i.jsxs("div",{className:"min-w-0 flex-1",children:[i.jsxs("div",{className:"flex items-center gap-2",children:[i.jsx("span",{className:"text-sm text-fg-primary font-medium",children:Ce}),i.jsx("span",{className:`px-1.5 py-0.5 rounded text-[10px] capitalize font-medium ${J.role==="manager"?"bg-amber-500/15 text-amber-400":"bg-blue-500/15 text-blue-400"}`,children:J.role??"worker"}),(J.count??1)>1&&i.jsxs("span",{className:"text-[10px] text-fg-muted",children:["×",J.count]})]}),(J.roleName||J.templateId)&&i.jsx("div",{className:"text-[10px] text-fg-tertiary font-mono mt-0.5",children:J.roleName??J.templateId})]}),J.skills&&J.skills.length>0&&i.jsxs("div",{className:"flex flex-wrap gap-1 shrink-0",children:[J.skills.slice(0,3).map($=>i.jsx("span",{className:"px-1.5 py-0.5 text-[9px] bg-surface-elevated text-fg-muted rounded border border-border-default",children:$},$)),J.skills.length>3&&i.jsxs("span",{className:"text-[9px] text-fg-muted",children:["+",J.skills.length-3]})]})]},fe)})})]});return i.jsx(i.Fragment,{children:i.jsx(qs,{type:"team",name:g.id,onBack:()=>{x(null),M(null)},readOnly:!0,initialManifest:ae,contentSlot:H,actionSlot:i.jsxs(i.Fragment,{children:[_&&i.jsx("span",{className:`text-xs ${_.ok?"text-green-500":"text-red-500"}`,children:_.message}),i.jsx("button",{onClick:()=>{ee(g)},disabled:S,className:"px-4 py-1.5 text-xs bg-brand-600 hover:bg-brand-500 text-white rounded-lg transition-colors font-medium disabled:opacity-50",children:n(S?"teamStore.deploying":"teamStore.deployTeam")})]})})})}return i.jsxs("div",{className:"flex-1 overflow-hidden flex flex-col",children:[i.jsxs("div",{"data-electron-drag":!0,className:"px-6 h-14 flex items-center justify-between shrink-0 gap-3",children:[i.jsx("h2",{className:"text-lg font-semibold",children:n("teamStore.title")}),i.jsx("input",{type:"text",placeholder:n("teamStore.searchPlaceholder"),value:l,onChange:G=>c(G.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"})]}),i.jsx("div",{className:"flex-1 overflow-y-auto p-7 space-y-8",children:T?i.jsx("div",{className:"grid grid-cols-1 lg:grid-cols-2 gap-4",children:Array.from({length:4}).map((G,ae)=>i.jsx("div",{className:"h-56 rounded-2xl skeleton"},ae))}):d.length===0&&p.length===0?i.jsxs("div",{className:"text-center py-20",children:[i.jsx("div",{className:"text-4xl mb-4 opacity-30",children:"◉"}),i.jsx("div",{className:"text-fg-secondary font-medium mb-1",children:l?n("teamStore.noResults",{search:l}):n("teamStore.noTeams")}),i.jsx("div",{className:"text-fg-tertiary text-sm",children:n(l?"teamStore.noResultsHint":"teamStore.noTeamsHint")})]}):i.jsxs(i.Fragment,{children:[d.length>0&&i.jsxs("section",{children:[i.jsxs("div",{className:"flex items-baseline gap-2 mb-3",children:[i.jsx("h3",{className:"section-title",children:n("teamStore.builtin")}),i.jsx("span",{className:"text-xs text-fg-tertiary",children:n("teamStore.available",{count:d.length})})]}),i.jsx(Fa,{columns:2,children:d.map(G=>i.jsx(vr,{type:"team",name:yh(G,s),description:wk(G,s),seed:G.id,icon:G.icon||"users",version:G.version,category:G.category,tags:G.tags,authorLabel:G.author,hideStats:!0,showTypeBadge:!1,cornerLabel:n("teamStore.builtin"),onClick:()=>x(G)},G.id))})]}),p.length>0&&i.jsxs("section",{children:[i.jsx("h3",{className:"section-title mb-3",children:n("teamStore.markusHub")}),i.jsx(Fa,{columns:2,children:p.map(G=>i.jsx(Wre,{item:G,localInfo:P.get(Fc(G)),purchased:cm(G,I),onStatusChange:F,highlight:G.id===e,onHighlightDone:t,onViewDetail:ae=>L({type:"team",name:ae})},G.id))})]})]})})]})}function Wre({item:e,localInfo:t,purchased:n,onStatusChange:a,highlight:s,onHighlightDone:l,onViewDetail:c}){const{t:d}=ot(["store"]),[m,p]=k.useState(!1),[h,g]=k.useState(""),x=k.useRef(null),[y,w]=k.useState(!1);k.useEffect(()=>{if(s&&x.current){x.current.scrollIntoView({behavior:"smooth",block:"center"}),w(!0);const K=setTimeout(()=>{w(!1)},4e3);return()=>clearTimeout(K)}},[s,l]);const T=t?.installed??!1,C=T&&e.version&&t?.localVersion&&Kre(e.version,t.localVersion),S=(e.priceCents??0)>0,E=S?`$${((e.priceCents??0)/100).toFixed(2)}`:null,_=async K=>{if(K.stopPropagation(),!m){p(!0),g("");try{await Is(e),g(C?d("card.upgraded"):d("card.installed")+"!"),a()}catch(Y){const L=Y instanceof Error?Y.message:"";L.includes("402")||L.includes("Purchase required")?g(d("card.purchaseRequired")):g(d("card.failed"))}finally{p(!1)}}},M=async K=>{if(K.stopPropagation(),!m){p(!0),g("");try{await vb(e,L=>{L==="checkout_opened"?g(d("card.waitingPurchase","Waiting for purchase...")):L==="installing"&&g(d("card.installing"))})==="installed"?(g(d("card.installed")+"!"),a()):g("")}catch(Y){g(Y instanceof Error?Y.message:d("card.failed"))}finally{p(!1)}}},P=e.slug&&e.author?.username?`${st.getUrl()}/@${encodeURIComponent(e.author.username)}/${encodeURIComponent(e.slug)}`:null,R=()=>{T&&c?c(Fc(e)):P&&window.open(P,"_blank","noopener,noreferrer")},I=i.jsxs(i.Fragment,{children:[C?i.jsx("button",{onClick:K=>{_(K)},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?i.jsxs("button",{onClick:K=>{_(K)},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?i.jsx("button",{onClick:K=>{M(K)},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"):i.jsxs(i.Fragment,{children:[d("card.buy","Buy")," ",E]})}):i.jsx("button",{onClick:K=>{_(K)},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&&i.jsx("span",{className:`text-[10px] ${h===d("card.failed")||h===d("card.purchaseRequired")?"text-red-500":"text-green-600"}`,children:h})]});return i.jsx("div",{ref:x,className:y?"animate-pulse":"",children:i.jsx(vr,{type:"team",showTypeBadge:!1,name:e.name,description:e.description,seed:e.slug||e.name,icon:e.icon||"users",cover:e.thumbnailUrl,hubBase:st.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:y,onClick:R,actions:I})})}function xh(e,t){return e.i18n?.[t]?.displayName||e.name}function vh(e,t){return e.i18n?.[t]?.description||e.description||""}function o6(e,t){const n=e.split(".").map(Number),a=t.split(".").map(Number);for(let s=0;s<Math.max(n.length,a.length);s++){const l=n[s]??0,c=a[s]??0;if(l>c)return!0;if(l<c)return!1}return!1}const Yre={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 Qre({item:e,installedSkills:t,purchased:n,onMsg:a,onRefresh:s}){const{t:l}=ot(["store"]),[c,d]=k.useState(!1),m=e.name.toLowerCase().trim().replace(/\s+/g,"-").replace(/[\/\\:*?"<>|]+/g,"").replace(/-{2,}/g,"-").replace(/^-|-$/g,"")||"unnamed",p=t.find(S=>S.name===e.name||S.name===m||!!e.slug&&S.name===e.slug),h=!!p,g=h&&e.version&&p?.version&&o6(e.version,p.version),x=(e.priceCents??0)>0,[y,w]=k.useState(""),T=async()=>{if(!c){d(!0),w("");try{await Is(e),a(g?`Upgraded ${e.name}`:`Installed ${e.name}`,"success"),s()}catch(S){const E=S instanceof Error?S.message:"";E.includes("402")||E.includes("Purchase required")?a(l("card.purchaseRequired"),"error"):a(l("card.failed"),"error")}finally{d(!1)}}},C=async()=>{if(!c){d(!0),w("");try{await vb(e,E=>{E==="checkout_opened"?w(l("card.waitingPurchase","Waiting for purchase...")):E==="installing"&&w(l("card.installing"))})==="installed"&&(a(`Purchased & installed ${e.name}`,"success"),s()),w("")}catch(S){a(S instanceof Error?S.message:l("card.failed"),"error"),w("")}finally{d(!1)}}};if(g)return i.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 i.jsxs("span",{className:"px-2.5 py-1 text-[10px] bg-surface-overlay text-fg-secondary rounded-lg",children:[l("card.installed"),p?.version?` (v${p.version})`:""]});if(x&&!n){const S=`$${((e.priceCents??0)/100).toFixed(2)}`;return i.jsx("span",{className:"inline-flex items-center gap-1.5",children:i.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?y||l("card.installing"):i.jsxs(i.Fragment,{children:[l("card.buy","Buy")," ",S]})})})}return i.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 Sk({item:e,installedSkills:t,purchased:n,onMsg:a,onRefresh:s,highlight:l,onHighlightDone:c,type:d="skill"}){const m=k.useRef(null),[p,h]=k.useState(!1);k.useEffect(()=>{if(l&&m.current){m.current.scrollIntoView({behavior:"smooth",block:"center"}),h(!0);const y=setTimeout(()=>{h(!1)},4e3);return()=>clearTimeout(y)}},[l,c]);const g=e.slug&&e.author?.username?`${st.getUrl()}/@${encodeURIComponent(e.author.username)}/${encodeURIComponent(e.slug)}`:null,x=()=>{g&&window.open(g,"_blank","noopener,noreferrer")};return i.jsx("div",{ref:m,className:p?"animate-pulse":"",children:i.jsx(vr,{type:d,showTypeBadge:d!=="skill",name:e.name,description:e.description,seed:e.slug||e.name,icon:e.icon||tm(e.slug||e.name,e.category),cover:e.thumbnailUrl,hubBase:st.getUrl(),author:e.author,version:e.version,category:e.category,tags:e.tags,rating:parseFloat(e.avgRating)||0,ratingCount:e.ratingCount,downloadCount:e.downloadCount,priceCents:e.priceCents,currency:e.currency,onClick:x,actions:i.jsx(Qre,{item:e,installedSkills:t,purchased:n,onMsg:a,onRefresh:s})})})}function Xre({highlightItemId:e,onHighlightDone:t}={}){const{t:n,i18n:a}=ot(["store","common"]),s=a.language,l=Xo(),[c,d]=k.useState("skills"),[m,p]=k.useState(null),[h,g]=k.useState(new Set),[x,y]=k.useState([]),[w,T]=k.useState(null),[C,S]=k.useState([]),[E,_]=k.useState(0),[M,P]=k.useState(1),[R,I]=k.useState([]),[K,Y]=k.useState(""),[L,F]=k.useState("score"),[ne,ee]=k.useState(""),[G,ae]=k.useState(!1),[H,J]=k.useState([]),[fe,Ce]=k.useState(!1),[$,V]=k.useState([]),[pe,z]=k.useState(""),[je,Ue]=k.useState(!1),[qe,He]=k.useState([]),[ut,dt]=k.useState([]),[Nt,wt]=k.useState(new Set),[Zt,Wt]=k.useState(!1),[rt,$e]=k.useState(""),mt=[{id:"skills",labelKey:"skillStore.tabs.all"},{id:"skillhub",labelKey:"skillStore.tabs.skillhub"},{id:"skillssh",labelKey:"skillStore.tabs.skillssh"}],At=(q,te="success")=>{p({text:q,type:te}),setTimeout(()=>p(null),te==="error"?1e4:4e3)},Dt=k.useCallback(async()=>{try{const q=await Ae.skills.list();y(q.skills)}catch{}},[]),ln=k.useCallback(async()=>{Ce(!0);try{const q=await Ae.skills.builtin();J(q.skills)}catch{}Ce(!1)},[]),ce=k.useCallback(async q=>{ae(!0);try{const te=await Ae.skills.registrySkillhub({q:q?.q,category:q?.category,page:q?.page??1,limit:24,sort:q?.sort??L});S(te.skills),_(te.total),te.categories?.length&&I(te.categories)}catch{}ae(!1)},[L]),et=k.useCallback(async q=>{Ue(!0);try{const te=await Ae.skills.registrySkillssh(q);V(te.skills)}catch{}Ue(!1)},[]),nt=k.useCallback(async q=>{Wt(!0);try{const te=q?st.search({type:"skill",q,limit:50}):Ls(qa.hubSkills)??st.search({type:"skill",limit:50}),Se=st.search({subtype:"connector",q:q||void 0,limit:50}).catch(()=>({items:[]})),[De,Pe]=await Promise.all([te,Se,st.isAuthenticated()?st.purchases.mine().then(ue=>wt(new Set(ue.purchases.map(Be=>Be.itemId)))).catch(()=>{}):Promise.resolve()]);let Q=De?.items??[],X=Pe?.items??[];if(e){const ue=Q.some(Ie=>Ie.id===e),Be=X.some(Ie=>Ie.id===e);if(!ue&&!Be)try{const{item:Ie}=await st.getItem(e);Ie?.subtype==="connector"?X=[Ie,...X]:Ie?Q=[Ie,...Q]:t?.()}catch{t?.()}else ue&&(Q=[Q.find(Ge=>Ge.id===e),...Q.filter(Ge=>Ge.id!==e)]),Be&&(X=[X.find(Ge=>Ge.id===e),...X.filter(Ge=>Ge.id!==e)])}He(Q),dt(X)}catch{}Wt(!1)},[e,t]);k.useEffect(()=>{Dt(),ln(),ce(),et()},[]),k.useEffect(()=>{c==="skills"&&nt(rt)},[c,rt,nt]);const we=async q=>{g(te=>new Set(te).add(q.name));try{const te=await Ae.skills.install({name:q.name,source:"skillhub",slug:q.slug,sourceUrl:q.homepage,description:q.description_zh??q.description,category:"custom",version:q.version});await Dt(),At(`"${q.name}" installed (${te.method}) → ${te.path}`),window.dispatchEvent(new CustomEvent("markus:data-changed"))}catch{At(`Download failed for "${q.name}". You can try manually from: ${q.homepage}`,"error")}g(te=>{const Se=new Set(te);return Se.delete(q.name),Se})},Me=async q=>{g(te=>new Set(te).add(q.name));try{const te=await Ae.skills.install({name:q.name,source:"skillssh",sourceUrl:q.url,githubRepo:`${q.author}/${q.repo}`,githubSkillPath:q.name});await Dt(),At(`"${q.name}" installed (${te.method}) → ${te.path}`),window.dispatchEvent(new CustomEvent("markus:data-changed"))}catch{At(`Download failed for "${q.name}". You can try manually from: ${q.url}`,"error")}g(te=>{const Se=new Set(te);return Se.delete(q.name),Se})},Ne=async q=>{g(te=>new Set(te).add(q.name));try{const te=await Ae.skills.install({name:q.name,source:"builtin"});await Dt(),await ln(),At(`"${q.name}" installed (${te.method}) → ${te.path}`),window.dispatchEvent(new CustomEvent("markus:data-changed"))}catch(te){At(`Install failed for "${q.name}": ${te}`,"error")}g(te=>{const Se=new Set(te);return Se.delete(q.name),Se})},se=$.filter(q=>{if(!pe)return!0;const te=pe.toLowerCase();return q.name.toLowerCase().includes(te)||q.repo.toLowerCase().includes(te)});if(w){const q=w,te={};q.instructions&&(te["SKILL.md"]=q.instructions);const Se={type:"skill",name:q.name,displayName:xh(q,s),version:q.version,description:vh(q,s),author:q.author??"",category:q.category??"general",tags:q.tags,files:te,skill:{skillFile:q.instructions?"SKILL.md":"",requiredPermissions:q.requiredPermissions,mcpServers:void 0,alwaysOn:!1}},De=q.installed&&q.installedVersion&&o6(q.version,q.installedVersion)?i.jsx("button",{onClick:()=>{Ne(q)},disabled:h.has(q.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(q.name)?n("card.upgrading"):n("card.upgrade",{version:q.version})}):q.installed?i.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:[i.jsx("svg",{className:"w-3 h-3",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",children:i.jsx("polyline",{points:"20 6 9 17 4 12"})}),n("card.installed"),q.installedVersion?` v${q.installedVersion}`:""]}):i.jsx("button",{onClick:()=>{Ne(q)},disabled:h.has(q.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(q.name)?n("card.installing"):n("card.install")}),Pe=i.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[i.jsxs("div",{className:"rounded-xl border border-border-default bg-surface-secondary/40 p-5",children:[i.jsx("h3",{className:"text-xs text-fg-tertiary uppercase tracking-wider mb-3",children:n("skillStore.details")}),i.jsxs("div",{className:"space-y-2.5 text-sm",children:[q.category&&i.jsxs("div",{className:"flex items-center gap-2",children:[i.jsx("span",{className:"text-fg-tertiary w-24",children:n("skillStore.category")}),i.jsx("span",{className:`px-2 py-0.5 rounded-full text-[10px] font-medium capitalize ${Yre[q.category]??"bg-gray-500/15 text-fg-secondary"}`,children:q.category})]}),i.jsxs("div",{className:"flex items-center gap-2",children:[i.jsx("span",{className:"text-fg-tertiary w-24",children:n("skillStore.version")}),i.jsx("span",{className:"text-fg-secondary font-mono text-xs",children:q.version})]}),q.hasMcpServers&&i.jsxs("div",{className:"flex items-center gap-2",children:[i.jsx("span",{className:"text-fg-tertiary w-24",children:n("skillStore.integration")}),i.jsx("span",{className:"px-2 py-0.5 rounded text-[10px] bg-purple-500/15 text-purple-400",children:"MCP"})]}),q.hasInstructions&&i.jsxs("div",{className:"flex items-center gap-2",children:[i.jsx("span",{className:"text-fg-tertiary w-24",children:n("skillStore.instructions")}),i.jsx("span",{className:"text-green-500 text-xs",children:"✓"})]})]})]}),(q.requiredPermissions.length>0||q.tags.length>0)&&i.jsxs("div",{className:"space-y-4",children:[q.requiredPermissions.length>0&&i.jsxs("div",{className:"rounded-xl border border-border-default bg-surface-secondary/40 p-5",children:[i.jsx("h3",{className:"text-xs text-fg-tertiary uppercase tracking-wider mb-3",children:n("skillStore.permissions")}),i.jsx("div",{className:"flex flex-wrap gap-1.5",children:q.requiredPermissions.map(Q=>i.jsx("span",{className:"px-2.5 py-1 text-xs bg-amber-500/10 text-amber-500 rounded-lg border border-amber-500/20",children:Q},Q))})]}),q.tags.length>0&&i.jsxs("div",{className:"rounded-xl border border-border-default bg-surface-secondary/40 p-5",children:[i.jsx("h3",{className:"text-xs text-fg-tertiary uppercase tracking-wider mb-3",children:n("skillStore.tags")}),i.jsx("div",{className:"flex flex-wrap gap-1.5",children:q.tags.map(Q=>i.jsx("span",{className:"px-2.5 py-1 text-xs bg-surface-elevated text-fg-secondary rounded-lg border border-border-default/50",children:Q},Q))})]})]})]});return i.jsxs(i.Fragment,{children:[i.jsx(qs,{type:"skill",name:q.name,onBack:()=>T(null),readOnly:!0,initialManifest:Se,actionSlot:De,contentSlot:Pe}),m&&i.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 i.jsxs("div",{className:"flex-1 overflow-hidden flex flex-col",children:[i.jsxs("div",{className:`${l?"px-4":"px-6"} shrink-0`,children:[i.jsx("div",{"data-electron-drag":!0,className:"flex items-center h-14",children:i.jsx("h2",{className:"text-lg font-semibold",children:n("skillStore.title")})}),i.jsx("div",{className:`flex ${l?"flex-wrap":""} gap-1 pb-2 overflow-x-auto scrollbar-hide`,children:mt.map(q=>i.jsx("button",{onClick:()=>d(q.id),className:`px-3 py-1.5 text-xs rounded-lg transition-colors shrink-0 ${c===q.id?"bg-brand-600 text-white":"text-fg-secondary hover:text-fg-primary hover:bg-surface-elevated"}`,children:n(q.labelKey)},q.id))})]}),m&&i.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 q=rt.trim().toLowerCase(),te=q?H.filter(Pe=>xh(Pe,s).toLowerCase().includes(q)||vh(Pe,s).toLowerCase().includes(q)):H,Se=fe&&Zt,De=te.length===0&&qe.length===0&&ut.length===0;return i.jsxs("div",{className:`flex-1 overflow-y-auto ${l?"p-4":"p-6"} space-y-8`,children:[i.jsx("div",{className:"flex items-center gap-2",children:i.jsx("input",{value:rt,onChange:Pe=>$e(Pe.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"}`})}),Se&&De?i.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-4",children:Array.from({length:6}).map((Pe,Q)=>i.jsx("div",{className:"h-56 rounded-2xl skeleton"},Q))}):De?i.jsxs("div",{className:"text-center text-fg-tertiary py-20",children:[i.jsx("div",{className:"text-4xl mb-3 opacity-30",children:"◇"}),i.jsx("div",{children:n("skillStore.noBuiltin")}),i.jsx("div",{className:"text-xs mt-1",children:n("skillStore.noBuiltinHint")})]}):i.jsxs(i.Fragment,{children:[te.length>0&&i.jsxs("section",{children:[i.jsxs("div",{className:"flex items-baseline gap-2 mb-3",children:[i.jsx("h3",{className:"section-title",children:n("skillStore.tabs.builtin")}),i.jsx("span",{className:"text-xs text-fg-tertiary",children:n("skillStore.builtinCount",{count:te.length})})]}),i.jsx(Fa,{columns:3,children:te.map(Pe=>i.jsx(vr,{type:"skill",name:xh(Pe,s),description:vh(Pe,s),seed:Pe.name,icon:tm(Pe.name,Pe.category),version:Pe.version,category:Pe.category,tags:Pe.tags,authorLabel:Pe.author||void 0,installed:Pe.installed,hideStats:!0,showTypeBadge:!1,cornerLabel:Pe.installed?void 0:n("skillStore.tabs.builtin"),onClick:()=>T(Pe)},Pe.name))})]}),qe.length>0&&i.jsxs("section",{children:[i.jsx("h3",{className:"section-title mb-3",children:n("skillStore.tabs.markusHub")}),i.jsx(Fa,{columns:3,children:qe.map(Pe=>i.jsx(Sk,{item:Pe,installedSkills:x,purchased:cm(Pe,Nt),onMsg:At,onRefresh:()=>{Dt(),nt(rt)},highlight:Pe.id===e,onHighlightDone:t},Pe.id))})]}),ut.length>0&&i.jsxs("section",{children:[i.jsxs("div",{className:"mb-3",children:[i.jsx("h3",{className:"section-title",children:n("tabs.connectors")}),i.jsx("p",{className:"text-xs text-fg-tertiary mt-0.5",children:n("connectorStore.emptyHint","连接器让智能体接入外部工具与服务 (MCP)")})]}),i.jsx(Fa,{columns:3,children:ut.map(Pe=>i.jsx(Sk,{item:Pe,type:"connector",installedSkills:x,purchased:cm(Pe,Nt),onMsg:At,onRefresh:()=>{Dt(),nt(rt)},highlight:Pe.id===e,onHighlightDone:t},Pe.id))})]})]})]})})(),c==="skillhub"&&i.jsxs("div",{className:`flex-1 overflow-y-auto ${l?"p-4":"p-6"}`,children:[i.jsxs("div",{className:"flex items-center gap-2 mb-3 flex-wrap",children:[i.jsxs("select",{value:K,onChange:q=>{Y(q.target.value),P(1),ce({q:ne||void 0,category:q.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:[i.jsx("option",{value:"",children:n("skillStore.allCategories")}),R.map(q=>i.jsx("option",{value:q,children:q},q))]}),i.jsxs("select",{value:L,onChange:q=>{F(q.target.value),P(1),ce({q:ne||void 0,category:K||void 0,page:1,sort:q.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:[i.jsx("option",{value:"score",children:n("skillStore.sortScore")}),i.jsx("option",{value:"downloads",children:n("skillStore.sortDownloads")}),i.jsx("option",{value:"stars",children:n("skillStore.sortStars")}),i.jsx("option",{value:"installs",children:n("skillStore.sortInstalls")})]}),!l&&i.jsx("span",{className:"text-xs text-fg-tertiary ml-auto",children:i.jsx("a",{href:"https://skillhub.tencent.com",target:"_blank",rel:"noopener noreferrer",className:"text-brand-500 hover:text-brand-500",children:n("skillStore.visitSite")})})]}),i.jsxs("div",{className:"flex items-center gap-2 mb-5",children:[i.jsx("input",{value:ne,onChange:q=>ee(q.target.value),onKeyDown:q=>{q.key==="Enter"&&(P(1),ce({q:ne||void 0,category:K||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"}),i.jsx("button",{onClick:()=>{P(1),ce({q:ne||void 0,category:K||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"})]}),G?i.jsx("div",{className:"text-center text-fg-tertiary py-20",children:i.jsx("div",{className:"animate-pulse",children:n("skillStore.loadingSkillhub")})}):C.length===0?i.jsxs("div",{className:"text-center text-fg-tertiary py-20",children:[i.jsx("div",{className:"text-4xl mb-3 opacity-30",children:"◎"}),i.jsx("div",{children:n("skillStore.noSkillhub")})]}):i.jsxs(i.Fragment,{children:[i.jsx("div",{className:"text-xs text-fg-tertiary mb-3",children:n("skillStore.skillhubTotal",{count:E.toLocaleString()})}),i.jsx(Fa,{columns:3,children:C.map(q=>{const te=x.some(Se=>Se.name===q.name||Se.name===q.slug);return i.jsx(vr,{type:"skill",name:q.name,description:q.description_zh??q.description??"",seed:q.slug,icon:tm(q.slug||q.name,q.tags?.[0]),version:q.version,authorLabel:"SkillHub",showTypeBadge:!1,tags:q.tags,installed:te,hideStats:!0,onClick:()=>window.open(q.homepage,"_blank","noopener,noreferrer"),footerLeft:i.jsxs("span",{className:"flex items-center gap-2 text-[10px] text-fg-tertiary",children:[q.stars>0&&i.jsxs("span",{className:"text-amber-600",children:["★ ",q.stars.toLocaleString()]}),q.downloads>0&&i.jsxs("span",{children:[q.downloads>=1e4?`${(q.downloads/1e4).toFixed(1)}万`:q.downloads.toLocaleString()," ",n("skillStore.downloads")]})]}),actions:te?void 0:i.jsx("button",{onClick:()=>{we(q)},disabled:h.has(q.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(q.name)?"...":n("card.install")})},q.slug)})}),E>24&&i.jsxs("div",{className:"flex items-center justify-center gap-2 mt-6",children:[i.jsx("button",{disabled:M<=1,onClick:()=>{const q=M-1;P(q),ce({q:ne||void 0,category:K||void 0,page:q})},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")}),i.jsx("span",{className:"text-xs text-fg-tertiary",children:n("skillStore.pageInfo",{current:M,total:Math.ceil(E/24)})}),i.jsx("button",{disabled:M>=Math.ceil(E/24),onClick:()=>{const q=M+1;P(q),ce({q:ne||void 0,category:K||void 0,page:q})},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"&&i.jsxs("div",{className:`flex-1 overflow-y-auto ${l?"p-4":"p-6"}`,children:[i.jsxs("div",{className:`flex ${l?"flex-wrap":""} items-center gap-2 mb-5`,children:[i.jsx("input",{value:pe,onChange:q=>z(q.target.value),onKeyDown:q=>{q.key==="Enter"&&pe.trim()&&et(pe)},placeholder:n("skillStore.searchSkillssh"),className:`px-3 py-1.5 bg-surface-elevated border border-border-default rounded-lg text-sm text-fg-primary focus:border-brand-500 outline-none ${l?"flex-1 min-w-0":"w-72"}`}),i.jsx("button",{onClick:()=>{pe.trim()&&et(pe)},className:"px-3 py-1.5 bg-brand-600 hover:bg-brand-500 text-white text-xs rounded-lg shrink-0",children:"Search"}),!l&&i.jsx("span",{className:"text-xs text-fg-tertiary ml-auto",children:i.jsx("a",{href:"https://skills.sh",target:"_blank",rel:"noopener noreferrer",className:"text-brand-500 hover:text-brand-500",children:n("skillStore.visitSite")})})]}),je?i.jsx("div",{className:"text-center text-fg-tertiary py-20",children:i.jsx("div",{className:"animate-pulse",children:n("skillStore.loadingSkillssh")})}):se.length===0?i.jsxs("div",{className:"text-center text-fg-tertiary py-20",children:[i.jsx("div",{className:"text-4xl mb-3 opacity-30",children:"⬡"}),i.jsx("div",{children:n("skillStore.browseSkillssh")}),i.jsx("div",{className:"text-xs mt-1",children:n("skillStore.browseSkillsshHint")})]}):i.jsx(Fa,{columns:3,children:se.map(q=>{const te=x.some(Se=>Se.name===q.name);return i.jsx(vr,{type:"skill",name:q.name,description:q.description||"",seed:`${q.author}-${q.name}`,icon:tm(q.name),authorLabel:`${q.author}/${q.repo}`,showTypeBadge:!1,installed:te,hideStats:!0,cornerLabel:te?void 0:"skills.sh",onClick:()=>window.open(q.url,"_blank","noopener,noreferrer"),footerLeft:q.installs?i.jsxs("span",{className:"text-[10px] text-fg-tertiary",children:[q.installs," installs"]}):void 0,actions:te?void 0:i.jsx("button",{onClick:()=>{Me(q)},disabled:h.has(q.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(q.name)?"...":n("card.install")})},`${q.author}-${q.name}`)})})]})]})}const Jre=["agent","team","skill","connector"];function wh({title:e,subtitle:t,onMore:n,moreLabel:a}){return i.jsxs("div",{className:"flex items-end justify-between mb-3",children:[i.jsxs("div",{children:[i.jsx("h3",{className:"section-title",children:e}),t&&i.jsx("p",{className:"section-subtitle",children:t})]}),n&&i.jsxs("button",{className:"section-link",onClick:n,children:[a??"View all"," →"]})]})}function Zre({item:e,onOpen:t}){const n=il(e.subtype==="connector"?"connector":e.itemType),a=xb(n,e.slug||e.name),s=Bs[n];return i.jsxs("button",{onClick:t,className:"group relative w-full overflow-hidden rounded-2xl text-left h-44 md:h-52",style:{background:a},children:[i.jsx("div",{className:"absolute inset-0 bg-gradient-to-r from-black/55 via-black/20 to-transparent"}),i.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:i.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"})}),i.jsxs("div",{className:"relative h-full flex flex-col justify-end p-5 md:p-6",children:[i.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 · ",s.label]}),i.jsx("h2",{className:"text-xl md:text-2xl font-bold text-white drop-shadow-sm",children:e.name}),i.jsx("p",{className:"text-sm text-white/85 truncate max-w-lg mt-1",children:e.description}),i.jsxs("div",{className:"flex items-center gap-3 mt-3 text-white/80 text-xs",children:[i.jsxs("span",{className:"inline-flex items-center gap-1.5",children:[i.jsx(Om,{name:e.author?.displayName,username:e.author?.username,avatarUrl:e.author?.avatarUrl,hubBase:st.getUrl(),size:18}),e.author?.displayName||e.author?.username]}),i.jsxs("span",{children:["↓ ",$o(e.downloadCount)]}),(e.priceCents??0)>0?i.jsxs("span",{className:"badge-paid",children:["$",((e.priceCents??0)/100).toFixed(0)]}):i.jsx("span",{className:"badge-free",children:"Free"})]})]})]})}function Ck({items:e,onOpen:t}){return i.jsx(Fa,{columns:3,children:e.map(n=>i.jsx(vr,{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:st.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 Ak(){return i.jsx(Fa,{columns:3,children:Array.from({length:6}).map((e,t)=>i.jsx("div",{className:"h-64 rounded-2xl skeleton"},t))})}function eie({onOpenType:e}){const{t}=ot(["store","common"]),[n,a]=k.useState([]),[s,l]=k.useState(!0);k.useEffect(()=>{let g=!1;return(async()=>{l(!0);try{const x=await st.search({limit:60,sort:"popular"});g||a(x.items??[])}catch{g||a([])}finally{g||l(!1)}})(),()=>{g=!0}},[]);const c=k.useMemo(()=>{const g=n.filter(y=>y.featured);return(g.length>0?g:n).slice(0,3)},[n]),d=k.useMemo(()=>[...n].sort((g,x)=>(x.trendingScore??x.downloadCount)-(g.trendingScore??g.downloadCount)).slice(0,10),[n]),m=k.useMemo(()=>[...n].sort((g,x)=>(x.createdAt||"").localeCompare(g.createdAt||"")).slice(0,10),[n]),p=k.useMemo(()=>{const g=new Map;for(const x of n){const y=x.author?.username||x.author?.id;if(!y)continue;const w=g.get(y)??{author:x.author,downloads:0,count:0};w.downloads+=x.downloadCount||0,w.count+=1,g.set(y,w)}return[...g.values()].sort((x,y)=>y.downloads-x.downloads).slice(0,6)},[n]),h=g=>e(il(g.subtype==="connector"?"connector":g.itemType),g.id);return i.jsxs("div",{className:"flex-1 overflow-y-auto px-5 md:px-7 py-5 space-y-8",children:[i.jsxs("div",{className:"hero-glow rounded-2xl border border-border-subtle bg-surface-secondary p-5 md:p-6",children:[i.jsx("h1",{className:"text-2xl font-bold text-gradient tracking-tight",children:t("discover.title","Markus 广场")}),i.jsx("p",{className:"text-sm text-fg-tertiary mt-1 max-w-2xl",children:t("discover.subtitle","发现社区共享的智能体、AI 小队、技能与连接器 — 由创作者共建的开放生态。")}),i.jsx("div",{className:"flex flex-wrap gap-2 mt-4",children:Jre.map(g=>i.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 ${Bs[g].gradient} hover:opacity-90 transition-opacity`,children:[Bs[g].labelZh,i.jsx("span",{className:"opacity-70",children:Bs[g].label})]},g))})]}),s?i.jsx("div",{className:"h-52 rounded-2xl skeleton"}):c.length>0?i.jsx("div",{className:"grid grid-cols-1 lg:grid-cols-3 gap-4",children:c.map(g=>i.jsx(Zre,{item:g,onOpen:()=>h(g)},g.id))}):null,i.jsxs("section",{children:[i.jsx(wh,{title:t("discover.trending","热门趋势"),subtitle:t("discover.trendingSub","社区中下载与评分增长最快的资产")}),s?i.jsx(Ak,{}):d.length>0?i.jsx(Ck,{items:d,onOpen:h}):i.jsx(tie,{})]}),i.jsxs("section",{children:[i.jsx(wh,{title:t("discover.fresh","新鲜上架"),subtitle:t("discover.freshSub","来自创作者的最新作品")}),s?i.jsx(Ak,{}):m.length>0?i.jsx(Ck,{items:m,onOpen:h}):null]}),p.length>0&&i.jsxs("section",{children:[i.jsx(wh,{title:t("discover.topCreators","顶尖创作者"),subtitle:t("discover.topCreatorsSub","生态贡献榜")}),i.jsx("div",{className:"grid grid-cols-2 md:grid-cols-3 lg:grid-cols-6 gap-3",children:p.map((g,x)=>i.jsxs("div",{className:"asset-card p-4 flex flex-col items-center text-center",children:[i.jsxs("div",{className:"relative",children:[i.jsx(Om,{name:g.author?.displayName,username:g.author?.username,avatarUrl:g.author?.avatarUrl,hubBase:st.getUrl(),size:48,verified:x<3}),x<3&&i.jsx("span",{className:"absolute -top-1 -left-1 w-5 h-5 rounded-full bg-amber-400 text-black text-[10px] font-bold flex items-center justify-center ring-2 ring-surface-secondary",children:x+1})]}),i.jsx("div",{className:"text-sm font-semibold text-fg-primary truncate w-full mt-2",children:g.author?.displayName||g.author?.username}),i.jsxs("div",{className:"text-[11px] text-fg-tertiary mt-0.5",children:[g.count," 作品 · ↓ ",$o(g.downloads)]})]},g.author?.username||x))})]})]})}function tie(){const{t:e}=ot(["store"]);return i.jsxs("div",{className:"text-center py-12 rounded-2xl border border-dashed border-border-default",children:[i.jsx("div",{className:"text-3xl mb-2 opacity-40",children:"✦"}),i.jsx("div",{className:"text-fg-secondary font-medium",children:e("discover.empty","生态正在成长中")}),i.jsx("div",{className:"text-fg-tertiary text-sm mt-1",children:e("discover.emptyHint","成为首批创作者,分享你的第一个资产")})]})}function Fd(e,t,n){return e.i18n?.[n]?.[t]}function nie(){const{t:e,i18n:t}=ot(["store","common"]),n=Xo(),a=t.language,[s,l]=k.useState([]),[c,d]=k.useState({}),[m,p]=k.useState(new Set),[h,g]=k.useState(null),[x,y]=k.useState(!0),[w,T]=k.useState(""),[C,S]=k.useState("all"),[E,_]=k.useState(null),M=k.useCallback(async()=>{y(!0);try{const[I,K,Y,L]=await Promise.all([Ae.builder.artifacts.list().catch(()=>({artifacts:[]})),Ae.builder.artifacts.installed().catch(()=>({installed:{}})),Ae.skills.updates().catch(()=>({updates:[],count:0})),Ae.skills.builtin().catch(()=>({skills:[]}))]),F={};for(const G of Y.updates)F[G.name]={availableVersion:G.availableVersion,installedVersion:G.installedVersion,displayName:G.displayName,description:G.description};d(F);const ne=I.artifacts.filter(G=>{const ae=`${G.type}/${G.name}`;return!!K.installed[ae]}),ee=new Set(ne.filter(G=>G.type==="skill").map(G=>G.name));for(const G of L.skills)!G.installed||ee.has(G.name)||!(K.installed[`skill/${G.name}`]||F[G.name])&&!G.updateAvailable||!K.installed[`skill/${G.name}`]&&!F[G.name]||(ne.push({type:"skill",name:G.name,meta:{displayName:G.i18n?.[a]?.displayName||G.name,description:G.i18n?.[a]?.description||G.description||"",version:G.installedVersion||G.version,author:G.author,category:G.category,tags:G.tags,i18n:G.i18n},path:"",updatedAt:""}),ee.add(G.name));for(const[G,ae]of Object.entries(F))ee.has(G)||(ne.push({type:"skill",name:G,meta:{displayName:ae.displayName||G,description:ae.description||"",version:ae.installedVersion},path:"",updatedAt:""}),ee.add(G));l(ne)}catch{}y(!1)},[a]);k.useEffect(()=>{M()},[M]),k.useEffect(()=>{const I=()=>{M()};return window.addEventListener("markus:data-changed",I),()=>window.removeEventListener("markus:data-changed",I)},[M]),k.useEffect(()=>{if(!h)return;const I=setTimeout(()=>g(null),3e3);return()=>clearTimeout(I)},[h]);const P=async(I,K)=>{if(!m.has(I)){p(Y=>new Set(Y).add(I));try{await Ae.skills.install({name:I,source:"builtin"});try{localStorage.removeItem("markus:template-updates-ack")}catch{}g({text:e("installedTab.updateSuccess",{name:I,version:K}),type:"success"}),window.dispatchEvent(new CustomEvent("markus:data-changed")),await M()}catch{g({text:e("installedTab.updateFailed",{name:I}),type:"error"})}p(Y=>{const L=new Set(Y);return L.delete(I),L})}},R=s.filter(I=>{if(C!=="all"&&I.type!==C)return!1;if(!w)return!0;const K=w.toLowerCase(),Y=(Fd(I.meta,"displayName",a)||I.meta.displayName||I.name).toLowerCase(),L=(Fd(I.meta,"description",a)||I.meta.description||"").toLowerCase();return Y.includes(K)||L.includes(K)}).sort((I,K)=>{const Y=I.type==="skill"&&c[I.name]?1:0;return(K.type==="skill"&&c[K.name]?1:0)-Y});return E?i.jsx(qs,{type:E.type,name:E.name,onBack:()=>_(null)}):i.jsxs("div",{className:"flex-1 overflow-hidden flex flex-col",children:[i.jsxs("div",{"data-electron-drag":!0,className:`${n?"px-4":"px-6"} h-14 flex items-center shrink-0 gap-3`,children:[i.jsx("h2",{className:"text-lg font-semibold",children:e("installedTab.title")}),Object.keys(c).length>0&&i.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]})]}),i.jsxs("div",{className:`flex flex-wrap items-center gap-2 ${n?"px-4":"px-6"} py-2 shrink-0`,children:[i.jsx("div",{className:"flex gap-1",children:["all","agent","team","skill"].map(I=>i.jsx("button",{onClick:()=>S(I),className:`px-3 py-1 text-xs rounded-md transition-colors ${C===I?"bg-brand-600 text-white":"text-fg-secondary hover:text-fg-primary hover:bg-surface-elevated"}`,children:e(`installedTab.filter${I==="all"?"All":I==="agent"?"Agents":I==="team"?"Teams":"Skills"}`)},I))}),i.jsx("div",{className:"flex-1 min-w-[120px]",children:i.jsx("input",{type:"text",placeholder:e("installedTab.searchPlaceholder"),value:w,onChange:I=>T(I.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"})})]}),i.jsx("div",{className:`flex-1 overflow-y-auto ${n?"p-4":"p-7"}`,children:x?i.jsx("div",{className:"text-center text-fg-tertiary py-20 animate-pulse",children:e("installedTab.loading")}):R.length===0?i.jsxs("div",{className:"text-center py-20",children:[i.jsx("div",{className:"text-4xl mb-4 opacity-30",children:"⧉"}),i.jsx("div",{className:"text-fg-secondary font-medium mb-1",children:e("installedTab.noItems")}),i.jsx("div",{className:"text-fg-tertiary text-sm",children:e("installedTab.noItemsHint")})]}):i.jsx(Fa,{columns:3,children:R.map(I=>{const K=Fd(I.meta,"displayName",a)||I.meta.displayName||I.name,Y=Fd(I.meta,"description",a)||I.meta.description||"",L=I.meta.version||"",F=I.meta.author||"",ne=I.meta.tags??[],ee=I.meta.category||"",G=I.meta.icon,ae=G&&/\.(png|jpe?g|gif|webp|svg)$/i.test(G)&&!G.startsWith("http")&&!G.startsWith("data:")&&!G.startsWith("/")?`/api/builder/artifacts/${I.type}s/${encodeURIComponent(I.name)}/${G}`:G,H=I.type==="skill"?c[I.name]:void 0;return i.jsx(vr,{type:I.type,name:K,description:Y,seed:I.name,icon:ae,author:null,authorLabel:F||void 0,version:H?H.installedVersion:L,category:ee,tags:ne,installed:!H,hideStats:!0,cornerLabel:H?e("installedTab.updateAvailable"):void 0,onClick:()=>{I.path&&_({type:I.type,name:I.name})},actions:H?i.jsx("button",{type:"button",disabled:m.has(I.name),onClick:()=>{P(I.name,H.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(I.name)?e("installedTab.updating"):e("installedTab.updateTo",{version:H.availableVersion})}):void 0},`${I.type}/${I.name}`)})})}),h&&i.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 aie=50,rie=30;function iie(e,t,n,a){const s=k.useRef(0),l=k.useRef(0),c=k.useCallback(m=>{s.current=m.touches[0].clientX,l.current=m.touches[0].clientY},[]),d=k.useCallback(m=>{const p=m.changedTouches[0].clientX-s.current,h=m.changedTouches[0].clientY-l.current,g=Math.abs(p),x=Math.abs(h);if(g<aie||Math.atan2(x,g)*(180/Math.PI)>rie)return;if(a?.scrollContainerRef?.current){const T=a.scrollContainerRef.current,C=T.scrollLeft<=1,S=T.scrollLeft+T.clientWidth>=T.scrollWidth-1;if(p>0&&!C||p<0&&!S)return}const w=e.findIndex(T=>T.id===t);p<0&&w<e.length-1?n(e[w+1].id):p>0&&w>0?n(e[w-1].id):p>0&&w===0&&a?.onSwipeOutLeft?a.onSwipeOutLeft():p<0&&w===e.length-1&&a?.onSwipeOutRight&&a.onSwipeOutRight()},[e,t,n,a]);return{onTouchStart:c,onTouchEnd:d}}const sie=["builder","discover","agents","teams","skills","installed"],oie={agent:"agents",team:"teams",skill:"skills",connector:"skills"};function Sg(e){return!!e&&sie.includes(e)}function Tk(){const e=localStorage.getItem("markus_nav_installItem"),t=localStorage.getItem("markus_nav_storeTab");return{tab:Sg(t)?t:"builder",installId:e}}function lie({authUser:e}){const{t}=ot(["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]),[a]=k.useState(Tk),[s,l]=k.useState(a.tab),[c,d]=k.useState(a.installId),m=iie(n,s,l);k.useEffect(()=>{const h=Tk();h.installId&&(d(h.installId),Sg(h.tab)&&l(h.tab),localStorage.removeItem("markus_nav_installItem"),localStorage.removeItem("markus_nav_storeTab"))},[]),k.useEffect(()=>{const h=g=>{const x=g.detail,y=x.params?.storeTab??localStorage.getItem("markus_nav_storeTab");Sg(y)&&l(y);const w=x.params?.installItem??localStorage.getItem("markus_nav_installItem");w&&d(w),localStorage.removeItem("markus_nav_storeTab"),localStorage.removeItem("markus_nav_installItem")};return window.addEventListener("markus:navigate",h),()=>window.removeEventListener("markus:navigate",h)},[]);const p=(h,g)=>{g&&d(g),l(oie[h]??"agents")};return i.jsxs("div",{className:"flex-1 overflow-hidden flex flex-col",onTouchStart:m.onTouchStart,onTouchEnd:m.onTouchEnd,children:[i.jsxs("div",{className:"flex items-center shrink-0 overflow-x-auto scrollbar-hide",children:[i.jsx(g4,{className:"ml-2"}),n.map(h=>i.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 ${s===h.id?"border-brand-500 text-brand-500":"border-transparent text-fg-tertiary"}`,children:h.label},h.id))]}),i.jsxs("div",{className:"flex-1 overflow-hidden flex flex-col",children:[s==="builder"&&i.jsx(r6,{authUser:e}),s==="discover"&&i.jsx(eie,{onOpenType:p}),s==="agents"&&i.jsx(Ure,{authUser:e,highlightItemId:c,onHighlightDone:()=>d(null)}),s==="teams"&&i.jsx(Vre,{highlightItemId:c,onHighlightDone:()=>d(null)}),s==="skills"&&i.jsx(Xre,{highlightItemId:c,onHighlightDone:()=>d(null)}),s==="installed"&&i.jsx(nie,{})]})]})}const Nk="usageType",kh="profile";function cie({onComplete:e,theme:t,onThemeChange:n,skipProfile:a,onProfileUpdated:s}){const{t:l}=ot(["onboarding","common"]),[c,d]=k.useState(0),[m,p]=k.useState(""),[h,g]=k.useState(""),[x,y]=k.useState(""),[w,T]=k.useState(""),[C,S]=k.useState(!1),[E,_]=k.useState(""),[M,P]=k.useState(!1),[R,I]=k.useState(null);k.useEffect(()=>{Ae.auth.me().then(({user:$e})=>{$e.name&&p($e.name),$e.email&&g($e.email),$e.avatarUrl&&I($e.avatarUrl);const mt=$e.name||$e.email?.split("@")[0]||"";mt&&F(At=>At||l("usageType.defaultOrgName",{name:mt}))}).catch(()=>{}),Ae.settings.getOrg().then(({org:$e})=>{$e?.name&&$e.name!=="My Organization"&&F($e.name)}).catch(()=>{}),jn()&&Ae.hubOrgs.invitations().then($e=>{$e.invitations?.length>0&&Ce($e.invitations)}).catch(()=>{})},[]);const[K,Y]=k.useState(null),[L,F]=k.useState(""),[ne,ee]=k.useState(!1),[G,ae]=k.useState(!1),[H,J]=k.useState(""),[fe,Ce]=k.useState([]),[$,V]=k.useState(null),[pe,z]=k.useState(null),je=async()=>{const $e=L.trim();if($e){ee(!0),J("");try{if(await Ae.settings.updateOrg($e),jn()){const mt=await Ae.hubOrgs.mine(),At=mt.orgs?.find(Dt=>Dt.role==="owner")??mt.orgs?.[0];At?.id?await Ae.hubOrgs.update(At.id,{name:$e}):await Ae.hubOrgs.create($e)}ae(!0)}catch{J(l("usageType.orgNameSaveFailed"))}finally{ee(!1)}}},[Ue,qe]=k.useState(!0),He=async()=>{if(_(""),!m.trim()){_(l("profile.errors.nameRequired"));return}if(!h.trim()){_(l("profile.errors.emailRequired"));return}if(!/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(h.trim())){_(l("profile.errors.emailInvalid"));return}if(x&&x.length<6){_(l("profile.errors.passwordTooShort"));return}if(x&&x!==w){_(l("profile.errors.passwordMismatch"));return}S(!0);try{const{user:$e}=await Ae.auth.updateProfile(m.trim(),h.trim());x&&await Ae.auth.changePassword("",x),s?.($e),P(!0)}catch{_(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")}],dt=[{id:"welcome",title:l("welcome.title"),subtitle:l("welcome.subtitle"),content:i.jsx("p",{className:"text-fg-secondary text-sm leading-relaxed",children:i.jsx(dT,{i18nKey:"welcome.description",ns:"onboarding",components:{strong:i.jsx("strong",{className:"text-fg-primary"})}})})},{id:Nk,title:l("usageType.title",{defaultValue:"How will you use Markus?"}),subtitle:l("usageType.subtitle",{defaultValue:"This helps us tailor your experience."}),content:i.jsxs("div",{className:"space-y-4",children:[i.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[i.jsxs("button",{onClick:()=>{Y("personal"),ae(!0)},className:`flex flex-col items-center gap-3 rounded-xl border-2 p-5 transition-all text-left ${K==="personal"?"border-brand-500 bg-brand-500/10":"border-border-default hover:border-fg-tertiary bg-surface-elevated/30"}`,children:[i.jsx("span",{className:"text-2xl",children:"👤"}),i.jsxs("div",{children:[i.jsx("div",{className:"font-medium text-fg-primary text-sm text-center",children:l("usageType.personal",{defaultValue:"Personal"})}),i.jsx("div",{className:"text-[11px] text-fg-tertiary mt-1 text-center",children:l("usageType.personalDesc",{defaultValue:"Individual use with your own AI agents."})})]})]}),i.jsxs("button",{onClick:()=>{Y("organization"),ae(!1)},className:`flex flex-col items-center gap-3 rounded-xl border-2 p-5 transition-all text-left ${K==="organization"?"border-brand-500 bg-brand-500/10":"border-border-default hover:border-fg-tertiary bg-surface-elevated/30"}`,children:[i.jsx("span",{className:"text-2xl",children:"🏢"}),i.jsxs("div",{children:[i.jsx("div",{className:"font-medium text-fg-primary text-sm text-center",children:l("usageType.organization",{defaultValue:"Team & Enterprise"})}),i.jsx("div",{className:"text-[11px] text-fg-tertiary mt-1 text-center",children:l("usageType.organizationDesc",{defaultValue:"For teams sharing licenses and collaborating."})})]})]})]}),K==="organization"&&i.jsxs("div",{className:"space-y-4 mt-4",children:[fe.length>0&&i.jsxs("div",{className:"space-y-2",children:[i.jsx("div",{className:"text-xs text-fg-tertiary font-medium",children:l("usageType.pendingInvitations")}),fe.map($e=>i.jsxs("div",{className:"flex items-center justify-between px-4 py-3 rounded-xl border border-amber-500/20 bg-amber-500/5",children:[i.jsxs("div",{children:[i.jsx("div",{className:"text-sm font-medium text-fg-primary",children:$e.orgName}),i.jsx("div",{className:"text-[11px] text-fg-tertiary",children:l("usageType.invitedBy",{name:$e.invitedBy})})]}),i.jsx("button",{onClick:async()=>{V($e.orgId);try{await Ae.hubOrgs.acceptInvitation($e.orgId),z($e.orgId),ae(!0)}catch{}finally{V(null)}},disabled:$===$e.orgId||pe===$e.orgId,className:"px-3 py-1.5 text-xs rounded-lg bg-brand-600 hover:bg-brand-500 disabled:opacity-40 text-white transition-colors",children:pe===$e.orgId?l("usageType.accepted"):$===$e.orgId?l("usageType.accepting"):l("usageType.acceptAndJoin")})]},$e.orgId)),i.jsx("div",{className:"text-[11px] text-fg-tertiary text-center pt-1",children:l("usageType.orCreateNew")})]}),i.jsxs("div",{className:"space-y-1",children:[i.jsx("label",{className:"text-xs text-fg-tertiary font-medium",children:l("usageType.orgNameLabel")}),i.jsx("input",{type:"text",value:L,onChange:$e=>{F($e.target.value),ae(!1),J("")},placeholder:l("usageType.orgNamePlaceholder"),className:"w-full px-4 py-2.5 bg-surface-elevated border border-border-default rounded-xl text-sm text-fg-primary focus:border-brand-500 outline-none transition-colors"})]}),H&&i.jsx("p",{className:"text-xs text-red-500",children:H}),i.jsx("button",{onClick:()=>{je()},disabled:ne||!L.trim()||G,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(ne?"common:saving":G?"usageType.orgNameSaved":"usageType.setOrgName")})]})]})},{id:kh,title:l("profile.title"),subtitle:l("profile.subtitle"),content:M?i.jsxs("div",{className:"flex items-center gap-3 bg-green-500/10 border border-green-500/30 rounded-xl p-4",children:[i.jsx("span",{className:"text-green-600 text-lg",children:"✓"}),i.jsxs("div",{children:[i.jsx("div",{className:"text-sm font-medium text-green-600",children:l("profile.saved")}),i.jsxs("div",{className:"text-xs text-fg-secondary mt-0.5",children:[m," · ",h]})]})]}):i.jsxs("div",{className:"space-y-4",children:[i.jsx("div",{className:"flex justify-center",children:i.jsx(f4,{currentUrl:R,name:m,size:64,targetType:"user"})}),i.jsxs("div",{className:"space-y-1",children:[i.jsxs("label",{className:"text-xs text-fg-tertiary font-medium",children:[l("profile.nameLabel")," ",i.jsx("span",{className:"text-red-500",children:"*"})]}),i.jsx("input",{type:"text",value:m,onChange:$e=>p($e.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})]}),i.jsxs("div",{className:"space-y-1",children:[i.jsxs("label",{className:"text-xs text-fg-tertiary font-medium",children:[l("profile.emailLabel")," ",i.jsx("span",{className:"text-red-500",children:"*"})]}),i.jsx("input",{type:"email",value:h,onChange:$e=>g($e.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"})]}),i.jsxs("div",{className:"space-y-1",children:[i.jsx("label",{className:"text-xs text-fg-tertiary font-medium",children:l("profile.newPasswordLabel")}),i.jsx("input",{type:"password",value:x,onChange:$e=>y($e.target.value),placeholder:l("profile.newPasswordPlaceholder"),className:"w-full px-4 py-2.5 bg-surface-elevated border border-border-default rounded-xl text-sm text-fg-primary focus:border-brand-500 outline-none transition-colors"})]}),x&&i.jsxs("div",{className:"space-y-1",children:[i.jsx("label",{className:"text-xs text-fg-tertiary font-medium",children:l("profile.confirmPasswordLabel")}),i.jsx("input",{type:"password",value:w,onChange:$e=>T($e.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&&i.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}),i.jsx("button",{onClick:()=>{He()},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:i.jsxs("div",{className:"space-y-4",children:[i.jsx("div",{className:"grid grid-cols-3 gap-3",children:ut.map($e=>i.jsxs("button",{onClick:()=>n($e.value),className:`flex flex-col items-center gap-2 rounded-xl border-2 p-5 transition-all ${t===$e.value?"border-brand-500 bg-brand-500/10":"border-border-default hover:border-fg-tertiary bg-surface-elevated/30"}`,children:[i.jsx("span",{className:"text-2xl",children:$e.icon}),i.jsx("span",{className:"text-sm font-medium text-fg-primary",children:$e.label}),i.jsx("span",{className:"text-[11px] text-fg-tertiary leading-tight text-center",children:$e.desc})]},$e.value))}),i.jsxs("label",{className:"flex items-center gap-2.5 p-3 bg-surface-elevated/30 rounded-lg cursor-pointer group",children:[i.jsx("input",{type:"checkbox",checked:Ue,onChange:$e=>qe($e.target.checked),className:"accent-brand-500 shrink-0"}),i.jsx("span",{className:"text-[11px] text-fg-tertiary",children:l("done.telemetry")})]})]})}],Nt=a?dt.filter($e=>$e.id!==kh):dt,wt=Nt.findIndex($e=>$e.id===Nk),Zt=Nt.findIndex($e=>$e.id===kh),Wt=()=>{c===wt&&wt>=0&&!K||c===wt&&K==="organization"&&!G||c===Zt&&Zt>=0&&!M||(c<Nt.length-1?d(c+1):(fetch("/api/settings/telemetry",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({enabled:Ue})}).catch(()=>{}),e()))},rt=Nt[c];return i.jsx("div",{className:"min-h-dvh bg-surface-primary flex items-center justify-center p-4",children:i.jsx("div",{className:"w-full max-w-lg",children:i.jsxs("div",{className:"bg-surface-elevated rounded-2xl p-8",children:[i.jsx("div",{className:"flex gap-1.5 mb-8",children:Nt.map(($e,mt)=>i.jsx("div",{className:`h-1 flex-1 rounded-full transition-colors ${mt<=c?"bg-brand-500":"bg-surface-elevated"}`},mt))}),i.jsx("h2",{className:"text-2xl font-bold text-fg-primary",children:rt.title}),i.jsx("p",{className:"text-sm text-fg-secondary mt-1 mb-6",children:rt.subtitle}),rt.content,i.jsxs("div",{className:"flex justify-between mt-8",children:[c>0?i.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")}):i.jsx("span",{}),i.jsx("button",{onClick:Wt,disabled:Zt>=0&&c===Zt&&!M||wt>=0&&c===wt&&(!K||K==="organization"&&!G),className:`px-6 py-2.5 text-white text-sm rounded-xl transition-colors ${Zt>=0&&c===Zt&&!M||wt>=0&&c===wt&&(!K||K==="organization"&&!G)?"bg-brand-600/40 cursor-not-allowed":"bg-brand-600 hover:bg-brand-500"}`,children:c===Nt.length-1?l("getStarted"):l("common:next")})]})]})})})}const Ek="markus:legal-consent",uie="https://markus.global";function die({onLogin:e,hasOwner:t}){const{t:n,i18n:a}=ot("auth"),[s,l]=k.useState(null),[c,d]=k.useState(""),[m,p]=k.useState(!1),[h,g]=k.useState(""),[x,y]=k.useState(""),[w,T]=k.useState(!1),[C,S]=k.useState(!1),E=F=>{const ne=(a.language||"").toLowerCase().startsWith("zh")?"?lang=zh":"";return`${uie}${F}${ne}`},_=()=>{try{localStorage.setItem(Ek,JSON.stringify({acceptedAt:new Date().toISOString(),terms:!0,privacy:!0}))}catch{}},M=()=>C?(_(),!0):(T(!1),requestAnimationFrame(()=>T(!0)),!1),P=async()=>{const F=jn(),ne=xr();if(!F||!ne){d(n("login.hubUnavailable"));return}const ee=await Ae.auth.hubLogin(F,ne);if(window.markusDesktop?.clearPendingDeepLinkAuth?.(),ee.cloudAiReady===!1)try{sessionStorage.setItem("markus:cloud-ai-warning",ee.cloudAiError?n("login.cloudAiNotReady",{error:ee.cloudAiError}):n("login.cloudAiNotReadyGeneric"))}catch{}e(ee.user,ee.needsOnboarding??!1,{fromHub:!0})},R=async(F,ne=!1)=>{if(!(!ne&&!M())){d(""),l(F??"hub");try{if(ne&&jn()&&xr()){await P();return}await Ha({method:F,force:!0}),await P()}catch(ee){const G=ee instanceof Error?ee.message:"";if(!G.includes("cancelled")){if(!ne&&jn())return R(F,!0);d(G||n("login.hubUnavailable"))}}finally{l(null)}}},I=()=>{uU(),l(null),d("")};k.useEffect(()=>{const F=window.markusDesktop;if(!F?.peekPendingDeepLinkAuth&&!F?.consumePendingDeepLinkAuth)return;let ne=!1;return(async()=>{const ee=F.peekPendingDeepLinkAuth?await F.peekPendingDeepLinkAuth():null;if(ne||!ee)return;let G=!1;try{G=!!localStorage.getItem(Ek)}catch{}if(!C&&!G){d(n("login.consentRequired"));return}G&&!C&&S(!0),_();const ae=F.consumePendingDeepLinkAuth?await F.consumePendingDeepLinkAuth():ee;if(!(ne||!ae)){d(""),l("hub");try{if(!await cU(ae)||!jn()||!xr()){d(n("login.hubUnavailable"));return}await P()}catch{d(n("login.hubUnavailable"))}finally{ne||l(null)}}})().catch(()=>{}),()=>{ne=!0}},[C]);const K=async F=>{if(F.preventDefault(),!(!h.trim()||!x)&&M()){d(""),l("local");try{const{user:ne,needsOnboarding:ee}=await Ae.auth.login(h.trim(),x);e(ne,ee??!1)}catch{d(n("login.invalidCredentials"))}finally{l(null)}}},Y=n(t?"login.welcomeBack":"login.getStarted"),L="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 i.jsxs("div",{className:"min-h-dvh bg-surface-primary flex flex-col items-center justify-center p-4 relative overflow-hidden",children:[i.jsxs("div",{className:"pointer-events-none absolute inset-0 overflow-hidden",children:[i.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]"}),i.jsx("div",{className:"absolute top-1/4 -left-40 h-[26rem] w-[26rem] rounded-full bg-brand-400/10 blur-[100px]"}),i.jsx("div",{className:"absolute -bottom-40 -right-32 h-[34rem] w-[34rem] rounded-full bg-brand-600/10 blur-[110px]"})]}),i.jsxs("div",{className:"w-full max-w-[26rem] relative z-10 flex-1 flex flex-col justify-center",children:[i.jsxs("div",{className:"text-center mb-8",children:[i.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"}),i.jsx("div",{className:"text-[1.75rem] leading-none font-extrabold tracking-tight text-fg-primary mb-2",children:"Markus"}),i.jsx("div",{className:"text-sm text-fg-tertiary",children:Y})]}),i.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?i.jsxs("div",{className:"space-y-4",children:[i.jsxs("div",{children:[i.jsx("div",{className:"text-base font-semibold text-fg-primary",children:n("login.localTitle")}),i.jsx("div",{className:"text-xs text-fg-tertiary mt-0.5",children:n("login.localAccountHint")})]}),i.jsxs("form",{onSubmit:K,className:"space-y-3",children:[i.jsx("input",{type:"email",value:h,onChange:F=>g(F.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}),i.jsx("input",{type:"password",value:x,onChange:F=>y(F.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&&i.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&&i.jsx("p",{className:"text-[11px] text-fg-tertiary",children:n("login.defaultCredentials")}),i.jsx("button",{type:"submit",disabled:s==="local"||!h||!x,className:"w-full h-11 bg-brand-600 hover:bg-brand-500 disabled:opacity-50 text-white text-sm font-semibold rounded-xl transition-all shadow-md shadow-brand-900/30 hover:shadow-lg active:scale-[0.99]",children:n(s==="local"?"login.signingIn":"login.signIn")})]}),i.jsx("div",{className:"text-center",children:i.jsx("button",{onClick:()=>{p(!1),d("")},className:"text-xs text-fg-tertiary hover:text-fg-secondary transition-colors",children:n("login.backToHub")})})]}):i.jsxs("div",{className:"space-y-3",children:[i.jsxs("button",{onClick:()=>R("google"),disabled:!!s,className:L,children:[i.jsxs("svg",{className:"w-5 h-5",viewBox:"0 0 24 24",children:[i.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"}),i.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"}),i.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"}),i.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(s==="google"?"login.connectingHub":"login.withGoogle")]}),i.jsxs("button",{onClick:()=>R("github"),disabled:!!s,className:L,children:[i.jsx("svg",{className:"w-5 h-5",viewBox:"0 0 24 24",fill:"currentColor",children:i.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(s==="github"?"login.connectingHub":"login.withGithub")]}),i.jsxs("button",{onClick:()=>R("email"),disabled:!!s,className:L,children:[i.jsx("svg",{className:"w-5 h-5",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:1.5,children:i.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(s==="email"?"login.connectingHub":"login.withEmail")]}),s&&(s==="google"||s==="github"||s==="email"||s==="hub")&&i.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:[i.jsx("p",{children:n("login.browserOpened")}),i.jsx("button",{type:"button",onClick:I,className:"text-brand-500 hover:text-brand-400 underline font-medium",children:n("login.cancelWaiting")})]}),c&&i.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}),i.jsxs("div",{className:"flex items-center gap-3 py-1 text-[11px] text-fg-tertiary",children:[i.jsx("span",{className:"h-px flex-1 bg-border-default"}),n("login.or"),i.jsx("span",{className:"h-px flex-1 bg-border-default"})]}),i.jsx("button",{onClick:()=>{p(!0),d("")},disabled:!!s,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")})]})}),i.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:[i.jsx("input",{type:"checkbox",checked:C,onChange:F=>{S(F.target.checked),F.target.checked&&T(!1)},className:"mt-0.5 h-3.5 w-3.5 shrink-0 accent-brand-600 cursor-pointer"}),i.jsxs("span",{className:"text-center",children:[n("login.consentPrefix")," ",i.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")," ",i.jsx("a",{href:E("/privacy"),target:"_blank",rel:"noopener noreferrer",className:"text-brand-500 hover:text-brand-400 underline",children:n("login.privacyLink")})]})]})]}),i.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:[i.jsx("a",{href:"https://markus.global",target:"_blank",rel:"noopener noreferrer",className:"hover:text-fg-secondary transition-colors",children:"markus.global"}),i.jsx("a",{href:"mailto:business@markus.global",className:"hover:text-fg-secondary transition-colors",children:n("login.contactSales")})]})]})}function mie({token:e,onComplete:t}){const{t:n}=ot("auth"),[a,s]=k.useState(null),[l,c]=k.useState(""),[d,m]=k.useState(""),[p,h]=k.useState(""),[g,x]=k.useState(!1),[y,w]=k.useState(!1),[T,C]=k.useState(!1);k.useEffect(()=>{Ae.auth.inviteInfo(e).then(E=>s(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}x(!0);try{await Ae.auth.setup(e,l),w(!0),setTimeout(()=>{window.location.hash="",t()},2e3)}catch{h(n("invite.error"))}finally{x(!1)}};return i.jsxs("div",{className:"min-h-dvh bg-surface-primary flex items-center justify-center p-4 relative overflow-hidden",children:[i.jsx("div",{className:"absolute inset-0 bg-[radial-gradient(ellipse_at_top,_var(--tw-gradient-stops))] from-brand-950/50 via-transparent to-transparent"}),i.jsxs("div",{className:"w-full max-w-sm relative z-10",children:[i.jsxs("div",{className:"text-center mb-8",children:[i.jsx("img",{src:"/logo.png",alt:"Markus",className:"w-14 h-14 mx-auto mb-3 rounded-xl shadow-lg shadow-black/40"}),i.jsx("div",{className:"text-2xl font-extrabold tracking-tight text-fg-primary mb-1",children:"Markus"}),i.jsx("div",{className:"text-sm text-fg-tertiary",children:n("invite.subtitle")})]}),i.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?i.jsxs("div",{className:"text-center space-y-3",children:[i.jsx("div",{className:"text-red-500 text-3xl",children:"⚠"}),i.jsx("p",{className:"text-sm text-fg-secondary",children:n("invite.invalidLink")}),i.jsx("button",{onClick:()=>{window.location.hash="",t()},className:"text-sm text-brand-500 hover:text-brand-400",children:n("login.signIn")})]}):y?i.jsxs("div",{className:"text-center space-y-3",children:[i.jsx("div",{className:"text-green-500 text-3xl",children:"✓"}),i.jsx("p",{className:"text-sm text-fg-secondary",children:n("invite.setupComplete")})]}):a?i.jsxs("form",{onSubmit:S,className:"space-y-5",children:[i.jsx("h2",{className:"text-lg font-semibold text-fg-primary text-center",children:n("invite.greeting",{name:a.name})}),i.jsx("p",{className:"text-xs text-fg-tertiary text-center",children:a.email}),i.jsxs("div",{className:"space-y-1",children:[i.jsx("label",{className:"text-xs text-fg-tertiary font-medium",children:n("invite.setPassword")}),i.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})]}),i.jsxs("div",{className:"space-y-1",children:[i.jsx("label",{className:"text-xs text-fg-tertiary font-medium",children:n("invite.confirmPassword")}),i.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})]}),p&&i.jsx("div",{className:"px-3 py-2 bg-red-500/10 border border-red-500/30 rounded-lg text-xs text-red-500",children:p}),i.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")})]}):i.jsx("div",{className:"text-center text-fg-tertiary text-sm animate-pulse py-4",children:"Loading…"})})]})]})}function pie({onComplete:e,isFirstTime:t}){const{t:n}=ot("auth"),[a,s]=k.useState(""),[l,c]=k.useState(""),[d,m]=k.useState(""),[p,h]=k.useState(""),[g,x]=k.useState(!1),y=async w=>{if(w.preventDefault(),h(""),l.length<6){h(n("changePassword.passwordMinLength"));return}if(l!==d){h(n("changePassword.passwordsDoNotMatch"));return}x(!0);try{await Ae.auth.changePassword(a,l),e()}catch{h(n("changePassword.failedToChange"))}finally{x(!1)}};return i.jsxs("div",{className:"min-h-dvh bg-surface-primary flex items-center justify-center p-4 relative overflow-hidden",children:[i.jsx("div",{className:"absolute inset-0 bg-[radial-gradient(ellipse_at_top,_var(--tw-gradient-stops))] from-brand-950/50 via-transparent to-transparent"}),i.jsxs("div",{className:"w-full max-w-sm relative z-10",children:[i.jsxs("div",{className:"text-center mb-8",children:[i.jsx("img",{src:"/logo.png",alt:"Markus",className:"w-14 h-14 mx-auto mb-3 rounded-xl shadow-lg shadow-black/40"}),i.jsx("div",{className:"text-2xl font-extrabold tracking-tight text-fg-primary mb-1",children:"Markus"}),i.jsx("div",{className:"text-sm text-fg-tertiary",children:n("login.subtitle")})]}),i.jsxs("form",{onSubmit:y,className:"bg-surface-secondary/80 backdrop-blur-sm border border-border-default rounded-2xl p-8 space-y-5 shadow-2xl shadow-black/30",children:[i.jsxs("div",{children:[i.jsx("h2",{className:"text-lg font-semibold text-fg-primary text-center",children:n(t?"changePassword.setYourPassword":"changePassword.changePassword")}),t&&i.jsx("p",{className:"text-xs text-amber-600/80 text-center mt-2",children:n("changePassword.defaultPasswordWarning")})]}),!t&&i.jsxs("div",{className:"space-y-1",children:[i.jsx("label",{className:"text-xs text-fg-tertiary font-medium",children:n("changePassword.currentPassword")}),i.jsx("input",{type:"password",value:a,onChange:w=>s(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"})]}),i.jsxs("div",{className:"space-y-1",children:[i.jsx("label",{className:"text-xs text-fg-tertiary font-medium",children:n("changePassword.newPassword")}),i.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})]}),i.jsxs("div",{className:"space-y-1",children:[i.jsx("label",{className:"text-xs text-fg-tertiary font-medium",children:n("changePassword.confirmNewPassword")}),i.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})]}),p&&i.jsx("div",{className:"px-3 py-2 bg-red-500/10 border border-red-500/30 rounded-lg text-xs text-red-500",children:p}),i.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 fie({side:e,defaultWidth:t,minWidth:n,maxWidth:a,collapsedWidth:s=0,storageKey:l}){const[c,d]=k.useState(()=>{try{const T=localStorage.getItem(`${l}_w`);if(T)return Math.max(n,Math.min(a,parseInt(T,10)))}catch{}return t}),[m,p]=k.useState(()=>{try{return localStorage.getItem(`${l}_c`)==="1"}catch{return!1}}),h=k.useRef(!1),g=k.useRef(n),x=k.useRef(a);g.current=n,x.current=a,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(a,T)))},[n,a]);const y=k.useCallback(T=>{T.preventDefault(),h.current=!0;const C=T.clientX,S=c,E=M=>{if(!h.current)return;const P=M.clientX-C;d(Math.max(g.current,Math.min(x.current,S+P)))},_=()=>{h.current=!1,document.removeEventListener("mousemove",E),document.removeEventListener("mouseup",_),document.body.style.cursor="",document.body.style.userSelect=""};document.addEventListener("mousemove",E),document.addEventListener("mouseup",_),document.body.style.cursor="col-resize",document.body.style.userSelect="none"},[c,e]),w=k.useCallback(()=>p(T=>!T),[]);return{width:m?s:c,rawWidth:c,collapsed:m,toggle:w,setCollapsed:p,setWidth:d,onResizeStart:y}}const Dse=[{value:"system",label:"System"},{value:"light",label:"Light"},{value:"dark",label:"Dark"},{value:"cyberpunk",label:"Cyberpunk"},{value:"mono",label:"Mono"}],Cg="markus-theme";function jk(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 hie(){try{const e=localStorage.getItem(Cg);if(e==="midnight")return localStorage.setItem(Cg,"dark"),"dark";if(e==="light"||e==="dark"||e==="system"||e==="cyberpunk"||e==="mono")return e}catch{}return"system"}function gie(){const[e,t]=k.useState(hie),n=k.useCallback(a=>{t(a);try{localStorage.setItem(Cg,a)}catch{}jk(a)},[]);return k.useEffect(()=>{jk(e)},[e]),{mode:e,setMode:n}}const am={agents:[],tasks:[],requirements:[],projects:[],deliverables:[],workflows:[]},bie={team:["agents","workflows","tasks","requirements","projects","deliverables"],work:["workflows","projects","requirements","tasks","agents","deliverables"],deliverables:["deliverables","agents","tasks","requirements","projects","workflows"]},yie=["agents","tasks","requirements","projects","deliverables","workflows"];let Mk="",_k="all",Rk=am,Dk=!1;function xie({onClose:e,currentPage:t}){const{t:n}=ot(["common","home","work"]);Qo(!0);const[a,s]=k.useState(Mk),[l,c]=k.useState(_k),[d,m]=k.useState(Rk),[p,h]=k.useState(!1),[g,x]=k.useState(Dk),[y,w]=k.useState(-1);k.useEffect(()=>{Mk=a},[a]),k.useEffect(()=>{_k=l},[l]),k.useEffect(()=>{Rk=d},[d]),k.useEffect(()=>{Dk=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 _=k.useCallback(async ee=>{if(!ee.trim()){m(am),x(!1),w(-1);return}h(!0),x(!0),w(-1);const G=ee.toLowerCase();try{const[ae,H,J,fe,Ce,$]=await Promise.allSettled([Ae.agents.list(),Ae.tasks.list({search:ee,pageSize:20}),Ae.requirements.list(),Ae.projects.list(),Ae.deliverables.search({q:ee,limit:20}),Ae.teams.list()]),V=ae.status==="fulfilled"?ae.value.agents.filter(He=>He.name?.toLowerCase().includes(G)||He.role?.toLowerCase().includes(G)):[],pe=H.status==="fulfilled"?H.value.tasks:[],z=J.status==="fulfilled"?J.value.requirements.filter(He=>He.title?.toLowerCase().includes(G)||He.description?.toLowerCase().includes(G)):[],je=fe.status==="fulfilled"?fe.value.projects.filter(He=>He.name?.toLowerCase().includes(G)||He.description?.toLowerCase().includes(G)):[],Ue=Ce.status==="fulfilled"?Ce.value.results:[],qe=[];if($.status==="fulfilled"){const He=await Promise.allSettled($.value.teams.map(ut=>Ae.workflows.list(ut.id)));for(const ut of He)if(ut.status==="fulfilled")for(const dt of ut.value.workflows)(dt.name.toLowerCase().includes(G)||(dt.displayName||"").toLowerCase().includes(G)||dt.description?.toLowerCase().includes(G))&&qe.push(dt)}m({agents:V,tasks:pe,requirements:z,projects:je,deliverables:Ue,workflows:qe})}catch{m(am)}finally{h(!1)}},[]),M=ee=>{s(ee),C.current&&clearTimeout(C.current),C.current=setTimeout(()=>_(ee),400)},P=k.useCallback((ee,G)=>{e(),at.navigate(ee,G)},[e]),R=[{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:"工作流"})}],I=k.useMemo(()=>bie[t||""]||yie,[t]),K=k.useMemo(()=>{const ee=[],G=l==="all"?8:void 0,ae=H=>{if(l!=="all"&&l!==H)return;const J=d[H].length;if(H==="workflows"){const fe=G?d.workflows.slice(0,G):d.workflows;for(const Ce of fe)ee.push({id:Ce.name,type:"workflow",page:de.WORK,params:{boardType:"workflows"}})}else{const fe=d[H],Ce=G?fe.slice(0,G):fe;for(const $ of Ce)switch(H){case"agents":ee.push({id:$.id,type:"agent",page:de.TEAM,params:{agentId:$.id}});break;case"tasks":ee.push({id:$.id,type:"task",page:de.WORK,params:{openTask:$.id}});break;case"requirements":ee.push({id:$.id,type:"requirement",page:de.WORK,params:{openRequirement:$.id}});break;case"projects":ee.push({id:$.id,type:"project",page:de.WORK,params:{projectId:$.id}});break;case"deliverables":ee.push({id:$.id,type:"deliverable",page:de.DELIVERABLES,params:{openDeliverable:$.id}});break}}G&&J>G&&ee.push({id:`more_${H}`,type:"showMore",page:"",expandCategory:H,totalCount:J})};for(const H of I)ae(H);return ee},[d,l,I]),Y=k.useCallback(ee=>{if(ee.type==="showMore"&&ee.expandCategory){c(ee.expandCategory),w(-1);return}P(ee.page,ee.params)},[P]);k.useEffect(()=>{const ee=E.current;if(!ee||y<0)return;const G=ee.querySelector(`[data-idx="${y}"]`);G&&G.scrollIntoView({block:"nearest"})},[y]);const L=k.useCallback(ee=>{if(ee.key==="Escape"){e();return}if(ee.key==="Tab"){ee.preventDefault();const H=R.map(Ce=>Ce.id),J=H.indexOf(l),fe=ee.shiftKey?J<=0?H.length-1:J-1:J>=H.length-1?0:J+1;c(H[fe]),w(-1);return}const G=ee.ctrlKey&&ee.key==="n"||ee.key==="ArrowDown",ae=ee.ctrlKey&&ee.key==="p"||ee.key==="ArrowUp";if(G||ae){ee.preventDefault(),w(H=>{const J=K.length-1;return J<0?-1:G?H>=J?0:H+1:H<=0?J:H-1});return}ee.key==="Enter"&&(ee.preventDefault(),y>=0&&y<K.length&&Y(K[y]))},[e,K,y,Y,R,l]);k.useEffect(()=>(document.addEventListener("keydown",L),()=>document.removeEventListener("keydown",L)),[L]);const F=K.length>0;let ne=0;return i.jsx("div",{ref:S,className:"fixed inset-0 bg-black/50 flex items-start justify-center z-50 pt-[8vh]",onClick:ee=>{ee.target===S.current&&e()},children:i.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:[i.jsxs("div",{className:"shrink-0 px-5 pt-4 pb-3 border-b border-border-default space-y-3",children:[i.jsxs("div",{className:"relative",children:[i.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:[i.jsx("circle",{cx:"11",cy:"11",r:"8"}),i.jsx("line",{x1:"21",y1:"21",x2:"16.65",y2:"16.65"})]}),i.jsx("input",{ref:T,value:a,onChange:ee=>M(ee.target.value),placeholder:n("common:search"),className:"w-full bg-surface-elevated border border-border-default rounded-xl pl-9 pr-9 py-2.5 text-sm text-fg-primary placeholder:text-fg-tertiary focus:border-brand-500 focus:outline-none transition-colors"}),a&&i.jsx("button",{onClick:()=>{s(""),m(am),x(!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:i.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[i.jsx("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),i.jsx("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]})})]}),i.jsx("div",{className:"flex gap-1 overflow-x-auto scrollbar-hide",children:R.map(ee=>i.jsx("button",{onClick:()=>{c(ee.id),w(-1)},className:`px-3 py-1.5 text-xs rounded-lg whitespace-nowrap transition-colors ${l===ee.id?"bg-brand-600 text-white":"bg-surface-elevated text-fg-secondary hover:text-fg-primary"}`,children:ee.label},ee.id))})]}),i.jsxs("div",{ref:E,className:"flex-1 overflow-y-auto px-5 py-3",children:[p&&i.jsx("div",{className:"flex items-center justify-center py-8",children:i.jsx("div",{className:"text-fg-tertiary text-sm animate-pulse",children:n("common:loading")})}),!p&&g&&!F&&i.jsxs("div",{className:"flex flex-col items-center justify-center py-8 text-center",children:[i.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:[i.jsx("circle",{cx:"11",cy:"11",r:"8"}),i.jsx("line",{x1:"21",y1:"21",x2:"16.65",y2:"16.65"})]}),i.jsx("p",{className:"text-sm text-fg-tertiary",children:n("common:noResults",{defaultValue:"没有找到相关结果"})})]}),!p&&F&&i.jsx("div",{className:"space-y-4",children:I.map(ee=>{if(l!=="all"&&l!==ee)return null;const G=l==="all"?8:void 0,ae=H=>{const J=ne++,fe=H==="agents"?d.agents.length:H==="tasks"?d.tasks.length:H==="requirements"?d.requirements.length:H==="projects"?d.projects.length:H==="workflows"?d.workflows.length:d.deliverables.length;return i.jsxs("button",{"data-idx":J,onClick:()=>{c(H),w(-1)},className:`mt-1 w-full text-xs py-1.5 rounded-lg transition-colors ${J===y?"bg-brand-600/15 ring-1 ring-brand-500/40 text-brand-500":"text-brand-500 hover:text-brand-400 hover:bg-surface-overlay"}`,children:[n("common:showAll",{defaultValue:"查看全部"})," (",fe,")"]})};return ee==="agents"&&d.agents.length>0?i.jsxs("section",{children:[i.jsx("h3",{className:"text-xs font-medium text-fg-tertiary uppercase mb-2",children:n("common:agents",{defaultValue:"智能体"})}),i.jsx("div",{className:"space-y-0.5",children:(G?d.agents.slice(0,G):d.agents).map(H=>{const J=ne++;return i.jsxs("button",{"data-idx":J,onClick:()=>P(de.TEAM,{agentId:H.id}),className:`w-full flex items-center gap-3 px-3 py-2 rounded-xl transition-colors text-left ${J===y?"bg-brand-600/15 ring-1 ring-brand-500/40":"hover:bg-surface-overlay"}`,children:[i.jsx(Zi,{name:H.name||"Agent",avatarUrl:H.avatarUrl,size:28}),i.jsxs("div",{className:"flex-1 min-w-0",children:[i.jsx("div",{className:"text-sm font-medium text-fg-primary truncate",children:H.name}),i.jsx("div",{className:"text-xs text-fg-tertiary truncate",children:H.role||H.status})]}),i.jsx(vie,{status:H.status})]},H.id)})}),G&&d.agents.length>G&&ae("agents")]},"agents"):ee==="tasks"&&d.tasks.length>0?i.jsxs("section",{children:[i.jsx("h3",{className:"text-xs font-medium text-fg-tertiary uppercase mb-2",children:n("common:tasks",{defaultValue:"任务"})}),i.jsx("div",{className:"space-y-0.5",children:(G?d.tasks.slice(0,G):d.tasks).map(H=>{const J=ne++;return i.jsxs("button",{"data-idx":J,onClick:()=>P(de.WORK,{openTask:H.id}),className:`w-full flex items-center gap-3 px-3 py-2 rounded-xl transition-colors text-left ${J===y?"bg-brand-600/15 ring-1 ring-brand-500/40":"hover:bg-surface-overlay"}`,children:[i.jsx(wie,{status:H.status}),i.jsxs("div",{className:"flex-1 min-w-0",children:[i.jsx("div",{className:"text-sm text-fg-primary truncate",children:H.title}),i.jsxs("div",{className:"text-xs text-fg-tertiary truncate",children:[H.status," · ",H.priority||""]})]})]},H.id)})}),G&&d.tasks.length>G&&ae("tasks")]},"tasks"):ee==="requirements"&&d.requirements.length>0?i.jsxs("section",{children:[i.jsx("h3",{className:"text-xs font-medium text-fg-tertiary uppercase mb-2",children:n("common:requirements",{defaultValue:"需求"})}),i.jsx("div",{className:"space-y-0.5",children:(G?d.requirements.slice(0,G):d.requirements).map(H=>{const J=ne++;return i.jsxs("button",{"data-idx":J,onClick:()=>P(de.WORK,{openRequirement:H.id}),className:`w-full flex items-center gap-3 px-3 py-2 rounded-xl transition-colors text-left ${J===y?"bg-brand-600/15 ring-1 ring-brand-500/40":"hover:bg-surface-overlay"}`,children:[i.jsx("div",{className:`w-7 h-7 rounded-lg flex items-center justify-center shrink-0 ${H.status==="approved"?"text-green-500 bg-green-500/15":H.status==="pending"?"text-amber-500 bg-amber-500/15":H.status==="rejected"?"text-red-500 bg-red-500/15":"text-fg-tertiary bg-surface-elevated"}`,children:i.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[i.jsx("path",{d:"M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z"}),i.jsx("polyline",{points:"14 2 14 8 20 8"}),i.jsx("line",{x1:"16",y1:"13",x2:"8",y2:"13"}),i.jsx("line",{x1:"16",y1:"17",x2:"8",y2:"17"})]})}),i.jsxs("div",{className:"flex-1 min-w-0",children:[i.jsx("div",{className:"text-sm text-fg-primary truncate",children:H.title}),i.jsxs("div",{className:"text-xs text-fg-tertiary truncate",children:[H.status," · ",H.priority||""]})]})]},H.id)})}),G&&d.requirements.length>G&&ae("requirements")]},"requirements"):ee==="projects"&&d.projects.length>0?i.jsxs("section",{children:[i.jsx("h3",{className:"text-xs font-medium text-fg-tertiary uppercase mb-2",children:n("common:projects",{defaultValue:"项目"})}),i.jsx("div",{className:"space-y-0.5",children:(G?d.projects.slice(0,G):d.projects).map(H=>{const J=ne++;return i.jsxs("button",{"data-idx":J,onClick:()=>P(de.WORK,{projectId:H.id}),className:`w-full flex items-center gap-3 px-3 py-2 rounded-xl transition-colors text-left ${J===y?"bg-brand-600/15 ring-1 ring-brand-500/40":"hover:bg-surface-overlay"}`,children:[i.jsx("div",{className:"w-7 h-7 rounded-lg bg-brand-500/15 flex items-center justify-center shrink-0",children:i.jsx("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",className:"text-brand-500",children:i.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"})})}),i.jsxs("div",{className:"flex-1 min-w-0",children:[i.jsx("div",{className:"text-sm text-fg-primary truncate",children:H.name}),H.description&&i.jsx("div",{className:"text-xs text-fg-tertiary truncate",children:H.description})]})]},H.id)})}),G&&d.projects.length>G&&ae("projects")]},"projects"):ee==="deliverables"&&d.deliverables.length>0?i.jsxs("section",{children:[i.jsx("h3",{className:"text-xs font-medium text-fg-tertiary uppercase mb-2",children:n("common:deliverables",{defaultValue:"交付物"})}),i.jsx("div",{className:"space-y-0.5",children:(G?d.deliverables.slice(0,G):d.deliverables).map(H=>{const J=ne++;return i.jsxs("button",{"data-idx":J,onClick:()=>P(de.DELIVERABLES,{openDeliverable:H.id}),className:`w-full flex items-center gap-3 px-3 py-2 rounded-xl transition-colors text-left ${J===y?"bg-brand-600/15 ring-1 ring-brand-500/40":"hover:bg-surface-overlay"}`,children:[i.jsx("div",{className:"w-7 h-7 rounded-lg bg-purple-500/15 flex items-center justify-center shrink-0",children:i.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",className:"text-purple-500",children:[i.jsx("path",{d:"M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z"}),i.jsx("polyline",{points:"14 2 14 8 20 8"})]})}),i.jsxs("div",{className:"flex-1 min-w-0",children:[i.jsx("div",{className:"text-sm text-fg-primary truncate",children:H.title}),i.jsxs("div",{className:"text-xs text-fg-tertiary truncate",children:[H.type," · ",H.status]})]})]},H.id)})}),G&&d.deliverables.length>G&&ae("deliverables")]},"deliverables"):ee==="workflows"&&d.workflows.length>0?i.jsxs("section",{children:[i.jsx("h3",{className:"text-xs font-medium text-fg-tertiary uppercase mb-2",children:n("common:workflows",{defaultValue:"工作流"})}),i.jsx("div",{className:"space-y-0.5",children:(G?d.workflows.slice(0,G):d.workflows).map(H=>{const J=ne++;return i.jsxs("button",{"data-idx":J,onClick:()=>P(de.WORK,{boardType:"workflows"}),className:`w-full flex items-center gap-3 px-3 py-2 rounded-xl transition-colors text-left ${J===y?"bg-brand-600/15 ring-1 ring-brand-500/40":"hover:bg-surface-overlay"}`,children:[i.jsx("div",{className:"w-7 h-7 rounded-lg bg-teal-500/15 flex items-center justify-center shrink-0",children:i.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",className:"text-teal-500",children:[i.jsx("circle",{cx:"12",cy:"12",r:"3"}),i.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"})]})}),i.jsxs("div",{className:"flex-1 min-w-0",children:[i.jsx("div",{className:"text-sm text-fg-primary truncate",children:H.displayName||H.name}),i.jsxs("div",{className:"text-xs text-fg-tertiary truncate",children:[H.stepCount," steps · v",H.version]})]})]},H.name)})}),G&&d.workflows.length>G&&ae("workflows")]},"workflows"):null})}),!p&&!g&&i.jsxs("div",{className:"flex flex-col items-center justify-center py-8 text-center",children:[i.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:[i.jsx("circle",{cx:"11",cy:"11",r:"8"}),i.jsx("line",{x1:"21",y1:"21",x2:"16.65",y2:"16.65"})]}),i.jsx("p",{className:"text-sm text-fg-tertiary",children:n("common:searchHint",{defaultValue:"输入关键词搜索"})})]})]}),i.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:[i.jsxs("span",{children:[i.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:"唤起/关闭"})]}),i.jsxs("span",{children:[i.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:"切换分类"})]}),i.jsxs("span",{children:[i.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:"导航"})]}),i.jsxs("span",{children:[i.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:"打开"})]}),i.jsxs("span",{children:[i.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 vie({status:e}){const t=e==="active"||e==="idle"?"bg-green-500":e==="working"||e==="busy"?"bg-blue-500":"bg-gray-400";return i.jsx("span",{className:`w-2 h-2 rounded-full shrink-0 ${t}`})}function wie({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 i.jsx("div",{className:`w-7 h-7 rounded-lg flex items-center justify-center shrink-0 ${t}`,children:i.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[i.jsx("path",{d:"M9 11l3 3L22 4"}),i.jsx("path",{d:"M21 12v7a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h11"})]})})}const kie=["layout","navigation","tasks","team","search","rightPanel","terminal","help"];function Sie(e){return e===de.TEAM?"team":e===de.WORK?"work":e===de.DELIVERABLES?"deliverables":e===de.STORE?"store":"any"}function Cie({open:e,onClose:t,page:n}){const{t:a}=ot("common"),s=typeof navigator<"u"&&navigator.platform.toUpperCase().includes("MAC"),l=Sie(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?i.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":a("shortcuts.title"),children:i.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:[i.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:[i.jsx("h2",{className:"text-sm font-semibold text-fg-primary",children:a("shortcuts.title")}),i.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":a("shortcuts.close"),children:i.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[i.jsx("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),i.jsx("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]})})]}),i.jsx("div",{className:"px-4 py-3 space-y-4",children:kie.map(c=>{const d=TU.filter(m=>{if(m.group!==c)return!1;const p=m.page??"any";return p==="any"?!0:p===l});return d.length===0?null:i.jsxs("section",{children:[i.jsx("h3",{className:"text-[11px] font-semibold uppercase tracking-wide text-fg-tertiary mb-2",children:a(`shortcuts.groups.${c}`)}),i.jsx("ul",{className:"space-y-1.5",children:d.map(m=>i.jsxs("li",{className:"flex items-center justify-between gap-3 text-sm",children:[i.jsx("span",{className:"text-fg-secondary min-w-0",children:a(m.labelKey??m.label,{defaultValue:m.label})}),i.jsx("kbd",{className:"shrink-0 px-2 py-1 rounded bg-surface-elevated border border-border-default text-[13px] font-medium leading-none text-fg-primary font-mono",children:x4(m.keys,s,m.bare)})]},m.id))})]},c)})})]})}):null}function Aie({authUser:e,onClose:t,onSaved:n,onUserUpdated:a}){const{t:s}=ot("common");Qo(!0);const[l,c]=k.useState(e.name||""),[d,m]=k.useState(e.email||""),[p,h]=k.useState(!1),[g,x]=k.useState(""),[y,w]=k.useState(()=>m4(e.avatarUrl,xr()?.avatarUrl)),T=async C=>{if(C.preventDefault(),!l.trim()){x(s("profile.nameRequired"));return}if(d&&!/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(d.trim())){x(s("profile.invalidEmail"));return}h(!0),x("");try{const{user:S}=await Ae.auth.updateProfile(l.trim(),d.trim());n({...S,avatarUrl:y??S.avatarUrl})}catch{x(s("profile.failedToSave"))}finally{h(!1)}};return i.jsx("div",{className:"fixed inset-0 bg-black/60 flex items-center justify-center z-[10000]",onClick:t,children:i.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:[i.jsx("h3",{className:"text-base font-semibold mb-5",children:s("profile.editProfile")}),i.jsx("div",{className:"flex justify-center mb-5",children:i.jsx(f4,{currentUrl:y,name:l,size:72,targetType:"user",targetId:e.id,onUploaded:C=>{w(C),a?.({...e,avatarUrl:C})}})}),i.jsxs("div",{className:"space-y-3",children:[i.jsxs("div",{children:[i.jsx("label",{className:"block text-xs text-fg-tertiary font-medium mb-1",children:s("profile.name")}),i.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"})]}),i.jsxs("div",{children:[i.jsx("label",{className:"block text-xs text-fg-tertiary font-medium mb-1",children:s("profile.email")}),i.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&&i.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})]}),i.jsxs("div",{className:"flex justify-end gap-3 mt-5",children:[i.jsx("button",{type:"button",onClick:t,className:"px-4 py-2 text-sm border border-border-default rounded-lg hover:bg-surface-elevated",children:s("cancel")}),i.jsx("button",{type:"submit",disabled:p,className:"px-4 py-2 text-sm bg-brand-600 hover:bg-brand-500 disabled:opacity-50 text-white rounded-lg",children:s(p?"saving":"save")})]})]})})}const Lk=k.lazy(()=>va(()=>import("./Team-YUOVSMYB.js"),__vite__mapDeps([2,3,4,5,6])).then(e=>({default:e.TeamPage}))),Ik=k.lazy(()=>va(()=>import("./Settings-x1XJ8_4m.js"),[]).then(e=>({default:e.Settings}))),Tie=k.lazy(()=>va(()=>import("./Store-CcHbeFLa.js"),[]).then(e=>({default:e.StorePage}))),Nie=k.lazy(()=>va(()=>Promise.resolve().then(()=>$re),void 0).then(e=>({default:e.AgentBuilder}))),Ok=k.lazy(()=>va(()=>import("./Work-CWfGwHiq.js"),__vite__mapDeps([7,4,1,8,3,9])).then(e=>({default:e.WorkPage}))),Pk=k.lazy(()=>va(()=>import("./Deliverables-D4ugAcBA.js"),__vite__mapDeps([10,4,5])).then(e=>({default:e.DeliverablesPage}))),Eie=k.lazy(()=>va(()=>import("./Notifications-DA8vJKEr.js"),[]).then(e=>({default:e.NotificationsPage}))),jie=k.lazy(()=>va(()=>import("./Search-xvm7dGkp.js"),[]).then(e=>({default:e.SearchPage}))),Mie={visibility:"hidden",position:"absolute",inset:0,pointerEvents:"none",zIndex:-1};function _ie(e){try{const t=navigator.language,n=Intl.DateTimeFormat().resolvedOptions().timeZone,a=e.preferences??{};if(a.locale===t&&a.timezone===n)return;Ae.auth.updatePreferences({locale:t,timezone:n}).catch(()=>{})}catch{}}function Rie(){return i.jsx("div",{className:"flex-1 flex items-center justify-center text-fg-tertiary text-sm animate-pulse",children:"Loading..."})}const Die=k.memo(function({id:t,activePage:n,children:a}){const s=t===n;return i.jsx("div",{className:"flex-1 overflow-hidden flex flex-col",style:s?void 0:Mie,children:i.jsx(k.Suspense,{fallback:i.jsx(Rie,{}),children:a})})},(e,t)=>{const n=e.id===e.activePage,a=t.id===t.activePage;return n!==a?!1:a?e.children===t.children:!0}),Ud={};function l6(e){return typeof window<"u"&&window.matchMedia("(max-width: 767px)").matches?a4[e]??e:e}function zk(){return l6(Sc())}function Lie(){const{t:e}=ot("common"),[t,n]=k.useState(zk),[a,s]=k.useState(!1),[l,c]=k.useState(!0),d=Xo(),m=gie(),p=fie({side:"left",defaultWidth:160,minWidth:140,maxWidth:400,collapsedWidth:64,storageKey:"markus_sidebar"}),[h,g]=k.useState(()=>new Set([zk()])),[x,y]=k.useState("loading"),[w,T]=k.useState(!1),[C,S]=k.useState(null),[E,_]=k.useState({hasOwner:!1,hasMultipleUsers:!1}),[M,P]=k.useState(!1),[R,I]=k.useState(!1),[K,Y]=k.useState(null),[L,F]=k.useState(!1),[ne,ee]=k.useState(null),[G,ae]=k.useState(()=>{const Q=localStorage.getItem("markus_update_dismissed");return Q||null}),[H,J]=k.useState(!1),[fe,Ce]=k.useState(!1),$=qc(),V=$?.leftCollapsed??!1,pe=$?.toggleLeftCollapsed,z=$?.setLeftCollapsed,je=$?.keyboardPane??"l0",Ue=$?.setKeyboardPane,qe=$?.l0FocusPageId??null,He=$?.setL0FocusPageId,ut=k.useRef(t);ut.current=t;const dt=k.useRef(de.HOME),Nt=$?.toggleRightPanel,wt=$?.toggleTerminalPanel,Zt=$?.cycleRightPanelTab,Wt=$?.activateRightPanelTabAt,rt=$?.openNewRightPanelTab,$e=$?.rightPanelOpen??!1,mt=$?.activeRightPanelTabId??null,At=$?.openRightPanel,Dt=$?.closeRightPanelTab,ln=$?.updateRightPanelBrowserTab,ce=$?.updateRightPanelTerminalTab,et=k.useRef($?.rightPanelTabs);et.current=$?.rightPanelTabs,k.useEffect(()=>{const Q=window.markusDesktop?.browser?.onPageEvent;if(!(!Q||!At))return Q(X=>{if(X.type==="closed"){const ue=et.current?.find(Be=>Be.payload.kind==="url"&&Be.payload.browserId===X.browserId);ue&&Dt&&Dt(ue.id);return}if(X.type==="navigated"){if(X.url&&Ac(X.url))return;X.browserId&&ln&&ln(X.browserId,{url:X.url,title:X.title||X.url});return}if(X.type==="opened"||X.type==="selected"){if(!X.url&&!X.browserId||X.browserId.startsWith("eb_")||Ste(X.browserId)||X.url&&Ac(X.url))return;At({kind:"url",url:X.url||"about:blank",title:X.title||X.url||"Browser",browserId:X.browserId,pageId:X.pageId})}})},[At,Dt,ln]),k.useEffect(()=>{const Q=window.markusDesktop?.terminal?.onEvent;if(!(!Q||!At))return Q(X=>{if(X.type==="closed"){const ue=et.current?.find(Be=>Be.payload.kind==="terminal"&&Be.payload.terminalId===X.id);ue&&Dt&&Dt(ue.id);return}if(X.type==="cwd"){X.cwd&&ce?.(X.id,{cwd:X.cwd});return}if(X.type==="selected"){(X.title||X.cwd)&&ce?.(X.id,{title:X.title,cwd:X.cwd});return}if(X.type==="opened"){if(mb.has(X.id)){(X.title||X.cwd)&&ce?.(X.id,{title:X.title,cwd:X.cwd});return}_s(X.id),At({kind:"terminal",terminalId:X.id,title:X.title||"Terminal",cwd:X.cwd})}})},[At,Dt,ce]);const nt=$?.handleTerminalExit;k.useEffect(()=>{const Q=window.markusDesktop?.terminal?.onExit;if(!(!Q||!nt))return Q(X=>{nt(X.id)})},[nt]),k.useLayoutEffect(()=>{const Q=t===de.TEAM&&$e&&$?.rightPanelMode==="browser";wf(Q)},[t,$e,$?.rightPanelMode]),k.useEffect(()=>{window.markusDesktop?.browser?.hideAll?.()},[]);const we=k.useRef(!1);k.useEffect(()=>{if(!we.current){we.current=!0;return}p.setCollapsed(V)},[V,p.setCollapsed]),k.useEffect(()=>{if(d)return;const Q=navigator.platform.toUpperCase().includes("MAC"),X=Be=>{Q&&Be.metaKey&&!Be.ctrlKey&&Be.key==="p"?(Be.preventDefault(),J(Ie=>!Ie)):!Q&&Be.ctrlKey&&!Be.metaKey&&Be.key==="p"&&(Be.preventDefault(),J(Ie=>!Ie))},ue=()=>J(!0);return document.addEventListener("keydown",X),window.addEventListener("markus:open-search",ue),()=>{document.removeEventListener("keydown",X),window.removeEventListener("markus:open-search",ue)}},[d]);const Me=k.useCallback(()=>!$e||!mt||!Dt?!1:(Dt(mt),!0),[$e,mt,Dt]);k.useEffect(()=>{const Q=window.markusDesktop?.onAppShortcut?.(X=>{if(X.type==="close-tab"){Me();return}X.type==="new-tab"&&rt?.()});return()=>{Q?.()}},[Me,rt]),k.useEffect(()=>{if(d||!pe||!Nt)return;const Q=navigator.platform.toUpperCase().includes("MAC"),X=ue=>{if(!(Q?ue.metaKey&&!ue.ctrlKey:ue.ctrlKey&&!ue.metaKey)||ue.altKey)return;if(!ue.shiftKey&&(ue.key==="/"||ue.code==="Slash")){ue.preventDefault(),Ce(Ge=>!Ge);return}if(ue.shiftKey&&(ue.key==="?"||ue.key==="/")){ue.preventDefault(),Ce(Ge=>!Ge);return}if(ue.shiftKey&&$e&&Zt){if(ue.key==="]"||ue.code==="BracketRight"){ue.preventDefault(),Zt(1);return}if(ue.key==="["||ue.code==="BracketLeft"){ue.preventDefault(),Zt(-1);return}}if(!ue.shiftKey&&$e&&Wt){const Ge=ue.key>="1"&&ue.key<="9"?Number(ue.key):0;if(Ge>=1){ue.preventDefault(),Wt(Ge-1);return}}if(ue.shiftKey)return;const Ie=ue.key.toLowerCase();if(Ie==="w"){ue.preventDefault(),ue.stopPropagation(),Me();return}if(Ie==="t"){ue.preventDefault(),rt?.();return}if(Ie==="b"){if(t===de.DELIVERABLES)return;ue.preventDefault(),pe()}else if(t===de.TEAM&&Ie==="l"){if(!Q&&Pv(ue.target)||Q&&Pv(ue.target)&&ue.ctrlKey)return;ue.preventDefault(),Nt()}else t===de.TEAM&&Ie==="j"&&wt&&(ue.preventDefault(),wt())};return document.addEventListener("keydown",X,!0),()=>document.removeEventListener("keydown",X,!0)},[d,t,pe,Nt,wt,Zt,Wt,$e,Me,rt]);const Ne=k.useCallback((Q,X)=>{let ue=kc(Q);d?ue=a4[ue]??ue:ue===de.NOTIFICATIONS&&(ue=de.HOME),ue!==de.TEAM&&wf(!1);const Be=Sc(),Ie=window.location.hash.slice(1);Ie!==Nh(Be)?Ud[Be]=Ie:delete Ud[Be];const Ge=ut.current;if(ue===de.SETTINGS&&Ge!==de.SETTINGS&&(dt.current=Ge,at.setSettingsReturnPage(Ge),Ue?.("l1"),He?.(de.SETTINGS)),Ge===de.SETTINGS&&ue!==de.SETTINGS&&(Ue?.("l0"),He?.(ue)),ue===de.SETTINGS&&X?.tab){const Rt=`settings/${X.tab}`;Ud[ue]=Rt,history.pushState(null,"","#"+Rt),window.dispatchEvent(new HashChangeEvent("hashchange")),n(ue),g(Mt=>Mt.has(ue)?Mt:new Set([...Mt,ue]));return}const kt=ue!==de.WORK?Ud[ue]:void 0;kt&&kt!==Nh(ue)?(history.pushState(null,"",Ps(ue)),history.pushState(null,"","#"+kt)):history.pushState(null,"",Ps(ue)),window.dispatchEvent(new HashChangeEvent("hashchange")),n(ue),g(Rt=>Rt.has(ue)?Rt:new Set([...Rt,ue]))},[d,Ue,He]);k.useEffect(()=>{at.setHandler((Q,X)=>Ne(Q,X))},[Ne]),k.useEffect(()=>{je==="l0"&&t!==de.SETTINGS&&He?.(t)},[je,t,He]),k.useEffect(()=>{if(d||!Ue||!He)return;const Q=X=>{if(X.metaKey||X.ctrlKey||X.altKey||Ov(X.target))return;const ue=X.key.length===1?X.key.toLowerCase():X.key;if(t===de.SETTINGS&&(ue==="h"||ue==="ArrowLeft")){X.preventDefault(),X.stopImmediatePropagation(),at.leaveSettings();return}if(je!=="l0"||t===de.SETTINGS)return;const Be=qe&&Eo.includes(qe)?qe:t,Ie=Math.max(0,Eo.indexOf(Be));if(ue==="j"||ue==="ArrowDown"){X.preventDefault(),X.stopImmediatePropagation();const Ge=Eo[Math.min(Eo.length-1,Ie+1)];He(Ge),Ge!==t&&Ne(Ge),requestAnimationFrame(()=>{document.querySelector(`[data-l0-page-id="${Ge}"]`)?.scrollIntoView({block:"nearest"})});return}if(ue==="k"||ue==="ArrowUp"){X.preventDefault(),X.stopImmediatePropagation();const Ge=Eo[Math.max(0,Ie-1)];He(Ge),Ge!==t&&Ne(Ge),requestAnimationFrame(()=>{document.querySelector(`[data-l0-page-id="${Ge}"]`)?.scrollIntoView({block:"nearest"})});return}if(ue==="l"||ue==="ArrowRight"||ue==="Enter"){const Ge=qe&&Eo.includes(qe)?qe:t;if(!ZF.has(Ge)){X.preventDefault(),X.stopImmediatePropagation();return}X.preventDefault(),X.stopImmediatePropagation(),Ge!==t&&Ne(Ge),z?.(!1),Ue("l1");return}(ue==="h"||ue==="ArrowLeft")&&(X.preventDefault(),X.stopImmediatePropagation())};return document.addEventListener("keydown",Q,!0),()=>document.removeEventListener("keydown",Q,!0)},[d,je,qe,t,Ne,Ue,He,z]),k.useEffect(()=>{const Q=()=>T(!0);return window.addEventListener("markus:open-edit-profile",Q),()=>window.removeEventListener("markus:open-edit-profile",Q)},[]),k.useEffect(()=>{if(!window.markusDesktop)return;!d&&t!==de.SETTINGS&&!p.collapsed?window.markusDesktop.setTrafficLightPosition(16,16):window.markusDesktop.setTrafficLightPosition(6,16)},[p.collapsed,t,d]),k.useEffect(()=>{window.markusDesktop&&window.markusDesktop.onNotificationClick(Q=>{if(Q.openNotifications&&window.dispatchEvent(new CustomEvent("markus:open-notifications")),Q.page){const X=kc(Q.page);Q.params&&Object.entries(Q.params).forEach(([ue,Be])=>localStorage.setItem(`markus_nav_${ue}`,Be)),Ne(X),window.dispatchEvent(new CustomEvent("markus:navigate",{detail:{page:X,params:Q.params}}))}})},[Ne]);const se=k.useCallback(()=>{fetch("/api/settings/llm").then(Q=>Q.ok?Q.json():null).then(Q=>{if(Q?.providers){const X=Object.values(Q.providers).some(ue=>ue.configured);Y(X)}}).catch(()=>{})},[]),q=k.useCallback((Q,X)=>{if(!Q)return;const Be=X&&{agent:"agents",team:"teams",skill:"skills"}[X]||"agents";localStorage.setItem("markus_nav_installItem",Q),localStorage.setItem("markus_nav_storeTab",Be);const Ie=new URLSearchParams(window.location.search);Ie.get("install")||(Ie.set("install",Q),X&&Ie.set("type",X));const Ge=Ie.toString();window.history.replaceState(null,"",`${window.location.pathname}?${Ge}${Ps(de.STORE)}`);const kt=()=>at.navigate(de.STORE,{storeTab:Be,installItem:Q});kt(),setTimeout(kt,500),setTimeout(kt,1500)},[]);k.useEffect(()=>{const Q=new URLSearchParams(window.location.search),X=Q.get("install");X&&q(X,Q.get("type"));const ue=window.markusDesktop;ue?.onDeepLinkInstall?.(({id:Ge,type:kt})=>q(Ge,kt)),ue?.consumePendingDeepLinkInstall?.().then(Ge=>{Ge?.id&&q(Ge.id,Ge.type)}),Ae.auth.me().then(({user:Ge})=>{y(Ge),S(!0),s(!1),Ge.preferences?.guideHidden===!0&&!_h(Ge.id)&&Rh(Ge.id),_ie(Ge),Ir.connect(Ge.id),se(),Ae.health().then(Rt=>{Rt.updateAvailable&&Rt.latestVersion&&ee({latestVersion:Rt.latestVersion,currentVersion:Rt.version})}).catch(()=>{});const kt=()=>{Ns(qa.builderArtifacts,()=>Ae.builder.artifacts.list()),Ns(qa.builderAgents,()=>Ae.agents.list()),Ns(qa.builderHubMyItems,()=>st.myItems()),Ns(qa.builderInstalled,()=>Ae.builder.artifacts.installed()),Ns(qa.hubAgents,()=>st.search({type:"agent",limit:50})),Ns(qa.hubTeams,()=>st.search({type:"team",limit:50})),Ns(qa.hubSkills,()=>st.search({type:"skill",limit:50}))};typeof requestIdleCallback=="function"?requestIdleCallback(kt,{timeout:5e3}):setTimeout(kt,3e3)}).catch(()=>{y(null),Ae.auth.status().then(({initialized:Ge,hasOwner:kt,hasMultipleUsers:Rt})=>{S(Ge),_({hasOwner:kt,hasMultipleUsers:Rt})}).catch(()=>S(!0))}),Ir.connect();const Be=Ir.on("notification",()=>{window.dispatchEvent(new CustomEvent("markus:notifications-changed"))}),Ie=()=>{const Ge=l6(Sc());Ge!==de.TEAM&&wf(!1),n(Ge),g(kt=>kt.has(Ge)?kt:new Set([...kt,Ge]))};return window.addEventListener("hashchange",Ie),window.addEventListener("popstate",Ie),()=>{Be(),Ir.disconnect(),window.removeEventListener("hashchange",Ie),window.removeEventListener("popstate",Ie)}},[]),k.useEffect(()=>{const Q=x!=="loading"&&x!==null?x.id:void 0;if(!Q)return;const X=navigator.platform.toUpperCase().includes("MAC"),ue=Be=>{if(Ov(Be.target))return;const Ie={key:Be.key,code:Be.code,metaKey:Be.metaKey,ctrlKey:Be.ctrlKey,altKey:Be.altKey,shiftKey:Be.shiftKey};CU(Ie,Q,X)&&window.dispatchEvent(new CustomEvent("markus:shortcut-lesson-complete"))};return window.addEventListener("keydown",ue,!0),()=>window.removeEventListener("keydown",ue,!0)},[x]);const te=x!=="loading"&&x!==null?x:void 0,Se=k.useMemo(()=>d?{[de.HOME]:i.jsx($v,{authUser:te}),[de.TEAM]:i.jsx(Lk,{authUser:te}),[de.BUILDER]:i.jsx(lie,{authUser:te}),[de.SETTINGS]:i.jsx(Ik,{theme:m.mode,onThemeChange:m.setMode,authUser:te,onLogout:()=>{Ae.auth.logout().catch(()=>{}),Ds(),y(null)},onUserUpdated:Q=>y(Q)}),[de.WORK]:i.jsx(Ok,{authUser:te}),[de.DELIVERABLES]:i.jsx(Pk,{authUser:te}),[de.NOTIFICATIONS]:i.jsx(Eie,{authUser:te}),[de.SEARCH]:i.jsx(jie,{})}:{[de.HOME]:i.jsx($v,{authUser:te}),[de.TEAM]:i.jsx(Lk,{authUser:te}),[de.SETTINGS]:i.jsx(Ik,{theme:m.mode,onThemeChange:m.setMode,authUser:te,onLogout:()=>{Ae.auth.logout().catch(()=>{}),Ds(),y(null)},onUserUpdated:Q=>y(Q)}),[de.STORE]:i.jsx(Tie,{authUser:te}),[de.BUILDER]:i.jsx(Nie,{authUser:te}),[de.WORK]:i.jsx(Ok,{authUser:te}),[de.DELIVERABLES]:i.jsx(Pk,{authUser:te})},[te?.id,te?.role,m.mode,d]);if(x==="loading"||x===null&&C===null)return i.jsx("div",{className:"min-h-dvh bg-surface-primary flex items-center justify-center",children:i.jsx("div",{className:"text-fg-tertiary text-sm animate-pulse",children:e("loading")})});const Pe=(typeof window<"u"?window.location.hash:"").match(/^#invite\?token=([a-f0-9]+)/);return Pe?i.jsx(mie,{token:Pe[1],onComplete:()=>{window.location.hash="",localStorage.removeItem("markus_onboarded"),s(!0),P(!0),y("loading"),Ae.auth.me().then(Q=>{zv(Q.user.id),y(Q.user)}).catch(()=>y(null))}}):x===null?i.jsx(die,{hasOwner:E.hasOwner,hasMultipleUsers:E.hasMultipleUsers,onLogin:(Q,X,ue)=>{y(Q),Ir.connect(Q.id),X?(zv(Q.id),s(!0),ue?.fromHub&&P(!0)):(s(!1),_h(Q.id)?(Rh(Q.id),Ae.auth.updatePreferences({guideHidden:!0}).catch(()=>{}),y({...Q,preferences:{...Q.preferences,guideHidden:!0}})):y(Q))}}):R?i.jsx(pie,{onComplete:()=>I(!1),isFirstTime:!0}):a?i.jsx(cie,{theme:m.mode,onThemeChange:m.setMode,skipProfile:M,onProfileUpdated:Q=>{const X={id:Q.id,name:Q.name,email:Q.email,role:Q.role,orgId:Q.orgId??"default",avatarUrl:Q.avatarUrl};y(X)},onComplete:()=>{localStorage.removeItem("markus_onboarded"),s(!1),P(!1),Ae.auth.me().then(Q=>y(Q.user)).catch(()=>{}),se(),Ne(de.HOME)}}):i.jsxs("div",{className:`flex h-dvh bg-surface-primary text-fg-primary overflow-x-hidden ${d?"flex-col":""}`,children:[!d&&t!==de.SETTINGS&&i.jsxs(i.Fragment,{children:[i.jsx("div",{className:"relative z-40 shrink-0",style:{width:p.width},children:i.jsx(ure,{currentPage:t,onNavigate:Q=>{Ne(Q),c(!1),Ue?.("l0"),He?.(Q)},authUser:x,collapsed:p.collapsed,onToggleCollapse:p.toggle,onLogout:()=>{Ae.auth.logout().catch(()=>{}),Ds(),y(null)},keyboardFocusPageId:qe,keyboardPaneActive:je==="l0"})}),i.jsx("div",{className:`${p.collapsed?"w-0":"w-1.5 cursor-col-resize"} shrink-0 group relative z-10 flex items-center justify-center`,onMouseDown:p.collapsed?void 0:p.onResizeStart,children:!p.collapsed&&i.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"})})]}),i.jsxs("div",{className:`flex-1 overflow-hidden flex flex-col min-w-0 ${d&&t!==de.SETTINGS&&t!==de.SEARCH?"pb-14":""}`,children:[K===!1&&!L&&t!==de.SETTINGS&&i.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:[i.jsx("span",{className:d?"text-xs":"",children:e("llmBanner.message")}),i.jsxs("div",{className:"flex items-center gap-3",children:[i.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")}),i.jsx("button",{onClick:()=>F(!0),className:"text-amber-500 hover:text-amber-600 text-xs",children:e("dismiss")})]})]}),ne&&G!==ne.latestVersion&&i.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:[i.jsx("span",{className:d?"text-xs":"",children:e("update.available",{latest:ne.latestVersion,current:ne.currentVersion})}),i.jsxs("span",{className:"flex items-center gap-3 shrink-0",children:[i.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")}),i.jsx("button",{onClick:()=>{ae(ne.latestVersion),localStorage.setItem("markus_update_dismissed",ne.latestVersion)},className:"text-fg-tertiary hover:text-fg-secondary text-xs shrink-0",children:e("dismiss")})]})]}),i.jsx("main",{className:"flex-1 overflow-hidden flex flex-col relative",children:Object.keys(Se).map(Q=>h.has(Q)?i.jsx(Die,{id:Q,activePage:t,children:Se[Q]},Q):null)})]}),d&&t!==de.SETTINGS&&t!==de.SEARCH&&i.jsx(xre,{currentPage:t,onNavigate:Ne,userId:te?.id}),d&&i.jsx(wU,{authUser:te,onNavigate:Ne,onLogout:()=>{Ae.auth.logout().catch(()=>{}),Ds(),y(null)}}),!d&&H&&i.jsx(xie,{onClose:()=>J(!1),currentPage:t}),!d&&i.jsx(Cie,{open:fe,onClose:()=>Ce(!1),page:t}),w&&te&&i.jsx(Aie,{authUser:te,onClose:()=>T(!1),onUserUpdated:Q=>y(Q),onSaved:Q=>{T(!1),y(Q)}})]})}const Bk="data-anim-paused",Hk="data-anim-tick",$k=8,Iie=250;function Oie(){return document.visibilityState!=="visible"||document.hidden?!0:!document.hasFocus()}let xc=null,Po=0;function Pie(){xc===null&&(Po=Po%$k,document.documentElement.setAttribute(Hk,String(Po)),xc=window.setInterval(()=>{Po=(Po+1)%$k,document.documentElement.setAttribute(Hk,String(Po))},Iie))}function zie(){xc!==null&&(window.clearInterval(xc),xc=null)}function oc(){const e=document.documentElement;Oie()?(e.setAttribute(Bk,"true"),zie()):(e.removeAttribute(Bk),Pie())}let qk=!1;function Bie(){qk||typeof document>"u"||(qk=!0,oc(),document.addEventListener("visibilitychange",oc,{passive:!0}),window.addEventListener("focus",oc,{passive:!0}),window.addEventListener("blur",oc,{passive:!0}),window.addEventListener("pageshow",oc,{passive:!0}))}Bie();xA.createRoot(document.getElementById("root")).render(i.jsx(k.StrictMode,{children:i.jsx(jte,{children:i.jsx(Lie,{})})}));export{Dse as $,Zi as A,Qo as B,li as C,pne as D,Ps as E,ba as F,aU as G,Kie as H,nie as I,gb as J,Xie as K,bg as L,g4 as M,ore as N,hne as O,de as P,yg as Q,$ie as R,eie as S,Ure as T,Sae as U,kae as V,Vie as W,Zie as X,Jie as Y,Go as Z,va as _,Xo as a,wse as a$,qie as a0,xr as a1,dT as a2,cse as a3,tU as a4,Fie as a5,Uie as a6,_s as a7,Md as a8,fi as a9,Rse as aA,xse as aB,Sse as aC,Qie as aD,sse as aE,bb as aF,x4 as aG,fse as aH,hse as aI,gse as aJ,Ase as aK,Jw as aL,Zte as aM,_se as aN,Cse as aO,jse as aP,Tse as aQ,dk as aR,mk as aS,ire as aT,Mse as aU,vse as aV,kse as aW,IS as aX,Pv as aY,bse as aZ,yse as a_,mm as aa,Ese as ab,nne as ac,Lw as ad,_ae as ae,zs as af,rl as ag,mse as ah,use as ai,ise as aj,dse as ak,lse as al,ose as am,tse as an,$ae as ao,ase as ap,pse as aq,Kae as ar,Nse as as,VS as at,rse as au,Oae as av,ese as aw,Gie as ax,nse as ay,gre as az,hU as b,Yie as b0,PS as b1,qc as c,iie as d,Vre as e,Xre as f,Is as g,st as h,Ov as i,i as j,zr as k,Ae as l,fie as m,at as n,jn as o,kc as p,Ea as q,k as r,hb as s,Ha as t,ot as u,Hie as v,Ir as w,Ic as x,zm as y,pT as z};
882
+ ${t("share.rejectedEncourage")}`})},className:"text-xs px-2 py-1.5 rounded-lg border border-red-500/30 text-red-400 hover:bg-red-500/10 transition-colors inline-flex items-center gap-1 cursor-pointer",title:t("share.rejectedTip"),children:[i.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:[i.jsx("circle",{cx:"12",cy:"12",r:"10"}),i.jsx("line",{x1:"15",y1:"9",x2:"9",y2:"15"}),i.jsx("line",{x1:"9",y1:"9",x2:"15",y2:"15"})]}),t("share.rejected")]}),i.jsxs("button",{onClick:()=>{rt(ce,{visibility:Ne?.visibility??"public"})},disabled:!!Me,className:"text-xs px-3 py-1.5 rounded-lg border border-brand-500/40 text-brand-400 hover:bg-brand-500/10 hover:border-brand-500/60 transition-colors disabled:opacity-50 inline-flex items-center gap-1",title:t("share.rejectedTip"),children:[i.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:[i.jsx("polyline",{points:"23 4 23 10 17 10"}),i.jsx("polyline",{points:"1 20 1 14 7 14"}),i.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"})]}),t(Me==="share"?"common:sharing":"share.resubmit")]})]}):q?i.jsxs(i.Fragment,{children:[te&&i.jsxs("button",{onClick:()=>{const Ie=Ne?.visibility??"public";rt(ce,{visibility:Ie})},disabled:!!Me,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:[i.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:[i.jsx("polyline",{points:"23 4 23 10 17 10"}),i.jsx("polyline",{points:"1 20 1 14 7 14"}),i.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"})]}),Me==="share"?t("common:sharing"):t("share.updateVersion",{version:se})]}),i.jsxs("a",{href:Se()??"#",target:"_blank",rel:"noopener noreferrer",onClick:Ie=>{const Ge=Se();Go()&&Ge&&(Ie.preventDefault(),fi(Ge))},className:`text-xs px-3 py-1.5 rounded-lg border transition-colors inline-flex items-center gap-1 ${Ne?.visibility==="org"?"border-blue-500/30 text-blue-500 hover:text-blue-400 hover:border-blue-400/40":Ne?.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:[Ne?.visibility==="org"?i.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:[i.jsx("path",{d:"M3 21h18"}),i.jsx("path",{d:"M9 8h1"}),i.jsx("path",{d:"M9 12h1"}),i.jsx("path",{d:"M9 16h1"}),i.jsx("path",{d:"M14 8h1"}),i.jsx("path",{d:"M14 12h1"}),i.jsx("path",{d:"M14 16h1"}),i.jsx("path",{d:"M5 21V5a2 2 0 0 1 2-2h10a2 2 0 0 1 2 2v16"})]}):Ne?.visibility==="unlisted"?i.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:[i.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"}),i.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"})]}):i.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:[i.jsx("path",{d:"M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6"}),i.jsx("polyline",{points:"15 3 21 3 21 9"}),i.jsx("line",{x1:"10",y1:"14",x2:"21",y2:"3"})]}),Ne?.visibility==="org"?t("visibility.sharedOrg"):Ne?.visibility==="unlisted"?t("visibility.sharedUnlisted"):t("visibility.shared")]}),i.jsxs("button",{onClick:()=>Y({key:we,name:et}),disabled:!!Me,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:[i.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:[i.jsx("path",{d:"M18.84 12.25l1.72-1.71a5 5 0 0 0-7.07-7.07l-1.72 1.71"}),i.jsx("path",{d:"M5.17 11.75l-1.71 1.71a5 5 0 0 0 7.07 7.07l1.71-1.71"}),i.jsx("line",{x1:"2",y1:"2",x2:"22",y2:"22"})]}),t("unshare")]})]}):i.jsxs("button",{onClick:async()=>{await st.ensureAuth(),Array.isArray(ce.meta.screenshots)&&ce.meta.screenshots.length>0?J(ce):ee(ce)},disabled:!!Me,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:[i.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:[i.jsx("circle",{cx:"18",cy:"5",r:"3"}),i.jsx("circle",{cx:"6",cy:"12",r:"3"}),i.jsx("circle",{cx:"18",cy:"19",r:"3"}),i.jsx("line",{x1:"8.59",y1:"13.51",x2:"15.42",y2:"17.49"}),i.jsx("line",{x1:"15.41",y1:"6.51",x2:"8.59",y2:"10.49"})]}),t(Me==="share"?"common:sharing":"common:share")]})]}),Q=i.jsx("button",{onClick:()=>S(ce),disabled:!!Me,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:i.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:[i.jsx("polyline",{points:"3 6 5 6 21 6"}),i.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"})]})}),X=ce.meta.icon,Be=!!X&&/\.(png|jpe?g|gif|webp|svg)$/i.test(X)?X.startsWith("http")||X.startsWith("/")?X:`/api/builder/artifacts/${ce.type}s/${encodeURIComponent(ce.name)}/images/${encodeURIComponent(X.split("/").pop()??"")}?v=${ce.updatedAt??""}`:X;return i.jsx(vr,{type:ce.type,name:et,description:nt,seed:we,icon:Be,version:se,footerLeft:i.jsxs("span",{className:"flex items-center gap-2 text-[10px] text-fg-tertiary min-w-0",children:[i.jsx("button",{onClick:Ie=>{Ie.stopPropagation(),Ae.system.openPath(ce.path).catch(()=>{})},className:"hover:text-fg-secondary transition-colors truncate min-w-0",title:ce.path,children:Ire(ce.path)}),i.jsx("span",{className:"shrink-0",children:"·"}),i.jsx("span",{className:"shrink-0",children:new Date(ce.updatedAt).toLocaleDateString()})]}),headerAction:Q,actions:Pe,onClick:()=>ln(ce)},we)})})),E&&i.jsx(ba,{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;_(null),Zt(ce)},onCancel:()=>_(null)}),M&&i.jsx(ba,{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;P(null),Wt(ce)},onCancel:()=>P(null)}),C&&i.jsx(ba,{title:t("confirmDeleteLocal"),message:t("deleteCannotUndo",{name:C.meta.displayName||C.meta.name||C.name}),confirmLabel:t("common:delete"),onConfirm:mt,onCancel:()=>S(null)}),K&&i.jsx(ba,{title:t("confirmUnshare"),message:t("removeFromHub",{name:K.name}),confirmLabel:t("unshare"),onConfirm:()=>{$e()},onCancel:()=>Y(null)}),L&&i.jsx(ba,{alertOnly:!0,variant:L.variant??"primary",title:L.title,message:L.message,onConfirm:()=>F(null),onCancel:()=>F(null)}),ne&&i.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/60 backdrop-blur-sm",onClick:()=>ee(null),children:i.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:[i.jsx("h3",{className:"text-base font-semibold text-fg-primary mb-2",children:t("common:share")}),i.jsx("p",{className:"text-sm text-fg-secondary mb-5",children:t("share.imagePrompt")}),i.jsxs("div",{className:"flex gap-3",children:[i.jsx("button",{onClick:()=>{const ce=ne;ee(null),J(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")}),i.jsx("button",{onClick:()=>{const ce=ne;ee(null),ln(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")})]})]})}),G&&i.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/60 backdrop-blur-sm",onClick:()=>ae(null),children:i.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:i.jsx(Hre,{isUpdate:R.has(`${G.type}/${G.name}`),onCancel:()=>ae(null),onConfirm:(ce,et)=>{const nt=G;ae(null),rt(nt,{priceCents:et>0?et:void 0})}})})}),H&&i.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/60 backdrop-blur-sm",onClick:()=>J(null),children:i.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:i.jsx(Bre,{onCancel:()=>J(null),onConfirm:(ce,et,nt,we)=>{const Me=H;J(null),rt(Me,{visibility:ce,orgId:et,priceCents:nt,donationsEnabled:we})}})})})]})})}function Bre({onCancel:e,onConfirm:t}){const{t:n}=ot(["builder","common"]),[a,s]=k.useState("public"),[l,c]=k.useState([]),[d,m]=k.useState(""),[p,h]=k.useState(!1),[g,x]=k.useState(0),[y,w]=k.useState(!1);k.useEffect(()=>{a==="org"&&l.length===0&&(h(!0),st.myOrgs().then(S=>{c(S.memberships),S.memberships.length>0&&m(S.memberships[0].id)}).catch(()=>{}).finally(()=>h(!1)))},[a,l.length]);const T=a==="public"||a==="unlisted",C=[{value:"public",icon:i.jsxs("svg",{className:"w-4 h-4",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[i.jsx("circle",{cx:"12",cy:"12",r:"10"}),i.jsx("line",{x1:"2",y1:"12",x2:"22",y2:"12"}),i.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:i.jsxs("svg",{className:"w-4 h-4",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[i.jsx("path",{d:"M3 21h18"}),i.jsx("path",{d:"M9 8h1"}),i.jsx("path",{d:"M9 12h1"}),i.jsx("path",{d:"M9 16h1"}),i.jsx("path",{d:"M14 8h1"}),i.jsx("path",{d:"M14 12h1"}),i.jsx("path",{d:"M14 16h1"}),i.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:i.jsxs("svg",{className:"w-4 h-4",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[i.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"}),i.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 i.jsxs(i.Fragment,{children:[i.jsx("h3",{className:"text-base font-semibold text-fg-primary mb-4",children:n("visibility.label")}),i.jsx("div",{className:"space-y-2 mb-5",children:C.map(S=>i.jsxs("label",{className:`flex items-center gap-3 p-3 rounded-lg border cursor-pointer transition-colors ${a===S.value?"border-brand-500 bg-brand-500/10":"border-border-default hover:border-gray-600"}`,children:[i.jsx("input",{type:"radio",name:"visibility",checked:a===S.value,onChange:()=>s(S.value),className:"accent-brand-500"}),i.jsx("div",{className:"flex items-center gap-2 text-fg-secondary",children:S.icon}),i.jsxs("div",{children:[i.jsx("div",{className:"text-sm font-medium text-fg-primary",children:S.label}),i.jsx("div",{className:"text-[11px] text-fg-tertiary",children:S.desc})]})]},S.value))}),a==="org"&&i.jsxs("div",{className:"mb-5",children:[i.jsx("label",{className:"text-xs text-fg-secondary block mb-1.5",children:n("visibility.orgSelect")}),p?i.jsx("div",{className:"text-xs text-fg-tertiary py-2",children:"Loading..."}):l.length===0?i.jsx("div",{className:"text-xs text-fg-tertiary py-2",children:n("visibility.orgNone")}):i.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=>i.jsx("option",{value:S.id,children:S.name},S.id))})]}),T&&i.jsxs("div",{className:"mb-5",children:[i.jsx("label",{className:"text-xs text-fg-secondary block mb-1.5",children:n("pricing.label")}),i.jsx("div",{className:"grid grid-cols-4 gap-2 mb-3",children:i6.map(S=>i.jsx("button",{type:"button",onClick:()=>x(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))}),i.jsxs("label",{className:"flex items-center gap-2 cursor-pointer",children:[i.jsx("input",{type:"checkbox",checked:y,onChange:S=>w(S.target.checked),className:"accent-brand-500"}),i.jsx("span",{className:"text-xs text-fg-secondary",children:n("pricing.enableTips")})]})]}),T&&i.jsx("div",{className:"mb-4 text-[11px] text-fg-tertiary rounded-lg border border-border-default px-3 py-2",children:n("pricing.reviewNote")}),i.jsxs("div",{className:"flex gap-3",children:[i.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")}),i.jsx("button",{onClick:()=>t(a,a==="org"?d:void 0,T&&g>0?g:void 0,T?y:void 0),disabled:a==="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 i6=[{cents:0,label:"Free"},{cents:100,label:"$1"},{cents:500,label:"$5"},{cents:1e3,label:"$10"}];function Hre({isUpdate:e,onCancel:t,onConfirm:n}){const{t:a}=ot(["builder","common"]),[s,l]=k.useState(0);return i.jsxs(i.Fragment,{children:[i.jsx("h3",{className:"text-base font-semibold text-fg-primary mb-4",children:a(e?"shareMode.titleUpdate":"shareMode.title")}),i.jsx("div",{className:"space-y-2 mb-5",children:i6.map(c=>i.jsxs("label",{className:`flex items-center gap-3 p-3 rounded-lg border cursor-pointer transition-colors ${s===c.cents?"border-brand-500 bg-brand-500/10":"border-border-default hover:border-gray-600"}`,children:[i.jsx("input",{type:"radio",name:"sharePrice",checked:s===c.cents,onChange:()=>l(c.cents),className:"accent-brand-500"}),i.jsxs("div",{children:[i.jsx("div",{className:"text-sm font-medium text-fg-primary",children:c.label}),i.jsx("div",{className:"text-[11px] text-fg-tertiary",children:c.cents===0?a("shareMode.freeDesc"):a("shareMode.paidDesc")})]})]},c.cents))}),i.jsxs("div",{className:"flex gap-3",children:[i.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:a("common:cancel")}),i.jsx("button",{onClick:()=>n(s>0?"paid":"free",s),className:"flex-1 text-sm px-4 py-2 rounded-lg bg-brand-600 hover:bg-brand-500 text-white transition-colors",children:a(e?"shareMode.update":"shareMode.share")})]})]})}const $re=Object.freeze(Object.defineProperty({__proto__:null,AgentBuilder:r6},Symbol.toStringTag,{value:"Module"}));async function s6(e,t){if(!t)return{items:e,highlighted:null,missing:!1};const n=e.find(a=>a.id===t);if(n)return{items:[n,...e.filter(a=>a.id!==t)],highlighted:n,missing:!1};try{const{item:a}=await st.getItem(t);return a?{items:[a,...e],highlighted:a,missing:!1}:{items:e,highlighted:null,missing:!0}}catch{return{items:e,highlighted:null,missing:!0}}}function qre(e,t){const n=e.split(".").map(Number),a=t.split(".").map(Number);for(let s=0;s<Math.max(n.length,a.length);s++){const l=n[s]??0,c=a[s]??0;if(l>c)return!0;if(l<c)return!1}return!1}function Pm(e,t){const n=e.i18n?.[t];return n?.displayName||n?.name||e.name}function xk(e,t){return e.i18n?.[t]?.description||e.description}const Fre={manager:"bg-brand-500/15 text-brand-500",worker:"bg-blue-500/15 text-blue-600"};function Ure({authUser:e,highlightItemId:t,onHighlightDone:n}={}){const{t:a,i18n:s}=ot(["store","common"]),l=s.language,[c,d]=k.useState(""),[m,p]=k.useState([]),[h,g]=k.useState([]),[x,y]=k.useState(null),[w,T]=k.useState({}),[C,S]=k.useState(!1),[E,_]=k.useState(!0),[M,P]=k.useState(new Map),[R,I]=k.useState(new Set),[K,Y]=k.useState(null),[L,F]=k.useState(null),ne=k.useCallback(async()=>{try{const[ae,H]=await Promise.all([Ae.builder.artifacts.list().catch(()=>({artifacts:[]})),Ae.builder.artifacts.installed().catch(()=>({installed:{}}))]),J=new Map;for(const fe of ae.artifacts){if(fe.type!=="agent")continue;const Ce=!!H.installed[`agent/${fe.name}`];J.set(fe.name,{installed:Ce,localVersion:fe.meta.version||void 0,localUpdatedAt:fe.updatedAt})}P(J)}catch{}},[]),ee=k.useCallback(async()=>{_(!0);try{const ae=c?st.search({type:"agent",q:c,limit:50}):Ls(qa.hubAgents)??st.search({type:"agent",limit:50}),H=new URLSearchParams;c&&H.set("q",c);const J=fetch("/api/templates?"+H.toString()).then(V=>V.json()).catch(()=>({templates:[]})),[fe,Ce]=await Promise.all([ae.catch(()=>({items:[],total:0})),J,ne(),st.isAuthenticated()?st.purchases.mine().then(V=>I(new Set(V.purchases.map(pe=>pe.itemId)))).catch(()=>{}):Promise.resolve()]),$=await s6(fe?.items??[],t);g($.items),p(Array.isArray(Ce.templates)?Ce.templates:[]),$.missing&&n?.()}catch{p([]),g([])}finally{_(!1)}},[c,ne,t,n]);k.useEffect(()=>{ee()},[ee]),k.useEffect(()=>{if(!x){T({});return}fetch(`/api/templates/${encodeURIComponent(x.id)}/files`,{credentials:"include"}).then(ae=>ae.json()).then(ae=>T(ae.files??{})).catch(()=>T({}))},[x]);const G=async(ae,H,J)=>{try{const fe=await fetch("/api/templates/instantiate",{method:"POST",headers:{"Content-Type":"application/json"},credentials:"include",body:JSON.stringify({templateId:ae,name:H,orgId:"default",teamId:J})});if(!fe.ok)throw new Error(`Failed: ${fe.status}`);S(!1),y(null)}catch(fe){F({title:a("common:create",{defaultValue:"Create"}),message:`Failed to create agent: ${fe}`,variant:"danger"})}};if(K)return i.jsx(qs,{type:K.type,name:K.name,onBack:()=>Y(null)});if(x){const ae={type:"agent",name:x.id,displayName:Pm(x,l),version:x.version,description:xk(x,l),author:x.author,category:x.category,tags:x.tags,icon:x.icon,files:w,agent:{roleName:x.roleId,agentRole:x.agentRole==="manager"?"manager":"worker"},dependencies:{skills:x.skills}},H=i.jsxs("div",{className:"space-y-6",children:[i.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[i.jsxs("div",{className:"rounded-xl border border-border-default bg-surface-secondary/40 p-5",children:[i.jsx("h3",{className:"text-xs text-fg-tertiary uppercase tracking-wider mb-3",children:a("agentStore.roleConfig")}),i.jsxs("div",{className:"space-y-2.5 text-sm",children:[i.jsxs("div",{className:"flex items-center gap-2",children:[i.jsx("span",{className:"text-fg-tertiary w-20",children:a("agentStore.role")}),i.jsx("span",{className:"text-fg-secondary font-mono text-xs bg-surface-elevated px-2 py-0.5 rounded",children:x.roleId})]}),i.jsxs("div",{className:"flex items-center gap-2",children:[i.jsx("span",{className:"text-fg-tertiary w-20",children:a("agentStore.position")}),i.jsx("span",{className:`px-2 py-0.5 rounded text-xs capitalize ${Fre[x.agentRole]??""}`,children:x.agentRole})]})]})]}),i.jsxs("div",{className:"rounded-xl border border-border-default bg-surface-secondary/40 p-5",children:[i.jsx("h3",{className:"text-xs text-fg-tertiary uppercase tracking-wider mb-3",children:a("agentStore.skills")}),i.jsxs("div",{className:"flex flex-wrap gap-1.5",children:[x.skills.map(J=>i.jsx("span",{className:"px-2.5 py-1 text-xs bg-brand-500/10 text-brand-500 rounded-lg border border-brand-500/20",children:J},J)),x.skills.length===0&&i.jsx("span",{className:"text-xs text-fg-tertiary italic",children:a("agentStore.noSkills")})]})]})]}),x.starterTasks&&x.starterTasks.length>0&&i.jsxs("div",{className:"rounded-xl border border-border-default bg-surface-secondary/40 p-5",children:[i.jsx("h3",{className:"text-xs text-fg-tertiary uppercase tracking-wider mb-3",children:a("agentStore.starterTasks")}),i.jsx("div",{className:"space-y-2",children:x.starterTasks.map((J,fe)=>i.jsxs("div",{className:"flex items-start gap-3 bg-surface-elevated/50 rounded-lg p-3",children:[i.jsx("span",{className:`inline-block w-2 h-2 rounded-full shrink-0 mt-1 ${J.priority==="high"?"bg-red-400":J.priority==="medium"?"bg-amber-400":"bg-green-400"}`}),i.jsxs("div",{children:[i.jsx("div",{className:"text-sm text-fg-primary",children:J.title}),J.description&&i.jsx("div",{className:"text-xs text-fg-tertiary mt-0.5",children:J.description})]})]},fe))})]})]});return i.jsxs(i.Fragment,{children:[i.jsx(qs,{type:"agent",name:x.id,onBack:()=>y(null),readOnly:!0,initialManifest:ae,actionSlot:i.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:a("agentStore.hireAgent")}),contentSlot:H}),C&&i.jsx(vk,{template:x,lang:l,onClose:()=>S(!1),onHire:G}),L&&i.jsx(ba,{alertOnly:!0,variant:L.variant??"danger",title:L.title,message:L.message,onConfirm:()=>F(null),onCancel:()=>F(null)})]})}return i.jsxs("div",{className:"flex-1 overflow-hidden flex flex-col",children:[i.jsxs("div",{"data-electron-drag":!0,className:"px-6 h-14 flex items-center justify-between shrink-0 gap-3",children:[i.jsx("h2",{className:"text-lg font-semibold",children:a("agentStore.title")}),i.jsx("input",{type:"text",placeholder:a("agentStore.searchPlaceholder"),value:c,onChange:ae=>d(ae.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"})]}),i.jsx("div",{className:"flex-1 overflow-y-auto p-7 space-y-8",children:E?i.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-4",children:Array.from({length:6}).map((ae,H)=>i.jsx("div",{className:"h-56 rounded-2xl skeleton"},H))}):m.length===0&&h.length===0?i.jsxs("div",{className:"text-center py-20",children:[i.jsx("div",{className:"text-4xl mb-4 opacity-30",children:"⧉"}),i.jsx("div",{className:"text-fg-secondary font-medium mb-1",children:c?a("agentStore.noResults",{search:c}):a("agentStore.noAgents")}),i.jsx("div",{className:"text-fg-tertiary text-sm",children:a(c?"agentStore.noResultsHint":"agentStore.noAgentsHint")})]}):i.jsxs(i.Fragment,{children:[m.length>0&&i.jsxs("section",{children:[i.jsxs("div",{className:"flex items-baseline gap-2 mb-3",children:[i.jsx("h3",{className:"section-title",children:a("agentStore.builtin")}),i.jsx("span",{className:"text-xs text-fg-tertiary",children:a("agentStore.available",{count:m.length})})]}),i.jsx(Fa,{columns:3,children:m.map(ae=>i.jsx(vr,{type:"agent",name:Pm(ae,l),description:xk(ae,l),seed:ae.id,icon:ae.icon,version:ae.version,category:ae.category,tags:ae.tags,authorLabel:ae.author,hideStats:!0,showTypeBadge:!1,cornerLabel:a("agentStore.builtin"),onClick:()=>y(ae)},ae.id))})]}),h.length>0&&i.jsxs("section",{children:[i.jsx("h3",{className:"section-title mb-3",children:a("agentStore.markusHub")}),i.jsx(Fa,{columns:3,children:h.map(ae=>i.jsx(Gre,{item:ae,localInfo:M.get(Fc(ae)),purchased:cm(ae,R),onStatusChange:ne,highlight:ae.id===t,onHighlightDone:n,onViewDetail:H=>Y({type:"agent",name:H})},ae.id))})]})]})}),C&&x&&i.jsx(vk,{template:x,lang:l,onClose:()=>S(!1),onHire:G}),L&&i.jsx(ba,{alertOnly:!0,variant:L.variant??"danger",title:L.title,message:L.message,onConfirm:()=>F(null),onCancel:()=>F(null)})]})}function Fc(e,t){if(e.slug&&e.slug.trim())return e.slug.trim();const n=t&&typeof t.name=="string"?t.name.trim():"";return mm(n||e.name,"hub-pkg")}function Is(e){return(async()=>{const t=await st.download(e.id),n=t.name||e.name,a=t.config??{},s=Fc(e,a),l=t.itemType==="team"?"team":t.itemType==="skill"?"skill":"agent",c={type:"hub",hubItemId:e.id},d=(t.version||e.version||(typeof a.version=="string"?a.version:"")||"").trim()||void 0;if(t.files&&Object.keys(t.files).length>0)await Ae.builder.artifacts.import(l,s,t.files,c,d);else{const m={...a,...d?{version:d}:{},name:s,displayName:a.displayName||n,description:e.description,source:c};await Ae.builder.artifacts.save(l,m)}return await Ae.builder.artifacts.install(l,s),window.dispatchEvent(new CustomEvent("markus:data-changed")),n})()}async function vb(e,t){t("checking"),await st.ensureAuth();const n=await st.purchases.checkout(e.id);if(n.alreadyOwned)return t("installing"),await Is(e),"installed";try{if((await st.creator.getBalance()).availableBalance>=(e.priceCents??0)){const c=await st.purchases.payWithEarnings(e.id);if(c.ok||c.alreadyOwned)return t("installing"),await Is(e),"installed"}}catch{}if(!n.checkoutUrl)throw new Error("No checkout URL");t("checkout_opened");const a=Go();let s=null;return a?fi(n.checkoutUrl):s=window.open(n.checkoutUrl,"_blank","noopener"),new Promise((l,c)=>{const d=Date.now(),m=300*1e3,p=setInterval(async()=>{if(Date.now()-d>m){clearInterval(p),l("cancelled");return}const g=!a&&s?s.closed:!1;try{if((await st.purchases.checkout(e.id)).alreadyOwned){clearInterval(p),t("installing");try{await Is(e),l("installed")}catch(y){c(y)}return}}catch{}if(g){clearInterval(p);try{if((await st.purchases.checkout(e.id)).alreadyOwned){t("installing"),await Is(e),l("installed");return}}catch{}l("cancelled")}},2e3)})}function Gre({item:e,localInfo:t,purchased:n,onStatusChange:a,highlight:s,onHighlightDone:l,onViewDetail:c}){const{t:d}=ot(["store"]),[m,p]=k.useState(!1),[h,g]=k.useState(""),x=k.useRef(null),[y,w]=k.useState(!1);k.useEffect(()=>{if(s&&x.current){x.current.scrollIntoView({behavior:"smooth",block:"center"}),w(!0);const K=setTimeout(()=>{w(!1)},4e3);return()=>clearTimeout(K)}},[s,l]);const T=t?.installed??!1,C=T&&e.version&&t?.localVersion&&qre(e.version,t.localVersion),S=(e.priceCents??0)>0,E=async K=>{if(K.stopPropagation(),!m){p(!0),g("");try{await Is(e),g(C?d("card.upgraded"):d("card.installed")+"!"),a()}catch(Y){const L=Y instanceof Error?Y.message:"";L.includes("402")||L.includes("Purchase required")?g(d("card.purchaseRequired")):g(d("card.failed"))}finally{p(!1)}}},_=async K=>{if(K.stopPropagation(),!m){p(!0),g("");try{await vb(e,L=>{L==="checkout_opened"?g(d("card.waitingPurchase","Waiting for purchase...")):L==="installing"&&g(d("card.installing"))})==="installed"?(g(d("card.installed")+"!"),a()):g("")}catch(Y){g(Y instanceof Error?Y.message:d("card.failed"))}finally{p(!1)}}},M=S?`$${((e.priceCents??0)/100).toFixed(2)}`:null,P=e.slug&&e.author?.username?`${st.getUrl()}/@${encodeURIComponent(e.author.username)}/${encodeURIComponent(e.slug)}`:null,R=()=>{T&&c?c(Fc(e)):P&&window.open(P,"_blank","noopener,noreferrer")},I=i.jsxs(i.Fragment,{children:[C?i.jsx("button",{onClick:K=>{E(K)},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?i.jsxs("button",{onClick:K=>{E(K)},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?i.jsx("button",{onClick:K=>{_(K)},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"):i.jsxs(i.Fragment,{children:[d("card.buy","Buy")," ",M]})}):i.jsx("button",{onClick:K=>{E(K)},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)&&i.jsx("span",{className:`text-[10px] ${h===d("card.failed")||h===d("card.purchaseRequired")?"text-red-500":"text-green-600"}`,children:h})]});return i.jsx("div",{ref:x,className:y?"animate-pulse":"",children:i.jsx(vr,{type:"agent",showTypeBadge:!1,name:e.name,description:e.description,seed:e.slug||e.name,icon:e.icon||"bot",cover:e.thumbnailUrl,hubBase:st.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:y,onClick:R,actions:I})})}function vk({template:e,lang:t,onClose:n,onHire:a}){const{t:s}=ot(["store"]),[l,c]=k.useState(`${Pm(e,t)} Agent`),[d,m]=k.useState(""),[p,h]=k.useState([]),[g,x]=k.useState(!1);k.useEffect(()=>{fetch("/api/teams",{credentials:"include"}).then(w=>w.json()).then(w=>h(w.teams??[])).catch(()=>{})},[]);const y=async()=>{if(l.trim()){x(!0);try{await a(e.id,l.trim(),d||void 0)}finally{x(!1)}}};return i.jsx("div",{className:"fixed inset-0 bg-black/60 flex items-center justify-center z-50",onClick:n,children:i.jsxs("div",{className:"bg-surface-secondary border border-border-default rounded-xl p-6 w-[440px] shadow-2xl",onClick:w=>w.stopPropagation(),children:[i.jsx("div",{className:"flex items-center gap-3 mb-5",children:i.jsxs("div",{children:[i.jsx("h3",{className:"text-base font-semibold",children:s("hireModal.title")}),i.jsx("p",{className:"text-xs text-fg-tertiary",children:s("hireModal.creating",{name:Pm(e,t)})})]})}),i.jsxs("div",{className:"space-y-4",children:[i.jsxs("div",{children:[i.jsx("label",{className:"block text-xs text-fg-tertiary mb-1.5",children:s("hireModal.agentName")}),i.jsx("input",{type:"text",value:l,onChange:w=>c(w.target.value),className:"input-field",autoFocus:!0})]}),p.length>0&&i.jsxs("div",{children:[i.jsx("label",{className:"block text-xs text-fg-tertiary mb-1.5",children:s("hireModal.assignTeam")}),i.jsxs("select",{value:d,onChange:w=>m(w.target.value),className:"input-field",children:[i.jsx("option",{value:"",children:s("hireModal.noTeam")}),p.map(w=>i.jsx("option",{value:w.id,children:w.name},w.id))]})]}),i.jsxs("div",{className:"bg-surface-elevated/50 rounded-lg p-3",children:[i.jsx("div",{className:"text-xs text-fg-tertiary mb-2 font-medium",children:s("hireModal.agentConfig")}),i.jsxs("div",{className:"grid grid-cols-2 gap-y-1.5 gap-x-4 text-xs",children:[i.jsx("div",{className:"text-fg-tertiary",children:s("hireModal.role")}),i.jsx("div",{className:"text-fg-secondary font-mono",children:e.roleId}),i.jsx("div",{className:"text-fg-tertiary",children:s("hireModal.position")}),i.jsx("div",{className:"text-fg-secondary capitalize",children:e.agentRole}),i.jsx("div",{className:"text-fg-tertiary",children:s("hireModal.skills")}),i.jsx("div",{className:"text-fg-secondary",children:e.skills.join(", ")||s("hireModal.none")})]})]})]}),i.jsxs("div",{className:"flex justify-end gap-3 mt-6",children:[i.jsx("button",{onClick:n,className:"btn-secondary",children:s("hireModal.cancel")}),i.jsx("button",{onClick:y,disabled:!l.trim()||g,className:"btn-primary",children:s(g?"hireModal.creating_progress":"hireModal.create")})]})]})})}function yh(e,t){const n=e.i18n?.[t];return n?.displayName||n?.name||e.name}function wk(e,t){return e.i18n?.[t]?.description||e.description}function kk(e,t,n){return e.i18n?.[n]?.members?.[t]||t}function Kre(e,t){const n=e.split(".").map(Number),a=t.split(".").map(Number);for(let s=0;s<Math.max(n.length,a.length);s++){const l=n[s]??0,c=a[s]??0;if(l>c)return!0;if(l<c)return!1}return!1}function Vre({highlightItemId:e,onHighlightDone:t}={}){const{t:n,i18n:a}=ot(["store","common"]),s=a.language,[l,c]=k.useState(""),[d,m]=k.useState([]),[p,h]=k.useState([]),[g,x]=k.useState(null),[y,w]=k.useState({}),[T,C]=k.useState(!0),[S,E]=k.useState(!1),[_,M]=k.useState(null),[P,R]=k.useState(new Map),[I,K]=k.useState(new Set),[Y,L]=k.useState(null),F=k.useCallback(async()=>{try{const[G,ae]=await Promise.all([Ae.builder.artifacts.list().catch(()=>({artifacts:[]})),Ae.builder.artifacts.installed().catch(()=>({installed:{}}))]),H=new Map;for(const J of G.artifacts){if(J.type!=="team")continue;const fe=!!ae.installed[`team/${J.name}`];H.set(J.name,{installed:fe,localVersion:J.meta.version||void 0,localUpdatedAt:J.updatedAt})}R(H)}catch{}},[]),ne=k.useCallback(async()=>{C(!0);try{const G=l?st.search({type:"team",q:l,limit:50}):Ls(qa.hubTeams)??st.search({type:"team",limit:50}),[ae,H]=await Promise.all([G.catch(()=>({items:[],total:0})),Ae.teamTemplates.list(l||void 0).catch(()=>({templates:[]})),F(),st.isAuthenticated()?st.purchases.mine().then(fe=>K(new Set(fe.purchases.map(Ce=>Ce.itemId)))).catch(()=>{}):Promise.resolve()]),J=await s6(ae?.items??[],e);h(J.items),m(H?.templates??[]),J.missing&&t?.()}catch{m([]),h([])}finally{C(!1)}},[l,F,e,t]);k.useEffect(()=>{ne()},[ne]),k.useEffect(()=>{if(!g){w({});return}fetch(`/api/team-templates/${encodeURIComponent(g.id)}/files`,{credentials:"include"}).then(G=>G.json()).then(G=>w(G.files??{})).catch(()=>w({}))},[g]);const ee=async G=>{E(!0),M(null);try{const H=(await Ae.teams.create(G.name,G.description)).team.id;let J,fe=0;const Ce=[];for(const V of G.members){const pe=V.count??1;for(let z=0;z<pe;z++){const je=V.name??`${G.name} Agent ${z+1}`,Ue=pe>1?`${je} ${z+1}`:je,qe=V.roleName??V.templateId;try{const He=await fetch("/api/agents",{method:"POST",headers:{"Content-Type":"application/json"},credentials:"include",body:JSON.stringify({name:Ue,...qe?{roleName:qe}:{},orgId:"default",teamId:H,agentRole:V.role??"worker",skills:V.skills??[]})});if(He.ok){fe++;const ut=await He.json();V.role==="manager"&&!J&&(J=ut.agent?.id)}else{const ut=await He.json().catch(()=>({error:`HTTP ${He.status}`}));Ce.push(`${Ue}: ${ut.error??He.statusText}`)}}catch(He){Ce.push(`${Ue}: ${String(He)}`)}}}J&&await Ae.teams.update(H,{managerId:J,managerType:"agent"}).catch(()=>{});const $=Ce.length>0?` (${Ce.length} failed: ${Ce[0]})`:"";M({ok:fe>0,message:`Team "${yh(G,s)}" deployed with ${fe} agent(s)${$}`})}catch(ae){M({ok:!1,message:`Failed: ${ae}`})}finally{E(!1)}};if(Y)return i.jsx(qs,{type:Y.type,name:Y.name,onBack:()=>L(null)});if(g){const G={...y};g.announcements&&(G["ANNOUNCEMENT.md"]=g.announcements),g.norms&&(G["NORMS.md"]=g.norms);const ae={type:"team",name:g.id,displayName:yh(g,s),version:g.version,description:wk(g,s),author:g.author,category:g.category??"general",tags:g.tags??[],files:G,team:{members:g.members.map(J=>({name:kk(g,J.name??J.roleName??J.templateId??"Agent",s),role:J.role??"worker",roleName:J.roleName??J.templateId,count:J.count??1,skills:J.skills??[]}))}},H=i.jsxs("div",{className:"rounded-xl border border-border-default bg-surface-secondary/40 overflow-hidden",children:[i.jsx("div",{className:"px-5 py-3 border-b border-border-default bg-surface-elevated/30",children:i.jsx("h3",{className:"text-xs text-fg-tertiary uppercase tracking-wider",children:n("teamStore.teamComposition")})}),i.jsx("div",{className:"p-5 space-y-2",children:g.members.map((J,fe)=>{const Ce=kk(g,J.name??J.roleName??J.templateId??"Agent",s);return i.jsxs("div",{className:"flex items-center gap-3 bg-surface-elevated/50 rounded-lg p-3",children:[i.jsx("div",{className:`w-9 h-9 rounded-lg flex items-center justify-center text-sm font-bold shrink-0 ${J.role==="manager"?"bg-amber-500/15 text-amber-400 ring-1 ring-amber-500/30":"bg-blue-500/15 text-blue-400 ring-1 ring-blue-500/30"}`,children:(Ce[0]??"?").toUpperCase()}),i.jsxs("div",{className:"min-w-0 flex-1",children:[i.jsxs("div",{className:"flex items-center gap-2",children:[i.jsx("span",{className:"text-sm text-fg-primary font-medium",children:Ce}),i.jsx("span",{className:`px-1.5 py-0.5 rounded text-[10px] capitalize font-medium ${J.role==="manager"?"bg-amber-500/15 text-amber-400":"bg-blue-500/15 text-blue-400"}`,children:J.role??"worker"}),(J.count??1)>1&&i.jsxs("span",{className:"text-[10px] text-fg-muted",children:["×",J.count]})]}),(J.roleName||J.templateId)&&i.jsx("div",{className:"text-[10px] text-fg-tertiary font-mono mt-0.5",children:J.roleName??J.templateId})]}),J.skills&&J.skills.length>0&&i.jsxs("div",{className:"flex flex-wrap gap-1 shrink-0",children:[J.skills.slice(0,3).map($=>i.jsx("span",{className:"px-1.5 py-0.5 text-[9px] bg-surface-elevated text-fg-muted rounded border border-border-default",children:$},$)),J.skills.length>3&&i.jsxs("span",{className:"text-[9px] text-fg-muted",children:["+",J.skills.length-3]})]})]},fe)})})]});return i.jsx(i.Fragment,{children:i.jsx(qs,{type:"team",name:g.id,onBack:()=>{x(null),M(null)},readOnly:!0,initialManifest:ae,contentSlot:H,actionSlot:i.jsxs(i.Fragment,{children:[_&&i.jsx("span",{className:`text-xs ${_.ok?"text-green-500":"text-red-500"}`,children:_.message}),i.jsx("button",{onClick:()=>{ee(g)},disabled:S,className:"px-4 py-1.5 text-xs bg-brand-600 hover:bg-brand-500 text-white rounded-lg transition-colors font-medium disabled:opacity-50",children:n(S?"teamStore.deploying":"teamStore.deployTeam")})]})})})}return i.jsxs("div",{className:"flex-1 overflow-hidden flex flex-col",children:[i.jsxs("div",{"data-electron-drag":!0,className:"px-6 h-14 flex items-center justify-between shrink-0 gap-3",children:[i.jsx("h2",{className:"text-lg font-semibold",children:n("teamStore.title")}),i.jsx("input",{type:"text",placeholder:n("teamStore.searchPlaceholder"),value:l,onChange:G=>c(G.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"})]}),i.jsx("div",{className:"flex-1 overflow-y-auto p-7 space-y-8",children:T?i.jsx("div",{className:"grid grid-cols-1 lg:grid-cols-2 gap-4",children:Array.from({length:4}).map((G,ae)=>i.jsx("div",{className:"h-56 rounded-2xl skeleton"},ae))}):d.length===0&&p.length===0?i.jsxs("div",{className:"text-center py-20",children:[i.jsx("div",{className:"text-4xl mb-4 opacity-30",children:"◉"}),i.jsx("div",{className:"text-fg-secondary font-medium mb-1",children:l?n("teamStore.noResults",{search:l}):n("teamStore.noTeams")}),i.jsx("div",{className:"text-fg-tertiary text-sm",children:n(l?"teamStore.noResultsHint":"teamStore.noTeamsHint")})]}):i.jsxs(i.Fragment,{children:[d.length>0&&i.jsxs("section",{children:[i.jsxs("div",{className:"flex items-baseline gap-2 mb-3",children:[i.jsx("h3",{className:"section-title",children:n("teamStore.builtin")}),i.jsx("span",{className:"text-xs text-fg-tertiary",children:n("teamStore.available",{count:d.length})})]}),i.jsx(Fa,{columns:2,children:d.map(G=>i.jsx(vr,{type:"team",name:yh(G,s),description:wk(G,s),seed:G.id,icon:G.icon||"users",version:G.version,category:G.category,tags:G.tags,authorLabel:G.author,hideStats:!0,showTypeBadge:!1,cornerLabel:n("teamStore.builtin"),onClick:()=>x(G)},G.id))})]}),p.length>0&&i.jsxs("section",{children:[i.jsx("h3",{className:"section-title mb-3",children:n("teamStore.markusHub")}),i.jsx(Fa,{columns:2,children:p.map(G=>i.jsx(Wre,{item:G,localInfo:P.get(Fc(G)),purchased:cm(G,I),onStatusChange:F,highlight:G.id===e,onHighlightDone:t,onViewDetail:ae=>L({type:"team",name:ae})},G.id))})]})]})})]})}function Wre({item:e,localInfo:t,purchased:n,onStatusChange:a,highlight:s,onHighlightDone:l,onViewDetail:c}){const{t:d}=ot(["store"]),[m,p]=k.useState(!1),[h,g]=k.useState(""),x=k.useRef(null),[y,w]=k.useState(!1);k.useEffect(()=>{if(s&&x.current){x.current.scrollIntoView({behavior:"smooth",block:"center"}),w(!0);const K=setTimeout(()=>{w(!1)},4e3);return()=>clearTimeout(K)}},[s,l]);const T=t?.installed??!1,C=T&&e.version&&t?.localVersion&&Kre(e.version,t.localVersion),S=(e.priceCents??0)>0,E=S?`$${((e.priceCents??0)/100).toFixed(2)}`:null,_=async K=>{if(K.stopPropagation(),!m){p(!0),g("");try{await Is(e),g(C?d("card.upgraded"):d("card.installed")+"!"),a()}catch(Y){const L=Y instanceof Error?Y.message:"";L.includes("402")||L.includes("Purchase required")?g(d("card.purchaseRequired")):g(d("card.failed"))}finally{p(!1)}}},M=async K=>{if(K.stopPropagation(),!m){p(!0),g("");try{await vb(e,L=>{L==="checkout_opened"?g(d("card.waitingPurchase","Waiting for purchase...")):L==="installing"&&g(d("card.installing"))})==="installed"?(g(d("card.installed")+"!"),a()):g("")}catch(Y){g(Y instanceof Error?Y.message:d("card.failed"))}finally{p(!1)}}},P=e.slug&&e.author?.username?`${st.getUrl()}/@${encodeURIComponent(e.author.username)}/${encodeURIComponent(e.slug)}`:null,R=()=>{T&&c?c(Fc(e)):P&&window.open(P,"_blank","noopener,noreferrer")},I=i.jsxs(i.Fragment,{children:[C?i.jsx("button",{onClick:K=>{_(K)},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?i.jsxs("button",{onClick:K=>{_(K)},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?i.jsx("button",{onClick:K=>{M(K)},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"):i.jsxs(i.Fragment,{children:[d("card.buy","Buy")," ",E]})}):i.jsx("button",{onClick:K=>{_(K)},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&&i.jsx("span",{className:`text-[10px] ${h===d("card.failed")||h===d("card.purchaseRequired")?"text-red-500":"text-green-600"}`,children:h})]});return i.jsx("div",{ref:x,className:y?"animate-pulse":"",children:i.jsx(vr,{type:"team",showTypeBadge:!1,name:e.name,description:e.description,seed:e.slug||e.name,icon:e.icon||"users",cover:e.thumbnailUrl,hubBase:st.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:y,onClick:R,actions:I})})}function xh(e,t){return e.i18n?.[t]?.displayName||e.name}function vh(e,t){return e.i18n?.[t]?.description||e.description||""}function o6(e,t){const n=e.split(".").map(Number),a=t.split(".").map(Number);for(let s=0;s<Math.max(n.length,a.length);s++){const l=n[s]??0,c=a[s]??0;if(l>c)return!0;if(l<c)return!1}return!1}const Yre={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 Qre({item:e,installedSkills:t,purchased:n,onMsg:a,onRefresh:s}){const{t:l}=ot(["store"]),[c,d]=k.useState(!1),m=e.name.toLowerCase().trim().replace(/\s+/g,"-").replace(/[\/\\:*?"<>|]+/g,"").replace(/-{2,}/g,"-").replace(/^-|-$/g,"")||"unnamed",p=t.find(S=>S.name===e.name||S.name===m||!!e.slug&&S.name===e.slug),h=!!p,g=h&&e.version&&p?.version&&o6(e.version,p.version),x=(e.priceCents??0)>0,[y,w]=k.useState(""),T=async()=>{if(!c){d(!0),w("");try{await Is(e),a(g?`Upgraded ${e.name}`:`Installed ${e.name}`,"success"),s()}catch(S){const E=S instanceof Error?S.message:"";E.includes("402")||E.includes("Purchase required")?a(l("card.purchaseRequired"),"error"):a(l("card.failed"),"error")}finally{d(!1)}}},C=async()=>{if(!c){d(!0),w("");try{await vb(e,E=>{E==="checkout_opened"?w(l("card.waitingPurchase","Waiting for purchase...")):E==="installing"&&w(l("card.installing"))})==="installed"&&(a(`Purchased & installed ${e.name}`,"success"),s()),w("")}catch(S){a(S instanceof Error?S.message:l("card.failed"),"error"),w("")}finally{d(!1)}}};if(g)return i.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 i.jsxs("span",{className:"px-2.5 py-1 text-[10px] bg-surface-overlay text-fg-secondary rounded-lg",children:[l("card.installed"),p?.version?` (v${p.version})`:""]});if(x&&!n){const S=`$${((e.priceCents??0)/100).toFixed(2)}`;return i.jsx("span",{className:"inline-flex items-center gap-1.5",children:i.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?y||l("card.installing"):i.jsxs(i.Fragment,{children:[l("card.buy","Buy")," ",S]})})})}return i.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 Sk({item:e,installedSkills:t,purchased:n,onMsg:a,onRefresh:s,highlight:l,onHighlightDone:c,type:d="skill"}){const m=k.useRef(null),[p,h]=k.useState(!1);k.useEffect(()=>{if(l&&m.current){m.current.scrollIntoView({behavior:"smooth",block:"center"}),h(!0);const y=setTimeout(()=>{h(!1)},4e3);return()=>clearTimeout(y)}},[l,c]);const g=e.slug&&e.author?.username?`${st.getUrl()}/@${encodeURIComponent(e.author.username)}/${encodeURIComponent(e.slug)}`:null,x=()=>{g&&window.open(g,"_blank","noopener,noreferrer")};return i.jsx("div",{ref:m,className:p?"animate-pulse":"",children:i.jsx(vr,{type:d,showTypeBadge:d!=="skill",name:e.name,description:e.description,seed:e.slug||e.name,icon:e.icon||tm(e.slug||e.name,e.category),cover:e.thumbnailUrl,hubBase:st.getUrl(),author:e.author,version:e.version,category:e.category,tags:e.tags,rating:parseFloat(e.avgRating)||0,ratingCount:e.ratingCount,downloadCount:e.downloadCount,priceCents:e.priceCents,currency:e.currency,onClick:x,actions:i.jsx(Qre,{item:e,installedSkills:t,purchased:n,onMsg:a,onRefresh:s})})})}function Xre({highlightItemId:e,onHighlightDone:t}={}){const{t:n,i18n:a}=ot(["store","common"]),s=a.language,l=Xo(),[c,d]=k.useState("skills"),[m,p]=k.useState(null),[h,g]=k.useState(new Set),[x,y]=k.useState([]),[w,T]=k.useState(null),[C,S]=k.useState([]),[E,_]=k.useState(0),[M,P]=k.useState(1),[R,I]=k.useState([]),[K,Y]=k.useState(""),[L,F]=k.useState("score"),[ne,ee]=k.useState(""),[G,ae]=k.useState(!1),[H,J]=k.useState([]),[fe,Ce]=k.useState(!1),[$,V]=k.useState([]),[pe,z]=k.useState(""),[je,Ue]=k.useState(!1),[qe,He]=k.useState([]),[ut,dt]=k.useState([]),[Nt,wt]=k.useState(new Set),[Zt,Wt]=k.useState(!1),[rt,$e]=k.useState(""),mt=[{id:"skills",labelKey:"skillStore.tabs.all"},{id:"skillhub",labelKey:"skillStore.tabs.skillhub"},{id:"skillssh",labelKey:"skillStore.tabs.skillssh"}],At=(q,te="success")=>{p({text:q,type:te}),setTimeout(()=>p(null),te==="error"?1e4:4e3)},Dt=k.useCallback(async()=>{try{const q=await Ae.skills.list();y(q.skills)}catch{}},[]),ln=k.useCallback(async()=>{Ce(!0);try{const q=await Ae.skills.builtin();J(q.skills)}catch{}Ce(!1)},[]),ce=k.useCallback(async q=>{ae(!0);try{const te=await Ae.skills.registrySkillhub({q:q?.q,category:q?.category,page:q?.page??1,limit:24,sort:q?.sort??L});S(te.skills),_(te.total),te.categories?.length&&I(te.categories)}catch{}ae(!1)},[L]),et=k.useCallback(async q=>{Ue(!0);try{const te=await Ae.skills.registrySkillssh(q);V(te.skills)}catch{}Ue(!1)},[]),nt=k.useCallback(async q=>{Wt(!0);try{const te=q?st.search({type:"skill",q,limit:50}):Ls(qa.hubSkills)??st.search({type:"skill",limit:50}),Se=st.search({subtype:"connector",q:q||void 0,limit:50}).catch(()=>({items:[]})),[De,Pe]=await Promise.all([te,Se,st.isAuthenticated()?st.purchases.mine().then(ue=>wt(new Set(ue.purchases.map(Be=>Be.itemId)))).catch(()=>{}):Promise.resolve()]);let Q=De?.items??[],X=Pe?.items??[];if(e){const ue=Q.some(Ie=>Ie.id===e),Be=X.some(Ie=>Ie.id===e);if(!ue&&!Be)try{const{item:Ie}=await st.getItem(e);Ie?.subtype==="connector"?X=[Ie,...X]:Ie?Q=[Ie,...Q]:t?.()}catch{t?.()}else ue&&(Q=[Q.find(Ge=>Ge.id===e),...Q.filter(Ge=>Ge.id!==e)]),Be&&(X=[X.find(Ge=>Ge.id===e),...X.filter(Ge=>Ge.id!==e)])}He(Q),dt(X)}catch{}Wt(!1)},[e,t]);k.useEffect(()=>{Dt(),ln(),ce(),et()},[]),k.useEffect(()=>{c==="skills"&&nt(rt)},[c,rt,nt]);const we=async q=>{g(te=>new Set(te).add(q.name));try{const te=await Ae.skills.install({name:q.name,source:"skillhub",slug:q.slug,sourceUrl:q.homepage,description:q.description_zh??q.description,category:"custom",version:q.version});await Dt(),At(`"${q.name}" installed (${te.method}) → ${te.path}`),window.dispatchEvent(new CustomEvent("markus:data-changed"))}catch{At(`Download failed for "${q.name}". You can try manually from: ${q.homepage}`,"error")}g(te=>{const Se=new Set(te);return Se.delete(q.name),Se})},Me=async q=>{g(te=>new Set(te).add(q.name));try{const te=await Ae.skills.install({name:q.name,source:"skillssh",sourceUrl:q.url,githubRepo:`${q.author}/${q.repo}`,githubSkillPath:q.name});await Dt(),At(`"${q.name}" installed (${te.method}) → ${te.path}`),window.dispatchEvent(new CustomEvent("markus:data-changed"))}catch{At(`Download failed for "${q.name}". You can try manually from: ${q.url}`,"error")}g(te=>{const Se=new Set(te);return Se.delete(q.name),Se})},Ne=async q=>{g(te=>new Set(te).add(q.name));try{const te=await Ae.skills.install({name:q.name,source:"builtin"});await Dt(),await ln(),At(`"${q.name}" installed (${te.method}) → ${te.path}`),window.dispatchEvent(new CustomEvent("markus:data-changed"))}catch(te){At(`Install failed for "${q.name}": ${te}`,"error")}g(te=>{const Se=new Set(te);return Se.delete(q.name),Se})},se=$.filter(q=>{if(!pe)return!0;const te=pe.toLowerCase();return q.name.toLowerCase().includes(te)||q.repo.toLowerCase().includes(te)});if(w){const q=w,te={};q.instructions&&(te["SKILL.md"]=q.instructions);const Se={type:"skill",name:q.name,displayName:xh(q,s),version:q.version,description:vh(q,s),author:q.author??"",category:q.category??"general",tags:q.tags,files:te,skill:{skillFile:q.instructions?"SKILL.md":"",requiredPermissions:q.requiredPermissions,mcpServers:void 0,alwaysOn:!1}},De=q.installed&&q.installedVersion&&o6(q.version,q.installedVersion)?i.jsx("button",{onClick:()=>{Ne(q)},disabled:h.has(q.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(q.name)?n("card.upgrading"):n("card.upgrade",{version:q.version})}):q.installed?i.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:[i.jsx("svg",{className:"w-3 h-3",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",children:i.jsx("polyline",{points:"20 6 9 17 4 12"})}),n("card.installed"),q.installedVersion?` v${q.installedVersion}`:""]}):i.jsx("button",{onClick:()=>{Ne(q)},disabled:h.has(q.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(q.name)?n("card.installing"):n("card.install")}),Pe=i.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[i.jsxs("div",{className:"rounded-xl border border-border-default bg-surface-secondary/40 p-5",children:[i.jsx("h3",{className:"text-xs text-fg-tertiary uppercase tracking-wider mb-3",children:n("skillStore.details")}),i.jsxs("div",{className:"space-y-2.5 text-sm",children:[q.category&&i.jsxs("div",{className:"flex items-center gap-2",children:[i.jsx("span",{className:"text-fg-tertiary w-24",children:n("skillStore.category")}),i.jsx("span",{className:`px-2 py-0.5 rounded-full text-[10px] font-medium capitalize ${Yre[q.category]??"bg-gray-500/15 text-fg-secondary"}`,children:q.category})]}),i.jsxs("div",{className:"flex items-center gap-2",children:[i.jsx("span",{className:"text-fg-tertiary w-24",children:n("skillStore.version")}),i.jsx("span",{className:"text-fg-secondary font-mono text-xs",children:q.version})]}),q.hasMcpServers&&i.jsxs("div",{className:"flex items-center gap-2",children:[i.jsx("span",{className:"text-fg-tertiary w-24",children:n("skillStore.integration")}),i.jsx("span",{className:"px-2 py-0.5 rounded text-[10px] bg-purple-500/15 text-purple-400",children:"MCP"})]}),q.hasInstructions&&i.jsxs("div",{className:"flex items-center gap-2",children:[i.jsx("span",{className:"text-fg-tertiary w-24",children:n("skillStore.instructions")}),i.jsx("span",{className:"text-green-500 text-xs",children:"✓"})]})]})]}),(q.requiredPermissions.length>0||q.tags.length>0)&&i.jsxs("div",{className:"space-y-4",children:[q.requiredPermissions.length>0&&i.jsxs("div",{className:"rounded-xl border border-border-default bg-surface-secondary/40 p-5",children:[i.jsx("h3",{className:"text-xs text-fg-tertiary uppercase tracking-wider mb-3",children:n("skillStore.permissions")}),i.jsx("div",{className:"flex flex-wrap gap-1.5",children:q.requiredPermissions.map(Q=>i.jsx("span",{className:"px-2.5 py-1 text-xs bg-amber-500/10 text-amber-500 rounded-lg border border-amber-500/20",children:Q},Q))})]}),q.tags.length>0&&i.jsxs("div",{className:"rounded-xl border border-border-default bg-surface-secondary/40 p-5",children:[i.jsx("h3",{className:"text-xs text-fg-tertiary uppercase tracking-wider mb-3",children:n("skillStore.tags")}),i.jsx("div",{className:"flex flex-wrap gap-1.5",children:q.tags.map(Q=>i.jsx("span",{className:"px-2.5 py-1 text-xs bg-surface-elevated text-fg-secondary rounded-lg border border-border-default/50",children:Q},Q))})]})]})]});return i.jsxs(i.Fragment,{children:[i.jsx(qs,{type:"skill",name:q.name,onBack:()=>T(null),readOnly:!0,initialManifest:Se,actionSlot:De,contentSlot:Pe}),m&&i.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 i.jsxs("div",{className:"flex-1 overflow-hidden flex flex-col",children:[i.jsxs("div",{className:`${l?"px-4":"px-6"} shrink-0`,children:[i.jsx("div",{"data-electron-drag":!0,className:"flex items-center h-14",children:i.jsx("h2",{className:"text-lg font-semibold",children:n("skillStore.title")})}),i.jsx("div",{className:`flex ${l?"flex-wrap":""} gap-1 pb-2 overflow-x-auto scrollbar-hide`,children:mt.map(q=>i.jsx("button",{onClick:()=>d(q.id),className:`px-3 py-1.5 text-xs rounded-lg transition-colors shrink-0 ${c===q.id?"bg-brand-600 text-white":"text-fg-secondary hover:text-fg-primary hover:bg-surface-elevated"}`,children:n(q.labelKey)},q.id))})]}),m&&i.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 q=rt.trim().toLowerCase(),te=q?H.filter(Pe=>xh(Pe,s).toLowerCase().includes(q)||vh(Pe,s).toLowerCase().includes(q)):H,Se=fe&&Zt,De=te.length===0&&qe.length===0&&ut.length===0;return i.jsxs("div",{className:`flex-1 overflow-y-auto ${l?"p-4":"p-6"} space-y-8`,children:[i.jsx("div",{className:"flex items-center gap-2",children:i.jsx("input",{value:rt,onChange:Pe=>$e(Pe.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"}`})}),Se&&De?i.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-4",children:Array.from({length:6}).map((Pe,Q)=>i.jsx("div",{className:"h-56 rounded-2xl skeleton"},Q))}):De?i.jsxs("div",{className:"text-center text-fg-tertiary py-20",children:[i.jsx("div",{className:"text-4xl mb-3 opacity-30",children:"◇"}),i.jsx("div",{children:n("skillStore.noBuiltin")}),i.jsx("div",{className:"text-xs mt-1",children:n("skillStore.noBuiltinHint")})]}):i.jsxs(i.Fragment,{children:[te.length>0&&i.jsxs("section",{children:[i.jsxs("div",{className:"flex items-baseline gap-2 mb-3",children:[i.jsx("h3",{className:"section-title",children:n("skillStore.tabs.builtin")}),i.jsx("span",{className:"text-xs text-fg-tertiary",children:n("skillStore.builtinCount",{count:te.length})})]}),i.jsx(Fa,{columns:3,children:te.map(Pe=>i.jsx(vr,{type:"skill",name:xh(Pe,s),description:vh(Pe,s),seed:Pe.name,icon:tm(Pe.name,Pe.category),version:Pe.version,category:Pe.category,tags:Pe.tags,authorLabel:Pe.author||void 0,installed:Pe.installed,hideStats:!0,showTypeBadge:!1,cornerLabel:Pe.installed?void 0:n("skillStore.tabs.builtin"),onClick:()=>T(Pe)},Pe.name))})]}),qe.length>0&&i.jsxs("section",{children:[i.jsx("h3",{className:"section-title mb-3",children:n("skillStore.tabs.markusHub")}),i.jsx(Fa,{columns:3,children:qe.map(Pe=>i.jsx(Sk,{item:Pe,installedSkills:x,purchased:cm(Pe,Nt),onMsg:At,onRefresh:()=>{Dt(),nt(rt)},highlight:Pe.id===e,onHighlightDone:t},Pe.id))})]}),ut.length>0&&i.jsxs("section",{children:[i.jsxs("div",{className:"mb-3",children:[i.jsx("h3",{className:"section-title",children:n("tabs.connectors")}),i.jsx("p",{className:"text-xs text-fg-tertiary mt-0.5",children:n("connectorStore.emptyHint","连接器让智能体接入外部工具与服务 (MCP)")})]}),i.jsx(Fa,{columns:3,children:ut.map(Pe=>i.jsx(Sk,{item:Pe,type:"connector",installedSkills:x,purchased:cm(Pe,Nt),onMsg:At,onRefresh:()=>{Dt(),nt(rt)},highlight:Pe.id===e,onHighlightDone:t},Pe.id))})]})]})]})})(),c==="skillhub"&&i.jsxs("div",{className:`flex-1 overflow-y-auto ${l?"p-4":"p-6"}`,children:[i.jsxs("div",{className:"flex items-center gap-2 mb-3 flex-wrap",children:[i.jsxs("select",{value:K,onChange:q=>{Y(q.target.value),P(1),ce({q:ne||void 0,category:q.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:[i.jsx("option",{value:"",children:n("skillStore.allCategories")}),R.map(q=>i.jsx("option",{value:q,children:q},q))]}),i.jsxs("select",{value:L,onChange:q=>{F(q.target.value),P(1),ce({q:ne||void 0,category:K||void 0,page:1,sort:q.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:[i.jsx("option",{value:"score",children:n("skillStore.sortScore")}),i.jsx("option",{value:"downloads",children:n("skillStore.sortDownloads")}),i.jsx("option",{value:"stars",children:n("skillStore.sortStars")}),i.jsx("option",{value:"installs",children:n("skillStore.sortInstalls")})]}),!l&&i.jsx("span",{className:"text-xs text-fg-tertiary ml-auto",children:i.jsx("a",{href:"https://skillhub.tencent.com",target:"_blank",rel:"noopener noreferrer",className:"text-brand-500 hover:text-brand-500",children:n("skillStore.visitSite")})})]}),i.jsxs("div",{className:"flex items-center gap-2 mb-5",children:[i.jsx("input",{value:ne,onChange:q=>ee(q.target.value),onKeyDown:q=>{q.key==="Enter"&&(P(1),ce({q:ne||void 0,category:K||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"}),i.jsx("button",{onClick:()=>{P(1),ce({q:ne||void 0,category:K||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"})]}),G?i.jsx("div",{className:"text-center text-fg-tertiary py-20",children:i.jsx("div",{className:"animate-pulse",children:n("skillStore.loadingSkillhub")})}):C.length===0?i.jsxs("div",{className:"text-center text-fg-tertiary py-20",children:[i.jsx("div",{className:"text-4xl mb-3 opacity-30",children:"◎"}),i.jsx("div",{children:n("skillStore.noSkillhub")})]}):i.jsxs(i.Fragment,{children:[i.jsx("div",{className:"text-xs text-fg-tertiary mb-3",children:n("skillStore.skillhubTotal",{count:E.toLocaleString()})}),i.jsx(Fa,{columns:3,children:C.map(q=>{const te=x.some(Se=>Se.name===q.name||Se.name===q.slug);return i.jsx(vr,{type:"skill",name:q.name,description:q.description_zh??q.description??"",seed:q.slug,icon:tm(q.slug||q.name,q.tags?.[0]),version:q.version,authorLabel:"SkillHub",showTypeBadge:!1,tags:q.tags,installed:te,hideStats:!0,onClick:()=>window.open(q.homepage,"_blank","noopener,noreferrer"),footerLeft:i.jsxs("span",{className:"flex items-center gap-2 text-[10px] text-fg-tertiary",children:[q.stars>0&&i.jsxs("span",{className:"text-amber-600",children:["★ ",q.stars.toLocaleString()]}),q.downloads>0&&i.jsxs("span",{children:[q.downloads>=1e4?`${(q.downloads/1e4).toFixed(1)}万`:q.downloads.toLocaleString()," ",n("skillStore.downloads")]})]}),actions:te?void 0:i.jsx("button",{onClick:()=>{we(q)},disabled:h.has(q.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(q.name)?"...":n("card.install")})},q.slug)})}),E>24&&i.jsxs("div",{className:"flex items-center justify-center gap-2 mt-6",children:[i.jsx("button",{disabled:M<=1,onClick:()=>{const q=M-1;P(q),ce({q:ne||void 0,category:K||void 0,page:q})},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")}),i.jsx("span",{className:"text-xs text-fg-tertiary",children:n("skillStore.pageInfo",{current:M,total:Math.ceil(E/24)})}),i.jsx("button",{disabled:M>=Math.ceil(E/24),onClick:()=>{const q=M+1;P(q),ce({q:ne||void 0,category:K||void 0,page:q})},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"&&i.jsxs("div",{className:`flex-1 overflow-y-auto ${l?"p-4":"p-6"}`,children:[i.jsxs("div",{className:`flex ${l?"flex-wrap":""} items-center gap-2 mb-5`,children:[i.jsx("input",{value:pe,onChange:q=>z(q.target.value),onKeyDown:q=>{q.key==="Enter"&&pe.trim()&&et(pe)},placeholder:n("skillStore.searchSkillssh"),className:`px-3 py-1.5 bg-surface-elevated border border-border-default rounded-lg text-sm text-fg-primary focus:border-brand-500 outline-none ${l?"flex-1 min-w-0":"w-72"}`}),i.jsx("button",{onClick:()=>{pe.trim()&&et(pe)},className:"px-3 py-1.5 bg-brand-600 hover:bg-brand-500 text-white text-xs rounded-lg shrink-0",children:"Search"}),!l&&i.jsx("span",{className:"text-xs text-fg-tertiary ml-auto",children:i.jsx("a",{href:"https://skills.sh",target:"_blank",rel:"noopener noreferrer",className:"text-brand-500 hover:text-brand-500",children:n("skillStore.visitSite")})})]}),je?i.jsx("div",{className:"text-center text-fg-tertiary py-20",children:i.jsx("div",{className:"animate-pulse",children:n("skillStore.loadingSkillssh")})}):se.length===0?i.jsxs("div",{className:"text-center text-fg-tertiary py-20",children:[i.jsx("div",{className:"text-4xl mb-3 opacity-30",children:"⬡"}),i.jsx("div",{children:n("skillStore.browseSkillssh")}),i.jsx("div",{className:"text-xs mt-1",children:n("skillStore.browseSkillsshHint")})]}):i.jsx(Fa,{columns:3,children:se.map(q=>{const te=x.some(Se=>Se.name===q.name);return i.jsx(vr,{type:"skill",name:q.name,description:q.description||"",seed:`${q.author}-${q.name}`,icon:tm(q.name),authorLabel:`${q.author}/${q.repo}`,showTypeBadge:!1,installed:te,hideStats:!0,cornerLabel:te?void 0:"skills.sh",onClick:()=>window.open(q.url,"_blank","noopener,noreferrer"),footerLeft:q.installs?i.jsxs("span",{className:"text-[10px] text-fg-tertiary",children:[q.installs," installs"]}):void 0,actions:te?void 0:i.jsx("button",{onClick:()=>{Me(q)},disabled:h.has(q.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(q.name)?"...":n("card.install")})},`${q.author}-${q.name}`)})})]})]})}const Jre=["agent","team","skill","connector"];function wh({title:e,subtitle:t,onMore:n,moreLabel:a}){return i.jsxs("div",{className:"flex items-end justify-between mb-3",children:[i.jsxs("div",{children:[i.jsx("h3",{className:"section-title",children:e}),t&&i.jsx("p",{className:"section-subtitle",children:t})]}),n&&i.jsxs("button",{className:"section-link",onClick:n,children:[a??"View all"," →"]})]})}function Zre({item:e,onOpen:t}){const n=il(e.subtype==="connector"?"connector":e.itemType),a=xb(n,e.slug||e.name),s=Bs[n];return i.jsxs("button",{onClick:t,className:"group relative w-full overflow-hidden rounded-2xl text-left h-44 md:h-52",style:{background:a},children:[i.jsx("div",{className:"absolute inset-0 bg-gradient-to-r from-black/55 via-black/20 to-transparent"}),i.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:i.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"})}),i.jsxs("div",{className:"relative h-full flex flex-col justify-end p-5 md:p-6",children:[i.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 · ",s.label]}),i.jsx("h2",{className:"text-xl md:text-2xl font-bold text-white drop-shadow-sm",children:e.name}),i.jsx("p",{className:"text-sm text-white/85 truncate max-w-lg mt-1",children:e.description}),i.jsxs("div",{className:"flex items-center gap-3 mt-3 text-white/80 text-xs",children:[i.jsxs("span",{className:"inline-flex items-center gap-1.5",children:[i.jsx(Om,{name:e.author?.displayName,username:e.author?.username,avatarUrl:e.author?.avatarUrl,hubBase:st.getUrl(),size:18}),e.author?.displayName||e.author?.username]}),i.jsxs("span",{children:["↓ ",$o(e.downloadCount)]}),(e.priceCents??0)>0?i.jsxs("span",{className:"badge-paid",children:["$",((e.priceCents??0)/100).toFixed(0)]}):i.jsx("span",{className:"badge-free",children:"Free"})]})]})]})}function Ck({items:e,onOpen:t}){return i.jsx(Fa,{columns:3,children:e.map(n=>i.jsx(vr,{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:st.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 Ak(){return i.jsx(Fa,{columns:3,children:Array.from({length:6}).map((e,t)=>i.jsx("div",{className:"h-64 rounded-2xl skeleton"},t))})}function eie({onOpenType:e}){const{t}=ot(["store","common"]),[n,a]=k.useState([]),[s,l]=k.useState(!0);k.useEffect(()=>{let g=!1;return(async()=>{l(!0);try{const x=await st.search({limit:60,sort:"popular"});g||a(x.items??[])}catch{g||a([])}finally{g||l(!1)}})(),()=>{g=!0}},[]);const c=k.useMemo(()=>{const g=n.filter(y=>y.featured);return(g.length>0?g:n).slice(0,3)},[n]),d=k.useMemo(()=>[...n].sort((g,x)=>(x.trendingScore??x.downloadCount)-(g.trendingScore??g.downloadCount)).slice(0,10),[n]),m=k.useMemo(()=>[...n].sort((g,x)=>(x.createdAt||"").localeCompare(g.createdAt||"")).slice(0,10),[n]),p=k.useMemo(()=>{const g=new Map;for(const x of n){const y=x.author?.username||x.author?.id;if(!y)continue;const w=g.get(y)??{author:x.author,downloads:0,count:0};w.downloads+=x.downloadCount||0,w.count+=1,g.set(y,w)}return[...g.values()].sort((x,y)=>y.downloads-x.downloads).slice(0,6)},[n]),h=g=>e(il(g.subtype==="connector"?"connector":g.itemType),g.id);return i.jsxs("div",{className:"flex-1 overflow-y-auto px-5 md:px-7 py-5 space-y-8",children:[i.jsxs("div",{className:"hero-glow rounded-2xl border border-border-subtle bg-surface-secondary p-5 md:p-6",children:[i.jsx("h1",{className:"text-2xl font-bold text-gradient tracking-tight",children:t("discover.title","Markus 广场")}),i.jsx("p",{className:"text-sm text-fg-tertiary mt-1 max-w-2xl",children:t("discover.subtitle","发现社区共享的智能体、AI 小队、技能与连接器 — 由创作者共建的开放生态。")}),i.jsx("div",{className:"flex flex-wrap gap-2 mt-4",children:Jre.map(g=>i.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 ${Bs[g].gradient} hover:opacity-90 transition-opacity`,children:[Bs[g].labelZh,i.jsx("span",{className:"opacity-70",children:Bs[g].label})]},g))})]}),s?i.jsx("div",{className:"h-52 rounded-2xl skeleton"}):c.length>0?i.jsx("div",{className:"grid grid-cols-1 lg:grid-cols-3 gap-4",children:c.map(g=>i.jsx(Zre,{item:g,onOpen:()=>h(g)},g.id))}):null,i.jsxs("section",{children:[i.jsx(wh,{title:t("discover.trending","热门趋势"),subtitle:t("discover.trendingSub","社区中下载与评分增长最快的资产")}),s?i.jsx(Ak,{}):d.length>0?i.jsx(Ck,{items:d,onOpen:h}):i.jsx(tie,{})]}),i.jsxs("section",{children:[i.jsx(wh,{title:t("discover.fresh","新鲜上架"),subtitle:t("discover.freshSub","来自创作者的最新作品")}),s?i.jsx(Ak,{}):m.length>0?i.jsx(Ck,{items:m,onOpen:h}):null]}),p.length>0&&i.jsxs("section",{children:[i.jsx(wh,{title:t("discover.topCreators","顶尖创作者"),subtitle:t("discover.topCreatorsSub","生态贡献榜")}),i.jsx("div",{className:"grid grid-cols-2 md:grid-cols-3 lg:grid-cols-6 gap-3",children:p.map((g,x)=>i.jsxs("div",{className:"asset-card p-4 flex flex-col items-center text-center",children:[i.jsxs("div",{className:"relative",children:[i.jsx(Om,{name:g.author?.displayName,username:g.author?.username,avatarUrl:g.author?.avatarUrl,hubBase:st.getUrl(),size:48,verified:x<3}),x<3&&i.jsx("span",{className:"absolute -top-1 -left-1 w-5 h-5 rounded-full bg-amber-400 text-black text-[10px] font-bold flex items-center justify-center ring-2 ring-surface-secondary",children:x+1})]}),i.jsx("div",{className:"text-sm font-semibold text-fg-primary truncate w-full mt-2",children:g.author?.displayName||g.author?.username}),i.jsxs("div",{className:"text-[11px] text-fg-tertiary mt-0.5",children:[g.count," 作品 · ↓ ",$o(g.downloads)]})]},g.author?.username||x))})]})]})}function tie(){const{t:e}=ot(["store"]);return i.jsxs("div",{className:"text-center py-12 rounded-2xl border border-dashed border-border-default",children:[i.jsx("div",{className:"text-3xl mb-2 opacity-40",children:"✦"}),i.jsx("div",{className:"text-fg-secondary font-medium",children:e("discover.empty","生态正在成长中")}),i.jsx("div",{className:"text-fg-tertiary text-sm mt-1",children:e("discover.emptyHint","成为首批创作者,分享你的第一个资产")})]})}function Fd(e,t,n){return e.i18n?.[n]?.[t]}function nie(){const{t:e,i18n:t}=ot(["store","common"]),n=Xo(),a=t.language,[s,l]=k.useState([]),[c,d]=k.useState({}),[m,p]=k.useState(new Set),[h,g]=k.useState(null),[x,y]=k.useState(!0),[w,T]=k.useState(""),[C,S]=k.useState("all"),[E,_]=k.useState(null),M=k.useCallback(async()=>{y(!0);try{const[I,K,Y,L]=await Promise.all([Ae.builder.artifacts.list().catch(()=>({artifacts:[]})),Ae.builder.artifacts.installed().catch(()=>({installed:{}})),Ae.skills.updates().catch(()=>({updates:[],count:0})),Ae.skills.builtin().catch(()=>({skills:[]}))]),F={};for(const G of Y.updates)F[G.name]={availableVersion:G.availableVersion,installedVersion:G.installedVersion,displayName:G.displayName,description:G.description};d(F);const ne=I.artifacts.filter(G=>{const ae=`${G.type}/${G.name}`;return!!K.installed[ae]}),ee=new Set(ne.filter(G=>G.type==="skill").map(G=>G.name));for(const G of L.skills)!G.installed||ee.has(G.name)||!(K.installed[`skill/${G.name}`]||F[G.name])&&!G.updateAvailable||!K.installed[`skill/${G.name}`]&&!F[G.name]||(ne.push({type:"skill",name:G.name,meta:{displayName:G.i18n?.[a]?.displayName||G.name,description:G.i18n?.[a]?.description||G.description||"",version:G.installedVersion||G.version,author:G.author,category:G.category,tags:G.tags,i18n:G.i18n},path:"",updatedAt:""}),ee.add(G.name));for(const[G,ae]of Object.entries(F))ee.has(G)||(ne.push({type:"skill",name:G,meta:{displayName:ae.displayName||G,description:ae.description||"",version:ae.installedVersion},path:"",updatedAt:""}),ee.add(G));l(ne)}catch{}y(!1)},[a]);k.useEffect(()=>{M()},[M]),k.useEffect(()=>{const I=()=>{M()};return window.addEventListener("markus:data-changed",I),()=>window.removeEventListener("markus:data-changed",I)},[M]),k.useEffect(()=>{if(!h)return;const I=setTimeout(()=>g(null),3e3);return()=>clearTimeout(I)},[h]);const P=async(I,K)=>{if(!m.has(I)){p(Y=>new Set(Y).add(I));try{await Ae.skills.install({name:I,source:"builtin"});try{localStorage.removeItem("markus:template-updates-ack")}catch{}g({text:e("installedTab.updateSuccess",{name:I,version:K}),type:"success"}),window.dispatchEvent(new CustomEvent("markus:data-changed")),await M()}catch{g({text:e("installedTab.updateFailed",{name:I}),type:"error"})}p(Y=>{const L=new Set(Y);return L.delete(I),L})}},R=s.filter(I=>{if(C!=="all"&&I.type!==C)return!1;if(!w)return!0;const K=w.toLowerCase(),Y=(Fd(I.meta,"displayName",a)||I.meta.displayName||I.name).toLowerCase(),L=(Fd(I.meta,"description",a)||I.meta.description||"").toLowerCase();return Y.includes(K)||L.includes(K)}).sort((I,K)=>{const Y=I.type==="skill"&&c[I.name]?1:0;return(K.type==="skill"&&c[K.name]?1:0)-Y});return E?i.jsx(qs,{type:E.type,name:E.name,onBack:()=>_(null)}):i.jsxs("div",{className:"flex-1 overflow-hidden flex flex-col",children:[i.jsxs("div",{"data-electron-drag":!0,className:`${n?"px-4":"px-6"} h-14 flex items-center shrink-0 gap-3`,children:[i.jsx("h2",{className:"text-lg font-semibold",children:e("installedTab.title")}),Object.keys(c).length>0&&i.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]})]}),i.jsxs("div",{className:`flex flex-wrap items-center gap-2 ${n?"px-4":"px-6"} py-2 shrink-0`,children:[i.jsx("div",{className:"flex gap-1",children:["all","agent","team","skill"].map(I=>i.jsx("button",{onClick:()=>S(I),className:`px-3 py-1 text-xs rounded-md transition-colors ${C===I?"bg-brand-600 text-white":"text-fg-secondary hover:text-fg-primary hover:bg-surface-elevated"}`,children:e(`installedTab.filter${I==="all"?"All":I==="agent"?"Agents":I==="team"?"Teams":"Skills"}`)},I))}),i.jsx("div",{className:"flex-1 min-w-[120px]",children:i.jsx("input",{type:"text",placeholder:e("installedTab.searchPlaceholder"),value:w,onChange:I=>T(I.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"})})]}),i.jsx("div",{className:`flex-1 overflow-y-auto ${n?"p-4":"p-7"}`,children:x?i.jsx("div",{className:"text-center text-fg-tertiary py-20 animate-pulse",children:e("installedTab.loading")}):R.length===0?i.jsxs("div",{className:"text-center py-20",children:[i.jsx("div",{className:"text-4xl mb-4 opacity-30",children:"⧉"}),i.jsx("div",{className:"text-fg-secondary font-medium mb-1",children:e("installedTab.noItems")}),i.jsx("div",{className:"text-fg-tertiary text-sm",children:e("installedTab.noItemsHint")})]}):i.jsx(Fa,{columns:3,children:R.map(I=>{const K=Fd(I.meta,"displayName",a)||I.meta.displayName||I.name,Y=Fd(I.meta,"description",a)||I.meta.description||"",L=I.meta.version||"",F=I.meta.author||"",ne=I.meta.tags??[],ee=I.meta.category||"",G=I.meta.icon,ae=G&&/\.(png|jpe?g|gif|webp|svg)$/i.test(G)&&!G.startsWith("http")&&!G.startsWith("data:")&&!G.startsWith("/")?`/api/builder/artifacts/${I.type}s/${encodeURIComponent(I.name)}/${G}`:G,H=I.type==="skill"?c[I.name]:void 0;return i.jsx(vr,{type:I.type,name:K,description:Y,seed:I.name,icon:ae,author:null,authorLabel:F||void 0,version:H?H.installedVersion:L,category:ee,tags:ne,installed:!H,hideStats:!0,cornerLabel:H?e("installedTab.updateAvailable"):void 0,onClick:()=>{I.path&&_({type:I.type,name:I.name})},actions:H?i.jsx("button",{type:"button",disabled:m.has(I.name),onClick:()=>{P(I.name,H.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(I.name)?e("installedTab.updating"):e("installedTab.updateTo",{version:H.availableVersion})}):void 0},`${I.type}/${I.name}`)})})}),h&&i.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 aie=50,rie=30;function iie(e,t,n,a){const s=k.useRef(0),l=k.useRef(0),c=k.useCallback(m=>{s.current=m.touches[0].clientX,l.current=m.touches[0].clientY},[]),d=k.useCallback(m=>{const p=m.changedTouches[0].clientX-s.current,h=m.changedTouches[0].clientY-l.current,g=Math.abs(p),x=Math.abs(h);if(g<aie||Math.atan2(x,g)*(180/Math.PI)>rie)return;if(a?.scrollContainerRef?.current){const T=a.scrollContainerRef.current,C=T.scrollLeft<=1,S=T.scrollLeft+T.clientWidth>=T.scrollWidth-1;if(p>0&&!C||p<0&&!S)return}const w=e.findIndex(T=>T.id===t);p<0&&w<e.length-1?n(e[w+1].id):p>0&&w>0?n(e[w-1].id):p>0&&w===0&&a?.onSwipeOutLeft?a.onSwipeOutLeft():p<0&&w===e.length-1&&a?.onSwipeOutRight&&a.onSwipeOutRight()},[e,t,n,a]);return{onTouchStart:c,onTouchEnd:d}}const sie=["builder","discover","agents","teams","skills","installed"],oie={agent:"agents",team:"teams",skill:"skills",connector:"skills"};function Sg(e){return!!e&&sie.includes(e)}function Tk(){const e=localStorage.getItem("markus_nav_installItem"),t=localStorage.getItem("markus_nav_storeTab");return{tab:Sg(t)?t:"builder",installId:e}}function lie({authUser:e}){const{t}=ot(["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]),[a]=k.useState(Tk),[s,l]=k.useState(a.tab),[c,d]=k.useState(a.installId),m=iie(n,s,l);k.useEffect(()=>{const h=Tk();h.installId&&(d(h.installId),Sg(h.tab)&&l(h.tab),localStorage.removeItem("markus_nav_installItem"),localStorage.removeItem("markus_nav_storeTab"))},[]),k.useEffect(()=>{const h=g=>{const x=g.detail,y=x.params?.storeTab??localStorage.getItem("markus_nav_storeTab");Sg(y)&&l(y);const w=x.params?.installItem??localStorage.getItem("markus_nav_installItem");w&&d(w),localStorage.removeItem("markus_nav_storeTab"),localStorage.removeItem("markus_nav_installItem")};return window.addEventListener("markus:navigate",h),()=>window.removeEventListener("markus:navigate",h)},[]);const p=(h,g)=>{g&&d(g),l(oie[h]??"agents")};return i.jsxs("div",{className:"flex-1 overflow-hidden flex flex-col",onTouchStart:m.onTouchStart,onTouchEnd:m.onTouchEnd,children:[i.jsxs("div",{className:"flex items-center shrink-0 overflow-x-auto scrollbar-hide",children:[i.jsx(g4,{className:"ml-2"}),n.map(h=>i.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 ${s===h.id?"border-brand-500 text-brand-500":"border-transparent text-fg-tertiary"}`,children:h.label},h.id))]}),i.jsxs("div",{className:"flex-1 overflow-hidden flex flex-col",children:[s==="builder"&&i.jsx(r6,{authUser:e}),s==="discover"&&i.jsx(eie,{onOpenType:p}),s==="agents"&&i.jsx(Ure,{authUser:e,highlightItemId:c,onHighlightDone:()=>d(null)}),s==="teams"&&i.jsx(Vre,{highlightItemId:c,onHighlightDone:()=>d(null)}),s==="skills"&&i.jsx(Xre,{highlightItemId:c,onHighlightDone:()=>d(null)}),s==="installed"&&i.jsx(nie,{})]})]})}const Nk="usageType",kh="profile";function cie({onComplete:e,theme:t,onThemeChange:n,skipProfile:a,onProfileUpdated:s}){const{t:l}=ot(["onboarding","common"]),[c,d]=k.useState(0),[m,p]=k.useState(""),[h,g]=k.useState(""),[x,y]=k.useState(""),[w,T]=k.useState(""),[C,S]=k.useState(!1),[E,_]=k.useState(""),[M,P]=k.useState(!1),[R,I]=k.useState(null);k.useEffect(()=>{Ae.auth.me().then(({user:$e})=>{$e.name&&p($e.name),$e.email&&g($e.email),$e.avatarUrl&&I($e.avatarUrl);const mt=$e.name||$e.email?.split("@")[0]||"";mt&&F(At=>At||l("usageType.defaultOrgName",{name:mt}))}).catch(()=>{}),Ae.settings.getOrg().then(({org:$e})=>{$e?.name&&$e.name!=="My Organization"&&F($e.name)}).catch(()=>{}),jn()&&Ae.hubOrgs.invitations().then($e=>{$e.invitations?.length>0&&Ce($e.invitations)}).catch(()=>{})},[]);const[K,Y]=k.useState(null),[L,F]=k.useState(""),[ne,ee]=k.useState(!1),[G,ae]=k.useState(!1),[H,J]=k.useState(""),[fe,Ce]=k.useState([]),[$,V]=k.useState(null),[pe,z]=k.useState(null),je=async()=>{const $e=L.trim();if($e){ee(!0),J("");try{if(await Ae.settings.updateOrg($e),jn()){const mt=await Ae.hubOrgs.mine(),At=mt.orgs?.find(Dt=>Dt.role==="owner")??mt.orgs?.[0];At?.id?await Ae.hubOrgs.update(At.id,{name:$e}):await Ae.hubOrgs.create($e)}ae(!0)}catch{J(l("usageType.orgNameSaveFailed"))}finally{ee(!1)}}},[Ue,qe]=k.useState(!0),He=async()=>{if(_(""),!m.trim()){_(l("profile.errors.nameRequired"));return}if(!h.trim()){_(l("profile.errors.emailRequired"));return}if(!/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(h.trim())){_(l("profile.errors.emailInvalid"));return}if(x&&x.length<6){_(l("profile.errors.passwordTooShort"));return}if(x&&x!==w){_(l("profile.errors.passwordMismatch"));return}S(!0);try{const{user:$e}=await Ae.auth.updateProfile(m.trim(),h.trim());x&&await Ae.auth.changePassword("",x),s?.($e),P(!0)}catch{_(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")}],dt=[{id:"welcome",title:l("welcome.title"),subtitle:l("welcome.subtitle"),content:i.jsx("p",{className:"text-fg-secondary text-sm leading-relaxed",children:i.jsx(dT,{i18nKey:"welcome.description",ns:"onboarding",components:{strong:i.jsx("strong",{className:"text-fg-primary"})}})})},{id:Nk,title:l("usageType.title",{defaultValue:"How will you use Markus?"}),subtitle:l("usageType.subtitle",{defaultValue:"This helps us tailor your experience."}),content:i.jsxs("div",{className:"space-y-4",children:[i.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[i.jsxs("button",{onClick:()=>{Y("personal"),ae(!0)},className:`flex flex-col items-center gap-3 rounded-xl border-2 p-5 transition-all text-left ${K==="personal"?"border-brand-500 bg-brand-500/10":"border-border-default hover:border-fg-tertiary bg-surface-elevated/30"}`,children:[i.jsx("span",{className:"text-2xl",children:"👤"}),i.jsxs("div",{children:[i.jsx("div",{className:"font-medium text-fg-primary text-sm text-center",children:l("usageType.personal",{defaultValue:"Personal"})}),i.jsx("div",{className:"text-[11px] text-fg-tertiary mt-1 text-center",children:l("usageType.personalDesc",{defaultValue:"Individual use with your own AI agents."})})]})]}),i.jsxs("button",{onClick:()=>{Y("organization"),ae(!1)},className:`flex flex-col items-center gap-3 rounded-xl border-2 p-5 transition-all text-left ${K==="organization"?"border-brand-500 bg-brand-500/10":"border-border-default hover:border-fg-tertiary bg-surface-elevated/30"}`,children:[i.jsx("span",{className:"text-2xl",children:"🏢"}),i.jsxs("div",{children:[i.jsx("div",{className:"font-medium text-fg-primary text-sm text-center",children:l("usageType.organization",{defaultValue:"Team & Enterprise"})}),i.jsx("div",{className:"text-[11px] text-fg-tertiary mt-1 text-center",children:l("usageType.organizationDesc",{defaultValue:"For teams sharing licenses and collaborating."})})]})]})]}),K==="organization"&&i.jsxs("div",{className:"space-y-4 mt-4",children:[fe.length>0&&i.jsxs("div",{className:"space-y-2",children:[i.jsx("div",{className:"text-xs text-fg-tertiary font-medium",children:l("usageType.pendingInvitations")}),fe.map($e=>i.jsxs("div",{className:"flex items-center justify-between px-4 py-3 rounded-xl border border-amber-500/20 bg-amber-500/5",children:[i.jsxs("div",{children:[i.jsx("div",{className:"text-sm font-medium text-fg-primary",children:$e.orgName}),i.jsx("div",{className:"text-[11px] text-fg-tertiary",children:l("usageType.invitedBy",{name:$e.invitedBy})})]}),i.jsx("button",{onClick:async()=>{V($e.orgId);try{await Ae.hubOrgs.acceptInvitation($e.orgId),z($e.orgId),ae(!0)}catch{}finally{V(null)}},disabled:$===$e.orgId||pe===$e.orgId,className:"px-3 py-1.5 text-xs rounded-lg bg-brand-600 hover:bg-brand-500 disabled:opacity-40 text-white transition-colors",children:pe===$e.orgId?l("usageType.accepted"):$===$e.orgId?l("usageType.accepting"):l("usageType.acceptAndJoin")})]},$e.orgId)),i.jsx("div",{className:"text-[11px] text-fg-tertiary text-center pt-1",children:l("usageType.orCreateNew")})]}),i.jsxs("div",{className:"space-y-1",children:[i.jsx("label",{className:"text-xs text-fg-tertiary font-medium",children:l("usageType.orgNameLabel")}),i.jsx("input",{type:"text",value:L,onChange:$e=>{F($e.target.value),ae(!1),J("")},placeholder:l("usageType.orgNamePlaceholder"),className:"w-full px-4 py-2.5 bg-surface-elevated border border-border-default rounded-xl text-sm text-fg-primary focus:border-brand-500 outline-none transition-colors"})]}),H&&i.jsx("p",{className:"text-xs text-red-500",children:H}),i.jsx("button",{onClick:()=>{je()},disabled:ne||!L.trim()||G,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(ne?"common:saving":G?"usageType.orgNameSaved":"usageType.setOrgName")})]})]})},{id:kh,title:l("profile.title"),subtitle:l("profile.subtitle"),content:M?i.jsxs("div",{className:"flex items-center gap-3 bg-green-500/10 border border-green-500/30 rounded-xl p-4",children:[i.jsx("span",{className:"text-green-600 text-lg",children:"✓"}),i.jsxs("div",{children:[i.jsx("div",{className:"text-sm font-medium text-green-600",children:l("profile.saved")}),i.jsxs("div",{className:"text-xs text-fg-secondary mt-0.5",children:[m," · ",h]})]})]}):i.jsxs("div",{className:"space-y-4",children:[i.jsx("div",{className:"flex justify-center",children:i.jsx(f4,{currentUrl:R,name:m,size:64,targetType:"user"})}),i.jsxs("div",{className:"space-y-1",children:[i.jsxs("label",{className:"text-xs text-fg-tertiary font-medium",children:[l("profile.nameLabel")," ",i.jsx("span",{className:"text-red-500",children:"*"})]}),i.jsx("input",{type:"text",value:m,onChange:$e=>p($e.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})]}),i.jsxs("div",{className:"space-y-1",children:[i.jsxs("label",{className:"text-xs text-fg-tertiary font-medium",children:[l("profile.emailLabel")," ",i.jsx("span",{className:"text-red-500",children:"*"})]}),i.jsx("input",{type:"email",value:h,onChange:$e=>g($e.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"})]}),i.jsxs("div",{className:"space-y-1",children:[i.jsx("label",{className:"text-xs text-fg-tertiary font-medium",children:l("profile.newPasswordLabel")}),i.jsx("input",{type:"password",value:x,onChange:$e=>y($e.target.value),placeholder:l("profile.newPasswordPlaceholder"),className:"w-full px-4 py-2.5 bg-surface-elevated border border-border-default rounded-xl text-sm text-fg-primary focus:border-brand-500 outline-none transition-colors"})]}),x&&i.jsxs("div",{className:"space-y-1",children:[i.jsx("label",{className:"text-xs text-fg-tertiary font-medium",children:l("profile.confirmPasswordLabel")}),i.jsx("input",{type:"password",value:w,onChange:$e=>T($e.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&&i.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}),i.jsx("button",{onClick:()=>{He()},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:i.jsxs("div",{className:"space-y-4",children:[i.jsx("div",{className:"grid grid-cols-3 gap-3",children:ut.map($e=>i.jsxs("button",{onClick:()=>n($e.value),className:`flex flex-col items-center gap-2 rounded-xl border-2 p-5 transition-all ${t===$e.value?"border-brand-500 bg-brand-500/10":"border-border-default hover:border-fg-tertiary bg-surface-elevated/30"}`,children:[i.jsx("span",{className:"text-2xl",children:$e.icon}),i.jsx("span",{className:"text-sm font-medium text-fg-primary",children:$e.label}),i.jsx("span",{className:"text-[11px] text-fg-tertiary leading-tight text-center",children:$e.desc})]},$e.value))}),i.jsxs("label",{className:"flex items-center gap-2.5 p-3 bg-surface-elevated/30 rounded-lg cursor-pointer group",children:[i.jsx("input",{type:"checkbox",checked:Ue,onChange:$e=>qe($e.target.checked),className:"accent-brand-500 shrink-0"}),i.jsx("span",{className:"text-[11px] text-fg-tertiary",children:l("done.telemetry")})]})]})}],Nt=a?dt.filter($e=>$e.id!==kh):dt,wt=Nt.findIndex($e=>$e.id===Nk),Zt=Nt.findIndex($e=>$e.id===kh),Wt=()=>{c===wt&&wt>=0&&!K||c===wt&&K==="organization"&&!G||c===Zt&&Zt>=0&&!M||(c<Nt.length-1?d(c+1):(fetch("/api/settings/telemetry",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({enabled:Ue})}).catch(()=>{}),e()))},rt=Nt[c];return i.jsx("div",{className:"min-h-dvh bg-surface-primary flex items-center justify-center p-4",children:i.jsx("div",{className:"w-full max-w-lg",children:i.jsxs("div",{className:"bg-surface-elevated rounded-2xl p-8",children:[i.jsx("div",{className:"flex gap-1.5 mb-8",children:Nt.map(($e,mt)=>i.jsx("div",{className:`h-1 flex-1 rounded-full transition-colors ${mt<=c?"bg-brand-500":"bg-surface-elevated"}`},mt))}),i.jsx("h2",{className:"text-2xl font-bold text-fg-primary",children:rt.title}),i.jsx("p",{className:"text-sm text-fg-secondary mt-1 mb-6",children:rt.subtitle}),rt.content,i.jsxs("div",{className:"flex justify-between mt-8",children:[c>0?i.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")}):i.jsx("span",{}),i.jsx("button",{onClick:Wt,disabled:Zt>=0&&c===Zt&&!M||wt>=0&&c===wt&&(!K||K==="organization"&&!G),className:`px-6 py-2.5 text-white text-sm rounded-xl transition-colors ${Zt>=0&&c===Zt&&!M||wt>=0&&c===wt&&(!K||K==="organization"&&!G)?"bg-brand-600/40 cursor-not-allowed":"bg-brand-600 hover:bg-brand-500"}`,children:c===Nt.length-1?l("getStarted"):l("common:next")})]})]})})})}const Ek="markus:legal-consent",uie="https://markus.global";function die({onLogin:e,hasOwner:t}){const{t:n,i18n:a}=ot("auth"),[s,l]=k.useState(null),[c,d]=k.useState(""),[m,p]=k.useState(!1),[h,g]=k.useState(""),[x,y]=k.useState(""),[w,T]=k.useState(!1),[C,S]=k.useState(!1),E=F=>{const ne=(a.language||"").toLowerCase().startsWith("zh")?"?lang=zh":"";return`${uie}${F}${ne}`},_=()=>{try{localStorage.setItem(Ek,JSON.stringify({acceptedAt:new Date().toISOString(),terms:!0,privacy:!0}))}catch{}},M=()=>C?(_(),!0):(T(!1),requestAnimationFrame(()=>T(!0)),!1),P=async()=>{const F=jn(),ne=xr();if(!F||!ne){d(n("login.hubUnavailable"));return}const ee=await Ae.auth.hubLogin(F,ne);if(window.markusDesktop?.clearPendingDeepLinkAuth?.(),ee.cloudAiReady===!1)try{sessionStorage.setItem("markus:cloud-ai-warning",ee.cloudAiError?n("login.cloudAiNotReady",{error:ee.cloudAiError}):n("login.cloudAiNotReadyGeneric"))}catch{}e(ee.user,ee.needsOnboarding??!1,{fromHub:!0})},R=async(F,ne=!1)=>{if(!(!ne&&!M())){d(""),l(F??"hub");try{if(ne&&jn()&&xr()){await P();return}await Ha({method:F,force:!0}),await P()}catch(ee){const G=ee instanceof Error?ee.message:"";if(!G.includes("cancelled")){if(!ne&&jn())return R(F,!0);d(G||n("login.hubUnavailable"))}}finally{l(null)}}},I=()=>{uU(),l(null),d("")};k.useEffect(()=>{const F=window.markusDesktop;if(!F?.peekPendingDeepLinkAuth&&!F?.consumePendingDeepLinkAuth)return;let ne=!1;return(async()=>{const ee=F.peekPendingDeepLinkAuth?await F.peekPendingDeepLinkAuth():null;if(ne||!ee)return;let G=!1;try{G=!!localStorage.getItem(Ek)}catch{}if(!C&&!G){d(n("login.consentRequired"));return}G&&!C&&S(!0),_();const ae=F.consumePendingDeepLinkAuth?await F.consumePendingDeepLinkAuth():ee;if(!(ne||!ae)){d(""),l("hub");try{if(!await cU(ae)||!jn()||!xr()){d(n("login.hubUnavailable"));return}await P()}catch{d(n("login.hubUnavailable"))}finally{ne||l(null)}}})().catch(()=>{}),()=>{ne=!0}},[C]);const K=async F=>{if(F.preventDefault(),!(!h.trim()||!x)&&M()){d(""),l("local");try{const{user:ne,needsOnboarding:ee}=await Ae.auth.login(h.trim(),x);e(ne,ee??!1)}catch{d(n("login.invalidCredentials"))}finally{l(null)}}},Y=n(t?"login.welcomeBack":"login.getStarted"),L="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 i.jsxs("div",{className:"min-h-dvh bg-surface-primary flex flex-col items-center justify-center p-4 relative overflow-hidden",children:[i.jsxs("div",{className:"pointer-events-none absolute inset-0 overflow-hidden",children:[i.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]"}),i.jsx("div",{className:"absolute top-1/4 -left-40 h-[26rem] w-[26rem] rounded-full bg-brand-400/10 blur-[100px]"}),i.jsx("div",{className:"absolute -bottom-40 -right-32 h-[34rem] w-[34rem] rounded-full bg-brand-600/10 blur-[110px]"})]}),i.jsxs("div",{className:"w-full max-w-[26rem] relative z-10 flex-1 flex flex-col justify-center",children:[i.jsxs("div",{className:"text-center mb-8",children:[i.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"}),i.jsx("div",{className:"text-[1.75rem] leading-none font-extrabold tracking-tight text-fg-primary mb-2",children:"Markus"}),i.jsx("div",{className:"text-sm text-fg-tertiary",children:Y})]}),i.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?i.jsxs("div",{className:"space-y-4",children:[i.jsxs("div",{children:[i.jsx("div",{className:"text-base font-semibold text-fg-primary",children:n("login.localTitle")}),i.jsx("div",{className:"text-xs text-fg-tertiary mt-0.5",children:n("login.localAccountHint")})]}),i.jsxs("form",{onSubmit:K,className:"space-y-3",children:[i.jsx("input",{type:"email",value:h,onChange:F=>g(F.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}),i.jsx("input",{type:"password",value:x,onChange:F=>y(F.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&&i.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&&i.jsx("p",{className:"text-[11px] text-fg-tertiary",children:n("login.defaultCredentials")}),i.jsx("button",{type:"submit",disabled:s==="local"||!h||!x,className:"w-full h-11 bg-brand-600 hover:bg-brand-500 disabled:opacity-50 text-white text-sm font-semibold rounded-xl transition-all shadow-md shadow-brand-900/30 hover:shadow-lg active:scale-[0.99]",children:n(s==="local"?"login.signingIn":"login.signIn")})]}),i.jsx("div",{className:"text-center",children:i.jsx("button",{onClick:()=>{p(!1),d("")},className:"text-xs text-fg-tertiary hover:text-fg-secondary transition-colors",children:n("login.backToHub")})})]}):i.jsxs("div",{className:"space-y-3",children:[i.jsxs("button",{onClick:()=>R("google"),disabled:!!s,className:L,children:[i.jsxs("svg",{className:"w-5 h-5",viewBox:"0 0 24 24",children:[i.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"}),i.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"}),i.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"}),i.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(s==="google"?"login.connectingHub":"login.withGoogle")]}),i.jsxs("button",{onClick:()=>R("github"),disabled:!!s,className:L,children:[i.jsx("svg",{className:"w-5 h-5",viewBox:"0 0 24 24",fill:"currentColor",children:i.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(s==="github"?"login.connectingHub":"login.withGithub")]}),i.jsxs("button",{onClick:()=>R("email"),disabled:!!s,className:L,children:[i.jsx("svg",{className:"w-5 h-5",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:1.5,children:i.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(s==="email"?"login.connectingHub":"login.withEmail")]}),s&&(s==="google"||s==="github"||s==="email"||s==="hub")&&i.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:[i.jsx("p",{children:n("login.browserOpened")}),i.jsx("button",{type:"button",onClick:I,className:"text-brand-500 hover:text-brand-400 underline font-medium",children:n("login.cancelWaiting")})]}),c&&i.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}),i.jsxs("div",{className:"flex items-center gap-3 py-1 text-[11px] text-fg-tertiary",children:[i.jsx("span",{className:"h-px flex-1 bg-border-default"}),n("login.or"),i.jsx("span",{className:"h-px flex-1 bg-border-default"})]}),i.jsx("button",{onClick:()=>{p(!0),d("")},disabled:!!s,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")})]})}),i.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:[i.jsx("input",{type:"checkbox",checked:C,onChange:F=>{S(F.target.checked),F.target.checked&&T(!1)},className:"mt-0.5 h-3.5 w-3.5 shrink-0 accent-brand-600 cursor-pointer"}),i.jsxs("span",{className:"text-center",children:[n("login.consentPrefix")," ",i.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")," ",i.jsx("a",{href:E("/privacy"),target:"_blank",rel:"noopener noreferrer",className:"text-brand-500 hover:text-brand-400 underline",children:n("login.privacyLink")})]})]})]}),i.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:[i.jsx("a",{href:"https://markus.global",target:"_blank",rel:"noopener noreferrer",className:"hover:text-fg-secondary transition-colors",children:"markus.global"}),i.jsx("a",{href:"mailto:business@markus.global",className:"hover:text-fg-secondary transition-colors",children:n("login.contactSales")})]})]})}function mie({token:e,onComplete:t}){const{t:n}=ot("auth"),[a,s]=k.useState(null),[l,c]=k.useState(""),[d,m]=k.useState(""),[p,h]=k.useState(""),[g,x]=k.useState(!1),[y,w]=k.useState(!1),[T,C]=k.useState(!1);k.useEffect(()=>{Ae.auth.inviteInfo(e).then(E=>s(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}x(!0);try{await Ae.auth.setup(e,l),w(!0),setTimeout(()=>{window.location.hash="",t()},2e3)}catch{h(n("invite.error"))}finally{x(!1)}};return i.jsxs("div",{className:"min-h-dvh bg-surface-primary flex items-center justify-center p-4 relative overflow-hidden",children:[i.jsx("div",{className:"absolute inset-0 bg-[radial-gradient(ellipse_at_top,_var(--tw-gradient-stops))] from-brand-950/50 via-transparent to-transparent"}),i.jsxs("div",{className:"w-full max-w-sm relative z-10",children:[i.jsxs("div",{className:"text-center mb-8",children:[i.jsx("img",{src:"/logo.png",alt:"Markus",className:"w-14 h-14 mx-auto mb-3 rounded-xl shadow-lg shadow-black/40"}),i.jsx("div",{className:"text-2xl font-extrabold tracking-tight text-fg-primary mb-1",children:"Markus"}),i.jsx("div",{className:"text-sm text-fg-tertiary",children:n("invite.subtitle")})]}),i.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?i.jsxs("div",{className:"text-center space-y-3",children:[i.jsx("div",{className:"text-red-500 text-3xl",children:"⚠"}),i.jsx("p",{className:"text-sm text-fg-secondary",children:n("invite.invalidLink")}),i.jsx("button",{onClick:()=>{window.location.hash="",t()},className:"text-sm text-brand-500 hover:text-brand-400",children:n("login.signIn")})]}):y?i.jsxs("div",{className:"text-center space-y-3",children:[i.jsx("div",{className:"text-green-500 text-3xl",children:"✓"}),i.jsx("p",{className:"text-sm text-fg-secondary",children:n("invite.setupComplete")})]}):a?i.jsxs("form",{onSubmit:S,className:"space-y-5",children:[i.jsx("h2",{className:"text-lg font-semibold text-fg-primary text-center",children:n("invite.greeting",{name:a.name})}),i.jsx("p",{className:"text-xs text-fg-tertiary text-center",children:a.email}),i.jsxs("div",{className:"space-y-1",children:[i.jsx("label",{className:"text-xs text-fg-tertiary font-medium",children:n("invite.setPassword")}),i.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})]}),i.jsxs("div",{className:"space-y-1",children:[i.jsx("label",{className:"text-xs text-fg-tertiary font-medium",children:n("invite.confirmPassword")}),i.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})]}),p&&i.jsx("div",{className:"px-3 py-2 bg-red-500/10 border border-red-500/30 rounded-lg text-xs text-red-500",children:p}),i.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")})]}):i.jsx("div",{className:"text-center text-fg-tertiary text-sm animate-pulse py-4",children:"Loading…"})})]})]})}function pie({onComplete:e,isFirstTime:t}){const{t:n}=ot("auth"),[a,s]=k.useState(""),[l,c]=k.useState(""),[d,m]=k.useState(""),[p,h]=k.useState(""),[g,x]=k.useState(!1),y=async w=>{if(w.preventDefault(),h(""),l.length<6){h(n("changePassword.passwordMinLength"));return}if(l!==d){h(n("changePassword.passwordsDoNotMatch"));return}x(!0);try{await Ae.auth.changePassword(a,l),e()}catch{h(n("changePassword.failedToChange"))}finally{x(!1)}};return i.jsxs("div",{className:"min-h-dvh bg-surface-primary flex items-center justify-center p-4 relative overflow-hidden",children:[i.jsx("div",{className:"absolute inset-0 bg-[radial-gradient(ellipse_at_top,_var(--tw-gradient-stops))] from-brand-950/50 via-transparent to-transparent"}),i.jsxs("div",{className:"w-full max-w-sm relative z-10",children:[i.jsxs("div",{className:"text-center mb-8",children:[i.jsx("img",{src:"/logo.png",alt:"Markus",className:"w-14 h-14 mx-auto mb-3 rounded-xl shadow-lg shadow-black/40"}),i.jsx("div",{className:"text-2xl font-extrabold tracking-tight text-fg-primary mb-1",children:"Markus"}),i.jsx("div",{className:"text-sm text-fg-tertiary",children:n("login.subtitle")})]}),i.jsxs("form",{onSubmit:y,className:"bg-surface-secondary/80 backdrop-blur-sm border border-border-default rounded-2xl p-8 space-y-5 shadow-2xl shadow-black/30",children:[i.jsxs("div",{children:[i.jsx("h2",{className:"text-lg font-semibold text-fg-primary text-center",children:n(t?"changePassword.setYourPassword":"changePassword.changePassword")}),t&&i.jsx("p",{className:"text-xs text-amber-600/80 text-center mt-2",children:n("changePassword.defaultPasswordWarning")})]}),!t&&i.jsxs("div",{className:"space-y-1",children:[i.jsx("label",{className:"text-xs text-fg-tertiary font-medium",children:n("changePassword.currentPassword")}),i.jsx("input",{type:"password",value:a,onChange:w=>s(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"})]}),i.jsxs("div",{className:"space-y-1",children:[i.jsx("label",{className:"text-xs text-fg-tertiary font-medium",children:n("changePassword.newPassword")}),i.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})]}),i.jsxs("div",{className:"space-y-1",children:[i.jsx("label",{className:"text-xs text-fg-tertiary font-medium",children:n("changePassword.confirmNewPassword")}),i.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})]}),p&&i.jsx("div",{className:"px-3 py-2 bg-red-500/10 border border-red-500/30 rounded-lg text-xs text-red-500",children:p}),i.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 fie({side:e,defaultWidth:t,minWidth:n,maxWidth:a,collapsedWidth:s=0,storageKey:l}){const[c,d]=k.useState(()=>{try{const T=localStorage.getItem(`${l}_w`);if(T)return Math.max(n,Math.min(a,parseInt(T,10)))}catch{}return t}),[m,p]=k.useState(()=>{try{return localStorage.getItem(`${l}_c`)==="1"}catch{return!1}}),h=k.useRef(!1),g=k.useRef(n),x=k.useRef(a);g.current=n,x.current=a,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(a,T)))},[n,a]);const y=k.useCallback(T=>{T.preventDefault(),h.current=!0;const C=T.clientX,S=c,E=M=>{if(!h.current)return;const P=M.clientX-C;d(Math.max(g.current,Math.min(x.current,S+P)))},_=()=>{h.current=!1,document.removeEventListener("mousemove",E),document.removeEventListener("mouseup",_),document.body.style.cursor="",document.body.style.userSelect=""};document.addEventListener("mousemove",E),document.addEventListener("mouseup",_),document.body.style.cursor="col-resize",document.body.style.userSelect="none"},[c,e]),w=k.useCallback(()=>p(T=>!T),[]);return{width:m?s:c,rawWidth:c,collapsed:m,toggle:w,setCollapsed:p,setWidth:d,onResizeStart:y}}const Dse=[{value:"system",label:"System"},{value:"light",label:"Light"},{value:"dark",label:"Dark"},{value:"cyberpunk",label:"Cyberpunk"},{value:"mono",label:"Mono"}],Cg="markus-theme";function jk(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 hie(){try{const e=localStorage.getItem(Cg);if(e==="midnight")return localStorage.setItem(Cg,"dark"),"dark";if(e==="light"||e==="dark"||e==="system"||e==="cyberpunk"||e==="mono")return e}catch{}return"system"}function gie(){const[e,t]=k.useState(hie),n=k.useCallback(a=>{t(a);try{localStorage.setItem(Cg,a)}catch{}jk(a)},[]);return k.useEffect(()=>{jk(e)},[e]),{mode:e,setMode:n}}const am={agents:[],tasks:[],requirements:[],projects:[],deliverables:[],workflows:[]},bie={team:["agents","workflows","tasks","requirements","projects","deliverables"],work:["workflows","projects","requirements","tasks","agents","deliverables"],deliverables:["deliverables","agents","tasks","requirements","projects","workflows"]},yie=["agents","tasks","requirements","projects","deliverables","workflows"];let Mk="",_k="all",Rk=am,Dk=!1;function xie({onClose:e,currentPage:t}){const{t:n}=ot(["common","home","work"]);Qo(!0);const[a,s]=k.useState(Mk),[l,c]=k.useState(_k),[d,m]=k.useState(Rk),[p,h]=k.useState(!1),[g,x]=k.useState(Dk),[y,w]=k.useState(-1);k.useEffect(()=>{Mk=a},[a]),k.useEffect(()=>{_k=l},[l]),k.useEffect(()=>{Rk=d},[d]),k.useEffect(()=>{Dk=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 _=k.useCallback(async ee=>{if(!ee.trim()){m(am),x(!1),w(-1);return}h(!0),x(!0),w(-1);const G=ee.toLowerCase();try{const[ae,H,J,fe,Ce,$]=await Promise.allSettled([Ae.agents.list(),Ae.tasks.list({search:ee,pageSize:20}),Ae.requirements.list(),Ae.projects.list(),Ae.deliverables.search({q:ee,limit:20}),Ae.teams.list()]),V=ae.status==="fulfilled"?ae.value.agents.filter(He=>He.name?.toLowerCase().includes(G)||He.role?.toLowerCase().includes(G)):[],pe=H.status==="fulfilled"?H.value.tasks:[],z=J.status==="fulfilled"?J.value.requirements.filter(He=>He.title?.toLowerCase().includes(G)||He.description?.toLowerCase().includes(G)):[],je=fe.status==="fulfilled"?fe.value.projects.filter(He=>He.name?.toLowerCase().includes(G)||He.description?.toLowerCase().includes(G)):[],Ue=Ce.status==="fulfilled"?Ce.value.results:[],qe=[];if($.status==="fulfilled"){const He=await Promise.allSettled($.value.teams.map(ut=>Ae.workflows.list(ut.id)));for(const ut of He)if(ut.status==="fulfilled")for(const dt of ut.value.workflows)(dt.name.toLowerCase().includes(G)||(dt.displayName||"").toLowerCase().includes(G)||dt.description?.toLowerCase().includes(G))&&qe.push(dt)}m({agents:V,tasks:pe,requirements:z,projects:je,deliverables:Ue,workflows:qe})}catch{m(am)}finally{h(!1)}},[]),M=ee=>{s(ee),C.current&&clearTimeout(C.current),C.current=setTimeout(()=>_(ee),400)},P=k.useCallback((ee,G)=>{e(),at.navigate(ee,G)},[e]),R=[{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:"工作流"})}],I=k.useMemo(()=>bie[t||""]||yie,[t]),K=k.useMemo(()=>{const ee=[],G=l==="all"?8:void 0,ae=H=>{if(l!=="all"&&l!==H)return;const J=d[H].length;if(H==="workflows"){const fe=G?d.workflows.slice(0,G):d.workflows;for(const Ce of fe)ee.push({id:Ce.name,type:"workflow",page:de.WORK,params:{boardType:"workflows"}})}else{const fe=d[H],Ce=G?fe.slice(0,G):fe;for(const $ of Ce)switch(H){case"agents":ee.push({id:$.id,type:"agent",page:de.TEAM,params:{agentId:$.id}});break;case"tasks":ee.push({id:$.id,type:"task",page:de.WORK,params:{openTask:$.id}});break;case"requirements":ee.push({id:$.id,type:"requirement",page:de.WORK,params:{openRequirement:$.id}});break;case"projects":ee.push({id:$.id,type:"project",page:de.WORK,params:{projectId:$.id}});break;case"deliverables":ee.push({id:$.id,type:"deliverable",page:de.DELIVERABLES,params:{openDeliverable:$.id}});break}}G&&J>G&&ee.push({id:`more_${H}`,type:"showMore",page:"",expandCategory:H,totalCount:J})};for(const H of I)ae(H);return ee},[d,l,I]),Y=k.useCallback(ee=>{if(ee.type==="showMore"&&ee.expandCategory){c(ee.expandCategory),w(-1);return}P(ee.page,ee.params)},[P]);k.useEffect(()=>{const ee=E.current;if(!ee||y<0)return;const G=ee.querySelector(`[data-idx="${y}"]`);G&&G.scrollIntoView({block:"nearest"})},[y]);const L=k.useCallback(ee=>{if(ee.key==="Escape"){e();return}if(ee.key==="Tab"){ee.preventDefault();const H=R.map(Ce=>Ce.id),J=H.indexOf(l),fe=ee.shiftKey?J<=0?H.length-1:J-1:J>=H.length-1?0:J+1;c(H[fe]),w(-1);return}const G=ee.ctrlKey&&ee.key==="n"||ee.key==="ArrowDown",ae=ee.ctrlKey&&ee.key==="p"||ee.key==="ArrowUp";if(G||ae){ee.preventDefault(),w(H=>{const J=K.length-1;return J<0?-1:G?H>=J?0:H+1:H<=0?J:H-1});return}ee.key==="Enter"&&(ee.preventDefault(),y>=0&&y<K.length&&Y(K[y]))},[e,K,y,Y,R,l]);k.useEffect(()=>(document.addEventListener("keydown",L),()=>document.removeEventListener("keydown",L)),[L]);const F=K.length>0;let ne=0;return i.jsx("div",{ref:S,className:"fixed inset-0 bg-black/50 flex items-start justify-center z-50 pt-[8vh]",onClick:ee=>{ee.target===S.current&&e()},children:i.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:[i.jsxs("div",{className:"shrink-0 px-5 pt-4 pb-3 border-b border-border-default space-y-3",children:[i.jsxs("div",{className:"relative",children:[i.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:[i.jsx("circle",{cx:"11",cy:"11",r:"8"}),i.jsx("line",{x1:"21",y1:"21",x2:"16.65",y2:"16.65"})]}),i.jsx("input",{ref:T,value:a,onChange:ee=>M(ee.target.value),placeholder:n("common:search"),className:"w-full bg-surface-elevated border border-border-default rounded-xl pl-9 pr-9 py-2.5 text-sm text-fg-primary placeholder:text-fg-tertiary focus:border-brand-500 focus:outline-none transition-colors"}),a&&i.jsx("button",{onClick:()=>{s(""),m(am),x(!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:i.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[i.jsx("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),i.jsx("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]})})]}),i.jsx("div",{className:"flex gap-1 overflow-x-auto scrollbar-hide",children:R.map(ee=>i.jsx("button",{onClick:()=>{c(ee.id),w(-1)},className:`px-3 py-1.5 text-xs rounded-lg whitespace-nowrap transition-colors ${l===ee.id?"bg-brand-600 text-white":"bg-surface-elevated text-fg-secondary hover:text-fg-primary"}`,children:ee.label},ee.id))})]}),i.jsxs("div",{ref:E,className:"flex-1 overflow-y-auto px-5 py-3",children:[p&&i.jsx("div",{className:"flex items-center justify-center py-8",children:i.jsx("div",{className:"text-fg-tertiary text-sm animate-pulse",children:n("common:loading")})}),!p&&g&&!F&&i.jsxs("div",{className:"flex flex-col items-center justify-center py-8 text-center",children:[i.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:[i.jsx("circle",{cx:"11",cy:"11",r:"8"}),i.jsx("line",{x1:"21",y1:"21",x2:"16.65",y2:"16.65"})]}),i.jsx("p",{className:"text-sm text-fg-tertiary",children:n("common:noResults",{defaultValue:"没有找到相关结果"})})]}),!p&&F&&i.jsx("div",{className:"space-y-4",children:I.map(ee=>{if(l!=="all"&&l!==ee)return null;const G=l==="all"?8:void 0,ae=H=>{const J=ne++,fe=H==="agents"?d.agents.length:H==="tasks"?d.tasks.length:H==="requirements"?d.requirements.length:H==="projects"?d.projects.length:H==="workflows"?d.workflows.length:d.deliverables.length;return i.jsxs("button",{"data-idx":J,onClick:()=>{c(H),w(-1)},className:`mt-1 w-full text-xs py-1.5 rounded-lg transition-colors ${J===y?"bg-brand-600/15 ring-1 ring-brand-500/40 text-brand-500":"text-brand-500 hover:text-brand-400 hover:bg-surface-overlay"}`,children:[n("common:showAll",{defaultValue:"查看全部"})," (",fe,")"]})};return ee==="agents"&&d.agents.length>0?i.jsxs("section",{children:[i.jsx("h3",{className:"text-xs font-medium text-fg-tertiary uppercase mb-2",children:n("common:agents",{defaultValue:"智能体"})}),i.jsx("div",{className:"space-y-0.5",children:(G?d.agents.slice(0,G):d.agents).map(H=>{const J=ne++;return i.jsxs("button",{"data-idx":J,onClick:()=>P(de.TEAM,{agentId:H.id}),className:`w-full flex items-center gap-3 px-3 py-2 rounded-xl transition-colors text-left ${J===y?"bg-brand-600/15 ring-1 ring-brand-500/40":"hover:bg-surface-overlay"}`,children:[i.jsx(Zi,{name:H.name||"Agent",avatarUrl:H.avatarUrl,size:28}),i.jsxs("div",{className:"flex-1 min-w-0",children:[i.jsx("div",{className:"text-sm font-medium text-fg-primary truncate",children:H.name}),i.jsx("div",{className:"text-xs text-fg-tertiary truncate",children:H.role||H.status})]}),i.jsx(vie,{status:H.status})]},H.id)})}),G&&d.agents.length>G&&ae("agents")]},"agents"):ee==="tasks"&&d.tasks.length>0?i.jsxs("section",{children:[i.jsx("h3",{className:"text-xs font-medium text-fg-tertiary uppercase mb-2",children:n("common:tasks",{defaultValue:"任务"})}),i.jsx("div",{className:"space-y-0.5",children:(G?d.tasks.slice(0,G):d.tasks).map(H=>{const J=ne++;return i.jsxs("button",{"data-idx":J,onClick:()=>P(de.WORK,{openTask:H.id}),className:`w-full flex items-center gap-3 px-3 py-2 rounded-xl transition-colors text-left ${J===y?"bg-brand-600/15 ring-1 ring-brand-500/40":"hover:bg-surface-overlay"}`,children:[i.jsx(wie,{status:H.status}),i.jsxs("div",{className:"flex-1 min-w-0",children:[i.jsx("div",{className:"text-sm text-fg-primary truncate",children:H.title}),i.jsxs("div",{className:"text-xs text-fg-tertiary truncate",children:[H.status," · ",H.priority||""]})]})]},H.id)})}),G&&d.tasks.length>G&&ae("tasks")]},"tasks"):ee==="requirements"&&d.requirements.length>0?i.jsxs("section",{children:[i.jsx("h3",{className:"text-xs font-medium text-fg-tertiary uppercase mb-2",children:n("common:requirements",{defaultValue:"需求"})}),i.jsx("div",{className:"space-y-0.5",children:(G?d.requirements.slice(0,G):d.requirements).map(H=>{const J=ne++;return i.jsxs("button",{"data-idx":J,onClick:()=>P(de.WORK,{openRequirement:H.id}),className:`w-full flex items-center gap-3 px-3 py-2 rounded-xl transition-colors text-left ${J===y?"bg-brand-600/15 ring-1 ring-brand-500/40":"hover:bg-surface-overlay"}`,children:[i.jsx("div",{className:`w-7 h-7 rounded-lg flex items-center justify-center shrink-0 ${H.status==="approved"?"text-green-500 bg-green-500/15":H.status==="pending"?"text-amber-500 bg-amber-500/15":H.status==="rejected"?"text-red-500 bg-red-500/15":"text-fg-tertiary bg-surface-elevated"}`,children:i.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[i.jsx("path",{d:"M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z"}),i.jsx("polyline",{points:"14 2 14 8 20 8"}),i.jsx("line",{x1:"16",y1:"13",x2:"8",y2:"13"}),i.jsx("line",{x1:"16",y1:"17",x2:"8",y2:"17"})]})}),i.jsxs("div",{className:"flex-1 min-w-0",children:[i.jsx("div",{className:"text-sm text-fg-primary truncate",children:H.title}),i.jsxs("div",{className:"text-xs text-fg-tertiary truncate",children:[H.status," · ",H.priority||""]})]})]},H.id)})}),G&&d.requirements.length>G&&ae("requirements")]},"requirements"):ee==="projects"&&d.projects.length>0?i.jsxs("section",{children:[i.jsx("h3",{className:"text-xs font-medium text-fg-tertiary uppercase mb-2",children:n("common:projects",{defaultValue:"项目"})}),i.jsx("div",{className:"space-y-0.5",children:(G?d.projects.slice(0,G):d.projects).map(H=>{const J=ne++;return i.jsxs("button",{"data-idx":J,onClick:()=>P(de.WORK,{projectId:H.id}),className:`w-full flex items-center gap-3 px-3 py-2 rounded-xl transition-colors text-left ${J===y?"bg-brand-600/15 ring-1 ring-brand-500/40":"hover:bg-surface-overlay"}`,children:[i.jsx("div",{className:"w-7 h-7 rounded-lg bg-brand-500/15 flex items-center justify-center shrink-0",children:i.jsx("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",className:"text-brand-500",children:i.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"})})}),i.jsxs("div",{className:"flex-1 min-w-0",children:[i.jsx("div",{className:"text-sm text-fg-primary truncate",children:H.name}),H.description&&i.jsx("div",{className:"text-xs text-fg-tertiary truncate",children:H.description})]})]},H.id)})}),G&&d.projects.length>G&&ae("projects")]},"projects"):ee==="deliverables"&&d.deliverables.length>0?i.jsxs("section",{children:[i.jsx("h3",{className:"text-xs font-medium text-fg-tertiary uppercase mb-2",children:n("common:deliverables",{defaultValue:"交付物"})}),i.jsx("div",{className:"space-y-0.5",children:(G?d.deliverables.slice(0,G):d.deliverables).map(H=>{const J=ne++;return i.jsxs("button",{"data-idx":J,onClick:()=>P(de.DELIVERABLES,{openDeliverable:H.id}),className:`w-full flex items-center gap-3 px-3 py-2 rounded-xl transition-colors text-left ${J===y?"bg-brand-600/15 ring-1 ring-brand-500/40":"hover:bg-surface-overlay"}`,children:[i.jsx("div",{className:"w-7 h-7 rounded-lg bg-purple-500/15 flex items-center justify-center shrink-0",children:i.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",className:"text-purple-500",children:[i.jsx("path",{d:"M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z"}),i.jsx("polyline",{points:"14 2 14 8 20 8"})]})}),i.jsxs("div",{className:"flex-1 min-w-0",children:[i.jsx("div",{className:"text-sm text-fg-primary truncate",children:H.title}),i.jsxs("div",{className:"text-xs text-fg-tertiary truncate",children:[H.type," · ",H.status]})]})]},H.id)})}),G&&d.deliverables.length>G&&ae("deliverables")]},"deliverables"):ee==="workflows"&&d.workflows.length>0?i.jsxs("section",{children:[i.jsx("h3",{className:"text-xs font-medium text-fg-tertiary uppercase mb-2",children:n("common:workflows",{defaultValue:"工作流"})}),i.jsx("div",{className:"space-y-0.5",children:(G?d.workflows.slice(0,G):d.workflows).map(H=>{const J=ne++;return i.jsxs("button",{"data-idx":J,onClick:()=>P(de.WORK,{boardType:"workflows"}),className:`w-full flex items-center gap-3 px-3 py-2 rounded-xl transition-colors text-left ${J===y?"bg-brand-600/15 ring-1 ring-brand-500/40":"hover:bg-surface-overlay"}`,children:[i.jsx("div",{className:"w-7 h-7 rounded-lg bg-teal-500/15 flex items-center justify-center shrink-0",children:i.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",className:"text-teal-500",children:[i.jsx("circle",{cx:"12",cy:"12",r:"3"}),i.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"})]})}),i.jsxs("div",{className:"flex-1 min-w-0",children:[i.jsx("div",{className:"text-sm text-fg-primary truncate",children:H.displayName||H.name}),i.jsxs("div",{className:"text-xs text-fg-tertiary truncate",children:[H.stepCount," steps · v",H.version]})]})]},H.name)})}),G&&d.workflows.length>G&&ae("workflows")]},"workflows"):null})}),!p&&!g&&i.jsxs("div",{className:"flex flex-col items-center justify-center py-8 text-center",children:[i.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:[i.jsx("circle",{cx:"11",cy:"11",r:"8"}),i.jsx("line",{x1:"21",y1:"21",x2:"16.65",y2:"16.65"})]}),i.jsx("p",{className:"text-sm text-fg-tertiary",children:n("common:searchHint",{defaultValue:"输入关键词搜索"})})]})]}),i.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:[i.jsxs("span",{children:[i.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:"唤起/关闭"})]}),i.jsxs("span",{children:[i.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:"切换分类"})]}),i.jsxs("span",{children:[i.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:"导航"})]}),i.jsxs("span",{children:[i.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:"打开"})]}),i.jsxs("span",{children:[i.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 vie({status:e}){const t=e==="active"||e==="idle"?"bg-green-500":e==="working"||e==="busy"?"bg-blue-500":"bg-gray-400";return i.jsx("span",{className:`w-2 h-2 rounded-full shrink-0 ${t}`})}function wie({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 i.jsx("div",{className:`w-7 h-7 rounded-lg flex items-center justify-center shrink-0 ${t}`,children:i.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[i.jsx("path",{d:"M9 11l3 3L22 4"}),i.jsx("path",{d:"M21 12v7a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h11"})]})})}const kie=["layout","navigation","tasks","team","search","rightPanel","terminal","help"];function Sie(e){return e===de.TEAM?"team":e===de.WORK?"work":e===de.DELIVERABLES?"deliverables":e===de.STORE?"store":"any"}function Cie({open:e,onClose:t,page:n}){const{t:a}=ot("common"),s=typeof navigator<"u"&&navigator.platform.toUpperCase().includes("MAC"),l=Sie(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?i.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":a("shortcuts.title"),children:i.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:[i.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:[i.jsx("h2",{className:"text-sm font-semibold text-fg-primary",children:a("shortcuts.title")}),i.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":a("shortcuts.close"),children:i.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[i.jsx("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),i.jsx("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]})})]}),i.jsx("div",{className:"px-4 py-3 space-y-4",children:kie.map(c=>{const d=TU.filter(m=>{if(m.group!==c)return!1;const p=m.page??"any";return p==="any"?!0:p===l});return d.length===0?null:i.jsxs("section",{children:[i.jsx("h3",{className:"text-[11px] font-semibold uppercase tracking-wide text-fg-tertiary mb-2",children:a(`shortcuts.groups.${c}`)}),i.jsx("ul",{className:"space-y-1.5",children:d.map(m=>i.jsxs("li",{className:"flex items-center justify-between gap-3 text-sm",children:[i.jsx("span",{className:"text-fg-secondary min-w-0",children:a(m.labelKey??m.label,{defaultValue:m.label})}),i.jsx("kbd",{className:"shrink-0 px-2 py-1 rounded bg-surface-elevated border border-border-default text-[13px] font-medium leading-none text-fg-primary font-mono",children:x4(m.keys,s,m.bare)})]},m.id))})]},c)})})]})}):null}function Aie({authUser:e,onClose:t,onSaved:n,onUserUpdated:a}){const{t:s}=ot("common");Qo(!0);const[l,c]=k.useState(e.name||""),[d,m]=k.useState(e.email||""),[p,h]=k.useState(!1),[g,x]=k.useState(""),[y,w]=k.useState(()=>m4(e.avatarUrl,xr()?.avatarUrl)),T=async C=>{if(C.preventDefault(),!l.trim()){x(s("profile.nameRequired"));return}if(d&&!/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(d.trim())){x(s("profile.invalidEmail"));return}h(!0),x("");try{const{user:S}=await Ae.auth.updateProfile(l.trim(),d.trim());n({...S,avatarUrl:y??S.avatarUrl})}catch{x(s("profile.failedToSave"))}finally{h(!1)}};return i.jsx("div",{className:"fixed inset-0 bg-black/60 flex items-center justify-center z-[10000]",onClick:t,children:i.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:[i.jsx("h3",{className:"text-base font-semibold mb-5",children:s("profile.editProfile")}),i.jsx("div",{className:"flex justify-center mb-5",children:i.jsx(f4,{currentUrl:y,name:l,size:72,targetType:"user",targetId:e.id,onUploaded:C=>{w(C),a?.({...e,avatarUrl:C})}})}),i.jsxs("div",{className:"space-y-3",children:[i.jsxs("div",{children:[i.jsx("label",{className:"block text-xs text-fg-tertiary font-medium mb-1",children:s("profile.name")}),i.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"})]}),i.jsxs("div",{children:[i.jsx("label",{className:"block text-xs text-fg-tertiary font-medium mb-1",children:s("profile.email")}),i.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&&i.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})]}),i.jsxs("div",{className:"flex justify-end gap-3 mt-5",children:[i.jsx("button",{type:"button",onClick:t,className:"px-4 py-2 text-sm border border-border-default rounded-lg hover:bg-surface-elevated",children:s("cancel")}),i.jsx("button",{type:"submit",disabled:p,className:"px-4 py-2 text-sm bg-brand-600 hover:bg-brand-500 disabled:opacity-50 text-white rounded-lg",children:s(p?"saving":"save")})]})]})})}const Lk=k.lazy(()=>va(()=>import("./Team-DJ1rMsS3.js"),__vite__mapDeps([2,3,4,5,6,7])).then(e=>({default:e.TeamPage}))),Ik=k.lazy(()=>va(()=>import("./Settings-D3Sk4wo8.js"),__vite__mapDeps([8,6])).then(e=>({default:e.Settings}))),Tie=k.lazy(()=>va(()=>import("./Store-_qnw3ukN.js"),[]).then(e=>({default:e.StorePage}))),Nie=k.lazy(()=>va(()=>Promise.resolve().then(()=>$re),void 0).then(e=>({default:e.AgentBuilder}))),Ok=k.lazy(()=>va(()=>import("./Work-CB0n0sCV.js"),__vite__mapDeps([9,4,1,10,3,11])).then(e=>({default:e.WorkPage}))),Pk=k.lazy(()=>va(()=>import("./Deliverables-DJAIrKO-.js"),__vite__mapDeps([12,4,5])).then(e=>({default:e.DeliverablesPage}))),Eie=k.lazy(()=>va(()=>import("./Notifications-Yg4YtKfK.js"),[]).then(e=>({default:e.NotificationsPage}))),jie=k.lazy(()=>va(()=>import("./Search-BxrbCVbt.js"),[]).then(e=>({default:e.SearchPage}))),Mie={visibility:"hidden",position:"absolute",inset:0,pointerEvents:"none",zIndex:-1};function _ie(e){try{const t=navigator.language,n=Intl.DateTimeFormat().resolvedOptions().timeZone,a=e.preferences??{};if(a.locale===t&&a.timezone===n)return;Ae.auth.updatePreferences({locale:t,timezone:n}).catch(()=>{})}catch{}}function Rie(){return i.jsx("div",{className:"flex-1 flex items-center justify-center text-fg-tertiary text-sm animate-pulse",children:"Loading..."})}const Die=k.memo(function({id:t,activePage:n,children:a}){const s=t===n;return i.jsx("div",{className:"flex-1 overflow-hidden flex flex-col",style:s?void 0:Mie,children:i.jsx(k.Suspense,{fallback:i.jsx(Rie,{}),children:a})})},(e,t)=>{const n=e.id===e.activePage,a=t.id===t.activePage;return n!==a?!1:a?e.children===t.children:!0}),Ud={};function l6(e){return typeof window<"u"&&window.matchMedia("(max-width: 767px)").matches?a4[e]??e:e}function zk(){return l6(Sc())}function Lie(){const{t:e}=ot("common"),[t,n]=k.useState(zk),[a,s]=k.useState(!1),[l,c]=k.useState(!0),d=Xo(),m=gie(),p=fie({side:"left",defaultWidth:160,minWidth:140,maxWidth:400,collapsedWidth:64,storageKey:"markus_sidebar"}),[h,g]=k.useState(()=>new Set([zk()])),[x,y]=k.useState("loading"),[w,T]=k.useState(!1),[C,S]=k.useState(null),[E,_]=k.useState({hasOwner:!1,hasMultipleUsers:!1}),[M,P]=k.useState(!1),[R,I]=k.useState(!1),[K,Y]=k.useState(null),[L,F]=k.useState(!1),[ne,ee]=k.useState(null),[G,ae]=k.useState(()=>{const Q=localStorage.getItem("markus_update_dismissed");return Q||null}),[H,J]=k.useState(!1),[fe,Ce]=k.useState(!1),$=qc(),V=$?.leftCollapsed??!1,pe=$?.toggleLeftCollapsed,z=$?.setLeftCollapsed,je=$?.keyboardPane??"l0",Ue=$?.setKeyboardPane,qe=$?.l0FocusPageId??null,He=$?.setL0FocusPageId,ut=k.useRef(t);ut.current=t;const dt=k.useRef(de.HOME),Nt=$?.toggleRightPanel,wt=$?.toggleTerminalPanel,Zt=$?.cycleRightPanelTab,Wt=$?.activateRightPanelTabAt,rt=$?.openNewRightPanelTab,$e=$?.rightPanelOpen??!1,mt=$?.activeRightPanelTabId??null,At=$?.openRightPanel,Dt=$?.closeRightPanelTab,ln=$?.updateRightPanelBrowserTab,ce=$?.updateRightPanelTerminalTab,et=k.useRef($?.rightPanelTabs);et.current=$?.rightPanelTabs,k.useEffect(()=>{const Q=window.markusDesktop?.browser?.onPageEvent;if(!(!Q||!At))return Q(X=>{if(X.type==="closed"){const ue=et.current?.find(Be=>Be.payload.kind==="url"&&Be.payload.browserId===X.browserId);ue&&Dt&&Dt(ue.id);return}if(X.type==="navigated"){if(X.url&&Ac(X.url))return;X.browserId&&ln&&ln(X.browserId,{url:X.url,title:X.title||X.url});return}if(X.type==="opened"||X.type==="selected"){if(!X.url&&!X.browserId||X.browserId.startsWith("eb_")||Ste(X.browserId)||X.url&&Ac(X.url))return;At({kind:"url",url:X.url||"about:blank",title:X.title||X.url||"Browser",browserId:X.browserId,pageId:X.pageId})}})},[At,Dt,ln]),k.useEffect(()=>{const Q=window.markusDesktop?.terminal?.onEvent;if(!(!Q||!At))return Q(X=>{if(X.type==="closed"){const ue=et.current?.find(Be=>Be.payload.kind==="terminal"&&Be.payload.terminalId===X.id);ue&&Dt&&Dt(ue.id);return}if(X.type==="cwd"){X.cwd&&ce?.(X.id,{cwd:X.cwd});return}if(X.type==="selected"){(X.title||X.cwd)&&ce?.(X.id,{title:X.title,cwd:X.cwd});return}if(X.type==="opened"){if(mb.has(X.id)){(X.title||X.cwd)&&ce?.(X.id,{title:X.title,cwd:X.cwd});return}_s(X.id),At({kind:"terminal",terminalId:X.id,title:X.title||"Terminal",cwd:X.cwd})}})},[At,Dt,ce]);const nt=$?.handleTerminalExit;k.useEffect(()=>{const Q=window.markusDesktop?.terminal?.onExit;if(!(!Q||!nt))return Q(X=>{nt(X.id)})},[nt]),k.useLayoutEffect(()=>{const Q=t===de.TEAM&&$e&&$?.rightPanelMode==="browser";wf(Q)},[t,$e,$?.rightPanelMode]),k.useEffect(()=>{window.markusDesktop?.browser?.hideAll?.()},[]);const we=k.useRef(!1);k.useEffect(()=>{if(!we.current){we.current=!0;return}p.setCollapsed(V)},[V,p.setCollapsed]),k.useEffect(()=>{if(d)return;const Q=navigator.platform.toUpperCase().includes("MAC"),X=Be=>{Q&&Be.metaKey&&!Be.ctrlKey&&Be.key==="p"?(Be.preventDefault(),J(Ie=>!Ie)):!Q&&Be.ctrlKey&&!Be.metaKey&&Be.key==="p"&&(Be.preventDefault(),J(Ie=>!Ie))},ue=()=>J(!0);return document.addEventListener("keydown",X),window.addEventListener("markus:open-search",ue),()=>{document.removeEventListener("keydown",X),window.removeEventListener("markus:open-search",ue)}},[d]);const Me=k.useCallback(()=>!$e||!mt||!Dt?!1:(Dt(mt),!0),[$e,mt,Dt]);k.useEffect(()=>{const Q=window.markusDesktop?.onAppShortcut?.(X=>{if(X.type==="close-tab"){Me();return}X.type==="new-tab"&&rt?.()});return()=>{Q?.()}},[Me,rt]),k.useEffect(()=>{if(d||!pe||!Nt)return;const Q=navigator.platform.toUpperCase().includes("MAC"),X=ue=>{if(!(Q?ue.metaKey&&!ue.ctrlKey:ue.ctrlKey&&!ue.metaKey)||ue.altKey)return;if(!ue.shiftKey&&(ue.key==="/"||ue.code==="Slash")){ue.preventDefault(),Ce(Ge=>!Ge);return}if(ue.shiftKey&&(ue.key==="?"||ue.key==="/")){ue.preventDefault(),Ce(Ge=>!Ge);return}if(ue.shiftKey&&$e&&Zt){if(ue.key==="]"||ue.code==="BracketRight"){ue.preventDefault(),Zt(1);return}if(ue.key==="["||ue.code==="BracketLeft"){ue.preventDefault(),Zt(-1);return}}if(!ue.shiftKey&&$e&&Wt){const Ge=ue.key>="1"&&ue.key<="9"?Number(ue.key):0;if(Ge>=1){ue.preventDefault(),Wt(Ge-1);return}}if(ue.shiftKey)return;const Ie=ue.key.toLowerCase();if(Ie==="w"){ue.preventDefault(),ue.stopPropagation(),Me();return}if(Ie==="t"){ue.preventDefault(),rt?.();return}if(Ie==="b"){if(t===de.DELIVERABLES)return;ue.preventDefault(),pe()}else if(t===de.TEAM&&Ie==="l"){if(!Q&&Pv(ue.target)||Q&&Pv(ue.target)&&ue.ctrlKey)return;ue.preventDefault(),Nt()}else t===de.TEAM&&Ie==="j"&&wt&&(ue.preventDefault(),wt())};return document.addEventListener("keydown",X,!0),()=>document.removeEventListener("keydown",X,!0)},[d,t,pe,Nt,wt,Zt,Wt,$e,Me,rt]);const Ne=k.useCallback((Q,X)=>{let ue=kc(Q);d?ue=a4[ue]??ue:ue===de.NOTIFICATIONS&&(ue=de.HOME),ue!==de.TEAM&&wf(!1);const Be=Sc(),Ie=window.location.hash.slice(1);Ie!==Nh(Be)?Ud[Be]=Ie:delete Ud[Be];const Ge=ut.current;if(ue===de.SETTINGS&&Ge!==de.SETTINGS&&(dt.current=Ge,at.setSettingsReturnPage(Ge),Ue?.("l1"),He?.(de.SETTINGS)),Ge===de.SETTINGS&&ue!==de.SETTINGS&&(Ue?.("l0"),He?.(ue)),ue===de.SETTINGS&&X?.tab){const Rt=`settings/${X.tab}`;Ud[ue]=Rt,history.pushState(null,"","#"+Rt),window.dispatchEvent(new HashChangeEvent("hashchange")),n(ue),g(Mt=>Mt.has(ue)?Mt:new Set([...Mt,ue]));return}const kt=ue!==de.WORK?Ud[ue]:void 0;kt&&kt!==Nh(ue)?(history.pushState(null,"",Ps(ue)),history.pushState(null,"","#"+kt)):history.pushState(null,"",Ps(ue)),window.dispatchEvent(new HashChangeEvent("hashchange")),n(ue),g(Rt=>Rt.has(ue)?Rt:new Set([...Rt,ue]))},[d,Ue,He]);k.useEffect(()=>{at.setHandler((Q,X)=>Ne(Q,X))},[Ne]),k.useEffect(()=>{je==="l0"&&t!==de.SETTINGS&&He?.(t)},[je,t,He]),k.useEffect(()=>{if(d||!Ue||!He)return;const Q=X=>{if(X.metaKey||X.ctrlKey||X.altKey||Ov(X.target))return;const ue=X.key.length===1?X.key.toLowerCase():X.key;if(t===de.SETTINGS&&(ue==="h"||ue==="ArrowLeft")){X.preventDefault(),X.stopImmediatePropagation(),at.leaveSettings();return}if(je!=="l0"||t===de.SETTINGS)return;const Be=qe&&Eo.includes(qe)?qe:t,Ie=Math.max(0,Eo.indexOf(Be));if(ue==="j"||ue==="ArrowDown"){X.preventDefault(),X.stopImmediatePropagation();const Ge=Eo[Math.min(Eo.length-1,Ie+1)];He(Ge),Ge!==t&&Ne(Ge),requestAnimationFrame(()=>{document.querySelector(`[data-l0-page-id="${Ge}"]`)?.scrollIntoView({block:"nearest"})});return}if(ue==="k"||ue==="ArrowUp"){X.preventDefault(),X.stopImmediatePropagation();const Ge=Eo[Math.max(0,Ie-1)];He(Ge),Ge!==t&&Ne(Ge),requestAnimationFrame(()=>{document.querySelector(`[data-l0-page-id="${Ge}"]`)?.scrollIntoView({block:"nearest"})});return}if(ue==="l"||ue==="ArrowRight"||ue==="Enter"){const Ge=qe&&Eo.includes(qe)?qe:t;if(!ZF.has(Ge)){X.preventDefault(),X.stopImmediatePropagation();return}X.preventDefault(),X.stopImmediatePropagation(),Ge!==t&&Ne(Ge),z?.(!1),Ue("l1");return}(ue==="h"||ue==="ArrowLeft")&&(X.preventDefault(),X.stopImmediatePropagation())};return document.addEventListener("keydown",Q,!0),()=>document.removeEventListener("keydown",Q,!0)},[d,je,qe,t,Ne,Ue,He,z]),k.useEffect(()=>{const Q=()=>T(!0);return window.addEventListener("markus:open-edit-profile",Q),()=>window.removeEventListener("markus:open-edit-profile",Q)},[]),k.useEffect(()=>{if(!window.markusDesktop)return;!d&&t!==de.SETTINGS&&!p.collapsed?window.markusDesktop.setTrafficLightPosition(16,16):window.markusDesktop.setTrafficLightPosition(6,16)},[p.collapsed,t,d]),k.useEffect(()=>{window.markusDesktop&&window.markusDesktop.onNotificationClick(Q=>{if(Q.openNotifications&&window.dispatchEvent(new CustomEvent("markus:open-notifications")),Q.page){const X=kc(Q.page);Q.params&&Object.entries(Q.params).forEach(([ue,Be])=>localStorage.setItem(`markus_nav_${ue}`,Be)),Ne(X),window.dispatchEvent(new CustomEvent("markus:navigate",{detail:{page:X,params:Q.params}}))}})},[Ne]);const se=k.useCallback(()=>{fetch("/api/settings/llm").then(Q=>Q.ok?Q.json():null).then(Q=>{if(Q?.providers){const X=Object.values(Q.providers).some(ue=>ue.configured);Y(X)}}).catch(()=>{})},[]),q=k.useCallback((Q,X)=>{if(!Q)return;const Be=X&&{agent:"agents",team:"teams",skill:"skills"}[X]||"agents";localStorage.setItem("markus_nav_installItem",Q),localStorage.setItem("markus_nav_storeTab",Be);const Ie=new URLSearchParams(window.location.search);Ie.get("install")||(Ie.set("install",Q),X&&Ie.set("type",X));const Ge=Ie.toString();window.history.replaceState(null,"",`${window.location.pathname}?${Ge}${Ps(de.STORE)}`);const kt=()=>at.navigate(de.STORE,{storeTab:Be,installItem:Q});kt(),setTimeout(kt,500),setTimeout(kt,1500)},[]);k.useEffect(()=>{const Q=new URLSearchParams(window.location.search),X=Q.get("install");X&&q(X,Q.get("type"));const ue=window.markusDesktop;ue?.onDeepLinkInstall?.(({id:Ge,type:kt})=>q(Ge,kt)),ue?.consumePendingDeepLinkInstall?.().then(Ge=>{Ge?.id&&q(Ge.id,Ge.type)}),Ae.auth.me().then(({user:Ge})=>{y(Ge),S(!0),s(!1),Ge.preferences?.guideHidden===!0&&!_h(Ge.id)&&Rh(Ge.id),_ie(Ge),Ir.connect(Ge.id),se(),Ae.health().then(Rt=>{Rt.updateAvailable&&Rt.latestVersion&&ee({latestVersion:Rt.latestVersion,currentVersion:Rt.version})}).catch(()=>{});const kt=()=>{Ns(qa.builderArtifacts,()=>Ae.builder.artifacts.list()),Ns(qa.builderAgents,()=>Ae.agents.list()),Ns(qa.builderHubMyItems,()=>st.myItems()),Ns(qa.builderInstalled,()=>Ae.builder.artifacts.installed()),Ns(qa.hubAgents,()=>st.search({type:"agent",limit:50})),Ns(qa.hubTeams,()=>st.search({type:"team",limit:50})),Ns(qa.hubSkills,()=>st.search({type:"skill",limit:50}))};typeof requestIdleCallback=="function"?requestIdleCallback(kt,{timeout:5e3}):setTimeout(kt,3e3)}).catch(()=>{y(null),Ae.auth.status().then(({initialized:Ge,hasOwner:kt,hasMultipleUsers:Rt})=>{S(Ge),_({hasOwner:kt,hasMultipleUsers:Rt})}).catch(()=>S(!0))}),Ir.connect();const Be=Ir.on("notification",()=>{window.dispatchEvent(new CustomEvent("markus:notifications-changed"))}),Ie=()=>{const Ge=l6(Sc());Ge!==de.TEAM&&wf(!1),n(Ge),g(kt=>kt.has(Ge)?kt:new Set([...kt,Ge]))};return window.addEventListener("hashchange",Ie),window.addEventListener("popstate",Ie),()=>{Be(),Ir.disconnect(),window.removeEventListener("hashchange",Ie),window.removeEventListener("popstate",Ie)}},[]),k.useEffect(()=>{const Q=x!=="loading"&&x!==null?x.id:void 0;if(!Q)return;const X=navigator.platform.toUpperCase().includes("MAC"),ue=Be=>{if(Ov(Be.target))return;const Ie={key:Be.key,code:Be.code,metaKey:Be.metaKey,ctrlKey:Be.ctrlKey,altKey:Be.altKey,shiftKey:Be.shiftKey};CU(Ie,Q,X)&&window.dispatchEvent(new CustomEvent("markus:shortcut-lesson-complete"))};return window.addEventListener("keydown",ue,!0),()=>window.removeEventListener("keydown",ue,!0)},[x]);const te=x!=="loading"&&x!==null?x:void 0,Se=k.useMemo(()=>d?{[de.HOME]:i.jsx($v,{authUser:te}),[de.TEAM]:i.jsx(Lk,{authUser:te}),[de.BUILDER]:i.jsx(lie,{authUser:te}),[de.SETTINGS]:i.jsx(Ik,{theme:m.mode,onThemeChange:m.setMode,authUser:te,onLogout:()=>{Ae.auth.logout().catch(()=>{}),Ds(),y(null)},onUserUpdated:Q=>y(Q)}),[de.WORK]:i.jsx(Ok,{authUser:te}),[de.DELIVERABLES]:i.jsx(Pk,{authUser:te}),[de.NOTIFICATIONS]:i.jsx(Eie,{authUser:te}),[de.SEARCH]:i.jsx(jie,{})}:{[de.HOME]:i.jsx($v,{authUser:te}),[de.TEAM]:i.jsx(Lk,{authUser:te}),[de.SETTINGS]:i.jsx(Ik,{theme:m.mode,onThemeChange:m.setMode,authUser:te,onLogout:()=>{Ae.auth.logout().catch(()=>{}),Ds(),y(null)},onUserUpdated:Q=>y(Q)}),[de.STORE]:i.jsx(Tie,{authUser:te}),[de.BUILDER]:i.jsx(Nie,{authUser:te}),[de.WORK]:i.jsx(Ok,{authUser:te}),[de.DELIVERABLES]:i.jsx(Pk,{authUser:te})},[te?.id,te?.role,m.mode,d]);if(x==="loading"||x===null&&C===null)return i.jsx("div",{className:"min-h-dvh bg-surface-primary flex items-center justify-center",children:i.jsx("div",{className:"text-fg-tertiary text-sm animate-pulse",children:e("loading")})});const Pe=(typeof window<"u"?window.location.hash:"").match(/^#invite\?token=([a-f0-9]+)/);return Pe?i.jsx(mie,{token:Pe[1],onComplete:()=>{window.location.hash="",localStorage.removeItem("markus_onboarded"),s(!0),P(!0),y("loading"),Ae.auth.me().then(Q=>{zv(Q.user.id),y(Q.user)}).catch(()=>y(null))}}):x===null?i.jsx(die,{hasOwner:E.hasOwner,hasMultipleUsers:E.hasMultipleUsers,onLogin:(Q,X,ue)=>{y(Q),Ir.connect(Q.id),X?(zv(Q.id),s(!0),ue?.fromHub&&P(!0)):(s(!1),_h(Q.id)?(Rh(Q.id),Ae.auth.updatePreferences({guideHidden:!0}).catch(()=>{}),y({...Q,preferences:{...Q.preferences,guideHidden:!0}})):y(Q))}}):R?i.jsx(pie,{onComplete:()=>I(!1),isFirstTime:!0}):a?i.jsx(cie,{theme:m.mode,onThemeChange:m.setMode,skipProfile:M,onProfileUpdated:Q=>{const X={id:Q.id,name:Q.name,email:Q.email,role:Q.role,orgId:Q.orgId??"default",avatarUrl:Q.avatarUrl};y(X)},onComplete:()=>{localStorage.removeItem("markus_onboarded"),s(!1),P(!1),Ae.auth.me().then(Q=>y(Q.user)).catch(()=>{}),se(),Ne(de.HOME)}}):i.jsxs("div",{className:`flex h-dvh bg-surface-primary text-fg-primary overflow-x-hidden ${d?"flex-col":""}`,children:[!d&&t!==de.SETTINGS&&i.jsxs(i.Fragment,{children:[i.jsx("div",{className:"relative z-40 shrink-0",style:{width:p.width},children:i.jsx(ure,{currentPage:t,onNavigate:Q=>{Ne(Q),c(!1),Ue?.("l0"),He?.(Q)},authUser:x,collapsed:p.collapsed,onToggleCollapse:p.toggle,onLogout:()=>{Ae.auth.logout().catch(()=>{}),Ds(),y(null)},keyboardFocusPageId:qe,keyboardPaneActive:je==="l0"})}),i.jsx("div",{className:`${p.collapsed?"w-0":"w-1.5 cursor-col-resize"} shrink-0 group relative z-10 flex items-center justify-center`,onMouseDown:p.collapsed?void 0:p.onResizeStart,children:!p.collapsed&&i.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"})})]}),i.jsxs("div",{className:`flex-1 overflow-hidden flex flex-col min-w-0 ${d&&t!==de.SETTINGS&&t!==de.SEARCH?"pb-14":""}`,children:[K===!1&&!L&&t!==de.SETTINGS&&i.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:[i.jsx("span",{className:d?"text-xs":"",children:e("llmBanner.message")}),i.jsxs("div",{className:"flex items-center gap-3",children:[i.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")}),i.jsx("button",{onClick:()=>F(!0),className:"text-amber-500 hover:text-amber-600 text-xs",children:e("dismiss")})]})]}),ne&&G!==ne.latestVersion&&i.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:[i.jsx("span",{className:d?"text-xs":"",children:e("update.available",{latest:ne.latestVersion,current:ne.currentVersion})}),i.jsxs("span",{className:"flex items-center gap-3 shrink-0",children:[i.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")}),i.jsx("button",{onClick:()=>{ae(ne.latestVersion),localStorage.setItem("markus_update_dismissed",ne.latestVersion)},className:"text-fg-tertiary hover:text-fg-secondary text-xs shrink-0",children:e("dismiss")})]})]}),i.jsx("main",{className:"flex-1 overflow-hidden flex flex-col relative",children:Object.keys(Se).map(Q=>h.has(Q)?i.jsx(Die,{id:Q,activePage:t,children:Se[Q]},Q):null)})]}),d&&t!==de.SETTINGS&&t!==de.SEARCH&&i.jsx(xre,{currentPage:t,onNavigate:Ne,userId:te?.id}),d&&i.jsx(wU,{authUser:te,onNavigate:Ne,onLogout:()=>{Ae.auth.logout().catch(()=>{}),Ds(),y(null)}}),!d&&H&&i.jsx(xie,{onClose:()=>J(!1),currentPage:t}),!d&&i.jsx(Cie,{open:fe,onClose:()=>Ce(!1),page:t}),w&&te&&i.jsx(Aie,{authUser:te,onClose:()=>T(!1),onUserUpdated:Q=>y(Q),onSaved:Q=>{T(!1),y(Q)}})]})}const Bk="data-anim-paused",Hk="data-anim-tick",$k=8,Iie=250;function Oie(){return document.visibilityState!=="visible"||document.hidden?!0:!document.hasFocus()}let xc=null,Po=0;function Pie(){xc===null&&(Po=Po%$k,document.documentElement.setAttribute(Hk,String(Po)),xc=window.setInterval(()=>{Po=(Po+1)%$k,document.documentElement.setAttribute(Hk,String(Po))},Iie))}function zie(){xc!==null&&(window.clearInterval(xc),xc=null)}function oc(){const e=document.documentElement;Oie()?(e.setAttribute(Bk,"true"),zie()):(e.removeAttribute(Bk),Pie())}let qk=!1;function Bie(){qk||typeof document>"u"||(qk=!0,oc(),document.addEventListener("visibilitychange",oc,{passive:!0}),window.addEventListener("focus",oc,{passive:!0}),window.addEventListener("blur",oc,{passive:!0}),window.addEventListener("pageshow",oc,{passive:!0}))}Bie();xA.createRoot(document.getElementById("root")).render(i.jsx(k.StrictMode,{children:i.jsx(jte,{children:i.jsx(Lie,{})})}));export{Dse as $,Zi as A,Qo as B,li as C,pne as D,Ps as E,ba as F,aU as G,Kie as H,nie as I,gb as J,Xie as K,bg as L,g4 as M,ore as N,hne as O,de as P,yg as Q,$ie as R,eie as S,Ure as T,Sae as U,kae as V,Vie as W,Zie as X,Jie as Y,Go as Z,va as _,Xo as a,wse as a$,qie as a0,xr as a1,dT as a2,cse as a3,tU as a4,Fie as a5,Uie as a6,_s as a7,Md as a8,fi as a9,Rse as aA,xse as aB,Sse as aC,Qie as aD,sse as aE,bb as aF,x4 as aG,fse as aH,hse as aI,gse as aJ,Ase as aK,Jw as aL,Zte as aM,_se as aN,Cse as aO,jse as aP,Tse as aQ,dk as aR,mk as aS,ire as aT,Mse as aU,vse as aV,kse as aW,IS as aX,Pv as aY,bse as aZ,yse as a_,mm as aa,Ese as ab,nne as ac,Lw as ad,_ae as ae,zs as af,rl as ag,mse as ah,use as ai,ise as aj,dse as ak,lse as al,ose as am,tse as an,$ae as ao,ase as ap,pse as aq,Kae as ar,Nse as as,VS as at,rse as au,Oae as av,ese as aw,Gie as ax,nse as ay,gre as az,hU as b,Yie as b0,PS as b1,qc as c,iie as d,Vre as e,Xre as f,Is as g,st as h,Ov as i,i as j,zr as k,Ae as l,fie as m,at as n,jn as o,kc as p,Ea as q,k as r,hb as s,Ha as t,ot as u,Hie as v,Ir as w,Ic as x,zm as y,pT as z};